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_CFG1;
4147 timeDomAlloc->mappingType = PUSCH_MAPPING_TYPE_A;
4148 timeDomAlloc->startSymbolAndLength = calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
4151 timeDomAlloc = timeDomAllocList->choice.setup->list.array[idx];
4152 DU_ALLOC(timeDomAlloc->k2, sizeof(long));
4153 if(!timeDomAlloc->k2)
4155 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4158 *(timeDomAlloc->k2) = PUSCH_K2_CFG2;
4159 timeDomAlloc->mappingType = PUSCH_MAPPING_TYPE_A;
4160 timeDomAlloc->startSymbolAndLength = calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
4165 /*******************************************************************
4167 * @brief Builds BWP UL dedicated PUSCH Config
4171 * Function : BuildBWPUlDedPuschCfg
4174 * Builds BWP UL dedicated PUSCH Config
4176 * @params[in] : PUSCH_Config_t *puschCfg
4178 * @return ROK - success
4181 * ****************************************************************/
4182 uint8_t BuildBWPUlDedPuschCfg(PUSCH_Config_t *puschCfg)
4184 puschCfg->dataScramblingIdentityPUSCH = NULLP;
4185 DU_ALLOC(puschCfg->dataScramblingIdentityPUSCH, sizeof(long));
4186 if(!puschCfg->dataScramblingIdentityPUSCH)
4188 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4191 *(puschCfg->dataScramblingIdentityPUSCH) = SCRAMBLING_ID;
4193 puschCfg->txConfig = NULLP;
4194 puschCfg->dmrs_UplinkForPUSCH_MappingTypeA = NULLP;
4195 DU_ALLOC(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA, \
4196 sizeof(struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA));
4197 if(!puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
4199 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4203 if(BuildDMRSULPuschMapTypeA(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA) != ROK)
4208 puschCfg->dmrs_UplinkForPUSCH_MappingTypeB = NULLP;
4209 puschCfg->pusch_PowerControl = NULLP;
4210 puschCfg->frequencyHopping = NULLP;
4211 puschCfg->frequencyHoppingOffsetLists = NULLP;
4212 puschCfg->resourceAllocation = RES_ALLOC_TYPE;
4214 puschCfg->pusch_TimeDomainAllocationList = NULLP;
4215 DU_ALLOC(puschCfg->pusch_TimeDomainAllocationList, \
4216 sizeof(struct PUSCH_Config__pusch_TimeDomainAllocationList));
4217 if(!puschCfg->pusch_TimeDomainAllocationList)
4219 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4223 if(BuildPuschTimeDomAllocList(puschCfg->pusch_TimeDomainAllocationList) != ROK)
4228 puschCfg->pusch_AggregationFactor = NULLP;
4229 puschCfg->mcs_Table = NULLP;
4230 puschCfg->mcs_TableTransformPrecoder = NULLP;
4231 puschCfg->transformPrecoder = NULLP;
4232 DU_ALLOC(puschCfg->transformPrecoder, sizeof(long));
4233 if(!puschCfg->transformPrecoder)
4235 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4238 *(puschCfg->transformPrecoder) = PUSCH_TRANSFORM_PRECODER;
4240 puschCfg->codebookSubset = NULLP;
4241 puschCfg->maxRank = NULLP;
4242 puschCfg->rbg_Size = NULLP;
4243 puschCfg->uci_OnPUSCH = NULLP;
4244 puschCfg->tp_pi2BPSK = NULLP;
4249 /*******************************************************************
4251 * @brief Builds BWP UL dedicated PUCCH Config
4255 * Function : BuildBWPUlDedPucchCfg
4258 * Builds BWP UL dedicated PUCCH Config
4260 * @params[in] : PUCCH_Config_t *pucchCfg
4262 * @return ROK - success
4265 * ****************************************************************/
4266 uint8_t BuildBWPUlDedPucchCfg(PUCCH_Config_t *pucchCfg)
4268 uint8_t arrIdx, elementCnt;
4270 DU_ALLOC(pucchCfg->dl_DataToUL_ACK, sizeof(struct PUCCH_Config__dl_DataToUL_ACK));
4271 if(pucchCfg->dl_DataToUL_ACK == NULLP)
4273 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
4278 pucchCfg->dl_DataToUL_ACK->list.count = elementCnt;
4279 pucchCfg->dl_DataToUL_ACK->list.size = elementCnt * sizeof(long *);
4280 DU_ALLOC(pucchCfg->dl_DataToUL_ACK->list.array, pucchCfg->dl_DataToUL_ACK->list.size);
4281 if(pucchCfg->dl_DataToUL_ACK->list.array == NULLP)
4283 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
4287 for(arrIdx = 0; arrIdx < pucchCfg->dl_DataToUL_ACK->list.count; arrIdx++)
4289 DU_ALLOC(pucchCfg->dl_DataToUL_ACK->list.array[arrIdx], sizeof(long));
4290 if(pucchCfg->dl_DataToUL_ACK->list.array[arrIdx] == NULLP)
4292 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
4298 *(pucchCfg->dl_DataToUL_ACK->list.array[arrIdx++]) = 1;
4299 *(pucchCfg->dl_DataToUL_ACK->list.array[arrIdx]) = 2;
4303 /*******************************************************************
4305 * @brief Fills SRS resource to add/modify list
4309 * Function : BuildSrsRsrcAddModList
4311 * Functionality: Fills SRS resource to add/modify list
4314 * @return ROK - success
4317 * ****************************************************************/
4318 uint8_t BuildSrsRsrcAddModList(struct SRS_Config__srs_ResourceToAddModList *resourceList)
4324 resourceList->list.count = elementCnt;
4325 resourceList->list.size = elementCnt * sizeof(SRS_Resource_t *);
4326 resourceList->list.array = NULLP;
4327 DU_ALLOC(resourceList->list.array, resourceList->list.size);
4328 if(!resourceList->list.array)
4330 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
4334 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
4336 DU_ALLOC(resourceList->list.array[rsrcIdx], sizeof(SRS_Resource_t));
4337 if(!resourceList->list.array[rsrcIdx])
4339 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
4345 resourceList->list.array[rsrcIdx]->srs_ResourceId = SRS_RSRC_ID;
4346 resourceList->list.array[rsrcIdx]->nrofSRS_Ports = SRS_Resource__nrofSRS_Ports_port1;
4347 resourceList->list.array[rsrcIdx]->transmissionComb.present = SRS_Resource__transmissionComb_PR_n2;
4349 resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2 = NULLP;
4350 DU_ALLOC(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2, \
4351 sizeof(struct SRS_Resource__transmissionComb__n2));
4352 if(!resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2)
4354 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
4357 resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2->combOffset_n2\
4358 = SRS_COMB_OFFSET_N2;
4359 resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2->cyclicShift_n2\
4360 = SRS_CYCLIC_SHIFT_N2;
4362 resourceList->list.array[rsrcIdx]->resourceMapping.startPosition = \
4364 resourceList->list.array[rsrcIdx]->resourceMapping.nrofSymbols = \
4365 SRS_Resource__resourceMapping__nrofSymbols_n1;
4366 resourceList->list.array[rsrcIdx]->resourceMapping.repetitionFactor = \
4367 SRS_Resource__resourceMapping__repetitionFactor_n1;
4369 resourceList->list.array[rsrcIdx]->freqDomainPosition = SRS_FREQ_DOM_POS;
4370 resourceList->list.array[rsrcIdx]->freqDomainShift = SRS_FREQ_DOM_SHIFT;
4371 resourceList->list.array[rsrcIdx]->freqHopping.c_SRS = C_SRS;
4372 resourceList->list.array[rsrcIdx]->freqHopping.b_SRS = B_SRS;
4373 resourceList->list.array[rsrcIdx]->freqHopping.b_hop = B_HOP;
4374 resourceList->list.array[rsrcIdx]->groupOrSequenceHopping = \
4375 SRS_Resource__groupOrSequenceHopping_neither;
4377 /* Setting resource type to aperiodic for intergration purposes */
4378 resourceList->list.array[rsrcIdx]->resourceType.present = \
4379 SRS_Resource__resourceType_PR_aperiodic;
4380 resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic = NULLP;
4381 DU_ALLOC(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic,
4382 sizeof(struct SRS_Resource__resourceType__aperiodic));
4383 if(!resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic)
4385 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
4388 resourceList->list.array[rsrcIdx]->sequenceId = SRS_SEQ_ID;
4393 /*******************************************************************
4395 * @brief Build SRS resource set Add/mod list
4399 * Function : BuildSrsRsrcSetAddModList
4401 * Functionality: Build SRS resource set Add/mod list
4404 * @return ROK - success
4407 * ****************************************************************/
4408 uint8_t BuildSrsRsrcSetAddModList
4410 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList
4416 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList;
4419 rsrcSetList->list.count = elementCnt;
4420 rsrcSetList->list.size = elementCnt * sizeof(SRS_ResourceSet_t *);
4421 rsrcSetList->list.array = NULLP;
4422 DU_ALLOC(rsrcSetList->list.array, rsrcSetList->list.size);
4423 if(!rsrcSetList->list.array)
4425 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4429 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
4431 DU_ALLOC(rsrcSetList->list.array[rSetIdx], sizeof(SRS_ResourceSet_t));
4432 if(!rsrcSetList->list.array[rSetIdx])
4434 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4440 rsrcSetList->list.array[rSetIdx]->srs_ResourceSetId = SRS_RSET_ID;
4442 /* Fill Resource Id list in resource set */
4443 rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList = NULLP;
4444 DU_ALLOC(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList,\
4445 sizeof(struct SRS_ResourceSet__srs_ResourceIdList));
4446 if(!rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
4448 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4453 rsrcIdList = rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
4454 rsrcIdList->list.count = elementCnt;
4455 rsrcIdList->list.size = elementCnt * sizeof(SRS_ResourceId_t *);
4456 rsrcIdList->list.array = NULLP;
4457 DU_ALLOC(rsrcIdList->list.array, rsrcIdList->list.size);
4458 if(!rsrcIdList->list.array)
4460 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4464 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count; rsrcIdx++)
4466 DU_ALLOC(rsrcIdList->list.array[rsrcIdx], sizeof(SRS_ResourceId_t));
4467 if(!rsrcIdList->list.array[rsrcIdx])
4469 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4475 *rsrcIdList->list.array[rsrcIdx] = SRS_RSRC_ID;
4477 /* Fill resource type */
4478 rsrcSetList->list.array[rSetIdx]->resourceType.present = \
4479 SRS_ResourceSet__resourceType_PR_aperiodic;
4481 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic = NULLP;
4482 DU_ALLOC(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic, \
4483 sizeof(struct SRS_ResourceSet__resourceType__aperiodic));
4484 if(!rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic)
4486 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4489 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic->aperiodicSRS_ResourceTrigger \
4490 = APERIODIC_SRS_RESRC_TRIGGER;
4492 /* TODO : Fill values for below IEs as expected by Viavi */
4493 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic->csi_RS = NULLP;
4494 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic->slotOffset = NULLP;
4497 rsrcSetList->list.array[rSetIdx]->usage = SRS_ResourceSet__usage_codebook;
4498 rsrcSetList->list.array[rSetIdx]->alpha = NULLP;
4499 rsrcSetList->list.array[rSetIdx]->p0 = NULLP;
4500 rsrcSetList->list.array[rSetIdx]->pathlossReferenceRS = NULLP;
4501 rsrcSetList->list.array[rSetIdx]->srs_PowerControlAdjustmentStates = NULLP;
4506 /*******************************************************************
4508 * @brief Builds BWP UL dedicated SRS Config
4512 * Function : BuildBWPUlDedSrsCfg
4514 * Functionality: Builds BWP UL dedicated SRS Config
4516 * @params[in] SRS Config
4517 * @return ROK - success
4520 * ****************************************************************/
4521 uint8_t BuildBWPUlDedSrsCfg(SRS_Config_t *srsCfg)
4523 srsCfg->srs_ResourceSetToReleaseList = NULLP;
4524 srsCfg->srs_ResourceSetToAddModList = NULLP;
4525 DU_ALLOC(srsCfg->srs_ResourceSetToAddModList, \
4526 sizeof(struct SRS_Config__srs_ResourceSetToAddModList));
4527 if(!srsCfg->srs_ResourceSetToAddModList)
4529 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedSrsCfg");
4532 if(BuildSrsRsrcSetAddModList(srsCfg->srs_ResourceSetToAddModList) != ROK)
4537 srsCfg->srs_ResourceToReleaseList = NULLP;
4539 /* Resource to Add/Modify list */
4540 srsCfg->srs_ResourceToAddModList = NULLP;
4541 DU_ALLOC(srsCfg->srs_ResourceToAddModList, \
4542 sizeof(struct SRS_Config__srs_ResourceToAddModList));
4543 if(!srsCfg->srs_ResourceToAddModList)
4545 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedSrsCfg");
4549 if(BuildSrsRsrcAddModList(srsCfg->srs_ResourceToAddModList) != ROK)
4554 srsCfg->tpc_Accumulation = NULLP;
4561 /*******************************************************************
4563 * @brief Builds Pusch Serving cell Config
4567 * Function : BuildPuschSrvCellCfg
4569 * Functionality: Builds Pusch Serving cell Config
4571 * @params[in] struct UplinkConfig__pusch_ServingCellConfig *puschCfg
4573 * @return ROK - success
4576 * ****************************************************************/
4577 uint8_t BuildPuschSrvCellCfg(struct UplinkConfig__pusch_ServingCellConfig *puschCfg)
4579 puschCfg->present = UplinkConfig__pusch_ServingCellConfig_PR_setup;
4580 puschCfg->choice.setup = NULLP;
4581 DU_ALLOC(puschCfg->choice.setup, sizeof(struct PUSCH_ServingCellConfig));
4582 if(!puschCfg->choice.setup)
4584 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
4588 puschCfg->choice.setup->codeBlockGroupTransmission = NULLP;
4589 puschCfg->choice.setup->rateMatching = NULLP;
4590 puschCfg->choice.setup->xOverhead = NULLP;
4591 puschCfg->choice.setup->ext1 = NULLP;
4592 DU_ALLOC(puschCfg->choice.setup->ext1, sizeof(struct PUSCH_ServingCellConfig__ext1));
4593 if(!puschCfg->choice.setup->ext1)
4595 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
4599 puschCfg->choice.setup->ext1->maxMIMO_Layers = NULLP;
4600 DU_ALLOC(puschCfg->choice.setup->ext1->maxMIMO_Layers, sizeof(long));
4601 if(!puschCfg->choice.setup->ext1->maxMIMO_Layers)
4603 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
4606 *(puschCfg->choice.setup->ext1->maxMIMO_Layers) = PUSCH_MAX_MIMO_LAYERS;
4608 puschCfg->choice.setup->ext1->processingType2Enabled= NULLP;
4609 DU_ALLOC(puschCfg->choice.setup->ext1->processingType2Enabled,sizeof(BOOLEAN_t));
4610 if(!puschCfg->choice.setup->ext1->processingType2Enabled)
4612 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
4615 *(puschCfg->choice.setup->ext1->processingType2Enabled) = PUSCH_PROCESS_TYPE2_ENABLED;
4619 /*******************************************************************
4621 * @brief Builds inital UL BWP
4625 * Function : BuildInitialUlBWP
4627 * Functionality: Builds initial UL BWP
4629 * @params[in] BWP_UplinkDedicated_t *ulBwp
4630 * @return ROK - success
4633 * ****************************************************************/
4634 uint8_t BuildInitialUlBWP(BWP_UplinkDedicated_t *ulBwp)
4636 ulBwp->pucch_Config = NULLP;
4637 DU_ALLOC(ulBwp->pucch_Config, sizeof(struct BWP_UplinkDedicated__pucch_Config));
4638 if(!ulBwp->pucch_Config)
4640 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4644 ulBwp->pucch_Config->present = BWP_UplinkDedicated__pucch_Config_PR_setup;
4645 ulBwp->pucch_Config->choice.setup = NULLP;
4646 DU_ALLOC(ulBwp->pucch_Config->choice.setup, sizeof(PUCCH_Config_t));
4647 if(!ulBwp->pucch_Config->choice.setup)
4649 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4653 if(BuildBWPUlDedPucchCfg(ulBwp->pucch_Config->choice.setup) != ROK)
4658 /* Fill BWP UL dedicated PUSCH config */
4659 ulBwp->pusch_Config = NULLP;
4660 DU_ALLOC(ulBwp->pusch_Config, sizeof(struct BWP_UplinkDedicated__pusch_Config));
4661 if(!ulBwp->pusch_Config)
4663 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4667 ulBwp->pusch_Config->present = BWP_UplinkDedicated__pusch_Config_PR_setup;
4668 ulBwp->pusch_Config->choice.setup = NULLP;
4669 DU_ALLOC(ulBwp->pusch_Config->choice.setup, sizeof(PUSCH_Config_t));
4670 if(!ulBwp->pusch_Config->choice.setup)
4672 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4676 if(BuildBWPUlDedPuschCfg(ulBwp->pusch_Config->choice.setup) != ROK)
4681 ulBwp->configuredGrantConfig = NULLP;
4683 /* Fill BPW UL dedicated SRS config */
4684 ulBwp->srs_Config = NULLP;
4685 DU_ALLOC(ulBwp->srs_Config, sizeof(struct BWP_UplinkDedicated__srs_Config));
4686 if(!ulBwp->srs_Config)
4688 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4692 ulBwp->srs_Config->present = BWP_UplinkDedicated__srs_Config_PR_setup;
4693 ulBwp->srs_Config->choice.setup = NULLP;
4694 DU_ALLOC(ulBwp->srs_Config->choice.setup, sizeof(SRS_Config_t));
4695 if(!ulBwp->srs_Config->choice.setup)
4697 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4701 if(BuildBWPUlDedSrsCfg(ulBwp->srs_Config->choice.setup) != ROK)
4706 ulBwp->beamFailureRecoveryConfig = NULLP;
4711 /*******************************************************************
4713 * @brief Builds UL config
4716 * Function : BuildUlCfg
4718 * Functionality: Builds UL config in spCellCfgDed
4720 * @params[in] UplinkConfig_t *ulCfg
4722 * @return ROK - success
4725 * ****************************************************************/
4726 uint8_t BuildUlCfg(UplinkConfig_t *ulCfg)
4728 ulCfg->initialUplinkBWP = NULLP;
4729 DU_ALLOC(ulCfg->initialUplinkBWP, sizeof(BWP_UplinkDedicated_t));
4730 if(!ulCfg->initialUplinkBWP)
4732 DU_LOG("\nERROR --> F1AP : Memory Allocation failed in BuildUlCfg");
4736 if(BuildInitialUlBWP(ulCfg->initialUplinkBWP) != ROK)
4741 ulCfg->uplinkBWP_ToReleaseList = NULLP;
4742 ulCfg->uplinkBWP_ToAddModList = NULLP;
4743 ulCfg->firstActiveUplinkBWP_Id = NULLP;
4744 DU_ALLOC(ulCfg->firstActiveUplinkBWP_Id, sizeof(BWP_Id_t));
4745 if(!ulCfg->firstActiveUplinkBWP_Id)
4747 DU_LOG("\nERROR --> F1AP : Memory Allocation failed in BuildUlCfg");
4750 *(ulCfg->firstActiveUplinkBWP_Id) = ACTIVE_UL_BWP_ID;
4752 ulCfg->pusch_ServingCellConfig = NULLP;
4753 DU_ALLOC(ulCfg->pusch_ServingCellConfig, \
4754 sizeof(struct UplinkConfig__pusch_ServingCellConfig));
4755 if(!ulCfg->pusch_ServingCellConfig)
4757 DU_LOG("\nERROR --> F1AP : Memory Allocation failed in BuildUlCfg");
4761 if(BuildPuschSrvCellCfg(ulCfg->pusch_ServingCellConfig) != ROK)
4766 ulCfg->carrierSwitching = NULLP;
4767 ulCfg->ext1 = NULLP;
4771 /*******************************************************************
4773 * @brief Builds PDSCH serving cell config
4776 * Function : BuildPdschSrvCellCfg
4778 * Functionality: Builds PDSCH serving cell config in spCellCfgDed
4780 * @params[in] struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg
4782 * @return ROK - success
4785 * ****************************************************************/
4786 uint8_t BuildPdschSrvCellCfg(struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg)
4788 pdschCfg->present = ServingCellConfig__pdsch_ServingCellConfig_PR_setup;
4789 pdschCfg->choice.setup = NULLP;
4790 DU_ALLOC(pdschCfg->choice.setup, sizeof( struct PDSCH_ServingCellConfig));
4791 if(!pdschCfg->choice.setup)
4793 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
4797 pdschCfg->choice.setup->codeBlockGroupTransmission = NULLP;
4798 pdschCfg->choice.setup->xOverhead = NULLP;
4799 pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH = NULLP;
4800 DU_ALLOC(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH, sizeof(long));
4801 if(!pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH)
4803 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
4806 *(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH)= PDSCH_NUM_HARQ_PROC;
4807 pdschCfg->choice.setup->pucch_Cell = NULLP;
4808 pdschCfg->choice.setup->ext1 = NULLP;
4813 /*******************************************************************
4815 * @brief Builds CSI Meas config
4818 * Function : BuildCsiMeasCfg
4820 * Functionality: Builds CSI Meas config in spCellCfgDed
4822 * @params[in] struct ServingCellConfig__csi_MeasConfig *csiMeasCfg
4824 * @return ROK - success
4827 * ****************************************************************/
4828 uint8_t BuildCsiMeasCfg(struct ServingCellConfig__csi_MeasConfig *csiMeasCfg)
4834 /*******************************************************************
4836 * @brief Builds Spcell config dedicated
4839 * Function : BuildSpCellCfgDed
4841 * Functionality: Builds sp cell config dedicated in spCellCfg
4843 * @params[in] ServingCellConfig_t srvCellCfg
4845 * @return ROK - success
4848 * ****************************************************************/
4849 uint8_t BuildSpCellCfgDed(ServingCellConfig_t *srvCellCfg)
4851 srvCellCfg->tdd_UL_DL_ConfigurationDedicated = NULLP;
4852 DU_ALLOC(srvCellCfg->tdd_UL_DL_ConfigurationDedicated, sizeof(TDD_UL_DL_ConfigDedicated_t));
4853 if(!srvCellCfg->tdd_UL_DL_ConfigurationDedicated)
4855 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4859 srvCellCfg->initialDownlinkBWP = NULLP;
4860 DU_ALLOC(srvCellCfg->initialDownlinkBWP, sizeof(BWP_DownlinkDedicated_t));
4861 if(!srvCellCfg->initialDownlinkBWP)
4863 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4867 if(BuildInitialDlBWP(srvCellCfg->initialDownlinkBWP) != ROK)
4869 DU_LOG("\nERROR --> F1AP : BuildInitialDlBWP failed");
4872 srvCellCfg->downlinkBWP_ToReleaseList = NULLP;
4873 srvCellCfg->downlinkBWP_ToAddModList = NULLP;
4875 srvCellCfg->firstActiveDownlinkBWP_Id = NULLP;
4876 DU_ALLOC(srvCellCfg->firstActiveDownlinkBWP_Id, sizeof(long));
4877 if(!srvCellCfg->firstActiveDownlinkBWP_Id)
4879 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4882 *(srvCellCfg->firstActiveDownlinkBWP_Id) = ACTIVE_DL_BWP_ID;
4884 srvCellCfg->bwp_InactivityTimer = NULLP;
4886 srvCellCfg->defaultDownlinkBWP_Id = NULLP;
4887 DU_ALLOC(srvCellCfg->defaultDownlinkBWP_Id, sizeof(long));
4888 if(!srvCellCfg->defaultDownlinkBWP_Id)
4890 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4893 *(srvCellCfg->defaultDownlinkBWP_Id) = ACTIVE_DL_BWP_ID;
4895 srvCellCfg->uplinkConfig = NULLP;
4896 DU_ALLOC(srvCellCfg->uplinkConfig, sizeof(UplinkConfig_t));
4897 if(!srvCellCfg->uplinkConfig)
4899 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4903 if(BuildUlCfg(srvCellCfg->uplinkConfig) != ROK)
4905 DU_LOG("\nERROR --> F1AP : BuildUlCfg failed");
4908 srvCellCfg->supplementaryUplink = NULLP;
4909 srvCellCfg->pdcch_ServingCellConfig = NULLP;
4911 srvCellCfg->pdsch_ServingCellConfig = NULLP;
4912 DU_ALLOC(srvCellCfg->pdsch_ServingCellConfig, sizeof(struct ServingCellConfig__pdsch_ServingCellConfig));
4913 if(!srvCellCfg->pdsch_ServingCellConfig)
4915 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4919 if(BuildPdschSrvCellCfg(srvCellCfg->pdsch_ServingCellConfig) != ROK)
4921 DU_LOG("\nERROR --> F1AP : BuildPdschSrvCellCfg failed");
4925 srvCellCfg->csi_MeasConfig = NULLP;
4927 DU_ALLOC(srvCellCfg->csi_MeasConfig, sizeof(struct ServingCellConfig__csi_MeasConfig))
4928 if(!srvCellCfg->csi_MeasConfig)
4930 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4934 if(BuildCsiMeasCfg(srvCellCfg->csi_MeasConfig) != ROK)
4936 DU_LOG("\nF1AP : BuildCsiMeasCfg failed");
4940 srvCellCfg->sCellDeactivationTimer = NULLP;
4941 srvCellCfg->crossCarrierSchedulingConfig = NULLP;
4942 srvCellCfg->tag_Id = TAG_ID;
4943 srvCellCfg->dummy = NULLP;
4944 srvCellCfg->pathlossReferenceLinking = NULLP;
4945 srvCellCfg->servingCellMO = NULLP;
4946 srvCellCfg->ext1 = NULLP;
4950 /*******************************************************************
4952 * @brief Builds Spcell config
4956 * Function : BuildSpCellCfg
4958 * Functionality: Builds sp cell config in DuToCuRrcContainer
4960 * @params[in] SpCellConfig_t spCellCfg
4962 * @return ROK - success
4965 * ****************************************************************/
4966 uint8_t BuildSpCellCfg(SpCellConfig_t *spCellCfg)
4969 spCellCfg->servCellIndex = NULLP;
4970 DU_ALLOC(spCellCfg->servCellIndex, sizeof(long));
4971 if(!spCellCfg->servCellIndex)
4973 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
4976 *(spCellCfg->servCellIndex) = SERV_CELL_IDX;
4978 spCellCfg->reconfigurationWithSync = NULLP;
4979 spCellCfg->rlf_TimersAndConstants = NULLP;
4980 spCellCfg->rlmInSyncOutOfSyncThreshold = NULLP;
4981 DU_ALLOC(spCellCfg->rlmInSyncOutOfSyncThreshold, sizeof(long));
4982 if(!spCellCfg->rlmInSyncOutOfSyncThreshold)
4984 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
4987 *(spCellCfg->rlmInSyncOutOfSyncThreshold) = RLM_SYNC_OUT_SYNC_THRESHOLD;
4989 spCellCfg->spCellConfigDedicated = NULLP;
4990 DU_ALLOC(spCellCfg->spCellConfigDedicated, sizeof(ServingCellConfig_t));
4991 if(!spCellCfg->spCellConfigDedicated)
4993 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
4996 if(BuildSpCellCfgDed(spCellCfg->spCellConfigDedicated) != ROK)
4998 DU_LOG("\nERROR --> F1AP : BuildSpCellCfgDed failed");
5003 /*******************************************************************
5005 * @brief Builds Phy cell group config
5009 * Function : BuildPhyCellGrpCfg
5011 * Functionality: Builds Phy cell group config in DuToCuRrcContainer
5013 * @params[in] PhysicalCellGroupConfig_t *phyCellGrpCfg
5015 * @return ROK - success
5018 * ****************************************************************/
5019 uint8_t BuildPhyCellGrpCfg(PhysicalCellGroupConfig_t *phyCellGrpCfg)
5021 phyCellGrpCfg->harq_ACK_SpatialBundlingPUCCH = NULLP;
5022 phyCellGrpCfg->harq_ACK_SpatialBundlingPUSCH = NULLP;
5024 phyCellGrpCfg->p_NR_FR1 = NULLP;
5025 DU_ALLOC(phyCellGrpCfg->p_NR_FR1, sizeof(long));
5026 if(!phyCellGrpCfg->p_NR_FR1)
5028 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildPhyCellGrpCfg");
5031 *(phyCellGrpCfg->p_NR_FR1) = P_NR_FR1;
5032 phyCellGrpCfg->pdsch_HARQ_ACK_Codebook = PDSCH_HARQ_ACK_CODEBOOK;
5033 phyCellGrpCfg->tpc_SRS_RNTI = NULLP;
5034 phyCellGrpCfg->tpc_PUCCH_RNTI = NULLP;
5035 phyCellGrpCfg->tpc_PUSCH_RNTI = NULLP;
5036 phyCellGrpCfg->sp_CSI_RNTI = NULLP;
5037 phyCellGrpCfg->cs_RNTI = NULLP;
5038 phyCellGrpCfg->ext1 = NULLP;
5039 phyCellGrpCfg->ext2 = NULLP;
5043 /*******************************************************************
5045 * @brief Builds Mac cell group config
5049 * Function : BuildMacCellGrpCfg
5051 * Functionality: Builds Mac cell group config in DuToCuRrcContainer
5053 * @params[in] MAC_CellGroupConfig_t *macCellGrpCfg
5055 * @return ROK - success
5058 * ****************************************************************/
5059 uint8_t BuildMacCellGrpCfg(MAC_CellGroupConfig_t *macCellGrpCfg)
5061 macCellGrpCfg->drx_Config = NULLP;
5062 macCellGrpCfg->schedulingRequestConfig = NULLP;
5063 DU_ALLOC(macCellGrpCfg->schedulingRequestConfig, sizeof(struct SchedulingRequestConfig));
5064 if(!macCellGrpCfg->schedulingRequestConfig)
5066 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
5070 if(BuildSchedulingReqConfig(macCellGrpCfg->schedulingRequestConfig) != ROK)
5072 DU_LOG("\nERROR --> F1AP : BuildSchedulingReqConfig failed");
5076 macCellGrpCfg->bsr_Config = NULLP;
5077 DU_ALLOC(macCellGrpCfg->bsr_Config, sizeof(struct BSR_Config));
5078 if(!macCellGrpCfg->bsr_Config)
5080 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
5084 if(BuildBsrConfig(macCellGrpCfg->bsr_Config) != ROK)
5086 DU_LOG("\nERROR --> F1AP : BuildBsrConfig failed");
5090 macCellGrpCfg->tag_Config = NULLP;
5091 DU_ALLOC(macCellGrpCfg->tag_Config, sizeof(struct TAG_Config));
5092 if(!macCellGrpCfg->tag_Config)
5094 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
5098 if(BuildTagConfig(macCellGrpCfg->tag_Config) != ROK)
5100 DU_LOG("\nERROR --> F1AP : BuildTagConfig failed");
5104 macCellGrpCfg->phr_Config = NULLP;
5105 DU_ALLOC(macCellGrpCfg->phr_Config, sizeof(struct MAC_CellGroupConfig__phr_Config));
5106 if(!macCellGrpCfg->phr_Config)
5108 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
5112 if(BuildPhrConfig(macCellGrpCfg->phr_Config) != ROK)
5114 DU_LOG("\nERROR --> F1AP : BuildPhrConfig failed");
5118 macCellGrpCfg->skipUplinkTxDynamic = false;
5119 macCellGrpCfg->ext1 = NULLP;
5123 /*******************************************************************
5125 * @brief Frees memeory allocated for SearchSpcToAddModList
5129 * Function : FreeSearchSpcToAddModList
5131 * Functionality: Deallocating memory of SearchSpcToAddModList
5133 * @params[in] struct PDCCH_Config__searchSpacesToAddModList *searchSpcList
5137 4221 * ****************************************************************/
5138 void FreeSearchSpcToAddModList(struct PDCCH_Config__searchSpacesToAddModList *searchSpcList)
5142 struct SearchSpace *searchSpc=NULLP;
5144 if(searchSpcList->list.array)
5146 if(searchSpcList->list.array[idx2])
5148 searchSpc = searchSpcList->list.array[idx2];
5149 if(searchSpc->controlResourceSetId)
5151 if(searchSpc->monitoringSlotPeriodicityAndOffset)
5153 if(searchSpc->monitoringSymbolsWithinSlot)
5155 if(searchSpc->monitoringSymbolsWithinSlot->buf)
5157 if(searchSpc->nrofCandidates)
5159 if(searchSpc->searchSpaceType)
5161 DU_FREE(searchSpc->searchSpaceType->choice.ue_Specific,\
5162 sizeof(struct SearchSpace__searchSpaceType__ue_Specific));
5163 DU_FREE(searchSpc->searchSpaceType, sizeof(struct
5164 SearchSpace__searchSpaceType));
5166 DU_FREE(searchSpc->nrofCandidates,
5167 sizeof(struct SearchSpace__nrofCandidates));
5169 DU_FREE(searchSpc->monitoringSymbolsWithinSlot->buf, \
5170 searchSpc->monitoringSymbolsWithinSlot->size);
5172 DU_FREE(searchSpc->monitoringSymbolsWithinSlot,
5173 sizeof(BIT_STRING_t));
5175 DU_FREE(searchSpc->monitoringSlotPeriodicityAndOffset, \
5176 sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
5178 DU_FREE(searchSpc->controlResourceSetId,
5179 sizeof(ControlResourceSetId_t));
5182 for(idx1 = 0; idx1 < searchSpcList->list.count; idx1++)
5184 DU_FREE(searchSpcList->list.array[idx1],
5185 sizeof(struct SearchSpace));
5187 DU_FREE(searchSpcList->list.array,searchSpcList->list.size);
5190 /*******************************************************************
5192 * @brief Frees memory allocated for PdschTimeDomAllocList
5196 * Function : FreePdschTimeDomAllocList
5198 * Functionality: Deallocating memory of PdschTimeDomAllocList
5200 * @params[in] struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
5204 * ****************************************************************/
5205 void FreePdschTimeDomAllocList( struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList)
5209 if(timeDomAllocList->choice.setup)
5211 if(timeDomAllocList->choice.setup->list.array)
5213 for(idx1 = 0; idx1 <timeDomAllocList->choice.setup->list.count ; idx1++)
5215 DU_FREE(timeDomAllocList->choice.setup->list.array[idx1]->k0, sizeof(long));
5216 DU_FREE(timeDomAllocList->choice.setup->list.array[idx1],
5217 sizeof(struct PDSCH_TimeDomainResourceAllocation));
5219 DU_FREE(timeDomAllocList->choice.setup->list.array, \
5220 timeDomAllocList->choice.setup->list.size);
5222 DU_FREE(timeDomAllocList->choice.setup,\
5223 sizeof(struct PDSCH_TimeDomainResourceAllocationList));
5226 /*******************************************************************
5228 * @brief Frees memory allocated for PuschTimeDomAllocList
5232 * Function : FreePuschTimeDomAllocList
5234 * Functionality: Deallocating memory of PuschTimeDomAllocList
5236 * @params[in] PUSCH_Config_t *puschCfg
5240 * ****************************************************************/
5241 void FreePuschTimeDomAllocList(PUSCH_Config_t *puschCfg)
5245 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList_t=NULLP;
5247 if(puschCfg->pusch_TimeDomainAllocationList)
5249 timeDomAllocList_t=puschCfg->pusch_TimeDomainAllocationList;
5250 if(timeDomAllocList_t->choice.setup)
5252 if(timeDomAllocList_t->choice.setup->list.array)
5254 DU_FREE(timeDomAllocList_t->choice.setup->list.array[idx2]->k2, sizeof(long));
5255 for(idx1 = 0; idx1<timeDomAllocList_t->choice.setup->list.count; idx1++)
5257 DU_FREE(timeDomAllocList_t->choice.setup->list.array[idx1],\
5258 sizeof(PUSCH_TimeDomainResourceAllocation_t));
5260 DU_FREE(timeDomAllocList_t->choice.setup->list.array, \
5261 timeDomAllocList_t->choice.setup->list.size);
5263 DU_FREE(timeDomAllocList_t->choice.setup, \
5264 sizeof(struct PUSCH_TimeDomainResourceAllocationList));
5266 DU_FREE(puschCfg->transformPrecoder, sizeof(long));
5267 DU_FREE(puschCfg->pusch_TimeDomainAllocationList, \
5268 sizeof(struct PUSCH_Config__pusch_TimeDomainAllocationList));
5272 /*******************************************************************
5274 * @brief Frees memory allocated for InitialUlBWP
5278 * Function : FreeInitialUlBWP
5280 * Functionality: Deallocating memory of InitialUlBWP
5282 * @params[in] BWP_UplinkDedicated_t *ulBwp
5286 * ****************************************************************/
5287 void FreeInitialUlBWP(BWP_UplinkDedicated_t *ulBwp)
5289 uint8_t rSetIdx, rsrcIdx, k1Idx;
5290 SRS_Config_t *srsCfg = NULLP;
5291 PUSCH_Config_t *puschCfg = NULLP;
5292 PUCCH_Config_t *pucchCfg = NULLP;
5293 struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg = NULLP;
5294 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList = NULLP;
5295 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList = NULLP;
5296 struct SRS_Config__srs_ResourceToAddModList *resourceList = NULLP;
5298 if(ulBwp->pucch_Config)
5300 if(ulBwp->pucch_Config->choice.setup)
5302 pucchCfg = ulBwp->pucch_Config->choice.setup;
5303 if(pucchCfg->dl_DataToUL_ACK)
5305 if(pucchCfg->dl_DataToUL_ACK->list.array)
5307 for(k1Idx = 0; k1Idx < pucchCfg->dl_DataToUL_ACK->list.count; k1Idx++)
5309 DU_FREE(pucchCfg->dl_DataToUL_ACK->list.array[k1Idx], sizeof(long));
5311 DU_FREE(pucchCfg->dl_DataToUL_ACK->list.array, pucchCfg->dl_DataToUL_ACK->list.size);
5313 DU_FREE(pucchCfg->dl_DataToUL_ACK, sizeof(struct PUCCH_Config__dl_DataToUL_ACK));
5315 DU_FREE(ulBwp->pucch_Config->choice.setup, sizeof(PUCCH_Config_t));
5317 DU_FREE(ulBwp->pucch_Config, sizeof(struct BWP_UplinkDedicated__pucch_Config));
5320 if(ulBwp->pusch_Config)
5322 if(ulBwp->pusch_Config->choice.setup)
5324 puschCfg=ulBwp->pusch_Config->choice.setup;
5325 if(puschCfg->dataScramblingIdentityPUSCH)
5327 if(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
5329 FreePuschTimeDomAllocList(puschCfg);
5330 dmrsUlCfg=puschCfg->dmrs_UplinkForPUSCH_MappingTypeA;
5331 if(dmrsUlCfg->choice.setup)
5333 if(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
5335 if(dmrsUlCfg->choice.setup->transformPrecodingDisabled)
5337 DU_FREE(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0,\
5339 DU_FREE(dmrsUlCfg->choice.setup->transformPrecodingDisabled,
5340 sizeof(struct DMRS_UplinkConfig__transformPrecodingDisabled));
5342 DU_FREE(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition,
5345 DU_FREE(dmrsUlCfg->choice.setup,sizeof(DMRS_UplinkConfig_t));
5347 DU_FREE(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA, \
5348 sizeof(struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA));
5350 DU_FREE(puschCfg->dataScramblingIdentityPUSCH, sizeof(long));
5352 DU_FREE(ulBwp->pusch_Config->choice.setup, sizeof(PUSCH_Config_t));
5354 DU_FREE(ulBwp->pusch_Config, sizeof(struct BWP_UplinkDedicated__pusch_Config));
5356 /* Free SRS-Config */
5357 if(ulBwp->srs_Config)
5359 if(ulBwp->srs_Config->choice.setup)
5361 srsCfg = ulBwp->srs_Config->choice.setup;
5363 /* Free Resource Set to add/mod list */
5364 if(srsCfg->srs_ResourceSetToAddModList)
5366 rsrcSetList = srsCfg->srs_ResourceSetToAddModList;
5367 if(rsrcSetList->list.array)
5371 /* Free SRS resource Id list in this SRS resource set */
5372 if(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
5374 rsrcIdList = rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
5376 if(rsrcIdList->list.array)
5378 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count; rsrcIdx++)
5380 DU_FREE(rsrcIdList->list.array[rsrcIdx], sizeof(SRS_ResourceId_t));
5382 DU_FREE(rsrcIdList->list.array, rsrcIdList->list.size);
5384 DU_FREE(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList,\
5385 sizeof(struct SRS_ResourceSet__srs_ResourceIdList));
5388 /* Free resource type info for this SRS resource set */
5389 DU_FREE(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic, \
5390 sizeof(struct SRS_ResourceSet__resourceType__aperiodic));
5392 /* Free memory for each resource set */
5393 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
5395 DU_FREE(rsrcSetList->list.array[rSetIdx], sizeof(SRS_ResourceSet_t));
5397 DU_FREE(rsrcSetList->list.array, rsrcSetList->list.size);
5399 DU_FREE(srsCfg->srs_ResourceSetToAddModList, \
5400 sizeof(struct SRS_Config__srs_ResourceSetToAddModList));
5403 /* Free resource to add/modd list */
5404 if(srsCfg->srs_ResourceToAddModList)
5406 resourceList = srsCfg->srs_ResourceToAddModList;
5407 if(resourceList->list.array)
5410 DU_FREE(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2,\
5411 sizeof(struct SRS_Resource__transmissionComb__n2));
5412 DU_FREE(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic,\
5413 sizeof(struct SRS_Resource__resourceType__aperiodic));
5415 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
5417 DU_FREE(resourceList->list.array[rsrcIdx], sizeof(SRS_Resource_t));
5419 DU_FREE(resourceList->list.array, resourceList->list.size);
5421 DU_FREE(srsCfg->srs_ResourceToAddModList, \
5422 sizeof(struct SRS_Config__srs_ResourceToAddModList));
5425 DU_FREE(ulBwp->srs_Config->choice.setup, sizeof(SRS_Config_t));
5427 DU_FREE(ulBwp->srs_Config, sizeof(struct BWP_UplinkDedicated__srs_Config));
5431 /*******************************************************************
5433 * @brief Frees memory allocated for initialUplinkBWP
5437 * Function : FreeinitialUplinkBWP
5439 * Functionality: Deallocating memory of initialUplinkBWP
5441 * @params[in] UplinkConfig_t *ulCfg
5446 * ****************************************************************/
5447 void FreeinitialUplinkBWP(UplinkConfig_t *ulCfg)
5449 BWP_UplinkDedicated_t *ulBwp=NULLP;
5450 struct UplinkConfig__pusch_ServingCellConfig *puschCfg=NULLP;
5452 if(ulCfg->initialUplinkBWP)
5454 ulBwp=ulCfg->initialUplinkBWP;
5455 if(ulCfg->firstActiveUplinkBWP_Id)
5457 if(ulCfg->pusch_ServingCellConfig)
5459 puschCfg=ulCfg->pusch_ServingCellConfig;
5460 if(puschCfg->choice.setup)
5462 if(puschCfg->choice.setup->ext1)
5464 DU_FREE(puschCfg->choice.setup->ext1->\
5465 processingType2Enabled,sizeof(BOOLEAN_t));
5466 DU_FREE(puschCfg->choice.setup->ext1->\
5467 maxMIMO_Layers,sizeof(long));
5468 DU_FREE(puschCfg->choice.setup->ext1, \
5469 sizeof(struct PUSCH_ServingCellConfig__ext1));
5471 DU_FREE(puschCfg->choice.setup, sizeof(struct PUSCH_ServingCellConfig));
5473 DU_FREE(ulCfg->pusch_ServingCellConfig, sizeof(struct UplinkConfig__pusch_ServingCellConfig));
5475 DU_FREE(ulCfg->firstActiveUplinkBWP_Id, sizeof(BWP_Id_t));
5477 FreeInitialUlBWP(ulBwp);
5478 DU_FREE(ulCfg->initialUplinkBWP, sizeof(BWP_UplinkDedicated_t));
5481 /*******************************************************************
5483 * @brief Frees emmory allocated for BWPDlDedPdschCfg
5487 * Function : FreeBWPDlDedPdschCfg
5489 * Functionality: Deallocating memory of BWPDlDedPdschCfg
5491 * @params[in] BWP_DownlinkDedicated_t *dlBwp
5496 * ****************************************************************/
5497 void FreeBWPDlDedPdschCfg(BWP_DownlinkDedicated_t *dlBwp)
5499 struct PDSCH_Config *pdschCfg=NULLP;
5500 struct PDSCH_Config__prb_BundlingType *prbBndlType=NULLP;
5501 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList=NULLP;
5502 struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg=NULLP;
5504 if(dlBwp->pdsch_Config->choice.setup)
5506 pdschCfg=dlBwp->pdsch_Config->choice.setup;
5507 if(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
5509 if(pdschCfg->pdsch_TimeDomainAllocationList)
5511 timeDomAllocList=pdschCfg->pdsch_TimeDomainAllocationList;
5512 if(pdschCfg->maxNrofCodeWordsScheduledByDCI)
5514 prbBndlType=&pdschCfg->prb_BundlingType;
5515 DU_FREE(prbBndlType->choice.staticBundling,\
5516 sizeof(struct PDSCH_Config__prb_BundlingType__staticBundling));
5517 DU_FREE(pdschCfg->maxNrofCodeWordsScheduledByDCI, sizeof(long));
5519 FreePdschTimeDomAllocList(timeDomAllocList);
5520 DU_FREE(pdschCfg->pdsch_TimeDomainAllocationList, \
5521 sizeof(struct PDSCH_Config__pdsch_TimeDomainAllocationList));
5523 dmrsDlCfg=pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA;
5524 if(dmrsDlCfg->choice.setup)
5526 DU_FREE(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition,
5528 DU_FREE(dmrsDlCfg->choice.setup, sizeof(struct DMRS_DownlinkConfig));
5530 DU_FREE(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA, \
5531 sizeof(struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA));
5533 DU_FREE(dlBwp->pdsch_Config->choice.setup, sizeof(struct PDSCH_Config));
5536 /*******************************************************************
5538 * @brief Frees emmory allocated for BWPDlDedPdcchCfg
5542 * Function : FreeBWPDlDedPdcchCfg
5544 * Functionality: Deallocating memory of BWPDlDedPdcchCfg
5546 * @params[in] BWP_DownlinkDedicated_t *dlBwp
5551 * ****************************************************************/
5552 void FreeBWPDlDedPdcchCfg(BWP_DownlinkDedicated_t *dlBwp)
5556 struct PDCCH_Config *pdcchCfg=NULLP;
5557 struct ControlResourceSet *controlRSet=NULLP;
5558 struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList=NULLP;
5560 if(dlBwp->pdcch_Config->choice.setup)
5562 pdcchCfg=dlBwp->pdcch_Config->choice.setup;
5563 if(pdcchCfg->controlResourceSetToAddModList)
5565 controlRSetList = pdcchCfg->controlResourceSetToAddModList;
5566 if(controlRSetList->list.array)
5568 controlRSet = controlRSetList->list.array[idx2];
5571 if(controlRSet->frequencyDomainResources.buf)
5573 if(controlRSet->pdcch_DMRS_ScramblingID)
5575 if(pdcchCfg->searchSpacesToAddModList)
5577 FreeSearchSpcToAddModList(pdcchCfg->searchSpacesToAddModList);
5578 DU_FREE(pdcchCfg->searchSpacesToAddModList, \
5579 sizeof(struct PDCCH_Config__searchSpacesToAddModList));
5581 DU_FREE(controlRSet->pdcch_DMRS_ScramblingID, sizeof(long));
5583 DU_FREE(controlRSet->frequencyDomainResources.buf, \
5584 controlRSet->frequencyDomainResources.size);
5587 for(idx1 = 0; idx1 <controlRSetList->list.count; idx1++)
5589 DU_FREE(controlRSetList->list.array[idx1], sizeof(struct ControlResourceSet));
5591 DU_FREE(controlRSetList->list.array, controlRSetList->list.size);
5593 DU_FREE(pdcchCfg->controlResourceSetToAddModList, \
5594 sizeof(struct PDCCH_Config__controlResourceSetToAddModList));
5596 DU_FREE(dlBwp->pdcch_Config->choice.setup, sizeof(struct PDCCH_Config));
5600 /*******************************************************************
5602 * @brief Frees emmory allocated for DUToCURRCContainer
5606 * Function : FreeMemDuToCuRrcCont
5608 * Functionality: Deallocating memory of DuToCuRrcContainer
5610 * @params[in] DuToCuRRCContainer, DuToCuRRCContainer
5612 * @return ROK - success
5615 * ****************************************************************/
5616 uint8_t FreeMemDuToCuRrcCont(CellGroupConfigRrc_t *cellGrpCfg)
5619 SpCellConfig_t *spCellCfg=NULLP;
5620 ServingCellConfig_t *srvCellCfg=NULLP;
5621 BWP_DownlinkDedicated_t *dlBwp=NULLP;
5622 MAC_CellGroupConfig_t *macCellGrpCfg=NULLP;
5623 PhysicalCellGroupConfig_t *phyCellGrpCfg=NULLP;
5624 struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList=NULLP;
5625 struct RLC_Config *rlcConfig=NULLP;
5626 struct LogicalChannelConfig *macLcConfig=NULLP;
5627 struct SchedulingRequestConfig *schedulingRequestConfig=NULLP;
5628 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList=NULLP;
5629 struct TAG_Config *tagConfig=NULLP;
5630 struct TAG_Config__tag_ToAddModList *tagList=NULLP;
5631 struct MAC_CellGroupConfig__phr_Config *phrConfig=NULLP;
5632 struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg=NULLP;
5634 rlcBearerList = cellGrpCfg->rlc_BearerToAddModList;
5637 if(rlcBearerList->list.array)
5639 for(idx=0; idx<rlcBearerList->list.count; idx++)
5641 if(rlcBearerList->list.array[idx])
5643 rlcConfig = rlcBearerList->list.array[idx]->rlc_Config;
5644 macLcConfig = rlcBearerList->list.array[idx]->mac_LogicalChannelConfig;
5647 if(rlcConfig->choice.am)
5649 DU_FREE(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
5650 DU_FREE(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
5651 DU_FREE(rlcConfig->choice.am, sizeof(struct RLC_Config__am));
5653 DU_FREE(rlcConfig, sizeof(struct RLC_Config));
5655 DU_FREE(rlcBearerList->list.array[idx]->servedRadioBearer, sizeof(struct RLC_BearerConfig__servedRadioBearer));
5658 if(macLcConfig->ul_SpecificParameters)
5660 DU_FREE(macLcConfig->ul_SpecificParameters->schedulingRequestID, sizeof(SchedulingRequestId_t));
5661 DU_FREE(macLcConfig->ul_SpecificParameters->logicalChannelGroup, sizeof(long));
5662 DU_FREE(macLcConfig->ul_SpecificParameters, sizeof(struct LogicalChannelConfig__ul_SpecificParameters));
5664 DU_FREE(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig, sizeof(struct LogicalChannelConfig));
5666 DU_FREE(rlcBearerList->list.array[idx], sizeof(struct RLC_BearerConfig));
5669 DU_FREE(rlcBearerList->list.array, rlcBearerList->list.size);
5671 DU_FREE(cellGrpCfg->rlc_BearerToAddModList, sizeof(struct CellGroupConfigRrc__rlc_BearerToAddModList));
5674 macCellGrpCfg = cellGrpCfg->mac_CellGroupConfig;
5677 schedulingRequestConfig = macCellGrpCfg->schedulingRequestConfig;
5678 if(schedulingRequestConfig)
5680 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
5683 if(schReqList->list.array)
5685 for(idx=0;idx<schReqList->list.count; idx++)
5687 if(schReqList->list.array[idx])
5689 DU_FREE(schReqList->list.array[idx]->sr_ProhibitTimer, sizeof(long));
5690 DU_FREE(schReqList->list.array[idx], sizeof(struct SchedulingRequestToAddMod));
5693 DU_FREE(schReqList->list.array, schReqList->list.size);
5695 DU_FREE(schedulingRequestConfig->schedulingRequestToAddModList,\
5696 sizeof(struct SchedulingRequestConfig__schedulingRequestToAddModList)); }
5697 DU_FREE(macCellGrpCfg->schedulingRequestConfig, sizeof(struct SchedulingRequestConfig));
5699 if(macCellGrpCfg->bsr_Config)
5701 DU_FREE(macCellGrpCfg->bsr_Config, sizeof(struct BSR_Config));
5703 tagConfig = macCellGrpCfg->tag_Config;
5706 tagList = tagConfig->tag_ToAddModList;
5709 if(tagList->list.array)
5711 for(idx=0; idx<tagList->list.count; idx++)
5713 DU_FREE(tagList->list.array[idx], sizeof(struct TAG));
5715 DU_FREE(tagList->list.array, tagList->list.size);
5717 DU_FREE(tagConfig->tag_ToAddModList, sizeof(struct TAG_Config__tag_ToAddModList));
5719 DU_FREE(tagConfig, sizeof(struct TAG_Config));
5722 phrConfig = macCellGrpCfg->phr_Config;
5725 DU_FREE(phrConfig->choice.setup, sizeof(struct PHR_Config));
5726 DU_FREE(phrConfig, sizeof(struct MAC_CellGroupConfig__phr_Config));
5729 DU_FREE(macCellGrpCfg, sizeof(MAC_CellGroupConfig_t));
5732 phyCellGrpCfg = cellGrpCfg->physicalCellGroupConfig;
5735 DU_FREE(phyCellGrpCfg->p_NR_FR1, sizeof(long));
5736 DU_FREE(phyCellGrpCfg, sizeof(PhysicalCellGroupConfig_t));
5739 spCellCfg = cellGrpCfg->spCellConfig;
5742 if(spCellCfg->servCellIndex)
5744 if(spCellCfg->rlmInSyncOutOfSyncThreshold)
5746 if(spCellCfg->spCellConfigDedicated)
5748 srvCellCfg = spCellCfg->spCellConfigDedicated;
5749 if(srvCellCfg->tdd_UL_DL_ConfigurationDedicated)
5751 if(srvCellCfg->initialDownlinkBWP)
5753 dlBwp = srvCellCfg->initialDownlinkBWP;
5754 if(srvCellCfg->firstActiveDownlinkBWP_Id)
5756 if(srvCellCfg->defaultDownlinkBWP_Id)
5758 if(srvCellCfg->uplinkConfig)
5760 if(srvCellCfg->pdsch_ServingCellConfig)
5762 pdschCfg= srvCellCfg->pdsch_ServingCellConfig;
5763 if(pdschCfg->choice.setup)
5765 DU_FREE(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH,sizeof(long));
5766 DU_FREE(pdschCfg->choice.setup, sizeof( struct PDSCH_ServingCellConfig));
5768 DU_FREE(srvCellCfg->pdsch_ServingCellConfig, sizeof(struct
5769 ServingCellConfig__pdsch_ServingCellConfig));
5771 FreeinitialUplinkBWP(srvCellCfg->uplinkConfig);
5772 DU_FREE(srvCellCfg->uplinkConfig, sizeof(UplinkConfig_t));
5774 DU_FREE(srvCellCfg->defaultDownlinkBWP_Id, sizeof(long));
5776 DU_FREE(srvCellCfg->firstActiveDownlinkBWP_Id, sizeof(long));
5778 if(dlBwp->pdcch_Config)
5780 if(dlBwp->pdsch_Config)
5782 FreeBWPDlDedPdschCfg(dlBwp);
5783 DU_FREE(dlBwp->pdsch_Config, sizeof(struct BWP_DownlinkDedicated__pdsch_Config));
5785 FreeBWPDlDedPdcchCfg(dlBwp);
5786 DU_FREE(dlBwp->pdcch_Config, sizeof(struct BWP_DownlinkDedicated__pdcch_Config));
5788 DU_FREE(srvCellCfg->initialDownlinkBWP, sizeof(BWP_DownlinkDedicated_t));
5790 DU_FREE(srvCellCfg->tdd_UL_DL_ConfigurationDedicated, sizeof(TDD_UL_DL_ConfigDedicated_t));
5792 DU_FREE(spCellCfg->spCellConfigDedicated, sizeof(ServingCellConfig_t));
5794 DU_FREE(spCellCfg->rlmInSyncOutOfSyncThreshold, sizeof(long));
5796 DU_FREE(spCellCfg->servCellIndex, sizeof(long));
5798 DU_FREE(spCellCfg,sizeof(SpCellConfig_t));
5802 /*******************************************************************
5804 * @brief Builds DU To CU RRC Container
5808 * Function : BuildDuToCuRrcContainer
5810 * Functionality: Builds DuToCuRrcContainer
5812 * @params[in] idx, index in F1AP msg
5813 * DuToCuRRCContainer, DuToCuRRCContainer
5815 * @return ROK - success
5818 * ****************************************************************/
5819 uint8_t BuildDuToCuRrcContainer(DUtoCURRCContainer_t *duToCuRrcContainer)
5822 CellGroupConfigRrc_t cellGrpCfg;
5823 asn_enc_rval_t encRetVal;
5824 memset(&cellGrpCfg, 0, sizeof(CellGroupConfigRrc_t));
5825 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
5829 cellGrpCfg.cellGroupId = CELL_GRP_ID;
5831 cellGrpCfg.rlc_BearerToAddModList = NULLP;
5832 DU_ALLOC(cellGrpCfg.rlc_BearerToAddModList, sizeof(struct CellGroupConfigRrc__rlc_BearerToAddModList));
5833 if(!cellGrpCfg.rlc_BearerToAddModList)
5835 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5839 if(BuildRlcBearerToAddModList(cellGrpCfg.rlc_BearerToAddModList) != ROK)
5841 DU_LOG("\nERROR --> F1AP : BuildRlcBearerToAddModList failed");
5846 cellGrpCfg.rlc_BearerToReleaseList = NULLP;
5847 cellGrpCfg.mac_CellGroupConfig = NULLP;
5848 DU_ALLOC(cellGrpCfg.mac_CellGroupConfig, sizeof(MAC_CellGroupConfig_t));
5849 if(!cellGrpCfg.mac_CellGroupConfig)
5851 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5855 if(BuildMacCellGrpCfg(cellGrpCfg.mac_CellGroupConfig) != ROK)
5857 DU_LOG("\nERROR --> F1AP : BuildMacCellGrpCfg failed");
5862 cellGrpCfg.physicalCellGroupConfig = NULLP;
5863 DU_ALLOC(cellGrpCfg.physicalCellGroupConfig, sizeof(PhysicalCellGroupConfig_t));
5864 if(!cellGrpCfg.physicalCellGroupConfig)
5866 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5870 if(BuildPhyCellGrpCfg(cellGrpCfg.physicalCellGroupConfig) != ROK)
5872 DU_LOG("\nERROR --> F1AP : BuildPhyCellGrpCfg failed");
5877 cellGrpCfg.spCellConfig = NULLP;
5878 DU_ALLOC(cellGrpCfg.spCellConfig, sizeof(SpCellConfig_t));
5879 if(!cellGrpCfg.spCellConfig)
5881 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5885 if(BuildSpCellCfg(cellGrpCfg.spCellConfig) != ROK)
5887 DU_LOG("\nERROR --> F1AP : BuildSpCellCfg failed");
5892 cellGrpCfg.sCellToAddModList = NULLP;
5893 cellGrpCfg.sCellToReleaseList = NULLP;
5894 cellGrpCfg.ext1 = NULLP;
5896 /* encode cellGrpCfg into duToCuRrcContainer */
5897 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, &cellGrpCfg);
5898 memset(encBuf, 0, ENC_BUF_MAX_LEN);
5900 encRetVal = aper_encode(&asn_DEF_CellGroupConfigRrc, 0, &cellGrpCfg, PrepFinalEncBuf, encBuf);
5901 /* Encode results */
5902 if(encRetVal.encoded == ENCODE_FAIL)
5904 DU_LOG( "\nERROR --> F1AP : Could not encode DuToCuRrcContainer (at %s)\n",\
5905 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
5911 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for DuToCuRrcContainer\n");
5912 for(int i=0; i< encBufSize; i++)
5914 printf("%x",encBuf[i]);
5918 duToCuRrcContainer->size = encBufSize;
5919 DU_ALLOC(duToCuRrcContainer->buf, duToCuRrcContainer->size);
5920 if(!duToCuRrcContainer->buf)
5922 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDuToCuRrcContainer");
5928 memcpy(duToCuRrcContainer->buf, encBuf, duToCuRrcContainer->size);
5932 FreeMemDuToCuRrcCont(&cellGrpCfg);
5936 /*******************************************************************
5938 * @brief Free memory allocated in InitialULRRCMessage
5942 * Function : freeInitUlRrcMsgTransfer
5944 * Functionality: Free memory allocated in InitialULRRCMessage
5946 * @params[in]F1AP_PDU_t *f1apMsg)
5948 * @return ROK - success
5951 * ****************************************************************/
5953 uint8_t freeInitUlRrcMsgTransfer(F1AP_PDU_t *f1apMsg)
5955 uint8_t ieIdx, arrIdx;
5956 InitialULRRCMessageTransfer_t *initULRRCMsg=NULLP;
5960 if(f1apMsg->choice.initiatingMessage)
5962 initULRRCMsg = &f1apMsg->choice.initiatingMessage->value.\
5963 choice.InitialULRRCMessageTransfer;
5964 if(initULRRCMsg->protocolIEs.list.array)
5966 for(ieIdx = 0; ieIdx < initULRRCMsg->protocolIEs.list.count; ieIdx++)
5968 switch(initULRRCMsg->protocolIEs.list.array[ieIdx]->id)
5970 case ProtocolIE_ID_id_NRCGI:
5972 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.buf)
5974 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.buf)
5976 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.buf,\
5977 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.size);
5979 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.buf,\
5980 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.size);
5984 case ProtocolIE_ID_id_RRCContainer:
5986 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
5988 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf,\
5989 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size);
5993 case ProtocolIE_ID_id_DUtoCURRCContainer:
5995 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.buf)
5997 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.buf,
5998 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.size);
6006 for(arrIdx = 0; arrIdx < ieIdx; arrIdx++)
6008 if(initULRRCMsg->protocolIEs.list.array[arrIdx])
6010 DU_FREE(initULRRCMsg->protocolIEs.list.array[arrIdx],\
6011 sizeof(InitialULRRCMessageTransferIEs_t));
6014 DU_FREE(initULRRCMsg->protocolIEs.list.array, initULRRCMsg->protocolIEs.list.size);
6016 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
6018 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
6022 DU_LOG("\nERROR --> DU_APP : Recevied F1ap Pdu is null at freeInitUlRrcMsgTransfer()");
6028 /*******************************************************************
6030 * @brief Builds and sends the InitialULRRCMessage
6034 * Function : BuildAndSendInitialRrcMsgTransfer
6036 * Functionality: Constructs the Initial UL RRC Message Transfer and sends
6037 * it to the CU through SCTP.
6041 * @return ROK - success
6044 * ****************************************************************/
6045 uint8_t BuildAndSendInitialRrcMsgTransfer(uint32_t gnbDuUeF1apId, uint16_t crnti,
6046 uint16_t rrcContSize, uint8_t *rrcContainer)
6051 asn_enc_rval_t encRetVal;
6052 F1AP_PDU_t *f1apMsg = NULLP;
6053 InitialULRRCMessageTransfer_t *initULRRCMsg = NULLP;
6054 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
6058 DU_LOG("\n INFO --> F1AP : Building RRC Setup Request\n");
6059 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
6060 if(f1apMsg == NULLP)
6062 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
6065 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
6066 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
6067 if(f1apMsg->choice.initiatingMessage == NULLP)
6069 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
6072 f1apMsg->choice.initiatingMessage->procedureCode =\
6073 ProcedureCode_id_InitialULRRCMessageTransfer;
6074 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
6075 f1apMsg->choice.initiatingMessage->value.present = \
6076 InitiatingMessage__value_PR_InitialULRRCMessageTransfer;
6078 &f1apMsg->choice.initiatingMessage->value.choice.InitialULRRCMessageTransfer;
6080 initULRRCMsg->protocolIEs.list.count = elementCnt;
6081 initULRRCMsg->protocolIEs.list.size = \
6082 elementCnt * sizeof(InitialULRRCMessageTransferIEs_t *);
6083 /* Initialize the F1Setup members */
6084 DU_ALLOC(initULRRCMsg->protocolIEs.list.array,initULRRCMsg->protocolIEs.list.size);
6085 if(initULRRCMsg->protocolIEs.list.array == NULLP)
6087 DU_LOG(" ERROR --> F1AP : Memory allocation for\
6088 RRCSetupRequestMessageTransferIEs failed");
6091 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
6093 DU_ALLOC(initULRRCMsg->protocolIEs.list.array[ieIdx],\
6094 sizeof(InitialULRRCMessageTransferIEs_t));
6095 if(initULRRCMsg->protocolIEs.list.array[ieIdx] == NULLP)
6101 /*GNB DU UE F1AP ID*/
6102 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6103 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
6104 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6105 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present = \
6106 InitialULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
6107 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
6112 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6113 ProtocolIE_ID_id_NRCGI;
6114 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality =Criticality_reject;
6115 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present = \
6116 InitialULRRCMessageTransferIEs__value_PR_NRCGI;
6119 BuildNrcgi(&initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI);
6127 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6128 ProtocolIE_ID_id_C_RNTI;
6129 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6130 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
6131 InitialULRRCMessageTransferIEs__value_PR_C_RNTI;
6132 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.C_RNTI = crnti;
6136 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6137 ProtocolIE_ID_id_RRCContainer;
6138 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6139 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
6140 InitialULRRCMessageTransferIEs__value_PR_RRCContainer;
6142 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size = rrcContSize;
6143 DU_ALLOC(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf,
6144 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size)
6145 if(!initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
6147 DU_LOG(" ERROR --> F1AP : Memory allocation for RRCSetupRequestMessageTransferIEs failed");
6151 memcpy(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf, rrcContainer,
6152 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size);
6155 /*DUtoCURRCContainer*/
6157 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DUtoCURRCContainer;
6158 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6159 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
6160 InitialULRRCMessageTransferIEs__value_PR_DUtoCURRCContainer;
6162 ret = BuildDuToCuRrcContainer(&initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer);
6168 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
6170 /* Encode the F1SetupRequest type as APER */
6171 memset(encBuf, 0, ENC_BUF_MAX_LEN);
6173 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
6174 /* Encode results */
6175 if(encRetVal.encoded == ENCODE_FAIL)
6177 DU_LOG( "\nERROR --> F1AP : Could not encode Initial UL RRC Message Transfer\
6178 structure (at %s)\n",encRetVal.failed_type ? \
6179 encRetVal.failed_type->name : "unknown");
6186 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for Initial UL RRC\
6187 Message transfer\n");
6188 for(int i=0; i< encBufSize; i++)
6190 printf("%x",encBuf[i]);
6194 if(sendF1APMsg() != ROK)
6196 DU_LOG("\nERROR --> F1AP : Sending Initial UL RRC Message Transfer Failed");
6202 freeInitUlRrcMsgTransfer(f1apMsg);
6204 }/* End of BuildAndSendInitialRrcMsgTransfer*/
6206 /***** UE SETUP REQUEST *****/
6208 /*******************************************************************
6210 * @brief Free Qos And Snssai Drb Info
6214 * Function : freeDrbQosAndSnssaiInfo
6216 * Functionality: Free Qos And Snssai Drb Info
6218 * @params[in] LcCfg *lcCfg,
6221 * ****************************************************************/
6222 void freeDrbQosAndSnssaiInfo(LcCfg *lcCfg)
6226 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
6230 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
6234 /******************************************************************
6236 * @brief Function to delete the RLC Lc cfg from UE APP DB
6240 * Function : freeRlcLcCfg
6242 * Functionality: Function to delete the RLC Lc cfg from UE APP DB
6245 *****************************************************************/
6247 void freeRlcLcCfg(RlcBearerCfg *lcCfg)
6249 switch(lcCfg->rlcMode)
6255 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
6259 case RLC_UM_BI_DIRECTIONAL :
6261 if(lcCfg->u.umBiDirCfg)
6263 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
6267 case RLC_UM_UNI_DIRECTIONAL_UL :
6269 if(lcCfg->u.umUniDirUlCfg)
6271 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
6276 case RLC_UM_UNI_DIRECTIONAL_DL :
6278 if(lcCfg->u.umUniDirDlCfg)
6280 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
6285 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at freeRlcLcCfg()", lcCfg->rlcMode);
6290 /*******************************************************************
6292 * @brief Function to free MacLcCfg
6296 * Function : freeMacLcCfg
6298 * Functionality: Function to free MacLcCfg
6300 * @params[in] LcCfg *lcCfg,
6303 * ****************************************************************/
6305 void freeMacLcCfg(LcCfg *lcCfg)
6307 /* Deleting DRBQOS */
6310 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
6312 /* Deleting SNSSAI */
6315 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
6318 /*******************************************************************
6320 * @brief Free UE NR Capability received in UE Context setup request
6324 * Function : freeAperDecodeUeNrCapability
6327 * Free UE NR Capability received in UE Context setup request
6330 * @return ROK - success
6333 * ****************************************************************/
6334 void freeAperDecodeUeNrCapability(void *ueNrCapability)
6337 FeatureSets_t *featureSets =NULLP;
6338 UE_NR_Capability_t *ueNrCap = (UE_NR_Capability_t *)ueNrCapability;
6340 if(ueNrCap->rf_Parameters.supportedBandListNR.list.array)
6342 for(arrIdx = 0; arrIdx < ueNrCap->rf_Parameters.supportedBandListNR.list.count; arrIdx++)
6344 if(ueNrCap->rf_Parameters.supportedBandListNR.list.array[arrIdx])
6345 free(ueNrCap->rf_Parameters.supportedBandListNR.list.array[arrIdx]);
6347 free(ueNrCap->rf_Parameters.supportedBandListNR.list.array);
6350 if(ueNrCap->featureSets)
6352 featureSets = ueNrCap->featureSets;
6353 if(featureSets->featureSetsDownlinkPerCC)
6355 if(featureSets->featureSetsDownlinkPerCC->list.array)
6357 for(arrIdx = 0; arrIdx < featureSets->featureSetsDownlinkPerCC->list.count; arrIdx++)
6359 if(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx])
6361 if(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]->supportedModulationOrderDL)
6362 free(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]->supportedModulationOrderDL);
6363 free(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]);
6366 free(featureSets->featureSetsDownlinkPerCC->list.array);
6368 free(featureSets->featureSetsDownlinkPerCC);
6370 if(featureSets->featureSetsUplinkPerCC)
6372 if(featureSets->featureSetsUplinkPerCC->list.array)
6374 for(arrIdx = 0; arrIdx < featureSets->featureSetsUplinkPerCC->list.count; arrIdx++)
6376 if(featureSets->featureSetsUplinkPerCC->list.array[arrIdx])
6378 if(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]->supportedModulationOrderUL)
6379 free(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]->supportedModulationOrderUL);
6380 free(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]);
6383 free(featureSets->featureSetsUplinkPerCC->list.array);
6385 free(featureSets->featureSetsUplinkPerCC);
6387 free(ueNrCap->featureSets);
6391 /*******************************************************************
6393 * @brief Function to free PdcchSearchSpcToAddModList
6394 where memory allocated by aper_decoder
6398 * Function : freeAperDecodePdcchSearchSpcToAddModList
6400 * Functionality: Function to free PdcchSearchSpcToAddModList
6402 * @params[in] struct PDCCH_Config__searchSpacesToAddModList *searchSpcList
6405 * ****************************************************************/
6407 void freeAperDecodePdcchSearchSpcToAddModList(struct PDCCH_Config__searchSpacesToAddModList *searchSpcList)
6409 uint8_t searchSpcArrIdx=0;
6410 uint8_t searchSpcArrIdx1=0;
6411 struct SearchSpace *searchSpc=NULLP;
6414 if(searchSpcList->list.array)
6416 if(searchSpcList->list.array[searchSpcArrIdx1])
6418 searchSpc = searchSpcList->list.array[searchSpcArrIdx1];
6419 if(searchSpc->controlResourceSetId)
6421 if(searchSpc->monitoringSlotPeriodicityAndOffset)
6423 if(searchSpc->monitoringSymbolsWithinSlot)
6425 if(searchSpc->monitoringSymbolsWithinSlot->buf)
6427 if(searchSpc->nrofCandidates)
6429 if(searchSpc->searchSpaceType)
6431 free(searchSpc->searchSpaceType->choice.ue_Specific);
6432 free(searchSpc->searchSpaceType);
6434 free(searchSpc->nrofCandidates);
6436 free(searchSpc->monitoringSymbolsWithinSlot->buf);
6438 free(searchSpc->monitoringSymbolsWithinSlot);
6440 free(searchSpc->monitoringSlotPeriodicityAndOffset);
6442 free(searchSpc->controlResourceSetId);
6445 for(searchSpcArrIdx = 0; searchSpcArrIdx < searchSpcList->list.count; searchSpcArrIdx++)
6447 free(searchSpcList->list.array[searchSpcArrIdx]);
6449 free(searchSpcList->list.array);
6452 /*******************************************************************
6454 * @brief Function for free part for the memory allocated by aper_decoder
6458 * Function : freeAperDecodeBWPDlDedPdcchConfig
6460 * Functionality: Function to free BWPDlDedPdcchConfig
6465 * ****************************************************************/
6468 void freeAperDecodeBWPDlDedPdcchConfig(BWP_DownlinkDedicated_t *dlBwp)
6472 struct PDCCH_Config *pdcchCfg=NULLP;
6473 struct ControlResourceSet *controlRSet=NULLP;
6474 struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList=NULLP;
6476 if(dlBwp->pdcch_Config->choice.setup)
6478 pdcchCfg=dlBwp->pdcch_Config->choice.setup;
6479 if(pdcchCfg->controlResourceSetToAddModList)
6481 controlRSetList = pdcchCfg->controlResourceSetToAddModList;
6482 if(controlRSetList->list.array)
6484 controlRSet = controlRSetList->list.array[arrIdx2];
6487 if(controlRSet->frequencyDomainResources.buf)
6489 if(controlRSet->pdcch_DMRS_ScramblingID)
6491 if(pdcchCfg->searchSpacesToAddModList)
6493 freeAperDecodePdcchSearchSpcToAddModList(pdcchCfg->searchSpacesToAddModList);
6494 free(pdcchCfg->searchSpacesToAddModList);
6496 free(controlRSet->pdcch_DMRS_ScramblingID);
6498 free(controlRSet->frequencyDomainResources.buf);
6501 for(arrIdx1 = 0; arrIdx1 <controlRSetList->list.count; arrIdx1++)
6503 free(controlRSetList->list.array[arrIdx1]);
6505 free(controlRSetList->list.array);
6507 free(pdcchCfg->controlResourceSetToAddModList);
6509 free(dlBwp->pdcch_Config->choice.setup);
6512 /*******************************************************************
6514 * @brief Function to free PdschTimeDomAllocationList
6515 * where the memory allocated by aper_decoder
6519 * Function : freeAperDecodePdschTimeDomAllocationList
6521 * Functionality: Function to free PdschTimeDomAllocationList
6523 * @params[in] struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
6526 * ****************************************************************/
6529 void freeAperDecodePdschTimeDomAllocationList( struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList)
6533 if(timeDomAllocList->choice.setup)
6535 if(timeDomAllocList->choice.setup->list.array)
6537 for(arrIdx = 0; arrIdx <timeDomAllocList->choice.setup->list.count ; arrIdx++)
6539 free(timeDomAllocList->choice.setup->list.array[arrIdx]);
6541 free(timeDomAllocList->choice.setup->list.array);
6543 free(timeDomAllocList->choice.setup);
6547 /*******************************************************************
6549 * @brief Function to free BWPDlDedPdschConfig
6550 * where the memory allocated by aper_decoder
6554 * Function : freeAperDecodeBWPDlDedPdschConfig
6556 * Functionality: Function to free BWPDlDedPdschConfig
6558 * @params[in] BWP_DownlinkDedicated_t *dlBwp
6561 * ****************************************************************/
6564 void freeAperDecodeBWPDlDedPdschConfig(BWP_DownlinkDedicated_t *dlBwp)
6566 struct PDSCH_Config *pdschCfg=NULLP;
6567 struct PDSCH_Config__prb_BundlingType *prbBndlType=NULLP;
6568 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList=NULLP;
6569 struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg=NULLP;
6571 if(dlBwp->pdsch_Config->choice.setup)
6573 pdschCfg=dlBwp->pdsch_Config->choice.setup;
6574 if(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
6576 if(pdschCfg->pdsch_TimeDomainAllocationList)
6578 timeDomAllocList=pdschCfg->pdsch_TimeDomainAllocationList;
6579 if(pdschCfg->maxNrofCodeWordsScheduledByDCI)
6581 prbBndlType=&pdschCfg->prb_BundlingType;
6582 free(prbBndlType->choice.staticBundling);
6583 free(pdschCfg->maxNrofCodeWordsScheduledByDCI);
6585 freeAperDecodePdschTimeDomAllocationList(timeDomAllocList);
6586 free(pdschCfg->pdsch_TimeDomainAllocationList);
6588 dmrsDlCfg=pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA;
6589 if(dmrsDlCfg->choice.setup)
6591 free(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition);
6592 free(dmrsDlCfg->choice.setup);
6594 free(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA);
6596 free(dlBwp->pdsch_Config->choice.setup);
6599 /*******************************************************************
6601 * @brief Function to free PuschTimeDomAllocListCfg
6602 where the memory allocated by aper_decoder
6606 * Function : freeAperDecodePuschTimeDomAllocListCfg
6608 * Functionality: Function to free PuschTimeDomAllocListCfg
6610 * @params[in] PUSCH_Config_t *puschCfg
6613 * ****************************************************************/
6616 void freeAperDecodePuschTimeDomAllocListCfg(PUSCH_Config_t *puschCfg)
6620 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList_t=NULLP;
6622 if(puschCfg->pusch_TimeDomainAllocationList)
6624 timeDomAllocList_t=puschCfg->pusch_TimeDomainAllocationList;
6625 if(timeDomAllocList_t->choice.setup)
6627 if(timeDomAllocList_t->choice.setup->list.array)
6629 free(timeDomAllocList_t->choice.setup->list.array[arrIdx1]->k2);
6630 for(arrIdx = 0; arrIdx<timeDomAllocList_t->choice.setup->list.count; arrIdx++)
6632 free(timeDomAllocList_t->choice.setup->list.array[arrIdx]);
6634 free(timeDomAllocList_t->choice.setup->list.array);
6636 free(timeDomAllocList_t->choice.setup);
6638 free(puschCfg->transformPrecoder);
6639 free(puschCfg->pusch_TimeDomainAllocationList);
6642 /*******************************************************************
6644 * @brief Function to free InitialUlBWPConfig where memory allocated by aper_decoder
6648 * Function : freeAperDecodeInitialUlBWPConfig
6650 * Functionality: Function to free InitialUlBWPConfig
6652 * @params[in] BWP_UplinkDedicated_t *ulBwp
6655 * ****************************************************************/
6658 void freeAperDecodeInitialUlBWPConfig(BWP_UplinkDedicated_t *ulBwp)
6662 SRS_Config_t *srsCfg = NULLP;
6663 PUSCH_Config_t *puschCfg = NULLP;
6664 struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg = NULLP;
6665 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList = NULLP;
6666 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList = NULLP;
6667 struct SRS_Config__srs_ResourceToAddModList *resourceList = NULLP;
6669 if(ulBwp->pusch_Config)
6671 if(ulBwp->pusch_Config->choice.setup)
6673 puschCfg=ulBwp->pusch_Config->choice.setup;
6674 if(puschCfg->dataScramblingIdentityPUSCH)
6676 if(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
6678 freeAperDecodePuschTimeDomAllocListCfg(puschCfg);
6679 dmrsUlCfg=puschCfg->dmrs_UplinkForPUSCH_MappingTypeA;
6680 if(dmrsUlCfg->choice.setup)
6682 if(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
6684 if(dmrsUlCfg->choice.setup->transformPrecodingDisabled)
6686 free(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0);
6687 free(dmrsUlCfg->choice.setup->transformPrecodingDisabled);
6689 free(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition);
6691 free(dmrsUlCfg->choice.setup);
6693 free(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA);
6695 free(puschCfg->dataScramblingIdentityPUSCH);
6697 free(ulBwp->pusch_Config->choice.setup);
6699 free(ulBwp->pusch_Config);
6701 /* Free SRS-Config */
6702 if(ulBwp->srs_Config)
6704 if(ulBwp->srs_Config->choice.setup)
6706 srsCfg = ulBwp->srs_Config->choice.setup;
6708 /* Free Resource Set to add/mod list */
6709 if(srsCfg->srs_ResourceSetToAddModList)
6711 rsrcSetList = srsCfg->srs_ResourceSetToAddModList;
6712 if(rsrcSetList->list.array)
6716 /* Free SRS resource Id list in this SRS resource set */
6717 if(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
6720 rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
6722 if(rsrcIdList->list.array)
6724 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count;
6727 free(rsrcIdList->list.array[rsrcIdx]);
6729 free(rsrcIdList->list.array);
6731 free(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList);
6734 /* Free resource type info for this SRS resource set */
6736 free(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic);
6738 /* Free memory for each resource set */
6739 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
6741 free(rsrcSetList->list.array[rSetIdx]);
6743 free(rsrcSetList->list.array);
6745 free(srsCfg->srs_ResourceSetToAddModList);
6748 /* Free resource to add/modd list */
6749 if(srsCfg->srs_ResourceToAddModList)
6751 resourceList = srsCfg->srs_ResourceToAddModList;
6752 if(resourceList->list.array)
6756 free(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2);
6757 free(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic);
6759 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
6761 free(resourceList->list.array[rsrcIdx]);
6763 free(resourceList->list.array);
6765 free(srsCfg->srs_ResourceToAddModList);
6768 free(ulBwp->srs_Config->choice.setup);
6770 free(ulBwp->srs_Config);
6774 /*******************************************************************
6776 * @brief Function to free initialUplinkBWPConfig where memory allocated by aper_decoder
6780 * Function : freeAperDecodeinitialUplinkBWPConfig
6782 * Functionality: Function to free initialUplinkBWPConfig
6784 * @params[in] UplinkConfig_t *ulCfg
6787 * ****************************************************************/
6790 void freeAperDecodeinitialUplinkBWPConfig(UplinkConfig_t *ulCfg)
6792 BWP_UplinkDedicated_t *ulBwp=NULLP;
6793 struct UplinkConfig__pusch_ServingCellConfig *puschCfg=NULLP;
6795 if(ulCfg->initialUplinkBWP)
6797 ulBwp=ulCfg->initialUplinkBWP;
6798 if(ulCfg->firstActiveUplinkBWP_Id)
6800 if(ulCfg->pusch_ServingCellConfig)
6802 puschCfg=ulCfg->pusch_ServingCellConfig;
6803 if(puschCfg->choice.setup)
6805 if(puschCfg->choice.setup->ext1)
6807 free(puschCfg->choice.setup->ext1->processingType2Enabled);
6808 free(puschCfg->choice.setup->ext1->maxMIMO_Layers);
6809 free(puschCfg->choice.setup->ext1);
6811 free(puschCfg->choice.setup);
6813 free(ulCfg->pusch_ServingCellConfig);
6815 free(ulCfg->firstActiveUplinkBWP_Id);
6817 freeAperDecodeInitialUlBWPConfig(ulBwp);
6818 free(ulCfg->initialUplinkBWP);
6822 /*******************************************************************
6824 * @brief Function to free DuUeCfg
6828 * Function : freeDuUeCfg
6830 * Functionality: Function to free DuUeCfg
6832 * @params[in] DuUeCfg *ueCfg
6835 * ****************************************************************/
6836 void freeDuUeCfg(DuUeCfg *ueCfg)
6840 SpCellConfig_t *spCellCfg = NULLP;
6841 ServingCellConfig_t *srvCellCfg = NULLP;
6842 BWP_DownlinkDedicated_t *dlBwp = NULLP;
6843 MAC_CellGroupConfig_t *macCellGrpCfg = NULLP;
6844 PhysicalCellGroupConfig_t *phyCellGrpCfg = NULLP;
6845 struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList = NULLP;
6846 struct RLC_Config *rlcConfig = NULLP;
6847 struct LogicalChannelConfig *macLcConfig = NULLP;
6848 struct SchedulingRequestConfig *schedulingRequestConfig = NULLP;
6849 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList = NULLP;
6850 struct TAG_Config *tagConfig = NULLP;
6851 struct TAG_Config__tag_ToAddModList *tagList = NULLP;
6852 struct MAC_CellGroupConfig__phr_Config *phrConfig = NULLP;
6853 struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg = NULLP;
6854 CellGroupConfigRrc_t *cellGrpCfg = ueCfg->cellGrpCfg;
6856 if(ueCfg->ueNrCapability)
6858 freeAperDecodeUeNrCapability(ueCfg->ueNrCapability);
6859 DU_FREE(ueCfg->ueNrCapability, sizeof(UE_NR_Capability_t));
6860 ueCfg->ueNrCapability = NULLP;
6863 if(ueCfg->cellGrpCfg)
6866 rlcBearerList = cellGrpCfg->rlc_BearerToAddModList;
6869 if(rlcBearerList->list.array)
6871 for(arrIdx=0; arrIdx<rlcBearerList->list.count; arrIdx++)
6873 if(rlcBearerList->list.array[arrIdx])
6875 rlcConfig = rlcBearerList->list.array[arrIdx]->rlc_Config;
6876 macLcConfig = rlcBearerList->list.array[arrIdx]->mac_LogicalChannelConfig;
6878 if(rlcBearerList->list.array[arrIdx]->servedRadioBearer)
6880 free(rlcBearerList->list.array[arrIdx]->servedRadioBearer);
6884 if(rlcConfig->choice.am)
6886 free(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength);
6887 free(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength);
6888 free(rlcConfig->choice.am);
6890 free(rlcBearerList->list.array[arrIdx]->rlc_Config);
6894 if(macLcConfig->ul_SpecificParameters)
6896 free(macLcConfig->ul_SpecificParameters->schedulingRequestID);
6897 free(macLcConfig->ul_SpecificParameters->logicalChannelGroup);
6898 free(macLcConfig->ul_SpecificParameters);
6900 free(rlcBearerList->list.array[arrIdx]->mac_LogicalChannelConfig);
6902 free(rlcBearerList->list.array[arrIdx]);
6905 free(rlcBearerList->list.array);
6907 free(cellGrpCfg->rlc_BearerToAddModList);
6910 macCellGrpCfg = cellGrpCfg->mac_CellGroupConfig;
6913 schedulingRequestConfig = macCellGrpCfg->schedulingRequestConfig;
6914 if(schedulingRequestConfig)
6916 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
6919 if(schReqList->list.array)
6921 for(arrIdx=0;arrIdx<schReqList->list.count; arrIdx++)
6923 if(schReqList->list.array[arrIdx])
6925 free(schReqList->list.array[arrIdx]->sr_ProhibitTimer);
6926 free(schReqList->list.array[arrIdx]);
6929 free(schReqList->list.array);
6931 free(schedulingRequestConfig->schedulingRequestToAddModList);
6933 free(macCellGrpCfg->schedulingRequestConfig);
6935 if(macCellGrpCfg->bsr_Config)
6937 free(macCellGrpCfg->bsr_Config);
6939 tagConfig = macCellGrpCfg->tag_Config;
6942 tagList = tagConfig->tag_ToAddModList;
6945 if(tagList->list.array)
6947 for(arrIdx=0; arrIdx<tagList->list.count; arrIdx++)
6949 free(tagList->list.array[arrIdx]);
6951 free(tagList->list.array);
6953 free(tagConfig->tag_ToAddModList);
6958 phrConfig = macCellGrpCfg->phr_Config;
6961 free(phrConfig->choice.setup);
6965 free(macCellGrpCfg);
6968 phyCellGrpCfg = cellGrpCfg->physicalCellGroupConfig;
6971 free(phyCellGrpCfg->p_NR_FR1);
6972 free(phyCellGrpCfg);
6975 spCellCfg = cellGrpCfg->spCellConfig;
6978 if(spCellCfg->servCellIndex)
6980 if(spCellCfg->rlmInSyncOutOfSyncThreshold)
6982 if(spCellCfg->spCellConfigDedicated)
6984 srvCellCfg = spCellCfg->spCellConfigDedicated;
6985 if(srvCellCfg->initialDownlinkBWP)
6987 dlBwp = srvCellCfg->initialDownlinkBWP;
6988 if(srvCellCfg->firstActiveDownlinkBWP_Id)
6990 if(srvCellCfg->defaultDownlinkBWP_Id)
6992 if(srvCellCfg->uplinkConfig)
6995 if(srvCellCfg->pdsch_ServingCellConfig)
6998 srvCellCfg->pdsch_ServingCellConfig;
6999 if(pdschCfg->choice.setup)
7002 free(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH);
7003 free(pdschCfg->choice.setup);
7006 free(srvCellCfg->pdsch_ServingCellConfig);
7009 freeAperDecodeinitialUplinkBWPConfig(srvCellCfg->uplinkConfig);
7010 free(srvCellCfg->uplinkConfig);
7012 free(srvCellCfg->defaultDownlinkBWP_Id);
7015 free(srvCellCfg->firstActiveDownlinkBWP_Id);
7017 if(dlBwp->pdcch_Config)
7019 if(dlBwp->pdsch_Config)
7021 freeAperDecodeBWPDlDedPdschConfig(dlBwp);
7022 free(dlBwp->pdsch_Config);
7024 freeAperDecodeBWPDlDedPdcchConfig(dlBwp);
7025 free(dlBwp->pdcch_Config);
7027 free(srvCellCfg->initialDownlinkBWP);
7030 free(spCellCfg->spCellConfigDedicated);
7032 free(spCellCfg->rlmInSyncOutOfSyncThreshold);
7034 free(spCellCfg->servCellIndex);
7038 DU_FREE(ueCfg->cellGrpCfg, sizeof(CellGroupConfigRrc_t));
7039 ueCfg->cellGrpCfg = NULLP;
7043 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCfg->ambrCfg, sizeof(AmbrCfg));
7045 for(lcIdx = 0; lcIdx < ueCfg->numRlcLcs; lcIdx++)
7047 freeRlcLcCfg(&ueCfg->rlcLcCfg[lcIdx]);
7049 for(lcIdx = 0; lcIdx < ueCfg->numMacLcs; lcIdx++)
7051 freeMacLcCfg(&ueCfg->macLcCfg[lcIdx]);
7053 for(lcIdx = 0; lcIdx < ueCfg->numDrb; lcIdx++)
7055 DU_FREE(ueCfg->upTnlInfo[lcIdx].tnlCfg1, sizeof(GtpTnlCfg));
7059 /*******************************************************************
7061 * @brief Function to free UecontextSetupDb
7065 * Function : freeF1UeDb
7067 * Functionality: Function to free UecontextSetupDb
7069 * @params[in] UecontextSetupDb *
7072 * ****************************************************************/
7074 void freeF1UeDb(F1UeContextSetupDb *f1UeDb)
7077 if(f1UeDb->dlRrcMsg)
7079 if(f1UeDb->dlRrcMsg->rrcMsgPdu)
7081 //DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,\
7082 f1UeDb->dlRrcMsg->rrcMsgPdu, f1UeDb->dlRrcMsg->rrcMsgSize);
7084 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
7086 freeDuUeCfg(&f1UeDb->duUeCfg);
7087 memset(f1UeDb, 0, sizeof(F1UeContextSetupDb));
7088 DU_FREE(f1UeDb, sizeof(F1UeContextSetupDb));
7091 /*******************************************************************
7093 * @brief Function to build Am cfg Info
7097 * Function : extractRlcAmCfg
7099 * Functionality: Function to build Am cfg Info
7101 * @params[in] AmBearerCfg *
7104 * @return ROK/RFAILED
7106 * ****************************************************************/
7108 void extractRlcAmCfg(AmBearerCfg *amCfgToSet, struct RLC_Config__am *rlcAmCfg)
7113 if(rlcAmCfg->dl_AM_RLC.sn_FieldLength)
7115 amCfgToSet->ulAmCfg.snLenUl = *(rlcAmCfg->dl_AM_RLC.sn_FieldLength);
7116 /*TODO: Check the timer value when sent by real CU */
7117 amCfgToSet->ulAmCfg.reAssemTmr = rlcAmCfg->dl_AM_RLC.t_Reassembly;
7118 amCfgToSet->ulAmCfg.statProhTmr = rlcAmCfg->dl_AM_RLC.t_StatusProhibit;
7122 if(rlcAmCfg->ul_AM_RLC.sn_FieldLength)
7124 amCfgToSet->dlAmCfg.snLenDl = *(rlcAmCfg->ul_AM_RLC.sn_FieldLength);
7125 amCfgToSet->dlAmCfg.pollRetxTmr = rlcAmCfg->ul_AM_RLC.t_PollRetransmit;
7126 amCfgToSet->dlAmCfg.pollPdu = rlcAmCfg->ul_AM_RLC.pollPDU;
7127 amCfgToSet->dlAmCfg.pollByte = rlcAmCfg->ul_AM_RLC.pollByte;
7128 amCfgToSet->dlAmCfg.maxRetxTh = rlcAmCfg->ul_AM_RLC.maxRetxThreshold;
7133 /*******************************************************************
7135 * @brief Function to build Um Bi Info
7139 * Function : extractRlcUmBiCfg
7141 * Functionality: Function to build Um Bi Info
7143 * @params[in] UmBiDirBearerCfg *
7146 * @return ROK/RFAILED
7148 * ****************************************************************/
7150 void extractRlcUmBiCfg(UmBiDirBearerCfg *umBiCfgToSet, struct RLC_Config__um_Bi_Directional *rlcBiCfg)
7154 /* UL UM BI DIR Cfg */
7155 if(rlcBiCfg->dl_UM_RLC.sn_FieldLength)
7157 umBiCfgToSet->ulUmCfg.snLenUlUm = *(rlcBiCfg->dl_UM_RLC.sn_FieldLength);
7158 umBiCfgToSet->ulUmCfg.reAssemTmr = rlcBiCfg->dl_UM_RLC.t_Reassembly;
7161 /* DL UM BI DIR Cfg */
7162 if(rlcBiCfg->ul_UM_RLC.sn_FieldLength)
7163 umBiCfgToSet->dlUmCfg.snLenDlUm = *(rlcBiCfg->ul_UM_RLC.sn_FieldLength);
7167 /*******************************************************************
7169 * @brief Function to build Um Ul Info
7173 * Function : extractRlcUmUlCfg
7175 * Functionality: Function to build Um Ul Info
7177 * @params[in] UmUniDirUlBearerCfg *
7180 * @return ROK/RFAILED
7182 * ****************************************************************/
7184 void extractRlcUmUlCfg(UmUniDirUlBearerCfg *umUlCfgToSet, struct RLC_Config__um_Uni_Directional_DL *umUlCfg)
7188 if(umUlCfg->dl_UM_RLC.sn_FieldLength)
7190 umUlCfgToSet->ulUmCfg.snLenUlUm = *(umUlCfg->dl_UM_RLC.sn_FieldLength);
7191 umUlCfgToSet->ulUmCfg.reAssemTmr = umUlCfg->dl_UM_RLC.t_Reassembly;
7196 /*******************************************************************
7198 * @brief Function to build Um Uni Dl Info
7202 * Function : extractRlcUmDlCfg
7204 * Functionality: Function to build Um Uni Dl Info
7206 * @params[in] UmUniDirDlBearerCfg *
7209 * @return ROK/RFAILED
7211 * ****************************************************************/
7212 void extractRlcUmDlCfg(UmUniDirDlBearerCfg *umDlCfgToSet, struct RLC_Config__um_Uni_Directional_UL *umDlCfg)
7216 if(umDlCfg->ul_UM_RLC.sn_FieldLength)
7217 umDlCfgToSet->dlUmCfg.snLenDlUm = *(umDlCfg->ul_UM_RLC.sn_FieldLength);
7221 /*******************************************************************
7223 * @brief Function to extractRlcModeCfg
7227 * Function : extractRlcModeCfg
7229 * Functionality: Function to extractRlcModeCfg
7231 * @params[in] RLC_Config_t *
7234 * @return ROK/RFAILED
7236 * ****************************************************************/
7237 void extractRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *rlcDbCfg, RLC_Config_t *lcCfg)
7245 if(lcCfg->choice.am)
7247 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.amCfg, sizeof(AmBearerCfg));
7248 if(rlcDbCfg->u.amCfg)
7249 extractRlcAmCfg(rlcDbCfg->u.amCfg, lcCfg->choice.am);
7253 case RLC_UM_BI_DIRECTIONAL :
7255 if(lcCfg->choice.um_Bi_Directional)
7257 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
7258 if(rlcDbCfg->u.umBiDirCfg)
7259 extractRlcUmBiCfg(rlcDbCfg->u.umBiDirCfg, lcCfg->choice.um_Bi_Directional);
7263 case RLC_UM_UNI_DIRECTIONAL_UL :
7265 if(lcCfg->choice.um_Uni_Directional_DL)
7267 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
7268 if(rlcDbCfg->u.umUniDirUlCfg)
7269 extractRlcUmUlCfg(rlcDbCfg->u.umUniDirUlCfg, lcCfg->choice.um_Uni_Directional_DL);
7273 case RLC_UM_UNI_DIRECTIONAL_DL :
7275 if(lcCfg->choice.um_Uni_Directional_UL)
7277 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
7278 if(rlcDbCfg->u.umUniDirDlCfg)
7279 extractRlcUmDlCfg(rlcDbCfg->u.umUniDirDlCfg, lcCfg->choice.um_Uni_Directional_UL);
7284 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
7290 /*******************************************************************
7292 * @brief Function to extract extractUlLcCfg
7296 * Function : extractUlLcCfg
7298 * Functionality: Function to extract extractUlLcCfg
7300 * @params[in] UlLcCfg *f1UlLcCfg, LogicalChannelConfig_t *ulLcCfg
7303 * ****************************************************************/
7305 void extractUlLcCfg(UlLcCfg *f1UlLcCfg, LogicalChannelConfig_t *ulLcCfg)
7309 if(ulLcCfg->ul_SpecificParameters)
7311 f1UlLcCfg->priority = \
7312 ulLcCfg->ul_SpecificParameters->priority;
7313 if(ulLcCfg->ul_SpecificParameters->logicalChannelGroup)
7315 f1UlLcCfg->lcGroup = \
7316 *(ulLcCfg->ul_SpecificParameters->logicalChannelGroup);
7318 if(ulLcCfg->ul_SpecificParameters->schedulingRequestID)
7320 f1UlLcCfg->schReqId = \
7321 *(ulLcCfg->ul_SpecificParameters->schedulingRequestID);
7324 ulLcCfg->ul_SpecificParameters->prioritisedBitRate;
7326 ulLcCfg->ul_SpecificParameters->bucketSizeDuration;
7331 /*******************************************************************
7333 * @brief Function to procRlcLcCfg
7337 * Function : procRlcLcCfg
7339 * Functionality: Function to procRlcLcCfg
7341 * @params[in] rbId, lcId, rbType, rlcMod
7342 * RLC_Config_t *, RlcBearerCfg * ,
7345 * ****************************************************************/
7347 void procRlcLcCfg(uint8_t rbId, uint8_t lcId, uint8_t rbType, uint8_t rlcMode,\
7348 uint8_t configType, RLC_Config_t *f1RlcCfg, RlcBearerCfg *lcCfg)
7352 lcCfg->configType = configType;
7354 if(rbType == RB_TYPE_SRB)
7356 lcCfg->rbType = RB_TYPE_SRB;
7358 lcCfg->lcType = LCH_DCCH;
7359 lcCfg->rlcMode = RLC_AM;
7361 else if(rbType == RB_TYPE_DRB)
7363 lcCfg->rbType = RB_TYPE_DRB;
7365 lcCfg->lcType = LCH_DTCH;
7366 lcCfg->rlcMode = rlcMode;
7368 if(f1RlcCfg) /* rlc mode config recived */
7370 extractRlcModeCfg(lcCfg->rlcMode, lcCfg, f1RlcCfg);
7376 /*******************************************************************
7378 * @brief Fills DrbQos Info received by CU
7382 * Function : extractQosInfo
7384 * Functionality: Fills DrbQos Info received by CU
7386 * @params[in] DrbQosInfo *qosToAdd,
7387 * QoSFlowLevelQoSParameters_t *qosFlowCfg
7390 * ****************************************************************/
7392 void extractQosInfo(DrbQosInfo *qosToAdd, QoSFlowLevelQoSParameters_t *qosFlowCfg)
7394 qosToAdd->fiveQiType = qosFlowCfg->qoS_Characteristics.present;
7395 qosToAdd->u.nonDyn5Qi.fiveQi =\
7396 qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->fiveQI;
7397 if(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow)
7399 qosToAdd->u.nonDyn5Qi.avgWindow = \
7400 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
7402 qosToAdd->u.nonDyn5Qi.maxDataBurstVol = \
7403 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
7404 if(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->qoSPriorityLevel)
7406 qosToAdd->u.nonDyn5Qi.priorLevel = \
7407 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->qoSPriorityLevel);
7409 qosToAdd->ngRanRetPri.priorityLevel = \
7410 qosFlowCfg->nGRANallocationRetentionPriority.priorityLevel;
7411 qosToAdd->ngRanRetPri.preEmptionCap = \
7412 qosFlowCfg->nGRANallocationRetentionPriority.pre_emptionCapability;
7413 qosToAdd->ngRanRetPri.preEmptionVul = \
7414 qosFlowCfg->nGRANallocationRetentionPriority.pre_emptionVulnerability;
7415 if(qosFlowCfg->gBR_QoS_Flow_Information)
7417 memcpy(&qosToAdd->grbQosInfo.maxFlowBitRateDl, \
7418 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateDownlink.buf, \
7419 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateDownlink.size);
7420 memcpy(&qosToAdd->grbQosInfo.maxFlowBitRateUl, \
7421 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateUplink.buf, \
7422 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateUplink.size);
7423 memcpy(&qosToAdd->grbQosInfo.guarFlowBitRateDl,\
7424 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateDownlink.buf, \
7425 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateDownlink.size);
7426 memcpy(&qosToAdd->grbQosInfo.guarFlowBitRateUl,\
7427 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateUplink.buf, \
7428 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateUplink.size);
7430 qosToAdd->pduSessionId = 0;
7431 qosToAdd->ulPduSessAggMaxBitRate = 0;
7434 /*******************************************************************
7436 * @brief Function to extract GTP Tunnel Info from CU
7440 * Function : extractUpTnlInfo
7442 * Functionality: Function to extract GTP Tunnel Info from CU
7444 * @params[in] F1AP message
7445 * @return ROK/RFAILED
7447 * ****************************************************************/
7449 uint8_t extractUpTnlInfo(uint8_t drbId, uint8_t configType,\
7450 ULUPTNLInformation_ToBeSetup_List_t *tnlInfo, UpTnlCfg *upTnlInfo)
7453 uint32_t ipv4_du = 0;
7454 GTPTunnel_t *gtpTunnel = NULLP;
7456 upTnlInfo->drbId = drbId;
7457 upTnlInfo->configType = configType;
7459 cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
7461 cmInetAddr((char *)DU_IP_V4_ADDR, &ipv4_du);
7464 for(tnlIdx=0; tnlIdx < tnlInfo->list.count; tnlIdx++)
7466 if(tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.present == UPTransportLayerInformation_PR_gTPTunnel)
7468 if(tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.choice.gTPTunnel)
7470 gtpTunnel = tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.choice.gTPTunnel;
7471 DU_ALLOC(upTnlInfo->tnlCfg1, sizeof(GtpTnlCfg));
7472 if(upTnlInfo->tnlCfg1 == NULLP)
7474 DU_LOG("\nERROR --> F1AP : extractUpTnlInfo: Failed to allocate mmeory for tunnel cfg 1");
7477 bitStringToInt(>pTunnel->transportLayerAddress, &upTnlInfo->tnlCfg1->ulTnlAddress);
7478 upTnlInfo->tnlCfg1->dlTnlAddress = ipv4_du;
7479 if(gtpTunnel->gTP_TEID.size > 0)
7481 teIdStringToInt(gtpTunnel->gTP_TEID.buf, &upTnlInfo->tnlCfg1->teId);
7489 /*******************************************************************
7491 * @brief Function to extract Drb Qos Cfg Info from CU
7495 * Function : extractDrbQosCfg
7497 * Functionality: Function to extract Drb Qos Cfg Info from CU
7499 * @params[in] DRB_Information_t *drbInfo, LcCfg *macLcToAdd
7500 * @return ROK/RFAILED
7502 * ****************************************************************/
7504 uint8_t extractDrbQosCfg(DRB_Information_t *drbInfo, LcCfg *macLcToAdd )
7506 if(!macLcToAdd->drbQos)
7508 DU_ALLOC_SHRABL_BUF(macLcToAdd->drbQos, sizeof(DrbQosInfo));
7509 if(macLcToAdd->drbQos == NULLP)
7511 DU_LOG("\nERROR --> DUAPP:Memory failed at allocating DrbQos at extractDrbCfg()");
7516 if(drbInfo->dRB_QoS.qoS_Characteristics.present == QoS_Characteristics_PR_non_Dynamic_5QI)
7518 extractQosInfo(macLcToAdd->drbQos, &drbInfo->dRB_QoS);
7519 macLcToAdd->dlLcCfg.lcp = macLcToAdd->drbQos->ngRanRetPri.priorityLevel;
7521 if(!macLcToAdd->snssai)
7523 DU_ALLOC_SHRABL_BUF(macLcToAdd->snssai, sizeof(Snssai));
7524 if(macLcToAdd->snssai == NULLP)
7526 DU_LOG("\nERROR --> DUAPP : Memory failed at allocating SNSSAI at extractDrbCfg()");
7530 memcpy(&macLcToAdd->snssai->sst, drbInfo->sNSSAI.sST.buf, \
7531 drbInfo->sNSSAI.sST.size);
7532 if(drbInfo->sNSSAI.sD)
7534 memcpy(macLcToAdd->snssai->sd, drbInfo->sNSSAI.sD->buf, \
7535 drbInfo->sNSSAI.sD->size);
7539 /*******************************************************************
7541 * @brief Function to extract DRB info received from CU
7545 * Function : extractDrbCfg
7547 * Functionality: Function to extract DRB info received from CU
7549 * @params[in] F1AP message
7552 * ****************************************************************/
7553 uint8_t extractDrbCfg(DRBs_ToBeSetup_Item_t *drbItem,DRBs_ToBeSetupMod_Item_t *drbSetupModItem,\
7554 LcCfg *macLcToAdd, UpTnlCfg *upTnlInfo)
7556 DRB_Information_t *drbInfo = NULLP;
7558 if(drbItem != NULLP)
7560 if(extractUpTnlInfo(drbItem->dRBID, CONFIG_ADD, &drbItem->uLUPTNLInformation_ToBeSetup_List, upTnlInfo) != ROK)
7562 DU_LOG("\nERROR --> DUAPP : Failed to extract tunnel Cfg at extractDrbCfg()");
7565 if(drbItem->qoSInformation.present == QoSInformation_PR_choice_extension)
7567 if(drbItem->qoSInformation.choice.choice_extension->value.present == QoSInformation_ExtIEs__value_PR_DRB_Information)
7569 drbInfo = &drbItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information;
7570 if(extractDrbQosCfg(drbInfo , macLcToAdd) != ROK)
7572 DU_LOG("\nERROR --> DUAPP : Failed to extract qos Cfg at extractDrbCfg()");
7578 else if(drbSetupModItem != NULLP)
7580 if(extractUpTnlInfo(drbSetupModItem->dRBID, CONFIG_ADD, &drbSetupModItem->uLUPTNLInformation_ToBeSetup_List,\
7583 DU_LOG("\nERROR --> DUAPP : Failed to extract tunnel Cfg at extractDrbCfg()");
7586 if(drbSetupModItem->qoSInformation.present == QoSInformation_PR_choice_extension)
7588 if(drbSetupModItem->qoSInformation.choice.choice_extension->value.present ==\
7589 QoSInformation_ExtIEs__value_PR_DRB_Information)
7591 drbInfo = &drbSetupModItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information;
7592 if(extractDrbQosCfg(drbInfo , macLcToAdd) != ROK)
7594 DU_LOG("\nERROR --> DUAPP : Failed to extract qos Cfg at extractDrbCfg()");
7605 /*******************************************************************
7607 * @brief Function to extract RB info received from CU
7611 * Function : extractMacRbCfg
7613 * Functionality: Function to extract RB info received from CU
7615 * @params[in] F1AP message
7616 * @return ROK/RFAILED
7618 * ****************************************************************/
7620 uint8_t extractMacRbCfg(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbCfg,\
7621 DRBs_ToBeSetupMod_Item_t *drbSetupModCfg, LogicalChannelConfig_t *ulLcCfg, LcCfg *lcCfg, UpTnlCfg *upTnlInfo)
7625 if(extractDrbCfg(drbCfg, NULL, lcCfg, upTnlInfo) != ROK)
7627 DU_LOG("ERROR --> F1AP : Failed to build Drb Qos at extractMacRbCfg()");
7631 else if(drbSetupModCfg != NULLP)
7633 if(extractDrbCfg(NULL, drbSetupModCfg, lcCfg, upTnlInfo) != ROK)
7635 DU_LOG("ERROR --> F1AP : Failed to build Drb Qos at extractMacRbCfg()");
7641 lcCfg->drbQos = NULLP;
7642 lcCfg->snssai = NULLP;
7643 if(lcCfg->lcId == SRB2_LCID)
7644 lcCfg->dlLcCfg.lcp = LC_PRIORITY_3;
7646 lcCfg->dlLcCfg.lcp = LC_PRIORITY_1;
7650 lcCfg->ulLcCfgPres = true;
7651 extractUlLcCfg(&lcCfg->ulLcCfg, ulLcCfg);
7654 lcCfg->ulLcCfgPres = false;
7658 /*******************************************************************
7660 * @brief Function processing LC config info received from CU
7664 * Function : procMacLcCfg
7666 * Functionality: Function processing LC config info received from CU
7668 * @params[in] F1AP message
7669 * @return ROK/RFAILED
7671 * ****************************************************************/
7673 uint8_t procMacLcCfg(uint8_t lcId, uint8_t rbType, uint8_t configType,\
7674 DRBs_ToBeSetup_Item_t *drbItem, DRBs_ToBeSetupMod_Item_t *drbSetupModItem, LogicalChannelConfig_t *ulLcCfg,\
7675 LcCfg *lcCfg, UpTnlCfg *upTnlInfo)
7680 lcCfg->configType = configType;
7681 if(rbType == RB_TYPE_SRB)
7683 ret = extractMacRbCfg(lcId, NULL,NULL, ulLcCfg, lcCfg, NULL);
7685 else if(rbType == RB_TYPE_DRB)
7688 ret = extractMacRbCfg(lcId, drbItem, NULL, ulLcCfg, lcCfg, upTnlInfo);
7689 else if(drbSetupModItem != NULL)
7690 ret = extractMacRbCfg(lcId, NULL, drbSetupModItem, ulLcCfg, lcCfg, upTnlInfo);
7695 /*******************************************************************
7697 * @brief Function to extract Rlc cfg To Add/Mod in CellGrp Info
7701 * Function : extractRlcCfgToAddMod
7703 * Functionality: Function to extract Rlc cfg To Add/Mod in CellGrp Info
7705 * @params[in] CellGroupConfigRrc__rlc_BearerTo pointer
7707 * @return ROK/RFAILED
7709 * ****************************************************************/
7711 uint8_t extractRlcCfgToAddMod(struct CellGroupConfigRrc__rlc_BearerToAddModList *lcCfg, DuUeCfg *ueCfgDb)
7713 uint8_t idx, rbId, lcId, rlcMode, rbType;
7714 RLC_Config_t *f1RlcCfg = NULLP;
7715 LogicalChannelConfig_t *macUlLcCfg = NULLP;
7717 for(idx = 0; idx < lcCfg->list.count; idx++)
7719 lcId = lcCfg->list.array[idx]->logicalChannelIdentity;
7720 if(lcCfg->list.array[idx]->servedRadioBearer)
7722 /* RadioBearer for SRB/DRB */
7723 if(lcCfg->list.array[idx]->servedRadioBearer->present ==\
7724 RLC_BearerConfig__servedRadioBearer_PR_srb_Identity)
7726 rbId = lcCfg->list.array[idx]->servedRadioBearer->choice.srb_Identity;
7727 rbType = RB_TYPE_SRB;
7729 else if(lcCfg->list.array[idx]->servedRadioBearer->present ==\
7730 RLC_BearerConfig__servedRadioBearer_PR_drb_Identity)
7732 rbId = lcCfg->list.array[idx]->servedRadioBearer->choice.drb_Identity;
7733 rbType = RB_TYPE_DRB;
7737 DU_LOG("\nERROR --> No components present in Bearer config to ADD/MOD");
7740 /* MAC UL LC Config */
7741 if(lcCfg->list.array[idx]->mac_LogicalChannelConfig)
7743 macUlLcCfg = lcCfg->list.array[idx]->mac_LogicalChannelConfig;
7748 DU_LOG("\nERROR --> DUAPP: Received RadioBearer config is NULL");
7751 /* RLC Mode Config */
7752 if(lcCfg->list.array[idx]->rlc_Config)
7754 rlcMode = lcCfg->list.array[idx]->rlc_Config->present;
7755 f1RlcCfg = lcCfg->list.array[idx]->rlc_Config;
7758 /* Filling RLC/MAC Config*/
7759 memset(&ueCfgDb->macLcCfg[idx], 0, sizeof(LcCfg));
7760 memset(&ueCfgDb->rlcLcCfg[idx], 0, sizeof(RlcBearerCfg));
7761 procRlcLcCfg(rbId, lcId, rbType, rlcMode, CONFIG_UNKNOWN, f1RlcCfg, &(ueCfgDb->rlcLcCfg[idx]));
7762 if(procMacLcCfg(lcId, rbType, CONFIG_UNKNOWN, NULL, NULL, macUlLcCfg, &ueCfgDb->macLcCfg[idx], NULL) != ROK)
7764 DU_LOG("\nERROR --> DU APP : Failed while filling MAC LC config at extractRlcCfgToAddMod()");
7767 (ueCfgDb->numRlcLcs)++;
7768 (ueCfgDb->numMacLcs)++;
7770 //TODO: To send the failure cause in UeContextSetupRsp
7774 /*******************************************************************
7776 * @brief DeAlloc pdsch serv cell config info
7780 * Function : freeMacPdschServCellInfo
7782 * Functionality: DeAlloc pdsch serv cell config info
7784 * @params[in] PdschServCellCfg pointer
7787 * ****************************************************************/
7789 void freeMacPdschServCellInfo(PdschServCellCfg *pdsch)
7791 if(pdsch->xOverhead)
7793 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->xOverhead, sizeof(PdschXOverhead));
7795 if(pdsch->codeBlkGrpFlushInd)
7797 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->codeBlkGrpFlushInd, sizeof(bool));
7799 if(pdsch->maxCodeBlkGrpPerTb)
7801 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
7803 if(pdsch->maxMimoLayers)
7805 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->maxMimoLayers, sizeof(uint8_t));
7809 /*******************************************************************
7811 * @brief Free Serving cell Info
7815 * Function : freeMacServingCellInfo
7817 * Functionality: Free Serving cell Info
7819 * @params[in] ServCellCfgInfo *srvCellCfg
7822 * ****************************************************************/
7823 void freeMacServingCellInfo(ServCellCfgInfo *srvCellCfg)
7825 uint8_t timeDomRsrcIdx;
7827 if(srvCellCfg->initDlBwp.pdschPresent)
7829 for(timeDomRsrcIdx = 0; timeDomRsrcIdx < srvCellCfg->initDlBwp.pdschCfg.numTimeDomRsrcAlloc; timeDomRsrcIdx++)
7831 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, \
7832 srvCellCfg->initDlBwp.pdschCfg.timeDomRsrcAllociList[timeDomRsrcIdx].k0, sizeof(uint8_t));
7836 freeMacPdschServCellInfo(&srvCellCfg->pdschServCellCfg);
7837 if(srvCellCfg->bwpInactivityTmr)
7839 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, srvCellCfg->bwpInactivityTmr, sizeof(uint8_t));
7842 if(srvCellCfg->initUlBwp.pucchPresent)
7844 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, srvCellCfg->initUlBwp.pucchCfg.dlDataToUlAck, sizeof(PucchDlDataToUlAck));
7848 /*******************************************************************
7850 * @brief Free cell Grp Cfg Info
7854 * Function : freeUeReCfgCellGrpInfo
7856 * Functionality: Free cell Grp Cfg Info
7858 * @params[in] MacUeCfg* duUeCfg
7861 * ****************************************************************/
7863 void freeUeReCfgCellGrpInfo(MacUeCfg *macUeCfg)
7865 freeMacServingCellInfo(&macUeCfg->spCellCfg.servCellCfg);
7868 /*******************************************************************
7870 * @brief Fills Reconfig SchReqReConfig
7874 * Function : extractSchReqReConfig
7876 * Functionality: Fills Reconfig SchReqReConfig
7878 * @params[in] SchedulingRequestConfig_t *cuSchedReq
7879 * SchedReqCfg* macSchedReq
7882 * ****************************************************************/
7883 void extractSchReqReConfig(SchedulingRequestConfig_t *cuSchedReq, SchedReqCfg *macSchedReq)
7885 uint8_t schReqIdx = 0;
7886 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqListToAdd = NULLP;
7887 struct SchedulingRequestConfig__schedulingRequestToReleaseList *schReqListToRel = NULLP;
7889 if(cuSchedReq->schedulingRequestToAddModList)
7891 schReqListToAdd = cuSchedReq->schedulingRequestToAddModList;
7892 if(schReqListToAdd->list.count)
7894 macSchedReq->addModListCount = schReqListToAdd->list.count;
7895 for(schReqIdx = 0; schReqIdx < schReqListToAdd->list.count; schReqIdx++)
7897 macSchedReq->addModList[schReqIdx].schedReqId = \
7898 schReqListToAdd->list.array[schReqIdx]->schedulingRequestId;
7899 macSchedReq->addModList[schReqIdx].srProhibitTmr = \
7900 *(schReqListToAdd->list.array[schReqIdx]->sr_ProhibitTimer);
7901 macSchedReq->addModList[schReqIdx].srTransMax =\
7902 schReqListToAdd->list.array[schReqIdx]->sr_TransMax;
7906 /* Scheduling Req To release */
7907 if(cuSchedReq->schedulingRequestToReleaseList)
7909 schReqListToRel = cuSchedReq->schedulingRequestToReleaseList;
7910 if(schReqListToRel->list.count)
7912 macSchedReq->relListCount = schReqListToRel->list.count;
7913 for(schReqIdx = 0; schReqIdx < schReqListToRel->list.count; schReqIdx++)
7915 macSchedReq->relList[schReqIdx] = \
7916 *schReqListToRel->list.array[schReqIdx];
7922 /*******************************************************************
7924 * @brief Fills TagReconfig
7928 * Function : extractTagReconfig
7930 * Functionality: Fills extractTagReconfig
7932 * @params[in] TAG_Config_t *cuTagCfg
7936 * ****************************************************************/
7938 void extractTagReconfig(TAG_Config_t *cuTagCfg, TagCfg *macTagCfg)
7941 struct TAG_Config__tag_ToAddModList *tagListToAddMod = NULLP;
7942 struct TAG_Config__tag_ToReleaseList *tagListToRel = NULLP;
7944 /* Tag config to AddMod */
7945 if(cuTagCfg->tag_ToAddModList)
7947 tagListToAddMod = cuTagCfg->tag_ToAddModList;
7948 if(tagListToAddMod->list.count)
7950 macTagCfg->addModListCount = tagListToAddMod->list.count;
7951 for(tagIdx = 0; tagIdx < tagListToAddMod->list.count; tagIdx++)
7953 macTagCfg->addModList[tagIdx].tagId =\
7954 tagListToAddMod->list.array[tagIdx]->tag_Id;
7955 macTagCfg->addModList[tagIdx].timeAlignTimer = \
7957 tagListToAddMod->list.array[tagIdx]->timeAlignmentTimer;
7961 /* Tag config to release */
7962 if(cuTagCfg->tag_ToReleaseList)
7964 tagListToRel = cuTagCfg->tag_ToReleaseList;
7965 if(tagListToRel->list.count)
7967 macTagCfg->relListCount = tagListToRel->list.count;
7968 for(tagIdx = 0; tagIdx < tagListToRel->list.count; tagIdx++)
7970 macTagCfg->relList[tagIdx] = *tagListToRel->list.array[tagIdx];
7976 /*******************************************************************
7978 * @brief Fills PdcchCfg received by CU
7982 * Function : extractPdcchCfg
7984 * Functionality: Fills PdcchCfg received by CU
7986 * @params[in] PDCCH_Config_t *cuPdcchCfg,
7987 * PdcchConfig *duPdcchCfg
7990 * ****************************************************************/
7992 void extractPdcchCfg(PDCCH_Config_t *cuPdcchCfg, PdcchConfig *macPdcchCfg)
7994 uint8_t cRsetIdx = 0;
7995 uint8_t srchSpcIdx = 0;
7997 struct PDCCH_Config__controlResourceSetToAddModList *cRsetToAddModList = NULLP;
7998 struct PDCCH_Config__controlResourceSetToReleaseList *cRsetToRelList = NULLP;
7999 struct PDCCH_Config__searchSpacesToAddModList *srchSpcToAddModList = NULLP;
8000 struct PDCCH_Config__searchSpacesToReleaseList *srchSpcToRelList = NULLP;
8003 /* Control Resource Set To Add/Mod List */
8004 if(cuPdcchCfg->controlResourceSetToAddModList)
8006 cRsetToAddModList = cuPdcchCfg->controlResourceSetToAddModList;
8007 if(cRsetToAddModList->list.count)
8009 macPdcchCfg->numCRsetToAddMod = cRsetToAddModList->list.count;
8010 for(cRsetIdx = 0; cRsetIdx < cRsetToAddModList->list.count; cRsetIdx++)
8012 macPdcchCfg->cRSetToAddModList[cRsetIdx].cRSetId = \
8013 cRsetToAddModList->list.array[cRsetIdx]->controlResourceSetId;
8014 bitStringToInt(&cRsetToAddModList->list.array[cRsetIdx]->frequencyDomainResources,\
8015 macPdcchCfg->cRSetToAddModList[cRsetIdx].freqDomainRsrc);
8016 macPdcchCfg->cRSetToAddModList[cRsetIdx].duration = \
8017 cRsetToAddModList->list.array[cRsetIdx]->duration;
8019 macPdcchCfg->cRSetToAddModList[cRsetIdx].cceRegMappingType = \
8020 cRsetToAddModList->list.array[cRsetIdx]->cce_REG_MappingType.present;
8021 if(macPdcchCfg->cRSetToAddModList[cRsetIdx].cceRegMappingType == CCE_REG_MAPPINGTYPE_PR_INTERLEAVED)
8023 //TODO: handle the case for Interleaved
8025 macPdcchCfg->cRSetToAddModList[cRsetIdx].precoderGranularity = \
8026 cRsetToAddModList->list.array[cRsetIdx]->precoderGranularity;
8027 if(cRsetToAddModList->list.array[cRsetIdx]->pdcch_DMRS_ScramblingID)
8029 macPdcchCfg->cRSetToAddModList[cRsetIdx].dmrsScramblingId= \
8030 *(cRsetToAddModList->list.array[cRsetIdx]->pdcch_DMRS_ScramblingID);
8036 /* Control Resource Set To Release List */
8037 if(cuPdcchCfg->controlResourceSetToReleaseList)
8039 cRsetToRelList = cuPdcchCfg->controlResourceSetToReleaseList;
8040 if(cRsetToRelList->list.count)
8042 macPdcchCfg->numCRsetToRel = cRsetToRelList->list.count;
8043 for(cRsetIdx = 0; cRsetIdx < cRsetToRelList->list.count; cRsetIdx++)
8045 macPdcchCfg->cRSetToRelList[cRsetIdx] = *(cRsetToRelList->list.array[cRsetIdx]);
8050 /* Search space To Add/Mod List */
8051 if(cuPdcchCfg->searchSpacesToAddModList)
8053 srchSpcToAddModList = cuPdcchCfg->searchSpacesToAddModList;
8054 if(srchSpcToAddModList->list.count)
8056 macPdcchCfg->numSearchSpcToAddMod = srchSpcToAddModList->list.count;
8057 for(srchSpcIdx = 0; srchSpcIdx < srchSpcToAddModList->list.count; srchSpcIdx++)
8059 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceId =\
8060 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceId;
8061 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].cRSetId =\
8062 *(srchSpcToAddModList->list.array[srchSpcIdx]->controlResourceSetId);
8063 if(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSlotPeriodicityAndOffset)
8065 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].mSlotPeriodicityAndOffset =\
8066 srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSlotPeriodicityAndOffset->present;
8068 if(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSymbolsWithinSlot)
8070 bitStringToInt(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSymbolsWithinSlot,\
8071 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].mSymbolsWithinSlot);
8073 if(srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates)
8075 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel1 = \
8076 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel1;
8077 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel2 = \
8078 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel2;
8079 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel4 = \
8080 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel4;
8082 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel8 = \
8083 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel8;
8085 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel16 = \
8086 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel16;
8088 if(srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType)
8090 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceType =\
8091 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType->present;
8092 if(macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceType == SEARCHSPACETYPE_PR_UE_SPECIFIC)
8094 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].ueSpecificDciFormat =\
8095 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType->choice.ue_Specific->dci_Formats;
8102 /* Search space To Rel List */
8103 if(cuPdcchCfg->searchSpacesToReleaseList)
8105 srchSpcToRelList = cuPdcchCfg->searchSpacesToReleaseList;
8106 if(srchSpcToRelList->list.count)
8108 macPdcchCfg->numSearchSpcToRel = srchSpcToRelList->list.count;
8109 for(srchSpcIdx = 0; srchSpcIdx < srchSpcToRelList->list.count; srchSpcIdx++)
8111 macPdcchCfg->searchSpcToRelList[srchSpcIdx] =\
8112 *(srchSpcToRelList->list.array[srchSpcIdx]);
8118 /*******************************************************************
8120 * @brief Fills PdschCfg received by CU
8124 * Function : extractPdschCfg
8126 * Functionality: Fills PdschCfg received by CU
8128 * @params[in] PDSCH_Config_t *cuPdschCfg,
8129 * PdschConfig *macPdschCfg
8132 * ****************************************************************/
8134 void extractPdschCfg(PDSCH_Config_t *cuPdschCfg, PdschConfig *macPdschCfg)
8137 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAlloc = NULLP;
8139 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
8141 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->present == \
8142 PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA_PR_setup)
8144 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)
8146 macPdschCfg->dmrsDlCfgForPdschMapTypeA.addPos = \
8147 *(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition);
8151 macPdschCfg->resourceAllocType = cuPdschCfg->resourceAllocation;
8152 if(cuPdschCfg->pdsch_TimeDomainAllocationList)
8154 timeDomAlloc = cuPdschCfg->pdsch_TimeDomainAllocationList;
8155 if(timeDomAlloc->present ==\
8156 PDSCH_Config__pdsch_TimeDomainAllocationList_PR_setup)
8158 if(timeDomAlloc->choice.setup)
8160 macPdschCfg->numTimeDomRsrcAlloc = timeDomAlloc->choice.setup->list.count;
8161 for(timeDomIdx = 0; timeDomIdx < timeDomAlloc->choice.setup->list.count; timeDomIdx++)
8163 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0 = NULLP;
8164 if(timeDomAlloc->choice.setup->list.array[timeDomIdx]->k0)
8166 if(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0 == NULL)
8168 DU_ALLOC_SHRABL_BUF(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0, sizeof(uint8_t));
8169 if(!macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0)
8171 DU_LOG("\nERROR --> DU APP : Memory allocation failed for k0 at extractPdschCfg()");
8175 *(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0) = \
8176 *(timeDomAlloc->choice.setup->list.array[timeDomIdx]->k0);
8178 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].mappingType = \
8179 timeDomAlloc->choice.setup->list.array[timeDomIdx]->mappingType;
8180 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].startSymbolAndLength = \
8181 timeDomAlloc->choice.setup->list.array[timeDomIdx]->startSymbolAndLength;
8186 macPdschCfg->rbgSize = cuPdschCfg->rbg_Size;
8187 if(cuPdschCfg->maxNrofCodeWordsScheduledByDCI)
8188 macPdschCfg->numCodeWordsSchByDci = *(cuPdschCfg->maxNrofCodeWordsScheduledByDCI);
8189 if(cuPdschCfg->prb_BundlingType.present == PDSCH_Config__prb_BundlingType_PR_staticBundling)
8191 macPdschCfg->bundlingType = cuPdschCfg->prb_BundlingType.present;
8192 if(cuPdschCfg->prb_BundlingType.choice.staticBundling)
8194 if(cuPdschCfg->prb_BundlingType.choice.staticBundling->bundleSize)
8196 macPdschCfg->bundlingInfo.StaticBundling.size = \
8197 *(cuPdschCfg->prb_BundlingType.choice.staticBundling->bundleSize);
8201 else if(cuPdschCfg->prb_BundlingType.present == PDSCH_Config__prb_BundlingType_PR_dynamicBundling)
8203 macPdschCfg->bundlingType = cuPdschCfg->prb_BundlingType.present;
8208 /*******************************************************************
8210 * @brief Fills PdschServingCellCfg received by CU
8214 * Function : extractPdschServingCellCfg
8216 * Functionality: Fills PdschCfg received by CU
8218 * @params[in] PDSCH_ServingCellConfig_t *cuPdschSrvCellCfg,
8219 * PdschServCellCfg *macUePdschSrvCellCfg
8220 * @return ROK/RFAILED
8222 * ****************************************************************/
8224 uint8_t extractPdschServingCellCfg(PDSCH_ServingCellConfig_t *cuPdschSrvCellCfg, PdschServCellCfg *macUePdschSrvCellCfg)
8226 if(cuPdschSrvCellCfg->codeBlockGroupTransmission)
8228 if(cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup)
8230 if(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb)
8232 *(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb) = \
8233 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock;
8237 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
8238 if(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb)
8240 *(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb) = \
8241 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock;
8245 DU_LOG("\nERROR --> DU APP : Memory allocation failed for maxCodeBlkGrpPerTb at extractPdschServingCellCfg()");
8249 if(macUePdschSrvCellCfg->codeBlkGrpFlushInd)
8251 *(macUePdschSrvCellCfg->codeBlkGrpFlushInd) = \
8252 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->codeBlockGroupFlushIndicator;
8256 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->codeBlkGrpFlushInd , sizeof(bool));
8257 if(macUePdschSrvCellCfg->codeBlkGrpFlushInd)
8259 *(macUePdschSrvCellCfg->codeBlkGrpFlushInd) = \
8260 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->codeBlockGroupFlushIndicator;
8264 DU_LOG("\nERROR --> DU APP : Memory allocation failed for codeBlkGrpFlushInd at extractPdschServingCellCfg()");
8270 if(cuPdschSrvCellCfg->nrofHARQ_ProcessesForPDSCH)
8272 macUePdschSrvCellCfg->numHarqProcForPdsch = *(cuPdschSrvCellCfg->nrofHARQ_ProcessesForPDSCH);
8274 if(cuPdschSrvCellCfg->ext1)
8276 if(cuPdschSrvCellCfg->ext1->maxMIMO_Layers)
8278 if(macUePdschSrvCellCfg->maxMimoLayers)
8280 *(macUePdschSrvCellCfg->maxMimoLayers) = *(cuPdschSrvCellCfg->ext1->maxMIMO_Layers);
8284 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->maxMimoLayers, sizeof(uint8_t));
8285 if(macUePdschSrvCellCfg->maxMimoLayers)
8287 *(macUePdschSrvCellCfg->maxMimoLayers) = *(cuPdschSrvCellCfg->ext1->maxMIMO_Layers);
8291 DU_LOG("\nERROR --> DU APP : Memory allocation failed for maxMimoLayers at extractPdschServingCellCfg()");
8297 if(cuPdschSrvCellCfg->xOverhead)
8299 if(macUePdschSrvCellCfg->xOverhead)
8301 *(macUePdschSrvCellCfg->xOverhead) = *(cuPdschSrvCellCfg->xOverhead);
8305 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->xOverhead, sizeof(PdschXOverhead));
8306 if(macUePdschSrvCellCfg->xOverhead)
8308 *(macUePdschSrvCellCfg->xOverhead) = *(cuPdschSrvCellCfg->xOverhead);
8312 DU_LOG("\nERROR --> DU APP : Memory allocation failed for xOverhead at extractPdschServingCellCfg()");
8320 /*******************************************************************
8322 * @brief Fills PuschCfg received by CU
8326 * Function : extractPuschCfg
8328 * Functionality: Fills PuschCfg received by CU
8330 * @params[in] BWP_UplinkDedicated__pusch_Config *cuPuschCfg,
8331 * PuschCfg *macPuschCfg
8334 * ****************************************************************/
8336 void extractPuschCfg(struct BWP_UplinkDedicated__pusch_Config *cuPuschCfg, PuschCfg *macPuschCfg)
8338 uint8_t timeDomIdx = 0;
8339 DMRS_UplinkConfig_t *dmrsUlCfg = NULLP;
8340 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList = NULLP;
8342 if(cuPuschCfg->present == BWP_UplinkDedicated__pusch_Config_PR_setup)
8344 if(cuPuschCfg->choice.setup)
8346 if(cuPuschCfg->choice.setup->dataScramblingIdentityPUSCH)
8348 macPuschCfg->dataScramblingId = \
8349 *(cuPuschCfg->choice.setup->dataScramblingIdentityPUSCH);
8351 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA)
8353 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->present == PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA_PR_setup)
8355 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup)
8357 dmrsUlCfg = (cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup);
8358 if(dmrsUlCfg->dmrs_AdditionalPosition)
8360 macPuschCfg->dmrsUlCfgForPuschMapTypeA.addPos =\
8361 *(dmrsUlCfg->dmrs_AdditionalPosition);
8363 if(dmrsUlCfg->transformPrecodingDisabled)
8365 if(dmrsUlCfg->transformPrecodingDisabled->scramblingID0)
8367 macPuschCfg->dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0 = \
8368 *(dmrsUlCfg->transformPrecodingDisabled->scramblingID0);
8374 /*Res Alloc Type for UL */
8375 if(cuPuschCfg->choice.setup->resourceAllocation)
8377 macPuschCfg->resourceAllocType = \
8378 cuPuschCfg->choice.setup->resourceAllocation;
8380 if(cuPuschCfg->choice.setup->pusch_TimeDomainAllocationList)
8382 timeDomAllocList = cuPuschCfg->choice.setup->pusch_TimeDomainAllocationList;
8383 if(timeDomAllocList->present == PUSCH_Config__pusch_TimeDomainAllocationList_PR_setup)
8385 if(timeDomAllocList->choice.setup)
8387 macPuschCfg->numTimeDomRsrcAlloc = timeDomAllocList->choice.setup->list.count;
8388 for(timeDomIdx = 0; timeDomIdx <timeDomAllocList->choice.setup->list.count; timeDomIdx++)
8390 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].k2 = \
8391 *(timeDomAllocList->choice.setup->list.array[timeDomIdx]->k2);
8392 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].mappingType = \
8393 timeDomAllocList->choice.setup->list.array[timeDomIdx]->mappingType;
8394 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].startSymbolAndLength = \
8395 timeDomAllocList->choice.setup->list.array[timeDomIdx]->startSymbolAndLength;
8400 if(cuPuschCfg->choice.setup->transformPrecoder)
8401 macPuschCfg->transformPrecoder = *(cuPuschCfg->choice.setup->transformPrecoder);
8406 /*******************************************************************
8408 * @brief Function to fill pucch Power Control
8412 * Function : extractPucchPowerControl
8414 * Functionality: Function to fill pucch Power Control
8416 * @params[in] PucchPowerControl *pwrCtrl,
8417 * struct PUCCH_PowerControl *cuPwrCtrlCfg
8420 * ****************************************************************/
8422 void extractPucchPowerControl(PucchPowerControl *pwrCtrl, struct PUCCH_PowerControl *cuPwrCtrlCfg)
8426 if(cuPwrCtrlCfg->deltaF_PUCCH_f0)
8427 pwrCtrl->deltaF_Format0 = *cuPwrCtrlCfg->deltaF_PUCCH_f0;
8428 if(cuPwrCtrlCfg->deltaF_PUCCH_f1)
8429 pwrCtrl->deltaF_Format1 = *cuPwrCtrlCfg->deltaF_PUCCH_f1;
8430 if(cuPwrCtrlCfg->deltaF_PUCCH_f2)
8431 pwrCtrl->deltaF_Format2 = *cuPwrCtrlCfg->deltaF_PUCCH_f2;
8432 if(cuPwrCtrlCfg->deltaF_PUCCH_f3)
8433 pwrCtrl->deltaF_Format3 = *cuPwrCtrlCfg->deltaF_PUCCH_f3;
8434 if(cuPwrCtrlCfg->deltaF_PUCCH_f4)
8435 pwrCtrl->deltaF_Format4 = *cuPwrCtrlCfg->deltaF_PUCCH_f4;
8436 if(cuPwrCtrlCfg->p0_Set)
8438 pwrCtrl->p0SetCount = cuPwrCtrlCfg->p0_Set->list.count;
8439 for(arrIdx=0; arrIdx < pwrCtrl->p0SetCount; arrIdx++)
8441 pwrCtrl->p0Set[arrIdx].p0PucchId =\
8442 cuPwrCtrlCfg->p0_Set->list.array[arrIdx]->p0_PUCCH_Id;
8443 pwrCtrl->p0Set[arrIdx].p0PucchVal =\
8444 cuPwrCtrlCfg->p0_Set->list.array[arrIdx]->p0_PUCCH_Value;
8447 if(cuPwrCtrlCfg->pathlossReferenceRSs)
8449 pwrCtrl->pathLossRefRSListCount = cuPwrCtrlCfg->pathlossReferenceRSs->list.count;
8450 for(arrIdx = 0; arrIdx < pwrCtrl->pathLossRefRSListCount; arrIdx++)
8452 pwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId =\
8453 cuPwrCtrlCfg->pathlossReferenceRSs->list.array[arrIdx]->pucch_PathlossReferenceRS_Id;
8458 /*******************************************************************
8460 * @brief Function to extractResrcSetToAddModList sent by CU
8464 * Function : extractResrcSetToAddModList
8466 * Functionality: Fucntion to extractResrcSetToAddModList
8468 * @params[in] PucchResrcSetCfg pointer,
8469 * struct PUCCH_Config__resourceSetToAddModList pointer
8472 * ****************************************************************/
8474 void extractResrcSetToAddModList(PucchResrcSetCfg *macRsrcSetList, struct PUCCH_Config__resourceSetToAddModList *cuRsrcSetList)
8476 uint8_t arrIdx, rsrcListIdx;
8478 macRsrcSetList->resrcSetToAddModListCount = cuRsrcSetList->list.count;
8479 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToAddModListCount; arrIdx++)
8481 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId =\
8482 cuRsrcSetList->list.array[arrIdx]->pucch_ResourceSetId;
8483 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount =\
8484 cuRsrcSetList->list.array[arrIdx]->resourceList.list.count;
8485 for(rsrcListIdx = 0; rsrcListIdx < macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount; rsrcListIdx++)
8487 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx] =\
8488 *cuRsrcSetList->list.array[arrIdx]->resourceList.list.array[rsrcListIdx];
8490 macRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize =\
8491 *cuRsrcSetList->list.array[arrIdx]->maxPayloadMinus1;
8493 }/* End of extractResrcSetToAddModList */
8495 /*******************************************************************
8497 * @brief Fills extractResrcToAddModList sent by CU
8501 * Function : extractResrcToAddModList
8503 * Functionality: Fills extractResrcToAddModList
8505 * @params[in] PucchResrcCfg pointer,
8506 * struct PUCCH_Config__resourceToAddModList pointer
8507 * @return ROk/RFAILED
8509 * ****************************************************************/
8511 uint8_t extractResrcToAddModList(PucchResrcCfg *macResrcList, struct PUCCH_Config__resourceToAddModList *cuResrcList)
8515 macResrcList->resrcToAddModListCount = cuResrcList->list.count;
8516 for(arrIdx = 0; arrIdx < macResrcList->resrcToAddModListCount; arrIdx++)
8518 macResrcList->resrcToAddModList[arrIdx].resrcId =\
8519 cuResrcList->list.array[arrIdx]->pucch_ResourceId;
8520 macResrcList->resrcToAddModList[arrIdx].startPrb =\
8521 cuResrcList->list.array[arrIdx]->startingPRB;
8522 if(cuResrcList->list.array[arrIdx]->intraSlotFrequencyHopping)
8524 macResrcList->resrcToAddModList[arrIdx].intraFreqHop =\
8525 *cuResrcList->list.array[arrIdx]->intraSlotFrequencyHopping;
8527 if(cuResrcList->list.array[arrIdx]->secondHopPRB)
8529 macResrcList->resrcToAddModList[arrIdx].secondPrbHop =\
8530 *cuResrcList->list.array[arrIdx]->secondHopPRB;
8532 /* PUCCH RSRC FORMAT */
8533 if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format0)
8535 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_0;
8536 if(cuResrcList->list.array[arrIdx]->format.choice.format0)
8538 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0, sizeof(PucchFormat0));
8539 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0 == NULLP)
8541 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format0 in extractResrcToAddModList()");
8544 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->initialCyclicShift =\
8545 cuResrcList->list.array[arrIdx]->format.choice.format0->initialCyclicShift;
8546 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->numSymbols =\
8547 cuResrcList->list.array[arrIdx]->format.choice.format0->nrofSymbols;
8548 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->startSymbolIdx =\
8549 cuResrcList->list.array[arrIdx]->format.choice.format0->startingSymbolIndex;
8552 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format1)
8554 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_1;
8555 if(cuResrcList->list.array[arrIdx]->format.choice.format1)
8557 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1, sizeof(PucchFormat1));
8558 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1 == NULLP)
8560 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format1 in extractResrcToAddModList()");
8563 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->initialCyclicShift =\
8564 cuResrcList->list.array[arrIdx]->format.choice.format1->initialCyclicShift;
8565 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->numSymbols =\
8566 cuResrcList->list.array[arrIdx]->format.choice.format1->nrofSymbols;
8567 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->startSymbolIdx =\
8568 cuResrcList->list.array[arrIdx]->format.choice.format1->startingSymbolIndex;
8569 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->timeDomOCC =\
8570 cuResrcList->list.array[arrIdx]->format.choice.format1->timeDomainOCC;
8573 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format2)
8575 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_2;
8576 if(cuResrcList->list.array[arrIdx]->format.choice.format2)
8578 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2, sizeof(PucchFormat2_3));
8579 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2 == NULLP)
8581 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format2 in extractResrcToAddModList()");
8584 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->numPrbs =\
8585 cuResrcList->list.array[arrIdx]->format.choice.format2->nrofPRBs;
8586 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->numSymbols =\
8587 cuResrcList->list.array[arrIdx]->format.choice.format2->nrofSymbols;
8588 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->startSymbolIdx =\
8589 cuResrcList->list.array[arrIdx]->format.choice.format2->startingSymbolIndex;
8592 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format3)
8594 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_3;
8595 if(cuResrcList->list.array[arrIdx]->format.choice.format3)
8597 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3, sizeof(PucchFormat2_3));
8598 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3 == NULLP)
8600 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format3 in extractResrcToAddModList()");
8603 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->numPrbs =\
8604 cuResrcList->list.array[arrIdx]->format.choice.format3->nrofPRBs;
8605 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->numSymbols =\
8606 cuResrcList->list.array[arrIdx]->format.choice.format3->nrofSymbols;
8607 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->startSymbolIdx =\
8608 cuResrcList->list.array[arrIdx]->format.choice.format3->startingSymbolIndex;
8611 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format4)
8613 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_4;
8614 if(cuResrcList->list.array[arrIdx]->format.choice.format4)
8616 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4, sizeof(PucchFormat4));
8617 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4 == NULLP)
8619 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format4 in extractResrcToAddModList()");
8622 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->numSymbols =\
8623 cuResrcList->list.array[arrIdx]->format.choice.format4->nrofSymbols;
8624 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->occLen =\
8625 cuResrcList->list.array[arrIdx]->format.choice.format4->occ_Length;
8626 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->occIdx =\
8627 cuResrcList->list.array[arrIdx]->format.choice.format4->occ_Index;
8628 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->startSymbolIdx =\
8629 cuResrcList->list.array[arrIdx]->format.choice.format4->startingSymbolIndex;
8635 }/* End of extractResrcToAddModList */
8637 /*******************************************************************
8639 * @brief Fills fillPucchSchedReqPeriodAndOffset sent by CU
8643 * Function : fillPucchSchedReqPeriodAndOffset
8645 * Functionality: To fillPucchSchedReqPeriodAndOffset
8647 * @params[in] macPeriodicty,
8648 * SchedulingRequestResourceConfig__periodicityAndOffset pointer
8651 * ****************************************************************/
8653 void fillPucchSchedReqPeriodAndOffset(uint8_t macPeriodicty, uint16_t macOffset,\
8654 struct SchedulingRequestResourceConfig__periodicityAndOffset *cuPeriodicty)
8656 macPeriodicty = cuPeriodicty->present;
8657 switch(macPeriodicty)
8659 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sym2:
8661 macOffset = cuPeriodicty->choice.sym2;
8664 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sym6or7:
8666 macOffset = cuPeriodicty->choice.sym6or7;
8669 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl1:
8671 macOffset = cuPeriodicty->choice.sl1;
8674 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl2:
8676 macOffset = cuPeriodicty->choice.sl2;
8679 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl4:
8681 macOffset = cuPeriodicty->choice.sl4;
8684 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl5:
8686 macOffset = cuPeriodicty->choice.sl5;
8689 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl8:
8691 macOffset = cuPeriodicty->choice.sl8;
8694 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl10:
8696 macOffset = cuPeriodicty->choice.sl10;
8699 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl16:
8701 macOffset = cuPeriodicty->choice.sl16;
8704 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl20:
8706 macOffset = cuPeriodicty->choice.sl20;
8709 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl40:
8711 macOffset = cuPeriodicty->choice.sl40;
8714 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl80:
8716 macOffset = cuPeriodicty->choice.sl80;
8719 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl160:
8721 macOffset = cuPeriodicty->choice.sl160;
8724 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl320:
8726 macOffset = cuPeriodicty->choice.sl320;
8729 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl640:
8731 macOffset = cuPeriodicty->choice.sl640;
8735 DU_LOG("\nERROR --> F1AP : Invalid periodicity %d", macPeriodicty);
8739 /*******************************************************************
8741 * @brief Function to extractPucchFormatCfg sent by CU
8745 * Function : extractPucchFormatCfg
8747 * Functionality: Function to extractPucchFormatCfg
8749 * @params[in] PucchFormatCfg pointer,
8750 * PUCCH_FormatConfig_t pointer
8753 * ****************************************************************/
8755 void extractPucchFormatCfg(PucchFormatCfg *macFormatCfg, PUCCH_FormatConfig_t *cuFormatCfg)
8757 if(cuFormatCfg->interslotFrequencyHopping)
8758 macFormatCfg->interSlotFreqHop = *cuFormatCfg->interslotFrequencyHopping;
8759 if(cuFormatCfg->additionalDMRS)
8760 macFormatCfg->addDmrs = *cuFormatCfg->additionalDMRS;
8761 if(cuFormatCfg->maxCodeRate)
8762 macFormatCfg->maxCodeRate = *cuFormatCfg->maxCodeRate;
8763 if(cuFormatCfg->nrofSlots)
8764 macFormatCfg->numSlots = *cuFormatCfg->nrofSlots;
8765 if(cuFormatCfg->pi2BPSK)
8766 macFormatCfg->pi2BPSK = *cuFormatCfg->pi2BPSK;
8767 if(cuFormatCfg->simultaneousHARQ_ACK_CSI)
8768 macFormatCfg->harqAckCSI = *cuFormatCfg->simultaneousHARQ_ACK_CSI;
8769 }/* End of extractPucchFormatCfg */
8771 /*******************************************************************
8773 * @brief Function to extractSchedReqCfgToAddMod sent by CU
8777 * Function : extractSchedReqCfgToAddMod
8779 * Functionality: Function to extractSchedReqCfgToAddMod
8781 * @params[in] PucchSchedReqCfg pointer,
8782 * PUCCH_Config__schedulingRequestResourceToAddModList pointer
8785 * ****************************************************************/
8787 void extractSchedReqCfgToAddMod(PucchSchedReqCfg *macSchedReqCfg, struct PUCCH_Config__schedulingRequestResourceToAddModList *cuSchedReqList)
8791 macSchedReqCfg->schedAddModListCount = cuSchedReqList->list.count;
8792 for(arrIdx = 0; arrIdx < macSchedReqCfg->schedAddModListCount; arrIdx++)
8794 macSchedReqCfg->schedAddModList[arrIdx].resrcId =\
8795 cuSchedReqList->list.array[arrIdx]->schedulingRequestResourceId;
8796 macSchedReqCfg->schedAddModList[arrIdx].requestId =\
8797 cuSchedReqList->list.array[arrIdx]->schedulingRequestID;
8798 if(cuSchedReqList->list.array[arrIdx]->periodicityAndOffset)
8800 fillPucchSchedReqPeriodAndOffset(macSchedReqCfg->schedAddModList[arrIdx].periodicity,\
8801 macSchedReqCfg->schedAddModList[arrIdx].offset, cuSchedReqList->list.array[arrIdx]->periodicityAndOffset);
8803 if(cuSchedReqList->list.array[arrIdx]->resource)
8805 macSchedReqCfg->schedAddModList[arrIdx].resrc =\
8806 *cuSchedReqList->list.array[arrIdx]->resource;
8810 }/* End of extractSchedReqCfgToAddMod */
8812 /*******************************************************************
8814 * @brief Fills PucchCfg received by CU
8818 * Function : extractPucchCfg
8820 * Functionality: Fills PucchCfg received by CU
8822 * @params[in] BWP_UplinkDedicated__pucch_Config *cuPucchCfg,
8823 * PucchCfg *macPucchCfg
8824 * @return ROK/RFAILED
8826 * ****************************************************************/
8828 uint8_t extractPucchCfg(struct BWP_UplinkDedicated__pucch_Config *cuPucchCfg, PucchCfg *macPucchCfg)
8832 if(cuPucchCfg->present == BWP_UplinkDedicated__pucch_Config_PR_setup)
8834 if(cuPucchCfg->choice.setup)
8836 /* Resource Set Cfg */
8837 if(cuPucchCfg->choice.setup->resourceSetToAddModList)
8839 DU_ALLOC_SHRABL_BUF(macPucchCfg->resrcSet, sizeof(PucchResrcSetCfg));
8840 if(macPucchCfg->resrcSet == NULLP)
8842 DU_LOG("\nERROR --> F1AP : Failed to extract Resrc set List in extractPucchCfg()");
8845 memset(macPucchCfg->resrcSet, 0, sizeof(PucchResrcSetCfg));
8846 extractResrcSetToAddModList(macPucchCfg->resrcSet, cuPucchCfg->choice.setup->resourceSetToAddModList);
8850 if(cuPucchCfg->choice.setup->resourceToAddModList)
8852 DU_ALLOC_SHRABL_BUF(macPucchCfg->resrc, sizeof(PucchResrcCfg));
8853 if(macPucchCfg->resrc == NULLP)
8855 DU_LOG("\nERROR --> F1AP : Failed to extract Resrc List in extractPucchCfg()");
8858 memset(macPucchCfg->resrc, 0, sizeof(PucchResrcCfg));
8859 extractResrcToAddModList(macPucchCfg->resrc, cuPucchCfg->choice.setup->resourceToAddModList);
8863 if(cuPucchCfg->choice.setup->format1)
8865 DU_ALLOC_SHRABL_BUF(macPucchCfg->format1, sizeof(PucchFormatCfg));
8866 if(macPucchCfg->format1 == NULLP)
8868 DU_LOG("\nERROR --> F1AP : Failed to extract format 1 Cfg in extractPucchCfg()");
8871 memset(macPucchCfg->format1, 0, sizeof(PucchFormatCfg));
8872 extractPucchFormatCfg(macPucchCfg->format1,\
8873 cuPucchCfg->choice.setup->format1->choice.setup);
8877 if(cuPucchCfg->choice.setup->format2)
8879 DU_ALLOC_SHRABL_BUF(macPucchCfg->format2, sizeof(PucchFormatCfg));
8880 if(macPucchCfg->format2 == NULLP)
8882 DU_LOG("\nERROR --> F1AP : Failed to extract format 2 Cfg in extractPucchCfg()");
8885 memset(macPucchCfg->format2, 0, sizeof(PucchFormatCfg));
8886 extractPucchFormatCfg(macPucchCfg->format2,\
8887 cuPucchCfg->choice.setup->format2->choice.setup);
8891 if(cuPucchCfg->choice.setup->format3)
8893 DU_ALLOC_SHRABL_BUF(macPucchCfg->format3, sizeof(PucchFormatCfg));
8894 if(macPucchCfg->format3 == NULLP)
8896 DU_LOG("\nERROR --> F1AP : Failed to extract format 3 Cfg in extractPucchCfg()");
8899 memset(macPucchCfg->format3, 0, sizeof(PucchFormatCfg));
8900 extractPucchFormatCfg(macPucchCfg->format3,\
8901 cuPucchCfg->choice.setup->format3->choice.setup);
8905 if(cuPucchCfg->choice.setup->format4)
8907 DU_ALLOC_SHRABL_BUF(macPucchCfg->format4, sizeof(PucchFormatCfg));
8908 if(macPucchCfg->format4 == NULLP)
8910 DU_LOG("\nERROR --> F1AP : Failed to extract format 4 Cfg in extractPucchCfg()");
8913 memset(macPucchCfg->format4, 0, sizeof(PucchFormatCfg));
8914 extractPucchFormatCfg(macPucchCfg->format4,\
8915 cuPucchCfg->choice.setup->format4->choice.setup);
8918 /* Sched Req List */
8919 if(cuPucchCfg->choice.setup->schedulingRequestResourceToAddModList)
8921 DU_ALLOC_SHRABL_BUF(macPucchCfg->schedReq, sizeof(PucchSchedReqCfg));
8922 if(macPucchCfg->schedReq == NULLP)
8924 DU_LOG("\nERROR --> F1AP : Failed to extract schedReqCfg in extractPucchCfg()");
8927 memset(macPucchCfg->schedReq, 0, sizeof(PucchSchedReqCfg));
8928 extractSchedReqCfgToAddMod(macPucchCfg->schedReq,\
8929 cuPucchCfg->choice.setup->schedulingRequestResourceToAddModList);
8932 /*TODO: Add support for Spatial Info */
8935 if(cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList)
8937 DU_ALLOC_SHRABL_BUF(macPucchCfg->multiCsiCfg, sizeof(PucchMultiCsiCfg));
8938 if(macPucchCfg->multiCsiCfg == NULLP)
8940 DU_LOG("\nERROR --> F1AP : Failed to extract multiCsiCfg in extractPucchCfg()");
8943 memset(macPucchCfg->multiCsiCfg, 0, sizeof(PucchMultiCsiCfg));
8944 macPucchCfg->multiCsiCfg->multiCsiResrcListCount = cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList->list.count;
8945 for(arrIdx =0; arrIdx < macPucchCfg->multiCsiCfg->multiCsiResrcListCount; arrIdx++)
8947 macPucchCfg->multiCsiCfg->multiCsiResrcList[arrIdx] =\
8948 *cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList->list.array[arrIdx];
8952 /* Dl_DataToUL_ACK */
8953 if(cuPucchCfg->choice.setup->dl_DataToUL_ACK)
8955 DU_ALLOC_SHRABL_BUF(macPucchCfg->dlDataToUlAck, sizeof(PucchDlDataToUlAck));
8956 if(macPucchCfg->dlDataToUlAck == NULLP)
8958 DU_LOG("\nERROR --> F1AP : Failed to extract Dl_DataToUL_ACK in extractPucchCfg()");
8961 memset(macPucchCfg->dlDataToUlAck, 0, sizeof(PucchDlDataToUlAck));
8962 macPucchCfg->dlDataToUlAck->dlDataToUlAckListCount = cuPucchCfg->choice.setup->dl_DataToUL_ACK->list.count;
8963 for(arrIdx = 0; arrIdx < macPucchCfg->dlDataToUlAck->dlDataToUlAckListCount; arrIdx++)
8965 macPucchCfg->dlDataToUlAck->dlDataToUlAckList[arrIdx] =\
8966 *cuPucchCfg->choice.setup->dl_DataToUL_ACK->list.array[arrIdx];
8971 if(cuPucchCfg->choice.setup->pucch_PowerControl)
8973 DU_ALLOC_SHRABL_BUF(macPucchCfg->powerControl, sizeof(PucchPowerControl));
8974 if(macPucchCfg->powerControl == NULLP)
8976 DU_LOG("\nERROR --> F1AP : Failed to extract power control in extractPucchCfg()");
8979 extractPucchPowerControl(macPucchCfg->powerControl,\
8980 cuPucchCfg->choice.setup->pucch_PowerControl);
8987 /*******************************************************************
8989 * @brief Fills ServingCellReconfig received by CU
8993 * Function : extractSpCellDedicatedCfg
8995 * Functionality: Fills ServingCellReconfig received by CU
8997 * @params[in] ServingCellConfig_t *cuSrvCellCfg
8998 * ServCellCfgInfo *macSrvCellCfg
8999 * @return ROK/RFAILD
9001 * ****************************************************************/
9002 uint8_t extractSpCellDedicatedCfg(ServingCellConfig_t *cuSrvCellCfg, ServCellCfgInfo *macSrvCellCfg)
9005 BWP_DownlinkDedicated_t *dlBwp = NULLP;
9006 BWP_UplinkDedicated_t *ulBwp = NULLP;
9008 if(cuSrvCellCfg->initialDownlinkBWP)
9010 dlBwp = ((BWP_DownlinkDedicated_t *)(cuSrvCellCfg->initialDownlinkBWP));
9011 if(dlBwp->pdcch_Config)
9013 if(dlBwp->pdcch_Config->choice.setup)
9015 macSrvCellCfg->initDlBwp.pdcchPresent = true;
9016 extractPdcchCfg(dlBwp->pdcch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdcchCfg);
9019 if(dlBwp->pdsch_Config)
9021 if(dlBwp->pdsch_Config->choice.setup)
9023 macSrvCellCfg->initDlBwp.pdschPresent = true;
9024 extractPdschCfg(dlBwp->pdsch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdschCfg);
9028 if(cuSrvCellCfg->firstActiveDownlinkBWP_Id)
9029 macSrvCellCfg->firstActvDlBwpId = *(cuSrvCellCfg->firstActiveDownlinkBWP_Id);
9030 if(cuSrvCellCfg->defaultDownlinkBWP_Id)
9031 macSrvCellCfg->defaultDlBwpId = *(cuSrvCellCfg->defaultDownlinkBWP_Id);
9032 if(cuSrvCellCfg->bwp_InactivityTimer)
9034 if(macSrvCellCfg->bwpInactivityTmr)
9036 memcpy(macSrvCellCfg->bwpInactivityTmr, cuSrvCellCfg->bwp_InactivityTimer, sizeof(uint8_t));
9040 macSrvCellCfg->bwpInactivityTmr = NULLP;
9041 DU_ALLOC_SHRABL_BUF(macSrvCellCfg->bwpInactivityTmr, sizeof(uint8_t));
9042 if(macSrvCellCfg->bwpInactivityTmr)
9044 memcpy(macSrvCellCfg->bwpInactivityTmr, cuSrvCellCfg->bwp_InactivityTimer, sizeof(uint8_t));
9048 DU_LOG("\nERROR --> F1AP : Memory Alloc failed for bwpInactivityTmr at extractSpCellDedicatedCfg()");
9053 if(cuSrvCellCfg->pdsch_ServingCellConfig)
9055 if(cuSrvCellCfg->pdsch_ServingCellConfig->choice.setup)
9057 ret = extractPdschServingCellCfg(cuSrvCellCfg->pdsch_ServingCellConfig->choice.setup, &macSrvCellCfg->pdschServCellCfg);
9060 DU_LOG("\nERROR --> F1AP : Failed at extractPdschServingCellCfg()");
9065 if(cuSrvCellCfg->uplinkConfig)
9067 if(cuSrvCellCfg->uplinkConfig->initialUplinkBWP)
9069 ulBwp = ((BWP_UplinkDedicated_t *)(cuSrvCellCfg->uplinkConfig->initialUplinkBWP));
9070 if(ulBwp->pusch_Config)
9072 macSrvCellCfg->initUlBwp.puschPresent = true;
9073 extractPuschCfg(ulBwp->pusch_Config, &macSrvCellCfg->initUlBwp.puschCfg);
9075 if(ulBwp->pucch_Config)
9077 macSrvCellCfg->initUlBwp.pucchPresent = true;
9078 memset(&macSrvCellCfg->initUlBwp.pucchCfg, 0, sizeof(PucchCfg));
9079 extractPucchCfg(ulBwp->pucch_Config, &macSrvCellCfg->initUlBwp.pucchCfg);
9082 if(cuSrvCellCfg->uplinkConfig->firstActiveUplinkBWP_Id)
9083 macSrvCellCfg->firstActvUlBwpId = *(cuSrvCellCfg->uplinkConfig->firstActiveUplinkBWP_Id);
9087 /*******************************************************************
9089 * @brief Fills Reconfig Cell group Info received by CU
9093 * Function : extractUeReCfgCellInfo
9095 * Functionality: Fills Reconfig Cell group Info received by CU
9097 * @params[in] CellGroupConfigRrc_t *macCellGrpCfg
9098 * MacUeCfg* macUeCfg
9099 * @return ROK/RFAILED
9101 * ****************************************************************/
9102 uint8_t extractUeReCfgCellInfo(CellGroupConfigRrc_t *cellGrp, MacUeCfg *macUeCfg)
9105 MAC_CellGroupConfig_t *macCellGroup = NULLP;
9106 PhysicalCellGroupConfig_t *phyCellGrpCfg = NULLP;
9107 SpCellConfig_t *spcellCfg = NULLP;
9108 ServingCellConfig_t *servCellCfg = NULLP;
9112 /* Fill MacCell Group Reconfig */
9113 if(cellGrp->mac_CellGroupConfig)
9115 macUeCfg->macCellGrpCfgPres = true;
9116 macCellGroup = ((MAC_CellGroupConfig_t *)(cellGrp->mac_CellGroupConfig));
9117 if(macCellGroup->schedulingRequestConfig)
9119 extractSchReqReConfig(macCellGroup->schedulingRequestConfig, &macUeCfg->macCellGrpCfg.schReqCfg);
9121 if(macCellGroup->tag_Config)
9123 extractTagReconfig(macCellGroup->tag_Config, &macUeCfg->macCellGrpCfg.tagCfg);
9125 if(macCellGroup->bsr_Config)
9127 macUeCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer = macCellGroup->bsr_Config->periodicBSR_Timer;
9128 macUeCfg->macCellGrpCfg.bsrTmrCfg.retxTimer = macCellGroup->bsr_Config->retxBSR_Timer;
9129 if(macCellGroup->bsr_Config->logicalChannelSR_DelayTimer)
9131 macUeCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer =\
9132 *(macCellGroup->bsr_Config->logicalChannelSR_DelayTimer);
9135 if(macCellGroup->phr_Config)
9137 if(macCellGroup->phr_Config->present == MAC_CellGroupConfig__phr_Config_PR_setup)
9139 macUeCfg->macCellGrpCfg.phrCfgSetupPres = true;
9140 if(macCellGroup->phr_Config->choice.setup)
9142 macUeCfg->macCellGrpCfg.phrCfg.periodicTimer = \
9143 macCellGroup->phr_Config->choice.setup->phr_PeriodicTimer;
9144 macUeCfg->macCellGrpCfg.phrCfg.prohibitTimer = \
9145 macCellGroup->phr_Config->choice.setup->phr_ProhibitTimer;
9146 macUeCfg->macCellGrpCfg.phrCfg.txPowerFactor = \
9147 macCellGroup->phr_Config->choice.setup->phr_Tx_PowerFactorChange;
9148 macUeCfg->macCellGrpCfg.phrCfg.multiplePHR = \
9149 macCellGroup->phr_Config->choice.setup->multiplePHR;
9150 macUeCfg->macCellGrpCfg.phrCfg.dummy = \
9151 macCellGroup->phr_Config->choice.setup->dummy;
9152 macUeCfg->macCellGrpCfg.phrCfg.phrType2OtherCell = \
9153 macCellGroup->phr_Config->choice.setup->phr_Type2OtherCell;
9154 macUeCfg->macCellGrpCfg.phrCfg.phrOtherCG = \
9155 macCellGroup->phr_Config->choice.setup->phr_ModeOtherCG;
9160 /* Fill Physical Cell Group Reconfig */
9161 if(cellGrp->physicalCellGroupConfig)
9163 macUeCfg->phyCellGrpCfgPres = true;
9164 phyCellGrpCfg = ((PhysicalCellGroupConfig_t *)(cellGrp->physicalCellGroupConfig));
9165 if(phyCellGrpCfg->p_NR_FR1)
9167 if(*(phyCellGrpCfg->p_NR_FR1) != macUeCfg->phyCellGrpCfg.pNrFr1)
9168 macUeCfg->phyCellGrpCfg.pNrFr1 = *(phyCellGrpCfg->p_NR_FR1);
9170 macUeCfg->phyCellGrpCfg.pdschHarqAckCodebook = phyCellGrpCfg->pdsch_HARQ_ACK_Codebook;
9172 /* Fill SpCell Reconfig */
9173 if(cellGrp->spCellConfig)
9175 macUeCfg->spCellCfgPres = true;
9176 spcellCfg = ((SpCellConfig_t *)(cellGrp->spCellConfig));
9177 if(spcellCfg->servCellIndex)
9179 macUeCfg->spCellCfg.servCellIdx = *(spcellCfg->servCellIndex);
9181 /* Fill Serving cell Reconfig info */
9182 if(cellGrp->spCellConfig->spCellConfigDedicated)
9184 servCellCfg = ((ServingCellConfig_t *)(cellGrp->spCellConfig->spCellConfigDedicated));
9185 ret = extractSpCellDedicatedCfg(servCellCfg, &macUeCfg->spCellCfg.servCellCfg);
9188 DU_LOG("\nERROR --> F1AP : Failed at extractSpCellDedicatedCfg()");
9195 /*******************************************************************
9197 * @brief free the memory allocated by decoder
9201 * Function : freeAperDecodeNrcgi
9203 * Functionality: Free Nrcgi values
9205 * @params[in] NRCGI_t *nrcgi
9208 * ****************************************************************/
9211 void freeAperDecodeNrcgi(NRCGI_t *nrcgi)
9213 if(nrcgi->pLMN_Identity.buf != NULLP)
9215 free(nrcgi->pLMN_Identity.buf);
9217 if(nrcgi->nRCellIdentity.buf != NULLP)
9219 free(nrcgi->nRCellIdentity.buf);
9222 /*******************************************************************
9224 * @brief free the memory allocated by decoder
9228 * Function : freeAperDecodeCuToDuInfo
9230 * Functionality: Free Cu To Du Information
9232 * @params[in] CUtoDURRCInformation_t *rrcMsg
9235 * ****************************************************************/
9238 void freeAperDecodeCuToDuInfo(CUtoDURRCInformation_t *rrcMsg)
9243 if(rrcMsg->uE_CapabilityRAT_ContainerList)
9245 if(rrcMsg->uE_CapabilityRAT_ContainerList->buf)
9246 free(rrcMsg->uE_CapabilityRAT_ContainerList->buf);
9247 free(rrcMsg->uE_CapabilityRAT_ContainerList);
9250 if(rrcMsg->iE_Extensions)
9252 if(rrcMsg->iE_Extensions->list.array)
9254 for(ieIdx= 0; ieIdx < rrcMsg->iE_Extensions->list.count; ieIdx++)
9256 if(rrcMsg->iE_Extensions->list.array[ieIdx])
9258 switch(rrcMsg->iE_Extensions->list.array[ieIdx]->id)
9260 case ProtocolIE_ID_id_CellGroupConfig:
9261 if(rrcMsg->iE_Extensions->list.array[ieIdx]->extensionValue.choice.CellGroupConfig.buf != NULLP)
9263 free(rrcMsg->iE_Extensions->list.array[ieIdx]->extensionValue.choice.CellGroupConfig.buf);
9267 DU_LOG("\nERROR --> F1AP : Invalid Event type %ld at FreeCuToDuInfo()", \
9268 rrcMsg->iE_Extensions->list.array[ieIdx]->id);
9273 for(arrIdx = 0; arrIdx < ieIdx; arrIdx++)
9275 free(rrcMsg->iE_Extensions->list.array[arrIdx]);
9277 free(rrcMsg->iE_Extensions->list.array);
9281 free(rrcMsg->iE_Extensions);
9284 /*******************************************************************
9286 * @brief free the memory allocated by decoder
9290 * Function : freeAperDecodeSplCellList
9292 * Functionality: Free Spl Cell List
9293 where memory allocated by aper_decoder
9295 * @params[in] SCell_ToBeSetup_List_t *spCellLst
9298 * ****************************************************************/
9301 void freeAperDecodeSplCellList(SCell_ToBeSetup_List_t *spCellLst)
9305 if(spCellLst->list.array != NULLP)
9307 for(cellIdx=0; cellIdx<spCellLst->list.count; cellIdx++)
9309 if(cellIdx==0&&spCellLst->list.array[cellIdx]!=NULLP)
9311 freeAperDecodeNrcgi(&spCellLst->list.array[cellIdx]->value.choice.SCell_ToBeSetup_Item.sCell_ID);
9313 if(spCellLst->list.array[cellIdx]!=NULLP)
9315 free(spCellLst->list.array[cellIdx]);
9318 free(spCellLst->list.array);
9321 /*******************************************************************
9323 * @brief free the memory allocated by decoder
9327 * Function : freeAperDecodeSRBSetup
9329 * Functionality: added free part for the memory allocated by aper_decoder
9331 * @params[in] SRBs_ToBeSetup_List_t *srbSet
9334 ****************************************************************/
9337 void freeAperDecodeSRBSetup(SRBs_ToBeSetup_List_t *srbSet)
9340 if(srbSet->list.array != NULLP)
9342 for(srbIdx=0; srbIdx<srbSet->list.count; srbIdx++)
9344 if(srbSet->list.array[srbIdx]!=NULLP)
9346 free(srbSet->list.array[srbIdx]);
9349 free(srbSet->list.array);
9353 /*******************************************************************
9355 * @brief free the memory allocated by decoder
9359 * Function : freeAperDecodeULTnlInfo
9361 * Functionality: added free part for the memory allocated by aper_decoder
9363 * @params[in] ULUPTNLInformation_ToBeSetup_List_t *ulInfo
9366 * ****************************************************************/
9369 void freeAperDecodeULTnlInfo(ULUPTNLInformation_ToBeSetup_List_t *ulInfo)
9372 if(ulInfo->list.array != NULLP)
9374 for(ulIdx=0; ulIdx<ulInfo->list.count; ulIdx++)
9376 if(ulIdx==0&&ulInfo->list.array[ulIdx]!=NULLP)
9378 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel!=NULLP)
9380 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->\
9381 transportLayerAddress.buf != NULLP)
9383 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf\
9386 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf);
9388 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->\
9389 transportLayerAddress.buf);
9391 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel);
9394 if(ulInfo->list.array[ulIdx]!=NULLP)
9396 free(ulInfo->list.array[ulIdx]);
9399 free(ulInfo->list.array);
9402 /*******************************************************************
9404 * @brief free the memory allocated by decoder
9408 * Function : freeAperDecodeDRBSetup
9410 * Functionality: free DRBSetup which is allocated by decoder
9412 * @params[in] DRBs_ToBeSetup_List_t *drbSet
9415 * ****************************************************************/
9417 void freeAperDecodeDRBSetup(DRBs_ToBeSetup_List_t *drbSet)
9419 DRBs_ToBeSetup_Item_t *drbSetItem = NULLP;
9423 if(drbSet->list.array != NULLP)
9425 for(drbIdx=0; drbIdx<drbSet->list.count; drbIdx++)
9427 if(drbIdx==0&&drbSet->list.array[drbIdx] != NULLP)
9429 drbSetItem =&drbSet->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item;
9430 if(drbSetItem->qoSInformation.choice.choice_extension != NULLP)
9432 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9433 qoS_Characteristics.choice.non_Dynamic_5QI !=NULLP)
9435 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9436 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
9438 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9439 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
9442 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sST.buf!=NULLP)
9445 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD!=NULLP)
9448 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD->\
9452 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.\
9453 flows_Mapped_To_DRB_List.list.array != NULLP)
9456 for(flowIdx=0;flowIdx<drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9457 DRB_Information.flows_Mapped_To_DRB_List.list.count; flowIdx++)
9460 if(flowIdx==0&&drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9461 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]!=NULLP)
9463 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9464 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9465 qoSFlowLevelQoSParameters.\
9466 qoS_Characteristics.choice.non_Dynamic_5QI!=NULLP)
9468 if(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->averagingWindow!=NULLP)
9474 if(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->maxDataBurstVolume!=NULLP)
9481 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->maxDataBurstVolume);
9487 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9488 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9489 qoSFlowLevelQoSParameters.\
9490 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
9493 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9495 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9496 qoSFlowLevelQoSParameters.\
9497 qoS_Characteristics.choice.non_Dynamic_5QI);
9500 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9501 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]!=NULLP)
9504 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9505 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]);
9509 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9510 DRB_Information.flows_Mapped_To_DRB_List.list.array);
9513 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9514 DRB_Information.sNSSAI.sD->buf);
9517 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD);
9520 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sST.buf);
9524 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9526 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
9529 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9530 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
9533 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9534 qoS_Characteristics.choice.non_Dynamic_5QI);
9536 free(drbSetItem->qoSInformation.choice.choice_extension);
9538 freeAperDecodeULTnlInfo(&drbSetItem->uLUPTNLInformation_ToBeSetup_List);
9539 if(drbSetItem->uLConfiguration)
9541 free(drbSetItem->uLConfiguration);
9544 if(drbSet->list.array[drbIdx]!=NULLP)
9546 free(drbSet->list.array[drbIdx]);
9549 free(drbSet->list.array);
9554 /*******************************************************************
9556 * @brief builds Mac Cell Cfg
9560 * Function : procUeReCfgCellInfo
9562 * Functionality: builds Mac Cell Cfg
9564 * @params[in] MacUeCfg pointer
9569 * ****************************************************************/
9570 uint8_t procUeReCfgCellInfo(MacUeCfg *macUeCfgToSend, void *cellInfo)
9573 CellGroupConfigRrc_t *cellGrp = NULLP;
9577 cellGrp = (CellGroupConfigRrc_t *)cellInfo;
9578 ret = extractUeReCfgCellInfo(cellGrp, macUeCfgToSend);
9580 DU_LOG("\nERROR --> F1AP : Failed at procUeReCfgCellInfo()");
9584 freeUeReCfgCellGrpInfo(macUeCfgToSend);
9589 /*******************************************************************
9591 * @brief Filling modulation info in mac ue cfg
9595 * Function : duFillModulationDetails
9597 * Functionality: Filling modulation info in mac ue cfg
9599 * @params[in] MAC UE Config to be updated
9600 * Current UE configuration
9601 * UE NR capability from CU
9602 * @return ROK - success
9605 * ****************************************************************/
9606 void duFillModulationDetails(MacUeCfg *ueCfg, MacUeCfg *oldUeCfg, void *ueCap)
9608 UE_NR_Capability_t *ueNrCap=NULLP;
9612 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
9613 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
9617 ueNrCap = (UE_NR_Capability_t *)ueCap;
9619 /* Filling DL modulation info */
9620 if(ueNrCap->featureSets && ueNrCap->featureSets->featureSetsDownlinkPerCC && \
9621 ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0] && \
9622 ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0]->supportedModulationOrderDL)
9624 switch(*(ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0]->supportedModulationOrderDL))
9626 case ModulationOrder_qpsk:
9628 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
9631 case ModulationOrder_qam16:
9633 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM16;
9636 case ModulationOrder_qam64:
9638 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM64;
9639 ueCfg->dlModInfo.mcsIndex = PDSCH_MCS_INDEX;
9640 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64;
9643 case ModulationOrder_qam256:
9645 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM256;
9650 DU_LOG("\nERROR --> DU APP: Incorrect downlink modulation order received. Reatining old modulation configuration");
9651 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
9658 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
9661 /* Filling UL modulation info */
9662 if(ueNrCap->featureSets && ueNrCap->featureSets->featureSetsUplinkPerCC && \
9663 ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0] && \
9664 ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0]->supportedModulationOrderUL)
9666 switch(*(ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0]->supportedModulationOrderUL))
9668 case ModulationOrder_qpsk:
9670 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
9673 case ModulationOrder_qam16:
9675 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM16;
9676 ueCfg->ulModInfo.mcsIndex = PUSCH_MCS_INDEX;
9677 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64;
9680 case ModulationOrder_qam64:
9682 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM64;
9685 case ModulationOrder_qam256:
9687 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM256;
9692 DU_LOG("\nERROR --> DU APP: Incorrect uplink modulation order received. Reatining old modulation configuration");
9693 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
9700 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
9705 /*******************************************************************
9707 * @brief Function to extract cellGrp Info present in cutoDu cont
9711 * Function : extractCellGrpInfo
9713 * Functionality: Function to extract cellGrp Info present
9716 * @params[in] ProtocolExtensionContainer_4624P16_t pointer
9718 * @return CellGroupConfigRrc_t *
9720 * ****************************************************************/
9722 CellGroupConfigRrc_t *extractCellGrpInfo(ProtocolExtensionContainer_4624P16_t *protocolIeExtn,\
9727 uint16_t recvBufLen =0;
9728 CellGroupConfigRrc_t *cellGrpCfg = NULLP;
9729 CUtoDURRCInformation_ExtIEs_t *extIeInfo = NULLP;
9730 asn_dec_rval_t rval; /* Decoder return value */
9731 memset(&rval, 0, sizeof(asn_dec_rval_t));
9735 for(idx2 = 0; idx2 < protocolIeExtn->list.count; idx2++)
9737 extIeInfo = ((CUtoDURRCInformation_ExtIEs_t *)(protocolIeExtn->list.array[idx2]));
9741 case ProtocolIE_ID_id_CellGroupConfig:
9743 recvBufLen = extIeInfo->extensionValue.choice.CellGroupConfig.size;
9744 /* decoding the CellGroup Buf received */
9745 DU_ALLOC(cellGrpCfg, sizeof(CellGroupConfigRrc_t));
9748 memset(cellGrpCfg, 0, sizeof(CellGroupConfigRrc_t));
9749 rval = aper_decode(0, &asn_DEF_CellGroupConfigRrc, (void **)&cellGrpCfg,
9750 extIeInfo->extensionValue.choice.CellGroupConfig.buf, recvBufLen, 0, 0);
9751 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
9753 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
9756 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, cellGrpCfg);
9757 if(extractRlcCfgToAddMod(cellGrpCfg->rlc_BearerToAddModList, ueCfgDb))
9763 DU_LOG("\nERROR --> F1AP : Invalid IE received CUtoDURRCInformation:%d at decodeCellGrpCfg()", id);
9771 /*******************************************************************
9773 * @brief Fills Srb List received by CU
9777 * Function : procSrbListToSetup
9779 * Functionality: Fills Srb List received by CU
9781 * @params[in] SRBs_ToBeSetup_Item_t *cuSrbItem
9783 * RlcBearerCfg pointer
9786 * ****************************************************************/
9787 uint8_t procSrbListToSetup(SRBs_ToBeSetup_Item_t * srbItem, LcCfg *macLcToAdd, RlcBearerCfg *rlcLcToAdd)
9791 /* Filling RLC INFO */
9792 procRlcLcCfg(srbItem->sRBID, srbItem->sRBID, RB_TYPE_SRB, RLC_AM, CONFIG_ADD, NULL, rlcLcToAdd);
9794 /* Filling MAC INFO */
9795 ret = procMacLcCfg(srbItem->sRBID, RB_TYPE_SRB, CONFIG_ADD, NULL,NULL, NULL, macLcToAdd, NULL);
9798 DU_LOG("\nERROR --> F1AP : Failed at MAC LC Cfg in procSrbListToSetup()");
9806 /*******************************************************************
9808 * @brief extract Srb List received by CU
9812 * Function : extractSrbListToSetup
9814 * Functionality: extract Srb List received by CU
9815 * for both MAC and RLC
9817 * @params[in] SRBs_ToBeSetup_Item_t pointer
9819 * @return ROK/RFAIED
9821 * ****************************************************************/
9823 uint8_t extractSrbListToSetup(SRBs_ToBeSetup_List_t *srbCfg, DuUeCfg *ueCfgDb)
9825 uint8_t ret, srbIdx;
9826 SRBs_ToBeSetup_Item_t *srbItem = NULLP;
9830 for(srbIdx = 0; srbIdx < srbCfg->list.count; srbIdx++)
9832 srbItem = &srbCfg->list.array[srbIdx]->value.choice.SRBs_ToBeSetup_Item;
9833 if(ueCfgDb->numMacLcs > MAX_NUM_LC)
9835 DU_LOG("\nERROR --> F1AP: MAX LC Reached in MAC");
9839 if(ueCfgDb->numRlcLcs > MAX_NUM_LC)
9841 DU_LOG("\nERROR --> F1AP: MAX LC Reached in RLC");
9845 memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(LcCfg));
9846 memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(RlcBearerCfg));
9847 ret = procSrbListToSetup(srbItem, &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs],\
9848 &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs]);
9849 ueCfgDb->numRlcLcs++;
9850 ueCfgDb->numMacLcs++;
9853 DU_LOG("\nERROR --> F1AP: Failed at extractSrbListToSetup()");
9864 /*******************************************************************
9866 * @brief Fills Drb List received by CU
9870 * Function : procDrbListToSetup
9872 * Functionality: Fills Drb List received by CU
9873 * for both MAC and RLC
9875 * @params[in] SRBs_ToBeSetup_Item_t pointer
9877 * RlcBearerCfg pointer
9880 * ****************************************************************/
9882 uint8_t procDrbListToSetup(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbItem,\
9883 DRBs_ToBeSetupMod_Item_t *drbSetupModItem, LcCfg *macLcToAdd, RlcBearerCfg *rlcLcToAdd, UpTnlCfg *upTnlInfo)
9886 if(drbItem != NULLP)
9888 /* Filling RLC INFO */
9889 procRlcLcCfg(drbItem->dRBID, lcId, RB_TYPE_DRB, drbItem->rLCMode, CONFIG_ADD, NULL, rlcLcToAdd);
9891 /* Filling MAC INFO */
9892 if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_ADD, drbItem, NULL, NULL, macLcToAdd, upTnlInfo) != ROK)
9894 DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in procDrbListToSetup()");
9898 else if(drbSetupModItem != NULLP)
9900 procRlcLcCfg(drbSetupModItem->dRBID, lcId, RB_TYPE_DRB, drbSetupModItem->rLCMode, CONFIG_ADD, NULL, rlcLcToAdd);
9902 if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_ADD, NULL, drbSetupModItem, NULL, macLcToAdd, upTnlInfo) != ROK)
9904 DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in procDrbListToSetup()");
9911 /*******************************************************************
9913 * @brief extract Drb List received by CU
9917 * Function : extractDrbListToSetup
9919 * Functionality: extract Drb List received by CU
9920 * for both MAC and RLC
9922 * @params[in] DRBs_ToBeSetup_Item_t pointer
9924 * @return ROK/RFAIED
9926 * ****************************************************************/
9928 uint8_t extractDrbListToSetup(uint8_t lcId, DRBs_ToBeSetup_List_t *drbCfg,DRBs_ToBeSetupMod_List_t *drbSetupModCfg,\
9929 uint8_t drbCount, DuUeCfg *ueCfgDb)
9931 uint8_t ret, drbIdx;
9932 DRBs_ToBeSetup_Item_t *drbItem = NULLP;
9933 DRBs_ToBeSetupMod_ItemIEs_t *drbSetupModItem = NULLP;
9938 for(drbIdx = 0; drbIdx < drbCount; drbIdx++)
9940 if(ueCfgDb->numMacLcs > MAX_NUM_LC)
9942 DU_LOG("\nERROR --> F1AP : MAX LC Reached in MAC at extractDrbListToSetup()");
9946 if(ueCfgDb->numRlcLcs > MAX_NUM_LC)
9948 DU_LOG("\nERROR --> F1AP : MAX LC Reached in RLC at extractDrbListToSetup()");
9952 memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(LcCfg));
9953 memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(RlcBearerCfg));
9957 drbItem = &drbCfg->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item;
9958 ret = procDrbListToSetup(lcId, drbItem, NULL, &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs],\
9959 &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], &ueCfgDb->upTnlInfo[ueCfgDb->numDrb]);
9962 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetup()");
9966 else if(drbSetupModCfg != NULL)
9968 drbSetupModItem = (DRBs_ToBeSetupMod_ItemIEs_t *) drbSetupModCfg->list.array[drbIdx];
9969 ret = procDrbListToSetup(lcId, NULL, &(drbSetupModItem->value.choice.DRBs_ToBeSetupMod_Item) ,\
9970 &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs],\
9971 &ueCfgDb->upTnlInfo[ueCfgDb->numDrb]);
9974 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetup()");
9978 ueCfgDb->numRlcLcs++;
9979 ueCfgDb->numMacLcs++;
9983 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetup()");
9994 /*******************************************************************
9996 * @brief Function to extract Dl RRC Msg received from CU
10000 * Function : extractDlRrcMsg
10002 * Functionality: Function to extract Dl RRC Msg received from CU
10004 * @params[in] F1AP message
10005 * @return ROK - success
10006 * RFAILED - failure
10008 * ****************************************************************/
10010 uint8_t extractDlRrcMsg(uint32_t gnbDuUeF1apId, uint32_t gnbCuUeF1apId, \
10011 F1DlRrcMsg *dlRrcMsg, RRCContainer_t *rrcContainer)
10014 dlRrcMsg->rrcMsgSize = rrcContainer->size;
10015 if(dlRrcMsg->rrcMsgSize > 0)
10017 DU_ALLOC_SHRABL_BUF(dlRrcMsg->rrcMsgPdu, dlRrcMsg->rrcMsgSize);
10018 if(!dlRrcMsg->rrcMsgPdu)
10020 DU_LOG("\nERROR --> DU APP : Memory allocation failed for RRC Msg in extractDlRrcMsg()");
10025 dlRrcMsg->gnbDuUeF1apId = gnbDuUeF1apId;
10026 dlRrcMsg->gnbCuUeF1apId = gnbCuUeF1apId;
10027 dlRrcMsg->srbId = SRB1_LCID;
10028 memcpy(dlRrcMsg->rrcMsgPdu, rrcContainer->buf, dlRrcMsg->rrcMsgSize);
10034 /*******************************************************************
10036 * @brief Extract UE capability info
10040 * Function : extractUeCapability
10042 * Functionality: Extract UE capability info and stores in ue Cb
10044 * @params[in] Octet string of UE capability RAT container list
10045 * @return ROK - success
10046 * RFAILED - failure
10048 * ****************************************************************/
10049 UE_NR_Capability_t *extractUeCapability(UE_CapabilityRAT_ContainerList_t *ueCapablityListBuf, DuUeCb *ueCb)
10052 uint16_t recvBufLen;
10053 asn_dec_rval_t rval;
10054 UE_NR_Capability_t *ueNrCap = NULLP;
10055 UE_CapabilityRAT_ContainerListRRC_t *ueCapRatContList = NULLP;
10057 /* Decoding UE Capability RAT Container List */
10058 recvBufLen = ueCapablityListBuf->size;
10059 DU_ALLOC(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
10060 if(!ueCapRatContList)
10062 DU_LOG("\nERROR --> F1AP : Memory allocation failed in extractUeCapability");
10065 memset(ueCapRatContList, 0, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
10066 memset(&rval, 0, sizeof(asn_dec_rval_t));
10067 rval = aper_decode(0, &asn_DEF_UE_CapabilityRAT_ContainerListRRC, (void **)&ueCapRatContList,
10068 ueCapablityListBuf->buf, recvBufLen, 0, 0);
10069 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
10071 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
10074 xer_fprint(stdout, &asn_DEF_UE_CapabilityRAT_ContainerListRRC, ueCapRatContList);
10076 /* Free encoded buffer after decoding */
10078 for(idx = 0; idx < ueCapRatContList->list.count; idx++)
10080 if(ueCapRatContList->list.array[idx]->rat_Type == RAT_Type_nr)
10082 /* Decoding UE NR Capability */
10083 recvBufLen = ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.size;
10084 DU_ALLOC(ueNrCap, sizeof(UE_NR_Capability_t));
10087 DU_LOG("\nERROR --> F1AP : Memory allocation failed in extractUeCapability");
10088 DU_FREE(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
10091 memset(ueNrCap, 0, sizeof(UE_NR_Capability_t));
10092 memset(&rval, 0, sizeof(asn_dec_rval_t));
10093 rval = aper_decode(0, &asn_DEF_UE_NR_Capability, (void **)&ueNrCap,
10094 ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.buf, recvBufLen, 0, 0);
10095 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
10097 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
10100 xer_fprint(stdout, &asn_DEF_UE_NR_Capability, ueNrCap);
10102 /* Free encoded buffer after decoding */
10103 free(ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.buf);
10105 free(ueCapRatContList->list.array[idx]);
10109 free(ueCapRatContList->list.array);
10110 DU_FREE(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
10114 /*******************************************************************
10116 * @brief free UE context setup request from CU
10120 * Function : freeAperDecodeF1UeContextSetupReq
10122 * Functionality: freeing part for the memory allocated by aper_decoder
10124 * @params[in] F1AP message
10125 * @return ROK - success
10126 * RFAILED - failure
10128 * ****************************************************************/
10129 void freeAperDecodeF1UeContextSetupReq(UEContextSetupRequest_t *ueSetReq)
10133 if(ueSetReq->protocolIEs.list.array != NULLP)
10135 for(ieIdx = 0; ieIdx < ueSetReq->protocolIEs.list.count; ieIdx++)
10137 if(ueSetReq->protocolIEs.list.array[ieIdx])
10139 switch(ueSetReq->protocolIEs.list.array[ieIdx]->id)
10141 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
10143 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
10145 case ProtocolIE_ID_id_SpCell_ID:
10146 freeAperDecodeNrcgi(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.NRCGI);
10148 case ProtocolIE_ID_id_ServCellIndex:
10150 case ProtocolIE_ID_id_SpCellULConfigured:
10152 case ProtocolIE_ID_id_CUtoDURRCInformation:
10154 freeAperDecodeCuToDuInfo(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation);
10156 case ProtocolIE_ID_id_SCell_ToBeSetup_List:
10158 freeAperDecodeSplCellList(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SCell_ToBeSetup_List);
10160 case ProtocolIE_ID_id_SRBs_ToBeSetup_List:
10162 freeAperDecodeSRBSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SRBs_ToBeSetup_List);
10164 case ProtocolIE_ID_id_DRBs_ToBeSetup_List:
10166 freeAperDecodeDRBSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRBs_ToBeSetup_List);
10168 case ProtocolIE_ID_id_RRCContainer:
10171 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf != NULLP)
10174 free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf);
10178 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
10180 case ProtocolIE_ID_id_GNB_DU_UE_AMBR_UL:
10182 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf)
10184 free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf);
10189 DU_LOG("\nERROR --> F1AP: Invalid event type %ld " ,ueSetReq->protocolIEs.list.array[ieIdx]->id);
10191 free(ueSetReq->protocolIEs.list.array[ieIdx]);
10194 free(ueSetReq->protocolIEs.list.array);
10197 /*******************************************************************
10199 * @brief Process UE context setup request from CU
10203 * Function : procF1UeContextSetupReq
10205 * Functionality: Process UE context setup request from CU
10207 * @params[in] F1AP message
10208 * @return ROK - success
10209 * RFAILED - failure
10211 * ****************************************************************/
10212 uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg)
10214 uint8_t ret=0, ieIdx=0, ueIdx=0, lcId=0, cellIdx=0;
10215 bool ueCbFound = false;
10216 uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId=0, bitRateSize=0;
10217 DuUeCb *duUeCb = NULL;
10218 UEContextSetupRequest_t *ueSetReq = NULL;
10219 DRBs_ToBeSetup_List_t *drbCfg = NULL;
10223 ueSetReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextSetupRequest;
10224 for(ieIdx=0; (ieIdx < ueSetReq->protocolIEs.list.count && ret == ROK); ieIdx++)
10226 switch(ueSetReq->protocolIEs.list.array[ieIdx]->id)
10228 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
10230 gnbCuUeF1apId = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID;
10233 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
10235 gnbDuUeF1apId = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID;
10238 case ProtocolIE_ID_id_ServCellIndex:
10240 cellIdx = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.ServCellIndex;
10241 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
10243 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
10244 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
10247 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
10248 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
10251 memset(duUeCb->f1UeDb, 0, sizeof(F1UeContextSetupDb));
10252 duUeCb->f1UeDb->actionType = UE_CTXT_SETUP;
10253 duUeCb->f1UeDb->cellIdx = cellIdx;
10257 DU_LOG("\nERROR --> F1AP: Memory Alloc Failed at procF1UeContextSetupReq()");
10268 DU_LOG("\nERROR --> F1AP: DuUeCb is not found at procF1UeContextSetupReq()");
10273 case ProtocolIE_ID_id_SpCellULConfigured:
10274 /* Indicates whether the gNB-CU requests the gNB-DU to configure the uplink as no UL,
10275 UL, SUL or UL+SUL for the indicated cell for the UE */
10277 case ProtocolIE_ID_id_CUtoDURRCInformation:
10279 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList)
10281 duUeCb->f1UeDb->duUeCfg.ueNrCapability = \
10282 extractUeCapability(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.\
10283 uE_CapabilityRAT_ContainerList, duUeCb);
10285 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.iE_Extensions)
10287 duUeCb->f1UeDb->duUeCfg.cellGrpCfg = extractCellGrpInfo(ueSetReq->protocolIEs.list.array[ieIdx]->\
10288 value.choice.CUtoDURRCInformation.iE_Extensions, &duUeCb->f1UeDb->duUeCfg);
10289 if(!duUeCb->f1UeDb->duUeCfg.cellGrpCfg)
10291 DU_LOG("\nERROR --> F1AP: Failed to extract cell Grp Info");
10292 //TODO: Update the failure cause in ue context Setup Response
10298 case ProtocolIE_ID_id_SCell_ToBeSetup_List:
10300 DU_LOG("\nINFO --> DU_APP: Received SCell_ToBeSetup_List but Not processing the list");
10303 case ProtocolIE_ID_id_SRBs_ToBeSetup_List:
10305 if(extractSrbListToSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SRBs_ToBeSetup_List,\
10306 &duUeCb->f1UeDb->duUeCfg))
10308 DU_LOG("\nERROR --> DU APP : Failed at extractSrbListToSetup()");
10309 //TODO: Update the failure cause in ue context Setup Response
10314 case ProtocolIE_ID_id_DRBs_ToBeSetup_List:
10316 lcId = getDrbLcId(&duUeCb->drbBitMap);
10317 if(lcId != RFAILED)
10319 drbCfg = &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRBs_ToBeSetup_List;
10320 if(extractDrbListToSetup(lcId, drbCfg, NULL, drbCfg->list.count, &duUeCb->f1UeDb->duUeCfg))
10322 DU_LOG("\nERROR --> DU APP : Failed at extractDrbListToSetup()");
10323 //TODO: Update the failure cause in ue context Setup Response
10331 case ProtocolIE_ID_id_RRCContainer:
10333 /* Filling Dl RRC Msg Info */
10334 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
10335 if(!duUeCb->f1UeDb->dlRrcMsg)
10337 DU_LOG("\nERROR --> DU APP : Memory allocation failed for DL RRC Msg in procUeCtxtSetupReq()");
10342 duUeCb->f1UeDb->dlRrcMsgPres = true;
10343 memset(duUeCb->f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
10344 ret = extractDlRrcMsg(gnbDuUeF1apId, gnbCuUeF1apId, duUeCb->f1UeDb->dlRrcMsg,\
10345 &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer);
10349 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
10351 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
10353 duUeCb->f1UeDb->dlRrcMsg->deliveryStatRpt = true;
10357 DU_LOG("\nERROR --> Ignoring delivery report, since rrcContainer is not present");
10361 case ProtocolIE_ID_id_GNB_DU_UE_AMBR_UL:
10363 /* MaximumBitRate Uplink */
10364 bitRateSize = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.size;
10365 if(bitRateSize > 0)
10367 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->duUeCfg.ambrCfg, bitRateSize);
10368 if(!duUeCb->f1UeDb->duUeCfg.ambrCfg)
10370 DU_LOG("\nERROR --> DU APP : Memory allocation failed for bitRate in procUeCtxtSetupReq");
10375 memset(duUeCb->f1UeDb->duUeCfg.ambrCfg, 0, sizeof(AmbrCfg));
10376 memcpy(&duUeCb->f1UeDb->duUeCfg.ambrCfg->ulBr,
10377 ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf, bitRateSize);
10392 /*TODO : Negative case*/
10393 // BuildAndSendUeContextSetupRsp(cellId,ueIdx);
10394 DU_LOG("\nERROR --> F1AP: Failed to process UE CNTXT SETUP REQ at procF1UeContextSetupReq()");
10397 ret = duProcUeContextSetupRequest(duUeCb);
10399 freeAperDecodeF1UeContextSetupReq(ueSetReq);
10403 /*******************************************************************
10404 * @brief Free the memory allocated for Dl Tunnel Info
10408 * Function : freeDlTnlInfo
10411 * Free the memory allocated for Dl Tunnel Info
10413 * @params[in] DLUPTNLInformation_ToBeSetup_List_t *
10416 * ****************************************************************/
10418 void freeDlTnlInfo(DLUPTNLInformation_ToBeSetup_List_t *tnlInfo)
10420 uint8_t arrIdx = 0;
10424 for(arrIdx=0; arrIdx < tnlInfo->list.count; arrIdx++)
10426 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.buf,\
10427 tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.size);
10428 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf,\
10429 tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->gTP_TEID.size);
10430 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel, sizeof(GTPTunnel_t));
10431 DU_FREE(tnlInfo->list.array[arrIdx], sizeof(DLUPTNLInformation_ToBeSetup_Item_t));
10433 DU_FREE(tnlInfo->list.array, tnlInfo->list.size);
10437 /*******************************************************************
10438 * @brief Free the memory allocated for DRB setup List
10442 * Function : freeDrbSetupList
10445 * Free the memory allocated for DRB setup list
10447 * @params[in] DRBs_Setup_List_t *
10450 * ****************************************************************/
10451 void freeDrbSetupList(DRBs_Setup_List_t *drbSetupList)
10453 uint8_t arrIdx = 0;
10454 DRBs_Setup_ItemIEs_t *drbItemIe = NULLP;
10456 for(arrIdx = 0; arrIdx < drbSetupList->list.count; arrIdx++)
10458 drbItemIe = ((DRBs_Setup_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
10459 freeDlTnlInfo(&drbItemIe->value.choice.DRBs_Setup_Item.dLUPTNLInformation_ToBeSetup_List);
10460 DU_FREE(drbSetupList->list.array[arrIdx], sizeof(DRBs_Setup_Item_t));
10462 DU_FREE(drbSetupList->list.array, drbSetupList->list.size);
10465 /*******************************************************************
10466 * @brief Free the memory allocated for UE Setup response
10470 * Function : FreeUeContextSetupRsp
10473 * Free the memory allocated for UE Setup response
10475 * @params[in] F1AP PDU for UE setup response
10476 * @return ROK - success
10477 * RFAILED - failure
10479 * ****************************************************************/
10480 void FreeUeContextSetupRsp(F1AP_PDU_t *f1apMsg)
10483 UEContextSetupResponse_t *ueSetRsp = NULLP;
10487 if(f1apMsg->choice.successfulOutcome)
10489 ueSetRsp = &f1apMsg->choice.successfulOutcome->value.choice.\
10490 UEContextSetupResponse;
10491 if(ueSetRsp->protocolIEs.list.array)
10493 for(idx = 0; idx < ueSetRsp->protocolIEs.list.count; idx++)
10495 if(ueSetRsp->protocolIEs.list.array[idx])
10497 switch(ueSetRsp->protocolIEs.list.array[idx]->id)
10499 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
10501 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
10503 case ProtocolIE_ID_id_DUtoCURRCInformation:
10505 CellGroupConfig_t *cellGrpCfg = NULLP;
10506 cellGrpCfg = &ueSetRsp->protocolIEs.list.array[idx]->value.choice.\
10507 DUtoCURRCInformation.cellGroupConfig;
10508 if(cellGrpCfg->buf != NULLP)
10510 DU_FREE(cellGrpCfg->buf, cellGrpCfg->size);
10511 cellGrpCfg = NULLP;
10515 case ProtocolIE_ID_id_DRBs_Setup_List:
10517 freeDrbSetupList(&ueSetRsp->protocolIEs.list.array[idx]->value.choice.DRBs_Setup_List);
10521 DU_LOG("\nERROR --> DUAPP: Invalid Id %ld at FreeUeContextSetupRsp()",\
10522 ueSetRsp->protocolIEs.list.array[idx]->id);
10525 DU_FREE(ueSetRsp->protocolIEs.list.array[idx],\
10526 sizeof(UEContextSetupResponseIEs_t));
10529 DU_FREE(ueSetRsp->protocolIEs.list.array, \
10530 ueSetRsp->protocolIEs.list.size);
10532 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
10534 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
10538 /*******************************************************************
10540 * @brief Builds Ue context Setup Rsp DU To CU Info
10544 * Function : EncodeUeCntxtDuToCuInfo
10546 * Functionality: Builds Ue context Setup Rsp DU To CU Info
10548 * @params[in] CellGroupConfig_t *, CellGroupConfigRrc_t *
10550 * @return ROK - success
10551 * RFAILED - failure
10553 ******************************************************************/
10555 uint8_t EncodeUeCntxtDuToCuInfo(CellGroupConfig_t *duToCuCellGrp, CellGroupConfigRrc_t *duCellGrpCfg)
10557 asn_enc_rval_t encRetVal;
10559 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, duCellGrpCfg);
10560 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
10562 encRetVal = aper_encode(&asn_DEF_CellGroupConfigRrc, 0, duCellGrpCfg, PrepFinalEncBuf, encBuf);
10563 /* Encode results */
10564 if(encRetVal.encoded == ENCODE_FAIL)
10566 DU_LOG( "\nERROR --> F1AP : Could not encode UeCntxtDuToCuInfo (at %s)\n",\
10567 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
10572 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UeCntxtDuToCuInfo\n");
10573 for(int i=0; i< encBufSize; i++)
10575 printf("%x",encBuf[i]);
10578 duToCuCellGrp->size = encBufSize;
10579 DU_ALLOC(duToCuCellGrp->buf, duToCuCellGrp->size);
10580 if(!duToCuCellGrp->buf)
10582 DU_LOG("\nERROR --> F1AP : Memory allocation failed in UeCntxtDuToCuInfo");
10584 memcpy(duToCuCellGrp->buf, encBuf, duToCuCellGrp->size);
10588 /*******************************************************************
10590 * @brief Fills Dl Gtp tunnel Info
10594 * Function : fillGtpTunnelforDl
10596 * Functionality: Fills Dl Gtp tunnel Info
10600 * @return ROK - success
10601 * RFAILED - failure
10603 * ****************************************************************/
10605 uint8_t fillGtpTunnelforDl(GTPTunnel_t *gtpDl, GtpTnlCfg *gtpUeCfg)
10607 uint8_t bufSize = 0;
10609 gtpDl->transportLayerAddress.size = 4*sizeof(uint8_t);
10610 DU_ALLOC(gtpDl->transportLayerAddress.buf, gtpDl->transportLayerAddress.size);
10611 if(gtpDl->transportLayerAddress.buf == NULLP)
10615 memcpy(gtpDl->transportLayerAddress.buf, >pUeCfg->dlTnlAddress, gtpDl->transportLayerAddress.size);
10618 gtpDl->gTP_TEID.size = 4 * sizeof(uint8_t);
10619 DU_ALLOC(gtpDl->gTP_TEID.buf, gtpDl->gTP_TEID.size);
10620 if(gtpDl->gTP_TEID.buf == NULLP)
10624 bufSize = 3; /*forming an Octect String*/
10625 fillTeIdString(bufSize, gtpUeCfg->teId, gtpDl->gTP_TEID.buf);
10630 /*******************************************************************
10632 * @brief Fills DL Tunnel Setup List
10636 * Function : fillDlTnlSetupList
10638 * Functionality: Fills the DL Tunnel Setup List
10642 * @return ROK - success
10643 * RFAILED - failure
10645 * ****************************************************************/
10647 uint8_t fillDlTnlSetupList(DLUPTNLInformation_ToBeSetup_List_t *dlTnlInfo, UpTnlCfg *tnlCfg)
10649 uint8_t ret = ROK, arrIdx = 0, eleCount = 0;
10652 dlTnlInfo->list.count = eleCount;
10653 dlTnlInfo->list.size = (eleCount * sizeof(DLUPTNLInformation_ToBeSetup_Item_t *));
10655 /* Initialize the DL Tnl Setup List Members */
10656 DU_ALLOC(dlTnlInfo->list.array, dlTnlInfo->list.size);
10657 if(dlTnlInfo->list.array == NULLP)
10659 DU_LOG(" ERROR --> F1AP : Memory allocation for DL Tnl Setup List in fillDlTnlSetupList()");
10662 for(arrIdx=0; arrIdx < eleCount; arrIdx++)
10664 DU_ALLOC(dlTnlInfo->list.array[arrIdx], sizeof(DLUPTNLInformation_ToBeSetup_Item_t));
10665 if(dlTnlInfo->list.array[arrIdx] == NULLP)
10667 DU_LOG(" ERROR --> F1AP : Memory allocation for arrIdx [%d] failed in fillDlTnlSetupList()", arrIdx);
10670 dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.present = UPTransportLayerInformation_PR_gTPTunnel;
10671 DU_ALLOC(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel, sizeof(GTPTunnel_t));
10672 if(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel == NULLP)
10674 DU_LOG(" ERROR --> F1AP : Memory allocation for DL tunnel info in fillDlTnlSetupList()");
10677 ret = fillGtpTunnelforDl(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel,\
10685 /*******************************************************************
10687 * @brief Fills the Drb Setup List for Ue Context Setup Response
10691 * Function : fillDrbSetupList
10693 * Functionality: Fills the Drb Setup List for Ue Context Setup Response
10697 * @return ROK - success
10698 * RFAILED - failure
10700 * ****************************************************************/
10701 uint8_t fillDrbSetupList(DRBs_Setup_List_t *drbSetupList, DuUeCfg *ueCfg)
10703 uint8_t ret = ROK, arrIdx = 0, eleCount = 0;
10704 DRBs_Setup_ItemIEs_t *drbItemIe = NULLP;
10706 eleCount = ueCfg->numDrb;
10707 drbSetupList->list.count = eleCount;
10708 drbSetupList->list.size = \
10709 (eleCount * sizeof(DRBs_Setup_Item_t *));
10711 /* Initialize the Drb Setup List Members */
10712 DU_ALLOC(drbSetupList->list.array, drbSetupList->list.size);
10713 if(drbSetupList->list.array == NULLP)
10715 DU_LOG(" ERROR --> F1AP : Memory allocation for DRB Setup List in fillDrbSetupList()");
10719 for(arrIdx=0; arrIdx < eleCount; arrIdx++)
10721 DU_ALLOC(drbSetupList->list.array[arrIdx], sizeof(DRBs_Setup_Item_t));
10722 if(drbSetupList->list.array[arrIdx] == NULLP)
10724 DU_LOG(" ERROR --> F1AP : Memory allocation for arrIdx [%d] failed in fillDrbSetupList()", arrIdx);
10727 drbItemIe = ((DRBs_Setup_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
10728 drbItemIe->id = ProtocolIE_ID_id_DRBs_Setup_Item;
10729 drbItemIe->criticality = Criticality_reject;
10730 drbItemIe->value.present = DRBs_Setup_ItemIEs__value_PR_DRBs_Setup_Item;
10731 drbItemIe->value.choice.DRBs_Setup_Item.dRBID = ueCfg->upTnlInfo[arrIdx].drbId;
10732 ret = fillDlTnlSetupList(&drbItemIe->value.choice.DRBs_Setup_Item.dLUPTNLInformation_ToBeSetup_List,\
10733 &ueCfg->upTnlInfo[arrIdx]);
10740 /*******************************************************************
10742 * @brief Builds and sends the UE Setup Response
10746 * Function : BuildAndSendUeContextSetupRsp
10748 * Functionality: Constructs the UE Setup Response and sends
10749 * it to the DU through SCTP.
10751 * @params[in] uint8_t cellId,uint8_t ueIdx
10753 * @return ROK - success
10754 * RFAILED - failure
10756 * ****************************************************************/
10757 uint8_t BuildAndSendUeContextSetupRsp(uint8_t cellId,uint8_t ueIdx)
10759 uint8_t idx, ret, cellIdx, elementCnt;
10760 uint32_t gnbCuUeF1apId; /* gNB-CU UE F1AP Id */
10761 uint32_t gnbDuUeF1apId; /* gNB-DU UE F1AP Id */
10762 asn_enc_rval_t encRetVal; /* Encoder return value */
10763 F1AP_PDU_t *f1apMsg = NULLP;
10764 UEContextSetupResponse_t *ueSetRsp = NULLP;
10765 CellGroupConfigRrc_t *cellGrpCfg = NULLP;
10766 DuUeCb *ueCb = NULLP;
10768 DU_LOG("\n INFO --> F1AP : Building UE Context Setup Response for cellId %d, ueIdx %d\n", cellId, ueIdx);
10772 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
10773 if(f1apMsg == NULLP)
10775 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
10780 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
10781 DU_ALLOC(f1apMsg->choice.successfulOutcome,
10782 sizeof(SuccessfulOutcome_t));
10783 if(f1apMsg->choice.successfulOutcome == NULLP)
10785 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
10790 f1apMsg->choice.successfulOutcome->procedureCode = \
10791 ProcedureCode_id_UEContextSetup;
10792 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
10793 f1apMsg->choice.successfulOutcome->value.present = \
10794 SuccessfulOutcome__value_PR_UEContextSetupResponse;
10797 &f1apMsg->choice.successfulOutcome->value.choice.UEContextSetupResponse;
10799 ueSetRsp->protocolIEs.list.count = elementCnt;
10800 ueSetRsp->protocolIEs.list.size = \
10801 elementCnt * sizeof(UEContextSetupResponse_t *);
10803 /* Initialize the UESetup members */
10804 DU_ALLOC(ueSetRsp->protocolIEs.list.array, \
10805 ueSetRsp->protocolIEs.list.size);
10806 if(ueSetRsp->protocolIEs.list.array == NULLP)
10808 DU_LOG(" ERROR --> F1AP : Memory allocation for UE Setup Response failed");
10813 for(idx=0; idx<elementCnt; idx++)
10815 DU_ALLOC(ueSetRsp->protocolIEs.list.array[idx],\
10816 sizeof(UEContextSetupResponseIEs_t));
10817 if(ueSetRsp->protocolIEs.list.array[idx] == NULLP)
10819 DU_LOG(" ERROR --> F1AP : Memory allocation for UE Setup Response failed");
10824 /* Fetching Ue Cb Info*/
10825 GET_CELL_IDX(cellId, cellIdx);
10826 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
10827 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
10828 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
10831 /*GNB CU UE F1AP ID*/
10832 ueSetRsp->protocolIEs.list.array[idx]->id = \
10833 ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
10834 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
10835 ueSetRsp->protocolIEs.list.array[idx]->value.present = \
10836 UEContextSetupResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
10837 ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
10839 /*GNB DU UE F1AP ID*/
10841 ueSetRsp->protocolIEs.list.array[idx]->id = \
10842 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
10843 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
10844 ueSetRsp->protocolIEs.list.array[idx]->value.present = \
10845 UEContextSetupResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
10846 ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
10849 /*DUtoCURRC Information */
10851 ueSetRsp->protocolIEs.list.array[idx]->id = \
10852 ProtocolIE_ID_id_DUtoCURRCInformation;
10853 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
10854 ueSetRsp->protocolIEs.list.array[idx]->value.present =\
10855 UEContextSetupResponseIEs__value_PR_DUtoCURRCInformation;
10858 if(ueCb->f1UeDb->duUeCfg.cellGrpCfg)
10860 cellGrpCfg = (CellGroupConfigRrc_t*)ueCb->f1UeDb->duUeCfg.cellGrpCfg;
10861 ret = EncodeUeCntxtDuToCuInfo(&ueSetRsp->protocolIEs.list.array[idx]->value.\
10862 choice.DUtoCURRCInformation.cellGroupConfig, cellGrpCfg);
10865 DU_LOG("\nERROR --> F1AP : Failed to EncodeUeCntxtDuToCuInfo in BuildAndSendUeContextSetupRsp()");
10866 freeF1UeDb(ueCb->f1UeDb);
10867 ueCb->f1UeDb = NULLP;
10874 DU_LOG("\nERROR --> F1AP : Failed to form DUtoCU RRCInfo at BuildAndSendUeContextSetupRsp()");
10879 /* Drb Setup List */
10881 ueSetRsp->protocolIEs.list.array[idx]->id = \
10882 ProtocolIE_ID_id_DRBs_Setup_List;
10883 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
10884 ueSetRsp->protocolIEs.list.array[idx]->value.present =\
10885 UEContextSetupResponseIEs__value_PR_DRBs_Setup_List;
10886 ret = fillDrbSetupList(&ueSetRsp->protocolIEs.list.array[idx]->value.choice.DRBs_Setup_List,\
10887 &ueCb->f1UeDb->duUeCfg);
10890 DU_LOG("\nERROR --> F1AP : Failed to fillDrbSetupList in BuildAndSendUeContextSetupRsp()");
10891 freeF1UeDb(ueCb->f1UeDb);
10892 ueCb->f1UeDb = NULLP;
10896 /* Free UeContext Db created during Ue context Req */
10897 freeF1UeDb(ueCb->f1UeDb);
10898 ueCb->f1UeDb = NULLP;
10900 /* TODO: To send Drb list */
10901 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
10903 /* Encode the UE context setup response type as APER */
10904 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
10906 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
10908 /* Encode results */
10909 if(encRetVal.encoded == ENCODE_FAIL)
10911 DU_LOG( "\nERROR --> F1AP : Could not encode UE Context Setup Response structure (at %s)\n",\
10912 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
10918 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UE Context Setup Response\n");
10919 for(int i=0; i< encBufSize; i++)
10921 printf("%x",encBuf[i]);
10926 if(sendF1APMsg() != ROK)
10928 DU_LOG("\nERROR --> F1AP : Sending UE Context Setup Response failed");
10934 FreeUeContextSetupRsp(f1apMsg);
10936 }/* End of BuildAndSendUeContextSetupRsp */
10937 /*******************************************************************
10939 * @brief Build And Send Ue Context Rsp
10943 * Function : BuildAndSendUeCtxtRsp
10945 * Functionality : Build And Send Ue Context Rsp
10948 * @return sucess = ROK
10949 * failure = RFAILED
10951 * ****************************************************************/
10952 uint8_t BuildAndSendUeCtxtRsp(uint8_t cellId, uint8_t ueIdx)
10954 uint8_t cellIdx = 0, actionType = 0;
10956 GET_CELL_IDX(cellId, cellIdx);
10957 actionType = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb->actionType;
10961 case UE_CTXT_SETUP:
10963 BuildAndSendUeContextSetupRsp(cellId,ueIdx);
10968 BuildAndSendUeContextModRsp(cellId, ueIdx);
10972 DU_LOG("ERROR --> F1AP: Invalid Action Type %d at BuildAndSendUeCtxtRsp()", actionType);
10979 /*******************************************************************
10981 * @brief deallocating the memory of F1reset msg
10985 * Function : FreeF1ResetReq
10988 * - freeing memory of F1reset request msg
10994 * ****************************************************************/
10995 void FreeF1ResetReq(F1AP_PDU_t *f1apMsg)
10998 Reset_t *f1ResetMsg;
11002 if(f1apMsg->choice.initiatingMessage)
11004 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
11006 if(f1ResetMsg->protocolIEs.list.array)
11008 for(idx=0 ;idx < f1ResetMsg->protocolIEs.list.count ; idx++)
11010 if(f1ResetMsg->protocolIEs.list.array[idx])
11012 DU_FREE(f1ResetMsg->protocolIEs.list.array[idx],sizeof(ResetIEs_t));
11015 DU_FREE(f1ResetMsg->protocolIEs.list.array,f1ResetMsg->protocolIEs.list.size);
11017 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
11019 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
11022 /*******************************************************************
11024 * @brief Build and Send F1reset request
11028 * Function : BuildAndSendF1ResetReq
11031 * - Build and Send F1reset request msg
11034 * @return ROK - success
11035 * RFAILED - failure
11037 * ****************************************************************/
11038 uint8_t BuildAndSendF1ResetReq()
11040 uint8_t elementCnt=0;
11042 uint8_t ret= RFAILED;
11043 Reset_t *f1ResetMsg = NULLP;
11044 F1AP_PDU_t *f1apMsg = NULLP;
11045 asn_enc_rval_t encRetVal;
11046 DU_LOG("\nINFO --> F1AP : Building F1 Reset request \n");
11049 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
11050 if(f1apMsg == NULLP)
11054 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
11055 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
11056 if(f1apMsg->choice.initiatingMessage == NULLP)
11060 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_Reset;
11061 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
11062 f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_Reset;
11064 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
11067 f1ResetMsg->protocolIEs.list.count = elementCnt;
11068 f1ResetMsg->protocolIEs.list.size = elementCnt * sizeof(ResetIEs_t *);
11070 /* Initialize the F1Setup members */
11071 DU_ALLOC(f1ResetMsg->protocolIEs.list.array,f1ResetMsg->protocolIEs.list.size);
11072 if(f1ResetMsg->protocolIEs.list.array == NULLP)
11076 for(idx=0; idx<elementCnt; idx++)
11078 DU_ALLOC(f1ResetMsg->protocolIEs.list.array[idx],sizeof(ResetIEs_t));
11079 if(f1ResetMsg->protocolIEs.list.array[idx] == NULLP)
11087 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID;
11088 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11089 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_TransactionID;
11090 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.TransactionID = 1;
11094 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_Cause;
11095 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_ignore;
11096 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_Cause;
11097 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.Cause.present = Cause_PR_radioNetwork;
11098 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.Cause.choice.radioNetwork = CauseRadioNetwork_action_desirable_for_radio_reasons;
11102 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_ResetType;
11103 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11104 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_ResetType;
11105 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.ResetType.present = ResetType_PR_f1_Interface;
11106 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.ResetType.choice.f1_Interface = ResetAll_reset_all;
11108 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
11110 /* Encode the F1SetupRequest type as APER */
11111 memset(encBuf, 0, ENC_BUF_MAX_LEN);
11113 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
11116 /* Encode results */
11117 if(encRetVal.encoded == ENCODE_FAIL)
11119 DU_LOG("\nERROR --> F1AP : Could not encode F1Reset structure (at %s)\n",\
11120 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
11125 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for F1Reset\n");
11126 for(idx=0; idx< encBufSize; idx++)
11128 printf("%x",encBuf[idx]);
11132 if(sendF1APMsg() != ROK)
11134 DU_LOG("\nERROR --> F1AP : Sending F1 Reset request failed");
11142 FreeF1ResetReq(f1apMsg);
11145 /*******************************************************************
11147 * @brief Build And Send F1ResetAck
11151 * Function : BuildAndSendF1ResetAck
11154 * - Build And Send F1ResetRSP
11156 * @return ROK - success
11157 * RFAILED - failure
11159 * ****************************************************************/
11160 void FreeF1ResetAck(F1AP_PDU_t *f1apMsg)
11163 ResetAcknowledge_t *f1ResetAck;
11167 if(f1apMsg->choice.successfulOutcome)
11169 f1ResetAck= &f1apMsg->choice.successfulOutcome->value.choice.ResetAcknowledge;
11171 if(f1ResetAck->protocolIEs.list.array)
11173 for(idx=0; idx<f1ResetAck->protocolIEs.list.count ; idx++)
11175 if(f1ResetAck->protocolIEs.list.array[idx])
11177 DU_FREE(f1ResetAck->protocolIEs.list.array[idx], sizeof(ResetAcknowledgeIEs_t));
11180 DU_FREE(f1ResetAck->protocolIEs.list.array, f1ResetAck->protocolIEs.list.size );
11182 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
11184 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
11188 /*******************************************************************
11190 * @brief Build And Send F1ResetAck
11194 * Function : BuildAndSendF1ResetAck
11197 * - Build And Send F1ResetRSP
11200 * @return ROK - success
11201 * RFAILED - failure
11203 * ****************************************************************/
11204 uint8_t BuildAndSendF1ResetAck()
11207 uint8_t elementCnt = 0;
11208 uint8_t ret = RFAILED;
11209 F1AP_PDU_t *f1apMsg = NULL;
11210 ResetAcknowledge_t *f1ResetAck = NULLP;
11211 asn_enc_rval_t encRetVal;
11212 DU_LOG("\nINFO --> F1AP : Building F1 Reset Acknowledgment \n");
11215 /* Allocate the memory for F1ResetRequest_t */
11216 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
11217 if(f1apMsg == NULLP)
11219 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11223 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
11225 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
11226 if(f1apMsg->choice.successfulOutcome == NULLP)
11228 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11231 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
11232 f1apMsg->choice.successfulOutcome->value.present = SuccessfulOutcome__value_PR_ResetAcknowledge;
11233 f1ResetAck = &f1apMsg->choice.successfulOutcome->value.choice.ResetAcknowledge;
11237 f1ResetAck->protocolIEs.list.count = elementCnt;
11238 f1ResetAck->protocolIEs.list.size = elementCnt*sizeof(ResetAcknowledgeIEs_t *);
11240 DU_ALLOC(f1ResetAck->protocolIEs.list.array, f1ResetAck->protocolIEs.list.size );
11241 if(f1ResetAck->protocolIEs.list.array == NULLP)
11243 DU_LOG("\nERROR --> F1AP : Memory allocation for F1ResetAckIEs failed");
11247 for(idx=0; idx<elementCnt; idx++)
11249 DU_ALLOC(f1ResetAck->protocolIEs.list.array[idx], sizeof(ResetAcknowledgeIEs_t));
11250 if(f1ResetAck->protocolIEs.list.array[idx] == NULLP)
11257 f1ResetAck->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID;
11258 f1ResetAck->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11259 f1ResetAck->protocolIEs.list.array[idx]->value.present = ResetAcknowledgeIEs__value_PR_TransactionID;
11260 f1ResetAck->protocolIEs.list.array[idx]->value.choice.TransactionID = TRANS_ID;
11262 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
11264 /* Encode the F1SetupRequest type as UPER */
11265 memset(encBuf, 0, ENC_BUF_MAX_LEN);
11267 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
11269 /* Check encode results */
11270 if(encRetVal.encoded == ENCODE_FAIL)
11272 DU_LOG("\nERROR --> F1AP : Could not encode F1ResetAck structure (at %s)\n",\
11273 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
11278 DU_LOG("\nDUBUG --> F1AP : Created APER encoded buffer for F1ResetAck\n");
11279 for(int i=0; i< encBufSize; i++)
11281 printf("%x",encBuf[i]);
11285 if(sendF1APMsg() != ROK)
11287 DU_LOG("\nERROR --> F1AP : Sending F1 Reset Acknowledgement failed");
11295 FreeF1ResetAck(f1apMsg);
11298 /******************************************************************
11300 * @brief free F1 reset msg allocated by aper_decoder
11304 * Function : freeAperDecodeF1ResetMsg
11306 * Functionality: free F1 reset msg allocated by aper_decoder
11308 * @params[in] Reset_t *f1ResetMsg
11311 * ****************************************************************/
11313 void freeAperDecodeF1ResetMsg(Reset_t *f1ResetMsg)
11316 if(f1ResetMsg->protocolIEs.list.array)
11318 for(ieIdx=0 ;ieIdx < f1ResetMsg->protocolIEs.list.count ; ieIdx++)
11320 if(f1ResetMsg->protocolIEs.list.array[ieIdx])
11322 free(f1ResetMsg->protocolIEs.list.array[ieIdx]);
11325 free(f1ResetMsg->protocolIEs.list.array);
11329 /******************************************************************
11331 * @brief Processes DL RRC Message Transfer sent by CU
11335 * Function : procF1ResetReq
11337 * Functionality: Processes DL RRC Message Transfer sent by CU
11339 * @params[in] F1AP_PDU_t ASN decoded F1AP message
11340 * @return ROK - success
11341 * RFAILED - failure
11343 * ****************************************************************/
11344 uint8_t procF1ResetReq(F1AP_PDU_t *f1apMsg)
11346 /* we are currently not supporting Ue release. right now we are supporting only init case of fireset */
11349 Reset_t *f1ResetMsg = NULLP;
11351 DU_LOG("\nINFO --> Processing F1 reset request");
11352 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
11354 for(ieIdx=0; ieIdx<f1ResetMsg->protocolIEs.list.count; ieIdx++)
11356 switch(f1ResetMsg->protocolIEs.list.array[ieIdx]->id)
11358 case ProtocolIE_ID_id_TransactionID:
11361 case ProtocolIE_ID_id_Cause:
11364 case ProtocolIE_ID_id_ResetType:
11373 ret = BuildAndSendF1ResetAck();
11374 DU_LOG("\nINFO --> UE release is not supported for now");
11376 freeAperDecodeF1ResetMsg(f1ResetMsg);
11381 /*******************************************************************
11383 * @brief free the RRC delivery report
11387 * Function : freeRrcDeliveryReport
11389 * Functionality: free the RRC delivery report
11392 * @return ROK - success
11393 * RFAILED - failure
11395 * ****************************************************************/
11396 void freeRrcDeliveryReport(F1AP_PDU_t *f1apMsg )
11399 RRCDeliveryReport_t *rrcDeliveryReport= NULLP;
11403 if(f1apMsg->choice.initiatingMessage)
11405 rrcDeliveryReport = &f1apMsg->choice.initiatingMessage->value.choice.RRCDeliveryReport;
11406 if(rrcDeliveryReport->protocolIEs.list.array)
11408 for(idx =0 ;idx <rrcDeliveryReport->protocolIEs.list.count ;
11411 if(rrcDeliveryReport->protocolIEs.list.array[idx])
11413 DU_FREE(rrcDeliveryReport->protocolIEs.list.array[idx],
11414 sizeof(RRCDeliveryReportIEs_t));
11417 DU_FREE(rrcDeliveryReport->protocolIEs.list.array,
11418 rrcDeliveryReport->protocolIEs.list.size);
11420 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
11423 sizeof(F1AP_PDU_t));
11427 /*******************************************************************
11429 * @brief Builds and sends the RRC delivery report
11433 * Function : BuildAndSendRrcDeliveryReport
11435 * Functionality: Builds and sends the RRC delivery report
11439 * @return ROK - success
11440 * RFAILED - failure
11442 * ****************************************************************/
11443 uint8_t BuildAndSendRrcDeliveryReport(uint32_t gnbCuUeF1apId, \
11444 uint32_t gnbDuUeF1apId, RrcDeliveryReport *rrcDelivery)
11446 uint8_t ret = RFAILED;
11449 uint8_t elementCnt = 0;
11450 F1AP_PDU_t *f1apMsg = NULLP;
11451 asn_enc_rval_t encRetVal;
11452 RRCDeliveryReport_t *rrcDeliveryReport= NULLP;
11456 DU_LOG("\nINFO --> F1AP : Building RRC delivery Message Transfer Message\n");
11457 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
11458 if(f1apMsg == NULLP)
11460 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11463 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
11464 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
11465 if(f1apMsg->choice.initiatingMessage == NULLP)
11467 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11470 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_RRCDeliveryReport;
11471 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
11472 f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_RRCDeliveryReport;
11474 rrcDeliveryReport = &f1apMsg->choice.initiatingMessage->value.choice.RRCDeliveryReport;
11476 rrcDeliveryReport->protocolIEs.list.count = elementCnt;
11477 rrcDeliveryReport->protocolIEs.list.size = elementCnt * sizeof(RRCDeliveryReportIEs_t *);
11479 /* Initialize the F1Setup members */
11480 DU_ALLOC(rrcDeliveryReport->protocolIEs.list.array, rrcDeliveryReport->protocolIEs.list.size);
11481 if(rrcDeliveryReport->protocolIEs.list.array == NULLP)
11483 DU_LOG(" ERROR --> F1AP : Memory allocation for RRC Delivery failed");
11486 for(idx =0 ;idx <elementCnt; idx++)
11488 DU_ALLOC(rrcDeliveryReport->protocolIEs.list.array[idx], sizeof(RRCDeliveryReportIEs_t));
11489 if(rrcDeliveryReport->protocolIEs.list.array[idx] == NULLP)
11497 /*GNB CU UE F1AP ID*/
11498 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
11499 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
11500 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_GNB_CU_UE_F1AP_ID;
11501 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
11503 /*GNB DU UE F1AP ID*/
11505 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
11506 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
11507 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_GNB_DU_UE_F1AP_ID;
11508 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
11510 /*RRC delivery status*/
11512 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_RRCDeliveryStatus;
11513 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_ignore;
11514 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_RRCDeliveryStatus;
11515 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.RRCDeliveryStatus.delivery_status =\
11516 rrcDelivery->rrcDeliveryStatus.deliveryStatus;
11517 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.RRCDeliveryStatus.triggering_message =\
11518 rrcDelivery->rrcDeliveryStatus.triggeringMessage;
11522 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_SRBID;
11523 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_ignore;
11524 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_SRBID;
11525 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.SRBID = rrcDelivery->srbId;
11527 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
11529 /* Encode the RRC DELIVERY REPORT type as APER */
11530 memset(encBuf, 0, ENC_BUF_MAX_LEN);
11532 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
11535 /* Encode results */
11536 if(encRetVal.encoded == ENCODE_FAIL)
11538 DU_LOG("\nERROR --> F1AP : Could not encode RRC Delivery Msg structure (at %s)\n",\
11539 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
11544 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for RRC Delivery Msg \n");
11545 for(idx=0; idx< encBufSize; idx++)
11547 printf("%x",encBuf[idx]);
11552 if(sendF1APMsg() != ROK)
11554 DU_LOG("\nERROR --> F1AP : Sending RRC delivery msg request failed");
11562 freeRrcDeliveryReport(f1apMsg);
11566 /*******************************************************************
11568 * @brief Processes cells to be activated
11572 * Function : extractCellsToBeActivated
11575 * - Processes cells to be activated list received in F1SetupRsp
11578 * @return ROK - success
11579 * RFAILED - failure
11581 * ****************************************************************/
11583 uint8_t extractCellsToBeActivated(Cells_to_be_Activated_List_t cellsToActivate)
11586 uint16_t idx, nci, pci = 0;
11587 Cells_to_be_Activated_List_Item_t cell;
11589 for(idx=0; idx<cellsToActivate.list.count; idx++)
11592 cell = cellsToActivate.list.array[idx]->value.choice.Cells_to_be_Activated_List_Item;
11593 bitStringToInt(&cell.nRCGI.nRCellIdentity, &nci);
11599 ret = duProcCellsToBeActivated(cell.nRCGI.pLMN_Identity.buf, nci, pci);
11603 /******************************************************************
11605 * @brief Processes F1 Setup Response allocated by aper_decoder
11609 * Function : freeF1SetupRsp
11611 * Functionality: free F1 Setup Response allocated by aper_decoder
11613 * @params[in] F1SetupResponse_t *f1SetRspMsg
11616 * ****************************************************************/
11618 void freeAperDecodeF1SetupRsp(F1SetupResponse_t *f1SetRspMsg)
11622 Cells_to_be_Activated_List_t *cellToActivate =NULLP;
11623 RRC_Version_t *rrcVer =NULLP;
11625 if(f1SetRspMsg->protocolIEs.list.array)
11627 for(ieIdx=0; ieIdx<f1SetRspMsg->protocolIEs.list.count; ieIdx++)
11629 if(f1SetRspMsg->protocolIEs.list.array[ieIdx])
11631 switch(f1SetRspMsg->protocolIEs.list.array[ieIdx]->id)
11633 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
11636 &f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.Cells_to_be_Activated_List;
11637 if(cellToActivate->list.array)
11639 for(arrIdx=0; arrIdx<cellToActivate->list.count ; arrIdx++)
11641 if(cellToActivate->list.array[arrIdx])
11644 if(cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.nRCGI.\
11647 if(cellToActivate->list.array[0]->value.choice.\
11648 Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf)
11650 free(cellToActivate->list.array[0]->value.choice.\
11651 Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf);
11654 free(cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.\
11655 nRCGI.pLMN_Identity.buf);
11657 free(cellToActivate->list.array[arrIdx]);
11660 free(cellToActivate->list.array);
11664 case ProtocolIE_ID_id_TransactionID:
11668 case ProtocolIE_ID_id_gNB_CU_Name:
11670 free(f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_Name.buf);
11673 case ProtocolIE_ID_id_GNB_CU_RRC_Version:
11675 rrcVer = &f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.RRC_Version;
11676 if(rrcVer->latest_RRC_Version.buf)
11678 if(rrcVer->iE_Extensions)
11680 if(rrcVer->iE_Extensions->list.array)
11682 if(rrcVer->iE_Extensions->list.array[0])
11684 if(rrcVer->iE_Extensions->list.\
11685 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf)
11687 free(rrcVer->iE_Extensions->list.\
11688 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf);
11690 free(rrcVer->iE_Extensions->list.array[0]);
11692 free(rrcVer->iE_Extensions->list.array);
11694 free(rrcVer->iE_Extensions);
11696 free(rrcVer->latest_RRC_Version.buf);
11703 DU_LOG("\nERROR --> DU_APP : Invalid IE received in F1SetupRsp:%ld",
11704 f1SetRspMsg->protocolIEs.list.array[ieIdx]->id);
11707 free(f1SetRspMsg->protocolIEs.list.array[ieIdx]);
11710 free(f1SetRspMsg->protocolIEs.list.array);
11713 /******************************************************************
11715 * @brief Processes F1 Setup Response sent by CU
11719 * Function : procF1SetupRsp
11721 * Functionality: Processes F1 Setup Response sent by CU
11723 * @params[in] F1AP_PDU_t ASN decoded F1AP message
11724 * @return ROK - success
11725 * RFAILED - failure
11727 * ****************************************************************/
11728 uint8_t procF1SetupRsp(F1AP_PDU_t *f1apMsg)
11732 F1SetupResponse_t *f1SetRspMsg = NULLP;
11733 GNB_CU_Name_t *cuName = NULLP;
11734 F1SetupRsp f1SetRspDb;
11735 RRC_Version_t *rrcVer =NULLP;
11737 memset(&f1SetRspDb, 0, sizeof(F1SetupRsp));
11739 DU_LOG("\nINFO --> F1AP : F1 Setup Response received");
11740 f1SetRspMsg = &f1apMsg->choice.successfulOutcome->value.choice.F1SetupResponse;
11742 for(idx=0; idx<f1SetRspMsg->protocolIEs.list.count; idx++)
11744 switch(f1SetRspMsg->protocolIEs.list.array[idx]->id)
11746 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
11748 extractCellsToBeActivated(f1SetRspMsg->protocolIEs.list.array[idx]->\
11749 value.choice.Cells_to_be_Activated_List);
11752 case ProtocolIE_ID_id_TransactionID:
11754 f1SetRspDb.transId = f1SetRspMsg->protocolIEs.list.array[idx]->\
11755 value.choice.TransactionID;
11758 case ProtocolIE_ID_id_gNB_CU_Name:
11760 cuName = &f1SetRspMsg->protocolIEs.list.array[idx]->\
11761 value.choice.GNB_CU_Name;
11762 strcpy(f1SetRspDb.cuName, (const char*)cuName->buf);
11765 case ProtocolIE_ID_id_GNB_CU_RRC_Version:
11767 rrcVer = &f1SetRspMsg->protocolIEs.list.array[idx]->value.choice.RRC_Version;
11768 strcpy(f1SetRspDb.rrcVersion.rrcVer,
11769 (const char*)rrcVer->latest_RRC_Version.buf);
11773 DU_LOG("\nERROR --> DU_APP : Invalid IE received in F1SetupRsp:%ld",
11774 f1SetRspMsg->protocolIEs.list.array[idx]->id);
11776 duProcF1SetupRsp();
11779 freeAperDecodeF1SetupRsp(f1SetRspMsg);
11782 /*******************************************************************
11784 * @brief free GNB DU config update ack
11788 * Function : freeAperDecodeGnbDuAck
11790 * Functionality: Processes GNB DU config update ack And
11791 * added free part for the memory allocated by aper_decoder
11793 * @params[in] F1AP_PDU_t ASN decoded F1AP message
11794 * @return ROK - success
11795 * RFAILED - failure
11797 * ****************************************************************/
11799 void freeAperDecodeGnbDuAck(GNBDUConfigurationUpdateAcknowledge_t *gnbDuAck)
11803 if(gnbDuAck->protocolIEs.list.array)
11805 for(ieIdx=0; ieIdx < gnbDuAck->protocolIEs.list.count; ieIdx++)
11807 if(gnbDuAck->protocolIEs.list.array[ieIdx])
11809 free(gnbDuAck->protocolIEs.list.array[ieIdx]);
11812 free(gnbDuAck->protocolIEs.list.array);
11816 /*******************************************************************
11818 * @brief Building result of gnb-du config update ack output
11822 * Function : duProcGnbDuCfgUpdAckMsg
11825 * Building output of gnb-du config update ack
11827 * @params[in] transId
11830 * ****************************************************************/
11832 uint8_t duProcGnbDuCfgUpdAckMsg(uint8_t transId)
11834 uint8_t ieIdx=0, arrIdx=0,ret=ROK;
11835 uint8_t ueId =0 , ueIdx =0;
11836 uint16_t cellId =0, cellIdx =0, crnti=0;
11837 CmLList *f1apPduNode = NULLP;
11838 ReservedF1apPduInfo *f1apPduInfo =NULLP;
11839 F1AP_PDU_t *f1apMsgPdu = NULLP;
11840 GNBDUConfigurationUpdate_t *gnbDuConfigUpdate = NULLP;
11841 BIT_STRING_t *cellIdentity=NULLP;
11842 struct Served_Cells_To_Delete_ItemIEs *deleteItemIe=NULLP;
11843 Served_Cells_To_Delete_List_t *cellsToDelete=NULLP;
11844 Served_Cells_To_Delete_Item_t *deleteItem=NULLP;
11846 DU_LOG("\nINFO --> DU APP: GNB-DU config update Ack received ");
11847 f1apPduNode = searchFromReservedF1apPduList(transId);
11848 f1apPduInfo = (ReservedF1apPduInfo *)f1apPduNode->node;
11849 f1apMsgPdu = (F1AP_PDU_t *)f1apPduInfo->f1apMsg;
11853 if(f1apMsgPdu->choice.initiatingMessage)
11855 gnbDuConfigUpdate = &f1apMsgPdu->choice.initiatingMessage->value.choice.GNBDUConfigurationUpdate;
11856 for(ieIdx=0; ieIdx < gnbDuConfigUpdate->protocolIEs.list.count; ieIdx++)
11858 switch(gnbDuConfigUpdate->protocolIEs.list.array[ieIdx]->id)
11860 case ProtocolIE_ID_id_Served_Cells_To_Delete_List:
11862 cellsToDelete = &gnbDuConfigUpdate->protocolIEs.list.array[ieIdx]->value.choice.\
11863 Served_Cells_To_Delete_List;
11864 if(cellsToDelete->list.array)
11866 if(cellsToDelete->list.array[arrIdx])
11868 deleteItemIe = (Served_Cells_To_Delete_ItemIEs_t*)cellsToDelete->list.array[arrIdx];
11869 deleteItem=&deleteItemIe->value.choice.Served_Cells_To_Delete_Item;
11870 if(deleteItem->oldNRCGI.nRCellIdentity.buf)
11872 cellIdentity = &deleteItem->oldNRCGI.nRCellIdentity;
11873 bitStringToInt(cellIdentity, &cellId);
11878 GET_CELL_IDX(cellId, cellIdx);
11879 if(duCb.actvCellLst[cellIdx] != NULLP)
11881 if(duCb.actvCellLst[cellIdx]->numActvUes == 0)
11883 duCb.actvCellLst[cellId-1]->cellStatus = DELETION_IN_PROGRESS;
11884 ret = duSendCellDeletReq(cellId);
11887 DU_LOG("ERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): Failed to send cell delete\
11888 request for cellId[%d]", cellId);
11893 for(ueIdx = 0; ueIdx < duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
11895 crnti = duCb.actvCellLst[cellIdx]->ueCb[ueIdx].crnti;
11896 GET_UE_IDX(crnti,ueId);
11897 ret = BuildAndSendUeContextReleaseReq(cellId, ueId);
11900 DU_LOG("ERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): Failed to build and send UE delete\
11901 request for cellId[%d]", cellId);
11908 DU_LOG("ERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): CellId [%d] not found", cellId);
11921 FreeDUConfigUpdate(f1apMsgPdu);
11922 deleteFromReservedF1apPduList(f1apPduNode);
11926 /*******************************************************************
11928 * @brief Processes GNB DU config update ack
11932 * Function : procF1GNBDUCfgUpdAck
11934 * Functionality: added free part for the memory allocated by aper_decoder
11936 * @params[in] F1AP_PDU_t *f1apMsg
11939 * ****************************************************************/
11940 uint8_t procF1GNBDUCfgUpdAck(F1AP_PDU_t *f1apMsg)
11942 uint8_t ieIdx=0,transId=0;
11943 GNBDUConfigurationUpdateAcknowledge_t *gnbDuAck = NULLP;
11945 DU_LOG("\nINFO --> F1AP : GNB-DU config update acknowledgment");
11946 gnbDuAck = &f1apMsg->choice.successfulOutcome->value.choice.GNBDUConfigurationUpdateAcknowledge;
11948 for(ieIdx=0; ieIdx < gnbDuAck->protocolIEs.list.count; ieIdx++)
11950 switch(gnbDuAck->protocolIEs.list.array[ieIdx]->id)
11952 case ProtocolIE_ID_id_TransactionID:
11954 transId = gnbDuAck->protocolIEs.list.array[ieIdx]->value.choice.TransactionID;
11957 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
11963 DU_LOG("\nERROR --> F1AP: procF1GNBDUCfgUpdAck(): Invalid IE Received: %ld", \
11964 gnbDuAck->protocolIEs.list.array[ieIdx]->id);
11970 duProcGnbDuCfgUpdAckMsg(transId);
11973 /* presently we are not supporting F1 Reset from DU to CU , we are only
11974 * supporting F1 Reset from CU to DU */
11976 if(BuildAndSendF1ResetReq() != ROK)
11982 freeAperDecodeGnbDuAck(gnbDuAck);
11985 /******************************************************************
11987 * @brief free DL RRC Message Transfer allocated by aper_decoder
11991 * Function : freeAperDecodef1DlRrcMsg
11993 * Functionality: free DL RRC Message Transfer allocated by aper_decoder
11995 * @params[in] DLRRCMessageTransfer_t *f1DlRrcMsg
11996 * @return ROK - success
11997 * RFAILED - failure
11999 * ****************************************************************/
12001 void freeAperDecodef1DlRrcMsg(DLRRCMessageTransfer_t *f1DlRrcMsg)
12004 RRCContainer_t *rrcContainer = NULLP;
12006 if(f1DlRrcMsg->protocolIEs.list.array)
12008 for(ieIdx=0; ieIdx<f1DlRrcMsg->protocolIEs.list.count; ieIdx++)
12010 if(f1DlRrcMsg->protocolIEs.list.array[ieIdx])
12012 switch(f1DlRrcMsg->protocolIEs.list.array[ieIdx]->id)
12014 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12016 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12018 case ProtocolIE_ID_id_SRBID:
12020 case ProtocolIE_ID_id_RRCContainer:
12022 rrcContainer =&f1DlRrcMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer;
12023 free(rrcContainer->buf);
12025 case ProtocolIE_ID_id_ExecuteDuplication:
12027 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
12031 free(f1DlRrcMsg->protocolIEs.list.array[ieIdx]);
12034 free(f1DlRrcMsg->protocolIEs.list.array);
12037 /******************************************************************
12039 * @brief Processes DL RRC Message Transfer sent by CU
12043 * Function : procF1DlRrcMsgTrans
12045 * Functionality: Processes DL RRC Message Transfer sent by CU
12047 * @params[in] F1AP_PDU_t ASN decoded F1AP message
12048 * @return ROK - success
12049 * RFAILED - failure
12051 * ****************************************************************/
12052 uint8_t procF1DlRrcMsgTrans(F1AP_PDU_t *f1apMsg)
12055 DLRRCMessageTransfer_t *f1DlRrcMsg = NULLP;
12057 memset(&dlMsg, 0, sizeof(F1DlRrcMsg));
12059 DU_LOG("\nINFO --> DU_APP : DL RRC message transfer Recevied");
12060 f1DlRrcMsg = &f1apMsg->choice.initiatingMessage->value.choice.DLRRCMessageTransfer;
12064 for(idx=0; idx<f1DlRrcMsg->protocolIEs.list.count; idx++)
12066 switch(f1DlRrcMsg->protocolIEs.list.array[idx]->id)
12068 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12070 dlMsg.gnbCuUeF1apId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID;
12073 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12075 dlMsg.gnbDuUeF1apId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID;
12078 case ProtocolIE_ID_id_SRBID:
12080 dlMsg.srbId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.SRBID;
12083 case ProtocolIE_ID_id_ExecuteDuplication:
12084 dlMsg.execDup = true;
12087 case ProtocolIE_ID_id_RRCContainer:
12089 if(f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size > 0)
12091 dlMsg.rrcMsgSize = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size;
12092 DU_ALLOC_SHRABL_BUF(dlMsg.rrcMsgPdu, dlMsg.rrcMsgSize);
12093 if(dlMsg.rrcMsgPdu)
12095 memcpy(dlMsg.rrcMsgPdu, f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.buf,\
12100 DU_LOG("\nERROR --> DU APP : Memory alloc Failed at RRC Container at procF1DlRrcMsgTrans()");
12106 DU_LOG("\nERROR --> DU_APP : RRC Container Size is invalid:%ld",\
12107 f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size);
12112 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
12114 dlMsg.deliveryStatRpt = true;
12118 DU_LOG("\nERROR --> DU_APP : Invalid IE received in DL RRC Msg Transfer:%ld",
12119 f1DlRrcMsg->protocolIEs.list.array[idx]->id);
12123 ret = duProcDlRrcMsg(&dlMsg);
12125 freeAperDecodef1DlRrcMsg(f1DlRrcMsg);
12128 /*******************************************************************
12130 * @brief Builds the DRB to be Setup Mod list
12136 * Functionality: Constructs the DRB to be Setup Mod list
12138 * @params[in] DRBs_SetupMod_List_t *drbSet
12140 * @return ROK - success
12141 * RFAILED - failure
12143 * ****************************************************************/
12145 uint8_t BuildDrbSetupModList(DRBs_SetupMod_List_t *drbSet , DuUeCfg *ueCfg)
12149 struct DRBs_SetupMod_ItemIEs *drbItemIe;
12152 drbSet->list.count = drbCnt;
12153 drbSet->list.size = drbCnt * sizeof(DRBs_SetupMod_ItemIEs_t *);
12154 DU_ALLOC(drbSet->list.array, drbSet->list.size);
12155 if(drbSet->list.array == NULLP)
12157 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDrbToBeSetupModList");
12160 for(arrIdx=0; arrIdx<drbCnt; arrIdx++)
12162 DU_ALLOC(drbSet->list.array[arrIdx], sizeof(DRBs_SetupMod_ItemIEs_t));
12163 if(drbSet->list.array[arrIdx] == NULLP)
12165 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDrbToBeSetupModList");
12169 drbItemIe = (struct DRBs_SetupMod_ItemIEs *)drbSet->list.array[arrIdx];
12170 drbItemIe->id = ProtocolIE_ID_id_DRBs_SetupMod_Item;
12171 drbItemIe->criticality = Criticality_reject;
12172 drbItemIe->value.present = DRBs_SetupMod_ItemIEs__value_PR_DRBs_SetupMod_Item;
12173 drbItemIe->value.choice.DRBs_SetupMod_Item.dRBID = ueCfg->upTnlInfo[arrIdx].drbId;
12174 if(fillDlTnlSetupList(&drbItemIe->value.choice.DRBs_SetupMod_Item.dLUPTNLInformation_ToBeSetup_List,\
12175 &ueCfg->upTnlInfo[arrIdx])!= ROK)
12177 DU_LOG("\nERROR --> F1AP : Failed to fill DlTnl SetupList in BuildDrbToBeSetupModList");
12185 /*******************************************************************
12186 * @brief Free the memory allocated for DRB setup List
12190 * Function : FreeDrbSetupModList
12193 * Free the memory allocated for DRB setup list
12195 * @params[in] DRBs_Setup_List_t *
12198 * ****************************************************************/
12199 void FreeDrbSetupModList(DRBs_SetupMod_List_t *drbSetupList)
12201 uint8_t arrIdx = 0;
12202 DRBs_SetupMod_ItemIEs_t *drbItemIe = NULLP;
12204 for(arrIdx = 0; arrIdx < drbSetupList->list.count; arrIdx++)
12206 drbItemIe = ((DRBs_SetupMod_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
12207 freeDlTnlInfo(&drbItemIe->value.choice.DRBs_SetupMod_Item.dLUPTNLInformation_ToBeSetup_List);
12208 DU_FREE(drbSetupList->list.array[arrIdx], sizeof(DRBs_SetupMod_ItemIEs_t));
12210 DU_FREE(drbSetupList->list.array, drbSetupList->list.size);
12212 /*******************************************************************
12213 * @brief Free the memory allocated for UE Context Mod Response
12217 * Function : FreeUeContextModResp
12220 * Free the memory allocated for UE Context Mod Response
12222 * @params[in] F1AP_PDU_t *f1apMsg
12225 * ****************************************************************/
12227 void FreeUeContextModResp(F1AP_PDU_t *f1apMsg)
12230 UEContextModificationResponse_t *ueContextModifyRes = NULLP;
12233 if(f1apMsg->choice.successfulOutcome)
12235 ueContextModifyRes =&f1apMsg->choice.successfulOutcome->value.choice.UEContextModificationResponse;
12236 if(ueContextModifyRes->protocolIEs.list.array)
12238 for(ieIdx=0 ; ieIdx<ueContextModifyRes->protocolIEs.list.count; ieIdx++)
12240 if(ueContextModifyRes->protocolIEs.list.array[ieIdx])
12242 switch(ueContextModifyRes->protocolIEs.list.array[ieIdx]->id)
12244 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12246 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12248 case ProtocolIE_ID_id_DRBs_SetupMod_List:
12250 FreeDrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
12251 value.choice.DRBs_SetupMod_List));
12255 DU_FREE(ueContextModifyRes->protocolIEs.list.array[ieIdx], sizeof(UEContextModificationResponse_t));
12259 DU_FREE(ueContextModifyRes->protocolIEs.list.array, ueContextModifyRes->protocolIEs.list.size);
12261 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
12263 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
12267 /*****************************************************************i
12269 * @brief Creating the ue context modifcation response and sending
12273 * Function : BuildAndSendUeContextModRsp
12276 * - Creating the ue context modifcation response
12278 * @params[in] uint8_t cellId,uint8_t ueIdx
12279 * @return ROK - success
12280 * RFAILED - failure
12282 * ****************************************************************/
12283 uint8_t BuildAndSendUeContextModRsp(uint8_t cellId,uint8_t ueIdx)
12286 uint8_t cellIdx =0;
12287 uint8_t elementCnt = 0;
12288 uint8_t ret = RFAILED;
12289 uint32_t gnbCuUeF1apId; /* gNB-CU UE F1AP Id */
12290 uint32_t gnbDuUeF1apId; /* gNB-DU UE F1AP Id */
12291 F1AP_PDU_t *f1apMsg = NULLP;
12292 asn_enc_rval_t encRetVal;
12293 UEContextModificationResponse_t *ueContextModifyRes = NULLP;
12294 DuUeCb *ueCb = NULLP;
12296 DU_LOG("\nINFO --> F1AP : Building Ue context modification response\n");
12300 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
12301 if(f1apMsg == NULLP)
12303 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed Ue context modification");
12307 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
12309 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
12310 if(f1apMsg->choice.successfulOutcome == NULLP)
12312 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed Ue context modification");
12315 f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_UEContextModification;
12316 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
12317 f1apMsg->choice.successfulOutcome->value.present = SuccessfulOutcome__value_PR_UEContextModificationResponse;
12319 ueContextModifyRes =&f1apMsg->choice.successfulOutcome->value.choice.UEContextModificationResponse;
12322 ueContextModifyRes->protocolIEs.list.count = elementCnt;
12323 ueContextModifyRes->protocolIEs.list.size = elementCnt*sizeof(UEContextModificationResponse_t*);
12325 /* Initialize the UE context modification members */
12326 DU_ALLOC(ueContextModifyRes->protocolIEs.list.array, ueContextModifyRes->protocolIEs.list.size);
12327 if(ueContextModifyRes->protocolIEs.list.array == NULLP)
12329 DU_LOG("\nERROR --> F1AP : Memory allocation for UE context modifcation Request failed");
12333 for(ieIdx=0 ; ieIdx<elementCnt; ieIdx++)
12335 DU_ALLOC(ueContextModifyRes->protocolIEs.list.array[ieIdx], sizeof(UEContextModificationResponse_t));
12336 if(ueContextModifyRes->protocolIEs.list.array[ieIdx] == NULLP)
12338 DU_LOG("\nERROR --> F1AP : Memory allocation for UE context modifcation Request failed");
12343 /* Fetching Ue Cb Info*/
12344 GET_CELL_IDX(cellId, cellIdx);
12345 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
12346 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
12347 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
12350 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
12351 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
12352 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present =\
12353 UEContextModificationResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
12354 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
12357 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
12358 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
12359 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present=\
12360 UEContextModificationResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
12361 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
12364 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DRBs_SetupMod_List;
12365 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
12366 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present =\
12367 UEContextModificationResponseIEs__value_PR_DRBs_SetupMod_List;
12370 ret = BuildDrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
12371 value.choice.DRBs_SetupMod_List) , &ueCb->f1UeDb->duUeCfg);
12374 DU_LOG( "\nERROR --> F1AP : Failed to build drb setupmod List ");
12377 freeF1UeDb(ueCb->f1UeDb);
12378 ueCb->f1UeDb = NULLP;
12380 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
12382 /* Encode the F1SetupRequest type as APER */
12383 memset(encBuf, 0, ENC_BUF_MAX_LEN);
12385 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,encBuf);
12387 /* Encode results */
12388 if(encRetVal.encoded == ENCODE_FAIL)
12390 DU_LOG( "\nERROR --> F1AP : Could not encode UE Context Setup Request structure (at %s)\n",\
12391 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
12397 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UE Context Modification Response\n");
12398 for(int i=0; i< encBufSize; i++)
12400 printf("%x",encBuf[i]);
12405 if(sendF1APMsg() != ROK)
12407 DU_LOG("\nERROR --> F1AP : Sending UE Context Setup Res Failed");
12413 FreeUeContextModResp(f1apMsg);
12416 /*******************************************************************
12418 * @brief Deallocating the memory allocated by the aper decoder
12423 * Function : freeAperDecodeQosInfo
12425 * Functionality: Deallocating the memory allocated for QOSInfo
12427 * @params[in] QoSFlowLevelQoSParameters_t *drbQos
12431 * ****************************************************************/
12433 void freeAperDecodeQosInfo(QoSFlowLevelQoSParameters_t *drbQos)
12435 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI != NULLP)
12437 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
12439 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
12441 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
12443 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
12445 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI);
12448 /*******************************************************************
12450 * @brief Deallocating the memory allocated by the aper decoder
12451 * for UlTnlInfoforDrb
12455 * Function : freeAperDecodeUlTnlInfoforDrbSetupMod
12457 * Functionality: Deallocating memory allocated for UlTnlInfoforDrb
12459 * @params[in] ULUPTNLInformation_ToBeSetup_List_t *ulInfo
12463 * ****************************************************************/
12464 void freeAperDecodeUlTnlInfoforDrbSetupMod(ULUPTNLInformation_ToBeSetup_List_t *ulInfo)
12468 if(ulInfo->list.array)
12470 for(arrIdx=0; arrIdx<ulInfo->list.count ; arrIdx++)
12472 if(ulInfo->list.array[arrIdx])
12474 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel )
12476 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.buf)
12478 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf)
12480 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\
12483 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\
12484 transportLayerAddress.buf);
12486 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel);
12488 free(ulInfo->list.array[arrIdx]);
12491 free(ulInfo->list.array);
12494 /*******************************************************************
12496 * @brief Deallocating the memory allocated by the aper decoder
12497 * for DrbSetupModItem
12501 * Function : freeAperDecodeDrbSetupModItem
12503 * Functionality: Deallocating memory allocated for DrbSetupModItem
12505 * @params[in] DRBs_ToBeSetupMod_Item_t *drbItem
12509 * ****************************************************************/
12511 void freeAperDecodeDrbSetupModItem(DRBs_ToBeSetupMod_Item_t *drbItem)
12514 SNSSAI_t *snssai =NULLP;
12515 Flows_Mapped_To_DRB_List_t *flowMap = NULLP;
12517 drbItem->qoSInformation.present = QoSInformation_PR_choice_extension;
12518 switch(drbItem->qoSInformation.present)
12520 case QoSInformation_PR_NOTHING:
12522 case QoSInformation_PR_eUTRANQoS:
12524 if(drbItem->qoSInformation.choice.eUTRANQoS)
12526 free(drbItem->qoSInformation.choice.eUTRANQoS);
12530 case QoSInformation_PR_choice_extension:
12532 if(drbItem->qoSInformation.choice.choice_extension)
12534 freeAperDecodeQosInfo(&drbItem->qoSInformation.choice.choice_extension->value.choice.\
12535 DRB_Information.dRB_QoS);
12536 snssai = &drbItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI;
12537 if(snssai->sST.buf)
12539 free(snssai->sST.buf);
12543 if(snssai->sD->buf)
12545 free(snssai->sD->buf);
12550 flowMap = &drbItem->qoSInformation.choice.choice_extension->value.choice.\
12551 DRB_Information.flows_Mapped_To_DRB_List;
12552 if(flowMap->list.array)
12554 for(arrIdx=0; arrIdx<flowMap->list.count; arrIdx++)
12556 if(flowMap->list.array[arrIdx] )
12558 freeAperDecodeQosInfo(&flowMap->list.array[arrIdx]->qoSFlowLevelQoSParameters);
12559 free(flowMap->list.array[arrIdx]);
12562 free(flowMap->list.array);
12565 free(drbItem->qoSInformation.choice.choice_extension);
12571 freeAperDecodeUlTnlInfoforDrbSetupMod(&drbItem->uLUPTNLInformation_ToBeSetup_List);
12572 if(drbItem->uLConfiguration)
12574 free(drbItem->uLConfiguration);
12578 /*******************************************************************
12580 * @brief Deallocating the memory allocated by the aper decoder
12581 * for DrbToBeSetupModList
12585 * Function : freeAperDecodeDrbToBeSetupModList
12587 * Functionality: Deallocating memory allocated for DrbToBeSetupModList
12589 * @params[in] DRBs_ToBeSetupMod_List_t *drbSet
12593 * ****************************************************************/
12595 void freeAperDecodeDrbToBeSetupModList(DRBs_ToBeSetupMod_List_t *drbSet)
12598 struct DRBs_ToBeSetupMod_ItemIEs *drbItemIe;
12600 if(drbSet->list.array)
12602 for(arrIdx=0; arrIdx<drbSet->list.count ; arrIdx++)
12604 if(drbSet->list.array[arrIdx] != NULLP)
12608 drbItemIe = (DRBs_ToBeSetupMod_ItemIEs_t *)drbSet->list.array[arrIdx];
12609 freeAperDecodeDrbSetupModItem(&(drbItemIe->value.choice.DRBs_ToBeSetupMod_Item));
12611 free(drbSet->list.array[arrIdx]);
12614 free(drbSet->list.array);
12618 /*******************************************************************
12620 * @brief Deallocating the memory allocated by the aper decoder
12621 * for UeContextModificationReqMsg
12625 * Function : freeAperDecodeUeContextModificationReqMsg
12627 * Functionality: Deallocating memory allocated for
12628 * UeContextModificationReqMsg
12630 * @params[in] UEContextModificationRequest_t *UeContextModifyReq
12634 * ****************************************************************/
12635 void freeAperDecodeUeContextModificationReqMsg(UEContextModificationRequest_t *UeContextModifyReq )
12637 uint8_t arrIdx, ieId;
12639 if(UeContextModifyReq->protocolIEs.list.array)
12641 for( arrIdx = 0 ; arrIdx<UeContextModifyReq->protocolIEs.list.count ; arrIdx++)
12643 if(UeContextModifyReq->protocolIEs.list.array[arrIdx])
12645 ieId = UeContextModifyReq->protocolIEs.list.array[arrIdx]->id;
12648 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12650 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12652 case ProtocolIE_ID_id_DRBs_ToBeSetupMod_List:
12654 freeAperDecodeDrbToBeSetupModList(&UeContextModifyReq->protocolIEs.list.array[arrIdx]->\
12655 value.choice.DRBs_ToBeSetupMod_List);
12659 free(UeContextModifyReq->protocolIEs.list.array[arrIdx]);
12662 free(UeContextModifyReq->protocolIEs.list.array);
12665 /*******************************************************************
12667 * @brief processing the F1 UeContextModificationReq
12671 * Function : procF1UeContextModificationReq
12673 * Functionality: processing the F1 UeContextModificationReq
12675 * @params[in] F1AP_PDU_t *f1apMsg
12678 * ****************************************************************/
12679 uint8_t procF1UeContextModificationReq(F1AP_PDU_t *f1apMsg)
12681 UEContextModificationRequest_t *ueContextModifyReq = NULLP;
12682 uint8_t ret = ROK, ieIdx = 0, lcId =0,cellIdx=0, ueIdx=0;
12683 DuUeCb *duUeCb = NULLP;
12684 DRBs_ToBeSetupMod_List_t *drbSetupModCfg;
12685 uint32_t gnbCuUeF1apId, gnbDuUeF1apId;
12687 ueContextModifyReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextModificationRequest;
12688 for(ieIdx=0; (ieIdx < ueContextModifyReq->protocolIEs.list.count && ret == ROK); ieIdx++)
12690 switch(ueContextModifyReq->protocolIEs.list.array[ieIdx]->id)
12692 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12694 gnbCuUeF1apId = ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID;
12697 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12699 gnbDuUeF1apId = ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID;
12702 case ProtocolIE_ID_id_DRBs_ToBeSetupMod_List:
12704 for(cellIdx = 0; cellIdx < duCb.numActvCells; cellIdx++)
12706 for(ueIdx = 0; ueIdx < duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
12708 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
12709 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
12712 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
12713 lcId = getDrbLcId(&duUeCb->drbBitMap);
12714 if(lcId != RFAILED)
12716 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
12719 duUeCb->f1UeDb->actionType = UE_CTXT_MOD;
12720 drbSetupModCfg = &ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.\
12721 choice.DRBs_ToBeSetupMod_List;
12722 if(extractDrbListToSetup(lcId, NULL, drbSetupModCfg ,drbSetupModCfg->list.count, \
12723 &duUeCb->f1UeDb->duUeCfg))
12725 DU_LOG("\nERROR --> DU APP : Failed at extractDrbListToSetup()");
12733 if(ueIdx >= duCb.actvCellLst[cellIdx]->numActvUes)
12735 DU_LOG("\nERROR --> DU APP : wrong values of gnbCuUeF1apId and gnbDuUeF1apId ");
12745 ret = duProcUeContextModReq(duUeCb);
12747 freeAperDecodeUeContextModificationReqMsg(ueContextModifyReq);
12750 /*****************************************************************i
12752 * @brief Free memory allocated for UE Context Release Request
12756 * Function : FreeUeContextReleaseReq
12759 * - Free memory allocated for UE Context Release Request
12761 * @params[in] F1AP_PDU_t *f1apMsg
12764 * *************************************************************/
12765 void FreeUeContextReleaseReq(F1AP_PDU_t *f1apMsg)
12768 UEContextReleaseRequest_t *ueReleaseReq = NULLP;
12772 if(f1apMsg->choice.initiatingMessage)
12774 ueReleaseReq =&f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseRequest;
12775 if(ueReleaseReq->protocolIEs.list.array)
12777 for(ieIdx=0 ; ieIdx<ueReleaseReq->protocolIEs.list.count; ieIdx++)
12779 DU_FREE(ueReleaseReq->protocolIEs.list.array[ieIdx], sizeof(UEContextReleaseRequest_t));
12781 DU_FREE(ueReleaseReq->protocolIEs.list.array, ueReleaseReq->protocolIEs.list.size);
12783 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
12785 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
12789 /*****************************************************************i
12791 * @brief Build and Send UE Context Release Request
12795 * Function : BuildAndSendUeContextReleaseReq
12798 * - Build and Send UE Context Release Request
12801 * @return ROK - success
12802 * RFAILED - failure
12804 * *************************************************************/
12805 uint8_t BuildAndSendUeContextReleaseReq(uint16_t cellId, uint8_t ueIdx)
12807 bool memAllocFail = false;
12809 uint8_t ret = RFAILED;
12810 uint16_t cellIdx =0;
12811 uint16_t crnti = 0;
12812 uint8_t elementCnt = 0;
12813 uint32_t gnbCuUeF1apId =0; /* gNB-CU UE F1AP Id */
12814 uint32_t gnbDuUeF1apId =0; /* gNB-DU UE F1AP Id */
12815 asn_enc_rval_t encRetVal;
12816 F1AP_PDU_t *f1apMsg = NULLP;
12817 UEContextReleaseRequest_t *ueReleaseReq = NULLP;
12819 DU_LOG("\nINFO --> Building the UE Context Release Request");
12822 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
12823 if(f1apMsg == NULLP)
12825 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for f1apMsg");
12829 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
12830 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
12831 if(f1apMsg->choice.initiatingMessage == NULLP)
12833 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for\
12834 initiatingMessage");
12837 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_UEContextReleaseRequest;
12838 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
12839 f1apMsg->choice.initiatingMessage->value.present = \
12840 InitiatingMessage__value_PR_UEContextReleaseRequest;
12842 ueReleaseReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseRequest;
12846 ueReleaseReq->protocolIEs.list.count = elementCnt;
12847 ueReleaseReq->protocolIEs.list.size = elementCnt * sizeof(UEContextReleaseRequest_t *);
12849 /* Initialize the F1Setup members */
12850 DU_ALLOC(ueReleaseReq->protocolIEs.list.array,ueReleaseReq->protocolIEs.list.size);
12851 if(ueReleaseReq->protocolIEs.list.array == NULLP)
12853 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for IE array");
12856 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
12858 DU_ALLOC(ueReleaseReq->protocolIEs.list.array[ieIdx],\
12859 sizeof(UEContextReleaseRequest_t));
12860 if(ueReleaseReq->protocolIEs.list.array[ieIdx] == NULLP)
12862 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for IE elements");
12863 memAllocFail = true;
12867 if(memAllocFail == true)
12870 /* Fetching Ue Cb Info*/
12871 GET_CELL_IDX(cellId, cellIdx);
12872 if(duCb.actvCellLst[cellIdx] == NULLP)
12874 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): CellId[%d] does not exist", cellId);
12879 GET_CRNTI(crnti, ueIdx);
12880 if(duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti != crnti)
12882 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): crnti[%d] does not exist", crnti);
12885 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
12886 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
12890 ueReleaseReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
12891 ueReleaseReq->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
12892 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.present = \
12893 UEContextReleaseRequestIEs__value_PR_GNB_CU_UE_F1AP_ID;
12894 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID =gnbCuUeF1apId;
12897 ueReleaseReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
12898 ueReleaseReq->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
12899 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.present =\
12900 UEContextReleaseRequestIEs__value_PR_GNB_DU_UE_F1AP_ID;
12901 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID =gnbDuUeF1apId;
12903 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
12905 /* Encode the F1SetupRequest type as APER */
12906 memset(encBuf, 0, ENC_BUF_MAX_LEN);
12908 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
12909 /* Encode results */
12910 if(encRetVal.encoded == ENCODE_FAIL)
12912 DU_LOG("\nERROR --> F1AP : Could not encode UEContextReleaseRequest structure (at %s)\n",\
12913 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
12918 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UEContextReleaseRequest\n");
12919 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
12921 printf("%x",encBuf[ieIdx]);
12926 if(sendF1APMsg() != ROK)
12928 DU_LOG("\nERROR --> F1AP : Sending UE Context Release Request failed");
12935 FreeUeContextReleaseReq(f1apMsg);
12938 /*****************************************************************i
12940 * @brief Free memory allocated for UE Context Release Complete
12944 * Function : FreeUeContextReleaseComplete
12947 * - Free memory allocated for UE Context Release Complete
12949 * @params[in] F1AP_PDU_t *f1apMsg
12952 * *************************************************************/
12953 void FreeUeContextReleaseComplete(F1AP_PDU_t *f1apMsg)
12956 UEContextReleaseComplete_t *ueReleaseComplete = NULLP;
12960 if(f1apMsg->choice.successfulOutcome)
12962 ueReleaseComplete =&f1apMsg->choice.successfulOutcome->value.choice.UEContextReleaseComplete;
12963 if(ueReleaseComplete->protocolIEs.list.array)
12965 for(ieIdx=0 ; ieIdx<ueReleaseComplete->protocolIEs.list.count; ieIdx++)
12967 DU_FREE(ueReleaseComplete->protocolIEs.list.array[ieIdx], sizeof(UEContextReleaseComplete_t));
12969 DU_FREE(ueReleaseComplete->protocolIEs.list.array, ueReleaseComplete->protocolIEs.list.size);
12971 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
12973 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
12977 /*****************************************************************i
12979 * @brief Build and Send UE Context Release Complete
12983 * Function : BuildAndSendUeContextReleaseComplete
12986 * - Build and Send UE Context Release Complete
12988 * @params[in] cellId, gnbCuUeF1apId, gnbDuUeF1apId
12989 * @return ROK - success
12990 * RFAILED - failure
12992 * *************************************************************/
12993 uint8_t BuildAndSendUeContextReleaseComplete(uint16_t cellId, uint32_t gnbCuUeF1apId, uint32_t gnbDuUeF1apId)
12995 bool memAllocFail = false;
12996 uint8_t ieIdx =0, ret = RFAILED, elementCnt = 0;
12997 asn_enc_rval_t encRetVal;
12998 F1AP_PDU_t *f1apMsg = NULLP;
12999 UEContextReleaseComplete_t *ueReleaseComplete = NULLP;
13001 DU_LOG("\nINFO --> Building the UE Context Release Complete");
13004 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
13005 if(f1apMsg == NULLP)
13007 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for f1apMsg");
13011 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
13012 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
13013 if(f1apMsg->choice.successfulOutcome == NULLP)
13015 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for\
13016 successfulOutcome");
13019 f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_UEContextRelease;
13020 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
13021 f1apMsg->choice.successfulOutcome->value.present = \
13022 SuccessfulOutcome__value_PR_UEContextReleaseComplete;
13024 ueReleaseComplete = &f1apMsg->choice.successfulOutcome->value.choice.UEContextReleaseComplete;
13027 ueReleaseComplete->protocolIEs.list.count = elementCnt;
13028 ueReleaseComplete->protocolIEs.list.size = elementCnt * sizeof(UEContextReleaseComplete_t *);
13030 /* Initialize the UE Release Complete members */
13031 DU_ALLOC(ueReleaseComplete->protocolIEs.list.array,ueReleaseComplete->protocolIEs.list.size);
13032 if(ueReleaseComplete->protocolIEs.list.array == NULLP)
13034 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for IE array");
13037 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
13039 DU_ALLOC(ueReleaseComplete->protocolIEs.list.array[ieIdx],\
13040 sizeof(UEContextReleaseComplete_t));
13041 if(ueReleaseComplete->protocolIEs.list.array[ieIdx] == NULLP)
13043 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for IE\
13045 memAllocFail = true;
13049 if(memAllocFail == true)
13054 ueReleaseComplete->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
13055 ueReleaseComplete->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
13056 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.present = \
13057 UEContextReleaseCompleteIEs__value_PR_GNB_CU_UE_F1AP_ID;
13058 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID =gnbCuUeF1apId;
13061 ueReleaseComplete->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
13062 ueReleaseComplete->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
13063 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.present =\
13064 UEContextReleaseCompleteIEs__value_PR_GNB_DU_UE_F1AP_ID;
13065 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID =gnbDuUeF1apId;
13067 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
13069 /* Encode the F1SetupComplete type as APER */
13070 memset(encBuf, 0, ENC_BUF_MAX_LEN);
13072 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
13073 /* Encode results */
13074 if(encRetVal.encoded == ENCODE_FAIL)
13076 DU_LOG("\nERROR --> F1AP : Could not encode UEContextReleaseComplete structure (at %s)\n",\
13077 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
13082 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UEContextReleaseComplete\n");
13083 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
13085 printf("%x",encBuf[ieIdx]);
13090 if(sendF1APMsg() != ROK)
13092 DU_LOG("\nERROR --> F1AP : Sending UE Context Release Complete failed");
13101 duCb.actvCellLst[cellId-1]->cellStatus = DELETION_IN_PROGRESS;
13102 ret = duSendCellDeletReq(cellId);
13105 DU_LOG("\nERROR --> F1AP: BuildAndSendUeContextReleaseComplete(): Failed to process cell\
13106 Delete req for CellId");
13109 FreeUeContextReleaseComplete(f1apMsg);
13114 /*******************************************************************
13116 * @brief added free part for the memory allocated by aper_decoder
13120 * Function : freeAperDecodeUeContextReleaseCommand
13122 * Functionality: added free part for the memory allocated by aper_decoder
13124 * @params[in] F1AP_PDU_t *f1apMsg
13127 * ****************************************************************/
13128 void freeAperDecodeUeContextReleaseCommand(F1AP_PDU_t *f1apMsg)
13131 UEContextReleaseCommand_t *ueContextReleaseCommand = NULLP;
13133 ueContextReleaseCommand = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseCommand;
13135 if(ueContextReleaseCommand->protocolIEs.list.array)
13137 for(ieIdx=0; ieIdx < ueContextReleaseCommand->protocolIEs.list.count; ieIdx++)
13139 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx])
13141 switch(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id)
13143 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
13145 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
13147 case ProtocolIE_ID_id_Cause:
13149 case ProtocolIE_ID_id_RRCContainer:
13151 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
13153 free(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf);
13158 DU_LOG("\nERROR --> F1AP: freeAperDecodeUeContextReleaseCommand():Invalid IE Received: %ld"\
13159 ,ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id);
13163 free(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]);
13165 free(ueContextReleaseCommand->protocolIEs.list.array);
13168 /*******************************************************************
13170 * @brief processing of UE Context Release Command
13174 * Function : procF1UeContextReleaseCommand
13176 * Functionality: processing of UE Context Release Command
13178 * @params[in] F1AP_PDU_t *f1apMsg
13181 * ****************************************************************/
13182 uint8_t procF1UeContextReleaseCommand(F1AP_PDU_t *f1apMsg)
13184 uint8_t ieIdx=0, ret=ROK, ueIdx=0;
13185 uint16_t cellIdx =0;
13187 uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId=0;
13188 DuUeCb *duUeCb = NULLP;
13189 UEContextReleaseCommand_t *ueContextReleaseCommand = NULLP;
13191 ueContextReleaseCommand = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseCommand;
13193 if(ueContextReleaseCommand->protocolIEs.list.array)
13195 for(ieIdx=0; ieIdx < ueContextReleaseCommand->protocolIEs.list.count; ieIdx++)
13197 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx])
13199 switch(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id)
13201 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
13203 gnbCuUeF1apId= ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
13204 value.choice.GNB_CU_UE_F1AP_ID;
13208 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
13210 gnbDuUeF1apId = ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
13211 value.choice.GNB_DU_UE_F1AP_ID;
13215 case ProtocolIE_ID_id_Cause:
13220 case ProtocolIE_ID_id_RRCContainer:
13222 for(cellIdx = 0; cellIdx < duCb.numActvCells; cellIdx++)
13224 for(ueIdx = 0; ueIdx < duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
13226 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
13227 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
13229 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
13230 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
13233 memset(duUeCb->f1UeDb, 0, sizeof(F1UeContextSetupDb));
13234 duUeCb->f1UeDb->actionType = UE_CTXT_RELEASE;
13235 duUeCb->f1UeDb->cellIdx = cellIdx;
13236 /* Filling Dl RRC Msg Info */
13237 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
13238 if(!duUeCb->f1UeDb->dlRrcMsg)
13240 DU_LOG("\nERROR --> DU APP : procF1UeContextReleaseCommand(): \
13241 Memory allocation failed ");
13246 duUeCb->f1UeDb->dlRrcMsgPres = true;
13247 memset(duUeCb->f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
13248 ret = extractDlRrcMsg(gnbDuUeF1apId, gnbCuUeF1apId, duUeCb->f1UeDb->dlRrcMsg,\
13249 &ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
13250 value.choice.RRCContainer);
13256 DU_LOG("\nERROR --> DU APP : procF1UeContextReleaseCommand(): \
13257 Memory allocation failed ");
13266 if(ueIdxFound == true)
13273 DU_LOG("\nERROR --> F1AP: DuUeCb is not found at procF1UeContextSetupReq()");
13281 DU_LOG("\nERROR --> F1AP: freeAperDecodeUeContextReleaseCommand():Invalid IE Received: %ld"\
13282 ,ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id);
13290 duProcUeContextReleaseCommand(duUeCb);
13292 freeAperDecodeUeContextReleaseCommand(f1apMsg);
13295 /**************************************************************
13297 * @brief Handles received F1AP message and sends back response
13301 * Function : F1APMsgHdlr
13304 * - Decodes received F1AP control message
13305 * - Prepares response message, encodes and sends to SCTP
13308 * @return ROK - success
13309 * RFAILED - failure
13311 * ****************************************************************/
13312 void F1APMsgHdlr(Buffer *mBuf)
13315 char *recvBuf =NULLP;
13317 MsgLen recvBufLen =0;
13318 F1AP_PDU_t *f1apMsg =NULLP;
13319 asn_dec_rval_t rval; /* Decoder return value */
13320 F1AP_PDU_t f1apasnmsg ;
13321 DU_LOG("\nINFO --> F1AP : Received F1AP message buffer");
13322 ODU_PRINT_MSG(mBuf, 0,0);
13324 /* Copy mBuf into char array to decode it */
13325 ODU_GET_MSG_LEN(mBuf, &recvBufLen);
13326 DU_ALLOC(recvBuf, (Size)recvBufLen);
13328 if(recvBuf == NULLP)
13330 DU_LOG("\nERROR --> F1AP : Memory allocation failed");
13333 if(ODU_COPY_MSG_TO_FIX_BUF(mBuf, 0, recvBufLen, (Data *)recvBuf, ©Cnt) != ROK)
13335 DU_LOG("\nERROR --> F1AP : Failed while copying %d", copyCnt);
13339 printf("\nDEBUG --> F1AP : Received flat buffer to be decoded : ");
13340 for(i=0; i< recvBufLen; i++)
13342 printf("%x",recvBuf[i]);
13345 /* Decoding flat buffer into F1AP messsage */
13346 f1apMsg = &f1apasnmsg;
13347 memset(f1apMsg, 0, sizeof(F1AP_PDU_t));
13349 rval = aper_decode(0, &asn_DEF_F1AP_PDU, (void **)&f1apMsg, recvBuf, recvBufLen, 0, 0);
13350 DU_FREE(recvBuf, (Size)recvBufLen);
13352 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
13354 DU_LOG("\nERROR --> F1AP : ASN decode failed");
13358 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
13360 switch(f1apMsg->present)
13362 case F1AP_PDU_PR_successfulOutcome:
13364 switch(f1apMsg->choice.successfulOutcome->value.present)
13366 case SuccessfulOutcome__value_PR_ResetAcknowledge:
13368 DU_LOG("\nINFO --> F1AP : F1ResetAcknowledge is received successfully ");
13371 case SuccessfulOutcome__value_PR_F1SetupResponse:
13373 #ifndef ODU_TEST_STUB
13374 procF1SetupRsp(f1apMsg);
13379 case SuccessfulOutcome__value_PR_GNBDUConfigurationUpdateAcknowledge:
13381 procF1GNBDUCfgUpdAck(f1apMsg);
13387 DU_LOG("\nERROR --> F1AP : Invalid type of SuccessfulOutcome__value_PR_ResetAcknowledge [%d]",\
13388 f1apMsg->choice.successfulOutcome->value.present);
13391 }/* End of switch(successfulOutcome) */
13392 free(f1apMsg->choice.successfulOutcome);
13395 case F1AP_PDU_PR_initiatingMessage:
13397 switch(f1apMsg->choice.initiatingMessage->value.present)
13399 case InitiatingMessage__value_PR_Reset:
13401 procF1ResetReq(f1apMsg);
13404 case InitiatingMessage__value_PR_DLRRCMessageTransfer:
13406 procF1DlRrcMsgTrans(f1apMsg);
13409 case InitiatingMessage__value_PR_UEContextSetupRequest:
13411 procF1UeContextSetupReq(f1apMsg);
13414 case InitiatingMessage__value_PR_UEContextModificationRequest:
13416 procF1UeContextModificationReq(f1apMsg);
13419 case InitiatingMessage__value_PR_UEContextReleaseCommand:
13421 procF1UeContextReleaseCommand(f1apMsg);
13426 DU_LOG("\nERROR --> F1AP : Invalid type of F1AP_PDU_PR_initiatingMessage [%d]",
13427 f1apMsg->choice.initiatingMessage->value.present);
13430 }/* End of switch(initiatingMessage) */
13431 free(f1apMsg->choice.initiatingMessage);
13437 DU_LOG("\nERROR --> F1AP : Invalid type of f1apMsg->present [%d]",f1apMsg->present);
13442 }/* End of switch(f1apMsg->present) */
13444 } /* End of F1APMsgHdlr */
13446 /**********************************************************************
13448 **********************************************************************/