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"
29 #include "BCCH-BCH-Message.h"
31 #include "PLMN-IdentityInfo.h"
32 #include "PLMN-IdentitY.h"
33 #include "SIB-TypeInfo.h"
34 #include "SchedulingInfo.h"
35 #include "SI-SchedulingInfo.h"
36 #include "ConnEstFailureControl.h"
37 #include "FrequencyInfoDL-SIB.h"
38 #include "SearchSpace.h"
39 #include "SCS-SpecificCarrier.h"
40 #include "NR-MultiBandInfo.h"
41 #include "PDCCH-ConfigCommon.h"
42 #include "PDSCH-TimeDomainResourceAllocation.h"
43 #include "PDSCH-TimeDomainResourceAllocationList.h"
44 #include "PDSCH-ConfigCommon.h"
45 #include "BWP-DownlinkCommon.h"
46 #include "DownlinkConfigCommonSIB.h"
47 #include "RACH-ConfigCommon.h"
48 #include "PUSCH-TimeDomainResourceAllocation.h"
49 #include "PUSCH-TimeDomainResourceAllocationList.h"
50 #include "PUSCH-ConfigCommon.h"
51 #include "PUCCH-ConfigCommon.h"
52 #include "UplinkConfigCommonSIB.h"
53 #include "TDD-UL-DL-ConfigCommon.h"
54 #include "ServingCellConfigCommonSIB.h"
57 #include "odu_common_codec.h"
58 #include "du_sys_info_hdl.h"
60 void FreeSib1Msg(SIB1_t *sib1Msg);
61 uint8_t FreqInfoUlret = RFAILED;
62 uint8_t RachCfgCommonret = RFAILED;
63 uint8_t PuschCfgCommonret = RFAILED;
64 uint8_t UlCfgCommSibret = RFAILED;
65 uint8_t FreqInfoDlret = RFAILED;
66 uint8_t DlCfgCommSibret = RFAILED;
67 uint8_t CommonSerachSpaceListret = RFAILED;
69 /*******************************************************************
77 * Functionality: Building MIB
79 * @return ROK - success
82 * ****************************************************************/
83 uint8_t BuildMib(MIB_t *mib)
85 mib->systemFrameNumber.size = sizeof(uint8_t);
86 DU_ALLOC(mib->systemFrameNumber.buf,
87 mib->systemFrameNumber.size);
88 if(!(mib->systemFrameNumber.buf))
90 DU_LOG("DU APP: MIB msg memory allocation failure");
94 *(mib->systemFrameNumber.buf) =
95 duCfgParam.mibParams.sysFrmNum;
96 mib->systemFrameNumber.bits_unused = ODU_VALUE_TWO;
98 mib->subCarrierSpacingCommon =\
99 duCfgParam.mibParams.subCarrierSpacingCommon;
100 mib->ssb_SubcarrierOffset =\
101 duCfgParam.mibParams.ssb_SubcarrierOffset;
102 mib->dmrs_TypeA_Position =\
103 duCfgParam.mibParams.dmrs_TypeA_Position;
104 mib->pdcch_ConfigSIB1.controlResourceSetZero = \
105 duCfgParam.mibParams.controlResourceSetZero;
106 mib->pdcch_ConfigSIB1.searchSpaceZero = \
107 duCfgParam.mibParams.searchSpaceZero;
108 mib->cellBarred = duCfgParam.mibParams.cellBarred;
109 mib->intraFreqReselection =
110 duCfgParam.mibParams.intraFreqReselection;
111 mib->spare.size = sizeof(uint8_t);
112 DU_ALLOC(mib->spare.buf, mib->spare.size);
115 DU_LOG("DU APP: MIB msg memory allocation failure");
118 *(mib->spare.buf) = SPARE;
119 mib->spare.bits_unused = ODU_VALUE_SEVEN;
122 /*******************************************************************
124 * @brief Free MIB PDU for broadcast
128 * Function : FreeMibPdu
130 * Functionality: Deallocating MIB PDU for system broadcast
132 * @param[in]: BCCH_BCH_Message_t *bcchMsg
136 * ****************************************************************/
137 void FreeMibPdu(BCCH_BCH_Message_t *bcchMsg)
141 if(!bcchMsg->message.choice.mib)
143 if(!(bcchMsg->message.choice.mib->systemFrameNumber.buf))
145 if(!bcchMsg->message.choice.mib->spare.buf)
147 DU_FREE(bcchMsg->message.choice.mib->spare.buf,\
148 bcchMsg->message.choice.mib->spare.size);
150 DU_FREE(bcchMsg->message.choice.mib->systemFrameNumber.buf,
151 bcchMsg->message.choice.mib->systemFrameNumber.size);
153 DU_FREE(bcchMsg->message.choice.mib, sizeof(MIB_t));
155 DU_FREE(bcchMsg, sizeof(BCCH_BCH_Message_t));
158 /*******************************************************************
160 * @brief Builds MIB PDU for broadcast
164 * Function : BuildMibPdu
166 * Functionality: Building MIB PDU for system broadcast
168 * @return ROK - success
171 * ****************************************************************/
172 uint8_t BuildMibPdu()
175 uint8_t ret = RFAILED;
176 BCCH_BCH_Message_t *bcchMsg;
177 asn_enc_rval_t encRetVal; /* Encoder return value */
180 DU_ALLOC(bcchMsg, sizeof(BCCH_BCH_Message_t));
183 DU_LOG("\nMemory allocation failure in BuildMibPdu");
187 bcchMsg->message.present = BCCH_BCH_MessageType_PR_mib;
188 DU_ALLOC(bcchMsg->message.choice.mib, sizeof(MIB_t));
189 if(!bcchMsg->message.choice.mib)
191 DU_LOG("\nMemory allocation failure in BuildMibPdu");
194 BuildMibret = BuildMib(bcchMsg->message.choice.mib);
195 if(BuildMibret != ROK)
199 xer_fprint(stdout, &asn_DEF_BCCH_BCH_Message, bcchMsg);
200 cmMemset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
202 encRetVal = aper_encode(&asn_DEF_BCCH_BCH_Message, 0,
203 bcchMsg, PrepFinalEncBuf, encBuf);
204 printf("\nencbufSize:%d\n", encBufSize);
205 if(encRetVal.encoded == -1)
207 DU_LOG("\nDU APP: Could not encode BCCH BCH Message Type structure(at %s)\n",
208 encRetVal.failed_type?\
209 encRetVal.failed_type->name
214 /* Print encoded buffer */
215 for(int i=0; i< encBufSize; i++)
217 printf("%x\t",encBuf[i]);
224 /* Free allocated memory */
230 /*******************************************************************
232 * @brief free MIB message in Served Cell Info
236 * Function : FreeMibMsg
238 * Functionality: deallocating MIB message in Served Cell Info
240 * @param[in] MIB_t *mibMsg
245 * ****************************************************************/
246 void FreeMibMsg( MIB_t *mibMsg)
250 if(!(mibMsg->systemFrameNumber.buf))
252 if(!mibMsg->spare.buf)
254 DU_FREE(mibMsg->spare.buf, mibMsg->spare.size);
256 DU_FREE(mibMsg->systemFrameNumber.buf,
257 mibMsg->systemFrameNumber.size);
259 DU_FREE(mibMsg, sizeof(MIB_t));
262 /*******************************************************************
264 * @brief Builds MIB message in Served Cell Info
268 * Function : BuildMibMsg
270 * Functionality: Building MIB message in Served Cell Info
272 * @return ROK - success
275 * ****************************************************************/
276 uint8_t BuildMibMsg()
279 asn_enc_rval_t encRetVal; /* Encoder return value */
280 uint8_t ret = RFAILED;
284 DU_ALLOC(mibMsg, sizeof(MIB_t));
287 DU_LOG("DU APP: MIB msg memory allocation failure");
290 BuildMibret = BuildMib(mibMsg);
291 if(BuildMibret != ROK)
295 xer_fprint(stdout, &asn_DEF_MIB, mibMsg);
296 cmMemset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
298 encRetVal = aper_encode(&asn_DEF_MIB, 0,
299 mibMsg, PrepFinalEncBuf, encBuf);
300 printf("\nencbufSize:%d\n", encBufSize);
301 if(encRetVal.encoded == -1)
303 DU_LOG("\nDU APP: Could not encode MIB structure(at %s)\n",
304 encRetVal.failed_type?\
305 encRetVal.failed_type->name
310 /* Print encoded buffer */
311 for(int i=0; i< encBufSize; i++)
313 printf("%x\t",encBuf[i]);
317 /* Free allocated memory */
328 /*******************************************************************
330 * @brief Builds CellIdentity within SIB1 message
334 * Function : BuildCellIdentity
336 * Functionality: Building RAN area code in SIB1 message
338 * @params[in] RAN_AreaCode_t **ranAreaCode
339 * @return ROK - success
342 * ****************************************************************/
343 uint8_t BuildCellIdentity(CellIdentity_t *cellIdentity)
345 cellIdentity->size = ODU_VALUE_FIVE*sizeof(uint8_t);
346 cellIdentity->bits_unused = ODU_VALUE_FOUR;
348 DU_ALLOC(cellIdentity->buf, cellIdentity->size);
349 if(!cellIdentity->buf)
351 DU_LOG("DU APP: CellIdentity memory allocation failure");
354 *cellIdentity->buf = duCfgParam.sib1Params.cellIdentity;
358 /*******************************************************************
360 * @brief Builds RANAC within SIB1 message
364 * Function : BuildRanac
366 * Functionality: Building RAN area code in SIB1 message
368 * @params[in] RAN_AreaCode_t **ranAreaCode
369 * @return ROK - success
372 * ****************************************************************/
373 uint8_t BuildRanac(RAN_AreaCode_t **ranAreaCode)
375 RAN_AreaCode_t *ranac;
376 DU_ALLOC(ranac, sizeof(RAN_AreaCode_t));
379 DU_LOG("DU APP: RANAC memory allocation failure");
382 *ranac = duCfgParam.sib1Params.ranac;
383 *ranAreaCode = ranac;
386 /*******************************************************************
388 * @brief Builds TAC within SIB1 message
392 * Function : BuildTac
394 * Functionality: Building Tracking area code in SIB1 message
396 * @params[in] TrackingAreaCode_t **tac
397 * @return ROK - success
400 * ****************************************************************/
401 uint8_t BuildTac(TrackingAreaCode_t **trackAreaCode)
403 TrackingAreaCode_t *tac;
406 DU_ALLOC(tac, sizeof(TrackingAreaCode_t));
409 DU_LOG("DU APP: TAC memory allocation failure");
413 tac->size = ODU_VALUE_THREE*sizeof(uint8_t);
414 DU_ALLOC(tac->buf, tac->size);
417 DU_LOG("DU APP: TAC memory allocation failure");
420 *(tac->buf) = duCfgParam.sib1Params.tac;
421 tac->bits_unused = ODU_VALUE_ZERO;
422 *trackAreaCode = tac;
427 /*******************************************************************
429 * @brief Builds PLMN list within SIB1 message
433 * Function : BuildPlmnList
435 * Functionality: Building PLMN list in SIB1 message
437 * @params[in] CellAccessRelatedInfo_t *cellAccessInfo
438 * @return ROK - success
441 * ****************************************************************/
442 uint8_t BuildPlmnList(CellAccessRelatedInfo_t *cellAccessInfo)
448 TrackingAreaCode_t **tac;
449 RAN_AreaCode_t **ranac;
450 CellIdentity_t *cellIdentity;
452 struct PLMN_IdentityInfo__plmn_IdentityList
455 DU_ALLOC(cellAccessInfo->plmn_IdentityList.list.array,
456 cellAccessInfo->plmn_IdentityList.list.size);
457 if(!cellAccessInfo->plmn_IdentityList.list.array)
459 DU_LOG("DU APP: BuildPlmnList memory allocation failure");
462 elementCnt = cellAccessInfo->plmn_IdentityList.list.count;
463 for(idx=0; idx<elementCnt; idx++)
465 DU_ALLOC(cellAccessInfo->plmn_IdentityList.list.array[idx],
466 sizeof(PLMN_IdentityInfo_t));
467 if(!cellAccessInfo->plmn_IdentityList.list.array[idx])
469 DU_LOG("DU APP: BuildPlmnList memory allocation failure");
476 elementCnt = ODU_VALUE_ONE;
478 plmnIdInfo = &cellAccessInfo->plmn_IdentityList.list.array[idx]->\
480 plmnIdInfo->list.count = elementCnt;
481 plmnIdInfo->list.size = elementCnt * sizeof(PLMN_IdentitY_t *);
482 DU_ALLOC(plmnIdInfo->list.array, plmnIdInfo->list.size);
483 if(!plmnIdInfo->list.array)
485 DU_LOG("DU APP: BuildPlmnList memory allocation failure");
489 for(idx1=0; idx1<elementCnt; idx1++)
491 DU_ALLOC(plmnIdInfo->list.array[idx1],
492 sizeof(PLMN_IdentitY_t));
493 if(!(plmnIdInfo->list.array[idx1]))
495 DU_LOG("DU APP: BuildPlmnList memory allocation failure");
500 DU_ALLOC(plmnIdInfo->list.array[idx1]->mcc,
502 if(!plmnIdInfo->list.array[idx1]->mcc)
504 DU_LOG("DU APP: BuildPlmnList memory allocation failure");
508 elementCnt = ODU_VALUE_THREE;
509 plmnIdInfo->list.array[idx1]->mcc->list.count = elementCnt;
510 plmnIdInfo->list.array[idx1]->mcc->list.size =\
511 elementCnt * sizeof(MCC_MNC_Digit_t *);
512 DU_ALLOC(plmnIdInfo->list.array[idx1]->mcc->list.array,
513 plmnIdInfo->list.array[idx1]->mcc->list.size)
514 if(!(plmnIdInfo->list.array[idx1]->mcc->list.array))
516 DU_LOG("DU APP: BuildPlmnList memory allocation failure");
519 for(idx2=0; idx2<elementCnt; idx2++)
521 DU_ALLOC(plmnIdInfo->list.array[idx1]->mcc->list.array[idx2],
522 sizeof(MCC_MNC_Digit_t));
523 if(!plmnIdInfo->list.array[idx1]->mcc->list.array[idx2])
525 DU_LOG("DU APP: BuildPlmnList memory allocation failure");
528 *(plmnIdInfo->list.array[idx1]->mcc->list.array[idx2])=\
529 duCfgParam.sib1Params.plmn.mcc[idx2];
532 plmnIdInfo->list.array[idx1]->mnc.list.count = elementCnt;
533 plmnIdInfo->list.array[idx1]->mnc.list.size =\
534 elementCnt * sizeof(MCC_MNC_Digit_t *);
535 DU_ALLOC(plmnIdInfo->list.array[idx1]->mnc.list.array,
536 plmnIdInfo->list.array[idx1]->mnc.list.size);
537 if(!plmnIdInfo->list.array[idx1]->mnc.list.array)
539 DU_LOG("DU APP: BuildPlmnList memory allocation failure");
542 for(idx2=0; idx2<elementCnt; idx2++)
544 DU_ALLOC(plmnIdInfo->list.array[idx1]->mnc.list.array[idx2],
545 sizeof(MCC_MNC_Digit_t));
546 if(!plmnIdInfo->list.array[idx1]->mnc.list.array[idx2])
548 DU_LOG("DU APP: BuildPlmnList memory allocation failure");
551 *(plmnIdInfo->list.array[idx1]->mnc.list.array[idx2])=\
552 duCfgParam.sib1Params.plmn.mnc[idx2];
555 /* Tracking Area Code */
556 tac = &cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode;
564 ranac = &cellAccessInfo->plmn_IdentityList.list.array[idx]->ranac;
565 ret=BuildRanac(ranac);
573 &cellAccessInfo->plmn_IdentityList.list.array[idx]->cellIdentity;
574 ret=BuildCellIdentity(cellIdentity);
580 /* cellReservedForOperatorUse */
581 cellAccessInfo->plmn_IdentityList.list.array[idx]->\
582 cellReservedForOperatorUse = \
583 duCfgParam.sib1Params.cellResvdForOpUse;
589 /*******************************************************************
591 * @brief Build SIB Map Info List
595 * Function : BuildSibMapInfoList
598 * Build SIB MapInfo List
600 * @params[in] SIB_Mapping_t pointer
601 * @return ROK - success
604 * ****************************************************************/
605 uint8_t BuildSibMapInfoList(SIB_Mapping_t *sibMapInfo)
607 uint8_t itr; /* List iterator */
608 uint8_t elementCnt; /* Number of elements in list */
609 SIB_TypeInfo_t *sibTypeInfo; /* Scheduling info */
611 /* SI scheduling info list */
612 DU_ALLOC(sibMapInfo->list.array, sibMapInfo->list.size);
613 if(!sibMapInfo->list.array)
615 DU_LOG("DU APP: BuildSibMapInfoList memory allocation failure");
619 elementCnt = sibMapInfo->list.count;
620 for(itr = 0; itr < elementCnt; itr++)
622 DU_ALLOC(sibMapInfo->list.array[itr], sizeof(SIB_TypeInfo_t));
623 if(!sibMapInfo->list.array[itr])
625 DU_LOG("DU APP: BuildSibMapInfoList memory allocation failure");
631 sibTypeInfo = sibMapInfo->list.array[itr];
632 sibTypeInfo->type = duCfgParam.sib1Params.siSchedInfo.sibType;
633 DU_ALLOC(sibTypeInfo->valueTag, sizeof(long));
634 if(!sibTypeInfo->valueTag)
636 DU_LOG("DU APP: BuildSibMapInfoList memory allocation failure");
640 *sibTypeInfo->valueTag = duCfgParam.sib1Params.siSchedInfo.sibValTag;
645 /*******************************************************************
647 * @brief Builds SI Scheduling info list within SIB1 message
651 * Function : BuildSiSchedInfoList
654 * Building SI Scheduling info list in SIB1 message
656 * @params[in] struct SI_SchedulingInfo__schedulingInfoList *si_SchedulingInfo
657 * @return ROK - success
660 * ****************************************************************/
661 uint8_t BuildSiSchedInfoList(struct SI_SchedulingInfo__schedulingInfoList *si_SchedulingInfoList)
663 uint8_t itr; /* List iterator */
664 uint8_t elementCnt; /* Number of elements in list */
666 SchedulingInfo_t *schedInfo; /* Scheduling info */
668 /* SI scheduling info list */
669 DU_ALLOC(si_SchedulingInfoList->list.array, si_SchedulingInfoList->list.size);
670 if(!si_SchedulingInfoList->list.array)
672 DU_LOG("DU APP: BuildSiSchedInfoList memory allocation failure");
676 elementCnt = si_SchedulingInfoList->list.count;
677 for(itr = 0; itr < elementCnt; itr++)
679 DU_ALLOC(si_SchedulingInfoList->list.array[itr], sizeof(struct SchedulingInfo));
680 if(!si_SchedulingInfoList->list.array[itr])
682 DU_LOG("DU APP: BuildSiSchedInfoList memory allocation failure");
688 schedInfo = si_SchedulingInfoList->list.array[itr];
689 schedInfo->si_BroadcastStatus = duCfgParam.sib1Params.siSchedInfo.broadcastSta;
690 schedInfo->si_Periodicity = duCfgParam.sib1Params.siSchedInfo.preiodicity;
692 elementCnt = ODU_VALUE_ONE;
693 schedInfo->sib_MappingInfo.list.count = elementCnt;
694 schedInfo->sib_MappingInfo.list.size = elementCnt * sizeof(SIB_TypeInfo_t *);
696 ret = BuildSibMapInfoList(&schedInfo->sib_MappingInfo);
705 /*******************************************************************
707 * @brief Builds SCS Specific carrier list for DL
711 * Function : BuildScsSpecificCarrierListDl
714 * Builds Subcarrier specific carrier list for downlink
716 * @params[in] FrequencyInfoDL_SIB__scs_SpecificCarrierList pointer
717 * @return ROK - success
720 * ****************************************************************/
721 uint8_t BuildScsSpecificCarrierListDl
723 struct FrequencyInfoDL_SIB__scs_SpecificCarrierList *scsCarrierList
727 ScsSpecCarrier duScsSpecCarrier;
729 duScsSpecCarrier = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.dlScsCarrier;
731 DU_ALLOC(scsCarrierList->list.array, scsCarrierList->list.size);
732 if(!scsCarrierList->list.array)
734 DU_LOG("\nDU APP : SCS Specific Carrier list memory allocation failed");
738 for(idx = 0; idx < scsCarrierList->list.count; idx++)
740 DU_ALLOC(scsCarrierList->list.array[idx], sizeof(SCS_SpecificCarrier_t));
741 if(!scsCarrierList->list.array[idx])
743 DU_LOG("\nDU APP : SCS Specific Carrier list memory allocation failed");
749 scsCarrierList->list.array[idx]->offsetToCarrier = duScsSpecCarrier.scsOffset;
750 scsCarrierList->list.array[idx]->subcarrierSpacing = duScsSpecCarrier.scs;
751 scsCarrierList->list.array[idx]->carrierBandwidth = duScsSpecCarrier.scsBw;
754 } /* End of BuildScsSpecificCarrierListDl */
756 /*******************************************************************
758 * @brief Builds common search space list
762 * Function : BuildCommonSerachSpaceList
765 * Builds common search space list
767 * @params[in] PDCCH_ConfigCommon__commonSearchSpaceList pointer
768 * @return ROK - success
771 * ****************************************************************/
772 uint8_t BuildCommonSerachSpaceList
774 struct PDCCH_ConfigCommon__commonSearchSpaceList *searchSpclist
778 SearchSpace_t *searchSpace;
779 PdcchCfgCommon duPdcchCfg;
781 duPdcchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdcchCfg;
783 DU_ALLOC(searchSpclist->list.array, searchSpclist->list.size)
784 if(!searchSpclist->list.array)
786 DU_LOG("\nDU APP : Common search space list memory alloc failed");
790 for(idx = 0; idx < searchSpclist->list.count; idx++)
792 DU_ALLOC(searchSpclist->list.array[idx], sizeof(SearchSpace_t));
793 if(!searchSpclist->list.array[idx])
795 DU_LOG("\nDU APP : Common search space list memory alloc failed");
801 searchSpace = searchSpclist->list.array[idx];
803 /* Search Space id */
804 searchSpace->searchSpaceId = duPdcchCfg.searchSpcId;
806 /* Control Resource Set Id */
807 DU_ALLOC(searchSpace->controlResourceSetId, sizeof(ControlResourceSetId_t));
808 if(!searchSpace->controlResourceSetId)
810 DU_LOG("\nDU APP : Common search space list memory alloc failed");
813 *searchSpace->controlResourceSetId = duPdcchCfg.ctrlRsrcSetId;
815 /* Monitoring Slot periodicity and offset */
816 DU_ALLOC(searchSpace->monitoringSlotPeriodicityAndOffset,\
817 sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
818 if(!searchSpace->monitoringSlotPeriodicityAndOffset)
820 DU_LOG("\nDU APP : Common search space list memory alloc failed");
823 searchSpace->monitoringSlotPeriodicityAndOffset->present = \
824 duPdcchCfg.monitorSlotPrdAndOffPresent;
825 switch(searchSpace->monitoringSlotPeriodicityAndOffset->present)
827 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1:
829 //searchSpace->monitoringSlotPeriodicityAndOffset->choice.s11 = \
830 duPdcchCfg.monitorSlotPrdAndOff;
833 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2:
838 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl4:
843 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl5:
848 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl8:
853 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl10:
858 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl16:
863 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl20:
868 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl40:
873 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl80:
878 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl160:
883 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl320:
887 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl640:
892 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1280:
897 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2560:
904 DU_LOG("\nDU APP : Invalid value:Montoring slot periodicity and offset");
909 /* Monitoring Symbols Within Slot */
910 DU_ALLOC(searchSpace->monitoringSymbolsWithinSlot,\
911 sizeof(BIT_STRING_t));
912 if(!searchSpace->monitoringSymbolsWithinSlot)
914 DU_LOG("\nDU APP : Common search space list memory alloc failed");
917 searchSpace->monitoringSymbolsWithinSlot->size = 2*sizeof(uint8_t);
918 DU_ALLOC(searchSpace->monitoringSymbolsWithinSlot->buf, \
919 searchSpace->monitoringSymbolsWithinSlot->size );
920 if(!searchSpace->monitoringSymbolsWithinSlot->buf)
922 DU_LOG("\nDU APP : Common search space list memory alloc failed");
925 searchSpace->monitoringSymbolsWithinSlot->buf[0] = duPdcchCfg.monitorSymbolsInSlot[0];
926 searchSpace->monitoringSymbolsWithinSlot->buf[1] = duPdcchCfg.monitorSymbolsInSlot[1];
927 searchSpace->monitoringSymbolsWithinSlot->bits_unused = 2;
929 /* Number of candidates per aggregation level */
930 DU_ALLOC(searchSpace->nrofCandidates,\
931 sizeof(struct SearchSpace__nrofCandidates));
932 if(!searchSpace->nrofCandidates)
934 DU_LOG("\nDU APP : Common search space list memory alloc failed");
937 searchSpace->nrofCandidates->aggregationLevel1 = duPdcchCfg.numCandAggLvl1;
938 searchSpace->nrofCandidates->aggregationLevel2 = duPdcchCfg.numCandAggLvl2;
939 searchSpace->nrofCandidates->aggregationLevel4 = duPdcchCfg.numCandAggLvl4;
940 searchSpace->nrofCandidates->aggregationLevel8 = duPdcchCfg.numCandAggLvl8;
941 searchSpace->nrofCandidates->aggregationLevel16 = duPdcchCfg.numCandAggLvl16;
943 /* Search Space type and DCI Format */
944 DU_ALLOC(searchSpace->searchSpaceType,\
945 sizeof( struct SearchSpace__searchSpaceType));
946 if(!searchSpace->searchSpaceType)
948 DU_LOG("\nDU APP : Common search space list memory alloc failed");
952 searchSpace->searchSpaceType->present = duPdcchCfg.searchSpcType;
953 switch(searchSpace->searchSpaceType->present)
955 case SearchSpace__searchSpaceType_PR_NOTHING:
960 case SearchSpace__searchSpaceType_PR_common:
962 DU_ALLOC(searchSpace->searchSpaceType->choice.common,\
963 sizeof(struct SearchSpace__searchSpaceType__common));
964 if(!searchSpace->searchSpaceType->choice.common)
966 DU_LOG("\nDU APP : Common search space list memory alloc failed");
970 DU_ALLOC(searchSpace->searchSpaceType->choice.common->\
971 dci_Format0_0_AndFormat1_0, sizeof(struct \
972 SearchSpace__searchSpaceType__common__dci_Format0_0_AndFormat1_0));
973 if(!searchSpace->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0)
975 DU_LOG("\nDU APP : Common search space list memory alloc failed");
980 case SearchSpace__searchSpaceType_PR_ue_Specific:
986 DU_LOG("\nDU_APP: Invalid Search Space type");
993 }/* BuildCommonSerachSpaceList */
995 /*******************************************************************
997 * @brief Builds PDCCH configuration common
1001 * Function : BuildPdcchCfgCommon
1004 * Builds PDCCH configuration common
1006 * @params[in] BWP_DownlinkCommon__pdcch_ConfigCommon pointer
1007 * @return ROK - success
1010 * ****************************************************************/
1011 uint8_t BuildPdcchCfgCommon(struct BWP_DownlinkCommon__pdcch_ConfigCommon *pdcchCfg)
1015 PdcchCfgCommon duPdcchCfg;
1016 PDCCH_ConfigCommon_t *pdcchSetup;
1018 duPdcchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdcchCfg;
1020 pdcchCfg->present = duPdcchCfg.present;
1022 switch(pdcchCfg->present)
1024 case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_NOTHING:
1029 case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_release:
1034 case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup:
1036 DU_ALLOC(pdcchCfg->choice.setup, sizeof(PDCCH_ConfigCommon_t));
1037 if(!pdcchCfg->choice.setup)
1039 DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1042 pdcchSetup = pdcchCfg->choice.setup;
1044 /* Control Resource Set Zero */
1045 DU_ALLOC(pdcchSetup->controlResourceSetZero,
1046 sizeof(ControlResourceSetZero_t));
1047 if(!pdcchSetup->controlResourceSetZero)
1049 DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1052 *pdcchSetup->controlResourceSetZero = duPdcchCfg.ctrlRsrcSetZero;
1054 /* Search space zero */
1055 DU_ALLOC(pdcchSetup->searchSpaceZero, sizeof(SearchSpaceZero_t));
1056 if(!pdcchSetup->searchSpaceZero)
1058 DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1061 *pdcchSetup->searchSpaceZero = duPdcchCfg.searchSpcZero;
1063 /* Common Search Space List */
1064 DU_ALLOC(pdcchSetup->commonSearchSpaceList,\
1065 sizeof(struct PDCCH_ConfigCommon__commonSearchSpaceList));
1066 if(!pdcchSetup->commonSearchSpaceList)
1068 DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1071 elementCnt = ODU_VALUE_ONE;
1072 pdcchSetup->commonSearchSpaceList->list.count = elementCnt;
1073 pdcchSetup->commonSearchSpaceList->list.size = \
1074 elementCnt * sizeof(SearchSpace_t *);
1075 ret = BuildCommonSerachSpaceList(pdcchSetup->commonSearchSpaceList);
1080 CommonSerachSpaceListret=ROK;
1082 /* Search Space for SIB1 */
1083 DU_ALLOC(pdcchSetup->searchSpaceSIB1, sizeof(SearchSpaceId_t));
1084 if(!pdcchSetup->searchSpaceSIB1)
1086 DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1089 *pdcchSetup->searchSpaceSIB1 = duPdcchCfg.searchSpcSib1;
1091 /* Serach Space for Paging */
1092 DU_ALLOC(pdcchSetup->pagingSearchSpace, sizeof(SearchSpaceId_t));
1093 if(!pdcchSetup->pagingSearchSpace)
1095 DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1098 *pdcchSetup->pagingSearchSpace = duPdcchCfg.pagingSearchSpc;
1100 /* Search space for Random Access */
1101 DU_ALLOC(pdcchSetup->ra_SearchSpace, sizeof(SearchSpaceId_t));
1102 if(!pdcchSetup->ra_SearchSpace)
1104 DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1107 *pdcchSetup->ra_SearchSpace = duPdcchCfg.raSearchSpc;
1113 DU_LOG("\nDU APP : Invalid PDCCH Config type");
1119 } /* BuildPdcchCfgCommon */
1121 /*******************************************************************
1123 * @brief Builds PDSCH configuration common
1127 * Function : BuildPdschCfgCommon
1130 * Builds PDSCH configuration common
1132 * @params[in] BWP_DownlinkCommon__pdsch_ConfigCommon pointer
1133 * @return ROK - success
1136 * ****************************************************************/
1137 uint8_t BuildPdschCfgCommon(struct BWP_DownlinkCommon__pdsch_ConfigCommon *pdschCfg)
1141 PdschCfgCommon duPdschCfg;
1142 PDSCH_ConfigCommon_t *pdschSetup;
1143 PDSCH_TimeDomainResourceAllocation_t *timeDomRsrcAllocInfo;
1145 duPdschCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdschCfg;
1147 pdschCfg->present = duPdschCfg.present;
1149 switch(pdschCfg->present)
1151 case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_NOTHING:
1156 case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_release:
1161 case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup:
1163 DU_ALLOC(pdschCfg->choice.setup, sizeof(PDSCH_ConfigCommon_t));
1164 if(!pdschCfg->choice.setup)
1166 DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1169 pdschSetup = pdschCfg->choice.setup;
1171 /* Time Domain Allocation List */
1172 DU_ALLOC(pdschSetup->pdsch_TimeDomainAllocationList, \
1173 sizeof(PDSCH_TimeDomainResourceAllocationList_t));
1174 if(!pdschSetup->pdsch_TimeDomainAllocationList)
1176 DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1179 elementCnt = ODU_VALUE_ONE;
1180 pdschSetup->pdsch_TimeDomainAllocationList->list.count = elementCnt;
1181 pdschSetup->pdsch_TimeDomainAllocationList->list.size = \
1182 elementCnt * sizeof(PDSCH_TimeDomainResourceAllocation_t *);
1184 DU_ALLOC(pdschSetup->pdsch_TimeDomainAllocationList->list.array,\
1185 pdschSetup->pdsch_TimeDomainAllocationList->list.size);
1186 if(!pdschSetup->pdsch_TimeDomainAllocationList->list.array)
1188 DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1192 for(idx=0; idx<elementCnt; idx++)
1194 DU_ALLOC(pdschSetup->pdsch_TimeDomainAllocationList->list.array[idx],\
1195 sizeof(PDSCH_TimeDomainResourceAllocation_t));
1196 if(!pdschSetup->pdsch_TimeDomainAllocationList->list.array[idx])
1198 DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1204 timeDomRsrcAllocInfo = pdschSetup->pdsch_TimeDomainAllocationList->list.array[idx];
1207 DU_ALLOC(timeDomRsrcAllocInfo->k0, sizeof(long));
1208 if(!timeDomRsrcAllocInfo->k0)
1210 DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1213 *timeDomRsrcAllocInfo->k0 = duPdschCfg.k0;
1215 timeDomRsrcAllocInfo->mappingType = duPdschCfg.mapType;
1216 timeDomRsrcAllocInfo->startSymbolAndLength = duPdschCfg.sliv;
1222 DU_LOG("\nDU APP: Invalid PDSCH Configuration type");
1228 }/* BuildPdschCfgCommon */
1230 /*******************************************************************
1232 * @brief Builds DL BWP common
1236 * Function : BuildBwpDlCommon
1239 * Builds DL BWP common
1241 * @params[in] BWP_DownlinkCommon_t pointer
1242 * @return ROK - success
1245 * ****************************************************************/
1246 uint8_t BuildBwpDlCommon(BWP_DownlinkCommon_t *bwp)
1249 DlCfgCommon duDlCfg;
1251 duDlCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg;
1253 bwp->genericParameters.locationAndBandwidth = duDlCfg.locAndBw;
1254 bwp->genericParameters.subcarrierSpacing = duDlCfg.dlScsCarrier.scs;
1256 /* PDCCH Config Common */
1257 DU_ALLOC(bwp->pdcch_ConfigCommon, \
1258 sizeof(struct BWP_DownlinkCommon__pdcch_ConfigCommon));
1259 if(!bwp->pdcch_ConfigCommon)
1261 DU_LOG("\nDU APP : DL BWP memory allocation failed");
1264 ret=BuildPdcchCfgCommon(bwp->pdcch_ConfigCommon);
1269 /* PDSCH Config Common */
1270 DU_ALLOC(bwp->pdsch_ConfigCommon, \
1271 sizeof(struct BWP_DownlinkCommon__pdsch_ConfigCommon));
1272 if(!bwp->pdsch_ConfigCommon)
1274 DU_LOG("\nDU APP : DL BWP memory allocation failed");
1277 ret=BuildPdschCfgCommon(bwp->pdsch_ConfigCommon);
1283 } /* BuildBwpDlCommon */
1285 /*******************************************************************
1287 * @brief Build BCCH configuration
1291 * Function : BuildBcchConfig
1294 * Build BCCH configuration
1296 * @params[in] BCCH_Config_t pointer
1297 * @return ROK - success
1300 * ****************************************************************/
1302 uint8_t BuildBcchConfig(BCCH_Config_t *bcchCfg)
1306 duBcchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.bcchCfg;
1308 bcchCfg->modificationPeriodCoeff = duBcchCfg.modPrdCoeff;
1311 }/* BuildBcchConfig */
1313 /*******************************************************************
1315 * @brief Builds PCCH configuration
1319 * Function : BuildPcchConfig
1322 * Builds PCCH configuration
1325 * @return ROK - success
1328 * ****************************************************************/
1329 uint8_t BuildPcchConfig(PCCH_Config_t *pcchCfg)
1333 duPcchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pcchCfg;
1335 pcchCfg->defaultPagingCycle = duPcchCfg.dfltPagingCycle;
1336 pcchCfg->nAndPagingFrameOffset.present = duPcchCfg.nAndPagingFrmOffPresent;
1337 switch(pcchCfg->nAndPagingFrameOffset.present)
1339 case PCCH_Config__nAndPagingFrameOffset_PR_NOTHING:
1344 case PCCH_Config__nAndPagingFrameOffset_PR_oneT:
1348 case PCCH_Config__nAndPagingFrameOffset_PR_halfT:
1353 case PCCH_Config__nAndPagingFrameOffset_PR_quarterT:
1358 case PCCH_Config__nAndPagingFrameOffset_PR_oneEighthT:
1363 case PCCH_Config__nAndPagingFrameOffset_PR_oneSixteenthT:
1370 DU_LOG("\nDU APP : Invalid nAndPagingFrameOffset configuration");
1374 pcchCfg->ns = duPcchCfg.numPagingOcc;
1377 }/* BuildPcchConfig */
1379 /*******************************************************************
1381 * @brief Builds Frequency Info for Downlink
1385 * Function : BuildFreqInfoDl
1388 * Builds Frequency Info for Downlink
1391 * @return ROK - success
1394 * ****************************************************************/
1396 uint8_t BuildFreqInfoDl(FrequencyInfoDL_SIB_t *frequencyInfoDL)
1402 NR_MultiBandInfo_t *multiBandInfo;
1404 dlCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg;
1406 /* NR Multi-Band Info */
1407 elementCnt = ODU_VALUE_ONE;
1408 frequencyInfoDL->frequencyBandList.list.count = elementCnt;
1409 frequencyInfoDL->frequencyBandList.list.size = \
1410 elementCnt * sizeof(NR_MultiBandInfo_t *);
1412 DU_ALLOC(frequencyInfoDL->frequencyBandList.list.array, \
1413 frequencyInfoDL->frequencyBandList.list.size);
1414 if(!frequencyInfoDL->frequencyBandList.list.array)
1416 DU_LOG("\nDU APP : SIB1 DL Configuration memory allocation failed");
1420 for(idx = 0; idx < elementCnt; idx++)
1422 DU_ALLOC(frequencyInfoDL->frequencyBandList.list.array[idx],\
1423 sizeof(NR_MultiBandInfo_t));
1424 if(!frequencyInfoDL->frequencyBandList.list.array[idx])
1426 DU_LOG("\nDU APP : SIB1 DL Configuration memory allocation failed");
1432 multiBandInfo = frequencyInfoDL->frequencyBandList.list.array[idx];
1434 /* Frequency band indicator */
1435 DU_ALLOC(multiBandInfo->freqBandIndicatorNR, sizeof(FreqBandIndicatorNR_t));
1436 if(!multiBandInfo->freqBandIndicatorNR)
1438 DU_LOG("\nDU APP : SIB1 DL Configuration memory allocation failed");
1441 *multiBandInfo->freqBandIndicatorNR = dlCfg.freqBandInd;
1443 /* Offset to Point A */
1444 frequencyInfoDL->offsetToPointA = dlCfg.offsetToPointA;
1446 /* Subcarrier Spacing specifc carrier */
1447 elementCnt = ODU_VALUE_ONE;
1448 frequencyInfoDL->scs_SpecificCarrierList.list.count = elementCnt;
1449 frequencyInfoDL->scs_SpecificCarrierList.list.size = \
1450 elementCnt * sizeof(SCS_SpecificCarrier_t *);
1451 ret= BuildScsSpecificCarrierListDl(&frequencyInfoDL->scs_SpecificCarrierList);
1458 }/* BuildFreqInfoDl */
1460 /*******************************************************************
1462 * @brief Builds DL configuration common for SIB
1466 * Function : BuildDlCfgCommSib
1469 * Builds DL configuration common for SIB
1471 * @params[in] DownlinkConfigCommonSIB_t pointer
1472 * @return ROK - success
1475 * ****************************************************************/
1477 uint8_t BuildDlCfgCommSib(DownlinkConfigCommonSIB_t *dlCfg)
1479 /* DL frequency info */
1481 ret = BuildFreqInfoDl(&dlCfg->frequencyInfoDL);
1487 /* BWP Downlink Common */
1488 ret = BuildBwpDlCommon(&dlCfg->initialDownlinkBWP);
1494 ret = BuildBcchConfig(&dlCfg->bcch_Config);
1500 ret = BuildPcchConfig(&dlCfg->pcch_Config);
1506 } /* BuildDlCfgCommSib */
1508 /*******************************************************************
1510 * @brief Builds SCS specific carrier list for UL
1514 * Function : BuildScsSpecificCarrierListUl
1517 * Builds SCS specific carrier list for UL
1520 * @return ROK - success
1523 * ****************************************************************/
1525 uint8_t BuildScsSpecificCarrierListUl
1527 struct FrequencyInfoUL_SIB__scs_SpecificCarrierList *scsCarrierList
1531 ScsSpecCarrier duScsSpecCarrier;
1533 duScsSpecCarrier = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.ulScsCarrier;
1535 DU_ALLOC(scsCarrierList->list.array, scsCarrierList->list.size);
1536 if(!scsCarrierList->list.array)
1538 DU_LOG("\nDU APP : SCS Specific Carrier list memory allocation failed");
1542 for(idx = 0; idx < scsCarrierList->list.count; idx++)
1544 DU_ALLOC(scsCarrierList->list.array[idx], sizeof(SCS_SpecificCarrier_t));
1545 if(!scsCarrierList->list.array[idx])
1547 DU_LOG("\nDU APP : SCS Specific Carrier list memory allocation failed");
1552 scsCarrierList->list.array[idx]->offsetToCarrier = duScsSpecCarrier.scsOffset;
1553 scsCarrierList->list.array[idx]->subcarrierSpacing = duScsSpecCarrier.scs;
1554 scsCarrierList->list.array[idx]->carrierBandwidth = duScsSpecCarrier.scsBw;
1557 } /* End of BuildScsSpecificCarrierListUl */
1559 /*******************************************************************
1561 * @brief Builds frequency infor for UL
1565 * Function : BuildFreqInfoUl
1568 * Builds frequency infor for UL
1570 * @params[in] FrequencyInfoUL_SIB_t pointer
1571 * @return ROK - success
1574 * ****************************************************************/
1576 uint8_t BuildFreqInfoUl(FrequencyInfoUL_SIB_t *frequencyInfoUL)
1581 ulCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg;
1583 /* Subcarrier Spacing specifc carrier */
1584 elementCnt = ODU_VALUE_ONE;
1585 frequencyInfoUL->scs_SpecificCarrierList.list.count = elementCnt;
1586 frequencyInfoUL->scs_SpecificCarrierList.list.size = \
1587 elementCnt * sizeof(SCS_SpecificCarrier_t *);
1588 ret=BuildScsSpecificCarrierListUl(&frequencyInfoUL->scs_SpecificCarrierList);
1594 DU_ALLOC(frequencyInfoUL->p_Max, sizeof(P_Max_t));
1595 if(!frequencyInfoUL->p_Max)
1597 DU_LOG("\nDU APP : UL Frequency Infoo memory allocation failure");
1600 *frequencyInfoUL->p_Max = ulCfg.pMax;
1603 }/* BuildFreqInfoUl */
1605 /*******************************************************************
1607 * @brief Builds RACH configuration common
1611 * Function : BuildRachCfgCommon
1614 * Builds RACH configuration common
1616 * @params[in] BWP_UplinkCommon__rach_ConfigCommon pointer
1617 * @return ROK - success
1620 * ****************************************************************/
1622 uint8_t BuildRachCfgCommon(struct BWP_UplinkCommon__rach_ConfigCommon *rachCfg)
1624 RachCfgCommon duRachCfg;
1625 RACH_ConfigCommon_t *setup;
1627 duRachCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.rachCfg;
1629 rachCfg->present = duRachCfg.present;
1630 switch(rachCfg->present)
1632 case BWP_UplinkCommon__rach_ConfigCommon_PR_NOTHING:
1637 case BWP_UplinkCommon__rach_ConfigCommon_PR_release:
1642 case BWP_UplinkCommon__rach_ConfigCommon_PR_setup:
1644 DU_ALLOC(rachCfg->choice.setup, sizeof(RACH_ConfigCommon_t));
1645 if(!rachCfg->choice.setup)
1647 DU_LOG("\nDU APP : Rach Config memory alloc failed");
1650 setup = rachCfg->choice.setup;
1652 /* Generic RACH Configuration */
1653 setup->rach_ConfigGeneric.prach_ConfigurationIndex = duRachCfg.prachCfgIdx;
1654 setup->rach_ConfigGeneric.msg1_FDM = duRachCfg.msg1Fdm;
1655 setup->rach_ConfigGeneric.msg1_FrequencyStart = duRachCfg.msg1FreqStart;
1656 setup->rach_ConfigGeneric.zeroCorrelationZoneConfig = duRachCfg.zeroCorrZoneCfg;
1657 setup->rach_ConfigGeneric.preambleReceivedTargetPower = duRachCfg.preambleRcvdTgtPwr;
1658 setup->rach_ConfigGeneric.preambleTransMax = duRachCfg.preambleTransMax;
1659 setup->rach_ConfigGeneric.powerRampingStep = duRachCfg.pwrRampingStep;
1660 setup->rach_ConfigGeneric.ra_ResponseWindow = duRachCfg.raRspWindow;
1662 /* Total number of RA preambles */
1663 DU_ALLOC(setup->totalNumberOfRA_Preambles, sizeof(long));
1664 if(!setup->totalNumberOfRA_Preambles)
1666 DU_LOG("\nDU APP : Rach Config memory alloc failed");
1669 *setup->totalNumberOfRA_Preambles = duRachCfg.numRaPreamble;
1671 /* SSB per RACH occassion and CB Preambles per SSB */
1672 DU_ALLOC(setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB,\
1673 sizeof(struct RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB));
1674 if(!setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB)
1676 DU_LOG("\nDU APP : Rach Config memory alloc failed");
1679 setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present = \
1680 duRachCfg.ssbPerRachOccPresent;
1681 switch(setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present)
1683 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_NOTHING:
1688 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneEighth:
1693 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneFourth:
1698 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneHalf:
1703 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one:
1705 setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.one =\
1706 duRachCfg.numSsbPerRachOcc;
1708 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_two:
1713 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_four:
1718 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_eight:
1723 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_sixteen:
1730 DU_LOG("\nDU APP: Invalid value for \
1731 ssb_PerRach_OccassionAndCB_PreamblesPerSSB");
1736 /* RA Contention Resolution Timer */
1737 setup->ra_ContentionResolutionTimer = duRachCfg.contResTimer;
1739 /* RSRP Threshold SSB */
1740 DU_ALLOC(setup->rsrp_ThresholdSSB, sizeof(RSRP_Range_t));
1741 if(!setup->rsrp_ThresholdSSB)
1743 DU_LOG("\nDU APP : Rach Config memory alloc failed");
1746 *setup->rsrp_ThresholdSSB = duRachCfg.rsrpThreshSsb;
1748 /* Root Sequence index */
1749 setup->prach_RootSequenceIndex.present = duRachCfg.rootSeqIdxPresent;
1750 switch(setup->prach_RootSequenceIndex.present)
1752 case RACH_ConfigCommon__prach_RootSequenceIndex_PR_NOTHING:
1757 case RACH_ConfigCommon__prach_RootSequenceIndex_PR_l839:
1762 case RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139:
1764 setup->prach_RootSequenceIndex.choice.l139 = duRachCfg.rootSeqIdx;
1769 DU_LOG("\nDU APP: Inavlid PRACH root sequence index type");
1774 /* Msg 1 Subcarrier spacing */
1775 DU_ALLOC(setup->msg1_SubcarrierSpacing, sizeof(SubcarrierSpacing_t));
1776 if(!setup->msg1_SubcarrierSpacing)
1778 DU_LOG("\nDU APP : Rach Config memory alloc failed");
1781 *setup->msg1_SubcarrierSpacing = duRachCfg.msg1Scs;
1783 /* Restricted Set Config */
1784 setup->restrictedSetConfig = duRachCfg.restrictedSetCfg;
1790 DU_LOG("\nDU APP : Invalid RACH Config type ");
1795 }/* BuildRachCfgCommon */
1797 /*******************************************************************
1799 * @brief Builds PUSCH configuration for common
1803 * Function : BuildPuschCfgCommon
1806 * Builds PUSCH configuration for common
1809 * @return ROK - success
1812 * ****************************************************************/
1814 uint8_t BuildPuschCfgCommon(struct BWP_UplinkCommon__pusch_ConfigCommon *puschCfg)
1818 PuschCfgCommon duPuschCfg;
1819 PUSCH_ConfigCommon_t *setup;
1820 PUSCH_TimeDomainResourceAllocation_t *timeDomRsrcAllocInfo;
1822 duPuschCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.puschCfg;
1824 puschCfg->present = duPuschCfg.present;
1825 switch(puschCfg->present)
1827 case BWP_UplinkCommon__pusch_ConfigCommon_PR_NOTHING:
1832 case BWP_UplinkCommon__pusch_ConfigCommon_PR_release:
1837 case BWP_UplinkCommon__pusch_ConfigCommon_PR_setup:
1839 DU_ALLOC(puschCfg->choice.setup, sizeof(PUSCH_ConfigCommon_t));
1840 if(!puschCfg->choice.setup)
1842 DU_LOG("\nDU APP : PUSCH Config memory alloc failed");
1845 setup = puschCfg->choice.setup;
1847 /* Time Domain Resource Allocation List */
1848 DU_ALLOC(setup->pusch_TimeDomainAllocationList,\
1849 sizeof(PUSCH_TimeDomainResourceAllocationList_t));
1850 if(!setup->pusch_TimeDomainAllocationList)
1852 DU_LOG("\nDU APP : PUSCH Config memory alloc failed");
1855 elementCnt = ODU_VALUE_ONE;
1856 setup->pusch_TimeDomainAllocationList->list.count = elementCnt;
1857 setup->pusch_TimeDomainAllocationList->list.size = \
1858 elementCnt * sizeof(PUSCH_TimeDomainResourceAllocation_t *);
1860 DU_ALLOC(setup->pusch_TimeDomainAllocationList->list.array, \
1861 setup->pusch_TimeDomainAllocationList->list.size);
1862 if(!setup->pusch_TimeDomainAllocationList->list.array)
1864 DU_LOG("\nDU APP : PUSCH Config memory alloc failed");
1868 for(idx=0; idx<elementCnt; idx++)
1870 DU_ALLOC(setup->pusch_TimeDomainAllocationList->list.array[idx],\
1871 sizeof(PUSCH_TimeDomainResourceAllocation_t));
1872 if(!setup->pusch_TimeDomainAllocationList->list.array[idx])
1874 DU_LOG("\nDU APP : PUSCH Config memory alloc failed");
1880 timeDomRsrcAllocInfo = setup->pusch_TimeDomainAllocationList->list.array[idx];
1883 DU_ALLOC(timeDomRsrcAllocInfo->k2, sizeof(long));
1884 if(!timeDomRsrcAllocInfo->k2)
1886 DU_LOG("\nDU APP : PUSCH Config memory alloc failed");
1889 *timeDomRsrcAllocInfo->k2 = duPuschCfg.k2;
1891 timeDomRsrcAllocInfo->mappingType = duPuschCfg.mapType;
1892 timeDomRsrcAllocInfo->startSymbolAndLength = duPuschCfg.sliv;
1894 /* Msg3 Delta Preamble */
1895 DU_ALLOC(setup->msg3_DeltaPreamble, sizeof(long));
1896 if(!setup->msg3_DeltaPreamble)
1898 DU_LOG("\nDU APP : PUSCH Config memory alloc failed");
1901 *setup->msg3_DeltaPreamble = duPuschCfg.msg3DeltaPreamble;
1903 /* P0 Nominal with grnat */
1904 DU_ALLOC(setup->p0_NominalWithGrant, sizeof(long));
1905 if(!setup->p0_NominalWithGrant)
1907 DU_LOG("\nDU APP : PUSCH Config memory alloc failed");
1910 *setup->p0_NominalWithGrant = duPuschCfg.p0NominalWithGrant;
1916 DU_LOG("\nDU APP : Invalid PUSCH configuration type ");
1922 }/* BuildPuschCfgCommon */
1924 /*******************************************************************
1926 * @brief Builds PUCCH configuration common
1930 * Function : BuildPucchCfgCommon
1933 * Builds PUCCH configuration common
1936 * @return ROK - success
1939 * ****************************************************************/
1941 uint8_t BuildPucchCfgCommon( struct BWP_UplinkCommon__pucch_ConfigCommon *pucchCfg)
1943 PucchCfgCommon duPucchCfg;
1944 PUCCH_ConfigCommon_t *setup;
1946 duPucchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.pucchCfg;
1948 pucchCfg->present = duPucchCfg.present;
1949 switch(pucchCfg->present)
1951 case BWP_UplinkCommon__pucch_ConfigCommon_PR_NOTHING:
1956 case BWP_UplinkCommon__pucch_ConfigCommon_PR_release:
1961 case BWP_UplinkCommon__pucch_ConfigCommon_PR_setup:
1963 DU_ALLOC(pucchCfg->choice.setup, sizeof(PUCCH_ConfigCommon_t));
1964 if(!pucchCfg->choice.setup)
1966 DU_LOG("\nDU APP : PUCCH Config memory alloc failed");
1969 setup = pucchCfg->choice.setup;
1971 /* Resource Common */
1972 DU_ALLOC(setup->pucch_ResourceCommon, sizeof(long));
1973 if(!setup->pucch_ResourceCommon)
1975 DU_LOG("\nDU APP : PUCCH Config memory alloc failed");
1978 *setup->pucch_ResourceCommon = duPucchCfg.rsrcComm;
1981 setup->pucch_GroupHopping = duPucchCfg.grpHop;
1984 DU_ALLOC(setup->p0_nominal, sizeof(long));
1985 if(!setup->p0_nominal)
1987 DU_LOG("\nDU APP : PUCCH Config memory alloc failed");
1990 *setup->p0_nominal = duPucchCfg.p0Nominal;
1996 DU_LOG("\nDU APP : Invalid PUCCH Config type");
2001 }/* BuildPucchCfgCommon */
2003 /*******************************************************************
2005 * @brief Builds UL BWP Common
2009 * Function : BuildBwpUlCommon
2012 * Builds UL BWP Common
2014 * @params[in] BWP_UplinkCommon_t pointer
2015 * @return ROK - success
2018 * ****************************************************************/
2020 uint8_t BuildBwpUlCommon(BWP_UplinkCommon_t *bwp)
2023 UlCfgCommon duUlCfg;
2025 duUlCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg;
2027 bwp->genericParameters.locationAndBandwidth = duUlCfg.locAndBw;
2028 bwp->genericParameters.subcarrierSpacing = duUlCfg.ulScsCarrier.scs;
2030 /* RACH Config Common */
2031 DU_ALLOC(bwp->rach_ConfigCommon,\
2032 sizeof(struct BWP_UplinkCommon__rach_ConfigCommon));
2033 if(!bwp->rach_ConfigCommon)
2035 DU_LOG("\nDU APP : UL BWP memory allocation failed");
2038 ret = BuildRachCfgCommon(bwp->rach_ConfigCommon);
2043 RachCfgCommonret=ROK;
2045 /* PUSCH Config Common */
2046 DU_ALLOC(bwp->pusch_ConfigCommon,\
2047 sizeof(struct BWP_UplinkCommon__pusch_ConfigCommon));
2048 if(!bwp->pusch_ConfigCommon)
2050 DU_LOG("\nDU APP : UL BWP memory allocation failed");
2053 ret = BuildPuschCfgCommon(bwp->pusch_ConfigCommon);
2058 PuschCfgCommonret = ROK;
2060 /* PUCCH Config Common */
2061 DU_ALLOC(bwp->pucch_ConfigCommon,\
2062 sizeof(struct BWP_UplinkCommon__pucch_ConfigCommon));
2063 if(!bwp->pucch_ConfigCommon)
2065 DU_LOG("\nDU APP : UL BWP memory allocation failed");
2068 ret = BuildPucchCfgCommon(bwp->pucch_ConfigCommon);
2074 }/* BuildBwpUlCommon */
2076 /*******************************************************************
2078 * @brief Builds UL config common for SIB
2082 * Function : BuildUlCfgCommSib
2085 * Builds UL config common for SIB
2087 * @params[in] UplinkConfigCommonSIB_t pointer
2088 * @return ROK - success
2091 * ****************************************************************/
2093 uint8_t BuildUlCfgCommSib(UplinkConfigCommonSIB_t *ulCfg)
2096 /* UL frequency info */
2097 ret = BuildFreqInfoUl(&ulCfg->frequencyInfoUL);
2102 /* BWP Uplink Common */
2103 ret = BuildBwpUlCommon(&ulCfg->initialUplinkBWP);
2108 /* Time Alignment timer */
2109 ulCfg->timeAlignmentTimerCommon = \
2110 duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.timeAlignTimerComm;
2113 }/* BuildUlCfgCommSib */
2115 /*******************************************************************
2117 * @brief Builds TDD UL DL configuration common
2121 * Function : BuildTddUlDlCfgComm
2124 * Builds TDD UL DL configuration common
2126 * @params[in] TDD_UL_DL_ConfigCommon_t pointer
2127 * @return ROK - success
2130 * ****************************************************************/
2132 uint8_t BuildTddUlDlCfgComm(TDD_UL_DL_ConfigCommon_t *tddCfg)
2134 TddUlDlCfgCommon duTddCfg;
2136 duTddCfg = duCfgParam.sib1Params.srvCellCfgCommSib.tddCfg;
2138 /* Reference Subcarrier spacing */
2139 tddCfg->referenceSubcarrierSpacing = duTddCfg.refScs;
2142 tddCfg->pattern1.dl_UL_TransmissionPeriodicity = duTddCfg.txPrd;
2143 tddCfg->pattern1.nrofDownlinkSlots = duTddCfg.numDlSlots;
2144 tddCfg->pattern1.nrofDownlinkSymbols = duTddCfg.numDlSymbols;
2145 tddCfg->pattern1.nrofUplinkSlots = duTddCfg.numUlSlots;
2146 tddCfg->pattern1.nrofUplinkSymbols = duTddCfg.numUlSymbols;
2150 }/* BuildTddUlDlCfgComm */
2152 /*******************************************************************
2154 * @brief Builds Serving cell config common in SIB1 message
2158 * Function : BuildServCellCfgCommonSib
2161 * Building Serving cell config common in SIB1 message
2163 * @params[in] ServingCellConfigCommonSIB_t pointer
2164 * @return ROK - success
2167 * ****************************************************************/
2168 uint8_t BuildServCellCfgCommonSib(ServingCellConfigCommonSIB_t *srvCellCfg)
2170 SrvCellCfgCommSib duSrvCellCfg;
2171 BIT_STRING_t *ssbPosInBurst;
2173 duSrvCellCfg = duCfgParam.sib1Params.srvCellCfgCommSib;
2175 /* SSB Position in Burst */
2176 ssbPosInBurst = &srvCellCfg->ssb_PositionsInBurst.inOneGroup;
2177 ssbPosInBurst->size = 1;
2178 DU_ALLOC(ssbPosInBurst->buf, ssbPosInBurst->size * sizeof(uint8_t));
2179 if(!ssbPosInBurst->buf)
2181 DU_LOG("\nDU APP : Serving cell config common memory allocation failure");
2184 ssbPosInBurst->buf[0] = duSrvCellCfg.ssbPosInBurst;
2185 ssbPosInBurst->bits_unused = 0;
2187 switch(duSrvCellCfg.ssbPrdServingCell)
2189 case SSB_PERIODICITY_5MS:
2190 srvCellCfg->ssb_PeriodicityServingCell = \
2191 ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms5;
2193 case SSB_PERIODICITY_10MS:
2194 srvCellCfg->ssb_PeriodicityServingCell = \
2195 ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms10;
2197 case SSB_PERIODICITY_20MS:
2198 srvCellCfg->ssb_PeriodicityServingCell = \
2199 ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms20;
2201 case SSB_PERIODICITY_40MS:
2202 srvCellCfg->ssb_PeriodicityServingCell = \
2203 ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms40;
2205 case SSB_PERIODICITY_80MS:
2206 srvCellCfg->ssb_PeriodicityServingCell = \
2207 ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms80;
2209 case SSB_PERIODICITY_160MS:
2210 srvCellCfg->ssb_PeriodicityServingCell = \
2211 ServingCellConfigCommonSIB__ssb_PeriodicityServingCell_ms160;
2215 srvCellCfg->ss_PBCH_BlockPower = duSrvCellCfg.ssPbchBlockPwr;
2217 /* Downlink config common */
2218 ret = BuildDlCfgCommSib(&srvCellCfg->downlinkConfigCommon);
2223 DlCfgCommSibret = ROK;
2225 /* Uplink Config Comm */
2226 DU_ALLOC(srvCellCfg->uplinkConfigCommon, sizeof(UplinkConfigCommonSIB_t));
2227 if(!srvCellCfg->uplinkConfigCommon)
2229 DU_LOG("\nDU APP : Serving cell config common memory allocation failure");
2232 ret = BuildUlCfgCommSib(srvCellCfg->uplinkConfigCommon);
2237 UlCfgCommSibret=ROK;
2239 /* TDD UL DL Config Comm */
2240 DU_ALLOC(srvCellCfg->tdd_UL_DL_ConfigurationCommon, sizeof(TDD_UL_DL_ConfigCommon_t));
2241 if(!srvCellCfg->tdd_UL_DL_ConfigurationCommon)
2243 DU_LOG("\nDU APP : Serving cell config common memory allocation failure");
2246 ret = BuildTddUlDlCfgComm(srvCellCfg->tdd_UL_DL_ConfigurationCommon);
2254 /*******************************************************************
2256 * @brief Builds SIB message in Served Cell Info
2260 * Function : BuildSib1Msg
2262 * Functionality: Building SIB message in Served Cell Info
2264 * @return ROK - success
2267 * ****************************************************************/
2268 uint8_t BuildSib1Msg()
2271 CellAccessRelatedInfo_t *cellAccessInfo;
2274 asn_enc_rval_t encRetVal;
2275 uint8_t ret = RFAILED;
2279 DU_ALLOC(sib1Msg, sizeof(SIB1_t));
2282 DU_LOG("DU APP: SIB1 msg memory allocation failure");
2286 elementCnt = ODU_VALUE_ONE;
2289 cellAccessInfo = &sib1Msg->cellAccessRelatedInfo;
2290 cellAccessInfo->plmn_IdentityList.list.count =
2292 cellAccessInfo->plmn_IdentityList.list.size
2293 = elementCnt * sizeof(PLMN_IdentityInfo_t *);
2295 ret1 = BuildPlmnList(cellAccessInfo);
2300 /* Connection Establish Failure Control */
2301 DU_ALLOC(sib1Msg->connEstFailureControl, sizeof(ConnEstFailureControl_t));
2302 if(!sib1Msg->connEstFailureControl)
2304 DU_LOG("DU APP: sib1Msg->connEstFailureControl memory allocation failure");
2307 sib1Msg->connEstFailureControl->connEstFailCount =\
2308 duCfgParam.sib1Params.connEstFailCnt;
2309 sib1Msg->connEstFailureControl->connEstFailOffsetValidity =\
2310 duCfgParam.sib1Params.connEstFailOffValidity;
2312 /* SI Scheduling Info */
2313 DU_ALLOC(sib1Msg->si_SchedulingInfo, sizeof(SI_SchedulingInfo_t));
2314 if(!sib1Msg->si_SchedulingInfo)
2316 DU_LOG("DU APP: sib1Msg->si_SchedulingInfo memory allocation failure");
2319 elementCnt = ODU_VALUE_ONE;
2320 sib1Msg->si_SchedulingInfo->schedulingInfoList.list.count = elementCnt;
2321 sib1Msg->si_SchedulingInfo->schedulingInfoList.list.size = elementCnt *
2322 sizeof(struct SchedulingInfo *);
2323 ret1 = BuildSiSchedInfoList(&sib1Msg->si_SchedulingInfo->schedulingInfoList);
2328 sib1Msg->si_SchedulingInfo->si_WindowLength = duCfgParam.sib1Params.siSchedInfo.winLen;
2330 /* Serving Cell Config Common */
2331 DU_ALLOC(sib1Msg->servingCellConfigCommon, sizeof(ServingCellConfigCommonSIB_t));
2332 if(!sib1Msg->servingCellConfigCommon)
2334 DU_LOG("DU APP: sib1Msg->servingCellConfigCommon memory allocation failure");
2337 ret1 = BuildServCellCfgCommonSib(sib1Msg->servingCellConfigCommon);
2343 xer_fprint(stdout, &asn_DEF_SIB1, sib1Msg);
2345 /* Encode the F1SetupRequest type as APER */
2346 cmMemset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
2348 encRetVal = aper_encode(&asn_DEF_SIB1, 0, sib1Msg, PrepFinalEncBuf,\
2350 printf("\nencbufSize: %d\n", encBufSize);
2351 if(encRetVal.encoded == -1)
2353 DU_LOG("\nDU APP : Could not encode SIB1 structure (at %s)\n",\
2354 encRetVal.failed_type ?
2355 encRetVal.failed_type->name :
2359 for(int i=0; i< encBufSize; i++)
2361 printf("%x\t",encBuf[i]);
2369 FreeSib1Msg(sib1Msg);
2375 /*******************************************************************
2377 * @brief : deallocating the memory of BuildSib1Msg
2381 * Function : FreeFreqInfoDl
2383 * Functionality: Freeing memory of BuildFreqInfoDl
2385 * @params[in] : FrequencyInfoDL_SIB_t *frequencyInfoDL
2388 *******************************************************************/
2389 void FreeFreqInfoDl(FrequencyInfoDL_SIB_t *frequencyInfoDL)
2394 /* Free DL frequency info */
2395 if(!frequencyInfoDL->frequencyBandList.list.array)
2397 /*Free Frequency band indicator */
2398 if(!frequencyInfoDL->frequencyBandList.list.array[idx])
2400 if(!frequencyInfoDL->frequencyBandList.list.array[idx]->\
2401 freqBandIndicatorNR)
2403 if(!frequencyInfoDL->scs_SpecificCarrierList.list.array)
2405 for(idx1 = 0;idx1<frequencyInfoDL->scs_SpecificCarrierList.list.count;idx1++)
2407 if(!frequencyInfoDL->scs_SpecificCarrierList.list.array[idx1])
2409 DU_FREE(frequencyInfoDL->scs_SpecificCarrierList.list.\
2410 array[idx1], sizeof(SCS_SpecificCarrier_t));
2413 DU_FREE(frequencyInfoDL->scs_SpecificCarrierList.list.array,
2414 frequencyInfoDL->scs_SpecificCarrierList.list.size);
2416 DU_FREE(frequencyInfoDL->frequencyBandList.list.\
2417 array[idx]->freqBandIndicatorNR, sizeof(FreqBandIndicatorNR_t));
2420 for(idx = 0; idx <frequencyInfoDL->frequencyBandList.list.count; idx++)
2422 if(!frequencyInfoDL->frequencyBandList.list.array[idx])
2424 DU_FREE(frequencyInfoDL->frequencyBandList.list.array[idx],\
2425 sizeof(NR_MultiBandInfo_t));
2428 DU_FREE(frequencyInfoDL->frequencyBandList.list.array,\
2429 frequencyInfoDL->frequencyBandList.list.size);
2432 /*******************************************************************
2434 * @brief : deallocating the memory of BuildSib1Msg
2438 * Function : FreeCommonSerachSpaceList
2440 * Functionality: deallocating the memory of BuildCommonSerachSpaceList
2442 * @params[in] :struct PDCCH_ConfigCommon__commonSearchSpaceList *searchSpclist
2445 *******************************************************************/
2446 void FreeCommonSerachSpaceList( struct PDCCH_ConfigCommon__commonSearchSpaceList
2450 SearchSpace_t *searchSpace= NULLP;
2452 if(!searchSpclist->list.array)
2454 if( searchSpclist->list.array[idx] != NULLP)
2456 searchSpace= searchSpclist->list.array[idx];
2457 if(!searchSpace->controlResourceSetId)
2459 if(!searchSpace->monitoringSlotPeriodicityAndOffset)
2461 if(!searchSpace->monitoringSymbolsWithinSlot)
2463 if(!searchSpace->monitoringSymbolsWithinSlot->buf)
2465 if(!searchSpace->nrofCandidates)
2467 if(!searchSpace->searchSpaceType)
2469 switch(searchSpace->searchSpaceType->present)
2471 case SearchSpace__searchSpaceType_PR_NOTHING:
2473 case SearchSpace__searchSpaceType_PR_common:
2475 if(!searchSpace->searchSpaceType->choice.common)
2477 if(!searchSpace->searchSpaceType->choice.\
2478 common->dci_Format0_0_AndFormat1_0)
2480 DU_FREE(searchSpace->searchSpaceType->choice.\
2481 common->dci_Format0_0_AndFormat1_0,sizeof(struct\
2482 SearchSpace__searchSpaceType__common__dci_Format0_0_AndFormat1_0));
2484 DU_FREE(searchSpace->searchSpaceType->choice.common,\
2485 sizeof(struct SearchSpace__searchSpaceType__common));
2489 case SearchSpace__searchSpaceType_PR_ue_Specific:
2494 DU_FREE(searchSpace->searchSpaceType,\
2495 sizeof( struct SearchSpace__searchSpaceType));
2497 DU_FREE(searchSpace->nrofCandidates,\
2498 sizeof(struct SearchSpace__nrofCandidates));
2500 DU_FREE(searchSpace->monitoringSymbolsWithinSlot->buf,\
2501 searchSpace->monitoringSymbolsWithinSlot->size);
2503 DU_FREE(searchSpace->monitoringSymbolsWithinSlot,\
2504 sizeof(BIT_STRING_t));
2506 DU_FREE(searchSpace->monitoringSlotPeriodicityAndOffset,\
2507 sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
2509 DU_FREE(searchSpace->controlResourceSetId,sizeof(ControlResourceSetId_t));
2512 for(idx = 0; idx < searchSpclist->list.count; idx++)
2514 if(!searchSpclist->list.array[idx])
2516 DU_FREE(searchSpclist->list.array[idx], sizeof(SearchSpace_t));
2519 DU_FREE(searchSpclist->list.array, searchSpclist->list.size)
2522 /*******************************************************************
2524 * @brief : deallocating the memory of BuildSib1Msg
2528 * Function : FreeBwpDlCommon
2530 * Functionality :Deallocating memory of BuildBwpDlCommon
2532 * @params[in] : BWP_DownlinkCommon_t *bwp
2536 *******************************************************************/
2537 void FreeBwpDlCommon(BWP_DownlinkCommon_t *bwp)
2540 struct BWP_DownlinkCommon__pdsch_ConfigCommon *pdschCfg=bwp->pdsch_ConfigCommon;
2541 struct BWP_DownlinkCommon__pdcch_ConfigCommon *pdcchCfg=bwp->pdcch_ConfigCommon;
2542 pdcchCfg->present=duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdcchCfg.present;
2543 pdschCfg->present=duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdschCfg.present;
2545 if(!bwp->pdcch_ConfigCommon)
2547 if(!bwp->pdsch_ConfigCommon)
2549 switch( pdschCfg->present)
2551 case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_NOTHING:
2556 case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_release:
2561 case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup:
2563 if(!pdschCfg->choice.setup)
2565 if(!pdschCfg->choice.setup->pdsch_TimeDomainAllocationList)
2567 if(!pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array)
2569 if(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx]!= NULLP)
2571 if(!pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx]->k0)
2573 DU_FREE(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx]->k0,\
2577 for(idx=0; idx<pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.count ; idx++)
2579 if(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx]!=
2582 DU_FREE(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx],\
2583 sizeof(PDSCH_TimeDomainResourceAllocation_t));
2586 DU_FREE(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array,\
2587 pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.size);
2589 DU_FREE(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList,\
2590 sizeof(PDSCH_TimeDomainResourceAllocationList_t));
2592 DU_FREE(pdschCfg->choice.setup,
2593 sizeof(PDSCH_ConfigCommon_t));
2599 DU_FREE(bwp->pdsch_ConfigCommon,\
2600 sizeof(struct BWP_DownlinkCommon__pdsch_ConfigCommon));
2603 switch(pdcchCfg->present)
2605 case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_NOTHING:
2610 case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_release:
2615 case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup:
2617 if(!pdcchCfg->choice.setup)
2619 /* Control Resource Set Zero */
2620 if(! pdcchCfg->choice.setup->controlResourceSetZero)
2622 /* Search space zero */
2623 if(! pdcchCfg->choice.setup->searchSpaceZero)
2625 /* Common Search Space List */
2626 if(! pdcchCfg->choice.setup->commonSearchSpaceList)
2628 if(CommonSerachSpaceListret==ROK)
2630 if(!pdcchCfg->choice.setup->searchSpaceSIB1)
2632 if(!pdcchCfg->choice.setup->pagingSearchSpace)
2634 if(!pdcchCfg->choice.setup->ra_SearchSpace)
2636 DU_FREE(pdcchCfg->choice.setup->ra_SearchSpace,
2637 sizeof(SearchSpaceId_t));
2639 DU_FREE( pdcchCfg->choice.setup->pagingSearchSpace,
2640 sizeof(SearchSpaceId_t));
2642 DU_FREE( pdcchCfg->choice.setup->searchSpaceSIB1,
2643 sizeof(SearchSpaceId_t));
2647 FreeCommonSerachSpaceList(pdcchCfg->choice.setup->commonSearchSpaceList);
2649 DU_FREE( pdcchCfg->choice.setup->commonSearchSpaceList,\
2651 PDCCH_ConfigCommon__commonSearchSpaceList));
2653 DU_FREE( pdcchCfg->choice.setup->searchSpaceZero,
2654 sizeof(SearchSpaceZero_t));
2656 DU_FREE( pdcchCfg->choice.setup->controlResourceSetZero,
2657 sizeof(ControlResourceSetZero_t));
2659 DU_FREE(pdcchCfg->choice.setup,
2660 sizeof(PDCCH_ConfigCommon_t));
2667 DU_FREE(bwp->pdcch_ConfigCommon,sizeof(struct BWP_DownlinkCommon__pdcch_ConfigCommon));
2670 /*******************************************************************
2672 * @brief deallocating the memory of BuildSib1Msg
2676 * Function: FreeUlCfgCommSib
2678 * Functionality deallocating the memory of BuildUlCfgCommSib
2680 * @params[in] : UplinkConfigCommonSIB_t *ulCfg
2684 *******************************************************************/
2685 void FreeUlCfgCommSib(UplinkConfigCommonSIB_t *ulCfg)
2688 RACH_ConfigCommon_t *setup;
2689 BWP_UplinkCommon_t *bwp=&ulCfg->initialUplinkBWP;
2690 struct FrequencyInfoUL_SIB__scs_SpecificCarrierList *scsCarrierList;
2691 struct BWP_UplinkCommon__rach_ConfigCommon *rachCfg;
2692 struct BWP_UplinkCommon__pucch_ConfigCommon *pucchCfg;
2693 struct BWP_UplinkCommon__pusch_ConfigCommon *puschCfg;
2694 puschCfg=ulCfg->initialUplinkBWP.pusch_ConfigCommon;
2695 rachCfg =bwp->rach_ConfigCommon;
2696 scsCarrierList = &ulCfg->frequencyInfoUL.scs_SpecificCarrierList;
2698 if(!scsCarrierList->list.array)
2700 if(!ulCfg->frequencyInfoUL.p_Max)
2702 if(FreqInfoUlret == ROK)
2704 if(!bwp->rach_ConfigCommon)
2706 if(RachCfgCommonret== ROK)
2708 if(!bwp->pusch_ConfigCommon)
2711 if(PuschCfgCommonret==ROK)
2713 if(!bwp->pucch_ConfigCommon)
2715 pucchCfg=bwp->pucch_ConfigCommon;
2716 switch(pucchCfg->present)
2718 case BWP_UplinkCommon__pucch_ConfigCommon_PR_NOTHING:
2720 case BWP_UplinkCommon__pucch_ConfigCommon_PR_release:
2722 case BWP_UplinkCommon__pucch_ConfigCommon_PR_setup:
2724 if(!pucchCfg->choice.setup)
2727 if(!pucchCfg->choice.setup->pucch_ResourceCommon)
2729 if(!pucchCfg->choice.setup->p0_nominal)
2731 DU_FREE(pucchCfg->choice.setup->p0_nominal,
2734 DU_FREE(pucchCfg->choice.setup->pucch_ResourceCommon,
2737 DU_FREE(pucchCfg->choice.setup,
2738 sizeof(PUCCH_ConfigCommon_t));
2744 DU_FREE(bwp->pucch_ConfigCommon,\
2746 BWP_UplinkCommon__pucch_ConfigCommon));
2749 switch(puschCfg->present)
2751 case BWP_UplinkCommon__pusch_ConfigCommon_PR_NOTHING:
2753 case BWP_UplinkCommon__pusch_ConfigCommon_PR_release:
2755 case BWP_UplinkCommon__pusch_ConfigCommon_PR_setup:
2757 if(!puschCfg->choice.setup)
2760 if(! puschCfg->choice.setup->pusch_TimeDomainAllocationList)
2762 if(! puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array)
2764 if(!puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array[idx])
2766 if(!puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array[idx]->k2)
2768 if(! puschCfg->choice.setup->msg3_DeltaPreamble)
2770 if(!puschCfg->choice.setup->p0_NominalWithGrant)
2772 DU_FREE(puschCfg->choice.setup->p0_NominalWithGrant,
2775 DU_FREE(puschCfg->choice.setup->msg3_DeltaPreamble,
2778 DU_FREE(puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.\
2779 array[idx]->k2, sizeof(long));
2783 idx<puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.count;
2786 if(!puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array[idx])
2788 DU_FREE(puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array[idx],\
2789 sizeof(PUSCH_TimeDomainResourceAllocation_t));
2792 DU_FREE(puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array,\
2793 puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.size);
2795 DU_FREE(puschCfg->choice.setup->pusch_TimeDomainAllocationList,\
2796 sizeof(PUSCH_TimeDomainResourceAllocationList_t));
2798 DU_FREE(puschCfg->choice.setup,
2799 sizeof(PUSCH_ConfigCommon_t));
2806 DU_FREE(bwp->pusch_ConfigCommon,\
2807 sizeof(struct BWP_UplinkCommon__pusch_ConfigCommon));
2810 switch(rachCfg->present)
2812 case BWP_UplinkCommon__rach_ConfigCommon_PR_NOTHING:
2814 case BWP_UplinkCommon__rach_ConfigCommon_PR_release:
2816 case BWP_UplinkCommon__rach_ConfigCommon_PR_setup:
2818 if(!rachCfg->choice.setup)
2820 setup = rachCfg->choice.setup;
2821 if(!setup->totalNumberOfRA_Preambles)
2823 if(!setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB)
2825 if(!setup->rsrp_ThresholdSSB)
2827 if(!setup->msg1_SubcarrierSpacing)
2829 DU_FREE(setup->msg1_SubcarrierSpacing,
2830 sizeof(SubcarrierSpacing_t));
2832 DU_FREE(setup->rsrp_ThresholdSSB,
2833 sizeof(RSRP_Range_t));
2835 DU_FREE(setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB,\
2837 RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB));
2839 DU_FREE(setup->totalNumberOfRA_Preambles,
2843 DU_FREE(rachCfg->choice.setup,
2844 sizeof(RACH_ConfigCommon_t));
2850 DU_FREE(bwp->rach_ConfigCommon,\
2851 sizeof(struct BWP_UplinkCommon__rach_ConfigCommon));
2854 DU_FREE(ulCfg->frequencyInfoUL.p_Max, sizeof(P_Max_t));
2856 for(idx = 0; idx < scsCarrierList->list.count; idx++)
2858 if(!scsCarrierList->list.array[idx])
2860 DU_FREE(scsCarrierList->list.array[idx],
2861 sizeof(SCS_SpecificCarrier_t));
2864 DU_FREE(scsCarrierList->list.array, scsCarrierList->list.size);
2867 /*******************************************************************
2869 * @brief : Deallocating memory of SIB1 message
2873 * Function : FreeServCellCfgCommonSib
2875 * Functionality: Deallocating memory of BuildServCellCfgCommonSib
2877 * @params[in] : ServingCellConfigCommonSIB_t *srvCellCfg
2880 *******************************************************************/
2881 void FreeServCellCfgCommonSib(ServingCellConfigCommonSIB_t *srvCellCfg)
2883 BIT_STRING_t *ssbPosInBurst;
2884 ssbPosInBurst = &srvCellCfg->ssb_PositionsInBurst.inOneGroup;
2885 DownlinkConfigCommonSIB_t *dlCfg=&srvCellCfg->downlinkConfigCommon;
2887 if(!ssbPosInBurst->buf)
2889 /* Free DL frequency info */
2890 if(FreqInfoDlret == ROK)
2892 if(DlCfgCommSibret == ROK)
2894 /* Uplink Config Comm */
2895 if(!srvCellCfg->uplinkConfigCommon)
2897 if(UlCfgCommSibret==ROK)
2899 /* TDD UL DL Config Comm */
2900 if(!srvCellCfg->tdd_UL_DL_ConfigurationCommon)
2902 DU_FREE(srvCellCfg->tdd_UL_DL_ConfigurationCommon,
2903 sizeof(TDD_UL_DL_ConfigCommon_t));
2906 FreeUlCfgCommSib(srvCellCfg->uplinkConfigCommon);
2907 DU_FREE(srvCellCfg->uplinkConfigCommon,
2908 sizeof(UplinkConfigCommonSIB_t));
2911 FreeBwpDlCommon(&dlCfg->initialDownlinkBWP);
2913 FreeFreqInfoDl(&dlCfg->frequencyInfoDL);
2914 DU_FREE(ssbPosInBurst->buf, ssbPosInBurst->size * sizeof(uint8_t));
2917 /*******************************************************************
2919 * @brief : Deallcating memory of the function BuildSib1Msg
2923 * Function : FreeSib1Msg
2925 * Functionality: Deallcating memory of the function BuildSib1Msg
2927 * @params[in] ServingCellConfigCommonSIB_t pointer
2930 *******************************************************************/
2931 void FreeSib1Msg(SIB1_t *sib1Msg)
2936 CellIdentity_t *cellIdentity = NULLP;
2937 CellAccessRelatedInfo_t *cellAccessInfo ;
2938 struct PLMN_IdentityInfo__plmn_IdentityList *plmnIdInfo;
2941 if(sib1Msg != NULLP)
2943 cellAccessInfo = &sib1Msg->cellAccessRelatedInfo;
2944 if(cellAccessInfo->plmn_IdentityList.list.array !=NULLP)
2946 if(cellAccessInfo->plmn_IdentityList.list.array[idx]!=NULLP)
2949 &cellAccessInfo->plmn_IdentityList.list.array[idx]->plmn_IdentityList;
2951 if(plmnIdInfo->list.array !=NULLP)
2953 if(!plmnIdInfo->list.array[idx])
2955 if(!plmnIdInfo->list.array[idx]->mcc)
2957 if(!(plmnIdInfo->list.array[idx]->mcc->list.array))
2959 if(!plmnIdInfo->list.array[idx]->mnc.list.array)
2961 /*Free Tracking Area Code */
2962 if(!cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode)
2965 if(!cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode->buf)
2967 /* Free CellIdentity */
2968 if(!cellAccessInfo->plmn_IdentityList.list.array[idx]->ranac)
2971 =&cellAccessInfo->plmn_IdentityList.\
2972 list.array[idx]->cellIdentity;
2973 if(!cellIdentity->buf)
2975 /*Free Connection Establish Failure Control */
2976 if(!sib1Msg->connEstFailureControl)
2978 /*Free Serving Cell Config Common */
2979 if(!sib1Msg->si_SchedulingInfo)
2981 /* Free Serving Cell Config Common* */
2982 if(!sib1Msg->servingCellConfigCommon)
2984 /*Free BuildServCellCfgCommonSib*/
2985 FreeServCellCfgCommonSib(\
2986 sib1Msg->servingCellConfigCommon);
2988 DU_FREE(sib1Msg->servingCellConfigCommon,
2989 sizeof(ServingCellConfigCommonSIB_t));
2992 DU_FREE(sib1Msg->si_SchedulingInfo,
2993 sizeof(SI_SchedulingInfo_t));
2996 DU_FREE(sib1Msg->connEstFailureControl,
2997 sizeof(ConnEstFailureControl_t));
2999 DU_FREE(cellIdentity->buf,cellIdentity->size);
3002 DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx]->ranac, sizeof(RAN_AreaCode_t));
3005 DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode->buf,\
3006 cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode->size);
3009 DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode\
3010 , sizeof(TrackingAreaCode_t));
3013 for(idx2=0; idx2<plmnIdInfo->list.array[idx1]->mnc.list.count; idx2++)
3015 if(!plmnIdInfo->list.array[idx2]->mnc.list.array[idx2])
3017 DU_FREE(plmnIdInfo->list.array[idx2]->mnc.list.array[idx2],
3018 sizeof(MCC_MNC_Digit_t));
3021 DU_FREE(plmnIdInfo->list.array[idx]->mnc.list.array,
3022 plmnIdInfo->list.array[idx1]->mnc.list.size);
3025 for(idx1=0; idx1<plmnIdInfo->list.array[idx]->mcc->list.count; idx1++)
3027 if(plmnIdInfo->list.array[idx]->mcc->list.array[idx1]!=NULLP)
3029 DU_FREE(plmnIdInfo->list.array[idx]->mcc->list.array[idx1],\
3030 sizeof(MCC_MNC_Digit_t));
3034 DU_FREE(plmnIdInfo->list.array[idx]->mcc->list.array,\
3035 plmnIdInfo->list.array[idx]->mcc->list.size)
3037 DU_FREE(plmnIdInfo->list.array[idx]->mcc,sizeof(MCC_t));
3040 for(idx1=0; idx1<plmnIdInfo->list.count; idx1++)
3042 if(!(plmnIdInfo->list.array[idx1]))
3044 DU_FREE(plmnIdInfo->list.array[idx1],
3045 sizeof(PLMN_IdentitY_t));
3048 DU_FREE(plmnIdInfo->list.array, plmnIdInfo->list.size);
3051 for(idx=0; idx<cellAccessInfo->plmn_IdentityList.list.count; idx++)
3053 if(cellAccessInfo->plmn_IdentityList.list.array[idx]!=NULLP)
3055 DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx],
3056 sizeof(PLMN_IdentityInfo_t));
3059 DU_FREE(cellAccessInfo->plmn_IdentityList.list.array,
3060 cellAccessInfo->plmn_IdentityList.list.size);
3062 DU_FREE(sib1Msg, sizeof(SIB1_t));
3067 /**********************************************************************
3069 **********************************************************************/