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 */
23 #include "BCCH-BCH-Message.h"
25 #include "PLMN-IdentityInfo.h"
26 #include "PLMN-IdentitY.h"
27 #include "SIB-TypeInfo.h"
28 #include "SchedulingInfo.h"
29 #include "SI-SchedulingInfo.h"
30 #include "ConnEstFailureControl.h"
31 #include "FrequencyInfoDL-SIB.h"
32 #include "SearchSpace.h"
33 #include "SCS-SpecificCarrier.h"
34 #include "NR-MultiBandInfo.h"
35 #include "PDCCH-ConfigCommon.h"
36 #include "PDSCH-TimeDomainResourceAllocation.h"
37 #include "PDSCH-TimeDomainResourceAllocationList.h"
38 #include "PDSCH-ConfigCommon.h"
39 #include "BWP-DownlinkCommon.h"
40 #include "DownlinkConfigCommonSIB.h"
41 #include "RACH-ConfigCommon.h"
42 #include "PUSCH-TimeDomainResourceAllocation.h"
43 #include "PUSCH-TimeDomainResourceAllocationList.h"
44 #include "PUSCH-ConfigCommon.h"
45 #include "PUCCH-ConfigCommon.h"
46 #include "UplinkConfigCommonSIB.h"
47 #include "TDD-UL-DL-ConfigCommon.h"
48 #include "ServingCellConfigCommonSIB.h"
51 #include "du_sys_info_hdl.h"
52 void FreeSib1Msg(SIB1_t *sib1Msg);
53 uint8_t FreqInfoUlret = RFAILED;
54 uint8_t RachCfgCommonret = RFAILED;
55 uint8_t PuschCfgCommonret = RFAILED;
56 uint8_t UlCfgCommSibret = RFAILED;
57 uint8_t FreqInfoDlret = RFAILED;
58 uint8_t DlCfgCommSibret = RFAILED;
59 uint8_t CommonSerachSpaceListret = RFAILED;
60 /*******************************************************************
68 * Functionality: Building MIB
70 * @return ROK - success
73 * ****************************************************************/
74 uint8_t BuildMib(MIB_t *mib)
76 mib->systemFrameNumber.size = sizeof(uint8_t);
77 DU_ALLOC(mib->systemFrameNumber.buf,
78 mib->systemFrameNumber.size);
79 if(!(mib->systemFrameNumber.buf))
81 DU_LOG("DU APP: MIB msg memory allocation failure");
85 *(mib->systemFrameNumber.buf) =
86 duCfgParam.mibParams.sysFrmNum;
87 mib->systemFrameNumber.bits_unused = ODU_VALUE_TWO;
89 mib->subCarrierSpacingCommon =\
90 duCfgParam.mibParams.subCarrierSpacingCommon;
91 mib->ssb_SubcarrierOffset =\
92 duCfgParam.mibParams.ssb_SubcarrierOffset;
93 mib->dmrs_TypeA_Position =\
94 duCfgParam.mibParams.dmrs_TypeA_Position;
95 mib->pdcch_ConfigSIB1.controlResourceSetZero = \
96 duCfgParam.mibParams.controlResourceSetZero;
97 mib->pdcch_ConfigSIB1.searchSpaceZero = \
98 duCfgParam.mibParams.searchSpaceZero;
99 mib->cellBarred = duCfgParam.mibParams.cellBarred;
100 mib->intraFreqReselection =
101 duCfgParam.mibParams.intraFreqReselection;
102 mib->spare.size = sizeof(uint8_t);
103 DU_ALLOC(mib->spare.buf, mib->spare.size);
106 DU_LOG("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()
166 uint8_t ret = RFAILED;
167 BCCH_BCH_Message_t *bcchMsg;
168 asn_enc_rval_t encRetVal; /* Encoder return value */
171 DU_ALLOC(bcchMsg, sizeof(BCCH_BCH_Message_t));
174 DU_LOG("\nMemory allocation failure in BuildMibPdu");
178 bcchMsg->message.present = BCCH_BCH_MessageType_PR_mib;
179 DU_ALLOC(bcchMsg->message.choice.mib, sizeof(MIB_t));
180 if(!bcchMsg->message.choice.mib)
182 DU_LOG("\nMemory allocation failure in BuildMibPdu");
185 BuildMibret = BuildMib(bcchMsg->message.choice.mib);
186 if(BuildMibret != ROK)
190 xer_fprint(stdout, &asn_DEF_BCCH_BCH_Message, bcchMsg);
191 cmMemset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
193 encRetVal = aper_encode(&asn_DEF_BCCH_BCH_Message, 0,
194 bcchMsg, PrepFinalEncBuf, encBuf);
195 printf("\nencbufSize:%d\n", encBufSize);
196 if(encRetVal.encoded == -1)
198 DU_LOG("\nDU APP: Could not encode BCCH BCH Message Type structure(at %s)\n",
199 encRetVal.failed_type?\
200 encRetVal.failed_type->name
205 /* Print encoded buffer */
206 for(int i=0; i< encBufSize; i++)
208 printf("%x\t",encBuf[i]);
215 /* Free allocated memory */
221 /*******************************************************************
223 * @brief free MIB message in Served Cell Info
227 * Function : FreeMibMsg
229 * Functionality: deallocating MIB message in Served Cell Info
231 * @param[in] MIB_t *mibMsg
236 * ****************************************************************/
237 void FreeMibMsg( MIB_t *mibMsg)
241 if(!(mibMsg->systemFrameNumber.buf))
243 if(!mibMsg->spare.buf)
245 DU_FREE(mibMsg->spare.buf, mibMsg->spare.size);
247 DU_FREE(mibMsg->systemFrameNumber.buf,
248 mibMsg->systemFrameNumber.size);
250 DU_FREE(mibMsg, sizeof(MIB_t));
253 /*******************************************************************
255 * @brief Builds MIB message in Served Cell Info
259 * Function : BuildMibMsg
261 * Functionality: Building MIB message in Served Cell Info
263 * @return ROK - success
266 * ****************************************************************/
267 uint8_t BuildMibMsg()
270 asn_enc_rval_t encRetVal; /* Encoder return value */
271 uint8_t ret = RFAILED;
275 DU_ALLOC(mibMsg, sizeof(MIB_t));
278 DU_LOG("DU APP: MIB msg memory allocation failure");
281 BuildMibret = BuildMib(mibMsg);
282 if(BuildMibret != ROK)
286 xer_fprint(stdout, &asn_DEF_MIB, mibMsg);
287 cmMemset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
289 encRetVal = aper_encode(&asn_DEF_MIB, 0,
290 mibMsg, PrepFinalEncBuf, encBuf);
291 printf("\nencbufSize:%d\n", encBufSize);
292 if(encRetVal.encoded == -1)
294 DU_LOG("\nDU APP: Could not encode MIB structure(at %s)\n",
295 encRetVal.failed_type?\
296 encRetVal.failed_type->name
301 /* Print encoded buffer */
302 for(int i=0; i< encBufSize; i++)
304 printf("%x\t",encBuf[i]);
308 /* Free allocated memory */
319 /*******************************************************************
321 * @brief Builds CellIdentity within SIB1 message
325 * Function : BuildCellIdentity
327 * Functionality: Building RAN area code in SIB1 message
329 * @params[in] RAN_AreaCode_t **ranAreaCode
330 * @return ROK - success
333 * ****************************************************************/
334 uint8_t BuildCellIdentity(CellIdentity_t *cellIdentity)
336 cellIdentity->size = ODU_VALUE_FIVE*sizeof(uint8_t);
337 cellIdentity->bits_unused = ODU_VALUE_FOUR;
339 DU_ALLOC(cellIdentity->buf, cellIdentity->size);
340 if(!cellIdentity->buf)
342 DU_LOG("DU APP: CellIdentity memory allocation failure");
345 *cellIdentity->buf = duCfgParam.sib1Params.cellIdentity;
349 /*******************************************************************
351 * @brief Builds RANAC within SIB1 message
355 * Function : BuildRanac
357 * Functionality: Building RAN area code in SIB1 message
359 * @params[in] RAN_AreaCode_t **ranAreaCode
360 * @return ROK - success
363 * ****************************************************************/
364 uint8_t BuildRanac(RAN_AreaCode_t **ranAreaCode)
366 RAN_AreaCode_t *ranac;
367 DU_ALLOC(ranac, sizeof(RAN_AreaCode_t));
370 DU_LOG("DU APP: RANAC memory allocation failure");
373 *ranac = duCfgParam.sib1Params.ranac;
374 *ranAreaCode = ranac;
377 /*******************************************************************
379 * @brief Builds TAC within SIB1 message
383 * Function : BuildTac
385 * Functionality: Building Tracking area code in SIB1 message
387 * @params[in] TrackingAreaCode_t **tac
388 * @return ROK - success
391 * ****************************************************************/
392 uint8_t BuildTac(TrackingAreaCode_t **trackAreaCode)
394 TrackingAreaCode_t *tac;
397 DU_ALLOC(tac, sizeof(TrackingAreaCode_t));
400 DU_LOG("DU APP: TAC memory allocation failure");
404 tac->size = ODU_VALUE_THREE*sizeof(uint8_t);
405 DU_ALLOC(tac->buf, tac->size);
408 DU_LOG("DU APP: TAC memory allocation failure");
411 *(tac->buf) = duCfgParam.sib1Params.tac;
412 tac->bits_unused = ODU_VALUE_ZERO;
413 *trackAreaCode = tac;
418 /*******************************************************************
420 * @brief Builds PLMN list within SIB1 message
424 * Function : BuildPlmnList
426 * Functionality: Building PLMN list in SIB1 message
428 * @params[in] CellAccessRelatedInfo_t *cellAccessInfo
429 * @return ROK - success
432 * ****************************************************************/
433 uint8_t BuildPlmnList(CellAccessRelatedInfo_t *cellAccessInfo)
439 TrackingAreaCode_t **tac;
440 RAN_AreaCode_t **ranac;
441 CellIdentity_t *cellIdentity;
443 struct PLMN_IdentityInfo__plmn_IdentityList
446 DU_ALLOC(cellAccessInfo->plmn_IdentityList.list.array,
447 cellAccessInfo->plmn_IdentityList.list.size);
448 if(!cellAccessInfo->plmn_IdentityList.list.array)
450 DU_LOG("DU APP: BuildPlmnList memory allocation failure");
453 elementCnt = cellAccessInfo->plmn_IdentityList.list.count;
454 for(idx=0; idx<elementCnt; idx++)
456 DU_ALLOC(cellAccessInfo->plmn_IdentityList.list.array[idx],
457 sizeof(PLMN_IdentityInfo_t));
458 if(!cellAccessInfo->plmn_IdentityList.list.array[idx])
460 DU_LOG("DU APP: BuildPlmnList memory allocation failure");
467 elementCnt = ODU_VALUE_ONE;
469 plmnIdInfo = &cellAccessInfo->plmn_IdentityList.list.array[idx]->\
471 plmnIdInfo->list.count = elementCnt;
472 plmnIdInfo->list.size = elementCnt * sizeof(PLMN_IdentitY_t *);
473 DU_ALLOC(plmnIdInfo->list.array, plmnIdInfo->list.size);
474 if(!plmnIdInfo->list.array)
476 DU_LOG("DU APP: BuildPlmnList memory allocation failure");
480 for(idx1=0; idx1<elementCnt; idx1++)
482 DU_ALLOC(plmnIdInfo->list.array[idx1],
483 sizeof(PLMN_IdentitY_t));
484 if(!(plmnIdInfo->list.array[idx1]))
486 DU_LOG("DU APP: BuildPlmnList memory allocation failure");
491 DU_ALLOC(plmnIdInfo->list.array[idx1]->mcc,
493 if(!plmnIdInfo->list.array[idx1]->mcc)
495 DU_LOG("DU APP: BuildPlmnList memory allocation failure");
499 elementCnt = ODU_VALUE_THREE;
500 plmnIdInfo->list.array[idx1]->mcc->list.count = elementCnt;
501 plmnIdInfo->list.array[idx1]->mcc->list.size =\
502 elementCnt * sizeof(MCC_MNC_Digit_t *);
503 DU_ALLOC(plmnIdInfo->list.array[idx1]->mcc->list.array,
504 plmnIdInfo->list.array[idx1]->mcc->list.size)
505 if(!(plmnIdInfo->list.array[idx1]->mcc->list.array))
507 DU_LOG("DU APP: BuildPlmnList memory allocation failure");
510 for(idx2=0; idx2<elementCnt; idx2++)
512 DU_ALLOC(plmnIdInfo->list.array[idx1]->mcc->list.array[idx2],
513 sizeof(MCC_MNC_Digit_t));
514 if(!plmnIdInfo->list.array[idx1]->mcc->list.array[idx2])
516 DU_LOG("DU APP: BuildPlmnList memory allocation failure");
519 *(plmnIdInfo->list.array[idx1]->mcc->list.array[idx2])=\
520 duCfgParam.sib1Params.plmn.mcc[idx2];
523 plmnIdInfo->list.array[idx1]->mnc.list.count = elementCnt;
524 plmnIdInfo->list.array[idx1]->mnc.list.size =\
525 elementCnt * sizeof(MCC_MNC_Digit_t *);
526 DU_ALLOC(plmnIdInfo->list.array[idx1]->mnc.list.array,
527 plmnIdInfo->list.array[idx1]->mnc.list.size);
528 if(!plmnIdInfo->list.array[idx1]->mnc.list.array)
530 DU_LOG("DU APP: BuildPlmnList memory allocation failure");
533 for(idx2=0; idx2<elementCnt; idx2++)
535 DU_ALLOC(plmnIdInfo->list.array[idx1]->mnc.list.array[idx2],
536 sizeof(MCC_MNC_Digit_t));
537 if(!plmnIdInfo->list.array[idx1]->mnc.list.array[idx2])
539 DU_LOG("DU APP: BuildPlmnList memory allocation failure");
542 *(plmnIdInfo->list.array[idx1]->mnc.list.array[idx2])=\
543 duCfgParam.sib1Params.plmn.mnc[idx2];
546 /* Tracking Area Code */
547 tac = &cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode;
555 ranac = &cellAccessInfo->plmn_IdentityList.list.array[idx]->ranac;
556 ret=BuildRanac(ranac);
564 &cellAccessInfo->plmn_IdentityList.list.array[idx]->cellIdentity;
565 ret=BuildCellIdentity(cellIdentity);
571 /* cellReservedForOperatorUse */
572 cellAccessInfo->plmn_IdentityList.list.array[idx]->\
573 cellReservedForOperatorUse = \
574 duCfgParam.sib1Params.cellResvdForOpUse;
580 /*******************************************************************
582 * @brief Build SIB Map Info List
586 * Function : BuildSibMapInfoList
589 * Build SIB MapInfo List
591 * @params[in] SIB_Mapping_t pointer
592 * @return ROK - success
595 * ****************************************************************/
596 uint8_t BuildSibMapInfoList(SIB_Mapping_t *sibMapInfo)
598 uint8_t itr; /* List iterator */
599 uint8_t elementCnt; /* Number of elements in list */
600 SIB_TypeInfo_t *sibTypeInfo; /* Scheduling info */
602 /* SI scheduling info list */
603 DU_ALLOC(sibMapInfo->list.array, sibMapInfo->list.size);
604 if(!sibMapInfo->list.array)
606 DU_LOG("DU APP: BuildSibMapInfoList memory allocation failure");
610 elementCnt = sibMapInfo->list.count;
611 for(itr = 0; itr < elementCnt; itr++)
613 DU_ALLOC(sibMapInfo->list.array[itr], sizeof(SIB_TypeInfo_t));
614 if(!sibMapInfo->list.array[itr])
616 DU_LOG("DU APP: BuildSibMapInfoList memory allocation failure");
622 sibTypeInfo = sibMapInfo->list.array[itr];
623 sibTypeInfo->type = duCfgParam.sib1Params.siSchedInfo.sibType;
624 DU_ALLOC(sibTypeInfo->valueTag, sizeof(long));
625 if(!sibTypeInfo->valueTag)
627 DU_LOG("DU APP: BuildSibMapInfoList memory allocation failure");
631 *sibTypeInfo->valueTag = duCfgParam.sib1Params.siSchedInfo.sibValTag;
636 /*******************************************************************
638 * @brief Builds SI Scheduling info list within SIB1 message
642 * Function : BuildSiSchedInfoList
645 * Building SI Scheduling info list in SIB1 message
647 * @params[in] struct SI_SchedulingInfo__schedulingInfoList *si_SchedulingInfo
648 * @return ROK - success
651 * ****************************************************************/
652 uint8_t BuildSiSchedInfoList(struct SI_SchedulingInfo__schedulingInfoList *si_SchedulingInfoList)
654 uint8_t itr; /* List iterator */
655 uint8_t elementCnt; /* Number of elements in list */
657 SchedulingInfo_t *schedInfo; /* Scheduling info */
659 /* SI scheduling info list */
660 DU_ALLOC(si_SchedulingInfoList->list.array, si_SchedulingInfoList->list.size);
661 if(!si_SchedulingInfoList->list.array)
663 DU_LOG("DU APP: BuildSiSchedInfoList memory allocation failure");
667 elementCnt = si_SchedulingInfoList->list.count;
668 for(itr = 0; itr < elementCnt; itr++)
670 DU_ALLOC(si_SchedulingInfoList->list.array[itr], sizeof(struct SchedulingInfo));
671 if(!si_SchedulingInfoList->list.array[itr])
673 DU_LOG("DU APP: BuildSiSchedInfoList memory allocation failure");
679 schedInfo = si_SchedulingInfoList->list.array[itr];
680 schedInfo->si_BroadcastStatus = duCfgParam.sib1Params.siSchedInfo.broadcastSta;
681 schedInfo->si_Periodicity = duCfgParam.sib1Params.siSchedInfo.preiodicity;
683 elementCnt = ODU_VALUE_ONE;
684 schedInfo->sib_MappingInfo.list.count = elementCnt;
685 schedInfo->sib_MappingInfo.list.size = elementCnt * sizeof(SIB_TypeInfo_t *);
687 ret = BuildSibMapInfoList(&schedInfo->sib_MappingInfo);
696 /*******************************************************************
698 * @brief Builds SCS Specific carrier list for DL
702 * Function : BuildScsSpecificCarrierListDl
705 * Builds Subcarrier specific carrier list for downlink
707 * @params[in] FrequencyInfoDL_SIB__scs_SpecificCarrierList pointer
708 * @return ROK - success
711 * ****************************************************************/
712 uint8_t BuildScsSpecificCarrierListDl
714 struct FrequencyInfoDL_SIB__scs_SpecificCarrierList *scsCarrierList
718 ScsSpecCarrier duScsSpecCarrier;
720 duScsSpecCarrier = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.dlScsCarrier;
722 DU_ALLOC(scsCarrierList->list.array, scsCarrierList->list.size);
723 if(!scsCarrierList->list.array)
725 DU_LOG("\nDU APP : SCS Specific Carrier list memory allocation failed");
729 for(idx = 0; idx < scsCarrierList->list.count; idx++)
731 DU_ALLOC(scsCarrierList->list.array[idx], sizeof(SCS_SpecificCarrier_t));
732 if(!scsCarrierList->list.array[idx])
734 DU_LOG("\nDU APP : SCS Specific Carrier list memory allocation failed");
740 scsCarrierList->list.array[idx]->offsetToCarrier = duScsSpecCarrier.scsOffset;
741 scsCarrierList->list.array[idx]->subcarrierSpacing = duScsSpecCarrier.scs;
742 scsCarrierList->list.array[idx]->carrierBandwidth = duScsSpecCarrier.scsBw;
745 } /* End of BuildScsSpecificCarrierListDl */
747 /*******************************************************************
749 * @brief Builds common search space list
753 * Function : BuildCommonSerachSpaceList
756 * Builds common search space list
758 * @params[in] PDCCH_ConfigCommon__commonSearchSpaceList pointer
759 * @return ROK - success
762 * ****************************************************************/
763 uint8_t BuildCommonSerachSpaceList
765 struct PDCCH_ConfigCommon__commonSearchSpaceList *searchSpclist
769 SearchSpace_t *searchSpace;
770 PdcchCfgCommon duPdcchCfg;
772 duPdcchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdcchCfg;
774 DU_ALLOC(searchSpclist->list.array, searchSpclist->list.size)
775 if(!searchSpclist->list.array)
777 DU_LOG("\nDU APP : Common search space list memory alloc failed");
781 for(idx = 0; idx < searchSpclist->list.count; idx++)
783 DU_ALLOC(searchSpclist->list.array[idx], sizeof(SearchSpace_t));
784 if(!searchSpclist->list.array[idx])
786 DU_LOG("\nDU APP : Common search space list memory alloc failed");
792 searchSpace = searchSpclist->list.array[idx];
794 /* Search Space id */
795 searchSpace->searchSpaceId = duPdcchCfg.searchSpcId;
797 /* Control Resource Set Id */
798 DU_ALLOC(searchSpace->controlResourceSetId, sizeof(ControlResourceSetId_t));
799 if(!searchSpace->controlResourceSetId)
801 DU_LOG("\nDU APP : Common search space list memory alloc failed");
804 *searchSpace->controlResourceSetId = duPdcchCfg.ctrlRsrcSetId;
806 /* Monitoring Slot periodicity and offset */
807 DU_ALLOC(searchSpace->monitoringSlotPeriodicityAndOffset,\
808 sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
809 if(!searchSpace->monitoringSlotPeriodicityAndOffset)
811 DU_LOG("\nDU APP : Common search space list memory alloc failed");
814 searchSpace->monitoringSlotPeriodicityAndOffset->present = \
815 duPdcchCfg.monitorSlotPrdAndOffPresent;
816 switch(searchSpace->monitoringSlotPeriodicityAndOffset->present)
818 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1:
820 //searchSpace->monitoringSlotPeriodicityAndOffset->choice.s11 = \
821 duPdcchCfg.monitorSlotPrdAndOff;
824 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2:
829 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl4:
834 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl5:
839 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl8:
844 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl10:
849 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl16:
854 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl20:
859 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl40:
864 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl80:
869 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl160:
874 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl320:
878 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl640:
883 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1280:
888 case SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl2560:
895 DU_LOG("\nDU APP : Invalid value:Montoring slot periodicity and offset");
900 /* Monitoring Symbols Within Slot */
901 DU_ALLOC(searchSpace->monitoringSymbolsWithinSlot,\
902 sizeof(BIT_STRING_t));
903 if(!searchSpace->monitoringSymbolsWithinSlot)
905 DU_LOG("\nDU APP : Common search space list memory alloc failed");
908 searchSpace->monitoringSymbolsWithinSlot->size = 2*sizeof(uint8_t);
909 DU_ALLOC(searchSpace->monitoringSymbolsWithinSlot->buf, \
910 searchSpace->monitoringSymbolsWithinSlot->size );
911 if(!searchSpace->monitoringSymbolsWithinSlot->buf)
913 DU_LOG("\nDU APP : Common search space list memory alloc failed");
916 searchSpace->monitoringSymbolsWithinSlot->buf[0] = duPdcchCfg.monitorSymbolsInSlot[0];
917 searchSpace->monitoringSymbolsWithinSlot->buf[1] = duPdcchCfg.monitorSymbolsInSlot[1];
918 searchSpace->monitoringSymbolsWithinSlot->bits_unused = 2;
920 /* Number of candidates per aggregation level */
921 DU_ALLOC(searchSpace->nrofCandidates,\
922 sizeof(struct SearchSpace__nrofCandidates));
923 if(!searchSpace->nrofCandidates)
925 DU_LOG("\nDU APP : Common search space list memory alloc failed");
928 searchSpace->nrofCandidates->aggregationLevel1 = duPdcchCfg.numCandAggLvl1;
929 searchSpace->nrofCandidates->aggregationLevel2 = duPdcchCfg.numCandAggLvl2;
930 searchSpace->nrofCandidates->aggregationLevel4 = duPdcchCfg.numCandAggLvl4;
931 searchSpace->nrofCandidates->aggregationLevel8 = duPdcchCfg.numCandAggLvl8;
932 searchSpace->nrofCandidates->aggregationLevel16 = duPdcchCfg.numCandAggLvl16;
934 /* Search Space type and DCI Format */
935 DU_ALLOC(searchSpace->searchSpaceType,\
936 sizeof( struct SearchSpace__searchSpaceType));
937 if(!searchSpace->searchSpaceType)
939 DU_LOG("\nDU APP : Common search space list memory alloc failed");
943 searchSpace->searchSpaceType->present = duPdcchCfg.searchSpcType;
944 switch(searchSpace->searchSpaceType->present)
946 case SearchSpace__searchSpaceType_PR_NOTHING:
951 case SearchSpace__searchSpaceType_PR_common:
953 DU_ALLOC(searchSpace->searchSpaceType->choice.common,\
954 sizeof(struct SearchSpace__searchSpaceType__common));
955 if(!searchSpace->searchSpaceType->choice.common)
957 DU_LOG("\nDU APP : Common search space list memory alloc failed");
961 DU_ALLOC(searchSpace->searchSpaceType->choice.common->\
962 dci_Format0_0_AndFormat1_0, sizeof(struct \
963 SearchSpace__searchSpaceType__common__dci_Format0_0_AndFormat1_0));
964 if(!searchSpace->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0)
966 DU_LOG("\nDU APP : Common search space list memory alloc failed");
971 case SearchSpace__searchSpaceType_PR_ue_Specific:
977 DU_LOG("\nDU_APP: Invalid Search Space type");
984 }/* BuildCommonSerachSpaceList */
986 /*******************************************************************
988 * @brief Builds PDCCH configuration common
992 * Function : BuildPdcchCfgCommon
995 * Builds PDCCH configuration common
997 * @params[in] BWP_DownlinkCommon__pdcch_ConfigCommon pointer
998 * @return ROK - success
1001 * ****************************************************************/
1002 uint8_t BuildPdcchCfgCommon(struct BWP_DownlinkCommon__pdcch_ConfigCommon *pdcchCfg)
1006 PdcchCfgCommon duPdcchCfg;
1007 PDCCH_ConfigCommon_t *pdcchSetup;
1009 duPdcchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdcchCfg;
1011 pdcchCfg->present = duPdcchCfg.present;
1013 switch(pdcchCfg->present)
1015 case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_NOTHING:
1020 case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_release:
1025 case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup:
1027 DU_ALLOC(pdcchCfg->choice.setup, sizeof(PDCCH_ConfigCommon_t));
1028 if(!pdcchCfg->choice.setup)
1030 DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1033 pdcchSetup = pdcchCfg->choice.setup;
1035 /* Control Resource Set Zero */
1036 DU_ALLOC(pdcchSetup->controlResourceSetZero,
1037 sizeof(ControlResourceSetZero_t));
1038 if(!pdcchSetup->controlResourceSetZero)
1040 DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1043 *pdcchSetup->controlResourceSetZero = duPdcchCfg.ctrlRsrcSetZero;
1045 /* Search space zero */
1046 DU_ALLOC(pdcchSetup->searchSpaceZero, sizeof(SearchSpaceZero_t));
1047 if(!pdcchSetup->searchSpaceZero)
1049 DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1052 *pdcchSetup->searchSpaceZero = duPdcchCfg.searchSpcZero;
1054 /* Common Search Space List */
1055 DU_ALLOC(pdcchSetup->commonSearchSpaceList,\
1056 sizeof(struct PDCCH_ConfigCommon__commonSearchSpaceList));
1057 if(!pdcchSetup->commonSearchSpaceList)
1059 DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1062 elementCnt = ODU_VALUE_ONE;
1063 pdcchSetup->commonSearchSpaceList->list.count = elementCnt;
1064 pdcchSetup->commonSearchSpaceList->list.size = \
1065 elementCnt * sizeof(SearchSpace_t *);
1066 ret = BuildCommonSerachSpaceList(pdcchSetup->commonSearchSpaceList);
1071 CommonSerachSpaceListret=ROK;
1073 /* Search Space for SIB1 */
1074 DU_ALLOC(pdcchSetup->searchSpaceSIB1, sizeof(SearchSpaceId_t));
1075 if(!pdcchSetup->searchSpaceSIB1)
1077 DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1080 *pdcchSetup->searchSpaceSIB1 = duPdcchCfg.searchSpcSib1;
1082 /* Serach Space for Paging */
1083 DU_ALLOC(pdcchSetup->pagingSearchSpace, sizeof(SearchSpaceId_t));
1084 if(!pdcchSetup->pagingSearchSpace)
1086 DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1089 *pdcchSetup->pagingSearchSpace = duPdcchCfg.pagingSearchSpc;
1091 /* Search space for Random Access */
1092 DU_ALLOC(pdcchSetup->ra_SearchSpace, sizeof(SearchSpaceId_t));
1093 if(!pdcchSetup->ra_SearchSpace)
1095 DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1098 *pdcchSetup->ra_SearchSpace = duPdcchCfg.raSearchSpc;
1104 DU_LOG("\nDU APP : Invalid PDCCH Config type");
1110 } /* BuildPdcchCfgCommon */
1112 /*******************************************************************
1114 * @brief Builds PDSCH configuration common
1118 * Function : BuildPdschCfgCommon
1121 * Builds PDSCH configuration common
1123 * @params[in] BWP_DownlinkCommon__pdsch_ConfigCommon pointer
1124 * @return ROK - success
1127 * ****************************************************************/
1128 uint8_t BuildPdschCfgCommon(struct BWP_DownlinkCommon__pdsch_ConfigCommon *pdschCfg)
1132 PdschCfgCommon duPdschCfg;
1133 PDSCH_ConfigCommon_t *pdschSetup;
1134 PDSCH_TimeDomainResourceAllocation_t *timeDomRsrcAllocInfo;
1136 duPdschCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdschCfg;
1138 pdschCfg->present = duPdschCfg.present;
1140 switch(pdschCfg->present)
1142 case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_NOTHING:
1147 case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_release:
1152 case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup:
1154 DU_ALLOC(pdschCfg->choice.setup, sizeof(PDSCH_ConfigCommon_t));
1155 if(!pdschCfg->choice.setup)
1157 DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1160 pdschSetup = pdschCfg->choice.setup;
1162 /* Time Domain Allocation List */
1163 DU_ALLOC(pdschSetup->pdsch_TimeDomainAllocationList, \
1164 sizeof(PDSCH_TimeDomainResourceAllocationList_t));
1165 if(!pdschSetup->pdsch_TimeDomainAllocationList)
1167 DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1170 elementCnt = ODU_VALUE_ONE;
1171 pdschSetup->pdsch_TimeDomainAllocationList->list.count = elementCnt;
1172 pdschSetup->pdsch_TimeDomainAllocationList->list.size = \
1173 elementCnt * sizeof(PDSCH_TimeDomainResourceAllocation_t *);
1175 DU_ALLOC(pdschSetup->pdsch_TimeDomainAllocationList->list.array,\
1176 pdschSetup->pdsch_TimeDomainAllocationList->list.size);
1177 if(!pdschSetup->pdsch_TimeDomainAllocationList->list.array)
1179 DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1183 for(idx=0; idx<elementCnt; idx++)
1185 DU_ALLOC(pdschSetup->pdsch_TimeDomainAllocationList->list.array[idx],\
1186 sizeof(PDSCH_TimeDomainResourceAllocation_t));
1187 if(!pdschSetup->pdsch_TimeDomainAllocationList->list.array[idx])
1189 DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1195 timeDomRsrcAllocInfo = pdschSetup->pdsch_TimeDomainAllocationList->list.array[idx];
1198 DU_ALLOC(timeDomRsrcAllocInfo->k0, sizeof(long));
1199 if(!timeDomRsrcAllocInfo->k0)
1201 DU_LOG("\nDU APP : PDCCH Config memory alloc failed");
1204 *timeDomRsrcAllocInfo->k0 = duPdschCfg.k0;
1206 timeDomRsrcAllocInfo->mappingType = duPdschCfg.mapType;
1207 timeDomRsrcAllocInfo->startSymbolAndLength = duPdschCfg.sliv;
1213 DU_LOG("\nDU APP: Invalid PDSCH Configuration type");
1219 }/* BuildPdschCfgCommon */
1221 /*******************************************************************
1223 * @brief Builds DL BWP common
1227 * Function : BuildBwpDlCommon
1230 * Builds DL BWP common
1232 * @params[in] BWP_DownlinkCommon_t pointer
1233 * @return ROK - success
1236 * ****************************************************************/
1237 uint8_t BuildBwpDlCommon(BWP_DownlinkCommon_t *bwp)
1240 DlCfgCommon duDlCfg;
1242 duDlCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg;
1244 bwp->genericParameters.locationAndBandwidth = duDlCfg.locAndBw;
1245 bwp->genericParameters.subcarrierSpacing = duDlCfg.dlScsCarrier.scs;
1247 /* PDCCH Config Common */
1248 DU_ALLOC(bwp->pdcch_ConfigCommon, \
1249 sizeof(struct BWP_DownlinkCommon__pdcch_ConfigCommon));
1250 if(!bwp->pdcch_ConfigCommon)
1252 DU_LOG("\nDU APP : DL BWP memory allocation failed");
1255 ret=BuildPdcchCfgCommon(bwp->pdcch_ConfigCommon);
1260 /* PDSCH Config Common */
1261 DU_ALLOC(bwp->pdsch_ConfigCommon, \
1262 sizeof(struct BWP_DownlinkCommon__pdsch_ConfigCommon));
1263 if(!bwp->pdsch_ConfigCommon)
1265 DU_LOG("\nDU APP : DL BWP memory allocation failed");
1268 ret=BuildPdschCfgCommon(bwp->pdsch_ConfigCommon);
1274 } /* BuildBwpDlCommon */
1276 /*******************************************************************
1278 * @brief Build BCCH configuration
1282 * Function : BuildBcchConfig
1285 * Build BCCH configuration
1287 * @params[in] BCCH_Config_t pointer
1288 * @return ROK - success
1291 * ****************************************************************/
1293 uint8_t BuildBcchConfig(BCCH_Config_t *bcchCfg)
1297 duBcchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.bcchCfg;
1299 bcchCfg->modificationPeriodCoeff = duBcchCfg.modPrdCoeff;
1302 }/* BuildBcchConfig */
1304 /*******************************************************************
1306 * @brief Builds PCCH configuration
1310 * Function : BuildPcchConfig
1313 * Builds PCCH configuration
1316 * @return ROK - success
1319 * ****************************************************************/
1320 uint8_t BuildPcchConfig(PCCH_Config_t *pcchCfg)
1324 duPcchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pcchCfg;
1326 pcchCfg->defaultPagingCycle = duPcchCfg.dfltPagingCycle;
1327 pcchCfg->nAndPagingFrameOffset.present = duPcchCfg.nAndPagingFrmOffPresent;
1328 switch(pcchCfg->nAndPagingFrameOffset.present)
1330 case PCCH_Config__nAndPagingFrameOffset_PR_NOTHING:
1335 case PCCH_Config__nAndPagingFrameOffset_PR_oneT:
1339 case PCCH_Config__nAndPagingFrameOffset_PR_halfT:
1344 case PCCH_Config__nAndPagingFrameOffset_PR_quarterT:
1349 case PCCH_Config__nAndPagingFrameOffset_PR_oneEighthT:
1354 case PCCH_Config__nAndPagingFrameOffset_PR_oneSixteenthT:
1361 DU_LOG("\nDU APP : Invalid nAndPagingFrameOffset configuration");
1365 pcchCfg->ns = duPcchCfg.numPagingOcc;
1368 }/* BuildPcchConfig */
1370 /*******************************************************************
1372 * @brief Builds Frequency Info for Downlink
1376 * Function : BuildFreqInfoDl
1379 * Builds Frequency Info for Downlink
1382 * @return ROK - success
1385 * ****************************************************************/
1387 uint8_t BuildFreqInfoDl(FrequencyInfoDL_SIB_t *frequencyInfoDL)
1393 NR_MultiBandInfo_t *multiBandInfo;
1395 dlCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg;
1397 /* NR Multi-Band Info */
1398 elementCnt = ODU_VALUE_ONE;
1399 frequencyInfoDL->frequencyBandList.list.count = elementCnt;
1400 frequencyInfoDL->frequencyBandList.list.size = \
1401 elementCnt * sizeof(NR_MultiBandInfo_t *);
1403 DU_ALLOC(frequencyInfoDL->frequencyBandList.list.array, \
1404 frequencyInfoDL->frequencyBandList.list.size);
1405 if(!frequencyInfoDL->frequencyBandList.list.array)
1407 DU_LOG("\nDU APP : SIB1 DL Configuration memory allocation failed");
1411 for(idx = 0; idx < elementCnt; idx++)
1413 DU_ALLOC(frequencyInfoDL->frequencyBandList.list.array[idx],\
1414 sizeof(NR_MultiBandInfo_t));
1415 if(!frequencyInfoDL->frequencyBandList.list.array[idx])
1417 DU_LOG("\nDU APP : SIB1 DL Configuration memory allocation failed");
1423 multiBandInfo = frequencyInfoDL->frequencyBandList.list.array[idx];
1425 /* Frequency band indicator */
1426 DU_ALLOC(multiBandInfo->freqBandIndicatorNR, sizeof(FreqBandIndicatorNR_t));
1427 if(!multiBandInfo->freqBandIndicatorNR)
1429 DU_LOG("\nDU APP : SIB1 DL Configuration memory allocation failed");
1432 *multiBandInfo->freqBandIndicatorNR = dlCfg.freqBandInd;
1434 /* Offset to Point A */
1435 frequencyInfoDL->offsetToPointA = dlCfg.offsetToPointA;
1437 /* Subcarrier Spacing specifc carrier */
1438 elementCnt = ODU_VALUE_ONE;
1439 frequencyInfoDL->scs_SpecificCarrierList.list.count = elementCnt;
1440 frequencyInfoDL->scs_SpecificCarrierList.list.size = \
1441 elementCnt * sizeof(SCS_SpecificCarrier_t *);
1442 ret= BuildScsSpecificCarrierListDl(&frequencyInfoDL->scs_SpecificCarrierList);
1449 }/* BuildFreqInfoDl */
1451 /*******************************************************************
1453 * @brief Builds DL configuration common for SIB
1457 * Function : BuildDlCfgCommSib
1460 * Builds DL configuration common for SIB
1462 * @params[in] DownlinkConfigCommonSIB_t pointer
1463 * @return ROK - success
1466 * ****************************************************************/
1468 uint8_t BuildDlCfgCommSib(DownlinkConfigCommonSIB_t *dlCfg)
1470 /* DL frequency info */
1472 ret = BuildFreqInfoDl(&dlCfg->frequencyInfoDL);
1478 /* BWP Downlink Common */
1479 ret = BuildBwpDlCommon(&dlCfg->initialDownlinkBWP);
1485 ret = BuildBcchConfig(&dlCfg->bcch_Config);
1491 ret = BuildPcchConfig(&dlCfg->pcch_Config);
1497 } /* BuildDlCfgCommSib */
1499 /*******************************************************************
1501 * @brief Builds SCS specific carrier list for UL
1505 * Function : BuildScsSpecificCarrierListUl
1508 * Builds SCS specific carrier list for UL
1511 * @return ROK - success
1514 * ****************************************************************/
1516 uint8_t BuildScsSpecificCarrierListUl
1518 struct FrequencyInfoUL_SIB__scs_SpecificCarrierList *scsCarrierList
1522 ScsSpecCarrier duScsSpecCarrier;
1524 duScsSpecCarrier = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.ulScsCarrier;
1526 DU_ALLOC(scsCarrierList->list.array, scsCarrierList->list.size);
1527 if(!scsCarrierList->list.array)
1529 DU_LOG("\nDU APP : SCS Specific Carrier list memory allocation failed");
1533 for(idx = 0; idx < scsCarrierList->list.count; idx++)
1535 DU_ALLOC(scsCarrierList->list.array[idx], sizeof(SCS_SpecificCarrier_t));
1536 if(!scsCarrierList->list.array[idx])
1538 DU_LOG("\nDU APP : SCS Specific Carrier list memory allocation failed");
1543 scsCarrierList->list.array[idx]->offsetToCarrier = duScsSpecCarrier.scsOffset;
1544 scsCarrierList->list.array[idx]->subcarrierSpacing = duScsSpecCarrier.scs;
1545 scsCarrierList->list.array[idx]->carrierBandwidth = duScsSpecCarrier.scsBw;
1548 } /* End of BuildScsSpecificCarrierListUl */
1550 /*******************************************************************
1552 * @brief Builds frequency infor for UL
1556 * Function : BuildFreqInfoUl
1559 * Builds frequency infor for UL
1561 * @params[in] FrequencyInfoUL_SIB_t pointer
1562 * @return ROK - success
1565 * ****************************************************************/
1567 uint8_t BuildFreqInfoUl(FrequencyInfoUL_SIB_t *frequencyInfoUL)
1572 ulCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg;
1574 /* Subcarrier Spacing specifc carrier */
1575 elementCnt = ODU_VALUE_ONE;
1576 frequencyInfoUL->scs_SpecificCarrierList.list.count = elementCnt;
1577 frequencyInfoUL->scs_SpecificCarrierList.list.size = \
1578 elementCnt * sizeof(SCS_SpecificCarrier_t *);
1579 ret=BuildScsSpecificCarrierListUl(&frequencyInfoUL->scs_SpecificCarrierList);
1585 DU_ALLOC(frequencyInfoUL->p_Max, sizeof(P_Max_t));
1586 if(!frequencyInfoUL->p_Max)
1588 DU_LOG("\nDU APP : UL Frequency Infoo memory allocation failure");
1591 *frequencyInfoUL->p_Max = ulCfg.pMax;
1594 }/* BuildFreqInfoUl */
1596 /*******************************************************************
1598 * @brief Builds RACH configuration common
1602 * Function : BuildRachCfgCommon
1605 * Builds RACH configuration common
1607 * @params[in] BWP_UplinkCommon__rach_ConfigCommon pointer
1608 * @return ROK - success
1611 * ****************************************************************/
1613 uint8_t BuildRachCfgCommon(struct BWP_UplinkCommon__rach_ConfigCommon *rachCfg)
1615 RachCfgCommon duRachCfg;
1616 RACH_ConfigCommon_t *setup;
1618 duRachCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.rachCfg;
1620 rachCfg->present = duRachCfg.present;
1621 switch(rachCfg->present)
1623 case BWP_UplinkCommon__rach_ConfigCommon_PR_NOTHING:
1628 case BWP_UplinkCommon__rach_ConfigCommon_PR_release:
1633 case BWP_UplinkCommon__rach_ConfigCommon_PR_setup:
1635 DU_ALLOC(rachCfg->choice.setup, sizeof(RACH_ConfigCommon_t));
1636 if(!rachCfg->choice.setup)
1638 DU_LOG("\nDU APP : Rach Config memory alloc failed");
1641 setup = rachCfg->choice.setup;
1643 /* Generic RACH Configuration */
1644 setup->rach_ConfigGeneric.prach_ConfigurationIndex = duRachCfg.prachCfgIdx;
1645 setup->rach_ConfigGeneric.msg1_FDM = duRachCfg.msg1Fdm;
1646 setup->rach_ConfigGeneric.msg1_FrequencyStart = duRachCfg.msg1FreqStart;
1647 setup->rach_ConfigGeneric.zeroCorrelationZoneConfig = duRachCfg.zeroCorrZoneCfg;
1648 setup->rach_ConfigGeneric.preambleReceivedTargetPower = duRachCfg.preambleRcvdTgtPwr;
1649 setup->rach_ConfigGeneric.preambleTransMax = duRachCfg.preambleTransMax;
1650 setup->rach_ConfigGeneric.powerRampingStep = duRachCfg.pwrRampingStep;
1651 setup->rach_ConfigGeneric.ra_ResponseWindow = duRachCfg.raRspWindow;
1653 /* Total number of RA preambles */
1654 DU_ALLOC(setup->totalNumberOfRA_Preambles, sizeof(long));
1655 if(!setup->totalNumberOfRA_Preambles)
1657 DU_LOG("\nDU APP : Rach Config memory alloc failed");
1660 *setup->totalNumberOfRA_Preambles = duRachCfg.numRaPreamble;
1662 /* SSB per RACH occassion and CB Preambles per SSB */
1663 DU_ALLOC(setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB,\
1664 sizeof(struct RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB));
1665 if(!setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB)
1667 DU_LOG("\nDU APP : Rach Config memory alloc failed");
1670 setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present = \
1671 duRachCfg.ssbPerRachOccPresent;
1672 switch(setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->present)
1674 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_NOTHING:
1679 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneEighth:
1684 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneFourth:
1689 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_oneHalf:
1694 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_one:
1696 setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB->choice.one =\
1697 duRachCfg.numSsbPerRachOcc;
1699 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_two:
1704 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_four:
1709 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_eight:
1714 case RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB_PR_sixteen:
1721 DU_LOG("\nDU APP: Invalid value for \
1722 ssb_PerRach_OccassionAndCB_PreamblesPerSSB");
1727 /* RA Contention Resolution Timer */
1728 setup->ra_ContentionResolutionTimer = duRachCfg.contResTimer;
1730 /* RSRP Threshold SSB */
1731 DU_ALLOC(setup->rsrp_ThresholdSSB, sizeof(RSRP_Range_t));
1732 if(!setup->rsrp_ThresholdSSB)
1734 DU_LOG("\nDU APP : Rach Config memory alloc failed");
1737 *setup->rsrp_ThresholdSSB = duRachCfg.rsrpThreshSsb;
1739 /* Root Sequence index */
1740 setup->prach_RootSequenceIndex.present = duRachCfg.rootSeqIdxPresent;
1741 switch(setup->prach_RootSequenceIndex.present)
1743 case RACH_ConfigCommon__prach_RootSequenceIndex_PR_NOTHING:
1748 case RACH_ConfigCommon__prach_RootSequenceIndex_PR_l839:
1753 case RACH_ConfigCommon__prach_RootSequenceIndex_PR_l139:
1755 setup->prach_RootSequenceIndex.choice.l139 = duRachCfg.rootSeqIdx;
1760 DU_LOG("\nDU APP: Inavlid PRACH root sequence index type");
1765 /* Msg 1 Subcarrier spacing */
1766 DU_ALLOC(setup->msg1_SubcarrierSpacing, sizeof(SubcarrierSpacing_t));
1767 if(!setup->msg1_SubcarrierSpacing)
1769 DU_LOG("\nDU APP : Rach Config memory alloc failed");
1772 *setup->msg1_SubcarrierSpacing = duRachCfg.msg1Scs;
1774 /* Restricted Set Config */
1775 setup->restrictedSetConfig = duRachCfg.restrictedSetCfg;
1781 DU_LOG("\nDU APP : Invalid RACH Config type ");
1786 }/* BuildRachCfgCommon */
1788 /*******************************************************************
1790 * @brief Builds PUSCH configuration for common
1794 * Function : BuildPuschCfgCommon
1797 * Builds PUSCH configuration for common
1800 * @return ROK - success
1803 * ****************************************************************/
1805 uint8_t BuildPuschCfgCommon(struct BWP_UplinkCommon__pusch_ConfigCommon *puschCfg)
1809 PuschCfgCommon duPuschCfg;
1810 PUSCH_ConfigCommon_t *setup;
1811 PUSCH_TimeDomainResourceAllocation_t *timeDomRsrcAllocInfo;
1813 duPuschCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.puschCfg;
1815 puschCfg->present = duPuschCfg.present;
1816 switch(puschCfg->present)
1818 case BWP_UplinkCommon__pusch_ConfigCommon_PR_NOTHING:
1823 case BWP_UplinkCommon__pusch_ConfigCommon_PR_release:
1828 case BWP_UplinkCommon__pusch_ConfigCommon_PR_setup:
1830 DU_ALLOC(puschCfg->choice.setup, sizeof(PUSCH_ConfigCommon_t));
1831 if(!puschCfg->choice.setup)
1833 DU_LOG("\nDU APP : PUSCH Config memory alloc failed");
1836 setup = puschCfg->choice.setup;
1838 /* Time Domain Resource Allocation List */
1839 DU_ALLOC(setup->pusch_TimeDomainAllocationList,\
1840 sizeof(PUSCH_TimeDomainResourceAllocationList_t));
1841 if(!setup->pusch_TimeDomainAllocationList)
1843 DU_LOG("\nDU APP : PUSCH Config memory alloc failed");
1846 elementCnt = ODU_VALUE_ONE;
1847 setup->pusch_TimeDomainAllocationList->list.count = elementCnt;
1848 setup->pusch_TimeDomainAllocationList->list.size = \
1849 elementCnt * sizeof(PUSCH_TimeDomainResourceAllocation_t *);
1851 DU_ALLOC(setup->pusch_TimeDomainAllocationList->list.array, \
1852 setup->pusch_TimeDomainAllocationList->list.size);
1853 if(!setup->pusch_TimeDomainAllocationList->list.array)
1855 DU_LOG("\nDU APP : PUSCH Config memory alloc failed");
1859 for(idx=0; idx<elementCnt; idx++)
1861 DU_ALLOC(setup->pusch_TimeDomainAllocationList->list.array[idx],\
1862 sizeof(PUSCH_TimeDomainResourceAllocation_t));
1863 if(!setup->pusch_TimeDomainAllocationList->list.array[idx])
1865 DU_LOG("\nDU APP : PUSCH Config memory alloc failed");
1871 timeDomRsrcAllocInfo = setup->pusch_TimeDomainAllocationList->list.array[idx];
1874 DU_ALLOC(timeDomRsrcAllocInfo->k2, sizeof(long));
1875 if(!timeDomRsrcAllocInfo->k2)
1877 DU_LOG("\nDU APP : PUSCH Config memory alloc failed");
1880 *timeDomRsrcAllocInfo->k2 = duPuschCfg.k2;
1882 timeDomRsrcAllocInfo->mappingType = duPuschCfg.mapType;
1883 timeDomRsrcAllocInfo->startSymbolAndLength = duPuschCfg.sliv;
1885 /* Msg3 Delta Preamble */
1886 DU_ALLOC(setup->msg3_DeltaPreamble, sizeof(long));
1887 if(!setup->msg3_DeltaPreamble)
1889 DU_LOG("\nDU APP : PUSCH Config memory alloc failed");
1892 *setup->msg3_DeltaPreamble = duPuschCfg.msg3DeltaPreamble;
1894 /* P0 Nominal with grnat */
1895 DU_ALLOC(setup->p0_NominalWithGrant, sizeof(long));
1896 if(!setup->p0_NominalWithGrant)
1898 DU_LOG("\nDU APP : PUSCH Config memory alloc failed");
1901 *setup->p0_NominalWithGrant = duPuschCfg.p0NominalWithGrant;
1907 DU_LOG("\nDU APP : Invalid PUSCH configuration type ");
1913 }/* BuildPuschCfgCommon */
1915 /*******************************************************************
1917 * @brief Builds PUCCH configuration common
1921 * Function : BuildPucchCfgCommon
1924 * Builds PUCCH configuration common
1927 * @return ROK - success
1930 * ****************************************************************/
1932 uint8_t BuildPucchCfgCommon( struct BWP_UplinkCommon__pucch_ConfigCommon *pucchCfg)
1934 PucchCfgCommon duPucchCfg;
1935 PUCCH_ConfigCommon_t *setup;
1937 duPucchCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.pucchCfg;
1939 pucchCfg->present = duPucchCfg.present;
1940 switch(pucchCfg->present)
1942 case BWP_UplinkCommon__pucch_ConfigCommon_PR_NOTHING:
1947 case BWP_UplinkCommon__pucch_ConfigCommon_PR_release:
1952 case BWP_UplinkCommon__pucch_ConfigCommon_PR_setup:
1954 DU_ALLOC(pucchCfg->choice.setup, sizeof(PUCCH_ConfigCommon_t));
1955 if(!pucchCfg->choice.setup)
1957 DU_LOG("\nDU APP : PUCCH Config memory alloc failed");
1960 setup = pucchCfg->choice.setup;
1962 /* Resource Common */
1963 DU_ALLOC(setup->pucch_ResourceCommon, sizeof(long));
1964 if(!setup->pucch_ResourceCommon)
1966 DU_LOG("\nDU APP : PUCCH Config memory alloc failed");
1969 *setup->pucch_ResourceCommon = duPucchCfg.rsrcComm;
1972 setup->pucch_GroupHopping = duPucchCfg.grpHop;
1975 DU_ALLOC(setup->p0_nominal, sizeof(long));
1976 if(!setup->p0_nominal)
1978 DU_LOG("\nDU APP : PUCCH Config memory alloc failed");
1981 *setup->p0_nominal = duPucchCfg.p0Nominal;
1987 DU_LOG("\nDU APP : Invalid PUCCH Config type");
1992 }/* BuildPucchCfgCommon */
1994 /*******************************************************************
1996 * @brief Builds UL BWP Common
2000 * Function : BuildBwpUlCommon
2003 * Builds UL BWP Common
2005 * @params[in] BWP_UplinkCommon_t pointer
2006 * @return ROK - success
2009 * ****************************************************************/
2011 uint8_t BuildBwpUlCommon(BWP_UplinkCommon_t *bwp)
2014 UlCfgCommon duUlCfg;
2016 duUlCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg;
2018 bwp->genericParameters.locationAndBandwidth = duUlCfg.locAndBw;
2019 bwp->genericParameters.subcarrierSpacing = duUlCfg.ulScsCarrier.scs;
2021 /* RACH Config Common */
2022 DU_ALLOC(bwp->rach_ConfigCommon,\
2023 sizeof(struct BWP_UplinkCommon__rach_ConfigCommon));
2024 if(!bwp->rach_ConfigCommon)
2026 DU_LOG("\nDU APP : UL BWP memory allocation failed");
2029 ret = BuildRachCfgCommon(bwp->rach_ConfigCommon);
2034 RachCfgCommonret=ROK;
2036 /* PUSCH Config Common */
2037 DU_ALLOC(bwp->pusch_ConfigCommon,\
2038 sizeof(struct BWP_UplinkCommon__pusch_ConfigCommon));
2039 if(!bwp->pusch_ConfigCommon)
2041 DU_LOG("\nDU APP : UL BWP memory allocation failed");
2044 ret = BuildPuschCfgCommon(bwp->pusch_ConfigCommon);
2049 PuschCfgCommonret = ROK;
2051 /* PUCCH Config Common */
2052 DU_ALLOC(bwp->pucch_ConfigCommon,\
2053 sizeof(struct BWP_UplinkCommon__pucch_ConfigCommon));
2054 if(!bwp->pucch_ConfigCommon)
2056 DU_LOG("\nDU APP : UL BWP memory allocation failed");
2059 ret = BuildPucchCfgCommon(bwp->pucch_ConfigCommon);
2065 }/* BuildBwpUlCommon */
2067 /*******************************************************************
2069 * @brief Builds UL config common for SIB
2073 * Function : BuildUlCfgCommSib
2076 * Builds UL config common for SIB
2078 * @params[in] UplinkConfigCommonSIB_t pointer
2079 * @return ROK - success
2082 * ****************************************************************/
2084 uint8_t BuildUlCfgCommSib(UplinkConfigCommonSIB_t *ulCfg)
2087 /* UL frequency info */
2088 ret = BuildFreqInfoUl(&ulCfg->frequencyInfoUL);
2093 /* BWP Uplink Common */
2094 ret = BuildBwpUlCommon(&ulCfg->initialUplinkBWP);
2099 /* Time Alignment timer */
2100 ulCfg->timeAlignmentTimerCommon = \
2101 duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.timeAlignTimerComm;
2104 }/* BuildUlCfgCommSib */
2106 /*******************************************************************
2108 * @brief Builds TDD UL DL configuration common
2112 * Function : BuildTddUlDlCfgComm
2115 * Builds TDD UL DL configuration common
2117 * @params[in] TDD_UL_DL_ConfigCommon_t pointer
2118 * @return ROK - success
2121 * ****************************************************************/
2123 uint8_t BuildTddUlDlCfgComm(TDD_UL_DL_ConfigCommon_t *tddCfg)
2125 TddUlDlCfgCommon duTddCfg;
2127 duTddCfg = duCfgParam.sib1Params.srvCellCfgCommSib.tddCfg;
2129 /* Reference Subcarrier spacing */
2130 tddCfg->referenceSubcarrierSpacing = duTddCfg.refScs;
2133 tddCfg->pattern1.dl_UL_TransmissionPeriodicity = duTddCfg.txPrd;
2134 tddCfg->pattern1.nrofDownlinkSlots = duTddCfg.numDlSlots;
2135 tddCfg->pattern1.nrofDownlinkSymbols = duTddCfg.numDlSymbols;
2136 tddCfg->pattern1.nrofUplinkSlots = duTddCfg.numUlSlots;
2137 tddCfg->pattern1.nrofUplinkSymbols = duTddCfg.numUlSymbols;
2141 }/* BuildTddUlDlCfgComm */
2143 /*******************************************************************
2145 * @brief Builds Serving cell config common in SIB1 message
2149 * Function : BuildServCellCfgCommonSib
2152 * Building Serving cell config common in SIB1 message
2154 * @params[in] ServingCellConfigCommonSIB_t pointer
2155 * @return ROK - success
2158 * ****************************************************************/
2159 uint8_t BuildServCellCfgCommonSib(ServingCellConfigCommonSIB_t *srvCellCfg)
2161 SrvCellCfgCommSib duSrvCellCfg;
2162 BIT_STRING_t *ssbPosInBurst;
2164 duSrvCellCfg = duCfgParam.sib1Params.srvCellCfgCommSib;
2166 /* SSB Position in Burst */
2167 ssbPosInBurst = &srvCellCfg->ssb_PositionsInBurst.inOneGroup;
2168 ssbPosInBurst->size = 1;
2169 DU_ALLOC(ssbPosInBurst->buf, ssbPosInBurst->size * sizeof(uint8_t));
2170 if(!ssbPosInBurst->buf)
2172 DU_LOG("\nDU APP : Serving cell config common memory allocation failure");
2175 ssbPosInBurst->buf[0] = duSrvCellCfg.ssbPosInBurst;
2176 ssbPosInBurst->bits_unused = 0;
2178 srvCellCfg->ssb_PeriodicityServingCell = duSrvCellCfg.ssbPrdServingCell;
2179 srvCellCfg->ss_PBCH_BlockPower = duSrvCellCfg.ssPbchBlockPwr;
2181 /* Downlink config common */
2182 ret = BuildDlCfgCommSib(&srvCellCfg->downlinkConfigCommon);
2187 DlCfgCommSibret = ROK;
2189 /* Uplink Config Comm */
2190 DU_ALLOC(srvCellCfg->uplinkConfigCommon, sizeof(UplinkConfigCommonSIB_t));
2191 if(!srvCellCfg->uplinkConfigCommon)
2193 DU_LOG("\nDU APP : Serving cell config common memory allocation failure");
2196 ret = BuildUlCfgCommSib(srvCellCfg->uplinkConfigCommon);
2201 UlCfgCommSibret=ROK;
2203 /* TDD UL DL Config Comm */
2204 DU_ALLOC(srvCellCfg->tdd_UL_DL_ConfigurationCommon, sizeof(TDD_UL_DL_ConfigCommon_t));
2205 if(!srvCellCfg->tdd_UL_DL_ConfigurationCommon)
2207 DU_LOG("\nDU APP : Serving cell config common memory allocation failure");
2210 ret = BuildTddUlDlCfgComm(srvCellCfg->tdd_UL_DL_ConfigurationCommon);
2218 /*******************************************************************
2220 * @brief Builds SIB message in Served Cell Info
2224 * Function : BuildSib1Msg
2226 * Functionality: Building SIB message in Served Cell Info
2228 * @return ROK - success
2231 * ****************************************************************/
2232 uint8_t BuildSib1Msg()
2235 CellAccessRelatedInfo_t *cellAccessInfo;
2238 asn_enc_rval_t encRetVal;
2239 uint8_t ret = RFAILED;
2243 DU_ALLOC(sib1Msg, sizeof(SIB1_t));
2246 DU_LOG("DU APP: SIB1 msg memory allocation failure");
2250 elementCnt = ODU_VALUE_ONE;
2253 cellAccessInfo = &sib1Msg->cellAccessRelatedInfo;
2254 cellAccessInfo->plmn_IdentityList.list.count =
2256 cellAccessInfo->plmn_IdentityList.list.size
2257 = elementCnt * sizeof(PLMN_IdentityInfo_t *);
2259 ret1 = BuildPlmnList(cellAccessInfo);
2264 /* Connection Establish Failure Control */
2265 DU_ALLOC(sib1Msg->connEstFailureControl, sizeof(ConnEstFailureControl_t));
2266 if(!sib1Msg->connEstFailureControl)
2268 DU_LOG("DU APP: sib1Msg->connEstFailureControl memory allocation failure");
2271 sib1Msg->connEstFailureControl->connEstFailCount =\
2272 duCfgParam.sib1Params.connEstFailCnt;
2273 sib1Msg->connEstFailureControl->connEstFailOffsetValidity =\
2274 duCfgParam.sib1Params.connEstFailOffValidity;
2276 /* SI Scheduling Info */
2277 DU_ALLOC(sib1Msg->si_SchedulingInfo, sizeof(SI_SchedulingInfo_t));
2278 if(!sib1Msg->si_SchedulingInfo)
2280 DU_LOG("DU APP: sib1Msg->si_SchedulingInfo memory allocation failure");
2283 elementCnt = ODU_VALUE_ONE;
2284 sib1Msg->si_SchedulingInfo->schedulingInfoList.list.count = elementCnt;
2285 sib1Msg->si_SchedulingInfo->schedulingInfoList.list.size = elementCnt *
2286 sizeof(struct SchedulingInfo *);
2287 ret1 = BuildSiSchedInfoList(&sib1Msg->si_SchedulingInfo->schedulingInfoList);
2292 sib1Msg->si_SchedulingInfo->si_WindowLength = duCfgParam.sib1Params.siSchedInfo.winLen;
2294 /* Serving Cell Config Common */
2295 DU_ALLOC(sib1Msg->servingCellConfigCommon, sizeof(ServingCellConfigCommonSIB_t));
2296 if(!sib1Msg->servingCellConfigCommon)
2298 DU_LOG("DU APP: sib1Msg->servingCellConfigCommon memory allocation failure");
2301 ret1 = BuildServCellCfgCommonSib(sib1Msg->servingCellConfigCommon);
2307 xer_fprint(stdout, &asn_DEF_SIB1, sib1Msg);
2309 /* Encode the F1SetupRequest type as APER */
2310 cmMemset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
2312 encRetVal = aper_encode(&asn_DEF_SIB1, 0, sib1Msg, PrepFinalEncBuf,\
2314 printf("\nencbufSize: %d\n", encBufSize);
2315 if(encRetVal.encoded == -1)
2317 DU_LOG("\nDU APP : Could not encode SIB1 structure (at %s)\n",\
2318 encRetVal.failed_type ?
2319 encRetVal.failed_type->name :
2323 for(int i=0; i< encBufSize; i++)
2325 printf("%x\t",encBuf[i]);
2333 FreeSib1Msg(sib1Msg);
2339 /*******************************************************************
2341 * @brief : deallocating the memory of BuildSib1Msg
2345 * Function : FreeFreqInfoDl
2347 * Functionality: Freeing memory of BuildFreqInfoDl
2349 * @params[in] : FrequencyInfoDL_SIB_t *frequencyInfoDL
2352 *******************************************************************/
2353 void FreeFreqInfoDl(FrequencyInfoDL_SIB_t *frequencyInfoDL)
2358 /* Free DL frequency info */
2359 if(!frequencyInfoDL->frequencyBandList.list.array)
2361 /*Free Frequency band indicator */
2362 if(!frequencyInfoDL->frequencyBandList.list.array[idx])
2364 if(!frequencyInfoDL->frequencyBandList.list.array[idx]->\
2365 freqBandIndicatorNR)
2367 if(!frequencyInfoDL->scs_SpecificCarrierList.list.array)
2369 for(idx1 = 0;idx1<frequencyInfoDL->scs_SpecificCarrierList.list.count;idx1++)
2371 if(!frequencyInfoDL->scs_SpecificCarrierList.list.array[idx1])
2373 DU_FREE(frequencyInfoDL->scs_SpecificCarrierList.list.\
2374 array[idx1], sizeof(SCS_SpecificCarrier_t));
2377 DU_FREE(frequencyInfoDL->scs_SpecificCarrierList.list.array,
2378 frequencyInfoDL->scs_SpecificCarrierList.list.size);
2380 DU_FREE(frequencyInfoDL->frequencyBandList.list.\
2381 array[idx]->freqBandIndicatorNR, sizeof(FreqBandIndicatorNR_t));
2384 for(idx = 0; idx <frequencyInfoDL->frequencyBandList.list.count; idx++)
2386 if(!frequencyInfoDL->frequencyBandList.list.array[idx])
2388 DU_FREE(frequencyInfoDL->frequencyBandList.list.array[idx],\
2389 sizeof(NR_MultiBandInfo_t));
2392 DU_FREE(frequencyInfoDL->frequencyBandList.list.array,\
2393 frequencyInfoDL->frequencyBandList.list.size);
2396 /*******************************************************************
2398 * @brief : deallocating the memory of BuildSib1Msg
2402 * Function : FreeCommonSerachSpaceList
2404 * Functionality: deallocating the memory of BuildCommonSerachSpaceList
2406 * @params[in] :struct PDCCH_ConfigCommon__commonSearchSpaceList *searchSpclist
2409 *******************************************************************/
2410 void FreeCommonSerachSpaceList( struct PDCCH_ConfigCommon__commonSearchSpaceList
2414 SearchSpace_t *searchSpace= NULLP;
2416 if(!searchSpclist->list.array)
2418 if( searchSpclist->list.array[idx] != NULLP)
2420 searchSpace= searchSpclist->list.array[idx];
2421 if(!searchSpace->controlResourceSetId)
2423 if(!searchSpace->monitoringSlotPeriodicityAndOffset)
2425 if(!searchSpace->monitoringSymbolsWithinSlot)
2427 if(!searchSpace->monitoringSymbolsWithinSlot->buf)
2429 if(!searchSpace->nrofCandidates)
2431 if(!searchSpace->searchSpaceType)
2433 switch(searchSpace->searchSpaceType->present)
2435 case SearchSpace__searchSpaceType_PR_NOTHING:
2437 case SearchSpace__searchSpaceType_PR_common:
2439 if(!searchSpace->searchSpaceType->choice.common)
2441 if(!searchSpace->searchSpaceType->choice.\
2442 common->dci_Format0_0_AndFormat1_0)
2444 DU_FREE(searchSpace->searchSpaceType->choice.\
2445 common->dci_Format0_0_AndFormat1_0,sizeof(struct\
2446 SearchSpace__searchSpaceType__common__dci_Format0_0_AndFormat1_0));
2448 DU_FREE(searchSpace->searchSpaceType->choice.common,\
2449 sizeof(struct SearchSpace__searchSpaceType__common));
2453 case SearchSpace__searchSpaceType_PR_ue_Specific:
2458 DU_FREE(searchSpace->searchSpaceType,\
2459 sizeof( struct SearchSpace__searchSpaceType));
2461 DU_FREE(searchSpace->nrofCandidates,\
2462 sizeof(struct SearchSpace__nrofCandidates));
2464 DU_FREE(searchSpace->monitoringSymbolsWithinSlot->buf,\
2465 searchSpace->monitoringSymbolsWithinSlot->size);
2467 DU_FREE(searchSpace->monitoringSymbolsWithinSlot,\
2468 sizeof(BIT_STRING_t));
2470 DU_FREE(searchSpace->monitoringSlotPeriodicityAndOffset,\
2471 sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
2473 DU_FREE(searchSpace->controlResourceSetId,sizeof(ControlResourceSetId_t));
2476 for(idx = 0; idx < searchSpclist->list.count; idx++)
2478 if(!searchSpclist->list.array[idx])
2480 DU_FREE(searchSpclist->list.array[idx], sizeof(SearchSpace_t));
2483 DU_FREE(searchSpclist->list.array, searchSpclist->list.size)
2486 /*******************************************************************
2488 * @brief : deallocating the memory of BuildSib1Msg
2492 * Function : FreeBwpDlCommon
2494 * Functionality :Deallocating memory of BuildBwpDlCommon
2496 * @params[in] : BWP_DownlinkCommon_t *bwp
2500 *******************************************************************/
2501 void FreeBwpDlCommon(BWP_DownlinkCommon_t *bwp)
2504 struct BWP_DownlinkCommon__pdsch_ConfigCommon *pdschCfg=bwp->pdsch_ConfigCommon;
2505 struct BWP_DownlinkCommon__pdcch_ConfigCommon *pdcchCfg=bwp->pdcch_ConfigCommon;
2506 pdcchCfg->present=duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdcchCfg.present;
2507 pdschCfg->present=duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.pdschCfg.present;
2509 if(!bwp->pdcch_ConfigCommon)
2511 if(!bwp->pdsch_ConfigCommon)
2513 switch( pdschCfg->present)
2515 case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_NOTHING:
2520 case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_release:
2525 case BWP_DownlinkCommon__pdsch_ConfigCommon_PR_setup:
2527 if(!pdschCfg->choice.setup)
2529 if(!pdschCfg->choice.setup->pdsch_TimeDomainAllocationList)
2531 if(!pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array)
2533 if(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx]!= NULLP)
2535 if(!pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx]->k0)
2537 DU_FREE(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx]->k0,\
2541 for(idx=0; idx<pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.count ; idx++)
2543 if(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx]!=
2546 DU_FREE(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array[idx],\
2547 sizeof(PDSCH_TimeDomainResourceAllocation_t));
2550 DU_FREE(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.array,\
2551 pdschCfg->choice.setup->pdsch_TimeDomainAllocationList->list.size);
2553 DU_FREE(pdschCfg->choice.setup->pdsch_TimeDomainAllocationList,\
2554 sizeof(PDSCH_TimeDomainResourceAllocationList_t));
2556 DU_FREE(pdschCfg->choice.setup,
2557 sizeof(PDSCH_ConfigCommon_t));
2563 DU_FREE(bwp->pdsch_ConfigCommon,\
2564 sizeof(struct BWP_DownlinkCommon__pdsch_ConfigCommon));
2567 switch(pdcchCfg->present)
2569 case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_NOTHING:
2574 case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_release:
2579 case BWP_DownlinkCommon__pdcch_ConfigCommon_PR_setup:
2581 if(!pdcchCfg->choice.setup)
2583 /* Control Resource Set Zero */
2584 if(! pdcchCfg->choice.setup->controlResourceSetZero)
2586 /* Search space zero */
2587 if(! pdcchCfg->choice.setup->searchSpaceZero)
2589 /* Common Search Space List */
2590 if(! pdcchCfg->choice.setup->commonSearchSpaceList)
2592 if(CommonSerachSpaceListret==ROK)
2594 if(!pdcchCfg->choice.setup->searchSpaceSIB1)
2596 if(!pdcchCfg->choice.setup->pagingSearchSpace)
2598 if(!pdcchCfg->choice.setup->ra_SearchSpace)
2600 DU_FREE(pdcchCfg->choice.setup->ra_SearchSpace,
2601 sizeof(SearchSpaceId_t));
2603 DU_FREE( pdcchCfg->choice.setup->pagingSearchSpace,
2604 sizeof(SearchSpaceId_t));
2606 DU_FREE( pdcchCfg->choice.setup->searchSpaceSIB1,
2607 sizeof(SearchSpaceId_t));
2611 FreeCommonSerachSpaceList(pdcchCfg->choice.setup->commonSearchSpaceList);
2613 DU_FREE( pdcchCfg->choice.setup->commonSearchSpaceList,\
2615 PDCCH_ConfigCommon__commonSearchSpaceList));
2617 DU_FREE( pdcchCfg->choice.setup->searchSpaceZero,
2618 sizeof(SearchSpaceZero_t));
2620 DU_FREE( pdcchCfg->choice.setup->controlResourceSetZero,
2621 sizeof(ControlResourceSetZero_t));
2623 DU_FREE(pdcchCfg->choice.setup,
2624 sizeof(PDCCH_ConfigCommon_t));
2631 DU_FREE(bwp->pdcch_ConfigCommon,sizeof(struct BWP_DownlinkCommon__pdcch_ConfigCommon));
2634 /*******************************************************************
2636 * @brief deallocating the memory of BuildSib1Msg
2640 * Function: FreeUlCfgCommSib
2642 * Functionality deallocating the memory of BuildUlCfgCommSib
2644 * @params[in] : UplinkConfigCommonSIB_t *ulCfg
2648 *******************************************************************/
2649 void FreeUlCfgCommSib(UplinkConfigCommonSIB_t *ulCfg)
2652 RACH_ConfigCommon_t *setup;
2653 BWP_UplinkCommon_t *bwp=&ulCfg->initialUplinkBWP;
2654 struct FrequencyInfoUL_SIB__scs_SpecificCarrierList *scsCarrierList;
2655 struct BWP_UplinkCommon__rach_ConfigCommon *rachCfg;
2656 struct BWP_UplinkCommon__pucch_ConfigCommon *pucchCfg;
2657 struct BWP_UplinkCommon__pusch_ConfigCommon *puschCfg;
2658 puschCfg=ulCfg->initialUplinkBWP.pusch_ConfigCommon;
2659 rachCfg =bwp->rach_ConfigCommon;
2660 scsCarrierList = &ulCfg->frequencyInfoUL.scs_SpecificCarrierList;
2662 if(!scsCarrierList->list.array)
2664 if(!ulCfg->frequencyInfoUL.p_Max)
2666 if(FreqInfoUlret == ROK)
2668 if(!bwp->rach_ConfigCommon)
2670 if(RachCfgCommonret== ROK)
2672 if(!bwp->pusch_ConfigCommon)
2675 if(PuschCfgCommonret==ROK)
2677 if(!bwp->pucch_ConfigCommon)
2679 pucchCfg=bwp->pucch_ConfigCommon;
2680 switch(pucchCfg->present)
2682 case BWP_UplinkCommon__pucch_ConfigCommon_PR_NOTHING:
2684 case BWP_UplinkCommon__pucch_ConfigCommon_PR_release:
2686 case BWP_UplinkCommon__pucch_ConfigCommon_PR_setup:
2688 if(!pucchCfg->choice.setup)
2691 if(!pucchCfg->choice.setup->pucch_ResourceCommon)
2693 if(!pucchCfg->choice.setup->p0_nominal)
2695 DU_FREE(pucchCfg->choice.setup->p0_nominal,
2698 DU_FREE(pucchCfg->choice.setup->pucch_ResourceCommon,
2701 DU_FREE(pucchCfg->choice.setup,
2702 sizeof(PUCCH_ConfigCommon_t));
2708 DU_FREE(bwp->pucch_ConfigCommon,\
2710 BWP_UplinkCommon__pucch_ConfigCommon));
2713 switch(puschCfg->present)
2715 case BWP_UplinkCommon__pusch_ConfigCommon_PR_NOTHING:
2717 case BWP_UplinkCommon__pusch_ConfigCommon_PR_release:
2719 case BWP_UplinkCommon__pusch_ConfigCommon_PR_setup:
2721 if(!puschCfg->choice.setup)
2724 if(! puschCfg->choice.setup->pusch_TimeDomainAllocationList)
2726 if(! puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array)
2728 if(!puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array[idx])
2730 if(!puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array[idx]->k2)
2732 if(! puschCfg->choice.setup->msg3_DeltaPreamble)
2734 if(!puschCfg->choice.setup->p0_NominalWithGrant)
2736 DU_FREE(puschCfg->choice.setup->p0_NominalWithGrant,
2739 DU_FREE(puschCfg->choice.setup->msg3_DeltaPreamble,
2742 DU_FREE(puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.\
2743 array[idx]->k2, sizeof(long));
2747 idx<puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.count;
2750 if(!puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array[idx])
2752 DU_FREE(puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array[idx],\
2753 sizeof(PUSCH_TimeDomainResourceAllocation_t));
2756 DU_FREE(puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.array,\
2757 puschCfg->choice.setup->pusch_TimeDomainAllocationList->list.size);
2759 DU_FREE(puschCfg->choice.setup->pusch_TimeDomainAllocationList,\
2760 sizeof(PUSCH_TimeDomainResourceAllocationList_t));
2762 DU_FREE(puschCfg->choice.setup,
2763 sizeof(PUSCH_ConfigCommon_t));
2770 DU_FREE(bwp->pusch_ConfigCommon,\
2771 sizeof(struct BWP_UplinkCommon__pusch_ConfigCommon));
2774 switch(rachCfg->present)
2776 case BWP_UplinkCommon__rach_ConfigCommon_PR_NOTHING:
2778 case BWP_UplinkCommon__rach_ConfigCommon_PR_release:
2780 case BWP_UplinkCommon__rach_ConfigCommon_PR_setup:
2782 if(!rachCfg->choice.setup)
2784 setup = rachCfg->choice.setup;
2785 if(!setup->totalNumberOfRA_Preambles)
2787 if(!setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB)
2789 if(!setup->rsrp_ThresholdSSB)
2791 if(!setup->msg1_SubcarrierSpacing)
2793 DU_FREE(setup->msg1_SubcarrierSpacing,
2794 sizeof(SubcarrierSpacing_t));
2796 DU_FREE(setup->rsrp_ThresholdSSB,
2797 sizeof(RSRP_Range_t));
2799 DU_FREE(setup->ssb_perRACH_OccasionAndCB_PreamblesPerSSB,\
2801 RACH_ConfigCommon__ssb_perRACH_OccasionAndCB_PreamblesPerSSB));
2803 DU_FREE(setup->totalNumberOfRA_Preambles,
2807 DU_FREE(rachCfg->choice.setup,
2808 sizeof(RACH_ConfigCommon_t));
2814 DU_FREE(bwp->rach_ConfigCommon,\
2815 sizeof(struct BWP_UplinkCommon__rach_ConfigCommon));
2818 DU_FREE(ulCfg->frequencyInfoUL.p_Max, sizeof(P_Max_t));
2820 for(idx = 0; idx < scsCarrierList->list.count; idx++)
2822 if(!scsCarrierList->list.array[idx])
2824 DU_FREE(scsCarrierList->list.array[idx],
2825 sizeof(SCS_SpecificCarrier_t));
2828 DU_FREE(scsCarrierList->list.array, scsCarrierList->list.size);
2831 /*******************************************************************
2833 * @brief : Deallocating memory of SIB1 message
2837 * Function : FreeServCellCfgCommonSib
2839 * Functionality: Deallocating memory of BuildServCellCfgCommonSib
2841 * @params[in] : ServingCellConfigCommonSIB_t *srvCellCfg
2844 *******************************************************************/
2845 void FreeServCellCfgCommonSib(ServingCellConfigCommonSIB_t *srvCellCfg)
2847 BIT_STRING_t *ssbPosInBurst;
2848 ssbPosInBurst = &srvCellCfg->ssb_PositionsInBurst.inOneGroup;
2849 DownlinkConfigCommonSIB_t *dlCfg=&srvCellCfg->downlinkConfigCommon;
2851 if(!ssbPosInBurst->buf)
2853 /* Free DL frequency info */
2854 if(FreqInfoDlret == ROK)
2856 if(DlCfgCommSibret == ROK)
2858 /* Uplink Config Comm */
2859 if(!srvCellCfg->uplinkConfigCommon)
2861 if(UlCfgCommSibret==ROK)
2863 /* TDD UL DL Config Comm */
2864 if(!srvCellCfg->tdd_UL_DL_ConfigurationCommon)
2866 DU_FREE(srvCellCfg->tdd_UL_DL_ConfigurationCommon,
2867 sizeof(TDD_UL_DL_ConfigCommon_t));
2870 FreeUlCfgCommSib(srvCellCfg->uplinkConfigCommon);
2871 DU_FREE(srvCellCfg->uplinkConfigCommon,
2872 sizeof(UplinkConfigCommonSIB_t));
2875 FreeBwpDlCommon(&dlCfg->initialDownlinkBWP);
2877 FreeFreqInfoDl(&dlCfg->frequencyInfoDL);
2878 DU_FREE(ssbPosInBurst->buf, ssbPosInBurst->size * sizeof(uint8_t));
2881 /*******************************************************************
2883 * @brief : Deallcating memory of the function BuildSib1Msg
2887 * Function : FreeSib1Msg
2889 * Functionality: Deallcating memory of the function BuildSib1Msg
2891 * @params[in] ServingCellConfigCommonSIB_t pointer
2894 *******************************************************************/
2895 void FreeSib1Msg(SIB1_t *sib1Msg)
2900 CellIdentity_t *cellIdentity = NULLP;
2901 CellAccessRelatedInfo_t *cellAccessInfo ;
2902 struct PLMN_IdentityInfo__plmn_IdentityList *plmnIdInfo;
2905 if(sib1Msg != NULLP)
2907 cellAccessInfo = &sib1Msg->cellAccessRelatedInfo;
2908 if(cellAccessInfo->plmn_IdentityList.list.array !=NULLP)
2910 if(cellAccessInfo->plmn_IdentityList.list.array[idx]!=NULLP)
2913 &cellAccessInfo->plmn_IdentityList.list.array[idx]->plmn_IdentityList;
2915 if(plmnIdInfo->list.array !=NULLP)
2917 if(!plmnIdInfo->list.array[idx])
2919 if(!plmnIdInfo->list.array[idx]->mcc)
2921 if(!(plmnIdInfo->list.array[idx]->mcc->list.array))
2923 if(!plmnIdInfo->list.array[idx]->mnc.list.array)
2925 /*Free Tracking Area Code */
2926 if(!cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode)
2929 if(!cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode->buf)
2931 /* Free CellIdentity */
2932 if(!cellAccessInfo->plmn_IdentityList.list.array[idx]->ranac)
2935 =&cellAccessInfo->plmn_IdentityList.\
2936 list.array[idx]->cellIdentity;
2937 if(!cellIdentity->buf)
2939 /*Free Connection Establish Failure Control */
2940 if(!sib1Msg->connEstFailureControl)
2942 /*Free Serving Cell Config Common */
2943 if(!sib1Msg->si_SchedulingInfo)
2945 /* Free Serving Cell Config Common* */
2946 if(!sib1Msg->servingCellConfigCommon)
2948 /*Free BuildServCellCfgCommonSib*/
2949 FreeServCellCfgCommonSib(\
2950 sib1Msg->servingCellConfigCommon);
2952 DU_FREE(sib1Msg->servingCellConfigCommon,
2953 sizeof(ServingCellConfigCommonSIB_t));
2956 DU_FREE(sib1Msg->si_SchedulingInfo,
2957 sizeof(SI_SchedulingInfo_t));
2960 DU_FREE(sib1Msg->connEstFailureControl,
2961 sizeof(ConnEstFailureControl_t));
2963 DU_FREE(cellIdentity->buf,cellIdentity->size);
2966 DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx]->ranac, sizeof(RAN_AreaCode_t));
2969 DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode->buf,\
2970 cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode->size);
2973 DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx]->trackingAreaCode\
2974 , sizeof(TrackingAreaCode_t));
2977 for(idx2=0; idx2<plmnIdInfo->list.array[idx1]->mnc.list.count; idx2++)
2979 if(!plmnIdInfo->list.array[idx2]->mnc.list.array[idx2])
2981 DU_FREE(plmnIdInfo->list.array[idx2]->mnc.list.array[idx2],
2982 sizeof(MCC_MNC_Digit_t));
2985 DU_FREE(plmnIdInfo->list.array[idx]->mnc.list.array,
2986 plmnIdInfo->list.array[idx1]->mnc.list.size);
2989 for(idx1=0; idx1<plmnIdInfo->list.array[idx]->mcc->list.count; idx1++)
2991 if(plmnIdInfo->list.array[idx]->mcc->list.array[idx1]!=NULLP)
2993 DU_FREE(plmnIdInfo->list.array[idx]->mcc->list.array[idx1],\
2994 sizeof(MCC_MNC_Digit_t));
2998 DU_FREE(plmnIdInfo->list.array[idx]->mcc->list.array,\
2999 plmnIdInfo->list.array[idx]->mcc->list.size)
3001 DU_FREE(plmnIdInfo->list.array[idx]->mcc,sizeof(MCC_t));
3004 for(idx1=0; idx1<plmnIdInfo->list.count; idx1++)
3006 if(!(plmnIdInfo->list.array[idx1]))
3008 DU_FREE(plmnIdInfo->list.array[idx1],
3009 sizeof(PLMN_IdentitY_t));
3012 DU_FREE(plmnIdInfo->list.array, plmnIdInfo->list.size);
3015 for(idx=0; idx<cellAccessInfo->plmn_IdentityList.list.count; idx++)
3017 if(cellAccessInfo->plmn_IdentityList.list.array[idx]!=NULLP)
3019 DU_FREE(cellAccessInfo->plmn_IdentityList.list.array[idx],
3020 sizeof(PLMN_IdentityInfo_t));
3023 DU_FREE(cellAccessInfo->plmn_IdentityList.list.array,
3024 cellAccessInfo->plmn_IdentityList.list.size);
3026 DU_FREE(sib1Msg, sizeof(SIB1_t));
3031 /**********************************************************************
3033 **********************************************************************/