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 F1AP message handler functions */
20 #include "common_def.h"
26 #include "du_app_mac_inf.h"
28 #include "du_app_rlc_inf.h"
29 #include "du_mgr_main.h"
32 #include "FeatureSetUplinkPerCC.h"
33 #include "FeatureSetDownlinkPerCC.h"
34 #include "FeatureSets.h"
35 #include "UE-NR-Capability.h"
36 #include "UE-CapabilityRAT-Container.h"
37 #include "UE-CapabilityRAT-ContainerListRRC.h"
38 #include "GNB-DU-System-Information.h"
39 #include "CellGroupConfigRrc.h"
40 #include "MAC-CellGroupConfig.h"
41 #include "SchedulingRequestConfig.h"
42 #include "SchedulingRequestToAddMod.h"
43 #include "BSR-Config.h"
44 #include "TAG-Config.h"
46 #include "PHR-Config.h"
47 #include "RLC-Config.h"
48 #include "UL-AM-RLC.h"
49 #include "DL-AM-RLC.h"
50 #include "LogicalChannelConfig.h"
51 #include "RLC-BearerConfig.h"
52 #include "PhysicalCellGroupConfig.h"
53 #include "SpCellConfig.h"
54 #include "TDD-UL-DL-ConfigDedicated.h"
55 #include "ServingCellConfig.h"
56 #include "ControlResourceSet.h"
57 #include "SearchSpace.h"
58 #include "PDCCH-Config.h"
59 #include "PDSCH-TimeDomainResourceAllocation.h"
60 #include "PDSCH-TimeDomainResourceAllocationList.h"
61 #include "PDSCH-CodeBlockGroupTransmission.h"
62 #include "PDSCH-ServingCellConfig.h"
63 #include "DMRS-DownlinkConfig.h"
64 #include "PDSCH-Config.h"
65 #include "BWP-DownlinkDedicated.h"
66 #include "PUSCH-TimeDomainResourceAllocation.h"
67 #include "PUSCH-TimeDomainResourceAllocationList.h"
68 #include "DMRS-UplinkConfig.h"
69 #include "PUSCH-Config.h"
70 #include "SRS-ResourceId.h"
71 #include "SRS-Resource.h"
72 #include "SRS-ResourceSet.h"
73 #include "SRS-Config.h"
74 #include "BWP-UplinkDedicated.h"
75 #include "PUSCH-ServingCellConfig.h"
76 #include "UplinkConfig.h"
77 #include "DUtoCURRCContainer.h"
78 #include "GBR-QoSFlowInformation.h"
79 #include "QoSFlowLevelQoSParameters.h"
80 #include "PUCCH-Config.h"
81 #include "PUCCH-ResourceSet.h"
82 #include "PUCCH-Resource.h"
83 #include "PUCCH-PowerControl.h"
85 #include "PUCCH-PathlossReferenceRS.h"
86 #include "PUCCH-format0.h"
87 #include "PUCCH-format1.h"
88 #include "PUCCH-format2.h"
89 #include "PUCCH-format3.h"
90 #include "PUCCH-format4.h"
91 #include "PUCCH-FormatConfig.h"
92 #include "SchedulingRequestResourceConfig.h"
93 #include<ProtocolIE-Field.h>
94 #include "ProtocolExtensionField.h"
95 #include "odu_common_codec.h"
97 #include "du_cell_mgr.h"
98 #include "du_f1ap_msg_hdl.h"
99 #include "DRBs-Setup-Item.h"
100 #include "DLUPTNLInformation-ToBeSetup-List.h"
101 #include "DLUPTNLInformation-ToBeSetup-Item.h"
102 #include "UPTransportLayerInformation.h"
103 #include "GTPTunnel.h"
106 #include "ConfigInterface.h"
107 extern StartupConfig g_cfg;
110 DuCfgParams duCfgParam;
112 /************************************************************************
114 * @brief Converts enum values into actual value of Poll retransmit timer
118 * Function : getPollPdu
120 * Functionality: Converts enum values into actual value of poll
123 * @params[in] Enum value of pollPdu
124 * @return Actual value of pollPdu
126 * **********************************************************************/
128 uint16_t getPollRetxTmr(uint8_t pollRetxTmrCfg)
130 uint16_t pollRetxTmr;
132 /* All values of poll retx timer are at interval of 5ms.
133 * This is valid upto 250ms
134 * Hence converting the enum value to actual value by multiplying it to 5
136 if(pollRetxTmrCfg <= T_PollRetransmit_ms250)
137 pollRetxTmr = (pollRetxTmrCfg + 1) * 5;
140 switch(pollRetxTmrCfg)
142 case T_PollRetransmit_ms300:
145 case T_PollRetransmit_ms350:
148 case T_PollRetransmit_ms400:
151 case T_PollRetransmit_ms450:
154 case T_PollRetransmit_ms500:
157 case T_PollRetransmit_ms800:
161 DU_LOG("\nERROR --> F1AP: Invalid value of Poll Retransmit timer");
168 /*******************************************************************
170 * @brief Converts enum values into actual value of PollPdu
174 * Function : getPollPdu
176 * Functionality: Converts enum values into actual value of PollPdu
178 * @params[in] Enum value of pollPdu
179 * @return Actual value of pollPdu
181 * ****************************************************************/
182 int32_t getPollPdu(uint8_t pollPduCfg)
256 case PollPDU_infinity:
260 DU_LOG("\nERROR --> F1AP: Invalid value of poll pdu");
267 /*******************************************************************
269 * @brief Converts enum values into actual value of poll bytes
273 * Function : getPollByte
275 * Functionality: Converts enum values into actual value of pollBytes
277 * @params[in] Enum value
278 * @return Actual value
280 * ****************************************************************/
281 int32_t getPollByte(uint16_t pollBytesCfg)
331 case PollByte_kB1000:
334 case PollByte_kB1250:
337 case PollByte_kB1500:
340 case PollByte_kB2000:
343 case PollByte_kB3000:
346 case PollByte_kB4000:
349 case PollByte_kB4500:
352 case PollByte_kB5000:
355 case PollByte_kB5500:
358 case PollByte_kB6000:
361 case PollByte_kB6500:
364 case PollByte_kB7000:
367 case PollByte_kB7500:
377 pollBytes = 10000000;
380 pollBytes = 11000000;
383 pollBytes = 12000000;
386 pollBytes = 13000000;
389 pollBytes = 14000000;
392 pollBytes = 15000000;
395 pollBytes = 16000000;
398 pollBytes = 17000000;
401 pollBytes = 18000000;
404 pollBytes = 20000000;
407 pollBytes = 25000000;
410 pollBytes = 30000000;
413 pollBytes = 40000000;
415 case PollByte_infinity:
419 DU_LOG("\nERROR --> F1AP: Invalid value of poll bytes");
425 /*******************************************************************
427 * @brief Converts enum values into actual value of maxRetx
431 * Function : getMaxRetx
433 * Functionality: Converts enum values into actual value of maxRetx
435 * @params[in] Enum value
436 * @return Actual value
438 * ****************************************************************/
439 uint8_t getMaxRetx(uint8_t maxRetxCfg)
444 case UL_AM_RLC__maxRetxThreshold_t1:
447 case UL_AM_RLC__maxRetxThreshold_t2:
450 case UL_AM_RLC__maxRetxThreshold_t3:
453 case UL_AM_RLC__maxRetxThreshold_t4:
456 case UL_AM_RLC__maxRetxThreshold_t6:
459 case UL_AM_RLC__maxRetxThreshold_t8:
462 case UL_AM_RLC__maxRetxThreshold_t16:
465 case UL_AM_RLC__maxRetxThreshold_t32:
469 DU_LOG("\nERROR --> F1AP: Invalid configuration for Max retransmission threshold");
475 /*******************************************************************
476 * @brief Converts enum values into actual value of reassembly timer
480 * Function : getReAsmblTmr
482 * Functionality: Converts enum values into actual value of reassembly
485 * @params[in] Enum value of reassembly timer
486 * @return Actual value of reassembly timer
488 * **********************************************************************/
490 int8_t getReAsmblTmr(uint8_t reAsmblTmrCfg)
492 int8_t reAsmblTmr = 0;
494 if(reAsmblTmrCfg == T_Reassembly_ms0)
498 else if(reAsmblTmrCfg >= T_Reassembly_ms5 || reAsmblTmrCfg <= T_Reassembly_ms100)
500 /* All values of re assembly timer are at interval of 5ms.
501 * This is valid upto 100ms
502 * Hence converting the enum value to actual value by multiplying it to 5
504 reAsmblTmr = reAsmblTmrCfg * 5;
506 else if(reAsmblTmrCfg >= T_Reassembly_ms110 || reAsmblTmrCfg <= T_Reassembly_ms200)
508 /* All values of re assembly timer are at interval of 10ms.
509 * This is valid upto 200ms
510 * since enum value starts from 20 for 100ms, subtracting 10 and
511 * converting the enum value to actual value by multiplying it to 10
513 reAsmblTmr = ((reAsmblTmrCfg-10) * 10);
517 DU_LOG("\nERROR --> F1AP : Invalid value of Re Assembly timer %d", reAsmblTmrCfg);
523 /************************************************************************
525 * @brief Converts enum values into actual value of status prohibit timer
529 * Function : getStatProhTmr
531 * Functionality: Converts enum values into actual value of status prohibit
534 * @params[in] Enum value of status prohibit timer
535 * @return Actual value of status prohibit timer
537 * **********************************************************************/
539 int16_t getStatProhTmr(uint8_t statProhTmrCfg)
541 int16_t statProhTmr =0;
543 if(statProhTmrCfg == T_StatusProhibit_ms0)
547 else if(statProhTmrCfg >= T_StatusProhibit_ms5 || statProhTmrCfg <= T_StatusProhibit_ms250)
549 /* All values of re assembly timer are at interval of 5ms.
550 * This is valid upto 250ms
551 * Hence converting the enum value to actual value by multiplying it to 5
553 statProhTmr = statProhTmrCfg * 5;
557 switch(statProhTmrCfg)
559 case T_StatusProhibit_ms300:
562 case T_StatusProhibit_ms350:
565 case T_StatusProhibit_ms400:
568 case T_StatusProhibit_ms450:
571 case T_StatusProhibit_ms500:
574 case T_StatusProhibit_ms800:
577 case T_StatusProhibit_ms1000:
580 case T_StatusProhibit_ms1200:
583 case T_StatusProhibit_ms1600:
586 case T_StatusProhibit_ms2000:
589 case T_StatusProhibit_ms2400:
593 DU_LOG("\nInvalid value of Status Prohibit timer %d", statProhTmrCfg);
601 /*******************************************************************
603 * @brief Adding F1AP pdu to reserved pdu list
607 * Function : addToReservedF1apPduList
609 * Functionality: Adding F1AP pdu to reserved pdu list.
610 * These pdu are awaiting aknowledgment from CU
612 * @params[in] uint8_t transId, F1AP_PDU_t *f1apMsg
614 * @return ROK - success
617 * ****************************************************************/
619 void addToReservedF1apPduList(uint8_t transId, F1AP_PDU_t *f1apPdu)
621 CmLList *node = NULLP;
622 ReservedF1apPduInfo *pduInfo = NULLP;
623 DU_ALLOC(pduInfo, sizeof(ReservedF1apPduInfo));
626 DU_ALLOC(node, sizeof(CmLList));
629 pduInfo->transId = transId;
630 pduInfo->f1apMsg = (void*) f1apPdu;
632 node->node = (PTR)pduInfo;
633 cmLListAdd2Tail(&duCb.reservedF1apPduList, node);
638 /*******************************************************************
640 * @brief searching for F1AP pdu from ReservedF1apPduList
644 * Function : searchFromReservedF1apPduList
646 * Functionality: searching for F1AP pdu information
648 * @params[in] uint8_t transId
650 * @return pointer to F1AP_PDU_t
652 * ****************************************************************/
654 CmLList *searchFromReservedF1apPduList(uint8_t transId)
657 ReservedF1apPduInfo *f1apPdu;
658 if(duCb.reservedF1apPduList.count)
660 CM_LLIST_FIRST_NODE(&duCb.reservedF1apPduList, node);
663 f1apPdu = (ReservedF1apPduInfo*)node->node;
664 if(f1apPdu->transId == transId)
674 /*******************************************************************
676 * @brief deleting F1AP pdu information from ReservedF1apPduList
680 * Function : deleteFromReservedF1apPduList
682 * Functionality: deleting pdu information from ReservedF1apPduList
684 * @params[in] CmLList *node
688 * ****************************************************************/
690 void deleteFromReservedF1apPduList(CmLList *node)
692 ReservedF1apPduInfo *f1apPdu;
696 f1apPdu = (ReservedF1apPduInfo *)node->node;
697 cmLListDelFrm(&duCb.reservedF1apPduList, node);
698 DU_FREE(f1apPdu, sizeof(ReservedF1apPduInfo));
699 DU_FREE(node, sizeof(CmLList));
704 /*******************************************************************
706 * @brief Builds Uplink Info for NR
710 * Function : BuildULNRInfo
712 * Functionality: Building NR Uplink Info
714 * @params[in] NRFreqInfo_t *ulnrfreq
715 * @return ROK - success
718 * ****************************************************************/
719 uint8_t BuildULNRInfo(NRFreqInfo_t *ulnrfreq)
722 ulnrfreq->nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.\
723 fdd.ulNrFreqInfo.nrArfcn;
724 ulnrfreq->freqBandListNr.list.count = 1;
725 ulnrfreq->freqBandListNr.list.size = sizeof(FreqBandNrItem_t *);
726 DU_ALLOC(ulnrfreq->freqBandListNr.list.array,ulnrfreq->freqBandListNr.list.size);
727 if(ulnrfreq->freqBandListNr.list.array == NULLP)
731 for(idx=0;idx<ulnrfreq->freqBandListNr.list.count;idx++)
733 DU_ALLOC(ulnrfreq->freqBandListNr.list.array[idx],sizeof(FreqBandNrItem_t));
734 if(ulnrfreq->freqBandListNr.list.array[idx] == NULLP)
739 ulnrfreq->freqBandListNr.list.array[0]->freqBandIndicatorNr = \
740 duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.\
741 freqBand[0].nrFreqBand;
742 ulnrfreq->freqBandListNr.list.array[0]->supportedSULBandList.list.count = SUL_BAND_COUNT;
745 /*******************************************************************
747 * @brief Builds Downlink NR Info
751 * Function : BuildDLNRInfo
753 * Functionality: Building Downlink NR Info
755 * @params[in] NRFreqInfo_t *dlnrfreq
756 * @return ROK - success
759 * ****************************************************************/
760 uint8_t BuildDLNRInfo(NRFreqInfo_t *dlnrfreq)
763 dlnrfreq->nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.\
764 fdd.dlNrFreqInfo.nrArfcn;
765 dlnrfreq->freqBandListNr.list.count = 1;
766 dlnrfreq->freqBandListNr.list.size = sizeof(FreqBandNrItem_t *);
767 DU_ALLOC(dlnrfreq->freqBandListNr.list.array,dlnrfreq->freqBandListNr.list.size);
768 if(dlnrfreq->freqBandListNr.list.array == NULLP)
772 for(idx=0;idx< dlnrfreq->freqBandListNr.list.count;idx++)
774 DU_ALLOC(dlnrfreq->freqBandListNr.list.array[idx],sizeof(FreqBandNrItem_t));
775 if(dlnrfreq->freqBandListNr.list.array[idx] == NULLP)
780 dlnrfreq->freqBandListNr.list.array[0]->freqBandIndicatorNr = \
781 duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.\
782 freqBand[0].nrFreqBand;
783 dlnrfreq->freqBandListNr.list.array[0]->supportedSULBandList.list.count = SUL_BAND_COUNT;
788 /*******************************************************************
790 * @brief Builds NRCell ID
794 * Function : BuildNrCellId
796 * Functionality: Building the NR Cell ID
798 * @params[in] BIT_STRING_t *nrcell
799 * @return ROK - success
802 * ****************************************************************/
804 S16 BuildNrCellId(BIT_STRING_t *nrcell)
806 memset(nrcell->buf, 0, nrcell->size);
808 nrcell->bits_unused = 4;
812 /*******************************************************************
814 * @brief Builds Nrcgi
818 * Function : BuildNrcgi
820 * Functionality: Building the PLMN ID and NR Cell id
822 * @params[in] NRCGI_t *nrcgi
823 * @return ROK - success
826 * ****************************************************************/
827 uint8_t BuildNrcgi(NRCGI_t *nrcgi)
830 uint8_t byteSize = 5;
831 /* Allocate Buffer Memory */
832 nrcgi->pLMN_Identity.size = PLMN_SIZE * sizeof(uint8_t);
833 DU_ALLOC(nrcgi->pLMN_Identity.buf, nrcgi->pLMN_Identity.size);
834 if(nrcgi->pLMN_Identity.buf == NULLP)
838 ret = buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
839 nrcgi->pLMN_Identity.buf); // Building PLMN function
845 nrcgi->nRCellIdentity.size = byteSize * sizeof(uint8_t);
846 DU_ALLOC(nrcgi->nRCellIdentity.buf, nrcgi->nRCellIdentity.size);
847 if(nrcgi->nRCellIdentity.buf == NULLP)
851 BuildNrCellId(&nrcgi->nRCellIdentity);
855 /*******************************************************************
857 * @brief Builds FiveGStac
861 * Function : BuildFiveGSTac
863 * Functionality: Building the FiveGSTac
865 * @params[in] OCTET_STRING_t *fivegsTac
866 * @return ROK - success
869 * ****************************************************************/
870 uint8_t BuildFiveGSTac(Served_Cell_Information_t *servcell)
872 DU_ALLOC(servcell->fiveGS_TAC,sizeof(FiveGS_TAC_t));
873 if(servcell->fiveGS_TAC == NULLP)
877 servcell->fiveGS_TAC->size = 3 * sizeof(uint8_t);
878 DU_ALLOC(servcell->fiveGS_TAC->buf,\
879 sizeof(servcell->fiveGS_TAC->size));
880 if(servcell->fiveGS_TAC->buf == NULLP)
884 servcell->fiveGS_TAC->buf[0] = 0;
885 servcell->fiveGS_TAC->buf[1] = 0;
886 servcell->fiveGS_TAC->buf[2] = duCfgParam.srvdCellLst[0].duCellInfo.tac;
889 /*******************************************************************
891 * @brief Builds NR Mode
895 * Function : BuildNrMode
897 * Functionality: Building the NR Mode
899 * @params[in] NR_Mode_Info_t *fdd
900 * @return ROK - success
903 * ****************************************************************/
904 uint8_t BuildNrMode(NR_Mode_Info_t *mode)
906 uint8_t BuildDLNRInforet=0;
907 uint8_t BuildULNRInforet=0;
909 mode->present = NR_Mode_Info_PR_fDD;
910 if(mode->present == NR_Mode_Info_PR_fDD)
912 DU_ALLOC(mode->choice.fDD,sizeof(FDD_Info_t));
913 if(mode->choice.fDD == NULLP)
917 BuildULNRInforet = BuildULNRInfo(&mode->choice.fDD->uL_NRFreqInfo);
918 if(BuildULNRInforet != ROK)
922 BuildDLNRInforet = BuildDLNRInfo(&mode->choice.fDD->dL_NRFreqInfo);
923 if(BuildDLNRInforet != ROK)
928 mode->choice.fDD->uL_Transmission_Bandwidth.nRSCS = \
929 duCfgParam.srvdCellLst[0].duCellInfo.\
930 f1Mode.mode.fdd.ulTxBw.nrScs;
931 mode->choice.fDD->uL_Transmission_Bandwidth.nRNRB = \
932 duCfgParam.srvdCellLst[0].duCellInfo.\
933 f1Mode.mode.fdd.ulTxBw.nrb;
934 mode->choice.fDD->dL_Transmission_Bandwidth.nRSCS = \
935 duCfgParam.srvdCellLst[0].duCellInfo.\
936 f1Mode.mode.fdd.dlTxBw.nrScs;
937 mode->choice.fDD->dL_Transmission_Bandwidth.nRNRB = \
938 duCfgParam.srvdCellLst[0].duCellInfo.\
939 f1Mode.mode.fdd.dlTxBw.nrb;
942 /*******************************************************************
944 * @brief Builds IE Extensions for Served PLMNs
948 * Function : BuildExtensions
950 * Functionality: Building the IE Extensions
952 * @params[in] struct ProtocolExtensionContainer_4624P3 *buildextend
953 * @return ROK - success
956 * ****************************************************************/
957 uint8_t BuildExtensions(ProtocolExtensionContainer_4624P3_t **ieExtend)
961 uint8_t extensionCnt=1;
964 DU_ALLOC(*ieExtend,sizeof(ProtocolExtensionContainer_4624P3_t));
965 if((*ieExtend) == NULLP)
969 (*ieExtend)->list.count = extensionCnt;
970 (*ieExtend)->list.size = \
971 extensionCnt * sizeof(ServedPLMNs_ItemExtIEs_t *);
972 DU_ALLOC((*ieExtend)->list.array,(*ieExtend)->list.size);
973 if((*ieExtend)->list.array == NULLP)
977 for(plmnidx=0;plmnidx<extensionCnt;plmnidx++)
979 DU_ALLOC((*ieExtend)->list.array[plmnidx],\
980 sizeof(ServedPLMNs_ItemExtIEs_t));
981 if((*ieExtend)->list.array[plmnidx] == NULLP)
987 (*ieExtend)->list.array[idx]->id = ProtocolIE_ID_id_TAISliceSupportList;
988 (*ieExtend)->list.array[idx]->criticality = Criticality_ignore;
989 (*ieExtend)->list.array[idx]->extensionValue.present = \
990 ServedPLMNs_ItemExtIEs__extensionValue_PR_SliceSupportList;
991 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
993 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
994 list.size = sizeof(SliceSupportItem_t *);
995 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
996 list.array,sizeof(SliceSupportItem_t *));
997 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1002 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1003 list.array[sliceId],sizeof(SliceSupportItem_t));
1004 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1005 list.array[sliceId] == NULLP)
1009 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1010 list.array[sliceId]->sNSSAI.sST.size = sizeof(uint8_t);
1011 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList\
1012 .list.array[sliceId]->sNSSAI.sST.buf,(*ieExtend)->list.array[idx]->\
1013 extensionValue.choice.SliceSupportList.\
1014 list.array[sliceId]->sNSSAI.sST.size);
1015 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList\
1016 .list.array[sliceId]->sNSSAI.sST.buf == NULLP)
1020 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1021 list.array[sliceId]->sNSSAI.sST.buf[0] = 3;
1022 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1023 list.array[sliceId]->sNSSAI.sD,sizeof(OCTET_STRING_t));
1024 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1025 list.array[sliceId]->sNSSAI.sD == NULLP)
1029 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1030 list.array[sliceId]->sNSSAI.sD->size = 3*sizeof(uint8_t);
1031 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1032 list.array[sliceId]->sNSSAI.sD->buf,(*ieExtend)->list.array[idx]->extensionValue.choice.\
1033 SliceSupportList.list.array[sliceId]->sNSSAI.sD->size);
1034 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1035 list.array[sliceId]->sNSSAI.sD->buf == NULLP)
1040 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1041 list.array[sliceId]->sNSSAI.sD->buf[sdId] = 3;
1043 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1044 list.array[sliceId]->sNSSAI.sD->buf[sdId] = 6;
1046 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1047 list.array[sliceId]->sNSSAI.sD->buf[sdId] = 9;
1050 /*******************************************************************
1052 * @brief Builds Served PLMN
1056 * Function : BuildServedPlmn
1058 * Functionality: Building the Served PLMN
1060 * @params[in] GNB_DU_Served_Cells_Item_t *srvCellItem
1061 * @return ROK - success
1064 * ****************************************************************/
1065 uint8_t BuildServedPlmn(ServedPLMNs_List_t *srvplmn)
1068 uint8_t servPlmnCnt=1;
1069 uint8_t buildPlmnIdret=0;
1070 uint8_t BuildExtensionsret=0;
1071 srvplmn->list.count = servPlmnCnt;
1072 srvplmn->list.size = \
1073 servPlmnCnt*sizeof(ServedPLMNs_Item_t *);
1074 DU_ALLOC(srvplmn->list.array,srvplmn->list.size);
1075 if(srvplmn->list.array == NULLP)
1079 for(plmnidx=0; plmnidx<servPlmnCnt; plmnidx++)
1081 DU_ALLOC(srvplmn->list.array[plmnidx],\
1082 sizeof(ServedPLMNs_Item_t));
1083 if(srvplmn->list.array[plmnidx] == NULLP)
1088 srvplmn->list.array[0]->pLMN_Identity.size = PLMN_SIZE * sizeof(uint8_t);
1089 DU_ALLOC(srvplmn->list.array[0]->pLMN_Identity.buf, srvplmn->list.array[0]->pLMN_Identity.size);
1090 buildPlmnIdret = buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
1091 srvplmn->list.array[0]->pLMN_Identity.buf);
1092 if(buildPlmnIdret!= ROK)
1096 BuildExtensionsret = BuildExtensions(&srvplmn->list.array[0]->iE_Extensions);
1097 if(BuildExtensionsret!= ROK)
1103 /*******************************************************************
1105 * @brief Builds Served Cell List
1109 * Function : BuildServedCellList
1111 * Functionality: Building Served Cell List
1113 * @params[in] PLMNID plmn
1114 * @return ROK - success
1117 * ****************************************************************/
1119 uint8_t BuildServedCellList(GNB_DU_Served_Cells_List_t *duServedCell)
1121 uint8_t BuildNrcgiret=0;
1122 uint8_t BuildFiveGSTacret=0;
1123 uint8_t BuildServedPlmnret=0;
1124 uint8_t BuildNrModeret=0;
1128 GNB_DU_Served_Cells_Item_t *srvCellItem;
1129 duServedCell->list.size = plmnCnt * sizeof(GNB_DU_Served_Cells_ItemIEs_t *);
1130 duServedCell->list.count = plmnCnt;
1132 DU_ALLOC(duServedCell->list.array, duServedCell->list.size);
1133 if(duServedCell->list.array == NULLP)
1137 for(plmnidx=0; plmnidx<plmnCnt; plmnidx++)
1139 DU_ALLOC(duServedCell->list.array[plmnidx],\
1140 sizeof(GNB_DU_Served_Cells_ItemIEs_t));
1141 if(duServedCell->list.array[plmnidx] == NULLP)
1147 duServedCell->list.array[idx]->id = ProtocolIE_ID_id_GNB_DU_Served_Cells_Item;
1148 duServedCell->list.array[idx]->criticality = Criticality_reject;
1149 duServedCell->list.array[idx]->value.present = \
1150 GNB_DU_Served_Cells_ItemIEs__value_PR_GNB_DU_Served_Cells_Item;
1152 &duServedCell->list.array[idx]->value.choice.GNB_DU_Served_Cells_Item;
1154 BuildNrcgiret = BuildNrcgi(&srvCellItem->served_Cell_Information.nRCGI);
1155 if(BuildNrcgiret != ROK)
1160 srvCellItem->served_Cell_Information.nRPCI = \
1161 duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrPci;
1164 BuildFiveGSTacret = BuildFiveGSTac(&srvCellItem->served_Cell_Information);
1165 if(BuildFiveGSTacret != ROK)
1170 BuildServedPlmnret = BuildServedPlmn(&srvCellItem->served_Cell_Information.servedPLMNs);
1171 if(BuildServedPlmnret !=ROK)
1175 /*nR Mode Info with FDD*/
1176 BuildNrModeret = BuildNrMode(&srvCellItem->served_Cell_Information.nR_Mode_Info);
1177 if(BuildNrModeret != ROK)
1181 /*Measurement timing Config*/
1182 srvCellItem->served_Cell_Information.measurementTimingConfiguration.\
1183 size = sizeof(uint8_t);
1184 DU_ALLOC(srvCellItem->served_Cell_Information.\
1185 measurementTimingConfiguration.buf,srvCellItem->served_Cell_Information.measurementTimingConfiguration.size);
1186 if(srvCellItem->served_Cell_Information.\
1187 measurementTimingConfiguration.buf == NULLP)
1191 srvCellItem->served_Cell_Information.measurementTimingConfiguration.buf[0] = \
1192 duCfgParam.srvdCellLst[0].duCellInfo.measTimeCfg;
1194 /* GNB DU System Information */
1195 DU_ALLOC(srvCellItem->gNB_DU_System_Information,
1196 sizeof(GNB_DU_System_Information_t));
1197 if(!srvCellItem->gNB_DU_System_Information)
1202 srvCellItem->gNB_DU_System_Information->mIB_message.size = duCfgParam.srvdCellLst[0].duSysInfo.mibLen;
1203 DU_ALLOC(srvCellItem->gNB_DU_System_Information->mIB_message.buf,
1204 srvCellItem->gNB_DU_System_Information->mIB_message.size);
1205 if(!srvCellItem->gNB_DU_System_Information->mIB_message.buf)
1209 memcpy(srvCellItem->gNB_DU_System_Information->mIB_message.buf, duCfgParam.srvdCellLst[0].duSysInfo.mibMsg, \
1210 srvCellItem->gNB_DU_System_Information->mIB_message.size);
1213 srvCellItem->gNB_DU_System_Information->sIB1_message.size =\
1214 duCfgParam.srvdCellLst[0].duSysInfo.sib1Len;
1216 DU_ALLOC(srvCellItem->gNB_DU_System_Information->sIB1_message.buf,
1217 srvCellItem->gNB_DU_System_Information->sIB1_message.size);
1218 if(!srvCellItem->gNB_DU_System_Information->sIB1_message.buf)
1222 for(int x=0; x<srvCellItem->gNB_DU_System_Information->sIB1_message.size; x++)
1224 srvCellItem->gNB_DU_System_Information->sIB1_message.buf[x]=\
1225 duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg[x];
1229 /*******************************************************************
1231 * @brief Builds RRC Version
1235 * Function : BuildRrcVer
1237 * Functionality: Building RRC Version
1239 * @params[in] int idx,int elementCnt,RRC_Version_t *rrcver
1240 * @return ROK - success
1243 * ****************************************************************/
1244 uint8_t BuildRrcVer(RRC_Version_t *rrcVer)
1248 rrcVer->latest_RRC_Version.size = sizeof(uint8_t);
1249 DU_ALLOC(rrcVer->latest_RRC_Version.buf,sizeof(uint8_t));
1250 if(rrcVer->latest_RRC_Version.buf == NULLP)
1254 rrcVer->latest_RRC_Version.buf[0] = 0;
1255 rrcVer->latest_RRC_Version.bits_unused = 5;
1256 DU_ALLOC(rrcVer->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P81_t));
1257 if(rrcVer->iE_Extensions == NULLP)
1261 rrcVer->iE_Extensions->list.count = 1;
1262 rrcVer->iE_Extensions->list.size = sizeof(RRC_Version_ExtIEs_t *);
1263 DU_ALLOC(rrcVer->iE_Extensions->list.array,rrcVer->iE_Extensions->list.size);
1264 if(rrcVer->iE_Extensions->list.array == NULLP)
1269 DU_ALLOC(rrcVer->iE_Extensions->list.array[0],\
1270 sizeof(RRC_Version_ExtIEs_t));
1271 if(rrcVer->iE_Extensions->list.array[0] == NULLP)
1275 rrcVer->iE_Extensions->list.array[rrcExt]->id = \
1276 ProtocolIE_ID_id_latest_RRC_Version_Enhanced;
1277 rrcVer->iE_Extensions->list.array[rrcExt]->criticality = Criticality_reject;
1278 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.present =\
1279 RRC_Version_ExtIEs__extensionValue_PR_Latest_RRC_Version_Enhanced;
1280 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice\
1281 .Latest_RRC_Version_Enhanced.size = 3*sizeof(uint8_t);
1282 DU_ALLOC(rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice\
1283 .Latest_RRC_Version_Enhanced.buf,rrcVer->iE_Extensions->list.\
1284 array[rrcExt]->extensionValue.choice.Latest_RRC_Version_Enhanced.size);
1285 if(rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice\
1286 .Latest_RRC_Version_Enhanced.buf == NULLP)
1291 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice.\
1292 Latest_RRC_Version_Enhanced.buf[rrcLatest] = 15;
1294 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice.\
1295 Latest_RRC_Version_Enhanced.buf[rrcLatest] = 5;
1297 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice.\
1298 Latest_RRC_Version_Enhanced.buf[rrcLatest] = 0;
1301 /*******************************************************************
1303 * @brief Sends F1 msg over SCTP
1307 * Function : sendF1APMsg
1309 * Functionality: Sends F1 msg over SCTP
1311 * @params[in] Region region
1313 * @return ROK - success
1316 * ****************************************************************/
1317 uint8_t sendF1APMsg()
1319 Buffer *mBuf = NULLP;
1321 if(ODU_GET_MSG_BUF(DU_APP_MEM_REGION, DU_POOL, &mBuf) == ROK)
1323 if(ODU_ADD_POST_MSG_MULT((Data *)encBuf, encBufSize, mBuf) == ROK)
1325 ODU_PRINT_MSG(mBuf, 0,0);
1327 if(sctpSend(mBuf, F1_INTERFACE) != ROK)
1329 DU_LOG("\nERROR --> F1AP : SCTP Send failed");
1330 ODU_PUT_MSG_BUF(mBuf);
1336 DU_LOG("\nERROR --> F1AP : ODU_ADD_POST_MSG_MULT failed");
1337 ODU_PUT_MSG_BUF(mBuf);
1340 ODU_PUT_MSG_BUF(mBuf);
1344 DU_LOG("\nERROR --> F1AP : Failed to allocate memory");
1350 /*******************************************************************
1352 * @brief deallocating the memory of function BuildAndSendF1SetupReq()
1356 * Function : FreeRrcVer
1358 * Functionality: deallocating the memory of function BuildRrcVer
1360 * @params[in] RRC_Version_t *rrcVer
1364 *****************************************************************/
1365 void FreeRrcVer(RRC_Version_t *rrcVer)
1367 if(rrcVer->latest_RRC_Version.buf != NULLP)
1369 if(rrcVer->iE_Extensions != NULLP)
1371 if(rrcVer->iE_Extensions->list.array != NULLP)
1373 if(rrcVer->iE_Extensions->list.array[0] != NULLP)
1375 if(rrcVer->iE_Extensions->list.array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf
1378 DU_FREE(rrcVer->iE_Extensions->list.array[0]->extensionValue.choice\
1379 .Latest_RRC_Version_Enhanced.buf,rrcVer->iE_Extensions->list.\
1380 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.size);
1382 DU_FREE(rrcVer->iE_Extensions->list.array[0],sizeof(RRC_Version_ExtIEs_t));
1384 DU_FREE(rrcVer->iE_Extensions->list.array,sizeof(RRC_Version_ExtIEs_t*));
1386 DU_FREE(rrcVer->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P81_t));
1388 DU_FREE(rrcVer->latest_RRC_Version.buf,rrcVer->latest_RRC_Version.size);
1391 /*******************************************************************
1393 * @brief deallocating the memory of function BuildAndSendF1SetupReq()
1397 * Function : FreeServedCellList
1399 * Functionality: deallocating the memory of function BuildServedCellList
1402 * @params[in] GNB_DU_Served_Cells_List_t *duServedCell
1406 * ****************************************************************/
1407 void FreeServedCellList( GNB_DU_Served_Cells_List_t *duServedCell)
1413 uint8_t extensionCnt=1;
1415 GNB_DU_Served_Cells_Item_t *srvCellItem= &duServedCell->list.array[0]->value.choice.GNB_DU_Served_Cells_Item;
1416 if(duServedCell->list.array!=NULLP)
1418 if(duServedCell->list.array[0]!=NULLP)
1420 if(srvCellItem->served_Cell_Information.nRCGI.pLMN_Identity.buf!=NULLP)
1422 if(srvCellItem->served_Cell_Information.nRCGI.nRCellIdentity.buf !=NULLP)
1424 if(srvCellItem->served_Cell_Information.fiveGS_TAC!=NULLP)
1426 if(srvCellItem->served_Cell_Information.fiveGS_TAC->buf!=NULLP)
1428 if(srvCellItem->served_Cell_Information.servedPLMNs.list.array!=NULLP)
1430 if(srvCellItem->served_Cell_Information.servedPLMNs.list.array[0]!=NULLP)
1432 if(srvCellItem->served_Cell_Information.servedPLMNs.list.array[servId]->pLMN_Identity.buf!=NULLP)
1434 if(srvCellItem->served_Cell_Information.servedPLMNs.list.array[servId]->iE_Extensions!=NULLP)
1436 if(srvCellItem->served_Cell_Information.servedPLMNs.list.array[servId]->iE_Extensions->list.array!=NULLP)
1438 if(srvCellItem->served_Cell_Information.servedPLMNs.list.array[servId]->iE_Extensions->list.array[0]!=NULLP)
1440 if(srvCellItem->served_Cell_Information.servedPLMNs.list.array[servId]->iE_Extensions->list.array[0]->\
1441 extensionValue.choice.SliceSupportList.list.array!=NULLP)
1443 if(srvCellItem->served_Cell_Information.servedPLMNs.list.array[servId]->iE_Extensions->list.array[0]->\
1444 extensionValue.choice.SliceSupportList.list.array[sliceId]!= NULLP)
1446 if(srvCellItem->served_Cell_Information.servedPLMNs.list.array[servId]->iE_Extensions->list.array[0]->\
1447 extensionValue.choice.SliceSupportList.list.array[sliceId]->sNSSAI.sST.buf!=NULLP)
1449 if(srvCellItem->served_Cell_Information.servedPLMNs.list.array[servId]->iE_Extensions->list.array[0]->\
1450 extensionValue.choice.SliceSupportList.list.array[sliceId]->sNSSAI.sD!=NULLP)
1452 if(srvCellItem->served_Cell_Information.servedPLMNs.list.array[servId]->iE_Extensions->\
1453 list.array[0]->extensionValue.choice.SliceSupportList.list.array[sliceId]->sNSSAI.sD->buf!=NULLP)
1455 if(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD!=NULLP)
1457 if(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.\
1458 freqBandListNr.list.array!=NULLP)
1460 if(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.\
1461 freqBandListNr.list.array[0]!=NULLP)
1463 if(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.\
1464 freqBandListNr.list.array)
1466 if(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.\
1467 freqBandListNr.list.array[0]!=NULLP)
1469 if(srvCellItem->served_Cell_Information.measurementTimingConfiguration.buf!=NULLP)
1471 if(!srvCellItem->gNB_DU_System_Information)
1473 if(srvCellItem->gNB_DU_System_Information->mIB_message.buf!=NULLP)
1475 if(srvCellItem->gNB_DU_System_Information->sIB1_message.buf!=NULLP)
1477 DU_FREE(srvCellItem->gNB_DU_System_Information->sIB1_message.buf,\
1478 srvCellItem->gNB_DU_System_Information->sIB1_message.size);
1479 DU_FREE(duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg,\
1480 srvCellItem->gNB_DU_System_Information->sIB1_message.size);
1482 DU_FREE(srvCellItem->gNB_DU_System_Information->mIB_message.buf,\
1483 srvCellItem->gNB_DU_System_Information->mIB_message.size);
1484 DU_FREE(duCfgParam.srvdCellLst[0].duSysInfo.mibMsg,\
1485 strlen((char*)duCfgParam.srvdCellLst[0].duSysInfo.mibMsg));
1487 DU_FREE(srvCellItem->gNB_DU_System_Information,sizeof(GNB_DU_System_Information_t));
1489 DU_FREE(srvCellItem->served_Cell_Information.measurementTimingConfiguration.buf,\
1490 srvCellItem->served_Cell_Information.measurementTimingConfiguration.size);
1492 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.\
1493 freqBandListNr.list.array[0],sizeof(FreqBandNrItem_t));
1495 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.\
1496 freqBandListNr.list.array,sizeof(FreqBandNrItem_t *));
1498 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.\
1499 list.array[0],sizeof(FreqBandNrItem_t));
1501 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.\
1502 list.array,sizeof(FreqBandNrItem_t*));
1504 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD,sizeof(FDD_Info_t));
1506 DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.array[servId]->\
1507 iE_Extensions->list.array[ieId]->extensionValue.choice.SliceSupportList.list.array[sliceId]->\
1508 sNSSAI.sD->buf,srvCellItem->served_Cell_Information.servedPLMNs.list.array[servId]->iE_Extensions->
1509 list.array[ieId]->extensionValue.choice.SliceSupportList.list.array[sliceId]->sNSSAI.sD->size);
1511 DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.array[servId]->\
1512 iE_Extensions->list.array[ieId]->extensionValue.choice.SliceSupportList.\
1513 list.array[sliceId]->sNSSAI.sD,sizeof(OCTET_STRING_t));
1515 DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.array[servId]->\
1516 iE_Extensions->list.array[ieId]->extensionValue.choice.SliceSupportList.list.array[sliceId]->\
1517 sNSSAI.sST.buf,sizeof(uint8_t));
1519 DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.array[servId]->iE_Extensions->list.array[0]->\
1520 extensionValue.choice.SliceSupportList.list.array[sliceId],sizeof(SliceSupportItem_t));
1522 DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.array[servId]->iE_Extensions->list.array[0]->\
1523 extensionValue.choice.SliceSupportList.list.array,sizeof(SliceSupportItem_t*));
1525 DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.\
1526 array[servId]->iE_Extensions->list.array[plmnidx],sizeof(ServedPLMNs_ItemExtIEs_t));
1528 DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.\
1529 array[servId]->iE_Extensions->list.array,\
1530 extensionCnt*sizeof(ServedPLMNs_ItemExtIEs_t*));
1532 DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.\
1533 array[servId]->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P3_t));
1535 DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.\
1536 array[servId]->pLMN_Identity.buf,srvCellItem->served_Cell_Information.\
1537 servedPLMNs.list.array[servId]->pLMN_Identity.size
1540 DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.array[plmnidx],\
1541 sizeof(ServedPLMNs_Item_t *));
1543 DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.array,\
1544 sizeof(ServedPLMNs_Item_t *));
1546 DU_FREE(srvCellItem->served_Cell_Information.fiveGS_TAC->buf,\
1547 sizeof(srvCellItem->served_Cell_Information.fiveGS_TAC->size));
1549 DU_FREE(srvCellItem->served_Cell_Information.fiveGS_TAC,sizeof(FiveGS_TAC_t));
1551 DU_FREE(srvCellItem->served_Cell_Information.nRCGI.nRCellIdentity.buf,\
1552 srvCellItem->served_Cell_Information.nRCGI.nRCellIdentity.size *
1555 DU_FREE(srvCellItem->served_Cell_Information.nRCGI.pLMN_Identity.buf,\
1556 srvCellItem->served_Cell_Information.nRCGI.pLMN_Identity.size *
1559 DU_FREE(duServedCell->list.array[plmnidx],sizeof(GNB_DU_Served_Cells_ItemIEs_t));
1561 DU_FREE(duServedCell->list.array,plmnCnt*sizeof(GNB_DU_Served_Cells_ItemIEs_t*));
1564 /*******************************************************************
1566 * @brief deallocating the memory of function BuildAndSendF1SetupReq()
1570 * Function : FreeF1SetupReq
1572 * Functionality: deallocating the memory of function BuildAndSendF1SetupReq
1574 * @params[in] F1AP_PDU_t *f1apMsg
1578 * ****************************************************************/
1579 void FreeF1SetupReq(F1AP_PDU_t *f1apMsg)
1581 uint8_t ieIdx, ieIdx2;
1582 F1SetupRequest_t *f1SetupReq=NULLP;
1584 if(f1apMsg != NULLP)
1586 if(f1apMsg->choice.initiatingMessage != NULLP)
1588 f1SetupReq = &f1apMsg->choice.initiatingMessage->value.choice.F1SetupRequest;
1589 if(f1SetupReq->protocolIEs.list.array != NULLP)
1591 for(ieIdx = 0; ieIdx < f1SetupReq->protocolIEs.list.count; ieIdx++)
1593 if(f1SetupReq->protocolIEs.list.array[ieIdx] != NULLP)
1595 switch(f1SetupReq->protocolIEs.list.array[ieIdx]->id)
1597 case ProtocolIE_ID_id_TransactionID:
1599 case ProtocolIE_ID_id_gNB_DU_ID:
1600 DU_FREE(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
1601 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
1603 case ProtocolIE_ID_id_gNB_DU_Name:
1604 DU_FREE(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.buf,\
1605 strlen((char *)duCfgParam.duName));
1607 case ProtocolIE_ID_id_gNB_DU_Served_Cells_List:
1608 FreeServedCellList(&f1SetupReq->protocolIEs.list.\
1609 array[ieIdx]->value.choice.GNB_DU_Served_Cells_List);
1611 case ProtocolIE_ID_id_GNB_DU_RRC_Version:
1612 FreeRrcVer(&f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.RRC_Version);
1615 DU_LOG("\nERROR --> Invalid Event Type %ld", f1SetupReq->protocolIEs.list.array[ieIdx]->id);
1621 for(ieIdx2=0; ieIdx2< ieIdx; ieIdx2++)
1623 DU_FREE(f1SetupReq->protocolIEs.list.array[ieIdx2],sizeof(F1SetupRequestIEs_t));
1625 DU_FREE(f1SetupReq->protocolIEs.list.array,\
1626 f1SetupReq->protocolIEs.list.size);
1628 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
1630 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
1633 /*******************************************************************
1635 * @brief Builds and Send the F1SetupRequest
1639 * Function : BuildAndSendF1SetupReq
1641 * Functionality:Fills the F1SetupRequest
1643 * @return ROK - success
1646 ******************************************************************/
1647 uint8_t BuildAndSendF1SetupReq()
1649 uint8_t ret, ieIdx, elementCnt;
1650 F1AP_PDU_t *f1apMsg = NULLP;
1651 F1SetupRequest_t *f1SetupReq=NULLP;
1652 GNB_DU_Served_Cells_List_t *duServedCell=NULLP;
1653 RRC_Version_t *rrcVer=NULLP;
1654 asn_enc_rval_t encRetVal; /* Encoder return value */
1657 DU_LOG("\nINFO --> F1AP : Building F1 Setup Request\n");
1660 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
1661 if(f1apMsg == NULLP)
1665 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
1666 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
1667 if(f1apMsg->choice.initiatingMessage == NULLP)
1671 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_F1Setup;
1672 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
1673 f1apMsg->choice.initiatingMessage->value.present = \
1674 InitiatingMessage__value_PR_F1SetupRequest;
1676 f1SetupReq = &f1apMsg->choice.initiatingMessage->value.choice.F1SetupRequest;
1678 elementCnt = (duCfgParam.duName != NULL) ? 5 : 4;
1680 f1SetupReq->protocolIEs.list.count = elementCnt;
1681 f1SetupReq->protocolIEs.list.size = elementCnt * sizeof(F1SetupRequestIEs_t );
1683 /* Initialize the F1Setup members */
1684 DU_ALLOC(f1SetupReq->protocolIEs.list.array,f1SetupReq->protocolIEs.list.size);
1685 if(f1SetupReq->protocolIEs.list.array == NULLP)
1689 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
1691 DU_ALLOC(f1SetupReq->protocolIEs.list.array[ieIdx],\
1692 sizeof(F1SetupRequestIEs_t));
1693 if(f1SetupReq->protocolIEs.list.array[ieIdx] == NULLP)
1701 f1SetupReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_TransactionID;
1702 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1703 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present =\
1704 F1SetupRequestIEs__value_PR_TransactionID;
1705 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = \
1710 f1SetupReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_ID;
1711 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1712 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = \
1713 F1SetupRequestIEs__value_PR_GNB_DU_ID;
1714 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size =\
1717 DU_ALLOC(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
1718 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
1719 if(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf == \
1725 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf[0] =\
1729 if(duCfgParam.duName != NULL)
1732 f1SetupReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_Name;
1733 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_ignore;
1734 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = F1SetupRequestIEs__value_PR_GNB_DU_Name;
1735 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.size =\
1736 strlen((char *)duCfgParam.duName);
1737 DU_ALLOC(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.\
1738 GNB_DU_Name.buf, strlen((char *)duCfgParam.duName));
1739 if(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.\
1744 strcpy((char*)f1SetupReq->protocolIEs.list.array[ieIdx]->value.\
1745 choice.GNB_DU_Name.buf,
1746 (char*)&duCfgParam.duName);
1750 /*Served Cell list */
1752 f1SetupReq->protocolIEs.list.array[ieIdx]->id = \
1753 ProtocolIE_ID_id_gNB_DU_Served_Cells_List;
1754 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1755 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = \
1756 F1SetupRequestIEs__value_PR_GNB_DU_Served_Cells_List;
1757 duServedCell = &f1SetupReq->protocolIEs.list.\
1758 array[ieIdx]->value.choice.GNB_DU_Served_Cells_List;
1759 if(BuildServedCellList(duServedCell))
1765 f1SetupReq->protocolIEs.list.array[ieIdx]->id = \
1766 ProtocolIE_ID_id_GNB_DU_RRC_Version ;
1767 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1768 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = \
1769 F1SetupRequestIEs__value_PR_RRC_Version;
1770 rrcVer = &f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.RRC_Version;
1771 if(BuildRrcVer(rrcVer))
1775 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
1777 /* Encode the F1SetupRequest type as APER */
1778 memset(encBuf, 0, ENC_BUF_MAX_LEN);
1780 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
1783 /* Encode results */
1784 if(encRetVal.encoded == ENCODE_FAIL)
1786 DU_LOG("\nERROR --> F1AP : Could not encode F1SetupRequest structure (at %s)\n",\
1787 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
1792 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for F1SetupRequest\n");
1793 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
1795 printf("%x",encBuf[ieIdx]);
1800 if(sendF1APMsg() != ROK)
1802 DU_LOG("\nERROR --> F1AP : Sending F1 Setup request failed");
1810 FreeF1SetupReq(f1apMsg);
1813 }/* End of BuildAndSendF1SetupReq */
1815 /*******************************************************************
1817 * @brief Deallocating memory allocated for Served_Cells_To_Modify_Item_t
1821 * Function : freeCellsToModifyItem
1823 * Functionality: Deallocating memory of variables allocated in
1824 * BuildAndSendDUConfigUpdate function
1826 * @params[in] Served_Cells_To_Modify_Item_t *modifyItem
1828 * @return ROK - void
1830 * ****************************************************************/
1832 void freeCellsToModifyItem(Served_Cells_To_Modify_Item_t *modifyItem)
1834 uint8_t arrIdx=0,i=0;
1835 if(modifyItem->oldNRCGI.pLMN_Identity.buf != NULLP)
1837 if(modifyItem->oldNRCGI.nRCellIdentity.buf != NULLP)
1839 if(modifyItem->served_Cell_Information.nRCGI.pLMN_Identity.buf != NULLP)
1841 if(modifyItem->served_Cell_Information.nRCGI.nRCellIdentity.buf
1844 if(modifyItem->served_Cell_Information.servedPLMNs.list.array\
1847 if(!modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx])
1849 if(modifyItem->served_Cell_Information.servedPLMNs.list.\
1850 array[arrIdx]->pLMN_Identity.buf != NULLP)
1852 if(modifyItem->served_Cell_Information.servedPLMNs.list.\
1853 array[arrIdx]->iE_Extensions!= NULLP)
1855 if(modifyItem->served_Cell_Information.servedPLMNs.list.\
1856 array[arrIdx]->iE_Extensions->list.array != NULLP)
1858 if(modifyItem->served_Cell_Information.servedPLMNs.list.\
1859 array[arrIdx]->iE_Extensions->list.array[arrIdx])
1861 if(modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx]->\
1862 iE_Extensions->list.array[arrIdx]->extensionValue.choice.SliceSupportList.\
1865 if(modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx]->\
1866 iE_Extensions->list.array[arrIdx]->extensionValue.choice.SliceSupportList.\
1867 list.array[arrIdx]!=NULLP)
1869 if(modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx]->\
1870 iE_Extensions->list.array[arrIdx]->extensionValue.choice.SliceSupportList.\
1871 list.array[arrIdx]->sNSSAI.sST.buf!=NULLP)
1873 if(modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx]->\
1874 iE_Extensions->list.array[arrIdx]->extensionValue.choice.\
1876 list.array[arrIdx]->sNSSAI.sD != NULLP)
1878 if(modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx]->\
1879 iE_Extensions->list.array[arrIdx]->extensionValue.\
1880 choice.SliceSupportList.\
1881 list.array[arrIdx]->sNSSAI.sD->buf!=NULLP)
1883 if(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD
1886 if(modifyItem->served_Cell_Information.nR_Mode_Info.choice.\
1887 fDD->uL_NRFreqInfo.freqBandListNr.list.array!=NULLP)
1889 if(modifyItem->served_Cell_Information.nR_Mode_Info.choice.\
1890 fDD->uL_NRFreqInfo.freqBandListNr.list.array[arrIdx]!=NULLP)
1892 if(modifyItem->served_Cell_Information.nR_Mode_Info.choice.\
1893 fDD->dL_NRFreqInfo.freqBandListNr.list.array !=NULLP)
1895 if(modifyItem->served_Cell_Information.nR_Mode_Info.\
1896 choice.fDD->dL_NRFreqInfo.freqBandListNr.list.\
1897 array[arrIdx]!= NULLP)
1899 if(modifyItem->served_Cell_Information.\
1900 measurementTimingConfiguration.buf !=NULLP)
1902 DU_FREE(modifyItem->served_Cell_Information.\
1903 measurementTimingConfiguration.\
1904 buf,modifyItem->served_Cell_Information.\
1905 measurementTimingConfiguration.size);
1907 DU_FREE(modifyItem->served_Cell_Information.\
1908 nR_Mode_Info.choice.fDD->dL_NRFreqInfo.\
1910 list.array[arrIdx],sizeof(FreqBandNrItem_t));
1912 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info\
1913 .choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array,\
1914 modifyItem->served_Cell_Information.nR_Mode_Info.\
1915 choice.fDD->dL_NRFreqInfo.freqBandListNr.list.size);
1917 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.\
1918 choice.fDD->uL_NRFreqInfo.freqBandListNr.list.\
1919 array[arrIdx],sizeof(FreqBandNrItem_t));
1921 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.\
1923 fDD->uL_NRFreqInfo.freqBandListNr.list.\
1924 array,modifyItem->served_Cell_Information.nR_Mode_Info.\
1925 choice.fDD->uL_NRFreqInfo.freqBandListNr.list.size);
1927 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.\
1928 fDD,sizeof(FDD_Info_t));
1930 DU_FREE(modifyItem->served_Cell_Information.servedPLMNs.list.\
1931 array[arrIdx]->iE_Extensions->list.array[arrIdx]->extensionValue.\
1932 choice.SliceSupportList.\
1933 list.array[arrIdx]->sNSSAI.sD->buf,modifyItem->\
1934 served_Cell_Information.\
1935 servedPLMNs.list.array[arrIdx]->iE_Extensions->list.\
1937 extensionValue.choice.SliceSupportList.list.array[arrIdx]->\
1941 DU_FREE(modifyItem->served_Cell_Information.servedPLMNs.list.\
1943 iE_Extensions->list.array[arrIdx]->extensionValue.choice.\
1945 list.array[arrIdx]->sNSSAI.sD,sizeof(OCTET_STRING_t));
1947 DU_FREE(modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx]->\
1948 iE_Extensions->list.array[arrIdx]->extensionValue.choice.\
1950 list.array[arrIdx]->sNSSAI.sST.buf,modifyItem->served_Cell_Information.\
1952 list.array[arrIdx]->iE_Extensions->list.array[arrIdx]->\
1953 extensionValue.choice.\
1954 SliceSupportList.list.array[arrIdx]->sNSSAI.sST.size);
1956 DU_FREE(modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx]->\
1957 iE_Extensions->list.array[arrIdx]->extensionValue.choice.SliceSupportList.\
1958 list.array[arrIdx],sizeof(SliceSupportItem_t));
1960 DU_FREE(modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx]->\
1961 iE_Extensions->list.array[arrIdx]->extensionValue.choice.SliceSupportList.\
1963 modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx]->\
1964 iE_Extensions->list.array[arrIdx]->extensionValue.choice.\
1965 SliceSupportList.list.size);
1968 for(i=0;i<modifyItem->served_Cell_Information.servedPLMNs.list.\
1969 array[arrIdx]->iE_Extensions->list.count;i++)
1971 DU_FREE(modifyItem->served_Cell_Information.servedPLMNs.list.\
1972 array[arrIdx]->iE_Extensions->list.array[i],\
1973 sizeof(ServedPLMNs_ItemExtIEs_t ));
1975 DU_FREE(modifyItem->served_Cell_Information.servedPLMNs.list.\
1976 array[arrIdx]->iE_Extensions->list.array,modifyItem->served_Cell_Information.\
1977 servedPLMNs.list.array[arrIdx]->iE_Extensions->list.size);
1979 DU_FREE(modifyItem->served_Cell_Information.servedPLMNs.list.\
1980 array[arrIdx]->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P3_t));
1982 DU_FREE(modifyItem->served_Cell_Information.servedPLMNs.list.\
1983 array[arrIdx]->pLMN_Identity.buf,
1984 modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx]->pLMN_Identity.size);
1987 for(i=0;i<modifyItem->served_Cell_Information.servedPLMNs.list.count;i++)
1989 if(modifyItem->served_Cell_Information.servedPLMNs.list.array[i]
1992 DU_FREE(modifyItem->served_Cell_Information.servedPLMNs.list.array[i],\
1993 sizeof(ServedPLMNs_Item_t));
1996 DU_FREE(modifyItem->served_Cell_Information.servedPLMNs.list.array,\
1997 modifyItem->served_Cell_Information.servedPLMNs.list.size);
1999 DU_FREE(modifyItem->served_Cell_Information.nRCGI.nRCellIdentity.buf,\
2000 modifyItem->served_Cell_Information.nRCGI.nRCellIdentity.size);
2002 DU_FREE(modifyItem->served_Cell_Information.nRCGI.pLMN_Identity.buf,\
2003 modifyItem->served_Cell_Information.nRCGI.pLMN_Identity.size);
2005 DU_FREE(modifyItem->oldNRCGI.nRCellIdentity.buf,\
2006 modifyItem->oldNRCGI.nRCellIdentity.size);
2008 DU_FREE(modifyItem->oldNRCGI.pLMN_Identity.buf,\
2009 modifyItem->oldNRCGI.pLMN_Identity.size);
2012 /*******************************************************************
2014 * @brief Deallocating memory of BuildAndSendDUConfigUpdate
2018 * Function : FreeDUConfigUpdate
2020 * Functionality: Deallocating memory of variables allocated in
2021 * BuildAndSendDUConfigUpdate function
2023 * @params[in] F1AP_PDU_t *f1apDuCfg
2025 * @return ROK - void
2027 * ****************************************************************/
2028 void FreeDUConfigUpdate(F1AP_PDU_t *f1apDuCfg)
2030 uint8_t ieIdx=0, cellModifyIdx=0, cellDeleteIdx=0;
2031 GNBDUConfigurationUpdate_t *duCfgUpdate = NULLP;
2032 Served_Cells_To_Modify_List_t *cellsToModify=NULLP;
2033 Served_Cells_To_Delete_List_t *cellsToDelete=NULLP;
2034 Served_Cells_To_Delete_Item_t *deleteItem = NULLP;
2035 Served_Cells_To_Delete_ItemIEs_t *deleteItemIe = NULLP;
2037 if(f1apDuCfg != NULLP)
2039 if(f1apDuCfg->choice.initiatingMessage != NULLP)
2041 duCfgUpdate = &f1apDuCfg->choice.initiatingMessage->\
2042 value.choice.GNBDUConfigurationUpdate;
2043 if(duCfgUpdate->protocolIEs.list.array != NULLP)
2045 for(ieIdx=0; ieIdx<duCfgUpdate->protocolIEs.list.count; ieIdx++)
2047 if(duCfgUpdate->protocolIEs.list.array[ieIdx] != NULLP)
2049 switch(duCfgUpdate->protocolIEs.list.array[ieIdx]->id)
2051 case ProtocolIE_ID_id_Served_Cells_To_Modify_List:
2053 cellsToModify = &duCfgUpdate->protocolIEs.list.array[ieIdx]->\
2054 value.choice.Served_Cells_To_Modify_List;
2055 if(cellsToModify->list.array != NULLP)
2057 for(cellModifyIdx=0; cellModifyIdx<cellsToModify->list.count ;cellModifyIdx++)
2059 if(cellsToModify->list.array[cellModifyIdx] != NULLP)
2061 freeCellsToModifyItem(&cellsToModify->list.array[cellModifyIdx]->value.choice.\
2062 Served_Cells_To_Modify_Item);
2063 DU_FREE(cellsToModify->list.array[cellModifyIdx],\
2064 sizeof(Served_Cells_To_Modify_ItemIEs_t));
2067 DU_FREE(cellsToModify->list.array,cellsToModify->list.size);
2071 case ProtocolIE_ID_id_Served_Cells_To_Delete_List:
2073 cellsToDelete = &duCfgUpdate->protocolIEs.list.array[ieIdx]->\
2074 value.choice.Served_Cells_To_Delete_List;
2075 if(cellsToDelete->list.array != NULLP)
2077 for(cellDeleteIdx=0; cellDeleteIdx<cellsToDelete->list.count ;cellDeleteIdx++)
2079 if(cellsToDelete->list.array[cellDeleteIdx] != NULLP)
2081 deleteItemIe = ((Served_Cells_To_Delete_ItemIEs_t*)\
2082 cellsToDelete->list.array[cellDeleteIdx]);
2083 deleteItem=&deleteItemIe->value.choice.Served_Cells_To_Delete_Item;
2084 DU_FREE(deleteItem->oldNRCGI.pLMN_Identity.buf,\
2085 deleteItem->oldNRCGI.pLMN_Identity.size);
2086 DU_FREE(deleteItem->oldNRCGI.nRCellIdentity.buf,\
2087 deleteItem->oldNRCGI.nRCellIdentity.size);
2088 DU_FREE(cellsToDelete->list.array[cellDeleteIdx],\
2089 sizeof(Served_Cells_To_Delete_ItemIEs_t));
2092 DU_FREE(cellsToDelete->list.array,cellsToDelete->list.size);
2097 case GNBDUConfigurationUpdateIEs__value_PR_GNB_DU_ID:
2099 DU_FREE(duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
2100 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
2104 DU_FREE(duCfgUpdate->protocolIEs.list.array[ieIdx],\
2105 sizeof(GNBDUConfigurationUpdateIEs_t));
2108 DU_FREE(duCfgUpdate->protocolIEs.list.array,duCfgUpdate->protocolIEs.list.size);
2110 DU_FREE(f1apDuCfg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
2112 DU_FREE(f1apDuCfg, (Size)sizeof(F1AP_PDU_t));
2116 /*******************************************************************
2118 * @brief Fills Served Plmns required in ServCellInfo IE
2122 * Function : fillServedPlmns
2124 * Functionality: Fills Served Plmns required in ServCellInfo IE
2126 * @params[in] Pointer to ServedPLMNs_List_t *
2128 * @return ROK - success
2131 *****************************************************************/
2133 uint8_t fillServedPlmns(ServedPLMNs_List_t *servedPlmn)
2135 uint8_t ieIdx, ieListCnt;
2137 servedPlmn->list.array[0]->pLMN_Identity.size = 3*sizeof(uint8_t);
2138 DU_ALLOC(servedPlmn->list.array[0]->pLMN_Identity.buf, servedPlmn->list.\
2139 array[0]->pLMN_Identity.size);
2140 if(servedPlmn->list.array[0]->pLMN_Identity.buf == NULLP)
2144 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.plmn[0],\
2145 servedPlmn->list.array[0]->pLMN_Identity.buf);
2146 DU_ALLOC(servedPlmn->list.array[0]->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P3_t));
2147 if(servedPlmn->list.array[0]->iE_Extensions == NULLP)
2153 servedPlmn->list.array[0]->iE_Extensions->list.count = ieListCnt;
2154 servedPlmn->list.array[0]->iE_Extensions->list.size = ieListCnt *sizeof(ServedPLMNs_ItemExtIEs_t *);
2155 DU_ALLOC(servedPlmn->list.array[0]->iE_Extensions->list.array,servedPlmn->list.array[0]->\
2156 iE_Extensions->list.size);
2157 if(servedPlmn->list.array[0]->iE_Extensions->list.array == NULLP)
2161 for(ieIdx=0;ieIdx<ieListCnt;ieIdx++)
2163 DU_ALLOC(servedPlmn->list.array[0]->iE_Extensions->list.array[ieIdx],\
2164 sizeof(ServedPLMNs_ItemExtIEs_t));
2165 if(servedPlmn->list.array[0]->iE_Extensions->list.array[ieIdx] == NULLP)
2170 //plmnIeExt = servedPlmn->list.array[0]->iE_Extensions;
2171 servedPlmn->list.array[0]->iE_Extensions->list.array[0]->id =ProtocolIE_ID_id_TAISliceSupportList;
2172 servedPlmn->list.array[0]->iE_Extensions->list.array[0]->criticality = Criticality_ignore;
2173 servedPlmn->list.array[0]->iE_Extensions->list.array[0]->extensionValue.present = \
2174 ServedPLMNs_ItemExtIEs__extensionValue_PR_SliceSupportList;
2175 servedPlmn->list.array[0]->iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2177 servedPlmn->list.array[0]->\
2178 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2179 list.size = sizeof(SliceSupportItem_t *);
2180 DU_ALLOC(servedPlmn->list.array[0]->\
2181 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2182 list.array,servedPlmn->list.array[0]->\
2183 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.list.size);
2184 if(servedPlmn->list.array[0]->\
2185 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2186 list.array == NULLP)
2191 DU_ALLOC(servedPlmn->list.array[0]->\
2192 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2193 list.array[0],sizeof( SliceSupportItem_t));
2194 if(servedPlmn->list.array[0]->\
2195 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2196 list.array[0] == NULLP)
2200 servedPlmn->list.array[0]->\
2201 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2202 list.array[0]->sNSSAI.sST.size = sizeof(uint8_t);
2203 DU_ALLOC(servedPlmn->list.array[0]->\
2204 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2205 list.array[0]->sNSSAI.sST.buf,servedPlmn->list.array[0]->\
2206 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.list.array[0]->sNSSAI.sST.size);
2207 if(servedPlmn->list.array[0]->\
2208 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2209 list.array[0]->sNSSAI.sST.buf == NULLP)
2213 servedPlmn->list.array[0]->\
2214 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2215 list.array[0]->sNSSAI.sST.buf[0] = 3;
2216 DU_ALLOC(servedPlmn->list.array[0]->\
2217 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2218 list.array[0]->sNSSAI.sD,sizeof(OCTET_STRING_t));
2219 if(servedPlmn->list.array[0]->\
2220 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2221 list.array[0]->sNSSAI.sD == NULLP)
2225 servedPlmn->list.array[0]->\
2226 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2227 list.array[0]->sNSSAI.sD->size = 3*sizeof(uint8_t);
2228 DU_ALLOC(servedPlmn->list.array[0]->\
2229 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2230 list.array[0]->sNSSAI.sD->buf,servedPlmn->list.array[0]->\
2231 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2232 list.array[0]->sNSSAI.sD->size);
2233 if(servedPlmn->list.array[0]->\
2234 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2235 list.array[0]->sNSSAI.sD->buf == NULLP)
2239 servedPlmn->list.array[0]->\
2240 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2241 list.array[0]->sNSSAI.sD->buf[0] = 3;
2242 servedPlmn->list.array[0]->\
2243 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2244 list.array[0]->sNSSAI.sD->buf[1] = 6;
2245 servedPlmn->list.array[0]->\
2246 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2247 list.array[0]->sNSSAI.sD->buf[2] = 9;
2251 /*******************************************************************
2253 * @brief Fills Nr Fdd Info required in ServCellInfo IE
2257 * Function : fillNrFddInfo
2259 * Functionality: Fills Nr Fdd Info required in ServCellInfo IE
2261 * @params[in] Pointer to NR_Mode_Info_t *
2263 * @return ROK - success
2266 *****************************************************************/
2268 uint8_t fillNrFddInfo(NR_Mode_Info_t *nrFdd)
2270 nrFdd->choice.fDD->uL_NRFreqInfo.nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.\
2271 f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn;
2272 nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.count = 1;
2273 nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.size = sizeof(FreqBandNrItem_t*);
2274 DU_ALLOC(nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.\
2275 array, nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.size);
2276 if(nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array == NULLP)
2280 DU_ALLOC(nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array[0], \
2281 sizeof(FreqBandNrItem_t));
2282 if(nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array[0] == NULLP)
2286 nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array[0]->freqBandIndicatorNr = \
2287 duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.\
2288 freqBand[0].nrFreqBand;
2289 nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array[0]->supportedSULBandList.list.count=0;
2290 nrFdd->choice.fDD->dL_NRFreqInfo.nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.\
2291 dlNrFreqInfo.nrArfcn;
2292 nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.count = 1;
2293 nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.size = sizeof(FreqBandNrItem_t *);
2294 DU_ALLOC(nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array,nrFdd->\
2295 choice.fDD->dL_NRFreqInfo.freqBandListNr.list.size);
2296 if(nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array == NULLP)
2300 DU_ALLOC(nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array[0],\
2301 sizeof(FreqBandNrItem_t));
2302 if(nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array[0] == NULLP)
2306 nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array[0]->freqBandIndicatorNr = \
2307 duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.\
2308 freqBand[0].nrFreqBand;
2309 nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array[0]->supportedSULBandList.list.count=0;
2311 /*Transmission Bandwidth*/
2312 nrFdd->choice.fDD->uL_Transmission_Bandwidth.nRSCS = duCfgParam.srvdCellLst[0].duCellInfo.\
2313 f1Mode.mode.fdd.ulTxBw.nrScs;
2314 nrFdd->choice.fDD->uL_Transmission_Bandwidth.nRNRB = duCfgParam.srvdCellLst[0].duCellInfo.\
2315 f1Mode.mode.fdd.ulTxBw.nrb;
2316 nrFdd->choice.fDD->dL_Transmission_Bandwidth.nRSCS = duCfgParam.srvdCellLst[0].duCellInfo.\
2317 f1Mode.mode.fdd.dlTxBw.nrScs;
2318 nrFdd->choice.fDD->dL_Transmission_Bandwidth.nRNRB = duCfgParam.srvdCellLst[0].duCellInfo.\
2319 f1Mode.mode.fdd.dlTxBw.nrb;
2324 /*******************************************************************
2326 * @brief Fills ServCellInfo IE
2330 * Function : fillServedCellInfo
2332 * Functionality: Fills ServCellInfo
2334 * @params[in] Pointer to Served_Cell_Information_t *
2336 * @return ROK - success
2339 *****************************************************************/
2341 uint8_t fillServedCellInfo(Served_Cell_Information_t *srvCellInfo)
2343 uint8_t tmp, ieIdx, ieListCnt;
2346 srvCellInfo->nRCGI.pLMN_Identity.size =3*sizeof(uint8_t);
2347 DU_ALLOC(srvCellInfo->nRCGI.pLMN_Identity.buf,\
2348 srvCellInfo->nRCGI.pLMN_Identity.size);
2349 if(srvCellInfo->nRCGI.pLMN_Identity.buf == NULLP)
2353 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
2354 srvCellInfo->nRCGI.pLMN_Identity.buf);
2355 srvCellInfo->nRCGI.nRCellIdentity.size =5*sizeof(uint8_t);
2356 DU_ALLOC(srvCellInfo->nRCGI.nRCellIdentity.buf,\
2357 srvCellInfo->nRCGI.nRCellIdentity.size);
2358 if(srvCellInfo->nRCGI.nRCellIdentity.buf == NULLP)
2362 for (tmp = 0 ; tmp < srvCellInfo->\
2363 nRCGI.nRCellIdentity.size-1 ; tmp++)
2365 srvCellInfo->nRCGI.nRCellIdentity.buf[tmp] = 0;
2367 srvCellInfo->nRCGI.nRCellIdentity.buf[4] = 16;
2368 srvCellInfo->nRCGI.nRCellIdentity.bits_unused =4;
2371 srvCellInfo->nRPCI = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrPci;
2375 srvCellInfo->servedPLMNs.list.count = ieListCnt;
2376 srvCellInfo->servedPLMNs.list.size = ieListCnt*sizeof(ServedPLMNs_Item_t *);
2377 DU_ALLOC(srvCellInfo->servedPLMNs.list.array,\
2378 srvCellInfo->servedPLMNs.list.size);
2379 if(srvCellInfo->servedPLMNs.list.array == NULLP)
2383 for(ieIdx=0; ieIdx < ieListCnt; ieIdx++)
2385 DU_ALLOC(srvCellInfo->servedPLMNs.list.array[ieIdx],\
2386 sizeof(ServedPLMNs_Item_t));
2387 if(srvCellInfo->servedPLMNs.list.array[ieIdx]== NULLP)
2392 if(fillServedPlmns(&srvCellInfo->servedPLMNs))
2397 /*nR Mode Info with FDD*/
2398 srvCellInfo->nR_Mode_Info.present = NR_Mode_Info_PR_fDD;
2399 DU_ALLOC(srvCellInfo->nR_Mode_Info.choice.fDD,\
2400 sizeof(FDD_Info_t));
2401 if(srvCellInfo->nR_Mode_Info.choice.fDD == NULLP)
2405 if(fillNrFddInfo(&srvCellInfo->nR_Mode_Info))
2408 /*Measurement timing Config*/
2409 srvCellInfo->measurementTimingConfiguration.size = sizeof(uint8_t);
2410 DU_ALLOC(srvCellInfo->measurementTimingConfiguration.\
2411 buf,srvCellInfo->measurementTimingConfiguration.size);
2412 if(srvCellInfo->measurementTimingConfiguration.buf == NULLP)
2416 srvCellInfo->measurementTimingConfiguration.\
2417 buf[0] = duCfgParam.srvdCellLst[0].duCellInfo.measTimeCfg;
2422 /*******************************************************************
2424 * @brief Fills ServCellToModItem IE
2428 * Function : fillServCellToModItem
2430 * Functionality: Fills ServCellToModItem IE
2432 * @params[in] Pointer to Served_Cells_To_Modify_Item_t *
2434 * @return ROK - success
2437 *****************************************************************/
2439 uint8_t fillServCellToModItem(Served_Cells_To_Modify_Item_t *modifyItem)
2444 modifyItem->oldNRCGI.pLMN_Identity.size = 3*sizeof(uint8_t);
2445 DU_ALLOC(modifyItem->oldNRCGI.pLMN_Identity.buf,modifyItem->oldNRCGI.pLMN_Identity.size);
2446 if(modifyItem->oldNRCGI.pLMN_Identity.buf == NULLP)
2450 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
2451 modifyItem->oldNRCGI.pLMN_Identity.buf);
2454 modifyItem->oldNRCGI.nRCellIdentity.size = 5*sizeof(uint8_t);
2455 DU_ALLOC(modifyItem->oldNRCGI.nRCellIdentity.buf,\
2456 modifyItem->oldNRCGI.nRCellIdentity.size);
2457 if(modifyItem->oldNRCGI.nRCellIdentity.buf == NULLP)
2461 for(ieIdx = 0; ieIdx < modifyItem->oldNRCGI.nRCellIdentity.size-1; ieIdx++)
2463 modifyItem->oldNRCGI.nRCellIdentity.buf[ieIdx] = 0;
2465 modifyItem->oldNRCGI.nRCellIdentity.buf[4] = 16;
2466 modifyItem->oldNRCGI.nRCellIdentity.bits_unused = 4;
2468 if(fillServedCellInfo(&modifyItem->served_Cell_Information))
2474 /*******************************************************************
2476 * @brief Builds ServCellToModList
2480 * Function : buildServCellToModList
2482 * Functionality: Builds the serv cell to Mod List
2484 * @params[in] Pointer to Served_Cells_To_Modify_List_t *
2486 * @return ROK - success
2489 *****************************************************************/
2491 uint8_t buildServCellToModList(Served_Cells_To_Modify_List_t *cellsToModify)
2493 uint8_t ieListCnt, ieIdx;
2494 Served_Cells_To_Modify_Item_t *modifyItem = NULLP;
2497 cellsToModify->list.count = ieListCnt;
2498 cellsToModify->list.size = ieListCnt*sizeof(Served_Cells_To_Modify_ItemIEs_t *);
2499 DU_ALLOC(cellsToModify->list.array,cellsToModify->list.size);
2500 if(cellsToModify->list.array == NULLP)
2504 for(ieIdx=0; ieIdx< ieListCnt; ieIdx++)
2506 DU_ALLOC(cellsToModify->list.array[ieIdx],sizeof(Served_Cells_To_Modify_ItemIEs_t));
2507 if(cellsToModify->list.array[ieIdx] == NULLP)
2512 cellsToModify->list.array[0]->id = ProtocolIE_ID_id_Served_Cells_To_Modify_Item;
2513 cellsToModify->list.array[0]->criticality = Criticality_reject;
2514 cellsToModify->list.array[0]->value.present =\
2515 Served_Cells_To_Modify_ItemIEs__value_PR_Served_Cells_To_Modify_Item;
2516 modifyItem=&cellsToModify->list.array[0]->value.choice.Served_Cells_To_Modify_Item;
2518 if(fillServCellToModItem(modifyItem))
2523 /*******************************************************************
2525 * @brief filling the DeleteItemList
2529 * Function : fillCellToDeleteItem
2531 * Functionality: Filling the DeleteItemIe
2533 * @params[in] Pointer to Served_Cells_To_Delete_ItemIEs_t
2535 * @return ROK - success
2538 *****************************************************************/
2539 uint8_t fillCellToDeleteItem(struct Served_Cells_To_Delete_ItemIEs *deleteItemIe)
2542 Served_Cells_To_Delete_Item_t *deleteItem=NULLP;
2544 deleteItemIe->id = ProtocolIE_ID_id_Served_Cells_To_Delete_Item;
2545 deleteItemIe->criticality = Criticality_reject;
2546 deleteItemIe->value.present =\
2547 Served_Cells_To_Delete_ItemIEs__value_PR_Served_Cells_To_Delete_Item;
2548 deleteItem=&deleteItemIe->value.choice.Served_Cells_To_Delete_Item;
2551 deleteItem->oldNRCGI.pLMN_Identity.size = 3*sizeof(uint8_t);
2552 DU_ALLOC(deleteItem->oldNRCGI.pLMN_Identity.buf,deleteItem->oldNRCGI.pLMN_Identity.size);
2553 if(deleteItem->oldNRCGI.pLMN_Identity.buf == NULLP)
2555 DU_LOG("ERROR --> F1AP: fillCellToDeleteItem(): Failed to allocate the memory");
2558 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
2559 deleteItem->oldNRCGI.pLMN_Identity.buf);
2562 deleteItem->oldNRCGI.nRCellIdentity.size = 5*sizeof(uint8_t);
2563 DU_ALLOC(deleteItem->oldNRCGI.nRCellIdentity.buf,\
2564 deleteItem->oldNRCGI.nRCellIdentity.size);
2565 if(deleteItem->oldNRCGI.nRCellIdentity.buf == NULLP)
2567 DU_LOG("ERROR --> F1AP: fillCellToDeleteItem(): Failed to allocate the memory");
2570 for(arrIdx = 0; arrIdx < deleteItem->oldNRCGI.nRCellIdentity.size-1; arrIdx++)
2572 deleteItem->oldNRCGI.nRCellIdentity.buf[arrIdx] = 0;
2574 deleteItem->oldNRCGI.nRCellIdentity.buf[4] = 16;
2575 deleteItem->oldNRCGI.nRCellIdentity.bits_unused = 4;
2578 /*******************************************************************
2580 * @brief Builds ServCellToDeleteList
2584 * Function : buildServCellToDeleteList
2586 * Functionality: Builds the serv cell to delete List
2588 * @params[in] Pointer to Served_Cells_To_Delete_List_t *
2590 * @return ROK - success
2593 *****************************************************************/
2595 uint8_t buildServCellToDeleteList(Served_Cells_To_Delete_List_t *cellsToDelete)
2597 uint8_t ieListCnt, arrIdx;
2600 cellsToDelete->list.count = ieListCnt;
2601 cellsToDelete->list.size = ieListCnt*sizeof(Served_Cells_To_Delete_ItemIEs_t *);
2603 DU_ALLOC(cellsToDelete->list.array,cellsToDelete->list.size);
2604 if(cellsToDelete->list.array == NULLP)
2606 DU_LOG("\nERROR --> F1AP : buildServCellToDeleteList(): Memory allocation failed");
2610 for(arrIdx=0; arrIdx< ieListCnt; arrIdx++)
2612 DU_ALLOC(cellsToDelete->list.array[arrIdx],sizeof(Served_Cells_To_Delete_ItemIEs_t));
2613 if(cellsToDelete->list.array[arrIdx] == NULLP)
2615 DU_LOG("\nERROR --> F1AP : buildServCellToDeleteList(): Memory allocation failed");
2621 if(fillCellToDeleteItem((Served_Cells_To_Delete_ItemIEs_t*)cellsToDelete->list.array[arrIdx]) !=ROK)
2623 DU_LOG("\nERROR --> F1AP: buildServCellToDeleteList(): failed to fill Served_Cells_To_Delete_ItemIEs");
2629 /*******************************************************************
2631 * @brief Builds and sends the DUConfigUpdate
2635 * Function : BuildAndSendDUConfigUpdate
2637 * Functionality: Constructs the DU Update message and sends
2638 * it to the CU through SCTP.
2640 * @params[in] void **buf,Buffer to which encoded pattern is written into
2641 * @params[in] int *size,size of buffer
2643 * @return ROK - success
2646 * ****************************************************************/
2647 uint8_t BuildAndSendDUConfigUpdate(ServCellAction servCellAction)
2649 uint8_t ret =0, ieIdx=0, elementCnt=0;
2650 bool memAlloctionFailure = false;
2651 F1AP_PDU_t *f1apDuCfg = NULLP;
2652 GNBDUConfigurationUpdate_t *duCfgUpdate = NULLP;
2653 asn_enc_rval_t encRetVal; /* Encoder return value */
2655 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
2660 DU_LOG("\nINFO --> F1AP : Building DU config update\n");
2661 /* Allocate the memory for F1DuCfg */
2662 DU_ALLOC(f1apDuCfg, sizeof(F1AP_PDU_t));
2663 if(f1apDuCfg == NULLP)
2665 DU_LOG("\nERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation for F1AP-PDU failed");
2669 f1apDuCfg->present = F1AP_PDU_PR_initiatingMessage;
2670 DU_ALLOC(f1apDuCfg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
2671 if(f1apDuCfg->choice.initiatingMessage == NULLP)
2673 DU_LOG("\nERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation for F1AP-PDU failed");
2677 f1apDuCfg->choice.initiatingMessage->procedureCode = \
2678 ProcedureCode_id_gNBDUConfigurationUpdate;
2679 f1apDuCfg->choice.initiatingMessage->criticality = Criticality_reject;
2680 f1apDuCfg->choice.initiatingMessage->value.present = \
2681 InitiatingMessage__value_PR_GNBDUConfigurationUpdate;
2682 duCfgUpdate = &f1apDuCfg->choice.initiatingMessage->value.\
2683 choice.GNBDUConfigurationUpdate;
2685 duCfgUpdate->protocolIEs.list.count = elementCnt;
2686 duCfgUpdate->protocolIEs.list.size = \
2687 elementCnt * sizeof(GNBDUConfigurationUpdateIEs_t*);
2689 /* Initialize the F1Setup members */
2690 DU_ALLOC(duCfgUpdate->protocolIEs.list.array,duCfgUpdate->protocolIEs.list.size);
2691 if(duCfgUpdate->protocolIEs.list.array == NULLP)
2693 DU_LOG("ERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation failed");
2696 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
2698 DU_ALLOC(duCfgUpdate->protocolIEs.list.array[ieIdx],sizeof(GNBDUConfigurationUpdateIEs_t));
2699 if(duCfgUpdate->protocolIEs.list.array[ieIdx] == NULLP)
2701 DU_LOG("ERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation failed");
2702 memAlloctionFailure = true;
2707 if(memAlloctionFailure == true)
2713 duCfgUpdate->protocolIEs.list.array[ieIdx]->id=ProtocolIE_ID_id_TransactionID;
2714 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
2715 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2716 GNBDUConfigurationUpdateIEs__value_PR_TransactionID;
2717 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = TRANS_ID;
2720 if(servCellAction == SERV_CELL_TO_MODIFY)
2722 /*Served Cell to Modify */
2723 duCfgUpdate->protocolIEs.list.array[ieIdx]->id = \
2724 ProtocolIE_ID_id_Served_Cells_To_Modify_List;
2725 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality =Criticality_reject;
2726 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2727 GNBDUConfigurationUpdateIEs__value_PR_Served_Cells_To_Modify_List;
2728 if(buildServCellToModList(&duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.\
2729 Served_Cells_To_Modify_List))
2731 DU_LOG("ERROR --> DU APP : BuildAndSendDUConfigUpdate(): failed to build ServCellToModList");
2737 /*Served Cell to Delete */
2738 duCfgUpdate->protocolIEs.list.array[ieIdx]->id = \
2739 ProtocolIE_ID_id_Served_Cells_To_Delete_List;
2740 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality =Criticality_reject;
2741 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2742 GNBDUConfigurationUpdateIEs__value_PR_Served_Cells_To_Delete_List;
2743 if(buildServCellToDeleteList(&duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.\
2744 Served_Cells_To_Delete_List)!=ROK)
2746 DU_LOG("ERROR --> DU APP : BuildAndSendDUConfigUpdate(): failed to build ServCellToDeleteList");
2751 // NOTE :GNB DU SYS INFO:MIB AND SIB1 INFORMATION TO BE BUILT AND FILLED HERE
2754 duCfgUpdate->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_ID;
2755 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
2756 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2757 GNBDUConfigurationUpdateIEs__value_PR_GNB_DU_ID;
2758 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size = sizeof(uint8_t);
2759 DU_ALLOC(duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
2760 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
2761 if(duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf == NULLP)
2763 DU_LOG("ERROR --> DU APP : BuildAndSendDUConfigUpdate(): Memory allocation failed for GNB_DU_ID");
2766 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf[0] = duCfgParam.duId;
2768 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apDuCfg);
2770 /* Encode the DU Config Update type as APER */
2771 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
2773 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apDuCfg, PrepFinalEncBuf, encBuf);
2775 /* Checking encode results */
2776 if(encRetVal.encoded == ENCODE_FAIL)
2778 DU_LOG("ERROR --> F1AP : Could not encode DUConfigUpdate structure (at %s)\n",\
2779 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
2784 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for DUConfigUpdate\n");
2785 for(ieIdx =0; ieIdx < encBufSize; ieIdx++)
2787 printf("%x",encBuf[ieIdx]);
2791 if(sendF1APMsg() != ROK)
2793 DU_LOG("\nERROR --> F1AP : Sending GNB-DU Config Update failed");
2801 addToReservedF1apPduList(TRANS_ID,f1apDuCfg);
2806 /*******************************************************************
2808 * @brief free the ULRRCMessageTransfer
2812 * Function : FreeULRRCMessageTransfer
2814 * Functionality: Deallocating the memory of variable allocated in
2815 * FreeULRRCMessageTransfer
2819 * @return ROK - void
2821 ******************************************************************/
2822 void FreeULRRCMessageTransfer( F1AP_PDU_t *f1apMsg)
2825 ULRRCMessageTransfer_t *ulRRCMsg;
2827 if(f1apMsg != NULLP)
2829 if(f1apMsg->choice.initiatingMessage != NULLP)
2831 ulRRCMsg = &f1apMsg->choice.initiatingMessage->value.choice.ULRRCMessageTransfer;
2832 if(ulRRCMsg->protocolIEs.list.array != NULLP)
2834 for(idx1=0;idx1<ulRRCMsg->protocolIEs.list.count;idx1++)
2836 if(ulRRCMsg->protocolIEs.list.array[idx1] != NULLP)
2838 if(ulRRCMsg->protocolIEs.list.array[idx1]->value.present ==
2839 ULRRCMessageTransferIEs__value_PR_RRCContainer)
2841 DU_FREE(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf,
2842 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size);
2844 DU_FREE(ulRRCMsg->protocolIEs.list.array[idx1],sizeof(ULRRCMessageTransferIEs_t));
2847 DU_FREE(ulRRCMsg->protocolIEs.list.array,ulRRCMsg->protocolIEs.list.size );
2849 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
2851 DU_FREE(f1apMsg,sizeof(F1AP_PDU_t));
2854 /*******************************************************************
2856 * @brief Builds and sends the ULRRCMessageTransfer
2860 * Function : BuildAndSendULRRCMessageTransfer
2862 * Functionality: Constructs the UL RRC Message Transfer and sends
2863 * it to the CU through SCTP.
2867 * @return ROK - success
2870 * ****************************************************************/
2871 uint8_t BuildAndSendULRRCMessageTransfer(DuUeCb ueCb, uint8_t lcId, \
2872 uint16_t msgLen, uint8_t *rrcMsg)
2874 uint8_t elementCnt =0;
2877 F1AP_PDU_t *f1apMsg = NULLP;
2878 ULRRCMessageTransfer_t *ulRRCMsg = NULLP;
2879 asn_enc_rval_t encRetVal; /* Encoder return value */
2880 uint8_t ret =RFAILED;
2882 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
2886 DU_LOG("\n INFO --> F1AP : Building UL RRC Message Transfer Message\n");
2888 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
2889 if(f1apMsg == NULLP)
2891 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
2894 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
2895 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
2896 if(f1apMsg->choice.initiatingMessage == NULLP)
2898 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
2901 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_ULRRCMessageTransfer;
2902 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
2903 f1apMsg->choice.initiatingMessage->value.present = \
2904 InitiatingMessage__value_PR_ULRRCMessageTransfer;
2906 &f1apMsg->choice.initiatingMessage->value.choice.ULRRCMessageTransfer;
2908 ulRRCMsg->protocolIEs.list.count = elementCnt;
2909 ulRRCMsg->protocolIEs.list.size = \
2910 elementCnt * sizeof(ULRRCMessageTransferIEs_t *);
2912 /* Initialize the F1Setup members */
2913 DU_ALLOC(ulRRCMsg->protocolIEs.list.array, ulRRCMsg->protocolIEs.list.size);
2914 if(ulRRCMsg->protocolIEs.list.array == NULLP)
2916 DU_LOG(" ERROR --> F1AP : Memory allocation for UL RRC MessageTransferIEs failed");
2919 for(idx=0; idx<elementCnt; idx++)
2921 DU_ALLOC(ulRRCMsg->protocolIEs.list.array[idx],sizeof(ULRRCMessageTransferIEs_t));
2922 if(ulRRCMsg->protocolIEs.list.array[idx] == NULLP)
2930 /*GNB CU UE F1AP ID*/
2931 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
2932 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2933 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2934 ULRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID;
2935 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.GNB_CU_UE_F1AP_ID = ueCb.gnbCuUeF1apId;
2937 /*GNB DU UE F1AP ID*/
2939 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
2940 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2941 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2942 ULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
2943 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.GNB_DU_UE_F1AP_ID = ueCb.gnbDuUeF1apId;
2947 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_SRBID;
2948 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2949 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2950 ULRRCMessageTransferIEs__value_PR_SRBID;
2951 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.SRBID = lcId;
2955 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_RRCContainer;
2956 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2957 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2958 ULRRCMessageTransferIEs__value_PR_RRCContainer;
2959 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size = msgLen;
2960 DU_ALLOC(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf,
2961 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size)
2962 if(!ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf)
2964 DU_LOG(" ERROR --> F1AP : Memory allocation for BuildAndSendULRRCMessageTransfer failed");
2967 memset(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf, 0, msgLen);
2968 memcpy(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf, \
2969 rrcMsg, ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size);
2971 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
2973 /* Encode the F1SetupRequest type as APER */
2974 memset(encBuf, 0, ENC_BUF_MAX_LEN);
2976 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
2978 /* Encode results */
2979 if(encRetVal.encoded == ENCODE_FAIL)
2981 DU_LOG( "\nERROR --> F1AP : Could not encode ULRRCMessageTransfer structure (at %s)\n",\
2982 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
2987 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for ULRRCMessageTransfer\n");
2988 for(int i=0; i< encBufSize; i++)
2990 printf("%x",encBuf[i]);
2995 if(sendF1APMsg() != ROK)
2997 DU_LOG("\nERROR --> F1AP : Sending UL RRC Message Transfer Failed");
3003 FreeULRRCMessageTransfer(f1apMsg);
3006 }/* End of BuildAndSendULRRCMessageTransfer*/
3008 /*******************************************************************
3010 * @brief Builds tag config
3014 * Function : BuildTagConfig
3016 * Functionality: Builds tag config in MacCellGroupConfig
3018 * @params[in] TAG_Config *tag_Config
3020 * @return ROK - success
3023 * ****************************************************************/
3024 uint8_t BuildTagConfig(struct TAG_Config *tagConfig)
3026 struct TAG_Config__tag_ToAddModList *tagList;
3027 uint8_t idx, elementCnt;
3029 tagConfig->tag_ToReleaseList = NULLP;
3030 tagConfig->tag_ToAddModList = NULLP;
3031 DU_ALLOC(tagConfig->tag_ToAddModList, sizeof(struct TAG_Config__tag_ToAddModList));
3032 if(!tagConfig->tag_ToAddModList)
3034 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildTagConfig");
3038 elementCnt = 1; //ODU_VALUE_ONE;
3039 tagList = tagConfig->tag_ToAddModList;
3040 tagList->list.count = elementCnt;
3041 tagList->list.size = elementCnt * sizeof(struct TAG *);
3043 tagList->list.array = NULLP;
3044 DU_ALLOC(tagList->list.array, tagList->list.size);
3045 if(!tagList->list.array)
3047 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildTagConfig");
3051 for(idx=0; idx<tagList->list.count; idx++)
3053 tagList->list.array[idx] = NULLP;
3054 DU_ALLOC(tagList->list.array[idx], sizeof(struct TAG));
3055 if(!tagList->list.array[idx])
3057 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildTagConfig");
3063 tagList->list.array[idx]->tag_Id = TAG_ID;
3064 tagList->list.array[idx]->timeAlignmentTimer = TIME_ALIGNMENT_TMR;
3069 /*******************************************************************
3071 * @brief Builds PHR Config
3075 * Function : BuildPhrConfig
3077 * Functionality: Builds phrConfig in MacCellGroupConfig
3079 * @params[in] PHR Config *
3081 * @return ROK - success
3084 * ****************************************************************/
3085 uint8_t BuildPhrConfig(struct MAC_CellGroupConfig__phr_Config *phrConfig)
3088 phrConfig->present = MAC_CellGroupConfig__phr_Config_PR_setup;
3089 phrConfig->choice.setup = NULLP;
3090 DU_ALLOC(phrConfig->choice.setup, sizeof(struct PHR_Config));
3091 if(!phrConfig->choice.setup)
3093 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildPhrConfig");
3097 phrConfig->choice.setup->phr_PeriodicTimer = PHR_PERIODIC_TMR;
3098 phrConfig->choice.setup->phr_ProhibitTimer = PHR_PROHIBHIT_TMR;
3099 phrConfig->choice.setup->phr_Tx_PowerFactorChange = PHR_PWR_FACTOR_CHANGE;
3100 phrConfig->choice.setup->multiplePHR = false;
3101 phrConfig->choice.setup->dummy = false;
3102 phrConfig->choice.setup->phr_Type2OtherCell = false;
3103 phrConfig->choice.setup->phr_ModeOtherCG = PHR_MODE_OTHER_CG;
3108 /*******************************************************************
3110 * @brief Builds BSR Config
3114 * Function : BuildBsrConfig
3116 * Functionality: Builds BuildBsrConfig in MacCellGroupConfig
3118 * @params[in] BSR_Config *bsrConfig
3120 * @return ROK - success
3123 * ****************************************************************/
3124 uint8_t BuildBsrConfig(struct BSR_Config *bsrConfig)
3126 bsrConfig->periodicBSR_Timer = PERIODIC_BSR_TMR;
3127 bsrConfig->retxBSR_Timer = RETX_BSR_TMR;
3128 bsrConfig->logicalChannelSR_DelayTimer = NULLP;
3133 /*******************************************************************
3135 * @brief Builds scheduling request config
3139 * Function : BuildSchedulingReqConfig
3141 * Functionality: Builds BuildSchedulingReqConfig in MacCellGroupConfig
3143 * @params[in] SchedulingRequestConfig *schedulingRequestConfig
3145 * @return ROK - success
3148 * ****************************************************************/
3149 uint8_t BuildSchedulingReqConfig(struct SchedulingRequestConfig *schedulingRequestConfig)
3151 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList;
3152 uint8_t idx, elementCnt;
3154 schedulingRequestConfig->schedulingRequestToAddModList = NULLP;
3155 DU_ALLOC(schedulingRequestConfig->schedulingRequestToAddModList,
3156 sizeof(struct SchedulingRequestConfig__schedulingRequestToAddModList));
3157 if(!schedulingRequestConfig->schedulingRequestToAddModList)
3159 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
3163 elementCnt = 1; //ODU_VALUE_ONE;
3164 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
3165 schReqList->list.count = elementCnt;
3166 schReqList->list.size = elementCnt * sizeof(struct SchedulingRequestToAddMod *);
3168 schReqList->list.array = NULLP;
3169 DU_ALLOC(schReqList->list.array, schReqList->list.size);
3170 if(!schReqList->list.array)
3172 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
3176 for(idx=0;idx<schReqList->list.count; idx++)
3178 schReqList->list.array[idx] = NULLP;
3179 DU_ALLOC(schReqList->list.array[idx], sizeof(struct SchedulingRequestToAddMod));
3180 if(!schReqList->list.array[idx])
3182 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
3188 schReqList->list.array[idx]->schedulingRequestId = SCH_REQ_ID;
3190 schReqList->list.array[idx]->sr_ProhibitTimer = NULLP;
3191 DU_ALLOC(schReqList->list.array[idx]->sr_ProhibitTimer, sizeof(long));
3192 if(!schReqList->list.array[idx]->sr_ProhibitTimer)
3194 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
3197 *(schReqList->list.array[idx]->sr_ProhibitTimer) = SR_PROHIBIT_TMR;
3198 schReqList->list.array[idx]->sr_TransMax = SR_TRANS_MAX;
3199 schedulingRequestConfig->schedulingRequestToReleaseList = NULLP;
3204 /*******************************************************************
3206 * @brief Builds RLC Config
3210 * Function : BuildRlcConfig
3212 * Functionality: Builds RLC Config in BuildRlcBearerToAddModList
3214 * @params[in] RLC_Config *rlcConfig
3216 * @return ROK - success
3219 * ****************************************************************/
3220 uint8_t BuildRlcConfig(struct RLC_Config *rlcConfig)
3223 rlcConfig->present = RLC_Config_PR_am;
3225 rlcConfig->choice.am = NULLP;
3226 DU_ALLOC(rlcConfig->choice.am, sizeof(struct RLC_Config__am));
3227 if(!rlcConfig->choice.am)
3229 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfig");
3234 rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength = NULLP;
3235 DU_ALLOC(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
3236 if(!rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength)
3238 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfig");
3241 *(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength) = SN_FIELD_LEN;
3242 rlcConfig->choice.am->ul_AM_RLC.t_PollRetransmit = T_POLL_RETRANSMIT;
3243 rlcConfig->choice.am->ul_AM_RLC.pollPDU = POLL_PDU;
3244 rlcConfig->choice.am->ul_AM_RLC.pollByte = POLL_BYTE;
3245 rlcConfig->choice.am->ul_AM_RLC.maxRetxThreshold = MAX_RETX_THRESHOLD;
3248 rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength = NULLP;
3249 DU_ALLOC(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
3250 if(!rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength)
3252 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfig");
3255 *(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength) = SN_FIELD_LEN;
3256 rlcConfig->choice.am->dl_AM_RLC.t_Reassembly = T_REASSEMBLY;
3257 rlcConfig->choice.am->dl_AM_RLC.t_StatusProhibit = T_STATUS_PROHIBHIT;
3262 /*******************************************************************
3264 * @brief Builds MAC LC Config
3268 * Function : BuildMacLCConfig
3270 * Functionality: Builds MAC LC Config in BuildRlcBearerToAddModList
3272 * @params[in] struct LogicalChannelConfig macLcConfig
3274 * @return ROK - success
3277 * ****************************************************************/
3278 uint8_t BuildMacLCConfig(struct LogicalChannelConfig *macLcConfig)
3281 macLcConfig->ul_SpecificParameters = NULLP;
3282 DU_ALLOC(macLcConfig->ul_SpecificParameters, sizeof(struct LogicalChannelConfig__ul_SpecificParameters));
3283 if(!macLcConfig->ul_SpecificParameters)
3285 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacLCConfig");
3289 macLcConfig->ul_SpecificParameters->priority = MAC_LC_PRIORITY;
3290 macLcConfig->ul_SpecificParameters->prioritisedBitRate = PRIORTISIED_BIT_RATE;
3291 macLcConfig->ul_SpecificParameters->bucketSizeDuration = BUCKET_SIZE_DURATION;
3292 macLcConfig->ul_SpecificParameters->allowedServingCells = NULLP;
3293 macLcConfig->ul_SpecificParameters->allowedSCS_List = NULLP;
3294 macLcConfig->ul_SpecificParameters->maxPUSCH_Duration = NULLP;
3295 macLcConfig->ul_SpecificParameters->configuredGrantType1Allowed = NULLP;
3297 macLcConfig->ul_SpecificParameters->logicalChannelGroup = NULLP;
3298 DU_ALLOC(macLcConfig->ul_SpecificParameters->logicalChannelGroup, sizeof(long));
3299 if(!macLcConfig->ul_SpecificParameters->logicalChannelGroup)
3301 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacLCConfig");
3304 *(macLcConfig->ul_SpecificParameters->logicalChannelGroup) = LC_GRP;
3306 macLcConfig->ul_SpecificParameters->schedulingRequestID = NULLP;
3307 DU_ALLOC(macLcConfig->ul_SpecificParameters->schedulingRequestID, sizeof(SchedulingRequestId_t));
3308 if(!macLcConfig->ul_SpecificParameters->schedulingRequestID)
3310 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacLCConfig");
3313 *(macLcConfig->ul_SpecificParameters->schedulingRequestID) = SCH_REQ_ID;
3315 macLcConfig->ul_SpecificParameters->logicalChannelSR_Mask = false;
3316 macLcConfig->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = false;
3317 macLcConfig->ul_SpecificParameters->bitRateQueryProhibitTimer = NULLP;
3322 /*******************************************************************
3324 * @brief Builds RLC Bearer to Add/Mod list
3328 * Function :BuildRlcBearerToAddModList
3330 * Functionality: Builds RLC Bearer to Add/Mod list in DuToCuRrcContainer
3332 * @params[in] rlc_BearerToAddModList
3334 * @return ROK - success
3337 * ****************************************************************/
3338 uint8_t BuildRlcBearerToAddModList(struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList)
3340 uint8_t idx, elementCnt;
3343 rlcBearerList->list.count = elementCnt;
3344 rlcBearerList->list.size = elementCnt * sizeof(struct RLC_BearerConfig *);
3346 rlcBearerList->list.array = NULLP;
3347 DU_ALLOC(rlcBearerList->list.array, rlcBearerList->list.size);
3348 if(!rlcBearerList->list.array)
3350 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3354 for(idx=0; idx<rlcBearerList->list.count; idx++)
3356 rlcBearerList->list.array[idx] = NULLP;
3357 DU_ALLOC(rlcBearerList->list.array[idx], sizeof(struct RLC_BearerConfig));
3358 if(!rlcBearerList->list.array[idx])
3360 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3366 rlcBearerList->list.array[idx]->logicalChannelIdentity = SRB1_LCID;
3368 DU_ALLOC(rlcBearerList->list.array[idx]->servedRadioBearer, \
3369 sizeof(struct RLC_BearerConfig__servedRadioBearer));
3370 if(!rlcBearerList->list.array[idx]->servedRadioBearer)
3372 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3376 rlcBearerList->list.array[idx]->servedRadioBearer->present = \
3377 RLC_BearerConfig__servedRadioBearer_PR_srb_Identity;
3378 rlcBearerList->list.array[idx]->servedRadioBearer->choice.srb_Identity = \
3381 rlcBearerList->list.array[idx]->reestablishRLC = NULLP;
3382 rlcBearerList->list.array[idx]->rlc_Config = NULLP;
3383 DU_ALLOC(rlcBearerList->list.array[idx]->rlc_Config, sizeof(struct RLC_Config));
3384 if(!rlcBearerList->list.array[idx]->rlc_Config)
3386 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3390 if(BuildRlcConfig(rlcBearerList->list.array[idx]->rlc_Config) != ROK)
3392 DU_LOG("\nERROR --> F1AP : BuildRlcConfig failed");
3396 rlcBearerList->list.array[idx]->mac_LogicalChannelConfig = NULLP;
3397 DU_ALLOC(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig, \
3398 sizeof(struct LogicalChannelConfig));
3399 if(!rlcBearerList->list.array[idx]->mac_LogicalChannelConfig)
3401 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3405 if(BuildMacLCConfig(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig) != ROK)
3407 DU_LOG("\nERROR --> F1AP : BuildMacLCConfig failed");
3414 /*******************************************************************
3416 * @brief Build Control resource set to add/modify list
3420 * Function : BuildControlRSetToAddModList
3422 * Functionality: Build Control resource set to add/modify list
3425 * struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList
3427 * @return ROK - success
3430 * ****************************************************************/
3431 uint8_t BuildControlRSetToAddModList
3433 struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList
3438 uint8_t numBytes, bitsUnused;
3439 struct ControlResourceSet *controlRSet;
3440 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
3441 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
3445 controlRSetList->list.count = elementCnt;
3446 controlRSetList->list.size = \
3447 elementCnt * sizeof(struct ControlResourceSet *);
3449 controlRSetList->list.array = NULLP;
3450 DU_ALLOC(controlRSetList->list.array, controlRSetList->list.size);
3451 if(!controlRSetList->list.array)
3453 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3457 for(idx = 0; idx < elementCnt; idx++)
3459 controlRSetList->list.array[idx] = NULLP;
3460 DU_ALLOC(controlRSetList->list.array[idx], sizeof(struct ControlResourceSet));
3461 if(!controlRSetList->list.array[idx])
3463 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3469 controlRSet = controlRSetList->list.array[idx];
3471 controlRSet->controlResourceSetId = PDCCH_CTRL_RSRC_SET_ONE_ID;
3475 * Bit string stored ff0000000000
3479 controlRSet->frequencyDomainResources.size = numBytes * sizeof(uint8_t);
3481 controlRSet->frequencyDomainResources.buf = NULLP;
3482 DU_ALLOC(controlRSet->frequencyDomainResources.buf, \
3483 controlRSet->frequencyDomainResources.size);
3484 if(!controlRSet->frequencyDomainResources.buf)
3486 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3490 memset(controlRSet->frequencyDomainResources.buf, 0, FREQ_DOM_RSRC_SIZE);
3491 coreset0EndPrb = CORESET0_END_PRB;
3492 coreset1StartPrb = coreset0EndPrb + 6;
3493 coreset1NumPrb = CORESET1_NUM_PRB;
3494 /* calculate the PRBs */
3495 freqDomRscAllocType0(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
3496 memcpy(controlRSet->frequencyDomainResources.buf, freqDomainResource, FREQ_DOM_RSRC_SIZE);
3497 controlRSet->frequencyDomainResources.bits_unused = bitsUnused;
3499 controlRSet->duration = PDCCH_CTRL_RSRC_SET_ONE_DURATION;
3500 controlRSet->cce_REG_MappingType.present = \
3501 ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved;
3503 controlRSet->precoderGranularity = PDCCH_CTRL_RSRC_SET_ONE_PRECOD_GRANULARITY;
3504 controlRSet->tci_StatesPDCCH_ToAddList = NULLP;
3505 controlRSet->tci_StatesPDCCH_ToReleaseList = NULLP;
3506 controlRSet->tci_PresentInDCI = NULLP;
3508 uint8_t tciStateIdx;
3510 DU_ALLOC(controlRset->tci_StatesPDCCH_ToAddList, \
3511 sizeof(struct ControlResourceSet__tci_StatesPDCCH_ToAddList));
3512 if(!controlRset->tci_StatesPDCCH_ToAddList)
3514 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3519 controlRset->tci_StatesPDCCH_ToAddList->list.count = elementCnt;
3520 controlRset->tci_StatesPDCCH_ToAddList->list.size = elementCnt * sizeof(TCI_StateId_t *);
3521 DU_ALLOC(controlRset->tci_StatesPDCCH_ToAddList->list.array, \
3522 controlRset->tci_StatesPDCCH_ToAddList->list.size)
3523 if(!controlRset->tci_StatesPDCCH_ToAddList->list.array)
3525 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3529 for(tciStateIdx = 0; tciStateIdx <elementCntl; tciStateIdx++)
3531 DU_ALLOC(controlRset->tci_StatesPDCCH_ToAddList->list.array[tciStateIdx], sizeof(TCI_StateId_t));
3532 if(!controlRset->tci_StatesPDCCH_ToAddList->list.array[tciStateIdx])
3534 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3541 *(controlRset->tci_StatesPDCCH_ToAddList->list.array[tciStateIdx]);
3543 DU_ALLOC(controlRset->tci_PresentInDCI, sizeof(long));
3544 if(!controlRset->tci_PresentInDCI)
3546 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3550 *(controlRset->tci_PresentInDCI);
3553 controlRSet->pdcch_DMRS_ScramblingID = NULLP;
3554 DU_ALLOC(controlRSet->pdcch_DMRS_ScramblingID, sizeof(long));
3555 if(!controlRSet->pdcch_DMRS_ScramblingID)
3557 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3560 *(controlRSet->pdcch_DMRS_ScramblingID) = SCRAMBLING_ID;
3563 } /* End BuildControlRSetToAddModList */
3565 /*******************************************************************
3567 * @brief Build search space to add/modify list
3571 * Function : BuildSearchSpcToAddModList
3573 * Functionality: Build search space to add/modify list
3576 * @return ROK - success
3579 * ****************************************************************/
3580 uint8_t BuildSearchSpcToAddModList
3582 struct PDCCH_Config__searchSpacesToAddModList *searchSpcList
3590 struct SearchSpace *searchSpc;
3593 searchSpcList->list.count = elementCnt;
3594 searchSpcList->list.size = elementCnt * sizeof(struct SearchSpace *);
3596 searchSpcList->list.array = NULLP;
3597 DU_ALLOC(searchSpcList->list.array, searchSpcList->list.size);
3598 if(!searchSpcList->list.array)
3600 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3604 for(idx = 0; idx < elementCnt; idx++)
3606 searchSpcList->list.array[idx] = NULLP;
3607 DU_ALLOC(searchSpcList->list.array[idx], sizeof(struct SearchSpace));
3608 if(!searchSpcList->list.array[idx])
3610 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3616 searchSpc = searchSpcList->list.array[idx];
3618 searchSpc->searchSpaceId = PDCCH_SRCH_SPC_TWO_ID;
3620 searchSpc->controlResourceSetId = NULLP;
3621 DU_ALLOC(searchSpc->controlResourceSetId, sizeof(ControlResourceSetId_t));
3622 if(!searchSpc->controlResourceSetId)
3624 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3627 *(searchSpc->controlResourceSetId) = PDCCH_CTRL_RSRC_SET_ONE_ID;
3629 searchSpc->monitoringSlotPeriodicityAndOffset = NULLP;
3630 DU_ALLOC(searchSpc->monitoringSlotPeriodicityAndOffset, \
3631 sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
3632 if(!searchSpc->monitoringSlotPeriodicityAndOffset)
3634 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3637 searchSpc->monitoringSlotPeriodicityAndOffset->present = \
3638 SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
3640 searchSpc->duration = NULLP;
3641 searchSpc->monitoringSymbolsWithinSlot = NULLP;
3642 DU_ALLOC(searchSpc->monitoringSymbolsWithinSlot, sizeof(BIT_STRING_t));
3643 if(!searchSpc->monitoringSymbolsWithinSlot)
3645 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3649 /* Values taken from reference logs :
3652 * Bit string stores 8000
3657 searchSpc->monitoringSymbolsWithinSlot->size = numBytes * sizeof(uint8_t);
3658 searchSpc->monitoringSymbolsWithinSlot->buf = NULLP;
3659 DU_ALLOC(searchSpc->monitoringSymbolsWithinSlot->buf, \
3660 searchSpc->monitoringSymbolsWithinSlot->size);
3661 if(!searchSpc->monitoringSymbolsWithinSlot->buf)
3663 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3668 searchSpc->monitoringSymbolsWithinSlot->buf[byteIdx++] = \
3669 PDCCH_SYMBOL_WITHIN_SLOT /* setting MSB to 128 i.e. 0x80 */;
3670 searchSpc->monitoringSymbolsWithinSlot->buf[byteIdx++] = 0;
3671 searchSpc->monitoringSymbolsWithinSlot->bits_unused = bitsUnused;
3673 searchSpc->nrofCandidates = NULLP;
3674 DU_ALLOC(searchSpc->nrofCandidates, sizeof(struct SearchSpace__nrofCandidates));
3675 if(!searchSpc->nrofCandidates)
3677 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3681 searchSpc->nrofCandidates->aggregationLevel1 = \
3682 PDCCH_SRCH_SPC_TWO_AGG_LVL1_CANDIDATE;
3683 searchSpc->nrofCandidates->aggregationLevel2 = \
3684 PDCCH_SRCH_SPC_TWO_AGG_LVL2_CANDIDATE;
3685 searchSpc->nrofCandidates->aggregationLevel4 = \
3686 PDCCH_SRCH_SPC_TWO_AGG_LVL4_CANDIDATE;
3687 searchSpc->nrofCandidates->aggregationLevel8 = \
3688 PDCCH_SRCH_SPC_TWO_AGG_LVL8_CANDIDATE;
3689 searchSpc->nrofCandidates->aggregationLevel16 = \
3690 PDCCH_SRCH_SPC_TWO_AGG_LVL16_CANDIDATE;
3692 searchSpc->searchSpaceType = NULLP;
3693 DU_ALLOC(searchSpc->searchSpaceType, sizeof(struct SearchSpace__searchSpaceType));
3694 if(!searchSpc->searchSpaceType)
3696 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3700 searchSpc->searchSpaceType->present = SearchSpace__searchSpaceType_PR_ue_Specific;
3702 searchSpc->searchSpaceType->choice.ue_Specific = NULLP;
3703 DU_ALLOC(searchSpc->searchSpaceType->choice.ue_Specific, \
3704 sizeof(struct SearchSpace__searchSpaceType__ue_Specific));
3705 if(!searchSpc->searchSpaceType->choice.ue_Specific)
3707 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3710 searchSpc->searchSpaceType->choice.ue_Specific->dci_Formats = \
3711 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
3714 }/* End BuildSearchSpcToAddModList */
3716 /*******************************************************************
3718 * @brief Builds BWP DL dedicated PDCCH config
3722 * Function : BuildBWPDlDedPdcchCfg
3724 * Functionality: Builds BWP DL dedicated PDCCH config
3726 * @params[in] struct PDCCH_Config *pdcchCfg
3728 * @return ROK - success
3731 * ****************************************************************/
3732 uint8_t BuildBWPDlDedPdcchCfg(struct PDCCH_Config *pdcchCfg)
3734 pdcchCfg->controlResourceSetToAddModList = NULLP;
3735 DU_ALLOC(pdcchCfg->controlResourceSetToAddModList, \
3736 sizeof(struct PDCCH_Config__controlResourceSetToAddModList));
3737 if(!pdcchCfg->controlResourceSetToAddModList)
3739 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdcchCfg");
3743 if(BuildControlRSetToAddModList(pdcchCfg->controlResourceSetToAddModList) != ROK)
3748 pdcchCfg->controlResourceSetToReleaseList = NULLP;
3750 pdcchCfg->searchSpacesToAddModList = NULLP;
3751 DU_ALLOC(pdcchCfg->searchSpacesToAddModList, \
3752 sizeof(struct PDCCH_Config__searchSpacesToAddModList));
3753 if(!pdcchCfg->searchSpacesToAddModList)
3755 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdcchCfg");
3759 if(BuildSearchSpcToAddModList(pdcchCfg->searchSpacesToAddModList) != ROK)
3764 pdcchCfg->searchSpacesToReleaseList = NULLP;
3765 pdcchCfg->downlinkPreemption = NULLP;
3766 pdcchCfg->tpc_PUSCH = NULLP;
3767 pdcchCfg->tpc_PUCCH = NULLP;
3768 pdcchCfg->tpc_SRS = NULLP;
3773 /*******************************************************************
3775 * @brief Builds DMRS DL PDSCH Mapping type A
3779 * Function : BuildDMRSDLPdschMapTypeA
3781 * Functionality: Builds DMRS DL PDSCH Mapping type A
3784 * struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg
3785 * @return ROK - success
3788 * ****************************************************************/
3789 uint8_t BuildDMRSDLPdschMapTypeA
3791 struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg
3794 dmrsDlCfg->present = PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA_PR_setup;
3795 dmrsDlCfg->choice.setup = NULLP;
3796 DU_ALLOC(dmrsDlCfg->choice.setup, sizeof(struct DMRS_DownlinkConfig));
3797 if(!dmrsDlCfg->choice.setup)
3799 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
3803 dmrsDlCfg->choice.setup->dmrs_Type = NULLP;
3804 dmrsDlCfg->choice.setup->dmrs_AdditionalPosition = NULLP;
3805 DU_ALLOC(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition, sizeof(long));
3806 if(!dmrsDlCfg->choice.setup->dmrs_AdditionalPosition)
3808 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSDLPdschMapTypeA");
3811 *(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition) = DMRS_ADDITIONAL_POS;
3813 dmrsDlCfg->choice.setup->maxLength = NULLP;
3814 dmrsDlCfg->choice.setup->scramblingID0 = NULLP;
3815 dmrsDlCfg->choice.setup->scramblingID1 = NULLP;
3816 dmrsDlCfg->choice.setup->phaseTrackingRS = NULLP;
3821 /*******************************************************************
3823 * @brief Builds TCI states to add/modify list
3827 * Function : BuildTCIStatesToAddModList
3829 * Functionality:Builds TCI states to add/modify list
3832 * struct PDSCH_Config__tci_StatesToAddModList *tciStatesList
3834 * @return ROK - success
3837 * ****************************************************************/
3838 uint8_t BuildTCIStatesToAddModList(struct PDSCH_Config__tci_StatesToAddModList *tciStatesList)
3843 /*******************************************************************
3845 * @brief Builds PDSCH time domain allocation list
3849 * Function : BuildPdschTimeDomAllocList
3851 * Functionality: Builds PDSCH time domain allocation list
3854 * struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
3856 * @return ROK - success
3859 * ****************************************************************/
3860 uint8_t BuildPdschTimeDomAllocList
3862 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
3867 struct PDSCH_TimeDomainResourceAllocation *timeDomAlloc;
3869 timeDomAllocList->present = \
3870 PDSCH_Config__pdsch_TimeDomainAllocationList_PR_setup;
3872 timeDomAllocList->choice.setup = NULLP;
3873 DU_ALLOC(timeDomAllocList->choice.setup, \
3874 sizeof(struct PDSCH_TimeDomainResourceAllocationList));
3875 if(!timeDomAllocList->choice.setup)
3877 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
3882 timeDomAllocList->choice.setup->list.count = elementCnt;
3883 timeDomAllocList->choice.setup->list.size = \
3884 elementCnt * sizeof(struct PDSCH_TimeDomainResourceAllocation *);
3886 timeDomAllocList->choice.setup->list.array = NULLP;
3887 DU_ALLOC(timeDomAllocList->choice.setup->list.array, \
3888 timeDomAllocList->choice.setup->list.size);
3889 if(!timeDomAllocList->choice.setup->list.array)
3891 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
3895 for(idx = 0; idx < elementCnt; idx++)
3897 timeDomAllocList->choice.setup->list.array[idx] = NULLP;
3898 DU_ALLOC(timeDomAllocList->choice.setup->list.array[idx], \
3899 sizeof(struct PDSCH_TimeDomainResourceAllocation));
3900 if(!timeDomAllocList->choice.setup->list.array[idx])
3902 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
3908 timeDomAlloc = timeDomAllocList->choice.setup->list.array[idx];
3910 timeDomAlloc->k0 = NULLP;
3911 timeDomAlloc->mappingType = PDSCH_MAPPING_TYPE_A;
3912 timeDomAlloc->startSymbolAndLength = \
3913 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
3918 /*******************************************************************
3920 * @brief Builds PDSCH PRB Bundling type
3924 * Function : BuildPdschPrbBundlingType
3926 * Functionality: Builds PDSCH PRB Bundling type
3929 * struct PDSCH_Config__prb_BundlingType *prbBndlType
3931 * @return ROK - success
3934 * ****************************************************************/
3935 uint8_t BuildPdschPrbBundlingType
3937 struct PDSCH_Config__prb_BundlingType *prbBndlType
3940 prbBndlType->present = PDSCH_Config__prb_BundlingType_PR_staticBundling;
3942 prbBndlType->choice.staticBundling = NULLP;
3943 DU_ALLOC(prbBndlType->choice.staticBundling, \
3944 sizeof(struct PDSCH_Config__prb_BundlingType__staticBundling));
3945 if(!prbBndlType->choice.staticBundling)
3947 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschPrbBundlingType");
3950 prbBndlType->choice.staticBundling->bundleSize = NULLP;
3955 /*******************************************************************
3957 * @brief Builds BWP DL dedicated PDSCH config
3961 * Function : BuildBWPDlDedPdschCfg
3963 * Functionality: Builds BWP DL dedicated PDSCH config
3965 * @params[in] struct PDSCH_Config *pdschCfg
3967 * @return ROK - success
3970 * ****************************************************************/
3971 uint8_t BuildBWPDlDedPdschCfg(struct PDSCH_Config *pdschCfg)
3973 pdschCfg->dataScramblingIdentityPDSCH = NULLP;
3975 pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA = NULLP;
3976 DU_ALLOC(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA, \
3977 sizeof(struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA));
3978 if(!pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
3980 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
3984 if(BuildDMRSDLPdschMapTypeA(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA) != ROK)
3989 pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeB = NULLP;
3990 pdschCfg->tci_StatesToAddModList = NULLP;
3991 pdschCfg->tci_StatesToReleaseList = NULLP;
3992 pdschCfg->vrb_ToPRB_Interleaver = NULLP;
3994 DU_ALLOC(pdschCfg->tci_StatesToAddModList, sizeof(struct PDSCH_Config__tci_StatesToAddModList));
3995 if(!pdschCfg->tci_StatesToAddModList)
3997 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
4000 if(BuildTCIStatesToAddModList(pdschCfg->tci_StatesToAddModList) != ROK)
4006 pdschCfg->resourceAllocation = RES_ALLOC_TYPE;
4008 pdschCfg->pdsch_TimeDomainAllocationList = NULLP;
4009 DU_ALLOC(pdschCfg->pdsch_TimeDomainAllocationList, \
4010 sizeof(struct PDSCH_Config__pdsch_TimeDomainAllocationList));
4011 if(!pdschCfg->pdsch_TimeDomainAllocationList)
4013 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
4017 if(BuildPdschTimeDomAllocList(pdschCfg->pdsch_TimeDomainAllocationList) != ROK)
4022 pdschCfg->pdsch_AggregationFactor = NULLP;
4023 pdschCfg->rateMatchPatternToAddModList = NULLP;
4024 pdschCfg->rateMatchPatternToReleaseList = NULLP;
4025 pdschCfg->rateMatchPatternGroup1 = NULLP;
4026 pdschCfg->rateMatchPatternGroup2 = NULLP;
4027 pdschCfg->rbg_Size = PDSCH_RBG_SIZE;
4028 pdschCfg->mcs_Table = NULLP;
4030 pdschCfg->maxNrofCodeWordsScheduledByDCI = NULLP;
4031 DU_ALLOC(pdschCfg->maxNrofCodeWordsScheduledByDCI, sizeof(long));
4032 if(!pdschCfg->maxNrofCodeWordsScheduledByDCI)
4034 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
4037 *(pdschCfg->maxNrofCodeWordsScheduledByDCI) = PDSCH_MAX_CODEWORD_SCH_BY_DCI;
4039 if(BuildPdschPrbBundlingType(&pdschCfg->prb_BundlingType) != ROK)
4044 pdschCfg->zp_CSI_RS_ResourceToAddModList = NULLP;
4045 pdschCfg->zp_CSI_RS_ResourceToReleaseList = NULLP;
4046 pdschCfg->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList = NULLP;
4047 pdschCfg->aperiodic_ZP_CSI_RS_ResourceSetsToReleaseList = NULLP;
4048 pdschCfg->sp_ZP_CSI_RS_ResourceSetsToAddModList = NULLP;
4049 pdschCfg->sp_ZP_CSI_RS_ResourceSetsToReleaseList = NULLP;
4050 pdschCfg->p_ZP_CSI_RS_ResourceSet = NULLP;
4055 /*******************************************************************
4057 * @brief Builds intitial DL BWP
4060 * Function : BuildInitialDlBWP
4062 * Functionality: Builds intitial DL BWP in spCellCfgDed
4064 * @params[in] BWP_DownlinkDedicated_t *dlBwp
4066 * @return ROK - success
4069 * ****************************************************************/
4070 uint8_t BuildInitialDlBWP(BWP_DownlinkDedicated_t *dlBwp)
4072 dlBwp->pdcch_Config = NULLP;
4073 DU_ALLOC(dlBwp->pdcch_Config, sizeof(struct BWP_DownlinkDedicated__pdcch_Config));
4074 if(!dlBwp->pdcch_Config)
4076 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
4079 dlBwp->pdcch_Config->present = BWP_DownlinkDedicated__pdcch_Config_PR_setup;
4081 dlBwp->pdcch_Config->choice.setup = NULLP;
4082 DU_ALLOC(dlBwp->pdcch_Config->choice.setup, sizeof(struct PDCCH_Config));
4083 if(!dlBwp->pdcch_Config->choice.setup)
4085 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
4088 if(BuildBWPDlDedPdcchCfg(dlBwp->pdcch_Config->choice.setup) != ROK)
4093 dlBwp->pdsch_Config = NULLP;
4094 DU_ALLOC(dlBwp->pdsch_Config, sizeof(struct BWP_DownlinkDedicated__pdsch_Config));
4095 if(!dlBwp->pdsch_Config)
4097 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
4100 dlBwp->pdsch_Config->present = BWP_DownlinkDedicated__pdsch_Config_PR_setup;
4102 dlBwp->pdsch_Config->choice.setup = NULLP;
4103 DU_ALLOC(dlBwp->pdsch_Config->choice.setup, sizeof(struct PDSCH_Config));
4104 if(!dlBwp->pdsch_Config->choice.setup)
4106 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
4110 if(BuildBWPDlDedPdschCfg(dlBwp->pdsch_Config->choice.setup) != ROK)
4115 dlBwp->sps_Config = NULLP;
4116 dlBwp->radioLinkMonitoringConfig = NULLP;
4120 /*******************************************************************
4122 * @brief Builds DMRS UL Pusch Mapping type A
4126 * Function : BuildDMRSULPuschMapTypeA
4128 * Functionality: Builds DMRS UL Pusch Mapping type A
4131 * struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg
4132 * @return ROK - success
4135 * ****************************************************************/
4136 uint8_t BuildDMRSULPuschMapTypeA
4138 struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg
4141 dmrsUlCfg->present = PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA_PR_setup;
4142 dmrsUlCfg->choice.setup= NULLP;
4143 DU_ALLOC(dmrsUlCfg->choice.setup, sizeof(DMRS_UplinkConfig_t));
4144 if(!dmrsUlCfg->choice.setup)
4146 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4150 dmrsUlCfg->choice.setup->dmrs_Type = NULLP;
4151 dmrsUlCfg->choice.setup->dmrs_AdditionalPosition = NULLP;
4152 DU_ALLOC(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition, sizeof(long));
4153 if(!dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
4155 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4158 *(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition) = DMRS_ADDITIONAL_POS;
4160 dmrsUlCfg->choice.setup->phaseTrackingRS = NULLP;
4161 dmrsUlCfg->choice.setup->maxLength = NULLP;
4162 dmrsUlCfg->choice.setup->transformPrecodingDisabled = NULLP;
4163 DU_ALLOC(dmrsUlCfg->choice.setup->transformPrecodingDisabled, \
4164 sizeof(struct DMRS_UplinkConfig__transformPrecodingDisabled));
4165 if(!dmrsUlCfg->choice.setup->transformPrecodingDisabled)
4167 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4171 dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0 = NULLP;
4172 DU_ALLOC(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0,\
4174 if(!dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0)
4176 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4179 *(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0) = SCRAMBLING_ID;
4181 dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID1 = NULLP;
4182 dmrsUlCfg->choice.setup->transformPrecodingEnabled = NULLP;
4186 /*******************************************************************
4188 * @brief Build PUSCH time domain allocation list
4192 * Function : BuildPuschTimeDomAllocList
4194 * Functionality: Build PUSCH time domain allocation list
4197 * struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList
4199 * @return ROK - success
4202 * ****************************************************************/
4203 uint8_t BuildPuschTimeDomAllocList
4205 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList
4210 PUSCH_TimeDomainResourceAllocation_t *timeDomAlloc;
4212 timeDomAllocList->present = PUSCH_Config__pusch_TimeDomainAllocationList_PR_setup;
4213 timeDomAllocList->choice.setup = NULLP;
4214 DU_ALLOC(timeDomAllocList->choice.setup, \
4215 sizeof(struct PUSCH_TimeDomainResourceAllocationList));
4216 if(!timeDomAllocList->choice.setup)
4218 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4223 timeDomAllocList->choice.setup->list.count = elementCnt;
4224 timeDomAllocList->choice.setup->list.size = \
4225 elementCnt * sizeof(PUSCH_TimeDomainResourceAllocation_t *);
4226 timeDomAllocList->choice.setup->list.array = NULLP;
4227 DU_ALLOC(timeDomAllocList->choice.setup->list.array, \
4228 timeDomAllocList->choice.setup->list.size);
4229 if(!timeDomAllocList->choice.setup->list.array)
4231 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4235 for(idx = 0; idx < elementCnt; idx++)
4237 timeDomAllocList->choice.setup->list.array[idx] = NULLP;
4238 DU_ALLOC(timeDomAllocList->choice.setup->list.array[idx],\
4239 sizeof(PUSCH_TimeDomainResourceAllocation_t));
4240 if(!timeDomAllocList->choice.setup->list.array[idx])
4242 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4248 timeDomAlloc = timeDomAllocList->choice.setup->list.array[idx];
4249 DU_ALLOC(timeDomAlloc->k2, sizeof(long));
4250 if(!timeDomAlloc->k2)
4252 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4255 *(timeDomAlloc->k2) = PUSCH_K2;
4256 timeDomAlloc->mappingType = PUSCH_MAPPING_TYPE_A;
4257 timeDomAlloc->startSymbolAndLength = calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
4261 /*******************************************************************
4263 * @brief Builds BWP UL dedicated PUSCH Config
4267 * Function : BuildBWPUlDedPuschCfg
4270 * Builds BWP UL dedicated PUSCH Config
4272 * @params[in] : PUSCH_Config_t *puschCfg
4274 * @return ROK - success
4277 * ****************************************************************/
4278 uint8_t BuildBWPUlDedPuschCfg(PUSCH_Config_t *puschCfg)
4280 puschCfg->dataScramblingIdentityPUSCH = NULLP;
4281 DU_ALLOC(puschCfg->dataScramblingIdentityPUSCH, sizeof(long));
4282 if(!puschCfg->dataScramblingIdentityPUSCH)
4284 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4287 *(puschCfg->dataScramblingIdentityPUSCH) = SCRAMBLING_ID;
4289 puschCfg->txConfig = NULLP;
4290 puschCfg->dmrs_UplinkForPUSCH_MappingTypeA = NULLP;
4291 DU_ALLOC(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA, \
4292 sizeof(struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA));
4293 if(!puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
4295 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4299 if(BuildDMRSULPuschMapTypeA(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA) != ROK)
4304 puschCfg->dmrs_UplinkForPUSCH_MappingTypeB = NULLP;
4305 puschCfg->pusch_PowerControl = NULLP;
4306 puschCfg->frequencyHopping = NULLP;
4307 puschCfg->frequencyHoppingOffsetLists = NULLP;
4308 puschCfg->resourceAllocation = RES_ALLOC_TYPE;
4310 puschCfg->pusch_TimeDomainAllocationList = NULLP;
4311 DU_ALLOC(puschCfg->pusch_TimeDomainAllocationList, \
4312 sizeof(struct PUSCH_Config__pusch_TimeDomainAllocationList));
4313 if(!puschCfg->pusch_TimeDomainAllocationList)
4315 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4319 if(BuildPuschTimeDomAllocList(puschCfg->pusch_TimeDomainAllocationList) != ROK)
4324 puschCfg->pusch_AggregationFactor = NULLP;
4325 puschCfg->mcs_Table = NULLP;
4326 puschCfg->mcs_TableTransformPrecoder = NULLP;
4327 puschCfg->transformPrecoder = NULLP;
4328 DU_ALLOC(puschCfg->transformPrecoder, sizeof(long));
4329 if(!puschCfg->transformPrecoder)
4331 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4334 *(puschCfg->transformPrecoder) = PUSCH_TRANSFORM_PRECODER;
4336 puschCfg->codebookSubset = NULLP;
4337 puschCfg->maxRank = NULLP;
4338 puschCfg->rbg_Size = NULLP;
4339 puschCfg->uci_OnPUSCH = NULLP;
4340 puschCfg->tp_pi2BPSK = NULLP;
4345 /*******************************************************************
4347 * @brief Fills SRS resource to add/modify list
4351 * Function : BuildSrsRsrcAddModList
4353 * Functionality: Fills SRS resource to add/modify list
4356 * @return ROK - success
4359 * ****************************************************************/
4360 uint8_t BuildSrsRsrcAddModList(struct SRS_Config__srs_ResourceToAddModList *resourceList)
4366 resourceList->list.count = elementCnt;
4367 resourceList->list.size = elementCnt * sizeof(SRS_Resource_t *);
4368 resourceList->list.array = NULLP;
4369 DU_ALLOC(resourceList->list.array, resourceList->list.size);
4370 if(!resourceList->list.array)
4372 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
4376 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
4378 DU_ALLOC(resourceList->list.array[rsrcIdx], sizeof(SRS_Resource_t));
4379 if(!resourceList->list.array[rsrcIdx])
4381 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
4387 resourceList->list.array[rsrcIdx]->srs_ResourceId = SRS_RSRC_ID;
4388 resourceList->list.array[rsrcIdx]->nrofSRS_Ports = SRS_Resource__nrofSRS_Ports_port1;
4389 resourceList->list.array[rsrcIdx]->transmissionComb.present = SRS_Resource__transmissionComb_PR_n2;
4391 resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2 = NULLP;
4392 DU_ALLOC(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2, \
4393 sizeof(struct SRS_Resource__transmissionComb__n2));
4394 if(!resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2)
4396 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
4399 resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2->combOffset_n2\
4400 = SRS_COMB_OFFSET_N2;
4401 resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2->cyclicShift_n2\
4402 = SRS_CYCLIC_SHIFT_N2;
4404 resourceList->list.array[rsrcIdx]->resourceMapping.startPosition = \
4406 resourceList->list.array[rsrcIdx]->resourceMapping.nrofSymbols = \
4407 SRS_Resource__resourceMapping__nrofSymbols_n1;
4408 resourceList->list.array[rsrcIdx]->resourceMapping.repetitionFactor = \
4409 SRS_Resource__resourceMapping__repetitionFactor_n1;
4411 resourceList->list.array[rsrcIdx]->freqDomainPosition = SRS_FREQ_DOM_POS;
4412 resourceList->list.array[rsrcIdx]->freqDomainShift = SRS_FREQ_DOM_SHIFT;
4413 resourceList->list.array[rsrcIdx]->freqHopping.c_SRS = C_SRS;
4414 resourceList->list.array[rsrcIdx]->freqHopping.b_SRS = B_SRS;
4415 resourceList->list.array[rsrcIdx]->freqHopping.b_hop = B_HOP;
4416 resourceList->list.array[rsrcIdx]->groupOrSequenceHopping = \
4417 SRS_Resource__groupOrSequenceHopping_neither;
4419 /* Setting resource type to aperiodic for intergration purposes */
4420 resourceList->list.array[rsrcIdx]->resourceType.present = \
4421 SRS_Resource__resourceType_PR_aperiodic;
4422 resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic = NULLP;
4423 DU_ALLOC(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic,
4424 sizeof(struct SRS_Resource__resourceType__aperiodic));
4425 if(!resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic)
4427 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
4430 resourceList->list.array[rsrcIdx]->sequenceId = SRS_SEQ_ID;
4435 /*******************************************************************
4437 * @brief Build SRS resource set Add/mod list
4441 * Function : BuildSrsRsrcSetAddModList
4443 * Functionality: Build SRS resource set Add/mod list
4446 * @return ROK - success
4449 * ****************************************************************/
4450 uint8_t BuildSrsRsrcSetAddModList
4452 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList
4458 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList;
4461 rsrcSetList->list.count = elementCnt;
4462 rsrcSetList->list.size = elementCnt * sizeof(SRS_ResourceSet_t *);
4463 rsrcSetList->list.array = NULLP;
4464 DU_ALLOC(rsrcSetList->list.array, rsrcSetList->list.size);
4465 if(!rsrcSetList->list.array)
4467 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4471 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
4473 DU_ALLOC(rsrcSetList->list.array[rSetIdx], sizeof(SRS_ResourceSet_t));
4474 if(!rsrcSetList->list.array[rSetIdx])
4476 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4482 rsrcSetList->list.array[rSetIdx]->srs_ResourceSetId = SRS_RSET_ID;
4484 /* Fill Resource Id list in resource set */
4485 rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList = NULLP;
4486 DU_ALLOC(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList,\
4487 sizeof(struct SRS_ResourceSet__srs_ResourceIdList));
4488 if(!rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
4490 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4495 rsrcIdList = rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
4496 rsrcIdList->list.count = elementCnt;
4497 rsrcIdList->list.size = elementCnt * sizeof(SRS_ResourceId_t *);
4498 rsrcIdList->list.array = NULLP;
4499 DU_ALLOC(rsrcIdList->list.array, rsrcIdList->list.size);
4500 if(!rsrcIdList->list.array)
4502 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4506 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count; rsrcIdx++)
4508 DU_ALLOC(rsrcIdList->list.array[rsrcIdx], sizeof(SRS_ResourceId_t));
4509 if(!rsrcIdList->list.array[rsrcIdx])
4511 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4517 *rsrcIdList->list.array[rsrcIdx] = SRS_RSRC_ID;
4519 /* Fill resource type */
4520 rsrcSetList->list.array[rSetIdx]->resourceType.present = \
4521 SRS_ResourceSet__resourceType_PR_aperiodic;
4523 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic = NULLP;
4524 DU_ALLOC(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic, \
4525 sizeof(struct SRS_ResourceSet__resourceType__aperiodic));
4526 if(!rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic)
4528 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4531 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic->aperiodicSRS_ResourceTrigger \
4532 = APERIODIC_SRS_RESRC_TRIGGER;
4534 /* TODO : Fill values for below IEs as expected by Viavi */
4535 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic->csi_RS = NULLP;
4536 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic->slotOffset = NULLP;
4539 rsrcSetList->list.array[rSetIdx]->usage = SRS_ResourceSet__usage_codebook;
4540 rsrcSetList->list.array[rSetIdx]->alpha = NULLP;
4541 rsrcSetList->list.array[rSetIdx]->p0 = NULLP;
4542 rsrcSetList->list.array[rSetIdx]->pathlossReferenceRS = NULLP;
4543 rsrcSetList->list.array[rSetIdx]->srs_PowerControlAdjustmentStates = NULLP;
4548 /*******************************************************************
4550 * @brief Builds BWP UL dedicated SRS Config
4554 * Function : BuildBWPUlDedSrsCfg
4556 * Functionality: Builds BWP UL dedicated SRS Config
4558 * @params[in] SRS Config
4559 * @return ROK - success
4562 * ****************************************************************/
4563 uint8_t BuildBWPUlDedSrsCfg(SRS_Config_t *srsCfg)
4565 srsCfg->srs_ResourceSetToReleaseList = NULLP;
4566 srsCfg->srs_ResourceSetToAddModList = NULLP;
4567 DU_ALLOC(srsCfg->srs_ResourceSetToAddModList, \
4568 sizeof(struct SRS_Config__srs_ResourceSetToAddModList));
4569 if(!srsCfg->srs_ResourceSetToAddModList)
4571 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedSrsCfg");
4574 if(BuildSrsRsrcSetAddModList(srsCfg->srs_ResourceSetToAddModList) != ROK)
4579 srsCfg->srs_ResourceToReleaseList = NULLP;
4581 /* Resource to Add/Modify list */
4582 srsCfg->srs_ResourceToAddModList = NULLP;
4583 DU_ALLOC(srsCfg->srs_ResourceToAddModList, \
4584 sizeof(struct SRS_Config__srs_ResourceToAddModList));
4585 if(!srsCfg->srs_ResourceToAddModList)
4587 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedSrsCfg");
4591 if(BuildSrsRsrcAddModList(srsCfg->srs_ResourceToAddModList) != ROK)
4596 srsCfg->tpc_Accumulation = NULLP;
4603 /*******************************************************************
4605 * @brief Builds Pusch Serving cell Config
4609 * Function : BuildPuschSrvCellCfg
4611 * Functionality: Builds Pusch Serving cell Config
4613 * @params[in] struct UplinkConfig__pusch_ServingCellConfig *puschCfg
4615 * @return ROK - success
4618 * ****************************************************************/
4619 uint8_t BuildPuschSrvCellCfg(struct UplinkConfig__pusch_ServingCellConfig *puschCfg)
4621 puschCfg->present = UplinkConfig__pusch_ServingCellConfig_PR_setup;
4622 puschCfg->choice.setup = NULLP;
4623 DU_ALLOC(puschCfg->choice.setup, sizeof(struct PUSCH_ServingCellConfig));
4624 if(!puschCfg->choice.setup)
4626 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
4630 puschCfg->choice.setup->codeBlockGroupTransmission = NULLP;
4631 puschCfg->choice.setup->rateMatching = NULLP;
4632 puschCfg->choice.setup->xOverhead = NULLP;
4633 puschCfg->choice.setup->ext1 = NULLP;
4634 DU_ALLOC(puschCfg->choice.setup->ext1, sizeof(struct PUSCH_ServingCellConfig__ext1));
4635 if(!puschCfg->choice.setup->ext1)
4637 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
4641 puschCfg->choice.setup->ext1->maxMIMO_Layers = NULLP;
4642 DU_ALLOC(puschCfg->choice.setup->ext1->maxMIMO_Layers, sizeof(long));
4643 if(!puschCfg->choice.setup->ext1->maxMIMO_Layers)
4645 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
4648 *(puschCfg->choice.setup->ext1->maxMIMO_Layers) = PUSCH_MAX_MIMO_LAYERS;
4650 puschCfg->choice.setup->ext1->processingType2Enabled= NULLP;
4651 DU_ALLOC(puschCfg->choice.setup->ext1->processingType2Enabled,sizeof(BOOLEAN_t));
4652 if(!puschCfg->choice.setup->ext1->processingType2Enabled)
4654 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
4657 *(puschCfg->choice.setup->ext1->processingType2Enabled) = PUSCH_PROCESS_TYPE2_ENABLED;
4661 /*******************************************************************
4663 * @brief Builds inital UL BWP
4667 * Function : BuildInitialUlBWP
4669 * Functionality: Builds initial UL BWP
4671 * @params[in] BWP_UplinkDedicated_t *ulBwp
4672 * @return ROK - success
4675 * ****************************************************************/
4676 uint8_t BuildInitialUlBWP(BWP_UplinkDedicated_t *ulBwp)
4678 ulBwp->pucch_Config = NULLP;
4680 /* Fill BWP UL dedicated PUSCH config */
4681 ulBwp->pusch_Config = NULLP;
4682 DU_ALLOC(ulBwp->pusch_Config, sizeof(struct BWP_UplinkDedicated__pusch_Config));
4683 if(!ulBwp->pusch_Config)
4685 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4689 ulBwp->pusch_Config->present = BWP_UplinkDedicated__pusch_Config_PR_setup;
4690 ulBwp->pusch_Config->choice.setup = NULLP;
4691 DU_ALLOC(ulBwp->pusch_Config->choice.setup, sizeof(PUSCH_Config_t));
4692 if(!ulBwp->pusch_Config->choice.setup)
4694 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4698 if(BuildBWPUlDedPuschCfg(ulBwp->pusch_Config->choice.setup) != ROK)
4703 ulBwp->configuredGrantConfig = NULLP;
4705 /* Fill BPW UL dedicated SRS config */
4706 ulBwp->srs_Config = NULLP;
4707 DU_ALLOC(ulBwp->srs_Config, sizeof(struct BWP_UplinkDedicated__srs_Config));
4708 if(!ulBwp->srs_Config)
4710 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4714 ulBwp->srs_Config->present = BWP_UplinkDedicated__srs_Config_PR_setup;
4715 ulBwp->srs_Config->choice.setup = NULLP;
4716 DU_ALLOC(ulBwp->srs_Config->choice.setup, sizeof(SRS_Config_t));
4717 if(!ulBwp->srs_Config->choice.setup)
4719 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4723 if(BuildBWPUlDedSrsCfg(ulBwp->srs_Config->choice.setup) != ROK)
4728 ulBwp->beamFailureRecoveryConfig = NULLP;
4733 /*******************************************************************
4735 * @brief Builds UL config
4738 * Function : BuildUlCfg
4740 * Functionality: Builds UL config in spCellCfgDed
4742 * @params[in] UplinkConfig_t *ulCfg
4744 * @return ROK - success
4747 * ****************************************************************/
4748 uint8_t BuildUlCfg(UplinkConfig_t *ulCfg)
4750 ulCfg->initialUplinkBWP = NULLP;
4751 DU_ALLOC(ulCfg->initialUplinkBWP, sizeof(BWP_UplinkDedicated_t));
4752 if(!ulCfg->initialUplinkBWP)
4754 DU_LOG("\nERROR --> F1AP : Memory Allocation failed in BuildUlCfg");
4758 if(BuildInitialUlBWP(ulCfg->initialUplinkBWP) != ROK)
4763 ulCfg->uplinkBWP_ToReleaseList = NULLP;
4764 ulCfg->uplinkBWP_ToAddModList = NULLP;
4765 ulCfg->firstActiveUplinkBWP_Id = NULLP;
4766 DU_ALLOC(ulCfg->firstActiveUplinkBWP_Id, sizeof(BWP_Id_t));
4767 if(!ulCfg->firstActiveUplinkBWP_Id)
4769 DU_LOG("\nERROR --> F1AP : Memory Allocation failed in BuildUlCfg");
4772 *(ulCfg->firstActiveUplinkBWP_Id) = ACTIVE_UL_BWP_ID;
4774 ulCfg->pusch_ServingCellConfig = NULLP;
4775 DU_ALLOC(ulCfg->pusch_ServingCellConfig, \
4776 sizeof(struct UplinkConfig__pusch_ServingCellConfig));
4777 if(!ulCfg->pusch_ServingCellConfig)
4779 DU_LOG("\nERROR --> F1AP : Memory Allocation failed in BuildUlCfg");
4783 if(BuildPuschSrvCellCfg(ulCfg->pusch_ServingCellConfig) != ROK)
4788 ulCfg->carrierSwitching = NULLP;
4789 ulCfg->ext1 = NULLP;
4793 /*******************************************************************
4795 * @brief Builds PDSCH serving cell config
4798 * Function : BuildPdschSrvCellCfg
4800 * Functionality: Builds PDSCH serving cell config in spCellCfgDed
4802 * @params[in] struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg
4804 * @return ROK - success
4807 * ****************************************************************/
4808 uint8_t BuildPdschSrvCellCfg(struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg)
4810 pdschCfg->present = ServingCellConfig__pdsch_ServingCellConfig_PR_setup;
4811 pdschCfg->choice.setup = NULLP;
4812 DU_ALLOC(pdschCfg->choice.setup, sizeof( struct PDSCH_ServingCellConfig));
4813 if(!pdschCfg->choice.setup)
4815 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
4819 pdschCfg->choice.setup->codeBlockGroupTransmission = NULLP;
4820 pdschCfg->choice.setup->xOverhead = NULLP;
4821 pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH = NULLP;
4822 DU_ALLOC(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH, sizeof(long));
4823 if(!pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH)
4825 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
4828 *(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH)= PDSCH_NUM_HARQ_PROC;
4829 pdschCfg->choice.setup->pucch_Cell = NULLP;
4830 pdschCfg->choice.setup->ext1 = NULLP;
4835 /*******************************************************************
4837 * @brief Builds CSI Meas config
4840 * Function : BuildCsiMeasCfg
4842 * Functionality: Builds CSI Meas config in spCellCfgDed
4844 * @params[in] struct ServingCellConfig__csi_MeasConfig *csiMeasCfg
4846 * @return ROK - success
4849 * ****************************************************************/
4850 uint8_t BuildCsiMeasCfg(struct ServingCellConfig__csi_MeasConfig *csiMeasCfg)
4856 /*******************************************************************
4858 * @brief Builds Spcell config dedicated
4861 * Function : BuildSpCellCfgDed
4863 * Functionality: Builds sp cell config dedicated in spCellCfg
4865 * @params[in] ServingCellConfig_t srvCellCfg
4867 * @return ROK - success
4870 * ****************************************************************/
4871 uint8_t BuildSpCellCfgDed(ServingCellConfig_t *srvCellCfg)
4873 srvCellCfg->tdd_UL_DL_ConfigurationDedicated = NULLP;
4874 DU_ALLOC(srvCellCfg->tdd_UL_DL_ConfigurationDedicated, sizeof(TDD_UL_DL_ConfigDedicated_t));
4875 if(!srvCellCfg->tdd_UL_DL_ConfigurationDedicated)
4877 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4881 srvCellCfg->initialDownlinkBWP = NULLP;
4882 DU_ALLOC(srvCellCfg->initialDownlinkBWP, sizeof(BWP_DownlinkDedicated_t));
4883 if(!srvCellCfg->initialDownlinkBWP)
4885 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4889 if(BuildInitialDlBWP(srvCellCfg->initialDownlinkBWP) != ROK)
4891 DU_LOG("\nERROR --> F1AP : BuildInitialDlBWP failed");
4894 srvCellCfg->downlinkBWP_ToReleaseList = NULLP;
4895 srvCellCfg->downlinkBWP_ToAddModList = NULLP;
4897 srvCellCfg->firstActiveDownlinkBWP_Id = NULLP;
4898 DU_ALLOC(srvCellCfg->firstActiveDownlinkBWP_Id, sizeof(long));
4899 if(!srvCellCfg->firstActiveDownlinkBWP_Id)
4901 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4904 *(srvCellCfg->firstActiveDownlinkBWP_Id) = ACTIVE_DL_BWP_ID;
4906 srvCellCfg->bwp_InactivityTimer = NULLP;
4908 srvCellCfg->defaultDownlinkBWP_Id = NULLP;
4909 DU_ALLOC(srvCellCfg->defaultDownlinkBWP_Id, sizeof(long));
4910 if(!srvCellCfg->defaultDownlinkBWP_Id)
4912 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4915 *(srvCellCfg->defaultDownlinkBWP_Id) = ACTIVE_DL_BWP_ID;
4917 srvCellCfg->uplinkConfig = NULLP;
4918 DU_ALLOC(srvCellCfg->uplinkConfig, sizeof(UplinkConfig_t));
4919 if(!srvCellCfg->uplinkConfig)
4921 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4925 if(BuildUlCfg(srvCellCfg->uplinkConfig) != ROK)
4927 DU_LOG("\nERROR --> F1AP : BuildUlCfg failed");
4930 srvCellCfg->supplementaryUplink = NULLP;
4931 srvCellCfg->pdcch_ServingCellConfig = NULLP;
4933 srvCellCfg->pdsch_ServingCellConfig = NULLP;
4934 DU_ALLOC(srvCellCfg->pdsch_ServingCellConfig, sizeof(struct ServingCellConfig__pdsch_ServingCellConfig));
4935 if(!srvCellCfg->pdsch_ServingCellConfig)
4937 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4941 if(BuildPdschSrvCellCfg(srvCellCfg->pdsch_ServingCellConfig) != ROK)
4943 DU_LOG("\nERROR --> F1AP : BuildPdschSrvCellCfg failed");
4947 srvCellCfg->csi_MeasConfig = NULLP;
4949 DU_ALLOC(srvCellCfg->csi_MeasConfig, sizeof(struct ServingCellConfig__csi_MeasConfig))
4950 if(!srvCellCfg->csi_MeasConfig)
4952 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4956 if(BuildCsiMeasCfg(srvCellCfg->csi_MeasConfig) != ROK)
4958 DU_LOG("\nF1AP : BuildCsiMeasCfg failed");
4962 srvCellCfg->sCellDeactivationTimer = NULLP;
4963 srvCellCfg->crossCarrierSchedulingConfig = NULLP;
4964 srvCellCfg->tag_Id = TAG_ID;
4965 srvCellCfg->dummy = NULLP;
4966 srvCellCfg->pathlossReferenceLinking = NULLP;
4967 srvCellCfg->servingCellMO = NULLP;
4968 srvCellCfg->ext1 = NULLP;
4972 /*******************************************************************
4974 * @brief Builds Spcell config
4978 * Function : BuildSpCellCfg
4980 * Functionality: Builds sp cell config in DuToCuRrcContainer
4982 * @params[in] SpCellConfig_t spCellCfg
4984 * @return ROK - success
4987 * ****************************************************************/
4988 uint8_t BuildSpCellCfg(SpCellConfig_t *spCellCfg)
4991 spCellCfg->servCellIndex = NULLP;
4992 DU_ALLOC(spCellCfg->servCellIndex, sizeof(long));
4993 if(!spCellCfg->servCellIndex)
4995 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
4998 *(spCellCfg->servCellIndex) = SERV_CELL_IDX;
5000 spCellCfg->reconfigurationWithSync = NULLP;
5001 spCellCfg->rlf_TimersAndConstants = NULLP;
5002 spCellCfg->rlmInSyncOutOfSyncThreshold = NULLP;
5003 DU_ALLOC(spCellCfg->rlmInSyncOutOfSyncThreshold, sizeof(long));
5004 if(!spCellCfg->rlmInSyncOutOfSyncThreshold)
5006 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
5009 *(spCellCfg->rlmInSyncOutOfSyncThreshold) = RLM_SYNC_OUT_SYNC_THRESHOLD;
5011 spCellCfg->spCellConfigDedicated = NULLP;
5012 DU_ALLOC(spCellCfg->spCellConfigDedicated, sizeof(ServingCellConfig_t));
5013 if(!spCellCfg->spCellConfigDedicated)
5015 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
5018 if(BuildSpCellCfgDed(spCellCfg->spCellConfigDedicated) != ROK)
5020 DU_LOG("\nERROR --> F1AP : BuildSpCellCfgDed failed");
5025 /*******************************************************************
5027 * @brief Builds Phy cell group config
5031 * Function : BuildPhyCellGrpCfg
5033 * Functionality: Builds Phy cell group config in DuToCuRrcContainer
5035 * @params[in] PhysicalCellGroupConfig_t *phyCellGrpCfg
5037 * @return ROK - success
5040 * ****************************************************************/
5041 uint8_t BuildPhyCellGrpCfg(PhysicalCellGroupConfig_t *phyCellGrpCfg)
5043 phyCellGrpCfg->harq_ACK_SpatialBundlingPUCCH = NULLP;
5044 phyCellGrpCfg->harq_ACK_SpatialBundlingPUSCH = NULLP;
5046 phyCellGrpCfg->p_NR_FR1 = NULLP;
5047 DU_ALLOC(phyCellGrpCfg->p_NR_FR1, sizeof(long));
5048 if(!phyCellGrpCfg->p_NR_FR1)
5050 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildPhyCellGrpCfg");
5053 *(phyCellGrpCfg->p_NR_FR1) = P_NR_FR1;
5054 phyCellGrpCfg->pdsch_HARQ_ACK_Codebook = PDSCH_HARQ_ACK_CODEBOOK;
5055 phyCellGrpCfg->tpc_SRS_RNTI = NULLP;
5056 phyCellGrpCfg->tpc_PUCCH_RNTI = NULLP;
5057 phyCellGrpCfg->tpc_PUSCH_RNTI = NULLP;
5058 phyCellGrpCfg->sp_CSI_RNTI = NULLP;
5059 phyCellGrpCfg->cs_RNTI = NULLP;
5060 phyCellGrpCfg->ext1 = NULLP;
5061 phyCellGrpCfg->ext2 = NULLP;
5065 /*******************************************************************
5067 * @brief Builds Mac cell group config
5071 * Function : BuildMacCellGrpCfg
5073 * Functionality: Builds Mac cell group config in DuToCuRrcContainer
5075 * @params[in] MAC_CellGroupConfig_t *macCellGrpCfg
5077 * @return ROK - success
5080 * ****************************************************************/
5081 uint8_t BuildMacCellGrpCfg(MAC_CellGroupConfig_t *macCellGrpCfg)
5083 macCellGrpCfg->drx_Config = NULLP;
5084 macCellGrpCfg->schedulingRequestConfig = NULLP;
5085 DU_ALLOC(macCellGrpCfg->schedulingRequestConfig, sizeof(struct SchedulingRequestConfig));
5086 if(!macCellGrpCfg->schedulingRequestConfig)
5088 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
5092 if(BuildSchedulingReqConfig(macCellGrpCfg->schedulingRequestConfig) != ROK)
5094 DU_LOG("\nERROR --> F1AP : BuildSchedulingReqConfig failed");
5098 macCellGrpCfg->bsr_Config = NULLP;
5099 DU_ALLOC(macCellGrpCfg->bsr_Config, sizeof(struct BSR_Config));
5100 if(!macCellGrpCfg->bsr_Config)
5102 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
5106 if(BuildBsrConfig(macCellGrpCfg->bsr_Config) != ROK)
5108 DU_LOG("\nERROR --> F1AP : BuildBsrConfig failed");
5112 macCellGrpCfg->tag_Config = NULLP;
5113 DU_ALLOC(macCellGrpCfg->tag_Config, sizeof(struct TAG_Config));
5114 if(!macCellGrpCfg->tag_Config)
5116 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
5120 if(BuildTagConfig(macCellGrpCfg->tag_Config) != ROK)
5122 DU_LOG("\nERROR --> F1AP : BuildTagConfig failed");
5126 macCellGrpCfg->phr_Config = NULLP;
5127 DU_ALLOC(macCellGrpCfg->phr_Config, sizeof(struct MAC_CellGroupConfig__phr_Config));
5128 if(!macCellGrpCfg->phr_Config)
5130 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
5134 if(BuildPhrConfig(macCellGrpCfg->phr_Config) != ROK)
5136 DU_LOG("\nERROR --> F1AP : BuildPhrConfig failed");
5140 macCellGrpCfg->skipUplinkTxDynamic = false;
5141 macCellGrpCfg->ext1 = NULLP;
5145 /*******************************************************************
5147 * @brief Frees memeory allocated for SearchSpcToAddModList
5151 * Function : FreeSearchSpcToAddModList
5153 * Functionality: Deallocating memory of SearchSpcToAddModList
5155 * @params[in] struct PDCCH_Config__searchSpacesToAddModList *searchSpcList
5159 4221 * ****************************************************************/
5160 void FreeSearchSpcToAddModList(struct PDCCH_Config__searchSpacesToAddModList *searchSpcList)
5164 struct SearchSpace *searchSpc=NULLP;
5166 if(searchSpcList->list.array)
5168 if(searchSpcList->list.array[idx2])
5170 searchSpc = searchSpcList->list.array[idx2];
5171 if(searchSpc->controlResourceSetId)
5173 if(searchSpc->monitoringSlotPeriodicityAndOffset)
5175 if(searchSpc->monitoringSymbolsWithinSlot)
5177 if(searchSpc->monitoringSymbolsWithinSlot->buf)
5179 if(searchSpc->nrofCandidates)
5181 if(searchSpc->searchSpaceType)
5183 DU_FREE(searchSpc->searchSpaceType->choice.ue_Specific,\
5184 sizeof(struct SearchSpace__searchSpaceType__ue_Specific));
5185 DU_FREE(searchSpc->searchSpaceType, sizeof(struct
5186 SearchSpace__searchSpaceType));
5188 DU_FREE(searchSpc->nrofCandidates,
5189 sizeof(struct SearchSpace__nrofCandidates));
5191 DU_FREE(searchSpc->monitoringSymbolsWithinSlot->buf, \
5192 searchSpc->monitoringSymbolsWithinSlot->size);
5194 DU_FREE(searchSpc->monitoringSymbolsWithinSlot,
5195 sizeof(BIT_STRING_t));
5197 DU_FREE(searchSpc->monitoringSlotPeriodicityAndOffset, \
5198 sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
5200 DU_FREE(searchSpc->controlResourceSetId,
5201 sizeof(ControlResourceSetId_t));
5204 for(idx1 = 0; idx1 < searchSpcList->list.count; idx1++)
5206 DU_FREE(searchSpcList->list.array[idx1],
5207 sizeof(struct SearchSpace));
5209 DU_FREE(searchSpcList->list.array,searchSpcList->list.size);
5212 /*******************************************************************
5214 * @brief Frees memory allocated for PdschTimeDomAllocList
5218 * Function : FreePdschTimeDomAllocList
5220 * Functionality: Deallocating memory of PdschTimeDomAllocList
5222 * @params[in] struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
5226 4221 * ****************************************************************/
5227 void FreePdschTimeDomAllocList( struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList)
5231 if(timeDomAllocList->choice.setup)
5233 if(timeDomAllocList->choice.setup->list.array)
5235 for(idx1 = 0; idx1 <timeDomAllocList->choice.setup->list.count ; idx1++)
5237 DU_FREE(timeDomAllocList->choice.setup->list.array[idx1],
5238 sizeof(struct PDSCH_TimeDomainResourceAllocation));
5240 DU_FREE(timeDomAllocList->choice.setup->list.array, \
5241 timeDomAllocList->choice.setup->list.size);
5243 DU_FREE(timeDomAllocList->choice.setup,\
5244 sizeof(struct PDSCH_TimeDomainResourceAllocationList));
5247 /*******************************************************************
5249 * @brief Frees memory allocated for PuschTimeDomAllocList
5253 * Function : FreePuschTimeDomAllocList
5255 * Functionality: Deallocating memory of PuschTimeDomAllocList
5257 * @params[in] PUSCH_Config_t *puschCfg
5261 * ****************************************************************/
5262 void FreePuschTimeDomAllocList(PUSCH_Config_t *puschCfg)
5266 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList_t=NULLP;
5268 if(puschCfg->pusch_TimeDomainAllocationList)
5270 timeDomAllocList_t=puschCfg->pusch_TimeDomainAllocationList;
5271 if(timeDomAllocList_t->choice.setup)
5273 if(timeDomAllocList_t->choice.setup->list.array)
5275 DU_FREE(timeDomAllocList_t->choice.setup->list.array[idx2]->k2, sizeof(long));
5276 for(idx1 = 0; idx1<timeDomAllocList_t->choice.setup->list.count; idx1++)
5278 DU_FREE(timeDomAllocList_t->choice.setup->list.array[idx1],\
5279 sizeof(PUSCH_TimeDomainResourceAllocation_t));
5281 DU_FREE(timeDomAllocList_t->choice.setup->list.array, \
5282 timeDomAllocList_t->choice.setup->list.size);
5284 DU_FREE(timeDomAllocList_t->choice.setup, \
5285 sizeof(struct PUSCH_TimeDomainResourceAllocationList));
5287 DU_FREE(puschCfg->transformPrecoder, sizeof(long));
5288 DU_FREE(puschCfg->pusch_TimeDomainAllocationList, \
5289 sizeof(struct PUSCH_Config__pusch_TimeDomainAllocationList));
5293 /*******************************************************************
5295 * @brief Frees memory allocated for InitialUlBWP
5299 * Function : FreeInitialUlBWP
5301 * Functionality: Deallocating memory of InitialUlBWP
5303 * @params[in] BWP_UplinkDedicated_t *ulBwp
5307 * ****************************************************************/
5308 void FreeInitialUlBWP(BWP_UplinkDedicated_t *ulBwp)
5310 uint8_t rSetIdx, rsrcIdx;
5311 SRS_Config_t *srsCfg = NULLP;
5312 PUSCH_Config_t *puschCfg = NULLP;
5313 struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg = NULLP;
5314 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList = NULLP;
5315 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList = NULLP;
5316 struct SRS_Config__srs_ResourceToAddModList *resourceList = NULLP;
5318 if(ulBwp->pusch_Config)
5320 if(ulBwp->pusch_Config->choice.setup)
5322 puschCfg=ulBwp->pusch_Config->choice.setup;
5323 if(puschCfg->dataScramblingIdentityPUSCH)
5325 if(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
5327 FreePuschTimeDomAllocList(puschCfg);
5328 dmrsUlCfg=puschCfg->dmrs_UplinkForPUSCH_MappingTypeA;
5329 if(dmrsUlCfg->choice.setup)
5331 if(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
5333 if(dmrsUlCfg->choice.setup->transformPrecodingDisabled)
5335 DU_FREE(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0,\
5337 DU_FREE(dmrsUlCfg->choice.setup->transformPrecodingDisabled,
5338 sizeof(struct DMRS_UplinkConfig__transformPrecodingDisabled));
5340 DU_FREE(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition,
5343 DU_FREE(dmrsUlCfg->choice.setup,sizeof(DMRS_UplinkConfig_t));
5345 DU_FREE(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA, \
5346 sizeof(struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA));
5348 DU_FREE(puschCfg->dataScramblingIdentityPUSCH, sizeof(long));
5350 DU_FREE(ulBwp->pusch_Config->choice.setup, sizeof(PUSCH_Config_t));
5352 DU_FREE(ulBwp->pusch_Config, sizeof(struct BWP_UplinkDedicated__pusch_Config));
5354 /* Free SRS-Config */
5355 if(ulBwp->srs_Config)
5357 if(ulBwp->srs_Config->choice.setup)
5359 srsCfg = ulBwp->srs_Config->choice.setup;
5361 /* Free Resource Set to add/mod list */
5362 if(srsCfg->srs_ResourceSetToAddModList)
5364 rsrcSetList = srsCfg->srs_ResourceSetToAddModList;
5365 if(rsrcSetList->list.array)
5369 /* Free SRS resource Id list in this SRS resource set */
5370 if(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
5372 rsrcIdList = rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
5374 if(rsrcIdList->list.array)
5376 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count; rsrcIdx++)
5378 DU_FREE(rsrcIdList->list.array[rsrcIdx], sizeof(SRS_ResourceId_t));
5380 DU_FREE(rsrcIdList->list.array, rsrcIdList->list.size);
5382 DU_FREE(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList,\
5383 sizeof(struct SRS_ResourceSet__srs_ResourceIdList));
5386 /* Free resource type info for this SRS resource set */
5387 DU_FREE(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic, \
5388 sizeof(struct SRS_ResourceSet__resourceType__aperiodic));
5390 /* Free memory for each resource set */
5391 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
5393 DU_FREE(rsrcSetList->list.array[rSetIdx], sizeof(SRS_ResourceSet_t));
5395 DU_FREE(rsrcSetList->list.array, rsrcSetList->list.size);
5397 DU_FREE(srsCfg->srs_ResourceSetToAddModList, \
5398 sizeof(struct SRS_Config__srs_ResourceSetToAddModList));
5401 /* Free resource to add/modd list */
5402 if(srsCfg->srs_ResourceToAddModList)
5404 resourceList = srsCfg->srs_ResourceToAddModList;
5405 if(resourceList->list.array)
5408 DU_FREE(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2,\
5409 sizeof(struct SRS_Resource__transmissionComb__n2));
5410 DU_FREE(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic,\
5411 sizeof(struct SRS_Resource__resourceType__aperiodic));
5413 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
5415 DU_FREE(resourceList->list.array[rsrcIdx], sizeof(SRS_Resource_t));
5417 DU_FREE(resourceList->list.array, resourceList->list.size);
5419 DU_FREE(srsCfg->srs_ResourceToAddModList, \
5420 sizeof(struct SRS_Config__srs_ResourceToAddModList));
5423 DU_FREE(ulBwp->srs_Config->choice.setup, sizeof(SRS_Config_t));
5425 DU_FREE(ulBwp->srs_Config, sizeof(struct BWP_UplinkDedicated__srs_Config));
5429 /*******************************************************************
5431 * @brief Frees memory allocated for initialUplinkBWP
5435 * Function : FreeinitialUplinkBWP
5437 * Functionality: Deallocating memory of initialUplinkBWP
5439 * @params[in] UplinkConfig_t *ulCfg
5444 * ****************************************************************/
5445 void FreeinitialUplinkBWP(UplinkConfig_t *ulCfg)
5447 BWP_UplinkDedicated_t *ulBwp=NULLP;
5448 struct UplinkConfig__pusch_ServingCellConfig *puschCfg=NULLP;
5450 if(ulCfg->initialUplinkBWP)
5452 ulBwp=ulCfg->initialUplinkBWP;
5453 if(ulCfg->firstActiveUplinkBWP_Id)
5455 if(ulCfg->pusch_ServingCellConfig)
5457 puschCfg=ulCfg->pusch_ServingCellConfig;
5458 if(puschCfg->choice.setup)
5460 if(puschCfg->choice.setup->ext1)
5462 DU_FREE(puschCfg->choice.setup->ext1->\
5463 processingType2Enabled,sizeof(BOOLEAN_t));
5464 DU_FREE(puschCfg->choice.setup->ext1->\
5465 maxMIMO_Layers,sizeof(long));
5466 DU_FREE(puschCfg->choice.setup->ext1, \
5467 sizeof(struct PUSCH_ServingCellConfig__ext1));
5469 DU_FREE(puschCfg->choice.setup, sizeof(struct PUSCH_ServingCellConfig));
5471 DU_FREE(ulCfg->pusch_ServingCellConfig, sizeof(struct UplinkConfig__pusch_ServingCellConfig));
5473 DU_FREE(ulCfg->firstActiveUplinkBWP_Id, sizeof(BWP_Id_t));
5475 FreeInitialUlBWP(ulBwp);
5476 DU_FREE(ulCfg->initialUplinkBWP, sizeof(BWP_UplinkDedicated_t));
5479 /*******************************************************************
5481 * @brief Frees emmory allocated for BWPDlDedPdschCfg
5485 * Function : FreeBWPDlDedPdschCfg
5487 * Functionality: Deallocating memory of BWPDlDedPdschCfg
5489 * @params[in] BWP_DownlinkDedicated_t *dlBwp
5494 * ****************************************************************/
5495 void FreeBWPDlDedPdschCfg(BWP_DownlinkDedicated_t *dlBwp)
5497 struct PDSCH_Config *pdschCfg=NULLP;
5498 struct PDSCH_Config__prb_BundlingType *prbBndlType=NULLP;
5499 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList=NULLP;
5500 struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg=NULLP;
5502 if(dlBwp->pdsch_Config->choice.setup)
5504 pdschCfg=dlBwp->pdsch_Config->choice.setup;
5505 if(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
5507 if(pdschCfg->pdsch_TimeDomainAllocationList)
5509 timeDomAllocList=pdschCfg->pdsch_TimeDomainAllocationList;
5510 if(pdschCfg->maxNrofCodeWordsScheduledByDCI)
5512 prbBndlType=&pdschCfg->prb_BundlingType;
5513 DU_FREE(prbBndlType->choice.staticBundling,\
5514 sizeof(struct PDSCH_Config__prb_BundlingType__staticBundling));
5515 DU_FREE(pdschCfg->maxNrofCodeWordsScheduledByDCI, sizeof(long));
5517 FreePdschTimeDomAllocList(timeDomAllocList);
5518 DU_FREE(pdschCfg->pdsch_TimeDomainAllocationList, \
5519 sizeof(struct PDSCH_Config__pdsch_TimeDomainAllocationList));
5521 dmrsDlCfg=pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA;
5522 if(dmrsDlCfg->choice.setup)
5524 DU_FREE(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition,
5526 DU_FREE(dmrsDlCfg->choice.setup, sizeof(struct DMRS_DownlinkConfig));
5528 DU_FREE(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA, \
5529 sizeof(struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA));
5531 DU_FREE(dlBwp->pdsch_Config->choice.setup, sizeof(struct PDSCH_Config));
5534 /*******************************************************************
5536 * @brief Frees emmory allocated for BWPDlDedPdcchCfg
5540 * Function : FreeBWPDlDedPdcchCfg
5542 * Functionality: Deallocating memory of BWPDlDedPdcchCfg
5544 * @params[in] BWP_DownlinkDedicated_t *dlBwp
5549 * ****************************************************************/
5550 void FreeBWPDlDedPdcchCfg(BWP_DownlinkDedicated_t *dlBwp)
5554 struct PDCCH_Config *pdcchCfg=NULLP;
5555 struct ControlResourceSet *controlRSet=NULLP;
5556 struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList=NULLP;
5558 if(dlBwp->pdcch_Config->choice.setup)
5560 pdcchCfg=dlBwp->pdcch_Config->choice.setup;
5561 if(pdcchCfg->controlResourceSetToAddModList)
5563 controlRSetList = pdcchCfg->controlResourceSetToAddModList;
5564 if(controlRSetList->list.array)
5566 controlRSet = controlRSetList->list.array[idx2];
5569 if(controlRSet->frequencyDomainResources.buf)
5571 if(controlRSet->pdcch_DMRS_ScramblingID)
5573 if(pdcchCfg->searchSpacesToAddModList)
5575 FreeSearchSpcToAddModList(pdcchCfg->searchSpacesToAddModList);
5576 DU_FREE(pdcchCfg->searchSpacesToAddModList, \
5577 sizeof(struct PDCCH_Config__searchSpacesToAddModList));
5579 DU_FREE(controlRSet->pdcch_DMRS_ScramblingID, sizeof(long));
5581 DU_FREE(controlRSet->frequencyDomainResources.buf, \
5582 controlRSet->frequencyDomainResources.size);
5585 for(idx1 = 0; idx1 <controlRSetList->list.count; idx1++)
5587 DU_FREE(controlRSetList->list.array[idx1], sizeof(struct ControlResourceSet));
5589 DU_FREE(controlRSetList->list.array, controlRSetList->list.size);
5591 DU_FREE(pdcchCfg->controlResourceSetToAddModList, \
5592 sizeof(struct PDCCH_Config__controlResourceSetToAddModList));
5594 DU_FREE(dlBwp->pdcch_Config->choice.setup, sizeof(struct PDCCH_Config));
5598 /*******************************************************************
5600 * @brief Frees emmory allocated for DUToCURRCContainer
5604 * Function : FreeMemDuToCuRrcCont
5606 * Functionality: Deallocating memory of DuToCuRrcContainer
5608 * @params[in] DuToCuRRCContainer, DuToCuRRCContainer
5610 * @return ROK - success
5613 * ****************************************************************/
5614 uint8_t FreeMemDuToCuRrcCont(CellGroupConfigRrc_t *cellGrpCfg)
5617 SpCellConfig_t *spCellCfg=NULLP;
5618 ServingCellConfig_t *srvCellCfg=NULLP;
5619 BWP_DownlinkDedicated_t *dlBwp=NULLP;
5620 MAC_CellGroupConfig_t *macCellGrpCfg=NULLP;
5621 PhysicalCellGroupConfig_t *phyCellGrpCfg=NULLP;
5622 struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList=NULLP;
5623 struct RLC_Config *rlcConfig=NULLP;
5624 struct LogicalChannelConfig *macLcConfig=NULLP;
5625 struct SchedulingRequestConfig *schedulingRequestConfig=NULLP;
5626 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList=NULLP;
5627 struct TAG_Config *tagConfig=NULLP;
5628 struct TAG_Config__tag_ToAddModList *tagList=NULLP;
5629 struct MAC_CellGroupConfig__phr_Config *phrConfig=NULLP;
5630 struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg=NULLP;
5632 rlcBearerList = cellGrpCfg->rlc_BearerToAddModList;
5635 if(rlcBearerList->list.array)
5637 for(idx=0; idx<rlcBearerList->list.count; idx++)
5639 if(rlcBearerList->list.array[idx])
5641 rlcConfig = rlcBearerList->list.array[idx]->rlc_Config;
5642 macLcConfig = rlcBearerList->list.array[idx]->mac_LogicalChannelConfig;
5645 if(rlcConfig->choice.am)
5647 DU_FREE(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
5648 DU_FREE(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
5649 DU_FREE(rlcConfig->choice.am, sizeof(struct RLC_Config__am));
5651 DU_FREE(rlcConfig, sizeof(struct RLC_Config));
5653 DU_FREE(rlcBearerList->list.array[idx]->servedRadioBearer, sizeof(struct RLC_BearerConfig__servedRadioBearer));
5656 if(macLcConfig->ul_SpecificParameters)
5658 DU_FREE(macLcConfig->ul_SpecificParameters->schedulingRequestID, sizeof(SchedulingRequestId_t));
5659 DU_FREE(macLcConfig->ul_SpecificParameters->logicalChannelGroup, sizeof(long));
5660 DU_FREE(macLcConfig->ul_SpecificParameters, sizeof(struct LogicalChannelConfig__ul_SpecificParameters));
5662 DU_FREE(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig, sizeof(struct LogicalChannelConfig));
5664 DU_FREE(rlcBearerList->list.array[idx], sizeof(struct RLC_BearerConfig));
5667 DU_FREE(rlcBearerList->list.array, rlcBearerList->list.size);
5669 DU_FREE(cellGrpCfg->rlc_BearerToAddModList, sizeof(struct CellGroupConfigRrc__rlc_BearerToAddModList));
5672 macCellGrpCfg = cellGrpCfg->mac_CellGroupConfig;
5675 schedulingRequestConfig = macCellGrpCfg->schedulingRequestConfig;
5676 if(schedulingRequestConfig)
5678 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
5681 if(schReqList->list.array)
5683 for(idx=0;idx<schReqList->list.count; idx++)
5685 if(schReqList->list.array[idx])
5687 DU_FREE(schReqList->list.array[idx]->sr_ProhibitTimer, sizeof(long));
5688 DU_FREE(schReqList->list.array[idx], sizeof(struct SchedulingRequestToAddMod));
5691 DU_FREE(schReqList->list.array, schReqList->list.size);
5693 DU_FREE(schedulingRequestConfig->schedulingRequestToAddModList,\
5694 sizeof(struct SchedulingRequestConfig__schedulingRequestToAddModList)); }
5695 DU_FREE(macCellGrpCfg->schedulingRequestConfig, sizeof(struct SchedulingRequestConfig));
5697 if(macCellGrpCfg->bsr_Config)
5699 DU_FREE(macCellGrpCfg->bsr_Config, sizeof(struct BSR_Config));
5701 tagConfig = macCellGrpCfg->tag_Config;
5704 tagList = tagConfig->tag_ToAddModList;
5707 if(tagList->list.array)
5709 for(idx=0; idx<tagList->list.count; idx++)
5711 DU_FREE(tagList->list.array[idx], sizeof(struct TAG));
5713 DU_FREE(tagList->list.array, tagList->list.size);
5715 DU_FREE(tagConfig->tag_ToAddModList, sizeof(struct TAG_Config__tag_ToAddModList));
5717 DU_FREE(tagConfig, sizeof(struct TAG_Config));
5720 phrConfig = macCellGrpCfg->phr_Config;
5723 DU_FREE(phrConfig->choice.setup, sizeof(struct PHR_Config));
5724 DU_FREE(phrConfig, sizeof(struct MAC_CellGroupConfig__phr_Config));
5727 DU_FREE(macCellGrpCfg, sizeof(MAC_CellGroupConfig_t));
5730 phyCellGrpCfg = cellGrpCfg->physicalCellGroupConfig;
5733 DU_FREE(phyCellGrpCfg->p_NR_FR1, sizeof(long));
5734 DU_FREE(phyCellGrpCfg, sizeof(PhysicalCellGroupConfig_t));
5737 spCellCfg = cellGrpCfg->spCellConfig;
5740 if(spCellCfg->servCellIndex)
5742 if(spCellCfg->rlmInSyncOutOfSyncThreshold)
5744 if(spCellCfg->spCellConfigDedicated)
5746 srvCellCfg = spCellCfg->spCellConfigDedicated;
5747 if(srvCellCfg->tdd_UL_DL_ConfigurationDedicated)
5749 if(srvCellCfg->initialDownlinkBWP)
5751 dlBwp = srvCellCfg->initialDownlinkBWP;
5752 if(srvCellCfg->firstActiveDownlinkBWP_Id)
5754 if(srvCellCfg->defaultDownlinkBWP_Id)
5756 if(srvCellCfg->uplinkConfig)
5758 if(srvCellCfg->pdsch_ServingCellConfig)
5760 pdschCfg= srvCellCfg->pdsch_ServingCellConfig;
5761 if(pdschCfg->choice.setup)
5763 DU_FREE(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH,sizeof(long));
5764 DU_FREE(pdschCfg->choice.setup, sizeof( struct PDSCH_ServingCellConfig));
5766 DU_FREE(srvCellCfg->pdsch_ServingCellConfig, sizeof(struct
5767 ServingCellConfig__pdsch_ServingCellConfig));
5769 FreeinitialUplinkBWP(srvCellCfg->uplinkConfig);
5770 DU_FREE(srvCellCfg->uplinkConfig, sizeof(UplinkConfig_t));
5772 DU_FREE(srvCellCfg->defaultDownlinkBWP_Id, sizeof(long));
5774 DU_FREE(srvCellCfg->firstActiveDownlinkBWP_Id, sizeof(long));
5776 if(dlBwp->pdcch_Config)
5778 if(dlBwp->pdsch_Config)
5780 FreeBWPDlDedPdschCfg(dlBwp);
5781 DU_FREE(dlBwp->pdsch_Config, sizeof(struct BWP_DownlinkDedicated__pdsch_Config));
5783 FreeBWPDlDedPdcchCfg(dlBwp);
5784 DU_FREE(dlBwp->pdcch_Config, sizeof(struct BWP_DownlinkDedicated__pdcch_Config));
5786 DU_FREE(srvCellCfg->initialDownlinkBWP, sizeof(BWP_DownlinkDedicated_t));
5788 DU_FREE(srvCellCfg->tdd_UL_DL_ConfigurationDedicated, sizeof(TDD_UL_DL_ConfigDedicated_t));
5790 DU_FREE(spCellCfg->spCellConfigDedicated, sizeof(ServingCellConfig_t));
5792 DU_FREE(spCellCfg->rlmInSyncOutOfSyncThreshold, sizeof(long));
5794 DU_FREE(spCellCfg->servCellIndex, sizeof(long));
5796 DU_FREE(spCellCfg,sizeof(SpCellConfig_t));
5800 /*******************************************************************
5802 * @brief Builds DU To CU RRC Container
5806 * Function : BuildDuToCuRrcContainer
5808 * Functionality: Builds DuToCuRrcContainer
5810 * @params[in] idx, index in F1AP msg
5811 * DuToCuRRCContainer, DuToCuRRCContainer
5813 * @return ROK - success
5816 * ****************************************************************/
5817 uint8_t BuildDuToCuRrcContainer(DUtoCURRCContainer_t *duToCuRrcContainer)
5820 CellGroupConfigRrc_t cellGrpCfg;
5821 asn_enc_rval_t encRetVal;
5822 memset(&cellGrpCfg, 0, sizeof(CellGroupConfigRrc_t));
5823 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
5827 cellGrpCfg.cellGroupId = CELL_GRP_ID;
5829 cellGrpCfg.rlc_BearerToAddModList = NULLP;
5830 DU_ALLOC(cellGrpCfg.rlc_BearerToAddModList, sizeof(struct CellGroupConfigRrc__rlc_BearerToAddModList));
5831 if(!cellGrpCfg.rlc_BearerToAddModList)
5833 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5837 if(BuildRlcBearerToAddModList(cellGrpCfg.rlc_BearerToAddModList) != ROK)
5839 DU_LOG("\nERROR --> F1AP : BuildRlcBearerToAddModList failed");
5844 cellGrpCfg.rlc_BearerToReleaseList = NULLP;
5845 cellGrpCfg.mac_CellGroupConfig = NULLP;
5846 DU_ALLOC(cellGrpCfg.mac_CellGroupConfig, sizeof(MAC_CellGroupConfig_t));
5847 if(!cellGrpCfg.mac_CellGroupConfig)
5849 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5853 if(BuildMacCellGrpCfg(cellGrpCfg.mac_CellGroupConfig) != ROK)
5855 DU_LOG("\nERROR --> F1AP : BuildMacCellGrpCfg failed");
5860 cellGrpCfg.physicalCellGroupConfig = NULLP;
5861 DU_ALLOC(cellGrpCfg.physicalCellGroupConfig, sizeof(PhysicalCellGroupConfig_t));
5862 if(!cellGrpCfg.physicalCellGroupConfig)
5864 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5868 if(BuildPhyCellGrpCfg(cellGrpCfg.physicalCellGroupConfig) != ROK)
5870 DU_LOG("\nERROR --> F1AP : BuildPhyCellGrpCfg failed");
5875 cellGrpCfg.spCellConfig = NULLP;
5876 DU_ALLOC(cellGrpCfg.spCellConfig, sizeof(SpCellConfig_t));
5877 if(!cellGrpCfg.spCellConfig)
5879 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5883 if(BuildSpCellCfg(cellGrpCfg.spCellConfig) != ROK)
5885 DU_LOG("\nERROR --> F1AP : BuildSpCellCfg failed");
5890 cellGrpCfg.sCellToAddModList = NULLP;
5891 cellGrpCfg.sCellToReleaseList = NULLP;
5892 cellGrpCfg.ext1 = NULLP;
5894 /* encode cellGrpCfg into duToCuRrcContainer */
5895 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, &cellGrpCfg);
5896 memset(encBuf, 0, ENC_BUF_MAX_LEN);
5898 encRetVal = aper_encode(&asn_DEF_CellGroupConfigRrc, 0, &cellGrpCfg, PrepFinalEncBuf, encBuf);
5899 /* Encode results */
5900 if(encRetVal.encoded == ENCODE_FAIL)
5902 DU_LOG( "\nERROR --> F1AP : Could not encode DuToCuRrcContainer (at %s)\n",\
5903 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
5909 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for DuToCuRrcContainer\n");
5910 for(int i=0; i< encBufSize; i++)
5912 printf("%x",encBuf[i]);
5916 duToCuRrcContainer->size = encBufSize;
5917 DU_ALLOC(duToCuRrcContainer->buf, duToCuRrcContainer->size);
5918 if(!duToCuRrcContainer->buf)
5920 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDuToCuRrcContainer");
5926 memcpy(duToCuRrcContainer->buf, encBuf, duToCuRrcContainer->size);
5930 FreeMemDuToCuRrcCont(&cellGrpCfg);
5934 /*******************************************************************
5936 * @brief Free memory allocated in InitialULRRCMessage
5940 * Function : freeInitUlRrcMsgTransfer
5942 * Functionality: Free memory allocated in InitialULRRCMessage
5944 * @params[in]F1AP_PDU_t *f1apMsg)
5946 * @return ROK - success
5949 * ****************************************************************/
5951 uint8_t freeInitUlRrcMsgTransfer(F1AP_PDU_t *f1apMsg)
5953 uint8_t ieIdx, arrIdx;
5954 InitialULRRCMessageTransfer_t *initULRRCMsg=NULLP;
5958 if(f1apMsg->choice.initiatingMessage)
5960 initULRRCMsg = &f1apMsg->choice.initiatingMessage->value.\
5961 choice.InitialULRRCMessageTransfer;
5962 if(initULRRCMsg->protocolIEs.list.array)
5964 for(ieIdx = 0; ieIdx < initULRRCMsg->protocolIEs.list.count; ieIdx++)
5966 switch(initULRRCMsg->protocolIEs.list.array[ieIdx]->id)
5968 case ProtocolIE_ID_id_NRCGI:
5970 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.buf)
5972 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.buf)
5974 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.buf,\
5975 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.size);
5977 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.buf,\
5978 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.size);
5982 case ProtocolIE_ID_id_RRCContainer:
5984 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
5986 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf,\
5987 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size);
5991 case ProtocolIE_ID_id_DUtoCURRCContainer:
5993 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.buf)
5995 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.buf,
5996 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.size);
6004 for(arrIdx = 0; arrIdx < ieIdx; arrIdx++)
6006 if(initULRRCMsg->protocolIEs.list.array[arrIdx])
6008 DU_FREE(initULRRCMsg->protocolIEs.list.array[arrIdx],\
6009 sizeof(InitialULRRCMessageTransferIEs_t));
6012 DU_FREE(initULRRCMsg->protocolIEs.list.array, initULRRCMsg->protocolIEs.list.size);
6014 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
6016 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
6020 DU_LOG("\nERROR --> DU_APP : Recevied F1ap Pdu is null at freeInitUlRrcMsgTransfer()");
6026 /*******************************************************************
6028 * @brief Builds and sends the InitialULRRCMessage
6032 * Function : BuildAndSendInitialRrcMsgTransfer
6034 * Functionality: Constructs the Initial UL RRC Message Transfer and sends
6035 * it to the CU through SCTP.
6039 * @return ROK - success
6042 * ****************************************************************/
6043 uint8_t BuildAndSendInitialRrcMsgTransfer(uint32_t gnbDuUeF1apId, uint16_t crnti,
6044 uint16_t rrcContSize, uint8_t *rrcContainer)
6049 asn_enc_rval_t encRetVal;
6050 F1AP_PDU_t *f1apMsg = NULLP;
6051 InitialULRRCMessageTransfer_t *initULRRCMsg = NULLP;
6052 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
6056 DU_LOG("\n INFO --> F1AP : Building RRC Setup Request\n");
6057 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
6058 if(f1apMsg == NULLP)
6060 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
6063 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
6064 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
6065 if(f1apMsg->choice.initiatingMessage == NULLP)
6067 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
6070 f1apMsg->choice.initiatingMessage->procedureCode =\
6071 ProcedureCode_id_InitialULRRCMessageTransfer;
6072 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
6073 f1apMsg->choice.initiatingMessage->value.present = \
6074 InitiatingMessage__value_PR_InitialULRRCMessageTransfer;
6076 &f1apMsg->choice.initiatingMessage->value.choice.InitialULRRCMessageTransfer;
6078 initULRRCMsg->protocolIEs.list.count = elementCnt;
6079 initULRRCMsg->protocolIEs.list.size = \
6080 elementCnt * sizeof(InitialULRRCMessageTransferIEs_t *);
6081 /* Initialize the F1Setup members */
6082 DU_ALLOC(initULRRCMsg->protocolIEs.list.array,initULRRCMsg->protocolIEs.list.size);
6083 if(initULRRCMsg->protocolIEs.list.array == NULLP)
6085 DU_LOG(" ERROR --> F1AP : Memory allocation for\
6086 RRCSetupRequestMessageTransferIEs failed");
6089 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
6091 DU_ALLOC(initULRRCMsg->protocolIEs.list.array[ieIdx],\
6092 sizeof(InitialULRRCMessageTransferIEs_t));
6093 if(initULRRCMsg->protocolIEs.list.array[ieIdx] == NULLP)
6099 /*GNB DU UE F1AP ID*/
6100 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6101 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
6102 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6103 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present = \
6104 InitialULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
6105 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
6110 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6111 ProtocolIE_ID_id_NRCGI;
6112 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality =Criticality_reject;
6113 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present = \
6114 InitialULRRCMessageTransferIEs__value_PR_NRCGI;
6117 BuildNrcgi(&initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI);
6125 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6126 ProtocolIE_ID_id_C_RNTI;
6127 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6128 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
6129 InitialULRRCMessageTransferIEs__value_PR_C_RNTI;
6130 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.C_RNTI = crnti;
6134 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6135 ProtocolIE_ID_id_RRCContainer;
6136 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6137 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
6138 InitialULRRCMessageTransferIEs__value_PR_RRCContainer;
6140 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size = rrcContSize;
6141 DU_ALLOC(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf,
6142 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size)
6143 if(!initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
6145 DU_LOG(" ERROR --> F1AP : Memory allocation for RRCSetupRequestMessageTransferIEs failed");
6149 memcpy(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf, rrcContainer,
6150 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size);
6153 /*DUtoCURRCContainer*/
6155 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DUtoCURRCContainer;
6156 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6157 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
6158 InitialULRRCMessageTransferIEs__value_PR_DUtoCURRCContainer;
6160 ret = BuildDuToCuRrcContainer(&initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer);
6166 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
6168 /* Encode the F1SetupRequest type as APER */
6169 memset(encBuf, 0, ENC_BUF_MAX_LEN);
6171 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
6172 /* Encode results */
6173 if(encRetVal.encoded == ENCODE_FAIL)
6175 DU_LOG( "\nERROR --> F1AP : Could not encode Initial UL RRC Message Transfer\
6176 structure (at %s)\n",encRetVal.failed_type ? \
6177 encRetVal.failed_type->name : "unknown");
6184 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for Initial UL RRC\
6185 Message transfer\n");
6186 for(int i=0; i< encBufSize; i++)
6188 printf("%x",encBuf[i]);
6192 if(sendF1APMsg() != ROK)
6194 DU_LOG("\nERROR --> F1AP : Sending Initial UL RRC Message Transfer Failed");
6200 freeInitUlRrcMsgTransfer(f1apMsg);
6202 }/* End of BuildAndSendInitialRrcMsgTransfer*/
6204 /***** UE SETUP REQUEST *****/
6206 /*******************************************************************
6208 * @brief Free Qos And Snssai Drb Info
6212 * Function : freeDrbQosAndSnssaiInfo
6214 * Functionality: Free Qos And Snssai Drb Info
6216 * @params[in] LcCfg *lcCfg,
6219 * ****************************************************************/
6220 void freeDrbQosAndSnssaiInfo(LcCfg *lcCfg)
6224 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
6228 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
6232 /******************************************************************
6234 * @brief Function to delete the RLC Lc cfg from UE APP DB
6238 * Function : freeRlcLcCfg
6240 * Functionality: Function to delete the RLC Lc cfg from UE APP DB
6243 *****************************************************************/
6245 void freeRlcLcCfg(RlcBearerCfg *lcCfg)
6247 switch(lcCfg->rlcMode)
6253 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
6254 lcCfg->u.amCfg = NULLP;
6258 case RLC_UM_BI_DIRECTIONAL :
6260 if(lcCfg->u.umBiDirCfg)
6262 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
6263 lcCfg->u.umBiDirCfg = NULLP;
6267 case RLC_UM_UNI_DIRECTIONAL_UL :
6269 if(lcCfg->u.umUniDirUlCfg)
6271 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
6272 lcCfg->u.umUniDirUlCfg = NULLP;
6277 case RLC_UM_UNI_DIRECTIONAL_DL :
6279 if(lcCfg->u.umUniDirDlCfg)
6281 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
6282 lcCfg->u.umUniDirDlCfg = NULLP;
6287 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at freeRlcLcCfg()", lcCfg->rlcMode);
6290 memset(lcCfg, 0, sizeof(LcCfg));
6292 /*******************************************************************
6294 * @brief Function to free MacLcCfg
6298 * Function : freeMacLcCfg
6300 * Functionality: Function to free MacLcCfg
6302 * @params[in] LcCfg *lcCfg,
6305 * ****************************************************************/
6307 void freeMacLcCfg(LcCfg *lcCfg)
6309 /* Deleting DRBQOS */
6312 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
6313 lcCfg->drbQos = NULLP;
6315 /* Deleting SNSSAI */
6318 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
6319 lcCfg->snssai = NULLP;
6321 memset(lcCfg, 0, sizeof(LcCfg));
6323 /*******************************************************************
6325 * @brief Free UE NR Capability received in UE Context setup request
6329 * Function : freeAperDecodeUeNrCapability
6332 * Free UE NR Capability received in UE Context setup request
6335 * @return ROK - success
6338 * ****************************************************************/
6339 void freeAperDecodeUeNrCapability(void *ueNrCapability)
6342 FeatureSets_t *featureSets =NULLP;
6343 UE_NR_Capability_t *ueNrCap = (UE_NR_Capability_t *)ueNrCapability;
6345 if(ueNrCap->rf_Parameters.supportedBandListNR.list.array)
6347 for(arrIdx = 0; arrIdx < ueNrCap->rf_Parameters.supportedBandListNR.list.count; arrIdx++)
6349 if(ueNrCap->rf_Parameters.supportedBandListNR.list.array[arrIdx])
6350 free(ueNrCap->rf_Parameters.supportedBandListNR.list.array[arrIdx]);
6352 free(ueNrCap->rf_Parameters.supportedBandListNR.list.array);
6355 if(ueNrCap->featureSets)
6357 featureSets = ueNrCap->featureSets;
6358 if(featureSets->featureSetsDownlinkPerCC)
6360 if(featureSets->featureSetsDownlinkPerCC->list.array)
6362 for(arrIdx = 0; arrIdx < featureSets->featureSetsDownlinkPerCC->list.count; arrIdx++)
6364 if(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx])
6366 if(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]->supportedModulationOrderDL)
6367 free(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]->supportedModulationOrderDL);
6368 free(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]);
6371 free(featureSets->featureSetsDownlinkPerCC->list.array);
6373 free(featureSets->featureSetsDownlinkPerCC);
6375 if(featureSets->featureSetsUplinkPerCC)
6377 if(featureSets->featureSetsUplinkPerCC->list.array)
6379 for(arrIdx = 0; arrIdx < featureSets->featureSetsUplinkPerCC->list.count; arrIdx++)
6381 if(featureSets->featureSetsUplinkPerCC->list.array[arrIdx])
6383 if(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]->supportedModulationOrderUL)
6384 free(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]->supportedModulationOrderUL);
6385 free(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]);
6388 free(featureSets->featureSetsUplinkPerCC->list.array);
6390 free(featureSets->featureSetsUplinkPerCC);
6392 free(ueNrCap->featureSets);
6396 /*******************************************************************
6398 * @brief Function to free PdcchSearchSpcToAddModList
6399 where memory allocated by aper_decoder
6403 * Function : freeAperDecodePdcchSearchSpcToAddModList
6405 * Functionality: Function to free PdcchSearchSpcToAddModList
6407 * @params[in] struct PDCCH_Config__searchSpacesToAddModList *searchSpcList
6410 * ****************************************************************/
6412 void freeAperDecodePdcchSearchSpcToAddModList(struct PDCCH_Config__searchSpacesToAddModList *searchSpcList)
6414 uint8_t searchSpcArrIdx=0;
6415 uint8_t searchSpcArrIdx1=0;
6416 struct SearchSpace *searchSpc=NULLP;
6419 if(searchSpcList->list.array)
6421 if(searchSpcList->list.array[searchSpcArrIdx1])
6423 searchSpc = searchSpcList->list.array[searchSpcArrIdx1];
6424 if(searchSpc->controlResourceSetId)
6426 if(searchSpc->monitoringSlotPeriodicityAndOffset)
6428 if(searchSpc->monitoringSymbolsWithinSlot)
6430 if(searchSpc->monitoringSymbolsWithinSlot->buf)
6432 if(searchSpc->nrofCandidates)
6434 if(searchSpc->searchSpaceType)
6436 free(searchSpc->searchSpaceType->choice.ue_Specific);
6437 free(searchSpc->searchSpaceType);
6439 free(searchSpc->nrofCandidates);
6441 free(searchSpc->monitoringSymbolsWithinSlot->buf);
6443 free(searchSpc->monitoringSymbolsWithinSlot);
6445 free(searchSpc->monitoringSlotPeriodicityAndOffset);
6447 free(searchSpc->controlResourceSetId);
6450 for(searchSpcArrIdx = 0; searchSpcArrIdx < searchSpcList->list.count; searchSpcArrIdx++)
6452 free(searchSpcList->list.array[searchSpcArrIdx]);
6454 free(searchSpcList->list.array);
6457 /*******************************************************************
6459 * @brief Function for free part for the memory allocated by aper_decoder
6463 * Function : freeAperDecodeBWPDlDedPdcchConfig
6465 * Functionality: Function to free BWPDlDedPdcchConfig
6470 * ****************************************************************/
6473 void freeAperDecodeBWPDlDedPdcchConfig(BWP_DownlinkDedicated_t *dlBwp)
6477 struct PDCCH_Config *pdcchCfg=NULLP;
6478 struct ControlResourceSet *controlRSet=NULLP;
6479 struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList=NULLP;
6481 if(dlBwp->pdcch_Config->choice.setup)
6483 pdcchCfg=dlBwp->pdcch_Config->choice.setup;
6484 if(pdcchCfg->controlResourceSetToAddModList)
6486 controlRSetList = pdcchCfg->controlResourceSetToAddModList;
6487 if(controlRSetList->list.array)
6489 controlRSet = controlRSetList->list.array[arrIdx2];
6492 if(controlRSet->frequencyDomainResources.buf)
6494 if(controlRSet->pdcch_DMRS_ScramblingID)
6496 if(pdcchCfg->searchSpacesToAddModList)
6498 freeAperDecodePdcchSearchSpcToAddModList(pdcchCfg->searchSpacesToAddModList);
6499 free(pdcchCfg->searchSpacesToAddModList);
6501 free(controlRSet->pdcch_DMRS_ScramblingID);
6503 free(controlRSet->frequencyDomainResources.buf);
6506 for(arrIdx1 = 0; arrIdx1 <controlRSetList->list.count; arrIdx1++)
6508 free(controlRSetList->list.array[arrIdx1]);
6510 free(controlRSetList->list.array);
6512 free(pdcchCfg->controlResourceSetToAddModList);
6514 free(dlBwp->pdcch_Config->choice.setup);
6517 /*******************************************************************
6519 * @brief Function to free PdschTimeDomAllocationList
6520 * where the memory allocated by aper_decoder
6524 * Function : freeAperDecodePdschTimeDomAllocationList
6526 * Functionality: Function to free PdschTimeDomAllocationList
6528 * @params[in] struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
6531 * ****************************************************************/
6534 void freeAperDecodePdschTimeDomAllocationList( struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList)
6538 if(timeDomAllocList->choice.setup)
6540 if(timeDomAllocList->choice.setup->list.array)
6542 for(arrIdx = 0; arrIdx <timeDomAllocList->choice.setup->list.count ; arrIdx++)
6544 free(timeDomAllocList->choice.setup->list.array[arrIdx]);
6546 free(timeDomAllocList->choice.setup->list.array);
6548 free(timeDomAllocList->choice.setup);
6552 /*******************************************************************
6554 * @brief Function to free BWPDlDedPdschConfig
6555 * where the memory allocated by aper_decoder
6559 * Function : freeAperDecodeBWPDlDedPdschConfig
6561 * Functionality: Function to free BWPDlDedPdschConfig
6563 * @params[in] BWP_DownlinkDedicated_t *dlBwp
6566 * ****************************************************************/
6569 void freeAperDecodeBWPDlDedPdschConfig(BWP_DownlinkDedicated_t *dlBwp)
6571 struct PDSCH_Config *pdschCfg=NULLP;
6572 struct PDSCH_Config__prb_BundlingType *prbBndlType=NULLP;
6573 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList=NULLP;
6574 struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg=NULLP;
6576 if(dlBwp->pdsch_Config->choice.setup)
6578 pdschCfg=dlBwp->pdsch_Config->choice.setup;
6579 if(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
6581 if(pdschCfg->pdsch_TimeDomainAllocationList)
6583 timeDomAllocList=pdschCfg->pdsch_TimeDomainAllocationList;
6584 if(pdschCfg->maxNrofCodeWordsScheduledByDCI)
6586 prbBndlType=&pdschCfg->prb_BundlingType;
6587 free(prbBndlType->choice.staticBundling);
6588 free(pdschCfg->maxNrofCodeWordsScheduledByDCI);
6590 freeAperDecodePdschTimeDomAllocationList(timeDomAllocList);
6591 free(pdschCfg->pdsch_TimeDomainAllocationList);
6593 dmrsDlCfg=pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA;
6594 if(dmrsDlCfg->choice.setup)
6596 free(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition);
6597 free(dmrsDlCfg->choice.setup);
6599 free(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA);
6601 free(dlBwp->pdsch_Config->choice.setup);
6604 /*******************************************************************
6606 * @brief Function to free PuschTimeDomAllocListCfg
6607 where the memory allocated by aper_decoder
6611 * Function : freeAperDecodePuschTimeDomAllocListCfg
6613 * Functionality: Function to free PuschTimeDomAllocListCfg
6615 * @params[in] PUSCH_Config_t *puschCfg
6618 * ****************************************************************/
6621 void freeAperDecodePuschTimeDomAllocListCfg(PUSCH_Config_t *puschCfg)
6625 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList_t=NULLP;
6627 if(puschCfg->pusch_TimeDomainAllocationList)
6629 timeDomAllocList_t=puschCfg->pusch_TimeDomainAllocationList;
6630 if(timeDomAllocList_t->choice.setup)
6632 if(timeDomAllocList_t->choice.setup->list.array)
6634 free(timeDomAllocList_t->choice.setup->list.array[arrIdx1]->k2);
6635 for(arrIdx = 0; arrIdx<timeDomAllocList_t->choice.setup->list.count; arrIdx++)
6637 free(timeDomAllocList_t->choice.setup->list.array[arrIdx]);
6639 free(timeDomAllocList_t->choice.setup->list.array);
6641 free(timeDomAllocList_t->choice.setup);
6643 free(puschCfg->transformPrecoder);
6644 free(puschCfg->pusch_TimeDomainAllocationList);
6647 /*******************************************************************
6649 * @brief Function to free InitialUlBWPConfig where memory allocated by aper_decoder
6653 * Function : freeAperDecodeInitialUlBWPConfig
6655 * Functionality: Function to free InitialUlBWPConfig
6657 * @params[in] BWP_UplinkDedicated_t *ulBwp
6660 * ****************************************************************/
6663 void freeAperDecodeInitialUlBWPConfig(BWP_UplinkDedicated_t *ulBwp)
6667 SRS_Config_t *srsCfg = NULLP;
6668 PUSCH_Config_t *puschCfg = NULLP;
6669 struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg = NULLP;
6670 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList = NULLP;
6671 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList = NULLP;
6672 struct SRS_Config__srs_ResourceToAddModList *resourceList = NULLP;
6674 if(ulBwp->pusch_Config)
6676 if(ulBwp->pusch_Config->choice.setup)
6678 puschCfg=ulBwp->pusch_Config->choice.setup;
6679 if(puschCfg->dataScramblingIdentityPUSCH)
6681 if(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
6683 freeAperDecodePuschTimeDomAllocListCfg(puschCfg);
6684 dmrsUlCfg=puschCfg->dmrs_UplinkForPUSCH_MappingTypeA;
6685 if(dmrsUlCfg->choice.setup)
6687 if(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
6689 if(dmrsUlCfg->choice.setup->transformPrecodingDisabled)
6691 free(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0);
6692 free(dmrsUlCfg->choice.setup->transformPrecodingDisabled);
6694 free(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition);
6696 free(dmrsUlCfg->choice.setup);
6698 free(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA);
6700 free(puschCfg->dataScramblingIdentityPUSCH);
6702 free(ulBwp->pusch_Config->choice.setup);
6704 free(ulBwp->pusch_Config);
6706 /* Free SRS-Config */
6707 if(ulBwp->srs_Config)
6709 if(ulBwp->srs_Config->choice.setup)
6711 srsCfg = ulBwp->srs_Config->choice.setup;
6713 /* Free Resource Set to add/mod list */
6714 if(srsCfg->srs_ResourceSetToAddModList)
6716 rsrcSetList = srsCfg->srs_ResourceSetToAddModList;
6717 if(rsrcSetList->list.array)
6721 /* Free SRS resource Id list in this SRS resource set */
6722 if(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
6725 rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
6727 if(rsrcIdList->list.array)
6729 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count;
6732 free(rsrcIdList->list.array[rsrcIdx]);
6734 free(rsrcIdList->list.array);
6736 free(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList);
6739 /* Free resource type info for this SRS resource set */
6741 free(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic);
6743 /* Free memory for each resource set */
6744 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
6746 free(rsrcSetList->list.array[rSetIdx]);
6748 free(rsrcSetList->list.array);
6750 free(srsCfg->srs_ResourceSetToAddModList);
6753 /* Free resource to add/modd list */
6754 if(srsCfg->srs_ResourceToAddModList)
6756 resourceList = srsCfg->srs_ResourceToAddModList;
6757 if(resourceList->list.array)
6761 free(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2);
6762 free(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic);
6764 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
6766 free(resourceList->list.array[rsrcIdx]);
6768 free(resourceList->list.array);
6770 free(srsCfg->srs_ResourceToAddModList);
6773 free(ulBwp->srs_Config->choice.setup);
6775 free(ulBwp->srs_Config);
6779 /*******************************************************************
6781 * @brief Function to free initialUplinkBWPConfig where memory allocated by aper_decoder
6785 * Function : freeAperDecodeinitialUplinkBWPConfig
6787 * Functionality: Function to free initialUplinkBWPConfig
6789 * @params[in] UplinkConfig_t *ulCfg
6792 * ****************************************************************/
6795 void freeAperDecodeinitialUplinkBWPConfig(UplinkConfig_t *ulCfg)
6797 BWP_UplinkDedicated_t *ulBwp=NULLP;
6798 struct UplinkConfig__pusch_ServingCellConfig *puschCfg=NULLP;
6800 if(ulCfg->initialUplinkBWP)
6802 ulBwp=ulCfg->initialUplinkBWP;
6803 if(ulCfg->firstActiveUplinkBWP_Id)
6805 if(ulCfg->pusch_ServingCellConfig)
6807 puschCfg=ulCfg->pusch_ServingCellConfig;
6808 if(puschCfg->choice.setup)
6810 if(puschCfg->choice.setup->ext1)
6812 free(puschCfg->choice.setup->ext1->processingType2Enabled);
6813 free(puschCfg->choice.setup->ext1->maxMIMO_Layers);
6814 free(puschCfg->choice.setup->ext1);
6816 free(puschCfg->choice.setup);
6818 free(ulCfg->pusch_ServingCellConfig);
6820 free(ulCfg->firstActiveUplinkBWP_Id);
6822 freeAperDecodeInitialUlBWPConfig(ulBwp);
6823 free(ulCfg->initialUplinkBWP);
6827 /*******************************************************************
6829 * @brief Function to free DuUeCfg
6833 * Function : freeDuUeCfg
6835 * Functionality: Function to free DuUeCfg
6837 * @params[in] DuUeCfg *ueCfg
6840 * ****************************************************************/
6841 void freeDuUeCfg(DuUeCfg *ueCfg)
6845 SpCellConfig_t *spCellCfg = NULLP;
6846 ServingCellConfig_t *srvCellCfg = NULLP;
6847 BWP_DownlinkDedicated_t *dlBwp = NULLP;
6848 MAC_CellGroupConfig_t *macCellGrpCfg = NULLP;
6849 PhysicalCellGroupConfig_t *phyCellGrpCfg = NULLP;
6850 struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList = NULLP;
6851 struct RLC_Config *rlcConfig = NULLP;
6852 struct LogicalChannelConfig *macLcConfig = NULLP;
6853 struct SchedulingRequestConfig *schedulingRequestConfig = NULLP;
6854 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList = NULLP;
6855 struct TAG_Config *tagConfig = NULLP;
6856 struct TAG_Config__tag_ToAddModList *tagList = NULLP;
6857 struct MAC_CellGroupConfig__phr_Config *phrConfig = NULLP;
6858 struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg = NULLP;
6859 CellGroupConfigRrc_t *cellGrpCfg = ueCfg->cellGrpCfg;
6861 if(ueCfg->ueNrCapability)
6863 freeAperDecodeUeNrCapability(ueCfg->ueNrCapability);
6864 DU_FREE(ueCfg->ueNrCapability, sizeof(UE_NR_Capability_t));
6865 ueCfg->ueNrCapability = NULLP;
6868 if(ueCfg->cellGrpCfg)
6871 rlcBearerList = cellGrpCfg->rlc_BearerToAddModList;
6874 if(rlcBearerList->list.array)
6876 for(arrIdx=0; arrIdx<rlcBearerList->list.count; arrIdx++)
6878 if(rlcBearerList->list.array[arrIdx])
6880 rlcConfig = rlcBearerList->list.array[arrIdx]->rlc_Config;
6881 macLcConfig = rlcBearerList->list.array[arrIdx]->mac_LogicalChannelConfig;
6883 if(rlcBearerList->list.array[arrIdx]->servedRadioBearer)
6885 free(rlcBearerList->list.array[arrIdx]->servedRadioBearer);
6889 if(rlcConfig->choice.am)
6891 free(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength);
6892 free(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength);
6893 free(rlcConfig->choice.am);
6895 free(rlcBearerList->list.array[arrIdx]->rlc_Config);
6899 if(macLcConfig->ul_SpecificParameters)
6901 free(macLcConfig->ul_SpecificParameters->schedulingRequestID);
6902 free(macLcConfig->ul_SpecificParameters->logicalChannelGroup);
6903 free(macLcConfig->ul_SpecificParameters);
6905 free(rlcBearerList->list.array[arrIdx]->mac_LogicalChannelConfig);
6907 free(rlcBearerList->list.array[arrIdx]);
6910 free(rlcBearerList->list.array);
6912 free(cellGrpCfg->rlc_BearerToAddModList);
6915 macCellGrpCfg = cellGrpCfg->mac_CellGroupConfig;
6918 schedulingRequestConfig = macCellGrpCfg->schedulingRequestConfig;
6919 if(schedulingRequestConfig)
6921 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
6924 if(schReqList->list.array)
6926 for(arrIdx=0;arrIdx<schReqList->list.count; arrIdx++)
6928 if(schReqList->list.array[arrIdx])
6930 free(schReqList->list.array[arrIdx]->sr_ProhibitTimer);
6931 free(schReqList->list.array[arrIdx]);
6934 free(schReqList->list.array);
6936 free(schedulingRequestConfig->schedulingRequestToAddModList);
6938 free(macCellGrpCfg->schedulingRequestConfig);
6940 if(macCellGrpCfg->bsr_Config)
6942 free(macCellGrpCfg->bsr_Config);
6944 tagConfig = macCellGrpCfg->tag_Config;
6947 tagList = tagConfig->tag_ToAddModList;
6950 if(tagList->list.array)
6952 for(arrIdx=0; arrIdx<tagList->list.count; arrIdx++)
6954 free(tagList->list.array[arrIdx]);
6956 free(tagList->list.array);
6958 free(tagConfig->tag_ToAddModList);
6963 phrConfig = macCellGrpCfg->phr_Config;
6966 free(phrConfig->choice.setup);
6970 free(macCellGrpCfg);
6973 phyCellGrpCfg = cellGrpCfg->physicalCellGroupConfig;
6976 free(phyCellGrpCfg->p_NR_FR1);
6977 free(phyCellGrpCfg);
6980 spCellCfg = cellGrpCfg->spCellConfig;
6983 if(spCellCfg->servCellIndex)
6985 if(spCellCfg->rlmInSyncOutOfSyncThreshold)
6987 if(spCellCfg->spCellConfigDedicated)
6989 srvCellCfg = spCellCfg->spCellConfigDedicated;
6990 if(srvCellCfg->initialDownlinkBWP)
6992 dlBwp = srvCellCfg->initialDownlinkBWP;
6993 if(srvCellCfg->firstActiveDownlinkBWP_Id)
6995 if(srvCellCfg->defaultDownlinkBWP_Id)
6997 if(srvCellCfg->uplinkConfig)
7000 if(srvCellCfg->pdsch_ServingCellConfig)
7003 srvCellCfg->pdsch_ServingCellConfig;
7004 if(pdschCfg->choice.setup)
7007 free(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH);
7008 free(pdschCfg->choice.setup);
7011 free(srvCellCfg->pdsch_ServingCellConfig);
7014 freeAperDecodeinitialUplinkBWPConfig(srvCellCfg->uplinkConfig);
7015 free(srvCellCfg->uplinkConfig);
7017 free(srvCellCfg->defaultDownlinkBWP_Id);
7020 free(srvCellCfg->firstActiveDownlinkBWP_Id);
7022 if(dlBwp->pdcch_Config)
7024 if(dlBwp->pdsch_Config)
7026 freeAperDecodeBWPDlDedPdschConfig(dlBwp);
7027 free(dlBwp->pdsch_Config);
7029 freeAperDecodeBWPDlDedPdcchConfig(dlBwp);
7030 free(dlBwp->pdcch_Config);
7032 free(srvCellCfg->initialDownlinkBWP);
7035 free(spCellCfg->spCellConfigDedicated);
7037 free(spCellCfg->rlmInSyncOutOfSyncThreshold);
7039 free(spCellCfg->servCellIndex);
7043 DU_FREE(ueCfg->cellGrpCfg, sizeof(CellGroupConfigRrc_t));
7044 ueCfg->cellGrpCfg = NULLP;
7048 memset(ueCfg->ambrCfg, 0, sizeof(AmbrCfg));
7049 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCfg->ambrCfg, sizeof(AmbrCfg));
7051 for(lcIdx = 0; lcIdx < ueCfg->numRlcLcs; lcIdx++)
7053 freeRlcLcCfg(&ueCfg->rlcLcCfg[lcIdx]);
7055 for(lcIdx = 0; lcIdx < ueCfg->numMacLcs; lcIdx++)
7057 freeMacLcCfg(&ueCfg->macLcCfg[lcIdx]);
7059 for(lcIdx = 0; lcIdx < ueCfg->numDrb; lcIdx++)
7061 DU_FREE(ueCfg->upTnlInfo[lcIdx].tnlCfg1, sizeof(GtpTnlCfg));
7062 memset(&ueCfg->upTnlInfo[lcIdx], 0, sizeof(UpTnlCfg));
7066 /*******************************************************************
7068 * @brief Function to free UecontextSetupDb
7072 * Function : freeF1UeDb
7074 * Functionality: Function to free UecontextSetupDb
7076 * @params[in] UecontextSetupDb *
7079 * ****************************************************************/
7081 void freeF1UeDb(F1UeContextSetupDb *f1UeDb)
7084 if(f1UeDb->dlRrcMsg)
7086 if(f1UeDb->dlRrcMsg->rrcMsgPdu)
7088 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,\
7089 f1UeDb->dlRrcMsg->rrcMsgPdu, f1UeDb->dlRrcMsg->rrcMsgSize);
7091 memset(f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
7093 freeDuUeCfg(&f1UeDb->duUeCfg);
7094 memset(f1UeDb, 0, sizeof(F1UeContextSetupDb));
7095 DU_FREE(f1UeDb, sizeof(F1UeContextSetupDb));
7098 /*******************************************************************
7100 * @brief Function to build Am cfg Info
7104 * Function : extractRlcAmCfg
7106 * Functionality: Function to build Am cfg Info
7108 * @params[in] AmBearerCfg *
7111 * @return ROK/RFAILED
7113 * ****************************************************************/
7115 void extractRlcAmCfg(AmBearerCfg *amCfgToSet, struct RLC_Config__am *rlcAmCfg)
7120 if(rlcAmCfg->dl_AM_RLC.sn_FieldLength)
7122 amCfgToSet->ulAmCfg.snLenUl = *(rlcAmCfg->dl_AM_RLC.sn_FieldLength);
7123 /*TODO: Check the timer value when sent by real CU */
7124 amCfgToSet->ulAmCfg.reAssemTmr = rlcAmCfg->dl_AM_RLC.t_Reassembly;
7125 amCfgToSet->ulAmCfg.statProhTmr = rlcAmCfg->dl_AM_RLC.t_StatusProhibit;
7129 if(rlcAmCfg->ul_AM_RLC.sn_FieldLength)
7131 amCfgToSet->dlAmCfg.snLenDl = *(rlcAmCfg->ul_AM_RLC.sn_FieldLength);
7132 amCfgToSet->dlAmCfg.pollRetxTmr = rlcAmCfg->ul_AM_RLC.t_PollRetransmit;
7133 amCfgToSet->dlAmCfg.pollPdu = rlcAmCfg->ul_AM_RLC.pollPDU;
7134 amCfgToSet->dlAmCfg.pollByte = rlcAmCfg->ul_AM_RLC.pollByte;
7135 amCfgToSet->dlAmCfg.maxRetxTh = rlcAmCfg->ul_AM_RLC.maxRetxThreshold;
7140 /*******************************************************************
7142 * @brief Function to build Um Bi Info
7146 * Function : extractRlcUmBiCfg
7148 * Functionality: Function to build Um Bi Info
7150 * @params[in] UmBiDirBearerCfg *
7153 * @return ROK/RFAILED
7155 * ****************************************************************/
7157 void extractRlcUmBiCfg(UmBiDirBearerCfg *umBiCfgToSet, struct RLC_Config__um_Bi_Directional *rlcBiCfg)
7161 /* UL UM BI DIR Cfg */
7162 if(rlcBiCfg->dl_UM_RLC.sn_FieldLength)
7164 umBiCfgToSet->ulUmCfg.snLenUlUm = *(rlcBiCfg->dl_UM_RLC.sn_FieldLength);
7165 umBiCfgToSet->ulUmCfg.reAssemTmr = rlcBiCfg->dl_UM_RLC.t_Reassembly;
7168 /* DL UM BI DIR Cfg */
7169 if(rlcBiCfg->ul_UM_RLC.sn_FieldLength)
7170 umBiCfgToSet->dlUmCfg.snLenDlUm = *(rlcBiCfg->ul_UM_RLC.sn_FieldLength);
7174 /*******************************************************************
7176 * @brief Function to build Um Ul Info
7180 * Function : extractRlcUmUlCfg
7182 * Functionality: Function to build Um Ul Info
7184 * @params[in] UmUniDirUlBearerCfg *
7187 * @return ROK/RFAILED
7189 * ****************************************************************/
7191 void extractRlcUmUlCfg(UmUniDirUlBearerCfg *umUlCfgToSet, struct RLC_Config__um_Uni_Directional_DL *umUlCfg)
7195 if(umUlCfg->dl_UM_RLC.sn_FieldLength)
7197 umUlCfgToSet->ulUmCfg.snLenUlUm = *(umUlCfg->dl_UM_RLC.sn_FieldLength);
7198 umUlCfgToSet->ulUmCfg.reAssemTmr = umUlCfg->dl_UM_RLC.t_Reassembly;
7203 /*******************************************************************
7205 * @brief Function to build Um Uni Dl Info
7209 * Function : extractRlcUmDlCfg
7211 * Functionality: Function to build Um Uni Dl Info
7213 * @params[in] UmUniDirDlBearerCfg *
7216 * @return ROK/RFAILED
7218 * ****************************************************************/
7219 void extractRlcUmDlCfg(UmUniDirDlBearerCfg *umDlCfgToSet, struct RLC_Config__um_Uni_Directional_UL *umDlCfg)
7223 if(umDlCfg->ul_UM_RLC.sn_FieldLength)
7224 umDlCfgToSet->dlUmCfg.snLenDlUm = *(umDlCfg->ul_UM_RLC.sn_FieldLength);
7228 /*******************************************************************
7230 * @brief Function to extractRlcModeCfg
7234 * Function : extractRlcModeCfg
7236 * Functionality: Function to extractRlcModeCfg
7238 * @params[in] RLC_Config_t *
7241 * @return ROK/RFAILED
7243 * ****************************************************************/
7244 void extractRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *rlcDbCfg, RLC_Config_t *lcCfg)
7252 if(lcCfg->choice.am)
7254 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.amCfg, sizeof(AmBearerCfg));
7255 if(rlcDbCfg->u.amCfg)
7256 extractRlcAmCfg(rlcDbCfg->u.amCfg, lcCfg->choice.am);
7260 case RLC_UM_BI_DIRECTIONAL :
7262 if(lcCfg->choice.um_Bi_Directional)
7264 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
7265 if(rlcDbCfg->u.umBiDirCfg)
7266 extractRlcUmBiCfg(rlcDbCfg->u.umBiDirCfg, lcCfg->choice.um_Bi_Directional);
7270 case RLC_UM_UNI_DIRECTIONAL_UL :
7272 if(lcCfg->choice.um_Uni_Directional_DL)
7274 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
7275 if(rlcDbCfg->u.umUniDirUlCfg)
7276 extractRlcUmUlCfg(rlcDbCfg->u.umUniDirUlCfg, lcCfg->choice.um_Uni_Directional_DL);
7280 case RLC_UM_UNI_DIRECTIONAL_DL :
7282 if(lcCfg->choice.um_Uni_Directional_UL)
7284 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
7285 if(rlcDbCfg->u.umUniDirDlCfg)
7286 extractRlcUmDlCfg(rlcDbCfg->u.umUniDirDlCfg, lcCfg->choice.um_Uni_Directional_UL);
7291 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
7297 /*******************************************************************
7299 * @brief Function to extract extractUlLcCfg
7303 * Function : extractUlLcCfg
7305 * Functionality: Function to extract extractUlLcCfg
7307 * @params[in] UlLcCfg *f1UlLcCfg, LogicalChannelConfig_t *ulLcCfg
7310 * ****************************************************************/
7312 void extractUlLcCfg(UlLcCfg *f1UlLcCfg, LogicalChannelConfig_t *ulLcCfg)
7316 if(ulLcCfg->ul_SpecificParameters)
7318 f1UlLcCfg->priority = \
7319 ulLcCfg->ul_SpecificParameters->priority;
7320 if(ulLcCfg->ul_SpecificParameters->logicalChannelGroup)
7322 f1UlLcCfg->lcGroup = \
7323 *(ulLcCfg->ul_SpecificParameters->logicalChannelGroup);
7325 if(ulLcCfg->ul_SpecificParameters->schedulingRequestID)
7327 f1UlLcCfg->schReqId = \
7328 *(ulLcCfg->ul_SpecificParameters->schedulingRequestID);
7331 ulLcCfg->ul_SpecificParameters->prioritisedBitRate;
7333 ulLcCfg->ul_SpecificParameters->bucketSizeDuration;
7338 /*******************************************************************
7340 * @brief Function to procRlcLcCfg
7344 * Function : procRlcLcCfg
7346 * Functionality: Function to procRlcLcCfg
7348 * @params[in] rbId, lcId, rbType, rlcMod
7349 * RLC_Config_t *, RlcBearerCfg * ,
7352 * ****************************************************************/
7354 void procRlcLcCfg(uint8_t rbId, uint8_t lcId, uint8_t rbType, uint8_t rlcMode,\
7355 uint8_t configType, RLC_Config_t *f1RlcCfg, RlcBearerCfg *lcCfg)
7359 lcCfg->configType = configType;
7361 if(rbType == RB_TYPE_SRB)
7363 lcCfg->rbType = RB_TYPE_SRB;
7365 lcCfg->lcType = LCH_DCCH;
7366 lcCfg->rlcMode = RLC_AM;
7368 else if(rbType == RB_TYPE_DRB)
7370 lcCfg->rbType = RB_TYPE_DRB;
7372 lcCfg->lcType = LCH_DTCH;
7373 lcCfg->rlcMode = rlcMode;
7375 if(f1RlcCfg) /* rlc mode config recived */
7377 extractRlcModeCfg(lcCfg->rlcMode, lcCfg, f1RlcCfg);
7383 /*******************************************************************
7385 * @brief Fills DrbQos Info received by CU
7389 * Function : extractQosInfo
7391 * Functionality: Fills DrbQos Info received by CU
7393 * @params[in] DrbQosInfo *qosToAdd,
7394 * QoSFlowLevelQoSParameters_t *qosFlowCfg
7397 * ****************************************************************/
7399 void extractQosInfo(DrbQosInfo *qosToAdd, QoSFlowLevelQoSParameters_t *qosFlowCfg)
7401 qosToAdd->fiveQiType = qosFlowCfg->qoS_Characteristics.present;
7402 qosToAdd->u.nonDyn5Qi.fiveQi =\
7403 qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->fiveQI;
7404 if(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow)
7406 qosToAdd->u.nonDyn5Qi.avgWindow = \
7407 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
7409 qosToAdd->u.nonDyn5Qi.maxDataBurstVol = \
7410 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
7411 if(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->qoSPriorityLevel)
7413 qosToAdd->u.nonDyn5Qi.priorLevel = \
7414 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->qoSPriorityLevel);
7416 qosToAdd->ngRanRetPri.priorityLevel = \
7417 qosFlowCfg->nGRANallocationRetentionPriority.priorityLevel;
7418 qosToAdd->ngRanRetPri.preEmptionCap = \
7419 qosFlowCfg->nGRANallocationRetentionPriority.pre_emptionCapability;
7420 qosToAdd->ngRanRetPri.preEmptionVul = \
7421 qosFlowCfg->nGRANallocationRetentionPriority.pre_emptionVulnerability;
7422 if(qosFlowCfg->gBR_QoS_Flow_Information)
7424 memcpy(&qosToAdd->grbQosInfo.maxFlowBitRateDl, \
7425 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateDownlink.buf, \
7426 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateDownlink.size);
7427 memcpy(&qosToAdd->grbQosInfo.maxFlowBitRateUl, \
7428 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateUplink.buf, \
7429 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateUplink.size);
7430 memcpy(&qosToAdd->grbQosInfo.guarFlowBitRateDl,\
7431 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateDownlink.buf, \
7432 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateDownlink.size);
7433 memcpy(&qosToAdd->grbQosInfo.guarFlowBitRateUl,\
7434 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateUplink.buf, \
7435 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateUplink.size);
7437 qosToAdd->pduSessionId = 0;
7438 qosToAdd->ulPduSessAggMaxBitRate = 0;
7441 /*******************************************************************
7443 * @brief Function to extract GTP Tunnel Info from CU
7447 * Function : extractUpTnlInfo
7449 * Functionality: Function to extract GTP Tunnel Info from CU
7451 * @params[in] F1AP message
7452 * @return ROK/RFAILED
7454 * ****************************************************************/
7456 uint8_t extractUpTnlInfo(uint8_t drbId, uint8_t configType,\
7457 ULUPTNLInformation_ToBeSetup_List_t *tnlInfo, UpTnlCfg *upTnlInfo)
7460 uint32_t ipv4_du = 0;
7461 GTPTunnel_t *gtpTunnel = NULLP;
7463 upTnlInfo->drbId = drbId;
7464 upTnlInfo->configType = configType;
7466 cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
7468 cmInetAddr((char *)DU_IP_V4_ADDR, &ipv4_du);
7471 for(tnlIdx=0; tnlIdx < tnlInfo->list.count; tnlIdx++)
7473 if(tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.present == UPTransportLayerInformation_PR_gTPTunnel)
7475 if(tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.choice.gTPTunnel)
7477 gtpTunnel = tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.choice.gTPTunnel;
7478 DU_ALLOC(upTnlInfo->tnlCfg1, sizeof(GtpTnlCfg));
7479 if(upTnlInfo->tnlCfg1 == NULLP)
7481 DU_LOG("\nERROR --> F1AP : extractUpTnlInfo: Failed to allocate mmeory for tunnel cfg 1");
7484 bitStringToInt(>pTunnel->transportLayerAddress, &upTnlInfo->tnlCfg1->ulTnlAddress);
7485 upTnlInfo->tnlCfg1->dlTnlAddress = ipv4_du;
7486 if(gtpTunnel->gTP_TEID.size > 0)
7488 teIdStringToInt(gtpTunnel->gTP_TEID.buf, &upTnlInfo->tnlCfg1->teId);
7496 /*******************************************************************
7498 * @brief Function to extract Drb Qos Cfg Info from CU
7502 * Function : extractDrbQosCfg
7504 * Functionality: Function to extract Drb Qos Cfg Info from CU
7506 * @params[in] DRB_Information_t *drbInfo, LcCfg *macLcToAdd
7507 * @return ROK/RFAILED
7509 * ****************************************************************/
7511 uint8_t extractDrbQosCfg(DRB_Information_t *drbInfo, LcCfg *macLcToAdd )
7513 if(!macLcToAdd->drbQos)
7515 DU_ALLOC_SHRABL_BUF(macLcToAdd->drbQos, sizeof(DrbQosInfo));
7516 if(macLcToAdd->drbQos == NULLP)
7518 DU_LOG("\nERROR --> DUAPP:Memory failed at allocating DrbQos at extractDrbCfg()");
7523 if(drbInfo->dRB_QoS.qoS_Characteristics.present == QoS_Characteristics_PR_non_Dynamic_5QI)
7525 extractQosInfo(macLcToAdd->drbQos, &drbInfo->dRB_QoS);
7526 macLcToAdd->dlLcCfg.lcp = macLcToAdd->drbQos->ngRanRetPri.priorityLevel;
7528 if(!macLcToAdd->snssai)
7530 DU_ALLOC_SHRABL_BUF(macLcToAdd->snssai, sizeof(Snssai));
7531 if(macLcToAdd->snssai == NULLP)
7533 DU_LOG("\nERROR --> DUAPP : Memory failed at allocating SNSSAI at extractDrbCfg()");
7537 memcpy(&macLcToAdd->snssai->sst, drbInfo->sNSSAI.sST.buf, \
7538 drbInfo->sNSSAI.sST.size);
7539 if(drbInfo->sNSSAI.sD)
7541 memcpy(macLcToAdd->snssai->sd, drbInfo->sNSSAI.sD->buf, \
7542 drbInfo->sNSSAI.sD->size);
7546 /*******************************************************************
7548 * @brief Function to extract DRB info received from CU
7552 * Function : extractDrbCfg
7554 * Functionality: Function to extract DRB info received from CU
7556 * @params[in] F1AP message
7559 * ****************************************************************/
7560 uint8_t extractDrbCfg(DRBs_ToBeSetup_Item_t *drbItem,DRBs_ToBeSetupMod_Item_t *drbSetupModItem,\
7561 LcCfg *macLcToAdd, UpTnlCfg *upTnlInfo)
7563 DRB_Information_t *drbInfo = NULLP;
7565 if(drbItem != NULLP)
7567 if(extractUpTnlInfo(drbItem->dRBID, CONFIG_ADD, &drbItem->uLUPTNLInformation_ToBeSetup_List, upTnlInfo) != ROK)
7569 DU_LOG("\nERROR --> DUAPP : Failed to extract tunnel Cfg at extractDrbCfg()");
7572 if(drbItem->qoSInformation.present == QoSInformation_PR_choice_extension)
7574 if(drbItem->qoSInformation.choice.choice_extension->value.present == QoSInformation_ExtIEs__value_PR_DRB_Information)
7576 drbInfo = &drbItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information;
7577 if(extractDrbQosCfg(drbInfo , macLcToAdd) != ROK)
7579 DU_LOG("\nERROR --> DUAPP : Failed to extract qos Cfg at extractDrbCfg()");
7585 else if(drbSetupModItem != NULLP)
7587 if(extractUpTnlInfo(drbSetupModItem->dRBID, CONFIG_ADD, &drbSetupModItem->uLUPTNLInformation_ToBeSetup_List,\
7590 DU_LOG("\nERROR --> DUAPP : Failed to extract tunnel Cfg at extractDrbCfg()");
7593 if(drbSetupModItem->qoSInformation.present == QoSInformation_PR_choice_extension)
7595 if(drbSetupModItem->qoSInformation.choice.choice_extension->value.present ==\
7596 QoSInformation_ExtIEs__value_PR_DRB_Information)
7598 drbInfo = &drbSetupModItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information;
7599 if(extractDrbQosCfg(drbInfo , macLcToAdd) != ROK)
7601 DU_LOG("\nERROR --> DUAPP : Failed to extract qos Cfg at extractDrbCfg()");
7612 /*******************************************************************
7614 * @brief Function to extract RB info received from CU
7618 * Function : extractMacRbCfg
7620 * Functionality: Function to extract RB info received from CU
7622 * @params[in] F1AP message
7623 * @return ROK/RFAILED
7625 * ****************************************************************/
7627 uint8_t extractMacRbCfg(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbCfg,\
7628 DRBs_ToBeSetupMod_Item_t *drbSetupModCfg, LogicalChannelConfig_t *ulLcCfg, LcCfg *lcCfg, UpTnlCfg *upTnlInfo)
7632 if(extractDrbCfg(drbCfg, NULL, lcCfg, upTnlInfo) != ROK)
7634 DU_LOG("ERROR --> F1AP : Failed to build Drb Qos at extractMacRbCfg()");
7638 else if(drbSetupModCfg != NULLP)
7640 if(extractDrbCfg(NULL, drbSetupModCfg, lcCfg, upTnlInfo) != ROK)
7642 DU_LOG("ERROR --> F1AP : Failed to build Drb Qos at extractMacRbCfg()");
7648 lcCfg->drbQos = NULLP;
7649 lcCfg->snssai = NULLP;
7650 if(lcCfg->lcId == SRB2_LCID)
7651 lcCfg->dlLcCfg.lcp = LC_PRIORITY_3;
7653 lcCfg->dlLcCfg.lcp = LC_PRIORITY_1;
7657 lcCfg->ulLcCfgPres = true;
7658 extractUlLcCfg(&lcCfg->ulLcCfg, ulLcCfg);
7661 lcCfg->ulLcCfgPres = false;
7665 /*******************************************************************
7667 * @brief Function processing LC config info received from CU
7671 * Function : procMacLcCfg
7673 * Functionality: Function processing LC config info received from CU
7675 * @params[in] F1AP message
7676 * @return ROK/RFAILED
7678 * ****************************************************************/
7680 uint8_t procMacLcCfg(uint8_t lcId, uint8_t rbType, uint8_t configType,\
7681 DRBs_ToBeSetup_Item_t *drbItem, DRBs_ToBeSetupMod_Item_t *drbSetupModItem, LogicalChannelConfig_t *ulLcCfg,\
7682 LcCfg *lcCfg, UpTnlCfg *upTnlInfo)
7687 lcCfg->configType = configType;
7688 if(rbType == RB_TYPE_SRB)
7690 ret = extractMacRbCfg(lcId, NULL,NULL, ulLcCfg, lcCfg, NULL);
7692 else if(rbType == RB_TYPE_DRB)
7695 ret = extractMacRbCfg(lcId, drbItem, NULL, ulLcCfg, lcCfg, upTnlInfo);
7696 else if(drbSetupModItem != NULL)
7697 ret = extractMacRbCfg(lcId, NULL, drbSetupModItem, ulLcCfg, lcCfg, upTnlInfo);
7702 /*******************************************************************
7704 * @brief Function to extract Rlc cfg To Add/Mod in CellGrp Info
7708 * Function : extractRlcCfgToAddMod
7710 * Functionality: Function to extract Rlc cfg To Add/Mod in CellGrp Info
7712 * @params[in] CellGroupConfigRrc__rlc_BearerTo pointer
7714 * @return ROK/RFAILED
7716 * ****************************************************************/
7718 uint8_t extractRlcCfgToAddMod(struct CellGroupConfigRrc__rlc_BearerToAddModList *lcCfg, DuUeCfg *ueCfgDb)
7720 uint8_t idx, rbId, lcId, rlcMode, rbType;
7721 RLC_Config_t *f1RlcCfg = NULLP;
7722 LogicalChannelConfig_t *macUlLcCfg = NULLP;
7724 for(idx = 0; idx < lcCfg->list.count; idx++)
7726 lcId = lcCfg->list.array[idx]->logicalChannelIdentity;
7727 if(lcCfg->list.array[idx]->servedRadioBearer)
7729 /* RadioBearer for SRB/DRB */
7730 if(lcCfg->list.array[idx]->servedRadioBearer->present ==\
7731 RLC_BearerConfig__servedRadioBearer_PR_srb_Identity)
7733 rbId = lcCfg->list.array[idx]->servedRadioBearer->choice.srb_Identity;
7734 rbType = RB_TYPE_SRB;
7736 else if(lcCfg->list.array[idx]->servedRadioBearer->present ==\
7737 RLC_BearerConfig__servedRadioBearer_PR_drb_Identity)
7739 rbId = lcCfg->list.array[idx]->servedRadioBearer->choice.drb_Identity;
7740 rbType = RB_TYPE_DRB;
7744 DU_LOG("\nERROR --> No components present in Bearer config to ADD/MOD");
7747 /* MAC UL LC Config */
7748 if(lcCfg->list.array[idx]->mac_LogicalChannelConfig)
7750 macUlLcCfg = lcCfg->list.array[idx]->mac_LogicalChannelConfig;
7755 DU_LOG("\nERROR --> DUAPP: Received RadioBearer config is NULL");
7758 /* RLC Mode Config */
7759 if(lcCfg->list.array[idx]->rlc_Config)
7761 rlcMode = lcCfg->list.array[idx]->rlc_Config->present;
7762 f1RlcCfg = lcCfg->list.array[idx]->rlc_Config;
7765 /* Filling RLC/MAC Config*/
7766 memset(&ueCfgDb->macLcCfg[idx], 0, sizeof(LcCfg));
7767 memset(&ueCfgDb->rlcLcCfg[idx], 0, sizeof(RlcBearerCfg));
7768 procRlcLcCfg(rbId, lcId, rbType, rlcMode, CONFIG_UNKNOWN, f1RlcCfg, &(ueCfgDb->rlcLcCfg[idx]));
7769 if(procMacLcCfg(lcId, rbType, CONFIG_UNKNOWN, NULL, NULL, macUlLcCfg, &ueCfgDb->macLcCfg[idx], NULL) != ROK)
7771 DU_LOG("\nERROR --> DU APP : Failed while filling MAC LC config at extractRlcCfgToAddMod()");
7774 (ueCfgDb->numRlcLcs)++;
7775 (ueCfgDb->numMacLcs)++;
7777 //TODO: To send the failure cause in UeContextSetupRsp
7781 /*******************************************************************
7783 * @brief DeAlloc pdsch serv cell config info
7787 * Function : freeMacPdschServCellInfo
7789 * Functionality: DeAlloc pdsch serv cell config info
7791 * @params[in] PdschServCellCfg pointer
7794 * ****************************************************************/
7796 void freeMacPdschServCellInfo(PdschServCellCfg *pdsch)
7798 if(pdsch->xOverhead)
7800 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->xOverhead, sizeof(PdschXOverhead));
7802 if(pdsch->codeBlkGrpFlushInd)
7804 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->codeBlkGrpFlushInd, sizeof(bool));
7806 if(pdsch->maxCodeBlkGrpPerTb)
7808 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
7810 if(pdsch->maxMimoLayers)
7812 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->maxMimoLayers, sizeof(uint8_t));
7816 /*******************************************************************
7818 * @brief Free Serving cell Info
7822 * Function : freeMacServingCellInfo
7824 * Functionality: Free Serving cell Info
7826 * @params[in] ServCellCfgInfo *srvCellCfg
7829 * ****************************************************************/
7830 void freeMacServingCellInfo(ServCellCfgInfo *srvCellCfg)
7832 freeMacPdschServCellInfo(&srvCellCfg->pdschServCellCfg);
7833 if(srvCellCfg->bwpInactivityTmr)
7835 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, srvCellCfg->bwpInactivityTmr, sizeof(uint8_t));
7839 /*******************************************************************
7841 * @brief Free cell Grp Cfg Info
7845 * Function : freeUeReCfgCellGrpInfo
7847 * Functionality: Free cell Grp Cfg Info
7849 * @params[in] MacUeCfg* duUeCfg
7852 * ****************************************************************/
7854 void freeUeReCfgCellGrpInfo(MacUeCfg *macUeCfg)
7856 freeMacServingCellInfo(&macUeCfg->spCellCfg.servCellCfg);
7859 /*******************************************************************
7861 * @brief Fills Reconfig SchReqReConfig
7865 * Function : extractSchReqReConfig
7867 * Functionality: Fills Reconfig SchReqReConfig
7869 * @params[in] SchedulingRequestConfig_t *cuSchedReq
7870 * SchedReqCfg* macSchedReq
7873 * ****************************************************************/
7874 void extractSchReqReConfig(SchedulingRequestConfig_t *cuSchedReq, SchedReqCfg *macSchedReq)
7876 uint8_t schReqIdx = 0;
7877 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqListToAdd = NULLP;
7878 struct SchedulingRequestConfig__schedulingRequestToReleaseList *schReqListToRel = NULLP;
7880 if(cuSchedReq->schedulingRequestToAddModList)
7882 schReqListToAdd = cuSchedReq->schedulingRequestToAddModList;
7883 if(schReqListToAdd->list.count)
7885 macSchedReq->addModListCount = schReqListToAdd->list.count;
7886 for(schReqIdx = 0; schReqIdx < schReqListToAdd->list.count; schReqIdx++)
7888 macSchedReq->addModList[schReqIdx].schedReqId = \
7889 schReqListToAdd->list.array[schReqIdx]->schedulingRequestId;
7890 macSchedReq->addModList[schReqIdx].srProhibitTmr = \
7891 *(schReqListToAdd->list.array[schReqIdx]->sr_ProhibitTimer);
7892 macSchedReq->addModList[schReqIdx].srTransMax =\
7893 schReqListToAdd->list.array[schReqIdx]->sr_TransMax;
7897 /* Scheduling Req To release */
7898 if(cuSchedReq->schedulingRequestToReleaseList)
7900 schReqListToRel = cuSchedReq->schedulingRequestToReleaseList;
7901 if(schReqListToRel->list.count)
7903 macSchedReq->relListCount = schReqListToRel->list.count;
7904 for(schReqIdx = 0; schReqIdx < schReqListToRel->list.count; schReqIdx++)
7906 macSchedReq->relList[schReqIdx] = \
7907 *schReqListToRel->list.array[schReqIdx];
7913 /*******************************************************************
7915 * @brief Fills TagReconfig
7919 * Function : extractTagReconfig
7921 * Functionality: Fills extractTagReconfig
7923 * @params[in] TAG_Config_t *cuTagCfg
7927 * ****************************************************************/
7929 void extractTagReconfig(TAG_Config_t *cuTagCfg, TagCfg *macTagCfg)
7932 struct TAG_Config__tag_ToAddModList *tagListToAddMod = NULLP;
7933 struct TAG_Config__tag_ToReleaseList *tagListToRel = NULLP;
7935 /* Tag config to AddMod */
7936 if(cuTagCfg->tag_ToAddModList)
7938 tagListToAddMod = cuTagCfg->tag_ToAddModList;
7939 if(tagListToAddMod->list.count)
7941 macTagCfg->addModListCount = tagListToAddMod->list.count;
7942 for(tagIdx = 0; tagIdx < tagListToAddMod->list.count; tagIdx++)
7944 macTagCfg->addModList[tagIdx].tagId =\
7945 tagListToAddMod->list.array[tagIdx]->tag_Id;
7946 macTagCfg->addModList[tagIdx].timeAlignTimer = \
7948 tagListToAddMod->list.array[tagIdx]->timeAlignmentTimer;
7952 /* Tag config to release */
7953 if(cuTagCfg->tag_ToReleaseList)
7955 tagListToRel = cuTagCfg->tag_ToReleaseList;
7956 if(tagListToRel->list.count)
7958 macTagCfg->relListCount = tagListToRel->list.count;
7959 for(tagIdx = 0; tagIdx < tagListToRel->list.count; tagIdx++)
7961 macTagCfg->relList[tagIdx] = *tagListToRel->list.array[tagIdx];
7967 /*******************************************************************
7969 * @brief Fills PdcchCfg received by CU
7973 * Function : extractPdcchCfg
7975 * Functionality: Fills PdcchCfg received by CU
7977 * @params[in] PDCCH_Config_t *cuPdcchCfg,
7978 * PdcchConfig *duPdcchCfg
7981 * ****************************************************************/
7983 void extractPdcchCfg(PDCCH_Config_t *cuPdcchCfg, PdcchConfig *macPdcchCfg)
7985 uint8_t cRsetIdx = 0;
7986 uint8_t srchSpcIdx = 0;
7988 struct PDCCH_Config__controlResourceSetToAddModList *cRsetToAddModList = NULLP;
7989 struct PDCCH_Config__controlResourceSetToReleaseList *cRsetToRelList = NULLP;
7990 struct PDCCH_Config__searchSpacesToAddModList *srchSpcToAddModList = NULLP;
7991 struct PDCCH_Config__searchSpacesToReleaseList *srchSpcToRelList = NULLP;
7994 /* Control Resource Set To Add/Mod List */
7995 if(cuPdcchCfg->controlResourceSetToAddModList)
7997 cRsetToAddModList = cuPdcchCfg->controlResourceSetToAddModList;
7998 if(cRsetToAddModList->list.count)
8000 macPdcchCfg->numCRsetToAddMod = cRsetToAddModList->list.count;
8001 for(cRsetIdx = 0; cRsetIdx < cRsetToAddModList->list.count; cRsetIdx++)
8003 macPdcchCfg->cRSetToAddModList[cRsetIdx].cRSetId = \
8004 cRsetToAddModList->list.array[cRsetIdx]->controlResourceSetId;
8005 bitStringToInt(&cRsetToAddModList->list.array[cRsetIdx]->frequencyDomainResources,\
8006 macPdcchCfg->cRSetToAddModList[cRsetIdx].freqDomainRsrc);
8007 macPdcchCfg->cRSetToAddModList[cRsetIdx].duration = \
8008 cRsetToAddModList->list.array[cRsetIdx]->duration;
8010 macPdcchCfg->cRSetToAddModList[cRsetIdx].cceRegMappingType = \
8011 cRsetToAddModList->list.array[cRsetIdx]->cce_REG_MappingType.present;
8012 if(macPdcchCfg->cRSetToAddModList[cRsetIdx].cceRegMappingType == CCE_REG_MAPPINGTYPE_PR_INTERLEAVED)
8014 //TODO: handle the case for Interleaved
8016 macPdcchCfg->cRSetToAddModList[cRsetIdx].precoderGranularity = \
8017 cRsetToAddModList->list.array[cRsetIdx]->precoderGranularity;
8018 if(cRsetToAddModList->list.array[cRsetIdx]->pdcch_DMRS_ScramblingID)
8020 macPdcchCfg->cRSetToAddModList[cRsetIdx].dmrsScramblingId= \
8021 *(cRsetToAddModList->list.array[cRsetIdx]->pdcch_DMRS_ScramblingID);
8027 /* Control Resource Set To Release List */
8028 if(cuPdcchCfg->controlResourceSetToReleaseList)
8030 cRsetToRelList = cuPdcchCfg->controlResourceSetToReleaseList;
8031 if(cRsetToRelList->list.count)
8033 macPdcchCfg->numCRsetToRel = cRsetToRelList->list.count;
8034 for(cRsetIdx = 0; cRsetIdx < cRsetToRelList->list.count; cRsetIdx++)
8036 macPdcchCfg->cRSetToRelList[cRsetIdx] = *(cRsetToRelList->list.array[cRsetIdx]);
8041 /* Search space To Add/Mod List */
8042 if(cuPdcchCfg->searchSpacesToAddModList)
8044 srchSpcToAddModList = cuPdcchCfg->searchSpacesToAddModList;
8045 if(srchSpcToAddModList->list.count)
8047 macPdcchCfg->numSearchSpcToAddMod = srchSpcToAddModList->list.count;
8048 for(srchSpcIdx = 0; srchSpcIdx < srchSpcToAddModList->list.count; srchSpcIdx++)
8050 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceId =\
8051 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceId;
8052 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].cRSetId =\
8053 *(srchSpcToAddModList->list.array[srchSpcIdx]->controlResourceSetId);
8054 if(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSlotPeriodicityAndOffset)
8056 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].mSlotPeriodicityAndOffset =\
8057 srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSlotPeriodicityAndOffset->present;
8059 if(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSymbolsWithinSlot)
8061 bitStringToInt(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSymbolsWithinSlot,\
8062 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].mSymbolsWithinSlot);
8064 if(srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates)
8066 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel1 = \
8067 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel1;
8068 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel2 = \
8069 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel2;
8070 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel4 = \
8071 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel4;
8073 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel8 = \
8074 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel8;
8076 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel16 = \
8077 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel16;
8079 if(srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType)
8081 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceType =\
8082 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType->present;
8083 if(macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceType == SEARCHSPACETYPE_PR_UE_SPECIFIC)
8085 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].ueSpecificDciFormat =\
8086 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType->choice.ue_Specific->dci_Formats;
8093 /* Search space To Rel List */
8094 if(cuPdcchCfg->searchSpacesToReleaseList)
8096 srchSpcToRelList = cuPdcchCfg->searchSpacesToReleaseList;
8097 if(srchSpcToRelList->list.count)
8099 macPdcchCfg->numSearchSpcToRel = srchSpcToRelList->list.count;
8100 for(srchSpcIdx = 0; srchSpcIdx < srchSpcToRelList->list.count; srchSpcIdx++)
8102 macPdcchCfg->searchSpcToRelList[srchSpcIdx] =\
8103 *(srchSpcToRelList->list.array[srchSpcIdx]);
8109 /*******************************************************************
8111 * @brief Fills PdschCfg received by CU
8115 * Function : extractPdschCfg
8117 * Functionality: Fills PdschCfg received by CU
8119 * @params[in] PDSCH_Config_t *cuPdschCfg,
8120 * PdschConfig *macPdschCfg
8123 * ****************************************************************/
8125 void extractPdschCfg(PDSCH_Config_t *cuPdschCfg, PdschConfig *macPdschCfg)
8128 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAlloc = NULLP;
8130 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
8132 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->present == \
8133 PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA_PR_setup)
8135 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)
8137 macPdschCfg->dmrsDlCfgForPdschMapTypeA.addPos = \
8138 *(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition);
8142 macPdschCfg->resourceAllocType = cuPdschCfg->resourceAllocation;
8143 if(cuPdschCfg->pdsch_TimeDomainAllocationList)
8145 timeDomAlloc = cuPdschCfg->pdsch_TimeDomainAllocationList;
8146 if(timeDomAlloc->present ==\
8147 PDSCH_Config__pdsch_TimeDomainAllocationList_PR_setup)
8149 if(timeDomAlloc->choice.setup)
8151 macPdschCfg->numTimeDomRsrcAlloc = timeDomAlloc->choice.setup->list.count;
8152 for(timeDomIdx = 0; timeDomIdx < timeDomAlloc->choice.setup->list.count; timeDomIdx++)
8154 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].mappingType = \
8155 timeDomAlloc->choice.setup->list.array[timeDomIdx]->mappingType;
8156 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].startSymbolAndLength = \
8157 timeDomAlloc->choice.setup->list.array[timeDomIdx]->startSymbolAndLength;
8162 macPdschCfg->rbgSize = cuPdschCfg->rbg_Size;
8163 if(cuPdschCfg->maxNrofCodeWordsScheduledByDCI)
8164 macPdschCfg->numCodeWordsSchByDci = *(cuPdschCfg->maxNrofCodeWordsScheduledByDCI);
8165 if(cuPdschCfg->prb_BundlingType.present == PDSCH_Config__prb_BundlingType_PR_staticBundling)
8167 macPdschCfg->bundlingType = cuPdschCfg->prb_BundlingType.present;
8168 if(cuPdschCfg->prb_BundlingType.choice.staticBundling)
8170 if(cuPdschCfg->prb_BundlingType.choice.staticBundling->bundleSize)
8172 macPdschCfg->bundlingInfo.StaticBundling.size = \
8173 *(cuPdschCfg->prb_BundlingType.choice.staticBundling->bundleSize);
8177 else if(cuPdschCfg->prb_BundlingType.present == PDSCH_Config__prb_BundlingType_PR_dynamicBundling)
8179 macPdschCfg->bundlingType = cuPdschCfg->prb_BundlingType.present;
8184 /*******************************************************************
8186 * @brief Fills PdschServingCellCfg received by CU
8190 * Function : extractPdschServingCellCfg
8192 * Functionality: Fills PdschCfg received by CU
8194 * @params[in] PDSCH_ServingCellConfig_t *cuPdschSrvCellCfg,
8195 * PdschServCellCfg *macUePdschSrvCellCfg
8196 * @return ROK/RFAILED
8198 * ****************************************************************/
8200 uint8_t extractPdschServingCellCfg(PDSCH_ServingCellConfig_t *cuPdschSrvCellCfg, PdschServCellCfg *macUePdschSrvCellCfg)
8202 if(cuPdschSrvCellCfg->codeBlockGroupTransmission)
8204 if(cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup)
8206 if(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb)
8208 *(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb) = \
8209 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock;
8213 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
8214 if(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb)
8216 *(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb) = \
8217 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock;
8221 DU_LOG("\nERROR --> DU APP : Memory allocation failed for maxCodeBlkGrpPerTb at extractPdschServingCellCfg()");
8225 if(macUePdschSrvCellCfg->codeBlkGrpFlushInd)
8227 *(macUePdschSrvCellCfg->codeBlkGrpFlushInd) = \
8228 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->codeBlockGroupFlushIndicator;
8232 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->codeBlkGrpFlushInd , sizeof(bool));
8233 if(macUePdschSrvCellCfg->codeBlkGrpFlushInd)
8235 *(macUePdschSrvCellCfg->codeBlkGrpFlushInd) = \
8236 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->codeBlockGroupFlushIndicator;
8240 DU_LOG("\nERROR --> DU APP : Memory allocation failed for codeBlkGrpFlushInd at extractPdschServingCellCfg()");
8246 if(cuPdschSrvCellCfg->nrofHARQ_ProcessesForPDSCH)
8248 macUePdschSrvCellCfg->numHarqProcForPdsch = *(cuPdschSrvCellCfg->nrofHARQ_ProcessesForPDSCH);
8250 if(cuPdschSrvCellCfg->ext1)
8252 if(cuPdschSrvCellCfg->ext1->maxMIMO_Layers)
8254 if(macUePdschSrvCellCfg->maxMimoLayers)
8256 *(macUePdschSrvCellCfg->maxMimoLayers) = *(cuPdschSrvCellCfg->ext1->maxMIMO_Layers);
8260 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->maxMimoLayers, sizeof(uint8_t));
8261 if(macUePdschSrvCellCfg->maxMimoLayers)
8263 *(macUePdschSrvCellCfg->maxMimoLayers) = *(cuPdschSrvCellCfg->ext1->maxMIMO_Layers);
8267 DU_LOG("\nERROR --> DU APP : Memory allocation failed for maxMimoLayers at extractPdschServingCellCfg()");
8273 if(cuPdschSrvCellCfg->xOverhead)
8275 if(macUePdschSrvCellCfg->xOverhead)
8277 *(macUePdschSrvCellCfg->xOverhead) = *(cuPdschSrvCellCfg->xOverhead);
8281 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->xOverhead, sizeof(PdschXOverhead));
8282 if(macUePdschSrvCellCfg->xOverhead)
8284 *(macUePdschSrvCellCfg->xOverhead) = *(cuPdschSrvCellCfg->xOverhead);
8288 DU_LOG("\nERROR --> DU APP : Memory allocation failed for xOverhead at extractPdschServingCellCfg()");
8296 /*******************************************************************
8298 * @brief Fills PuschCfg received by CU
8302 * Function : extractPuschCfg
8304 * Functionality: Fills PuschCfg received by CU
8306 * @params[in] BWP_UplinkDedicated__pusch_Config *cuPuschCfg,
8307 * PuschCfg *macPuschCfg
8310 * ****************************************************************/
8312 void extractPuschCfg(struct BWP_UplinkDedicated__pusch_Config *cuPuschCfg, PuschCfg *macPuschCfg)
8314 uint8_t timeDomIdx = 0;
8315 DMRS_UplinkConfig_t *dmrsUlCfg = NULLP;
8316 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList = NULLP;
8318 if(cuPuschCfg->present == BWP_UplinkDedicated__pusch_Config_PR_setup)
8320 if(cuPuschCfg->choice.setup)
8322 if(cuPuschCfg->choice.setup->dataScramblingIdentityPUSCH)
8324 macPuschCfg->dataScramblingId = \
8325 *(cuPuschCfg->choice.setup->dataScramblingIdentityPUSCH);
8327 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA)
8329 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->present == PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA_PR_setup)
8331 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup)
8333 dmrsUlCfg = (cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup);
8334 if(dmrsUlCfg->dmrs_AdditionalPosition)
8336 macPuschCfg->dmrsUlCfgForPuschMapTypeA.addPos =\
8337 *(dmrsUlCfg->dmrs_AdditionalPosition);
8339 if(dmrsUlCfg->transformPrecodingDisabled)
8341 if(dmrsUlCfg->transformPrecodingDisabled->scramblingID0)
8343 macPuschCfg->dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0 = \
8344 *(dmrsUlCfg->transformPrecodingDisabled->scramblingID0);
8350 /*Res Alloc Type for UL */
8351 if(cuPuschCfg->choice.setup->resourceAllocation)
8353 macPuschCfg->resourceAllocType = \
8354 cuPuschCfg->choice.setup->resourceAllocation;
8356 if(cuPuschCfg->choice.setup->pusch_TimeDomainAllocationList)
8358 timeDomAllocList = cuPuschCfg->choice.setup->pusch_TimeDomainAllocationList;
8359 if(timeDomAllocList->present == PUSCH_Config__pusch_TimeDomainAllocationList_PR_setup)
8361 if(timeDomAllocList->choice.setup)
8363 macPuschCfg->numTimeDomRsrcAlloc = timeDomAllocList->choice.setup->list.count;
8364 for(timeDomIdx = 0; timeDomIdx <timeDomAllocList->choice.setup->list.count; timeDomIdx++)
8366 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].k2 = \
8367 *(timeDomAllocList->choice.setup->list.array[timeDomIdx]->k2);
8368 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].mappingType = \
8369 timeDomAllocList->choice.setup->list.array[timeDomIdx]->mappingType;
8370 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].startSymbolAndLength = \
8371 timeDomAllocList->choice.setup->list.array[timeDomIdx]->startSymbolAndLength;
8376 if(cuPuschCfg->choice.setup->transformPrecoder)
8377 macPuschCfg->transformPrecoder = *(cuPuschCfg->choice.setup->transformPrecoder);
8382 /*******************************************************************
8384 * @brief Function to fill pucch Power Control
8388 * Function : extractPucchPowerControl
8390 * Functionality: Function to fill pucch Power Control
8392 * @params[in] PucchPowerControl *pwrCtrl,
8393 * struct PUCCH_PowerControl *cuPwrCtrlCfg
8396 * ****************************************************************/
8398 void extractPucchPowerControl(PucchPowerControl *pwrCtrl, struct PUCCH_PowerControl *cuPwrCtrlCfg)
8402 if(cuPwrCtrlCfg->deltaF_PUCCH_f0)
8403 pwrCtrl->deltaF_Format0 = *cuPwrCtrlCfg->deltaF_PUCCH_f0;
8404 if(cuPwrCtrlCfg->deltaF_PUCCH_f1)
8405 pwrCtrl->deltaF_Format1 = *cuPwrCtrlCfg->deltaF_PUCCH_f1;
8406 if(cuPwrCtrlCfg->deltaF_PUCCH_f2)
8407 pwrCtrl->deltaF_Format2 = *cuPwrCtrlCfg->deltaF_PUCCH_f2;
8408 if(cuPwrCtrlCfg->deltaF_PUCCH_f3)
8409 pwrCtrl->deltaF_Format3 = *cuPwrCtrlCfg->deltaF_PUCCH_f3;
8410 if(cuPwrCtrlCfg->deltaF_PUCCH_f4)
8411 pwrCtrl->deltaF_Format4 = *cuPwrCtrlCfg->deltaF_PUCCH_f4;
8412 if(cuPwrCtrlCfg->p0_Set)
8414 pwrCtrl->p0SetCount = cuPwrCtrlCfg->p0_Set->list.count;
8415 for(arrIdx=0; arrIdx < pwrCtrl->p0SetCount; arrIdx++)
8417 pwrCtrl->p0Set[arrIdx].p0PucchId =\
8418 cuPwrCtrlCfg->p0_Set->list.array[arrIdx]->p0_PUCCH_Id;
8419 pwrCtrl->p0Set[arrIdx].p0PucchVal =\
8420 cuPwrCtrlCfg->p0_Set->list.array[arrIdx]->p0_PUCCH_Value;
8423 if(cuPwrCtrlCfg->pathlossReferenceRSs)
8425 pwrCtrl->pathLossRefRSListCount = cuPwrCtrlCfg->pathlossReferenceRSs->list.count;
8426 for(arrIdx = 0; arrIdx < pwrCtrl->pathLossRefRSListCount; arrIdx++)
8428 pwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId =\
8429 cuPwrCtrlCfg->pathlossReferenceRSs->list.array[arrIdx]->pucch_PathlossReferenceRS_Id;
8434 /*******************************************************************
8436 * @brief Function to extractResrcSetToAddModList sent by CU
8440 * Function : extractResrcSetToAddModList
8442 * Functionality: Fucntion to extractResrcSetToAddModList
8444 * @params[in] PucchResrcSetCfg pointer,
8445 * struct PUCCH_Config__resourceSetToAddModList pointer
8448 * ****************************************************************/
8450 void extractResrcSetToAddModList(PucchResrcSetCfg *macRsrcSetList, struct PUCCH_Config__resourceSetToAddModList *cuRsrcSetList)
8452 uint8_t arrIdx, rsrcListIdx;
8454 macRsrcSetList->resrcSetToAddModListCount = cuRsrcSetList->list.count;
8455 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToAddModListCount; arrIdx++)
8457 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId =\
8458 cuRsrcSetList->list.array[arrIdx]->pucch_ResourceSetId;
8459 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount =\
8460 cuRsrcSetList->list.array[arrIdx]->resourceList.list.count;
8461 for(rsrcListIdx = 0; rsrcListIdx < macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount; rsrcListIdx++)
8463 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx] =\
8464 *cuRsrcSetList->list.array[arrIdx]->resourceList.list.array[rsrcListIdx];
8466 macRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize =\
8467 *cuRsrcSetList->list.array[arrIdx]->maxPayloadMinus1;
8469 }/* End of extractResrcSetToAddModList */
8471 /*******************************************************************
8473 * @brief Fills extractResrcToAddModList sent by CU
8477 * Function : extractResrcToAddModList
8479 * Functionality: Fills extractResrcToAddModList
8481 * @params[in] PucchResrcCfg pointer,
8482 * struct PUCCH_Config__resourceToAddModList pointer
8483 * @return ROk/RFAILED
8485 * ****************************************************************/
8487 uint8_t extractResrcToAddModList(PucchResrcCfg *macResrcList, struct PUCCH_Config__resourceToAddModList *cuResrcList)
8491 macResrcList->resrcToAddModListCount = cuResrcList->list.count;
8492 for(arrIdx = 0; arrIdx < macResrcList->resrcToAddModListCount; arrIdx++)
8494 macResrcList->resrcToAddModList[arrIdx].resrcId =\
8495 cuResrcList->list.array[arrIdx]->pucch_ResourceId;
8496 macResrcList->resrcToAddModList[arrIdx].startPrb =\
8497 cuResrcList->list.array[arrIdx]->startingPRB;
8498 if(cuResrcList->list.array[arrIdx]->intraSlotFrequencyHopping)
8500 macResrcList->resrcToAddModList[arrIdx].intraFreqHop =\
8501 *cuResrcList->list.array[arrIdx]->intraSlotFrequencyHopping;
8503 if(cuResrcList->list.array[arrIdx]->secondHopPRB)
8505 macResrcList->resrcToAddModList[arrIdx].secondPrbHop =\
8506 *cuResrcList->list.array[arrIdx]->secondHopPRB;
8508 /* PUCCH RSRC FORMAT */
8509 if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format0)
8511 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_0;
8512 if(cuResrcList->list.array[arrIdx]->format.choice.format0)
8514 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0, sizeof(PucchFormat0));
8515 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0 == NULLP)
8517 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format0 in extractResrcToAddModList()");
8520 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->initialCyclicShift =\
8521 cuResrcList->list.array[arrIdx]->format.choice.format0->initialCyclicShift;
8522 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->numSymbols =\
8523 cuResrcList->list.array[arrIdx]->format.choice.format0->nrofSymbols;
8524 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->startSymbolIdx =\
8525 cuResrcList->list.array[arrIdx]->format.choice.format0->startingSymbolIndex;
8528 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format1)
8530 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_1;
8531 if(cuResrcList->list.array[arrIdx]->format.choice.format1)
8533 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1, sizeof(PucchFormat1));
8534 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1 == NULLP)
8536 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format1 in extractResrcToAddModList()");
8539 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->initialCyclicShift =\
8540 cuResrcList->list.array[arrIdx]->format.choice.format1->initialCyclicShift;
8541 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->numSymbols =\
8542 cuResrcList->list.array[arrIdx]->format.choice.format1->nrofSymbols;
8543 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->startSymbolIdx =\
8544 cuResrcList->list.array[arrIdx]->format.choice.format1->startingSymbolIndex;
8545 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->timeDomOCC =\
8546 cuResrcList->list.array[arrIdx]->format.choice.format1->timeDomainOCC;
8549 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format2)
8551 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_2;
8552 if(cuResrcList->list.array[arrIdx]->format.choice.format2)
8554 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2, sizeof(PucchFormat2_3));
8555 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2 == NULLP)
8557 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format2 in extractResrcToAddModList()");
8560 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->numPrbs =\
8561 cuResrcList->list.array[arrIdx]->format.choice.format2->nrofPRBs;
8562 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->numSymbols =\
8563 cuResrcList->list.array[arrIdx]->format.choice.format2->nrofSymbols;
8564 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->startSymbolIdx =\
8565 cuResrcList->list.array[arrIdx]->format.choice.format2->startingSymbolIndex;
8568 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format3)
8570 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_3;
8571 if(cuResrcList->list.array[arrIdx]->format.choice.format3)
8573 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3, sizeof(PucchFormat2_3));
8574 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3 == NULLP)
8576 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format3 in extractResrcToAddModList()");
8579 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->numPrbs =\
8580 cuResrcList->list.array[arrIdx]->format.choice.format3->nrofPRBs;
8581 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->numSymbols =\
8582 cuResrcList->list.array[arrIdx]->format.choice.format3->nrofSymbols;
8583 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->startSymbolIdx =\
8584 cuResrcList->list.array[arrIdx]->format.choice.format3->startingSymbolIndex;
8587 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format4)
8589 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_4;
8590 if(cuResrcList->list.array[arrIdx]->format.choice.format4)
8592 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4, sizeof(PucchFormat4));
8593 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4 == NULLP)
8595 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format4 in extractResrcToAddModList()");
8598 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->numSymbols =\
8599 cuResrcList->list.array[arrIdx]->format.choice.format4->nrofSymbols;
8600 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->occLen =\
8601 cuResrcList->list.array[arrIdx]->format.choice.format4->occ_Length;
8602 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->occIdx =\
8603 cuResrcList->list.array[arrIdx]->format.choice.format4->occ_Index;
8604 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->startSymbolIdx =\
8605 cuResrcList->list.array[arrIdx]->format.choice.format4->startingSymbolIndex;
8611 }/* End of extractResrcToAddModList */
8613 /*******************************************************************
8615 * @brief Fills fillPucchSchedReqPeriodAndOffset sent by CU
8619 * Function : fillPucchSchedReqPeriodAndOffset
8621 * Functionality: To fillPucchSchedReqPeriodAndOffset
8623 * @params[in] macPeriodicty,
8624 * SchedulingRequestResourceConfig__periodicityAndOffset pointer
8627 * ****************************************************************/
8629 void fillPucchSchedReqPeriodAndOffset(uint8_t macPeriodicty, uint16_t macOffset,\
8630 struct SchedulingRequestResourceConfig__periodicityAndOffset *cuPeriodicty)
8632 macPeriodicty = cuPeriodicty->present;
8633 switch(macPeriodicty)
8635 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sym2:
8637 macOffset = cuPeriodicty->choice.sym2;
8640 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sym6or7:
8642 macOffset = cuPeriodicty->choice.sym6or7;
8645 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl1:
8647 macOffset = cuPeriodicty->choice.sl1;
8650 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl2:
8652 macOffset = cuPeriodicty->choice.sl2;
8655 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl4:
8657 macOffset = cuPeriodicty->choice.sl4;
8660 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl5:
8662 macOffset = cuPeriodicty->choice.sl5;
8665 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl8:
8667 macOffset = cuPeriodicty->choice.sl8;
8670 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl10:
8672 macOffset = cuPeriodicty->choice.sl10;
8675 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl16:
8677 macOffset = cuPeriodicty->choice.sl16;
8680 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl20:
8682 macOffset = cuPeriodicty->choice.sl20;
8685 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl40:
8687 macOffset = cuPeriodicty->choice.sl40;
8690 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl80:
8692 macOffset = cuPeriodicty->choice.sl80;
8695 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl160:
8697 macOffset = cuPeriodicty->choice.sl160;
8700 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl320:
8702 macOffset = cuPeriodicty->choice.sl320;
8705 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl640:
8707 macOffset = cuPeriodicty->choice.sl640;
8711 DU_LOG("\nERROR --> F1AP : Invalid periodicity %d", macPeriodicty);
8715 /*******************************************************************
8717 * @brief Function to extractPucchFormatCfg sent by CU
8721 * Function : extractPucchFormatCfg
8723 * Functionality: Function to extractPucchFormatCfg
8725 * @params[in] PucchFormatCfg pointer,
8726 * PUCCH_FormatConfig_t pointer
8729 * ****************************************************************/
8731 void extractPucchFormatCfg(PucchFormatCfg *macFormatCfg, PUCCH_FormatConfig_t *cuFormatCfg)
8733 if(cuFormatCfg->interslotFrequencyHopping)
8734 macFormatCfg->interSlotFreqHop = *cuFormatCfg->interslotFrequencyHopping;
8735 if(cuFormatCfg->additionalDMRS)
8736 macFormatCfg->addDmrs = *cuFormatCfg->additionalDMRS;
8737 if(cuFormatCfg->maxCodeRate)
8738 macFormatCfg->maxCodeRate = *cuFormatCfg->maxCodeRate;
8739 if(cuFormatCfg->nrofSlots)
8740 macFormatCfg->numSlots = *cuFormatCfg->nrofSlots;
8741 if(cuFormatCfg->pi2BPSK)
8742 macFormatCfg->pi2BPSK = *cuFormatCfg->pi2BPSK;
8743 if(cuFormatCfg->simultaneousHARQ_ACK_CSI)
8744 macFormatCfg->harqAckCSI = *cuFormatCfg->simultaneousHARQ_ACK_CSI;
8745 }/* End of extractPucchFormatCfg */
8747 /*******************************************************************
8749 * @brief Function to extractSchedReqCfgToAddMod sent by CU
8753 * Function : extractSchedReqCfgToAddMod
8755 * Functionality: Function to extractSchedReqCfgToAddMod
8757 * @params[in] PucchSchedReqCfg pointer,
8758 * PUCCH_Config__schedulingRequestResourceToAddModList pointer
8761 * ****************************************************************/
8763 void extractSchedReqCfgToAddMod(PucchSchedReqCfg *macSchedReqCfg, struct PUCCH_Config__schedulingRequestResourceToAddModList *cuSchedReqList)
8767 macSchedReqCfg->schedAddModListCount = cuSchedReqList->list.count;
8768 for(arrIdx = 0; arrIdx < macSchedReqCfg->schedAddModListCount; arrIdx++)
8770 macSchedReqCfg->schedAddModList[arrIdx].resrcId =\
8771 cuSchedReqList->list.array[arrIdx]->schedulingRequestResourceId;
8772 macSchedReqCfg->schedAddModList[arrIdx].requestId =\
8773 cuSchedReqList->list.array[arrIdx]->schedulingRequestID;
8774 if(cuSchedReqList->list.array[arrIdx]->periodicityAndOffset)
8776 fillPucchSchedReqPeriodAndOffset(macSchedReqCfg->schedAddModList[arrIdx].periodicity,\
8777 macSchedReqCfg->schedAddModList[arrIdx].offset, cuSchedReqList->list.array[arrIdx]->periodicityAndOffset);
8779 if(cuSchedReqList->list.array[arrIdx]->resource)
8781 macSchedReqCfg->schedAddModList[arrIdx].resrc =\
8782 *cuSchedReqList->list.array[arrIdx]->resource;
8786 }/* End of extractSchedReqCfgToAddMod */
8788 /*******************************************************************
8790 * @brief Fills PucchCfg received by CU
8794 * Function : extractPucchCfg
8796 * Functionality: Fills PucchCfg received by CU
8798 * @params[in] BWP_UplinkDedicated__pucch_Config *cuPucchCfg,
8799 * PucchCfg *macPucchCfg
8800 * @return ROK/RFAILED
8802 * ****************************************************************/
8804 uint8_t extractPucchCfg(struct BWP_UplinkDedicated__pucch_Config *cuPucchCfg, PucchCfg *macPucchCfg)
8808 if(cuPucchCfg->present == BWP_UplinkDedicated__pucch_Config_PR_setup)
8810 if(cuPucchCfg->choice.setup)
8812 /* Resource Set Cfg */
8813 if(cuPucchCfg->choice.setup->resourceSetToAddModList)
8815 DU_ALLOC_SHRABL_BUF(macPucchCfg->resrcSet, sizeof(PucchResrcSetCfg));
8816 if(macPucchCfg->resrcSet == NULLP)
8818 DU_LOG("\nERROR --> F1AP : Failed to extract Resrc set List in extractPucchCfg()");
8821 memset(macPucchCfg->resrcSet, 0, sizeof(PucchResrcSetCfg));
8822 extractResrcSetToAddModList(macPucchCfg->resrcSet, cuPucchCfg->choice.setup->resourceSetToAddModList);
8826 if(cuPucchCfg->choice.setup->resourceToAddModList)
8828 DU_ALLOC_SHRABL_BUF(macPucchCfg->resrc, sizeof(PucchResrcCfg));
8829 if(macPucchCfg->resrc == NULLP)
8831 DU_LOG("\nERROR --> F1AP : Failed to extract Resrc List in extractPucchCfg()");
8834 memset(macPucchCfg->resrc, 0, sizeof(PucchResrcCfg));
8835 extractResrcToAddModList(macPucchCfg->resrc, cuPucchCfg->choice.setup->resourceToAddModList);
8839 if(cuPucchCfg->choice.setup->format1)
8841 DU_ALLOC_SHRABL_BUF(macPucchCfg->format1, sizeof(PucchFormatCfg));
8842 if(macPucchCfg->format1 == NULLP)
8844 DU_LOG("\nERROR --> F1AP : Failed to extract format 1 Cfg in extractPucchCfg()");
8847 memset(macPucchCfg->format1, 0, sizeof(PucchFormatCfg));
8848 extractPucchFormatCfg(macPucchCfg->format1,\
8849 cuPucchCfg->choice.setup->format1->choice.setup);
8853 if(cuPucchCfg->choice.setup->format2)
8855 DU_ALLOC_SHRABL_BUF(macPucchCfg->format2, sizeof(PucchFormatCfg));
8856 if(macPucchCfg->format2 == NULLP)
8858 DU_LOG("\nERROR --> F1AP : Failed to extract format 2 Cfg in extractPucchCfg()");
8861 memset(macPucchCfg->format2, 0, sizeof(PucchFormatCfg));
8862 extractPucchFormatCfg(macPucchCfg->format2,\
8863 cuPucchCfg->choice.setup->format2->choice.setup);
8867 if(cuPucchCfg->choice.setup->format3)
8869 DU_ALLOC_SHRABL_BUF(macPucchCfg->format3, sizeof(PucchFormatCfg));
8870 if(macPucchCfg->format3 == NULLP)
8872 DU_LOG("\nERROR --> F1AP : Failed to extract format 3 Cfg in extractPucchCfg()");
8875 memset(macPucchCfg->format3, 0, sizeof(PucchFormatCfg));
8876 extractPucchFormatCfg(macPucchCfg->format3,\
8877 cuPucchCfg->choice.setup->format3->choice.setup);
8881 if(cuPucchCfg->choice.setup->format4)
8883 DU_ALLOC_SHRABL_BUF(macPucchCfg->format4, sizeof(PucchFormatCfg));
8884 if(macPucchCfg->format4 == NULLP)
8886 DU_LOG("\nERROR --> F1AP : Failed to extract format 4 Cfg in extractPucchCfg()");
8889 memset(macPucchCfg->format4, 0, sizeof(PucchFormatCfg));
8890 extractPucchFormatCfg(macPucchCfg->format4,\
8891 cuPucchCfg->choice.setup->format4->choice.setup);
8894 /* Sched Req List */
8895 if(cuPucchCfg->choice.setup->schedulingRequestResourceToAddModList)
8897 DU_ALLOC_SHRABL_BUF(macPucchCfg->schedReq, sizeof(PucchSchedReqCfg));
8898 if(macPucchCfg->schedReq == NULLP)
8900 DU_LOG("\nERROR --> F1AP : Failed to extract schedReqCfg in extractPucchCfg()");
8903 memset(macPucchCfg->schedReq, 0, sizeof(PucchSchedReqCfg));
8904 extractSchedReqCfgToAddMod(macPucchCfg->schedReq,\
8905 cuPucchCfg->choice.setup->schedulingRequestResourceToAddModList);
8908 /*TODO: Add support for Spatial Info */
8911 if(cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList)
8913 DU_ALLOC_SHRABL_BUF(macPucchCfg->multiCsiCfg, sizeof(PucchMultiCsiCfg));
8914 if(macPucchCfg->multiCsiCfg == NULLP)
8916 DU_LOG("\nERROR --> F1AP : Failed to extract multiCsiCfg in extractPucchCfg()");
8919 memset(macPucchCfg->multiCsiCfg, 0, sizeof(PucchMultiCsiCfg));
8920 macPucchCfg->multiCsiCfg->multiCsiResrcListCount = cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList->list.count;
8921 for(arrIdx =0; arrIdx < macPucchCfg->multiCsiCfg->multiCsiResrcListCount; arrIdx++)
8923 macPucchCfg->multiCsiCfg->multiCsiResrcList[arrIdx] =\
8924 *cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList->list.array[arrIdx];
8928 /* Dl_DataToUL_ACK */
8929 if(cuPucchCfg->choice.setup->dl_DataToUL_ACK)
8931 DU_ALLOC_SHRABL_BUF(macPucchCfg->dlDataToUlAck, sizeof(PucchDlDataToUlAck));
8932 if(macPucchCfg->dlDataToUlAck == NULLP)
8934 DU_LOG("\nERROR --> F1AP : Failed to extract Dl_DataToUL_ACK in extractPucchCfg()");
8937 memset(macPucchCfg->dlDataToUlAck, 0, sizeof(PucchDlDataToUlAck));
8938 macPucchCfg->dlDataToUlAck->dlDataToUlAckListCount = cuPucchCfg->choice.setup->dl_DataToUL_ACK->list.count;
8939 for(arrIdx = 0; arrIdx < macPucchCfg->dlDataToUlAck->dlDataToUlAckListCount; arrIdx++)
8941 macPucchCfg->dlDataToUlAck->dlDataToUlAckList[arrIdx] =\
8942 *cuPucchCfg->choice.setup->dl_DataToUL_ACK->list.array[arrIdx];
8947 if(cuPucchCfg->choice.setup->pucch_PowerControl)
8949 DU_ALLOC_SHRABL_BUF(macPucchCfg->powerControl, sizeof(PucchPowerControl));
8950 if(macPucchCfg->powerControl == NULLP)
8952 DU_LOG("\nERROR --> F1AP : Failed to extract power control in extractPucchCfg()");
8955 extractPucchPowerControl(macPucchCfg->powerControl,\
8956 cuPucchCfg->choice.setup->pucch_PowerControl);
8963 /*******************************************************************
8965 * @brief Fills ServingCellReconfig received by CU
8969 * Function : extractSpCellDedicatedCfg
8971 * Functionality: Fills ServingCellReconfig received by CU
8973 * @params[in] ServingCellConfig_t *cuSrvCellCfg
8974 * ServCellCfgInfo *macSrvCellCfg
8975 * @return ROK/RFAILD
8977 * ****************************************************************/
8978 uint8_t extractSpCellDedicatedCfg(ServingCellConfig_t *cuSrvCellCfg, ServCellCfgInfo *macSrvCellCfg)
8981 BWP_DownlinkDedicated_t *dlBwp = NULLP;
8982 BWP_UplinkDedicated_t *ulBwp = NULLP;
8984 if(cuSrvCellCfg->initialDownlinkBWP)
8986 dlBwp = ((BWP_DownlinkDedicated_t *)(cuSrvCellCfg->initialDownlinkBWP));
8987 if(dlBwp->pdcch_Config)
8989 if(dlBwp->pdcch_Config->choice.setup)
8991 macSrvCellCfg->initDlBwp.pdcchPresent = true;
8992 extractPdcchCfg(dlBwp->pdcch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdcchCfg);
8995 if(dlBwp->pdsch_Config)
8997 if(dlBwp->pdsch_Config->choice.setup)
8999 macSrvCellCfg->initDlBwp.pdschPresent = true;
9000 extractPdschCfg(dlBwp->pdsch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdschCfg);
9004 if(cuSrvCellCfg->firstActiveDownlinkBWP_Id)
9005 macSrvCellCfg->firstActvDlBwpId = *(cuSrvCellCfg->firstActiveDownlinkBWP_Id);
9006 if(cuSrvCellCfg->defaultDownlinkBWP_Id)
9007 macSrvCellCfg->defaultDlBwpId = *(cuSrvCellCfg->defaultDownlinkBWP_Id);
9008 if(cuSrvCellCfg->bwp_InactivityTimer)
9010 if(macSrvCellCfg->bwpInactivityTmr)
9012 memcpy(macSrvCellCfg->bwpInactivityTmr, cuSrvCellCfg->bwp_InactivityTimer, sizeof(uint8_t));
9016 macSrvCellCfg->bwpInactivityTmr = NULLP;
9017 DU_ALLOC_SHRABL_BUF(macSrvCellCfg->bwpInactivityTmr, sizeof(uint8_t));
9018 if(macSrvCellCfg->bwpInactivityTmr)
9020 memcpy(macSrvCellCfg->bwpInactivityTmr, cuSrvCellCfg->bwp_InactivityTimer, sizeof(uint8_t));
9024 DU_LOG("\nERROR --> F1AP : Memory Alloc failed for bwpInactivityTmr at extractSpCellDedicatedCfg()");
9029 if(cuSrvCellCfg->pdsch_ServingCellConfig)
9031 if(cuSrvCellCfg->pdsch_ServingCellConfig->choice.setup)
9033 ret = extractPdschServingCellCfg(cuSrvCellCfg->pdsch_ServingCellConfig->choice.setup, &macSrvCellCfg->pdschServCellCfg);
9036 DU_LOG("\nERROR --> F1AP : Failed at extractPdschServingCellCfg()");
9041 if(cuSrvCellCfg->uplinkConfig)
9043 if(cuSrvCellCfg->uplinkConfig->initialUplinkBWP)
9045 ulBwp = ((BWP_UplinkDedicated_t *)(cuSrvCellCfg->uplinkConfig->initialUplinkBWP));
9046 if(ulBwp->pusch_Config)
9048 macSrvCellCfg->initUlBwp.puschPresent = true;
9049 extractPuschCfg(ulBwp->pusch_Config, &macSrvCellCfg->initUlBwp.puschCfg);
9051 if(ulBwp->pucch_Config)
9053 macSrvCellCfg->initUlBwp.pucchPresent = true;
9054 memset(&macSrvCellCfg->initUlBwp.pucchCfg, 0, sizeof(PucchCfg));
9055 extractPucchCfg(ulBwp->pucch_Config, &macSrvCellCfg->initUlBwp.pucchCfg);
9058 if(cuSrvCellCfg->uplinkConfig->firstActiveUplinkBWP_Id)
9059 macSrvCellCfg->firstActvUlBwpId = *(cuSrvCellCfg->uplinkConfig->firstActiveUplinkBWP_Id);
9063 /*******************************************************************
9065 * @brief Fills Reconfig Cell group Info received by CU
9069 * Function : extractUeReCfgCellInfo
9071 * Functionality: Fills Reconfig Cell group Info received by CU
9073 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
9074 * MacUeCfg* macUeCfg
9075 * @return ROK/RFAILED
9077 * ****************************************************************/
9078 uint8_t extractUeReCfgCellInfo(CellGroupConfigRrc_t *cellGrp, MacUeCfg *macUeCfg)
9081 MAC_CellGroupConfig_t *macCellGroup = NULLP;
9082 PhysicalCellGroupConfig_t *phyCellGrpCfg = NULLP;
9083 SpCellConfig_t *spcellCfg = NULLP;
9084 ServingCellConfig_t *servCellCfg = NULLP;
9088 /* Fill MacCell Group Reconfig */
9089 if(cellGrp->mac_CellGroupConfig)
9091 macUeCfg->macCellGrpCfgPres = true;
9092 macCellGroup = ((MAC_CellGroupConfig_t *)(cellGrp->mac_CellGroupConfig));
9093 if(macCellGroup->schedulingRequestConfig)
9095 extractSchReqReConfig(macCellGroup->schedulingRequestConfig, &macUeCfg->macCellGrpCfg.schReqCfg);
9097 if(macCellGroup->tag_Config)
9099 extractTagReconfig(macCellGroup->tag_Config, &macUeCfg->macCellGrpCfg.tagCfg);
9101 if(macCellGroup->bsr_Config)
9103 macUeCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer = macCellGroup->bsr_Config->periodicBSR_Timer;
9104 macUeCfg->macCellGrpCfg.bsrTmrCfg.retxTimer = macCellGroup->bsr_Config->retxBSR_Timer;
9105 if(macCellGroup->bsr_Config->logicalChannelSR_DelayTimer)
9107 macUeCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer =\
9108 *(macCellGroup->bsr_Config->logicalChannelSR_DelayTimer);
9111 if(macCellGroup->phr_Config)
9113 if(macCellGroup->phr_Config->present == MAC_CellGroupConfig__phr_Config_PR_setup)
9115 macUeCfg->macCellGrpCfg.phrCfgSetupPres = true;
9116 if(macCellGroup->phr_Config->choice.setup)
9118 macUeCfg->macCellGrpCfg.phrCfg.periodicTimer = \
9119 macCellGroup->phr_Config->choice.setup->phr_PeriodicTimer;
9120 macUeCfg->macCellGrpCfg.phrCfg.prohibitTimer = \
9121 macCellGroup->phr_Config->choice.setup->phr_ProhibitTimer;
9122 macUeCfg->macCellGrpCfg.phrCfg.txPowerFactor = \
9123 macCellGroup->phr_Config->choice.setup->phr_Tx_PowerFactorChange;
9124 macUeCfg->macCellGrpCfg.phrCfg.multiplePHR = \
9125 macCellGroup->phr_Config->choice.setup->multiplePHR;
9126 macUeCfg->macCellGrpCfg.phrCfg.dummy = \
9127 macCellGroup->phr_Config->choice.setup->dummy;
9128 macUeCfg->macCellGrpCfg.phrCfg.phrType2OtherCell = \
9129 macCellGroup->phr_Config->choice.setup->phr_Type2OtherCell;
9130 macUeCfg->macCellGrpCfg.phrCfg.phrOtherCG = \
9131 macCellGroup->phr_Config->choice.setup->phr_ModeOtherCG;
9136 /* Fill Physical Cell Group Reconfig */
9137 if(cellGrp->physicalCellGroupConfig)
9139 macUeCfg->phyCellGrpCfgPres = true;
9140 phyCellGrpCfg = ((PhysicalCellGroupConfig_t *)(cellGrp->physicalCellGroupConfig));
9141 if(phyCellGrpCfg->p_NR_FR1)
9143 if(*(phyCellGrpCfg->p_NR_FR1) != macUeCfg->phyCellGrpCfg.pNrFr1)
9144 macUeCfg->phyCellGrpCfg.pNrFr1 = *(phyCellGrpCfg->p_NR_FR1);
9146 macUeCfg->phyCellGrpCfg.pdschHarqAckCodebook = phyCellGrpCfg->pdsch_HARQ_ACK_Codebook;
9148 /* Fill SpCell Reconfig */
9149 if(cellGrp->spCellConfig)
9151 macUeCfg->spCellCfgPres = true;
9152 spcellCfg = ((SpCellConfig_t *)(cellGrp->spCellConfig));
9153 if(spcellCfg->servCellIndex)
9155 macUeCfg->spCellCfg.servCellIdx = *(spcellCfg->servCellIndex);
9157 /* Fill Serving cell Reconfig info */
9158 if(cellGrp->spCellConfig->spCellConfigDedicated)
9160 servCellCfg = ((ServingCellConfig_t *)(cellGrp->spCellConfig->spCellConfigDedicated));
9161 ret = extractSpCellDedicatedCfg(servCellCfg, &macUeCfg->spCellCfg.servCellCfg);
9164 DU_LOG("\nERROR --> F1AP : Failed at extractSpCellDedicatedCfg()");
9171 /*******************************************************************
9173 * @brief free the memory allocated by decoder
9177 * Function : freeAperDecodeNrcgi
9179 * Functionality: Free Nrcgi values
9181 * @params[in] NRCGI_t *nrcgi
9184 * ****************************************************************/
9187 void freeAperDecodeNrcgi(NRCGI_t *nrcgi)
9189 if(nrcgi->pLMN_Identity.buf != NULLP)
9191 free(nrcgi->pLMN_Identity.buf);
9193 if(nrcgi->nRCellIdentity.buf != NULLP)
9195 free(nrcgi->nRCellIdentity.buf);
9198 /*******************************************************************
9200 * @brief free the memory allocated by decoder
9204 * Function : freeAperDecodeCuToDuInfo
9206 * Functionality: Free Cu To Du Information
9208 * @params[in] CUtoDURRCInformation_t *rrcMsg
9211 * ****************************************************************/
9214 void freeAperDecodeCuToDuInfo(CUtoDURRCInformation_t *rrcMsg)
9219 if(rrcMsg->uE_CapabilityRAT_ContainerList)
9221 if(rrcMsg->uE_CapabilityRAT_ContainerList->buf)
9222 free(rrcMsg->uE_CapabilityRAT_ContainerList->buf);
9223 free(rrcMsg->uE_CapabilityRAT_ContainerList);
9226 if(rrcMsg->iE_Extensions)
9228 if(rrcMsg->iE_Extensions->list.array)
9230 for(ieIdx= 0; ieIdx < rrcMsg->iE_Extensions->list.count; ieIdx++)
9232 if(rrcMsg->iE_Extensions->list.array[ieIdx])
9234 switch(rrcMsg->iE_Extensions->list.array[ieIdx]->id)
9236 case ProtocolIE_ID_id_CellGroupConfig:
9237 if(rrcMsg->iE_Extensions->list.array[ieIdx]->extensionValue.choice.CellGroupConfig.buf != NULLP)
9239 free(rrcMsg->iE_Extensions->list.array[ieIdx]->extensionValue.choice.CellGroupConfig.buf);
9243 DU_LOG("\nERROR --> F1AP : Invalid Event type %ld at FreeCuToDuInfo()", \
9244 rrcMsg->iE_Extensions->list.array[ieIdx]->id);
9249 for(arrIdx = 0; arrIdx < ieIdx; arrIdx++)
9251 free(rrcMsg->iE_Extensions->list.array[arrIdx]);
9253 free(rrcMsg->iE_Extensions->list.array);
9257 free(rrcMsg->iE_Extensions);
9260 /*******************************************************************
9262 * @brief free the memory allocated by decoder
9266 * Function : freeAperDecodeSplCellList
9268 * Functionality: Free Spl Cell List
9269 where memory allocated by aper_decoder
9271 * @params[in] SCell_ToBeSetup_List_t *spCellLst
9274 * ****************************************************************/
9277 void freeAperDecodeSplCellList(SCell_ToBeSetup_List_t *spCellLst)
9281 if(spCellLst->list.array != NULLP)
9283 for(cellIdx=0; cellIdx<spCellLst->list.count; cellIdx++)
9285 if(cellIdx==0&&spCellLst->list.array[cellIdx]!=NULLP)
9287 freeAperDecodeNrcgi(&spCellLst->list.array[cellIdx]->value.choice.SCell_ToBeSetup_Item.sCell_ID);
9289 if(spCellLst->list.array[cellIdx]!=NULLP)
9291 free(spCellLst->list.array[cellIdx]);
9294 free(spCellLst->list.array);
9297 /*******************************************************************
9299 * @brief free the memory allocated by decoder
9303 * Function : freeAperDecodeSRBSetup
9305 * Functionality: added free part for the memory allocated by aper_decoder
9307 * @params[in] SRBs_ToBeSetup_List_t *srbSet
9310 ****************************************************************/
9313 void freeAperDecodeSRBSetup(SRBs_ToBeSetup_List_t *srbSet)
9316 if(srbSet->list.array != NULLP)
9318 for(srbIdx=0; srbIdx<srbSet->list.count; srbIdx++)
9320 if(srbSet->list.array[srbIdx]!=NULLP)
9322 free(srbSet->list.array[srbIdx]);
9325 free(srbSet->list.array);
9329 /*******************************************************************
9331 * @brief free the memory allocated by decoder
9335 * Function : freeAperDecodeULTnlInfo
9337 * Functionality: added free part for the memory allocated by aper_decoder
9339 * @params[in] ULUPTNLInformation_ToBeSetup_List_t *ulInfo
9342 * ****************************************************************/
9345 void freeAperDecodeULTnlInfo(ULUPTNLInformation_ToBeSetup_List_t *ulInfo)
9348 if(ulInfo->list.array != NULLP)
9350 for(ulIdx=0; ulIdx<ulInfo->list.count; ulIdx++)
9352 if(ulIdx==0&&ulInfo->list.array[ulIdx]!=NULLP)
9354 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel!=NULLP)
9356 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->\
9357 transportLayerAddress.buf != NULLP)
9359 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf\
9362 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf);
9364 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->\
9365 transportLayerAddress.buf);
9367 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel);
9370 if(ulInfo->list.array[ulIdx]!=NULLP)
9372 free(ulInfo->list.array[ulIdx]);
9375 free(ulInfo->list.array);
9378 /*******************************************************************
9380 * @brief free the memory allocated by decoder
9384 * Function : freeAperDecodeDRBSetup
9386 * Functionality: free DRBSetup which is allocated by decoder
9388 * @params[in] DRBs_ToBeSetup_List_t *drbSet
9391 * ****************************************************************/
9393 void freeAperDecodeDRBSetup(DRBs_ToBeSetup_List_t *drbSet)
9395 DRBs_ToBeSetup_Item_t *drbSetItem = NULLP;
9399 if(drbSet->list.array != NULLP)
9401 for(drbIdx=0; drbIdx<drbSet->list.count; drbIdx++)
9403 if(drbIdx==0&&drbSet->list.array[drbIdx] != NULLP)
9405 drbSetItem =&drbSet->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item;
9406 if(drbSetItem->qoSInformation.choice.choice_extension != NULLP)
9408 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9409 qoS_Characteristics.choice.non_Dynamic_5QI !=NULLP)
9411 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9412 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
9414 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9415 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
9418 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sST.buf!=NULLP)
9421 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD!=NULLP)
9424 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD->\
9428 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.\
9429 flows_Mapped_To_DRB_List.list.array != NULLP)
9432 for(flowIdx=0;flowIdx<drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9433 DRB_Information.flows_Mapped_To_DRB_List.list.count; flowIdx++)
9436 if(flowIdx==0&&drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9437 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]!=NULLP)
9439 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9440 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9441 qoSFlowLevelQoSParameters.\
9442 qoS_Characteristics.choice.non_Dynamic_5QI!=NULLP)
9444 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9445 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9446 qoSFlowLevelQoSParameters.\
9447 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
9450 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9451 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9452 qoSFlowLevelQoSParameters.\
9453 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
9457 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9458 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9459 qoSFlowLevelQoSParameters.\
9460 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
9463 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9464 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9465 qoSFlowLevelQoSParameters.\
9466 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
9469 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9471 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9472 qoSFlowLevelQoSParameters.\
9473 qoS_Characteristics.choice.non_Dynamic_5QI);
9476 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9477 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]!=NULLP)
9480 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9481 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]);
9485 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9486 DRB_Information.flows_Mapped_To_DRB_List.list.array);
9489 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9490 DRB_Information.sNSSAI.sD->buf);
9493 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD);
9496 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sST.buf);
9500 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9502 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
9505 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9506 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
9509 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9510 qoS_Characteristics.choice.non_Dynamic_5QI);
9512 free(drbSetItem->qoSInformation.choice.choice_extension);
9514 freeAperDecodeULTnlInfo(&drbSetItem->uLUPTNLInformation_ToBeSetup_List);
9515 if(drbSetItem->uLConfiguration)
9517 free(drbSetItem->uLConfiguration);
9520 if(drbSet->list.array[drbIdx]!=NULLP)
9522 free(drbSet->list.array[drbIdx]);
9525 free(drbSet->list.array);
9530 /*******************************************************************
9532 * @brief builds Mac Cell Cfg
9536 * Function : procUeReCfgCellInfo
9538 * Functionality: builds Mac Cell Cfg
9540 * @params[in] MacUeCfg pointer
9545 * ****************************************************************/
9546 uint8_t procUeReCfgCellInfo(MacUeCfg *macUeCfg, void *cellInfo)
9549 CellGroupConfigRrc_t *cellGrp = NULLP;
9553 cellGrp = (CellGroupConfigRrc_t *)cellInfo;
9554 ret = extractUeReCfgCellInfo(cellGrp, macUeCfg);
9556 DU_LOG("\nERROR --> F1AP : Failed at procUeReCfgCellInfo()");
9560 freeUeReCfgCellGrpInfo(macUeCfg);
9565 /*******************************************************************
9567 * @brief Filling modulation info in mac ue cfg
9571 * Function : duFillModulationDetails
9573 * Functionality: Filling modulation info in mac ue cfg
9575 * @params[in] MAC UE Config to be updated
9576 * Current UE configuration
9577 * UE NR capability from CU
9578 * @return ROK - success
9581 * ****************************************************************/
9582 void duFillModulationDetails(MacUeCfg *ueCfg, MacUeCfg *oldUeCfg, void *ueCap)
9584 UE_NR_Capability_t *ueNrCap=NULLP;
9588 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
9589 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
9593 ueNrCap = (UE_NR_Capability_t *)ueCap;
9595 /* Filling DL modulation info */
9596 if(ueNrCap->featureSets && ueNrCap->featureSets->featureSetsDownlinkPerCC && \
9597 ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0] && \
9598 ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0]->supportedModulationOrderDL)
9600 switch(*(ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0]->supportedModulationOrderDL))
9602 case ModulationOrder_qpsk:
9604 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
9607 case ModulationOrder_qam16:
9609 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM16;
9612 case ModulationOrder_qam64:
9614 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM64;
9615 ueCfg->dlModInfo.mcsIndex = PDSCH_MCS_INDEX;
9616 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64;
9619 case ModulationOrder_qam256:
9621 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM256;
9626 DU_LOG("\nERROR --> DU APP: Incorrect downlink modulation order received. Reatining old modulation configuration");
9627 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
9634 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
9637 /* Filling UL modulation info */
9638 if(ueNrCap->featureSets && ueNrCap->featureSets->featureSetsUplinkPerCC && \
9639 ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0] && \
9640 ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0]->supportedModulationOrderUL)
9642 switch(*(ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0]->supportedModulationOrderUL))
9644 case ModulationOrder_qpsk:
9646 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
9649 case ModulationOrder_qam16:
9651 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM16;
9652 ueCfg->ulModInfo.mcsIndex = PUSCH_MCS_INDEX;
9653 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64;
9656 case ModulationOrder_qam64:
9658 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM64;
9661 case ModulationOrder_qam256:
9663 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM256;
9668 DU_LOG("\nERROR --> DU APP: Incorrect uplink modulation order received. Reatining old modulation configuration");
9669 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
9676 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
9681 /*******************************************************************
9683 * @brief Function to extract cellGrp Info present in cutoDu cont
9687 * Function : extractCellGrpInfo
9689 * Functionality: Function to extract cellGrp Info present
9692 * @params[in] ProtocolExtensionContainer_4624P16_t pointer
9694 * @return CellGroupConfigRrc_t *
9696 * ****************************************************************/
9698 CellGroupConfigRrc_t *extractCellGrpInfo(ProtocolExtensionContainer_4624P16_t *protocolIeExtn,\
9703 uint16_t recvBufLen =0;
9704 CellGroupConfigRrc_t *cellGrpCfg = NULLP;
9705 CUtoDURRCInformation_ExtIEs_t *extIeInfo = NULLP;
9706 asn_dec_rval_t rval; /* Decoder return value */
9707 memset(&rval, 0, sizeof(asn_dec_rval_t));
9711 for(idx2 = 0; idx2 < protocolIeExtn->list.count; idx2++)
9713 extIeInfo = ((CUtoDURRCInformation_ExtIEs_t *)(protocolIeExtn->list.array[idx2]));
9717 case ProtocolIE_ID_id_CellGroupConfig:
9719 recvBufLen = extIeInfo->extensionValue.choice.CellGroupConfig.size;
9720 /* decoding the CellGroup Buf received */
9721 DU_ALLOC(cellGrpCfg, sizeof(CellGroupConfigRrc_t));
9724 memset(cellGrpCfg, 0, sizeof(CellGroupConfigRrc_t));
9725 rval = aper_decode(0, &asn_DEF_CellGroupConfigRrc, (void **)&cellGrpCfg,
9726 extIeInfo->extensionValue.choice.CellGroupConfig.buf, recvBufLen, 0, 0);
9727 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
9729 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
9732 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, cellGrpCfg);
9733 if(extractRlcCfgToAddMod(cellGrpCfg->rlc_BearerToAddModList, ueCfgDb))
9739 DU_LOG("\nERROR --> F1AP : Invalid IE received CUtoDURRCInformation:%d at decodeCellGrpCfg()", id);
9747 /*******************************************************************
9749 * @brief Fills Srb List received by CU
9753 * Function : procSrbListToSetup
9755 * Functionality: Fills Srb List received by CU
9757 * @params[in] SRBs_ToBeSetup_Item_t *cuSrbItem
9759 * RlcBearerCfg pointer
9762 * ****************************************************************/
9763 uint8_t procSrbListToSetup(SRBs_ToBeSetup_Item_t * srbItem, LcCfg *macLcToAdd, RlcBearerCfg *rlcLcToAdd)
9767 /* Filling RLC INFO */
9768 procRlcLcCfg(srbItem->sRBID, srbItem->sRBID, RB_TYPE_SRB, RLC_AM, CONFIG_ADD, NULL, rlcLcToAdd);
9770 /* Filling MAC INFO */
9771 ret = procMacLcCfg(srbItem->sRBID, RB_TYPE_SRB, CONFIG_ADD, NULL,NULL, NULL, macLcToAdd, NULL);
9774 DU_LOG("\nERROR --> F1AP : Failed at MAC LC Cfg in procSrbListToSetup()");
9782 /*******************************************************************
9784 * @brief extract Srb List received by CU
9788 * Function : extractSrbListToSetup
9790 * Functionality: extract Srb List received by CU
9791 * for both MAC and RLC
9793 * @params[in] SRBs_ToBeSetup_Item_t pointer
9795 * @return ROK/RFAIED
9797 * ****************************************************************/
9799 uint8_t extractSrbListToSetup(SRBs_ToBeSetup_List_t *srbCfg, DuUeCfg *ueCfgDb)
9801 uint8_t ret, srbIdx;
9802 SRBs_ToBeSetup_Item_t *srbItem = NULLP;
9806 for(srbIdx = 0; srbIdx < srbCfg->list.count; srbIdx++)
9808 srbItem = &srbCfg->list.array[srbIdx]->value.choice.SRBs_ToBeSetup_Item;
9809 if(ueCfgDb->numMacLcs > MAX_NUM_LC)
9811 DU_LOG("\nERROR --> F1AP: MAX LC Reached in MAC");
9815 if(ueCfgDb->numRlcLcs > MAX_NUM_LC)
9817 DU_LOG("\nERROR --> F1AP: MAX LC Reached in RLC");
9821 memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(LcCfg));
9822 memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(RlcBearerCfg));
9823 ret = procSrbListToSetup(srbItem, &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs],\
9824 &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs]);
9825 ueCfgDb->numRlcLcs++;
9826 ueCfgDb->numMacLcs++;
9829 DU_LOG("\nERROR --> F1AP: Failed at extractSrbListToSetup()");
9840 /*******************************************************************
9842 * @brief Fills Drb List received by CU
9846 * Function : procDrbListToSetup
9848 * Functionality: Fills Drb List received by CU
9849 * for both MAC and RLC
9851 * @params[in] SRBs_ToBeSetup_Item_t pointer
9853 * RlcBearerCfg pointer
9856 * ****************************************************************/
9858 uint8_t procDrbListToSetup(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbItem,\
9859 DRBs_ToBeSetupMod_Item_t *drbSetupModItem, LcCfg *macLcToAdd, RlcBearerCfg *rlcLcToAdd, UpTnlCfg *upTnlInfo)
9862 if(drbItem != NULLP)
9864 /* Filling RLC INFO */
9865 procRlcLcCfg(drbItem->dRBID, lcId, RB_TYPE_DRB, drbItem->rLCMode, CONFIG_ADD, NULL, rlcLcToAdd);
9867 /* Filling MAC INFO */
9868 if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_ADD, drbItem, NULL, NULL, macLcToAdd, upTnlInfo) != ROK)
9870 DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in procDrbListToSetup()");
9874 else if(drbSetupModItem != NULLP)
9876 procRlcLcCfg(drbSetupModItem->dRBID, lcId, RB_TYPE_DRB, drbSetupModItem->rLCMode, CONFIG_ADD, NULL, rlcLcToAdd);
9878 if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_ADD, NULL, drbSetupModItem, NULL, macLcToAdd, upTnlInfo) != ROK)
9880 DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in procDrbListToSetup()");
9887 /*******************************************************************
9889 * @brief extract Drb List received by CU
9893 * Function : extractDrbListToSetup
9895 * Functionality: extract Drb List received by CU
9896 * for both MAC and RLC
9898 * @params[in] DRBs_ToBeSetup_Item_t pointer
9900 * @return ROK/RFAIED
9902 * ****************************************************************/
9904 uint8_t extractDrbListToSetup(uint8_t lcId, DRBs_ToBeSetup_List_t *drbCfg,DRBs_ToBeSetupMod_List_t *drbSetupModCfg,\
9905 uint8_t drbCount, DuUeCfg *ueCfgDb)
9907 uint8_t ret, drbIdx;
9908 DRBs_ToBeSetup_Item_t *drbItem = NULLP;
9909 DRBs_ToBeSetupMod_ItemIEs_t *drbSetupModItem = NULLP;
9914 for(drbIdx = 0; drbIdx < drbCount; drbIdx++)
9916 if(ueCfgDb->numMacLcs > MAX_NUM_LC)
9918 DU_LOG("\nERROR --> F1AP : MAX LC Reached in MAC at extractDrbListToSetup()");
9922 if(ueCfgDb->numRlcLcs > MAX_NUM_LC)
9924 DU_LOG("\nERROR --> F1AP : MAX LC Reached in RLC at extractDrbListToSetup()");
9928 memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(LcCfg));
9929 memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(RlcBearerCfg));
9933 drbItem = &drbCfg->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item;
9934 ret = procDrbListToSetup(lcId, drbItem, NULL, &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs],\
9935 &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], &ueCfgDb->upTnlInfo[ueCfgDb->numDrb]);
9938 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetup()");
9942 else if(drbSetupModCfg != NULL)
9944 drbSetupModItem = (DRBs_ToBeSetupMod_ItemIEs_t *) drbSetupModCfg->list.array[drbIdx];
9945 ret = procDrbListToSetup(lcId, NULL, &(drbSetupModItem->value.choice.DRBs_ToBeSetupMod_Item) ,\
9946 &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs],\
9947 &ueCfgDb->upTnlInfo[ueCfgDb->numDrb]);
9950 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetup()");
9954 ueCfgDb->numRlcLcs++;
9955 ueCfgDb->numMacLcs++;
9959 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetup()");
9970 /*******************************************************************
9972 * @brief Function to extract Dl RRC Msg received from CU
9976 * Function : extractDlRrcMsg
9978 * Functionality: Function to extract Dl RRC Msg received from CU
9980 * @params[in] F1AP message
9981 * @return ROK - success
9984 * ****************************************************************/
9986 uint8_t extractDlRrcMsg(uint32_t gnbDuUeF1apId, uint32_t gnbCuUeF1apId, \
9987 F1DlRrcMsg *dlRrcMsg, RRCContainer_t *rrcContainer)
9990 dlRrcMsg->rrcMsgSize = rrcContainer->size;
9991 if(dlRrcMsg->rrcMsgSize > 0)
9993 DU_ALLOC_SHRABL_BUF(dlRrcMsg->rrcMsgPdu, dlRrcMsg->rrcMsgSize);
9994 if(!dlRrcMsg->rrcMsgPdu)
9996 DU_LOG("\nERROR --> DU APP : Memory allocation failed for RRC Msg in extractDlRrcMsg()");
10001 dlRrcMsg->gnbDuUeF1apId = gnbDuUeF1apId;
10002 dlRrcMsg->gnbCuUeF1apId = gnbCuUeF1apId;
10003 dlRrcMsg->srbId = SRB1_LCID;
10004 memcpy(dlRrcMsg->rrcMsgPdu, rrcContainer->buf, dlRrcMsg->rrcMsgSize);
10010 /*******************************************************************
10012 * @brief Extract UE capability info
10016 * Function : extractUeCapability
10018 * Functionality: Extract UE capability info and stores in ue Cb
10020 * @params[in] Octet string of UE capability RAT container list
10021 * @return ROK - success
10022 * RFAILED - failure
10024 * ****************************************************************/
10025 UE_NR_Capability_t *extractUeCapability(UE_CapabilityRAT_ContainerList_t *ueCapablityListBuf, DuUeCb *ueCb)
10028 uint16_t recvBufLen;
10029 asn_dec_rval_t rval;
10030 UE_NR_Capability_t *ueNrCap = NULLP;
10031 UE_CapabilityRAT_ContainerListRRC_t *ueCapRatContList = NULLP;
10033 /* Decoding UE Capability RAT Container List */
10034 recvBufLen = ueCapablityListBuf->size;
10035 DU_ALLOC(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
10036 if(!ueCapRatContList)
10038 DU_LOG("\nERROR --> F1AP : Memory allocation failed in extractUeCapability");
10041 memset(ueCapRatContList, 0, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
10042 memset(&rval, 0, sizeof(asn_dec_rval_t));
10043 rval = aper_decode(0, &asn_DEF_UE_CapabilityRAT_ContainerListRRC, (void **)&ueCapRatContList,
10044 ueCapablityListBuf->buf, recvBufLen, 0, 0);
10045 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
10047 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
10050 xer_fprint(stdout, &asn_DEF_UE_CapabilityRAT_ContainerListRRC, ueCapRatContList);
10052 /* Free encoded buffer after decoding */
10054 for(idx = 0; idx < ueCapRatContList->list.count; idx++)
10056 if(ueCapRatContList->list.array[idx]->rat_Type == RAT_Type_nr)
10058 /* Decoding UE NR Capability */
10059 recvBufLen = ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.size;
10060 DU_ALLOC(ueNrCap, sizeof(UE_NR_Capability_t));
10063 DU_LOG("\nERROR --> F1AP : Memory allocation failed in extractUeCapability");
10064 DU_FREE(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
10067 memset(ueNrCap, 0, sizeof(UE_NR_Capability_t));
10068 memset(&rval, 0, sizeof(asn_dec_rval_t));
10069 rval = aper_decode(0, &asn_DEF_UE_NR_Capability, (void **)&ueNrCap,
10070 ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.buf, recvBufLen, 0, 0);
10071 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
10073 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
10076 xer_fprint(stdout, &asn_DEF_UE_NR_Capability, ueNrCap);
10078 /* Free encoded buffer after decoding */
10079 free(ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.buf);
10081 free(ueCapRatContList->list.array[idx]);
10085 free(ueCapRatContList->list.array);
10086 DU_FREE(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
10090 /*******************************************************************
10092 * @brief free UE context setup request from CU
10096 * Function : freeAperDecodeF1UeContextSetupReq
10098 * Functionality: freeing part for the memory allocated by aper_decoder
10100 * @params[in] F1AP message
10101 * @return ROK - success
10102 * RFAILED - failure
10104 * ****************************************************************/
10105 void freeAperDecodeF1UeContextSetupReq(UEContextSetupRequest_t *ueSetReq)
10109 if(ueSetReq->protocolIEs.list.array != NULLP)
10111 for(ieIdx = 0; ieIdx < ueSetReq->protocolIEs.list.count; ieIdx++)
10113 if(ueSetReq->protocolIEs.list.array[ieIdx])
10115 switch(ueSetReq->protocolIEs.list.array[ieIdx]->id)
10117 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
10119 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
10121 case ProtocolIE_ID_id_SpCell_ID:
10122 freeAperDecodeNrcgi(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.NRCGI);
10124 case ProtocolIE_ID_id_ServCellIndex:
10126 case ProtocolIE_ID_id_SpCellULConfigured:
10128 case ProtocolIE_ID_id_CUtoDURRCInformation:
10130 freeAperDecodeCuToDuInfo(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation);
10132 case ProtocolIE_ID_id_SCell_ToBeSetup_List:
10134 freeAperDecodeSplCellList(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SCell_ToBeSetup_List);
10136 case ProtocolIE_ID_id_SRBs_ToBeSetup_List:
10138 freeAperDecodeSRBSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SRBs_ToBeSetup_List);
10140 case ProtocolIE_ID_id_DRBs_ToBeSetup_List:
10142 freeAperDecodeDRBSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRBs_ToBeSetup_List);
10144 case ProtocolIE_ID_id_RRCContainer:
10147 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf != NULLP)
10150 free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf);
10154 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
10156 case ProtocolIE_ID_id_GNB_DU_UE_AMBR_UL:
10158 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf)
10160 free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf);
10165 DU_LOG("\nERROR --> F1AP: Invalid event type %ld " ,ueSetReq->protocolIEs.list.array[ieIdx]->id);
10167 free(ueSetReq->protocolIEs.list.array[ieIdx]);
10170 free(ueSetReq->protocolIEs.list.array);
10173 /*******************************************************************
10175 * @brief Process UE context setup request from CU
10179 * Function : procF1UeContextSetupReq
10181 * Functionality: Process UE context setup request from CU
10183 * @params[in] F1AP message
10184 * @return ROK - success
10185 * RFAILED - failure
10187 * ****************************************************************/
10188 uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg)
10190 uint8_t ret=0, ieIdx=0, ueIdx=0, lcId=0, cellIdx=0;
10191 bool ueCbFound = false;
10192 uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId=0, bitRateSize=0;
10193 DuUeCb *duUeCb = NULL;
10194 UEContextSetupRequest_t *ueSetReq = NULL;
10195 DRBs_ToBeSetup_List_t *drbCfg = NULL;
10199 ueSetReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextSetupRequest;
10200 for(ieIdx=0; (ieIdx < ueSetReq->protocolIEs.list.count && ret == ROK); ieIdx++)
10202 switch(ueSetReq->protocolIEs.list.array[ieIdx]->id)
10204 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
10206 gnbCuUeF1apId = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID;
10209 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
10211 gnbDuUeF1apId = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID;
10214 case ProtocolIE_ID_id_ServCellIndex:
10216 cellIdx = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.ServCellIndex;
10217 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
10219 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
10220 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
10223 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
10224 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
10227 memset(duUeCb->f1UeDb, 0, sizeof(F1UeContextSetupDb));
10228 duUeCb->f1UeDb->actionType = UE_CTXT_SETUP;
10229 duUeCb->f1UeDb->cellIdx = cellIdx;
10233 DU_LOG("\nERROR --> F1AP: Memory Alloc Failed at procF1UeContextSetupReq()");
10243 DU_LOG("\nERROR --> F1AP: DuUeCb is not found at procF1UeContextSetupReq()");
10248 case ProtocolIE_ID_id_SpCellULConfigured:
10249 /* Indicates whether the gNB-CU requests the gNB-DU to configure the uplink as no UL,
10250 UL, SUL or UL+SUL for the indicated cell for the UE */
10252 case ProtocolIE_ID_id_CUtoDURRCInformation:
10254 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList)
10256 duUeCb->f1UeDb->duUeCfg.ueNrCapability = \
10257 extractUeCapability(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.\
10258 uE_CapabilityRAT_ContainerList, duUeCb);
10260 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.iE_Extensions)
10262 duUeCb->f1UeDb->duUeCfg.cellGrpCfg = extractCellGrpInfo(ueSetReq->protocolIEs.list.array[ieIdx]->\
10263 value.choice.CUtoDURRCInformation.iE_Extensions, &duUeCb->f1UeDb->duUeCfg);
10264 if(!duUeCb->f1UeDb->duUeCfg.cellGrpCfg)
10266 DU_LOG("\nERROR --> F1AP: Failed to extract cell Grp Info");
10267 //TODO: Update the failure cause in ue context Setup Response
10273 case ProtocolIE_ID_id_SCell_ToBeSetup_List:
10275 DU_LOG("\nINFO --> DU_APP: Received SCell_ToBeSetup_List but Not processing the list");
10278 case ProtocolIE_ID_id_SRBs_ToBeSetup_List:
10280 if(extractSrbListToSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SRBs_ToBeSetup_List,\
10281 &duUeCb->f1UeDb->duUeCfg))
10283 DU_LOG("\nERROR --> DU APP : Failed at extractSrbListToSetup()");
10284 //TODO: Update the failure cause in ue context Setup Response
10289 case ProtocolIE_ID_id_DRBs_ToBeSetup_List:
10291 lcId = getDrbLcId(&duUeCb->drbBitMap);
10292 if(lcId != RFAILED)
10294 drbCfg = &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRBs_ToBeSetup_List;
10295 if(extractDrbListToSetup(lcId, drbCfg, NULL, drbCfg->list.count, &duUeCb->f1UeDb->duUeCfg))
10297 DU_LOG("\nERROR --> DU APP : Failed at extractDrbListToSetup()");
10298 //TODO: Update the failure cause in ue context Setup Response
10306 case ProtocolIE_ID_id_RRCContainer:
10308 /* Filling Dl RRC Msg Info */
10309 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
10310 if(!duUeCb->f1UeDb->dlRrcMsg)
10312 DU_LOG("\nERROR --> DU APP : Memory allocation failed for DL RRC Msg in procUeCtxtSetupReq()");
10317 duUeCb->f1UeDb->dlRrcMsgPres = true;
10318 memset(duUeCb->f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
10319 ret = extractDlRrcMsg(gnbDuUeF1apId, gnbCuUeF1apId, duUeCb->f1UeDb->dlRrcMsg,\
10320 &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer);
10324 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
10326 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
10328 duUeCb->f1UeDb->dlRrcMsg->deliveryStatRpt = true;
10332 DU_LOG("\nERROR --> Ignoring delivery report, since rrcContainer is not present");
10336 case ProtocolIE_ID_id_GNB_DU_UE_AMBR_UL:
10338 /* MaximumBitRate Uplink */
10339 bitRateSize = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.size;
10340 if(bitRateSize > 0)
10342 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->duUeCfg.ambrCfg, bitRateSize);
10343 if(!duUeCb->f1UeDb->duUeCfg.ambrCfg)
10345 DU_LOG("\nERROR --> DU APP : Memory allocation failed for bitRate in procUeCtxtSetupReq");
10350 memset(duUeCb->f1UeDb->duUeCfg.ambrCfg, 0, sizeof(AmbrCfg));
10351 memcpy(&duUeCb->f1UeDb->duUeCfg.ambrCfg->ulBr,
10352 ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf, bitRateSize);
10367 /*TODO : Negative case*/
10368 // BuildAndSendUeContextSetupRsp(cellId,ueIdx);
10369 DU_LOG("\nERROR --> F1AP: Failed to process UE CNTXT SETUP REQ at procF1UeContextSetupReq()");
10372 ret = duProcUeContextSetupRequest(duUeCb);
10374 freeAperDecodeF1UeContextSetupReq(ueSetReq);
10378 /*******************************************************************
10379 * @brief Free the memory allocated for Dl Tunnel Info
10383 * Function : freeDlTnlInfo
10386 * Free the memory allocated for Dl Tunnel Info
10388 * @params[in] DLUPTNLInformation_ToBeSetup_List_t *
10391 * ****************************************************************/
10393 void freeDlTnlInfo(DLUPTNLInformation_ToBeSetup_List_t *tnlInfo)
10395 uint8_t arrIdx = 0;
10397 for(arrIdx=0; arrIdx < tnlInfo->list.count; arrIdx++)
10399 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel, sizeof(GTPTunnel_t));
10403 /*******************************************************************
10404 * @brief Free the memory allocated for DRB setup List
10408 * Function : freeDrbSetupList
10411 * Free the memory allocated for DRB setup list
10413 * @params[in] DRBs_Setup_List_t *
10416 * ****************************************************************/
10417 void freeDrbSetupList(DRBs_Setup_List_t *drbSetupList)
10419 uint8_t arrIdx = 0;
10420 DRBs_Setup_ItemIEs_t *drbItemIe = NULLP;
10422 for(arrIdx = 0; arrIdx < drbSetupList->list.count; arrIdx++)
10424 drbItemIe = ((DRBs_Setup_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
10425 freeDlTnlInfo(&drbItemIe->value.choice.DRBs_Setup_Item.dLUPTNLInformation_ToBeSetup_List);
10429 /*******************************************************************
10430 * @brief Free the memory allocated for UE Setup response
10434 * Function : FreeUeContextSetupRsp
10437 * Free the memory allocated for UE Setup response
10439 * @params[in] F1AP PDU for UE setup response
10440 * @return ROK - success
10441 * RFAILED - failure
10443 * ****************************************************************/
10444 void FreeUeContextSetupRsp(F1AP_PDU_t *f1apMsg)
10447 UEContextSetupResponse_t *ueSetRsp = NULLP;
10451 if(f1apMsg->choice.successfulOutcome)
10453 ueSetRsp = &f1apMsg->choice.successfulOutcome->value.choice.\
10454 UEContextSetupResponse;
10455 if(ueSetRsp->protocolIEs.list.array)
10457 for(idx = 0; idx < ueSetRsp->protocolIEs.list.count; idx++)
10459 if(ueSetRsp->protocolIEs.list.array[idx])
10461 switch(ueSetRsp->protocolIEs.list.array[idx]->id)
10463 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
10465 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
10467 case ProtocolIE_ID_id_DUtoCURRCInformation:
10469 CellGroupConfig_t *cellGrpCfg = NULLP;
10470 cellGrpCfg = &ueSetRsp->protocolIEs.list.array[idx]->value.choice.\
10471 DUtoCURRCInformation.cellGroupConfig;
10472 if(cellGrpCfg->buf != NULLP)
10474 DU_FREE(cellGrpCfg->buf, cellGrpCfg->size);
10475 cellGrpCfg = NULLP;
10479 case ProtocolIE_ID_id_DRBs_Setup_List:
10481 freeDrbSetupList(&ueSetRsp->protocolIEs.list.array[idx]->value.choice.DRBs_Setup_List);
10485 DU_LOG("\nERROR --> DUAPP: Invalid Id %ld at FreeUeContextSetupRsp()",\
10486 ueSetRsp->protocolIEs.list.array[idx]->id);
10489 DU_FREE(ueSetRsp->protocolIEs.list.array[idx],\
10490 sizeof(UEContextSetupResponseIEs_t));
10493 DU_FREE(ueSetRsp->protocolIEs.list.array, \
10494 ueSetRsp->protocolIEs.list.size);
10496 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
10498 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
10502 /*******************************************************************
10504 * @brief Builds Ue context Setup Rsp DU To CU Info
10508 * Function : EncodeUeCntxtDuToCuInfo
10510 * Functionality: Builds Ue context Setup Rsp DU To CU Info
10512 * @params[in] CellGroupConfig_t *, CellGroupConfigRrc_t *
10514 * @return ROK - success
10515 * RFAILED - failure
10517 ******************************************************************/
10519 uint8_t EncodeUeCntxtDuToCuInfo(CellGroupConfig_t *duToCuCellGrp, CellGroupConfigRrc_t *duCellGrpCfg)
10521 asn_enc_rval_t encRetVal;
10523 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, duCellGrpCfg);
10524 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
10526 encRetVal = aper_encode(&asn_DEF_CellGroupConfigRrc, 0, duCellGrpCfg, PrepFinalEncBuf, encBuf);
10527 /* Encode results */
10528 if(encRetVal.encoded == ENCODE_FAIL)
10530 DU_LOG( "\nERROR --> F1AP : Could not encode UeCntxtDuToCuInfo (at %s)\n",\
10531 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
10536 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UeCntxtDuToCuInfo\n");
10537 for(int i=0; i< encBufSize; i++)
10539 printf("%x",encBuf[i]);
10542 duToCuCellGrp->size = encBufSize;
10543 DU_ALLOC(duToCuCellGrp->buf, duToCuCellGrp->size);
10544 if(!duToCuCellGrp->buf)
10546 DU_LOG("\nERROR --> F1AP : Memory allocation failed in UeCntxtDuToCuInfo");
10548 memcpy(duToCuCellGrp->buf, encBuf, duToCuCellGrp->size);
10552 /*******************************************************************
10554 * @brief Fills Dl Gtp tunnel Info
10558 * Function : fillGtpTunnelforDl
10560 * Functionality: Fills Dl Gtp tunnel Info
10564 * @return ROK - success
10565 * RFAILED - failure
10567 * ****************************************************************/
10569 uint8_t fillGtpTunnelforDl(GTPTunnel_t *gtpDl, GtpTnlCfg *gtpUeCfg)
10571 uint8_t bufSize = 0;
10573 gtpDl->transportLayerAddress.size = 4*sizeof(uint8_t);
10574 DU_ALLOC(gtpDl->transportLayerAddress.buf, gtpDl->transportLayerAddress.size);
10575 if(gtpDl->transportLayerAddress.buf == NULLP)
10579 memcpy(gtpDl->transportLayerAddress.buf, >pUeCfg->dlTnlAddress, gtpDl->transportLayerAddress.size);
10582 gtpDl->gTP_TEID.size = 4 * sizeof(uint8_t);
10583 DU_ALLOC(gtpDl->gTP_TEID.buf, gtpDl->gTP_TEID.size);
10584 if(gtpDl->gTP_TEID.buf == NULLP)
10588 bufSize = 3; /*forming an Octect String*/
10589 fillTeIdString(bufSize, gtpUeCfg->teId, gtpDl->gTP_TEID.buf);
10594 /*******************************************************************
10596 * @brief Fills DL Tunnel Setup List
10600 * Function : fillDlTnlSetupList
10602 * Functionality: Fills the DL Tunnel Setup List
10606 * @return ROK - success
10607 * RFAILED - failure
10609 * ****************************************************************/
10611 uint8_t fillDlTnlSetupList(DLUPTNLInformation_ToBeSetup_List_t *dlTnlInfo, UpTnlCfg *tnlCfg)
10613 uint8_t ret = ROK, arrIdx = 0, eleCount = 0;
10616 dlTnlInfo->list.count = eleCount;
10617 dlTnlInfo->list.size = (eleCount * sizeof(DLUPTNLInformation_ToBeSetup_Item_t *));
10619 /* Initialize the DL Tnl Setup List Members */
10620 DU_ALLOC(dlTnlInfo->list.array, dlTnlInfo->list.size);
10621 if(dlTnlInfo->list.array == NULLP)
10623 DU_LOG(" ERROR --> F1AP : Memory allocation for DL Tnl Setup List in fillDlTnlSetupList()");
10626 for(arrIdx=0; arrIdx < eleCount; arrIdx++)
10628 DU_ALLOC(dlTnlInfo->list.array[arrIdx], sizeof(DLUPTNLInformation_ToBeSetup_Item_t));
10629 if(dlTnlInfo->list.array[arrIdx] == NULLP)
10631 DU_LOG(" ERROR --> F1AP : Memory allocation for arrIdx [%d] failed in fillDlTnlSetupList()", arrIdx);
10634 dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.present = UPTransportLayerInformation_PR_gTPTunnel;
10635 DU_ALLOC(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel, sizeof(GTPTunnel_t));
10636 if(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel == NULLP)
10638 DU_LOG(" ERROR --> F1AP : Memory allocation for DL tunnel info in fillDlTnlSetupList()");
10641 ret = fillGtpTunnelforDl(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel,\
10649 /*******************************************************************
10651 * @brief Fills the Drb Setup List for Ue Context Setup Response
10655 * Function : fillDrbSetupList
10657 * Functionality: Fills the Drb Setup List for Ue Context Setup Response
10661 * @return ROK - success
10662 * RFAILED - failure
10664 * ****************************************************************/
10665 uint8_t fillDrbSetupList(DRBs_Setup_List_t *drbSetupList, DuUeCfg *ueCfg)
10667 uint8_t ret = ROK, arrIdx = 0, eleCount = 0;
10668 DRBs_Setup_ItemIEs_t *drbItemIe = NULLP;
10670 eleCount = ueCfg->numDrb;
10671 drbSetupList->list.count = eleCount;
10672 drbSetupList->list.size = \
10673 (eleCount * sizeof(DRBs_Setup_Item_t *));
10675 /* Initialize the Drb Setup List Members */
10676 DU_ALLOC(drbSetupList->list.array, drbSetupList->list.size);
10677 if(drbSetupList->list.array == NULLP)
10679 DU_LOG(" ERROR --> F1AP : Memory allocation for DRB Setup List in fillDrbSetupList()");
10683 for(arrIdx=0; arrIdx < eleCount; arrIdx++)
10685 DU_ALLOC(drbSetupList->list.array[arrIdx], sizeof(DRBs_Setup_Item_t));
10686 if(drbSetupList->list.array[arrIdx] == NULLP)
10688 DU_LOG(" ERROR --> F1AP : Memory allocation for arrIdx [%d] failed in fillDrbSetupList()", arrIdx);
10691 drbItemIe = ((DRBs_Setup_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
10692 drbItemIe->id = ProtocolIE_ID_id_DRBs_Setup_Item;
10693 drbItemIe->criticality = Criticality_reject;
10694 drbItemIe->value.present = DRBs_Setup_ItemIEs__value_PR_DRBs_Setup_Item;
10695 drbItemIe->value.choice.DRBs_Setup_Item.dRBID = ueCfg->upTnlInfo[arrIdx].drbId;
10696 ret = fillDlTnlSetupList(&drbItemIe->value.choice.DRBs_Setup_Item.dLUPTNLInformation_ToBeSetup_List,\
10697 &ueCfg->upTnlInfo[arrIdx]);
10704 /*******************************************************************
10706 * @brief Builds and sends the UE Setup Response
10710 * Function : BuildAndSendUeContextSetupRsp
10712 * Functionality: Constructs the UE Setup Response and sends
10713 * it to the DU through SCTP.
10715 * @params[in] uint8_t cellId,uint8_t ueIdx
10717 * @return ROK - success
10718 * RFAILED - failure
10720 * ****************************************************************/
10721 uint8_t BuildAndSendUeContextSetupRsp(uint8_t cellId,uint8_t ueIdx)
10723 uint8_t idx, ret, cellIdx, elementCnt;
10724 uint32_t gnbCuUeF1apId; /* gNB-CU UE F1AP Id */
10725 uint32_t gnbDuUeF1apId; /* gNB-DU UE F1AP Id */
10726 asn_enc_rval_t encRetVal; /* Encoder return value */
10727 F1AP_PDU_t *f1apMsg = NULLP;
10728 UEContextSetupResponse_t *ueSetRsp = NULLP;
10729 CellGroupConfigRrc_t *cellGrpCfg = NULLP;
10730 DuUeCb *ueCb = NULLP;
10732 DU_LOG("\n INFO --> F1AP : Building UE Context Setup Response for cellId %d, ueIdx %d\n", cellId, ueIdx);
10736 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
10737 if(f1apMsg == NULLP)
10739 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
10744 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
10745 DU_ALLOC(f1apMsg->choice.successfulOutcome,
10746 sizeof(SuccessfulOutcome_t));
10747 if(f1apMsg->choice.successfulOutcome == NULLP)
10749 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
10754 f1apMsg->choice.successfulOutcome->procedureCode = \
10755 ProcedureCode_id_UEContextSetup;
10756 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
10757 f1apMsg->choice.successfulOutcome->value.present = \
10758 SuccessfulOutcome__value_PR_UEContextSetupResponse;
10761 &f1apMsg->choice.successfulOutcome->value.choice.UEContextSetupResponse;
10763 ueSetRsp->protocolIEs.list.count = elementCnt;
10764 ueSetRsp->protocolIEs.list.size = \
10765 elementCnt * sizeof(UEContextSetupResponse_t *);
10767 /* Initialize the UESetup members */
10768 DU_ALLOC(ueSetRsp->protocolIEs.list.array, \
10769 ueSetRsp->protocolIEs.list.size);
10770 if(ueSetRsp->protocolIEs.list.array == NULLP)
10772 DU_LOG(" ERROR --> F1AP : Memory allocation for UE Setup Response failed");
10777 for(idx=0; idx<elementCnt; idx++)
10779 DU_ALLOC(ueSetRsp->protocolIEs.list.array[idx],\
10780 sizeof(UEContextSetupResponseIEs_t));
10781 if(ueSetRsp->protocolIEs.list.array[idx] == NULLP)
10783 DU_LOG(" ERROR --> F1AP : Memory allocation for UE Setup Response failed");
10788 /* Fetching Ue Cb Info*/
10789 GET_CELL_IDX(cellId, cellIdx);
10790 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
10791 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
10792 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
10795 /*GNB CU UE F1AP ID*/
10796 ueSetRsp->protocolIEs.list.array[idx]->id = \
10797 ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
10798 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
10799 ueSetRsp->protocolIEs.list.array[idx]->value.present = \
10800 UEContextSetupResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
10801 ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
10803 /*GNB DU UE F1AP ID*/
10805 ueSetRsp->protocolIEs.list.array[idx]->id = \
10806 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
10807 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
10808 ueSetRsp->protocolIEs.list.array[idx]->value.present = \
10809 UEContextSetupResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
10810 ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
10813 /*DUtoCURRC Information */
10815 ueSetRsp->protocolIEs.list.array[idx]->id = \
10816 ProtocolIE_ID_id_DUtoCURRCInformation;
10817 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
10818 ueSetRsp->protocolIEs.list.array[idx]->value.present =\
10819 UEContextSetupResponseIEs__value_PR_DUtoCURRCInformation;
10822 if(ueCb->f1UeDb->duUeCfg.cellGrpCfg)
10824 cellGrpCfg = (CellGroupConfigRrc_t*)ueCb->f1UeDb->duUeCfg.cellGrpCfg;
10825 ret = EncodeUeCntxtDuToCuInfo(&ueSetRsp->protocolIEs.list.array[idx]->value.\
10826 choice.DUtoCURRCInformation.cellGroupConfig, cellGrpCfg);
10829 DU_LOG("\nERROR --> F1AP : Failed to EncodeUeCntxtDuToCuInfo in BuildAndSendUeContextSetupRsp()");
10830 freeF1UeDb(ueCb->f1UeDb);
10831 ueCb->f1UeDb = NULLP;
10838 DU_LOG("\nERROR --> F1AP : Failed to form DUtoCU RRCInfo at BuildAndSendUeContextSetupRsp()");
10843 /* Drb Setup List */
10845 ueSetRsp->protocolIEs.list.array[idx]->id = \
10846 ProtocolIE_ID_id_DRBs_Setup_List;
10847 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
10848 ueSetRsp->protocolIEs.list.array[idx]->value.present =\
10849 UEContextSetupResponseIEs__value_PR_DRBs_Setup_List;
10850 ret = fillDrbSetupList(&ueSetRsp->protocolIEs.list.array[idx]->value.choice.DRBs_Setup_List,\
10851 &ueCb->f1UeDb->duUeCfg);
10854 DU_LOG("\nERROR --> F1AP : Failed to fillDrbSetupList in BuildAndSendUeContextSetupRsp()");
10855 freeF1UeDb(ueCb->f1UeDb);
10856 ueCb->f1UeDb = NULLP;
10860 /* Free UeContext Db created during Ue context Req */
10861 freeF1UeDb(ueCb->f1UeDb);
10862 ueCb->f1UeDb = NULLP;
10864 /* TODO: To send Drb list */
10865 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
10867 /* Encode the UE context setup response type as APER */
10868 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
10870 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
10872 /* Encode results */
10873 if(encRetVal.encoded == ENCODE_FAIL)
10875 DU_LOG( "\nERROR --> F1AP : Could not encode UE Context Setup Response structure (at %s)\n",\
10876 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
10882 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UE Context Setup Response\n");
10883 for(int i=0; i< encBufSize; i++)
10885 printf("%x",encBuf[i]);
10890 if(sendF1APMsg() != ROK)
10892 DU_LOG("\nERROR --> F1AP : Sending UE Context Setup Response failed");
10898 FreeUeContextSetupRsp(f1apMsg);
10900 }/* End of BuildAndSendUeContextSetupRsp */
10901 /*******************************************************************
10903 * @brief Build And Send Ue Context Rsp
10907 * Function : BuildAndSendUeCtxtRsp
10909 * Functionality : Build And Send Ue Context Rsp
10912 * @return sucess = ROK
10913 * failure = RFAILED
10915 * ****************************************************************/
10916 uint8_t BuildAndSendUeCtxtRsp(uint8_t cellId, uint8_t ueIdx)
10918 uint8_t cellIdx = 0, actionType = 0;
10920 GET_CELL_IDX(cellId, cellIdx);
10921 actionType = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb->actionType;
10925 case UE_CTXT_SETUP:
10927 BuildAndSendUeContextSetupRsp(cellId,ueIdx);
10932 BuildAndSendUeContextModRsp(cellId, ueIdx);
10936 DU_LOG("ERROR --> F1AP: Invalid Action Type %d at BuildAndSendUeCtxtRsp()", actionType);
10943 /*******************************************************************
10945 * @brief deallocating the memory of F1reset msg
10949 * Function : FreeF1ResetReq
10952 * - freeing memory of F1reset request msg
10958 * ****************************************************************/
10959 void FreeF1ResetReq(F1AP_PDU_t *f1apMsg)
10962 Reset_t *f1ResetMsg;
10966 if(f1apMsg->choice.initiatingMessage)
10968 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
10970 if(f1ResetMsg->protocolIEs.list.array)
10972 for(idx=0 ;idx < f1ResetMsg->protocolIEs.list.count ; idx++)
10974 if(f1ResetMsg->protocolIEs.list.array[idx])
10976 DU_FREE(f1ResetMsg->protocolIEs.list.array[idx],sizeof(ResetIEs_t));
10979 DU_FREE(f1ResetMsg->protocolIEs.list.array,f1ResetMsg->protocolIEs.list.size);
10981 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
10983 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
10986 /*******************************************************************
10988 * @brief Build and Send F1reset request
10992 * Function : BuildAndSendF1ResetReq
10995 * - Build and Send F1reset request msg
10998 * @return ROK - success
10999 * RFAILED - failure
11001 * ****************************************************************/
11002 uint8_t BuildAndSendF1ResetReq()
11004 uint8_t elementCnt=0;
11006 uint8_t ret= RFAILED;
11007 Reset_t *f1ResetMsg = NULLP;
11008 F1AP_PDU_t *f1apMsg = NULLP;
11009 asn_enc_rval_t encRetVal;
11010 DU_LOG("\nINFO --> F1AP : Building F1 Reset request \n");
11013 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
11014 if(f1apMsg == NULLP)
11018 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
11019 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
11020 if(f1apMsg->choice.initiatingMessage == NULLP)
11024 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_Reset;
11025 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
11026 f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_Reset;
11028 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
11031 f1ResetMsg->protocolIEs.list.count = elementCnt;
11032 f1ResetMsg->protocolIEs.list.size = elementCnt * sizeof(ResetIEs_t *);
11034 /* Initialize the F1Setup members */
11035 DU_ALLOC(f1ResetMsg->protocolIEs.list.array,f1ResetMsg->protocolIEs.list.size);
11036 if(f1ResetMsg->protocolIEs.list.array == NULLP)
11040 for(idx=0; idx<elementCnt; idx++)
11042 DU_ALLOC(f1ResetMsg->protocolIEs.list.array[idx],sizeof(ResetIEs_t));
11043 if(f1ResetMsg->protocolIEs.list.array[idx] == NULLP)
11051 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID;
11052 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11053 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_TransactionID;
11054 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.TransactionID = 1;
11058 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_Cause;
11059 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_ignore;
11060 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_Cause;
11061 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.Cause.present = Cause_PR_radioNetwork;
11062 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.Cause.choice.radioNetwork = CauseRadioNetwork_action_desirable_for_radio_reasons;
11066 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_ResetType;
11067 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11068 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_ResetType;
11069 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.ResetType.present = ResetType_PR_f1_Interface;
11070 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.ResetType.choice.f1_Interface = ResetAll_reset_all;
11072 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
11074 /* Encode the F1SetupRequest type as APER */
11075 memset(encBuf, 0, ENC_BUF_MAX_LEN);
11077 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
11080 /* Encode results */
11081 if(encRetVal.encoded == ENCODE_FAIL)
11083 DU_LOG("\nERROR --> F1AP : Could not encode F1Reset structure (at %s)\n",\
11084 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
11089 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for F1Reset\n");
11090 for(idx=0; idx< encBufSize; idx++)
11092 printf("%x",encBuf[idx]);
11096 if(sendF1APMsg() != ROK)
11098 DU_LOG("\nERROR --> F1AP : Sending F1 Reset request failed");
11106 FreeF1ResetReq(f1apMsg);
11109 /*******************************************************************
11111 * @brief Build And Send F1ResetAck
11115 * Function : BuildAndSendF1ResetAck
11118 * - Build And Send F1ResetRSP
11120 * @return ROK - success
11121 * RFAILED - failure
11123 * ****************************************************************/
11124 void FreeF1ResetAck(F1AP_PDU_t *f1apMsg)
11127 ResetAcknowledge_t *f1ResetAck;
11131 if(f1apMsg->choice.successfulOutcome)
11133 f1ResetAck= &f1apMsg->choice.successfulOutcome->value.choice.ResetAcknowledge;
11135 if(f1ResetAck->protocolIEs.list.array)
11137 for(idx=0; idx<f1ResetAck->protocolIEs.list.count ; idx++)
11139 if(f1ResetAck->protocolIEs.list.array[idx])
11141 DU_FREE(f1ResetAck->protocolIEs.list.array[idx], sizeof(ResetAcknowledgeIEs_t));
11144 DU_FREE(f1ResetAck->protocolIEs.list.array, f1ResetAck->protocolIEs.list.size );
11146 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
11148 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
11152 /*******************************************************************
11154 * @brief Build And Send F1ResetAck
11158 * Function : BuildAndSendF1ResetAck
11161 * - Build And Send F1ResetRSP
11164 * @return ROK - success
11165 * RFAILED - failure
11167 * ****************************************************************/
11168 uint8_t BuildAndSendF1ResetAck()
11171 uint8_t elementCnt = 0;
11172 uint8_t ret = RFAILED;
11173 F1AP_PDU_t *f1apMsg = NULL;
11174 ResetAcknowledge_t *f1ResetAck = NULLP;
11175 asn_enc_rval_t encRetVal;
11176 DU_LOG("\nINFO --> F1AP : Building F1 Reset Acknowledgment \n");
11179 /* Allocate the memory for F1ResetRequest_t */
11180 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
11181 if(f1apMsg == NULLP)
11183 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11187 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
11189 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
11190 if(f1apMsg->choice.successfulOutcome == NULLP)
11192 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11195 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
11196 f1apMsg->choice.successfulOutcome->value.present = SuccessfulOutcome__value_PR_ResetAcknowledge;
11197 f1ResetAck = &f1apMsg->choice.successfulOutcome->value.choice.ResetAcknowledge;
11201 f1ResetAck->protocolIEs.list.count = elementCnt;
11202 f1ResetAck->protocolIEs.list.size = elementCnt*sizeof(ResetAcknowledgeIEs_t *);
11204 DU_ALLOC(f1ResetAck->protocolIEs.list.array, f1ResetAck->protocolIEs.list.size );
11205 if(f1ResetAck->protocolIEs.list.array == NULLP)
11207 DU_LOG("\nERROR --> F1AP : Memory allocation for F1ResetAckIEs failed");
11211 for(idx=0; idx<elementCnt; idx++)
11213 DU_ALLOC(f1ResetAck->protocolIEs.list.array[idx], sizeof(ResetAcknowledgeIEs_t));
11214 if(f1ResetAck->protocolIEs.list.array[idx] == NULLP)
11221 f1ResetAck->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID;
11222 f1ResetAck->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11223 f1ResetAck->protocolIEs.list.array[idx]->value.present = ResetAcknowledgeIEs__value_PR_TransactionID;
11224 f1ResetAck->protocolIEs.list.array[idx]->value.choice.TransactionID = TRANS_ID;
11226 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
11228 /* Encode the F1SetupRequest type as UPER */
11229 memset(encBuf, 0, ENC_BUF_MAX_LEN);
11231 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
11233 /* Check encode results */
11234 if(encRetVal.encoded == ENCODE_FAIL)
11236 DU_LOG("\nERROR --> F1AP : Could not encode F1ResetAck structure (at %s)\n",\
11237 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
11242 DU_LOG("\nDUBUG --> F1AP : Created APER encoded buffer for F1ResetAck\n");
11243 for(int i=0; i< encBufSize; i++)
11245 printf("%x",encBuf[i]);
11249 if(sendF1APMsg() != ROK)
11251 DU_LOG("\nERROR --> F1AP : Sending F1 Reset Acknowledgement failed");
11259 FreeF1ResetAck(f1apMsg);
11262 /******************************************************************
11264 * @brief free F1 reset msg allocated by aper_decoder
11268 * Function : freeAperDecodeF1ResetMsg
11270 * Functionality: free F1 reset msg allocated by aper_decoder
11272 * @params[in] Reset_t *f1ResetMsg
11275 * ****************************************************************/
11277 void freeAperDecodeF1ResetMsg(Reset_t *f1ResetMsg)
11280 if(f1ResetMsg->protocolIEs.list.array)
11282 for(ieIdx=0 ;ieIdx < f1ResetMsg->protocolIEs.list.count ; ieIdx++)
11284 if(f1ResetMsg->protocolIEs.list.array[ieIdx])
11286 free(f1ResetMsg->protocolIEs.list.array[ieIdx]);
11289 free(f1ResetMsg->protocolIEs.list.array);
11293 /******************************************************************
11295 * @brief Processes DL RRC Message Transfer sent by CU
11299 * Function : procF1ResetReq
11301 * Functionality: Processes DL RRC Message Transfer sent by CU
11303 * @params[in] F1AP_PDU_t ASN decoded F1AP message
11304 * @return ROK - success
11305 * RFAILED - failure
11307 * ****************************************************************/
11308 uint8_t procF1ResetReq(F1AP_PDU_t *f1apMsg)
11310 /* we are currently not supporting Ue release. right now we are supporting only init case of fireset */
11313 Reset_t *f1ResetMsg = NULLP;
11315 DU_LOG("\nINFO --> Processing F1 reset request");
11316 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
11318 for(ieIdx=0; ieIdx<f1ResetMsg->protocolIEs.list.count; ieIdx++)
11320 switch(f1ResetMsg->protocolIEs.list.array[ieIdx]->id)
11322 case ProtocolIE_ID_id_TransactionID:
11325 case ProtocolIE_ID_id_Cause:
11328 case ProtocolIE_ID_id_ResetType:
11337 ret = BuildAndSendF1ResetAck();
11338 DU_LOG("\nINFO --> UE release is not supported for now");
11340 freeAperDecodeF1ResetMsg(f1ResetMsg);
11345 /*******************************************************************
11347 * @brief free the RRC delivery report
11351 * Function : freeRrcDeliveryReport
11353 * Functionality: free the RRC delivery report
11356 * @return ROK - success
11357 * RFAILED - failure
11359 * ****************************************************************/
11360 void freeRrcDeliveryReport(F1AP_PDU_t *f1apMsg )
11363 RRCDeliveryReport_t *rrcDeliveryReport= NULLP;
11367 if(f1apMsg->choice.initiatingMessage)
11369 rrcDeliveryReport = &f1apMsg->choice.initiatingMessage->value.choice.RRCDeliveryReport;
11370 if(rrcDeliveryReport->protocolIEs.list.array)
11372 for(idx =0 ;idx <rrcDeliveryReport->protocolIEs.list.count ;
11375 if(rrcDeliveryReport->protocolIEs.list.array[idx])
11377 DU_FREE(rrcDeliveryReport->protocolIEs.list.array[idx],
11378 sizeof(RRCDeliveryReportIEs_t));
11381 DU_FREE(rrcDeliveryReport->protocolIEs.list.array,
11382 rrcDeliveryReport->protocolIEs.list.size);
11384 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
11387 sizeof(F1AP_PDU_t));
11391 /*******************************************************************
11393 * @brief Builds and sends the RRC delivery report
11397 * Function : BuildAndSendRrcDeliveryReport
11399 * Functionality: Builds and sends the RRC delivery report
11403 * @return ROK - success
11404 * RFAILED - failure
11406 * ****************************************************************/
11407 uint8_t BuildAndSendRrcDeliveryReport(uint32_t gnbCuUeF1apId, \
11408 uint32_t gnbDuUeF1apId, RrcDeliveryReport *rrcDelivery)
11410 uint8_t ret = RFAILED;
11413 uint8_t elementCnt = 0;
11414 F1AP_PDU_t *f1apMsg = NULLP;
11415 asn_enc_rval_t encRetVal;
11416 RRCDeliveryReport_t *rrcDeliveryReport= NULLP;
11420 DU_LOG("\nINFO --> F1AP : Building RRC delivery Message Transfer Message\n");
11421 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
11422 if(f1apMsg == NULLP)
11424 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11427 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
11428 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
11429 if(f1apMsg->choice.initiatingMessage == NULLP)
11431 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11434 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_RRCDeliveryReport;
11435 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
11436 f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_RRCDeliveryReport;
11438 rrcDeliveryReport = &f1apMsg->choice.initiatingMessage->value.choice.RRCDeliveryReport;
11440 rrcDeliveryReport->protocolIEs.list.count = elementCnt;
11441 rrcDeliveryReport->protocolIEs.list.size = elementCnt * sizeof(RRCDeliveryReportIEs_t *);
11443 /* Initialize the F1Setup members */
11444 DU_ALLOC(rrcDeliveryReport->protocolIEs.list.array, rrcDeliveryReport->protocolIEs.list.size);
11445 if(rrcDeliveryReport->protocolIEs.list.array == NULLP)
11447 DU_LOG(" ERROR --> F1AP : Memory allocation for RRC Delivery failed");
11450 for(idx =0 ;idx <elementCnt; idx++)
11452 DU_ALLOC(rrcDeliveryReport->protocolIEs.list.array[idx], sizeof(RRCDeliveryReportIEs_t));
11453 if(rrcDeliveryReport->protocolIEs.list.array[idx] == NULLP)
11461 /*GNB CU UE F1AP ID*/
11462 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
11463 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
11464 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_GNB_CU_UE_F1AP_ID;
11465 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
11467 /*GNB DU UE F1AP ID*/
11469 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
11470 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
11471 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_GNB_DU_UE_F1AP_ID;
11472 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
11474 /*RRC delivery status*/
11476 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_RRCDeliveryStatus;
11477 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_ignore;
11478 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_RRCDeliveryStatus;
11479 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.RRCDeliveryStatus.delivery_status =\
11480 rrcDelivery->rrcDeliveryStatus.deliveryStatus;
11481 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.RRCDeliveryStatus.triggering_message =\
11482 rrcDelivery->rrcDeliveryStatus.triggeringMessage;
11486 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_SRBID;
11487 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_ignore;
11488 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_SRBID;
11489 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.SRBID = rrcDelivery->srbId;
11491 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
11493 /* Encode the RRC DELIVERY REPORT type as APER */
11494 memset(encBuf, 0, ENC_BUF_MAX_LEN);
11496 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
11499 /* Encode results */
11500 if(encRetVal.encoded == ENCODE_FAIL)
11502 DU_LOG("\nERROR --> F1AP : Could not encode RRC Delivery Msg structure (at %s)\n",\
11503 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
11508 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for RRC Delivery Msg \n");
11509 for(idx=0; idx< encBufSize; idx++)
11511 printf("%x",encBuf[idx]);
11516 if(sendF1APMsg() != ROK)
11518 DU_LOG("\nERROR --> F1AP : Sending RRC delivery msg request failed");
11526 freeRrcDeliveryReport(f1apMsg);
11530 /*******************************************************************
11532 * @brief Processes cells to be activated
11536 * Function : extractCellsToBeActivated
11539 * - Processes cells to be activated list received in F1SetupRsp
11542 * @return ROK - success
11543 * RFAILED - failure
11545 * ****************************************************************/
11547 uint8_t extractCellsToBeActivated(Cells_to_be_Activated_List_t cellsToActivate)
11550 uint16_t idx, nci, pci = 0;
11551 Cells_to_be_Activated_List_Item_t cell;
11553 for(idx=0; idx<cellsToActivate.list.count; idx++)
11556 cell = cellsToActivate.list.array[idx]->value.choice.Cells_to_be_Activated_List_Item;
11557 bitStringToInt(&cell.nRCGI.nRCellIdentity, &nci);
11563 ret = duProcCellsToBeActivated(cell.nRCGI.pLMN_Identity.buf, nci, pci);
11567 /******************************************************************
11569 * @brief Processes F1 Setup Response allocated by aper_decoder
11573 * Function : freeF1SetupRsp
11575 * Functionality: free F1 Setup Response allocated by aper_decoder
11577 * @params[in] F1SetupResponse_t *f1SetRspMsg
11580 * ****************************************************************/
11582 void freeAperDecodeF1SetupRsp(F1SetupResponse_t *f1SetRspMsg)
11586 Cells_to_be_Activated_List_t *cellToActivate =NULLP;
11587 RRC_Version_t *rrcVer =NULLP;
11589 if(f1SetRspMsg->protocolIEs.list.array)
11591 for(ieIdx=0; ieIdx<f1SetRspMsg->protocolIEs.list.count; ieIdx++)
11593 if(f1SetRspMsg->protocolIEs.list.array[ieIdx])
11595 switch(f1SetRspMsg->protocolIEs.list.array[ieIdx]->id)
11597 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
11600 &f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.Cells_to_be_Activated_List;
11601 if(cellToActivate->list.array)
11603 for(arrIdx=0; arrIdx<cellToActivate->list.count ; arrIdx++)
11605 if(cellToActivate->list.array[arrIdx])
11608 if(cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.nRCGI.\
11611 if(cellToActivate->list.array[0]->value.choice.\
11612 Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf)
11614 free(cellToActivate->list.array[0]->value.choice.\
11615 Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf);
11618 free(cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.\
11619 nRCGI.pLMN_Identity.buf);
11621 free(cellToActivate->list.array[arrIdx]);
11624 free(cellToActivate->list.array);
11628 case ProtocolIE_ID_id_TransactionID:
11632 case ProtocolIE_ID_id_gNB_CU_Name:
11634 free(f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_Name.buf);
11637 case ProtocolIE_ID_id_GNB_CU_RRC_Version:
11639 rrcVer = &f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.RRC_Version;
11640 if(rrcVer->latest_RRC_Version.buf)
11642 if(rrcVer->iE_Extensions)
11644 if(rrcVer->iE_Extensions->list.array)
11646 if(rrcVer->iE_Extensions->list.array[0])
11648 if(rrcVer->iE_Extensions->list.\
11649 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf)
11651 free(rrcVer->iE_Extensions->list.\
11652 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf);
11654 free(rrcVer->iE_Extensions->list.array[0]);
11656 free(rrcVer->iE_Extensions->list.array);
11658 free(rrcVer->iE_Extensions);
11660 free(rrcVer->latest_RRC_Version.buf);
11667 DU_LOG("\nERROR --> DU_APP : Invalid IE received in F1SetupRsp:%ld",
11668 f1SetRspMsg->protocolIEs.list.array[ieIdx]->id);
11671 free(f1SetRspMsg->protocolIEs.list.array[ieIdx]);
11674 free(f1SetRspMsg->protocolIEs.list.array);
11677 /******************************************************************
11679 * @brief Processes F1 Setup Response sent by CU
11683 * Function : procF1SetupRsp
11685 * Functionality: Processes F1 Setup Response sent by CU
11687 * @params[in] F1AP_PDU_t ASN decoded F1AP message
11688 * @return ROK - success
11689 * RFAILED - failure
11691 * ****************************************************************/
11692 uint8_t procF1SetupRsp(F1AP_PDU_t *f1apMsg)
11696 F1SetupResponse_t *f1SetRspMsg = NULLP;
11697 GNB_CU_Name_t *cuName = NULLP;
11698 F1SetupRsp f1SetRspDb;
11699 RRC_Version_t *rrcVer =NULLP;
11701 memset(&f1SetRspDb, 0, sizeof(F1SetupRsp));
11703 DU_LOG("\nINFO --> F1AP : F1 Setup Response received");
11704 f1SetRspMsg = &f1apMsg->choice.successfulOutcome->value.choice.F1SetupResponse;
11706 for(idx=0; idx<f1SetRspMsg->protocolIEs.list.count; idx++)
11708 switch(f1SetRspMsg->protocolIEs.list.array[idx]->id)
11710 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
11712 extractCellsToBeActivated(f1SetRspMsg->protocolIEs.list.array[idx]->\
11713 value.choice.Cells_to_be_Activated_List);
11716 case ProtocolIE_ID_id_TransactionID:
11718 f1SetRspDb.transId = f1SetRspMsg->protocolIEs.list.array[idx]->\
11719 value.choice.TransactionID;
11722 case ProtocolIE_ID_id_gNB_CU_Name:
11724 cuName = &f1SetRspMsg->protocolIEs.list.array[idx]->\
11725 value.choice.GNB_CU_Name;
11726 strcpy(f1SetRspDb.cuName, (const char*)cuName->buf);
11729 case ProtocolIE_ID_id_GNB_CU_RRC_Version:
11731 rrcVer = &f1SetRspMsg->protocolIEs.list.array[idx]->value.choice.RRC_Version;
11732 strcpy(f1SetRspDb.rrcVersion.rrcVer,
11733 (const char*)rrcVer->latest_RRC_Version.buf);
11737 DU_LOG("\nERROR --> DU_APP : Invalid IE received in F1SetupRsp:%ld",
11738 f1SetRspMsg->protocolIEs.list.array[idx]->id);
11740 duProcF1SetupRsp();
11743 freeAperDecodeF1SetupRsp(f1SetRspMsg);
11746 /*******************************************************************
11748 * @brief free GNB DU config update ack
11752 * Function : freeAperDecodeGnbDuAck
11754 * Functionality: Processes GNB DU config update ack And
11755 * added free part for the memory allocated by aper_decoder
11757 * @params[in] F1AP_PDU_t ASN decoded F1AP message
11758 * @return ROK - success
11759 * RFAILED - failure
11761 * ****************************************************************/
11763 void freeAperDecodeGnbDuAck(GNBDUConfigurationUpdateAcknowledge_t *gnbDuAck)
11767 if(gnbDuAck->protocolIEs.list.array)
11769 for(ieIdx=0; ieIdx < gnbDuAck->protocolIEs.list.count; ieIdx++)
11771 if(gnbDuAck->protocolIEs.list.array[ieIdx])
11773 free(gnbDuAck->protocolIEs.list.array[ieIdx]);
11776 free(gnbDuAck->protocolIEs.list.array);
11780 /*******************************************************************
11782 * @brief Building result of gnb-du config update ack output
11786 * Function : duProcGnbDuCfgUpdAckMsg
11789 * Building output of gnb-du config update ack
11791 * @params[in] transId
11794 * ****************************************************************/
11796 uint8_t duProcGnbDuCfgUpdAckMsg(uint8_t transId)
11798 uint8_t ieIdx=0, arrIdx=0,ret=ROK;
11799 uint8_t ueId =0 , ueIdx =0;
11800 uint16_t cellId =0, cellIdx =0, crnti=0;
11801 CmLList *f1apPduNode = NULLP;
11802 ReservedF1apPduInfo *f1apPduInfo =NULLP;
11803 F1AP_PDU_t *f1apMsgPdu = NULLP;
11804 GNBDUConfigurationUpdate_t *gnbDuConfigUpdate = NULLP;
11805 BIT_STRING_t *cellIdentity=NULLP;
11806 struct Served_Cells_To_Delete_ItemIEs *deleteItemIe=NULLP;
11807 Served_Cells_To_Delete_List_t *cellsToDelete=NULLP;
11808 Served_Cells_To_Delete_Item_t *deleteItem=NULLP;
11810 DU_LOG("\nINFO --> DU APP: GNB-DU config update Ack received ");
11811 f1apPduNode = searchFromReservedF1apPduList(transId);
11812 f1apPduInfo = (ReservedF1apPduInfo *)f1apPduNode->node;
11813 f1apMsgPdu = (F1AP_PDU_t *)f1apPduInfo->f1apMsg;
11817 if(f1apMsgPdu->choice.initiatingMessage)
11819 gnbDuConfigUpdate = &f1apMsgPdu->choice.initiatingMessage->value.choice.GNBDUConfigurationUpdate;
11820 for(ieIdx=0; ieIdx < gnbDuConfigUpdate->protocolIEs.list.count; ieIdx++)
11822 switch(gnbDuConfigUpdate->protocolIEs.list.array[ieIdx]->id)
11824 case ProtocolIE_ID_id_Served_Cells_To_Delete_List:
11826 cellsToDelete = &gnbDuConfigUpdate->protocolIEs.list.array[ieIdx]->value.choice.\
11827 Served_Cells_To_Delete_List;
11828 if(cellsToDelete->list.array)
11830 if(cellsToDelete->list.array[arrIdx])
11832 deleteItemIe = (Served_Cells_To_Delete_ItemIEs_t*)cellsToDelete->list.array[arrIdx];
11833 deleteItem=&deleteItemIe->value.choice.Served_Cells_To_Delete_Item;
11834 if(deleteItem->oldNRCGI.nRCellIdentity.buf)
11836 cellIdentity = &deleteItem->oldNRCGI.nRCellIdentity;
11837 bitStringToInt(cellIdentity, &cellId);
11842 GET_CELL_IDX(cellId, cellIdx);
11843 if(duCb.actvCellLst[cellIdx] != NULLP)
11845 if(duCb.actvCellLst[cellIdx]->numActvUes == 0)
11847 duCb.actvCellLst[cellId-1]->cellStatus = DELETION_IN_PROGRESS;
11848 ret = duSendCellDeletReq(cellId);
11851 DU_LOG("ERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): Failed to send cell delete\
11852 request for cellId[%d]", cellId);
11857 for(ueIdx = 0; ueIdx < duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
11859 crnti = duCb.actvCellLst[cellIdx]->ueCb[ueIdx].crnti;
11860 GET_UE_IDX(crnti,ueId);
11861 ret = BuildAndSendUeContextReleaseReq(cellId, ueId);
11864 DU_LOG("ERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): Failed to build and send UE delete\
11865 request for cellId[%d]", cellId);
11872 DU_LOG("ERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): CellId [%d] not found", cellId);
11885 FreeDUConfigUpdate(f1apMsgPdu);
11886 deleteFromReservedF1apPduList(f1apPduNode);
11890 /*******************************************************************
11892 * @brief Processes GNB DU config update ack
11896 * Function : procF1GNBDUCfgUpdAck
11898 * Functionality: added free part for the memory allocated by aper_decoder
11900 * @params[in] F1AP_PDU_t *f1apMsg
11903 * ****************************************************************/
11904 uint8_t procF1GNBDUCfgUpdAck(F1AP_PDU_t *f1apMsg)
11906 uint8_t ieIdx=0,transId=0;
11907 GNBDUConfigurationUpdateAcknowledge_t *gnbDuAck = NULLP;
11909 DU_LOG("\nINFO --> F1AP : GNB-DU config update acknowledgment");
11910 gnbDuAck = &f1apMsg->choice.successfulOutcome->value.choice.GNBDUConfigurationUpdateAcknowledge;
11912 for(ieIdx=0; ieIdx < gnbDuAck->protocolIEs.list.count; ieIdx++)
11914 switch(gnbDuAck->protocolIEs.list.array[ieIdx]->id)
11916 case ProtocolIE_ID_id_TransactionID:
11918 transId = gnbDuAck->protocolIEs.list.array[ieIdx]->value.choice.TransactionID;
11921 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
11927 DU_LOG("\nERROR --> F1AP: procF1GNBDUCfgUpdAck(): Invalid IE Received: %ld", \
11928 gnbDuAck->protocolIEs.list.array[ieIdx]->id);
11934 duProcGnbDuCfgUpdAckMsg(transId);
11937 /* presently we are not supporting F1 Reset from DU to CU , we are only
11938 * supporting F1 Reset from CU to DU */
11940 if(BuildAndSendF1ResetReq() != ROK)
11946 freeAperDecodeGnbDuAck(gnbDuAck);
11949 /******************************************************************
11951 * @brief free DL RRC Message Transfer allocated by aper_decoder
11955 * Function : freeAperDecodef1DlRrcMsg
11957 * Functionality: free DL RRC Message Transfer allocated by aper_decoder
11959 * @params[in] DLRRCMessageTransfer_t *f1DlRrcMsg
11960 * @return ROK - success
11961 * RFAILED - failure
11963 * ****************************************************************/
11965 void freeAperDecodef1DlRrcMsg(DLRRCMessageTransfer_t *f1DlRrcMsg)
11968 RRCContainer_t *rrcContainer = NULLP;
11970 if(f1DlRrcMsg->protocolIEs.list.array)
11972 for(ieIdx=0; ieIdx<f1DlRrcMsg->protocolIEs.list.count; ieIdx++)
11974 if(f1DlRrcMsg->protocolIEs.list.array[ieIdx])
11976 switch(f1DlRrcMsg->protocolIEs.list.array[ieIdx]->id)
11978 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
11980 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
11982 case ProtocolIE_ID_id_SRBID:
11984 case ProtocolIE_ID_id_RRCContainer:
11986 rrcContainer =&f1DlRrcMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer;
11987 free(rrcContainer->buf);
11989 case ProtocolIE_ID_id_ExecuteDuplication:
11991 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
11995 free(f1DlRrcMsg->protocolIEs.list.array[ieIdx]);
11998 free(f1DlRrcMsg->protocolIEs.list.array);
12001 /******************************************************************
12003 * @brief Processes DL RRC Message Transfer sent by CU
12007 * Function : procF1DlRrcMsgTrans
12009 * Functionality: Processes DL RRC Message Transfer sent by CU
12011 * @params[in] F1AP_PDU_t ASN decoded F1AP message
12012 * @return ROK - success
12013 * RFAILED - failure
12015 * ****************************************************************/
12016 uint8_t procF1DlRrcMsgTrans(F1AP_PDU_t *f1apMsg)
12019 DLRRCMessageTransfer_t *f1DlRrcMsg = NULLP;
12021 memset(&dlMsg, 0, sizeof(F1DlRrcMsg));
12023 DU_LOG("\nINFO --> DU_APP : DL RRC message transfer Recevied");
12024 f1DlRrcMsg = &f1apMsg->choice.initiatingMessage->value.choice.DLRRCMessageTransfer;
12028 for(idx=0; idx<f1DlRrcMsg->protocolIEs.list.count; idx++)
12030 switch(f1DlRrcMsg->protocolIEs.list.array[idx]->id)
12032 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12034 dlMsg.gnbCuUeF1apId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID;
12037 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12039 dlMsg.gnbDuUeF1apId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID;
12042 case ProtocolIE_ID_id_SRBID:
12044 dlMsg.srbId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.SRBID;
12047 case ProtocolIE_ID_id_ExecuteDuplication:
12048 dlMsg.execDup = true;
12051 case ProtocolIE_ID_id_RRCContainer:
12053 if(f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size > 0)
12055 dlMsg.rrcMsgSize = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size;
12056 DU_ALLOC(dlMsg.rrcMsgPdu, dlMsg.rrcMsgSize);
12057 if(dlMsg.rrcMsgPdu)
12059 memcpy(dlMsg.rrcMsgPdu, f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.buf,\
12064 DU_LOG("\nERROR --> DU APP : Memory alloc Failed at RRC Container at procF1DlRrcMsgTrans()");
12070 DU_LOG("\nERROR --> DU_APP : RRC Container Size is invalid:%ld",\
12071 f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size);
12076 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
12078 dlMsg.deliveryStatRpt = true;
12082 DU_LOG("\nERROR --> DU_APP : Invalid IE received in DL RRC Msg Transfer:%ld",
12083 f1DlRrcMsg->protocolIEs.list.array[idx]->id);
12087 ret = duProcDlRrcMsg(&dlMsg);
12089 freeAperDecodef1DlRrcMsg(f1DlRrcMsg);
12092 /*******************************************************************
12094 * @brief Builds the DRB to be Setup Mod list
12100 * Functionality: Constructs the DRB to be Setup Mod list
12102 * @params[in] DRBs_SetupMod_List_t *drbSet
12104 * @return ROK - success
12105 * RFAILED - failure
12107 * ****************************************************************/
12109 uint8_t BuildDrbSetupModList(DRBs_SetupMod_List_t *drbSet , DuUeCfg *ueCfg)
12113 struct DRBs_SetupMod_ItemIEs *drbItemIe;
12116 drbSet->list.count = drbCnt;
12117 drbSet->list.size = drbCnt * sizeof(DRBs_SetupMod_ItemIEs_t *);
12118 DU_ALLOC(drbSet->list.array, drbSet->list.size);
12119 if(drbSet->list.array == NULLP)
12121 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDrbToBeSetupModList");
12124 for(arrIdx=0; arrIdx<drbCnt; arrIdx++)
12126 DU_ALLOC(drbSet->list.array[arrIdx], sizeof(DRBs_SetupMod_ItemIEs_t));
12127 if(drbSet->list.array[arrIdx] == NULLP)
12129 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDrbToBeSetupModList");
12133 drbItemIe = (struct DRBs_SetupMod_ItemIEs *)drbSet->list.array[arrIdx];
12134 drbItemIe->id = ProtocolIE_ID_id_DRBs_SetupMod_Item;
12135 drbItemIe->criticality = Criticality_reject;
12136 drbItemIe->value.present = DRBs_SetupMod_ItemIEs__value_PR_DRBs_SetupMod_Item;
12137 drbItemIe->value.choice.DRBs_SetupMod_Item.dRBID = ueCfg->upTnlInfo[arrIdx].drbId;
12138 if(fillDlTnlSetupList(&drbItemIe->value.choice.DRBs_SetupMod_Item.dLUPTNLInformation_ToBeSetup_List,\
12139 &ueCfg->upTnlInfo[arrIdx])!= ROK)
12141 DU_LOG("\nERROR --> F1AP : Failed to fill DlTnl SetupList in BuildDrbToBeSetupModList");
12149 /*******************************************************************
12150 * @brief Free the memory allocated for DRB setup List
12154 * Function : FreeDrbSetupModList
12157 * Free the memory allocated for DRB setup list
12159 * @params[in] DRBs_Setup_List_t *
12162 * ****************************************************************/
12163 void FreeDrbSetupModList(DRBs_SetupMod_List_t *drbSetupList)
12165 uint8_t arrIdx = 0;
12166 DRBs_SetupMod_ItemIEs_t *drbItemIe = NULLP;
12168 for(arrIdx = 0; arrIdx < drbSetupList->list.count; arrIdx++)
12170 drbItemIe = ((DRBs_SetupMod_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
12171 freeDlTnlInfo(&drbItemIe->value.choice.DRBs_SetupMod_Item.dLUPTNLInformation_ToBeSetup_List);
12174 /*******************************************************************
12175 * @brief Free the memory allocated for UE Context Mod Response
12179 * Function : FreeUeContextModResp
12182 * Free the memory allocated for UE Context Mod Response
12184 * @params[in] F1AP_PDU_t *f1apMsg
12187 * ****************************************************************/
12189 void FreeUeContextModResp(F1AP_PDU_t *f1apMsg)
12192 UEContextModificationResponse_t *ueContextModifyRes = NULLP;
12195 if(f1apMsg->choice.successfulOutcome)
12197 ueContextModifyRes =&f1apMsg->choice.successfulOutcome->value.choice.UEContextModificationResponse;
12198 if(ueContextModifyRes->protocolIEs.list.array)
12200 for(ieIdx=0 ; ieIdx<ueContextModifyRes->protocolIEs.list.count; ieIdx++)
12202 if(ueContextModifyRes->protocolIEs.list.array[ieIdx])
12204 switch(ueContextModifyRes->protocolIEs.list.array[ieIdx]->id)
12206 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12208 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12210 case ProtocolIE_ID_id_DRBs_SetupMod_List:
12212 FreeDrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
12213 value.choice.DRBs_SetupMod_List));
12217 DU_FREE(ueContextModifyRes->protocolIEs.list.array[ieIdx], sizeof(UEContextModificationResponse_t));
12221 DU_FREE(ueContextModifyRes->protocolIEs.list.array, ueContextModifyRes->protocolIEs.list.size);
12223 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
12225 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
12229 /*****************************************************************i
12231 * @brief Creating the ue context modifcation response and sending
12235 * Function : BuildAndSendUeContextModRsp
12238 * - Creating the ue context modifcation response
12240 * @params[in] uint8_t cellId,uint8_t ueIdx
12241 * @return ROK - success
12242 * RFAILED - failure
12244 * ****************************************************************/
12245 uint8_t BuildAndSendUeContextModRsp(uint8_t cellId,uint8_t ueIdx)
12248 uint8_t cellIdx =0;
12249 uint8_t elementCnt = 0;
12250 uint8_t ret = RFAILED;
12251 uint32_t gnbCuUeF1apId; /* gNB-CU UE F1AP Id */
12252 uint32_t gnbDuUeF1apId; /* gNB-DU UE F1AP Id */
12253 F1AP_PDU_t *f1apMsg = NULLP;
12254 asn_enc_rval_t encRetVal;
12255 UEContextModificationResponse_t *ueContextModifyRes = NULLP;
12256 DuUeCb *ueCb = NULLP;
12258 DU_LOG("\nINFO --> F1AP : Building Ue context modification response\n");
12262 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
12263 if(f1apMsg == NULLP)
12265 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed Ue context modification");
12269 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
12271 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
12272 if(f1apMsg->choice.successfulOutcome == NULLP)
12274 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed Ue context modification");
12277 f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_UEContextModification;
12278 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
12279 f1apMsg->choice.successfulOutcome->value.present = SuccessfulOutcome__value_PR_UEContextModificationResponse;
12281 ueContextModifyRes =&f1apMsg->choice.successfulOutcome->value.choice.UEContextModificationResponse;
12284 ueContextModifyRes->protocolIEs.list.count = elementCnt;
12285 ueContextModifyRes->protocolIEs.list.size = elementCnt*sizeof(UEContextModificationResponse_t*);
12287 /* Initialize the UE context modification members */
12288 DU_ALLOC(ueContextModifyRes->protocolIEs.list.array, ueContextModifyRes->protocolIEs.list.size);
12289 if(ueContextModifyRes->protocolIEs.list.array == NULLP)
12291 DU_LOG("\nERROR --> F1AP : Memory allocation for UE context modifcation Request failed");
12295 for(ieIdx=0 ; ieIdx<elementCnt; ieIdx++)
12297 DU_ALLOC(ueContextModifyRes->protocolIEs.list.array[ieIdx], sizeof(UEContextModificationResponse_t));
12298 if(ueContextModifyRes->protocolIEs.list.array[ieIdx] == NULLP)
12300 DU_LOG("\nERROR --> F1AP : Memory allocation for UE context modifcation Request failed");
12305 /* Fetching Ue Cb Info*/
12306 GET_CELL_IDX(cellId, cellIdx);
12307 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
12308 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
12309 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
12312 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
12313 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
12314 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present =\
12315 UEContextModificationResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
12316 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
12319 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
12320 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
12321 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present=\
12322 UEContextModificationResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
12323 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
12326 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DRBs_SetupMod_List;
12327 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
12328 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present =\
12329 UEContextModificationResponseIEs__value_PR_DRBs_SetupMod_List;
12332 ret = BuildDrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
12333 value.choice.DRBs_SetupMod_List) , &ueCb->f1UeDb->duUeCfg);
12336 DU_LOG( "\nERROR --> F1AP : Failed to build drb setupmod List ");
12339 freeF1UeDb(ueCb->f1UeDb);
12340 ueCb->f1UeDb = NULLP;
12342 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
12344 /* Encode the F1SetupRequest type as APER */
12345 memset(encBuf, 0, ENC_BUF_MAX_LEN);
12347 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,encBuf);
12349 /* Encode results */
12350 if(encRetVal.encoded == ENCODE_FAIL)
12352 DU_LOG( "\nERROR --> F1AP : Could not encode UE Context Setup Request structure (at %s)\n",\
12353 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
12359 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UE Context Modification Response\n");
12360 for(int i=0; i< encBufSize; i++)
12362 printf("%x",encBuf[i]);
12367 if(sendF1APMsg() != ROK)
12369 DU_LOG("\nERROR --> F1AP : Sending UE Context Setup Res Failed");
12375 FreeUeContextModResp(f1apMsg);
12378 /*******************************************************************
12380 * @brief Deallocating the memory allocated by the aper decoder
12385 * Function : freeAperDecodeQosInfo
12387 * Functionality: Deallocating the memory allocated for QOSInfo
12389 * @params[in] QoSFlowLevelQoSParameters_t *drbQos
12393 * ****************************************************************/
12395 void freeAperDecodeQosInfo(QoSFlowLevelQoSParameters_t *drbQos)
12397 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI != NULLP)
12399 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
12401 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
12403 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
12405 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
12407 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI);
12410 /*******************************************************************
12412 * @brief Deallocating the memory allocated by the aper decoder
12413 * for UlTnlInfoforDrb
12417 * Function : freeAperDecodeUlTnlInfoforDrbSetupMod
12419 * Functionality: Deallocating memory allocated for UlTnlInfoforDrb
12421 * @params[in] ULUPTNLInformation_ToBeSetup_List_t *ulInfo
12425 * ****************************************************************/
12426 void freeAperDecodeUlTnlInfoforDrbSetupMod(ULUPTNLInformation_ToBeSetup_List_t *ulInfo)
12430 if(ulInfo->list.array)
12432 for(arrIdx=0; arrIdx<ulInfo->list.count ; arrIdx++)
12434 if(ulInfo->list.array[arrIdx])
12436 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel )
12438 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.buf)
12440 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf)
12442 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\
12445 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\
12446 transportLayerAddress.buf);
12448 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel);
12450 free(ulInfo->list.array[arrIdx]);
12453 free(ulInfo->list.array);
12456 /*******************************************************************
12458 * @brief Deallocating the memory allocated by the aper decoder
12459 * for DrbSetupModItem
12463 * Function : freeAperDecodeDrbSetupModItem
12465 * Functionality: Deallocating memory allocated for DrbSetupModItem
12467 * @params[in] DRBs_ToBeSetupMod_Item_t *drbItem
12471 * ****************************************************************/
12473 void freeAperDecodeDrbSetupModItem(DRBs_ToBeSetupMod_Item_t *drbItem)
12476 SNSSAI_t *snssai =NULLP;
12477 Flows_Mapped_To_DRB_List_t *flowMap = NULLP;
12479 drbItem->qoSInformation.present = QoSInformation_PR_choice_extension;
12480 switch(drbItem->qoSInformation.present)
12482 case QoSInformation_PR_NOTHING:
12484 case QoSInformation_PR_eUTRANQoS:
12486 if(drbItem->qoSInformation.choice.eUTRANQoS)
12488 free(drbItem->qoSInformation.choice.eUTRANQoS);
12492 case QoSInformation_PR_choice_extension:
12494 if(drbItem->qoSInformation.choice.choice_extension)
12496 freeAperDecodeQosInfo(&drbItem->qoSInformation.choice.choice_extension->value.choice.\
12497 DRB_Information.dRB_QoS);
12498 snssai = &drbItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI;
12499 if(snssai->sST.buf)
12501 free(snssai->sST.buf);
12505 if(snssai->sD->buf)
12507 free(snssai->sD->buf);
12512 flowMap = &drbItem->qoSInformation.choice.choice_extension->value.choice.\
12513 DRB_Information.flows_Mapped_To_DRB_List;
12514 if(flowMap->list.array)
12516 for(arrIdx=0; arrIdx<flowMap->list.count; arrIdx++)
12518 if(flowMap->list.array[arrIdx] )
12520 freeAperDecodeQosInfo(&flowMap->list.array[arrIdx]->qoSFlowLevelQoSParameters);
12521 free(flowMap->list.array[arrIdx]);
12524 free(flowMap->list.array);
12527 free(drbItem->qoSInformation.choice.choice_extension);
12533 freeAperDecodeUlTnlInfoforDrbSetupMod(&drbItem->uLUPTNLInformation_ToBeSetup_List);
12534 if(drbItem->uLConfiguration)
12536 free(drbItem->uLConfiguration);
12540 /*******************************************************************
12542 * @brief Deallocating the memory allocated by the aper decoder
12543 * for DrbToBeSetupModList
12547 * Function : freeAperDecodeDrbToBeSetupModList
12549 * Functionality: Deallocating memory allocated for DrbToBeSetupModList
12551 * @params[in] DRBs_ToBeSetupMod_List_t *drbSet
12555 * ****************************************************************/
12557 void freeAperDecodeDrbToBeSetupModList(DRBs_ToBeSetupMod_List_t *drbSet)
12560 struct DRBs_ToBeSetupMod_ItemIEs *drbItemIe;
12562 if(drbSet->list.array)
12564 for(arrIdx=0; arrIdx<drbSet->list.count ; arrIdx++)
12566 if(drbSet->list.array[arrIdx] != NULLP)
12570 drbItemIe = (DRBs_ToBeSetupMod_ItemIEs_t *)drbSet->list.array[arrIdx];
12571 freeAperDecodeDrbSetupModItem(&(drbItemIe->value.choice.DRBs_ToBeSetupMod_Item));
12573 free(drbSet->list.array[arrIdx]);
12576 free(drbSet->list.array);
12580 /*******************************************************************
12582 * @brief Deallocating the memory allocated by the aper decoder
12583 * for UeContextModificationReqMsg
12587 * Function : freeAperDecodeUeContextModificationReqMsg
12589 * Functionality: Deallocating memory allocated for
12590 * UeContextModificationReqMsg
12592 * @params[in] UEContextModificationRequest_t *UeContextModifyReq
12596 * ****************************************************************/
12597 void freeAperDecodeUeContextModificationReqMsg(UEContextModificationRequest_t *UeContextModifyReq )
12599 uint8_t arrIdx, ieId;
12601 if(UeContextModifyReq->protocolIEs.list.array)
12603 for( arrIdx = 0 ; arrIdx<UeContextModifyReq->protocolIEs.list.count ; arrIdx++)
12605 if(UeContextModifyReq->protocolIEs.list.array[arrIdx])
12607 ieId = UeContextModifyReq->protocolIEs.list.array[arrIdx]->id;
12610 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12612 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12614 case ProtocolIE_ID_id_DRBs_ToBeSetupMod_List:
12616 freeAperDecodeDrbToBeSetupModList(&UeContextModifyReq->protocolIEs.list.array[arrIdx]->\
12617 value.choice.DRBs_ToBeSetupMod_List);
12621 free(UeContextModifyReq->protocolIEs.list.array[arrIdx]);
12624 free(UeContextModifyReq->protocolIEs.list.array);
12627 /*******************************************************************
12629 * @brief processing the F1 UeContextModificationReq
12633 * Function : procF1UeContextModificationReq
12635 * Functionality: processing the F1 UeContextModificationReq
12637 * @params[in] F1AP_PDU_t *f1apMsg
12640 * ****************************************************************/
12641 uint8_t procF1UeContextModificationReq(F1AP_PDU_t *f1apMsg)
12643 UEContextModificationRequest_t *ueContextModifyReq = NULLP;
12644 uint8_t ret = ROK, ieIdx = 0, lcId =0,cellIdx=0, ueIdx=0;
12645 DuUeCb *duUeCb = NULLP;
12646 DRBs_ToBeSetupMod_List_t *drbSetupModCfg;
12647 uint32_t gnbCuUeF1apId, gnbDuUeF1apId;
12649 ueContextModifyReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextModificationRequest;
12650 for(ieIdx=0; (ieIdx < ueContextModifyReq->protocolIEs.list.count && ret == ROK); ieIdx++)
12652 switch(ueContextModifyReq->protocolIEs.list.array[ieIdx]->id)
12654 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12656 gnbCuUeF1apId = ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID;
12659 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12661 gnbDuUeF1apId = ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID;
12664 case ProtocolIE_ID_id_DRBs_ToBeSetupMod_List:
12666 for(cellIdx = 0; cellIdx < duCb.numActvCells; cellIdx++)
12668 for(ueIdx = 0; ueIdx < duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
12670 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
12671 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
12674 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
12675 lcId = getDrbLcId(&duUeCb->drbBitMap);
12676 if(lcId != RFAILED)
12678 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
12681 duUeCb->f1UeDb->actionType = UE_CTXT_MOD;
12682 drbSetupModCfg = &ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.\
12683 choice.DRBs_ToBeSetupMod_List;
12684 if(extractDrbListToSetup(lcId, NULL, drbSetupModCfg ,drbSetupModCfg->list.count, \
12685 &duUeCb->f1UeDb->duUeCfg))
12687 DU_LOG("\nERROR --> DU APP : Failed at extractDrbListToSetup()");
12695 DU_LOG("\nERROR --> DU APP : wrong values of gnbCuUeF1apId and gnbDuUeF1apId ");
12706 ret = duProcUeContextModReq(duUeCb);
12708 freeAperDecodeUeContextModificationReqMsg(ueContextModifyReq);
12711 /*****************************************************************i
12713 * @brief Free memory allocated for UE Context Release Request
12717 * Function : FreeUeContextReleaseReq
12720 * - Free memory allocated for UE Context Release Request
12722 * @params[in] F1AP_PDU_t *f1apMsg
12725 * *************************************************************/
12726 void FreeUeContextReleaseReq(F1AP_PDU_t *f1apMsg)
12729 UEContextReleaseRequest_t *ueReleaseReq = NULLP;
12733 if(f1apMsg->choice.initiatingMessage)
12735 ueReleaseReq =&f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseRequest;
12736 if(ueReleaseReq->protocolIEs.list.array)
12738 for(ieIdx=0 ; ieIdx<ueReleaseReq->protocolIEs.list.count; ieIdx++)
12740 DU_FREE(ueReleaseReq->protocolIEs.list.array[ieIdx], sizeof(UEContextReleaseRequest_t));
12742 DU_FREE(ueReleaseReq->protocolIEs.list.array, ueReleaseReq->protocolIEs.list.size);
12744 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
12746 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
12750 /*****************************************************************i
12752 * @brief Build and Send UE Context Release Request
12756 * Function : BuildAndSendUeContextReleaseReq
12759 * - Build and Send UE Context Release Request
12762 * @return ROK - success
12763 * RFAILED - failure
12765 * *************************************************************/
12766 uint8_t BuildAndSendUeContextReleaseReq(uint16_t cellId, uint8_t ueIdx)
12768 bool memAllocFail = false;
12770 uint8_t ret = RFAILED;
12771 uint16_t cellIdx =0;
12772 uint16_t crnti = 0;
12773 uint8_t elementCnt = 0;
12774 uint32_t gnbCuUeF1apId =0; /* gNB-CU UE F1AP Id */
12775 uint32_t gnbDuUeF1apId =0; /* gNB-DU UE F1AP Id */
12776 asn_enc_rval_t encRetVal;
12777 F1AP_PDU_t *f1apMsg = NULLP;
12778 UEContextReleaseRequest_t *ueReleaseReq = NULLP;
12780 DU_LOG("\nINFO --> Building the UE Context Release Request");
12783 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
12784 if(f1apMsg == NULLP)
12786 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for f1apMsg");
12790 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
12791 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
12792 if(f1apMsg->choice.initiatingMessage == NULLP)
12794 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for\
12795 initiatingMessage");
12798 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_UEContextReleaseRequest;
12799 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
12800 f1apMsg->choice.initiatingMessage->value.present = \
12801 InitiatingMessage__value_PR_UEContextReleaseRequest;
12803 ueReleaseReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseRequest;
12807 ueReleaseReq->protocolIEs.list.count = elementCnt;
12808 ueReleaseReq->protocolIEs.list.size = elementCnt * sizeof(UEContextReleaseRequest_t *);
12810 /* Initialize the F1Setup members */
12811 DU_ALLOC(ueReleaseReq->protocolIEs.list.array,ueReleaseReq->protocolIEs.list.size);
12812 if(ueReleaseReq->protocolIEs.list.array == NULLP)
12814 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for IE array");
12817 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
12819 DU_ALLOC(ueReleaseReq->protocolIEs.list.array[ieIdx],\
12820 sizeof(UEContextReleaseRequest_t));
12821 if(ueReleaseReq->protocolIEs.list.array[ieIdx] == NULLP)
12823 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for IE elements");
12824 memAllocFail = true;
12828 if(memAllocFail == true)
12831 /* Fetching Ue Cb Info*/
12832 GET_CELL_IDX(cellId, cellIdx);
12833 if(duCb.actvCellLst[cellIdx] == NULLP)
12835 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): CellId[%d] does not exist", cellId);
12840 GET_CRNTI(crnti, ueIdx);
12841 if(duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti != crnti)
12843 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): crnti[%d] does not exist", crnti);
12846 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
12847 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
12851 ueReleaseReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
12852 ueReleaseReq->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
12853 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.present = \
12854 UEContextReleaseRequestIEs__value_PR_GNB_CU_UE_F1AP_ID;
12855 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID =gnbCuUeF1apId;
12858 ueReleaseReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
12859 ueReleaseReq->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
12860 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.present =\
12861 UEContextReleaseRequestIEs__value_PR_GNB_DU_UE_F1AP_ID;
12862 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID =gnbDuUeF1apId;
12864 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
12866 /* Encode the F1SetupRequest type as APER */
12867 memset(encBuf, 0, ENC_BUF_MAX_LEN);
12869 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
12870 /* Encode results */
12871 if(encRetVal.encoded == ENCODE_FAIL)
12873 DU_LOG("\nERROR --> F1AP : Could not encode UEContextReleaseRequest structure (at %s)\n",\
12874 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
12879 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UEContextReleaseRequest\n");
12880 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
12882 printf("%x",encBuf[ieIdx]);
12887 if(sendF1APMsg() != ROK)
12889 DU_LOG("\nERROR --> F1AP : Sending UE Context Release Request failed");
12896 FreeUeContextReleaseReq(f1apMsg);
12899 /*****************************************************************i
12901 * @brief Free memory allocated for UE Context Release Complete
12905 * Function : FreeUeContextReleaseComplete
12908 * - Free memory allocated for UE Context Release Complete
12910 * @params[in] F1AP_PDU_t *f1apMsg
12913 * *************************************************************/
12914 void FreeUeContextReleaseComplete(F1AP_PDU_t *f1apMsg)
12917 UEContextReleaseComplete_t *ueReleaseComplete = NULLP;
12921 if(f1apMsg->choice.successfulOutcome)
12923 ueReleaseComplete =&f1apMsg->choice.successfulOutcome->value.choice.UEContextReleaseComplete;
12924 if(ueReleaseComplete->protocolIEs.list.array)
12926 for(ieIdx=0 ; ieIdx<ueReleaseComplete->protocolIEs.list.count; ieIdx++)
12928 DU_FREE(ueReleaseComplete->protocolIEs.list.array[ieIdx], sizeof(UEContextReleaseComplete_t));
12930 DU_FREE(ueReleaseComplete->protocolIEs.list.array, ueReleaseComplete->protocolIEs.list.size);
12932 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
12934 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
12938 /*****************************************************************i
12940 * @brief Build and Send UE Context Release Complete
12944 * Function : BuildAndSendUeContextReleaseComplete
12947 * - Build and Send UE Context Release Complete
12949 * @params[in] cellId, gnbCuUeF1apId, gnbDuUeF1apId
12950 * @return ROK - success
12951 * RFAILED - failure
12953 * *************************************************************/
12954 uint8_t BuildAndSendUeContextReleaseComplete(uint16_t cellId, uint32_t gnbCuUeF1apId, uint32_t gnbDuUeF1apId)
12956 bool memAllocFail = false;
12957 uint8_t ieIdx =0, ret = RFAILED, elementCnt = 0;
12958 asn_enc_rval_t encRetVal;
12959 F1AP_PDU_t *f1apMsg = NULLP;
12960 UEContextReleaseComplete_t *ueReleaseComplete = NULLP;
12962 DU_LOG("\nINFO --> Building the UE Context Release Complete");
12965 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
12966 if(f1apMsg == NULLP)
12968 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for f1apMsg");
12972 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
12973 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
12974 if(f1apMsg->choice.successfulOutcome == NULLP)
12976 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for\
12977 successfulOutcome");
12980 f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_UEContextRelease;
12981 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
12982 f1apMsg->choice.successfulOutcome->value.present = \
12983 SuccessfulOutcome__value_PR_UEContextReleaseComplete;
12985 ueReleaseComplete = &f1apMsg->choice.successfulOutcome->value.choice.UEContextReleaseComplete;
12988 ueReleaseComplete->protocolIEs.list.count = elementCnt;
12989 ueReleaseComplete->protocolIEs.list.size = elementCnt * sizeof(UEContextReleaseComplete_t *);
12991 /* Initialize the UE Release Complete members */
12992 DU_ALLOC(ueReleaseComplete->protocolIEs.list.array,ueReleaseComplete->protocolIEs.list.size);
12993 if(ueReleaseComplete->protocolIEs.list.array == NULLP)
12995 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for IE array");
12998 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
13000 DU_ALLOC(ueReleaseComplete->protocolIEs.list.array[ieIdx],\
13001 sizeof(UEContextReleaseComplete_t));
13002 if(ueReleaseComplete->protocolIEs.list.array[ieIdx] == NULLP)
13004 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for IE\
13006 memAllocFail = true;
13010 if(memAllocFail == true)
13015 ueReleaseComplete->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
13016 ueReleaseComplete->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
13017 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.present = \
13018 UEContextReleaseCompleteIEs__value_PR_GNB_CU_UE_F1AP_ID;
13019 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID =gnbCuUeF1apId;
13022 ueReleaseComplete->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
13023 ueReleaseComplete->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
13024 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.present =\
13025 UEContextReleaseCompleteIEs__value_PR_GNB_DU_UE_F1AP_ID;
13026 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID =gnbDuUeF1apId;
13028 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
13030 /* Encode the F1SetupComplete type as APER */
13031 memset(encBuf, 0, ENC_BUF_MAX_LEN);
13033 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
13034 /* Encode results */
13035 if(encRetVal.encoded == ENCODE_FAIL)
13037 DU_LOG("\nERROR --> F1AP : Could not encode UEContextReleaseComplete structure (at %s)\n",\
13038 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
13043 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UEContextReleaseComplete\n");
13044 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
13046 printf("%x",encBuf[ieIdx]);
13051 if(sendF1APMsg() != ROK)
13053 DU_LOG("\nERROR --> F1AP : Sending UE Context Release Complete failed");
13062 duCb.actvCellLst[cellId-1]->cellStatus = DELETION_IN_PROGRESS;
13063 ret = duSendCellDeletReq(cellId);
13066 DU_LOG("\nERROR --> F1AP: BuildAndSendUeContextReleaseComplete(): Failed to process cell\
13067 Delete req for CellId");
13070 FreeUeContextReleaseComplete(f1apMsg);
13075 /*******************************************************************
13077 * @brief added free part for the memory allocated by aper_decoder
13081 * Function : freeAperDecodeUeContextReleaseCommand
13083 * Functionality: added free part for the memory allocated by aper_decoder
13085 * @params[in] F1AP_PDU_t *f1apMsg
13088 * ****************************************************************/
13089 void freeAperDecodeUeContextReleaseCommand(F1AP_PDU_t *f1apMsg)
13092 UEContextReleaseCommand_t *ueContextReleaseCommand = NULLP;
13094 ueContextReleaseCommand = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseCommand;
13096 if(ueContextReleaseCommand->protocolIEs.list.array)
13098 for(ieIdx=0; ieIdx < ueContextReleaseCommand->protocolIEs.list.count; ieIdx++)
13100 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx])
13102 switch(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id)
13104 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
13106 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
13108 case ProtocolIE_ID_id_Cause:
13110 case ProtocolIE_ID_id_RRCContainer:
13112 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
13114 free(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf);
13119 DU_LOG("\nERROR --> F1AP: freeAperDecodeUeContextReleaseCommand():Invalid IE Received: %ld"\
13120 ,ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id);
13124 free(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]);
13126 free(ueContextReleaseCommand->protocolIEs.list.array);
13129 /*******************************************************************
13131 * @brief processing of UE Context Release Command
13135 * Function : procF1UeContextReleaseCommand
13137 * Functionality: processing of UE Context Release Command
13139 * @params[in] F1AP_PDU_t *f1apMsg
13142 * ****************************************************************/
13143 uint8_t procF1UeContextReleaseCommand(F1AP_PDU_t *f1apMsg)
13145 uint8_t ieIdx=0, ret=ROK, ueIdx=0;
13146 uint16_t cellIdx =0;
13148 uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId=0;
13149 DuUeCb *duUeCb = NULLP;
13150 UEContextReleaseCommand_t *ueContextReleaseCommand = NULLP;
13152 ueContextReleaseCommand = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseCommand;
13154 if(ueContextReleaseCommand->protocolIEs.list.array)
13156 for(ieIdx=0; ieIdx < ueContextReleaseCommand->protocolIEs.list.count; ieIdx++)
13158 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx])
13160 switch(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id)
13162 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
13164 gnbCuUeF1apId= ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
13165 value.choice.GNB_CU_UE_F1AP_ID;
13169 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
13171 gnbDuUeF1apId = ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
13172 value.choice.GNB_DU_UE_F1AP_ID;
13176 case ProtocolIE_ID_id_Cause:
13181 case ProtocolIE_ID_id_RRCContainer:
13183 for(cellIdx = 0; cellIdx < duCb.numActvCells; cellIdx++)
13185 for(ueIdx = 0; ueIdx < duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
13187 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
13188 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
13190 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
13191 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
13194 memset(duUeCb->f1UeDb, 0, sizeof(F1UeContextSetupDb));
13195 duUeCb->f1UeDb->actionType = UE_CTXT_RELEASE;
13196 duUeCb->f1UeDb->cellIdx = cellIdx;
13197 /* Filling Dl RRC Msg Info */
13198 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
13199 if(!duUeCb->f1UeDb->dlRrcMsg)
13201 DU_LOG("\nERROR --> DU APP : procF1UeContextReleaseCommand(): \
13202 Memory allocation failed ");
13207 duUeCb->f1UeDb->dlRrcMsgPres = true;
13208 memset(duUeCb->f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
13209 ret = extractDlRrcMsg(gnbDuUeF1apId, gnbCuUeF1apId, duUeCb->f1UeDb->dlRrcMsg,\
13210 &ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
13211 value.choice.RRCContainer);
13217 DU_LOG("\nERROR --> DU APP : procF1UeContextReleaseCommand(): \
13218 Memory allocation failed ");
13227 if(ueIdxFound == true)
13234 DU_LOG("\nERROR --> F1AP: DuUeCb is not found at procF1UeContextSetupReq()");
13242 DU_LOG("\nERROR --> F1AP: freeAperDecodeUeContextReleaseCommand():Invalid IE Received: %ld"\
13243 ,ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id);
13251 duProcUeContextReleaseCommand(duUeCb);
13253 freeAperDecodeUeContextReleaseCommand(f1apMsg);
13256 /**************************************************************
13258 * @brief Handles received F1AP message and sends back response
13262 * Function : F1APMsgHdlr
13265 * - Decodes received F1AP control message
13266 * - Prepares response message, encodes and sends to SCTP
13269 * @return ROK - success
13270 * RFAILED - failure
13272 * ****************************************************************/
13273 void F1APMsgHdlr(Buffer *mBuf)
13276 char *recvBuf =NULLP;
13278 MsgLen recvBufLen =0;
13279 F1AP_PDU_t *f1apMsg =NULLP;
13280 asn_dec_rval_t rval; /* Decoder return value */
13281 F1AP_PDU_t f1apasnmsg ;
13282 DU_LOG("\nINFO --> F1AP : Received F1AP message buffer");
13283 ODU_PRINT_MSG(mBuf, 0,0);
13285 /* Copy mBuf into char array to decode it */
13286 ODU_GET_MSG_LEN(mBuf, &recvBufLen);
13287 DU_ALLOC(recvBuf, (Size)recvBufLen);
13289 if(recvBuf == NULLP)
13291 DU_LOG("\nERROR --> F1AP : Memory allocation failed");
13294 if(ODU_COPY_MSG_TO_FIX_BUF(mBuf, 0, recvBufLen, (Data *)recvBuf, ©Cnt) != ROK)
13296 DU_LOG("\nERROR --> F1AP : Failed while copying %d", copyCnt);
13300 printf("\nDEBUG --> F1AP : Received flat buffer to be decoded : ");
13301 for(i=0; i< recvBufLen; i++)
13303 printf("%x",recvBuf[i]);
13306 /* Decoding flat buffer into F1AP messsage */
13307 f1apMsg = &f1apasnmsg;
13308 memset(f1apMsg, 0, sizeof(F1AP_PDU_t));
13310 rval = aper_decode(0, &asn_DEF_F1AP_PDU, (void **)&f1apMsg, recvBuf, recvBufLen, 0, 0);
13311 DU_FREE(recvBuf, (Size)recvBufLen);
13313 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
13315 DU_LOG("\nERROR --> F1AP : ASN decode failed");
13319 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
13321 switch(f1apMsg->present)
13323 case F1AP_PDU_PR_successfulOutcome:
13325 switch(f1apMsg->choice.successfulOutcome->value.present)
13327 case SuccessfulOutcome__value_PR_ResetAcknowledge:
13329 DU_LOG("\nINFO --> F1AP : F1ResetAcknowledge is received successfully ");
13332 case SuccessfulOutcome__value_PR_F1SetupResponse:
13334 #ifndef ODU_TEST_STUB
13335 procF1SetupRsp(f1apMsg);
13340 case SuccessfulOutcome__value_PR_GNBDUConfigurationUpdateAcknowledge:
13342 procF1GNBDUCfgUpdAck(f1apMsg);
13348 DU_LOG("\nERROR --> F1AP : Invalid type of SuccessfulOutcome__value_PR_ResetAcknowledge [%d]",\
13349 f1apMsg->choice.successfulOutcome->value.present);
13352 }/* End of switch(successfulOutcome) */
13353 free(f1apMsg->choice.successfulOutcome);
13356 case F1AP_PDU_PR_initiatingMessage:
13358 switch(f1apMsg->choice.initiatingMessage->value.present)
13360 case InitiatingMessage__value_PR_Reset:
13362 procF1ResetReq(f1apMsg);
13365 case InitiatingMessage__value_PR_DLRRCMessageTransfer:
13367 procF1DlRrcMsgTrans(f1apMsg);
13370 case InitiatingMessage__value_PR_UEContextSetupRequest:
13372 procF1UeContextSetupReq(f1apMsg);
13375 case InitiatingMessage__value_PR_UEContextModificationRequest:
13377 procF1UeContextModificationReq(f1apMsg);
13380 case InitiatingMessage__value_PR_UEContextReleaseCommand:
13382 procF1UeContextReleaseCommand(f1apMsg);
13387 DU_LOG("\nERROR --> F1AP : Invalid type of F1AP_PDU_PR_initiatingMessage [%d]",
13388 f1apMsg->choice.initiatingMessage->value.present);
13391 }/* End of switch(initiatingMessage) */
13392 free(f1apMsg->choice.initiatingMessage);
13398 DU_LOG("\nERROR --> F1AP : Invalid type of f1apMsg->present [%d]",f1apMsg->present);
13403 }/* End of switch(f1apMsg->present) */
13405 } /* End of F1APMsgHdlr */
13407 /**********************************************************************
13409 **********************************************************************/