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 *cellIdentity->buf = duCfgParam.sib1Params.cellIdentity;
345 /*******************************************************************
347 * @brief Builds RANAC within SIB1 message
351 * Function : BuildRanac
353 * Functionality: Building RAN area code in SIB1 message
355 * @params[in] RAN_AreaCode_t **ranAreaCode
356 * @return ROK - success
359 * ****************************************************************/
360 uint8_t BuildRanac(RAN_AreaCode_t **ranAreaCode)
362 RAN_AreaCode_t *ranac;
363 DU_ALLOC(ranac, sizeof(RAN_AreaCode_t));
366 DU_LOG("\nERROR --> DU APP: RANAC memory allocation failure");
369 *ranac = duCfgParam.sib1Params.ranac;
370 *ranAreaCode = ranac;
373 /*******************************************************************
375 * @brief Builds TAC within SIB1 message
379 * Function : BuildTac
381 * Functionality: Building Tracking area code in SIB1 message
383 * @params[in] TrackingAreaCode_t **tac
384 * @return ROK - success
387 * ****************************************************************/
388 uint8_t BuildTac(TrackingAreaCode_t **trackAreaCode)
390 TrackingAreaCode_t *tac;
393 DU_ALLOC(tac, sizeof(TrackingAreaCode_t));
396 DU_LOG("\nERROR --> DU APP: TAC memory allocation failure");
400 tac->size = ODU_VALUE_THREE*sizeof(uint8_t);
401 DU_ALLOC(tac->buf, tac->size);
404 DU_LOG("\nERROR --> DU APP: TAC memory allocation failure");
407 *(tac->buf) = duCfgParam.sib1Params.tac;
408 tac->bits_unused = ODU_VALUE_ZERO;
409 *trackAreaCode = tac;
414 /*******************************************************************
416 * @brief Builds PLMN list within SIB1 message
420 * Function : BuildPlmnList
422 * Functionality: Building PLMN list in SIB1 message
424 * @params[in] CellAccessRelatedInfo_t *cellAccessInfo
425 * @return ROK - success
428 * ****************************************************************/
429 uint8_t BuildPlmnList(CellAccessRelatedInfo_t *cellAccessInfo)
435 TrackingAreaCode_t **tac;
436 RAN_AreaCode_t **ranac;
437 CellIdentity_t *cellIdentity;
439 struct PLMN_IdentityInfo__plmn_IdentityList
442 DU_ALLOC(cellAccessInfo->plmn_IdentityList.list.array,
443 cellAccessInfo->plmn_IdentityList.list.size);
444 if(!cellAccessInfo->plmn_IdentityList.list.array)
446 DU_LOG("\nERROR --> DU APP: BuildPlmnList memory allocation failure");
449 elementCnt = cellAccessInfo->plmn_IdentityList.list.count;
450 for(idx=0; idx<elementCnt; idx++)
452 DU_ALLOC(cellAccessInfo->plmn_IdentityList.list.array[idx],
453 sizeof(PLMN_IdentityInfo_t));
454 if(!cellAccessInfo->plmn_IdentityList.list.array[idx])
456 DU_LOG("\nERROR --> DU APP: BuildPlmnList memory allocation failure");
463 elementCnt = ODU_VALUE_ONE;
465 plmnIdInfo = &cellAccessInfo->plmn_IdentityList.list.array[idx]->\
467 plmnIdInfo->list.count = elementCnt;
468 plmnIdInfo->list.size = elementCnt * sizeof(PLMN_IdentitY_t *);
469 DU_ALLOC(plmnIdInfo->list.array, plmnIdInfo->list.size);
470 if(!plmnIdInfo->list.array)
472 DU_LOG("\nERROR --> DU APP: BuildPlmnList memory allocation failure");
476 for(idx1=0; idx1<elementCnt; idx1++)
478 DU_ALLOC(plmnIdInfo->list.array[idx1],
479 sizeof(PLMN_IdentitY_t));
480 if(!(plmnIdInfo->list.array[idx1]))
482 DU_LOG("\nERROR --> DU APP: BuildPlmnList memory allocation failure");
487 DU_ALLOC(plmnIdInfo->list.array[idx1]->mcc,
489 if(!plmnIdInfo->list.array[idx1]->mcc)
491 DU_LOG("\nERROR --> DU APP: BuildPlmnList memory allocation failure");
495 elementCnt = ODU_VALUE_THREE;
496 plmnIdInfo->list.array[idx1]->mcc->list.count = elementCnt;
497 plmnIdInfo->list.array[idx1]->mcc->list.size =\
498 elementCnt * sizeof(MCC_MNC_Digit_t *);
499 DU_ALLOC(plmnIdInfo->list.array[idx1]->mcc->list.array,
500 plmnIdInfo->list.array[idx1]->mcc->list.size)
501 if(!(plmnIdInfo->list.array[idx1]->mcc->list.array))
503 DU_LOG("\nERROR --> DU APP: BuildPlmnList memory allocation failure");
506 for(idx2=0; idx2<elementCnt; idx2++)
508 DU_ALLOC(plmnIdInfo->list.array[idx1]->mcc->list.array[idx2],
509 sizeof(MCC_MNC_Digit_t));
510 if(!plmnIdInfo->list.array[idx1]->mcc->list.array[idx2])
512 DU_LOG("\nERROR --> DU APP: BuildPlmnList memory allocation failure");
515 *(plmnIdInfo->list.array[idx1]->mcc->list.array[idx2])=\
516 duCfgParam.sib1Params.plmn.mcc[idx2];
519 plmnIdInfo->list.array[idx1]->mnc.list.count = elementCnt;
520 plmnIdInfo->list.array[idx1]->mnc.list.size =\
521 elementCnt * sizeof(MCC_MNC_Digit_t *);
522 DU_ALLOC(plmnIdInfo->list.array[idx1]->mnc.list.array,\
523 plmnIdInfo->list.array[idx1]->mnc.list.size);
524 if(!plmnIdInfo->list.array[idx1]->mnc.list.array)
526 DU_LOG("\nERROR --> DU APP: BuildPlmnList memory allocation failure");
529 for(idx2=0; idx2<elementCnt; idx2++)
531 DU_ALLOC(plmnIdInfo->list.array[idx1]->mnc.list.array[idx2],
532 sizeof(MCC_MNC_Digit_t));
533 if(!plmnIdInfo->list.array[idx1]->mnc.list.array[idx2])
535 DU_LOG("\nERROR --> DU APP: BuildPlmnList memory allocation failure");
538 *(plmnIdInfo->list.array[idx1]->mnc.list.array[idx2])=\
539 duCfgParam.sib1Params.plmn.mnc[idx2];
542 /* Tracking Area Code */
543 tac = &cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode;
551 ranac = &cellAccessInfo->plmn_IdentityList.list.array[idx]->ranac;
552 ret=BuildRanac(ranac);
559 cellIdentity = &cellAccessInfo->plmn_IdentityList.list.array[idx]->cellIdentity;
560 ret=BuildCellIdentity(cellIdentity);
566 /* cellReservedForOperatorUse */
567 cellAccessInfo->plmn_IdentityList.list.array[idx]->\
568 cellReservedForOperatorUse = duCfgParam.sib1Params.cellResvdForOpUse;
574 /*******************************************************************
576 * @brief Build SIB Map Info List
580 * Function : BuildSibMapInfoList
583 * Build SIB MapInfo List
585 * @params[in] SIB_Mapping_t pointer
586 * @return ROK - success
589 * ****************************************************************/
590 uint8_t BuildSibMapInfoList(SIB_Mapping_t *sibMapInfo)
592 uint8_t itr; /* List iterator */
593 uint8_t elementCnt; /* Number of elements in list */
594 SIB_TypeInfo_t *sibTypeInfo; /* Scheduling info */
596 /* SI scheduling info list */
597 DU_ALLOC(sibMapInfo->list.array, sibMapInfo->list.size);
598 if(!sibMapInfo->list.array)
600 DU_LOG("\nERROR --> DU APP: BuildSibMapInfoList memory allocation failure");
604 elementCnt = sibMapInfo->list.count;
605 for(itr = 0; itr < elementCnt; itr++)
607 DU_ALLOC(sibMapInfo->list.array[itr], sizeof(SIB_TypeInfo_t));
608 if(!sibMapInfo->list.array[itr])
610 DU_LOG("\nERROR --> DU APP: BuildSibMapInfoList memory allocation failure");
616 sibTypeInfo = sibMapInfo->list.array[itr];
617 sibTypeInfo->type = duCfgParam.sib1Params.siSchedInfo.sibType;
618 DU_ALLOC(sibTypeInfo->valueTag, sizeof(long));
619 if(!sibTypeInfo->valueTag)
621 DU_LOG("\nERROR --> DU APP: BuildSibMapInfoList memory allocation failure");
625 *sibTypeInfo->valueTag = duCfgParam.sib1Params.siSchedInfo.sibValTag;
630 /*******************************************************************
632 * @brief Builds SI Scheduling info list within SIB1 message
636 * Function : BuildSiSchedInfoList
639 * Building SI Scheduling info list in SIB1 message
641 * @params[in] struct SI_SchedulingInfo__schedulingInfoList *si_SchedulingInfo
642 * @return ROK - success
645 * ****************************************************************/
646 uint8_t BuildSiSchedInfoList(struct SI_SchedulingInfo__schedulingInfoList *si_SchedulingInfoList)
648 uint8_t itr; /* List iterator */
649 uint8_t elementCnt; /* Number of elements in list */
651 SchedulingInfo_t *schedInfo; /* Scheduling info */
653 /* SI scheduling info list */
654 DU_ALLOC(si_SchedulingInfoList->list.array, si_SchedulingInfoList->list.size);
655 if(!si_SchedulingInfoList->list.array)
657 DU_LOG("\nERROR --> DU APP: BuildSiSchedInfoList memory allocation failure");
661 elementCnt = si_SchedulingInfoList->list.count;
662 for(itr = 0; itr < elementCnt; itr++)
664 DU_ALLOC(si_SchedulingInfoList->list.array[itr], sizeof(struct SchedulingInfo));
665 if(!si_SchedulingInfoList->list.array[itr])
667 DU_LOG("\nERROR --> DU APP: BuildSiSchedInfoList memory allocation failure");
673 schedInfo = si_SchedulingInfoList->list.array[itr];
674 schedInfo->si_BroadcastStatus = duCfgParam.sib1Params.siSchedInfo.broadcastSta;
675 schedInfo->si_Periodicity = duCfgParam.sib1Params.siSchedInfo.preiodicity;
677 elementCnt = ODU_VALUE_ONE;
678 schedInfo->sib_MappingInfo.list.count = elementCnt;
679 schedInfo->sib_MappingInfo.list.size = elementCnt * sizeof(SIB_TypeInfo_t *);
681 ret = BuildSibMapInfoList(&schedInfo->sib_MappingInfo);
690 /*******************************************************************
692 * @brief Builds SCS Specific carrier list for DL
696 * Function : BuildScsSpecificCarrierListDl
699 * Builds Subcarrier specific carrier list for downlink
701 * @params[in] FrequencyInfoDL_SIB__scs_SpecificCarrierList pointer
702 * @return ROK - success
705 * ****************************************************************/
706 uint8_t BuildScsSpecificCarrierListDl( struct FrequencyInfoDL_SIB__scs_SpecificCarrierList *scsCarrierList)
709 ScsSpecCarrier duScsSpecCarrier;
711 duScsSpecCarrier = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.dlScsCarrier;
713 DU_ALLOC(scsCarrierList->list.array, scsCarrierList->list.size);
714 if(!scsCarrierList->list.array)
716 DU_LOG("\nERROR --> DU APP : SCS Specific Carrier list memory allocation failed");
720 for(idx = 0; idx < scsCarrierList->list.count; idx++)
722 DU_ALLOC(scsCarrierList->list.array[idx], sizeof(SCS_SpecificCarrier_t));
723 if(!scsCarrierList->list.array[idx])
725 DU_LOG("\nERROR --> DU APP : SCS Specific Carrier list memory allocation failed");
731 scsCarrierList->list.array[idx]->offsetToCarrier = duScsSpecCarrier.scsOffset;
732 scsCarrierList->list.array[idx]->subcarrierSpacing = duScsSpecCarrier.scs;
733 scsCarrierList->list.array[idx]->carrierBandwidth = duScsSpecCarrier.scsBw;
736 } /* End of BuildScsSpecificCarrierListDl */
738 /*******************************************************************
740 * @brief Builds common search space list
744 * Function : BuildCommonSerachSpaceList
747 * Builds common search space list
749 * @params[in] PDCCH_ConfigCommon__commonSearchSpaceList pointer
750 * @return ROK - success
753 * ****************************************************************/
754 uint8_t BuildCommonSerachSpaceList( struct PDCCH_ConfigCommon__commonSearchSpaceList *searchSpclist)
757 SearchSpace_t *searchSpace;
758 PdcchCfgCommon duPdcchCfg;
760 duPdcchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdcchCfg;
762 DU_ALLOC(searchSpclist->list.array, searchSpclist->list.size)
763 if(!searchSpclist->list.array)
765 DU_LOG("\nERROR --> DU APP : Common search space list memory alloc failed");
769 for(idx = 0; idx < searchSpclist->list.count; idx++)
771 DU_ALLOC(searchSpclist->list.array[idx], sizeof(SearchSpace_t));
772 if(!searchSpclist->list.array[idx])
774 DU_LOG("\nERROR --> DU APP : Common search space list memory alloc failed");
780 searchSpace = searchSpclist->list.array[idx];
782 /* Search Space id */
783 searchSpace->searchSpaceId = duPdcchCfg.searchSpcId;
785 /* Control Resource Set Id */
786 DU_ALLOC(searchSpace->controlResourceSetId, sizeof(ControlResourceSetId_t));
787 if(!searchSpace->controlResourceSetId)
789 DU_LOG("\nERROR --> DU APP : Common search space list memory alloc failed");
792 *searchSpace->controlResourceSetId = duPdcchCfg.ctrlRsrcSetId;
794 /* Monitoring Slot periodicity and offset */
795 DU_ALLOC(searchSpace->monitoringSlotPeriodicityAndOffset,\
796 sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
797 if(!searchSpace->monitoringSlotPeriodicityAndOffset)
799 DU_LOG("\nERROR --> DU APP : Common search space list memory alloc failed");
802 searchSpace->monitoringSlotPeriodicityAndOffset->present = \
803 duPdcchCfg.monitorSlotPrdAndOffPresent;
804 switch(searchSpace->monitoringSlotPeriodicityAndOffset->present)
806 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1:
808 //searchSpace->monitoringSlotPeriodicityAndOffset->choice.s11 = duPdcchCfg.monitorSlotPrdAndOff;
811 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2:
816 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl4:
821 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl5:
826 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl8:
831 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl10:
836 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl16:
841 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl20:
846 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl40:
851 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl80:
856 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl160:
861 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl320:
866 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl640:
871 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1280:
876 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2560:
883 DU_LOG("\nERROR --> DU APP : Invalid value:Montoring slot periodicity and offset");
888 /* Monitoring Symbols Within Slot */
889 DU_ALLOC(searchSpace->monitoringSymbolsWithinSlot,\
890 sizeof(BIT_STRING_t));
891 if(!searchSpace->monitoringSymbolsWithinSlot)
893 DU_LOG("\nERROR --> DU APP : Common search space list memory alloc failed");
896 searchSpace->monitoringSymbolsWithinSlot->size = 2*sizeof(uint8_t);
897 DU_ALLOC(searchSpace->monitoringSymbolsWithinSlot->buf, \
898 searchSpace->monitoringSymbolsWithinSlot->size );
899 if(!searchSpace->monitoringSymbolsWithinSlot->buf)
901 DU_LOG("\nERROR --> DU APP : Common search space list memory alloc failed");
904 searchSpace->monitoringSymbolsWithinSlot->buf[0] = duPdcchCfg.monitorSymbolsInSlot[0];
905 searchSpace->monitoringSymbolsWithinSlot->buf[1] = duPdcchCfg.monitorSymbolsInSlot[1];
906 searchSpace->monitoringSymbolsWithinSlot->bits_unused = 2;
908 /* Number of candidates per aggregation level */
909 DU_ALLOC(searchSpace->nrofCandidates,\
910 sizeof(struct SearchSpace__nrofCandidates));
911 if(!searchSpace->nrofCandidates)
913 DU_LOG("\nERROR --> DU APP : Common search space list memory alloc failed");
916 searchSpace->nrofCandidates->aggregationLevel1 = duPdcchCfg.numCandAggLvl1;
917 searchSpace->nrofCandidates->aggregationLevel2 = duPdcchCfg.numCandAggLvl2;
918 searchSpace->nrofCandidates->aggregationLevel4 = duPdcchCfg.numCandAggLvl4;
919 searchSpace->nrofCandidates->aggregationLevel8 = duPdcchCfg.numCandAggLvl8;
920 searchSpace->nrofCandidates->aggregationLevel16 = duPdcchCfg.numCandAggLvl16;
922 /* Search Space type and DCI Format */
923 DU_ALLOC(searchSpace->searchSpaceType,\
924 sizeof( struct SearchSpace__searchSpaceType));
925 if(!searchSpace->searchSpaceType)
927 DU_LOG("\nERROR --> DU APP : Common search space list memory alloc failed");
931 searchSpace->searchSpaceType->present = duPdcchCfg.searchSpcType;
932 switch(searchSpace->searchSpaceType->present)
934 case SearchSpace__searchSpaceType_PR_NOTHING:
939 case SearchSpace__searchSpaceType_PR_common:
941 DU_ALLOC(searchSpace->searchSpaceType->choice.common, sizeof(struct SearchSpace__searchSpaceType__common));
942 if(!searchSpace->searchSpaceType->choice.common)
944 DU_LOG("\nERROR --> DU APP : Common search space list memory alloc failed");
948 DU_ALLOC(searchSpace->searchSpaceType->choice.common->\
949 dci_Format0_0_AndFormat1_0, sizeof(struct \
950 SearchSpace__searchSpaceType__common__dci_Format0_0_AndFormat1_0));
951 if(!searchSpace->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0)
953 DU_LOG("\nERROR --> DU APP : Common search space list memory alloc failed");
958 case SearchSpace__searchSpaceType_PR_ue_Specific:
964 DU_LOG("\nERROR --> DU_APP: Invalid Search Space type");
970 }/* BuildCommonSerachSpaceList */
972 /*******************************************************************
974 * @brief Builds PDCCH configuration common
978 * Function : BuildPdcchCfgCommon
981 * Builds PDCCH configuration common
983 * @params[in] BWP_DownlinkCommon__pdcch_ConfigCommon pointer
984 * @return ROK - success
987 * ****************************************************************/
988 uint8_t BuildPdcchCfgCommon(struct BWP_DownlinkCommon__pdcch_ConfigCommon *pdcchCfg)
992 PdcchCfgCommon duPdcchCfg;
993 PDCCH_ConfigCommon_t *pdcchSetup;
995 duPdcchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdcchCfg;
997 pdcchCfg->present = duPdcchCfg.present;
999 switch(pdcchCfg->present)
1001 case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_NOTHING:
1006 case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_release:
1011 case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup:
1013 DU_ALLOC(pdcchCfg->choice.setup, sizeof(PDCCH_ConfigCommon_t));
1014 if(!pdcchCfg->choice.setup)
1016 DU_LOG("\nERROR --> DU APP : PDCCH Config memory alloc failed");
1019 pdcchSetup = pdcchCfg->choice.setup;
1021 /* Control Resource Set Zero */
1022 DU_ALLOC(pdcchSetup->controlResourceSetZero, sizeof(ControlResourceSetZero_t));
1023 if(!pdcchSetup->controlResourceSetZero)
1025 DU_LOG("\nERROR --> DU APP : PDCCH Config memory alloc failed");
1028 *pdcchSetup->controlResourceSetZero = duPdcchCfg.ctrlRsrcSetZero;
1030 /* Search space zero */
1031 DU_ALLOC(pdcchSetup->searchSpaceZero, sizeof(SearchSpaceZero_t));
1032 if(!pdcchSetup->searchSpaceZero)
1034 DU_LOG("\nERROR --> DU APP : PDCCH Config memory alloc failed");
1037 *pdcchSetup->searchSpaceZero = duPdcchCfg.searchSpcZero;
1039 /* Common Search Space List */
1040 DU_ALLOC(pdcchSetup->commonSearchSpaceList,\
1041 sizeof(struct PDCCH_ConfigCommon__commonSearchSpaceList));
1042 if(!pdcchSetup->commonSearchSpaceList)
1044 DU_LOG("\nERROR --> DU APP : PDCCH Config memory alloc failed");
1047 elementCnt = ODU_VALUE_ONE;
1048 pdcchSetup->commonSearchSpaceList->list.count = elementCnt;
1049 pdcchSetup->commonSearchSpaceList->list.size = elementCnt * sizeof(SearchSpace_t *);
1050 ret = BuildCommonSerachSpaceList(pdcchSetup->commonSearchSpaceList);
1055 CommonSerachSpaceListret=ROK;
1057 /* Search Space for SIB1 */
1058 DU_ALLOC(pdcchSetup->searchSpaceSIB1, sizeof(SearchSpaceId_t));
1059 if(!pdcchSetup->searchSpaceSIB1)
1061 DU_LOG("\nERROR --> DU APP : PDCCH Config memory alloc failed");
1064 *pdcchSetup->searchSpaceSIB1 = duPdcchCfg.searchSpcSib1;
1066 /* Serach Space for Paging */
1067 DU_ALLOC(pdcchSetup->pagingSearchSpace, sizeof(SearchSpaceId_t));
1068 if(!pdcchSetup->pagingSearchSpace)
1070 DU_LOG("\nERROR --> DU APP : PDCCH Config memory alloc failed");
1073 *pdcchSetup->pagingSearchSpace = duPdcchCfg.pagingSearchSpc;
1075 /* Search space for Random Access */
1076 DU_ALLOC(pdcchSetup->ra_SearchSpace, sizeof(SearchSpaceId_t));
1077 if(!pdcchSetup->ra_SearchSpace)
1079 DU_LOG("\nERROR --> DU APP : PDCCH Config memory alloc failed");
1082 *pdcchSetup->ra_SearchSpace = duPdcchCfg.raSearchSpc;
1088 DU_LOG("\nERROR --> DU APP : Invalid PDCCH Config type");
1094 } /* BuildPdcchCfgCommon */
1096 /*******************************************************************
1098 * @brief Builds PDSCH configuration common
1102 * Function : BuildPdschCfgCommon
1105 * Builds PDSCH configuration common
1107 * @params[in] BWP_DownlinkCommon__pdsch_ConfigCommon pointer
1108 * @return ROK - success
1111 * ****************************************************************/
1112 uint8_t BuildPdschCfgCommon(struct BWP_DownlinkCommon__pdsch_ConfigCommon *pdschCfg)
1116 PdschCfgCommon duPdschCfg;
1117 PDSCH_ConfigCommon_t *pdschSetup;
1118 PDSCH_TimeDomainResourceAllocation_t *timeDomRsrcAllocInfo;
1120 duPdschCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdschCfg;
1122 pdschCfg->present = duPdschCfg.present;
1124 switch(pdschCfg->present)
1126 case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_NOTHING:
1131 case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_release:
1136 case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup:
1138 DU_ALLOC(pdschCfg->choice.setup, sizeof(PDSCH_ConfigCommon_t));
1139 if(!pdschCfg->choice.setup)
1141 DU_LOG("\nERROR --> DU APP : PDCCH Config memory alloc failed");
1144 pdschSetup = pdschCfg->choice.setup;
1146 /* Time Domain Allocation List */
1147 DU_ALLOC(pdschSetup->pdsch_TimeDomainAllocationList, \
1148 sizeof(PDSCH_TimeDomainResourceAllocationList_t));
1149 if(!pdschSetup->pdsch_TimeDomainAllocationList)
1151 DU_LOG("\nERROR --> DU APP : PDCCH Config memory alloc failed");
1154 elementCnt = ODU_VALUE_ONE;
1155 pdschSetup->pdsch_TimeDomainAllocationList->list.count = elementCnt;
1156 pdschSetup->pdsch_TimeDomainAllocationList->list.size = elementCnt * sizeof(PDSCH_TimeDomainResourceAllocation_t *);
1158 DU_ALLOC(pdschSetup->pdsch_TimeDomainAllocationList->list.array,\
1159 pdschSetup->pdsch_TimeDomainAllocationList->list.size);
1160 if(!pdschSetup->pdsch_TimeDomainAllocationList->list.array)
1162 DU_LOG("\nERROR --> DU APP : PDCCH Config memory alloc failed");
1166 for(idx=0; idx<elementCnt; idx++)
1168 DU_ALLOC(pdschSetup->pdsch_TimeDomainAllocationList->list.array[idx],\
1169 sizeof(PDSCH_TimeDomainResourceAllocation_t));
1170 if(!pdschSetup->pdsch_TimeDomainAllocationList->list.array[idx])
1172 DU_LOG("\nERROR --> DU APP : PDCCH Config memory alloc failed");
1178 timeDomRsrcAllocInfo = pdschSetup->pdsch_TimeDomainAllocationList->list.array[idx];
1181 DU_ALLOC(timeDomRsrcAllocInfo->k0, sizeof(long));
1182 if(!timeDomRsrcAllocInfo->k0)
1184 DU_LOG("\nERROR --> DU APP : PDCCH Config memory alloc failed");
1187 *timeDomRsrcAllocInfo->k0 = duPdschCfg.k0;
1189 timeDomRsrcAllocInfo->mappingType = duPdschCfg.mapType;
1190 timeDomRsrcAllocInfo->startSymbolAndLength = duPdschCfg.sliv;
1196 DU_LOG("\nERROR --> DU APP: Invalid PDSCH Configuration type");
1202 }/* BuildPdschCfgCommon */
1204 /*******************************************************************
1206 * @brief Builds DL BWP common
1210 * Function : BuildBwpDlCommon
1213 * Builds DL BWP common
1215 * @params[in] BWP_DownlinkCommon_t pointer
1216 * @return ROK - success
1219 * ****************************************************************/
1220 uint8_t BuildBwpDlCommon(BWP_DownlinkCommon_t *bwp)
1223 DlCfgCommon duDlCfg;
1225 duDlCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg;
1227 bwp->genericParameters.locationAndBandwidth = duDlCfg.locAndBw;
1228 bwp->genericParameters.subcarrierSpacing = duDlCfg.dlScsCarrier.scs;
1230 /* PDCCH Config Common */
1231 DU_ALLOC(bwp->pdcch_ConfigCommon, \
1232 sizeof(struct BWP_DownlinkCommon__pdcch_ConfigCommon));
1233 if(!bwp->pdcch_ConfigCommon)
1235 DU_LOG("\nERROR --> DU APP : DL BWP memory allocation failed");
1238 ret=BuildPdcchCfgCommon(bwp->pdcch_ConfigCommon);
1243 /* PDSCH Config Common */
1244 DU_ALLOC(bwp->pdsch_ConfigCommon, \
1245 sizeof(struct BWP_DownlinkCommon__pdsch_ConfigCommon));
1246 if(!bwp->pdsch_ConfigCommon)
1248 DU_LOG("\nERROR --> DU APP : DL BWP memory allocation failed");
1251 ret=BuildPdschCfgCommon(bwp->pdsch_ConfigCommon);
1257 } /* BuildBwpDlCommon */
1259 /*******************************************************************
1261 * @brief Build BCCH configuration
1265 * Function : BuildBcchConfig
1268 * Build BCCH configuration
1270 * @params[in] BCCH_Config_t pointer
1271 * @return ROK - success
1274 * ****************************************************************/
1276 uint8_t BuildBcchConfig(BCCH_Config_t *bcchCfg)
1280 duBcchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.bcchCfg;
1282 bcchCfg->modificationPeriodCoeff = duBcchCfg.modPrdCoeff;
1285 }/* BuildBcchConfig */
1287 /*******************************************************************
1289 * @brief Builds PCCH configuration
1293 * Function : BuildPcchConfig
1296 * Builds PCCH configuration
1299 * @return ROK - success
1302 * ****************************************************************/
1303 uint8_t BuildPcchConfig(PCCH_Config_t *pcchCfg)
1307 duPcchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pcchCfg;
1309 pcchCfg->defaultPagingCycle = duPcchCfg.dfltPagingCycle;
1310 pcchCfg->nAndPagingFrameOffset.present = duPcchCfg.nAndPagingFrmOffPresent;
1311 switch(pcchCfg->nAndPagingFrameOffset.present)
1313 case PCCH_Config__nAndPagingFrameOffset_PR_NOTHING:
1318 case PCCH_Config__nAndPagingFrameOffset_PR_oneT:
1323 case PCCH_Config__nAndPagingFrameOffset_PR_halfT:
1328 case PCCH_Config__nAndPagingFrameOffset_PR_quarterT:
1333 case PCCH_Config__nAndPagingFrameOffset_PR_oneEighthT:
1338 case PCCH_Config__nAndPagingFrameOffset_PR_oneSixteenthT:
1345 DU_LOG("\nERROR --> DU APP : Invalid nAndPagingFrameOffset configuration");
1349 pcchCfg->ns = duPcchCfg.numPagingOcc;
1352 }/* BuildPcchConfig */
1354 /*******************************************************************
1356 * @brief Builds Frequency Info for Downlink
1360 * Function : BuildFreqInfoDl
1363 * Builds Frequency Info for Downlink
1366 * @return ROK - success
1369 * ****************************************************************/
1371 uint8_t BuildFreqInfoDl(FrequencyInfoDL_SIB_t *frequencyInfoDL)
1377 NR_MultiBandInfo_t *multiBandInfo;
1379 dlCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg;
1381 /* NR Multi-Band Info */
1382 elementCnt = ODU_VALUE_ONE;
1383 frequencyInfoDL->frequencyBandList.list.count = elementCnt;
1384 frequencyInfoDL->frequencyBandList.list.size = \
1385 elementCnt * sizeof(NR_MultiBandInfo_t *);
1387 DU_ALLOC(frequencyInfoDL->frequencyBandList.list.array, \
1388 frequencyInfoDL->frequencyBandList.list.size);
1389 if(!frequencyInfoDL->frequencyBandList.list.array)
1391 DU_LOG("\nERROR --> DU APP : SIB1 DL Configuration memory allocation failed");
1395 for(idx = 0; idx < elementCnt; idx++)
1397 DU_ALLOC(frequencyInfoDL->frequencyBandList.list.array[idx],\
1398 sizeof(NR_MultiBandInfo_t));
1399 if(!frequencyInfoDL->frequencyBandList.list.array[idx])
1401 DU_LOG("\nERROR --> DU APP : SIB1 DL Configuration memory allocation failed");
1407 multiBandInfo = frequencyInfoDL->frequencyBandList.list.array[idx];
1409 /* Frequency band indicator */
1410 DU_ALLOC(multiBandInfo->freqBandIndicatorNR, sizeof(FreqBandIndicatorNR_t));
1411 if(!multiBandInfo->freqBandIndicatorNR)
1413 DU_LOG("\nERROR --> DU APP : SIB1 DL Configuration memory allocation failed");
1416 *multiBandInfo->freqBandIndicatorNR = dlCfg.freqBandInd;
1418 /* Offset to Point A */
1419 frequencyInfoDL->offsetToPointA = dlCfg.offsetToPointA;
1421 /* Subcarrier Spacing specifc carrier */
1422 elementCnt = ODU_VALUE_ONE;
1423 frequencyInfoDL->scs_SpecificCarrierList.list.count = elementCnt;
1424 frequencyInfoDL->scs_SpecificCarrierList.list.size = \
1425 elementCnt * sizeof(SCS_SpecificCarrier_t *);
1426 ret= BuildScsSpecificCarrierListDl(&frequencyInfoDL->scs_SpecificCarrierList);
1433 }/* BuildFreqInfoDl */
1435 /*******************************************************************
1437 * @brief Builds DL configuration common for SIB
1441 * Function : BuildDlCfgCommSib
1444 * Builds DL configuration common for SIB
1446 * @params[in] DownlinkConfigCommonSIB_t pointer
1447 * @return ROK - success
1450 * ****************************************************************/
1452 uint8_t BuildDlCfgCommSib(DownlinkConfigCommonSIB_t *dlCfg)
1454 /* DL frequency info */
1456 ret = BuildFreqInfoDl(&dlCfg->frequencyInfoDL);
1462 /* BWP Downlink Common */
1463 ret = BuildBwpDlCommon(&dlCfg->initialDownlinkBWP);
1469 ret = BuildBcchConfig(&dlCfg->bcch_Config);
1475 ret = BuildPcchConfig(&dlCfg->pcch_Config);
1481 } /* BuildDlCfgCommSib */
1483 /*******************************************************************
1485 * @brief Builds SCS specific carrier list for UL
1489 * Function : BuildScsSpecificCarrierListUl
1492 * Builds SCS specific carrier list for UL
1495 * @return ROK - success
1498 * ****************************************************************/
1500 uint8_t BuildScsSpecificCarrierListUl
1502 struct FrequencyInfoUL_SIB__scs_SpecificCarrierList *scsCarrierList
1506 ScsSpecCarrier duScsSpecCarrier;
1508 duScsSpecCarrier = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.ulScsCarrier;
1510 DU_ALLOC(scsCarrierList->list.array, scsCarrierList->list.size);
1511 if(!scsCarrierList->list.array)
1513 DU_LOG("\nERROR --> DU APP : SCS Specific Carrier list memory allocation failed");
1517 for(idx = 0; idx < scsCarrierList->list.count; idx++)
1519 DU_ALLOC(scsCarrierList->list.array[idx], sizeof(SCS_SpecificCarrier_t));
1520 if(!scsCarrierList->list.array[idx])
1522 DU_LOG("\nERROR --> DU APP : SCS Specific Carrier list memory allocation failed");
1527 scsCarrierList->list.array[idx]->offsetToCarrier = duScsSpecCarrier.scsOffset;
1528 scsCarrierList->list.array[idx]->subcarrierSpacing = duScsSpecCarrier.scs;
1529 scsCarrierList->list.array[idx]->carrierBandwidth = duScsSpecCarrier.scsBw;
1532 } /* End of BuildScsSpecificCarrierListUl */
1534 /*******************************************************************
1536 * @brief Builds frequency infor for UL
1540 * Function : BuildFreqInfoUl
1543 * Builds frequency infor for UL
1545 * @params[in] FrequencyInfoUL_SIB_t pointer
1546 * @return ROK - success
1549 * ****************************************************************/
1551 uint8_t BuildFreqInfoUl(FrequencyInfoUL_SIB_t *frequencyInfoUL)
1556 ulCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg;
1558 /* Subcarrier Spacing specifc carrier */
1559 elementCnt = ODU_VALUE_ONE;
1560 frequencyInfoUL->scs_SpecificCarrierList.list.count = elementCnt;
1561 frequencyInfoUL->scs_SpecificCarrierList.list.size = \
1562 elementCnt * sizeof(SCS_SpecificCarrier_t *);
1563 ret=BuildScsSpecificCarrierListUl(&frequencyInfoUL->scs_SpecificCarrierList);
1569 DU_ALLOC(frequencyInfoUL->p_Max, sizeof(P_Max_t));
1570 if(!frequencyInfoUL->p_Max)
1572 DU_LOG("\nERROR --> DU APP : UL Frequency Infoo memory allocation failure");
1575 *frequencyInfoUL->p_Max = ulCfg.pMax;
1578 }/* BuildFreqInfoUl */
1580 /*******************************************************************
1582 * @brief Builds RACH configuration common
1586 * Function : BuildRachCfgCommon
1589 * Builds RACH configuration common
1591 * @params[in] BWP_UplinkCommon__rach_ConfigCommon pointer
1592 * @return ROK - success
1595 * ****************************************************************/
1597 uint8_t BuildRachCfgCommon(struct BWP_UplinkCommon__rach_ConfigCommon *rachCfg)
1599 RachCfgCommon duRachCfg;
1600 RACH_ConfigCommon_t *setup;
1602 duRachCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.rachCfg;
1604 rachCfg->present = duRachCfg.present;
1605 switch(rachCfg->present)
1607 case BWP_UplinkCommon__rach_ConfigCommon_PR_NOTHING:
1612 case BWP_UplinkCommon__rach_ConfigCommon_PR_release:
1617 case BWP_UplinkCommon__rach_ConfigCommon_PR_setup:
1619 DU_ALLOC(rachCfg->choice.setup, sizeof(RACH_ConfigCommon_t));
1620 if(!rachCfg->choice.setup)
1622 DU_LOG("\nERROR --> DU APP : Rach Config memory alloc failed");
1625 setup = rachCfg->choice.setup;
1627 /* Generic RACH Configuration */
1628 setup->rach_ConfigGeneric.prach_ConfigurationIndex = duRachCfg.prachCfgIdx;
1629 setup->rach_ConfigGeneric.msg1_FDM = duRachCfg.msg1Fdm;
1630 setup->rach_ConfigGeneric.msg1_FrequencyStart = duRachCfg.msg1FreqStart;
1631 setup->rach_ConfigGeneric.zeroCorrelationZoneConfig = duRachCfg.zeroCorrZoneCfg;
1632 setup->rach_ConfigGeneric.preambleReceivedTargetPower = duRachCfg.preambleRcvdTgtPwr;
1633 setup->rach_ConfigGeneric.preambleTransMax = duRachCfg.preambleTransMax;
1634 setup->rach_ConfigGeneric.powerRampingStep = duRachCfg.pwrRampingStep;
1635 setup->rach_ConfigGeneric.ra_ResponseWindow = duRachCfg.raRspWindow;
1637 /* Total number of RA preambles */
1638 DU_ALLOC(setup->totalNumberOfRA_Preambles, sizeof(long));
1639 if(!setup->totalNumberOfRA_Preambles)
1641 DU_LOG("\nERROR --> DU APP : Rach Config memory alloc failed");
1644 *setup->totalNumberOfRA_Preambles = duRachCfg.numRaPreamble;
1646 /* SSB per RACH occassion and CB Preambles per SSB */
1647 DU_ALLOC(setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB,\
1648 sizeof(struct RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB));
1649 if(!setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB)
1651 DU_LOG("\nERROR --> DU APP : Rach Config memory alloc failed");
1654 setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present = \
1655 duRachCfg.ssbPerRachOccPresent;
1656 switch(setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present)
1658 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_NOTHING:
1663 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneEighth:
1668 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneFourth:
1673 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneHalf:
1678 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one:
1680 setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.one =\
1681 duRachCfg.numSsbPerRachOcc;
1683 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_two:
1688 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_four:
1693 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_eight:
1698 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_sixteen:
1705 DU_LOG("\nERROR --> DU APP: Invalid value for \
1706 ssb_PerRach_OccassionAndCB_PreamblesPerSSB");
1711 /* RA Contention Resolution Timer */
1712 setup->ra_ContentionResolutionTimer = duRachCfg.contResTimer;
1714 /* RSRP Threshold SSB */
1715 DU_ALLOC(setup->rsrp_ThresholdSSB, sizeof(RSRP_Range_t));
1716 if(!setup->rsrp_ThresholdSSB)
1718 DU_LOG("\nERROR --> DU APP : Rach Config memory alloc failed");
1721 *setup->rsrp_ThresholdSSB = duRachCfg.rsrpThreshSsb;
1723 /* Root Sequence index */
1724 setup->prach_RootSequenceIndex.present = duRachCfg.rootSeqIdxPresent;
1725 switch(setup->prach_RootSequenceIndex.present)
1727 case RACH_ConfigCommon__prach_RootSequenceIndex_PR_NOTHING:
1732 case RACH_ConfigCommon__prach_RootSequenceIndex_PR_l839:
1737 case RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139:
1739 setup->prach_RootSequenceIndex.choice.l139 = duRachCfg.rootSeqIdx;
1744 DU_LOG("\nERROR --> DU APP: Inavlid PRACH root sequence index type");
1749 /* Msg 1 Subcarrier spacing */
1750 DU_ALLOC(setup->msg1_SubcarrierSpacing, sizeof(SubcarrierSpacing_t));
1751 if(!setup->msg1_SubcarrierSpacing)
1753 DU_LOG("\nERROR --> DU APP : Rach Config memory alloc failed");
1756 *setup->msg1_SubcarrierSpacing = duRachCfg.msg1Scs;
1758 /* Restricted Set Config */
1759 setup->restrictedSetConfig = duRachCfg.restrictedSetCfg;
1765 DU_LOG("\nERROR --> DU APP : Invalid RACH Config type ");
1770 }/* BuildRachCfgCommon */
1772 /*******************************************************************
1774 * @brief Builds PUSCH configuration for common
1778 * Function : BuildPuschCfgCommon
1781 * Builds PUSCH configuration for common
1784 * @return ROK - success
1787 * ****************************************************************/
1789 uint8_t BuildPuschCfgCommon(struct BWP_UplinkCommon__pusch_ConfigCommon *puschCfg)
1793 PuschCfgCommon duPuschCfg;
1794 PUSCH_ConfigCommon_t *setup;
1795 PUSCH_TimeDomainResourceAllocation_t *timeDomRsrcAllocInfo;
1797 duPuschCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.puschCfg;
1799 puschCfg->present = duPuschCfg.present;
1800 switch(puschCfg->present)
1802 case BWP_UplinkCommon__pusch_ConfigCommon_PR_NOTHING:
1807 case BWP_UplinkCommon__pusch_ConfigCommon_PR_release:
1812 case BWP_UplinkCommon__pusch_ConfigCommon_PR_setup:
1814 DU_ALLOC(puschCfg->choice.setup, sizeof(PUSCH_ConfigCommon_t));
1815 if(!puschCfg->choice.setup)
1817 DU_LOG("\nERROR --> DU APP : PUSCH Config memory alloc failed");
1820 setup = puschCfg->choice.setup;
1822 /* Time Domain Resource Allocation List */
1823 DU_ALLOC(setup->pusch_TimeDomainAllocationList,\
1824 sizeof(PUSCH_TimeDomainResourceAllocationList_t));
1825 if(!setup->pusch_TimeDomainAllocationList)
1827 DU_LOG("\nERROR --> DU APP : PUSCH Config memory alloc failed");
1830 elementCnt = ODU_VALUE_ONE;
1831 setup->pusch_TimeDomainAllocationList->list.count = elementCnt;
1832 setup->pusch_TimeDomainAllocationList->list.size = \
1833 elementCnt * sizeof(PUSCH_TimeDomainResourceAllocation_t *);
1835 DU_ALLOC(setup->pusch_TimeDomainAllocationList->list.array, \
1836 setup->pusch_TimeDomainAllocationList->list.size);
1837 if(!setup->pusch_TimeDomainAllocationList->list.array)
1839 DU_LOG("\nERROR --> DU APP : PUSCH Config memory alloc failed");
1843 for(idx=0; idx<elementCnt; idx++)
1845 DU_ALLOC(setup->pusch_TimeDomainAllocationList->list.array[idx],\
1846 sizeof(PUSCH_TimeDomainResourceAllocation_t));
1847 if(!setup->pusch_TimeDomainAllocationList->list.array[idx])
1849 DU_LOG("\nERROR --> DU APP : PUSCH Config memory alloc failed");
1855 timeDomRsrcAllocInfo = setup->pusch_TimeDomainAllocationList->list.array[idx];
1858 DU_ALLOC(timeDomRsrcAllocInfo->k2, sizeof(long));
1859 if(!timeDomRsrcAllocInfo->k2)
1861 DU_LOG("\nERROR --> DU APP : PUSCH Config memory alloc failed");
1864 *timeDomRsrcAllocInfo->k2 = duPuschCfg.k2;
1866 timeDomRsrcAllocInfo->mappingType = duPuschCfg.mapType;
1867 timeDomRsrcAllocInfo->startSymbolAndLength = duPuschCfg.sliv;
1869 /* Msg3 Delta Preamble */
1870 DU_ALLOC(setup->msg3_DeltaPreamble, sizeof(long));
1871 if(!setup->msg3_DeltaPreamble)
1873 DU_LOG("\nERROR --> DU APP : PUSCH Config memory alloc failed");
1876 *setup->msg3_DeltaPreamble = duPuschCfg.msg3DeltaPreamble;
1878 /* P0 Nominal with grnat */
1879 DU_ALLOC(setup->p0_NominalWithGrant, sizeof(long));
1880 if(!setup->p0_NominalWithGrant)
1882 DU_LOG("\nERROR --> DU APP : PUSCH Config memory alloc failed");
1885 *setup->p0_NominalWithGrant = duPuschCfg.p0NominalWithGrant;
1891 DU_LOG("\nERROR --> DU APP : Invalid PUSCH configuration type ");
1897 }/* BuildPuschCfgCommon */
1899 /*******************************************************************
1901 * @brief Builds PUCCH configuration common
1905 * Function : BuildPucchCfgCommon
1908 * Builds PUCCH configuration common
1911 * @return ROK - success
1914 * ****************************************************************/
1916 uint8_t BuildPucchCfgCommon( struct BWP_UplinkCommon__pucch_ConfigCommon *pucchCfg)
1918 PucchCfgCommon duPucchCfg;
1919 PUCCH_ConfigCommon_t *setup;
1921 duPucchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.pucchCfg;
1923 pucchCfg->present = duPucchCfg.present;
1924 switch(pucchCfg->present)
1926 case BWP_UplinkCommon__pucch_ConfigCommon_PR_NOTHING:
1931 case BWP_UplinkCommon__pucch_ConfigCommon_PR_release:
1936 case BWP_UplinkCommon__pucch_ConfigCommon_PR_setup:
1938 DU_ALLOC(pucchCfg->choice.setup, sizeof(PUCCH_ConfigCommon_t));
1939 if(!pucchCfg->choice.setup)
1941 DU_LOG("\nERROR --> DU APP : PUCCH Config memory alloc failed");
1944 setup = pucchCfg->choice.setup;
1946 /* Resource Common */
1947 DU_ALLOC(setup->pucch_ResourceCommon, sizeof(long));
1948 if(!setup->pucch_ResourceCommon)
1950 DU_LOG("\nERROR --> DU APP : PUCCH Config memory alloc failed");
1953 *setup->pucch_ResourceCommon = duPucchCfg.rsrcComm;
1956 setup->pucch_GroupHopping = duPucchCfg.grpHop;
1959 DU_ALLOC(setup->p0_nominal, sizeof(long));
1960 if(!setup->p0_nominal)
1962 DU_LOG("\nERROR --> DU APP : PUCCH Config memory alloc failed");
1965 *setup->p0_nominal = duPucchCfg.p0Nominal;
1971 DU_LOG("\nERROR --> DU APP : Invalid PUCCH Config type");
1976 }/* BuildPucchCfgCommon */
1978 /*******************************************************************
1980 * @brief Builds UL BWP Common
1984 * Function : BuildBwpUlCommon
1987 * Builds UL BWP Common
1989 * @params[in] BWP_UplinkCommon_t pointer
1990 * @return ROK - success
1993 * ****************************************************************/
1995 uint8_t BuildBwpUlCommon(BWP_UplinkCommon_t *bwp)
1998 UlCfgCommon duUlCfg;
2000 duUlCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg;
2002 bwp->genericParameters.locationAndBandwidth = duUlCfg.locAndBw;
2003 bwp->genericParameters.subcarrierSpacing = duUlCfg.ulScsCarrier.scs;
2005 /* RACH Config Common */
2006 DU_ALLOC(bwp->rach_ConfigCommon,\
2007 sizeof(struct BWP_UplinkCommon__rach_ConfigCommon));
2008 if(!bwp->rach_ConfigCommon)
2010 DU_LOG("\nERROR --> DU APP : UL BWP memory allocation failed");
2013 ret = BuildRachCfgCommon(bwp->rach_ConfigCommon);
2018 RachCfgCommonret=ROK;
2020 /* PUSCH Config Common */
2021 DU_ALLOC(bwp->pusch_ConfigCommon,\
2022 sizeof(struct BWP_UplinkCommon__pusch_ConfigCommon));
2023 if(!bwp->pusch_ConfigCommon)
2025 DU_LOG("\nERROR --> DU APP : UL BWP memory allocation failed");
2028 ret = BuildPuschCfgCommon(bwp->pusch_ConfigCommon);
2033 PuschCfgCommonret = ROK;
2035 /* PUCCH Config Common */
2036 DU_ALLOC(bwp->pucch_ConfigCommon,\
2037 sizeof(struct BWP_UplinkCommon__pucch_ConfigCommon));
2038 if(!bwp->pucch_ConfigCommon)
2040 DU_LOG("\nERROR --> DU APP : UL BWP memory allocation failed");
2043 ret = BuildPucchCfgCommon(bwp->pucch_ConfigCommon);
2049 }/* BuildBwpUlCommon */
2051 /*******************************************************************
2053 * @brief Builds UL config common for SIB
2057 * Function : BuildUlCfgCommSib
2060 * Builds UL config common for SIB
2062 * @params[in] UplinkConfigCommonSIB_t pointer
2063 * @return ROK - success
2066 * ****************************************************************/
2068 uint8_t BuildUlCfgCommSib(UplinkConfigCommonSIB_t *ulCfg)
2071 /* UL frequency info */
2072 ret = BuildFreqInfoUl(&ulCfg->frequencyInfoUL);
2077 /* BWP Uplink Common */
2078 ret = BuildBwpUlCommon(&ulCfg->initialUplinkBWP);
2083 /* Time Alignment timer */
2084 ulCfg->timeAlignmentTimerCommon = \
2085 duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.timeAlignTimerComm;
2088 }/* BuildUlCfgCommSib */
2090 /*******************************************************************
2092 * @brief Builds TDD UL DL configuration common
2096 * Function : BuildTddUlDlCfgComm
2099 * Builds TDD UL DL configuration common
2101 * @params[in] TDD_UL_DL_ConfigCommon_t pointer
2102 * @return ROK - success
2105 * ****************************************************************/
2107 uint8_t BuildTddUlDlCfgComm(TDD_UL_DL_ConfigCommon_t *tddCfg)
2109 TddUlDlCfgCommon duTddCfg;
2111 duTddCfg = duCfgParam.sib1Params.srvCellCfgCommSib.tddCfg;
2113 /* Reference Subcarrier spacing */
2114 tddCfg->referenceSubcarrierSpacing = duTddCfg.refScs;
2117 tddCfg->pattern1.dl_UL_TransmissionPeriodicity = duTddCfg.txPrd;
2118 tddCfg->pattern1.nrofDownlinkSlots = duTddCfg.numDlSlots;
2119 tddCfg->pattern1.nrofDownlinkSymbols = duTddCfg.numDlSymbols;
2120 tddCfg->pattern1.nrofUplinkSlots = duTddCfg.numUlSlots;
2121 tddCfg->pattern1.nrofUplinkSymbols = duTddCfg.numUlSymbols;
2125 }/* BuildTddUlDlCfgComm */
2127 /*******************************************************************
2129 * @brief Builds Serving cell config common in SIB1 message
2133 * Function : BuildServCellCfgCommonSib
2136 * Building Serving cell config common in SIB1 message
2138 * @params[in] ServingCellConfigCommonSIB_t pointer
2139 * @return ROK - success
2142 * ****************************************************************/
2143 uint8_t BuildServCellCfgCommonSib(ServingCellConfigCommonSIB_t *srvCellCfg)
2145 SrvCellCfgCommSib duSrvCellCfg;
2146 BIT_STRING_t *ssbPosInBurst;
2148 duSrvCellCfg = duCfgParam.sib1Params.srvCellCfgCommSib;
2150 /* SSB Position in Burst */
2151 ssbPosInBurst = &srvCellCfg->ssb_PositionsInBurst.inOneGroup;
2152 ssbPosInBurst->size = 1;
2153 DU_ALLOC(ssbPosInBurst->buf, ssbPosInBurst->size * sizeof(uint8_t));
2154 if(!ssbPosInBurst->buf)
2156 DU_LOG("\nERROR --> DU APP : Serving cell config common memory allocation failure");
2159 ssbPosInBurst->buf[0] = duSrvCellCfg.ssbPosInBurst;
2160 ssbPosInBurst->bits_unused = 0;
2162 switch(duSrvCellCfg.ssbPrdServingCell)
2164 case SSB_PERIODICITY_5MS:
2165 srvCellCfg->ssb_PeriodicityServingCell = \
2166 ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms5;
2168 case SSB_PERIODICITY_10MS:
2169 srvCellCfg->ssb_PeriodicityServingCell = \
2170 ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms10;
2172 case SSB_PERIODICITY_20MS:
2173 srvCellCfg->ssb_PeriodicityServingCell = \
2174 ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms20;
2176 case SSB_PERIODICITY_40MS:
2177 srvCellCfg->ssb_PeriodicityServingCell = \
2178 ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms40;
2180 case SSB_PERIODICITY_80MS:
2181 srvCellCfg->ssb_PeriodicityServingCell = \
2182 ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms80;
2184 case SSB_PERIODICITY_160MS:
2185 srvCellCfg->ssb_PeriodicityServingCell = \
2186 ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms160;
2190 srvCellCfg->ss_PBCH_BlockPower = duSrvCellCfg.ssPbchBlockPwr;
2192 /* Downlink config common */
2193 ret = BuildDlCfgCommSib(&srvCellCfg->downlinkConfigCommon);
2198 DlCfgCommSibret = ROK;
2200 /* Uplink Config Comm */
2201 DU_ALLOC(srvCellCfg->uplinkConfigCommon, sizeof(UplinkConfigCommonSIB_t));
2202 if(!srvCellCfg->uplinkConfigCommon)
2204 DU_LOG("\nERROR --> DU APP : Serving cell config common memory allocation failure");
2207 ret = BuildUlCfgCommSib(srvCellCfg->uplinkConfigCommon);
2212 UlCfgCommSibret=ROK;
2214 /* TDD UL DL Config Comm */
2215 DU_ALLOC(srvCellCfg->tdd_UL_DL_ConfigurationCommon, sizeof(TDD_UL_DL_ConfigCommon_t));
2216 if(!srvCellCfg->tdd_UL_DL_ConfigurationCommon)
2218 DU_LOG("\nERROR --> DU APP : Serving cell config common memory allocation failure");
2221 ret = BuildTddUlDlCfgComm(srvCellCfg->tdd_UL_DL_ConfigurationCommon);
2229 /*******************************************************************
2231 * @brief Builds SIB message in Served Cell Info
2235 * Function : BuildSib1Msg
2237 * Functionality: Building SIB message in Served Cell Info
2239 * @return ROK - success
2242 * ****************************************************************/
2243 uint8_t BuildSib1Msg()
2246 CellAccessRelatedInfo_t *cellAccessInfo;
2249 asn_enc_rval_t encRetVal;
2250 uint8_t ret = RFAILED;
2254 DU_ALLOC(sib1Msg, sizeof(SIB1_t));
2257 DU_LOG("\nERROR --> DU APP: SIB1 msg memory allocation failure");
2261 elementCnt = ODU_VALUE_ONE;
2264 cellAccessInfo = &sib1Msg->cellAccessRelatedInfo;
2265 cellAccessInfo->plmn_IdentityList.list.count = elementCnt;
2266 cellAccessInfo->plmn_IdentityList.list.size = elementCnt * sizeof(PLMN_IdentityInfo_t *);
2268 ret1 = BuildPlmnList(cellAccessInfo);
2273 /* Connection Establish Failure Control */
2274 DU_ALLOC(sib1Msg->connEstFailureControl, sizeof(ConnEstFailureControl_t));
2275 if(!sib1Msg->connEstFailureControl)
2277 DU_LOG("\nERROR --> DU APP: sib1Msg->connEstFailureControl memory allocation failure");
2280 sib1Msg->connEstFailureControl->connEstFailCount =\
2281 duCfgParam.sib1Params.connEstFailCnt;
2282 sib1Msg->connEstFailureControl->connEstFailOffsetValidity =\
2283 duCfgParam.sib1Params.connEstFailOffValidity;
2285 /* SI Scheduling Info */
2286 DU_ALLOC(sib1Msg->si_SchedulingInfo, sizeof(SI_SchedulingInfo_t));
2287 if(!sib1Msg->si_SchedulingInfo)
2289 DU_LOG("\nERROR --> DU APP: sib1Msg->si_SchedulingInfo memory allocation failure");
2292 elementCnt = ODU_VALUE_ONE;
2293 sib1Msg->si_SchedulingInfo->schedulingInfoList.list.count = elementCnt;
2294 sib1Msg->si_SchedulingInfo->schedulingInfoList.list.size = elementCnt *
2295 sizeof(struct SchedulingInfo *);
2296 ret1 = BuildSiSchedInfoList(&sib1Msg->si_SchedulingInfo->schedulingInfoList);
2301 sib1Msg->si_SchedulingInfo->si_WindowLength = duCfgParam.sib1Params.siSchedInfo.winLen;
2303 /* Serving Cell Config Common */
2304 DU_ALLOC(sib1Msg->servingCellConfigCommon, sizeof(ServingCellConfigCommonSIB_t));
2305 if(!sib1Msg->servingCellConfigCommon)
2307 DU_LOG("\nERROR --> DU APP: sib1Msg->servingCellConfigCommon memory allocation failure");
2310 ret1 = BuildServCellCfgCommonSib(sib1Msg->servingCellConfigCommon);
2316 xer_fprint(stdout, &asn_DEF_SIB1, sib1Msg);
2318 /* Encode the F1SetupRequest type as APER */
2319 memset(encBuf, 0, ENC_BUF_MAX_LEN);
2321 encRetVal = aper_encode(&asn_DEF_SIB1, 0, sib1Msg, PrepFinalEncBuf,\
2323 printf("\nencbufSize: %d\n", encBufSize);
2324 if(encRetVal.encoded == -1)
2326 DU_LOG("\nERROR --> DU APP : Could not encode SIB1 structure (at %s)\n",\
2327 encRetVal.failed_type ?
2328 encRetVal.failed_type->name :
2332 for(int i=0; i< encBufSize; i++)
2334 printf("%x\t",encBuf[i]);
2342 FreeSib1Msg(sib1Msg);
2348 /*******************************************************************
2350 * @brief : deallocating the memory of BuildSib1Msg
2354 * Function : FreeFreqInfoDl
2356 * Functionality: Freeing memory of BuildFreqInfoDl
2358 * @params[in] : FrequencyInfoDL_SIB_t *frequencyInfoDL
2361 *******************************************************************/
2362 void FreeFreqInfoDl(FrequencyInfoDL_SIB_t *frequencyInfoDL)
2367 /* Free DL frequency info */
2368 if(!frequencyInfoDL->frequencyBandList.list.array)
2370 /*Free Frequency band indicator */
2371 if(!frequencyInfoDL->frequencyBandList.list.array[idx])
2373 if(!frequencyInfoDL->frequencyBandList.list.array[idx]->\
2374 freqBandIndicatorNR)
2376 if(!frequencyInfoDL->scs_SpecificCarrierList.list.array)
2378 for(idx1 = 0;idx1<frequencyInfoDL->scs_SpecificCarrierList.list.count;idx1++)
2380 if(!frequencyInfoDL->scs_SpecificCarrierList.list.array[idx1])
2382 DU_FREE(frequencyInfoDL->scs_SpecificCarrierList.list.\
2383 array[idx1], sizeof(SCS_SpecificCarrier_t));
2386 DU_FREE(frequencyInfoDL->scs_SpecificCarrierList.list.array,
2387 frequencyInfoDL->scs_SpecificCarrierList.list.size);
2389 DU_FREE(frequencyInfoDL->frequencyBandList.list.\
2390 array[idx]->freqBandIndicatorNR, sizeof(FreqBandIndicatorNR_t));
2393 for(idx = 0; idx <frequencyInfoDL->frequencyBandList.list.count; idx++)
2395 if(!frequencyInfoDL->frequencyBandList.list.array[idx])
2397 DU_FREE(frequencyInfoDL->frequencyBandList.list.array[idx],\
2398 sizeof(NR_MultiBandInfo_t));
2401 DU_FREE(frequencyInfoDL->frequencyBandList.list.array,\
2402 frequencyInfoDL->frequencyBandList.list.size);
2405 /*******************************************************************
2407 * @brief : deallocating the memory of BuildSib1Msg
2411 * Function : FreeCommonSerachSpaceList
2413 * Functionality: deallocating the memory of BuildCommonSerachSpaceList
2415 * @params[in] :struct PDCCH_ConfigCommon__commonSearchSpaceList *searchSpclist
2418 *******************************************************************/
2419 void FreeCommonSerachSpaceList( struct PDCCH_ConfigCommon__commonSearchSpaceList
2423 SearchSpace_t *searchSpace= NULLP;
2425 if(!searchSpclist->list.array)
2427 if( searchSpclist->list.array[idx] != NULLP)
2429 searchSpace= searchSpclist->list.array[idx];
2430 if(!searchSpace->controlResourceSetId)
2432 if(!searchSpace->monitoringSlotPeriodicityAndOffset)
2434 if(!searchSpace->monitoringSymbolsWithinSlot)
2436 if(!searchSpace->monitoringSymbolsWithinSlot->buf)
2438 if(!searchSpace->nrofCandidates)
2440 if(!searchSpace->searchSpaceType)
2442 switch(searchSpace->searchSpaceType->present)
2444 case SearchSpace__searchSpaceType_PR_NOTHING:
2446 case SearchSpace__searchSpaceType_PR_common:
2448 if(!searchSpace->searchSpaceType->choice.common)
2450 if(!searchSpace->searchSpaceType->choice.\
2451 common->dci_Format0_0_AndFormat1_0)
2453 DU_FREE(searchSpace->searchSpaceType->choice.\
2454 common->dci_Format0_0_AndFormat1_0,sizeof(struct\
2455 SearchSpace__searchSpaceType__common__dci_Format0_0_AndFormat1_0));
2457 DU_FREE(searchSpace->searchSpaceType->choice.common,\
2458 sizeof(struct SearchSpace__searchSpaceType__common));
2462 case SearchSpace__searchSpaceType_PR_ue_Specific:
2467 DU_FREE(searchSpace->searchSpaceType,\
2468 sizeof( struct SearchSpace__searchSpaceType));
2470 DU_FREE(searchSpace->nrofCandidates,\
2471 sizeof(struct SearchSpace__nrofCandidates));
2473 DU_FREE(searchSpace->monitoringSymbolsWithinSlot->buf,\
2474 searchSpace->monitoringSymbolsWithinSlot->size);
2476 DU_FREE(searchSpace->monitoringSymbolsWithinSlot,\
2477 sizeof(BIT_STRING_t));
2479 DU_FREE(searchSpace->monitoringSlotPeriodicityAndOffset,\
2480 sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
2482 DU_FREE(searchSpace->controlResourceSetId,sizeof(ControlResourceSetId_t));
2485 for(idx = 0; idx < searchSpclist->list.count; idx++)
2487 if(!searchSpclist->list.array[idx])
2489 DU_FREE(searchSpclist->list.array[idx], sizeof(SearchSpace_t));
2492 DU_FREE(searchSpclist->list.array, searchSpclist->list.size)
2495 /*******************************************************************
2497 * @brief : deallocating the memory of BuildSib1Msg
2501 * Function : FreeBwpDlCommon
2503 * Functionality :Deallocating memory of BuildBwpDlCommon
2505 * @params[in] : BWP_DownlinkCommon_t *bwp
2509 *******************************************************************/
2510 void FreeBwpDlCommon(BWP_DownlinkCommon_t *bwp)
2513 struct BWP_DownlinkCommon__pdsch_ConfigCommon *pdschCfg=bwp->pdsch_ConfigCommon;
2514 struct BWP_DownlinkCommon__pdcch_ConfigCommon *pdcchCfg=bwp->pdcch_ConfigCommon;
2515 pdcchCfg->present=duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdcchCfg.present;
2516 pdschCfg->present=duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdschCfg.present;
2518 if(!bwp->pdcch_ConfigCommon)
2520 if(!bwp->pdsch_ConfigCommon)
2522 switch( pdschCfg->present)
2524 case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_NOTHING:
2529 case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_release:
2534 case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup:
2536 if(!pdschCfg->choice.setup)
2538 if(!pdschCfg->choice.setup->pdsch_TimeDomainAllocationList)
2540 if(!pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array)
2542 if(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx]!= NULLP)
2544 if(!pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx]->k0)
2546 DU_FREE(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx]->k0,\
2550 for(idx=0; idx<pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.count ; idx++)
2552 if(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx]!=
2555 DU_FREE(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx],\
2556 sizeof(PDSCH_TimeDomainResourceAllocation_t));
2559 DU_FREE(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array,\
2560 pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.size);
2562 DU_FREE(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList,\
2563 sizeof(PDSCH_TimeDomainResourceAllocationList_t));
2565 DU_FREE(pdschCfg->choice.setup,
2566 sizeof(PDSCH_ConfigCommon_t));
2572 DU_FREE(bwp->pdsch_ConfigCommon,\
2573 sizeof(struct BWP_DownlinkCommon__pdsch_ConfigCommon));
2576 switch(pdcchCfg->present)
2578 case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_NOTHING:
2583 case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_release:
2588 case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup:
2590 if(!pdcchCfg->choice.setup)
2592 /* Control Resource Set Zero */
2593 if(! pdcchCfg->choice.setup->controlResourceSetZero)
2595 /* Search space zero */
2596 if(! pdcchCfg->choice.setup->searchSpaceZero)
2598 /* Common Search Space List */
2599 if(! pdcchCfg->choice.setup->commonSearchSpaceList)
2601 if(CommonSerachSpaceListret==ROK)
2603 if(!pdcchCfg->choice.setup->searchSpaceSIB1)
2605 if(!pdcchCfg->choice.setup->pagingSearchSpace)
2607 if(!pdcchCfg->choice.setup->ra_SearchSpace)
2609 DU_FREE(pdcchCfg->choice.setup->ra_SearchSpace,
2610 sizeof(SearchSpaceId_t));
2612 DU_FREE( pdcchCfg->choice.setup->pagingSearchSpace,
2613 sizeof(SearchSpaceId_t));
2615 DU_FREE( pdcchCfg->choice.setup->searchSpaceSIB1,
2616 sizeof(SearchSpaceId_t));
2620 FreeCommonSerachSpaceList(pdcchCfg->choice.setup->commonSearchSpaceList);
2622 DU_FREE( pdcchCfg->choice.setup->commonSearchSpaceList,\
2624 PDCCH_ConfigCommon__commonSearchSpaceList));
2626 DU_FREE( pdcchCfg->choice.setup->searchSpaceZero,
2627 sizeof(SearchSpaceZero_t));
2629 DU_FREE( pdcchCfg->choice.setup->controlResourceSetZero,
2630 sizeof(ControlResourceSetZero_t));
2632 DU_FREE(pdcchCfg->choice.setup,
2633 sizeof(PDCCH_ConfigCommon_t));
2640 DU_FREE(bwp->pdcch_ConfigCommon,sizeof(struct BWP_DownlinkCommon__pdcch_ConfigCommon));
2643 /*******************************************************************
2645 * @brief deallocating the memory of BuildSib1Msg
2649 * Function: FreeUlCfgCommSib
2651 * Functionality deallocating the memory of BuildUlCfgCommSib
2653 * @params[in] : UplinkConfigCommonSIB_t *ulCfg
2657 *******************************************************************/
2658 void FreeUlCfgCommSib(UplinkConfigCommonSIB_t *ulCfg)
2661 RACH_ConfigCommon_t *setup;
2662 BWP_UplinkCommon_t *bwp=&ulCfg->initialUplinkBWP;
2663 struct FrequencyInfoUL_SIB__scs_SpecificCarrierList *scsCarrierList;
2664 struct BWP_UplinkCommon__rach_ConfigCommon *rachCfg;
2665 struct BWP_UplinkCommon__pucch_ConfigCommon *pucchCfg;
2666 struct BWP_UplinkCommon__pusch_ConfigCommon *puschCfg;
2667 puschCfg=ulCfg->initialUplinkBWP.pusch_ConfigCommon;
2668 rachCfg =bwp->rach_ConfigCommon;
2669 scsCarrierList = &ulCfg->frequencyInfoUL.scs_SpecificCarrierList;
2671 if(!scsCarrierList->list.array)
2673 if(!ulCfg->frequencyInfoUL.p_Max)
2675 if(FreqInfoUlret == ROK)
2677 if(!bwp->rach_ConfigCommon)
2679 if(RachCfgCommonret== ROK)
2681 if(!bwp->pusch_ConfigCommon)
2684 if(PuschCfgCommonret==ROK)
2686 if(!bwp->pucch_ConfigCommon)
2688 pucchCfg=bwp->pucch_ConfigCommon;
2689 switch(pucchCfg->present)
2691 case BWP_UplinkCommon__pucch_ConfigCommon_PR_NOTHING:
2693 case BWP_UplinkCommon__pucch_ConfigCommon_PR_release:
2695 case BWP_UplinkCommon__pucch_ConfigCommon_PR_setup:
2697 if(!pucchCfg->choice.setup)
2700 if(!pucchCfg->choice.setup->pucch_ResourceCommon)
2702 if(!pucchCfg->choice.setup->p0_nominal)
2704 DU_FREE(pucchCfg->choice.setup->p0_nominal,
2707 DU_FREE(pucchCfg->choice.setup->pucch_ResourceCommon,
2710 DU_FREE(pucchCfg->choice.setup,
2711 sizeof(PUCCH_ConfigCommon_t));
2717 DU_FREE(bwp->pucch_ConfigCommon,\
2718 sizeof(struct BWP_UplinkCommon__pucch_ConfigCommon));
2721 switch(puschCfg->present)
2723 case BWP_UplinkCommon__pusch_ConfigCommon_PR_NOTHING:
2725 case BWP_UplinkCommon__pusch_ConfigCommon_PR_release:
2727 case BWP_UplinkCommon__pusch_ConfigCommon_PR_setup:
2729 if(!puschCfg->choice.setup)
2732 if(! puschCfg->choice.setup->pusch_TimeDomainAllocationList)
2734 if(! puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array)
2736 if(!puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array[idx])
2738 if(!puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array[idx]->k2)
2740 if(! puschCfg->choice.setup->msg3_DeltaPreamble)
2742 if(!puschCfg->choice.setup->p0_NominalWithGrant)
2744 DU_FREE(puschCfg->choice.setup->p0_NominalWithGrant,
2747 DU_FREE(puschCfg->choice.setup->msg3_DeltaPreamble,
2750 DU_FREE(puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.\
2751 array[idx]->k2, sizeof(long));
2755 idx<puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.count;
2758 if(!puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array[idx])
2760 DU_FREE(puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array[idx],\
2761 sizeof(PUSCH_TimeDomainResourceAllocation_t));
2764 DU_FREE(puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array,\
2765 puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.size);
2767 DU_FREE(puschCfg->choice.setup->pusch_TimeDomainAllocationList,\
2768 sizeof(PUSCH_TimeDomainResourceAllocationList_t));
2770 DU_FREE(puschCfg->choice.setup,
2771 sizeof(PUSCH_ConfigCommon_t));
2778 DU_FREE(bwp->pusch_ConfigCommon,\
2779 sizeof(struct BWP_UplinkCommon__pusch_ConfigCommon));
2782 switch(rachCfg->present)
2784 case BWP_UplinkCommon__rach_ConfigCommon_PR_NOTHING:
2786 case BWP_UplinkCommon__rach_ConfigCommon_PR_release:
2788 case BWP_UplinkCommon__rach_ConfigCommon_PR_setup:
2790 if(!rachCfg->choice.setup)
2792 setup = rachCfg->choice.setup;
2793 if(!setup->totalNumberOfRA_Preambles)
2795 if(!setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB)
2797 if(!setup->rsrp_ThresholdSSB)
2799 if(!setup->msg1_SubcarrierSpacing)
2801 DU_FREE(setup->msg1_SubcarrierSpacing,
2802 sizeof(SubcarrierSpacing_t));
2804 DU_FREE(setup->rsrp_ThresholdSSB,
2805 sizeof(RSRP_Range_t));
2807 DU_FREE(setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB,\
2809 RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB));
2811 DU_FREE(setup->totalNumberOfRA_Preambles,
2815 DU_FREE(rachCfg->choice.setup,
2816 sizeof(RACH_ConfigCommon_t));
2822 DU_FREE(bwp->rach_ConfigCommon,\
2823 sizeof(struct BWP_UplinkCommon__rach_ConfigCommon));
2826 DU_FREE(ulCfg->frequencyInfoUL.p_Max, sizeof(P_Max_t));
2828 for(idx = 0; idx < scsCarrierList->list.count; idx++)
2830 if(!scsCarrierList->list.array[idx])
2832 DU_FREE(scsCarrierList->list.array[idx],
2833 sizeof(SCS_SpecificCarrier_t));
2836 DU_FREE(scsCarrierList->list.array, scsCarrierList->list.size);
2839 /*******************************************************************
2841 * @brief : Deallocating memory of SIB1 message
2845 * Function : FreeServCellCfgCommonSib
2847 * Functionality: Deallocating memory of BuildServCellCfgCommonSib
2849 * @params[in] : ServingCellConfigCommonSIB_t *srvCellCfg
2852 *******************************************************************/
2853 void FreeServCellCfgCommonSib(ServingCellConfigCommonSIB_t *srvCellCfg)
2855 BIT_STRING_t *ssbPosInBurst;
2856 ssbPosInBurst = &srvCellCfg->ssb_PositionsInBurst.inOneGroup;
2857 DownlinkConfigCommonSIB_t *dlCfg=&srvCellCfg->downlinkConfigCommon;
2859 if(!ssbPosInBurst->buf)
2861 /* Free DL frequency info */
2862 if(FreqInfoDlret == ROK)
2864 if(DlCfgCommSibret == ROK)
2866 /* Uplink Config Comm */
2867 if(!srvCellCfg->uplinkConfigCommon)
2869 if(UlCfgCommSibret==ROK)
2871 /* TDD UL DL Config Comm */
2872 if(!srvCellCfg->tdd_UL_DL_ConfigurationCommon)
2874 DU_FREE(srvCellCfg->tdd_UL_DL_ConfigurationCommon,
2875 sizeof(TDD_UL_DL_ConfigCommon_t));
2878 FreeUlCfgCommSib(srvCellCfg->uplinkConfigCommon);
2879 DU_FREE(srvCellCfg->uplinkConfigCommon,
2880 sizeof(UplinkConfigCommonSIB_t));
2883 FreeBwpDlCommon(&dlCfg->initialDownlinkBWP);
2885 FreeFreqInfoDl(&dlCfg->frequencyInfoDL);
2886 DU_FREE(ssbPosInBurst->buf, ssbPosInBurst->size * sizeof(uint8_t));
2889 /*******************************************************************
2891 * @brief : Deallcating memory of the function BuildSib1Msg
2895 * Function : FreeSib1Msg
2897 * Functionality: Deallcating memory of the function BuildSib1Msg
2899 * @params[in] ServingCellConfigCommonSIB_t pointer
2902 *******************************************************************/
2903 void FreeSib1Msg(SIB1_t *sib1Msg)
2908 CellIdentity_t *cellIdentity = NULLP;
2909 CellAccessRelatedInfo_t *cellAccessInfo ;
2910 struct PLMN_IdentityInfo__plmn_IdentityList *plmnIdInfo;
2913 if(sib1Msg != NULLP)
2915 cellAccessInfo = &sib1Msg->cellAccessRelatedInfo;
2916 if(cellAccessInfo->plmn_IdentityList.list.array !=NULLP)
2918 if(cellAccessInfo->plmn_IdentityList.list.array[idx]!=NULLP)
2921 &cellAccessInfo->plmn_IdentityList.list.array[idx]->plmn_IdentityList;
2923 if(plmnIdInfo->list.array !=NULLP)
2925 if(!plmnIdInfo->list.array[idx])
2927 if(!plmnIdInfo->list.array[idx]->mcc)
2929 if(!(plmnIdInfo->list.array[idx]->mcc->list.array))
2931 if(!plmnIdInfo->list.array[idx]->mnc.list.array)
2933 /*Free Tracking Area Code */
2934 if(!cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode)
2937 if(!cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode->buf)
2939 /* Free CellIdentity */
2940 if(!cellAccessInfo->plmn_IdentityList.list.array[idx]->ranac)
2943 =&cellAccessInfo->plmn_IdentityList.\
2944 list.array[idx]->cellIdentity;
2945 if(!cellIdentity->buf)
2947 /*Free Connection Establish Failure Control */
2948 if(!sib1Msg->connEstFailureControl)
2950 /*Free Serving Cell Config Common */
2951 if(!sib1Msg->si_SchedulingInfo)
2953 /* Free Serving Cell Config Common* */
2954 if(!sib1Msg->servingCellConfigCommon)
2956 /*Free BuildServCellCfgCommonSib*/
2957 FreeServCellCfgCommonSib(\
2958 sib1Msg->servingCellConfigCommon);
2960 DU_FREE(sib1Msg->servingCellConfigCommon,
2961 sizeof(ServingCellConfigCommonSIB_t));
2964 DU_FREE(sib1Msg->si_SchedulingInfo,
2965 sizeof(SI_SchedulingInfo_t));
2968 DU_FREE(sib1Msg->connEstFailureControl,
2969 sizeof(ConnEstFailureControl_t));
2971 DU_FREE(cellIdentity->buf,cellIdentity->size);
2974 DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx]->ranac, sizeof(RAN_AreaCode_t));
2977 DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode->buf,\
2978 cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode->size);
2981 DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode\
2982 , sizeof(TrackingAreaCode_t));
2985 for(idx2=0; idx2<plmnIdInfo->list.array[idx1]->mnc.list.count; idx2++)
2987 if(!plmnIdInfo->list.array[idx2]->mnc.list.array[idx2])
2989 DU_FREE(plmnIdInfo->list.array[idx2]->mnc.list.array[idx2],
2990 sizeof(MCC_MNC_Digit_t));
2993 DU_FREE(plmnIdInfo->list.array[idx]->mnc.list.array,
2994 plmnIdInfo->list.array[idx1]->mnc.list.size);
2997 for(idx1=0; idx1<plmnIdInfo->list.array[idx]->mcc->list.count; idx1++)
2999 if(plmnIdInfo->list.array[idx]->mcc->list.array[idx1]!=NULLP)
3001 DU_FREE(plmnIdInfo->list.array[idx]->mcc->list.array[idx1],\
3002 sizeof(MCC_MNC_Digit_t));
3006 DU_FREE(plmnIdInfo->list.array[idx]->mcc->list.array,\
3007 plmnIdInfo->list.array[idx]->mcc->list.size)
3009 DU_FREE(plmnIdInfo->list.array[idx]->mcc,sizeof(MCC_t));
3012 for(idx1=0; idx1<plmnIdInfo->list.count; idx1++)
3014 if(!(plmnIdInfo->list.array[idx1]))
3016 DU_FREE(plmnIdInfo->list.array[idx1],
3017 sizeof(PLMN_IdentitY_t));
3020 DU_FREE(plmnIdInfo->list.array, plmnIdInfo->list.size);
3023 for(idx=0; idx<cellAccessInfo->plmn_IdentityList.list.count; idx++)
3025 if(cellAccessInfo->plmn_IdentityList.list.array[idx]!=NULLP)
3027 DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx],
3028 sizeof(PLMN_IdentityInfo_t));
3031 DU_FREE(cellAccessInfo->plmn_IdentityList.list.array,
3032 cellAccessInfo->plmn_IdentityList.list.size);
3034 DU_FREE(sib1Msg, sizeof(SIB1_t));
3039 /**********************************************************************
3041 **********************************************************************/