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)
1411 uint8_t extensionCnt=1;
1413 GNB_DU_Served_Cells_Item_t *srvCellItem;
1414 ServedPLMNs_Item_t *servedPlmnItem;
1415 SliceSupportItem_t *sliceSupportItem;
1417 if(duServedCell->list.array!=NULLP)
1419 if(duServedCell->list.array[0]!=NULLP)
1421 srvCellItem= &duServedCell->list.array[0]->value.choice.GNB_DU_Served_Cells_Item;
1423 DU_FREE(srvCellItem->served_Cell_Information.nRCGI.pLMN_Identity.buf,\
1424 srvCellItem->served_Cell_Information.nRCGI.pLMN_Identity.size * sizeof(uint8_t));
1425 DU_FREE(srvCellItem->served_Cell_Information.nRCGI.nRCellIdentity.buf,\
1426 srvCellItem->served_Cell_Information.nRCGI.nRCellIdentity.size * sizeof(uint8_t));
1428 if(srvCellItem->served_Cell_Information.fiveGS_TAC!=NULLP)
1430 DU_FREE(srvCellItem->served_Cell_Information.fiveGS_TAC->buf,\
1431 sizeof(srvCellItem->served_Cell_Information.fiveGS_TAC->size));
1432 DU_FREE(srvCellItem->served_Cell_Information.fiveGS_TAC,sizeof(FiveGS_TAC_t));
1435 if(srvCellItem->served_Cell_Information.servedPLMNs.list.array!=NULLP)
1437 if(srvCellItem->served_Cell_Information.servedPLMNs.list.array[plmnIdx] != NULLP)
1439 servedPlmnItem = srvCellItem->served_Cell_Information.servedPLMNs.list.array[plmnIdx];
1440 DU_FREE(servedPlmnItem->pLMN_Identity.buf, servedPlmnItem->pLMN_Identity.size * sizeof(uint8_t));
1442 if(servedPlmnItem->iE_Extensions != NULLP)
1444 if(servedPlmnItem->iE_Extensions->list.array != NULLP)
1446 if(servedPlmnItem->iE_Extensions->list.array[0] != NULLP)
1448 if(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.list.\
1451 if(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.list.\
1452 array[sliceId] != NULLP)
1454 sliceSupportItem = servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.\
1455 SliceSupportList.list.array[sliceId];
1457 DU_FREE(sliceSupportItem->sNSSAI.sST.buf, sizeof(uint8_t));
1459 if(sliceSupportItem->sNSSAI.sD != NULLP)
1461 DU_FREE(sliceSupportItem->sNSSAI.sD->buf, sliceSupportItem->sNSSAI.sD->size);
1462 DU_FREE(sliceSupportItem->sNSSAI.sD, sizeof(OCTET_STRING_t));
1465 DU_FREE(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
1466 list.array[sliceId], sizeof(SliceSupportItem_t));
1468 DU_FREE(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
1469 list.array, sizeof(SliceSupportItem_t*));
1471 DU_FREE(servedPlmnItem->iE_Extensions->list.array[0], sizeof(ServedPLMNs_ItemExtIEs_t));
1473 DU_FREE(servedPlmnItem->iE_Extensions->list.array, extensionCnt*sizeof(ServedPLMNs_ItemExtIEs_t*));
1475 DU_FREE(servedPlmnItem->iE_Extensions, sizeof(ProtocolExtensionContainer_4624P3_t));
1477 DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.array[plmnIdx], sizeof(ServedPLMNs_Item_t));
1479 DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.array, sizeof(ServedPLMNs_Item_t *));
1482 if(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD != NULLP)
1484 if(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.\
1485 freqBandListNr.list.array != NULLP)
1487 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.\
1488 list.array[0],sizeof(FreqBandNrItem_t));
1489 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.\
1490 list.array,sizeof(FreqBandNrItem_t*));
1493 if(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.\
1494 freqBandListNr.list.array)
1496 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.\
1497 freqBandListNr.list.array[0],sizeof(FreqBandNrItem_t));
1498 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.\
1499 freqBandListNr.list.array,sizeof(FreqBandNrItem_t *));
1501 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD, sizeof(FDD_Info_t));
1504 DU_FREE(srvCellItem->served_Cell_Information.measurementTimingConfiguration.buf,\
1505 srvCellItem->served_Cell_Information.measurementTimingConfiguration.size);
1507 if(srvCellItem->gNB_DU_System_Information != NULLP)
1509 if(srvCellItem->gNB_DU_System_Information->mIB_message.buf != NULLP)
1511 DU_FREE(srvCellItem->gNB_DU_System_Information->mIB_message.buf,\
1512 srvCellItem->gNB_DU_System_Information->mIB_message.size);
1515 if(srvCellItem->gNB_DU_System_Information->sIB1_message.buf != NULLP)
1517 DU_FREE(srvCellItem->gNB_DU_System_Information->sIB1_message.buf,\
1518 srvCellItem->gNB_DU_System_Information->sIB1_message.size);
1521 DU_FREE(srvCellItem->gNB_DU_System_Information, sizeof(GNB_DU_System_Information_t));
1524 DU_FREE(duServedCell->list.array[0], sizeof(GNB_DU_Served_Cells_ItemIEs_t));
1526 DU_FREE(duServedCell->list.array, plmnCnt * sizeof(GNB_DU_Served_Cells_ItemIEs_t*));
1530 /*******************************************************************
1532 * @brief deallocating the memory of function BuildAndSendF1SetupReq()
1536 * Function : FreeF1SetupReq
1538 * Functionality: deallocating the memory of function BuildAndSendF1SetupReq
1540 * @params[in] F1AP_PDU_t *f1apMsg
1544 * ****************************************************************/
1545 void FreeF1SetupReq(F1AP_PDU_t *f1apMsg)
1547 uint8_t ieIdx, ieIdx2;
1548 F1SetupRequest_t *f1SetupReq=NULLP;
1550 if(f1apMsg != NULLP)
1552 if(f1apMsg->choice.initiatingMessage != NULLP)
1554 f1SetupReq = &f1apMsg->choice.initiatingMessage->value.choice.F1SetupRequest;
1555 if(f1SetupReq->protocolIEs.list.array != NULLP)
1557 for(ieIdx = 0; ieIdx < f1SetupReq->protocolIEs.list.count; ieIdx++)
1559 if(f1SetupReq->protocolIEs.list.array[ieIdx] != NULLP)
1561 switch(f1SetupReq->protocolIEs.list.array[ieIdx]->id)
1563 case ProtocolIE_ID_id_TransactionID:
1565 case ProtocolIE_ID_id_gNB_DU_ID:
1566 DU_FREE(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
1567 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
1569 case ProtocolIE_ID_id_gNB_DU_Name:
1570 DU_FREE(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.buf,\
1571 strlen((char *)duCfgParam.duName));
1573 case ProtocolIE_ID_id_gNB_DU_Served_Cells_List:
1574 FreeServedCellList(&f1SetupReq->protocolIEs.list.\
1575 array[ieIdx]->value.choice.GNB_DU_Served_Cells_List);
1577 case ProtocolIE_ID_id_GNB_DU_RRC_Version:
1578 FreeRrcVer(&f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.RRC_Version);
1581 DU_LOG("\nERROR --> Invalid Event Type %ld", f1SetupReq->protocolIEs.list.array[ieIdx]->id);
1586 for(ieIdx2=0; ieIdx2< ieIdx; ieIdx2++)
1588 DU_FREE(f1SetupReq->protocolIEs.list.array[ieIdx2],sizeof(F1SetupRequestIEs_t));
1590 DU_FREE(f1SetupReq->protocolIEs.list.array,\
1591 f1SetupReq->protocolIEs.list.size);
1593 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
1595 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
1598 /*******************************************************************
1600 * @brief Builds and Send the F1SetupRequest
1604 * Function : BuildAndSendF1SetupReq
1606 * Functionality:Fills the F1SetupRequest
1608 * @return ROK - success
1611 ******************************************************************/
1612 uint8_t BuildAndSendF1SetupReq()
1614 uint8_t ret, ieIdx, elementCnt;
1615 F1AP_PDU_t *f1apMsg = NULLP;
1616 F1SetupRequest_t *f1SetupReq=NULLP;
1617 GNB_DU_Served_Cells_List_t *duServedCell=NULLP;
1618 RRC_Version_t *rrcVer=NULLP;
1619 asn_enc_rval_t encRetVal; /* Encoder return value */
1622 DU_LOG("\nINFO --> F1AP : Building F1 Setup Request\n");
1625 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
1626 if(f1apMsg == NULLP)
1630 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
1631 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
1632 if(f1apMsg->choice.initiatingMessage == NULLP)
1636 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_F1Setup;
1637 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
1638 f1apMsg->choice.initiatingMessage->value.present = \
1639 InitiatingMessage__value_PR_F1SetupRequest;
1641 f1SetupReq = &f1apMsg->choice.initiatingMessage->value.choice.F1SetupRequest;
1643 elementCnt = (duCfgParam.duName != NULL) ? 5 : 4;
1645 f1SetupReq->protocolIEs.list.count = elementCnt;
1646 f1SetupReq->protocolIEs.list.size = elementCnt * sizeof(F1SetupRequestIEs_t );
1648 /* Initialize the F1Setup members */
1649 DU_ALLOC(f1SetupReq->protocolIEs.list.array,f1SetupReq->protocolIEs.list.size);
1650 if(f1SetupReq->protocolIEs.list.array == NULLP)
1654 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
1656 DU_ALLOC(f1SetupReq->protocolIEs.list.array[ieIdx],\
1657 sizeof(F1SetupRequestIEs_t));
1658 if(f1SetupReq->protocolIEs.list.array[ieIdx] == NULLP)
1666 f1SetupReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_TransactionID;
1667 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1668 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present =\
1669 F1SetupRequestIEs__value_PR_TransactionID;
1670 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = \
1675 f1SetupReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_ID;
1676 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1677 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = \
1678 F1SetupRequestIEs__value_PR_GNB_DU_ID;
1679 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size =\
1682 DU_ALLOC(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
1683 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
1684 if(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf == \
1690 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf[0] =\
1694 if(duCfgParam.duName != NULL)
1697 f1SetupReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_Name;
1698 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_ignore;
1699 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = F1SetupRequestIEs__value_PR_GNB_DU_Name;
1700 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.size =\
1701 strlen((char *)duCfgParam.duName);
1702 DU_ALLOC(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.\
1703 GNB_DU_Name.buf, strlen((char *)duCfgParam.duName));
1704 if(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.\
1709 strcpy((char*)f1SetupReq->protocolIEs.list.array[ieIdx]->value.\
1710 choice.GNB_DU_Name.buf,
1711 (char*)&duCfgParam.duName);
1715 /*Served Cell list */
1717 f1SetupReq->protocolIEs.list.array[ieIdx]->id = \
1718 ProtocolIE_ID_id_gNB_DU_Served_Cells_List;
1719 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1720 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = \
1721 F1SetupRequestIEs__value_PR_GNB_DU_Served_Cells_List;
1722 duServedCell = &f1SetupReq->protocolIEs.list.\
1723 array[ieIdx]->value.choice.GNB_DU_Served_Cells_List;
1724 if(BuildServedCellList(duServedCell))
1730 f1SetupReq->protocolIEs.list.array[ieIdx]->id = \
1731 ProtocolIE_ID_id_GNB_DU_RRC_Version ;
1732 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1733 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = \
1734 F1SetupRequestIEs__value_PR_RRC_Version;
1735 rrcVer = &f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.RRC_Version;
1736 if(BuildRrcVer(rrcVer))
1740 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
1742 /* Encode the F1SetupRequest type as APER */
1743 memset(encBuf, 0, ENC_BUF_MAX_LEN);
1745 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
1748 /* Encode results */
1749 if(encRetVal.encoded == ENCODE_FAIL)
1751 DU_LOG("\nERROR --> F1AP : Could not encode F1SetupRequest structure (at %s)\n",\
1752 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
1757 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for F1SetupRequest\n");
1758 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
1760 printf("%x",encBuf[ieIdx]);
1765 if(sendF1APMsg() != ROK)
1767 DU_LOG("\nERROR --> F1AP : Sending F1 Setup request failed");
1775 FreeF1SetupReq(f1apMsg);
1778 }/* End of BuildAndSendF1SetupReq */
1780 /*******************************************************************
1782 * @brief Deallocating memory allocated for Served_Cells_To_Modify_Item_t
1786 * Function : freeCellsToModifyItem
1788 * Functionality: Deallocating memory of variables allocated in
1789 * BuildAndSendDUConfigUpdate function
1791 * @params[in] Served_Cells_To_Modify_Item_t *modifyItem
1793 * @return ROK - void
1795 * ****************************************************************/
1797 void freeCellsToModifyItem(Served_Cells_To_Modify_Item_t *modifyItem)
1799 uint8_t arrIdx=0,i=0;
1800 ServedPLMNs_Item_t *servedPlmnItem = NULLP;
1801 SliceSupportItem_t *sliceSupportItem = NULLP;
1803 DU_FREE(modifyItem->oldNRCGI.pLMN_Identity.buf, modifyItem->oldNRCGI.pLMN_Identity.size);
1804 DU_FREE(modifyItem->oldNRCGI.nRCellIdentity.buf, modifyItem->oldNRCGI.nRCellIdentity.size);
1806 DU_FREE(modifyItem->served_Cell_Information.nRCGI.pLMN_Identity.buf,\
1807 modifyItem->served_Cell_Information.nRCGI.pLMN_Identity.size);
1808 DU_FREE(modifyItem->served_Cell_Information.nRCGI.nRCellIdentity.buf,\
1809 modifyItem->served_Cell_Information.nRCGI.nRCellIdentity.size);
1811 if(modifyItem->served_Cell_Information.servedPLMNs.list.array != NULLP)
1813 if(modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx] != NULLP)
1815 servedPlmnItem = modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx];
1817 DU_FREE(servedPlmnItem->pLMN_Identity.buf,servedPlmnItem->pLMN_Identity.size);
1819 if(servedPlmnItem->iE_Extensions != NULLP)
1821 if(servedPlmnItem->iE_Extensions->list.array != NULLP)
1823 if(servedPlmnItem->iE_Extensions->list.array[arrIdx] != NULLP)
1825 if(servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.SliceSupportList.list.array != NULLP)
1827 if(servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.SliceSupportList.list.array[arrIdx] != NULLP)
1829 sliceSupportItem = modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx]->iE_Extensions->\
1830 list.array[arrIdx]->extensionValue.choice.SliceSupportList.list.array[arrIdx];
1832 DU_FREE(sliceSupportItem->sNSSAI.sST.buf, sliceSupportItem->sNSSAI.sST.size);
1833 if(sliceSupportItem->sNSSAI.sD != NULLP)
1835 DU_FREE(sliceSupportItem->sNSSAI.sD->buf, sliceSupportItem->sNSSAI.sD->size);
1836 DU_FREE(sliceSupportItem->sNSSAI.sD,sizeof(OCTET_STRING_t));
1838 DU_FREE(servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.SliceSupportList.\
1839 list.array[arrIdx], sizeof(SliceSupportItem_t));
1841 DU_FREE(servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.SliceSupportList.list.array,
1842 servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.SliceSupportList.list.size);
1845 for(i=0; i < servedPlmnItem->iE_Extensions->list.count ; i++)
1847 DU_FREE(servedPlmnItem->iE_Extensions->list.array[i], sizeof(ServedPLMNs_ItemExtIEs_t ));
1849 DU_FREE(servedPlmnItem->iE_Extensions->list.array, servedPlmnItem->iE_Extensions->list.size);
1851 DU_FREE(servedPlmnItem->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P3_t));
1854 for(i=0;i<modifyItem->served_Cell_Information.servedPLMNs.list.count;i++)
1856 DU_FREE(modifyItem->served_Cell_Information.servedPLMNs.list.array[i], sizeof(ServedPLMNs_Item_t));
1858 DU_FREE(modifyItem->served_Cell_Information.servedPLMNs.list.array,\
1859 modifyItem->served_Cell_Information.servedPLMNs.list.size);
1862 if(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD != NULLP)
1864 if(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array != NULLP)
1866 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.list.\
1867 array[arrIdx], sizeof(FreqBandNrItem_t));
1868 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array, \
1869 modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.list.size);
1872 if(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array != NULLP)
1874 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.freqBandListNr.list.\
1875 array[arrIdx], sizeof(FreqBandNrItem_t));
1876 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array,\
1877 modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.freqBandListNr.list.size);
1879 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD,sizeof(FDD_Info_t));
1882 DU_FREE(modifyItem->served_Cell_Information.measurementTimingConfiguration.buf,\
1883 modifyItem->served_Cell_Information.measurementTimingConfiguration.size);
1886 /*******************************************************************
1888 * @brief Deallocating memory of BuildAndSendDUConfigUpdate
1892 * Function : FreeDUConfigUpdate
1894 * Functionality: Deallocating memory of variables allocated in
1895 * BuildAndSendDUConfigUpdate function
1897 * @params[in] F1AP_PDU_t *f1apDuCfg
1899 * @return ROK - void
1901 * ****************************************************************/
1902 void FreeDUConfigUpdate(F1AP_PDU_t *f1apDuCfg)
1904 uint8_t ieIdx=0, cellModifyIdx=0, cellDeleteIdx=0;
1905 GNBDUConfigurationUpdate_t *duCfgUpdate = NULLP;
1906 Served_Cells_To_Modify_List_t *cellsToModify=NULLP;
1907 Served_Cells_To_Delete_List_t *cellsToDelete=NULLP;
1908 Served_Cells_To_Delete_Item_t *deleteItem = NULLP;
1909 Served_Cells_To_Delete_ItemIEs_t *deleteItemIe = NULLP;
1911 if(f1apDuCfg != NULLP)
1913 if(f1apDuCfg->choice.initiatingMessage != NULLP)
1915 duCfgUpdate = &f1apDuCfg->choice.initiatingMessage->\
1916 value.choice.GNBDUConfigurationUpdate;
1917 if(duCfgUpdate->protocolIEs.list.array != NULLP)
1919 for(ieIdx=0; ieIdx<duCfgUpdate->protocolIEs.list.count; ieIdx++)
1921 if(duCfgUpdate->protocolIEs.list.array[ieIdx] != NULLP)
1923 switch(duCfgUpdate->protocolIEs.list.array[ieIdx]->id)
1925 case ProtocolIE_ID_id_Served_Cells_To_Modify_List:
1927 cellsToModify = &duCfgUpdate->protocolIEs.list.array[ieIdx]->\
1928 value.choice.Served_Cells_To_Modify_List;
1929 if(cellsToModify->list.array != NULLP)
1931 for(cellModifyIdx=0; cellModifyIdx<cellsToModify->list.count ;cellModifyIdx++)
1933 if(cellsToModify->list.array[cellModifyIdx] != NULLP)
1935 freeCellsToModifyItem(&cellsToModify->list.array[cellModifyIdx]->value.choice.\
1936 Served_Cells_To_Modify_Item);
1937 DU_FREE(cellsToModify->list.array[cellModifyIdx],\
1938 sizeof(Served_Cells_To_Modify_ItemIEs_t));
1941 DU_FREE(cellsToModify->list.array,cellsToModify->list.size);
1945 case ProtocolIE_ID_id_Served_Cells_To_Delete_List:
1947 cellsToDelete = &duCfgUpdate->protocolIEs.list.array[ieIdx]->\
1948 value.choice.Served_Cells_To_Delete_List;
1949 if(cellsToDelete->list.array != NULLP)
1951 for(cellDeleteIdx=0; cellDeleteIdx<cellsToDelete->list.count ;cellDeleteIdx++)
1953 if(cellsToDelete->list.array[cellDeleteIdx] != NULLP)
1955 deleteItemIe = ((Served_Cells_To_Delete_ItemIEs_t*)\
1956 cellsToDelete->list.array[cellDeleteIdx]);
1957 deleteItem=&deleteItemIe->value.choice.Served_Cells_To_Delete_Item;
1958 DU_FREE(deleteItem->oldNRCGI.pLMN_Identity.buf,\
1959 deleteItem->oldNRCGI.pLMN_Identity.size);
1960 DU_FREE(deleteItem->oldNRCGI.nRCellIdentity.buf,\
1961 deleteItem->oldNRCGI.nRCellIdentity.size);
1962 DU_FREE(cellsToDelete->list.array[cellDeleteIdx],\
1963 sizeof(Served_Cells_To_Delete_ItemIEs_t));
1966 DU_FREE(cellsToDelete->list.array,cellsToDelete->list.size);
1971 case ProtocolIE_ID_id_gNB_DU_ID:
1973 DU_FREE(duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
1974 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
1978 DU_FREE(duCfgUpdate->protocolIEs.list.array[ieIdx],\
1979 sizeof(GNBDUConfigurationUpdateIEs_t));
1982 DU_FREE(duCfgUpdate->protocolIEs.list.array,duCfgUpdate->protocolIEs.list.size);
1984 DU_FREE(f1apDuCfg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
1986 DU_FREE(f1apDuCfg, (Size)sizeof(F1AP_PDU_t));
1990 /*******************************************************************
1992 * @brief Fills Served Plmns required in ServCellInfo IE
1996 * Function : fillServedPlmns
1998 * Functionality: Fills Served Plmns required in ServCellInfo IE
2000 * @params[in] Pointer to ServedPLMNs_List_t *
2002 * @return ROK - success
2005 *****************************************************************/
2007 uint8_t fillServedPlmns(ServedPLMNs_List_t *servedPlmn)
2009 uint8_t ieIdx, ieListCnt;
2011 servedPlmn->list.array[0]->pLMN_Identity.size = 3*sizeof(uint8_t);
2012 DU_ALLOC(servedPlmn->list.array[0]->pLMN_Identity.buf, servedPlmn->list.\
2013 array[0]->pLMN_Identity.size);
2014 if(servedPlmn->list.array[0]->pLMN_Identity.buf == NULLP)
2018 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.plmn[0],\
2019 servedPlmn->list.array[0]->pLMN_Identity.buf);
2020 DU_ALLOC(servedPlmn->list.array[0]->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P3_t));
2021 if(servedPlmn->list.array[0]->iE_Extensions == NULLP)
2027 servedPlmn->list.array[0]->iE_Extensions->list.count = ieListCnt;
2028 servedPlmn->list.array[0]->iE_Extensions->list.size = ieListCnt *sizeof(ServedPLMNs_ItemExtIEs_t *);
2029 DU_ALLOC(servedPlmn->list.array[0]->iE_Extensions->list.array,servedPlmn->list.array[0]->\
2030 iE_Extensions->list.size);
2031 if(servedPlmn->list.array[0]->iE_Extensions->list.array == NULLP)
2035 for(ieIdx=0;ieIdx<ieListCnt;ieIdx++)
2037 DU_ALLOC(servedPlmn->list.array[0]->iE_Extensions->list.array[ieIdx],\
2038 sizeof(ServedPLMNs_ItemExtIEs_t));
2039 if(servedPlmn->list.array[0]->iE_Extensions->list.array[ieIdx] == NULLP)
2044 //plmnIeExt = servedPlmn->list.array[0]->iE_Extensions;
2045 servedPlmn->list.array[0]->iE_Extensions->list.array[0]->id =ProtocolIE_ID_id_TAISliceSupportList;
2046 servedPlmn->list.array[0]->iE_Extensions->list.array[0]->criticality = Criticality_ignore;
2047 servedPlmn->list.array[0]->iE_Extensions->list.array[0]->extensionValue.present = \
2048 ServedPLMNs_ItemExtIEs__extensionValue_PR_SliceSupportList;
2049 servedPlmn->list.array[0]->iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2051 servedPlmn->list.array[0]->\
2052 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2053 list.size = sizeof(SliceSupportItem_t *);
2054 DU_ALLOC(servedPlmn->list.array[0]->\
2055 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2056 list.array,servedPlmn->list.array[0]->\
2057 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.list.size);
2058 if(servedPlmn->list.array[0]->\
2059 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2060 list.array == NULLP)
2065 DU_ALLOC(servedPlmn->list.array[0]->\
2066 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2067 list.array[0],sizeof( SliceSupportItem_t));
2068 if(servedPlmn->list.array[0]->\
2069 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2070 list.array[0] == NULLP)
2074 servedPlmn->list.array[0]->\
2075 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2076 list.array[0]->sNSSAI.sST.size = sizeof(uint8_t);
2077 DU_ALLOC(servedPlmn->list.array[0]->\
2078 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2079 list.array[0]->sNSSAI.sST.buf,servedPlmn->list.array[0]->\
2080 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.list.array[0]->sNSSAI.sST.size);
2081 if(servedPlmn->list.array[0]->\
2082 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2083 list.array[0]->sNSSAI.sST.buf == NULLP)
2087 servedPlmn->list.array[0]->\
2088 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2089 list.array[0]->sNSSAI.sST.buf[0] = 3;
2090 DU_ALLOC(servedPlmn->list.array[0]->\
2091 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2092 list.array[0]->sNSSAI.sD,sizeof(OCTET_STRING_t));
2093 if(servedPlmn->list.array[0]->\
2094 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2095 list.array[0]->sNSSAI.sD == NULLP)
2099 servedPlmn->list.array[0]->\
2100 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2101 list.array[0]->sNSSAI.sD->size = 3*sizeof(uint8_t);
2102 DU_ALLOC(servedPlmn->list.array[0]->\
2103 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2104 list.array[0]->sNSSAI.sD->buf,servedPlmn->list.array[0]->\
2105 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2106 list.array[0]->sNSSAI.sD->size);
2107 if(servedPlmn->list.array[0]->\
2108 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2109 list.array[0]->sNSSAI.sD->buf == NULLP)
2113 servedPlmn->list.array[0]->\
2114 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2115 list.array[0]->sNSSAI.sD->buf[0] = 3;
2116 servedPlmn->list.array[0]->\
2117 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2118 list.array[0]->sNSSAI.sD->buf[1] = 6;
2119 servedPlmn->list.array[0]->\
2120 iE_Extensions->list.array[0]->extensionValue.choice.SliceSupportList.\
2121 list.array[0]->sNSSAI.sD->buf[2] = 9;
2125 /*******************************************************************
2127 * @brief Fills Nr Fdd Info required in ServCellInfo IE
2131 * Function : fillNrFddInfo
2133 * Functionality: Fills Nr Fdd Info required in ServCellInfo IE
2135 * @params[in] Pointer to NR_Mode_Info_t *
2137 * @return ROK - success
2140 *****************************************************************/
2142 uint8_t fillNrFddInfo(NR_Mode_Info_t *nrFdd)
2144 nrFdd->choice.fDD->uL_NRFreqInfo.nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.\
2145 f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn;
2146 nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.count = 1;
2147 nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.size = sizeof(FreqBandNrItem_t*);
2148 DU_ALLOC(nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.\
2149 array, nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.size);
2150 if(nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array == NULLP)
2154 DU_ALLOC(nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array[0], \
2155 sizeof(FreqBandNrItem_t));
2156 if(nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array[0] == NULLP)
2160 nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array[0]->freqBandIndicatorNr = \
2161 duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.\
2162 freqBand[0].nrFreqBand;
2163 nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array[0]->supportedSULBandList.list.count=0;
2164 nrFdd->choice.fDD->dL_NRFreqInfo.nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.\
2165 dlNrFreqInfo.nrArfcn;
2166 nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.count = 1;
2167 nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.size = sizeof(FreqBandNrItem_t *);
2168 DU_ALLOC(nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array,nrFdd->\
2169 choice.fDD->dL_NRFreqInfo.freqBandListNr.list.size);
2170 if(nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array == NULLP)
2174 DU_ALLOC(nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array[0],\
2175 sizeof(FreqBandNrItem_t));
2176 if(nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array[0] == NULLP)
2180 nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array[0]->freqBandIndicatorNr = \
2181 duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.\
2182 freqBand[0].nrFreqBand;
2183 nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array[0]->supportedSULBandList.list.count=0;
2185 /*Transmission Bandwidth*/
2186 nrFdd->choice.fDD->uL_Transmission_Bandwidth.nRSCS = duCfgParam.srvdCellLst[0].duCellInfo.\
2187 f1Mode.mode.fdd.ulTxBw.nrScs;
2188 nrFdd->choice.fDD->uL_Transmission_Bandwidth.nRNRB = duCfgParam.srvdCellLst[0].duCellInfo.\
2189 f1Mode.mode.fdd.ulTxBw.nrb;
2190 nrFdd->choice.fDD->dL_Transmission_Bandwidth.nRSCS = duCfgParam.srvdCellLst[0].duCellInfo.\
2191 f1Mode.mode.fdd.dlTxBw.nrScs;
2192 nrFdd->choice.fDD->dL_Transmission_Bandwidth.nRNRB = duCfgParam.srvdCellLst[0].duCellInfo.\
2193 f1Mode.mode.fdd.dlTxBw.nrb;
2198 /*******************************************************************
2200 * @brief Fills ServCellInfo IE
2204 * Function : fillServedCellInfo
2206 * Functionality: Fills ServCellInfo
2208 * @params[in] Pointer to Served_Cell_Information_t *
2210 * @return ROK - success
2213 *****************************************************************/
2215 uint8_t fillServedCellInfo(Served_Cell_Information_t *srvCellInfo)
2217 uint8_t tmp, ieIdx, ieListCnt;
2220 srvCellInfo->nRCGI.pLMN_Identity.size =3*sizeof(uint8_t);
2221 DU_ALLOC(srvCellInfo->nRCGI.pLMN_Identity.buf,\
2222 srvCellInfo->nRCGI.pLMN_Identity.size);
2223 if(srvCellInfo->nRCGI.pLMN_Identity.buf == NULLP)
2227 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
2228 srvCellInfo->nRCGI.pLMN_Identity.buf);
2229 srvCellInfo->nRCGI.nRCellIdentity.size =5*sizeof(uint8_t);
2230 DU_ALLOC(srvCellInfo->nRCGI.nRCellIdentity.buf,\
2231 srvCellInfo->nRCGI.nRCellIdentity.size);
2232 if(srvCellInfo->nRCGI.nRCellIdentity.buf == NULLP)
2236 for (tmp = 0 ; tmp < srvCellInfo->\
2237 nRCGI.nRCellIdentity.size-1 ; tmp++)
2239 srvCellInfo->nRCGI.nRCellIdentity.buf[tmp] = 0;
2241 srvCellInfo->nRCGI.nRCellIdentity.buf[4] = 16;
2242 srvCellInfo->nRCGI.nRCellIdentity.bits_unused =4;
2245 srvCellInfo->nRPCI = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrPci;
2249 srvCellInfo->servedPLMNs.list.count = ieListCnt;
2250 srvCellInfo->servedPLMNs.list.size = ieListCnt*sizeof(ServedPLMNs_Item_t *);
2251 DU_ALLOC(srvCellInfo->servedPLMNs.list.array,\
2252 srvCellInfo->servedPLMNs.list.size);
2253 if(srvCellInfo->servedPLMNs.list.array == NULLP)
2257 for(ieIdx=0; ieIdx < ieListCnt; ieIdx++)
2259 DU_ALLOC(srvCellInfo->servedPLMNs.list.array[ieIdx],\
2260 sizeof(ServedPLMNs_Item_t));
2261 if(srvCellInfo->servedPLMNs.list.array[ieIdx]== NULLP)
2266 if(fillServedPlmns(&srvCellInfo->servedPLMNs))
2271 /*nR Mode Info with FDD*/
2272 srvCellInfo->nR_Mode_Info.present = NR_Mode_Info_PR_fDD;
2273 DU_ALLOC(srvCellInfo->nR_Mode_Info.choice.fDD,\
2274 sizeof(FDD_Info_t));
2275 if(srvCellInfo->nR_Mode_Info.choice.fDD == NULLP)
2279 if(fillNrFddInfo(&srvCellInfo->nR_Mode_Info))
2282 /*Measurement timing Config*/
2283 srvCellInfo->measurementTimingConfiguration.size = sizeof(uint8_t);
2284 DU_ALLOC(srvCellInfo->measurementTimingConfiguration.\
2285 buf,srvCellInfo->measurementTimingConfiguration.size);
2286 if(srvCellInfo->measurementTimingConfiguration.buf == NULLP)
2290 srvCellInfo->measurementTimingConfiguration.\
2291 buf[0] = duCfgParam.srvdCellLst[0].duCellInfo.measTimeCfg;
2296 /*******************************************************************
2298 * @brief Fills ServCellToModItem IE
2302 * Function : fillServCellToModItem
2304 * Functionality: Fills ServCellToModItem IE
2306 * @params[in] Pointer to Served_Cells_To_Modify_Item_t *
2308 * @return ROK - success
2311 *****************************************************************/
2313 uint8_t fillServCellToModItem(Served_Cells_To_Modify_Item_t *modifyItem)
2318 modifyItem->oldNRCGI.pLMN_Identity.size = 3*sizeof(uint8_t);
2319 DU_ALLOC(modifyItem->oldNRCGI.pLMN_Identity.buf,modifyItem->oldNRCGI.pLMN_Identity.size);
2320 if(modifyItem->oldNRCGI.pLMN_Identity.buf == NULLP)
2324 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
2325 modifyItem->oldNRCGI.pLMN_Identity.buf);
2328 modifyItem->oldNRCGI.nRCellIdentity.size = 5*sizeof(uint8_t);
2329 DU_ALLOC(modifyItem->oldNRCGI.nRCellIdentity.buf,\
2330 modifyItem->oldNRCGI.nRCellIdentity.size);
2331 if(modifyItem->oldNRCGI.nRCellIdentity.buf == NULLP)
2335 for(ieIdx = 0; ieIdx < modifyItem->oldNRCGI.nRCellIdentity.size-1; ieIdx++)
2337 modifyItem->oldNRCGI.nRCellIdentity.buf[ieIdx] = 0;
2339 modifyItem->oldNRCGI.nRCellIdentity.buf[4] = 16;
2340 modifyItem->oldNRCGI.nRCellIdentity.bits_unused = 4;
2342 if(fillServedCellInfo(&modifyItem->served_Cell_Information))
2348 /*******************************************************************
2350 * @brief Builds ServCellToModList
2354 * Function : buildServCellToModList
2356 * Functionality: Builds the serv cell to Mod List
2358 * @params[in] Pointer to Served_Cells_To_Modify_List_t *
2360 * @return ROK - success
2363 *****************************************************************/
2365 uint8_t buildServCellToModList(Served_Cells_To_Modify_List_t *cellsToModify)
2367 uint8_t ieListCnt, ieIdx;
2368 Served_Cells_To_Modify_Item_t *modifyItem = NULLP;
2371 cellsToModify->list.count = ieListCnt;
2372 cellsToModify->list.size = ieListCnt*sizeof(Served_Cells_To_Modify_ItemIEs_t *);
2373 DU_ALLOC(cellsToModify->list.array,cellsToModify->list.size);
2374 if(cellsToModify->list.array == NULLP)
2378 for(ieIdx=0; ieIdx< ieListCnt; ieIdx++)
2380 DU_ALLOC(cellsToModify->list.array[ieIdx],sizeof(Served_Cells_To_Modify_ItemIEs_t));
2381 if(cellsToModify->list.array[ieIdx] == NULLP)
2386 cellsToModify->list.array[0]->id = ProtocolIE_ID_id_Served_Cells_To_Modify_Item;
2387 cellsToModify->list.array[0]->criticality = Criticality_reject;
2388 cellsToModify->list.array[0]->value.present =\
2389 Served_Cells_To_Modify_ItemIEs__value_PR_Served_Cells_To_Modify_Item;
2390 modifyItem=&cellsToModify->list.array[0]->value.choice.Served_Cells_To_Modify_Item;
2392 if(fillServCellToModItem(modifyItem))
2397 /*******************************************************************
2399 * @brief filling the DeleteItemList
2403 * Function : fillCellToDeleteItem
2405 * Functionality: Filling the DeleteItemIe
2407 * @params[in] Pointer to Served_Cells_To_Delete_ItemIEs_t
2409 * @return ROK - success
2412 *****************************************************************/
2413 uint8_t fillCellToDeleteItem(struct Served_Cells_To_Delete_ItemIEs *deleteItemIe)
2416 Served_Cells_To_Delete_Item_t *deleteItem=NULLP;
2418 deleteItemIe->id = ProtocolIE_ID_id_Served_Cells_To_Delete_Item;
2419 deleteItemIe->criticality = Criticality_reject;
2420 deleteItemIe->value.present =\
2421 Served_Cells_To_Delete_ItemIEs__value_PR_Served_Cells_To_Delete_Item;
2422 deleteItem=&deleteItemIe->value.choice.Served_Cells_To_Delete_Item;
2425 deleteItem->oldNRCGI.pLMN_Identity.size = 3*sizeof(uint8_t);
2426 DU_ALLOC(deleteItem->oldNRCGI.pLMN_Identity.buf,deleteItem->oldNRCGI.pLMN_Identity.size);
2427 if(deleteItem->oldNRCGI.pLMN_Identity.buf == NULLP)
2429 DU_LOG("ERROR --> F1AP: fillCellToDeleteItem(): Failed to allocate the memory");
2432 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
2433 deleteItem->oldNRCGI.pLMN_Identity.buf);
2436 deleteItem->oldNRCGI.nRCellIdentity.size = 5*sizeof(uint8_t);
2437 DU_ALLOC(deleteItem->oldNRCGI.nRCellIdentity.buf,\
2438 deleteItem->oldNRCGI.nRCellIdentity.size);
2439 if(deleteItem->oldNRCGI.nRCellIdentity.buf == NULLP)
2441 DU_LOG("ERROR --> F1AP: fillCellToDeleteItem(): Failed to allocate the memory");
2444 for(arrIdx = 0; arrIdx < deleteItem->oldNRCGI.nRCellIdentity.size-1; arrIdx++)
2446 deleteItem->oldNRCGI.nRCellIdentity.buf[arrIdx] = 0;
2448 deleteItem->oldNRCGI.nRCellIdentity.buf[4] = 16;
2449 deleteItem->oldNRCGI.nRCellIdentity.bits_unused = 4;
2452 /*******************************************************************
2454 * @brief Builds ServCellToDeleteList
2458 * Function : buildServCellToDeleteList
2460 * Functionality: Builds the serv cell to delete List
2462 * @params[in] Pointer to Served_Cells_To_Delete_List_t *
2464 * @return ROK - success
2467 *****************************************************************/
2469 uint8_t buildServCellToDeleteList(Served_Cells_To_Delete_List_t *cellsToDelete)
2471 uint8_t ieListCnt, arrIdx;
2474 cellsToDelete->list.count = ieListCnt;
2475 cellsToDelete->list.size = ieListCnt*sizeof(Served_Cells_To_Delete_ItemIEs_t *);
2477 DU_ALLOC(cellsToDelete->list.array,cellsToDelete->list.size);
2478 if(cellsToDelete->list.array == NULLP)
2480 DU_LOG("\nERROR --> F1AP : buildServCellToDeleteList(): Memory allocation failed");
2484 for(arrIdx=0; arrIdx< ieListCnt; arrIdx++)
2486 DU_ALLOC(cellsToDelete->list.array[arrIdx],sizeof(Served_Cells_To_Delete_ItemIEs_t));
2487 if(cellsToDelete->list.array[arrIdx] == NULLP)
2489 DU_LOG("\nERROR --> F1AP : buildServCellToDeleteList(): Memory allocation failed");
2495 if(fillCellToDeleteItem((Served_Cells_To_Delete_ItemIEs_t*)cellsToDelete->list.array[arrIdx]) !=ROK)
2497 DU_LOG("\nERROR --> F1AP: buildServCellToDeleteList(): failed to fill Served_Cells_To_Delete_ItemIEs");
2503 /*******************************************************************
2505 * @brief Builds and sends the DUConfigUpdate
2509 * Function : BuildAndSendDUConfigUpdate
2511 * Functionality: Constructs the DU Update message and sends
2512 * it to the CU through SCTP.
2514 * @params[in] void **buf,Buffer to which encoded pattern is written into
2515 * @params[in] int *size,size of buffer
2517 * @return ROK - success
2520 * ****************************************************************/
2521 uint8_t BuildAndSendDUConfigUpdate(ServCellAction servCellAction)
2523 uint8_t ret =0, ieIdx=0, elementCnt=0;
2524 bool memAlloctionFailure = false;
2525 F1AP_PDU_t *f1apDuCfg = NULLP;
2526 GNBDUConfigurationUpdate_t *duCfgUpdate = NULLP;
2527 asn_enc_rval_t encRetVal; /* Encoder return value */
2529 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
2534 DU_LOG("\nINFO --> F1AP : Building DU config update\n");
2535 /* Allocate the memory for F1DuCfg */
2536 DU_ALLOC(f1apDuCfg, sizeof(F1AP_PDU_t));
2537 if(f1apDuCfg == NULLP)
2539 DU_LOG("\nERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation for F1AP-PDU failed");
2543 f1apDuCfg->present = F1AP_PDU_PR_initiatingMessage;
2544 DU_ALLOC(f1apDuCfg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
2545 if(f1apDuCfg->choice.initiatingMessage == NULLP)
2547 DU_LOG("\nERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation for F1AP-PDU failed");
2551 f1apDuCfg->choice.initiatingMessage->procedureCode = \
2552 ProcedureCode_id_gNBDUConfigurationUpdate;
2553 f1apDuCfg->choice.initiatingMessage->criticality = Criticality_reject;
2554 f1apDuCfg->choice.initiatingMessage->value.present = \
2555 InitiatingMessage__value_PR_GNBDUConfigurationUpdate;
2556 duCfgUpdate = &f1apDuCfg->choice.initiatingMessage->value.\
2557 choice.GNBDUConfigurationUpdate;
2559 duCfgUpdate->protocolIEs.list.count = elementCnt;
2560 duCfgUpdate->protocolIEs.list.size = \
2561 elementCnt * sizeof(GNBDUConfigurationUpdateIEs_t*);
2563 /* Initialize the F1Setup members */
2564 DU_ALLOC(duCfgUpdate->protocolIEs.list.array,duCfgUpdate->protocolIEs.list.size);
2565 if(duCfgUpdate->protocolIEs.list.array == NULLP)
2567 DU_LOG("ERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation failed");
2570 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
2572 DU_ALLOC(duCfgUpdate->protocolIEs.list.array[ieIdx],sizeof(GNBDUConfigurationUpdateIEs_t));
2573 if(duCfgUpdate->protocolIEs.list.array[ieIdx] == NULLP)
2575 DU_LOG("ERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation failed");
2576 memAlloctionFailure = true;
2581 if(memAlloctionFailure == true)
2587 duCfgUpdate->protocolIEs.list.array[ieIdx]->id=ProtocolIE_ID_id_TransactionID;
2588 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
2589 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2590 GNBDUConfigurationUpdateIEs__value_PR_TransactionID;
2591 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = TRANS_ID;
2594 if(servCellAction == SERV_CELL_TO_MODIFY)
2596 /*Served Cell to Modify */
2597 duCfgUpdate->protocolIEs.list.array[ieIdx]->id = \
2598 ProtocolIE_ID_id_Served_Cells_To_Modify_List;
2599 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality =Criticality_reject;
2600 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2601 GNBDUConfigurationUpdateIEs__value_PR_Served_Cells_To_Modify_List;
2602 if(buildServCellToModList(&duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.\
2603 Served_Cells_To_Modify_List))
2605 DU_LOG("ERROR --> DU APP : BuildAndSendDUConfigUpdate(): failed to build ServCellToModList");
2611 /*Served Cell to Delete */
2612 duCfgUpdate->protocolIEs.list.array[ieIdx]->id = \
2613 ProtocolIE_ID_id_Served_Cells_To_Delete_List;
2614 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality =Criticality_reject;
2615 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2616 GNBDUConfigurationUpdateIEs__value_PR_Served_Cells_To_Delete_List;
2617 if(buildServCellToDeleteList(&duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.\
2618 Served_Cells_To_Delete_List)!=ROK)
2620 DU_LOG("ERROR --> DU APP : BuildAndSendDUConfigUpdate(): failed to build ServCellToDeleteList");
2625 // NOTE :GNB DU SYS INFO:MIB AND SIB1 INFORMATION TO BE BUILT AND FILLED HERE
2628 duCfgUpdate->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_ID;
2629 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
2630 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2631 GNBDUConfigurationUpdateIEs__value_PR_GNB_DU_ID;
2632 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size = sizeof(uint8_t);
2633 DU_ALLOC(duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
2634 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
2635 if(duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf == NULLP)
2637 DU_LOG("ERROR --> DU APP : BuildAndSendDUConfigUpdate(): Memory allocation failed for GNB_DU_ID");
2640 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf[0] = duCfgParam.duId;
2642 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apDuCfg);
2644 /* Encode the DU Config Update type as APER */
2645 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
2647 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apDuCfg, PrepFinalEncBuf, encBuf);
2649 /* Checking encode results */
2650 if(encRetVal.encoded == ENCODE_FAIL)
2652 DU_LOG("ERROR --> F1AP : Could not encode DUConfigUpdate structure (at %s)\n",\
2653 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
2658 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for DUConfigUpdate\n");
2659 for(ieIdx =0; ieIdx < encBufSize; ieIdx++)
2661 printf("%x",encBuf[ieIdx]);
2665 if(sendF1APMsg() != ROK)
2667 DU_LOG("\nERROR --> F1AP : Sending GNB-DU Config Update failed");
2675 addToReservedF1apPduList(TRANS_ID,f1apDuCfg);
2680 /*******************************************************************
2682 * @brief free the ULRRCMessageTransfer
2686 * Function : FreeULRRCMessageTransfer
2688 * Functionality: Deallocating the memory of variable allocated in
2689 * FreeULRRCMessageTransfer
2693 * @return ROK - void
2695 ******************************************************************/
2696 void FreeULRRCMessageTransfer( F1AP_PDU_t *f1apMsg)
2699 ULRRCMessageTransfer_t *ulRRCMsg;
2701 if(f1apMsg != NULLP)
2703 if(f1apMsg->choice.initiatingMessage != NULLP)
2705 ulRRCMsg = &f1apMsg->choice.initiatingMessage->value.choice.ULRRCMessageTransfer;
2706 if(ulRRCMsg->protocolIEs.list.array != NULLP)
2708 for(idx1=0;idx1<ulRRCMsg->protocolIEs.list.count;idx1++)
2710 if(ulRRCMsg->protocolIEs.list.array[idx1] != NULLP)
2712 if(ulRRCMsg->protocolIEs.list.array[idx1]->value.present ==
2713 ULRRCMessageTransferIEs__value_PR_RRCContainer)
2715 DU_FREE(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf,
2716 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size);
2718 DU_FREE(ulRRCMsg->protocolIEs.list.array[idx1],sizeof(ULRRCMessageTransferIEs_t));
2721 DU_FREE(ulRRCMsg->protocolIEs.list.array,ulRRCMsg->protocolIEs.list.size );
2723 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
2725 DU_FREE(f1apMsg,sizeof(F1AP_PDU_t));
2728 /*******************************************************************
2730 * @brief Builds and sends the ULRRCMessageTransfer
2734 * Function : BuildAndSendULRRCMessageTransfer
2736 * Functionality: Constructs the UL RRC Message Transfer and sends
2737 * it to the CU through SCTP.
2741 * @return ROK - success
2744 * ****************************************************************/
2745 uint8_t BuildAndSendULRRCMessageTransfer(DuUeCb ueCb, uint8_t lcId, \
2746 uint16_t msgLen, uint8_t *rrcMsg)
2748 uint8_t elementCnt =0;
2751 F1AP_PDU_t *f1apMsg = NULLP;
2752 ULRRCMessageTransfer_t *ulRRCMsg = NULLP;
2753 asn_enc_rval_t encRetVal; /* Encoder return value */
2754 uint8_t ret =RFAILED;
2756 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
2760 DU_LOG("\n INFO --> F1AP : Building UL RRC Message Transfer Message\n");
2762 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
2763 if(f1apMsg == NULLP)
2765 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
2768 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
2769 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
2770 if(f1apMsg->choice.initiatingMessage == NULLP)
2772 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
2775 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_ULRRCMessageTransfer;
2776 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
2777 f1apMsg->choice.initiatingMessage->value.present = \
2778 InitiatingMessage__value_PR_ULRRCMessageTransfer;
2780 &f1apMsg->choice.initiatingMessage->value.choice.ULRRCMessageTransfer;
2782 ulRRCMsg->protocolIEs.list.count = elementCnt;
2783 ulRRCMsg->protocolIEs.list.size = \
2784 elementCnt * sizeof(ULRRCMessageTransferIEs_t *);
2786 /* Initialize the F1Setup members */
2787 DU_ALLOC(ulRRCMsg->protocolIEs.list.array, ulRRCMsg->protocolIEs.list.size);
2788 if(ulRRCMsg->protocolIEs.list.array == NULLP)
2790 DU_LOG(" ERROR --> F1AP : Memory allocation for UL RRC MessageTransferIEs failed");
2793 for(idx=0; idx<elementCnt; idx++)
2795 DU_ALLOC(ulRRCMsg->protocolIEs.list.array[idx],sizeof(ULRRCMessageTransferIEs_t));
2796 if(ulRRCMsg->protocolIEs.list.array[idx] == NULLP)
2804 /*GNB CU UE F1AP ID*/
2805 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
2806 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2807 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2808 ULRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID;
2809 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.GNB_CU_UE_F1AP_ID = ueCb.gnbCuUeF1apId;
2811 /*GNB DU UE F1AP ID*/
2813 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
2814 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2815 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2816 ULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
2817 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.GNB_DU_UE_F1AP_ID = ueCb.gnbDuUeF1apId;
2821 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_SRBID;
2822 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2823 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2824 ULRRCMessageTransferIEs__value_PR_SRBID;
2825 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.SRBID = lcId;
2829 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_RRCContainer;
2830 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2831 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2832 ULRRCMessageTransferIEs__value_PR_RRCContainer;
2833 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size = msgLen;
2834 DU_ALLOC(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf,
2835 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size)
2836 if(!ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf)
2838 DU_LOG(" ERROR --> F1AP : Memory allocation for BuildAndSendULRRCMessageTransfer failed");
2841 memset(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf, 0, msgLen);
2842 memcpy(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf, \
2843 rrcMsg, ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size);
2845 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
2847 /* Encode the F1SetupRequest type as APER */
2848 memset(encBuf, 0, ENC_BUF_MAX_LEN);
2850 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
2852 /* Encode results */
2853 if(encRetVal.encoded == ENCODE_FAIL)
2855 DU_LOG( "\nERROR --> F1AP : Could not encode ULRRCMessageTransfer structure (at %s)\n",\
2856 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
2861 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for ULRRCMessageTransfer\n");
2862 for(int i=0; i< encBufSize; i++)
2864 printf("%x",encBuf[i]);
2869 if(sendF1APMsg() != ROK)
2871 DU_LOG("\nERROR --> F1AP : Sending UL RRC Message Transfer Failed");
2877 FreeULRRCMessageTransfer(f1apMsg);
2880 }/* End of BuildAndSendULRRCMessageTransfer*/
2882 /*******************************************************************
2884 * @brief Builds tag config
2888 * Function : BuildTagConfig
2890 * Functionality: Builds tag config in MacCellGroupConfig
2892 * @params[in] TAG_Config *tag_Config
2894 * @return ROK - success
2897 * ****************************************************************/
2898 uint8_t BuildTagConfig(struct TAG_Config *tagConfig)
2900 struct TAG_Config__tag_ToAddModList *tagList;
2901 uint8_t idx, elementCnt;
2903 tagConfig->tag_ToReleaseList = NULLP;
2904 tagConfig->tag_ToAddModList = NULLP;
2905 DU_ALLOC(tagConfig->tag_ToAddModList, sizeof(struct TAG_Config__tag_ToAddModList));
2906 if(!tagConfig->tag_ToAddModList)
2908 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildTagConfig");
2912 elementCnt = 1; //ODU_VALUE_ONE;
2913 tagList = tagConfig->tag_ToAddModList;
2914 tagList->list.count = elementCnt;
2915 tagList->list.size = elementCnt * sizeof(struct TAG *);
2917 tagList->list.array = NULLP;
2918 DU_ALLOC(tagList->list.array, tagList->list.size);
2919 if(!tagList->list.array)
2921 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildTagConfig");
2925 for(idx=0; idx<tagList->list.count; idx++)
2927 tagList->list.array[idx] = NULLP;
2928 DU_ALLOC(tagList->list.array[idx], sizeof(struct TAG));
2929 if(!tagList->list.array[idx])
2931 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildTagConfig");
2937 tagList->list.array[idx]->tag_Id = TAG_ID;
2938 tagList->list.array[idx]->timeAlignmentTimer = TIME_ALIGNMENT_TMR;
2943 /*******************************************************************
2945 * @brief Builds PHR Config
2949 * Function : BuildPhrConfig
2951 * Functionality: Builds phrConfig in MacCellGroupConfig
2953 * @params[in] PHR Config *
2955 * @return ROK - success
2958 * ****************************************************************/
2959 uint8_t BuildPhrConfig(struct MAC_CellGroupConfig__phr_Config *phrConfig)
2962 phrConfig->present = MAC_CellGroupConfig__phr_Config_PR_setup;
2963 phrConfig->choice.setup = NULLP;
2964 DU_ALLOC(phrConfig->choice.setup, sizeof(struct PHR_Config));
2965 if(!phrConfig->choice.setup)
2967 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildPhrConfig");
2971 phrConfig->choice.setup->phr_PeriodicTimer = PHR_PERIODIC_TMR;
2972 phrConfig->choice.setup->phr_ProhibitTimer = PHR_PROHIBHIT_TMR;
2973 phrConfig->choice.setup->phr_Tx_PowerFactorChange = PHR_PWR_FACTOR_CHANGE;
2974 phrConfig->choice.setup->multiplePHR = false;
2975 phrConfig->choice.setup->dummy = false;
2976 phrConfig->choice.setup->phr_Type2OtherCell = false;
2977 phrConfig->choice.setup->phr_ModeOtherCG = PHR_MODE_OTHER_CG;
2982 /*******************************************************************
2984 * @brief Builds BSR Config
2988 * Function : BuildBsrConfig
2990 * Functionality: Builds BuildBsrConfig in MacCellGroupConfig
2992 * @params[in] BSR_Config *bsrConfig
2994 * @return ROK - success
2997 * ****************************************************************/
2998 uint8_t BuildBsrConfig(struct BSR_Config *bsrConfig)
3000 bsrConfig->periodicBSR_Timer = PERIODIC_BSR_TMR;
3001 bsrConfig->retxBSR_Timer = RETX_BSR_TMR;
3002 bsrConfig->logicalChannelSR_DelayTimer = NULLP;
3007 /*******************************************************************
3009 * @brief Builds scheduling request config
3013 * Function : BuildSchedulingReqConfig
3015 * Functionality: Builds BuildSchedulingReqConfig in MacCellGroupConfig
3017 * @params[in] SchedulingRequestConfig *schedulingRequestConfig
3019 * @return ROK - success
3022 * ****************************************************************/
3023 uint8_t BuildSchedulingReqConfig(struct SchedulingRequestConfig *schedulingRequestConfig)
3025 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList;
3026 uint8_t idx, elementCnt;
3028 schedulingRequestConfig->schedulingRequestToAddModList = NULLP;
3029 DU_ALLOC(schedulingRequestConfig->schedulingRequestToAddModList,
3030 sizeof(struct SchedulingRequestConfig__schedulingRequestToAddModList));
3031 if(!schedulingRequestConfig->schedulingRequestToAddModList)
3033 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
3037 elementCnt = 1; //ODU_VALUE_ONE;
3038 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
3039 schReqList->list.count = elementCnt;
3040 schReqList->list.size = elementCnt * sizeof(struct SchedulingRequestToAddMod *);
3042 schReqList->list.array = NULLP;
3043 DU_ALLOC(schReqList->list.array, schReqList->list.size);
3044 if(!schReqList->list.array)
3046 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
3050 for(idx=0;idx<schReqList->list.count; idx++)
3052 schReqList->list.array[idx] = NULLP;
3053 DU_ALLOC(schReqList->list.array[idx], sizeof(struct SchedulingRequestToAddMod));
3054 if(!schReqList->list.array[idx])
3056 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
3062 schReqList->list.array[idx]->schedulingRequestId = SCH_REQ_ID;
3064 schReqList->list.array[idx]->sr_ProhibitTimer = NULLP;
3065 DU_ALLOC(schReqList->list.array[idx]->sr_ProhibitTimer, sizeof(long));
3066 if(!schReqList->list.array[idx]->sr_ProhibitTimer)
3068 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
3071 *(schReqList->list.array[idx]->sr_ProhibitTimer) = SR_PROHIBIT_TMR;
3072 schReqList->list.array[idx]->sr_TransMax = SR_TRANS_MAX;
3073 schedulingRequestConfig->schedulingRequestToReleaseList = NULLP;
3078 /*******************************************************************
3080 * @brief Builds RLC Config
3084 * Function : BuildRlcConfig
3086 * Functionality: Builds RLC Config in BuildRlcBearerToAddModList
3088 * @params[in] RLC_Config *rlcConfig
3090 * @return ROK - success
3093 * ****************************************************************/
3094 uint8_t BuildRlcConfig(struct RLC_Config *rlcConfig)
3097 rlcConfig->present = RLC_Config_PR_am;
3099 rlcConfig->choice.am = NULLP;
3100 DU_ALLOC(rlcConfig->choice.am, sizeof(struct RLC_Config__am));
3101 if(!rlcConfig->choice.am)
3103 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfig");
3108 rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength = NULLP;
3109 DU_ALLOC(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
3110 if(!rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength)
3112 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfig");
3115 *(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength) = SN_FIELD_LEN;
3116 rlcConfig->choice.am->ul_AM_RLC.t_PollRetransmit = T_POLL_RETRANSMIT;
3117 rlcConfig->choice.am->ul_AM_RLC.pollPDU = POLL_PDU;
3118 rlcConfig->choice.am->ul_AM_RLC.pollByte = POLL_BYTE;
3119 rlcConfig->choice.am->ul_AM_RLC.maxRetxThreshold = MAX_RETX_THRESHOLD;
3122 rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength = NULLP;
3123 DU_ALLOC(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
3124 if(!rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength)
3126 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfig");
3129 *(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength) = SN_FIELD_LEN;
3130 rlcConfig->choice.am->dl_AM_RLC.t_Reassembly = T_REASSEMBLY;
3131 rlcConfig->choice.am->dl_AM_RLC.t_StatusProhibit = T_STATUS_PROHIBHIT;
3136 /*******************************************************************
3138 * @brief Builds MAC LC Config
3142 * Function : BuildMacLCConfig
3144 * Functionality: Builds MAC LC Config in BuildRlcBearerToAddModList
3146 * @params[in] struct LogicalChannelConfig macLcConfig
3148 * @return ROK - success
3151 * ****************************************************************/
3152 uint8_t BuildMacLCConfig(struct LogicalChannelConfig *macLcConfig)
3155 macLcConfig->ul_SpecificParameters = NULLP;
3156 DU_ALLOC(macLcConfig->ul_SpecificParameters, sizeof(struct LogicalChannelConfig__ul_SpecificParameters));
3157 if(!macLcConfig->ul_SpecificParameters)
3159 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacLCConfig");
3163 macLcConfig->ul_SpecificParameters->priority = MAC_LC_PRIORITY;
3164 macLcConfig->ul_SpecificParameters->prioritisedBitRate = PRIORTISIED_BIT_RATE;
3165 macLcConfig->ul_SpecificParameters->bucketSizeDuration = BUCKET_SIZE_DURATION;
3166 macLcConfig->ul_SpecificParameters->allowedServingCells = NULLP;
3167 macLcConfig->ul_SpecificParameters->allowedSCS_List = NULLP;
3168 macLcConfig->ul_SpecificParameters->maxPUSCH_Duration = NULLP;
3169 macLcConfig->ul_SpecificParameters->configuredGrantType1Allowed = NULLP;
3171 macLcConfig->ul_SpecificParameters->logicalChannelGroup = NULLP;
3172 DU_ALLOC(macLcConfig->ul_SpecificParameters->logicalChannelGroup, sizeof(long));
3173 if(!macLcConfig->ul_SpecificParameters->logicalChannelGroup)
3175 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacLCConfig");
3178 *(macLcConfig->ul_SpecificParameters->logicalChannelGroup) = LC_GRP;
3180 macLcConfig->ul_SpecificParameters->schedulingRequestID = NULLP;
3181 DU_ALLOC(macLcConfig->ul_SpecificParameters->schedulingRequestID, sizeof(SchedulingRequestId_t));
3182 if(!macLcConfig->ul_SpecificParameters->schedulingRequestID)
3184 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacLCConfig");
3187 *(macLcConfig->ul_SpecificParameters->schedulingRequestID) = SCH_REQ_ID;
3189 macLcConfig->ul_SpecificParameters->logicalChannelSR_Mask = false;
3190 macLcConfig->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = false;
3191 macLcConfig->ul_SpecificParameters->bitRateQueryProhibitTimer = NULLP;
3196 /*******************************************************************
3198 * @brief Builds RLC Bearer to Add/Mod list
3202 * Function :BuildRlcBearerToAddModList
3204 * Functionality: Builds RLC Bearer to Add/Mod list in DuToCuRrcContainer
3206 * @params[in] rlc_BearerToAddModList
3208 * @return ROK - success
3211 * ****************************************************************/
3212 uint8_t BuildRlcBearerToAddModList(struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList)
3214 uint8_t idx, elementCnt;
3217 rlcBearerList->list.count = elementCnt;
3218 rlcBearerList->list.size = elementCnt * sizeof(struct RLC_BearerConfig *);
3220 rlcBearerList->list.array = NULLP;
3221 DU_ALLOC(rlcBearerList->list.array, rlcBearerList->list.size);
3222 if(!rlcBearerList->list.array)
3224 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3228 for(idx=0; idx<rlcBearerList->list.count; idx++)
3230 rlcBearerList->list.array[idx] = NULLP;
3231 DU_ALLOC(rlcBearerList->list.array[idx], sizeof(struct RLC_BearerConfig));
3232 if(!rlcBearerList->list.array[idx])
3234 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3240 rlcBearerList->list.array[idx]->logicalChannelIdentity = SRB1_LCID;
3242 DU_ALLOC(rlcBearerList->list.array[idx]->servedRadioBearer, \
3243 sizeof(struct RLC_BearerConfig__servedRadioBearer));
3244 if(!rlcBearerList->list.array[idx]->servedRadioBearer)
3246 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3250 rlcBearerList->list.array[idx]->servedRadioBearer->present = \
3251 RLC_BearerConfig__servedRadioBearer_PR_srb_Identity;
3252 rlcBearerList->list.array[idx]->servedRadioBearer->choice.srb_Identity = \
3255 rlcBearerList->list.array[idx]->reestablishRLC = NULLP;
3256 rlcBearerList->list.array[idx]->rlc_Config = NULLP;
3257 DU_ALLOC(rlcBearerList->list.array[idx]->rlc_Config, sizeof(struct RLC_Config));
3258 if(!rlcBearerList->list.array[idx]->rlc_Config)
3260 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3264 if(BuildRlcConfig(rlcBearerList->list.array[idx]->rlc_Config) != ROK)
3266 DU_LOG("\nERROR --> F1AP : BuildRlcConfig failed");
3270 rlcBearerList->list.array[idx]->mac_LogicalChannelConfig = NULLP;
3271 DU_ALLOC(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig, \
3272 sizeof(struct LogicalChannelConfig));
3273 if(!rlcBearerList->list.array[idx]->mac_LogicalChannelConfig)
3275 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3279 if(BuildMacLCConfig(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig) != ROK)
3281 DU_LOG("\nERROR --> F1AP : BuildMacLCConfig failed");
3288 /*******************************************************************
3290 * @brief Build Control resource set to add/modify list
3294 * Function : BuildControlRSetToAddModList
3296 * Functionality: Build Control resource set to add/modify list
3299 * struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList
3301 * @return ROK - success
3304 * ****************************************************************/
3305 uint8_t BuildControlRSetToAddModList
3307 struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList
3312 uint8_t numBytes, bitsUnused;
3313 struct ControlResourceSet *controlRSet;
3314 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
3315 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
3319 controlRSetList->list.count = elementCnt;
3320 controlRSetList->list.size = \
3321 elementCnt * sizeof(struct ControlResourceSet *);
3323 controlRSetList->list.array = NULLP;
3324 DU_ALLOC(controlRSetList->list.array, controlRSetList->list.size);
3325 if(!controlRSetList->list.array)
3327 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3331 for(idx = 0; idx < elementCnt; idx++)
3333 controlRSetList->list.array[idx] = NULLP;
3334 DU_ALLOC(controlRSetList->list.array[idx], sizeof(struct ControlResourceSet));
3335 if(!controlRSetList->list.array[idx])
3337 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3343 controlRSet = controlRSetList->list.array[idx];
3345 controlRSet->controlResourceSetId = PDCCH_CTRL_RSRC_SET_ONE_ID;
3349 * Bit string stored ff0000000000
3353 controlRSet->frequencyDomainResources.size = numBytes * sizeof(uint8_t);
3355 controlRSet->frequencyDomainResources.buf = NULLP;
3356 DU_ALLOC(controlRSet->frequencyDomainResources.buf, \
3357 controlRSet->frequencyDomainResources.size);
3358 if(!controlRSet->frequencyDomainResources.buf)
3360 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3364 memset(controlRSet->frequencyDomainResources.buf, 0, FREQ_DOM_RSRC_SIZE);
3365 coreset0EndPrb = CORESET0_END_PRB;
3366 coreset1StartPrb = coreset0EndPrb + 6;
3367 coreset1NumPrb = CORESET1_NUM_PRB;
3368 /* calculate the PRBs */
3369 freqDomRscAllocType0(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
3370 memcpy(controlRSet->frequencyDomainResources.buf, freqDomainResource, FREQ_DOM_RSRC_SIZE);
3371 controlRSet->frequencyDomainResources.bits_unused = bitsUnused;
3373 controlRSet->duration = PDCCH_CTRL_RSRC_SET_ONE_DURATION;
3374 controlRSet->cce_REG_MappingType.present = \
3375 ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved;
3377 controlRSet->precoderGranularity = PDCCH_CTRL_RSRC_SET_ONE_PRECOD_GRANULARITY;
3378 controlRSet->tci_StatesPDCCH_ToAddList = NULLP;
3379 controlRSet->tci_StatesPDCCH_ToReleaseList = NULLP;
3380 controlRSet->tci_PresentInDCI = NULLP;
3382 uint8_t tciStateIdx;
3384 DU_ALLOC(controlRset->tci_StatesPDCCH_ToAddList, \
3385 sizeof(struct ControlResourceSet__tci_StatesPDCCH_ToAddList));
3386 if(!controlRset->tci_StatesPDCCH_ToAddList)
3388 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3393 controlRset->tci_StatesPDCCH_ToAddList->list.count = elementCnt;
3394 controlRset->tci_StatesPDCCH_ToAddList->list.size = elementCnt * sizeof(TCI_StateId_t *);
3395 DU_ALLOC(controlRset->tci_StatesPDCCH_ToAddList->list.array, \
3396 controlRset->tci_StatesPDCCH_ToAddList->list.size)
3397 if(!controlRset->tci_StatesPDCCH_ToAddList->list.array)
3399 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3403 for(tciStateIdx = 0; tciStateIdx <elementCntl; tciStateIdx++)
3405 DU_ALLOC(controlRset->tci_StatesPDCCH_ToAddList->list.array[tciStateIdx], sizeof(TCI_StateId_t));
3406 if(!controlRset->tci_StatesPDCCH_ToAddList->list.array[tciStateIdx])
3408 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3415 *(controlRset->tci_StatesPDCCH_ToAddList->list.array[tciStateIdx]);
3417 DU_ALLOC(controlRset->tci_PresentInDCI, sizeof(long));
3418 if(!controlRset->tci_PresentInDCI)
3420 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3424 *(controlRset->tci_PresentInDCI);
3427 controlRSet->pdcch_DMRS_ScramblingID = NULLP;
3428 DU_ALLOC(controlRSet->pdcch_DMRS_ScramblingID, sizeof(long));
3429 if(!controlRSet->pdcch_DMRS_ScramblingID)
3431 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3434 *(controlRSet->pdcch_DMRS_ScramblingID) = SCRAMBLING_ID;
3437 } /* End BuildControlRSetToAddModList */
3439 /*******************************************************************
3441 * @brief Build search space to add/modify list
3445 * Function : BuildSearchSpcToAddModList
3447 * Functionality: Build search space to add/modify list
3450 * @return ROK - success
3453 * ****************************************************************/
3454 uint8_t BuildSearchSpcToAddModList
3456 struct PDCCH_Config__searchSpacesToAddModList *searchSpcList
3464 struct SearchSpace *searchSpc;
3467 searchSpcList->list.count = elementCnt;
3468 searchSpcList->list.size = elementCnt * sizeof(struct SearchSpace *);
3470 searchSpcList->list.array = NULLP;
3471 DU_ALLOC(searchSpcList->list.array, searchSpcList->list.size);
3472 if(!searchSpcList->list.array)
3474 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3478 for(idx = 0; idx < elementCnt; idx++)
3480 searchSpcList->list.array[idx] = NULLP;
3481 DU_ALLOC(searchSpcList->list.array[idx], sizeof(struct SearchSpace));
3482 if(!searchSpcList->list.array[idx])
3484 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3490 searchSpc = searchSpcList->list.array[idx];
3492 searchSpc->searchSpaceId = PDCCH_SRCH_SPC_TWO_ID;
3494 searchSpc->controlResourceSetId = NULLP;
3495 DU_ALLOC(searchSpc->controlResourceSetId, sizeof(ControlResourceSetId_t));
3496 if(!searchSpc->controlResourceSetId)
3498 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3501 *(searchSpc->controlResourceSetId) = PDCCH_CTRL_RSRC_SET_ONE_ID;
3503 searchSpc->monitoringSlotPeriodicityAndOffset = NULLP;
3504 DU_ALLOC(searchSpc->monitoringSlotPeriodicityAndOffset, \
3505 sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
3506 if(!searchSpc->monitoringSlotPeriodicityAndOffset)
3508 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3511 searchSpc->monitoringSlotPeriodicityAndOffset->present = \
3512 SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
3514 searchSpc->duration = NULLP;
3515 searchSpc->monitoringSymbolsWithinSlot = NULLP;
3516 DU_ALLOC(searchSpc->monitoringSymbolsWithinSlot, sizeof(BIT_STRING_t));
3517 if(!searchSpc->monitoringSymbolsWithinSlot)
3519 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3523 /* Values taken from reference logs :
3526 * Bit string stores 8000
3531 searchSpc->monitoringSymbolsWithinSlot->size = numBytes * sizeof(uint8_t);
3532 searchSpc->monitoringSymbolsWithinSlot->buf = NULLP;
3533 DU_ALLOC(searchSpc->monitoringSymbolsWithinSlot->buf, \
3534 searchSpc->monitoringSymbolsWithinSlot->size);
3535 if(!searchSpc->monitoringSymbolsWithinSlot->buf)
3537 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3542 searchSpc->monitoringSymbolsWithinSlot->buf[byteIdx++] = \
3543 PDCCH_SYMBOL_WITHIN_SLOT /* setting MSB to 128 i.e. 0x80 */;
3544 searchSpc->monitoringSymbolsWithinSlot->buf[byteIdx++] = 0;
3545 searchSpc->monitoringSymbolsWithinSlot->bits_unused = bitsUnused;
3547 searchSpc->nrofCandidates = NULLP;
3548 DU_ALLOC(searchSpc->nrofCandidates, sizeof(struct SearchSpace__nrofCandidates));
3549 if(!searchSpc->nrofCandidates)
3551 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3555 searchSpc->nrofCandidates->aggregationLevel1 = \
3556 PDCCH_SRCH_SPC_TWO_AGG_LVL1_CANDIDATE;
3557 searchSpc->nrofCandidates->aggregationLevel2 = \
3558 PDCCH_SRCH_SPC_TWO_AGG_LVL2_CANDIDATE;
3559 searchSpc->nrofCandidates->aggregationLevel4 = \
3560 PDCCH_SRCH_SPC_TWO_AGG_LVL4_CANDIDATE;
3561 searchSpc->nrofCandidates->aggregationLevel8 = \
3562 PDCCH_SRCH_SPC_TWO_AGG_LVL8_CANDIDATE;
3563 searchSpc->nrofCandidates->aggregationLevel16 = \
3564 PDCCH_SRCH_SPC_TWO_AGG_LVL16_CANDIDATE;
3566 searchSpc->searchSpaceType = NULLP;
3567 DU_ALLOC(searchSpc->searchSpaceType, sizeof(struct SearchSpace__searchSpaceType));
3568 if(!searchSpc->searchSpaceType)
3570 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3574 searchSpc->searchSpaceType->present = SearchSpace__searchSpaceType_PR_ue_Specific;
3576 searchSpc->searchSpaceType->choice.ue_Specific = NULLP;
3577 DU_ALLOC(searchSpc->searchSpaceType->choice.ue_Specific, \
3578 sizeof(struct SearchSpace__searchSpaceType__ue_Specific));
3579 if(!searchSpc->searchSpaceType->choice.ue_Specific)
3581 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3584 searchSpc->searchSpaceType->choice.ue_Specific->dci_Formats = \
3585 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
3588 }/* End BuildSearchSpcToAddModList */
3590 /*******************************************************************
3592 * @brief Builds BWP DL dedicated PDCCH config
3596 * Function : BuildBWPDlDedPdcchCfg
3598 * Functionality: Builds BWP DL dedicated PDCCH config
3600 * @params[in] struct PDCCH_Config *pdcchCfg
3602 * @return ROK - success
3605 * ****************************************************************/
3606 uint8_t BuildBWPDlDedPdcchCfg(struct PDCCH_Config *pdcchCfg)
3608 pdcchCfg->controlResourceSetToAddModList = NULLP;
3609 DU_ALLOC(pdcchCfg->controlResourceSetToAddModList, \
3610 sizeof(struct PDCCH_Config__controlResourceSetToAddModList));
3611 if(!pdcchCfg->controlResourceSetToAddModList)
3613 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdcchCfg");
3617 if(BuildControlRSetToAddModList(pdcchCfg->controlResourceSetToAddModList) != ROK)
3622 pdcchCfg->controlResourceSetToReleaseList = NULLP;
3624 pdcchCfg->searchSpacesToAddModList = NULLP;
3625 DU_ALLOC(pdcchCfg->searchSpacesToAddModList, \
3626 sizeof(struct PDCCH_Config__searchSpacesToAddModList));
3627 if(!pdcchCfg->searchSpacesToAddModList)
3629 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdcchCfg");
3633 if(BuildSearchSpcToAddModList(pdcchCfg->searchSpacesToAddModList) != ROK)
3638 pdcchCfg->searchSpacesToReleaseList = NULLP;
3639 pdcchCfg->downlinkPreemption = NULLP;
3640 pdcchCfg->tpc_PUSCH = NULLP;
3641 pdcchCfg->tpc_PUCCH = NULLP;
3642 pdcchCfg->tpc_SRS = NULLP;
3647 /*******************************************************************
3649 * @brief Builds DMRS DL PDSCH Mapping type A
3653 * Function : BuildDMRSDLPdschMapTypeA
3655 * Functionality: Builds DMRS DL PDSCH Mapping type A
3658 * struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg
3659 * @return ROK - success
3662 * ****************************************************************/
3663 uint8_t BuildDMRSDLPdschMapTypeA
3665 struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg
3668 dmrsDlCfg->present = PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA_PR_setup;
3669 dmrsDlCfg->choice.setup = NULLP;
3670 DU_ALLOC(dmrsDlCfg->choice.setup, sizeof(struct DMRS_DownlinkConfig));
3671 if(!dmrsDlCfg->choice.setup)
3673 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
3677 dmrsDlCfg->choice.setup->dmrs_Type = NULLP;
3678 dmrsDlCfg->choice.setup->dmrs_AdditionalPosition = NULLP;
3679 DU_ALLOC(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition, sizeof(long));
3680 if(!dmrsDlCfg->choice.setup->dmrs_AdditionalPosition)
3682 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSDLPdschMapTypeA");
3685 *(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition) = DMRS_ADDITIONAL_POS;
3687 dmrsDlCfg->choice.setup->maxLength = NULLP;
3688 dmrsDlCfg->choice.setup->scramblingID0 = NULLP;
3689 dmrsDlCfg->choice.setup->scramblingID1 = NULLP;
3690 dmrsDlCfg->choice.setup->phaseTrackingRS = NULLP;
3695 /*******************************************************************
3697 * @brief Builds TCI states to add/modify list
3701 * Function : BuildTCIStatesToAddModList
3703 * Functionality:Builds TCI states to add/modify list
3706 * struct PDSCH_Config__tci_StatesToAddModList *tciStatesList
3708 * @return ROK - success
3711 * ****************************************************************/
3712 uint8_t BuildTCIStatesToAddModList(struct PDSCH_Config__tci_StatesToAddModList *tciStatesList)
3717 /*******************************************************************
3719 * @brief Builds PDSCH time domain allocation list
3723 * Function : BuildPdschTimeDomAllocList
3725 * Functionality: Builds PDSCH time domain allocation list
3728 * struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
3730 * @return ROK - success
3733 * ****************************************************************/
3734 uint8_t BuildPdschTimeDomAllocList
3736 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
3741 struct PDSCH_TimeDomainResourceAllocation *timeDomAlloc;
3743 timeDomAllocList->present = \
3744 PDSCH_Config__pdsch_TimeDomainAllocationList_PR_setup;
3746 timeDomAllocList->choice.setup = NULLP;
3747 DU_ALLOC(timeDomAllocList->choice.setup, \
3748 sizeof(struct PDSCH_TimeDomainResourceAllocationList));
3749 if(!timeDomAllocList->choice.setup)
3751 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
3756 timeDomAllocList->choice.setup->list.count = elementCnt;
3757 timeDomAllocList->choice.setup->list.size = \
3758 elementCnt * sizeof(struct PDSCH_TimeDomainResourceAllocation *);
3760 timeDomAllocList->choice.setup->list.array = NULLP;
3761 DU_ALLOC(timeDomAllocList->choice.setup->list.array, \
3762 timeDomAllocList->choice.setup->list.size);
3763 if(!timeDomAllocList->choice.setup->list.array)
3765 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
3769 for(idx = 0; idx < elementCnt; idx++)
3771 timeDomAllocList->choice.setup->list.array[idx] = NULLP;
3772 DU_ALLOC(timeDomAllocList->choice.setup->list.array[idx], \
3773 sizeof(struct PDSCH_TimeDomainResourceAllocation));
3774 if(!timeDomAllocList->choice.setup->list.array[idx])
3776 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
3782 timeDomAlloc = timeDomAllocList->choice.setup->list.array[idx];
3783 DU_ALLOC(timeDomAlloc->k0, sizeof(long));
3784 if(!timeDomAlloc->k0)
3786 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
3789 *(timeDomAlloc->k0) = 0;
3790 timeDomAlloc->mappingType = PDSCH_MAPPING_TYPE_A;
3791 timeDomAlloc->startSymbolAndLength = \
3792 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
3795 timeDomAlloc = timeDomAllocList->choice.setup->list.array[idx];
3796 DU_ALLOC(timeDomAlloc->k0, sizeof(long));
3797 if(!timeDomAlloc->k0)
3799 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
3802 *(timeDomAlloc->k0) = 1;
3803 timeDomAlloc->mappingType = PDSCH_MAPPING_TYPE_A;
3804 timeDomAlloc->startSymbolAndLength = calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
3809 /*******************************************************************
3811 * @brief Builds PDSCH PRB Bundling type
3815 * Function : BuildPdschPrbBundlingType
3817 * Functionality: Builds PDSCH PRB Bundling type
3820 * struct PDSCH_Config__prb_BundlingType *prbBndlType
3822 * @return ROK - success
3825 * ****************************************************************/
3826 uint8_t BuildPdschPrbBundlingType
3828 struct PDSCH_Config__prb_BundlingType *prbBndlType
3831 prbBndlType->present = PDSCH_Config__prb_BundlingType_PR_staticBundling;
3833 prbBndlType->choice.staticBundling = NULLP;
3834 DU_ALLOC(prbBndlType->choice.staticBundling, \
3835 sizeof(struct PDSCH_Config__prb_BundlingType__staticBundling));
3836 if(!prbBndlType->choice.staticBundling)
3838 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschPrbBundlingType");
3841 prbBndlType->choice.staticBundling->bundleSize = NULLP;
3846 /*******************************************************************
3848 * @brief Builds BWP DL dedicated PDSCH config
3852 * Function : BuildBWPDlDedPdschCfg
3854 * Functionality: Builds BWP DL dedicated PDSCH config
3856 * @params[in] struct PDSCH_Config *pdschCfg
3858 * @return ROK - success
3861 * ****************************************************************/
3862 uint8_t BuildBWPDlDedPdschCfg(struct PDSCH_Config *pdschCfg)
3864 pdschCfg->dataScramblingIdentityPDSCH = NULLP;
3866 pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA = NULLP;
3867 DU_ALLOC(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA, \
3868 sizeof(struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA));
3869 if(!pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
3871 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
3875 if(BuildDMRSDLPdschMapTypeA(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA) != ROK)
3880 pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeB = NULLP;
3881 pdschCfg->tci_StatesToAddModList = NULLP;
3882 pdschCfg->tci_StatesToReleaseList = NULLP;
3883 pdschCfg->vrb_ToPRB_Interleaver = NULLP;
3885 DU_ALLOC(pdschCfg->tci_StatesToAddModList, sizeof(struct PDSCH_Config__tci_StatesToAddModList));
3886 if(!pdschCfg->tci_StatesToAddModList)
3888 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
3891 if(BuildTCIStatesToAddModList(pdschCfg->tci_StatesToAddModList) != ROK)
3897 pdschCfg->resourceAllocation = RES_ALLOC_TYPE;
3899 pdschCfg->pdsch_TimeDomainAllocationList = NULLP;
3900 DU_ALLOC(pdschCfg->pdsch_TimeDomainAllocationList, \
3901 sizeof(struct PDSCH_Config__pdsch_TimeDomainAllocationList));
3902 if(!pdschCfg->pdsch_TimeDomainAllocationList)
3904 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
3908 if(BuildPdschTimeDomAllocList(pdschCfg->pdsch_TimeDomainAllocationList) != ROK)
3913 pdschCfg->pdsch_AggregationFactor = NULLP;
3914 pdschCfg->rateMatchPatternToAddModList = NULLP;
3915 pdschCfg->rateMatchPatternToReleaseList = NULLP;
3916 pdschCfg->rateMatchPatternGroup1 = NULLP;
3917 pdschCfg->rateMatchPatternGroup2 = NULLP;
3918 pdschCfg->rbg_Size = PDSCH_RBG_SIZE;
3919 pdschCfg->mcs_Table = NULLP;
3921 pdschCfg->maxNrofCodeWordsScheduledByDCI = NULLP;
3922 DU_ALLOC(pdschCfg->maxNrofCodeWordsScheduledByDCI, sizeof(long));
3923 if(!pdschCfg->maxNrofCodeWordsScheduledByDCI)
3925 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
3928 *(pdschCfg->maxNrofCodeWordsScheduledByDCI) = PDSCH_MAX_CODEWORD_SCH_BY_DCI;
3930 if(BuildPdschPrbBundlingType(&pdschCfg->prb_BundlingType) != ROK)
3935 pdschCfg->zp_CSI_RS_ResourceToAddModList = NULLP;
3936 pdschCfg->zp_CSI_RS_ResourceToReleaseList = NULLP;
3937 pdschCfg->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList = NULLP;
3938 pdschCfg->aperiodic_ZP_CSI_RS_ResourceSetsToReleaseList = NULLP;
3939 pdschCfg->sp_ZP_CSI_RS_ResourceSetsToAddModList = NULLP;
3940 pdschCfg->sp_ZP_CSI_RS_ResourceSetsToReleaseList = NULLP;
3941 pdschCfg->p_ZP_CSI_RS_ResourceSet = NULLP;
3946 /*******************************************************************
3948 * @brief Builds intitial DL BWP
3951 * Function : BuildInitialDlBWP
3953 * Functionality: Builds intitial DL BWP in spCellCfgDed
3955 * @params[in] BWP_DownlinkDedicated_t *dlBwp
3957 * @return ROK - success
3960 * ****************************************************************/
3961 uint8_t BuildInitialDlBWP(BWP_DownlinkDedicated_t *dlBwp)
3963 dlBwp->pdcch_Config = NULLP;
3964 DU_ALLOC(dlBwp->pdcch_Config, sizeof(struct BWP_DownlinkDedicated__pdcch_Config));
3965 if(!dlBwp->pdcch_Config)
3967 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
3970 dlBwp->pdcch_Config->present = BWP_DownlinkDedicated__pdcch_Config_PR_setup;
3972 dlBwp->pdcch_Config->choice.setup = NULLP;
3973 DU_ALLOC(dlBwp->pdcch_Config->choice.setup, sizeof(struct PDCCH_Config));
3974 if(!dlBwp->pdcch_Config->choice.setup)
3976 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
3979 if(BuildBWPDlDedPdcchCfg(dlBwp->pdcch_Config->choice.setup) != ROK)
3984 dlBwp->pdsch_Config = NULLP;
3985 DU_ALLOC(dlBwp->pdsch_Config, sizeof(struct BWP_DownlinkDedicated__pdsch_Config));
3986 if(!dlBwp->pdsch_Config)
3988 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
3991 dlBwp->pdsch_Config->present = BWP_DownlinkDedicated__pdsch_Config_PR_setup;
3993 dlBwp->pdsch_Config->choice.setup = NULLP;
3994 DU_ALLOC(dlBwp->pdsch_Config->choice.setup, sizeof(struct PDSCH_Config));
3995 if(!dlBwp->pdsch_Config->choice.setup)
3997 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
4001 if(BuildBWPDlDedPdschCfg(dlBwp->pdsch_Config->choice.setup) != ROK)
4006 dlBwp->sps_Config = NULLP;
4007 dlBwp->radioLinkMonitoringConfig = NULLP;
4011 /*******************************************************************
4013 * @brief Builds DMRS UL Pusch Mapping type A
4017 * Function : BuildDMRSULPuschMapTypeA
4019 * Functionality: Builds DMRS UL Pusch Mapping type A
4022 * struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg
4023 * @return ROK - success
4026 * ****************************************************************/
4027 uint8_t BuildDMRSULPuschMapTypeA
4029 struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg
4032 dmrsUlCfg->present = PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA_PR_setup;
4033 dmrsUlCfg->choice.setup= NULLP;
4034 DU_ALLOC(dmrsUlCfg->choice.setup, sizeof(DMRS_UplinkConfig_t));
4035 if(!dmrsUlCfg->choice.setup)
4037 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4041 dmrsUlCfg->choice.setup->dmrs_Type = NULLP;
4042 dmrsUlCfg->choice.setup->dmrs_AdditionalPosition = NULLP;
4043 DU_ALLOC(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition, sizeof(long));
4044 if(!dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
4046 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4049 *(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition) = DMRS_ADDITIONAL_POS;
4051 dmrsUlCfg->choice.setup->phaseTrackingRS = NULLP;
4052 dmrsUlCfg->choice.setup->maxLength = NULLP;
4053 dmrsUlCfg->choice.setup->transformPrecodingDisabled = NULLP;
4054 DU_ALLOC(dmrsUlCfg->choice.setup->transformPrecodingDisabled, \
4055 sizeof(struct DMRS_UplinkConfig__transformPrecodingDisabled));
4056 if(!dmrsUlCfg->choice.setup->transformPrecodingDisabled)
4058 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4062 dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0 = NULLP;
4063 DU_ALLOC(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0,\
4065 if(!dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0)
4067 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4070 *(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0) = SCRAMBLING_ID;
4072 dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID1 = NULLP;
4073 dmrsUlCfg->choice.setup->transformPrecodingEnabled = NULLP;
4077 /*******************************************************************
4079 * @brief Build PUSCH time domain allocation list
4083 * Function : BuildPuschTimeDomAllocList
4085 * Functionality: Build PUSCH time domain allocation list
4088 * struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList
4090 * @return ROK - success
4093 * ****************************************************************/
4094 uint8_t BuildPuschTimeDomAllocList
4096 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList
4101 PUSCH_TimeDomainResourceAllocation_t *timeDomAlloc;
4103 timeDomAllocList->present = PUSCH_Config__pusch_TimeDomainAllocationList_PR_setup;
4104 timeDomAllocList->choice.setup = NULLP;
4105 DU_ALLOC(timeDomAllocList->choice.setup, \
4106 sizeof(struct PUSCH_TimeDomainResourceAllocationList));
4107 if(!timeDomAllocList->choice.setup)
4109 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4114 timeDomAllocList->choice.setup->list.count = elementCnt;
4115 timeDomAllocList->choice.setup->list.size = \
4116 elementCnt * sizeof(PUSCH_TimeDomainResourceAllocation_t *);
4117 timeDomAllocList->choice.setup->list.array = NULLP;
4118 DU_ALLOC(timeDomAllocList->choice.setup->list.array, \
4119 timeDomAllocList->choice.setup->list.size);
4120 if(!timeDomAllocList->choice.setup->list.array)
4122 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4126 for(idx = 0; idx < elementCnt; idx++)
4128 timeDomAllocList->choice.setup->list.array[idx] = NULLP;
4129 DU_ALLOC(timeDomAllocList->choice.setup->list.array[idx],\
4130 sizeof(PUSCH_TimeDomainResourceAllocation_t));
4131 if(!timeDomAllocList->choice.setup->list.array[idx])
4133 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4139 timeDomAlloc = timeDomAllocList->choice.setup->list.array[idx];
4140 DU_ALLOC(timeDomAlloc->k2, sizeof(long));
4141 if(!timeDomAlloc->k2)
4143 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4146 *(timeDomAlloc->k2) = PUSCH_K2;
4147 timeDomAlloc->mappingType = PUSCH_MAPPING_TYPE_A;
4148 timeDomAlloc->startSymbolAndLength = calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
4152 /*******************************************************************
4154 * @brief Builds BWP UL dedicated PUSCH Config
4158 * Function : BuildBWPUlDedPuschCfg
4161 * Builds BWP UL dedicated PUSCH Config
4163 * @params[in] : PUSCH_Config_t *puschCfg
4165 * @return ROK - success
4168 * ****************************************************************/
4169 uint8_t BuildBWPUlDedPuschCfg(PUSCH_Config_t *puschCfg)
4171 puschCfg->dataScramblingIdentityPUSCH = NULLP;
4172 DU_ALLOC(puschCfg->dataScramblingIdentityPUSCH, sizeof(long));
4173 if(!puschCfg->dataScramblingIdentityPUSCH)
4175 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4178 *(puschCfg->dataScramblingIdentityPUSCH) = SCRAMBLING_ID;
4180 puschCfg->txConfig = NULLP;
4181 puschCfg->dmrs_UplinkForPUSCH_MappingTypeA = NULLP;
4182 DU_ALLOC(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA, \
4183 sizeof(struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA));
4184 if(!puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
4186 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4190 if(BuildDMRSULPuschMapTypeA(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA) != ROK)
4195 puschCfg->dmrs_UplinkForPUSCH_MappingTypeB = NULLP;
4196 puschCfg->pusch_PowerControl = NULLP;
4197 puschCfg->frequencyHopping = NULLP;
4198 puschCfg->frequencyHoppingOffsetLists = NULLP;
4199 puschCfg->resourceAllocation = RES_ALLOC_TYPE;
4201 puschCfg->pusch_TimeDomainAllocationList = NULLP;
4202 DU_ALLOC(puschCfg->pusch_TimeDomainAllocationList, \
4203 sizeof(struct PUSCH_Config__pusch_TimeDomainAllocationList));
4204 if(!puschCfg->pusch_TimeDomainAllocationList)
4206 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4210 if(BuildPuschTimeDomAllocList(puschCfg->pusch_TimeDomainAllocationList) != ROK)
4215 puschCfg->pusch_AggregationFactor = NULLP;
4216 puschCfg->mcs_Table = NULLP;
4217 puschCfg->mcs_TableTransformPrecoder = NULLP;
4218 puschCfg->transformPrecoder = NULLP;
4219 DU_ALLOC(puschCfg->transformPrecoder, sizeof(long));
4220 if(!puschCfg->transformPrecoder)
4222 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4225 *(puschCfg->transformPrecoder) = PUSCH_TRANSFORM_PRECODER;
4227 puschCfg->codebookSubset = NULLP;
4228 puschCfg->maxRank = NULLP;
4229 puschCfg->rbg_Size = NULLP;
4230 puschCfg->uci_OnPUSCH = NULLP;
4231 puschCfg->tp_pi2BPSK = NULLP;
4236 /*******************************************************************
4238 * @brief Builds BWP UL dedicated PUCCH Config
4242 * Function : BuildBWPUlDedPucchCfg
4245 * Builds BWP UL dedicated PUCCH Config
4247 * @params[in] : PUCCH_Config_t *pucchCfg
4249 * @return ROK - success
4252 * ****************************************************************/
4253 uint8_t BuildBWPUlDedPucchCfg(PUCCH_Config_t *pucchCfg)
4255 uint8_t arrIdx, elementCnt;
4257 DU_ALLOC(pucchCfg->dl_DataToUL_ACK, sizeof(struct PUCCH_Config__dl_DataToUL_ACK));
4258 if(pucchCfg->dl_DataToUL_ACK == NULLP)
4260 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
4265 pucchCfg->dl_DataToUL_ACK->list.count = elementCnt;
4266 pucchCfg->dl_DataToUL_ACK->list.size = elementCnt * sizeof(long *);
4267 DU_ALLOC(pucchCfg->dl_DataToUL_ACK->list.array, pucchCfg->dl_DataToUL_ACK->list.size);
4268 if(pucchCfg->dl_DataToUL_ACK->list.array == NULLP)
4270 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
4274 for(arrIdx = 0; arrIdx < pucchCfg->dl_DataToUL_ACK->list.count; arrIdx++)
4276 DU_ALLOC(pucchCfg->dl_DataToUL_ACK->list.array[arrIdx], sizeof(long));
4277 if(pucchCfg->dl_DataToUL_ACK->list.array[arrIdx] == NULLP)
4279 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
4285 *(pucchCfg->dl_DataToUL_ACK->list.array[arrIdx++]) = 1;
4286 *(pucchCfg->dl_DataToUL_ACK->list.array[arrIdx]) = 2;
4290 /*******************************************************************
4292 * @brief Fills SRS resource to add/modify list
4296 * Function : BuildSrsRsrcAddModList
4298 * Functionality: Fills SRS resource to add/modify list
4301 * @return ROK - success
4304 * ****************************************************************/
4305 uint8_t BuildSrsRsrcAddModList(struct SRS_Config__srs_ResourceToAddModList *resourceList)
4311 resourceList->list.count = elementCnt;
4312 resourceList->list.size = elementCnt * sizeof(SRS_Resource_t *);
4313 resourceList->list.array = NULLP;
4314 DU_ALLOC(resourceList->list.array, resourceList->list.size);
4315 if(!resourceList->list.array)
4317 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
4321 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
4323 DU_ALLOC(resourceList->list.array[rsrcIdx], sizeof(SRS_Resource_t));
4324 if(!resourceList->list.array[rsrcIdx])
4326 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
4332 resourceList->list.array[rsrcIdx]->srs_ResourceId = SRS_RSRC_ID;
4333 resourceList->list.array[rsrcIdx]->nrofSRS_Ports = SRS_Resource__nrofSRS_Ports_port1;
4334 resourceList->list.array[rsrcIdx]->transmissionComb.present = SRS_Resource__transmissionComb_PR_n2;
4336 resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2 = NULLP;
4337 DU_ALLOC(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2, \
4338 sizeof(struct SRS_Resource__transmissionComb__n2));
4339 if(!resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2)
4341 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
4344 resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2->combOffset_n2\
4345 = SRS_COMB_OFFSET_N2;
4346 resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2->cyclicShift_n2\
4347 = SRS_CYCLIC_SHIFT_N2;
4349 resourceList->list.array[rsrcIdx]->resourceMapping.startPosition = \
4351 resourceList->list.array[rsrcIdx]->resourceMapping.nrofSymbols = \
4352 SRS_Resource__resourceMapping__nrofSymbols_n1;
4353 resourceList->list.array[rsrcIdx]->resourceMapping.repetitionFactor = \
4354 SRS_Resource__resourceMapping__repetitionFactor_n1;
4356 resourceList->list.array[rsrcIdx]->freqDomainPosition = SRS_FREQ_DOM_POS;
4357 resourceList->list.array[rsrcIdx]->freqDomainShift = SRS_FREQ_DOM_SHIFT;
4358 resourceList->list.array[rsrcIdx]->freqHopping.c_SRS = C_SRS;
4359 resourceList->list.array[rsrcIdx]->freqHopping.b_SRS = B_SRS;
4360 resourceList->list.array[rsrcIdx]->freqHopping.b_hop = B_HOP;
4361 resourceList->list.array[rsrcIdx]->groupOrSequenceHopping = \
4362 SRS_Resource__groupOrSequenceHopping_neither;
4364 /* Setting resource type to aperiodic for intergration purposes */
4365 resourceList->list.array[rsrcIdx]->resourceType.present = \
4366 SRS_Resource__resourceType_PR_aperiodic;
4367 resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic = NULLP;
4368 DU_ALLOC(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic,
4369 sizeof(struct SRS_Resource__resourceType__aperiodic));
4370 if(!resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic)
4372 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
4375 resourceList->list.array[rsrcIdx]->sequenceId = SRS_SEQ_ID;
4380 /*******************************************************************
4382 * @brief Build SRS resource set Add/mod list
4386 * Function : BuildSrsRsrcSetAddModList
4388 * Functionality: Build SRS resource set Add/mod list
4391 * @return ROK - success
4394 * ****************************************************************/
4395 uint8_t BuildSrsRsrcSetAddModList
4397 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList
4403 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList;
4406 rsrcSetList->list.count = elementCnt;
4407 rsrcSetList->list.size = elementCnt * sizeof(SRS_ResourceSet_t *);
4408 rsrcSetList->list.array = NULLP;
4409 DU_ALLOC(rsrcSetList->list.array, rsrcSetList->list.size);
4410 if(!rsrcSetList->list.array)
4412 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4416 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
4418 DU_ALLOC(rsrcSetList->list.array[rSetIdx], sizeof(SRS_ResourceSet_t));
4419 if(!rsrcSetList->list.array[rSetIdx])
4421 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4427 rsrcSetList->list.array[rSetIdx]->srs_ResourceSetId = SRS_RSET_ID;
4429 /* Fill Resource Id list in resource set */
4430 rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList = NULLP;
4431 DU_ALLOC(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList,\
4432 sizeof(struct SRS_ResourceSet__srs_ResourceIdList));
4433 if(!rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
4435 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4440 rsrcIdList = rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
4441 rsrcIdList->list.count = elementCnt;
4442 rsrcIdList->list.size = elementCnt * sizeof(SRS_ResourceId_t *);
4443 rsrcIdList->list.array = NULLP;
4444 DU_ALLOC(rsrcIdList->list.array, rsrcIdList->list.size);
4445 if(!rsrcIdList->list.array)
4447 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4451 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count; rsrcIdx++)
4453 DU_ALLOC(rsrcIdList->list.array[rsrcIdx], sizeof(SRS_ResourceId_t));
4454 if(!rsrcIdList->list.array[rsrcIdx])
4456 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4462 *rsrcIdList->list.array[rsrcIdx] = SRS_RSRC_ID;
4464 /* Fill resource type */
4465 rsrcSetList->list.array[rSetIdx]->resourceType.present = \
4466 SRS_ResourceSet__resourceType_PR_aperiodic;
4468 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic = NULLP;
4469 DU_ALLOC(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic, \
4470 sizeof(struct SRS_ResourceSet__resourceType__aperiodic));
4471 if(!rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic)
4473 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4476 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic->aperiodicSRS_ResourceTrigger \
4477 = APERIODIC_SRS_RESRC_TRIGGER;
4479 /* TODO : Fill values for below IEs as expected by Viavi */
4480 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic->csi_RS = NULLP;
4481 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic->slotOffset = NULLP;
4484 rsrcSetList->list.array[rSetIdx]->usage = SRS_ResourceSet__usage_codebook;
4485 rsrcSetList->list.array[rSetIdx]->alpha = NULLP;
4486 rsrcSetList->list.array[rSetIdx]->p0 = NULLP;
4487 rsrcSetList->list.array[rSetIdx]->pathlossReferenceRS = NULLP;
4488 rsrcSetList->list.array[rSetIdx]->srs_PowerControlAdjustmentStates = NULLP;
4493 /*******************************************************************
4495 * @brief Builds BWP UL dedicated SRS Config
4499 * Function : BuildBWPUlDedSrsCfg
4501 * Functionality: Builds BWP UL dedicated SRS Config
4503 * @params[in] SRS Config
4504 * @return ROK - success
4507 * ****************************************************************/
4508 uint8_t BuildBWPUlDedSrsCfg(SRS_Config_t *srsCfg)
4510 srsCfg->srs_ResourceSetToReleaseList = NULLP;
4511 srsCfg->srs_ResourceSetToAddModList = NULLP;
4512 DU_ALLOC(srsCfg->srs_ResourceSetToAddModList, \
4513 sizeof(struct SRS_Config__srs_ResourceSetToAddModList));
4514 if(!srsCfg->srs_ResourceSetToAddModList)
4516 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedSrsCfg");
4519 if(BuildSrsRsrcSetAddModList(srsCfg->srs_ResourceSetToAddModList) != ROK)
4524 srsCfg->srs_ResourceToReleaseList = NULLP;
4526 /* Resource to Add/Modify list */
4527 srsCfg->srs_ResourceToAddModList = NULLP;
4528 DU_ALLOC(srsCfg->srs_ResourceToAddModList, \
4529 sizeof(struct SRS_Config__srs_ResourceToAddModList));
4530 if(!srsCfg->srs_ResourceToAddModList)
4532 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedSrsCfg");
4536 if(BuildSrsRsrcAddModList(srsCfg->srs_ResourceToAddModList) != ROK)
4541 srsCfg->tpc_Accumulation = NULLP;
4548 /*******************************************************************
4550 * @brief Builds Pusch Serving cell Config
4554 * Function : BuildPuschSrvCellCfg
4556 * Functionality: Builds Pusch Serving cell Config
4558 * @params[in] struct UplinkConfig__pusch_ServingCellConfig *puschCfg
4560 * @return ROK - success
4563 * ****************************************************************/
4564 uint8_t BuildPuschSrvCellCfg(struct UplinkConfig__pusch_ServingCellConfig *puschCfg)
4566 puschCfg->present = UplinkConfig__pusch_ServingCellConfig_PR_setup;
4567 puschCfg->choice.setup = NULLP;
4568 DU_ALLOC(puschCfg->choice.setup, sizeof(struct PUSCH_ServingCellConfig));
4569 if(!puschCfg->choice.setup)
4571 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
4575 puschCfg->choice.setup->codeBlockGroupTransmission = NULLP;
4576 puschCfg->choice.setup->rateMatching = NULLP;
4577 puschCfg->choice.setup->xOverhead = NULLP;
4578 puschCfg->choice.setup->ext1 = NULLP;
4579 DU_ALLOC(puschCfg->choice.setup->ext1, sizeof(struct PUSCH_ServingCellConfig__ext1));
4580 if(!puschCfg->choice.setup->ext1)
4582 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
4586 puschCfg->choice.setup->ext1->maxMIMO_Layers = NULLP;
4587 DU_ALLOC(puschCfg->choice.setup->ext1->maxMIMO_Layers, sizeof(long));
4588 if(!puschCfg->choice.setup->ext1->maxMIMO_Layers)
4590 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
4593 *(puschCfg->choice.setup->ext1->maxMIMO_Layers) = PUSCH_MAX_MIMO_LAYERS;
4595 puschCfg->choice.setup->ext1->processingType2Enabled= NULLP;
4596 DU_ALLOC(puschCfg->choice.setup->ext1->processingType2Enabled,sizeof(BOOLEAN_t));
4597 if(!puschCfg->choice.setup->ext1->processingType2Enabled)
4599 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
4602 *(puschCfg->choice.setup->ext1->processingType2Enabled) = PUSCH_PROCESS_TYPE2_ENABLED;
4606 /*******************************************************************
4608 * @brief Builds inital UL BWP
4612 * Function : BuildInitialUlBWP
4614 * Functionality: Builds initial UL BWP
4616 * @params[in] BWP_UplinkDedicated_t *ulBwp
4617 * @return ROK - success
4620 * ****************************************************************/
4621 uint8_t BuildInitialUlBWP(BWP_UplinkDedicated_t *ulBwp)
4623 ulBwp->pucch_Config = NULLP;
4624 DU_ALLOC(ulBwp->pucch_Config, sizeof(struct BWP_UplinkDedicated__pucch_Config));
4625 if(!ulBwp->pucch_Config)
4627 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4631 ulBwp->pucch_Config->present = BWP_UplinkDedicated__pucch_Config_PR_setup;
4632 ulBwp->pucch_Config->choice.setup = NULLP;
4633 DU_ALLOC(ulBwp->pucch_Config->choice.setup, sizeof(PUCCH_Config_t));
4634 if(!ulBwp->pucch_Config->choice.setup)
4636 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4640 if(BuildBWPUlDedPucchCfg(ulBwp->pucch_Config->choice.setup) != ROK)
4645 /* Fill BWP UL dedicated PUSCH config */
4646 ulBwp->pusch_Config = NULLP;
4647 DU_ALLOC(ulBwp->pusch_Config, sizeof(struct BWP_UplinkDedicated__pusch_Config));
4648 if(!ulBwp->pusch_Config)
4650 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4654 ulBwp->pusch_Config->present = BWP_UplinkDedicated__pusch_Config_PR_setup;
4655 ulBwp->pusch_Config->choice.setup = NULLP;
4656 DU_ALLOC(ulBwp->pusch_Config->choice.setup, sizeof(PUSCH_Config_t));
4657 if(!ulBwp->pusch_Config->choice.setup)
4659 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4663 if(BuildBWPUlDedPuschCfg(ulBwp->pusch_Config->choice.setup) != ROK)
4668 ulBwp->configuredGrantConfig = NULLP;
4670 /* Fill BPW UL dedicated SRS config */
4671 ulBwp->srs_Config = NULLP;
4672 DU_ALLOC(ulBwp->srs_Config, sizeof(struct BWP_UplinkDedicated__srs_Config));
4673 if(!ulBwp->srs_Config)
4675 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4679 ulBwp->srs_Config->present = BWP_UplinkDedicated__srs_Config_PR_setup;
4680 ulBwp->srs_Config->choice.setup = NULLP;
4681 DU_ALLOC(ulBwp->srs_Config->choice.setup, sizeof(SRS_Config_t));
4682 if(!ulBwp->srs_Config->choice.setup)
4684 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4688 if(BuildBWPUlDedSrsCfg(ulBwp->srs_Config->choice.setup) != ROK)
4693 ulBwp->beamFailureRecoveryConfig = NULLP;
4698 /*******************************************************************
4700 * @brief Builds UL config
4703 * Function : BuildUlCfg
4705 * Functionality: Builds UL config in spCellCfgDed
4707 * @params[in] UplinkConfig_t *ulCfg
4709 * @return ROK - success
4712 * ****************************************************************/
4713 uint8_t BuildUlCfg(UplinkConfig_t *ulCfg)
4715 ulCfg->initialUplinkBWP = NULLP;
4716 DU_ALLOC(ulCfg->initialUplinkBWP, sizeof(BWP_UplinkDedicated_t));
4717 if(!ulCfg->initialUplinkBWP)
4719 DU_LOG("\nERROR --> F1AP : Memory Allocation failed in BuildUlCfg");
4723 if(BuildInitialUlBWP(ulCfg->initialUplinkBWP) != ROK)
4728 ulCfg->uplinkBWP_ToReleaseList = NULLP;
4729 ulCfg->uplinkBWP_ToAddModList = NULLP;
4730 ulCfg->firstActiveUplinkBWP_Id = NULLP;
4731 DU_ALLOC(ulCfg->firstActiveUplinkBWP_Id, sizeof(BWP_Id_t));
4732 if(!ulCfg->firstActiveUplinkBWP_Id)
4734 DU_LOG("\nERROR --> F1AP : Memory Allocation failed in BuildUlCfg");
4737 *(ulCfg->firstActiveUplinkBWP_Id) = ACTIVE_UL_BWP_ID;
4739 ulCfg->pusch_ServingCellConfig = NULLP;
4740 DU_ALLOC(ulCfg->pusch_ServingCellConfig, \
4741 sizeof(struct UplinkConfig__pusch_ServingCellConfig));
4742 if(!ulCfg->pusch_ServingCellConfig)
4744 DU_LOG("\nERROR --> F1AP : Memory Allocation failed in BuildUlCfg");
4748 if(BuildPuschSrvCellCfg(ulCfg->pusch_ServingCellConfig) != ROK)
4753 ulCfg->carrierSwitching = NULLP;
4754 ulCfg->ext1 = NULLP;
4758 /*******************************************************************
4760 * @brief Builds PDSCH serving cell config
4763 * Function : BuildPdschSrvCellCfg
4765 * Functionality: Builds PDSCH serving cell config in spCellCfgDed
4767 * @params[in] struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg
4769 * @return ROK - success
4772 * ****************************************************************/
4773 uint8_t BuildPdschSrvCellCfg(struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg)
4775 pdschCfg->present = ServingCellConfig__pdsch_ServingCellConfig_PR_setup;
4776 pdschCfg->choice.setup = NULLP;
4777 DU_ALLOC(pdschCfg->choice.setup, sizeof( struct PDSCH_ServingCellConfig));
4778 if(!pdschCfg->choice.setup)
4780 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
4784 pdschCfg->choice.setup->codeBlockGroupTransmission = NULLP;
4785 pdschCfg->choice.setup->xOverhead = NULLP;
4786 pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH = NULLP;
4787 DU_ALLOC(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH, sizeof(long));
4788 if(!pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH)
4790 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
4793 *(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH)= PDSCH_NUM_HARQ_PROC;
4794 pdschCfg->choice.setup->pucch_Cell = NULLP;
4795 pdschCfg->choice.setup->ext1 = NULLP;
4800 /*******************************************************************
4802 * @brief Builds CSI Meas config
4805 * Function : BuildCsiMeasCfg
4807 * Functionality: Builds CSI Meas config in spCellCfgDed
4809 * @params[in] struct ServingCellConfig__csi_MeasConfig *csiMeasCfg
4811 * @return ROK - success
4814 * ****************************************************************/
4815 uint8_t BuildCsiMeasCfg(struct ServingCellConfig__csi_MeasConfig *csiMeasCfg)
4821 /*******************************************************************
4823 * @brief Builds Spcell config dedicated
4826 * Function : BuildSpCellCfgDed
4828 * Functionality: Builds sp cell config dedicated in spCellCfg
4830 * @params[in] ServingCellConfig_t srvCellCfg
4832 * @return ROK - success
4835 * ****************************************************************/
4836 uint8_t BuildSpCellCfgDed(ServingCellConfig_t *srvCellCfg)
4838 srvCellCfg->tdd_UL_DL_ConfigurationDedicated = NULLP;
4839 DU_ALLOC(srvCellCfg->tdd_UL_DL_ConfigurationDedicated, sizeof(TDD_UL_DL_ConfigDedicated_t));
4840 if(!srvCellCfg->tdd_UL_DL_ConfigurationDedicated)
4842 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4846 srvCellCfg->initialDownlinkBWP = NULLP;
4847 DU_ALLOC(srvCellCfg->initialDownlinkBWP, sizeof(BWP_DownlinkDedicated_t));
4848 if(!srvCellCfg->initialDownlinkBWP)
4850 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4854 if(BuildInitialDlBWP(srvCellCfg->initialDownlinkBWP) != ROK)
4856 DU_LOG("\nERROR --> F1AP : BuildInitialDlBWP failed");
4859 srvCellCfg->downlinkBWP_ToReleaseList = NULLP;
4860 srvCellCfg->downlinkBWP_ToAddModList = NULLP;
4862 srvCellCfg->firstActiveDownlinkBWP_Id = NULLP;
4863 DU_ALLOC(srvCellCfg->firstActiveDownlinkBWP_Id, sizeof(long));
4864 if(!srvCellCfg->firstActiveDownlinkBWP_Id)
4866 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4869 *(srvCellCfg->firstActiveDownlinkBWP_Id) = ACTIVE_DL_BWP_ID;
4871 srvCellCfg->bwp_InactivityTimer = NULLP;
4873 srvCellCfg->defaultDownlinkBWP_Id = NULLP;
4874 DU_ALLOC(srvCellCfg->defaultDownlinkBWP_Id, sizeof(long));
4875 if(!srvCellCfg->defaultDownlinkBWP_Id)
4877 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4880 *(srvCellCfg->defaultDownlinkBWP_Id) = ACTIVE_DL_BWP_ID;
4882 srvCellCfg->uplinkConfig = NULLP;
4883 DU_ALLOC(srvCellCfg->uplinkConfig, sizeof(UplinkConfig_t));
4884 if(!srvCellCfg->uplinkConfig)
4886 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4890 if(BuildUlCfg(srvCellCfg->uplinkConfig) != ROK)
4892 DU_LOG("\nERROR --> F1AP : BuildUlCfg failed");
4895 srvCellCfg->supplementaryUplink = NULLP;
4896 srvCellCfg->pdcch_ServingCellConfig = NULLP;
4898 srvCellCfg->pdsch_ServingCellConfig = NULLP;
4899 DU_ALLOC(srvCellCfg->pdsch_ServingCellConfig, sizeof(struct ServingCellConfig__pdsch_ServingCellConfig));
4900 if(!srvCellCfg->pdsch_ServingCellConfig)
4902 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4906 if(BuildPdschSrvCellCfg(srvCellCfg->pdsch_ServingCellConfig) != ROK)
4908 DU_LOG("\nERROR --> F1AP : BuildPdschSrvCellCfg failed");
4912 srvCellCfg->csi_MeasConfig = NULLP;
4914 DU_ALLOC(srvCellCfg->csi_MeasConfig, sizeof(struct ServingCellConfig__csi_MeasConfig))
4915 if(!srvCellCfg->csi_MeasConfig)
4917 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4921 if(BuildCsiMeasCfg(srvCellCfg->csi_MeasConfig) != ROK)
4923 DU_LOG("\nF1AP : BuildCsiMeasCfg failed");
4927 srvCellCfg->sCellDeactivationTimer = NULLP;
4928 srvCellCfg->crossCarrierSchedulingConfig = NULLP;
4929 srvCellCfg->tag_Id = TAG_ID;
4930 srvCellCfg->dummy = NULLP;
4931 srvCellCfg->pathlossReferenceLinking = NULLP;
4932 srvCellCfg->servingCellMO = NULLP;
4933 srvCellCfg->ext1 = NULLP;
4937 /*******************************************************************
4939 * @brief Builds Spcell config
4943 * Function : BuildSpCellCfg
4945 * Functionality: Builds sp cell config in DuToCuRrcContainer
4947 * @params[in] SpCellConfig_t spCellCfg
4949 * @return ROK - success
4952 * ****************************************************************/
4953 uint8_t BuildSpCellCfg(SpCellConfig_t *spCellCfg)
4956 spCellCfg->servCellIndex = NULLP;
4957 DU_ALLOC(spCellCfg->servCellIndex, sizeof(long));
4958 if(!spCellCfg->servCellIndex)
4960 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
4963 *(spCellCfg->servCellIndex) = SERV_CELL_IDX;
4965 spCellCfg->reconfigurationWithSync = NULLP;
4966 spCellCfg->rlf_TimersAndConstants = NULLP;
4967 spCellCfg->rlmInSyncOutOfSyncThreshold = NULLP;
4968 DU_ALLOC(spCellCfg->rlmInSyncOutOfSyncThreshold, sizeof(long));
4969 if(!spCellCfg->rlmInSyncOutOfSyncThreshold)
4971 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
4974 *(spCellCfg->rlmInSyncOutOfSyncThreshold) = RLM_SYNC_OUT_SYNC_THRESHOLD;
4976 spCellCfg->spCellConfigDedicated = NULLP;
4977 DU_ALLOC(spCellCfg->spCellConfigDedicated, sizeof(ServingCellConfig_t));
4978 if(!spCellCfg->spCellConfigDedicated)
4980 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
4983 if(BuildSpCellCfgDed(spCellCfg->spCellConfigDedicated) != ROK)
4985 DU_LOG("\nERROR --> F1AP : BuildSpCellCfgDed failed");
4990 /*******************************************************************
4992 * @brief Builds Phy cell group config
4996 * Function : BuildPhyCellGrpCfg
4998 * Functionality: Builds Phy cell group config in DuToCuRrcContainer
5000 * @params[in] PhysicalCellGroupConfig_t *phyCellGrpCfg
5002 * @return ROK - success
5005 * ****************************************************************/
5006 uint8_t BuildPhyCellGrpCfg(PhysicalCellGroupConfig_t *phyCellGrpCfg)
5008 phyCellGrpCfg->harq_ACK_SpatialBundlingPUCCH = NULLP;
5009 phyCellGrpCfg->harq_ACK_SpatialBundlingPUSCH = NULLP;
5011 phyCellGrpCfg->p_NR_FR1 = NULLP;
5012 DU_ALLOC(phyCellGrpCfg->p_NR_FR1, sizeof(long));
5013 if(!phyCellGrpCfg->p_NR_FR1)
5015 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildPhyCellGrpCfg");
5018 *(phyCellGrpCfg->p_NR_FR1) = P_NR_FR1;
5019 phyCellGrpCfg->pdsch_HARQ_ACK_Codebook = PDSCH_HARQ_ACK_CODEBOOK;
5020 phyCellGrpCfg->tpc_SRS_RNTI = NULLP;
5021 phyCellGrpCfg->tpc_PUCCH_RNTI = NULLP;
5022 phyCellGrpCfg->tpc_PUSCH_RNTI = NULLP;
5023 phyCellGrpCfg->sp_CSI_RNTI = NULLP;
5024 phyCellGrpCfg->cs_RNTI = NULLP;
5025 phyCellGrpCfg->ext1 = NULLP;
5026 phyCellGrpCfg->ext2 = NULLP;
5030 /*******************************************************************
5032 * @brief Builds Mac cell group config
5036 * Function : BuildMacCellGrpCfg
5038 * Functionality: Builds Mac cell group config in DuToCuRrcContainer
5040 * @params[in] MAC_CellGroupConfig_t *macCellGrpCfg
5042 * @return ROK - success
5045 * ****************************************************************/
5046 uint8_t BuildMacCellGrpCfg(MAC_CellGroupConfig_t *macCellGrpCfg)
5048 macCellGrpCfg->drx_Config = NULLP;
5049 macCellGrpCfg->schedulingRequestConfig = NULLP;
5050 DU_ALLOC(macCellGrpCfg->schedulingRequestConfig, sizeof(struct SchedulingRequestConfig));
5051 if(!macCellGrpCfg->schedulingRequestConfig)
5053 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
5057 if(BuildSchedulingReqConfig(macCellGrpCfg->schedulingRequestConfig) != ROK)
5059 DU_LOG("\nERROR --> F1AP : BuildSchedulingReqConfig failed");
5063 macCellGrpCfg->bsr_Config = NULLP;
5064 DU_ALLOC(macCellGrpCfg->bsr_Config, sizeof(struct BSR_Config));
5065 if(!macCellGrpCfg->bsr_Config)
5067 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
5071 if(BuildBsrConfig(macCellGrpCfg->bsr_Config) != ROK)
5073 DU_LOG("\nERROR --> F1AP : BuildBsrConfig failed");
5077 macCellGrpCfg->tag_Config = NULLP;
5078 DU_ALLOC(macCellGrpCfg->tag_Config, sizeof(struct TAG_Config));
5079 if(!macCellGrpCfg->tag_Config)
5081 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
5085 if(BuildTagConfig(macCellGrpCfg->tag_Config) != ROK)
5087 DU_LOG("\nERROR --> F1AP : BuildTagConfig failed");
5091 macCellGrpCfg->phr_Config = NULLP;
5092 DU_ALLOC(macCellGrpCfg->phr_Config, sizeof(struct MAC_CellGroupConfig__phr_Config));
5093 if(!macCellGrpCfg->phr_Config)
5095 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
5099 if(BuildPhrConfig(macCellGrpCfg->phr_Config) != ROK)
5101 DU_LOG("\nERROR --> F1AP : BuildPhrConfig failed");
5105 macCellGrpCfg->skipUplinkTxDynamic = false;
5106 macCellGrpCfg->ext1 = NULLP;
5110 /*******************************************************************
5112 * @brief Frees memeory allocated for SearchSpcToAddModList
5116 * Function : FreeSearchSpcToAddModList
5118 * Functionality: Deallocating memory of SearchSpcToAddModList
5120 * @params[in] struct PDCCH_Config__searchSpacesToAddModList *searchSpcList
5124 4221 * ****************************************************************/
5125 void FreeSearchSpcToAddModList(struct PDCCH_Config__searchSpacesToAddModList *searchSpcList)
5129 struct SearchSpace *searchSpc=NULLP;
5131 if(searchSpcList->list.array)
5133 if(searchSpcList->list.array[idx2])
5135 searchSpc = searchSpcList->list.array[idx2];
5136 if(searchSpc->controlResourceSetId)
5138 if(searchSpc->monitoringSlotPeriodicityAndOffset)
5140 if(searchSpc->monitoringSymbolsWithinSlot)
5142 if(searchSpc->monitoringSymbolsWithinSlot->buf)
5144 if(searchSpc->nrofCandidates)
5146 if(searchSpc->searchSpaceType)
5148 DU_FREE(searchSpc->searchSpaceType->choice.ue_Specific,\
5149 sizeof(struct SearchSpace__searchSpaceType__ue_Specific));
5150 DU_FREE(searchSpc->searchSpaceType, sizeof(struct
5151 SearchSpace__searchSpaceType));
5153 DU_FREE(searchSpc->nrofCandidates,
5154 sizeof(struct SearchSpace__nrofCandidates));
5156 DU_FREE(searchSpc->monitoringSymbolsWithinSlot->buf, \
5157 searchSpc->monitoringSymbolsWithinSlot->size);
5159 DU_FREE(searchSpc->monitoringSymbolsWithinSlot,
5160 sizeof(BIT_STRING_t));
5162 DU_FREE(searchSpc->monitoringSlotPeriodicityAndOffset, \
5163 sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
5165 DU_FREE(searchSpc->controlResourceSetId,
5166 sizeof(ControlResourceSetId_t));
5169 for(idx1 = 0; idx1 < searchSpcList->list.count; idx1++)
5171 DU_FREE(searchSpcList->list.array[idx1],
5172 sizeof(struct SearchSpace));
5174 DU_FREE(searchSpcList->list.array,searchSpcList->list.size);
5177 /*******************************************************************
5179 * @brief Frees memory allocated for PdschTimeDomAllocList
5183 * Function : FreePdschTimeDomAllocList
5185 * Functionality: Deallocating memory of PdschTimeDomAllocList
5187 * @params[in] struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
5191 * ****************************************************************/
5192 void FreePdschTimeDomAllocList( struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList)
5196 if(timeDomAllocList->choice.setup)
5198 if(timeDomAllocList->choice.setup->list.array)
5200 for(idx1 = 0; idx1 <timeDomAllocList->choice.setup->list.count ; idx1++)
5202 DU_FREE(timeDomAllocList->choice.setup->list.array[idx1]->k0, sizeof(long));
5203 DU_FREE(timeDomAllocList->choice.setup->list.array[idx1],
5204 sizeof(struct PDSCH_TimeDomainResourceAllocation));
5206 DU_FREE(timeDomAllocList->choice.setup->list.array, \
5207 timeDomAllocList->choice.setup->list.size);
5209 DU_FREE(timeDomAllocList->choice.setup,\
5210 sizeof(struct PDSCH_TimeDomainResourceAllocationList));
5213 /*******************************************************************
5215 * @brief Frees memory allocated for PuschTimeDomAllocList
5219 * Function : FreePuschTimeDomAllocList
5221 * Functionality: Deallocating memory of PuschTimeDomAllocList
5223 * @params[in] PUSCH_Config_t *puschCfg
5227 * ****************************************************************/
5228 void FreePuschTimeDomAllocList(PUSCH_Config_t *puschCfg)
5232 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList_t=NULLP;
5234 if(puschCfg->pusch_TimeDomainAllocationList)
5236 timeDomAllocList_t=puschCfg->pusch_TimeDomainAllocationList;
5237 if(timeDomAllocList_t->choice.setup)
5239 if(timeDomAllocList_t->choice.setup->list.array)
5241 DU_FREE(timeDomAllocList_t->choice.setup->list.array[idx2]->k2, sizeof(long));
5242 for(idx1 = 0; idx1<timeDomAllocList_t->choice.setup->list.count; idx1++)
5244 DU_FREE(timeDomAllocList_t->choice.setup->list.array[idx1],\
5245 sizeof(PUSCH_TimeDomainResourceAllocation_t));
5247 DU_FREE(timeDomAllocList_t->choice.setup->list.array, \
5248 timeDomAllocList_t->choice.setup->list.size);
5250 DU_FREE(timeDomAllocList_t->choice.setup, \
5251 sizeof(struct PUSCH_TimeDomainResourceAllocationList));
5253 DU_FREE(puschCfg->transformPrecoder, sizeof(long));
5254 DU_FREE(puschCfg->pusch_TimeDomainAllocationList, \
5255 sizeof(struct PUSCH_Config__pusch_TimeDomainAllocationList));
5259 /*******************************************************************
5261 * @brief Frees memory allocated for InitialUlBWP
5265 * Function : FreeInitialUlBWP
5267 * Functionality: Deallocating memory of InitialUlBWP
5269 * @params[in] BWP_UplinkDedicated_t *ulBwp
5273 * ****************************************************************/
5274 void FreeInitialUlBWP(BWP_UplinkDedicated_t *ulBwp)
5276 uint8_t rSetIdx, rsrcIdx, k1Idx;
5277 SRS_Config_t *srsCfg = NULLP;
5278 PUSCH_Config_t *puschCfg = NULLP;
5279 PUCCH_Config_t *pucchCfg = NULLP;
5280 struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg = NULLP;
5281 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList = NULLP;
5282 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList = NULLP;
5283 struct SRS_Config__srs_ResourceToAddModList *resourceList = NULLP;
5285 if(ulBwp->pucch_Config)
5287 if(ulBwp->pucch_Config->choice.setup)
5289 pucchCfg = ulBwp->pucch_Config->choice.setup;
5290 if(pucchCfg->dl_DataToUL_ACK)
5292 if(pucchCfg->dl_DataToUL_ACK->list.array)
5294 for(k1Idx = 0; k1Idx < pucchCfg->dl_DataToUL_ACK->list.count; k1Idx++)
5296 DU_FREE(pucchCfg->dl_DataToUL_ACK->list.array[k1Idx], sizeof(long));
5298 DU_FREE(pucchCfg->dl_DataToUL_ACK->list.array, pucchCfg->dl_DataToUL_ACK->list.size);
5300 DU_FREE(pucchCfg->dl_DataToUL_ACK, sizeof(struct PUCCH_Config__dl_DataToUL_ACK));
5302 DU_FREE(ulBwp->pucch_Config->choice.setup, sizeof(PUCCH_Config_t));
5304 DU_FREE(ulBwp->pucch_Config, sizeof(struct BWP_UplinkDedicated__pucch_Config));
5307 if(ulBwp->pusch_Config)
5309 if(ulBwp->pusch_Config->choice.setup)
5311 puschCfg=ulBwp->pusch_Config->choice.setup;
5312 if(puschCfg->dataScramblingIdentityPUSCH)
5314 if(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
5316 FreePuschTimeDomAllocList(puschCfg);
5317 dmrsUlCfg=puschCfg->dmrs_UplinkForPUSCH_MappingTypeA;
5318 if(dmrsUlCfg->choice.setup)
5320 if(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
5322 if(dmrsUlCfg->choice.setup->transformPrecodingDisabled)
5324 DU_FREE(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0,\
5326 DU_FREE(dmrsUlCfg->choice.setup->transformPrecodingDisabled,
5327 sizeof(struct DMRS_UplinkConfig__transformPrecodingDisabled));
5329 DU_FREE(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition,
5332 DU_FREE(dmrsUlCfg->choice.setup,sizeof(DMRS_UplinkConfig_t));
5334 DU_FREE(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA, \
5335 sizeof(struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA));
5337 DU_FREE(puschCfg->dataScramblingIdentityPUSCH, sizeof(long));
5339 DU_FREE(ulBwp->pusch_Config->choice.setup, sizeof(PUSCH_Config_t));
5341 DU_FREE(ulBwp->pusch_Config, sizeof(struct BWP_UplinkDedicated__pusch_Config));
5343 /* Free SRS-Config */
5344 if(ulBwp->srs_Config)
5346 if(ulBwp->srs_Config->choice.setup)
5348 srsCfg = ulBwp->srs_Config->choice.setup;
5350 /* Free Resource Set to add/mod list */
5351 if(srsCfg->srs_ResourceSetToAddModList)
5353 rsrcSetList = srsCfg->srs_ResourceSetToAddModList;
5354 if(rsrcSetList->list.array)
5358 /* Free SRS resource Id list in this SRS resource set */
5359 if(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
5361 rsrcIdList = rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
5363 if(rsrcIdList->list.array)
5365 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count; rsrcIdx++)
5367 DU_FREE(rsrcIdList->list.array[rsrcIdx], sizeof(SRS_ResourceId_t));
5369 DU_FREE(rsrcIdList->list.array, rsrcIdList->list.size);
5371 DU_FREE(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList,\
5372 sizeof(struct SRS_ResourceSet__srs_ResourceIdList));
5375 /* Free resource type info for this SRS resource set */
5376 DU_FREE(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic, \
5377 sizeof(struct SRS_ResourceSet__resourceType__aperiodic));
5379 /* Free memory for each resource set */
5380 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
5382 DU_FREE(rsrcSetList->list.array[rSetIdx], sizeof(SRS_ResourceSet_t));
5384 DU_FREE(rsrcSetList->list.array, rsrcSetList->list.size);
5386 DU_FREE(srsCfg->srs_ResourceSetToAddModList, \
5387 sizeof(struct SRS_Config__srs_ResourceSetToAddModList));
5390 /* Free resource to add/modd list */
5391 if(srsCfg->srs_ResourceToAddModList)
5393 resourceList = srsCfg->srs_ResourceToAddModList;
5394 if(resourceList->list.array)
5397 DU_FREE(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2,\
5398 sizeof(struct SRS_Resource__transmissionComb__n2));
5399 DU_FREE(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic,\
5400 sizeof(struct SRS_Resource__resourceType__aperiodic));
5402 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
5404 DU_FREE(resourceList->list.array[rsrcIdx], sizeof(SRS_Resource_t));
5406 DU_FREE(resourceList->list.array, resourceList->list.size);
5408 DU_FREE(srsCfg->srs_ResourceToAddModList, \
5409 sizeof(struct SRS_Config__srs_ResourceToAddModList));
5412 DU_FREE(ulBwp->srs_Config->choice.setup, sizeof(SRS_Config_t));
5414 DU_FREE(ulBwp->srs_Config, sizeof(struct BWP_UplinkDedicated__srs_Config));
5418 /*******************************************************************
5420 * @brief Frees memory allocated for initialUplinkBWP
5424 * Function : FreeinitialUplinkBWP
5426 * Functionality: Deallocating memory of initialUplinkBWP
5428 * @params[in] UplinkConfig_t *ulCfg
5433 * ****************************************************************/
5434 void FreeinitialUplinkBWP(UplinkConfig_t *ulCfg)
5436 BWP_UplinkDedicated_t *ulBwp=NULLP;
5437 struct UplinkConfig__pusch_ServingCellConfig *puschCfg=NULLP;
5439 if(ulCfg->initialUplinkBWP)
5441 ulBwp=ulCfg->initialUplinkBWP;
5442 if(ulCfg->firstActiveUplinkBWP_Id)
5444 if(ulCfg->pusch_ServingCellConfig)
5446 puschCfg=ulCfg->pusch_ServingCellConfig;
5447 if(puschCfg->choice.setup)
5449 if(puschCfg->choice.setup->ext1)
5451 DU_FREE(puschCfg->choice.setup->ext1->\
5452 processingType2Enabled,sizeof(BOOLEAN_t));
5453 DU_FREE(puschCfg->choice.setup->ext1->\
5454 maxMIMO_Layers,sizeof(long));
5455 DU_FREE(puschCfg->choice.setup->ext1, \
5456 sizeof(struct PUSCH_ServingCellConfig__ext1));
5458 DU_FREE(puschCfg->choice.setup, sizeof(struct PUSCH_ServingCellConfig));
5460 DU_FREE(ulCfg->pusch_ServingCellConfig, sizeof(struct UplinkConfig__pusch_ServingCellConfig));
5462 DU_FREE(ulCfg->firstActiveUplinkBWP_Id, sizeof(BWP_Id_t));
5464 FreeInitialUlBWP(ulBwp);
5465 DU_FREE(ulCfg->initialUplinkBWP, sizeof(BWP_UplinkDedicated_t));
5468 /*******************************************************************
5470 * @brief Frees emmory allocated for BWPDlDedPdschCfg
5474 * Function : FreeBWPDlDedPdschCfg
5476 * Functionality: Deallocating memory of BWPDlDedPdschCfg
5478 * @params[in] BWP_DownlinkDedicated_t *dlBwp
5483 * ****************************************************************/
5484 void FreeBWPDlDedPdschCfg(BWP_DownlinkDedicated_t *dlBwp)
5486 struct PDSCH_Config *pdschCfg=NULLP;
5487 struct PDSCH_Config__prb_BundlingType *prbBndlType=NULLP;
5488 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList=NULLP;
5489 struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg=NULLP;
5491 if(dlBwp->pdsch_Config->choice.setup)
5493 pdschCfg=dlBwp->pdsch_Config->choice.setup;
5494 if(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
5496 if(pdschCfg->pdsch_TimeDomainAllocationList)
5498 timeDomAllocList=pdschCfg->pdsch_TimeDomainAllocationList;
5499 if(pdschCfg->maxNrofCodeWordsScheduledByDCI)
5501 prbBndlType=&pdschCfg->prb_BundlingType;
5502 DU_FREE(prbBndlType->choice.staticBundling,\
5503 sizeof(struct PDSCH_Config__prb_BundlingType__staticBundling));
5504 DU_FREE(pdschCfg->maxNrofCodeWordsScheduledByDCI, sizeof(long));
5506 FreePdschTimeDomAllocList(timeDomAllocList);
5507 DU_FREE(pdschCfg->pdsch_TimeDomainAllocationList, \
5508 sizeof(struct PDSCH_Config__pdsch_TimeDomainAllocationList));
5510 dmrsDlCfg=pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA;
5511 if(dmrsDlCfg->choice.setup)
5513 DU_FREE(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition,
5515 DU_FREE(dmrsDlCfg->choice.setup, sizeof(struct DMRS_DownlinkConfig));
5517 DU_FREE(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA, \
5518 sizeof(struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA));
5520 DU_FREE(dlBwp->pdsch_Config->choice.setup, sizeof(struct PDSCH_Config));
5523 /*******************************************************************
5525 * @brief Frees emmory allocated for BWPDlDedPdcchCfg
5529 * Function : FreeBWPDlDedPdcchCfg
5531 * Functionality: Deallocating memory of BWPDlDedPdcchCfg
5533 * @params[in] BWP_DownlinkDedicated_t *dlBwp
5538 * ****************************************************************/
5539 void FreeBWPDlDedPdcchCfg(BWP_DownlinkDedicated_t *dlBwp)
5543 struct PDCCH_Config *pdcchCfg=NULLP;
5544 struct ControlResourceSet *controlRSet=NULLP;
5545 struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList=NULLP;
5547 if(dlBwp->pdcch_Config->choice.setup)
5549 pdcchCfg=dlBwp->pdcch_Config->choice.setup;
5550 if(pdcchCfg->controlResourceSetToAddModList)
5552 controlRSetList = pdcchCfg->controlResourceSetToAddModList;
5553 if(controlRSetList->list.array)
5555 controlRSet = controlRSetList->list.array[idx2];
5558 if(controlRSet->frequencyDomainResources.buf)
5560 if(controlRSet->pdcch_DMRS_ScramblingID)
5562 if(pdcchCfg->searchSpacesToAddModList)
5564 FreeSearchSpcToAddModList(pdcchCfg->searchSpacesToAddModList);
5565 DU_FREE(pdcchCfg->searchSpacesToAddModList, \
5566 sizeof(struct PDCCH_Config__searchSpacesToAddModList));
5568 DU_FREE(controlRSet->pdcch_DMRS_ScramblingID, sizeof(long));
5570 DU_FREE(controlRSet->frequencyDomainResources.buf, \
5571 controlRSet->frequencyDomainResources.size);
5574 for(idx1 = 0; idx1 <controlRSetList->list.count; idx1++)
5576 DU_FREE(controlRSetList->list.array[idx1], sizeof(struct ControlResourceSet));
5578 DU_FREE(controlRSetList->list.array, controlRSetList->list.size);
5580 DU_FREE(pdcchCfg->controlResourceSetToAddModList, \
5581 sizeof(struct PDCCH_Config__controlResourceSetToAddModList));
5583 DU_FREE(dlBwp->pdcch_Config->choice.setup, sizeof(struct PDCCH_Config));
5587 /*******************************************************************
5589 * @brief Frees emmory allocated for DUToCURRCContainer
5593 * Function : FreeMemDuToCuRrcCont
5595 * Functionality: Deallocating memory of DuToCuRrcContainer
5597 * @params[in] DuToCuRRCContainer, DuToCuRRCContainer
5599 * @return ROK - success
5602 * ****************************************************************/
5603 uint8_t FreeMemDuToCuRrcCont(CellGroupConfigRrc_t *cellGrpCfg)
5606 SpCellConfig_t *spCellCfg=NULLP;
5607 ServingCellConfig_t *srvCellCfg=NULLP;
5608 BWP_DownlinkDedicated_t *dlBwp=NULLP;
5609 MAC_CellGroupConfig_t *macCellGrpCfg=NULLP;
5610 PhysicalCellGroupConfig_t *phyCellGrpCfg=NULLP;
5611 struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList=NULLP;
5612 struct RLC_Config *rlcConfig=NULLP;
5613 struct LogicalChannelConfig *macLcConfig=NULLP;
5614 struct SchedulingRequestConfig *schedulingRequestConfig=NULLP;
5615 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList=NULLP;
5616 struct TAG_Config *tagConfig=NULLP;
5617 struct TAG_Config__tag_ToAddModList *tagList=NULLP;
5618 struct MAC_CellGroupConfig__phr_Config *phrConfig=NULLP;
5619 struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg=NULLP;
5621 rlcBearerList = cellGrpCfg->rlc_BearerToAddModList;
5624 if(rlcBearerList->list.array)
5626 for(idx=0; idx<rlcBearerList->list.count; idx++)
5628 if(rlcBearerList->list.array[idx])
5630 rlcConfig = rlcBearerList->list.array[idx]->rlc_Config;
5631 macLcConfig = rlcBearerList->list.array[idx]->mac_LogicalChannelConfig;
5634 if(rlcConfig->choice.am)
5636 DU_FREE(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
5637 DU_FREE(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
5638 DU_FREE(rlcConfig->choice.am, sizeof(struct RLC_Config__am));
5640 DU_FREE(rlcConfig, sizeof(struct RLC_Config));
5642 DU_FREE(rlcBearerList->list.array[idx]->servedRadioBearer, sizeof(struct RLC_BearerConfig__servedRadioBearer));
5645 if(macLcConfig->ul_SpecificParameters)
5647 DU_FREE(macLcConfig->ul_SpecificParameters->schedulingRequestID, sizeof(SchedulingRequestId_t));
5648 DU_FREE(macLcConfig->ul_SpecificParameters->logicalChannelGroup, sizeof(long));
5649 DU_FREE(macLcConfig->ul_SpecificParameters, sizeof(struct LogicalChannelConfig__ul_SpecificParameters));
5651 DU_FREE(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig, sizeof(struct LogicalChannelConfig));
5653 DU_FREE(rlcBearerList->list.array[idx], sizeof(struct RLC_BearerConfig));
5656 DU_FREE(rlcBearerList->list.array, rlcBearerList->list.size);
5658 DU_FREE(cellGrpCfg->rlc_BearerToAddModList, sizeof(struct CellGroupConfigRrc__rlc_BearerToAddModList));
5661 macCellGrpCfg = cellGrpCfg->mac_CellGroupConfig;
5664 schedulingRequestConfig = macCellGrpCfg->schedulingRequestConfig;
5665 if(schedulingRequestConfig)
5667 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
5670 if(schReqList->list.array)
5672 for(idx=0;idx<schReqList->list.count; idx++)
5674 if(schReqList->list.array[idx])
5676 DU_FREE(schReqList->list.array[idx]->sr_ProhibitTimer, sizeof(long));
5677 DU_FREE(schReqList->list.array[idx], sizeof(struct SchedulingRequestToAddMod));
5680 DU_FREE(schReqList->list.array, schReqList->list.size);
5682 DU_FREE(schedulingRequestConfig->schedulingRequestToAddModList,\
5683 sizeof(struct SchedulingRequestConfig__schedulingRequestToAddModList)); }
5684 DU_FREE(macCellGrpCfg->schedulingRequestConfig, sizeof(struct SchedulingRequestConfig));
5686 if(macCellGrpCfg->bsr_Config)
5688 DU_FREE(macCellGrpCfg->bsr_Config, sizeof(struct BSR_Config));
5690 tagConfig = macCellGrpCfg->tag_Config;
5693 tagList = tagConfig->tag_ToAddModList;
5696 if(tagList->list.array)
5698 for(idx=0; idx<tagList->list.count; idx++)
5700 DU_FREE(tagList->list.array[idx], sizeof(struct TAG));
5702 DU_FREE(tagList->list.array, tagList->list.size);
5704 DU_FREE(tagConfig->tag_ToAddModList, sizeof(struct TAG_Config__tag_ToAddModList));
5706 DU_FREE(tagConfig, sizeof(struct TAG_Config));
5709 phrConfig = macCellGrpCfg->phr_Config;
5712 DU_FREE(phrConfig->choice.setup, sizeof(struct PHR_Config));
5713 DU_FREE(phrConfig, sizeof(struct MAC_CellGroupConfig__phr_Config));
5716 DU_FREE(macCellGrpCfg, sizeof(MAC_CellGroupConfig_t));
5719 phyCellGrpCfg = cellGrpCfg->physicalCellGroupConfig;
5722 DU_FREE(phyCellGrpCfg->p_NR_FR1, sizeof(long));
5723 DU_FREE(phyCellGrpCfg, sizeof(PhysicalCellGroupConfig_t));
5726 spCellCfg = cellGrpCfg->spCellConfig;
5729 if(spCellCfg->servCellIndex)
5731 if(spCellCfg->rlmInSyncOutOfSyncThreshold)
5733 if(spCellCfg->spCellConfigDedicated)
5735 srvCellCfg = spCellCfg->spCellConfigDedicated;
5736 if(srvCellCfg->tdd_UL_DL_ConfigurationDedicated)
5738 if(srvCellCfg->initialDownlinkBWP)
5740 dlBwp = srvCellCfg->initialDownlinkBWP;
5741 if(srvCellCfg->firstActiveDownlinkBWP_Id)
5743 if(srvCellCfg->defaultDownlinkBWP_Id)
5745 if(srvCellCfg->uplinkConfig)
5747 if(srvCellCfg->pdsch_ServingCellConfig)
5749 pdschCfg= srvCellCfg->pdsch_ServingCellConfig;
5750 if(pdschCfg->choice.setup)
5752 DU_FREE(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH,sizeof(long));
5753 DU_FREE(pdschCfg->choice.setup, sizeof( struct PDSCH_ServingCellConfig));
5755 DU_FREE(srvCellCfg->pdsch_ServingCellConfig, sizeof(struct
5756 ServingCellConfig__pdsch_ServingCellConfig));
5758 FreeinitialUplinkBWP(srvCellCfg->uplinkConfig);
5759 DU_FREE(srvCellCfg->uplinkConfig, sizeof(UplinkConfig_t));
5761 DU_FREE(srvCellCfg->defaultDownlinkBWP_Id, sizeof(long));
5763 DU_FREE(srvCellCfg->firstActiveDownlinkBWP_Id, sizeof(long));
5765 if(dlBwp->pdcch_Config)
5767 if(dlBwp->pdsch_Config)
5769 FreeBWPDlDedPdschCfg(dlBwp);
5770 DU_FREE(dlBwp->pdsch_Config, sizeof(struct BWP_DownlinkDedicated__pdsch_Config));
5772 FreeBWPDlDedPdcchCfg(dlBwp);
5773 DU_FREE(dlBwp->pdcch_Config, sizeof(struct BWP_DownlinkDedicated__pdcch_Config));
5775 DU_FREE(srvCellCfg->initialDownlinkBWP, sizeof(BWP_DownlinkDedicated_t));
5777 DU_FREE(srvCellCfg->tdd_UL_DL_ConfigurationDedicated, sizeof(TDD_UL_DL_ConfigDedicated_t));
5779 DU_FREE(spCellCfg->spCellConfigDedicated, sizeof(ServingCellConfig_t));
5781 DU_FREE(spCellCfg->rlmInSyncOutOfSyncThreshold, sizeof(long));
5783 DU_FREE(spCellCfg->servCellIndex, sizeof(long));
5785 DU_FREE(spCellCfg,sizeof(SpCellConfig_t));
5789 /*******************************************************************
5791 * @brief Builds DU To CU RRC Container
5795 * Function : BuildDuToCuRrcContainer
5797 * Functionality: Builds DuToCuRrcContainer
5799 * @params[in] idx, index in F1AP msg
5800 * DuToCuRRCContainer, DuToCuRRCContainer
5802 * @return ROK - success
5805 * ****************************************************************/
5806 uint8_t BuildDuToCuRrcContainer(DUtoCURRCContainer_t *duToCuRrcContainer)
5809 CellGroupConfigRrc_t cellGrpCfg;
5810 asn_enc_rval_t encRetVal;
5811 memset(&cellGrpCfg, 0, sizeof(CellGroupConfigRrc_t));
5812 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
5816 cellGrpCfg.cellGroupId = CELL_GRP_ID;
5818 cellGrpCfg.rlc_BearerToAddModList = NULLP;
5819 DU_ALLOC(cellGrpCfg.rlc_BearerToAddModList, sizeof(struct CellGroupConfigRrc__rlc_BearerToAddModList));
5820 if(!cellGrpCfg.rlc_BearerToAddModList)
5822 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5826 if(BuildRlcBearerToAddModList(cellGrpCfg.rlc_BearerToAddModList) != ROK)
5828 DU_LOG("\nERROR --> F1AP : BuildRlcBearerToAddModList failed");
5833 cellGrpCfg.rlc_BearerToReleaseList = NULLP;
5834 cellGrpCfg.mac_CellGroupConfig = NULLP;
5835 DU_ALLOC(cellGrpCfg.mac_CellGroupConfig, sizeof(MAC_CellGroupConfig_t));
5836 if(!cellGrpCfg.mac_CellGroupConfig)
5838 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5842 if(BuildMacCellGrpCfg(cellGrpCfg.mac_CellGroupConfig) != ROK)
5844 DU_LOG("\nERROR --> F1AP : BuildMacCellGrpCfg failed");
5849 cellGrpCfg.physicalCellGroupConfig = NULLP;
5850 DU_ALLOC(cellGrpCfg.physicalCellGroupConfig, sizeof(PhysicalCellGroupConfig_t));
5851 if(!cellGrpCfg.physicalCellGroupConfig)
5853 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5857 if(BuildPhyCellGrpCfg(cellGrpCfg.physicalCellGroupConfig) != ROK)
5859 DU_LOG("\nERROR --> F1AP : BuildPhyCellGrpCfg failed");
5864 cellGrpCfg.spCellConfig = NULLP;
5865 DU_ALLOC(cellGrpCfg.spCellConfig, sizeof(SpCellConfig_t));
5866 if(!cellGrpCfg.spCellConfig)
5868 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5872 if(BuildSpCellCfg(cellGrpCfg.spCellConfig) != ROK)
5874 DU_LOG("\nERROR --> F1AP : BuildSpCellCfg failed");
5879 cellGrpCfg.sCellToAddModList = NULLP;
5880 cellGrpCfg.sCellToReleaseList = NULLP;
5881 cellGrpCfg.ext1 = NULLP;
5883 /* encode cellGrpCfg into duToCuRrcContainer */
5884 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, &cellGrpCfg);
5885 memset(encBuf, 0, ENC_BUF_MAX_LEN);
5887 encRetVal = aper_encode(&asn_DEF_CellGroupConfigRrc, 0, &cellGrpCfg, PrepFinalEncBuf, encBuf);
5888 /* Encode results */
5889 if(encRetVal.encoded == ENCODE_FAIL)
5891 DU_LOG( "\nERROR --> F1AP : Could not encode DuToCuRrcContainer (at %s)\n",\
5892 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
5898 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for DuToCuRrcContainer\n");
5899 for(int i=0; i< encBufSize; i++)
5901 printf("%x",encBuf[i]);
5905 duToCuRrcContainer->size = encBufSize;
5906 DU_ALLOC(duToCuRrcContainer->buf, duToCuRrcContainer->size);
5907 if(!duToCuRrcContainer->buf)
5909 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDuToCuRrcContainer");
5915 memcpy(duToCuRrcContainer->buf, encBuf, duToCuRrcContainer->size);
5919 FreeMemDuToCuRrcCont(&cellGrpCfg);
5923 /*******************************************************************
5925 * @brief Free memory allocated in InitialULRRCMessage
5929 * Function : freeInitUlRrcMsgTransfer
5931 * Functionality: Free memory allocated in InitialULRRCMessage
5933 * @params[in]F1AP_PDU_t *f1apMsg)
5935 * @return ROK - success
5938 * ****************************************************************/
5940 uint8_t freeInitUlRrcMsgTransfer(F1AP_PDU_t *f1apMsg)
5942 uint8_t ieIdx, arrIdx;
5943 InitialULRRCMessageTransfer_t *initULRRCMsg=NULLP;
5947 if(f1apMsg->choice.initiatingMessage)
5949 initULRRCMsg = &f1apMsg->choice.initiatingMessage->value.\
5950 choice.InitialULRRCMessageTransfer;
5951 if(initULRRCMsg->protocolIEs.list.array)
5953 for(ieIdx = 0; ieIdx < initULRRCMsg->protocolIEs.list.count; ieIdx++)
5955 switch(initULRRCMsg->protocolIEs.list.array[ieIdx]->id)
5957 case ProtocolIE_ID_id_NRCGI:
5959 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.buf)
5961 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.buf)
5963 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.buf,\
5964 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.size);
5966 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.buf,\
5967 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.size);
5971 case ProtocolIE_ID_id_RRCContainer:
5973 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
5975 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf,\
5976 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size);
5980 case ProtocolIE_ID_id_DUtoCURRCContainer:
5982 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.buf)
5984 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.buf,
5985 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.size);
5993 for(arrIdx = 0; arrIdx < ieIdx; arrIdx++)
5995 if(initULRRCMsg->protocolIEs.list.array[arrIdx])
5997 DU_FREE(initULRRCMsg->protocolIEs.list.array[arrIdx],\
5998 sizeof(InitialULRRCMessageTransferIEs_t));
6001 DU_FREE(initULRRCMsg->protocolIEs.list.array, initULRRCMsg->protocolIEs.list.size);
6003 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
6005 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
6009 DU_LOG("\nERROR --> DU_APP : Recevied F1ap Pdu is null at freeInitUlRrcMsgTransfer()");
6015 /*******************************************************************
6017 * @brief Builds and sends the InitialULRRCMessage
6021 * Function : BuildAndSendInitialRrcMsgTransfer
6023 * Functionality: Constructs the Initial UL RRC Message Transfer and sends
6024 * it to the CU through SCTP.
6028 * @return ROK - success
6031 * ****************************************************************/
6032 uint8_t BuildAndSendInitialRrcMsgTransfer(uint32_t gnbDuUeF1apId, uint16_t crnti,
6033 uint16_t rrcContSize, uint8_t *rrcContainer)
6038 asn_enc_rval_t encRetVal;
6039 F1AP_PDU_t *f1apMsg = NULLP;
6040 InitialULRRCMessageTransfer_t *initULRRCMsg = NULLP;
6041 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
6045 DU_LOG("\n INFO --> F1AP : Building RRC Setup Request\n");
6046 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
6047 if(f1apMsg == NULLP)
6049 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
6052 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
6053 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
6054 if(f1apMsg->choice.initiatingMessage == NULLP)
6056 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
6059 f1apMsg->choice.initiatingMessage->procedureCode =\
6060 ProcedureCode_id_InitialULRRCMessageTransfer;
6061 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
6062 f1apMsg->choice.initiatingMessage->value.present = \
6063 InitiatingMessage__value_PR_InitialULRRCMessageTransfer;
6065 &f1apMsg->choice.initiatingMessage->value.choice.InitialULRRCMessageTransfer;
6067 initULRRCMsg->protocolIEs.list.count = elementCnt;
6068 initULRRCMsg->protocolIEs.list.size = \
6069 elementCnt * sizeof(InitialULRRCMessageTransferIEs_t *);
6070 /* Initialize the F1Setup members */
6071 DU_ALLOC(initULRRCMsg->protocolIEs.list.array,initULRRCMsg->protocolIEs.list.size);
6072 if(initULRRCMsg->protocolIEs.list.array == NULLP)
6074 DU_LOG(" ERROR --> F1AP : Memory allocation for\
6075 RRCSetupRequestMessageTransferIEs failed");
6078 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
6080 DU_ALLOC(initULRRCMsg->protocolIEs.list.array[ieIdx],\
6081 sizeof(InitialULRRCMessageTransferIEs_t));
6082 if(initULRRCMsg->protocolIEs.list.array[ieIdx] == NULLP)
6088 /*GNB DU UE F1AP ID*/
6089 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6090 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
6091 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6092 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present = \
6093 InitialULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
6094 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
6099 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6100 ProtocolIE_ID_id_NRCGI;
6101 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality =Criticality_reject;
6102 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present = \
6103 InitialULRRCMessageTransferIEs__value_PR_NRCGI;
6106 BuildNrcgi(&initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI);
6114 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6115 ProtocolIE_ID_id_C_RNTI;
6116 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6117 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
6118 InitialULRRCMessageTransferIEs__value_PR_C_RNTI;
6119 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.C_RNTI = crnti;
6123 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6124 ProtocolIE_ID_id_RRCContainer;
6125 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6126 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
6127 InitialULRRCMessageTransferIEs__value_PR_RRCContainer;
6129 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size = rrcContSize;
6130 DU_ALLOC(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf,
6131 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size)
6132 if(!initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
6134 DU_LOG(" ERROR --> F1AP : Memory allocation for RRCSetupRequestMessageTransferIEs failed");
6138 memcpy(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf, rrcContainer,
6139 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size);
6142 /*DUtoCURRCContainer*/
6144 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DUtoCURRCContainer;
6145 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6146 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
6147 InitialULRRCMessageTransferIEs__value_PR_DUtoCURRCContainer;
6149 ret = BuildDuToCuRrcContainer(&initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer);
6155 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
6157 /* Encode the F1SetupRequest type as APER */
6158 memset(encBuf, 0, ENC_BUF_MAX_LEN);
6160 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
6161 /* Encode results */
6162 if(encRetVal.encoded == ENCODE_FAIL)
6164 DU_LOG( "\nERROR --> F1AP : Could not encode Initial UL RRC Message Transfer\
6165 structure (at %s)\n",encRetVal.failed_type ? \
6166 encRetVal.failed_type->name : "unknown");
6173 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for Initial UL RRC\
6174 Message transfer\n");
6175 for(int i=0; i< encBufSize; i++)
6177 printf("%x",encBuf[i]);
6181 if(sendF1APMsg() != ROK)
6183 DU_LOG("\nERROR --> F1AP : Sending Initial UL RRC Message Transfer Failed");
6189 freeInitUlRrcMsgTransfer(f1apMsg);
6191 }/* End of BuildAndSendInitialRrcMsgTransfer*/
6193 /***** UE SETUP REQUEST *****/
6195 /*******************************************************************
6197 * @brief Free Qos And Snssai Drb Info
6201 * Function : freeDrbQosAndSnssaiInfo
6203 * Functionality: Free Qos And Snssai Drb Info
6205 * @params[in] LcCfg *lcCfg,
6208 * ****************************************************************/
6209 void freeDrbQosAndSnssaiInfo(LcCfg *lcCfg)
6213 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
6217 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
6221 /******************************************************************
6223 * @brief Function to delete the RLC Lc cfg from UE APP DB
6227 * Function : freeRlcLcCfg
6229 * Functionality: Function to delete the RLC Lc cfg from UE APP DB
6232 *****************************************************************/
6234 void freeRlcLcCfg(RlcBearerCfg *lcCfg)
6236 switch(lcCfg->rlcMode)
6242 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
6246 case RLC_UM_BI_DIRECTIONAL :
6248 if(lcCfg->u.umBiDirCfg)
6250 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
6254 case RLC_UM_UNI_DIRECTIONAL_UL :
6256 if(lcCfg->u.umUniDirUlCfg)
6258 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
6263 case RLC_UM_UNI_DIRECTIONAL_DL :
6265 if(lcCfg->u.umUniDirDlCfg)
6267 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
6272 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at freeRlcLcCfg()", lcCfg->rlcMode);
6277 /*******************************************************************
6279 * @brief Function to free MacLcCfg
6283 * Function : freeMacLcCfg
6285 * Functionality: Function to free MacLcCfg
6287 * @params[in] LcCfg *lcCfg,
6290 * ****************************************************************/
6292 void freeMacLcCfg(LcCfg *lcCfg)
6294 /* Deleting DRBQOS */
6297 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
6299 /* Deleting SNSSAI */
6302 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
6305 /*******************************************************************
6307 * @brief Free UE NR Capability received in UE Context setup request
6311 * Function : freeAperDecodeUeNrCapability
6314 * Free UE NR Capability received in UE Context setup request
6317 * @return ROK - success
6320 * ****************************************************************/
6321 void freeAperDecodeUeNrCapability(void *ueNrCapability)
6324 FeatureSets_t *featureSets =NULLP;
6325 UE_NR_Capability_t *ueNrCap = (UE_NR_Capability_t *)ueNrCapability;
6327 if(ueNrCap->rf_Parameters.supportedBandListNR.list.array)
6329 for(arrIdx = 0; arrIdx < ueNrCap->rf_Parameters.supportedBandListNR.list.count; arrIdx++)
6331 if(ueNrCap->rf_Parameters.supportedBandListNR.list.array[arrIdx])
6332 free(ueNrCap->rf_Parameters.supportedBandListNR.list.array[arrIdx]);
6334 free(ueNrCap->rf_Parameters.supportedBandListNR.list.array);
6337 if(ueNrCap->featureSets)
6339 featureSets = ueNrCap->featureSets;
6340 if(featureSets->featureSetsDownlinkPerCC)
6342 if(featureSets->featureSetsDownlinkPerCC->list.array)
6344 for(arrIdx = 0; arrIdx < featureSets->featureSetsDownlinkPerCC->list.count; arrIdx++)
6346 if(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx])
6348 if(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]->supportedModulationOrderDL)
6349 free(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]->supportedModulationOrderDL);
6350 free(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]);
6353 free(featureSets->featureSetsDownlinkPerCC->list.array);
6355 free(featureSets->featureSetsDownlinkPerCC);
6357 if(featureSets->featureSetsUplinkPerCC)
6359 if(featureSets->featureSetsUplinkPerCC->list.array)
6361 for(arrIdx = 0; arrIdx < featureSets->featureSetsUplinkPerCC->list.count; arrIdx++)
6363 if(featureSets->featureSetsUplinkPerCC->list.array[arrIdx])
6365 if(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]->supportedModulationOrderUL)
6366 free(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]->supportedModulationOrderUL);
6367 free(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]);
6370 free(featureSets->featureSetsUplinkPerCC->list.array);
6372 free(featureSets->featureSetsUplinkPerCC);
6374 free(ueNrCap->featureSets);
6378 /*******************************************************************
6380 * @brief Function to free PdcchSearchSpcToAddModList
6381 where memory allocated by aper_decoder
6385 * Function : freeAperDecodePdcchSearchSpcToAddModList
6387 * Functionality: Function to free PdcchSearchSpcToAddModList
6389 * @params[in] struct PDCCH_Config__searchSpacesToAddModList *searchSpcList
6392 * ****************************************************************/
6394 void freeAperDecodePdcchSearchSpcToAddModList(struct PDCCH_Config__searchSpacesToAddModList *searchSpcList)
6396 uint8_t searchSpcArrIdx=0;
6397 uint8_t searchSpcArrIdx1=0;
6398 struct SearchSpace *searchSpc=NULLP;
6401 if(searchSpcList->list.array)
6403 if(searchSpcList->list.array[searchSpcArrIdx1])
6405 searchSpc = searchSpcList->list.array[searchSpcArrIdx1];
6406 if(searchSpc->controlResourceSetId)
6408 if(searchSpc->monitoringSlotPeriodicityAndOffset)
6410 if(searchSpc->monitoringSymbolsWithinSlot)
6412 if(searchSpc->monitoringSymbolsWithinSlot->buf)
6414 if(searchSpc->nrofCandidates)
6416 if(searchSpc->searchSpaceType)
6418 free(searchSpc->searchSpaceType->choice.ue_Specific);
6419 free(searchSpc->searchSpaceType);
6421 free(searchSpc->nrofCandidates);
6423 free(searchSpc->monitoringSymbolsWithinSlot->buf);
6425 free(searchSpc->monitoringSymbolsWithinSlot);
6427 free(searchSpc->monitoringSlotPeriodicityAndOffset);
6429 free(searchSpc->controlResourceSetId);
6432 for(searchSpcArrIdx = 0; searchSpcArrIdx < searchSpcList->list.count; searchSpcArrIdx++)
6434 free(searchSpcList->list.array[searchSpcArrIdx]);
6436 free(searchSpcList->list.array);
6439 /*******************************************************************
6441 * @brief Function for free part for the memory allocated by aper_decoder
6445 * Function : freeAperDecodeBWPDlDedPdcchConfig
6447 * Functionality: Function to free BWPDlDedPdcchConfig
6452 * ****************************************************************/
6455 void freeAperDecodeBWPDlDedPdcchConfig(BWP_DownlinkDedicated_t *dlBwp)
6459 struct PDCCH_Config *pdcchCfg=NULLP;
6460 struct ControlResourceSet *controlRSet=NULLP;
6461 struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList=NULLP;
6463 if(dlBwp->pdcch_Config->choice.setup)
6465 pdcchCfg=dlBwp->pdcch_Config->choice.setup;
6466 if(pdcchCfg->controlResourceSetToAddModList)
6468 controlRSetList = pdcchCfg->controlResourceSetToAddModList;
6469 if(controlRSetList->list.array)
6471 controlRSet = controlRSetList->list.array[arrIdx2];
6474 if(controlRSet->frequencyDomainResources.buf)
6476 if(controlRSet->pdcch_DMRS_ScramblingID)
6478 if(pdcchCfg->searchSpacesToAddModList)
6480 freeAperDecodePdcchSearchSpcToAddModList(pdcchCfg->searchSpacesToAddModList);
6481 free(pdcchCfg->searchSpacesToAddModList);
6483 free(controlRSet->pdcch_DMRS_ScramblingID);
6485 free(controlRSet->frequencyDomainResources.buf);
6488 for(arrIdx1 = 0; arrIdx1 <controlRSetList->list.count; arrIdx1++)
6490 free(controlRSetList->list.array[arrIdx1]);
6492 free(controlRSetList->list.array);
6494 free(pdcchCfg->controlResourceSetToAddModList);
6496 free(dlBwp->pdcch_Config->choice.setup);
6499 /*******************************************************************
6501 * @brief Function to free PdschTimeDomAllocationList
6502 * where the memory allocated by aper_decoder
6506 * Function : freeAperDecodePdschTimeDomAllocationList
6508 * Functionality: Function to free PdschTimeDomAllocationList
6510 * @params[in] struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
6513 * ****************************************************************/
6516 void freeAperDecodePdschTimeDomAllocationList( struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList)
6520 if(timeDomAllocList->choice.setup)
6522 if(timeDomAllocList->choice.setup->list.array)
6524 for(arrIdx = 0; arrIdx <timeDomAllocList->choice.setup->list.count ; arrIdx++)
6526 free(timeDomAllocList->choice.setup->list.array[arrIdx]);
6528 free(timeDomAllocList->choice.setup->list.array);
6530 free(timeDomAllocList->choice.setup);
6534 /*******************************************************************
6536 * @brief Function to free BWPDlDedPdschConfig
6537 * where the memory allocated by aper_decoder
6541 * Function : freeAperDecodeBWPDlDedPdschConfig
6543 * Functionality: Function to free BWPDlDedPdschConfig
6545 * @params[in] BWP_DownlinkDedicated_t *dlBwp
6548 * ****************************************************************/
6551 void freeAperDecodeBWPDlDedPdschConfig(BWP_DownlinkDedicated_t *dlBwp)
6553 struct PDSCH_Config *pdschCfg=NULLP;
6554 struct PDSCH_Config__prb_BundlingType *prbBndlType=NULLP;
6555 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList=NULLP;
6556 struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg=NULLP;
6558 if(dlBwp->pdsch_Config->choice.setup)
6560 pdschCfg=dlBwp->pdsch_Config->choice.setup;
6561 if(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
6563 if(pdschCfg->pdsch_TimeDomainAllocationList)
6565 timeDomAllocList=pdschCfg->pdsch_TimeDomainAllocationList;
6566 if(pdschCfg->maxNrofCodeWordsScheduledByDCI)
6568 prbBndlType=&pdschCfg->prb_BundlingType;
6569 free(prbBndlType->choice.staticBundling);
6570 free(pdschCfg->maxNrofCodeWordsScheduledByDCI);
6572 freeAperDecodePdschTimeDomAllocationList(timeDomAllocList);
6573 free(pdschCfg->pdsch_TimeDomainAllocationList);
6575 dmrsDlCfg=pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA;
6576 if(dmrsDlCfg->choice.setup)
6578 free(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition);
6579 free(dmrsDlCfg->choice.setup);
6581 free(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA);
6583 free(dlBwp->pdsch_Config->choice.setup);
6586 /*******************************************************************
6588 * @brief Function to free PuschTimeDomAllocListCfg
6589 where the memory allocated by aper_decoder
6593 * Function : freeAperDecodePuschTimeDomAllocListCfg
6595 * Functionality: Function to free PuschTimeDomAllocListCfg
6597 * @params[in] PUSCH_Config_t *puschCfg
6600 * ****************************************************************/
6603 void freeAperDecodePuschTimeDomAllocListCfg(PUSCH_Config_t *puschCfg)
6607 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList_t=NULLP;
6609 if(puschCfg->pusch_TimeDomainAllocationList)
6611 timeDomAllocList_t=puschCfg->pusch_TimeDomainAllocationList;
6612 if(timeDomAllocList_t->choice.setup)
6614 if(timeDomAllocList_t->choice.setup->list.array)
6616 free(timeDomAllocList_t->choice.setup->list.array[arrIdx1]->k2);
6617 for(arrIdx = 0; arrIdx<timeDomAllocList_t->choice.setup->list.count; arrIdx++)
6619 free(timeDomAllocList_t->choice.setup->list.array[arrIdx]);
6621 free(timeDomAllocList_t->choice.setup->list.array);
6623 free(timeDomAllocList_t->choice.setup);
6625 free(puschCfg->transformPrecoder);
6626 free(puschCfg->pusch_TimeDomainAllocationList);
6629 /*******************************************************************
6631 * @brief Function to free InitialUlBWPConfig where memory allocated by aper_decoder
6635 * Function : freeAperDecodeInitialUlBWPConfig
6637 * Functionality: Function to free InitialUlBWPConfig
6639 * @params[in] BWP_UplinkDedicated_t *ulBwp
6642 * ****************************************************************/
6645 void freeAperDecodeInitialUlBWPConfig(BWP_UplinkDedicated_t *ulBwp)
6649 SRS_Config_t *srsCfg = NULLP;
6650 PUSCH_Config_t *puschCfg = NULLP;
6651 struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg = NULLP;
6652 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList = NULLP;
6653 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList = NULLP;
6654 struct SRS_Config__srs_ResourceToAddModList *resourceList = NULLP;
6656 if(ulBwp->pusch_Config)
6658 if(ulBwp->pusch_Config->choice.setup)
6660 puschCfg=ulBwp->pusch_Config->choice.setup;
6661 if(puschCfg->dataScramblingIdentityPUSCH)
6663 if(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
6665 freeAperDecodePuschTimeDomAllocListCfg(puschCfg);
6666 dmrsUlCfg=puschCfg->dmrs_UplinkForPUSCH_MappingTypeA;
6667 if(dmrsUlCfg->choice.setup)
6669 if(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
6671 if(dmrsUlCfg->choice.setup->transformPrecodingDisabled)
6673 free(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0);
6674 free(dmrsUlCfg->choice.setup->transformPrecodingDisabled);
6676 free(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition);
6678 free(dmrsUlCfg->choice.setup);
6680 free(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA);
6682 free(puschCfg->dataScramblingIdentityPUSCH);
6684 free(ulBwp->pusch_Config->choice.setup);
6686 free(ulBwp->pusch_Config);
6688 /* Free SRS-Config */
6689 if(ulBwp->srs_Config)
6691 if(ulBwp->srs_Config->choice.setup)
6693 srsCfg = ulBwp->srs_Config->choice.setup;
6695 /* Free Resource Set to add/mod list */
6696 if(srsCfg->srs_ResourceSetToAddModList)
6698 rsrcSetList = srsCfg->srs_ResourceSetToAddModList;
6699 if(rsrcSetList->list.array)
6703 /* Free SRS resource Id list in this SRS resource set */
6704 if(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
6707 rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
6709 if(rsrcIdList->list.array)
6711 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count;
6714 free(rsrcIdList->list.array[rsrcIdx]);
6716 free(rsrcIdList->list.array);
6718 free(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList);
6721 /* Free resource type info for this SRS resource set */
6723 free(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic);
6725 /* Free memory for each resource set */
6726 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
6728 free(rsrcSetList->list.array[rSetIdx]);
6730 free(rsrcSetList->list.array);
6732 free(srsCfg->srs_ResourceSetToAddModList);
6735 /* Free resource to add/modd list */
6736 if(srsCfg->srs_ResourceToAddModList)
6738 resourceList = srsCfg->srs_ResourceToAddModList;
6739 if(resourceList->list.array)
6743 free(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2);
6744 free(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic);
6746 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
6748 free(resourceList->list.array[rsrcIdx]);
6750 free(resourceList->list.array);
6752 free(srsCfg->srs_ResourceToAddModList);
6755 free(ulBwp->srs_Config->choice.setup);
6757 free(ulBwp->srs_Config);
6761 /*******************************************************************
6763 * @brief Function to free initialUplinkBWPConfig where memory allocated by aper_decoder
6767 * Function : freeAperDecodeinitialUplinkBWPConfig
6769 * Functionality: Function to free initialUplinkBWPConfig
6771 * @params[in] UplinkConfig_t *ulCfg
6774 * ****************************************************************/
6777 void freeAperDecodeinitialUplinkBWPConfig(UplinkConfig_t *ulCfg)
6779 BWP_UplinkDedicated_t *ulBwp=NULLP;
6780 struct UplinkConfig__pusch_ServingCellConfig *puschCfg=NULLP;
6782 if(ulCfg->initialUplinkBWP)
6784 ulBwp=ulCfg->initialUplinkBWP;
6785 if(ulCfg->firstActiveUplinkBWP_Id)
6787 if(ulCfg->pusch_ServingCellConfig)
6789 puschCfg=ulCfg->pusch_ServingCellConfig;
6790 if(puschCfg->choice.setup)
6792 if(puschCfg->choice.setup->ext1)
6794 free(puschCfg->choice.setup->ext1->processingType2Enabled);
6795 free(puschCfg->choice.setup->ext1->maxMIMO_Layers);
6796 free(puschCfg->choice.setup->ext1);
6798 free(puschCfg->choice.setup);
6800 free(ulCfg->pusch_ServingCellConfig);
6802 free(ulCfg->firstActiveUplinkBWP_Id);
6804 freeAperDecodeInitialUlBWPConfig(ulBwp);
6805 free(ulCfg->initialUplinkBWP);
6809 /*******************************************************************
6811 * @brief Function to free DuUeCfg
6815 * Function : freeDuUeCfg
6817 * Functionality: Function to free DuUeCfg
6819 * @params[in] DuUeCfg *ueCfg
6822 * ****************************************************************/
6823 void freeDuUeCfg(DuUeCfg *ueCfg)
6827 SpCellConfig_t *spCellCfg = NULLP;
6828 ServingCellConfig_t *srvCellCfg = NULLP;
6829 BWP_DownlinkDedicated_t *dlBwp = NULLP;
6830 MAC_CellGroupConfig_t *macCellGrpCfg = NULLP;
6831 PhysicalCellGroupConfig_t *phyCellGrpCfg = NULLP;
6832 struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList = NULLP;
6833 struct RLC_Config *rlcConfig = NULLP;
6834 struct LogicalChannelConfig *macLcConfig = NULLP;
6835 struct SchedulingRequestConfig *schedulingRequestConfig = NULLP;
6836 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList = NULLP;
6837 struct TAG_Config *tagConfig = NULLP;
6838 struct TAG_Config__tag_ToAddModList *tagList = NULLP;
6839 struct MAC_CellGroupConfig__phr_Config *phrConfig = NULLP;
6840 struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg = NULLP;
6841 CellGroupConfigRrc_t *cellGrpCfg = ueCfg->cellGrpCfg;
6843 if(ueCfg->ueNrCapability)
6845 freeAperDecodeUeNrCapability(ueCfg->ueNrCapability);
6846 DU_FREE(ueCfg->ueNrCapability, sizeof(UE_NR_Capability_t));
6847 ueCfg->ueNrCapability = NULLP;
6850 if(ueCfg->cellGrpCfg)
6853 rlcBearerList = cellGrpCfg->rlc_BearerToAddModList;
6856 if(rlcBearerList->list.array)
6858 for(arrIdx=0; arrIdx<rlcBearerList->list.count; arrIdx++)
6860 if(rlcBearerList->list.array[arrIdx])
6862 rlcConfig = rlcBearerList->list.array[arrIdx]->rlc_Config;
6863 macLcConfig = rlcBearerList->list.array[arrIdx]->mac_LogicalChannelConfig;
6865 if(rlcBearerList->list.array[arrIdx]->servedRadioBearer)
6867 free(rlcBearerList->list.array[arrIdx]->servedRadioBearer);
6871 if(rlcConfig->choice.am)
6873 free(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength);
6874 free(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength);
6875 free(rlcConfig->choice.am);
6877 free(rlcBearerList->list.array[arrIdx]->rlc_Config);
6881 if(macLcConfig->ul_SpecificParameters)
6883 free(macLcConfig->ul_SpecificParameters->schedulingRequestID);
6884 free(macLcConfig->ul_SpecificParameters->logicalChannelGroup);
6885 free(macLcConfig->ul_SpecificParameters);
6887 free(rlcBearerList->list.array[arrIdx]->mac_LogicalChannelConfig);
6889 free(rlcBearerList->list.array[arrIdx]);
6892 free(rlcBearerList->list.array);
6894 free(cellGrpCfg->rlc_BearerToAddModList);
6897 macCellGrpCfg = cellGrpCfg->mac_CellGroupConfig;
6900 schedulingRequestConfig = macCellGrpCfg->schedulingRequestConfig;
6901 if(schedulingRequestConfig)
6903 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
6906 if(schReqList->list.array)
6908 for(arrIdx=0;arrIdx<schReqList->list.count; arrIdx++)
6910 if(schReqList->list.array[arrIdx])
6912 free(schReqList->list.array[arrIdx]->sr_ProhibitTimer);
6913 free(schReqList->list.array[arrIdx]);
6916 free(schReqList->list.array);
6918 free(schedulingRequestConfig->schedulingRequestToAddModList);
6920 free(macCellGrpCfg->schedulingRequestConfig);
6922 if(macCellGrpCfg->bsr_Config)
6924 free(macCellGrpCfg->bsr_Config);
6926 tagConfig = macCellGrpCfg->tag_Config;
6929 tagList = tagConfig->tag_ToAddModList;
6932 if(tagList->list.array)
6934 for(arrIdx=0; arrIdx<tagList->list.count; arrIdx++)
6936 free(tagList->list.array[arrIdx]);
6938 free(tagList->list.array);
6940 free(tagConfig->tag_ToAddModList);
6945 phrConfig = macCellGrpCfg->phr_Config;
6948 free(phrConfig->choice.setup);
6952 free(macCellGrpCfg);
6955 phyCellGrpCfg = cellGrpCfg->physicalCellGroupConfig;
6958 free(phyCellGrpCfg->p_NR_FR1);
6959 free(phyCellGrpCfg);
6962 spCellCfg = cellGrpCfg->spCellConfig;
6965 if(spCellCfg->servCellIndex)
6967 if(spCellCfg->rlmInSyncOutOfSyncThreshold)
6969 if(spCellCfg->spCellConfigDedicated)
6971 srvCellCfg = spCellCfg->spCellConfigDedicated;
6972 if(srvCellCfg->initialDownlinkBWP)
6974 dlBwp = srvCellCfg->initialDownlinkBWP;
6975 if(srvCellCfg->firstActiveDownlinkBWP_Id)
6977 if(srvCellCfg->defaultDownlinkBWP_Id)
6979 if(srvCellCfg->uplinkConfig)
6982 if(srvCellCfg->pdsch_ServingCellConfig)
6985 srvCellCfg->pdsch_ServingCellConfig;
6986 if(pdschCfg->choice.setup)
6989 free(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH);
6990 free(pdschCfg->choice.setup);
6993 free(srvCellCfg->pdsch_ServingCellConfig);
6996 freeAperDecodeinitialUplinkBWPConfig(srvCellCfg->uplinkConfig);
6997 free(srvCellCfg->uplinkConfig);
6999 free(srvCellCfg->defaultDownlinkBWP_Id);
7002 free(srvCellCfg->firstActiveDownlinkBWP_Id);
7004 if(dlBwp->pdcch_Config)
7006 if(dlBwp->pdsch_Config)
7008 freeAperDecodeBWPDlDedPdschConfig(dlBwp);
7009 free(dlBwp->pdsch_Config);
7011 freeAperDecodeBWPDlDedPdcchConfig(dlBwp);
7012 free(dlBwp->pdcch_Config);
7014 free(srvCellCfg->initialDownlinkBWP);
7017 free(spCellCfg->spCellConfigDedicated);
7019 free(spCellCfg->rlmInSyncOutOfSyncThreshold);
7021 free(spCellCfg->servCellIndex);
7025 DU_FREE(ueCfg->cellGrpCfg, sizeof(CellGroupConfigRrc_t));
7026 ueCfg->cellGrpCfg = NULLP;
7030 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCfg->ambrCfg, sizeof(AmbrCfg));
7032 for(lcIdx = 0; lcIdx < ueCfg->numRlcLcs; lcIdx++)
7034 freeRlcLcCfg(&ueCfg->rlcLcCfg[lcIdx]);
7036 for(lcIdx = 0; lcIdx < ueCfg->numMacLcs; lcIdx++)
7038 freeMacLcCfg(&ueCfg->macLcCfg[lcIdx]);
7040 for(lcIdx = 0; lcIdx < ueCfg->numDrb; lcIdx++)
7042 DU_FREE(ueCfg->upTnlInfo[lcIdx].tnlCfg1, sizeof(GtpTnlCfg));
7046 /*******************************************************************
7048 * @brief Function to free UecontextSetupDb
7052 * Function : freeF1UeDb
7054 * Functionality: Function to free UecontextSetupDb
7056 * @params[in] UecontextSetupDb *
7059 * ****************************************************************/
7061 void freeF1UeDb(F1UeContextSetupDb *f1UeDb)
7064 if(f1UeDb->dlRrcMsg)
7066 if(f1UeDb->dlRrcMsg->rrcMsgPdu)
7068 //DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,\
7069 f1UeDb->dlRrcMsg->rrcMsgPdu, f1UeDb->dlRrcMsg->rrcMsgSize);
7071 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
7073 freeDuUeCfg(&f1UeDb->duUeCfg);
7074 memset(f1UeDb, 0, sizeof(F1UeContextSetupDb));
7075 DU_FREE(f1UeDb, sizeof(F1UeContextSetupDb));
7078 /*******************************************************************
7080 * @brief Function to build Am cfg Info
7084 * Function : extractRlcAmCfg
7086 * Functionality: Function to build Am cfg Info
7088 * @params[in] AmBearerCfg *
7091 * @return ROK/RFAILED
7093 * ****************************************************************/
7095 void extractRlcAmCfg(AmBearerCfg *amCfgToSet, struct RLC_Config__am *rlcAmCfg)
7100 if(rlcAmCfg->dl_AM_RLC.sn_FieldLength)
7102 amCfgToSet->ulAmCfg.snLenUl = *(rlcAmCfg->dl_AM_RLC.sn_FieldLength);
7103 /*TODO: Check the timer value when sent by real CU */
7104 amCfgToSet->ulAmCfg.reAssemTmr = rlcAmCfg->dl_AM_RLC.t_Reassembly;
7105 amCfgToSet->ulAmCfg.statProhTmr = rlcAmCfg->dl_AM_RLC.t_StatusProhibit;
7109 if(rlcAmCfg->ul_AM_RLC.sn_FieldLength)
7111 amCfgToSet->dlAmCfg.snLenDl = *(rlcAmCfg->ul_AM_RLC.sn_FieldLength);
7112 amCfgToSet->dlAmCfg.pollRetxTmr = rlcAmCfg->ul_AM_RLC.t_PollRetransmit;
7113 amCfgToSet->dlAmCfg.pollPdu = rlcAmCfg->ul_AM_RLC.pollPDU;
7114 amCfgToSet->dlAmCfg.pollByte = rlcAmCfg->ul_AM_RLC.pollByte;
7115 amCfgToSet->dlAmCfg.maxRetxTh = rlcAmCfg->ul_AM_RLC.maxRetxThreshold;
7120 /*******************************************************************
7122 * @brief Function to build Um Bi Info
7126 * Function : extractRlcUmBiCfg
7128 * Functionality: Function to build Um Bi Info
7130 * @params[in] UmBiDirBearerCfg *
7133 * @return ROK/RFAILED
7135 * ****************************************************************/
7137 void extractRlcUmBiCfg(UmBiDirBearerCfg *umBiCfgToSet, struct RLC_Config__um_Bi_Directional *rlcBiCfg)
7141 /* UL UM BI DIR Cfg */
7142 if(rlcBiCfg->dl_UM_RLC.sn_FieldLength)
7144 umBiCfgToSet->ulUmCfg.snLenUlUm = *(rlcBiCfg->dl_UM_RLC.sn_FieldLength);
7145 umBiCfgToSet->ulUmCfg.reAssemTmr = rlcBiCfg->dl_UM_RLC.t_Reassembly;
7148 /* DL UM BI DIR Cfg */
7149 if(rlcBiCfg->ul_UM_RLC.sn_FieldLength)
7150 umBiCfgToSet->dlUmCfg.snLenDlUm = *(rlcBiCfg->ul_UM_RLC.sn_FieldLength);
7154 /*******************************************************************
7156 * @brief Function to build Um Ul Info
7160 * Function : extractRlcUmUlCfg
7162 * Functionality: Function to build Um Ul Info
7164 * @params[in] UmUniDirUlBearerCfg *
7167 * @return ROK/RFAILED
7169 * ****************************************************************/
7171 void extractRlcUmUlCfg(UmUniDirUlBearerCfg *umUlCfgToSet, struct RLC_Config__um_Uni_Directional_DL *umUlCfg)
7175 if(umUlCfg->dl_UM_RLC.sn_FieldLength)
7177 umUlCfgToSet->ulUmCfg.snLenUlUm = *(umUlCfg->dl_UM_RLC.sn_FieldLength);
7178 umUlCfgToSet->ulUmCfg.reAssemTmr = umUlCfg->dl_UM_RLC.t_Reassembly;
7183 /*******************************************************************
7185 * @brief Function to build Um Uni Dl Info
7189 * Function : extractRlcUmDlCfg
7191 * Functionality: Function to build Um Uni Dl Info
7193 * @params[in] UmUniDirDlBearerCfg *
7196 * @return ROK/RFAILED
7198 * ****************************************************************/
7199 void extractRlcUmDlCfg(UmUniDirDlBearerCfg *umDlCfgToSet, struct RLC_Config__um_Uni_Directional_UL *umDlCfg)
7203 if(umDlCfg->ul_UM_RLC.sn_FieldLength)
7204 umDlCfgToSet->dlUmCfg.snLenDlUm = *(umDlCfg->ul_UM_RLC.sn_FieldLength);
7208 /*******************************************************************
7210 * @brief Function to extractRlcModeCfg
7214 * Function : extractRlcModeCfg
7216 * Functionality: Function to extractRlcModeCfg
7218 * @params[in] RLC_Config_t *
7221 * @return ROK/RFAILED
7223 * ****************************************************************/
7224 void extractRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *rlcDbCfg, RLC_Config_t *lcCfg)
7232 if(lcCfg->choice.am)
7234 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.amCfg, sizeof(AmBearerCfg));
7235 if(rlcDbCfg->u.amCfg)
7236 extractRlcAmCfg(rlcDbCfg->u.amCfg, lcCfg->choice.am);
7240 case RLC_UM_BI_DIRECTIONAL :
7242 if(lcCfg->choice.um_Bi_Directional)
7244 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
7245 if(rlcDbCfg->u.umBiDirCfg)
7246 extractRlcUmBiCfg(rlcDbCfg->u.umBiDirCfg, lcCfg->choice.um_Bi_Directional);
7250 case RLC_UM_UNI_DIRECTIONAL_UL :
7252 if(lcCfg->choice.um_Uni_Directional_DL)
7254 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
7255 if(rlcDbCfg->u.umUniDirUlCfg)
7256 extractRlcUmUlCfg(rlcDbCfg->u.umUniDirUlCfg, lcCfg->choice.um_Uni_Directional_DL);
7260 case RLC_UM_UNI_DIRECTIONAL_DL :
7262 if(lcCfg->choice.um_Uni_Directional_UL)
7264 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
7265 if(rlcDbCfg->u.umUniDirDlCfg)
7266 extractRlcUmDlCfg(rlcDbCfg->u.umUniDirDlCfg, lcCfg->choice.um_Uni_Directional_UL);
7271 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
7277 /*******************************************************************
7279 * @brief Function to extract extractUlLcCfg
7283 * Function : extractUlLcCfg
7285 * Functionality: Function to extract extractUlLcCfg
7287 * @params[in] UlLcCfg *f1UlLcCfg, LogicalChannelConfig_t *ulLcCfg
7290 * ****************************************************************/
7292 void extractUlLcCfg(UlLcCfg *f1UlLcCfg, LogicalChannelConfig_t *ulLcCfg)
7296 if(ulLcCfg->ul_SpecificParameters)
7298 f1UlLcCfg->priority = \
7299 ulLcCfg->ul_SpecificParameters->priority;
7300 if(ulLcCfg->ul_SpecificParameters->logicalChannelGroup)
7302 f1UlLcCfg->lcGroup = \
7303 *(ulLcCfg->ul_SpecificParameters->logicalChannelGroup);
7305 if(ulLcCfg->ul_SpecificParameters->schedulingRequestID)
7307 f1UlLcCfg->schReqId = \
7308 *(ulLcCfg->ul_SpecificParameters->schedulingRequestID);
7311 ulLcCfg->ul_SpecificParameters->prioritisedBitRate;
7313 ulLcCfg->ul_SpecificParameters->bucketSizeDuration;
7318 /*******************************************************************
7320 * @brief Function to procRlcLcCfg
7324 * Function : procRlcLcCfg
7326 * Functionality: Function to procRlcLcCfg
7328 * @params[in] rbId, lcId, rbType, rlcMod
7329 * RLC_Config_t *, RlcBearerCfg * ,
7332 * ****************************************************************/
7334 void procRlcLcCfg(uint8_t rbId, uint8_t lcId, uint8_t rbType, uint8_t rlcMode,\
7335 uint8_t configType, RLC_Config_t *f1RlcCfg, RlcBearerCfg *lcCfg)
7339 lcCfg->configType = configType;
7341 if(rbType == RB_TYPE_SRB)
7343 lcCfg->rbType = RB_TYPE_SRB;
7345 lcCfg->lcType = LCH_DCCH;
7346 lcCfg->rlcMode = RLC_AM;
7348 else if(rbType == RB_TYPE_DRB)
7350 lcCfg->rbType = RB_TYPE_DRB;
7352 lcCfg->lcType = LCH_DTCH;
7353 lcCfg->rlcMode = rlcMode;
7355 if(f1RlcCfg) /* rlc mode config recived */
7357 extractRlcModeCfg(lcCfg->rlcMode, lcCfg, f1RlcCfg);
7363 /*******************************************************************
7365 * @brief Fills DrbQos Info received by CU
7369 * Function : extractQosInfo
7371 * Functionality: Fills DrbQos Info received by CU
7373 * @params[in] DrbQosInfo *qosToAdd,
7374 * QoSFlowLevelQoSParameters_t *qosFlowCfg
7377 * ****************************************************************/
7379 void extractQosInfo(DrbQosInfo *qosToAdd, QoSFlowLevelQoSParameters_t *qosFlowCfg)
7381 qosToAdd->fiveQiType = qosFlowCfg->qoS_Characteristics.present;
7382 qosToAdd->u.nonDyn5Qi.fiveQi =\
7383 qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->fiveQI;
7384 if(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow)
7386 qosToAdd->u.nonDyn5Qi.avgWindow = \
7387 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
7389 qosToAdd->u.nonDyn5Qi.maxDataBurstVol = \
7390 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
7391 if(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->qoSPriorityLevel)
7393 qosToAdd->u.nonDyn5Qi.priorLevel = \
7394 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->qoSPriorityLevel);
7396 qosToAdd->ngRanRetPri.priorityLevel = \
7397 qosFlowCfg->nGRANallocationRetentionPriority.priorityLevel;
7398 qosToAdd->ngRanRetPri.preEmptionCap = \
7399 qosFlowCfg->nGRANallocationRetentionPriority.pre_emptionCapability;
7400 qosToAdd->ngRanRetPri.preEmptionVul = \
7401 qosFlowCfg->nGRANallocationRetentionPriority.pre_emptionVulnerability;
7402 if(qosFlowCfg->gBR_QoS_Flow_Information)
7404 memcpy(&qosToAdd->grbQosInfo.maxFlowBitRateDl, \
7405 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateDownlink.buf, \
7406 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateDownlink.size);
7407 memcpy(&qosToAdd->grbQosInfo.maxFlowBitRateUl, \
7408 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateUplink.buf, \
7409 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateUplink.size);
7410 memcpy(&qosToAdd->grbQosInfo.guarFlowBitRateDl,\
7411 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateDownlink.buf, \
7412 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateDownlink.size);
7413 memcpy(&qosToAdd->grbQosInfo.guarFlowBitRateUl,\
7414 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateUplink.buf, \
7415 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateUplink.size);
7417 qosToAdd->pduSessionId = 0;
7418 qosToAdd->ulPduSessAggMaxBitRate = 0;
7421 /*******************************************************************
7423 * @brief Function to extract GTP Tunnel Info from CU
7427 * Function : extractUpTnlInfo
7429 * Functionality: Function to extract GTP Tunnel Info from CU
7431 * @params[in] F1AP message
7432 * @return ROK/RFAILED
7434 * ****************************************************************/
7436 uint8_t extractUpTnlInfo(uint8_t drbId, uint8_t configType,\
7437 ULUPTNLInformation_ToBeSetup_List_t *tnlInfo, UpTnlCfg *upTnlInfo)
7440 uint32_t ipv4_du = 0;
7441 GTPTunnel_t *gtpTunnel = NULLP;
7443 upTnlInfo->drbId = drbId;
7444 upTnlInfo->configType = configType;
7446 cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
7448 cmInetAddr((char *)DU_IP_V4_ADDR, &ipv4_du);
7451 for(tnlIdx=0; tnlIdx < tnlInfo->list.count; tnlIdx++)
7453 if(tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.present == UPTransportLayerInformation_PR_gTPTunnel)
7455 if(tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.choice.gTPTunnel)
7457 gtpTunnel = tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.choice.gTPTunnel;
7458 DU_ALLOC(upTnlInfo->tnlCfg1, sizeof(GtpTnlCfg));
7459 if(upTnlInfo->tnlCfg1 == NULLP)
7461 DU_LOG("\nERROR --> F1AP : extractUpTnlInfo: Failed to allocate mmeory for tunnel cfg 1");
7464 bitStringToInt(>pTunnel->transportLayerAddress, &upTnlInfo->tnlCfg1->ulTnlAddress);
7465 upTnlInfo->tnlCfg1->dlTnlAddress = ipv4_du;
7466 if(gtpTunnel->gTP_TEID.size > 0)
7468 teIdStringToInt(gtpTunnel->gTP_TEID.buf, &upTnlInfo->tnlCfg1->teId);
7476 /*******************************************************************
7478 * @brief Function to extract Drb Qos Cfg Info from CU
7482 * Function : extractDrbQosCfg
7484 * Functionality: Function to extract Drb Qos Cfg Info from CU
7486 * @params[in] DRB_Information_t *drbInfo, LcCfg *macLcToAdd
7487 * @return ROK/RFAILED
7489 * ****************************************************************/
7491 uint8_t extractDrbQosCfg(DRB_Information_t *drbInfo, LcCfg *macLcToAdd )
7493 if(!macLcToAdd->drbQos)
7495 DU_ALLOC_SHRABL_BUF(macLcToAdd->drbQos, sizeof(DrbQosInfo));
7496 if(macLcToAdd->drbQos == NULLP)
7498 DU_LOG("\nERROR --> DUAPP:Memory failed at allocating DrbQos at extractDrbCfg()");
7503 if(drbInfo->dRB_QoS.qoS_Characteristics.present == QoS_Characteristics_PR_non_Dynamic_5QI)
7505 extractQosInfo(macLcToAdd->drbQos, &drbInfo->dRB_QoS);
7506 macLcToAdd->dlLcCfg.lcp = macLcToAdd->drbQos->ngRanRetPri.priorityLevel;
7508 if(!macLcToAdd->snssai)
7510 DU_ALLOC_SHRABL_BUF(macLcToAdd->snssai, sizeof(Snssai));
7511 if(macLcToAdd->snssai == NULLP)
7513 DU_LOG("\nERROR --> DUAPP : Memory failed at allocating SNSSAI at extractDrbCfg()");
7517 memcpy(&macLcToAdd->snssai->sst, drbInfo->sNSSAI.sST.buf, \
7518 drbInfo->sNSSAI.sST.size);
7519 if(drbInfo->sNSSAI.sD)
7521 memcpy(macLcToAdd->snssai->sd, drbInfo->sNSSAI.sD->buf, \
7522 drbInfo->sNSSAI.sD->size);
7526 /*******************************************************************
7528 * @brief Function to extract DRB info received from CU
7532 * Function : extractDrbCfg
7534 * Functionality: Function to extract DRB info received from CU
7536 * @params[in] F1AP message
7539 * ****************************************************************/
7540 uint8_t extractDrbCfg(DRBs_ToBeSetup_Item_t *drbItem,DRBs_ToBeSetupMod_Item_t *drbSetupModItem,\
7541 LcCfg *macLcToAdd, UpTnlCfg *upTnlInfo)
7543 DRB_Information_t *drbInfo = NULLP;
7545 if(drbItem != NULLP)
7547 if(extractUpTnlInfo(drbItem->dRBID, CONFIG_ADD, &drbItem->uLUPTNLInformation_ToBeSetup_List, upTnlInfo) != ROK)
7549 DU_LOG("\nERROR --> DUAPP : Failed to extract tunnel Cfg at extractDrbCfg()");
7552 if(drbItem->qoSInformation.present == QoSInformation_PR_choice_extension)
7554 if(drbItem->qoSInformation.choice.choice_extension->value.present == QoSInformation_ExtIEs__value_PR_DRB_Information)
7556 drbInfo = &drbItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information;
7557 if(extractDrbQosCfg(drbInfo , macLcToAdd) != ROK)
7559 DU_LOG("\nERROR --> DUAPP : Failed to extract qos Cfg at extractDrbCfg()");
7565 else if(drbSetupModItem != NULLP)
7567 if(extractUpTnlInfo(drbSetupModItem->dRBID, CONFIG_ADD, &drbSetupModItem->uLUPTNLInformation_ToBeSetup_List,\
7570 DU_LOG("\nERROR --> DUAPP : Failed to extract tunnel Cfg at extractDrbCfg()");
7573 if(drbSetupModItem->qoSInformation.present == QoSInformation_PR_choice_extension)
7575 if(drbSetupModItem->qoSInformation.choice.choice_extension->value.present ==\
7576 QoSInformation_ExtIEs__value_PR_DRB_Information)
7578 drbInfo = &drbSetupModItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information;
7579 if(extractDrbQosCfg(drbInfo , macLcToAdd) != ROK)
7581 DU_LOG("\nERROR --> DUAPP : Failed to extract qos Cfg at extractDrbCfg()");
7592 /*******************************************************************
7594 * @brief Function to extract RB info received from CU
7598 * Function : extractMacRbCfg
7600 * Functionality: Function to extract RB info received from CU
7602 * @params[in] F1AP message
7603 * @return ROK/RFAILED
7605 * ****************************************************************/
7607 uint8_t extractMacRbCfg(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbCfg,\
7608 DRBs_ToBeSetupMod_Item_t *drbSetupModCfg, LogicalChannelConfig_t *ulLcCfg, LcCfg *lcCfg, UpTnlCfg *upTnlInfo)
7612 if(extractDrbCfg(drbCfg, NULL, lcCfg, upTnlInfo) != ROK)
7614 DU_LOG("ERROR --> F1AP : Failed to build Drb Qos at extractMacRbCfg()");
7618 else if(drbSetupModCfg != NULLP)
7620 if(extractDrbCfg(NULL, drbSetupModCfg, lcCfg, upTnlInfo) != ROK)
7622 DU_LOG("ERROR --> F1AP : Failed to build Drb Qos at extractMacRbCfg()");
7628 lcCfg->drbQos = NULLP;
7629 lcCfg->snssai = NULLP;
7630 if(lcCfg->lcId == SRB2_LCID)
7631 lcCfg->dlLcCfg.lcp = LC_PRIORITY_3;
7633 lcCfg->dlLcCfg.lcp = LC_PRIORITY_1;
7637 lcCfg->ulLcCfgPres = true;
7638 extractUlLcCfg(&lcCfg->ulLcCfg, ulLcCfg);
7641 lcCfg->ulLcCfgPres = false;
7645 /*******************************************************************
7647 * @brief Function processing LC config info received from CU
7651 * Function : procMacLcCfg
7653 * Functionality: Function processing LC config info received from CU
7655 * @params[in] F1AP message
7656 * @return ROK/RFAILED
7658 * ****************************************************************/
7660 uint8_t procMacLcCfg(uint8_t lcId, uint8_t rbType, uint8_t configType,\
7661 DRBs_ToBeSetup_Item_t *drbItem, DRBs_ToBeSetupMod_Item_t *drbSetupModItem, LogicalChannelConfig_t *ulLcCfg,\
7662 LcCfg *lcCfg, UpTnlCfg *upTnlInfo)
7667 lcCfg->configType = configType;
7668 if(rbType == RB_TYPE_SRB)
7670 ret = extractMacRbCfg(lcId, NULL,NULL, ulLcCfg, lcCfg, NULL);
7672 else if(rbType == RB_TYPE_DRB)
7675 ret = extractMacRbCfg(lcId, drbItem, NULL, ulLcCfg, lcCfg, upTnlInfo);
7676 else if(drbSetupModItem != NULL)
7677 ret = extractMacRbCfg(lcId, NULL, drbSetupModItem, ulLcCfg, lcCfg, upTnlInfo);
7682 /*******************************************************************
7684 * @brief Function to extract Rlc cfg To Add/Mod in CellGrp Info
7688 * Function : extractRlcCfgToAddMod
7690 * Functionality: Function to extract Rlc cfg To Add/Mod in CellGrp Info
7692 * @params[in] CellGroupConfigRrc__rlc_BearerTo pointer
7694 * @return ROK/RFAILED
7696 * ****************************************************************/
7698 uint8_t extractRlcCfgToAddMod(struct CellGroupConfigRrc__rlc_BearerToAddModList *lcCfg, DuUeCfg *ueCfgDb)
7700 uint8_t idx, rbId, lcId, rlcMode, rbType;
7701 RLC_Config_t *f1RlcCfg = NULLP;
7702 LogicalChannelConfig_t *macUlLcCfg = NULLP;
7704 for(idx = 0; idx < lcCfg->list.count; idx++)
7706 lcId = lcCfg->list.array[idx]->logicalChannelIdentity;
7707 if(lcCfg->list.array[idx]->servedRadioBearer)
7709 /* RadioBearer for SRB/DRB */
7710 if(lcCfg->list.array[idx]->servedRadioBearer->present ==\
7711 RLC_BearerConfig__servedRadioBearer_PR_srb_Identity)
7713 rbId = lcCfg->list.array[idx]->servedRadioBearer->choice.srb_Identity;
7714 rbType = RB_TYPE_SRB;
7716 else if(lcCfg->list.array[idx]->servedRadioBearer->present ==\
7717 RLC_BearerConfig__servedRadioBearer_PR_drb_Identity)
7719 rbId = lcCfg->list.array[idx]->servedRadioBearer->choice.drb_Identity;
7720 rbType = RB_TYPE_DRB;
7724 DU_LOG("\nERROR --> No components present in Bearer config to ADD/MOD");
7727 /* MAC UL LC Config */
7728 if(lcCfg->list.array[idx]->mac_LogicalChannelConfig)
7730 macUlLcCfg = lcCfg->list.array[idx]->mac_LogicalChannelConfig;
7735 DU_LOG("\nERROR --> DUAPP: Received RadioBearer config is NULL");
7738 /* RLC Mode Config */
7739 if(lcCfg->list.array[idx]->rlc_Config)
7741 rlcMode = lcCfg->list.array[idx]->rlc_Config->present;
7742 f1RlcCfg = lcCfg->list.array[idx]->rlc_Config;
7745 /* Filling RLC/MAC Config*/
7746 memset(&ueCfgDb->macLcCfg[idx], 0, sizeof(LcCfg));
7747 memset(&ueCfgDb->rlcLcCfg[idx], 0, sizeof(RlcBearerCfg));
7748 procRlcLcCfg(rbId, lcId, rbType, rlcMode, CONFIG_UNKNOWN, f1RlcCfg, &(ueCfgDb->rlcLcCfg[idx]));
7749 if(procMacLcCfg(lcId, rbType, CONFIG_UNKNOWN, NULL, NULL, macUlLcCfg, &ueCfgDb->macLcCfg[idx], NULL) != ROK)
7751 DU_LOG("\nERROR --> DU APP : Failed while filling MAC LC config at extractRlcCfgToAddMod()");
7754 (ueCfgDb->numRlcLcs)++;
7755 (ueCfgDb->numMacLcs)++;
7757 //TODO: To send the failure cause in UeContextSetupRsp
7761 /*******************************************************************
7763 * @brief DeAlloc pdsch serv cell config info
7767 * Function : freeMacPdschServCellInfo
7769 * Functionality: DeAlloc pdsch serv cell config info
7771 * @params[in] PdschServCellCfg pointer
7774 * ****************************************************************/
7776 void freeMacPdschServCellInfo(PdschServCellCfg *pdsch)
7778 if(pdsch->xOverhead)
7780 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->xOverhead, sizeof(PdschXOverhead));
7782 if(pdsch->codeBlkGrpFlushInd)
7784 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->codeBlkGrpFlushInd, sizeof(bool));
7786 if(pdsch->maxCodeBlkGrpPerTb)
7788 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
7790 if(pdsch->maxMimoLayers)
7792 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->maxMimoLayers, sizeof(uint8_t));
7796 /*******************************************************************
7798 * @brief Free Serving cell Info
7802 * Function : freeMacServingCellInfo
7804 * Functionality: Free Serving cell Info
7806 * @params[in] ServCellCfgInfo *srvCellCfg
7809 * ****************************************************************/
7810 void freeMacServingCellInfo(ServCellCfgInfo *srvCellCfg)
7812 uint8_t timeDomRsrcIdx;
7814 if(srvCellCfg->initDlBwp.pdschPresent)
7816 for(timeDomRsrcIdx = 0; timeDomRsrcIdx < srvCellCfg->initDlBwp.pdschCfg.numTimeDomRsrcAlloc; timeDomRsrcIdx++)
7818 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, \
7819 srvCellCfg->initDlBwp.pdschCfg.timeDomRsrcAllociList[timeDomRsrcIdx].k0, sizeof(uint8_t));
7823 freeMacPdschServCellInfo(&srvCellCfg->pdschServCellCfg);
7824 if(srvCellCfg->bwpInactivityTmr)
7826 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, srvCellCfg->bwpInactivityTmr, sizeof(uint8_t));
7829 if(srvCellCfg->initUlBwp.pucchPresent)
7831 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, srvCellCfg->initUlBwp.pucchCfg.dlDataToUlAck, sizeof(PucchDlDataToUlAck));
7835 /*******************************************************************
7837 * @brief Free cell Grp Cfg Info
7841 * Function : freeUeReCfgCellGrpInfo
7843 * Functionality: Free cell Grp Cfg Info
7845 * @params[in] MacUeCfg* duUeCfg
7848 * ****************************************************************/
7850 void freeUeReCfgCellGrpInfo(MacUeCfg *macUeCfg)
7852 freeMacServingCellInfo(&macUeCfg->spCellCfg.servCellCfg);
7855 /*******************************************************************
7857 * @brief Fills Reconfig SchReqReConfig
7861 * Function : extractSchReqReConfig
7863 * Functionality: Fills Reconfig SchReqReConfig
7865 * @params[in] SchedulingRequestConfig_t *cuSchedReq
7866 * SchedReqCfg* macSchedReq
7869 * ****************************************************************/
7870 void extractSchReqReConfig(SchedulingRequestConfig_t *cuSchedReq, SchedReqCfg *macSchedReq)
7872 uint8_t schReqIdx = 0;
7873 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqListToAdd = NULLP;
7874 struct SchedulingRequestConfig__schedulingRequestToReleaseList *schReqListToRel = NULLP;
7876 if(cuSchedReq->schedulingRequestToAddModList)
7878 schReqListToAdd = cuSchedReq->schedulingRequestToAddModList;
7879 if(schReqListToAdd->list.count)
7881 macSchedReq->addModListCount = schReqListToAdd->list.count;
7882 for(schReqIdx = 0; schReqIdx < schReqListToAdd->list.count; schReqIdx++)
7884 macSchedReq->addModList[schReqIdx].schedReqId = \
7885 schReqListToAdd->list.array[schReqIdx]->schedulingRequestId;
7886 macSchedReq->addModList[schReqIdx].srProhibitTmr = \
7887 *(schReqListToAdd->list.array[schReqIdx]->sr_ProhibitTimer);
7888 macSchedReq->addModList[schReqIdx].srTransMax =\
7889 schReqListToAdd->list.array[schReqIdx]->sr_TransMax;
7893 /* Scheduling Req To release */
7894 if(cuSchedReq->schedulingRequestToReleaseList)
7896 schReqListToRel = cuSchedReq->schedulingRequestToReleaseList;
7897 if(schReqListToRel->list.count)
7899 macSchedReq->relListCount = schReqListToRel->list.count;
7900 for(schReqIdx = 0; schReqIdx < schReqListToRel->list.count; schReqIdx++)
7902 macSchedReq->relList[schReqIdx] = \
7903 *schReqListToRel->list.array[schReqIdx];
7909 /*******************************************************************
7911 * @brief Fills TagReconfig
7915 * Function : extractTagReconfig
7917 * Functionality: Fills extractTagReconfig
7919 * @params[in] TAG_Config_t *cuTagCfg
7923 * ****************************************************************/
7925 void extractTagReconfig(TAG_Config_t *cuTagCfg, TagCfg *macTagCfg)
7928 struct TAG_Config__tag_ToAddModList *tagListToAddMod = NULLP;
7929 struct TAG_Config__tag_ToReleaseList *tagListToRel = NULLP;
7931 /* Tag config to AddMod */
7932 if(cuTagCfg->tag_ToAddModList)
7934 tagListToAddMod = cuTagCfg->tag_ToAddModList;
7935 if(tagListToAddMod->list.count)
7937 macTagCfg->addModListCount = tagListToAddMod->list.count;
7938 for(tagIdx = 0; tagIdx < tagListToAddMod->list.count; tagIdx++)
7940 macTagCfg->addModList[tagIdx].tagId =\
7941 tagListToAddMod->list.array[tagIdx]->tag_Id;
7942 macTagCfg->addModList[tagIdx].timeAlignTimer = \
7944 tagListToAddMod->list.array[tagIdx]->timeAlignmentTimer;
7948 /* Tag config to release */
7949 if(cuTagCfg->tag_ToReleaseList)
7951 tagListToRel = cuTagCfg->tag_ToReleaseList;
7952 if(tagListToRel->list.count)
7954 macTagCfg->relListCount = tagListToRel->list.count;
7955 for(tagIdx = 0; tagIdx < tagListToRel->list.count; tagIdx++)
7957 macTagCfg->relList[tagIdx] = *tagListToRel->list.array[tagIdx];
7963 /*******************************************************************
7965 * @brief Fills PdcchCfg received by CU
7969 * Function : extractPdcchCfg
7971 * Functionality: Fills PdcchCfg received by CU
7973 * @params[in] PDCCH_Config_t *cuPdcchCfg,
7974 * PdcchConfig *duPdcchCfg
7977 * ****************************************************************/
7979 void extractPdcchCfg(PDCCH_Config_t *cuPdcchCfg, PdcchConfig *macPdcchCfg)
7981 uint8_t cRsetIdx = 0;
7982 uint8_t srchSpcIdx = 0;
7984 struct PDCCH_Config__controlResourceSetToAddModList *cRsetToAddModList = NULLP;
7985 struct PDCCH_Config__controlResourceSetToReleaseList *cRsetToRelList = NULLP;
7986 struct PDCCH_Config__searchSpacesToAddModList *srchSpcToAddModList = NULLP;
7987 struct PDCCH_Config__searchSpacesToReleaseList *srchSpcToRelList = NULLP;
7990 /* Control Resource Set To Add/Mod List */
7991 if(cuPdcchCfg->controlResourceSetToAddModList)
7993 cRsetToAddModList = cuPdcchCfg->controlResourceSetToAddModList;
7994 if(cRsetToAddModList->list.count)
7996 macPdcchCfg->numCRsetToAddMod = cRsetToAddModList->list.count;
7997 for(cRsetIdx = 0; cRsetIdx < cRsetToAddModList->list.count; cRsetIdx++)
7999 macPdcchCfg->cRSetToAddModList[cRsetIdx].cRSetId = \
8000 cRsetToAddModList->list.array[cRsetIdx]->controlResourceSetId;
8001 bitStringToInt(&cRsetToAddModList->list.array[cRsetIdx]->frequencyDomainResources,\
8002 macPdcchCfg->cRSetToAddModList[cRsetIdx].freqDomainRsrc);
8003 macPdcchCfg->cRSetToAddModList[cRsetIdx].duration = \
8004 cRsetToAddModList->list.array[cRsetIdx]->duration;
8006 macPdcchCfg->cRSetToAddModList[cRsetIdx].cceRegMappingType = \
8007 cRsetToAddModList->list.array[cRsetIdx]->cce_REG_MappingType.present;
8008 if(macPdcchCfg->cRSetToAddModList[cRsetIdx].cceRegMappingType == CCE_REG_MAPPINGTYPE_PR_INTERLEAVED)
8010 //TODO: handle the case for Interleaved
8012 macPdcchCfg->cRSetToAddModList[cRsetIdx].precoderGranularity = \
8013 cRsetToAddModList->list.array[cRsetIdx]->precoderGranularity;
8014 if(cRsetToAddModList->list.array[cRsetIdx]->pdcch_DMRS_ScramblingID)
8016 macPdcchCfg->cRSetToAddModList[cRsetIdx].dmrsScramblingId= \
8017 *(cRsetToAddModList->list.array[cRsetIdx]->pdcch_DMRS_ScramblingID);
8023 /* Control Resource Set To Release List */
8024 if(cuPdcchCfg->controlResourceSetToReleaseList)
8026 cRsetToRelList = cuPdcchCfg->controlResourceSetToReleaseList;
8027 if(cRsetToRelList->list.count)
8029 macPdcchCfg->numCRsetToRel = cRsetToRelList->list.count;
8030 for(cRsetIdx = 0; cRsetIdx < cRsetToRelList->list.count; cRsetIdx++)
8032 macPdcchCfg->cRSetToRelList[cRsetIdx] = *(cRsetToRelList->list.array[cRsetIdx]);
8037 /* Search space To Add/Mod List */
8038 if(cuPdcchCfg->searchSpacesToAddModList)
8040 srchSpcToAddModList = cuPdcchCfg->searchSpacesToAddModList;
8041 if(srchSpcToAddModList->list.count)
8043 macPdcchCfg->numSearchSpcToAddMod = srchSpcToAddModList->list.count;
8044 for(srchSpcIdx = 0; srchSpcIdx < srchSpcToAddModList->list.count; srchSpcIdx++)
8046 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceId =\
8047 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceId;
8048 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].cRSetId =\
8049 *(srchSpcToAddModList->list.array[srchSpcIdx]->controlResourceSetId);
8050 if(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSlotPeriodicityAndOffset)
8052 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].mSlotPeriodicityAndOffset =\
8053 srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSlotPeriodicityAndOffset->present;
8055 if(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSymbolsWithinSlot)
8057 bitStringToInt(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSymbolsWithinSlot,\
8058 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].mSymbolsWithinSlot);
8060 if(srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates)
8062 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel1 = \
8063 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel1;
8064 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel2 = \
8065 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel2;
8066 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel4 = \
8067 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel4;
8069 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel8 = \
8070 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel8;
8072 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel16 = \
8073 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel16;
8075 if(srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType)
8077 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceType =\
8078 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType->present;
8079 if(macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceType == SEARCHSPACETYPE_PR_UE_SPECIFIC)
8081 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].ueSpecificDciFormat =\
8082 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType->choice.ue_Specific->dci_Formats;
8089 /* Search space To Rel List */
8090 if(cuPdcchCfg->searchSpacesToReleaseList)
8092 srchSpcToRelList = cuPdcchCfg->searchSpacesToReleaseList;
8093 if(srchSpcToRelList->list.count)
8095 macPdcchCfg->numSearchSpcToRel = srchSpcToRelList->list.count;
8096 for(srchSpcIdx = 0; srchSpcIdx < srchSpcToRelList->list.count; srchSpcIdx++)
8098 macPdcchCfg->searchSpcToRelList[srchSpcIdx] =\
8099 *(srchSpcToRelList->list.array[srchSpcIdx]);
8105 /*******************************************************************
8107 * @brief Fills PdschCfg received by CU
8111 * Function : extractPdschCfg
8113 * Functionality: Fills PdschCfg received by CU
8115 * @params[in] PDSCH_Config_t *cuPdschCfg,
8116 * PdschConfig *macPdschCfg
8119 * ****************************************************************/
8121 void extractPdschCfg(PDSCH_Config_t *cuPdschCfg, PdschConfig *macPdschCfg)
8124 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAlloc = NULLP;
8126 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
8128 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->present == \
8129 PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA_PR_setup)
8131 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)
8133 macPdschCfg->dmrsDlCfgForPdschMapTypeA.addPos = \
8134 *(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition);
8138 macPdschCfg->resourceAllocType = cuPdschCfg->resourceAllocation;
8139 if(cuPdschCfg->pdsch_TimeDomainAllocationList)
8141 timeDomAlloc = cuPdschCfg->pdsch_TimeDomainAllocationList;
8142 if(timeDomAlloc->present ==\
8143 PDSCH_Config__pdsch_TimeDomainAllocationList_PR_setup)
8145 if(timeDomAlloc->choice.setup)
8147 macPdschCfg->numTimeDomRsrcAlloc = timeDomAlloc->choice.setup->list.count;
8148 for(timeDomIdx = 0; timeDomIdx < timeDomAlloc->choice.setup->list.count; timeDomIdx++)
8150 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0 = NULLP;
8151 if(timeDomAlloc->choice.setup->list.array[timeDomIdx]->k0)
8153 if(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0 == NULL)
8155 DU_ALLOC_SHRABL_BUF(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0, sizeof(uint8_t));
8156 if(!macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0)
8158 DU_LOG("\nERROR --> DU APP : Memory allocation failed for k0 at extractPdschCfg()");
8162 *(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0) = \
8163 *(timeDomAlloc->choice.setup->list.array[timeDomIdx]->k0);
8165 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].mappingType = \
8166 timeDomAlloc->choice.setup->list.array[timeDomIdx]->mappingType;
8167 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].startSymbolAndLength = \
8168 timeDomAlloc->choice.setup->list.array[timeDomIdx]->startSymbolAndLength;
8173 macPdschCfg->rbgSize = cuPdschCfg->rbg_Size;
8174 if(cuPdschCfg->maxNrofCodeWordsScheduledByDCI)
8175 macPdschCfg->numCodeWordsSchByDci = *(cuPdschCfg->maxNrofCodeWordsScheduledByDCI);
8176 if(cuPdschCfg->prb_BundlingType.present == PDSCH_Config__prb_BundlingType_PR_staticBundling)
8178 macPdschCfg->bundlingType = cuPdschCfg->prb_BundlingType.present;
8179 if(cuPdschCfg->prb_BundlingType.choice.staticBundling)
8181 if(cuPdschCfg->prb_BundlingType.choice.staticBundling->bundleSize)
8183 macPdschCfg->bundlingInfo.StaticBundling.size = \
8184 *(cuPdschCfg->prb_BundlingType.choice.staticBundling->bundleSize);
8188 else if(cuPdschCfg->prb_BundlingType.present == PDSCH_Config__prb_BundlingType_PR_dynamicBundling)
8190 macPdschCfg->bundlingType = cuPdschCfg->prb_BundlingType.present;
8195 /*******************************************************************
8197 * @brief Fills PdschServingCellCfg received by CU
8201 * Function : extractPdschServingCellCfg
8203 * Functionality: Fills PdschCfg received by CU
8205 * @params[in] PDSCH_ServingCellConfig_t *cuPdschSrvCellCfg,
8206 * PdschServCellCfg *macUePdschSrvCellCfg
8207 * @return ROK/RFAILED
8209 * ****************************************************************/
8211 uint8_t extractPdschServingCellCfg(PDSCH_ServingCellConfig_t *cuPdschSrvCellCfg, PdschServCellCfg *macUePdschSrvCellCfg)
8213 if(cuPdschSrvCellCfg->codeBlockGroupTransmission)
8215 if(cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup)
8217 if(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb)
8219 *(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb) = \
8220 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock;
8224 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
8225 if(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb)
8227 *(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb) = \
8228 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock;
8232 DU_LOG("\nERROR --> DU APP : Memory allocation failed for maxCodeBlkGrpPerTb at extractPdschServingCellCfg()");
8236 if(macUePdschSrvCellCfg->codeBlkGrpFlushInd)
8238 *(macUePdschSrvCellCfg->codeBlkGrpFlushInd) = \
8239 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->codeBlockGroupFlushIndicator;
8243 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->codeBlkGrpFlushInd , sizeof(bool));
8244 if(macUePdschSrvCellCfg->codeBlkGrpFlushInd)
8246 *(macUePdschSrvCellCfg->codeBlkGrpFlushInd) = \
8247 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->codeBlockGroupFlushIndicator;
8251 DU_LOG("\nERROR --> DU APP : Memory allocation failed for codeBlkGrpFlushInd at extractPdschServingCellCfg()");
8257 if(cuPdschSrvCellCfg->nrofHARQ_ProcessesForPDSCH)
8259 macUePdschSrvCellCfg->numHarqProcForPdsch = *(cuPdschSrvCellCfg->nrofHARQ_ProcessesForPDSCH);
8261 if(cuPdschSrvCellCfg->ext1)
8263 if(cuPdschSrvCellCfg->ext1->maxMIMO_Layers)
8265 if(macUePdschSrvCellCfg->maxMimoLayers)
8267 *(macUePdschSrvCellCfg->maxMimoLayers) = *(cuPdschSrvCellCfg->ext1->maxMIMO_Layers);
8271 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->maxMimoLayers, sizeof(uint8_t));
8272 if(macUePdschSrvCellCfg->maxMimoLayers)
8274 *(macUePdschSrvCellCfg->maxMimoLayers) = *(cuPdschSrvCellCfg->ext1->maxMIMO_Layers);
8278 DU_LOG("\nERROR --> DU APP : Memory allocation failed for maxMimoLayers at extractPdschServingCellCfg()");
8284 if(cuPdschSrvCellCfg->xOverhead)
8286 if(macUePdschSrvCellCfg->xOverhead)
8288 *(macUePdschSrvCellCfg->xOverhead) = *(cuPdschSrvCellCfg->xOverhead);
8292 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->xOverhead, sizeof(PdschXOverhead));
8293 if(macUePdschSrvCellCfg->xOverhead)
8295 *(macUePdschSrvCellCfg->xOverhead) = *(cuPdschSrvCellCfg->xOverhead);
8299 DU_LOG("\nERROR --> DU APP : Memory allocation failed for xOverhead at extractPdschServingCellCfg()");
8307 /*******************************************************************
8309 * @brief Fills PuschCfg received by CU
8313 * Function : extractPuschCfg
8315 * Functionality: Fills PuschCfg received by CU
8317 * @params[in] BWP_UplinkDedicated__pusch_Config *cuPuschCfg,
8318 * PuschCfg *macPuschCfg
8321 * ****************************************************************/
8323 void extractPuschCfg(struct BWP_UplinkDedicated__pusch_Config *cuPuschCfg, PuschCfg *macPuschCfg)
8325 uint8_t timeDomIdx = 0;
8326 DMRS_UplinkConfig_t *dmrsUlCfg = NULLP;
8327 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList = NULLP;
8329 if(cuPuschCfg->present == BWP_UplinkDedicated__pusch_Config_PR_setup)
8331 if(cuPuschCfg->choice.setup)
8333 if(cuPuschCfg->choice.setup->dataScramblingIdentityPUSCH)
8335 macPuschCfg->dataScramblingId = \
8336 *(cuPuschCfg->choice.setup->dataScramblingIdentityPUSCH);
8338 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA)
8340 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->present == PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA_PR_setup)
8342 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup)
8344 dmrsUlCfg = (cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup);
8345 if(dmrsUlCfg->dmrs_AdditionalPosition)
8347 macPuschCfg->dmrsUlCfgForPuschMapTypeA.addPos =\
8348 *(dmrsUlCfg->dmrs_AdditionalPosition);
8350 if(dmrsUlCfg->transformPrecodingDisabled)
8352 if(dmrsUlCfg->transformPrecodingDisabled->scramblingID0)
8354 macPuschCfg->dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0 = \
8355 *(dmrsUlCfg->transformPrecodingDisabled->scramblingID0);
8361 /*Res Alloc Type for UL */
8362 if(cuPuschCfg->choice.setup->resourceAllocation)
8364 macPuschCfg->resourceAllocType = \
8365 cuPuschCfg->choice.setup->resourceAllocation;
8367 if(cuPuschCfg->choice.setup->pusch_TimeDomainAllocationList)
8369 timeDomAllocList = cuPuschCfg->choice.setup->pusch_TimeDomainAllocationList;
8370 if(timeDomAllocList->present == PUSCH_Config__pusch_TimeDomainAllocationList_PR_setup)
8372 if(timeDomAllocList->choice.setup)
8374 macPuschCfg->numTimeDomRsrcAlloc = timeDomAllocList->choice.setup->list.count;
8375 for(timeDomIdx = 0; timeDomIdx <timeDomAllocList->choice.setup->list.count; timeDomIdx++)
8377 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].k2 = \
8378 *(timeDomAllocList->choice.setup->list.array[timeDomIdx]->k2);
8379 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].mappingType = \
8380 timeDomAllocList->choice.setup->list.array[timeDomIdx]->mappingType;
8381 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].startSymbolAndLength = \
8382 timeDomAllocList->choice.setup->list.array[timeDomIdx]->startSymbolAndLength;
8387 if(cuPuschCfg->choice.setup->transformPrecoder)
8388 macPuschCfg->transformPrecoder = *(cuPuschCfg->choice.setup->transformPrecoder);
8393 /*******************************************************************
8395 * @brief Function to fill pucch Power Control
8399 * Function : extractPucchPowerControl
8401 * Functionality: Function to fill pucch Power Control
8403 * @params[in] PucchPowerControl *pwrCtrl,
8404 * struct PUCCH_PowerControl *cuPwrCtrlCfg
8407 * ****************************************************************/
8409 void extractPucchPowerControl(PucchPowerControl *pwrCtrl, struct PUCCH_PowerControl *cuPwrCtrlCfg)
8413 if(cuPwrCtrlCfg->deltaF_PUCCH_f0)
8414 pwrCtrl->deltaF_Format0 = *cuPwrCtrlCfg->deltaF_PUCCH_f0;
8415 if(cuPwrCtrlCfg->deltaF_PUCCH_f1)
8416 pwrCtrl->deltaF_Format1 = *cuPwrCtrlCfg->deltaF_PUCCH_f1;
8417 if(cuPwrCtrlCfg->deltaF_PUCCH_f2)
8418 pwrCtrl->deltaF_Format2 = *cuPwrCtrlCfg->deltaF_PUCCH_f2;
8419 if(cuPwrCtrlCfg->deltaF_PUCCH_f3)
8420 pwrCtrl->deltaF_Format3 = *cuPwrCtrlCfg->deltaF_PUCCH_f3;
8421 if(cuPwrCtrlCfg->deltaF_PUCCH_f4)
8422 pwrCtrl->deltaF_Format4 = *cuPwrCtrlCfg->deltaF_PUCCH_f4;
8423 if(cuPwrCtrlCfg->p0_Set)
8425 pwrCtrl->p0SetCount = cuPwrCtrlCfg->p0_Set->list.count;
8426 for(arrIdx=0; arrIdx < pwrCtrl->p0SetCount; arrIdx++)
8428 pwrCtrl->p0Set[arrIdx].p0PucchId =\
8429 cuPwrCtrlCfg->p0_Set->list.array[arrIdx]->p0_PUCCH_Id;
8430 pwrCtrl->p0Set[arrIdx].p0PucchVal =\
8431 cuPwrCtrlCfg->p0_Set->list.array[arrIdx]->p0_PUCCH_Value;
8434 if(cuPwrCtrlCfg->pathlossReferenceRSs)
8436 pwrCtrl->pathLossRefRSListCount = cuPwrCtrlCfg->pathlossReferenceRSs->list.count;
8437 for(arrIdx = 0; arrIdx < pwrCtrl->pathLossRefRSListCount; arrIdx++)
8439 pwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId =\
8440 cuPwrCtrlCfg->pathlossReferenceRSs->list.array[arrIdx]->pucch_PathlossReferenceRS_Id;
8445 /*******************************************************************
8447 * @brief Function to extractResrcSetToAddModList sent by CU
8451 * Function : extractResrcSetToAddModList
8453 * Functionality: Fucntion to extractResrcSetToAddModList
8455 * @params[in] PucchResrcSetCfg pointer,
8456 * struct PUCCH_Config__resourceSetToAddModList pointer
8459 * ****************************************************************/
8461 void extractResrcSetToAddModList(PucchResrcSetCfg *macRsrcSetList, struct PUCCH_Config__resourceSetToAddModList *cuRsrcSetList)
8463 uint8_t arrIdx, rsrcListIdx;
8465 macRsrcSetList->resrcSetToAddModListCount = cuRsrcSetList->list.count;
8466 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToAddModListCount; arrIdx++)
8468 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId =\
8469 cuRsrcSetList->list.array[arrIdx]->pucch_ResourceSetId;
8470 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount =\
8471 cuRsrcSetList->list.array[arrIdx]->resourceList.list.count;
8472 for(rsrcListIdx = 0; rsrcListIdx < macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount; rsrcListIdx++)
8474 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx] =\
8475 *cuRsrcSetList->list.array[arrIdx]->resourceList.list.array[rsrcListIdx];
8477 macRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize =\
8478 *cuRsrcSetList->list.array[arrIdx]->maxPayloadMinus1;
8480 }/* End of extractResrcSetToAddModList */
8482 /*******************************************************************
8484 * @brief Fills extractResrcToAddModList sent by CU
8488 * Function : extractResrcToAddModList
8490 * Functionality: Fills extractResrcToAddModList
8492 * @params[in] PucchResrcCfg pointer,
8493 * struct PUCCH_Config__resourceToAddModList pointer
8494 * @return ROk/RFAILED
8496 * ****************************************************************/
8498 uint8_t extractResrcToAddModList(PucchResrcCfg *macResrcList, struct PUCCH_Config__resourceToAddModList *cuResrcList)
8502 macResrcList->resrcToAddModListCount = cuResrcList->list.count;
8503 for(arrIdx = 0; arrIdx < macResrcList->resrcToAddModListCount; arrIdx++)
8505 macResrcList->resrcToAddModList[arrIdx].resrcId =\
8506 cuResrcList->list.array[arrIdx]->pucch_ResourceId;
8507 macResrcList->resrcToAddModList[arrIdx].startPrb =\
8508 cuResrcList->list.array[arrIdx]->startingPRB;
8509 if(cuResrcList->list.array[arrIdx]->intraSlotFrequencyHopping)
8511 macResrcList->resrcToAddModList[arrIdx].intraFreqHop =\
8512 *cuResrcList->list.array[arrIdx]->intraSlotFrequencyHopping;
8514 if(cuResrcList->list.array[arrIdx]->secondHopPRB)
8516 macResrcList->resrcToAddModList[arrIdx].secondPrbHop =\
8517 *cuResrcList->list.array[arrIdx]->secondHopPRB;
8519 /* PUCCH RSRC FORMAT */
8520 if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format0)
8522 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_0;
8523 if(cuResrcList->list.array[arrIdx]->format.choice.format0)
8525 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0, sizeof(PucchFormat0));
8526 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0 == NULLP)
8528 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format0 in extractResrcToAddModList()");
8531 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->initialCyclicShift =\
8532 cuResrcList->list.array[arrIdx]->format.choice.format0->initialCyclicShift;
8533 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->numSymbols =\
8534 cuResrcList->list.array[arrIdx]->format.choice.format0->nrofSymbols;
8535 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->startSymbolIdx =\
8536 cuResrcList->list.array[arrIdx]->format.choice.format0->startingSymbolIndex;
8539 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format1)
8541 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_1;
8542 if(cuResrcList->list.array[arrIdx]->format.choice.format1)
8544 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1, sizeof(PucchFormat1));
8545 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1 == NULLP)
8547 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format1 in extractResrcToAddModList()");
8550 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->initialCyclicShift =\
8551 cuResrcList->list.array[arrIdx]->format.choice.format1->initialCyclicShift;
8552 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->numSymbols =\
8553 cuResrcList->list.array[arrIdx]->format.choice.format1->nrofSymbols;
8554 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->startSymbolIdx =\
8555 cuResrcList->list.array[arrIdx]->format.choice.format1->startingSymbolIndex;
8556 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->timeDomOCC =\
8557 cuResrcList->list.array[arrIdx]->format.choice.format1->timeDomainOCC;
8560 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format2)
8562 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_2;
8563 if(cuResrcList->list.array[arrIdx]->format.choice.format2)
8565 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2, sizeof(PucchFormat2_3));
8566 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2 == NULLP)
8568 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format2 in extractResrcToAddModList()");
8571 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->numPrbs =\
8572 cuResrcList->list.array[arrIdx]->format.choice.format2->nrofPRBs;
8573 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->numSymbols =\
8574 cuResrcList->list.array[arrIdx]->format.choice.format2->nrofSymbols;
8575 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->startSymbolIdx =\
8576 cuResrcList->list.array[arrIdx]->format.choice.format2->startingSymbolIndex;
8579 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format3)
8581 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_3;
8582 if(cuResrcList->list.array[arrIdx]->format.choice.format3)
8584 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3, sizeof(PucchFormat2_3));
8585 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3 == NULLP)
8587 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format3 in extractResrcToAddModList()");
8590 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->numPrbs =\
8591 cuResrcList->list.array[arrIdx]->format.choice.format3->nrofPRBs;
8592 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->numSymbols =\
8593 cuResrcList->list.array[arrIdx]->format.choice.format3->nrofSymbols;
8594 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->startSymbolIdx =\
8595 cuResrcList->list.array[arrIdx]->format.choice.format3->startingSymbolIndex;
8598 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format4)
8600 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_4;
8601 if(cuResrcList->list.array[arrIdx]->format.choice.format4)
8603 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4, sizeof(PucchFormat4));
8604 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4 == NULLP)
8606 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format4 in extractResrcToAddModList()");
8609 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->numSymbols =\
8610 cuResrcList->list.array[arrIdx]->format.choice.format4->nrofSymbols;
8611 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->occLen =\
8612 cuResrcList->list.array[arrIdx]->format.choice.format4->occ_Length;
8613 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->occIdx =\
8614 cuResrcList->list.array[arrIdx]->format.choice.format4->occ_Index;
8615 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->startSymbolIdx =\
8616 cuResrcList->list.array[arrIdx]->format.choice.format4->startingSymbolIndex;
8622 }/* End of extractResrcToAddModList */
8624 /*******************************************************************
8626 * @brief Fills fillPucchSchedReqPeriodAndOffset sent by CU
8630 * Function : fillPucchSchedReqPeriodAndOffset
8632 * Functionality: To fillPucchSchedReqPeriodAndOffset
8634 * @params[in] macPeriodicty,
8635 * SchedulingRequestResourceConfig__periodicityAndOffset pointer
8638 * ****************************************************************/
8640 void fillPucchSchedReqPeriodAndOffset(uint8_t macPeriodicty, uint16_t macOffset,\
8641 struct SchedulingRequestResourceConfig__periodicityAndOffset *cuPeriodicty)
8643 macPeriodicty = cuPeriodicty->present;
8644 switch(macPeriodicty)
8646 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sym2:
8648 macOffset = cuPeriodicty->choice.sym2;
8651 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sym6or7:
8653 macOffset = cuPeriodicty->choice.sym6or7;
8656 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl1:
8658 macOffset = cuPeriodicty->choice.sl1;
8661 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl2:
8663 macOffset = cuPeriodicty->choice.sl2;
8666 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl4:
8668 macOffset = cuPeriodicty->choice.sl4;
8671 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl5:
8673 macOffset = cuPeriodicty->choice.sl5;
8676 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl8:
8678 macOffset = cuPeriodicty->choice.sl8;
8681 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl10:
8683 macOffset = cuPeriodicty->choice.sl10;
8686 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl16:
8688 macOffset = cuPeriodicty->choice.sl16;
8691 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl20:
8693 macOffset = cuPeriodicty->choice.sl20;
8696 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl40:
8698 macOffset = cuPeriodicty->choice.sl40;
8701 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl80:
8703 macOffset = cuPeriodicty->choice.sl80;
8706 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl160:
8708 macOffset = cuPeriodicty->choice.sl160;
8711 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl320:
8713 macOffset = cuPeriodicty->choice.sl320;
8716 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl640:
8718 macOffset = cuPeriodicty->choice.sl640;
8722 DU_LOG("\nERROR --> F1AP : Invalid periodicity %d", macPeriodicty);
8726 /*******************************************************************
8728 * @brief Function to extractPucchFormatCfg sent by CU
8732 * Function : extractPucchFormatCfg
8734 * Functionality: Function to extractPucchFormatCfg
8736 * @params[in] PucchFormatCfg pointer,
8737 * PUCCH_FormatConfig_t pointer
8740 * ****************************************************************/
8742 void extractPucchFormatCfg(PucchFormatCfg *macFormatCfg, PUCCH_FormatConfig_t *cuFormatCfg)
8744 if(cuFormatCfg->interslotFrequencyHopping)
8745 macFormatCfg->interSlotFreqHop = *cuFormatCfg->interslotFrequencyHopping;
8746 if(cuFormatCfg->additionalDMRS)
8747 macFormatCfg->addDmrs = *cuFormatCfg->additionalDMRS;
8748 if(cuFormatCfg->maxCodeRate)
8749 macFormatCfg->maxCodeRate = *cuFormatCfg->maxCodeRate;
8750 if(cuFormatCfg->nrofSlots)
8751 macFormatCfg->numSlots = *cuFormatCfg->nrofSlots;
8752 if(cuFormatCfg->pi2BPSK)
8753 macFormatCfg->pi2BPSK = *cuFormatCfg->pi2BPSK;
8754 if(cuFormatCfg->simultaneousHARQ_ACK_CSI)
8755 macFormatCfg->harqAckCSI = *cuFormatCfg->simultaneousHARQ_ACK_CSI;
8756 }/* End of extractPucchFormatCfg */
8758 /*******************************************************************
8760 * @brief Function to extractSchedReqCfgToAddMod sent by CU
8764 * Function : extractSchedReqCfgToAddMod
8766 * Functionality: Function to extractSchedReqCfgToAddMod
8768 * @params[in] PucchSchedReqCfg pointer,
8769 * PUCCH_Config__schedulingRequestResourceToAddModList pointer
8772 * ****************************************************************/
8774 void extractSchedReqCfgToAddMod(PucchSchedReqCfg *macSchedReqCfg, struct PUCCH_Config__schedulingRequestResourceToAddModList *cuSchedReqList)
8778 macSchedReqCfg->schedAddModListCount = cuSchedReqList->list.count;
8779 for(arrIdx = 0; arrIdx < macSchedReqCfg->schedAddModListCount; arrIdx++)
8781 macSchedReqCfg->schedAddModList[arrIdx].resrcId =\
8782 cuSchedReqList->list.array[arrIdx]->schedulingRequestResourceId;
8783 macSchedReqCfg->schedAddModList[arrIdx].requestId =\
8784 cuSchedReqList->list.array[arrIdx]->schedulingRequestID;
8785 if(cuSchedReqList->list.array[arrIdx]->periodicityAndOffset)
8787 fillPucchSchedReqPeriodAndOffset(macSchedReqCfg->schedAddModList[arrIdx].periodicity,\
8788 macSchedReqCfg->schedAddModList[arrIdx].offset, cuSchedReqList->list.array[arrIdx]->periodicityAndOffset);
8790 if(cuSchedReqList->list.array[arrIdx]->resource)
8792 macSchedReqCfg->schedAddModList[arrIdx].resrc =\
8793 *cuSchedReqList->list.array[arrIdx]->resource;
8797 }/* End of extractSchedReqCfgToAddMod */
8799 /*******************************************************************
8801 * @brief Fills PucchCfg received by CU
8805 * Function : extractPucchCfg
8807 * Functionality: Fills PucchCfg received by CU
8809 * @params[in] BWP_UplinkDedicated__pucch_Config *cuPucchCfg,
8810 * PucchCfg *macPucchCfg
8811 * @return ROK/RFAILED
8813 * ****************************************************************/
8815 uint8_t extractPucchCfg(struct BWP_UplinkDedicated__pucch_Config *cuPucchCfg, PucchCfg *macPucchCfg)
8819 if(cuPucchCfg->present == BWP_UplinkDedicated__pucch_Config_PR_setup)
8821 if(cuPucchCfg->choice.setup)
8823 /* Resource Set Cfg */
8824 if(cuPucchCfg->choice.setup->resourceSetToAddModList)
8826 DU_ALLOC_SHRABL_BUF(macPucchCfg->resrcSet, sizeof(PucchResrcSetCfg));
8827 if(macPucchCfg->resrcSet == NULLP)
8829 DU_LOG("\nERROR --> F1AP : Failed to extract Resrc set List in extractPucchCfg()");
8832 memset(macPucchCfg->resrcSet, 0, sizeof(PucchResrcSetCfg));
8833 extractResrcSetToAddModList(macPucchCfg->resrcSet, cuPucchCfg->choice.setup->resourceSetToAddModList);
8837 if(cuPucchCfg->choice.setup->resourceToAddModList)
8839 DU_ALLOC_SHRABL_BUF(macPucchCfg->resrc, sizeof(PucchResrcCfg));
8840 if(macPucchCfg->resrc == NULLP)
8842 DU_LOG("\nERROR --> F1AP : Failed to extract Resrc List in extractPucchCfg()");
8845 memset(macPucchCfg->resrc, 0, sizeof(PucchResrcCfg));
8846 extractResrcToAddModList(macPucchCfg->resrc, cuPucchCfg->choice.setup->resourceToAddModList);
8850 if(cuPucchCfg->choice.setup->format1)
8852 DU_ALLOC_SHRABL_BUF(macPucchCfg->format1, sizeof(PucchFormatCfg));
8853 if(macPucchCfg->format1 == NULLP)
8855 DU_LOG("\nERROR --> F1AP : Failed to extract format 1 Cfg in extractPucchCfg()");
8858 memset(macPucchCfg->format1, 0, sizeof(PucchFormatCfg));
8859 extractPucchFormatCfg(macPucchCfg->format1,\
8860 cuPucchCfg->choice.setup->format1->choice.setup);
8864 if(cuPucchCfg->choice.setup->format2)
8866 DU_ALLOC_SHRABL_BUF(macPucchCfg->format2, sizeof(PucchFormatCfg));
8867 if(macPucchCfg->format2 == NULLP)
8869 DU_LOG("\nERROR --> F1AP : Failed to extract format 2 Cfg in extractPucchCfg()");
8872 memset(macPucchCfg->format2, 0, sizeof(PucchFormatCfg));
8873 extractPucchFormatCfg(macPucchCfg->format2,\
8874 cuPucchCfg->choice.setup->format2->choice.setup);
8878 if(cuPucchCfg->choice.setup->format3)
8880 DU_ALLOC_SHRABL_BUF(macPucchCfg->format3, sizeof(PucchFormatCfg));
8881 if(macPucchCfg->format3 == NULLP)
8883 DU_LOG("\nERROR --> F1AP : Failed to extract format 3 Cfg in extractPucchCfg()");
8886 memset(macPucchCfg->format3, 0, sizeof(PucchFormatCfg));
8887 extractPucchFormatCfg(macPucchCfg->format3,\
8888 cuPucchCfg->choice.setup->format3->choice.setup);
8892 if(cuPucchCfg->choice.setup->format4)
8894 DU_ALLOC_SHRABL_BUF(macPucchCfg->format4, sizeof(PucchFormatCfg));
8895 if(macPucchCfg->format4 == NULLP)
8897 DU_LOG("\nERROR --> F1AP : Failed to extract format 4 Cfg in extractPucchCfg()");
8900 memset(macPucchCfg->format4, 0, sizeof(PucchFormatCfg));
8901 extractPucchFormatCfg(macPucchCfg->format4,\
8902 cuPucchCfg->choice.setup->format4->choice.setup);
8905 /* Sched Req List */
8906 if(cuPucchCfg->choice.setup->schedulingRequestResourceToAddModList)
8908 DU_ALLOC_SHRABL_BUF(macPucchCfg->schedReq, sizeof(PucchSchedReqCfg));
8909 if(macPucchCfg->schedReq == NULLP)
8911 DU_LOG("\nERROR --> F1AP : Failed to extract schedReqCfg in extractPucchCfg()");
8914 memset(macPucchCfg->schedReq, 0, sizeof(PucchSchedReqCfg));
8915 extractSchedReqCfgToAddMod(macPucchCfg->schedReq,\
8916 cuPucchCfg->choice.setup->schedulingRequestResourceToAddModList);
8919 /*TODO: Add support for Spatial Info */
8922 if(cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList)
8924 DU_ALLOC_SHRABL_BUF(macPucchCfg->multiCsiCfg, sizeof(PucchMultiCsiCfg));
8925 if(macPucchCfg->multiCsiCfg == NULLP)
8927 DU_LOG("\nERROR --> F1AP : Failed to extract multiCsiCfg in extractPucchCfg()");
8930 memset(macPucchCfg->multiCsiCfg, 0, sizeof(PucchMultiCsiCfg));
8931 macPucchCfg->multiCsiCfg->multiCsiResrcListCount = cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList->list.count;
8932 for(arrIdx =0; arrIdx < macPucchCfg->multiCsiCfg->multiCsiResrcListCount; arrIdx++)
8934 macPucchCfg->multiCsiCfg->multiCsiResrcList[arrIdx] =\
8935 *cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList->list.array[arrIdx];
8939 /* Dl_DataToUL_ACK */
8940 if(cuPucchCfg->choice.setup->dl_DataToUL_ACK)
8942 DU_ALLOC_SHRABL_BUF(macPucchCfg->dlDataToUlAck, sizeof(PucchDlDataToUlAck));
8943 if(macPucchCfg->dlDataToUlAck == NULLP)
8945 DU_LOG("\nERROR --> F1AP : Failed to extract Dl_DataToUL_ACK in extractPucchCfg()");
8948 memset(macPucchCfg->dlDataToUlAck, 0, sizeof(PucchDlDataToUlAck));
8949 macPucchCfg->dlDataToUlAck->dlDataToUlAckListCount = cuPucchCfg->choice.setup->dl_DataToUL_ACK->list.count;
8950 for(arrIdx = 0; arrIdx < macPucchCfg->dlDataToUlAck->dlDataToUlAckListCount; arrIdx++)
8952 macPucchCfg->dlDataToUlAck->dlDataToUlAckList[arrIdx] =\
8953 *cuPucchCfg->choice.setup->dl_DataToUL_ACK->list.array[arrIdx];
8958 if(cuPucchCfg->choice.setup->pucch_PowerControl)
8960 DU_ALLOC_SHRABL_BUF(macPucchCfg->powerControl, sizeof(PucchPowerControl));
8961 if(macPucchCfg->powerControl == NULLP)
8963 DU_LOG("\nERROR --> F1AP : Failed to extract power control in extractPucchCfg()");
8966 extractPucchPowerControl(macPucchCfg->powerControl,\
8967 cuPucchCfg->choice.setup->pucch_PowerControl);
8974 /*******************************************************************
8976 * @brief Fills ServingCellReconfig received by CU
8980 * Function : extractSpCellDedicatedCfg
8982 * Functionality: Fills ServingCellReconfig received by CU
8984 * @params[in] ServingCellConfig_t *cuSrvCellCfg
8985 * ServCellCfgInfo *macSrvCellCfg
8986 * @return ROK/RFAILD
8988 * ****************************************************************/
8989 uint8_t extractSpCellDedicatedCfg(ServingCellConfig_t *cuSrvCellCfg, ServCellCfgInfo *macSrvCellCfg)
8992 BWP_DownlinkDedicated_t *dlBwp = NULLP;
8993 BWP_UplinkDedicated_t *ulBwp = NULLP;
8995 if(cuSrvCellCfg->initialDownlinkBWP)
8997 dlBwp = ((BWP_DownlinkDedicated_t *)(cuSrvCellCfg->initialDownlinkBWP));
8998 if(dlBwp->pdcch_Config)
9000 if(dlBwp->pdcch_Config->choice.setup)
9002 macSrvCellCfg->initDlBwp.pdcchPresent = true;
9003 extractPdcchCfg(dlBwp->pdcch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdcchCfg);
9006 if(dlBwp->pdsch_Config)
9008 if(dlBwp->pdsch_Config->choice.setup)
9010 macSrvCellCfg->initDlBwp.pdschPresent = true;
9011 extractPdschCfg(dlBwp->pdsch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdschCfg);
9015 if(cuSrvCellCfg->firstActiveDownlinkBWP_Id)
9016 macSrvCellCfg->firstActvDlBwpId = *(cuSrvCellCfg->firstActiveDownlinkBWP_Id);
9017 if(cuSrvCellCfg->defaultDownlinkBWP_Id)
9018 macSrvCellCfg->defaultDlBwpId = *(cuSrvCellCfg->defaultDownlinkBWP_Id);
9019 if(cuSrvCellCfg->bwp_InactivityTimer)
9021 if(macSrvCellCfg->bwpInactivityTmr)
9023 memcpy(macSrvCellCfg->bwpInactivityTmr, cuSrvCellCfg->bwp_InactivityTimer, sizeof(uint8_t));
9027 macSrvCellCfg->bwpInactivityTmr = NULLP;
9028 DU_ALLOC_SHRABL_BUF(macSrvCellCfg->bwpInactivityTmr, sizeof(uint8_t));
9029 if(macSrvCellCfg->bwpInactivityTmr)
9031 memcpy(macSrvCellCfg->bwpInactivityTmr, cuSrvCellCfg->bwp_InactivityTimer, sizeof(uint8_t));
9035 DU_LOG("\nERROR --> F1AP : Memory Alloc failed for bwpInactivityTmr at extractSpCellDedicatedCfg()");
9040 if(cuSrvCellCfg->pdsch_ServingCellConfig)
9042 if(cuSrvCellCfg->pdsch_ServingCellConfig->choice.setup)
9044 ret = extractPdschServingCellCfg(cuSrvCellCfg->pdsch_ServingCellConfig->choice.setup, &macSrvCellCfg->pdschServCellCfg);
9047 DU_LOG("\nERROR --> F1AP : Failed at extractPdschServingCellCfg()");
9052 if(cuSrvCellCfg->uplinkConfig)
9054 if(cuSrvCellCfg->uplinkConfig->initialUplinkBWP)
9056 ulBwp = ((BWP_UplinkDedicated_t *)(cuSrvCellCfg->uplinkConfig->initialUplinkBWP));
9057 if(ulBwp->pusch_Config)
9059 macSrvCellCfg->initUlBwp.puschPresent = true;
9060 extractPuschCfg(ulBwp->pusch_Config, &macSrvCellCfg->initUlBwp.puschCfg);
9062 if(ulBwp->pucch_Config)
9064 macSrvCellCfg->initUlBwp.pucchPresent = true;
9065 memset(&macSrvCellCfg->initUlBwp.pucchCfg, 0, sizeof(PucchCfg));
9066 extractPucchCfg(ulBwp->pucch_Config, &macSrvCellCfg->initUlBwp.pucchCfg);
9069 if(cuSrvCellCfg->uplinkConfig->firstActiveUplinkBWP_Id)
9070 macSrvCellCfg->firstActvUlBwpId = *(cuSrvCellCfg->uplinkConfig->firstActiveUplinkBWP_Id);
9074 /*******************************************************************
9076 * @brief Fills Reconfig Cell group Info received by CU
9080 * Function : extractUeReCfgCellInfo
9082 * Functionality: Fills Reconfig Cell group Info received by CU
9084 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
9085 * MacUeCfg* macUeCfg
9086 * @return ROK/RFAILED
9088 * ****************************************************************/
9089 uint8_t extractUeReCfgCellInfo(CellGroupConfigRrc_t *cellGrp, MacUeCfg *macUeCfg)
9092 MAC_CellGroupConfig_t *macCellGroup = NULLP;
9093 PhysicalCellGroupConfig_t *phyCellGrpCfg = NULLP;
9094 SpCellConfig_t *spcellCfg = NULLP;
9095 ServingCellConfig_t *servCellCfg = NULLP;
9099 /* Fill MacCell Group Reconfig */
9100 if(cellGrp->mac_CellGroupConfig)
9102 macUeCfg->macCellGrpCfgPres = true;
9103 macCellGroup = ((MAC_CellGroupConfig_t *)(cellGrp->mac_CellGroupConfig));
9104 if(macCellGroup->schedulingRequestConfig)
9106 extractSchReqReConfig(macCellGroup->schedulingRequestConfig, &macUeCfg->macCellGrpCfg.schReqCfg);
9108 if(macCellGroup->tag_Config)
9110 extractTagReconfig(macCellGroup->tag_Config, &macUeCfg->macCellGrpCfg.tagCfg);
9112 if(macCellGroup->bsr_Config)
9114 macUeCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer = macCellGroup->bsr_Config->periodicBSR_Timer;
9115 macUeCfg->macCellGrpCfg.bsrTmrCfg.retxTimer = macCellGroup->bsr_Config->retxBSR_Timer;
9116 if(macCellGroup->bsr_Config->logicalChannelSR_DelayTimer)
9118 macUeCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer =\
9119 *(macCellGroup->bsr_Config->logicalChannelSR_DelayTimer);
9122 if(macCellGroup->phr_Config)
9124 if(macCellGroup->phr_Config->present == MAC_CellGroupConfig__phr_Config_PR_setup)
9126 macUeCfg->macCellGrpCfg.phrCfgSetupPres = true;
9127 if(macCellGroup->phr_Config->choice.setup)
9129 macUeCfg->macCellGrpCfg.phrCfg.periodicTimer = \
9130 macCellGroup->phr_Config->choice.setup->phr_PeriodicTimer;
9131 macUeCfg->macCellGrpCfg.phrCfg.prohibitTimer = \
9132 macCellGroup->phr_Config->choice.setup->phr_ProhibitTimer;
9133 macUeCfg->macCellGrpCfg.phrCfg.txPowerFactor = \
9134 macCellGroup->phr_Config->choice.setup->phr_Tx_PowerFactorChange;
9135 macUeCfg->macCellGrpCfg.phrCfg.multiplePHR = \
9136 macCellGroup->phr_Config->choice.setup->multiplePHR;
9137 macUeCfg->macCellGrpCfg.phrCfg.dummy = \
9138 macCellGroup->phr_Config->choice.setup->dummy;
9139 macUeCfg->macCellGrpCfg.phrCfg.phrType2OtherCell = \
9140 macCellGroup->phr_Config->choice.setup->phr_Type2OtherCell;
9141 macUeCfg->macCellGrpCfg.phrCfg.phrOtherCG = \
9142 macCellGroup->phr_Config->choice.setup->phr_ModeOtherCG;
9147 /* Fill Physical Cell Group Reconfig */
9148 if(cellGrp->physicalCellGroupConfig)
9150 macUeCfg->phyCellGrpCfgPres = true;
9151 phyCellGrpCfg = ((PhysicalCellGroupConfig_t *)(cellGrp->physicalCellGroupConfig));
9152 if(phyCellGrpCfg->p_NR_FR1)
9154 if(*(phyCellGrpCfg->p_NR_FR1) != macUeCfg->phyCellGrpCfg.pNrFr1)
9155 macUeCfg->phyCellGrpCfg.pNrFr1 = *(phyCellGrpCfg->p_NR_FR1);
9157 macUeCfg->phyCellGrpCfg.pdschHarqAckCodebook = phyCellGrpCfg->pdsch_HARQ_ACK_Codebook;
9159 /* Fill SpCell Reconfig */
9160 if(cellGrp->spCellConfig)
9162 macUeCfg->spCellCfgPres = true;
9163 spcellCfg = ((SpCellConfig_t *)(cellGrp->spCellConfig));
9164 if(spcellCfg->servCellIndex)
9166 macUeCfg->spCellCfg.servCellIdx = *(spcellCfg->servCellIndex);
9168 /* Fill Serving cell Reconfig info */
9169 if(cellGrp->spCellConfig->spCellConfigDedicated)
9171 servCellCfg = ((ServingCellConfig_t *)(cellGrp->spCellConfig->spCellConfigDedicated));
9172 ret = extractSpCellDedicatedCfg(servCellCfg, &macUeCfg->spCellCfg.servCellCfg);
9175 DU_LOG("\nERROR --> F1AP : Failed at extractSpCellDedicatedCfg()");
9182 /*******************************************************************
9184 * @brief free the memory allocated by decoder
9188 * Function : freeAperDecodeNrcgi
9190 * Functionality: Free Nrcgi values
9192 * @params[in] NRCGI_t *nrcgi
9195 * ****************************************************************/
9198 void freeAperDecodeNrcgi(NRCGI_t *nrcgi)
9200 if(nrcgi->pLMN_Identity.buf != NULLP)
9202 free(nrcgi->pLMN_Identity.buf);
9204 if(nrcgi->nRCellIdentity.buf != NULLP)
9206 free(nrcgi->nRCellIdentity.buf);
9209 /*******************************************************************
9211 * @brief free the memory allocated by decoder
9215 * Function : freeAperDecodeCuToDuInfo
9217 * Functionality: Free Cu To Du Information
9219 * @params[in] CUtoDURRCInformation_t *rrcMsg
9222 * ****************************************************************/
9225 void freeAperDecodeCuToDuInfo(CUtoDURRCInformation_t *rrcMsg)
9230 if(rrcMsg->uE_CapabilityRAT_ContainerList)
9232 if(rrcMsg->uE_CapabilityRAT_ContainerList->buf)
9233 free(rrcMsg->uE_CapabilityRAT_ContainerList->buf);
9234 free(rrcMsg->uE_CapabilityRAT_ContainerList);
9237 if(rrcMsg->iE_Extensions)
9239 if(rrcMsg->iE_Extensions->list.array)
9241 for(ieIdx= 0; ieIdx < rrcMsg->iE_Extensions->list.count; ieIdx++)
9243 if(rrcMsg->iE_Extensions->list.array[ieIdx])
9245 switch(rrcMsg->iE_Extensions->list.array[ieIdx]->id)
9247 case ProtocolIE_ID_id_CellGroupConfig:
9248 if(rrcMsg->iE_Extensions->list.array[ieIdx]->extensionValue.choice.CellGroupConfig.buf != NULLP)
9250 free(rrcMsg->iE_Extensions->list.array[ieIdx]->extensionValue.choice.CellGroupConfig.buf);
9254 DU_LOG("\nERROR --> F1AP : Invalid Event type %ld at FreeCuToDuInfo()", \
9255 rrcMsg->iE_Extensions->list.array[ieIdx]->id);
9260 for(arrIdx = 0; arrIdx < ieIdx; arrIdx++)
9262 free(rrcMsg->iE_Extensions->list.array[arrIdx]);
9264 free(rrcMsg->iE_Extensions->list.array);
9268 free(rrcMsg->iE_Extensions);
9271 /*******************************************************************
9273 * @brief free the memory allocated by decoder
9277 * Function : freeAperDecodeSplCellList
9279 * Functionality: Free Spl Cell List
9280 where memory allocated by aper_decoder
9282 * @params[in] SCell_ToBeSetup_List_t *spCellLst
9285 * ****************************************************************/
9288 void freeAperDecodeSplCellList(SCell_ToBeSetup_List_t *spCellLst)
9292 if(spCellLst->list.array != NULLP)
9294 for(cellIdx=0; cellIdx<spCellLst->list.count; cellIdx++)
9296 if(cellIdx==0&&spCellLst->list.array[cellIdx]!=NULLP)
9298 freeAperDecodeNrcgi(&spCellLst->list.array[cellIdx]->value.choice.SCell_ToBeSetup_Item.sCell_ID);
9300 if(spCellLst->list.array[cellIdx]!=NULLP)
9302 free(spCellLst->list.array[cellIdx]);
9305 free(spCellLst->list.array);
9308 /*******************************************************************
9310 * @brief free the memory allocated by decoder
9314 * Function : freeAperDecodeSRBSetup
9316 * Functionality: added free part for the memory allocated by aper_decoder
9318 * @params[in] SRBs_ToBeSetup_List_t *srbSet
9321 ****************************************************************/
9324 void freeAperDecodeSRBSetup(SRBs_ToBeSetup_List_t *srbSet)
9327 if(srbSet->list.array != NULLP)
9329 for(srbIdx=0; srbIdx<srbSet->list.count; srbIdx++)
9331 if(srbSet->list.array[srbIdx]!=NULLP)
9333 free(srbSet->list.array[srbIdx]);
9336 free(srbSet->list.array);
9340 /*******************************************************************
9342 * @brief free the memory allocated by decoder
9346 * Function : freeAperDecodeULTnlInfo
9348 * Functionality: added free part for the memory allocated by aper_decoder
9350 * @params[in] ULUPTNLInformation_ToBeSetup_List_t *ulInfo
9353 * ****************************************************************/
9356 void freeAperDecodeULTnlInfo(ULUPTNLInformation_ToBeSetup_List_t *ulInfo)
9359 if(ulInfo->list.array != NULLP)
9361 for(ulIdx=0; ulIdx<ulInfo->list.count; ulIdx++)
9363 if(ulIdx==0&&ulInfo->list.array[ulIdx]!=NULLP)
9365 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel!=NULLP)
9367 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->\
9368 transportLayerAddress.buf != NULLP)
9370 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf\
9373 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf);
9375 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->\
9376 transportLayerAddress.buf);
9378 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel);
9381 if(ulInfo->list.array[ulIdx]!=NULLP)
9383 free(ulInfo->list.array[ulIdx]);
9386 free(ulInfo->list.array);
9389 /*******************************************************************
9391 * @brief free the memory allocated by decoder
9395 * Function : freeAperDecodeDRBSetup
9397 * Functionality: free DRBSetup which is allocated by decoder
9399 * @params[in] DRBs_ToBeSetup_List_t *drbSet
9402 * ****************************************************************/
9404 void freeAperDecodeDRBSetup(DRBs_ToBeSetup_List_t *drbSet)
9406 DRBs_ToBeSetup_Item_t *drbSetItem = NULLP;
9410 if(drbSet->list.array != NULLP)
9412 for(drbIdx=0; drbIdx<drbSet->list.count; drbIdx++)
9414 if(drbIdx==0&&drbSet->list.array[drbIdx] != NULLP)
9416 drbSetItem =&drbSet->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item;
9417 if(drbSetItem->qoSInformation.choice.choice_extension != NULLP)
9419 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9420 qoS_Characteristics.choice.non_Dynamic_5QI !=NULLP)
9422 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9423 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
9425 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9426 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
9429 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sST.buf!=NULLP)
9432 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD!=NULLP)
9435 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD->\
9439 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.\
9440 flows_Mapped_To_DRB_List.list.array != NULLP)
9443 for(flowIdx=0;flowIdx<drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9444 DRB_Information.flows_Mapped_To_DRB_List.list.count; flowIdx++)
9447 if(flowIdx==0&&drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9448 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]!=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!=NULLP)
9455 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9456 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9457 qoSFlowLevelQoSParameters.\
9458 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
9461 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9462 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9463 qoSFlowLevelQoSParameters.\
9464 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
9468 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9469 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9470 qoSFlowLevelQoSParameters.\
9471 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
9474 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9475 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9476 qoSFlowLevelQoSParameters.\
9477 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
9480 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9482 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9483 qoSFlowLevelQoSParameters.\
9484 qoS_Characteristics.choice.non_Dynamic_5QI);
9487 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9488 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]!=NULLP)
9491 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9492 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]);
9496 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9497 DRB_Information.flows_Mapped_To_DRB_List.list.array);
9500 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9501 DRB_Information.sNSSAI.sD->buf);
9504 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD);
9507 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sST.buf);
9511 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9513 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
9516 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9517 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
9520 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9521 qoS_Characteristics.choice.non_Dynamic_5QI);
9523 free(drbSetItem->qoSInformation.choice.choice_extension);
9525 freeAperDecodeULTnlInfo(&drbSetItem->uLUPTNLInformation_ToBeSetup_List);
9526 if(drbSetItem->uLConfiguration)
9528 free(drbSetItem->uLConfiguration);
9531 if(drbSet->list.array[drbIdx]!=NULLP)
9533 free(drbSet->list.array[drbIdx]);
9536 free(drbSet->list.array);
9541 /*******************************************************************
9543 * @brief builds Mac Cell Cfg
9547 * Function : procUeReCfgCellInfo
9549 * Functionality: builds Mac Cell Cfg
9551 * @params[in] MacUeCfg pointer
9556 * ****************************************************************/
9557 uint8_t procUeReCfgCellInfo(MacUeCfg *macUeCfgToSend, void *cellInfo)
9560 CellGroupConfigRrc_t *cellGrp = NULLP;
9564 cellGrp = (CellGroupConfigRrc_t *)cellInfo;
9565 ret = extractUeReCfgCellInfo(cellGrp, macUeCfgToSend);
9567 DU_LOG("\nERROR --> F1AP : Failed at procUeReCfgCellInfo()");
9571 freeUeReCfgCellGrpInfo(macUeCfgToSend);
9576 /*******************************************************************
9578 * @brief Filling modulation info in mac ue cfg
9582 * Function : duFillModulationDetails
9584 * Functionality: Filling modulation info in mac ue cfg
9586 * @params[in] MAC UE Config to be updated
9587 * Current UE configuration
9588 * UE NR capability from CU
9589 * @return ROK - success
9592 * ****************************************************************/
9593 void duFillModulationDetails(MacUeCfg *ueCfg, MacUeCfg *oldUeCfg, void *ueCap)
9595 UE_NR_Capability_t *ueNrCap=NULLP;
9599 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
9600 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
9604 ueNrCap = (UE_NR_Capability_t *)ueCap;
9606 /* Filling DL modulation info */
9607 if(ueNrCap->featureSets && ueNrCap->featureSets->featureSetsDownlinkPerCC && \
9608 ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0] && \
9609 ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0]->supportedModulationOrderDL)
9611 switch(*(ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0]->supportedModulationOrderDL))
9613 case ModulationOrder_qpsk:
9615 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
9618 case ModulationOrder_qam16:
9620 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM16;
9623 case ModulationOrder_qam64:
9625 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM64;
9626 ueCfg->dlModInfo.mcsIndex = PDSCH_MCS_INDEX;
9627 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64;
9630 case ModulationOrder_qam256:
9632 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM256;
9637 DU_LOG("\nERROR --> DU APP: Incorrect downlink modulation order received. Reatining old modulation configuration");
9638 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
9645 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
9648 /* Filling UL modulation info */
9649 if(ueNrCap->featureSets && ueNrCap->featureSets->featureSetsUplinkPerCC && \
9650 ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0] && \
9651 ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0]->supportedModulationOrderUL)
9653 switch(*(ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0]->supportedModulationOrderUL))
9655 case ModulationOrder_qpsk:
9657 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
9660 case ModulationOrder_qam16:
9662 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM16;
9663 ueCfg->ulModInfo.mcsIndex = PUSCH_MCS_INDEX;
9664 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64;
9667 case ModulationOrder_qam64:
9669 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM64;
9672 case ModulationOrder_qam256:
9674 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM256;
9679 DU_LOG("\nERROR --> DU APP: Incorrect uplink modulation order received. Reatining old modulation configuration");
9680 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
9687 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
9692 /*******************************************************************
9694 * @brief Function to extract cellGrp Info present in cutoDu cont
9698 * Function : extractCellGrpInfo
9700 * Functionality: Function to extract cellGrp Info present
9703 * @params[in] ProtocolExtensionContainer_4624P16_t pointer
9705 * @return CellGroupConfigRrc_t *
9707 * ****************************************************************/
9709 CellGroupConfigRrc_t *extractCellGrpInfo(ProtocolExtensionContainer_4624P16_t *protocolIeExtn,\
9714 uint16_t recvBufLen =0;
9715 CellGroupConfigRrc_t *cellGrpCfg = NULLP;
9716 CUtoDURRCInformation_ExtIEs_t *extIeInfo = NULLP;
9717 asn_dec_rval_t rval; /* Decoder return value */
9718 memset(&rval, 0, sizeof(asn_dec_rval_t));
9722 for(idx2 = 0; idx2 < protocolIeExtn->list.count; idx2++)
9724 extIeInfo = ((CUtoDURRCInformation_ExtIEs_t *)(protocolIeExtn->list.array[idx2]));
9728 case ProtocolIE_ID_id_CellGroupConfig:
9730 recvBufLen = extIeInfo->extensionValue.choice.CellGroupConfig.size;
9731 /* decoding the CellGroup Buf received */
9732 DU_ALLOC(cellGrpCfg, sizeof(CellGroupConfigRrc_t));
9735 memset(cellGrpCfg, 0, sizeof(CellGroupConfigRrc_t));
9736 rval = aper_decode(0, &asn_DEF_CellGroupConfigRrc, (void **)&cellGrpCfg,
9737 extIeInfo->extensionValue.choice.CellGroupConfig.buf, recvBufLen, 0, 0);
9738 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
9740 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
9743 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, cellGrpCfg);
9744 if(extractRlcCfgToAddMod(cellGrpCfg->rlc_BearerToAddModList, ueCfgDb))
9750 DU_LOG("\nERROR --> F1AP : Invalid IE received CUtoDURRCInformation:%d at decodeCellGrpCfg()", id);
9758 /*******************************************************************
9760 * @brief Fills Srb List received by CU
9764 * Function : procSrbListToSetup
9766 * Functionality: Fills Srb List received by CU
9768 * @params[in] SRBs_ToBeSetup_Item_t *cuSrbItem
9770 * RlcBearerCfg pointer
9773 * ****************************************************************/
9774 uint8_t procSrbListToSetup(SRBs_ToBeSetup_Item_t * srbItem, LcCfg *macLcToAdd, RlcBearerCfg *rlcLcToAdd)
9778 /* Filling RLC INFO */
9779 procRlcLcCfg(srbItem->sRBID, srbItem->sRBID, RB_TYPE_SRB, RLC_AM, CONFIG_ADD, NULL, rlcLcToAdd);
9781 /* Filling MAC INFO */
9782 ret = procMacLcCfg(srbItem->sRBID, RB_TYPE_SRB, CONFIG_ADD, NULL,NULL, NULL, macLcToAdd, NULL);
9785 DU_LOG("\nERROR --> F1AP : Failed at MAC LC Cfg in procSrbListToSetup()");
9793 /*******************************************************************
9795 * @brief extract Srb List received by CU
9799 * Function : extractSrbListToSetup
9801 * Functionality: extract Srb List received by CU
9802 * for both MAC and RLC
9804 * @params[in] SRBs_ToBeSetup_Item_t pointer
9806 * @return ROK/RFAIED
9808 * ****************************************************************/
9810 uint8_t extractSrbListToSetup(SRBs_ToBeSetup_List_t *srbCfg, DuUeCfg *ueCfgDb)
9812 uint8_t ret, srbIdx;
9813 SRBs_ToBeSetup_Item_t *srbItem = NULLP;
9817 for(srbIdx = 0; srbIdx < srbCfg->list.count; srbIdx++)
9819 srbItem = &srbCfg->list.array[srbIdx]->value.choice.SRBs_ToBeSetup_Item;
9820 if(ueCfgDb->numMacLcs > MAX_NUM_LC)
9822 DU_LOG("\nERROR --> F1AP: MAX LC Reached in MAC");
9826 if(ueCfgDb->numRlcLcs > MAX_NUM_LC)
9828 DU_LOG("\nERROR --> F1AP: MAX LC Reached in RLC");
9832 memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(LcCfg));
9833 memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(RlcBearerCfg));
9834 ret = procSrbListToSetup(srbItem, &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs],\
9835 &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs]);
9836 ueCfgDb->numRlcLcs++;
9837 ueCfgDb->numMacLcs++;
9840 DU_LOG("\nERROR --> F1AP: Failed at extractSrbListToSetup()");
9851 /*******************************************************************
9853 * @brief Fills Drb List received by CU
9857 * Function : procDrbListToSetup
9859 * Functionality: Fills Drb List received by CU
9860 * for both MAC and RLC
9862 * @params[in] SRBs_ToBeSetup_Item_t pointer
9864 * RlcBearerCfg pointer
9867 * ****************************************************************/
9869 uint8_t procDrbListToSetup(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbItem,\
9870 DRBs_ToBeSetupMod_Item_t *drbSetupModItem, LcCfg *macLcToAdd, RlcBearerCfg *rlcLcToAdd, UpTnlCfg *upTnlInfo)
9873 if(drbItem != NULLP)
9875 /* Filling RLC INFO */
9876 procRlcLcCfg(drbItem->dRBID, lcId, RB_TYPE_DRB, drbItem->rLCMode, CONFIG_ADD, NULL, rlcLcToAdd);
9878 /* Filling MAC INFO */
9879 if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_ADD, drbItem, NULL, NULL, macLcToAdd, upTnlInfo) != ROK)
9881 DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in procDrbListToSetup()");
9885 else if(drbSetupModItem != NULLP)
9887 procRlcLcCfg(drbSetupModItem->dRBID, lcId, RB_TYPE_DRB, drbSetupModItem->rLCMode, CONFIG_ADD, NULL, rlcLcToAdd);
9889 if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_ADD, NULL, drbSetupModItem, NULL, macLcToAdd, upTnlInfo) != ROK)
9891 DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in procDrbListToSetup()");
9898 /*******************************************************************
9900 * @brief extract Drb List received by CU
9904 * Function : extractDrbListToSetup
9906 * Functionality: extract Drb List received by CU
9907 * for both MAC and RLC
9909 * @params[in] DRBs_ToBeSetup_Item_t pointer
9911 * @return ROK/RFAIED
9913 * ****************************************************************/
9915 uint8_t extractDrbListToSetup(uint8_t lcId, DRBs_ToBeSetup_List_t *drbCfg,DRBs_ToBeSetupMod_List_t *drbSetupModCfg,\
9916 uint8_t drbCount, DuUeCfg *ueCfgDb)
9918 uint8_t ret, drbIdx;
9919 DRBs_ToBeSetup_Item_t *drbItem = NULLP;
9920 DRBs_ToBeSetupMod_ItemIEs_t *drbSetupModItem = NULLP;
9925 for(drbIdx = 0; drbIdx < drbCount; drbIdx++)
9927 if(ueCfgDb->numMacLcs > MAX_NUM_LC)
9929 DU_LOG("\nERROR --> F1AP : MAX LC Reached in MAC at extractDrbListToSetup()");
9933 if(ueCfgDb->numRlcLcs > MAX_NUM_LC)
9935 DU_LOG("\nERROR --> F1AP : MAX LC Reached in RLC at extractDrbListToSetup()");
9939 memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(LcCfg));
9940 memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(RlcBearerCfg));
9944 drbItem = &drbCfg->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item;
9945 ret = procDrbListToSetup(lcId, drbItem, NULL, &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs],\
9946 &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], &ueCfgDb->upTnlInfo[ueCfgDb->numDrb]);
9949 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetup()");
9953 else if(drbSetupModCfg != NULL)
9955 drbSetupModItem = (DRBs_ToBeSetupMod_ItemIEs_t *) drbSetupModCfg->list.array[drbIdx];
9956 ret = procDrbListToSetup(lcId, NULL, &(drbSetupModItem->value.choice.DRBs_ToBeSetupMod_Item) ,\
9957 &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs],\
9958 &ueCfgDb->upTnlInfo[ueCfgDb->numDrb]);
9961 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetup()");
9965 ueCfgDb->numRlcLcs++;
9966 ueCfgDb->numMacLcs++;
9970 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetup()");
9981 /*******************************************************************
9983 * @brief Function to extract Dl RRC Msg received from CU
9987 * Function : extractDlRrcMsg
9989 * Functionality: Function to extract Dl RRC Msg received from CU
9991 * @params[in] F1AP message
9992 * @return ROK - success
9995 * ****************************************************************/
9997 uint8_t extractDlRrcMsg(uint32_t gnbDuUeF1apId, uint32_t gnbCuUeF1apId, \
9998 F1DlRrcMsg *dlRrcMsg, RRCContainer_t *rrcContainer)
10001 dlRrcMsg->rrcMsgSize = rrcContainer->size;
10002 if(dlRrcMsg->rrcMsgSize > 0)
10004 DU_ALLOC_SHRABL_BUF(dlRrcMsg->rrcMsgPdu, dlRrcMsg->rrcMsgSize);
10005 if(!dlRrcMsg->rrcMsgPdu)
10007 DU_LOG("\nERROR --> DU APP : Memory allocation failed for RRC Msg in extractDlRrcMsg()");
10012 dlRrcMsg->gnbDuUeF1apId = gnbDuUeF1apId;
10013 dlRrcMsg->gnbCuUeF1apId = gnbCuUeF1apId;
10014 dlRrcMsg->srbId = SRB1_LCID;
10015 memcpy(dlRrcMsg->rrcMsgPdu, rrcContainer->buf, dlRrcMsg->rrcMsgSize);
10021 /*******************************************************************
10023 * @brief Extract UE capability info
10027 * Function : extractUeCapability
10029 * Functionality: Extract UE capability info and stores in ue Cb
10031 * @params[in] Octet string of UE capability RAT container list
10032 * @return ROK - success
10033 * RFAILED - failure
10035 * ****************************************************************/
10036 UE_NR_Capability_t *extractUeCapability(UE_CapabilityRAT_ContainerList_t *ueCapablityListBuf, DuUeCb *ueCb)
10039 uint16_t recvBufLen;
10040 asn_dec_rval_t rval;
10041 UE_NR_Capability_t *ueNrCap = NULLP;
10042 UE_CapabilityRAT_ContainerListRRC_t *ueCapRatContList = NULLP;
10044 /* Decoding UE Capability RAT Container List */
10045 recvBufLen = ueCapablityListBuf->size;
10046 DU_ALLOC(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
10047 if(!ueCapRatContList)
10049 DU_LOG("\nERROR --> F1AP : Memory allocation failed in extractUeCapability");
10052 memset(ueCapRatContList, 0, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
10053 memset(&rval, 0, sizeof(asn_dec_rval_t));
10054 rval = aper_decode(0, &asn_DEF_UE_CapabilityRAT_ContainerListRRC, (void **)&ueCapRatContList,
10055 ueCapablityListBuf->buf, recvBufLen, 0, 0);
10056 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
10058 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
10061 xer_fprint(stdout, &asn_DEF_UE_CapabilityRAT_ContainerListRRC, ueCapRatContList);
10063 /* Free encoded buffer after decoding */
10065 for(idx = 0; idx < ueCapRatContList->list.count; idx++)
10067 if(ueCapRatContList->list.array[idx]->rat_Type == RAT_Type_nr)
10069 /* Decoding UE NR Capability */
10070 recvBufLen = ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.size;
10071 DU_ALLOC(ueNrCap, sizeof(UE_NR_Capability_t));
10074 DU_LOG("\nERROR --> F1AP : Memory allocation failed in extractUeCapability");
10075 DU_FREE(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
10078 memset(ueNrCap, 0, sizeof(UE_NR_Capability_t));
10079 memset(&rval, 0, sizeof(asn_dec_rval_t));
10080 rval = aper_decode(0, &asn_DEF_UE_NR_Capability, (void **)&ueNrCap,
10081 ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.buf, recvBufLen, 0, 0);
10082 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
10084 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
10087 xer_fprint(stdout, &asn_DEF_UE_NR_Capability, ueNrCap);
10089 /* Free encoded buffer after decoding */
10090 free(ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.buf);
10092 free(ueCapRatContList->list.array[idx]);
10096 free(ueCapRatContList->list.array);
10097 DU_FREE(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
10101 /*******************************************************************
10103 * @brief free UE context setup request from CU
10107 * Function : freeAperDecodeF1UeContextSetupReq
10109 * Functionality: freeing part for the memory allocated by aper_decoder
10111 * @params[in] F1AP message
10112 * @return ROK - success
10113 * RFAILED - failure
10115 * ****************************************************************/
10116 void freeAperDecodeF1UeContextSetupReq(UEContextSetupRequest_t *ueSetReq)
10120 if(ueSetReq->protocolIEs.list.array != NULLP)
10122 for(ieIdx = 0; ieIdx < ueSetReq->protocolIEs.list.count; ieIdx++)
10124 if(ueSetReq->protocolIEs.list.array[ieIdx])
10126 switch(ueSetReq->protocolIEs.list.array[ieIdx]->id)
10128 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
10130 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
10132 case ProtocolIE_ID_id_SpCell_ID:
10133 freeAperDecodeNrcgi(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.NRCGI);
10135 case ProtocolIE_ID_id_ServCellIndex:
10137 case ProtocolIE_ID_id_SpCellULConfigured:
10139 case ProtocolIE_ID_id_CUtoDURRCInformation:
10141 freeAperDecodeCuToDuInfo(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation);
10143 case ProtocolIE_ID_id_SCell_ToBeSetup_List:
10145 freeAperDecodeSplCellList(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SCell_ToBeSetup_List);
10147 case ProtocolIE_ID_id_SRBs_ToBeSetup_List:
10149 freeAperDecodeSRBSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SRBs_ToBeSetup_List);
10151 case ProtocolIE_ID_id_DRBs_ToBeSetup_List:
10153 freeAperDecodeDRBSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRBs_ToBeSetup_List);
10155 case ProtocolIE_ID_id_RRCContainer:
10158 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf != NULLP)
10161 free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf);
10165 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
10167 case ProtocolIE_ID_id_GNB_DU_UE_AMBR_UL:
10169 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf)
10171 free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf);
10176 DU_LOG("\nERROR --> F1AP: Invalid event type %ld " ,ueSetReq->protocolIEs.list.array[ieIdx]->id);
10178 free(ueSetReq->protocolIEs.list.array[ieIdx]);
10181 free(ueSetReq->protocolIEs.list.array);
10184 /*******************************************************************
10186 * @brief Process UE context setup request from CU
10190 * Function : procF1UeContextSetupReq
10192 * Functionality: Process UE context setup request from CU
10194 * @params[in] F1AP message
10195 * @return ROK - success
10196 * RFAILED - failure
10198 * ****************************************************************/
10199 uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg)
10201 uint8_t ret=0, ieIdx=0, ueIdx=0, lcId=0, cellIdx=0;
10202 bool ueCbFound = false;
10203 uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId=0, bitRateSize=0;
10204 DuUeCb *duUeCb = NULL;
10205 UEContextSetupRequest_t *ueSetReq = NULL;
10206 DRBs_ToBeSetup_List_t *drbCfg = NULL;
10210 ueSetReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextSetupRequest;
10211 for(ieIdx=0; (ieIdx < ueSetReq->protocolIEs.list.count && ret == ROK); ieIdx++)
10213 switch(ueSetReq->protocolIEs.list.array[ieIdx]->id)
10215 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
10217 gnbCuUeF1apId = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID;
10220 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
10222 gnbDuUeF1apId = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID;
10225 case ProtocolIE_ID_id_ServCellIndex:
10227 cellIdx = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.ServCellIndex;
10228 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
10230 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
10231 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
10234 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
10235 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
10238 memset(duUeCb->f1UeDb, 0, sizeof(F1UeContextSetupDb));
10239 duUeCb->f1UeDb->actionType = UE_CTXT_SETUP;
10240 duUeCb->f1UeDb->cellIdx = cellIdx;
10244 DU_LOG("\nERROR --> F1AP: Memory Alloc Failed at procF1UeContextSetupReq()");
10254 DU_LOG("\nERROR --> F1AP: DuUeCb is not found at procF1UeContextSetupReq()");
10259 case ProtocolIE_ID_id_SpCellULConfigured:
10260 /* Indicates whether the gNB-CU requests the gNB-DU to configure the uplink as no UL,
10261 UL, SUL or UL+SUL for the indicated cell for the UE */
10263 case ProtocolIE_ID_id_CUtoDURRCInformation:
10265 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList)
10267 duUeCb->f1UeDb->duUeCfg.ueNrCapability = \
10268 extractUeCapability(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.\
10269 uE_CapabilityRAT_ContainerList, duUeCb);
10271 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.iE_Extensions)
10273 duUeCb->f1UeDb->duUeCfg.cellGrpCfg = extractCellGrpInfo(ueSetReq->protocolIEs.list.array[ieIdx]->\
10274 value.choice.CUtoDURRCInformation.iE_Extensions, &duUeCb->f1UeDb->duUeCfg);
10275 if(!duUeCb->f1UeDb->duUeCfg.cellGrpCfg)
10277 DU_LOG("\nERROR --> F1AP: Failed to extract cell Grp Info");
10278 //TODO: Update the failure cause in ue context Setup Response
10284 case ProtocolIE_ID_id_SCell_ToBeSetup_List:
10286 DU_LOG("\nINFO --> DU_APP: Received SCell_ToBeSetup_List but Not processing the list");
10289 case ProtocolIE_ID_id_SRBs_ToBeSetup_List:
10291 if(extractSrbListToSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SRBs_ToBeSetup_List,\
10292 &duUeCb->f1UeDb->duUeCfg))
10294 DU_LOG("\nERROR --> DU APP : Failed at extractSrbListToSetup()");
10295 //TODO: Update the failure cause in ue context Setup Response
10300 case ProtocolIE_ID_id_DRBs_ToBeSetup_List:
10302 lcId = getDrbLcId(&duUeCb->drbBitMap);
10303 if(lcId != RFAILED)
10305 drbCfg = &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRBs_ToBeSetup_List;
10306 if(extractDrbListToSetup(lcId, drbCfg, NULL, drbCfg->list.count, &duUeCb->f1UeDb->duUeCfg))
10308 DU_LOG("\nERROR --> DU APP : Failed at extractDrbListToSetup()");
10309 //TODO: Update the failure cause in ue context Setup Response
10317 case ProtocolIE_ID_id_RRCContainer:
10319 /* Filling Dl RRC Msg Info */
10320 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
10321 if(!duUeCb->f1UeDb->dlRrcMsg)
10323 DU_LOG("\nERROR --> DU APP : Memory allocation failed for DL RRC Msg in procUeCtxtSetupReq()");
10328 duUeCb->f1UeDb->dlRrcMsgPres = true;
10329 memset(duUeCb->f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
10330 ret = extractDlRrcMsg(gnbDuUeF1apId, gnbCuUeF1apId, duUeCb->f1UeDb->dlRrcMsg,\
10331 &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer);
10335 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
10337 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
10339 duUeCb->f1UeDb->dlRrcMsg->deliveryStatRpt = true;
10343 DU_LOG("\nERROR --> Ignoring delivery report, since rrcContainer is not present");
10347 case ProtocolIE_ID_id_GNB_DU_UE_AMBR_UL:
10349 /* MaximumBitRate Uplink */
10350 bitRateSize = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.size;
10351 if(bitRateSize > 0)
10353 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->duUeCfg.ambrCfg, bitRateSize);
10354 if(!duUeCb->f1UeDb->duUeCfg.ambrCfg)
10356 DU_LOG("\nERROR --> DU APP : Memory allocation failed for bitRate in procUeCtxtSetupReq");
10361 memset(duUeCb->f1UeDb->duUeCfg.ambrCfg, 0, sizeof(AmbrCfg));
10362 memcpy(&duUeCb->f1UeDb->duUeCfg.ambrCfg->ulBr,
10363 ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf, bitRateSize);
10378 /*TODO : Negative case*/
10379 // BuildAndSendUeContextSetupRsp(cellId,ueIdx);
10380 DU_LOG("\nERROR --> F1AP: Failed to process UE CNTXT SETUP REQ at procF1UeContextSetupReq()");
10383 ret = duProcUeContextSetupRequest(duUeCb);
10385 freeAperDecodeF1UeContextSetupReq(ueSetReq);
10389 /*******************************************************************
10390 * @brief Free the memory allocated for Dl Tunnel Info
10394 * Function : freeDlTnlInfo
10397 * Free the memory allocated for Dl Tunnel Info
10399 * @params[in] DLUPTNLInformation_ToBeSetup_List_t *
10402 * ****************************************************************/
10404 void freeDlTnlInfo(DLUPTNLInformation_ToBeSetup_List_t *tnlInfo)
10406 uint8_t arrIdx = 0;
10410 for(arrIdx=0; arrIdx < tnlInfo->list.count; arrIdx++)
10412 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.buf,\
10413 tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.size);
10414 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf,\
10415 tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->gTP_TEID.size);
10416 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel, sizeof(GTPTunnel_t));
10417 DU_FREE(tnlInfo->list.array[arrIdx], sizeof(DLUPTNLInformation_ToBeSetup_Item_t));
10419 DU_FREE(tnlInfo->list.array, tnlInfo->list.size);
10423 /*******************************************************************
10424 * @brief Free the memory allocated for DRB setup List
10428 * Function : freeDrbSetupList
10431 * Free the memory allocated for DRB setup list
10433 * @params[in] DRBs_Setup_List_t *
10436 * ****************************************************************/
10437 void freeDrbSetupList(DRBs_Setup_List_t *drbSetupList)
10439 uint8_t arrIdx = 0;
10440 DRBs_Setup_ItemIEs_t *drbItemIe = NULLP;
10442 for(arrIdx = 0; arrIdx < drbSetupList->list.count; arrIdx++)
10444 drbItemIe = ((DRBs_Setup_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
10445 freeDlTnlInfo(&drbItemIe->value.choice.DRBs_Setup_Item.dLUPTNLInformation_ToBeSetup_List);
10446 DU_FREE(drbSetupList->list.array[arrIdx], sizeof(DRBs_Setup_Item_t));
10448 DU_FREE(drbSetupList->list.array, drbSetupList->list.size);
10451 /*******************************************************************
10452 * @brief Free the memory allocated for UE Setup response
10456 * Function : FreeUeContextSetupRsp
10459 * Free the memory allocated for UE Setup response
10461 * @params[in] F1AP PDU for UE setup response
10462 * @return ROK - success
10463 * RFAILED - failure
10465 * ****************************************************************/
10466 void FreeUeContextSetupRsp(F1AP_PDU_t *f1apMsg)
10469 UEContextSetupResponse_t *ueSetRsp = NULLP;
10473 if(f1apMsg->choice.successfulOutcome)
10475 ueSetRsp = &f1apMsg->choice.successfulOutcome->value.choice.\
10476 UEContextSetupResponse;
10477 if(ueSetRsp->protocolIEs.list.array)
10479 for(idx = 0; idx < ueSetRsp->protocolIEs.list.count; idx++)
10481 if(ueSetRsp->protocolIEs.list.array[idx])
10483 switch(ueSetRsp->protocolIEs.list.array[idx]->id)
10485 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
10487 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
10489 case ProtocolIE_ID_id_DUtoCURRCInformation:
10491 CellGroupConfig_t *cellGrpCfg = NULLP;
10492 cellGrpCfg = &ueSetRsp->protocolIEs.list.array[idx]->value.choice.\
10493 DUtoCURRCInformation.cellGroupConfig;
10494 if(cellGrpCfg->buf != NULLP)
10496 DU_FREE(cellGrpCfg->buf, cellGrpCfg->size);
10497 cellGrpCfg = NULLP;
10501 case ProtocolIE_ID_id_DRBs_Setup_List:
10503 freeDrbSetupList(&ueSetRsp->protocolIEs.list.array[idx]->value.choice.DRBs_Setup_List);
10507 DU_LOG("\nERROR --> DUAPP: Invalid Id %ld at FreeUeContextSetupRsp()",\
10508 ueSetRsp->protocolIEs.list.array[idx]->id);
10511 DU_FREE(ueSetRsp->protocolIEs.list.array[idx],\
10512 sizeof(UEContextSetupResponseIEs_t));
10515 DU_FREE(ueSetRsp->protocolIEs.list.array, \
10516 ueSetRsp->protocolIEs.list.size);
10518 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
10520 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
10524 /*******************************************************************
10526 * @brief Builds Ue context Setup Rsp DU To CU Info
10530 * Function : EncodeUeCntxtDuToCuInfo
10532 * Functionality: Builds Ue context Setup Rsp DU To CU Info
10534 * @params[in] CellGroupConfig_t *, CellGroupConfigRrc_t *
10536 * @return ROK - success
10537 * RFAILED - failure
10539 ******************************************************************/
10541 uint8_t EncodeUeCntxtDuToCuInfo(CellGroupConfig_t *duToCuCellGrp, CellGroupConfigRrc_t *duCellGrpCfg)
10543 asn_enc_rval_t encRetVal;
10545 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, duCellGrpCfg);
10546 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
10548 encRetVal = aper_encode(&asn_DEF_CellGroupConfigRrc, 0, duCellGrpCfg, PrepFinalEncBuf, encBuf);
10549 /* Encode results */
10550 if(encRetVal.encoded == ENCODE_FAIL)
10552 DU_LOG( "\nERROR --> F1AP : Could not encode UeCntxtDuToCuInfo (at %s)\n",\
10553 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
10558 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UeCntxtDuToCuInfo\n");
10559 for(int i=0; i< encBufSize; i++)
10561 printf("%x",encBuf[i]);
10564 duToCuCellGrp->size = encBufSize;
10565 DU_ALLOC(duToCuCellGrp->buf, duToCuCellGrp->size);
10566 if(!duToCuCellGrp->buf)
10568 DU_LOG("\nERROR --> F1AP : Memory allocation failed in UeCntxtDuToCuInfo");
10570 memcpy(duToCuCellGrp->buf, encBuf, duToCuCellGrp->size);
10574 /*******************************************************************
10576 * @brief Fills Dl Gtp tunnel Info
10580 * Function : fillGtpTunnelforDl
10582 * Functionality: Fills Dl Gtp tunnel Info
10586 * @return ROK - success
10587 * RFAILED - failure
10589 * ****************************************************************/
10591 uint8_t fillGtpTunnelforDl(GTPTunnel_t *gtpDl, GtpTnlCfg *gtpUeCfg)
10593 uint8_t bufSize = 0;
10595 gtpDl->transportLayerAddress.size = 4*sizeof(uint8_t);
10596 DU_ALLOC(gtpDl->transportLayerAddress.buf, gtpDl->transportLayerAddress.size);
10597 if(gtpDl->transportLayerAddress.buf == NULLP)
10601 memcpy(gtpDl->transportLayerAddress.buf, >pUeCfg->dlTnlAddress, gtpDl->transportLayerAddress.size);
10604 gtpDl->gTP_TEID.size = 4 * sizeof(uint8_t);
10605 DU_ALLOC(gtpDl->gTP_TEID.buf, gtpDl->gTP_TEID.size);
10606 if(gtpDl->gTP_TEID.buf == NULLP)
10610 bufSize = 3; /*forming an Octect String*/
10611 fillTeIdString(bufSize, gtpUeCfg->teId, gtpDl->gTP_TEID.buf);
10616 /*******************************************************************
10618 * @brief Fills DL Tunnel Setup List
10622 * Function : fillDlTnlSetupList
10624 * Functionality: Fills the DL Tunnel Setup List
10628 * @return ROK - success
10629 * RFAILED - failure
10631 * ****************************************************************/
10633 uint8_t fillDlTnlSetupList(DLUPTNLInformation_ToBeSetup_List_t *dlTnlInfo, UpTnlCfg *tnlCfg)
10635 uint8_t ret = ROK, arrIdx = 0, eleCount = 0;
10638 dlTnlInfo->list.count = eleCount;
10639 dlTnlInfo->list.size = (eleCount * sizeof(DLUPTNLInformation_ToBeSetup_Item_t *));
10641 /* Initialize the DL Tnl Setup List Members */
10642 DU_ALLOC(dlTnlInfo->list.array, dlTnlInfo->list.size);
10643 if(dlTnlInfo->list.array == NULLP)
10645 DU_LOG(" ERROR --> F1AP : Memory allocation for DL Tnl Setup List in fillDlTnlSetupList()");
10648 for(arrIdx=0; arrIdx < eleCount; arrIdx++)
10650 DU_ALLOC(dlTnlInfo->list.array[arrIdx], sizeof(DLUPTNLInformation_ToBeSetup_Item_t));
10651 if(dlTnlInfo->list.array[arrIdx] == NULLP)
10653 DU_LOG(" ERROR --> F1AP : Memory allocation for arrIdx [%d] failed in fillDlTnlSetupList()", arrIdx);
10656 dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.present = UPTransportLayerInformation_PR_gTPTunnel;
10657 DU_ALLOC(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel, sizeof(GTPTunnel_t));
10658 if(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel == NULLP)
10660 DU_LOG(" ERROR --> F1AP : Memory allocation for DL tunnel info in fillDlTnlSetupList()");
10663 ret = fillGtpTunnelforDl(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel,\
10671 /*******************************************************************
10673 * @brief Fills the Drb Setup List for Ue Context Setup Response
10677 * Function : fillDrbSetupList
10679 * Functionality: Fills the Drb Setup List for Ue Context Setup Response
10683 * @return ROK - success
10684 * RFAILED - failure
10686 * ****************************************************************/
10687 uint8_t fillDrbSetupList(DRBs_Setup_List_t *drbSetupList, DuUeCfg *ueCfg)
10689 uint8_t ret = ROK, arrIdx = 0, eleCount = 0;
10690 DRBs_Setup_ItemIEs_t *drbItemIe = NULLP;
10692 eleCount = ueCfg->numDrb;
10693 drbSetupList->list.count = eleCount;
10694 drbSetupList->list.size = \
10695 (eleCount * sizeof(DRBs_Setup_Item_t *));
10697 /* Initialize the Drb Setup List Members */
10698 DU_ALLOC(drbSetupList->list.array, drbSetupList->list.size);
10699 if(drbSetupList->list.array == NULLP)
10701 DU_LOG(" ERROR --> F1AP : Memory allocation for DRB Setup List in fillDrbSetupList()");
10705 for(arrIdx=0; arrIdx < eleCount; arrIdx++)
10707 DU_ALLOC(drbSetupList->list.array[arrIdx], sizeof(DRBs_Setup_Item_t));
10708 if(drbSetupList->list.array[arrIdx] == NULLP)
10710 DU_LOG(" ERROR --> F1AP : Memory allocation for arrIdx [%d] failed in fillDrbSetupList()", arrIdx);
10713 drbItemIe = ((DRBs_Setup_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
10714 drbItemIe->id = ProtocolIE_ID_id_DRBs_Setup_Item;
10715 drbItemIe->criticality = Criticality_reject;
10716 drbItemIe->value.present = DRBs_Setup_ItemIEs__value_PR_DRBs_Setup_Item;
10717 drbItemIe->value.choice.DRBs_Setup_Item.dRBID = ueCfg->upTnlInfo[arrIdx].drbId;
10718 ret = fillDlTnlSetupList(&drbItemIe->value.choice.DRBs_Setup_Item.dLUPTNLInformation_ToBeSetup_List,\
10719 &ueCfg->upTnlInfo[arrIdx]);
10726 /*******************************************************************
10728 * @brief Builds and sends the UE Setup Response
10732 * Function : BuildAndSendUeContextSetupRsp
10734 * Functionality: Constructs the UE Setup Response and sends
10735 * it to the DU through SCTP.
10737 * @params[in] uint8_t cellId,uint8_t ueIdx
10739 * @return ROK - success
10740 * RFAILED - failure
10742 * ****************************************************************/
10743 uint8_t BuildAndSendUeContextSetupRsp(uint8_t cellId,uint8_t ueIdx)
10745 uint8_t idx, ret, cellIdx, elementCnt;
10746 uint32_t gnbCuUeF1apId; /* gNB-CU UE F1AP Id */
10747 uint32_t gnbDuUeF1apId; /* gNB-DU UE F1AP Id */
10748 asn_enc_rval_t encRetVal; /* Encoder return value */
10749 F1AP_PDU_t *f1apMsg = NULLP;
10750 UEContextSetupResponse_t *ueSetRsp = NULLP;
10751 CellGroupConfigRrc_t *cellGrpCfg = NULLP;
10752 DuUeCb *ueCb = NULLP;
10754 DU_LOG("\n INFO --> F1AP : Building UE Context Setup Response for cellId %d, ueIdx %d\n", cellId, ueIdx);
10758 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
10759 if(f1apMsg == NULLP)
10761 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
10766 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
10767 DU_ALLOC(f1apMsg->choice.successfulOutcome,
10768 sizeof(SuccessfulOutcome_t));
10769 if(f1apMsg->choice.successfulOutcome == NULLP)
10771 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
10776 f1apMsg->choice.successfulOutcome->procedureCode = \
10777 ProcedureCode_id_UEContextSetup;
10778 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
10779 f1apMsg->choice.successfulOutcome->value.present = \
10780 SuccessfulOutcome__value_PR_UEContextSetupResponse;
10783 &f1apMsg->choice.successfulOutcome->value.choice.UEContextSetupResponse;
10785 ueSetRsp->protocolIEs.list.count = elementCnt;
10786 ueSetRsp->protocolIEs.list.size = \
10787 elementCnt * sizeof(UEContextSetupResponse_t *);
10789 /* Initialize the UESetup members */
10790 DU_ALLOC(ueSetRsp->protocolIEs.list.array, \
10791 ueSetRsp->protocolIEs.list.size);
10792 if(ueSetRsp->protocolIEs.list.array == NULLP)
10794 DU_LOG(" ERROR --> F1AP : Memory allocation for UE Setup Response failed");
10799 for(idx=0; idx<elementCnt; idx++)
10801 DU_ALLOC(ueSetRsp->protocolIEs.list.array[idx],\
10802 sizeof(UEContextSetupResponseIEs_t));
10803 if(ueSetRsp->protocolIEs.list.array[idx] == NULLP)
10805 DU_LOG(" ERROR --> F1AP : Memory allocation for UE Setup Response failed");
10810 /* Fetching Ue Cb Info*/
10811 GET_CELL_IDX(cellId, cellIdx);
10812 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
10813 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
10814 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
10817 /*GNB CU UE F1AP ID*/
10818 ueSetRsp->protocolIEs.list.array[idx]->id = \
10819 ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
10820 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
10821 ueSetRsp->protocolIEs.list.array[idx]->value.present = \
10822 UEContextSetupResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
10823 ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
10825 /*GNB DU UE F1AP ID*/
10827 ueSetRsp->protocolIEs.list.array[idx]->id = \
10828 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
10829 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
10830 ueSetRsp->protocolIEs.list.array[idx]->value.present = \
10831 UEContextSetupResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
10832 ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
10835 /*DUtoCURRC Information */
10837 ueSetRsp->protocolIEs.list.array[idx]->id = \
10838 ProtocolIE_ID_id_DUtoCURRCInformation;
10839 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
10840 ueSetRsp->protocolIEs.list.array[idx]->value.present =\
10841 UEContextSetupResponseIEs__value_PR_DUtoCURRCInformation;
10844 if(ueCb->f1UeDb->duUeCfg.cellGrpCfg)
10846 cellGrpCfg = (CellGroupConfigRrc_t*)ueCb->f1UeDb->duUeCfg.cellGrpCfg;
10847 ret = EncodeUeCntxtDuToCuInfo(&ueSetRsp->protocolIEs.list.array[idx]->value.\
10848 choice.DUtoCURRCInformation.cellGroupConfig, cellGrpCfg);
10851 DU_LOG("\nERROR --> F1AP : Failed to EncodeUeCntxtDuToCuInfo in BuildAndSendUeContextSetupRsp()");
10852 freeF1UeDb(ueCb->f1UeDb);
10853 ueCb->f1UeDb = NULLP;
10860 DU_LOG("\nERROR --> F1AP : Failed to form DUtoCU RRCInfo at BuildAndSendUeContextSetupRsp()");
10865 /* Drb Setup List */
10867 ueSetRsp->protocolIEs.list.array[idx]->id = \
10868 ProtocolIE_ID_id_DRBs_Setup_List;
10869 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
10870 ueSetRsp->protocolIEs.list.array[idx]->value.present =\
10871 UEContextSetupResponseIEs__value_PR_DRBs_Setup_List;
10872 ret = fillDrbSetupList(&ueSetRsp->protocolIEs.list.array[idx]->value.choice.DRBs_Setup_List,\
10873 &ueCb->f1UeDb->duUeCfg);
10876 DU_LOG("\nERROR --> F1AP : Failed to fillDrbSetupList in BuildAndSendUeContextSetupRsp()");
10877 freeF1UeDb(ueCb->f1UeDb);
10878 ueCb->f1UeDb = NULLP;
10882 /* Free UeContext Db created during Ue context Req */
10883 freeF1UeDb(ueCb->f1UeDb);
10884 ueCb->f1UeDb = NULLP;
10886 /* TODO: To send Drb list */
10887 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
10889 /* Encode the UE context setup response type as APER */
10890 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
10892 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
10894 /* Encode results */
10895 if(encRetVal.encoded == ENCODE_FAIL)
10897 DU_LOG( "\nERROR --> F1AP : Could not encode UE Context Setup Response structure (at %s)\n",\
10898 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
10904 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UE Context Setup Response\n");
10905 for(int i=0; i< encBufSize; i++)
10907 printf("%x",encBuf[i]);
10912 if(sendF1APMsg() != ROK)
10914 DU_LOG("\nERROR --> F1AP : Sending UE Context Setup Response failed");
10920 FreeUeContextSetupRsp(f1apMsg);
10922 }/* End of BuildAndSendUeContextSetupRsp */
10923 /*******************************************************************
10925 * @brief Build And Send Ue Context Rsp
10929 * Function : BuildAndSendUeCtxtRsp
10931 * Functionality : Build And Send Ue Context Rsp
10934 * @return sucess = ROK
10935 * failure = RFAILED
10937 * ****************************************************************/
10938 uint8_t BuildAndSendUeCtxtRsp(uint8_t cellId, uint8_t ueIdx)
10940 uint8_t cellIdx = 0, actionType = 0;
10942 GET_CELL_IDX(cellId, cellIdx);
10943 actionType = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb->actionType;
10947 case UE_CTXT_SETUP:
10949 BuildAndSendUeContextSetupRsp(cellId,ueIdx);
10954 BuildAndSendUeContextModRsp(cellId, ueIdx);
10958 DU_LOG("ERROR --> F1AP: Invalid Action Type %d at BuildAndSendUeCtxtRsp()", actionType);
10965 /*******************************************************************
10967 * @brief deallocating the memory of F1reset msg
10971 * Function : FreeF1ResetReq
10974 * - freeing memory of F1reset request msg
10980 * ****************************************************************/
10981 void FreeF1ResetReq(F1AP_PDU_t *f1apMsg)
10984 Reset_t *f1ResetMsg;
10988 if(f1apMsg->choice.initiatingMessage)
10990 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
10992 if(f1ResetMsg->protocolIEs.list.array)
10994 for(idx=0 ;idx < f1ResetMsg->protocolIEs.list.count ; idx++)
10996 if(f1ResetMsg->protocolIEs.list.array[idx])
10998 DU_FREE(f1ResetMsg->protocolIEs.list.array[idx],sizeof(ResetIEs_t));
11001 DU_FREE(f1ResetMsg->protocolIEs.list.array,f1ResetMsg->protocolIEs.list.size);
11003 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
11005 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
11008 /*******************************************************************
11010 * @brief Build and Send F1reset request
11014 * Function : BuildAndSendF1ResetReq
11017 * - Build and Send F1reset request msg
11020 * @return ROK - success
11021 * RFAILED - failure
11023 * ****************************************************************/
11024 uint8_t BuildAndSendF1ResetReq()
11026 uint8_t elementCnt=0;
11028 uint8_t ret= RFAILED;
11029 Reset_t *f1ResetMsg = NULLP;
11030 F1AP_PDU_t *f1apMsg = NULLP;
11031 asn_enc_rval_t encRetVal;
11032 DU_LOG("\nINFO --> F1AP : Building F1 Reset request \n");
11035 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
11036 if(f1apMsg == NULLP)
11040 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
11041 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
11042 if(f1apMsg->choice.initiatingMessage == NULLP)
11046 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_Reset;
11047 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
11048 f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_Reset;
11050 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
11053 f1ResetMsg->protocolIEs.list.count = elementCnt;
11054 f1ResetMsg->protocolIEs.list.size = elementCnt * sizeof(ResetIEs_t *);
11056 /* Initialize the F1Setup members */
11057 DU_ALLOC(f1ResetMsg->protocolIEs.list.array,f1ResetMsg->protocolIEs.list.size);
11058 if(f1ResetMsg->protocolIEs.list.array == NULLP)
11062 for(idx=0; idx<elementCnt; idx++)
11064 DU_ALLOC(f1ResetMsg->protocolIEs.list.array[idx],sizeof(ResetIEs_t));
11065 if(f1ResetMsg->protocolIEs.list.array[idx] == NULLP)
11073 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID;
11074 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11075 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_TransactionID;
11076 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.TransactionID = 1;
11080 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_Cause;
11081 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_ignore;
11082 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_Cause;
11083 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.Cause.present = Cause_PR_radioNetwork;
11084 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.Cause.choice.radioNetwork = CauseRadioNetwork_action_desirable_for_radio_reasons;
11088 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_ResetType;
11089 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11090 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_ResetType;
11091 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.ResetType.present = ResetType_PR_f1_Interface;
11092 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.ResetType.choice.f1_Interface = ResetAll_reset_all;
11094 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
11096 /* Encode the F1SetupRequest type as APER */
11097 memset(encBuf, 0, ENC_BUF_MAX_LEN);
11099 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
11102 /* Encode results */
11103 if(encRetVal.encoded == ENCODE_FAIL)
11105 DU_LOG("\nERROR --> F1AP : Could not encode F1Reset structure (at %s)\n",\
11106 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
11111 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for F1Reset\n");
11112 for(idx=0; idx< encBufSize; idx++)
11114 printf("%x",encBuf[idx]);
11118 if(sendF1APMsg() != ROK)
11120 DU_LOG("\nERROR --> F1AP : Sending F1 Reset request failed");
11128 FreeF1ResetReq(f1apMsg);
11131 /*******************************************************************
11133 * @brief Build And Send F1ResetAck
11137 * Function : BuildAndSendF1ResetAck
11140 * - Build And Send F1ResetRSP
11142 * @return ROK - success
11143 * RFAILED - failure
11145 * ****************************************************************/
11146 void FreeF1ResetAck(F1AP_PDU_t *f1apMsg)
11149 ResetAcknowledge_t *f1ResetAck;
11153 if(f1apMsg->choice.successfulOutcome)
11155 f1ResetAck= &f1apMsg->choice.successfulOutcome->value.choice.ResetAcknowledge;
11157 if(f1ResetAck->protocolIEs.list.array)
11159 for(idx=0; idx<f1ResetAck->protocolIEs.list.count ; idx++)
11161 if(f1ResetAck->protocolIEs.list.array[idx])
11163 DU_FREE(f1ResetAck->protocolIEs.list.array[idx], sizeof(ResetAcknowledgeIEs_t));
11166 DU_FREE(f1ResetAck->protocolIEs.list.array, f1ResetAck->protocolIEs.list.size );
11168 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
11170 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
11174 /*******************************************************************
11176 * @brief Build And Send F1ResetAck
11180 * Function : BuildAndSendF1ResetAck
11183 * - Build And Send F1ResetRSP
11186 * @return ROK - success
11187 * RFAILED - failure
11189 * ****************************************************************/
11190 uint8_t BuildAndSendF1ResetAck()
11193 uint8_t elementCnt = 0;
11194 uint8_t ret = RFAILED;
11195 F1AP_PDU_t *f1apMsg = NULL;
11196 ResetAcknowledge_t *f1ResetAck = NULLP;
11197 asn_enc_rval_t encRetVal;
11198 DU_LOG("\nINFO --> F1AP : Building F1 Reset Acknowledgment \n");
11201 /* Allocate the memory for F1ResetRequest_t */
11202 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
11203 if(f1apMsg == NULLP)
11205 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11209 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
11211 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
11212 if(f1apMsg->choice.successfulOutcome == NULLP)
11214 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11217 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
11218 f1apMsg->choice.successfulOutcome->value.present = SuccessfulOutcome__value_PR_ResetAcknowledge;
11219 f1ResetAck = &f1apMsg->choice.successfulOutcome->value.choice.ResetAcknowledge;
11223 f1ResetAck->protocolIEs.list.count = elementCnt;
11224 f1ResetAck->protocolIEs.list.size = elementCnt*sizeof(ResetAcknowledgeIEs_t *);
11226 DU_ALLOC(f1ResetAck->protocolIEs.list.array, f1ResetAck->protocolIEs.list.size );
11227 if(f1ResetAck->protocolIEs.list.array == NULLP)
11229 DU_LOG("\nERROR --> F1AP : Memory allocation for F1ResetAckIEs failed");
11233 for(idx=0; idx<elementCnt; idx++)
11235 DU_ALLOC(f1ResetAck->protocolIEs.list.array[idx], sizeof(ResetAcknowledgeIEs_t));
11236 if(f1ResetAck->protocolIEs.list.array[idx] == NULLP)
11243 f1ResetAck->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID;
11244 f1ResetAck->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11245 f1ResetAck->protocolIEs.list.array[idx]->value.present = ResetAcknowledgeIEs__value_PR_TransactionID;
11246 f1ResetAck->protocolIEs.list.array[idx]->value.choice.TransactionID = TRANS_ID;
11248 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
11250 /* Encode the F1SetupRequest type as UPER */
11251 memset(encBuf, 0, ENC_BUF_MAX_LEN);
11253 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
11255 /* Check encode results */
11256 if(encRetVal.encoded == ENCODE_FAIL)
11258 DU_LOG("\nERROR --> F1AP : Could not encode F1ResetAck structure (at %s)\n",\
11259 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
11264 DU_LOG("\nDUBUG --> F1AP : Created APER encoded buffer for F1ResetAck\n");
11265 for(int i=0; i< encBufSize; i++)
11267 printf("%x",encBuf[i]);
11271 if(sendF1APMsg() != ROK)
11273 DU_LOG("\nERROR --> F1AP : Sending F1 Reset Acknowledgement failed");
11281 FreeF1ResetAck(f1apMsg);
11284 /******************************************************************
11286 * @brief free F1 reset msg allocated by aper_decoder
11290 * Function : freeAperDecodeF1ResetMsg
11292 * Functionality: free F1 reset msg allocated by aper_decoder
11294 * @params[in] Reset_t *f1ResetMsg
11297 * ****************************************************************/
11299 void freeAperDecodeF1ResetMsg(Reset_t *f1ResetMsg)
11302 if(f1ResetMsg->protocolIEs.list.array)
11304 for(ieIdx=0 ;ieIdx < f1ResetMsg->protocolIEs.list.count ; ieIdx++)
11306 if(f1ResetMsg->protocolIEs.list.array[ieIdx])
11308 free(f1ResetMsg->protocolIEs.list.array[ieIdx]);
11311 free(f1ResetMsg->protocolIEs.list.array);
11315 /******************************************************************
11317 * @brief Processes DL RRC Message Transfer sent by CU
11321 * Function : procF1ResetReq
11323 * Functionality: Processes DL RRC Message Transfer sent by CU
11325 * @params[in] F1AP_PDU_t ASN decoded F1AP message
11326 * @return ROK - success
11327 * RFAILED - failure
11329 * ****************************************************************/
11330 uint8_t procF1ResetReq(F1AP_PDU_t *f1apMsg)
11332 /* we are currently not supporting Ue release. right now we are supporting only init case of fireset */
11335 Reset_t *f1ResetMsg = NULLP;
11337 DU_LOG("\nINFO --> Processing F1 reset request");
11338 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
11340 for(ieIdx=0; ieIdx<f1ResetMsg->protocolIEs.list.count; ieIdx++)
11342 switch(f1ResetMsg->protocolIEs.list.array[ieIdx]->id)
11344 case ProtocolIE_ID_id_TransactionID:
11347 case ProtocolIE_ID_id_Cause:
11350 case ProtocolIE_ID_id_ResetType:
11359 ret = BuildAndSendF1ResetAck();
11360 DU_LOG("\nINFO --> UE release is not supported for now");
11362 freeAperDecodeF1ResetMsg(f1ResetMsg);
11367 /*******************************************************************
11369 * @brief free the RRC delivery report
11373 * Function : freeRrcDeliveryReport
11375 * Functionality: free the RRC delivery report
11378 * @return ROK - success
11379 * RFAILED - failure
11381 * ****************************************************************/
11382 void freeRrcDeliveryReport(F1AP_PDU_t *f1apMsg )
11385 RRCDeliveryReport_t *rrcDeliveryReport= NULLP;
11389 if(f1apMsg->choice.initiatingMessage)
11391 rrcDeliveryReport = &f1apMsg->choice.initiatingMessage->value.choice.RRCDeliveryReport;
11392 if(rrcDeliveryReport->protocolIEs.list.array)
11394 for(idx =0 ;idx <rrcDeliveryReport->protocolIEs.list.count ;
11397 if(rrcDeliveryReport->protocolIEs.list.array[idx])
11399 DU_FREE(rrcDeliveryReport->protocolIEs.list.array[idx],
11400 sizeof(RRCDeliveryReportIEs_t));
11403 DU_FREE(rrcDeliveryReport->protocolIEs.list.array,
11404 rrcDeliveryReport->protocolIEs.list.size);
11406 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
11409 sizeof(F1AP_PDU_t));
11413 /*******************************************************************
11415 * @brief Builds and sends the RRC delivery report
11419 * Function : BuildAndSendRrcDeliveryReport
11421 * Functionality: Builds and sends the RRC delivery report
11425 * @return ROK - success
11426 * RFAILED - failure
11428 * ****************************************************************/
11429 uint8_t BuildAndSendRrcDeliveryReport(uint32_t gnbCuUeF1apId, \
11430 uint32_t gnbDuUeF1apId, RrcDeliveryReport *rrcDelivery)
11432 uint8_t ret = RFAILED;
11435 uint8_t elementCnt = 0;
11436 F1AP_PDU_t *f1apMsg = NULLP;
11437 asn_enc_rval_t encRetVal;
11438 RRCDeliveryReport_t *rrcDeliveryReport= NULLP;
11442 DU_LOG("\nINFO --> F1AP : Building RRC delivery Message Transfer Message\n");
11443 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
11444 if(f1apMsg == NULLP)
11446 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11449 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
11450 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
11451 if(f1apMsg->choice.initiatingMessage == NULLP)
11453 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11456 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_RRCDeliveryReport;
11457 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
11458 f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_RRCDeliveryReport;
11460 rrcDeliveryReport = &f1apMsg->choice.initiatingMessage->value.choice.RRCDeliveryReport;
11462 rrcDeliveryReport->protocolIEs.list.count = elementCnt;
11463 rrcDeliveryReport->protocolIEs.list.size = elementCnt * sizeof(RRCDeliveryReportIEs_t *);
11465 /* Initialize the F1Setup members */
11466 DU_ALLOC(rrcDeliveryReport->protocolIEs.list.array, rrcDeliveryReport->protocolIEs.list.size);
11467 if(rrcDeliveryReport->protocolIEs.list.array == NULLP)
11469 DU_LOG(" ERROR --> F1AP : Memory allocation for RRC Delivery failed");
11472 for(idx =0 ;idx <elementCnt; idx++)
11474 DU_ALLOC(rrcDeliveryReport->protocolIEs.list.array[idx], sizeof(RRCDeliveryReportIEs_t));
11475 if(rrcDeliveryReport->protocolIEs.list.array[idx] == NULLP)
11483 /*GNB CU UE F1AP ID*/
11484 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
11485 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
11486 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_GNB_CU_UE_F1AP_ID;
11487 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
11489 /*GNB DU UE F1AP ID*/
11491 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
11492 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
11493 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_GNB_DU_UE_F1AP_ID;
11494 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
11496 /*RRC delivery status*/
11498 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_RRCDeliveryStatus;
11499 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_ignore;
11500 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_RRCDeliveryStatus;
11501 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.RRCDeliveryStatus.delivery_status =\
11502 rrcDelivery->rrcDeliveryStatus.deliveryStatus;
11503 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.RRCDeliveryStatus.triggering_message =\
11504 rrcDelivery->rrcDeliveryStatus.triggeringMessage;
11508 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_SRBID;
11509 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_ignore;
11510 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_SRBID;
11511 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.SRBID = rrcDelivery->srbId;
11513 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
11515 /* Encode the RRC DELIVERY REPORT type as APER */
11516 memset(encBuf, 0, ENC_BUF_MAX_LEN);
11518 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
11521 /* Encode results */
11522 if(encRetVal.encoded == ENCODE_FAIL)
11524 DU_LOG("\nERROR --> F1AP : Could not encode RRC Delivery Msg structure (at %s)\n",\
11525 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
11530 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for RRC Delivery Msg \n");
11531 for(idx=0; idx< encBufSize; idx++)
11533 printf("%x",encBuf[idx]);
11538 if(sendF1APMsg() != ROK)
11540 DU_LOG("\nERROR --> F1AP : Sending RRC delivery msg request failed");
11548 freeRrcDeliveryReport(f1apMsg);
11552 /*******************************************************************
11554 * @brief Processes cells to be activated
11558 * Function : extractCellsToBeActivated
11561 * - Processes cells to be activated list received in F1SetupRsp
11564 * @return ROK - success
11565 * RFAILED - failure
11567 * ****************************************************************/
11569 uint8_t extractCellsToBeActivated(Cells_to_be_Activated_List_t cellsToActivate)
11572 uint16_t idx, nci, pci = 0;
11573 Cells_to_be_Activated_List_Item_t cell;
11575 for(idx=0; idx<cellsToActivate.list.count; idx++)
11578 cell = cellsToActivate.list.array[idx]->value.choice.Cells_to_be_Activated_List_Item;
11579 bitStringToInt(&cell.nRCGI.nRCellIdentity, &nci);
11585 ret = duProcCellsToBeActivated(cell.nRCGI.pLMN_Identity.buf, nci, pci);
11589 /******************************************************************
11591 * @brief Processes F1 Setup Response allocated by aper_decoder
11595 * Function : freeF1SetupRsp
11597 * Functionality: free F1 Setup Response allocated by aper_decoder
11599 * @params[in] F1SetupResponse_t *f1SetRspMsg
11602 * ****************************************************************/
11604 void freeAperDecodeF1SetupRsp(F1SetupResponse_t *f1SetRspMsg)
11608 Cells_to_be_Activated_List_t *cellToActivate =NULLP;
11609 RRC_Version_t *rrcVer =NULLP;
11611 if(f1SetRspMsg->protocolIEs.list.array)
11613 for(ieIdx=0; ieIdx<f1SetRspMsg->protocolIEs.list.count; ieIdx++)
11615 if(f1SetRspMsg->protocolIEs.list.array[ieIdx])
11617 switch(f1SetRspMsg->protocolIEs.list.array[ieIdx]->id)
11619 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
11622 &f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.Cells_to_be_Activated_List;
11623 if(cellToActivate->list.array)
11625 for(arrIdx=0; arrIdx<cellToActivate->list.count ; arrIdx++)
11627 if(cellToActivate->list.array[arrIdx])
11630 if(cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.nRCGI.\
11633 if(cellToActivate->list.array[0]->value.choice.\
11634 Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf)
11636 free(cellToActivate->list.array[0]->value.choice.\
11637 Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf);
11640 free(cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.\
11641 nRCGI.pLMN_Identity.buf);
11643 free(cellToActivate->list.array[arrIdx]);
11646 free(cellToActivate->list.array);
11650 case ProtocolIE_ID_id_TransactionID:
11654 case ProtocolIE_ID_id_gNB_CU_Name:
11656 free(f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_Name.buf);
11659 case ProtocolIE_ID_id_GNB_CU_RRC_Version:
11661 rrcVer = &f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.RRC_Version;
11662 if(rrcVer->latest_RRC_Version.buf)
11664 if(rrcVer->iE_Extensions)
11666 if(rrcVer->iE_Extensions->list.array)
11668 if(rrcVer->iE_Extensions->list.array[0])
11670 if(rrcVer->iE_Extensions->list.\
11671 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf)
11673 free(rrcVer->iE_Extensions->list.\
11674 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf);
11676 free(rrcVer->iE_Extensions->list.array[0]);
11678 free(rrcVer->iE_Extensions->list.array);
11680 free(rrcVer->iE_Extensions);
11682 free(rrcVer->latest_RRC_Version.buf);
11689 DU_LOG("\nERROR --> DU_APP : Invalid IE received in F1SetupRsp:%ld",
11690 f1SetRspMsg->protocolIEs.list.array[ieIdx]->id);
11693 free(f1SetRspMsg->protocolIEs.list.array[ieIdx]);
11696 free(f1SetRspMsg->protocolIEs.list.array);
11699 /******************************************************************
11701 * @brief Processes F1 Setup Response sent by CU
11705 * Function : procF1SetupRsp
11707 * Functionality: Processes F1 Setup Response sent by CU
11709 * @params[in] F1AP_PDU_t ASN decoded F1AP message
11710 * @return ROK - success
11711 * RFAILED - failure
11713 * ****************************************************************/
11714 uint8_t procF1SetupRsp(F1AP_PDU_t *f1apMsg)
11718 F1SetupResponse_t *f1SetRspMsg = NULLP;
11719 GNB_CU_Name_t *cuName = NULLP;
11720 F1SetupRsp f1SetRspDb;
11721 RRC_Version_t *rrcVer =NULLP;
11723 memset(&f1SetRspDb, 0, sizeof(F1SetupRsp));
11725 DU_LOG("\nINFO --> F1AP : F1 Setup Response received");
11726 f1SetRspMsg = &f1apMsg->choice.successfulOutcome->value.choice.F1SetupResponse;
11728 for(idx=0; idx<f1SetRspMsg->protocolIEs.list.count; idx++)
11730 switch(f1SetRspMsg->protocolIEs.list.array[idx]->id)
11732 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
11734 extractCellsToBeActivated(f1SetRspMsg->protocolIEs.list.array[idx]->\
11735 value.choice.Cells_to_be_Activated_List);
11738 case ProtocolIE_ID_id_TransactionID:
11740 f1SetRspDb.transId = f1SetRspMsg->protocolIEs.list.array[idx]->\
11741 value.choice.TransactionID;
11744 case ProtocolIE_ID_id_gNB_CU_Name:
11746 cuName = &f1SetRspMsg->protocolIEs.list.array[idx]->\
11747 value.choice.GNB_CU_Name;
11748 strcpy(f1SetRspDb.cuName, (const char*)cuName->buf);
11751 case ProtocolIE_ID_id_GNB_CU_RRC_Version:
11753 rrcVer = &f1SetRspMsg->protocolIEs.list.array[idx]->value.choice.RRC_Version;
11754 strcpy(f1SetRspDb.rrcVersion.rrcVer,
11755 (const char*)rrcVer->latest_RRC_Version.buf);
11759 DU_LOG("\nERROR --> DU_APP : Invalid IE received in F1SetupRsp:%ld",
11760 f1SetRspMsg->protocolIEs.list.array[idx]->id);
11762 duProcF1SetupRsp();
11765 freeAperDecodeF1SetupRsp(f1SetRspMsg);
11768 /*******************************************************************
11770 * @brief free GNB DU config update ack
11774 * Function : freeAperDecodeGnbDuAck
11776 * Functionality: Processes GNB DU config update ack And
11777 * added free part for the memory allocated by aper_decoder
11779 * @params[in] F1AP_PDU_t ASN decoded F1AP message
11780 * @return ROK - success
11781 * RFAILED - failure
11783 * ****************************************************************/
11785 void freeAperDecodeGnbDuAck(GNBDUConfigurationUpdateAcknowledge_t *gnbDuAck)
11789 if(gnbDuAck->protocolIEs.list.array)
11791 for(ieIdx=0; ieIdx < gnbDuAck->protocolIEs.list.count; ieIdx++)
11793 if(gnbDuAck->protocolIEs.list.array[ieIdx])
11795 free(gnbDuAck->protocolIEs.list.array[ieIdx]);
11798 free(gnbDuAck->protocolIEs.list.array);
11802 /*******************************************************************
11804 * @brief Building result of gnb-du config update ack output
11808 * Function : duProcGnbDuCfgUpdAckMsg
11811 * Building output of gnb-du config update ack
11813 * @params[in] transId
11816 * ****************************************************************/
11818 uint8_t duProcGnbDuCfgUpdAckMsg(uint8_t transId)
11820 uint8_t ieIdx=0, arrIdx=0,ret=ROK;
11821 uint8_t ueId =0 , ueIdx =0;
11822 uint16_t cellId =0, cellIdx =0, crnti=0;
11823 CmLList *f1apPduNode = NULLP;
11824 ReservedF1apPduInfo *f1apPduInfo =NULLP;
11825 F1AP_PDU_t *f1apMsgPdu = NULLP;
11826 GNBDUConfigurationUpdate_t *gnbDuConfigUpdate = NULLP;
11827 BIT_STRING_t *cellIdentity=NULLP;
11828 struct Served_Cells_To_Delete_ItemIEs *deleteItemIe=NULLP;
11829 Served_Cells_To_Delete_List_t *cellsToDelete=NULLP;
11830 Served_Cells_To_Delete_Item_t *deleteItem=NULLP;
11832 DU_LOG("\nINFO --> DU APP: GNB-DU config update Ack received ");
11833 f1apPduNode = searchFromReservedF1apPduList(transId);
11834 f1apPduInfo = (ReservedF1apPduInfo *)f1apPduNode->node;
11835 f1apMsgPdu = (F1AP_PDU_t *)f1apPduInfo->f1apMsg;
11839 if(f1apMsgPdu->choice.initiatingMessage)
11841 gnbDuConfigUpdate = &f1apMsgPdu->choice.initiatingMessage->value.choice.GNBDUConfigurationUpdate;
11842 for(ieIdx=0; ieIdx < gnbDuConfigUpdate->protocolIEs.list.count; ieIdx++)
11844 switch(gnbDuConfigUpdate->protocolIEs.list.array[ieIdx]->id)
11846 case ProtocolIE_ID_id_Served_Cells_To_Delete_List:
11848 cellsToDelete = &gnbDuConfigUpdate->protocolIEs.list.array[ieIdx]->value.choice.\
11849 Served_Cells_To_Delete_List;
11850 if(cellsToDelete->list.array)
11852 if(cellsToDelete->list.array[arrIdx])
11854 deleteItemIe = (Served_Cells_To_Delete_ItemIEs_t*)cellsToDelete->list.array[arrIdx];
11855 deleteItem=&deleteItemIe->value.choice.Served_Cells_To_Delete_Item;
11856 if(deleteItem->oldNRCGI.nRCellIdentity.buf)
11858 cellIdentity = &deleteItem->oldNRCGI.nRCellIdentity;
11859 bitStringToInt(cellIdentity, &cellId);
11864 GET_CELL_IDX(cellId, cellIdx);
11865 if(duCb.actvCellLst[cellIdx] != NULLP)
11867 if(duCb.actvCellLst[cellIdx]->numActvUes == 0)
11869 duCb.actvCellLst[cellId-1]->cellStatus = DELETION_IN_PROGRESS;
11870 ret = duSendCellDeletReq(cellId);
11873 DU_LOG("ERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): Failed to send cell delete\
11874 request for cellId[%d]", cellId);
11879 for(ueIdx = 0; ueIdx < duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
11881 crnti = duCb.actvCellLst[cellIdx]->ueCb[ueIdx].crnti;
11882 GET_UE_IDX(crnti,ueId);
11883 ret = BuildAndSendUeContextReleaseReq(cellId, ueId);
11886 DU_LOG("ERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): Failed to build and send UE delete\
11887 request for cellId[%d]", cellId);
11894 DU_LOG("ERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): CellId [%d] not found", cellId);
11907 FreeDUConfigUpdate(f1apMsgPdu);
11908 deleteFromReservedF1apPduList(f1apPduNode);
11912 /*******************************************************************
11914 * @brief Processes GNB DU config update ack
11918 * Function : procF1GNBDUCfgUpdAck
11920 * Functionality: added free part for the memory allocated by aper_decoder
11922 * @params[in] F1AP_PDU_t *f1apMsg
11925 * ****************************************************************/
11926 uint8_t procF1GNBDUCfgUpdAck(F1AP_PDU_t *f1apMsg)
11928 uint8_t ieIdx=0,transId=0;
11929 GNBDUConfigurationUpdateAcknowledge_t *gnbDuAck = NULLP;
11931 DU_LOG("\nINFO --> F1AP : GNB-DU config update acknowledgment");
11932 gnbDuAck = &f1apMsg->choice.successfulOutcome->value.choice.GNBDUConfigurationUpdateAcknowledge;
11934 for(ieIdx=0; ieIdx < gnbDuAck->protocolIEs.list.count; ieIdx++)
11936 switch(gnbDuAck->protocolIEs.list.array[ieIdx]->id)
11938 case ProtocolIE_ID_id_TransactionID:
11940 transId = gnbDuAck->protocolIEs.list.array[ieIdx]->value.choice.TransactionID;
11943 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
11949 DU_LOG("\nERROR --> F1AP: procF1GNBDUCfgUpdAck(): Invalid IE Received: %ld", \
11950 gnbDuAck->protocolIEs.list.array[ieIdx]->id);
11956 duProcGnbDuCfgUpdAckMsg(transId);
11959 /* presently we are not supporting F1 Reset from DU to CU , we are only
11960 * supporting F1 Reset from CU to DU */
11962 if(BuildAndSendF1ResetReq() != ROK)
11968 freeAperDecodeGnbDuAck(gnbDuAck);
11971 /******************************************************************
11973 * @brief free DL RRC Message Transfer allocated by aper_decoder
11977 * Function : freeAperDecodef1DlRrcMsg
11979 * Functionality: free DL RRC Message Transfer allocated by aper_decoder
11981 * @params[in] DLRRCMessageTransfer_t *f1DlRrcMsg
11982 * @return ROK - success
11983 * RFAILED - failure
11985 * ****************************************************************/
11987 void freeAperDecodef1DlRrcMsg(DLRRCMessageTransfer_t *f1DlRrcMsg)
11990 RRCContainer_t *rrcContainer = NULLP;
11992 if(f1DlRrcMsg->protocolIEs.list.array)
11994 for(ieIdx=0; ieIdx<f1DlRrcMsg->protocolIEs.list.count; ieIdx++)
11996 if(f1DlRrcMsg->protocolIEs.list.array[ieIdx])
11998 switch(f1DlRrcMsg->protocolIEs.list.array[ieIdx]->id)
12000 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12002 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12004 case ProtocolIE_ID_id_SRBID:
12006 case ProtocolIE_ID_id_RRCContainer:
12008 rrcContainer =&f1DlRrcMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer;
12009 free(rrcContainer->buf);
12011 case ProtocolIE_ID_id_ExecuteDuplication:
12013 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
12017 free(f1DlRrcMsg->protocolIEs.list.array[ieIdx]);
12020 free(f1DlRrcMsg->protocolIEs.list.array);
12023 /******************************************************************
12025 * @brief Processes DL RRC Message Transfer sent by CU
12029 * Function : procF1DlRrcMsgTrans
12031 * Functionality: Processes DL RRC Message Transfer sent by CU
12033 * @params[in] F1AP_PDU_t ASN decoded F1AP message
12034 * @return ROK - success
12035 * RFAILED - failure
12037 * ****************************************************************/
12038 uint8_t procF1DlRrcMsgTrans(F1AP_PDU_t *f1apMsg)
12041 DLRRCMessageTransfer_t *f1DlRrcMsg = NULLP;
12043 memset(&dlMsg, 0, sizeof(F1DlRrcMsg));
12045 DU_LOG("\nINFO --> DU_APP : DL RRC message transfer Recevied");
12046 f1DlRrcMsg = &f1apMsg->choice.initiatingMessage->value.choice.DLRRCMessageTransfer;
12050 for(idx=0; idx<f1DlRrcMsg->protocolIEs.list.count; idx++)
12052 switch(f1DlRrcMsg->protocolIEs.list.array[idx]->id)
12054 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12056 dlMsg.gnbCuUeF1apId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID;
12059 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12061 dlMsg.gnbDuUeF1apId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID;
12064 case ProtocolIE_ID_id_SRBID:
12066 dlMsg.srbId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.SRBID;
12069 case ProtocolIE_ID_id_ExecuteDuplication:
12070 dlMsg.execDup = true;
12073 case ProtocolIE_ID_id_RRCContainer:
12075 if(f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size > 0)
12077 dlMsg.rrcMsgSize = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size;
12078 DU_ALLOC_SHRABL_BUF(dlMsg.rrcMsgPdu, dlMsg.rrcMsgSize);
12079 if(dlMsg.rrcMsgPdu)
12081 memcpy(dlMsg.rrcMsgPdu, f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.buf,\
12086 DU_LOG("\nERROR --> DU APP : Memory alloc Failed at RRC Container at procF1DlRrcMsgTrans()");
12092 DU_LOG("\nERROR --> DU_APP : RRC Container Size is invalid:%ld",\
12093 f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size);
12098 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
12100 dlMsg.deliveryStatRpt = true;
12104 DU_LOG("\nERROR --> DU_APP : Invalid IE received in DL RRC Msg Transfer:%ld",
12105 f1DlRrcMsg->protocolIEs.list.array[idx]->id);
12109 ret = duProcDlRrcMsg(&dlMsg);
12111 freeAperDecodef1DlRrcMsg(f1DlRrcMsg);
12114 /*******************************************************************
12116 * @brief Builds the DRB to be Setup Mod list
12122 * Functionality: Constructs the DRB to be Setup Mod list
12124 * @params[in] DRBs_SetupMod_List_t *drbSet
12126 * @return ROK - success
12127 * RFAILED - failure
12129 * ****************************************************************/
12131 uint8_t BuildDrbSetupModList(DRBs_SetupMod_List_t *drbSet , DuUeCfg *ueCfg)
12135 struct DRBs_SetupMod_ItemIEs *drbItemIe;
12138 drbSet->list.count = drbCnt;
12139 drbSet->list.size = drbCnt * sizeof(DRBs_SetupMod_ItemIEs_t *);
12140 DU_ALLOC(drbSet->list.array, drbSet->list.size);
12141 if(drbSet->list.array == NULLP)
12143 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDrbToBeSetupModList");
12146 for(arrIdx=0; arrIdx<drbCnt; arrIdx++)
12148 DU_ALLOC(drbSet->list.array[arrIdx], sizeof(DRBs_SetupMod_ItemIEs_t));
12149 if(drbSet->list.array[arrIdx] == NULLP)
12151 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDrbToBeSetupModList");
12155 drbItemIe = (struct DRBs_SetupMod_ItemIEs *)drbSet->list.array[arrIdx];
12156 drbItemIe->id = ProtocolIE_ID_id_DRBs_SetupMod_Item;
12157 drbItemIe->criticality = Criticality_reject;
12158 drbItemIe->value.present = DRBs_SetupMod_ItemIEs__value_PR_DRBs_SetupMod_Item;
12159 drbItemIe->value.choice.DRBs_SetupMod_Item.dRBID = ueCfg->upTnlInfo[arrIdx].drbId;
12160 if(fillDlTnlSetupList(&drbItemIe->value.choice.DRBs_SetupMod_Item.dLUPTNLInformation_ToBeSetup_List,\
12161 &ueCfg->upTnlInfo[arrIdx])!= ROK)
12163 DU_LOG("\nERROR --> F1AP : Failed to fill DlTnl SetupList in BuildDrbToBeSetupModList");
12171 /*******************************************************************
12172 * @brief Free the memory allocated for DRB setup List
12176 * Function : FreeDrbSetupModList
12179 * Free the memory allocated for DRB setup list
12181 * @params[in] DRBs_Setup_List_t *
12184 * ****************************************************************/
12185 void FreeDrbSetupModList(DRBs_SetupMod_List_t *drbSetupList)
12187 uint8_t arrIdx = 0;
12188 DRBs_SetupMod_ItemIEs_t *drbItemIe = NULLP;
12190 for(arrIdx = 0; arrIdx < drbSetupList->list.count; arrIdx++)
12192 drbItemIe = ((DRBs_SetupMod_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
12193 freeDlTnlInfo(&drbItemIe->value.choice.DRBs_SetupMod_Item.dLUPTNLInformation_ToBeSetup_List);
12194 DU_FREE(drbSetupList->list.array[arrIdx], sizeof(DRBs_SetupMod_ItemIEs_t));
12196 DU_FREE(drbSetupList->list.array, drbSetupList->list.size);
12198 /*******************************************************************
12199 * @brief Free the memory allocated for UE Context Mod Response
12203 * Function : FreeUeContextModResp
12206 * Free the memory allocated for UE Context Mod Response
12208 * @params[in] F1AP_PDU_t *f1apMsg
12211 * ****************************************************************/
12213 void FreeUeContextModResp(F1AP_PDU_t *f1apMsg)
12216 UEContextModificationResponse_t *ueContextModifyRes = NULLP;
12219 if(f1apMsg->choice.successfulOutcome)
12221 ueContextModifyRes =&f1apMsg->choice.successfulOutcome->value.choice.UEContextModificationResponse;
12222 if(ueContextModifyRes->protocolIEs.list.array)
12224 for(ieIdx=0 ; ieIdx<ueContextModifyRes->protocolIEs.list.count; ieIdx++)
12226 if(ueContextModifyRes->protocolIEs.list.array[ieIdx])
12228 switch(ueContextModifyRes->protocolIEs.list.array[ieIdx]->id)
12230 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12232 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12234 case ProtocolIE_ID_id_DRBs_SetupMod_List:
12236 FreeDrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
12237 value.choice.DRBs_SetupMod_List));
12241 DU_FREE(ueContextModifyRes->protocolIEs.list.array[ieIdx], sizeof(UEContextModificationResponse_t));
12245 DU_FREE(ueContextModifyRes->protocolIEs.list.array, ueContextModifyRes->protocolIEs.list.size);
12247 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
12249 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
12253 /*****************************************************************i
12255 * @brief Creating the ue context modifcation response and sending
12259 * Function : BuildAndSendUeContextModRsp
12262 * - Creating the ue context modifcation response
12264 * @params[in] uint8_t cellId,uint8_t ueIdx
12265 * @return ROK - success
12266 * RFAILED - failure
12268 * ****************************************************************/
12269 uint8_t BuildAndSendUeContextModRsp(uint8_t cellId,uint8_t ueIdx)
12272 uint8_t cellIdx =0;
12273 uint8_t elementCnt = 0;
12274 uint8_t ret = RFAILED;
12275 uint32_t gnbCuUeF1apId; /* gNB-CU UE F1AP Id */
12276 uint32_t gnbDuUeF1apId; /* gNB-DU UE F1AP Id */
12277 F1AP_PDU_t *f1apMsg = NULLP;
12278 asn_enc_rval_t encRetVal;
12279 UEContextModificationResponse_t *ueContextModifyRes = NULLP;
12280 DuUeCb *ueCb = NULLP;
12282 DU_LOG("\nINFO --> F1AP : Building Ue context modification response\n");
12286 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
12287 if(f1apMsg == NULLP)
12289 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed Ue context modification");
12293 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
12295 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
12296 if(f1apMsg->choice.successfulOutcome == NULLP)
12298 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed Ue context modification");
12301 f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_UEContextModification;
12302 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
12303 f1apMsg->choice.successfulOutcome->value.present = SuccessfulOutcome__value_PR_UEContextModificationResponse;
12305 ueContextModifyRes =&f1apMsg->choice.successfulOutcome->value.choice.UEContextModificationResponse;
12308 ueContextModifyRes->protocolIEs.list.count = elementCnt;
12309 ueContextModifyRes->protocolIEs.list.size = elementCnt*sizeof(UEContextModificationResponse_t*);
12311 /* Initialize the UE context modification members */
12312 DU_ALLOC(ueContextModifyRes->protocolIEs.list.array, ueContextModifyRes->protocolIEs.list.size);
12313 if(ueContextModifyRes->protocolIEs.list.array == NULLP)
12315 DU_LOG("\nERROR --> F1AP : Memory allocation for UE context modifcation Request failed");
12319 for(ieIdx=0 ; ieIdx<elementCnt; ieIdx++)
12321 DU_ALLOC(ueContextModifyRes->protocolIEs.list.array[ieIdx], sizeof(UEContextModificationResponse_t));
12322 if(ueContextModifyRes->protocolIEs.list.array[ieIdx] == NULLP)
12324 DU_LOG("\nERROR --> F1AP : Memory allocation for UE context modifcation Request failed");
12329 /* Fetching Ue Cb Info*/
12330 GET_CELL_IDX(cellId, cellIdx);
12331 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
12332 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
12333 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
12336 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
12337 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
12338 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present =\
12339 UEContextModificationResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
12340 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
12343 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
12344 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
12345 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present=\
12346 UEContextModificationResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
12347 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
12350 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DRBs_SetupMod_List;
12351 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
12352 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present =\
12353 UEContextModificationResponseIEs__value_PR_DRBs_SetupMod_List;
12356 ret = BuildDrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
12357 value.choice.DRBs_SetupMod_List) , &ueCb->f1UeDb->duUeCfg);
12360 DU_LOG( "\nERROR --> F1AP : Failed to build drb setupmod List ");
12363 freeF1UeDb(ueCb->f1UeDb);
12364 ueCb->f1UeDb = NULLP;
12366 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
12368 /* Encode the F1SetupRequest type as APER */
12369 memset(encBuf, 0, ENC_BUF_MAX_LEN);
12371 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,encBuf);
12373 /* Encode results */
12374 if(encRetVal.encoded == ENCODE_FAIL)
12376 DU_LOG( "\nERROR --> F1AP : Could not encode UE Context Setup Request structure (at %s)\n",\
12377 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
12383 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UE Context Modification Response\n");
12384 for(int i=0; i< encBufSize; i++)
12386 printf("%x",encBuf[i]);
12391 if(sendF1APMsg() != ROK)
12393 DU_LOG("\nERROR --> F1AP : Sending UE Context Setup Res Failed");
12399 FreeUeContextModResp(f1apMsg);
12402 /*******************************************************************
12404 * @brief Deallocating the memory allocated by the aper decoder
12409 * Function : freeAperDecodeQosInfo
12411 * Functionality: Deallocating the memory allocated for QOSInfo
12413 * @params[in] QoSFlowLevelQoSParameters_t *drbQos
12417 * ****************************************************************/
12419 void freeAperDecodeQosInfo(QoSFlowLevelQoSParameters_t *drbQos)
12421 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI != NULLP)
12423 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
12425 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
12427 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
12429 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
12431 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI);
12434 /*******************************************************************
12436 * @brief Deallocating the memory allocated by the aper decoder
12437 * for UlTnlInfoforDrb
12441 * Function : freeAperDecodeUlTnlInfoforDrbSetupMod
12443 * Functionality: Deallocating memory allocated for UlTnlInfoforDrb
12445 * @params[in] ULUPTNLInformation_ToBeSetup_List_t *ulInfo
12449 * ****************************************************************/
12450 void freeAperDecodeUlTnlInfoforDrbSetupMod(ULUPTNLInformation_ToBeSetup_List_t *ulInfo)
12454 if(ulInfo->list.array)
12456 for(arrIdx=0; arrIdx<ulInfo->list.count ; arrIdx++)
12458 if(ulInfo->list.array[arrIdx])
12460 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel )
12462 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.buf)
12464 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf)
12466 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\
12469 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\
12470 transportLayerAddress.buf);
12472 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel);
12474 free(ulInfo->list.array[arrIdx]);
12477 free(ulInfo->list.array);
12480 /*******************************************************************
12482 * @brief Deallocating the memory allocated by the aper decoder
12483 * for DrbSetupModItem
12487 * Function : freeAperDecodeDrbSetupModItem
12489 * Functionality: Deallocating memory allocated for DrbSetupModItem
12491 * @params[in] DRBs_ToBeSetupMod_Item_t *drbItem
12495 * ****************************************************************/
12497 void freeAperDecodeDrbSetupModItem(DRBs_ToBeSetupMod_Item_t *drbItem)
12500 SNSSAI_t *snssai =NULLP;
12501 Flows_Mapped_To_DRB_List_t *flowMap = NULLP;
12503 drbItem->qoSInformation.present = QoSInformation_PR_choice_extension;
12504 switch(drbItem->qoSInformation.present)
12506 case QoSInformation_PR_NOTHING:
12508 case QoSInformation_PR_eUTRANQoS:
12510 if(drbItem->qoSInformation.choice.eUTRANQoS)
12512 free(drbItem->qoSInformation.choice.eUTRANQoS);
12516 case QoSInformation_PR_choice_extension:
12518 if(drbItem->qoSInformation.choice.choice_extension)
12520 freeAperDecodeQosInfo(&drbItem->qoSInformation.choice.choice_extension->value.choice.\
12521 DRB_Information.dRB_QoS);
12522 snssai = &drbItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI;
12523 if(snssai->sST.buf)
12525 free(snssai->sST.buf);
12529 if(snssai->sD->buf)
12531 free(snssai->sD->buf);
12536 flowMap = &drbItem->qoSInformation.choice.choice_extension->value.choice.\
12537 DRB_Information.flows_Mapped_To_DRB_List;
12538 if(flowMap->list.array)
12540 for(arrIdx=0; arrIdx<flowMap->list.count; arrIdx++)
12542 if(flowMap->list.array[arrIdx] )
12544 freeAperDecodeQosInfo(&flowMap->list.array[arrIdx]->qoSFlowLevelQoSParameters);
12545 free(flowMap->list.array[arrIdx]);
12548 free(flowMap->list.array);
12551 free(drbItem->qoSInformation.choice.choice_extension);
12557 freeAperDecodeUlTnlInfoforDrbSetupMod(&drbItem->uLUPTNLInformation_ToBeSetup_List);
12558 if(drbItem->uLConfiguration)
12560 free(drbItem->uLConfiguration);
12564 /*******************************************************************
12566 * @brief Deallocating the memory allocated by the aper decoder
12567 * for DrbToBeSetupModList
12571 * Function : freeAperDecodeDrbToBeSetupModList
12573 * Functionality: Deallocating memory allocated for DrbToBeSetupModList
12575 * @params[in] DRBs_ToBeSetupMod_List_t *drbSet
12579 * ****************************************************************/
12581 void freeAperDecodeDrbToBeSetupModList(DRBs_ToBeSetupMod_List_t *drbSet)
12584 struct DRBs_ToBeSetupMod_ItemIEs *drbItemIe;
12586 if(drbSet->list.array)
12588 for(arrIdx=0; arrIdx<drbSet->list.count ; arrIdx++)
12590 if(drbSet->list.array[arrIdx] != NULLP)
12594 drbItemIe = (DRBs_ToBeSetupMod_ItemIEs_t *)drbSet->list.array[arrIdx];
12595 freeAperDecodeDrbSetupModItem(&(drbItemIe->value.choice.DRBs_ToBeSetupMod_Item));
12597 free(drbSet->list.array[arrIdx]);
12600 free(drbSet->list.array);
12604 /*******************************************************************
12606 * @brief Deallocating the memory allocated by the aper decoder
12607 * for UeContextModificationReqMsg
12611 * Function : freeAperDecodeUeContextModificationReqMsg
12613 * Functionality: Deallocating memory allocated for
12614 * UeContextModificationReqMsg
12616 * @params[in] UEContextModificationRequest_t *UeContextModifyReq
12620 * ****************************************************************/
12621 void freeAperDecodeUeContextModificationReqMsg(UEContextModificationRequest_t *UeContextModifyReq )
12623 uint8_t arrIdx, ieId;
12625 if(UeContextModifyReq->protocolIEs.list.array)
12627 for( arrIdx = 0 ; arrIdx<UeContextModifyReq->protocolIEs.list.count ; arrIdx++)
12629 if(UeContextModifyReq->protocolIEs.list.array[arrIdx])
12631 ieId = UeContextModifyReq->protocolIEs.list.array[arrIdx]->id;
12634 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12636 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12638 case ProtocolIE_ID_id_DRBs_ToBeSetupMod_List:
12640 freeAperDecodeDrbToBeSetupModList(&UeContextModifyReq->protocolIEs.list.array[arrIdx]->\
12641 value.choice.DRBs_ToBeSetupMod_List);
12645 free(UeContextModifyReq->protocolIEs.list.array[arrIdx]);
12648 free(UeContextModifyReq->protocolIEs.list.array);
12651 /*******************************************************************
12653 * @brief processing the F1 UeContextModificationReq
12657 * Function : procF1UeContextModificationReq
12659 * Functionality: processing the F1 UeContextModificationReq
12661 * @params[in] F1AP_PDU_t *f1apMsg
12664 * ****************************************************************/
12665 uint8_t procF1UeContextModificationReq(F1AP_PDU_t *f1apMsg)
12667 UEContextModificationRequest_t *ueContextModifyReq = NULLP;
12668 uint8_t ret = ROK, ieIdx = 0, lcId =0,cellIdx=0, ueIdx=0;
12669 DuUeCb *duUeCb = NULLP;
12670 DRBs_ToBeSetupMod_List_t *drbSetupModCfg;
12671 uint32_t gnbCuUeF1apId, gnbDuUeF1apId;
12673 ueContextModifyReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextModificationRequest;
12674 for(ieIdx=0; (ieIdx < ueContextModifyReq->protocolIEs.list.count && ret == ROK); ieIdx++)
12676 switch(ueContextModifyReq->protocolIEs.list.array[ieIdx]->id)
12678 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12680 gnbCuUeF1apId = ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID;
12683 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12685 gnbDuUeF1apId = ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID;
12688 case ProtocolIE_ID_id_DRBs_ToBeSetupMod_List:
12690 for(cellIdx = 0; cellIdx < duCb.numActvCells; cellIdx++)
12692 for(ueIdx = 0; ueIdx < duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
12694 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
12695 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
12698 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
12699 lcId = getDrbLcId(&duUeCb->drbBitMap);
12700 if(lcId != RFAILED)
12702 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
12705 duUeCb->f1UeDb->actionType = UE_CTXT_MOD;
12706 drbSetupModCfg = &ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.\
12707 choice.DRBs_ToBeSetupMod_List;
12708 if(extractDrbListToSetup(lcId, NULL, drbSetupModCfg ,drbSetupModCfg->list.count, \
12709 &duUeCb->f1UeDb->duUeCfg))
12711 DU_LOG("\nERROR --> DU APP : Failed at extractDrbListToSetup()");
12719 DU_LOG("\nERROR --> DU APP : wrong values of gnbCuUeF1apId and gnbDuUeF1apId ");
12730 ret = duProcUeContextModReq(duUeCb);
12732 freeAperDecodeUeContextModificationReqMsg(ueContextModifyReq);
12735 /*****************************************************************i
12737 * @brief Free memory allocated for UE Context Release Request
12741 * Function : FreeUeContextReleaseReq
12744 * - Free memory allocated for UE Context Release Request
12746 * @params[in] F1AP_PDU_t *f1apMsg
12749 * *************************************************************/
12750 void FreeUeContextReleaseReq(F1AP_PDU_t *f1apMsg)
12753 UEContextReleaseRequest_t *ueReleaseReq = NULLP;
12757 if(f1apMsg->choice.initiatingMessage)
12759 ueReleaseReq =&f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseRequest;
12760 if(ueReleaseReq->protocolIEs.list.array)
12762 for(ieIdx=0 ; ieIdx<ueReleaseReq->protocolIEs.list.count; ieIdx++)
12764 DU_FREE(ueReleaseReq->protocolIEs.list.array[ieIdx], sizeof(UEContextReleaseRequest_t));
12766 DU_FREE(ueReleaseReq->protocolIEs.list.array, ueReleaseReq->protocolIEs.list.size);
12768 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
12770 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
12774 /*****************************************************************i
12776 * @brief Build and Send UE Context Release Request
12780 * Function : BuildAndSendUeContextReleaseReq
12783 * - Build and Send UE Context Release Request
12786 * @return ROK - success
12787 * RFAILED - failure
12789 * *************************************************************/
12790 uint8_t BuildAndSendUeContextReleaseReq(uint16_t cellId, uint8_t ueIdx)
12792 bool memAllocFail = false;
12794 uint8_t ret = RFAILED;
12795 uint16_t cellIdx =0;
12796 uint16_t crnti = 0;
12797 uint8_t elementCnt = 0;
12798 uint32_t gnbCuUeF1apId =0; /* gNB-CU UE F1AP Id */
12799 uint32_t gnbDuUeF1apId =0; /* gNB-DU UE F1AP Id */
12800 asn_enc_rval_t encRetVal;
12801 F1AP_PDU_t *f1apMsg = NULLP;
12802 UEContextReleaseRequest_t *ueReleaseReq = NULLP;
12804 DU_LOG("\nINFO --> Building the UE Context Release Request");
12807 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
12808 if(f1apMsg == NULLP)
12810 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for f1apMsg");
12814 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
12815 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
12816 if(f1apMsg->choice.initiatingMessage == NULLP)
12818 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for\
12819 initiatingMessage");
12822 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_UEContextReleaseRequest;
12823 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
12824 f1apMsg->choice.initiatingMessage->value.present = \
12825 InitiatingMessage__value_PR_UEContextReleaseRequest;
12827 ueReleaseReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseRequest;
12831 ueReleaseReq->protocolIEs.list.count = elementCnt;
12832 ueReleaseReq->protocolIEs.list.size = elementCnt * sizeof(UEContextReleaseRequest_t *);
12834 /* Initialize the F1Setup members */
12835 DU_ALLOC(ueReleaseReq->protocolIEs.list.array,ueReleaseReq->protocolIEs.list.size);
12836 if(ueReleaseReq->protocolIEs.list.array == NULLP)
12838 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for IE array");
12841 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
12843 DU_ALLOC(ueReleaseReq->protocolIEs.list.array[ieIdx],\
12844 sizeof(UEContextReleaseRequest_t));
12845 if(ueReleaseReq->protocolIEs.list.array[ieIdx] == NULLP)
12847 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for IE elements");
12848 memAllocFail = true;
12852 if(memAllocFail == true)
12855 /* Fetching Ue Cb Info*/
12856 GET_CELL_IDX(cellId, cellIdx);
12857 if(duCb.actvCellLst[cellIdx] == NULLP)
12859 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): CellId[%d] does not exist", cellId);
12864 GET_CRNTI(crnti, ueIdx);
12865 if(duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti != crnti)
12867 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): crnti[%d] does not exist", crnti);
12870 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
12871 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
12875 ueReleaseReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
12876 ueReleaseReq->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
12877 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.present = \
12878 UEContextReleaseRequestIEs__value_PR_GNB_CU_UE_F1AP_ID;
12879 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID =gnbCuUeF1apId;
12882 ueReleaseReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
12883 ueReleaseReq->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
12884 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.present =\
12885 UEContextReleaseRequestIEs__value_PR_GNB_DU_UE_F1AP_ID;
12886 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID =gnbDuUeF1apId;
12888 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
12890 /* Encode the F1SetupRequest type as APER */
12891 memset(encBuf, 0, ENC_BUF_MAX_LEN);
12893 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
12894 /* Encode results */
12895 if(encRetVal.encoded == ENCODE_FAIL)
12897 DU_LOG("\nERROR --> F1AP : Could not encode UEContextReleaseRequest structure (at %s)\n",\
12898 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
12903 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UEContextReleaseRequest\n");
12904 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
12906 printf("%x",encBuf[ieIdx]);
12911 if(sendF1APMsg() != ROK)
12913 DU_LOG("\nERROR --> F1AP : Sending UE Context Release Request failed");
12920 FreeUeContextReleaseReq(f1apMsg);
12923 /*****************************************************************i
12925 * @brief Free memory allocated for UE Context Release Complete
12929 * Function : FreeUeContextReleaseComplete
12932 * - Free memory allocated for UE Context Release Complete
12934 * @params[in] F1AP_PDU_t *f1apMsg
12937 * *************************************************************/
12938 void FreeUeContextReleaseComplete(F1AP_PDU_t *f1apMsg)
12941 UEContextReleaseComplete_t *ueReleaseComplete = NULLP;
12945 if(f1apMsg->choice.successfulOutcome)
12947 ueReleaseComplete =&f1apMsg->choice.successfulOutcome->value.choice.UEContextReleaseComplete;
12948 if(ueReleaseComplete->protocolIEs.list.array)
12950 for(ieIdx=0 ; ieIdx<ueReleaseComplete->protocolIEs.list.count; ieIdx++)
12952 DU_FREE(ueReleaseComplete->protocolIEs.list.array[ieIdx], sizeof(UEContextReleaseComplete_t));
12954 DU_FREE(ueReleaseComplete->protocolIEs.list.array, ueReleaseComplete->protocolIEs.list.size);
12956 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
12958 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
12962 /*****************************************************************i
12964 * @brief Build and Send UE Context Release Complete
12968 * Function : BuildAndSendUeContextReleaseComplete
12971 * - Build and Send UE Context Release Complete
12973 * @params[in] cellId, gnbCuUeF1apId, gnbDuUeF1apId
12974 * @return ROK - success
12975 * RFAILED - failure
12977 * *************************************************************/
12978 uint8_t BuildAndSendUeContextReleaseComplete(uint16_t cellId, uint32_t gnbCuUeF1apId, uint32_t gnbDuUeF1apId)
12980 bool memAllocFail = false;
12981 uint8_t ieIdx =0, ret = RFAILED, elementCnt = 0;
12982 asn_enc_rval_t encRetVal;
12983 F1AP_PDU_t *f1apMsg = NULLP;
12984 UEContextReleaseComplete_t *ueReleaseComplete = NULLP;
12986 DU_LOG("\nINFO --> Building the UE Context Release Complete");
12989 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
12990 if(f1apMsg == NULLP)
12992 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for f1apMsg");
12996 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
12997 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
12998 if(f1apMsg->choice.successfulOutcome == NULLP)
13000 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for\
13001 successfulOutcome");
13004 f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_UEContextRelease;
13005 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
13006 f1apMsg->choice.successfulOutcome->value.present = \
13007 SuccessfulOutcome__value_PR_UEContextReleaseComplete;
13009 ueReleaseComplete = &f1apMsg->choice.successfulOutcome->value.choice.UEContextReleaseComplete;
13012 ueReleaseComplete->protocolIEs.list.count = elementCnt;
13013 ueReleaseComplete->protocolIEs.list.size = elementCnt * sizeof(UEContextReleaseComplete_t *);
13015 /* Initialize the UE Release Complete members */
13016 DU_ALLOC(ueReleaseComplete->protocolIEs.list.array,ueReleaseComplete->protocolIEs.list.size);
13017 if(ueReleaseComplete->protocolIEs.list.array == NULLP)
13019 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for IE array");
13022 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
13024 DU_ALLOC(ueReleaseComplete->protocolIEs.list.array[ieIdx],\
13025 sizeof(UEContextReleaseComplete_t));
13026 if(ueReleaseComplete->protocolIEs.list.array[ieIdx] == NULLP)
13028 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for IE\
13030 memAllocFail = true;
13034 if(memAllocFail == true)
13039 ueReleaseComplete->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
13040 ueReleaseComplete->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
13041 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.present = \
13042 UEContextReleaseCompleteIEs__value_PR_GNB_CU_UE_F1AP_ID;
13043 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID =gnbCuUeF1apId;
13046 ueReleaseComplete->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
13047 ueReleaseComplete->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
13048 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.present =\
13049 UEContextReleaseCompleteIEs__value_PR_GNB_DU_UE_F1AP_ID;
13050 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID =gnbDuUeF1apId;
13052 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
13054 /* Encode the F1SetupComplete type as APER */
13055 memset(encBuf, 0, ENC_BUF_MAX_LEN);
13057 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
13058 /* Encode results */
13059 if(encRetVal.encoded == ENCODE_FAIL)
13061 DU_LOG("\nERROR --> F1AP : Could not encode UEContextReleaseComplete structure (at %s)\n",\
13062 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
13067 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UEContextReleaseComplete\n");
13068 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
13070 printf("%x",encBuf[ieIdx]);
13075 if(sendF1APMsg() != ROK)
13077 DU_LOG("\nERROR --> F1AP : Sending UE Context Release Complete failed");
13086 duCb.actvCellLst[cellId-1]->cellStatus = DELETION_IN_PROGRESS;
13087 ret = duSendCellDeletReq(cellId);
13090 DU_LOG("\nERROR --> F1AP: BuildAndSendUeContextReleaseComplete(): Failed to process cell\
13091 Delete req for CellId");
13094 FreeUeContextReleaseComplete(f1apMsg);
13099 /*******************************************************************
13101 * @brief added free part for the memory allocated by aper_decoder
13105 * Function : freeAperDecodeUeContextReleaseCommand
13107 * Functionality: added free part for the memory allocated by aper_decoder
13109 * @params[in] F1AP_PDU_t *f1apMsg
13112 * ****************************************************************/
13113 void freeAperDecodeUeContextReleaseCommand(F1AP_PDU_t *f1apMsg)
13116 UEContextReleaseCommand_t *ueContextReleaseCommand = NULLP;
13118 ueContextReleaseCommand = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseCommand;
13120 if(ueContextReleaseCommand->protocolIEs.list.array)
13122 for(ieIdx=0; ieIdx < ueContextReleaseCommand->protocolIEs.list.count; ieIdx++)
13124 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx])
13126 switch(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id)
13128 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
13130 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
13132 case ProtocolIE_ID_id_Cause:
13134 case ProtocolIE_ID_id_RRCContainer:
13136 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
13138 free(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf);
13143 DU_LOG("\nERROR --> F1AP: freeAperDecodeUeContextReleaseCommand():Invalid IE Received: %ld"\
13144 ,ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id);
13148 free(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]);
13150 free(ueContextReleaseCommand->protocolIEs.list.array);
13153 /*******************************************************************
13155 * @brief processing of UE Context Release Command
13159 * Function : procF1UeContextReleaseCommand
13161 * Functionality: processing of UE Context Release Command
13163 * @params[in] F1AP_PDU_t *f1apMsg
13166 * ****************************************************************/
13167 uint8_t procF1UeContextReleaseCommand(F1AP_PDU_t *f1apMsg)
13169 uint8_t ieIdx=0, ret=ROK, ueIdx=0;
13170 uint16_t cellIdx =0;
13172 uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId=0;
13173 DuUeCb *duUeCb = NULLP;
13174 UEContextReleaseCommand_t *ueContextReleaseCommand = NULLP;
13176 ueContextReleaseCommand = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseCommand;
13178 if(ueContextReleaseCommand->protocolIEs.list.array)
13180 for(ieIdx=0; ieIdx < ueContextReleaseCommand->protocolIEs.list.count; ieIdx++)
13182 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx])
13184 switch(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id)
13186 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
13188 gnbCuUeF1apId= ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
13189 value.choice.GNB_CU_UE_F1AP_ID;
13193 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
13195 gnbDuUeF1apId = ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
13196 value.choice.GNB_DU_UE_F1AP_ID;
13200 case ProtocolIE_ID_id_Cause:
13205 case ProtocolIE_ID_id_RRCContainer:
13207 for(cellIdx = 0; cellIdx < duCb.numActvCells; cellIdx++)
13209 for(ueIdx = 0; ueIdx < duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
13211 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
13212 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
13214 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
13215 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
13218 memset(duUeCb->f1UeDb, 0, sizeof(F1UeContextSetupDb));
13219 duUeCb->f1UeDb->actionType = UE_CTXT_RELEASE;
13220 duUeCb->f1UeDb->cellIdx = cellIdx;
13221 /* Filling Dl RRC Msg Info */
13222 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
13223 if(!duUeCb->f1UeDb->dlRrcMsg)
13225 DU_LOG("\nERROR --> DU APP : procF1UeContextReleaseCommand(): \
13226 Memory allocation failed ");
13231 duUeCb->f1UeDb->dlRrcMsgPres = true;
13232 memset(duUeCb->f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
13233 ret = extractDlRrcMsg(gnbDuUeF1apId, gnbCuUeF1apId, duUeCb->f1UeDb->dlRrcMsg,\
13234 &ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
13235 value.choice.RRCContainer);
13241 DU_LOG("\nERROR --> DU APP : procF1UeContextReleaseCommand(): \
13242 Memory allocation failed ");
13251 if(ueIdxFound == true)
13258 DU_LOG("\nERROR --> F1AP: DuUeCb is not found at procF1UeContextSetupReq()");
13266 DU_LOG("\nERROR --> F1AP: freeAperDecodeUeContextReleaseCommand():Invalid IE Received: %ld"\
13267 ,ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id);
13275 duProcUeContextReleaseCommand(duUeCb);
13277 freeAperDecodeUeContextReleaseCommand(f1apMsg);
13280 /**************************************************************
13282 * @brief Handles received F1AP message and sends back response
13286 * Function : F1APMsgHdlr
13289 * - Decodes received F1AP control message
13290 * - Prepares response message, encodes and sends to SCTP
13293 * @return ROK - success
13294 * RFAILED - failure
13296 * ****************************************************************/
13297 void F1APMsgHdlr(Buffer *mBuf)
13300 char *recvBuf =NULLP;
13302 MsgLen recvBufLen =0;
13303 F1AP_PDU_t *f1apMsg =NULLP;
13304 asn_dec_rval_t rval; /* Decoder return value */
13305 F1AP_PDU_t f1apasnmsg ;
13306 DU_LOG("\nINFO --> F1AP : Received F1AP message buffer");
13307 ODU_PRINT_MSG(mBuf, 0,0);
13309 /* Copy mBuf into char array to decode it */
13310 ODU_GET_MSG_LEN(mBuf, &recvBufLen);
13311 DU_ALLOC(recvBuf, (Size)recvBufLen);
13313 if(recvBuf == NULLP)
13315 DU_LOG("\nERROR --> F1AP : Memory allocation failed");
13318 if(ODU_COPY_MSG_TO_FIX_BUF(mBuf, 0, recvBufLen, (Data *)recvBuf, ©Cnt) != ROK)
13320 DU_LOG("\nERROR --> F1AP : Failed while copying %d", copyCnt);
13324 printf("\nDEBUG --> F1AP : Received flat buffer to be decoded : ");
13325 for(i=0; i< recvBufLen; i++)
13327 printf("%x",recvBuf[i]);
13330 /* Decoding flat buffer into F1AP messsage */
13331 f1apMsg = &f1apasnmsg;
13332 memset(f1apMsg, 0, sizeof(F1AP_PDU_t));
13334 rval = aper_decode(0, &asn_DEF_F1AP_PDU, (void **)&f1apMsg, recvBuf, recvBufLen, 0, 0);
13335 DU_FREE(recvBuf, (Size)recvBufLen);
13337 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
13339 DU_LOG("\nERROR --> F1AP : ASN decode failed");
13343 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
13345 switch(f1apMsg->present)
13347 case F1AP_PDU_PR_successfulOutcome:
13349 switch(f1apMsg->choice.successfulOutcome->value.present)
13351 case SuccessfulOutcome__value_PR_ResetAcknowledge:
13353 DU_LOG("\nINFO --> F1AP : F1ResetAcknowledge is received successfully ");
13356 case SuccessfulOutcome__value_PR_F1SetupResponse:
13358 #ifndef ODU_TEST_STUB
13359 procF1SetupRsp(f1apMsg);
13364 case SuccessfulOutcome__value_PR_GNBDUConfigurationUpdateAcknowledge:
13366 procF1GNBDUCfgUpdAck(f1apMsg);
13372 DU_LOG("\nERROR --> F1AP : Invalid type of SuccessfulOutcome__value_PR_ResetAcknowledge [%d]",\
13373 f1apMsg->choice.successfulOutcome->value.present);
13376 }/* End of switch(successfulOutcome) */
13377 free(f1apMsg->choice.successfulOutcome);
13380 case F1AP_PDU_PR_initiatingMessage:
13382 switch(f1apMsg->choice.initiatingMessage->value.present)
13384 case InitiatingMessage__value_PR_Reset:
13386 procF1ResetReq(f1apMsg);
13389 case InitiatingMessage__value_PR_DLRRCMessageTransfer:
13391 procF1DlRrcMsgTrans(f1apMsg);
13394 case InitiatingMessage__value_PR_UEContextSetupRequest:
13396 procF1UeContextSetupReq(f1apMsg);
13399 case InitiatingMessage__value_PR_UEContextModificationRequest:
13401 procF1UeContextModificationReq(f1apMsg);
13404 case InitiatingMessage__value_PR_UEContextReleaseCommand:
13406 procF1UeContextReleaseCommand(f1apMsg);
13411 DU_LOG("\nERROR --> F1AP : Invalid type of F1AP_PDU_PR_initiatingMessage [%d]",
13412 f1apMsg->choice.initiatingMessage->value.present);
13415 }/* End of switch(initiatingMessage) */
13416 free(f1apMsg->choice.initiatingMessage);
13422 DU_LOG("\nERROR --> F1AP : Invalid type of f1apMsg->present [%d]",f1apMsg->present);
13427 }/* End of switch(f1apMsg->present) */
13429 } /* End of F1APMsgHdlr */
13431 /**********************************************************************
13433 **********************************************************************/