1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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 *******************************************************************************/
19 /* This file contains ASN codec for MIB and SIB1 msgs */
20 #include "common_def.h"
25 #include "du_app_mac_inf.h"
28 #include "BCCH-BCH-Message.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"
56 #include "odu_common_codec.h"
57 #include "du_sys_info_hdl.h"
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;
68 /*******************************************************************
76 * Functionality: Building MIB
78 * @return ROK - success
81 * ****************************************************************/
82 uint8_t BuildMib(MIB_t *mib)
84 mib->systemFrameNumber.size = sizeof(uint8_t);
85 DU_ALLOC(mib->systemFrameNumber.buf, mib->systemFrameNumber.size);
86 if(!(mib->systemFrameNumber.buf))
88 DU_LOG("\nERROR --> DU APP: MIB msg memory allocation failure");
92 *(mib->systemFrameNumber.buf) = duCfgParam.mibParams.sysFrmNum;
93 mib->systemFrameNumber.bits_unused = ODU_VALUE_TWO;
95 mib->subCarrierSpacingCommon = duCfgParam.mibParams.subCarrierSpacingCommon;
96 mib->ssb_SubcarrierOffset = duCfgParam.mibParams.ssb_SubcarrierOffset;
97 mib->dmrs_TypeA_Position = duCfgParam.mibParams.dmrs_TypeA_Position;
98 mib->pdcch_ConfigSIB1.controlResourceSetZero = duCfgParam.mibParams.controlResourceSetZero;
99 mib->pdcch_ConfigSIB1.searchSpaceZero = duCfgParam.mibParams.searchSpaceZero;
100 mib->cellBarred = duCfgParam.mibParams.cellBarred;
101 mib->intraFreqReselection = duCfgParam.mibParams.intraFreqReselection;
102 mib->spare.size = sizeof(uint8_t);
103 DU_ALLOC(mib->spare.buf, mib->spare.size);
106 DU_LOG("\nERROR --> DU APP: MIB msg memory allocation failure");
109 *(mib->spare.buf) = SPARE;
110 mib->spare.bits_unused = ODU_VALUE_SEVEN;
113 /*******************************************************************
115 * @brief Free MIB PDU for broadcast
119 * Function : FreeMibPdu
121 * Functionality: Deallocating MIB PDU for system broadcast
123 * @param[in]: BCCH_BCH_Message_t *bcchMsg
127 * ****************************************************************/
128 void FreeMibPdu(BCCH_BCH_Message_t *bcchMsg)
132 if(!bcchMsg->message.choice.mib)
134 if(!(bcchMsg->message.choice.mib->systemFrameNumber.buf))
136 if(!bcchMsg->message.choice.mib->spare.buf)
138 DU_FREE(bcchMsg->message.choice.mib->spare.buf,\
139 bcchMsg->message.choice.mib->spare.size);
141 DU_FREE(bcchMsg->message.choice.mib->systemFrameNumber.buf,
142 bcchMsg->message.choice.mib->systemFrameNumber.size);
144 DU_FREE(bcchMsg->message.choice.mib, sizeof(MIB_t));
146 DU_FREE(bcchMsg, sizeof(BCCH_BCH_Message_t));
149 /*******************************************************************
151 * @brief Builds MIB PDU for broadcast
155 * Function : BuildMibPdu
157 * Functionality: Building MIB PDU for system broadcast
159 * @return ROK - success
162 * ****************************************************************/
163 uint8_t BuildMibPdu()
165 uint8_t ret = RFAILED;
166 BCCH_BCH_Message_t *bcchMsg;
167 asn_enc_rval_t encRetVal; /* Encoder return value */
170 DU_ALLOC(bcchMsg, sizeof(BCCH_BCH_Message_t));
173 DU_LOG("\nERROR --> Memory allocation failure in BuildMibPdu");
177 bcchMsg->message.present = BCCH_BCH_MessageType_PR_mib;
178 DU_ALLOC(bcchMsg->message.choice.mib, sizeof(MIB_t));
179 if(!bcchMsg->message.choice.mib)
181 DU_LOG("\nERROR --> Memory allocation failure in BuildMibPdu");
184 if(BuildMib(bcchMsg->message.choice.mib) != ROK)
188 xer_fprint(stdout, &asn_DEF_BCCH_BCH_Message, bcchMsg);
189 memset(encBuf, 0, ENC_BUF_MAX_LEN);
191 encRetVal = aper_encode(&asn_DEF_BCCH_BCH_Message, 0,
192 bcchMsg, PrepFinalEncBuf, encBuf);
193 printf("\nencbufSize:%d\n", encBufSize);
194 if(encRetVal.encoded == -1)
196 DU_LOG("\nERROR --> DU APP: Could not encode BCCH BCH Message Type structure(at %s)\n",
197 encRetVal.failed_type?\
198 encRetVal.failed_type->name
203 /* Print encoded buffer */
204 for(int i=0; i< encBufSize; i++)
206 printf("%x\t",encBuf[i]);
213 /* Free allocated memory */
219 /*******************************************************************
221 * @brief free MIB message in Served Cell Info
225 * Function : FreeMibMsg
227 * Functionality: deallocating MIB message in Served Cell Info
229 * @param[in] MIB_t *mibMsg
234 * ****************************************************************/
235 void FreeMibMsg( MIB_t *mibMsg)
239 if(!(mibMsg->systemFrameNumber.buf))
241 if(!mibMsg->spare.buf)
243 DU_FREE(mibMsg->spare.buf, mibMsg->spare.size);
245 DU_FREE(mibMsg->systemFrameNumber.buf,
246 mibMsg->systemFrameNumber.size);
248 DU_FREE(mibMsg, sizeof(MIB_t));
251 /*******************************************************************
253 * @brief Builds MIB message in Served Cell Info
257 * Function : BuildMibMsg
259 * Functionality: Building MIB message in Served Cell Info
261 * @return ROK - success
264 * ****************************************************************/
265 uint8_t BuildMibMsg()
268 asn_enc_rval_t encRetVal; /* Encoder return value */
269 uint8_t ret = RFAILED;
272 DU_ALLOC(mibMsg, sizeof(MIB_t));
275 DU_LOG("\nERROR --> DU APP: MIB msg memory allocation failure");
278 if(BuildMib(mibMsg) != ROK)
282 xer_fprint(stdout, &asn_DEF_MIB, mibMsg);
283 memset(encBuf, 0, ENC_BUF_MAX_LEN);
285 encRetVal = aper_encode(&asn_DEF_MIB, 0,
286 mibMsg, PrepFinalEncBuf, encBuf);
287 printf("\nencbufSize:%d\n", encBufSize);
288 if(encRetVal.encoded == -1)
290 DU_LOG("\nERROR --> DU APP: Could not encode MIB structure(at %s)\n",
291 encRetVal.failed_type?\
292 encRetVal.failed_type->name
297 /* Print encoded buffer */
298 for(int i=0; i< encBufSize; i++)
300 printf("%x\t",encBuf[i]);
304 /* Free allocated memory */
315 /*******************************************************************
317 * @brief Builds CellIdentity within SIB1 message
321 * Function : BuildCellIdentity
323 * Functionality: Building RAN area code in SIB1 message
325 * @params[in] RAN_AreaCode_t **ranAreaCode
326 * @return ROK - success
329 * ****************************************************************/
330 uint8_t BuildCellIdentity(CellIdentity_t *cellIdentity)
332 cellIdentity->size = ODU_VALUE_FIVE*sizeof(uint8_t);
333 cellIdentity->bits_unused = ODU_VALUE_FOUR;
335 DU_ALLOC(cellIdentity->buf, cellIdentity->size);
336 if(!cellIdentity->buf)
338 DU_LOG("\nERROR --> DU APP: CellIdentity memory allocation failure");
341 memset(cellIdentity->buf, 0, cellIdentity->size);
342 cellIdentity->buf[4] = duCfgParam.sib1Params.cellIdentity;
346 /*******************************************************************
348 * @brief Builds RANAC within SIB1 message
352 * Function : BuildRanac
354 * Functionality: Building RAN area code in SIB1 message
356 * @params[in] RAN_AreaCode_t **ranAreaCode
357 * @return ROK - success
360 * ****************************************************************/
361 uint8_t BuildRanac(RAN_AreaCode_t **ranAreaCode)
363 RAN_AreaCode_t *ranac;
364 DU_ALLOC(ranac, sizeof(RAN_AreaCode_t));
367 DU_LOG("\nERROR --> DU APP: RANAC memory allocation failure");
370 *ranac = duCfgParam.sib1Params.ranac;
371 *ranAreaCode = ranac;
374 /*******************************************************************
376 * @brief Builds TAC within SIB1 message
380 * Function : BuildTac
382 * Functionality: Building Tracking area code in SIB1 message
384 * @params[in] TrackingAreaCode_t **tac
385 * @return ROK - success
388 * ****************************************************************/
389 uint8_t BuildTac(TrackingAreaCode_t **trackAreaCode)
391 TrackingAreaCode_t *tac;
394 DU_ALLOC(tac, sizeof(TrackingAreaCode_t));
397 DU_LOG("\nERROR --> DU APP: TAC memory allocation failure");
401 tac->size = ODU_VALUE_THREE*sizeof(uint8_t);
402 DU_ALLOC(tac->buf, tac->size);
405 DU_LOG("\nERROR --> DU APP: TAC memory allocation failure");
408 *(tac->buf) = duCfgParam.sib1Params.tac;
409 tac->bits_unused = ODU_VALUE_ZERO;
410 *trackAreaCode = tac;
415 /*******************************************************************
417 * @brief Builds PLMN list within SIB1 message
421 * Function : BuildPlmnList
423 * Functionality: Building PLMN list in SIB1 message
425 * @params[in] CellAccessRelatedInfo_t *cellAccessInfo
426 * @return ROK - success
429 * ****************************************************************/
430 uint8_t BuildPlmnList(CellAccessRelatedInfo_t *cellAccessInfo)
436 TrackingAreaCode_t **tac;
437 RAN_AreaCode_t **ranac;
438 CellIdentity_t *cellIdentity;
440 struct PLMN_IdentityInfo__plmn_IdentityList
443 DU_ALLOC(cellAccessInfo->plmn_IdentityList.list.array,
444 cellAccessInfo->plmn_IdentityList.list.size);
445 if(!cellAccessInfo->plmn_IdentityList.list.array)
447 DU_LOG("\nERROR --> DU APP: BuildPlmnList memory allocation failure");
450 elementCnt = cellAccessInfo->plmn_IdentityList.list.count;
451 for(idx=0; idx<elementCnt; idx++)
453 DU_ALLOC(cellAccessInfo->plmn_IdentityList.list.array[idx],
454 sizeof(PLMN_IdentityInfo_t));
455 if(!cellAccessInfo->plmn_IdentityList.list.array[idx])
457 DU_LOG("\nERROR --> DU APP: BuildPlmnList memory allocation failure");
464 elementCnt = ODU_VALUE_ONE;
466 plmnIdInfo = &cellAccessInfo->plmn_IdentityList.list.array[idx]->\
468 plmnIdInfo->list.count = elementCnt;
469 plmnIdInfo->list.size = elementCnt * sizeof(PLMN_IdentitY_t *);
470 DU_ALLOC(plmnIdInfo->list.array, plmnIdInfo->list.size);
471 if(!plmnIdInfo->list.array)
473 DU_LOG("\nERROR --> DU APP: BuildPlmnList memory allocation failure");
477 for(idx1=0; idx1<elementCnt; idx1++)
479 DU_ALLOC(plmnIdInfo->list.array[idx1],
480 sizeof(PLMN_IdentitY_t));
481 if(!(plmnIdInfo->list.array[idx1]))
483 DU_LOG("\nERROR --> DU APP: BuildPlmnList memory allocation failure");
488 DU_ALLOC(plmnIdInfo->list.array[idx1]->mcc,
490 if(!plmnIdInfo->list.array[idx1]->mcc)
492 DU_LOG("\nERROR --> DU APP: BuildPlmnList memory allocation failure");
496 elementCnt = ODU_VALUE_THREE;
497 plmnIdInfo->list.array[idx1]->mcc->list.count = elementCnt;
498 plmnIdInfo->list.array[idx1]->mcc->list.size =\
499 elementCnt * sizeof(MCC_MNC_Digit_t *);
500 DU_ALLOC(plmnIdInfo->list.array[idx1]->mcc->list.array,
501 plmnIdInfo->list.array[idx1]->mcc->list.size)
502 if(!(plmnIdInfo->list.array[idx1]->mcc->list.array))
504 DU_LOG("\nERROR --> DU APP: BuildPlmnList memory allocation failure");
507 for(idx2=0; idx2<elementCnt; idx2++)
509 DU_ALLOC(plmnIdInfo->list.array[idx1]->mcc->list.array[idx2],
510 sizeof(MCC_MNC_Digit_t));
511 if(!plmnIdInfo->list.array[idx1]->mcc->list.array[idx2])
513 DU_LOG("\nERROR --> DU APP: BuildPlmnList memory allocation failure");
516 *(plmnIdInfo->list.array[idx1]->mcc->list.array[idx2])=\
517 duCfgParam.sib1Params.plmn.mcc[idx2];
520 plmnIdInfo->list.array[idx1]->mnc.list.count = elementCnt;
521 plmnIdInfo->list.array[idx1]->mnc.list.size =\
522 elementCnt * sizeof(MCC_MNC_Digit_t *);
523 DU_ALLOC(plmnIdInfo->list.array[idx1]->mnc.list.array,\
524 plmnIdInfo->list.array[idx1]->mnc.list.size);
525 if(!plmnIdInfo->list.array[idx1]->mnc.list.array)
527 DU_LOG("\nERROR --> DU APP: BuildPlmnList memory allocation failure");
530 for(idx2=0; idx2<elementCnt; idx2++)
532 DU_ALLOC(plmnIdInfo->list.array[idx1]->mnc.list.array[idx2],
533 sizeof(MCC_MNC_Digit_t));
534 if(!plmnIdInfo->list.array[idx1]->mnc.list.array[idx2])
536 DU_LOG("\nERROR --> DU APP: BuildPlmnList memory allocation failure");
539 *(plmnIdInfo->list.array[idx1]->mnc.list.array[idx2])=\
540 duCfgParam.sib1Params.plmn.mnc[idx2];
543 /* Tracking Area Code */
544 tac = &cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode;
552 ranac = &cellAccessInfo->plmn_IdentityList.list.array[idx]->ranac;
553 ret=BuildRanac(ranac);
560 cellIdentity = &cellAccessInfo->plmn_IdentityList.list.array[idx]->cellIdentity;
561 ret=BuildCellIdentity(cellIdentity);
567 /* cellReservedForOperatorUse */
568 cellAccessInfo->plmn_IdentityList.list.array[idx]->\
569 cellReservedForOperatorUse = duCfgParam.sib1Params.cellResvdForOpUse;
575 /*******************************************************************
577 * @brief Build SIB Map Info List
581 * Function : BuildSibMapInfoList
584 * Build SIB MapInfo List
586 * @params[in] SIB_Mapping_t pointer
587 * @return ROK - success
590 * ****************************************************************/
591 uint8_t BuildSibMapInfoList(SIB_Mapping_t *sibMapInfo)
593 uint8_t itr; /* List iterator */
594 uint8_t elementCnt; /* Number of elements in list */
595 SIB_TypeInfo_t *sibTypeInfo; /* Scheduling info */
597 /* SI scheduling info list */
598 DU_ALLOC(sibMapInfo->list.array, sibMapInfo->list.size);
599 if(!sibMapInfo->list.array)
601 DU_LOG("\nERROR --> DU APP: BuildSibMapInfoList memory allocation failure");
605 elementCnt = sibMapInfo->list.count;
606 for(itr = 0; itr < elementCnt; itr++)
608 DU_ALLOC(sibMapInfo->list.array[itr], sizeof(SIB_TypeInfo_t));
609 if(!sibMapInfo->list.array[itr])
611 DU_LOG("\nERROR --> DU APP: BuildSibMapInfoList memory allocation failure");
617 sibTypeInfo = sibMapInfo->list.array[itr];
618 sibTypeInfo->type = duCfgParam.sib1Params.siSchedInfo.sibType;
619 DU_ALLOC(sibTypeInfo->valueTag, sizeof(long));
620 if(!sibTypeInfo->valueTag)
622 DU_LOG("\nERROR --> DU APP: BuildSibMapInfoList memory allocation failure");
626 *sibTypeInfo->valueTag = duCfgParam.sib1Params.siSchedInfo.sibValTag;
631 /*******************************************************************
633 * @brief Builds SI Scheduling info list within SIB1 message
637 * Function : BuildSiSchedInfoList
640 * Building SI Scheduling info list in SIB1 message
642 * @params[in] struct SI_SchedulingInfo__schedulingInfoList *si_SchedulingInfo
643 * @return ROK - success
646 * ****************************************************************/
647 uint8_t BuildSiSchedInfoList(struct SI_SchedulingInfo__schedulingInfoList *si_SchedulingInfoList)
649 uint8_t itr; /* List iterator */
650 uint8_t elementCnt; /* Number of elements in list */
652 SchedulingInfo_t *schedInfo; /* Scheduling info */
654 /* SI scheduling info list */
655 DU_ALLOC(si_SchedulingInfoList->list.array, si_SchedulingInfoList->list.size);
656 if(!si_SchedulingInfoList->list.array)
658 DU_LOG("\nERROR --> DU APP: BuildSiSchedInfoList memory allocation failure");
662 elementCnt = si_SchedulingInfoList->list.count;
663 for(itr = 0; itr < elementCnt; itr++)
665 DU_ALLOC(si_SchedulingInfoList->list.array[itr], sizeof(struct SchedulingInfo));
666 if(!si_SchedulingInfoList->list.array[itr])
668 DU_LOG("\nERROR --> DU APP: BuildSiSchedInfoList memory allocation failure");
674 schedInfo = si_SchedulingInfoList->list.array[itr];
675 schedInfo->si_BroadcastStatus = duCfgParam.sib1Params.siSchedInfo.broadcastSta;
676 schedInfo->si_Periodicity = duCfgParam.sib1Params.siSchedInfo.preiodicity;
678 elementCnt = ODU_VALUE_ONE;
679 schedInfo->sib_MappingInfo.list.count = elementCnt;
680 schedInfo->sib_MappingInfo.list.size = elementCnt * sizeof(SIB_TypeInfo_t *);
682 ret = BuildSibMapInfoList(&schedInfo->sib_MappingInfo);
691 /*******************************************************************
693 * @brief Builds SCS Specific carrier list for DL
697 * Function : BuildScsSpecificCarrierListDl
700 * Builds Subcarrier specific carrier list for downlink
702 * @params[in] FrequencyInfoDL_SIB__scs_SpecificCarrierList pointer
703 * @return ROK - success
706 * ****************************************************************/
707 uint8_t BuildScsSpecificCarrierListDl( struct FrequencyInfoDL_SIB__scs_SpecificCarrierList *scsCarrierList)
710 ScsSpecCarrier duScsSpecCarrier;
712 duScsSpecCarrier = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.dlScsCarrier;
714 DU_ALLOC(scsCarrierList->list.array, scsCarrierList->list.size);
715 if(!scsCarrierList->list.array)
717 DU_LOG("\nERROR --> DU APP : SCS Specific Carrier list memory allocation failed");
721 for(idx = 0; idx < scsCarrierList->list.count; idx++)
723 DU_ALLOC(scsCarrierList->list.array[idx], sizeof(SCS_SpecificCarrier_t));
724 if(!scsCarrierList->list.array[idx])
726 DU_LOG("\nERROR --> DU APP : SCS Specific Carrier list memory allocation failed");
732 scsCarrierList->list.array[idx]->offsetToCarrier = duScsSpecCarrier.scsOffset;
733 scsCarrierList->list.array[idx]->subcarrierSpacing = duScsSpecCarrier.scs;
734 scsCarrierList->list.array[idx]->carrierBandwidth = duScsSpecCarrier.scsBw;
737 } /* End of BuildScsSpecificCarrierListDl */
739 /*******************************************************************
741 * @brief Builds common search space list
745 * Function : BuildCommonSerachSpaceList
748 * Builds common search space list
750 * @params[in] PDCCH_ConfigCommon__commonSearchSpaceList pointer
751 * @return ROK - success
754 * ****************************************************************/
755 uint8_t BuildCommonSerachSpaceList( struct PDCCH_ConfigCommon__commonSearchSpaceList *searchSpclist)
758 SearchSpace_t *searchSpace;
759 PdcchCfgCommon duPdcchCfg;
761 duPdcchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdcchCfg;
763 DU_ALLOC(searchSpclist->list.array, searchSpclist->list.size)
764 if(!searchSpclist->list.array)
766 DU_LOG("\nERROR --> DU APP : Common search space list memory alloc failed");
770 for(idx = 0; idx < searchSpclist->list.count; idx++)
772 DU_ALLOC(searchSpclist->list.array[idx], sizeof(SearchSpace_t));
773 if(!searchSpclist->list.array[idx])
775 DU_LOG("\nERROR --> DU APP : Common search space list memory alloc failed");
781 searchSpace = searchSpclist->list.array[idx];
783 /* Search Space id */
784 searchSpace->searchSpaceId = duPdcchCfg.searchSpcId;
786 /* Control Resource Set Id */
787 DU_ALLOC(searchSpace->controlResourceSetId, sizeof(ControlResourceSetId_t));
788 if(!searchSpace->controlResourceSetId)
790 DU_LOG("\nERROR --> DU APP : Common search space list memory alloc failed");
793 *searchSpace->controlResourceSetId = duPdcchCfg.ctrlRsrcSetId;
795 /* Monitoring Slot periodicity and offset */
796 DU_ALLOC(searchSpace->monitoringSlotPeriodicityAndOffset,\
797 sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
798 if(!searchSpace->monitoringSlotPeriodicityAndOffset)
800 DU_LOG("\nERROR --> DU APP : Common search space list memory alloc failed");
803 searchSpace->monitoringSlotPeriodicityAndOffset->present = \
804 duPdcchCfg.monitorSlotPrdAndOffPresent;
805 switch(searchSpace->monitoringSlotPeriodicityAndOffset->present)
807 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1:
809 //searchSpace->monitoringSlotPeriodicityAndOffset->choice.s11 = duPdcchCfg.monitorSlotPrdAndOff;
812 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2:
817 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl4:
822 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl5:
827 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl8:
832 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl10:
837 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl16:
842 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl20:
847 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl40:
852 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl80:
857 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl160:
862 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl320:
867 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl640:
872 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1280:
877 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2560:
884 DU_LOG("\nERROR --> DU APP : Invalid value:Montoring slot periodicity and offset");
889 /* Monitoring Symbols Within Slot */
890 DU_ALLOC(searchSpace->monitoringSymbolsWithinSlot,\
891 sizeof(BIT_STRING_t));
892 if(!searchSpace->monitoringSymbolsWithinSlot)
894 DU_LOG("\nERROR --> DU APP : Common search space list memory alloc failed");
897 searchSpace->monitoringSymbolsWithinSlot->size = 2*sizeof(uint8_t);
898 DU_ALLOC(searchSpace->monitoringSymbolsWithinSlot->buf, \
899 searchSpace->monitoringSymbolsWithinSlot->size );
900 if(!searchSpace->monitoringSymbolsWithinSlot->buf)
902 DU_LOG("\nERROR --> DU APP : Common search space list memory alloc failed");
905 searchSpace->monitoringSymbolsWithinSlot->buf[0] = duPdcchCfg.monitorSymbolsInSlot[0];
906 searchSpace->monitoringSymbolsWithinSlot->buf[1] = duPdcchCfg.monitorSymbolsInSlot[1];
907 searchSpace->monitoringSymbolsWithinSlot->bits_unused = 2;
909 /* Number of candidates per aggregation level */
910 DU_ALLOC(searchSpace->nrofCandidates,\
911 sizeof(struct SearchSpace__nrofCandidates));
912 if(!searchSpace->nrofCandidates)
914 DU_LOG("\nERROR --> DU APP : Common search space list memory alloc failed");
917 searchSpace->nrofCandidates->aggregationLevel1 = duPdcchCfg.numCandAggLvl1;
918 searchSpace->nrofCandidates->aggregationLevel2 = duPdcchCfg.numCandAggLvl2;
919 searchSpace->nrofCandidates->aggregationLevel4 = duPdcchCfg.numCandAggLvl4;
920 searchSpace->nrofCandidates->aggregationLevel8 = duPdcchCfg.numCandAggLvl8;
921 searchSpace->nrofCandidates->aggregationLevel16 = duPdcchCfg.numCandAggLvl16;
923 /* Search Space type and DCI Format */
924 DU_ALLOC(searchSpace->searchSpaceType,\
925 sizeof( struct SearchSpace__searchSpaceType));
926 if(!searchSpace->searchSpaceType)
928 DU_LOG("\nERROR --> DU APP : Common search space list memory alloc failed");
932 searchSpace->searchSpaceType->present = duPdcchCfg.searchSpcType;
933 switch(searchSpace->searchSpaceType->present)
935 case SearchSpace__searchSpaceType_PR_NOTHING:
940 case SearchSpace__searchSpaceType_PR_common:
942 DU_ALLOC(searchSpace->searchSpaceType->choice.common, sizeof(struct SearchSpace__searchSpaceType__common));
943 if(!searchSpace->searchSpaceType->choice.common)
945 DU_LOG("\nERROR --> DU APP : Common search space list memory alloc failed");
949 DU_ALLOC(searchSpace->searchSpaceType->choice.common->\
950 dci_Format0_0_AndFormat1_0, sizeof(struct \
951 SearchSpace__searchSpaceType__common__dci_Format0_0_AndFormat1_0));
952 if(!searchSpace->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0)
954 DU_LOG("\nERROR --> DU APP : Common search space list memory alloc failed");
959 case SearchSpace__searchSpaceType_PR_ue_Specific:
965 DU_LOG("\nERROR --> DU_APP: Invalid Search Space type");
971 }/* BuildCommonSerachSpaceList */
973 /*******************************************************************
975 * @brief Builds PDCCH configuration common
979 * Function : BuildPdcchCfgCommon
982 * Builds PDCCH configuration common
984 * @params[in] BWP_DownlinkCommon__pdcch_ConfigCommon pointer
985 * @return ROK - success
988 * ****************************************************************/
989 uint8_t BuildPdcchCfgCommon(struct BWP_DownlinkCommon__pdcch_ConfigCommon *pdcchCfg)
993 PdcchCfgCommon duPdcchCfg;
994 PDCCH_ConfigCommon_t *pdcchSetup;
996 duPdcchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdcchCfg;
998 pdcchCfg->present = duPdcchCfg.present;
1000 switch(pdcchCfg->present)
1002 case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_NOTHING:
1007 case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_release:
1012 case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup:
1014 DU_ALLOC(pdcchCfg->choice.setup, sizeof(PDCCH_ConfigCommon_t));
1015 if(!pdcchCfg->choice.setup)
1017 DU_LOG("\nERROR --> DU APP : PDCCH Config memory alloc failed");
1020 pdcchSetup = pdcchCfg->choice.setup;
1022 /* Control Resource Set Zero */
1023 DU_ALLOC(pdcchSetup->controlResourceSetZero, sizeof(ControlResourceSetZero_t));
1024 if(!pdcchSetup->controlResourceSetZero)
1026 DU_LOG("\nERROR --> DU APP : PDCCH Config memory alloc failed");
1029 *pdcchSetup->controlResourceSetZero = duPdcchCfg.ctrlRsrcSetZero;
1031 /* Search space zero */
1032 DU_ALLOC(pdcchSetup->searchSpaceZero, sizeof(SearchSpaceZero_t));
1033 if(!pdcchSetup->searchSpaceZero)
1035 DU_LOG("\nERROR --> DU APP : PDCCH Config memory alloc failed");
1038 *pdcchSetup->searchSpaceZero = duPdcchCfg.searchSpcZero;
1040 /* Common Search Space List */
1041 DU_ALLOC(pdcchSetup->commonSearchSpaceList,\
1042 sizeof(struct PDCCH_ConfigCommon__commonSearchSpaceList));
1043 if(!pdcchSetup->commonSearchSpaceList)
1045 DU_LOG("\nERROR --> DU APP : PDCCH Config memory alloc failed");
1048 elementCnt = ODU_VALUE_ONE;
1049 pdcchSetup->commonSearchSpaceList->list.count = elementCnt;
1050 pdcchSetup->commonSearchSpaceList->list.size = elementCnt * sizeof(SearchSpace_t *);
1051 ret = BuildCommonSerachSpaceList(pdcchSetup->commonSearchSpaceList);
1056 CommonSerachSpaceListret=ROK;
1058 /* Search Space for SIB1 */
1059 DU_ALLOC(pdcchSetup->searchSpaceSIB1, sizeof(SearchSpaceId_t));
1060 if(!pdcchSetup->searchSpaceSIB1)
1062 DU_LOG("\nERROR --> DU APP : PDCCH Config memory alloc failed");
1065 *pdcchSetup->searchSpaceSIB1 = duPdcchCfg.searchSpcSib1;
1067 /* Serach Space for Paging */
1068 DU_ALLOC(pdcchSetup->pagingSearchSpace, sizeof(SearchSpaceId_t));
1069 if(!pdcchSetup->pagingSearchSpace)
1071 DU_LOG("\nERROR --> DU APP : PDCCH Config memory alloc failed");
1074 *pdcchSetup->pagingSearchSpace = duPdcchCfg.pagingSearchSpc;
1076 /* Search space for Random Access */
1077 DU_ALLOC(pdcchSetup->ra_SearchSpace, sizeof(SearchSpaceId_t));
1078 if(!pdcchSetup->ra_SearchSpace)
1080 DU_LOG("\nERROR --> DU APP : PDCCH Config memory alloc failed");
1083 *pdcchSetup->ra_SearchSpace = duPdcchCfg.raSearchSpc;
1089 DU_LOG("\nERROR --> DU APP : Invalid PDCCH Config type");
1095 } /* BuildPdcchCfgCommon */
1097 /*******************************************************************
1099 * @brief Builds PDSCH configuration common
1103 * Function : BuildPdschCfgCommon
1106 * Builds PDSCH configuration common
1108 * @params[in] BWP_DownlinkCommon__pdsch_ConfigCommon pointer
1109 * @return ROK - success
1112 * ****************************************************************/
1113 uint8_t BuildPdschCfgCommon(struct BWP_DownlinkCommon__pdsch_ConfigCommon *pdschCfg)
1117 PdschCfgCommon duPdschCfg;
1118 PDSCH_ConfigCommon_t *pdschSetup;
1119 PDSCH_TimeDomainResourceAllocation_t *timeDomRsrcAllocInfo;
1121 duPdschCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdschCfg;
1123 pdschCfg->present = duPdschCfg.present;
1125 switch(pdschCfg->present)
1127 case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_NOTHING:
1132 case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_release:
1137 case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup:
1139 DU_ALLOC(pdschCfg->choice.setup, sizeof(PDSCH_ConfigCommon_t));
1140 if(!pdschCfg->choice.setup)
1142 DU_LOG("\nERROR --> DU APP : PDCCH Config memory alloc failed");
1145 pdschSetup = pdschCfg->choice.setup;
1147 /* Time Domain Allocation List */
1148 DU_ALLOC(pdschSetup->pdsch_TimeDomainAllocationList, \
1149 sizeof(PDSCH_TimeDomainResourceAllocationList_t));
1150 if(!pdschSetup->pdsch_TimeDomainAllocationList)
1152 DU_LOG("\nERROR --> DU APP : PDCCH Config memory alloc failed");
1155 elementCnt = duPdschCfg.numTimeDomRsrcAlloc;
1156 pdschSetup->pdsch_TimeDomainAllocationList->list.count = elementCnt;
1157 pdschSetup->pdsch_TimeDomainAllocationList->list.size = elementCnt * sizeof(PDSCH_TimeDomainResourceAllocation_t *);
1159 DU_ALLOC(pdschSetup->pdsch_TimeDomainAllocationList->list.array,\
1160 pdschSetup->pdsch_TimeDomainAllocationList->list.size);
1161 if(!pdschSetup->pdsch_TimeDomainAllocationList->list.array)
1163 DU_LOG("\nERROR --> DU APP : PDCCH Config memory alloc failed");
1167 for(idx=0; idx<elementCnt; idx++)
1169 DU_ALLOC(pdschSetup->pdsch_TimeDomainAllocationList->list.array[idx],\
1170 sizeof(PDSCH_TimeDomainResourceAllocation_t));
1171 if(!pdschSetup->pdsch_TimeDomainAllocationList->list.array[idx])
1173 DU_LOG("\nERROR --> DU APP : PDCCH Config memory alloc failed");
1178 for(idx = 0; idx < pdschSetup->pdsch_TimeDomainAllocationList->list.count; idx++)
1180 timeDomRsrcAllocInfo = pdschSetup->pdsch_TimeDomainAllocationList->list.array[idx];
1183 DU_ALLOC(timeDomRsrcAllocInfo->k0, sizeof(long));
1184 if(!timeDomRsrcAllocInfo->k0)
1186 DU_LOG("\nERROR --> DU APP : PDCCH Config memory alloc failed");
1189 *timeDomRsrcAllocInfo->k0 = duPdschCfg.timeDomAlloc[idx].k0;
1191 timeDomRsrcAllocInfo->mappingType = duPdschCfg.timeDomAlloc[idx].mapType;
1192 timeDomRsrcAllocInfo->startSymbolAndLength = duPdschCfg.timeDomAlloc[idx].sliv;
1198 DU_LOG("\nERROR --> DU APP: Invalid PDSCH Configuration type");
1204 }/* BuildPdschCfgCommon */
1206 /*******************************************************************
1208 * @brief Builds DL BWP common
1212 * Function : BuildBwpDlCommon
1215 * Builds DL BWP common
1217 * @params[in] BWP_DownlinkCommon_t pointer
1218 * @return ROK - success
1221 * ****************************************************************/
1222 uint8_t BuildBwpDlCommon(BWP_DownlinkCommon_t *bwp)
1225 DlCfgCommon duDlCfg;
1227 duDlCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg;
1229 bwp->genericParameters.locationAndBandwidth = duDlCfg.locAndBw;
1230 bwp->genericParameters.subcarrierSpacing = duDlCfg.dlScsCarrier.scs;
1232 /* PDCCH Config Common */
1233 DU_ALLOC(bwp->pdcch_ConfigCommon, \
1234 sizeof(struct BWP_DownlinkCommon__pdcch_ConfigCommon));
1235 if(!bwp->pdcch_ConfigCommon)
1237 DU_LOG("\nERROR --> DU APP : DL BWP memory allocation failed");
1240 ret=BuildPdcchCfgCommon(bwp->pdcch_ConfigCommon);
1245 /* PDSCH Config Common */
1246 DU_ALLOC(bwp->pdsch_ConfigCommon, \
1247 sizeof(struct BWP_DownlinkCommon__pdsch_ConfigCommon));
1248 if(!bwp->pdsch_ConfigCommon)
1250 DU_LOG("\nERROR --> DU APP : DL BWP memory allocation failed");
1253 ret=BuildPdschCfgCommon(bwp->pdsch_ConfigCommon);
1259 } /* BuildBwpDlCommon */
1261 /*******************************************************************
1263 * @brief Build BCCH configuration
1267 * Function : BuildBcchConfig
1270 * Build BCCH configuration
1272 * @params[in] BCCH_Config_t pointer
1273 * @return ROK - success
1276 * ****************************************************************/
1278 uint8_t BuildBcchConfig(BCCH_Config_t *bcchCfg)
1282 duBcchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.bcchCfg;
1284 bcchCfg->modificationPeriodCoeff = duBcchCfg.modPrdCoeff;
1287 }/* BuildBcchConfig */
1289 /*******************************************************************
1291 * @brief Builds PCCH configuration
1295 * Function : BuildPcchConfig
1298 * Builds PCCH configuration
1301 * @return ROK - success
1304 * ****************************************************************/
1305 uint8_t BuildPcchConfig(PCCH_Config_t *pcchCfg)
1309 duPcchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pcchCfg;
1311 pcchCfg->defaultPagingCycle = duPcchCfg.dfltPagingCycle;
1312 pcchCfg->nAndPagingFrameOffset.present = duPcchCfg.nAndPagingFrmOffPresent;
1313 switch(pcchCfg->nAndPagingFrameOffset.present)
1315 case PCCH_Config__nAndPagingFrameOffset_PR_NOTHING:
1320 case PCCH_Config__nAndPagingFrameOffset_PR_oneT:
1325 case PCCH_Config__nAndPagingFrameOffset_PR_halfT:
1330 case PCCH_Config__nAndPagingFrameOffset_PR_quarterT:
1335 case PCCH_Config__nAndPagingFrameOffset_PR_oneEighthT:
1340 case PCCH_Config__nAndPagingFrameOffset_PR_oneSixteenthT:
1347 DU_LOG("\nERROR --> DU APP : Invalid nAndPagingFrameOffset configuration");
1351 pcchCfg->ns = duPcchCfg.numPagingOcc;
1354 }/* BuildPcchConfig */
1356 /*******************************************************************
1358 * @brief Builds Frequency Info for Downlink
1362 * Function : BuildFreqInfoDl
1365 * Builds Frequency Info for Downlink
1368 * @return ROK - success
1371 * ****************************************************************/
1373 uint8_t BuildFreqInfoDl(FrequencyInfoDL_SIB_t *frequencyInfoDL)
1379 NR_MultiBandInfo_t *multiBandInfo;
1381 dlCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg;
1383 /* NR Multi-Band Info */
1384 elementCnt = ODU_VALUE_ONE;
1385 frequencyInfoDL->frequencyBandList.list.count = elementCnt;
1386 frequencyInfoDL->frequencyBandList.list.size = \
1387 elementCnt * sizeof(NR_MultiBandInfo_t *);
1389 DU_ALLOC(frequencyInfoDL->frequencyBandList.list.array, \
1390 frequencyInfoDL->frequencyBandList.list.size);
1391 if(!frequencyInfoDL->frequencyBandList.list.array)
1393 DU_LOG("\nERROR --> DU APP : SIB1 DL Configuration memory allocation failed");
1397 for(idx = 0; idx < elementCnt; idx++)
1399 DU_ALLOC(frequencyInfoDL->frequencyBandList.list.array[idx],\
1400 sizeof(NR_MultiBandInfo_t));
1401 if(!frequencyInfoDL->frequencyBandList.list.array[idx])
1403 DU_LOG("\nERROR --> DU APP : SIB1 DL Configuration memory allocation failed");
1409 multiBandInfo = frequencyInfoDL->frequencyBandList.list.array[idx];
1411 /* Frequency band indicator */
1412 DU_ALLOC(multiBandInfo->freqBandIndicatorNR, sizeof(FreqBandIndicatorNR_t));
1413 if(!multiBandInfo->freqBandIndicatorNR)
1415 DU_LOG("\nERROR --> DU APP : SIB1 DL Configuration memory allocation failed");
1418 *multiBandInfo->freqBandIndicatorNR = dlCfg.freqBandInd;
1420 /* Offset to Point A */
1421 frequencyInfoDL->offsetToPointA = dlCfg.offsetToPointA;
1423 /* Subcarrier Spacing specifc carrier */
1424 elementCnt = ODU_VALUE_ONE;
1425 frequencyInfoDL->scs_SpecificCarrierList.list.count = elementCnt;
1426 frequencyInfoDL->scs_SpecificCarrierList.list.size = \
1427 elementCnt * sizeof(SCS_SpecificCarrier_t *);
1428 ret= BuildScsSpecificCarrierListDl(&frequencyInfoDL->scs_SpecificCarrierList);
1435 }/* BuildFreqInfoDl */
1437 /*******************************************************************
1439 * @brief Builds DL configuration common for SIB
1443 * Function : BuildDlCfgCommSib
1446 * Builds DL configuration common for SIB
1448 * @params[in] DownlinkConfigCommonSIB_t pointer
1449 * @return ROK - success
1452 * ****************************************************************/
1454 uint8_t BuildDlCfgCommSib(DownlinkConfigCommonSIB_t *dlCfg)
1456 /* DL frequency info */
1458 ret = BuildFreqInfoDl(&dlCfg->frequencyInfoDL);
1464 /* BWP Downlink Common */
1465 ret = BuildBwpDlCommon(&dlCfg->initialDownlinkBWP);
1471 ret = BuildBcchConfig(&dlCfg->bcch_Config);
1477 ret = BuildPcchConfig(&dlCfg->pcch_Config);
1483 } /* BuildDlCfgCommSib */
1485 /*******************************************************************
1487 * @brief Builds SCS specific carrier list for UL
1491 * Function : BuildScsSpecificCarrierListUl
1494 * Builds SCS specific carrier list for UL
1497 * @return ROK - success
1500 * ****************************************************************/
1502 uint8_t BuildScsSpecificCarrierListUl
1504 struct FrequencyInfoUL_SIB__scs_SpecificCarrierList *scsCarrierList
1508 ScsSpecCarrier duScsSpecCarrier;
1510 duScsSpecCarrier = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.ulScsCarrier;
1512 DU_ALLOC(scsCarrierList->list.array, scsCarrierList->list.size);
1513 if(!scsCarrierList->list.array)
1515 DU_LOG("\nERROR --> DU APP : SCS Specific Carrier list memory allocation failed");
1519 for(idx = 0; idx < scsCarrierList->list.count; idx++)
1521 DU_ALLOC(scsCarrierList->list.array[idx], sizeof(SCS_SpecificCarrier_t));
1522 if(!scsCarrierList->list.array[idx])
1524 DU_LOG("\nERROR --> DU APP : SCS Specific Carrier list memory allocation failed");
1529 scsCarrierList->list.array[idx]->offsetToCarrier = duScsSpecCarrier.scsOffset;
1530 scsCarrierList->list.array[idx]->subcarrierSpacing = duScsSpecCarrier.scs;
1531 scsCarrierList->list.array[idx]->carrierBandwidth = duScsSpecCarrier.scsBw;
1534 } /* End of BuildScsSpecificCarrierListUl */
1536 /*******************************************************************
1538 * @brief Builds frequency infor for UL
1542 * Function : BuildFreqInfoUl
1545 * Builds frequency infor for UL
1547 * @params[in] FrequencyInfoUL_SIB_t pointer
1548 * @return ROK - success
1551 * ****************************************************************/
1553 uint8_t BuildFreqInfoUl(FrequencyInfoUL_SIB_t *frequencyInfoUL)
1558 ulCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg;
1560 /* Subcarrier Spacing specifc carrier */
1561 elementCnt = ODU_VALUE_ONE;
1562 frequencyInfoUL->scs_SpecificCarrierList.list.count = elementCnt;
1563 frequencyInfoUL->scs_SpecificCarrierList.list.size = \
1564 elementCnt * sizeof(SCS_SpecificCarrier_t *);
1565 ret=BuildScsSpecificCarrierListUl(&frequencyInfoUL->scs_SpecificCarrierList);
1571 DU_ALLOC(frequencyInfoUL->p_Max, sizeof(P_Max_t));
1572 if(!frequencyInfoUL->p_Max)
1574 DU_LOG("\nERROR --> DU APP : UL Frequency Infoo memory allocation failure");
1577 *frequencyInfoUL->p_Max = ulCfg.pMax;
1580 }/* BuildFreqInfoUl */
1582 /*******************************************************************
1584 * @brief Builds RACH configuration common
1588 * Function : BuildRachCfgCommon
1591 * Builds RACH configuration common
1593 * @params[in] BWP_UplinkCommon__rach_ConfigCommon pointer
1594 * @return ROK - success
1597 * ****************************************************************/
1599 uint8_t BuildRachCfgCommon(struct BWP_UplinkCommon__rach_ConfigCommon *rachCfg)
1601 RachCfgCommon duRachCfg;
1602 RACH_ConfigCommon_t *setup;
1604 duRachCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.rachCfg;
1606 rachCfg->present = duRachCfg.present;
1607 switch(rachCfg->present)
1609 case BWP_UplinkCommon__rach_ConfigCommon_PR_NOTHING:
1614 case BWP_UplinkCommon__rach_ConfigCommon_PR_release:
1619 case BWP_UplinkCommon__rach_ConfigCommon_PR_setup:
1621 DU_ALLOC(rachCfg->choice.setup, sizeof(RACH_ConfigCommon_t));
1622 if(!rachCfg->choice.setup)
1624 DU_LOG("\nERROR --> DU APP : Rach Config memory alloc failed");
1627 setup = rachCfg->choice.setup;
1629 /* Generic RACH Configuration */
1630 setup->rach_ConfigGeneric.prach_ConfigurationIndex = duRachCfg.prachCfgIdx;
1631 setup->rach_ConfigGeneric.msg1_FDM = duRachCfg.msg1Fdm;
1632 setup->rach_ConfigGeneric.msg1_FrequencyStart = duRachCfg.msg1FreqStart;
1633 setup->rach_ConfigGeneric.zeroCorrelationZoneConfig = duRachCfg.zeroCorrZoneCfg;
1634 setup->rach_ConfigGeneric.preambleReceivedTargetPower = duRachCfg.preambleRcvdTgtPwr;
1635 setup->rach_ConfigGeneric.preambleTransMax = duRachCfg.preambleTransMax;
1636 setup->rach_ConfigGeneric.powerRampingStep = duRachCfg.pwrRampingStep;
1637 setup->rach_ConfigGeneric.ra_ResponseWindow = duRachCfg.raRspWindow;
1639 /* Total number of RA preambles */
1640 DU_ALLOC(setup->totalNumberOfRA_Preambles, sizeof(long));
1641 if(!setup->totalNumberOfRA_Preambles)
1643 DU_LOG("\nERROR --> DU APP : Rach Config memory alloc failed");
1646 *setup->totalNumberOfRA_Preambles = duRachCfg.numRaPreamble;
1648 /* SSB per RACH occassion and CB Preambles per SSB */
1649 DU_ALLOC(setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB,\
1650 sizeof(struct RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB));
1651 if(!setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB)
1653 DU_LOG("\nERROR --> DU APP : Rach Config memory alloc failed");
1656 setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present = \
1657 duRachCfg.ssbPerRachOccPresent;
1658 switch(setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present)
1660 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_NOTHING:
1665 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneEighth:
1670 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneFourth:
1675 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneHalf:
1680 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one:
1682 setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.one =\
1683 duRachCfg.numSsbPerRachOcc;
1685 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_two:
1690 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_four:
1695 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_eight:
1700 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_sixteen:
1707 DU_LOG("\nERROR --> DU APP: Invalid value for \
1708 ssb_PerRach_OccassionAndCB_PreamblesPerSSB");
1713 /* RA Contention Resolution Timer */
1714 setup->ra_ContentionResolutionTimer = duRachCfg.contResTimer;
1716 /* RSRP Threshold SSB */
1717 DU_ALLOC(setup->rsrp_ThresholdSSB, sizeof(RSRP_Range_t));
1718 if(!setup->rsrp_ThresholdSSB)
1720 DU_LOG("\nERROR --> DU APP : Rach Config memory alloc failed");
1723 *setup->rsrp_ThresholdSSB = duRachCfg.rsrpThreshSsb;
1725 /* Root Sequence index */
1726 setup->prach_RootSequenceIndex.present = duRachCfg.rootSeqIdxPresent;
1727 switch(setup->prach_RootSequenceIndex.present)
1729 case RACH_ConfigCommon__prach_RootSequenceIndex_PR_NOTHING:
1734 case RACH_ConfigCommon__prach_RootSequenceIndex_PR_l839:
1739 case RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139:
1741 setup->prach_RootSequenceIndex.choice.l139 = duRachCfg.rootSeqIdx;
1746 DU_LOG("\nERROR --> DU APP: Inavlid PRACH root sequence index type");
1751 /* Msg 1 Subcarrier spacing */
1752 DU_ALLOC(setup->msg1_SubcarrierSpacing, sizeof(SubcarrierSpacing_t));
1753 if(!setup->msg1_SubcarrierSpacing)
1755 DU_LOG("\nERROR --> DU APP : Rach Config memory alloc failed");
1758 *setup->msg1_SubcarrierSpacing = duRachCfg.msg1Scs;
1760 /* Restricted Set Config */
1761 setup->restrictedSetConfig = duRachCfg.restrictedSetCfg;
1767 DU_LOG("\nERROR --> DU APP : Invalid RACH Config type ");
1772 }/* BuildRachCfgCommon */
1774 /*******************************************************************
1776 * @brief Builds PUSCH configuration for common
1780 * Function : BuildPuschCfgCommon
1783 * Builds PUSCH configuration for common
1786 * @return ROK - success
1789 * ****************************************************************/
1791 uint8_t BuildPuschCfgCommon(struct BWP_UplinkCommon__pusch_ConfigCommon *puschCfg)
1795 PuschCfgCommon duPuschCfg;
1796 PUSCH_ConfigCommon_t *setup;
1797 PUSCH_TimeDomainResourceAllocation_t *timeDomRsrcAllocInfo;
1799 duPuschCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.puschCfg;
1801 puschCfg->present = duPuschCfg.puschCfgPresent;
1802 switch(puschCfg->present)
1804 case BWP_UplinkCommon__pusch_ConfigCommon_PR_NOTHING:
1809 case BWP_UplinkCommon__pusch_ConfigCommon_PR_release:
1814 case BWP_UplinkCommon__pusch_ConfigCommon_PR_setup:
1816 DU_ALLOC(puschCfg->choice.setup, sizeof(PUSCH_ConfigCommon_t));
1817 if(!puschCfg->choice.setup)
1819 DU_LOG("\nERROR --> DU APP : PUSCH Config memory alloc failed");
1822 setup = puschCfg->choice.setup;
1824 /* Time Domain Resource Allocation List */
1825 DU_ALLOC(setup->pusch_TimeDomainAllocationList,\
1826 sizeof(PUSCH_TimeDomainResourceAllocationList_t));
1827 if(!setup->pusch_TimeDomainAllocationList)
1829 DU_LOG("\nERROR --> DU APP : PUSCH Config memory alloc failed");
1832 elementCnt = duPuschCfg.numTimeDomRsrcAlloc;
1833 setup->pusch_TimeDomainAllocationList->list.count = elementCnt;
1834 setup->pusch_TimeDomainAllocationList->list.size = \
1835 elementCnt * sizeof(PUSCH_TimeDomainResourceAllocation_t *);
1837 DU_ALLOC(setup->pusch_TimeDomainAllocationList->list.array, \
1838 setup->pusch_TimeDomainAllocationList->list.size);
1839 if(!setup->pusch_TimeDomainAllocationList->list.array)
1841 DU_LOG("\nERROR --> DU APP : PUSCH Config memory alloc failed");
1845 for(idx=0; idx<elementCnt; idx++)
1847 DU_ALLOC(setup->pusch_TimeDomainAllocationList->list.array[idx],\
1848 sizeof(PUSCH_TimeDomainResourceAllocation_t));
1849 if(!setup->pusch_TimeDomainAllocationList->list.array[idx])
1851 DU_LOG("\nERROR --> DU APP : PUSCH Config memory alloc failed");
1856 for(idx = 0; idx < elementCnt; idx++)
1858 timeDomRsrcAllocInfo = setup->pusch_TimeDomainAllocationList->list.array[idx];
1861 DU_ALLOC(timeDomRsrcAllocInfo->k2, sizeof(long));
1862 if(!timeDomRsrcAllocInfo->k2)
1864 DU_LOG("\nERROR --> DU APP : PUSCH Config memory alloc failed");
1867 *timeDomRsrcAllocInfo->k2 = duPuschCfg.timeDomAllocList[idx].k2;
1868 timeDomRsrcAllocInfo->mappingType = duPuschCfg.timeDomAllocList[idx].mapType;
1869 timeDomRsrcAllocInfo->startSymbolAndLength = duPuschCfg.timeDomAllocList[idx].sliv;
1871 /* Msg3 Delta Preamble */
1872 DU_ALLOC(setup->msg3_DeltaPreamble, sizeof(long));
1873 if(!setup->msg3_DeltaPreamble)
1875 DU_LOG("\nERROR --> DU APP : PUSCH Config memory alloc failed");
1878 *setup->msg3_DeltaPreamble = duPuschCfg.msg3DeltaPreamble;
1880 /* P0 Nominal with grnat */
1881 DU_ALLOC(setup->p0_NominalWithGrant, sizeof(long));
1882 if(!setup->p0_NominalWithGrant)
1884 DU_LOG("\nERROR --> DU APP : PUSCH Config memory alloc failed");
1887 *setup->p0_NominalWithGrant = duPuschCfg.p0NominalWithGrant;
1893 DU_LOG("\nERROR --> DU APP : Invalid PUSCH configuration type ");
1899 }/* BuildPuschCfgCommon */
1901 /*******************************************************************
1903 * @brief Builds PUCCH configuration common
1907 * Function : BuildPucchCfgCommon
1910 * Builds PUCCH configuration common
1913 * @return ROK - success
1916 * ****************************************************************/
1918 uint8_t BuildPucchCfgCommon( struct BWP_UplinkCommon__pucch_ConfigCommon *pucchCfg)
1920 PucchCfgCommon duPucchCfg;
1921 PUCCH_ConfigCommon_t *setup;
1923 duPucchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.pucchCfg;
1925 pucchCfg->present = duPucchCfg.present;
1926 switch(pucchCfg->present)
1928 case BWP_UplinkCommon__pucch_ConfigCommon_PR_NOTHING:
1933 case BWP_UplinkCommon__pucch_ConfigCommon_PR_release:
1938 case BWP_UplinkCommon__pucch_ConfigCommon_PR_setup:
1940 DU_ALLOC(pucchCfg->choice.setup, sizeof(PUCCH_ConfigCommon_t));
1941 if(!pucchCfg->choice.setup)
1943 DU_LOG("\nERROR --> DU APP : PUCCH Config memory alloc failed");
1946 setup = pucchCfg->choice.setup;
1948 /* Resource Common */
1949 DU_ALLOC(setup->pucch_ResourceCommon, sizeof(long));
1950 if(!setup->pucch_ResourceCommon)
1952 DU_LOG("\nERROR --> DU APP : PUCCH Config memory alloc failed");
1955 *setup->pucch_ResourceCommon = duPucchCfg.rsrcComm;
1958 setup->pucch_GroupHopping = duPucchCfg.grpHop;
1961 DU_ALLOC(setup->p0_nominal, sizeof(long));
1962 if(!setup->p0_nominal)
1964 DU_LOG("\nERROR --> DU APP : PUCCH Config memory alloc failed");
1967 *setup->p0_nominal = duPucchCfg.p0Nominal;
1973 DU_LOG("\nERROR --> DU APP : Invalid PUCCH Config type");
1978 }/* BuildPucchCfgCommon */
1980 /*******************************************************************
1982 * @brief Builds UL BWP Common
1986 * Function : BuildBwpUlCommon
1989 * Builds UL BWP Common
1991 * @params[in] BWP_UplinkCommon_t pointer
1992 * @return ROK - success
1995 * ****************************************************************/
1997 uint8_t BuildBwpUlCommon(BWP_UplinkCommon_t *bwp)
2000 UlCfgCommon duUlCfg;
2002 duUlCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg;
2004 bwp->genericParameters.locationAndBandwidth = duUlCfg.locAndBw;
2005 bwp->genericParameters.subcarrierSpacing = duUlCfg.ulScsCarrier.scs;
2007 /* RACH Config Common */
2008 DU_ALLOC(bwp->rach_ConfigCommon,\
2009 sizeof(struct BWP_UplinkCommon__rach_ConfigCommon));
2010 if(!bwp->rach_ConfigCommon)
2012 DU_LOG("\nERROR --> DU APP : UL BWP memory allocation failed");
2015 ret = BuildRachCfgCommon(bwp->rach_ConfigCommon);
2020 RachCfgCommonret=ROK;
2022 /* PUSCH Config Common */
2023 DU_ALLOC(bwp->pusch_ConfigCommon,\
2024 sizeof(struct BWP_UplinkCommon__pusch_ConfigCommon));
2025 if(!bwp->pusch_ConfigCommon)
2027 DU_LOG("\nERROR --> DU APP : UL BWP memory allocation failed");
2030 ret = BuildPuschCfgCommon(bwp->pusch_ConfigCommon);
2035 PuschCfgCommonret = ROK;
2037 /* PUCCH Config Common */
2038 DU_ALLOC(bwp->pucch_ConfigCommon,\
2039 sizeof(struct BWP_UplinkCommon__pucch_ConfigCommon));
2040 if(!bwp->pucch_ConfigCommon)
2042 DU_LOG("\nERROR --> DU APP : UL BWP memory allocation failed");
2045 ret = BuildPucchCfgCommon(bwp->pucch_ConfigCommon);
2051 }/* BuildBwpUlCommon */
2053 /*******************************************************************
2055 * @brief Builds UL config common for SIB
2059 * Function : BuildUlCfgCommSib
2062 * Builds UL config common for SIB
2064 * @params[in] UplinkConfigCommonSIB_t pointer
2065 * @return ROK - success
2068 * ****************************************************************/
2070 uint8_t BuildUlCfgCommSib(UplinkConfigCommonSIB_t *ulCfg)
2073 /* UL frequency info */
2074 ret = BuildFreqInfoUl(&ulCfg->frequencyInfoUL);
2079 /* BWP Uplink Common */
2080 ret = BuildBwpUlCommon(&ulCfg->initialUplinkBWP);
2085 /* Time Alignment timer */
2086 ulCfg->timeAlignmentTimerCommon = \
2087 duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.timeAlignTimerComm;
2090 }/* BuildUlCfgCommSib */
2092 /*******************************************************************
2094 * @brief Builds TDD UL DL configuration common
2098 * Function : BuildTddUlDlCfgComm
2101 * Builds TDD UL DL configuration common
2103 * @params[in] TDD_UL_DL_ConfigCommon_t pointer
2104 * @return ROK - success
2107 * ****************************************************************/
2109 uint8_t BuildTddUlDlCfgComm(TDD_UL_DL_ConfigCommon_t *tddCfg)
2111 TddUlDlCfgCommon duTddCfg;
2113 duTddCfg = duCfgParam.sib1Params.srvCellCfgCommSib.tddCfg;
2115 /* Reference Subcarrier spacing */
2116 tddCfg->referenceSubcarrierSpacing = duTddCfg.refScs;
2119 tddCfg->pattern1.dl_UL_TransmissionPeriodicity = duTddCfg.txPrd;
2120 tddCfg->pattern1.nrofDownlinkSlots = duTddCfg.numDlSlots;
2121 tddCfg->pattern1.nrofDownlinkSymbols = duTddCfg.numDlSymbols;
2122 tddCfg->pattern1.nrofUplinkSlots = duTddCfg.numUlSlots;
2123 tddCfg->pattern1.nrofUplinkSymbols = duTddCfg.numUlSymbols;
2127 }/* BuildTddUlDlCfgComm */
2129 /*******************************************************************
2131 * @brief Builds Serving cell config common in SIB1 message
2135 * Function : BuildServCellCfgCommonSib
2138 * Building Serving cell config common in SIB1 message
2140 * @params[in] ServingCellConfigCommonSIB_t pointer
2141 * @return ROK - success
2144 * ****************************************************************/
2145 uint8_t BuildServCellCfgCommonSib(ServingCellConfigCommonSIB_t *srvCellCfg)
2147 SrvCellCfgCommSib duSrvCellCfg;
2148 BIT_STRING_t *ssbPosInBurst;
2150 duSrvCellCfg = duCfgParam.sib1Params.srvCellCfgCommSib;
2152 /* SSB Position in Burst */
2153 ssbPosInBurst = &srvCellCfg->ssb_PositionsInBurst.inOneGroup;
2154 ssbPosInBurst->size = 1;
2155 DU_ALLOC(ssbPosInBurst->buf, ssbPosInBurst->size * sizeof(uint8_t));
2156 if(!ssbPosInBurst->buf)
2158 DU_LOG("\nERROR --> DU APP : Serving cell config common memory allocation failure");
2161 ssbPosInBurst->buf[0] = duSrvCellCfg.ssbPosInBurst;
2162 ssbPosInBurst->bits_unused = 0;
2164 switch(duSrvCellCfg.ssbPrdServingCell)
2166 case SSB_PERIODICITY_5MS:
2167 srvCellCfg->ssb_PeriodicityServingCell = \
2168 ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms5;
2170 case SSB_PERIODICITY_10MS:
2171 srvCellCfg->ssb_PeriodicityServingCell = \
2172 ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms10;
2174 case SSB_PERIODICITY_20MS:
2175 srvCellCfg->ssb_PeriodicityServingCell = \
2176 ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms20;
2178 case SSB_PERIODICITY_40MS:
2179 srvCellCfg->ssb_PeriodicityServingCell = \
2180 ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms40;
2182 case SSB_PERIODICITY_80MS:
2183 srvCellCfg->ssb_PeriodicityServingCell = \
2184 ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms80;
2186 case SSB_PERIODICITY_160MS:
2187 srvCellCfg->ssb_PeriodicityServingCell = \
2188 ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms160;
2192 srvCellCfg->ss_PBCH_BlockPower = duSrvCellCfg.ssPbchBlockPwr;
2194 /* Downlink config common */
2195 ret = BuildDlCfgCommSib(&srvCellCfg->downlinkConfigCommon);
2200 DlCfgCommSibret = ROK;
2202 /* Uplink Config Comm */
2203 DU_ALLOC(srvCellCfg->uplinkConfigCommon, sizeof(UplinkConfigCommonSIB_t));
2204 if(!srvCellCfg->uplinkConfigCommon)
2206 DU_LOG("\nERROR --> DU APP : Serving cell config common memory allocation failure");
2209 ret = BuildUlCfgCommSib(srvCellCfg->uplinkConfigCommon);
2214 UlCfgCommSibret=ROK;
2216 /* TDD UL DL Config Comm */
2217 DU_ALLOC(srvCellCfg->tdd_UL_DL_ConfigurationCommon, sizeof(TDD_UL_DL_ConfigCommon_t));
2218 if(!srvCellCfg->tdd_UL_DL_ConfigurationCommon)
2220 DU_LOG("\nERROR --> DU APP : Serving cell config common memory allocation failure");
2223 ret = BuildTddUlDlCfgComm(srvCellCfg->tdd_UL_DL_ConfigurationCommon);
2231 /*******************************************************************
2233 * @brief Builds SIB message in Served Cell Info
2237 * Function : BuildSib1Msg
2239 * Functionality: Building SIB message in Served Cell Info
2241 * @return ROK - success
2244 * ****************************************************************/
2245 uint8_t BuildSib1Msg()
2248 CellAccessRelatedInfo_t *cellAccessInfo;
2251 asn_enc_rval_t encRetVal;
2252 uint8_t ret = RFAILED;
2256 DU_ALLOC(sib1Msg, sizeof(SIB1_t));
2259 DU_LOG("\nERROR --> DU APP: SIB1 msg memory allocation failure");
2263 elementCnt = ODU_VALUE_ONE;
2266 cellAccessInfo = &sib1Msg->cellAccessRelatedInfo;
2267 cellAccessInfo->plmn_IdentityList.list.count = elementCnt;
2268 cellAccessInfo->plmn_IdentityList.list.size = elementCnt * sizeof(PLMN_IdentityInfo_t *);
2270 ret1 = BuildPlmnList(cellAccessInfo);
2275 /* Connection Establish Failure Control */
2276 DU_ALLOC(sib1Msg->connEstFailureControl, sizeof(ConnEstFailureControl_t));
2277 if(!sib1Msg->connEstFailureControl)
2279 DU_LOG("\nERROR --> DU APP: sib1Msg->connEstFailureControl memory allocation failure");
2282 sib1Msg->connEstFailureControl->connEstFailCount =\
2283 duCfgParam.sib1Params.connEstFailCnt;
2284 sib1Msg->connEstFailureControl->connEstFailOffsetValidity =\
2285 duCfgParam.sib1Params.connEstFailOffValidity;
2287 /* SI Scheduling Info */
2288 DU_ALLOC(sib1Msg->si_SchedulingInfo, sizeof(SI_SchedulingInfo_t));
2289 if(!sib1Msg->si_SchedulingInfo)
2291 DU_LOG("\nERROR --> DU APP: sib1Msg->si_SchedulingInfo memory allocation failure");
2294 elementCnt = ODU_VALUE_ONE;
2295 sib1Msg->si_SchedulingInfo->schedulingInfoList.list.count = elementCnt;
2296 sib1Msg->si_SchedulingInfo->schedulingInfoList.list.size = elementCnt *
2297 sizeof(struct SchedulingInfo *);
2298 ret1 = BuildSiSchedInfoList(&sib1Msg->si_SchedulingInfo->schedulingInfoList);
2303 sib1Msg->si_SchedulingInfo->si_WindowLength = duCfgParam.sib1Params.siSchedInfo.winLen;
2305 /* Serving Cell Config Common */
2306 DU_ALLOC(sib1Msg->servingCellConfigCommon, sizeof(ServingCellConfigCommonSIB_t));
2307 if(!sib1Msg->servingCellConfigCommon)
2309 DU_LOG("\nERROR --> DU APP: sib1Msg->servingCellConfigCommon memory allocation failure");
2312 ret1 = BuildServCellCfgCommonSib(sib1Msg->servingCellConfigCommon);
2318 xer_fprint(stdout, &asn_DEF_SIB1, sib1Msg);
2320 /* Encode the F1SetupRequest type as APER */
2321 memset(encBuf, 0, ENC_BUF_MAX_LEN);
2323 encRetVal = aper_encode(&asn_DEF_SIB1, 0, sib1Msg, PrepFinalEncBuf,\
2325 printf("\nencbufSize: %d\n", encBufSize);
2326 if(encRetVal.encoded == -1)
2328 DU_LOG("\nERROR --> DU APP : Could not encode SIB1 structure (at %s)\n",\
2329 encRetVal.failed_type ?
2330 encRetVal.failed_type->name :
2334 for(int i=0; i< encBufSize; i++)
2336 printf("%x\t",encBuf[i]);
2344 FreeSib1Msg(sib1Msg);
2350 /*******************************************************************
2352 * @brief : deallocating the memory of BuildSib1Msg
2356 * Function : FreeFreqInfoDl
2358 * Functionality: Freeing memory of BuildFreqInfoDl
2360 * @params[in] : FrequencyInfoDL_SIB_t *frequencyInfoDL
2363 *******************************************************************/
2364 void FreeFreqInfoDl(FrequencyInfoDL_SIB_t *frequencyInfoDL)
2369 /* Free DL frequency info */
2370 if(!frequencyInfoDL->frequencyBandList.list.array)
2372 /*Free Frequency band indicator */
2373 if(!frequencyInfoDL->frequencyBandList.list.array[idx])
2375 if(!frequencyInfoDL->frequencyBandList.list.array[idx]->\
2376 freqBandIndicatorNR)
2378 if(!frequencyInfoDL->scs_SpecificCarrierList.list.array)
2380 for(idx1 = 0;idx1<frequencyInfoDL->scs_SpecificCarrierList.list.count;idx1++)
2382 if(!frequencyInfoDL->scs_SpecificCarrierList.list.array[idx1])
2384 DU_FREE(frequencyInfoDL->scs_SpecificCarrierList.list.\
2385 array[idx1], sizeof(SCS_SpecificCarrier_t));
2388 DU_FREE(frequencyInfoDL->scs_SpecificCarrierList.list.array,
2389 frequencyInfoDL->scs_SpecificCarrierList.list.size);
2391 DU_FREE(frequencyInfoDL->frequencyBandList.list.\
2392 array[idx]->freqBandIndicatorNR, sizeof(FreqBandIndicatorNR_t));
2395 for(idx = 0; idx <frequencyInfoDL->frequencyBandList.list.count; idx++)
2397 if(!frequencyInfoDL->frequencyBandList.list.array[idx])
2399 DU_FREE(frequencyInfoDL->frequencyBandList.list.array[idx],\
2400 sizeof(NR_MultiBandInfo_t));
2403 DU_FREE(frequencyInfoDL->frequencyBandList.list.array,\
2404 frequencyInfoDL->frequencyBandList.list.size);
2407 /*******************************************************************
2409 * @brief : deallocating the memory of BuildSib1Msg
2413 * Function : FreeCommonSerachSpaceList
2415 * Functionality: deallocating the memory of BuildCommonSerachSpaceList
2417 * @params[in] :struct PDCCH_ConfigCommon__commonSearchSpaceList *searchSpclist
2420 *******************************************************************/
2421 void FreeCommonSerachSpaceList( struct PDCCH_ConfigCommon__commonSearchSpaceList
2425 SearchSpace_t *searchSpace= NULLP;
2427 if(!searchSpclist->list.array)
2429 if( searchSpclist->list.array[idx] != NULLP)
2431 searchSpace= searchSpclist->list.array[idx];
2432 if(!searchSpace->controlResourceSetId)
2434 if(!searchSpace->monitoringSlotPeriodicityAndOffset)
2436 if(!searchSpace->monitoringSymbolsWithinSlot)
2438 if(!searchSpace->monitoringSymbolsWithinSlot->buf)
2440 if(!searchSpace->nrofCandidates)
2442 if(!searchSpace->searchSpaceType)
2444 switch(searchSpace->searchSpaceType->present)
2446 case SearchSpace__searchSpaceType_PR_NOTHING:
2448 case SearchSpace__searchSpaceType_PR_common:
2450 if(!searchSpace->searchSpaceType->choice.common)
2452 if(!searchSpace->searchSpaceType->choice.\
2453 common->dci_Format0_0_AndFormat1_0)
2455 DU_FREE(searchSpace->searchSpaceType->choice.\
2456 common->dci_Format0_0_AndFormat1_0,sizeof(struct\
2457 SearchSpace__searchSpaceType__common__dci_Format0_0_AndFormat1_0));
2459 DU_FREE(searchSpace->searchSpaceType->choice.common,\
2460 sizeof(struct SearchSpace__searchSpaceType__common));
2464 case SearchSpace__searchSpaceType_PR_ue_Specific:
2469 DU_FREE(searchSpace->searchSpaceType,\
2470 sizeof( struct SearchSpace__searchSpaceType));
2472 DU_FREE(searchSpace->nrofCandidates,\
2473 sizeof(struct SearchSpace__nrofCandidates));
2475 DU_FREE(searchSpace->monitoringSymbolsWithinSlot->buf,\
2476 searchSpace->monitoringSymbolsWithinSlot->size);
2478 DU_FREE(searchSpace->monitoringSymbolsWithinSlot,\
2479 sizeof(BIT_STRING_t));
2481 DU_FREE(searchSpace->monitoringSlotPeriodicityAndOffset,\
2482 sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
2484 DU_FREE(searchSpace->controlResourceSetId,sizeof(ControlResourceSetId_t));
2487 for(idx = 0; idx < searchSpclist->list.count; idx++)
2489 if(!searchSpclist->list.array[idx])
2491 DU_FREE(searchSpclist->list.array[idx], sizeof(SearchSpace_t));
2494 DU_FREE(searchSpclist->list.array, searchSpclist->list.size)
2497 /*******************************************************************
2499 * @brief : deallocating the memory of BuildSib1Msg
2503 * Function : FreeBwpDlCommon
2505 * Functionality :Deallocating memory of BuildBwpDlCommon
2507 * @params[in] : BWP_DownlinkCommon_t *bwp
2511 *******************************************************************/
2512 void FreeBwpDlCommon(BWP_DownlinkCommon_t *bwp)
2515 struct BWP_DownlinkCommon__pdsch_ConfigCommon *pdschCfg=bwp->pdsch_ConfigCommon;
2516 struct BWP_DownlinkCommon__pdcch_ConfigCommon *pdcchCfg=bwp->pdcch_ConfigCommon;
2517 pdcchCfg->present=duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdcchCfg.present;
2518 pdschCfg->present=duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdschCfg.present;
2520 if(!bwp->pdcch_ConfigCommon)
2522 if(!bwp->pdsch_ConfigCommon)
2524 switch( pdschCfg->present)
2526 case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_NOTHING:
2531 case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_release:
2536 case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup:
2538 if(!pdschCfg->choice.setup)
2540 if(!pdschCfg->choice.setup->pdsch_TimeDomainAllocationList)
2542 if(!pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array)
2544 if(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx]!= NULLP)
2546 if(!pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx]->k0)
2548 DU_FREE(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx]->k0,\
2552 for(idx=0; idx<pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.count ; idx++)
2554 if(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx]!=
2557 DU_FREE(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx],\
2558 sizeof(PDSCH_TimeDomainResourceAllocation_t));
2561 DU_FREE(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array,\
2562 pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.size);
2564 DU_FREE(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList,\
2565 sizeof(PDSCH_TimeDomainResourceAllocationList_t));
2567 DU_FREE(pdschCfg->choice.setup,
2568 sizeof(PDSCH_ConfigCommon_t));
2574 DU_FREE(bwp->pdsch_ConfigCommon,\
2575 sizeof(struct BWP_DownlinkCommon__pdsch_ConfigCommon));
2578 switch(pdcchCfg->present)
2580 case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_NOTHING:
2585 case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_release:
2590 case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup:
2592 if(!pdcchCfg->choice.setup)
2594 /* Control Resource Set Zero */
2595 if(! pdcchCfg->choice.setup->controlResourceSetZero)
2597 /* Search space zero */
2598 if(! pdcchCfg->choice.setup->searchSpaceZero)
2600 /* Common Search Space List */
2601 if(! pdcchCfg->choice.setup->commonSearchSpaceList)
2603 if(CommonSerachSpaceListret==ROK)
2605 if(!pdcchCfg->choice.setup->searchSpaceSIB1)
2607 if(!pdcchCfg->choice.setup->pagingSearchSpace)
2609 if(!pdcchCfg->choice.setup->ra_SearchSpace)
2611 DU_FREE(pdcchCfg->choice.setup->ra_SearchSpace,
2612 sizeof(SearchSpaceId_t));
2614 DU_FREE( pdcchCfg->choice.setup->pagingSearchSpace,
2615 sizeof(SearchSpaceId_t));
2617 DU_FREE( pdcchCfg->choice.setup->searchSpaceSIB1,
2618 sizeof(SearchSpaceId_t));
2622 FreeCommonSerachSpaceList(pdcchCfg->choice.setup->commonSearchSpaceList);
2624 DU_FREE( pdcchCfg->choice.setup->commonSearchSpaceList,\
2626 PDCCH_ConfigCommon__commonSearchSpaceList));
2628 DU_FREE( pdcchCfg->choice.setup->searchSpaceZero,
2629 sizeof(SearchSpaceZero_t));
2631 DU_FREE( pdcchCfg->choice.setup->controlResourceSetZero,
2632 sizeof(ControlResourceSetZero_t));
2634 DU_FREE(pdcchCfg->choice.setup,
2635 sizeof(PDCCH_ConfigCommon_t));
2642 DU_FREE(bwp->pdcch_ConfigCommon,sizeof(struct BWP_DownlinkCommon__pdcch_ConfigCommon));
2645 /*******************************************************************
2647 * @brief deallocating the memory of BuildSib1Msg
2651 * Function: FreeUlCfgCommSib
2653 * Functionality deallocating the memory of BuildUlCfgCommSib
2655 * @params[in] : UplinkConfigCommonSIB_t *ulCfg
2659 *******************************************************************/
2660 void FreeUlCfgCommSib(UplinkConfigCommonSIB_t *ulCfg)
2663 RACH_ConfigCommon_t *setup;
2664 BWP_UplinkCommon_t *bwp=&ulCfg->initialUplinkBWP;
2665 struct FrequencyInfoUL_SIB__scs_SpecificCarrierList *scsCarrierList;
2666 struct BWP_UplinkCommon__rach_ConfigCommon *rachCfg;
2667 struct BWP_UplinkCommon__pucch_ConfigCommon *pucchCfg;
2668 struct BWP_UplinkCommon__pusch_ConfigCommon *puschCfg;
2669 puschCfg=ulCfg->initialUplinkBWP.pusch_ConfigCommon;
2670 rachCfg =bwp->rach_ConfigCommon;
2671 scsCarrierList = &ulCfg->frequencyInfoUL.scs_SpecificCarrierList;
2673 if(!scsCarrierList->list.array)
2675 if(!ulCfg->frequencyInfoUL.p_Max)
2677 if(FreqInfoUlret == ROK)
2679 if(!bwp->rach_ConfigCommon)
2681 if(RachCfgCommonret== ROK)
2683 if(!bwp->pusch_ConfigCommon)
2686 if(PuschCfgCommonret==ROK)
2688 if(!bwp->pucch_ConfigCommon)
2690 pucchCfg=bwp->pucch_ConfigCommon;
2691 switch(pucchCfg->present)
2693 case BWP_UplinkCommon__pucch_ConfigCommon_PR_NOTHING:
2695 case BWP_UplinkCommon__pucch_ConfigCommon_PR_release:
2697 case BWP_UplinkCommon__pucch_ConfigCommon_PR_setup:
2699 if(!pucchCfg->choice.setup)
2702 if(!pucchCfg->choice.setup->pucch_ResourceCommon)
2704 if(!pucchCfg->choice.setup->p0_nominal)
2706 DU_FREE(pucchCfg->choice.setup->p0_nominal,
2709 DU_FREE(pucchCfg->choice.setup->pucch_ResourceCommon,
2712 DU_FREE(pucchCfg->choice.setup,
2713 sizeof(PUCCH_ConfigCommon_t));
2719 DU_FREE(bwp->pucch_ConfigCommon,\
2720 sizeof(struct BWP_UplinkCommon__pucch_ConfigCommon));
2723 switch(puschCfg->present)
2725 case BWP_UplinkCommon__pusch_ConfigCommon_PR_NOTHING:
2727 case BWP_UplinkCommon__pusch_ConfigCommon_PR_release:
2729 case BWP_UplinkCommon__pusch_ConfigCommon_PR_setup:
2731 if(!puschCfg->choice.setup)
2734 if(! puschCfg->choice.setup->pusch_TimeDomainAllocationList)
2736 if(! puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array)
2738 if(!puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array[idx])
2740 if(!puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array[idx]->k2)
2742 if(! puschCfg->choice.setup->msg3_DeltaPreamble)
2744 if(!puschCfg->choice.setup->p0_NominalWithGrant)
2746 DU_FREE(puschCfg->choice.setup->p0_NominalWithGrant,
2749 DU_FREE(puschCfg->choice.setup->msg3_DeltaPreamble,
2752 DU_FREE(puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.\
2753 array[idx]->k2, sizeof(long));
2757 idx<puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.count;
2760 if(!puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array[idx])
2762 DU_FREE(puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array[idx],\
2763 sizeof(PUSCH_TimeDomainResourceAllocation_t));
2766 DU_FREE(puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array,\
2767 puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.size);
2769 DU_FREE(puschCfg->choice.setup->pusch_TimeDomainAllocationList,\
2770 sizeof(PUSCH_TimeDomainResourceAllocationList_t));
2772 DU_FREE(puschCfg->choice.setup,
2773 sizeof(PUSCH_ConfigCommon_t));
2780 DU_FREE(bwp->pusch_ConfigCommon,\
2781 sizeof(struct BWP_UplinkCommon__pusch_ConfigCommon));
2784 switch(rachCfg->present)
2786 case BWP_UplinkCommon__rach_ConfigCommon_PR_NOTHING:
2788 case BWP_UplinkCommon__rach_ConfigCommon_PR_release:
2790 case BWP_UplinkCommon__rach_ConfigCommon_PR_setup:
2792 if(!rachCfg->choice.setup)
2794 setup = rachCfg->choice.setup;
2795 if(!setup->totalNumberOfRA_Preambles)
2797 if(!setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB)
2799 if(!setup->rsrp_ThresholdSSB)
2801 if(!setup->msg1_SubcarrierSpacing)
2803 DU_FREE(setup->msg1_SubcarrierSpacing,
2804 sizeof(SubcarrierSpacing_t));
2806 DU_FREE(setup->rsrp_ThresholdSSB,
2807 sizeof(RSRP_Range_t));
2809 DU_FREE(setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB,\
2811 RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB));
2813 DU_FREE(setup->totalNumberOfRA_Preambles,
2817 DU_FREE(rachCfg->choice.setup,
2818 sizeof(RACH_ConfigCommon_t));
2824 DU_FREE(bwp->rach_ConfigCommon,\
2825 sizeof(struct BWP_UplinkCommon__rach_ConfigCommon));
2828 DU_FREE(ulCfg->frequencyInfoUL.p_Max, sizeof(P_Max_t));
2830 for(idx = 0; idx < scsCarrierList->list.count; idx++)
2832 if(!scsCarrierList->list.array[idx])
2834 DU_FREE(scsCarrierList->list.array[idx],
2835 sizeof(SCS_SpecificCarrier_t));
2838 DU_FREE(scsCarrierList->list.array, scsCarrierList->list.size);
2841 /*******************************************************************
2843 * @brief : Deallocating memory of SIB1 message
2847 * Function : FreeServCellCfgCommonSib
2849 * Functionality: Deallocating memory of BuildServCellCfgCommonSib
2851 * @params[in] : ServingCellConfigCommonSIB_t *srvCellCfg
2854 *******************************************************************/
2855 void FreeServCellCfgCommonSib(ServingCellConfigCommonSIB_t *srvCellCfg)
2857 BIT_STRING_t *ssbPosInBurst;
2858 ssbPosInBurst = &srvCellCfg->ssb_PositionsInBurst.inOneGroup;
2859 DownlinkConfigCommonSIB_t *dlCfg=&srvCellCfg->downlinkConfigCommon;
2861 if(!ssbPosInBurst->buf)
2863 /* Free DL frequency info */
2864 if(FreqInfoDlret == ROK)
2866 if(DlCfgCommSibret == ROK)
2868 /* Uplink Config Comm */
2869 if(!srvCellCfg->uplinkConfigCommon)
2871 if(UlCfgCommSibret==ROK)
2873 /* TDD UL DL Config Comm */
2874 if(!srvCellCfg->tdd_UL_DL_ConfigurationCommon)
2876 DU_FREE(srvCellCfg->tdd_UL_DL_ConfigurationCommon,
2877 sizeof(TDD_UL_DL_ConfigCommon_t));
2880 FreeUlCfgCommSib(srvCellCfg->uplinkConfigCommon);
2881 DU_FREE(srvCellCfg->uplinkConfigCommon,
2882 sizeof(UplinkConfigCommonSIB_t));
2885 FreeBwpDlCommon(&dlCfg->initialDownlinkBWP);
2887 FreeFreqInfoDl(&dlCfg->frequencyInfoDL);
2888 DU_FREE(ssbPosInBurst->buf, ssbPosInBurst->size * sizeof(uint8_t));
2891 /*******************************************************************
2893 * @brief : Deallcating memory of the function BuildSib1Msg
2897 * Function : FreeSib1Msg
2899 * Functionality: Deallcating memory of the function BuildSib1Msg
2901 * @params[in] ServingCellConfigCommonSIB_t pointer
2904 *******************************************************************/
2905 void FreeSib1Msg(SIB1_t *sib1Msg)
2910 CellIdentity_t *cellIdentity = NULLP;
2911 CellAccessRelatedInfo_t *cellAccessInfo ;
2912 struct PLMN_IdentityInfo__plmn_IdentityList *plmnIdInfo;
2915 if(sib1Msg != NULLP)
2917 cellAccessInfo = &sib1Msg->cellAccessRelatedInfo;
2918 if(cellAccessInfo->plmn_IdentityList.list.array !=NULLP)
2920 if(cellAccessInfo->plmn_IdentityList.list.array[idx]!=NULLP)
2923 &cellAccessInfo->plmn_IdentityList.list.array[idx]->plmn_IdentityList;
2925 if(plmnIdInfo->list.array !=NULLP)
2927 if(!plmnIdInfo->list.array[idx])
2929 if(!plmnIdInfo->list.array[idx]->mcc)
2931 if(!(plmnIdInfo->list.array[idx]->mcc->list.array))
2933 if(!plmnIdInfo->list.array[idx]->mnc.list.array)
2935 /*Free Tracking Area Code */
2936 if(!cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode)
2939 if(!cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode->buf)
2941 /* Free CellIdentity */
2942 if(!cellAccessInfo->plmn_IdentityList.list.array[idx]->ranac)
2945 =&cellAccessInfo->plmn_IdentityList.\
2946 list.array[idx]->cellIdentity;
2947 if(!cellIdentity->buf)
2949 /*Free Connection Establish Failure Control */
2950 if(!sib1Msg->connEstFailureControl)
2952 /*Free Serving Cell Config Common */
2953 if(!sib1Msg->si_SchedulingInfo)
2955 /* Free Serving Cell Config Common* */
2956 if(!sib1Msg->servingCellConfigCommon)
2958 /*Free BuildServCellCfgCommonSib*/
2959 FreeServCellCfgCommonSib(\
2960 sib1Msg->servingCellConfigCommon);
2962 DU_FREE(sib1Msg->servingCellConfigCommon,
2963 sizeof(ServingCellConfigCommonSIB_t));
2966 DU_FREE(sib1Msg->si_SchedulingInfo,
2967 sizeof(SI_SchedulingInfo_t));
2970 DU_FREE(sib1Msg->connEstFailureControl,
2971 sizeof(ConnEstFailureControl_t));
2973 DU_FREE(cellIdentity->buf,cellIdentity->size);
2976 DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx]->ranac, sizeof(RAN_AreaCode_t));
2979 DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode->buf,\
2980 cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode->size);
2983 DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode\
2984 , sizeof(TrackingAreaCode_t));
2987 for(idx2=0; idx2<plmnIdInfo->list.array[idx1]->mnc.list.count; idx2++)
2989 if(!plmnIdInfo->list.array[idx2]->mnc.list.array[idx2])
2991 DU_FREE(plmnIdInfo->list.array[idx2]->mnc.list.array[idx2],
2992 sizeof(MCC_MNC_Digit_t));
2995 DU_FREE(plmnIdInfo->list.array[idx]->mnc.list.array,
2996 plmnIdInfo->list.array[idx1]->mnc.list.size);
2999 for(idx1=0; idx1<plmnIdInfo->list.array[idx]->mcc->list.count; idx1++)
3001 if(plmnIdInfo->list.array[idx]->mcc->list.array[idx1]!=NULLP)
3003 DU_FREE(plmnIdInfo->list.array[idx]->mcc->list.array[idx1],\
3004 sizeof(MCC_MNC_Digit_t));
3008 DU_FREE(plmnIdInfo->list.array[idx]->mcc->list.array,\
3009 plmnIdInfo->list.array[idx]->mcc->list.size)
3011 DU_FREE(plmnIdInfo->list.array[idx]->mcc,sizeof(MCC_t));
3014 for(idx1=0; idx1<plmnIdInfo->list.count; idx1++)
3016 if(!(plmnIdInfo->list.array[idx1]))
3018 DU_FREE(plmnIdInfo->list.array[idx1],
3019 sizeof(PLMN_IdentitY_t));
3022 DU_FREE(plmnIdInfo->list.array, plmnIdInfo->list.size);
3025 for(idx=0; idx<cellAccessInfo->plmn_IdentityList.list.count; idx++)
3027 if(cellAccessInfo->plmn_IdentityList.list.array[idx]!=NULLP)
3029 DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx],
3030 sizeof(PLMN_IdentityInfo_t));
3033 DU_FREE(cellAccessInfo->plmn_IdentityList.list.array,
3034 cellAccessInfo->plmn_IdentityList.list.size);
3036 DU_FREE(sib1Msg, sizeof(SIB1_t));
3041 /**********************************************************************
3043 **********************************************************************/