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)
5243 uint8_t rsrcListIdx=0;
5244 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList_t=NULLP;
5246 if(puschCfg->pusch_TimeDomainAllocationList)
5248 timeDomAllocList_t=puschCfg->pusch_TimeDomainAllocationList;
5249 if(timeDomAllocList_t->choice.setup)
5251 if(timeDomAllocList_t->choice.setup->list.array)
5253 for(rsrcListIdx = 0; rsrcListIdx<timeDomAllocList_t->choice.setup->list.count; rsrcListIdx++)
5255 DU_FREE(timeDomAllocList_t->choice.setup->list.array[rsrcListIdx]->k2, sizeof(long));
5256 DU_FREE(timeDomAllocList_t->choice.setup->list.array[rsrcListIdx],\
5257 sizeof(PUSCH_TimeDomainResourceAllocation_t));
5259 DU_FREE(timeDomAllocList_t->choice.setup->list.array, \
5260 timeDomAllocList_t->choice.setup->list.size);
5262 DU_FREE(timeDomAllocList_t->choice.setup, \
5263 sizeof(struct PUSCH_TimeDomainResourceAllocationList));
5265 DU_FREE(puschCfg->transformPrecoder, sizeof(long));
5266 DU_FREE(puschCfg->pusch_TimeDomainAllocationList, \
5267 sizeof(struct PUSCH_Config__pusch_TimeDomainAllocationList));
5271 /*******************************************************************
5273 * @brief Frees memory allocated for InitialUlBWP
5277 * Function : FreeInitialUlBWP
5279 * Functionality: Deallocating memory of InitialUlBWP
5281 * @params[in] BWP_UplinkDedicated_t *ulBwp
5285 * ****************************************************************/
5286 void FreeInitialUlBWP(BWP_UplinkDedicated_t *ulBwp)
5288 uint8_t rSetIdx, rsrcIdx, k1Idx;
5289 SRS_Config_t *srsCfg = NULLP;
5290 PUSCH_Config_t *puschCfg = NULLP;
5291 PUCCH_Config_t *pucchCfg = NULLP;
5292 struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg = NULLP;
5293 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList = NULLP;
5294 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList = NULLP;
5295 struct SRS_Config__srs_ResourceToAddModList *resourceList = NULLP;
5297 if(ulBwp->pucch_Config)
5299 if(ulBwp->pucch_Config->choice.setup)
5301 pucchCfg = ulBwp->pucch_Config->choice.setup;
5302 if(pucchCfg->dl_DataToUL_ACK)
5304 if(pucchCfg->dl_DataToUL_ACK->list.array)
5306 for(k1Idx = 0; k1Idx < pucchCfg->dl_DataToUL_ACK->list.count; k1Idx++)
5308 DU_FREE(pucchCfg->dl_DataToUL_ACK->list.array[k1Idx], sizeof(long));
5310 DU_FREE(pucchCfg->dl_DataToUL_ACK->list.array, pucchCfg->dl_DataToUL_ACK->list.size);
5312 DU_FREE(pucchCfg->dl_DataToUL_ACK, sizeof(struct PUCCH_Config__dl_DataToUL_ACK));
5314 DU_FREE(ulBwp->pucch_Config->choice.setup, sizeof(PUCCH_Config_t));
5316 DU_FREE(ulBwp->pucch_Config, sizeof(struct BWP_UplinkDedicated__pucch_Config));
5319 if(ulBwp->pusch_Config)
5321 if(ulBwp->pusch_Config->choice.setup)
5323 puschCfg=ulBwp->pusch_Config->choice.setup;
5324 if(puschCfg->dataScramblingIdentityPUSCH)
5326 if(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
5328 FreePuschTimeDomAllocList(puschCfg);
5329 dmrsUlCfg=puschCfg->dmrs_UplinkForPUSCH_MappingTypeA;
5330 if(dmrsUlCfg->choice.setup)
5332 if(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
5334 if(dmrsUlCfg->choice.setup->transformPrecodingDisabled)
5336 DU_FREE(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0,\
5338 DU_FREE(dmrsUlCfg->choice.setup->transformPrecodingDisabled,
5339 sizeof(struct DMRS_UplinkConfig__transformPrecodingDisabled));
5341 DU_FREE(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition,
5344 DU_FREE(dmrsUlCfg->choice.setup,sizeof(DMRS_UplinkConfig_t));
5346 DU_FREE(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA, \
5347 sizeof(struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA));
5349 DU_FREE(puschCfg->dataScramblingIdentityPUSCH, sizeof(long));
5351 DU_FREE(ulBwp->pusch_Config->choice.setup, sizeof(PUSCH_Config_t));
5353 DU_FREE(ulBwp->pusch_Config, sizeof(struct BWP_UplinkDedicated__pusch_Config));
5355 /* Free SRS-Config */
5356 if(ulBwp->srs_Config)
5358 if(ulBwp->srs_Config->choice.setup)
5360 srsCfg = ulBwp->srs_Config->choice.setup;
5362 /* Free Resource Set to add/mod list */
5363 if(srsCfg->srs_ResourceSetToAddModList)
5365 rsrcSetList = srsCfg->srs_ResourceSetToAddModList;
5366 if(rsrcSetList->list.array)
5370 /* Free SRS resource Id list in this SRS resource set */
5371 if(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
5373 rsrcIdList = rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
5375 if(rsrcIdList->list.array)
5377 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count; rsrcIdx++)
5379 DU_FREE(rsrcIdList->list.array[rsrcIdx], sizeof(SRS_ResourceId_t));
5381 DU_FREE(rsrcIdList->list.array, rsrcIdList->list.size);
5383 DU_FREE(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList,\
5384 sizeof(struct SRS_ResourceSet__srs_ResourceIdList));
5387 /* Free resource type info for this SRS resource set */
5388 DU_FREE(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic, \
5389 sizeof(struct SRS_ResourceSet__resourceType__aperiodic));
5391 /* Free memory for each resource set */
5392 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
5394 DU_FREE(rsrcSetList->list.array[rSetIdx], sizeof(SRS_ResourceSet_t));
5396 DU_FREE(rsrcSetList->list.array, rsrcSetList->list.size);
5398 DU_FREE(srsCfg->srs_ResourceSetToAddModList, \
5399 sizeof(struct SRS_Config__srs_ResourceSetToAddModList));
5402 /* Free resource to add/modd list */
5403 if(srsCfg->srs_ResourceToAddModList)
5405 resourceList = srsCfg->srs_ResourceToAddModList;
5406 if(resourceList->list.array)
5409 DU_FREE(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2,\
5410 sizeof(struct SRS_Resource__transmissionComb__n2));
5411 DU_FREE(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic,\
5412 sizeof(struct SRS_Resource__resourceType__aperiodic));
5414 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
5416 DU_FREE(resourceList->list.array[rsrcIdx], sizeof(SRS_Resource_t));
5418 DU_FREE(resourceList->list.array, resourceList->list.size);
5420 DU_FREE(srsCfg->srs_ResourceToAddModList, \
5421 sizeof(struct SRS_Config__srs_ResourceToAddModList));
5424 DU_FREE(ulBwp->srs_Config->choice.setup, sizeof(SRS_Config_t));
5426 DU_FREE(ulBwp->srs_Config, sizeof(struct BWP_UplinkDedicated__srs_Config));
5430 /*******************************************************************
5432 * @brief Frees memory allocated for initialUplinkBWP
5436 * Function : FreeinitialUplinkBWP
5438 * Functionality: Deallocating memory of initialUplinkBWP
5440 * @params[in] UplinkConfig_t *ulCfg
5445 * ****************************************************************/
5446 void FreeinitialUplinkBWP(UplinkConfig_t *ulCfg)
5448 BWP_UplinkDedicated_t *ulBwp=NULLP;
5449 struct UplinkConfig__pusch_ServingCellConfig *puschCfg=NULLP;
5451 if(ulCfg->initialUplinkBWP)
5453 ulBwp=ulCfg->initialUplinkBWP;
5454 if(ulCfg->firstActiveUplinkBWP_Id)
5456 if(ulCfg->pusch_ServingCellConfig)
5458 puschCfg=ulCfg->pusch_ServingCellConfig;
5459 if(puschCfg->choice.setup)
5461 if(puschCfg->choice.setup->ext1)
5463 DU_FREE(puschCfg->choice.setup->ext1->\
5464 processingType2Enabled,sizeof(BOOLEAN_t));
5465 DU_FREE(puschCfg->choice.setup->ext1->\
5466 maxMIMO_Layers,sizeof(long));
5467 DU_FREE(puschCfg->choice.setup->ext1, \
5468 sizeof(struct PUSCH_ServingCellConfig__ext1));
5470 DU_FREE(puschCfg->choice.setup, sizeof(struct PUSCH_ServingCellConfig));
5472 DU_FREE(ulCfg->pusch_ServingCellConfig, sizeof(struct UplinkConfig__pusch_ServingCellConfig));
5474 DU_FREE(ulCfg->firstActiveUplinkBWP_Id, sizeof(BWP_Id_t));
5476 FreeInitialUlBWP(ulBwp);
5477 DU_FREE(ulCfg->initialUplinkBWP, sizeof(BWP_UplinkDedicated_t));
5480 /*******************************************************************
5482 * @brief Frees emmory allocated for BWPDlDedPdschCfg
5486 * Function : FreeBWPDlDedPdschCfg
5488 * Functionality: Deallocating memory of BWPDlDedPdschCfg
5490 * @params[in] BWP_DownlinkDedicated_t *dlBwp
5495 * ****************************************************************/
5496 void FreeBWPDlDedPdschCfg(BWP_DownlinkDedicated_t *dlBwp)
5498 struct PDSCH_Config *pdschCfg=NULLP;
5499 struct PDSCH_Config__prb_BundlingType *prbBndlType=NULLP;
5500 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList=NULLP;
5501 struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg=NULLP;
5503 if(dlBwp->pdsch_Config->choice.setup)
5505 pdschCfg=dlBwp->pdsch_Config->choice.setup;
5506 if(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
5508 if(pdschCfg->pdsch_TimeDomainAllocationList)
5510 timeDomAllocList=pdschCfg->pdsch_TimeDomainAllocationList;
5511 if(pdschCfg->maxNrofCodeWordsScheduledByDCI)
5513 prbBndlType=&pdschCfg->prb_BundlingType;
5514 DU_FREE(prbBndlType->choice.staticBundling,\
5515 sizeof(struct PDSCH_Config__prb_BundlingType__staticBundling));
5516 DU_FREE(pdschCfg->maxNrofCodeWordsScheduledByDCI, sizeof(long));
5518 FreePdschTimeDomAllocList(timeDomAllocList);
5519 DU_FREE(pdschCfg->pdsch_TimeDomainAllocationList, \
5520 sizeof(struct PDSCH_Config__pdsch_TimeDomainAllocationList));
5522 dmrsDlCfg=pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA;
5523 if(dmrsDlCfg->choice.setup)
5525 DU_FREE(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition,
5527 DU_FREE(dmrsDlCfg->choice.setup, sizeof(struct DMRS_DownlinkConfig));
5529 DU_FREE(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA, \
5530 sizeof(struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA));
5532 DU_FREE(dlBwp->pdsch_Config->choice.setup, sizeof(struct PDSCH_Config));
5535 /*******************************************************************
5537 * @brief Frees emmory allocated for BWPDlDedPdcchCfg
5541 * Function : FreeBWPDlDedPdcchCfg
5543 * Functionality: Deallocating memory of BWPDlDedPdcchCfg
5545 * @params[in] BWP_DownlinkDedicated_t *dlBwp
5550 * ****************************************************************/
5551 void FreeBWPDlDedPdcchCfg(BWP_DownlinkDedicated_t *dlBwp)
5555 struct PDCCH_Config *pdcchCfg=NULLP;
5556 struct ControlResourceSet *controlRSet=NULLP;
5557 struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList=NULLP;
5559 if(dlBwp->pdcch_Config->choice.setup)
5561 pdcchCfg=dlBwp->pdcch_Config->choice.setup;
5562 if(pdcchCfg->controlResourceSetToAddModList)
5564 controlRSetList = pdcchCfg->controlResourceSetToAddModList;
5565 if(controlRSetList->list.array)
5567 controlRSet = controlRSetList->list.array[idx2];
5570 if(controlRSet->frequencyDomainResources.buf)
5572 if(controlRSet->pdcch_DMRS_ScramblingID)
5574 if(pdcchCfg->searchSpacesToAddModList)
5576 FreeSearchSpcToAddModList(pdcchCfg->searchSpacesToAddModList);
5577 DU_FREE(pdcchCfg->searchSpacesToAddModList, \
5578 sizeof(struct PDCCH_Config__searchSpacesToAddModList));
5580 DU_FREE(controlRSet->pdcch_DMRS_ScramblingID, sizeof(long));
5582 DU_FREE(controlRSet->frequencyDomainResources.buf, \
5583 controlRSet->frequencyDomainResources.size);
5586 for(idx1 = 0; idx1 <controlRSetList->list.count; idx1++)
5588 DU_FREE(controlRSetList->list.array[idx1], sizeof(struct ControlResourceSet));
5590 DU_FREE(controlRSetList->list.array, controlRSetList->list.size);
5592 DU_FREE(pdcchCfg->controlResourceSetToAddModList, \
5593 sizeof(struct PDCCH_Config__controlResourceSetToAddModList));
5595 DU_FREE(dlBwp->pdcch_Config->choice.setup, sizeof(struct PDCCH_Config));
5599 /*******************************************************************
5601 * @brief Frees emmory allocated for DUToCURRCContainer
5605 * Function : FreeMemDuToCuRrcCont
5607 * Functionality: Deallocating memory of DuToCuRrcContainer
5609 * @params[in] DuToCuRRCContainer, DuToCuRRCContainer
5611 * @return ROK - success
5614 * ****************************************************************/
5615 uint8_t FreeMemDuToCuRrcCont(CellGroupConfigRrc_t *cellGrpCfg)
5618 SpCellConfig_t *spCellCfg=NULLP;
5619 ServingCellConfig_t *srvCellCfg=NULLP;
5620 BWP_DownlinkDedicated_t *dlBwp=NULLP;
5621 MAC_CellGroupConfig_t *macCellGrpCfg=NULLP;
5622 PhysicalCellGroupConfig_t *phyCellGrpCfg=NULLP;
5623 struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList=NULLP;
5624 struct RLC_Config *rlcConfig=NULLP;
5625 struct LogicalChannelConfig *macLcConfig=NULLP;
5626 struct SchedulingRequestConfig *schedulingRequestConfig=NULLP;
5627 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList=NULLP;
5628 struct TAG_Config *tagConfig=NULLP;
5629 struct TAG_Config__tag_ToAddModList *tagList=NULLP;
5630 struct MAC_CellGroupConfig__phr_Config *phrConfig=NULLP;
5631 struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg=NULLP;
5633 rlcBearerList = cellGrpCfg->rlc_BearerToAddModList;
5636 if(rlcBearerList->list.array)
5638 for(idx=0; idx<rlcBearerList->list.count; idx++)
5640 if(rlcBearerList->list.array[idx])
5642 rlcConfig = rlcBearerList->list.array[idx]->rlc_Config;
5643 macLcConfig = rlcBearerList->list.array[idx]->mac_LogicalChannelConfig;
5646 if(rlcConfig->choice.am)
5648 DU_FREE(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
5649 DU_FREE(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
5650 DU_FREE(rlcConfig->choice.am, sizeof(struct RLC_Config__am));
5652 DU_FREE(rlcConfig, sizeof(struct RLC_Config));
5654 DU_FREE(rlcBearerList->list.array[idx]->servedRadioBearer, sizeof(struct RLC_BearerConfig__servedRadioBearer));
5657 if(macLcConfig->ul_SpecificParameters)
5659 DU_FREE(macLcConfig->ul_SpecificParameters->schedulingRequestID, sizeof(SchedulingRequestId_t));
5660 DU_FREE(macLcConfig->ul_SpecificParameters->logicalChannelGroup, sizeof(long));
5661 DU_FREE(macLcConfig->ul_SpecificParameters, sizeof(struct LogicalChannelConfig__ul_SpecificParameters));
5663 DU_FREE(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig, sizeof(struct LogicalChannelConfig));
5665 DU_FREE(rlcBearerList->list.array[idx], sizeof(struct RLC_BearerConfig));
5668 DU_FREE(rlcBearerList->list.array, rlcBearerList->list.size);
5670 DU_FREE(cellGrpCfg->rlc_BearerToAddModList, sizeof(struct CellGroupConfigRrc__rlc_BearerToAddModList));
5673 macCellGrpCfg = cellGrpCfg->mac_CellGroupConfig;
5676 schedulingRequestConfig = macCellGrpCfg->schedulingRequestConfig;
5677 if(schedulingRequestConfig)
5679 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
5682 if(schReqList->list.array)
5684 for(idx=0;idx<schReqList->list.count; idx++)
5686 if(schReqList->list.array[idx])
5688 DU_FREE(schReqList->list.array[idx]->sr_ProhibitTimer, sizeof(long));
5689 DU_FREE(schReqList->list.array[idx], sizeof(struct SchedulingRequestToAddMod));
5692 DU_FREE(schReqList->list.array, schReqList->list.size);
5694 DU_FREE(schedulingRequestConfig->schedulingRequestToAddModList,\
5695 sizeof(struct SchedulingRequestConfig__schedulingRequestToAddModList)); }
5696 DU_FREE(macCellGrpCfg->schedulingRequestConfig, sizeof(struct SchedulingRequestConfig));
5698 if(macCellGrpCfg->bsr_Config)
5700 DU_FREE(macCellGrpCfg->bsr_Config, sizeof(struct BSR_Config));
5702 tagConfig = macCellGrpCfg->tag_Config;
5705 tagList = tagConfig->tag_ToAddModList;
5708 if(tagList->list.array)
5710 for(idx=0; idx<tagList->list.count; idx++)
5712 DU_FREE(tagList->list.array[idx], sizeof(struct TAG));
5714 DU_FREE(tagList->list.array, tagList->list.size);
5716 DU_FREE(tagConfig->tag_ToAddModList, sizeof(struct TAG_Config__tag_ToAddModList));
5718 DU_FREE(tagConfig, sizeof(struct TAG_Config));
5721 phrConfig = macCellGrpCfg->phr_Config;
5724 DU_FREE(phrConfig->choice.setup, sizeof(struct PHR_Config));
5725 DU_FREE(phrConfig, sizeof(struct MAC_CellGroupConfig__phr_Config));
5728 DU_FREE(macCellGrpCfg, sizeof(MAC_CellGroupConfig_t));
5731 phyCellGrpCfg = cellGrpCfg->physicalCellGroupConfig;
5734 DU_FREE(phyCellGrpCfg->p_NR_FR1, sizeof(long));
5735 DU_FREE(phyCellGrpCfg, sizeof(PhysicalCellGroupConfig_t));
5738 spCellCfg = cellGrpCfg->spCellConfig;
5741 if(spCellCfg->servCellIndex)
5743 if(spCellCfg->rlmInSyncOutOfSyncThreshold)
5745 if(spCellCfg->spCellConfigDedicated)
5747 srvCellCfg = spCellCfg->spCellConfigDedicated;
5748 if(srvCellCfg->tdd_UL_DL_ConfigurationDedicated)
5750 if(srvCellCfg->initialDownlinkBWP)
5752 dlBwp = srvCellCfg->initialDownlinkBWP;
5753 if(srvCellCfg->firstActiveDownlinkBWP_Id)
5755 if(srvCellCfg->defaultDownlinkBWP_Id)
5757 if(srvCellCfg->uplinkConfig)
5759 if(srvCellCfg->pdsch_ServingCellConfig)
5761 pdschCfg= srvCellCfg->pdsch_ServingCellConfig;
5762 if(pdschCfg->choice.setup)
5764 DU_FREE(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH,sizeof(long));
5765 DU_FREE(pdschCfg->choice.setup, sizeof( struct PDSCH_ServingCellConfig));
5767 DU_FREE(srvCellCfg->pdsch_ServingCellConfig, sizeof(struct
5768 ServingCellConfig__pdsch_ServingCellConfig));
5770 FreeinitialUplinkBWP(srvCellCfg->uplinkConfig);
5771 DU_FREE(srvCellCfg->uplinkConfig, sizeof(UplinkConfig_t));
5773 DU_FREE(srvCellCfg->defaultDownlinkBWP_Id, sizeof(long));
5775 DU_FREE(srvCellCfg->firstActiveDownlinkBWP_Id, sizeof(long));
5777 if(dlBwp->pdcch_Config)
5779 if(dlBwp->pdsch_Config)
5781 FreeBWPDlDedPdschCfg(dlBwp);
5782 DU_FREE(dlBwp->pdsch_Config, sizeof(struct BWP_DownlinkDedicated__pdsch_Config));
5784 FreeBWPDlDedPdcchCfg(dlBwp);
5785 DU_FREE(dlBwp->pdcch_Config, sizeof(struct BWP_DownlinkDedicated__pdcch_Config));
5787 DU_FREE(srvCellCfg->initialDownlinkBWP, sizeof(BWP_DownlinkDedicated_t));
5789 DU_FREE(srvCellCfg->tdd_UL_DL_ConfigurationDedicated, sizeof(TDD_UL_DL_ConfigDedicated_t));
5791 DU_FREE(spCellCfg->spCellConfigDedicated, sizeof(ServingCellConfig_t));
5793 DU_FREE(spCellCfg->rlmInSyncOutOfSyncThreshold, sizeof(long));
5795 DU_FREE(spCellCfg->servCellIndex, sizeof(long));
5797 DU_FREE(spCellCfg,sizeof(SpCellConfig_t));
5801 /*******************************************************************
5803 * @brief Builds DU To CU RRC Container
5807 * Function : BuildDuToCuRrcContainer
5809 * Functionality: Builds DuToCuRrcContainer
5811 * @params[in] idx, index in F1AP msg
5812 * DuToCuRRCContainer, DuToCuRRCContainer
5814 * @return ROK - success
5817 * ****************************************************************/
5818 uint8_t BuildDuToCuRrcContainer(DUtoCURRCContainer_t *duToCuRrcContainer)
5821 CellGroupConfigRrc_t cellGrpCfg;
5822 asn_enc_rval_t encRetVal;
5823 memset(&cellGrpCfg, 0, sizeof(CellGroupConfigRrc_t));
5824 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
5828 cellGrpCfg.cellGroupId = CELL_GRP_ID;
5830 cellGrpCfg.rlc_BearerToAddModList = NULLP;
5831 DU_ALLOC(cellGrpCfg.rlc_BearerToAddModList, sizeof(struct CellGroupConfigRrc__rlc_BearerToAddModList));
5832 if(!cellGrpCfg.rlc_BearerToAddModList)
5834 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5838 if(BuildRlcBearerToAddModList(cellGrpCfg.rlc_BearerToAddModList) != ROK)
5840 DU_LOG("\nERROR --> F1AP : BuildRlcBearerToAddModList failed");
5845 cellGrpCfg.rlc_BearerToReleaseList = NULLP;
5846 cellGrpCfg.mac_CellGroupConfig = NULLP;
5847 DU_ALLOC(cellGrpCfg.mac_CellGroupConfig, sizeof(MAC_CellGroupConfig_t));
5848 if(!cellGrpCfg.mac_CellGroupConfig)
5850 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5854 if(BuildMacCellGrpCfg(cellGrpCfg.mac_CellGroupConfig) != ROK)
5856 DU_LOG("\nERROR --> F1AP : BuildMacCellGrpCfg failed");
5861 cellGrpCfg.physicalCellGroupConfig = NULLP;
5862 DU_ALLOC(cellGrpCfg.physicalCellGroupConfig, sizeof(PhysicalCellGroupConfig_t));
5863 if(!cellGrpCfg.physicalCellGroupConfig)
5865 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5869 if(BuildPhyCellGrpCfg(cellGrpCfg.physicalCellGroupConfig) != ROK)
5871 DU_LOG("\nERROR --> F1AP : BuildPhyCellGrpCfg failed");
5876 cellGrpCfg.spCellConfig = NULLP;
5877 DU_ALLOC(cellGrpCfg.spCellConfig, sizeof(SpCellConfig_t));
5878 if(!cellGrpCfg.spCellConfig)
5880 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5884 if(BuildSpCellCfg(cellGrpCfg.spCellConfig) != ROK)
5886 DU_LOG("\nERROR --> F1AP : BuildSpCellCfg failed");
5891 cellGrpCfg.sCellToAddModList = NULLP;
5892 cellGrpCfg.sCellToReleaseList = NULLP;
5893 cellGrpCfg.ext1 = NULLP;
5895 /* encode cellGrpCfg into duToCuRrcContainer */
5896 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, &cellGrpCfg);
5897 memset(encBuf, 0, ENC_BUF_MAX_LEN);
5899 encRetVal = aper_encode(&asn_DEF_CellGroupConfigRrc, 0, &cellGrpCfg, PrepFinalEncBuf, encBuf);
5900 /* Encode results */
5901 if(encRetVal.encoded == ENCODE_FAIL)
5903 DU_LOG( "\nERROR --> F1AP : Could not encode DuToCuRrcContainer (at %s)\n",\
5904 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
5910 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for DuToCuRrcContainer\n");
5911 for(int i=0; i< encBufSize; i++)
5913 printf("%x",encBuf[i]);
5917 duToCuRrcContainer->size = encBufSize;
5918 DU_ALLOC(duToCuRrcContainer->buf, duToCuRrcContainer->size);
5919 if(!duToCuRrcContainer->buf)
5921 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDuToCuRrcContainer");
5927 memcpy(duToCuRrcContainer->buf, encBuf, duToCuRrcContainer->size);
5931 FreeMemDuToCuRrcCont(&cellGrpCfg);
5935 /*******************************************************************
5937 * @brief Free memory allocated in InitialULRRCMessage
5941 * Function : freeInitUlRrcMsgTransfer
5943 * Functionality: Free memory allocated in InitialULRRCMessage
5945 * @params[in]F1AP_PDU_t *f1apMsg)
5947 * @return ROK - success
5950 * ****************************************************************/
5952 uint8_t freeInitUlRrcMsgTransfer(F1AP_PDU_t *f1apMsg)
5954 uint8_t ieIdx, arrIdx;
5955 InitialULRRCMessageTransfer_t *initULRRCMsg=NULLP;
5959 if(f1apMsg->choice.initiatingMessage)
5961 initULRRCMsg = &f1apMsg->choice.initiatingMessage->value.\
5962 choice.InitialULRRCMessageTransfer;
5963 if(initULRRCMsg->protocolIEs.list.array)
5965 for(ieIdx = 0; ieIdx < initULRRCMsg->protocolIEs.list.count; ieIdx++)
5967 switch(initULRRCMsg->protocolIEs.list.array[ieIdx]->id)
5969 case ProtocolIE_ID_id_NRCGI:
5971 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.buf)
5973 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.buf)
5975 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.buf,\
5976 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.size);
5978 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.buf,\
5979 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.size);
5983 case ProtocolIE_ID_id_RRCContainer:
5985 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
5987 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf,\
5988 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size);
5992 case ProtocolIE_ID_id_DUtoCURRCContainer:
5994 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.buf)
5996 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.buf,
5997 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.size);
6005 for(arrIdx = 0; arrIdx < ieIdx; arrIdx++)
6007 if(initULRRCMsg->protocolIEs.list.array[arrIdx])
6009 DU_FREE(initULRRCMsg->protocolIEs.list.array[arrIdx],\
6010 sizeof(InitialULRRCMessageTransferIEs_t));
6013 DU_FREE(initULRRCMsg->protocolIEs.list.array, initULRRCMsg->protocolIEs.list.size);
6015 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
6017 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
6021 DU_LOG("\nERROR --> DU_APP : Recevied F1ap Pdu is null at freeInitUlRrcMsgTransfer()");
6027 /*******************************************************************
6029 * @brief Builds and sends the InitialULRRCMessage
6033 * Function : BuildAndSendInitialRrcMsgTransfer
6035 * Functionality: Constructs the Initial UL RRC Message Transfer and sends
6036 * it to the CU through SCTP.
6040 * @return ROK - success
6043 * ****************************************************************/
6044 uint8_t BuildAndSendInitialRrcMsgTransfer(uint32_t gnbDuUeF1apId, uint16_t crnti,
6045 uint16_t rrcContSize, uint8_t *rrcContainer)
6050 asn_enc_rval_t encRetVal;
6051 F1AP_PDU_t *f1apMsg = NULLP;
6052 InitialULRRCMessageTransfer_t *initULRRCMsg = NULLP;
6053 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
6057 DU_LOG("\n INFO --> F1AP : Building RRC Setup Request\n");
6058 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
6059 if(f1apMsg == NULLP)
6061 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
6064 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
6065 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
6066 if(f1apMsg->choice.initiatingMessage == NULLP)
6068 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
6071 f1apMsg->choice.initiatingMessage->procedureCode =\
6072 ProcedureCode_id_InitialULRRCMessageTransfer;
6073 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
6074 f1apMsg->choice.initiatingMessage->value.present = \
6075 InitiatingMessage__value_PR_InitialULRRCMessageTransfer;
6077 &f1apMsg->choice.initiatingMessage->value.choice.InitialULRRCMessageTransfer;
6079 initULRRCMsg->protocolIEs.list.count = elementCnt;
6080 initULRRCMsg->protocolIEs.list.size = \
6081 elementCnt * sizeof(InitialULRRCMessageTransferIEs_t *);
6082 /* Initialize the F1Setup members */
6083 DU_ALLOC(initULRRCMsg->protocolIEs.list.array,initULRRCMsg->protocolIEs.list.size);
6084 if(initULRRCMsg->protocolIEs.list.array == NULLP)
6086 DU_LOG(" ERROR --> F1AP : Memory allocation for\
6087 RRCSetupRequestMessageTransferIEs failed");
6090 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
6092 DU_ALLOC(initULRRCMsg->protocolIEs.list.array[ieIdx],\
6093 sizeof(InitialULRRCMessageTransferIEs_t));
6094 if(initULRRCMsg->protocolIEs.list.array[ieIdx] == NULLP)
6100 /*GNB DU UE F1AP ID*/
6101 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6102 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
6103 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6104 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present = \
6105 InitialULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
6106 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
6111 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6112 ProtocolIE_ID_id_NRCGI;
6113 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality =Criticality_reject;
6114 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present = \
6115 InitialULRRCMessageTransferIEs__value_PR_NRCGI;
6118 BuildNrcgi(&initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI);
6126 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6127 ProtocolIE_ID_id_C_RNTI;
6128 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6129 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
6130 InitialULRRCMessageTransferIEs__value_PR_C_RNTI;
6131 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.C_RNTI = crnti;
6135 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6136 ProtocolIE_ID_id_RRCContainer;
6137 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6138 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
6139 InitialULRRCMessageTransferIEs__value_PR_RRCContainer;
6141 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size = rrcContSize;
6142 DU_ALLOC(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf,
6143 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size)
6144 if(!initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
6146 DU_LOG(" ERROR --> F1AP : Memory allocation for RRCSetupRequestMessageTransferIEs failed");
6150 memcpy(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf, rrcContainer,
6151 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size);
6154 /*DUtoCURRCContainer*/
6156 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DUtoCURRCContainer;
6157 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6158 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
6159 InitialULRRCMessageTransferIEs__value_PR_DUtoCURRCContainer;
6161 ret = BuildDuToCuRrcContainer(&initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer);
6167 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
6169 /* Encode the F1SetupRequest type as APER */
6170 memset(encBuf, 0, ENC_BUF_MAX_LEN);
6172 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
6173 /* Encode results */
6174 if(encRetVal.encoded == ENCODE_FAIL)
6176 DU_LOG( "\nERROR --> F1AP : Could not encode Initial UL RRC Message Transfer\
6177 structure (at %s)\n",encRetVal.failed_type ? \
6178 encRetVal.failed_type->name : "unknown");
6185 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for Initial UL RRC\
6186 Message transfer\n");
6187 for(int i=0; i< encBufSize; i++)
6189 printf("%x",encBuf[i]);
6193 if(sendF1APMsg() != ROK)
6195 DU_LOG("\nERROR --> F1AP : Sending Initial UL RRC Message Transfer Failed");
6201 freeInitUlRrcMsgTransfer(f1apMsg);
6203 }/* End of BuildAndSendInitialRrcMsgTransfer*/
6205 /***** UE SETUP REQUEST *****/
6207 /*******************************************************************
6209 * @brief Free Qos And Snssai Drb Info
6213 * Function : freeDrbQosAndSnssaiInfo
6215 * Functionality: Free Qos And Snssai Drb Info
6217 * @params[in] LcCfg *lcCfg,
6220 * ****************************************************************/
6221 void freeDrbQosAndSnssaiInfo(LcCfg *lcCfg)
6225 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
6229 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
6233 /******************************************************************
6235 * @brief Function to delete the RLC Lc cfg from UE APP DB
6239 * Function : freeRlcLcCfg
6241 * Functionality: Function to delete the RLC Lc cfg from UE APP DB
6244 *****************************************************************/
6246 void freeRlcLcCfg(RlcBearerCfg *lcCfg)
6248 switch(lcCfg->rlcMode)
6254 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
6258 case RLC_UM_BI_DIRECTIONAL :
6260 if(lcCfg->u.umBiDirCfg)
6262 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
6266 case RLC_UM_UNI_DIRECTIONAL_UL :
6268 if(lcCfg->u.umUniDirUlCfg)
6270 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
6275 case RLC_UM_UNI_DIRECTIONAL_DL :
6277 if(lcCfg->u.umUniDirDlCfg)
6279 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
6284 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at freeRlcLcCfg()", lcCfg->rlcMode);
6289 /*******************************************************************
6291 * @brief Function to free MacLcCfg
6295 * Function : freeMacLcCfg
6297 * Functionality: Function to free MacLcCfg
6299 * @params[in] LcCfg *lcCfg,
6302 * ****************************************************************/
6304 void freeMacLcCfg(LcCfg *lcCfg)
6306 /* Deleting DRBQOS */
6309 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
6311 /* Deleting SNSSAI */
6314 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
6317 /*******************************************************************
6319 * @brief Free UE NR Capability received in UE Context setup request
6323 * Function : freeAperDecodeUeNrCapability
6326 * Free UE NR Capability received in UE Context setup request
6329 * @return ROK - success
6332 * ****************************************************************/
6333 void freeAperDecodeUeNrCapability(void *ueNrCapability)
6336 FeatureSets_t *featureSets =NULLP;
6337 UE_NR_Capability_t *ueNrCap = (UE_NR_Capability_t *)ueNrCapability;
6339 if(ueNrCap->rf_Parameters.supportedBandListNR.list.array)
6341 for(arrIdx = 0; arrIdx < ueNrCap->rf_Parameters.supportedBandListNR.list.count; arrIdx++)
6343 if(ueNrCap->rf_Parameters.supportedBandListNR.list.array[arrIdx])
6344 free(ueNrCap->rf_Parameters.supportedBandListNR.list.array[arrIdx]);
6346 free(ueNrCap->rf_Parameters.supportedBandListNR.list.array);
6349 if(ueNrCap->featureSets)
6351 featureSets = ueNrCap->featureSets;
6352 if(featureSets->featureSetsDownlinkPerCC)
6354 if(featureSets->featureSetsDownlinkPerCC->list.array)
6356 for(arrIdx = 0; arrIdx < featureSets->featureSetsDownlinkPerCC->list.count; arrIdx++)
6358 if(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx])
6360 if(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]->supportedModulationOrderDL)
6361 free(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]->supportedModulationOrderDL);
6362 free(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]);
6365 free(featureSets->featureSetsDownlinkPerCC->list.array);
6367 free(featureSets->featureSetsDownlinkPerCC);
6369 if(featureSets->featureSetsUplinkPerCC)
6371 if(featureSets->featureSetsUplinkPerCC->list.array)
6373 for(arrIdx = 0; arrIdx < featureSets->featureSetsUplinkPerCC->list.count; arrIdx++)
6375 if(featureSets->featureSetsUplinkPerCC->list.array[arrIdx])
6377 if(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]->supportedModulationOrderUL)
6378 free(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]->supportedModulationOrderUL);
6379 free(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]);
6382 free(featureSets->featureSetsUplinkPerCC->list.array);
6384 free(featureSets->featureSetsUplinkPerCC);
6386 free(ueNrCap->featureSets);
6390 /*******************************************************************
6392 * @brief Function to free PdcchSearchSpcToAddModList
6393 where memory allocated by aper_decoder
6397 * Function : freeAperDecodePdcchSearchSpcToAddModList
6399 * Functionality: Function to free PdcchSearchSpcToAddModList
6401 * @params[in] struct PDCCH_Config__searchSpacesToAddModList *searchSpcList
6404 * ****************************************************************/
6406 void freeAperDecodePdcchSearchSpcToAddModList(struct PDCCH_Config__searchSpacesToAddModList *searchSpcList)
6408 uint8_t searchSpcArrIdx=0;
6409 uint8_t searchSpcArrIdx1=0;
6410 struct SearchSpace *searchSpc=NULLP;
6413 if(searchSpcList->list.array)
6415 if(searchSpcList->list.array[searchSpcArrIdx1])
6417 searchSpc = searchSpcList->list.array[searchSpcArrIdx1];
6418 if(searchSpc->controlResourceSetId)
6420 if(searchSpc->monitoringSlotPeriodicityAndOffset)
6422 if(searchSpc->monitoringSymbolsWithinSlot)
6424 if(searchSpc->monitoringSymbolsWithinSlot->buf)
6426 if(searchSpc->nrofCandidates)
6428 if(searchSpc->searchSpaceType)
6430 free(searchSpc->searchSpaceType->choice.ue_Specific);
6431 free(searchSpc->searchSpaceType);
6433 free(searchSpc->nrofCandidates);
6435 free(searchSpc->monitoringSymbolsWithinSlot->buf);
6437 free(searchSpc->monitoringSymbolsWithinSlot);
6439 free(searchSpc->monitoringSlotPeriodicityAndOffset);
6441 free(searchSpc->controlResourceSetId);
6444 for(searchSpcArrIdx = 0; searchSpcArrIdx < searchSpcList->list.count; searchSpcArrIdx++)
6446 free(searchSpcList->list.array[searchSpcArrIdx]);
6448 free(searchSpcList->list.array);
6451 /*******************************************************************
6453 * @brief Function for free part for the memory allocated by aper_decoder
6457 * Function : freeAperDecodeBWPDlDedPdcchConfig
6459 * Functionality: Function to free BWPDlDedPdcchConfig
6464 * ****************************************************************/
6467 void freeAperDecodeBWPDlDedPdcchConfig(BWP_DownlinkDedicated_t *dlBwp)
6471 struct PDCCH_Config *pdcchCfg=NULLP;
6472 struct ControlResourceSet *controlRSet=NULLP;
6473 struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList=NULLP;
6475 if(dlBwp->pdcch_Config->choice.setup)
6477 pdcchCfg=dlBwp->pdcch_Config->choice.setup;
6478 if(pdcchCfg->controlResourceSetToAddModList)
6480 controlRSetList = pdcchCfg->controlResourceSetToAddModList;
6481 if(controlRSetList->list.array)
6483 controlRSet = controlRSetList->list.array[arrIdx2];
6486 if(controlRSet->frequencyDomainResources.buf)
6488 if(controlRSet->pdcch_DMRS_ScramblingID)
6490 if(pdcchCfg->searchSpacesToAddModList)
6492 freeAperDecodePdcchSearchSpcToAddModList(pdcchCfg->searchSpacesToAddModList);
6493 free(pdcchCfg->searchSpacesToAddModList);
6495 free(controlRSet->pdcch_DMRS_ScramblingID);
6497 free(controlRSet->frequencyDomainResources.buf);
6500 for(arrIdx1 = 0; arrIdx1 <controlRSetList->list.count; arrIdx1++)
6502 free(controlRSetList->list.array[arrIdx1]);
6504 free(controlRSetList->list.array);
6506 free(pdcchCfg->controlResourceSetToAddModList);
6508 free(dlBwp->pdcch_Config->choice.setup);
6511 /*******************************************************************
6513 * @brief Function to free PdschTimeDomAllocationList
6514 * where the memory allocated by aper_decoder
6518 * Function : freeAperDecodePdschTimeDomAllocationList
6520 * Functionality: Function to free PdschTimeDomAllocationList
6522 * @params[in] struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
6525 * ****************************************************************/
6528 void freeAperDecodePdschTimeDomAllocationList( struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList)
6532 if(timeDomAllocList->choice.setup)
6534 if(timeDomAllocList->choice.setup->list.array)
6536 for(arrIdx = 0; arrIdx <timeDomAllocList->choice.setup->list.count ; arrIdx++)
6538 free(timeDomAllocList->choice.setup->list.array[arrIdx]);
6540 free(timeDomAllocList->choice.setup->list.array);
6542 free(timeDomAllocList->choice.setup);
6546 /*******************************************************************
6548 * @brief Function to free BWPDlDedPdschConfig
6549 * where the memory allocated by aper_decoder
6553 * Function : freeAperDecodeBWPDlDedPdschConfig
6555 * Functionality: Function to free BWPDlDedPdschConfig
6557 * @params[in] BWP_DownlinkDedicated_t *dlBwp
6560 * ****************************************************************/
6563 void freeAperDecodeBWPDlDedPdschConfig(BWP_DownlinkDedicated_t *dlBwp)
6565 struct PDSCH_Config *pdschCfg=NULLP;
6566 struct PDSCH_Config__prb_BundlingType *prbBndlType=NULLP;
6567 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList=NULLP;
6568 struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg=NULLP;
6570 if(dlBwp->pdsch_Config->choice.setup)
6572 pdschCfg=dlBwp->pdsch_Config->choice.setup;
6573 if(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
6575 if(pdschCfg->pdsch_TimeDomainAllocationList)
6577 timeDomAllocList=pdschCfg->pdsch_TimeDomainAllocationList;
6578 if(pdschCfg->maxNrofCodeWordsScheduledByDCI)
6580 prbBndlType=&pdschCfg->prb_BundlingType;
6581 free(prbBndlType->choice.staticBundling);
6582 free(pdschCfg->maxNrofCodeWordsScheduledByDCI);
6584 freeAperDecodePdschTimeDomAllocationList(timeDomAllocList);
6585 free(pdschCfg->pdsch_TimeDomainAllocationList);
6587 dmrsDlCfg=pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA;
6588 if(dmrsDlCfg->choice.setup)
6590 free(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition);
6591 free(dmrsDlCfg->choice.setup);
6593 free(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA);
6595 free(dlBwp->pdsch_Config->choice.setup);
6598 /*******************************************************************
6600 * @brief Function to free PuschTimeDomAllocListCfg
6601 where the memory allocated by aper_decoder
6605 * Function : freeAperDecodePuschTimeDomAllocListCfg
6607 * Functionality: Function to free PuschTimeDomAllocListCfg
6609 * @params[in] PUSCH_Config_t *puschCfg
6612 * ****************************************************************/
6615 void freeAperDecodePuschTimeDomAllocListCfg(PUSCH_Config_t *puschCfg)
6619 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList_t=NULLP;
6621 if(puschCfg->pusch_TimeDomainAllocationList)
6623 timeDomAllocList_t=puschCfg->pusch_TimeDomainAllocationList;
6624 if(timeDomAllocList_t->choice.setup)
6626 if(timeDomAllocList_t->choice.setup->list.array)
6628 free(timeDomAllocList_t->choice.setup->list.array[arrIdx1]->k2);
6629 for(arrIdx = 0; arrIdx<timeDomAllocList_t->choice.setup->list.count; arrIdx++)
6631 free(timeDomAllocList_t->choice.setup->list.array[arrIdx]);
6633 free(timeDomAllocList_t->choice.setup->list.array);
6635 free(timeDomAllocList_t->choice.setup);
6637 free(puschCfg->transformPrecoder);
6638 free(puschCfg->pusch_TimeDomainAllocationList);
6641 /*******************************************************************
6643 * @brief Function to free InitialUlBWPConfig where memory allocated by aper_decoder
6647 * Function : freeAperDecodeInitialUlBWPConfig
6649 * Functionality: Function to free InitialUlBWPConfig
6651 * @params[in] BWP_UplinkDedicated_t *ulBwp
6654 * ****************************************************************/
6657 void freeAperDecodeInitialUlBWPConfig(BWP_UplinkDedicated_t *ulBwp)
6661 SRS_Config_t *srsCfg = NULLP;
6662 PUSCH_Config_t *puschCfg = NULLP;
6663 struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg = NULLP;
6664 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList = NULLP;
6665 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList = NULLP;
6666 struct SRS_Config__srs_ResourceToAddModList *resourceList = NULLP;
6668 if(ulBwp->pusch_Config)
6670 if(ulBwp->pusch_Config->choice.setup)
6672 puschCfg=ulBwp->pusch_Config->choice.setup;
6673 if(puschCfg->dataScramblingIdentityPUSCH)
6675 if(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
6677 freeAperDecodePuschTimeDomAllocListCfg(puschCfg);
6678 dmrsUlCfg=puschCfg->dmrs_UplinkForPUSCH_MappingTypeA;
6679 if(dmrsUlCfg->choice.setup)
6681 if(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
6683 if(dmrsUlCfg->choice.setup->transformPrecodingDisabled)
6685 free(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0);
6686 free(dmrsUlCfg->choice.setup->transformPrecodingDisabled);
6688 free(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition);
6690 free(dmrsUlCfg->choice.setup);
6692 free(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA);
6694 free(puschCfg->dataScramblingIdentityPUSCH);
6696 free(ulBwp->pusch_Config->choice.setup);
6698 free(ulBwp->pusch_Config);
6700 /* Free SRS-Config */
6701 if(ulBwp->srs_Config)
6703 if(ulBwp->srs_Config->choice.setup)
6705 srsCfg = ulBwp->srs_Config->choice.setup;
6707 /* Free Resource Set to add/mod list */
6708 if(srsCfg->srs_ResourceSetToAddModList)
6710 rsrcSetList = srsCfg->srs_ResourceSetToAddModList;
6711 if(rsrcSetList->list.array)
6715 /* Free SRS resource Id list in this SRS resource set */
6716 if(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
6719 rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
6721 if(rsrcIdList->list.array)
6723 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count;
6726 free(rsrcIdList->list.array[rsrcIdx]);
6728 free(rsrcIdList->list.array);
6730 free(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList);
6733 /* Free resource type info for this SRS resource set */
6735 free(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic);
6737 /* Free memory for each resource set */
6738 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
6740 free(rsrcSetList->list.array[rSetIdx]);
6742 free(rsrcSetList->list.array);
6744 free(srsCfg->srs_ResourceSetToAddModList);
6747 /* Free resource to add/modd list */
6748 if(srsCfg->srs_ResourceToAddModList)
6750 resourceList = srsCfg->srs_ResourceToAddModList;
6751 if(resourceList->list.array)
6755 free(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2);
6756 free(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic);
6758 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
6760 free(resourceList->list.array[rsrcIdx]);
6762 free(resourceList->list.array);
6764 free(srsCfg->srs_ResourceToAddModList);
6767 free(ulBwp->srs_Config->choice.setup);
6769 free(ulBwp->srs_Config);
6773 /*******************************************************************
6775 * @brief Function to free initialUplinkBWPConfig where memory allocated by aper_decoder
6779 * Function : freeAperDecodeinitialUplinkBWPConfig
6781 * Functionality: Function to free initialUplinkBWPConfig
6783 * @params[in] UplinkConfig_t *ulCfg
6786 * ****************************************************************/
6789 void freeAperDecodeinitialUplinkBWPConfig(UplinkConfig_t *ulCfg)
6791 BWP_UplinkDedicated_t *ulBwp=NULLP;
6792 struct UplinkConfig__pusch_ServingCellConfig *puschCfg=NULLP;
6794 if(ulCfg->initialUplinkBWP)
6796 ulBwp=ulCfg->initialUplinkBWP;
6797 if(ulCfg->firstActiveUplinkBWP_Id)
6799 if(ulCfg->pusch_ServingCellConfig)
6801 puschCfg=ulCfg->pusch_ServingCellConfig;
6802 if(puschCfg->choice.setup)
6804 if(puschCfg->choice.setup->ext1)
6806 free(puschCfg->choice.setup->ext1->processingType2Enabled);
6807 free(puschCfg->choice.setup->ext1->maxMIMO_Layers);
6808 free(puschCfg->choice.setup->ext1);
6810 free(puschCfg->choice.setup);
6812 free(ulCfg->pusch_ServingCellConfig);
6814 free(ulCfg->firstActiveUplinkBWP_Id);
6816 freeAperDecodeInitialUlBWPConfig(ulBwp);
6817 free(ulCfg->initialUplinkBWP);
6821 /*******************************************************************
6823 * @brief Function to free DuUeCfg
6827 * Function : freeDuUeCfg
6829 * Functionality: Function to free DuUeCfg
6831 * @params[in] DuUeCfg *ueCfg
6834 * ****************************************************************/
6835 void freeDuUeCfg(DuUeCfg *ueCfg)
6839 SpCellConfig_t *spCellCfg = NULLP;
6840 ServingCellConfig_t *srvCellCfg = NULLP;
6841 BWP_DownlinkDedicated_t *dlBwp = NULLP;
6842 MAC_CellGroupConfig_t *macCellGrpCfg = NULLP;
6843 PhysicalCellGroupConfig_t *phyCellGrpCfg = NULLP;
6844 struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList = NULLP;
6845 struct RLC_Config *rlcConfig = NULLP;
6846 struct LogicalChannelConfig *macLcConfig = NULLP;
6847 struct SchedulingRequestConfig *schedulingRequestConfig = NULLP;
6848 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList = NULLP;
6849 struct TAG_Config *tagConfig = NULLP;
6850 struct TAG_Config__tag_ToAddModList *tagList = NULLP;
6851 struct MAC_CellGroupConfig__phr_Config *phrConfig = NULLP;
6852 struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg = NULLP;
6853 CellGroupConfigRrc_t *cellGrpCfg = ueCfg->cellGrpCfg;
6855 if(ueCfg->ueNrCapability)
6857 freeAperDecodeUeNrCapability(ueCfg->ueNrCapability);
6858 DU_FREE(ueCfg->ueNrCapability, sizeof(UE_NR_Capability_t));
6859 ueCfg->ueNrCapability = NULLP;
6862 if(ueCfg->cellGrpCfg)
6865 rlcBearerList = cellGrpCfg->rlc_BearerToAddModList;
6868 if(rlcBearerList->list.array)
6870 for(arrIdx=0; arrIdx<rlcBearerList->list.count; arrIdx++)
6872 if(rlcBearerList->list.array[arrIdx])
6874 rlcConfig = rlcBearerList->list.array[arrIdx]->rlc_Config;
6875 macLcConfig = rlcBearerList->list.array[arrIdx]->mac_LogicalChannelConfig;
6877 if(rlcBearerList->list.array[arrIdx]->servedRadioBearer)
6879 free(rlcBearerList->list.array[arrIdx]->servedRadioBearer);
6883 if(rlcConfig->choice.am)
6885 free(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength);
6886 free(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength);
6887 free(rlcConfig->choice.am);
6889 free(rlcBearerList->list.array[arrIdx]->rlc_Config);
6893 if(macLcConfig->ul_SpecificParameters)
6895 free(macLcConfig->ul_SpecificParameters->schedulingRequestID);
6896 free(macLcConfig->ul_SpecificParameters->logicalChannelGroup);
6897 free(macLcConfig->ul_SpecificParameters);
6899 free(rlcBearerList->list.array[arrIdx]->mac_LogicalChannelConfig);
6901 free(rlcBearerList->list.array[arrIdx]);
6904 free(rlcBearerList->list.array);
6906 free(cellGrpCfg->rlc_BearerToAddModList);
6909 macCellGrpCfg = cellGrpCfg->mac_CellGroupConfig;
6912 schedulingRequestConfig = macCellGrpCfg->schedulingRequestConfig;
6913 if(schedulingRequestConfig)
6915 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
6918 if(schReqList->list.array)
6920 for(arrIdx=0;arrIdx<schReqList->list.count; arrIdx++)
6922 if(schReqList->list.array[arrIdx])
6924 free(schReqList->list.array[arrIdx]->sr_ProhibitTimer);
6925 free(schReqList->list.array[arrIdx]);
6928 free(schReqList->list.array);
6930 free(schedulingRequestConfig->schedulingRequestToAddModList);
6932 free(macCellGrpCfg->schedulingRequestConfig);
6934 if(macCellGrpCfg->bsr_Config)
6936 free(macCellGrpCfg->bsr_Config);
6938 tagConfig = macCellGrpCfg->tag_Config;
6941 tagList = tagConfig->tag_ToAddModList;
6944 if(tagList->list.array)
6946 for(arrIdx=0; arrIdx<tagList->list.count; arrIdx++)
6948 free(tagList->list.array[arrIdx]);
6950 free(tagList->list.array);
6952 free(tagConfig->tag_ToAddModList);
6957 phrConfig = macCellGrpCfg->phr_Config;
6960 free(phrConfig->choice.setup);
6964 free(macCellGrpCfg);
6967 phyCellGrpCfg = cellGrpCfg->physicalCellGroupConfig;
6970 free(phyCellGrpCfg->p_NR_FR1);
6971 free(phyCellGrpCfg);
6974 spCellCfg = cellGrpCfg->spCellConfig;
6977 if(spCellCfg->servCellIndex)
6979 if(spCellCfg->rlmInSyncOutOfSyncThreshold)
6981 if(spCellCfg->spCellConfigDedicated)
6983 srvCellCfg = spCellCfg->spCellConfigDedicated;
6984 if(srvCellCfg->initialDownlinkBWP)
6986 dlBwp = srvCellCfg->initialDownlinkBWP;
6987 if(srvCellCfg->firstActiveDownlinkBWP_Id)
6989 if(srvCellCfg->defaultDownlinkBWP_Id)
6991 if(srvCellCfg->uplinkConfig)
6994 if(srvCellCfg->pdsch_ServingCellConfig)
6997 srvCellCfg->pdsch_ServingCellConfig;
6998 if(pdschCfg->choice.setup)
7001 free(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH);
7002 free(pdschCfg->choice.setup);
7005 free(srvCellCfg->pdsch_ServingCellConfig);
7008 freeAperDecodeinitialUplinkBWPConfig(srvCellCfg->uplinkConfig);
7009 free(srvCellCfg->uplinkConfig);
7011 free(srvCellCfg->defaultDownlinkBWP_Id);
7014 free(srvCellCfg->firstActiveDownlinkBWP_Id);
7016 if(dlBwp->pdcch_Config)
7018 if(dlBwp->pdsch_Config)
7020 freeAperDecodeBWPDlDedPdschConfig(dlBwp);
7021 free(dlBwp->pdsch_Config);
7023 freeAperDecodeBWPDlDedPdcchConfig(dlBwp);
7024 free(dlBwp->pdcch_Config);
7026 free(srvCellCfg->initialDownlinkBWP);
7029 free(spCellCfg->spCellConfigDedicated);
7031 free(spCellCfg->rlmInSyncOutOfSyncThreshold);
7033 free(spCellCfg->servCellIndex);
7037 DU_FREE(ueCfg->cellGrpCfg, sizeof(CellGroupConfigRrc_t));
7038 ueCfg->cellGrpCfg = NULLP;
7042 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCfg->ambrCfg, sizeof(AmbrCfg));
7044 for(lcIdx = 0; lcIdx < ueCfg->numRlcLcs; lcIdx++)
7046 freeRlcLcCfg(&ueCfg->rlcLcCfg[lcIdx]);
7048 for(lcIdx = 0; lcIdx < ueCfg->numMacLcs; lcIdx++)
7050 freeMacLcCfg(&ueCfg->macLcCfg[lcIdx]);
7052 for(lcIdx = 0; lcIdx < ueCfg->numDrb; lcIdx++)
7054 DU_FREE(ueCfg->upTnlInfo[lcIdx].tnlCfg1, sizeof(GtpTnlCfg));
7058 /*******************************************************************
7060 * @brief Function to free UecontextSetupDb
7064 * Function : freeF1UeDb
7066 * Functionality: Function to free UecontextSetupDb
7068 * @params[in] UecontextSetupDb *
7071 * ****************************************************************/
7073 void freeF1UeDb(F1UeContextSetupDb *f1UeDb)
7076 if(f1UeDb->dlRrcMsg)
7078 if(f1UeDb->dlRrcMsg->rrcMsgPdu)
7080 //DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,\
7081 f1UeDb->dlRrcMsg->rrcMsgPdu, f1UeDb->dlRrcMsg->rrcMsgSize);
7083 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
7085 freeDuUeCfg(&f1UeDb->duUeCfg);
7086 memset(f1UeDb, 0, sizeof(F1UeContextSetupDb));
7087 DU_FREE(f1UeDb, sizeof(F1UeContextSetupDb));
7090 /*******************************************************************
7092 * @brief Function to build Am cfg Info
7096 * Function : extractRlcAmCfg
7098 * Functionality: Function to build Am cfg Info
7100 * @params[in] AmBearerCfg *
7103 * @return ROK/RFAILED
7105 * ****************************************************************/
7107 void extractRlcAmCfg(AmBearerCfg *amCfgToSet, struct RLC_Config__am *rlcAmCfg)
7112 if(rlcAmCfg->dl_AM_RLC.sn_FieldLength)
7114 amCfgToSet->ulAmCfg.snLenUl = *(rlcAmCfg->dl_AM_RLC.sn_FieldLength);
7115 /*TODO: Check the timer value when sent by real CU */
7116 amCfgToSet->ulAmCfg.reAssemTmr = rlcAmCfg->dl_AM_RLC.t_Reassembly;
7117 amCfgToSet->ulAmCfg.statProhTmr = rlcAmCfg->dl_AM_RLC.t_StatusProhibit;
7121 if(rlcAmCfg->ul_AM_RLC.sn_FieldLength)
7123 amCfgToSet->dlAmCfg.snLenDl = *(rlcAmCfg->ul_AM_RLC.sn_FieldLength);
7124 amCfgToSet->dlAmCfg.pollRetxTmr = rlcAmCfg->ul_AM_RLC.t_PollRetransmit;
7125 amCfgToSet->dlAmCfg.pollPdu = rlcAmCfg->ul_AM_RLC.pollPDU;
7126 amCfgToSet->dlAmCfg.pollByte = rlcAmCfg->ul_AM_RLC.pollByte;
7127 amCfgToSet->dlAmCfg.maxRetxTh = rlcAmCfg->ul_AM_RLC.maxRetxThreshold;
7132 /*******************************************************************
7134 * @brief Function to build Um Bi Info
7138 * Function : extractRlcUmBiCfg
7140 * Functionality: Function to build Um Bi Info
7142 * @params[in] UmBiDirBearerCfg *
7145 * @return ROK/RFAILED
7147 * ****************************************************************/
7149 void extractRlcUmBiCfg(UmBiDirBearerCfg *umBiCfgToSet, struct RLC_Config__um_Bi_Directional *rlcBiCfg)
7153 /* UL UM BI DIR Cfg */
7154 if(rlcBiCfg->dl_UM_RLC.sn_FieldLength)
7156 umBiCfgToSet->ulUmCfg.snLenUlUm = *(rlcBiCfg->dl_UM_RLC.sn_FieldLength);
7157 umBiCfgToSet->ulUmCfg.reAssemTmr = rlcBiCfg->dl_UM_RLC.t_Reassembly;
7160 /* DL UM BI DIR Cfg */
7161 if(rlcBiCfg->ul_UM_RLC.sn_FieldLength)
7162 umBiCfgToSet->dlUmCfg.snLenDlUm = *(rlcBiCfg->ul_UM_RLC.sn_FieldLength);
7166 /*******************************************************************
7168 * @brief Function to build Um Ul Info
7172 * Function : extractRlcUmUlCfg
7174 * Functionality: Function to build Um Ul Info
7176 * @params[in] UmUniDirUlBearerCfg *
7179 * @return ROK/RFAILED
7181 * ****************************************************************/
7183 void extractRlcUmUlCfg(UmUniDirUlBearerCfg *umUlCfgToSet, struct RLC_Config__um_Uni_Directional_DL *umUlCfg)
7187 if(umUlCfg->dl_UM_RLC.sn_FieldLength)
7189 umUlCfgToSet->ulUmCfg.snLenUlUm = *(umUlCfg->dl_UM_RLC.sn_FieldLength);
7190 umUlCfgToSet->ulUmCfg.reAssemTmr = umUlCfg->dl_UM_RLC.t_Reassembly;
7195 /*******************************************************************
7197 * @brief Function to build Um Uni Dl Info
7201 * Function : extractRlcUmDlCfg
7203 * Functionality: Function to build Um Uni Dl Info
7205 * @params[in] UmUniDirDlBearerCfg *
7208 * @return ROK/RFAILED
7210 * ****************************************************************/
7211 void extractRlcUmDlCfg(UmUniDirDlBearerCfg *umDlCfgToSet, struct RLC_Config__um_Uni_Directional_UL *umDlCfg)
7215 if(umDlCfg->ul_UM_RLC.sn_FieldLength)
7216 umDlCfgToSet->dlUmCfg.snLenDlUm = *(umDlCfg->ul_UM_RLC.sn_FieldLength);
7220 /*******************************************************************
7222 * @brief Function to extractRlcModeCfg
7226 * Function : extractRlcModeCfg
7228 * Functionality: Function to extractRlcModeCfg
7230 * @params[in] RLC_Config_t *
7233 * @return ROK/RFAILED
7235 * ****************************************************************/
7236 void extractRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *rlcDbCfg, RLC_Config_t *lcCfg)
7244 if(lcCfg->choice.am)
7246 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.amCfg, sizeof(AmBearerCfg));
7247 if(rlcDbCfg->u.amCfg)
7248 extractRlcAmCfg(rlcDbCfg->u.amCfg, lcCfg->choice.am);
7252 case RLC_UM_BI_DIRECTIONAL :
7254 if(lcCfg->choice.um_Bi_Directional)
7256 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
7257 if(rlcDbCfg->u.umBiDirCfg)
7258 extractRlcUmBiCfg(rlcDbCfg->u.umBiDirCfg, lcCfg->choice.um_Bi_Directional);
7262 case RLC_UM_UNI_DIRECTIONAL_UL :
7264 if(lcCfg->choice.um_Uni_Directional_DL)
7266 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
7267 if(rlcDbCfg->u.umUniDirUlCfg)
7268 extractRlcUmUlCfg(rlcDbCfg->u.umUniDirUlCfg, lcCfg->choice.um_Uni_Directional_DL);
7272 case RLC_UM_UNI_DIRECTIONAL_DL :
7274 if(lcCfg->choice.um_Uni_Directional_UL)
7276 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
7277 if(rlcDbCfg->u.umUniDirDlCfg)
7278 extractRlcUmDlCfg(rlcDbCfg->u.umUniDirDlCfg, lcCfg->choice.um_Uni_Directional_UL);
7283 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
7289 /*******************************************************************
7291 * @brief Function to extract extractUlLcCfg
7295 * Function : extractUlLcCfg
7297 * Functionality: Function to extract extractUlLcCfg
7299 * @params[in] UlLcCfg *f1UlLcCfg, LogicalChannelConfig_t *ulLcCfg
7302 * ****************************************************************/
7304 void extractUlLcCfg(UlLcCfg *f1UlLcCfg, LogicalChannelConfig_t *ulLcCfg)
7308 if(ulLcCfg->ul_SpecificParameters)
7310 f1UlLcCfg->priority = \
7311 ulLcCfg->ul_SpecificParameters->priority;
7312 if(ulLcCfg->ul_SpecificParameters->logicalChannelGroup)
7314 f1UlLcCfg->lcGroup = \
7315 *(ulLcCfg->ul_SpecificParameters->logicalChannelGroup);
7317 if(ulLcCfg->ul_SpecificParameters->schedulingRequestID)
7319 f1UlLcCfg->schReqId = \
7320 *(ulLcCfg->ul_SpecificParameters->schedulingRequestID);
7323 ulLcCfg->ul_SpecificParameters->prioritisedBitRate;
7325 ulLcCfg->ul_SpecificParameters->bucketSizeDuration;
7330 /*******************************************************************
7332 * @brief Function to procRlcLcCfg
7336 * Function : procRlcLcCfg
7338 * Functionality: Function to procRlcLcCfg
7340 * @params[in] rbId, lcId, rbType, rlcMod
7341 * RLC_Config_t *, RlcBearerCfg * ,
7344 * ****************************************************************/
7346 void procRlcLcCfg(uint8_t rbId, uint8_t lcId, uint8_t rbType, uint8_t rlcMode,\
7347 uint8_t configType, RLC_Config_t *f1RlcCfg, RlcBearerCfg *lcCfg)
7351 lcCfg->configType = configType;
7353 if(rbType == RB_TYPE_SRB)
7355 lcCfg->rbType = RB_TYPE_SRB;
7357 lcCfg->lcType = LCH_DCCH;
7358 lcCfg->rlcMode = RLC_AM;
7360 else if(rbType == RB_TYPE_DRB)
7362 lcCfg->rbType = RB_TYPE_DRB;
7364 lcCfg->lcType = LCH_DTCH;
7365 lcCfg->rlcMode = rlcMode;
7367 if(f1RlcCfg) /* rlc mode config recived */
7369 extractRlcModeCfg(lcCfg->rlcMode, lcCfg, f1RlcCfg);
7375 /*******************************************************************
7377 * @brief Fills DrbQos Info received by CU
7381 * Function : extractQosInfo
7383 * Functionality: Fills DrbQos Info received by CU
7385 * @params[in] DrbQosInfo *qosToAdd,
7386 * QoSFlowLevelQoSParameters_t *qosFlowCfg
7389 * ****************************************************************/
7391 void extractQosInfo(DrbQosInfo *qosToAdd, QoSFlowLevelQoSParameters_t *qosFlowCfg)
7393 qosToAdd->fiveQiType = qosFlowCfg->qoS_Characteristics.present;
7394 qosToAdd->u.nonDyn5Qi.fiveQi =\
7395 qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->fiveQI;
7396 if(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow)
7398 qosToAdd->u.nonDyn5Qi.avgWindow = \
7399 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
7401 qosToAdd->u.nonDyn5Qi.maxDataBurstVol = \
7402 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
7403 if(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->qoSPriorityLevel)
7405 qosToAdd->u.nonDyn5Qi.priorLevel = \
7406 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->qoSPriorityLevel);
7408 qosToAdd->ngRanRetPri.priorityLevel = \
7409 qosFlowCfg->nGRANallocationRetentionPriority.priorityLevel;
7410 qosToAdd->ngRanRetPri.preEmptionCap = \
7411 qosFlowCfg->nGRANallocationRetentionPriority.pre_emptionCapability;
7412 qosToAdd->ngRanRetPri.preEmptionVul = \
7413 qosFlowCfg->nGRANallocationRetentionPriority.pre_emptionVulnerability;
7414 if(qosFlowCfg->gBR_QoS_Flow_Information)
7416 memcpy(&qosToAdd->grbQosInfo.maxFlowBitRateDl, \
7417 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateDownlink.buf, \
7418 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateDownlink.size);
7419 memcpy(&qosToAdd->grbQosInfo.maxFlowBitRateUl, \
7420 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateUplink.buf, \
7421 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateUplink.size);
7422 memcpy(&qosToAdd->grbQosInfo.guarFlowBitRateDl,\
7423 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateDownlink.buf, \
7424 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateDownlink.size);
7425 memcpy(&qosToAdd->grbQosInfo.guarFlowBitRateUl,\
7426 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateUplink.buf, \
7427 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateUplink.size);
7429 qosToAdd->pduSessionId = 0;
7430 qosToAdd->ulPduSessAggMaxBitRate = 0;
7433 /*******************************************************************
7435 * @brief Function to extract GTP Tunnel Info from CU
7439 * Function : extractUpTnlInfo
7441 * Functionality: Function to extract GTP Tunnel Info from CU
7443 * @params[in] F1AP message
7444 * @return ROK/RFAILED
7446 * ****************************************************************/
7448 uint8_t extractUpTnlInfo(uint8_t drbId, uint8_t configType,\
7449 ULUPTNLInformation_ToBeSetup_List_t *tnlInfo, UpTnlCfg *upTnlInfo)
7452 uint32_t ipv4_du = 0;
7453 GTPTunnel_t *gtpTunnel = NULLP;
7455 upTnlInfo->drbId = drbId;
7456 upTnlInfo->configType = configType;
7458 cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
7460 cmInetAddr((char *)DU_IP_V4_ADDR, &ipv4_du);
7463 for(tnlIdx=0; tnlIdx < tnlInfo->list.count; tnlIdx++)
7465 if(tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.present == UPTransportLayerInformation_PR_gTPTunnel)
7467 if(tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.choice.gTPTunnel)
7469 gtpTunnel = tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.choice.gTPTunnel;
7470 DU_ALLOC(upTnlInfo->tnlCfg1, sizeof(GtpTnlCfg));
7471 if(upTnlInfo->tnlCfg1 == NULLP)
7473 DU_LOG("\nERROR --> F1AP : extractUpTnlInfo: Failed to allocate mmeory for tunnel cfg 1");
7476 bitStringToInt(>pTunnel->transportLayerAddress, &upTnlInfo->tnlCfg1->ulTnlAddress);
7477 upTnlInfo->tnlCfg1->dlTnlAddress = ipv4_du;
7478 if(gtpTunnel->gTP_TEID.size > 0)
7480 teIdStringToInt(gtpTunnel->gTP_TEID.buf, &upTnlInfo->tnlCfg1->teId);
7488 /*******************************************************************
7490 * @brief Function to extract Drb Qos Cfg Info from CU
7494 * Function : extractDrbQosCfg
7496 * Functionality: Function to extract Drb Qos Cfg Info from CU
7498 * @params[in] DRB_Information_t *drbInfo, LcCfg *macLcToAdd
7499 * @return ROK/RFAILED
7501 * ****************************************************************/
7503 uint8_t extractDrbQosCfg(DRB_Information_t *drbInfo, LcCfg *macLcToAdd )
7505 if(!macLcToAdd->drbQos)
7507 DU_ALLOC_SHRABL_BUF(macLcToAdd->drbQos, sizeof(DrbQosInfo));
7508 if(macLcToAdd->drbQos == NULLP)
7510 DU_LOG("\nERROR --> DUAPP:Memory failed at allocating DrbQos at extractDrbCfg()");
7515 if(drbInfo->dRB_QoS.qoS_Characteristics.present == QoS_Characteristics_PR_non_Dynamic_5QI)
7517 extractQosInfo(macLcToAdd->drbQos, &drbInfo->dRB_QoS);
7518 macLcToAdd->dlLcCfg.lcp = macLcToAdd->drbQos->ngRanRetPri.priorityLevel;
7520 if(!macLcToAdd->snssai)
7522 DU_ALLOC_SHRABL_BUF(macLcToAdd->snssai, sizeof(Snssai));
7523 if(macLcToAdd->snssai == NULLP)
7525 DU_LOG("\nERROR --> DUAPP : Memory failed at allocating SNSSAI at extractDrbCfg()");
7529 memcpy(&macLcToAdd->snssai->sst, drbInfo->sNSSAI.sST.buf, \
7530 drbInfo->sNSSAI.sST.size);
7531 if(drbInfo->sNSSAI.sD)
7533 memcpy(macLcToAdd->snssai->sd, drbInfo->sNSSAI.sD->buf, \
7534 drbInfo->sNSSAI.sD->size);
7538 /*******************************************************************
7540 * @brief Function to extract DRB info received from CU
7544 * Function : extractDrbCfg
7546 * Functionality: Function to extract DRB info received from CU
7548 * @params[in] F1AP message
7551 * ****************************************************************/
7552 uint8_t extractDrbCfg(DRBs_ToBeSetup_Item_t *drbItem,DRBs_ToBeSetupMod_Item_t *drbSetupModItem,\
7553 LcCfg *macLcToAdd, UpTnlCfg *upTnlInfo)
7555 DRB_Information_t *drbInfo = NULLP;
7557 if(drbItem != NULLP)
7559 if(extractUpTnlInfo(drbItem->dRBID, CONFIG_ADD, &drbItem->uLUPTNLInformation_ToBeSetup_List, upTnlInfo) != ROK)
7561 DU_LOG("\nERROR --> DUAPP : Failed to extract tunnel Cfg at extractDrbCfg()");
7564 if(drbItem->qoSInformation.present == QoSInformation_PR_choice_extension)
7566 if(drbItem->qoSInformation.choice.choice_extension->value.present == QoSInformation_ExtIEs__value_PR_DRB_Information)
7568 drbInfo = &drbItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information;
7569 if(extractDrbQosCfg(drbInfo , macLcToAdd) != ROK)
7571 DU_LOG("\nERROR --> DUAPP : Failed to extract qos Cfg at extractDrbCfg()");
7577 else if(drbSetupModItem != NULLP)
7579 if(extractUpTnlInfo(drbSetupModItem->dRBID, CONFIG_ADD, &drbSetupModItem->uLUPTNLInformation_ToBeSetup_List,\
7582 DU_LOG("\nERROR --> DUAPP : Failed to extract tunnel Cfg at extractDrbCfg()");
7585 if(drbSetupModItem->qoSInformation.present == QoSInformation_PR_choice_extension)
7587 if(drbSetupModItem->qoSInformation.choice.choice_extension->value.present ==\
7588 QoSInformation_ExtIEs__value_PR_DRB_Information)
7590 drbInfo = &drbSetupModItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information;
7591 if(extractDrbQosCfg(drbInfo , macLcToAdd) != ROK)
7593 DU_LOG("\nERROR --> DUAPP : Failed to extract qos Cfg at extractDrbCfg()");
7604 /*******************************************************************
7606 * @brief Function to extract RB info received from CU
7610 * Function : extractMacRbCfg
7612 * Functionality: Function to extract RB info received from CU
7614 * @params[in] F1AP message
7615 * @return ROK/RFAILED
7617 * ****************************************************************/
7619 uint8_t extractMacRbCfg(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbCfg,\
7620 DRBs_ToBeSetupMod_Item_t *drbSetupModCfg, LogicalChannelConfig_t *ulLcCfg, LcCfg *lcCfg, UpTnlCfg *upTnlInfo)
7624 if(extractDrbCfg(drbCfg, NULL, lcCfg, upTnlInfo) != ROK)
7626 DU_LOG("ERROR --> F1AP : Failed to build Drb Qos at extractMacRbCfg()");
7630 else if(drbSetupModCfg != NULLP)
7632 if(extractDrbCfg(NULL, drbSetupModCfg, lcCfg, upTnlInfo) != ROK)
7634 DU_LOG("ERROR --> F1AP : Failed to build Drb Qos at extractMacRbCfg()");
7640 lcCfg->drbQos = NULLP;
7641 lcCfg->snssai = NULLP;
7642 if(lcCfg->lcId == SRB2_LCID)
7643 lcCfg->dlLcCfg.lcp = LC_PRIORITY_3;
7645 lcCfg->dlLcCfg.lcp = LC_PRIORITY_1;
7649 lcCfg->ulLcCfgPres = true;
7650 extractUlLcCfg(&lcCfg->ulLcCfg, ulLcCfg);
7653 lcCfg->ulLcCfgPres = false;
7657 /*******************************************************************
7659 * @brief Function processing LC config info received from CU
7663 * Function : procMacLcCfg
7665 * Functionality: Function processing LC config info received from CU
7667 * @params[in] F1AP message
7668 * @return ROK/RFAILED
7670 * ****************************************************************/
7672 uint8_t procMacLcCfg(uint8_t lcId, uint8_t rbType, uint8_t configType,\
7673 DRBs_ToBeSetup_Item_t *drbItem, DRBs_ToBeSetupMod_Item_t *drbSetupModItem, LogicalChannelConfig_t *ulLcCfg,\
7674 LcCfg *lcCfg, UpTnlCfg *upTnlInfo)
7679 lcCfg->configType = configType;
7680 if(rbType == RB_TYPE_SRB)
7682 ret = extractMacRbCfg(lcId, NULL,NULL, ulLcCfg, lcCfg, NULL);
7684 else if(rbType == RB_TYPE_DRB)
7687 ret = extractMacRbCfg(lcId, drbItem, NULL, ulLcCfg, lcCfg, upTnlInfo);
7688 else if(drbSetupModItem != NULL)
7689 ret = extractMacRbCfg(lcId, NULL, drbSetupModItem, ulLcCfg, lcCfg, upTnlInfo);
7694 /*******************************************************************
7696 * @brief Function to extract Rlc cfg To Add/Mod in CellGrp Info
7700 * Function : extractRlcCfgToAddMod
7702 * Functionality: Function to extract Rlc cfg To Add/Mod in CellGrp Info
7704 * @params[in] CellGroupConfigRrc__rlc_BearerTo pointer
7706 * @return ROK/RFAILED
7708 * ****************************************************************/
7710 uint8_t extractRlcCfgToAddMod(struct CellGroupConfigRrc__rlc_BearerToAddModList *lcCfg, DuUeCfg *ueCfgDb)
7712 uint8_t idx, rbId, lcId, rlcMode, rbType;
7713 RLC_Config_t *f1RlcCfg = NULLP;
7714 LogicalChannelConfig_t *macUlLcCfg = NULLP;
7716 for(idx = 0; idx < lcCfg->list.count; idx++)
7718 lcId = lcCfg->list.array[idx]->logicalChannelIdentity;
7719 if(lcCfg->list.array[idx]->servedRadioBearer)
7721 /* RadioBearer for SRB/DRB */
7722 if(lcCfg->list.array[idx]->servedRadioBearer->present ==\
7723 RLC_BearerConfig__servedRadioBearer_PR_srb_Identity)
7725 rbId = lcCfg->list.array[idx]->servedRadioBearer->choice.srb_Identity;
7726 rbType = RB_TYPE_SRB;
7728 else if(lcCfg->list.array[idx]->servedRadioBearer->present ==\
7729 RLC_BearerConfig__servedRadioBearer_PR_drb_Identity)
7731 rbId = lcCfg->list.array[idx]->servedRadioBearer->choice.drb_Identity;
7732 rbType = RB_TYPE_DRB;
7736 DU_LOG("\nERROR --> No components present in Bearer config to ADD/MOD");
7739 /* MAC UL LC Config */
7740 if(lcCfg->list.array[idx]->mac_LogicalChannelConfig)
7742 macUlLcCfg = lcCfg->list.array[idx]->mac_LogicalChannelConfig;
7747 DU_LOG("\nERROR --> DUAPP: Received RadioBearer config is NULL");
7750 /* RLC Mode Config */
7751 if(lcCfg->list.array[idx]->rlc_Config)
7753 rlcMode = lcCfg->list.array[idx]->rlc_Config->present;
7754 f1RlcCfg = lcCfg->list.array[idx]->rlc_Config;
7757 /* Filling RLC/MAC Config*/
7758 memset(&ueCfgDb->macLcCfg[idx], 0, sizeof(LcCfg));
7759 memset(&ueCfgDb->rlcLcCfg[idx], 0, sizeof(RlcBearerCfg));
7760 procRlcLcCfg(rbId, lcId, rbType, rlcMode, CONFIG_UNKNOWN, f1RlcCfg, &(ueCfgDb->rlcLcCfg[idx]));
7761 if(procMacLcCfg(lcId, rbType, CONFIG_UNKNOWN, NULL, NULL, macUlLcCfg, &ueCfgDb->macLcCfg[idx], NULL) != ROK)
7763 DU_LOG("\nERROR --> DU APP : Failed while filling MAC LC config at extractRlcCfgToAddMod()");
7766 (ueCfgDb->numRlcLcs)++;
7767 (ueCfgDb->numMacLcs)++;
7769 //TODO: To send the failure cause in UeContextSetupRsp
7773 /*******************************************************************
7775 * @brief DeAlloc pdsch serv cell config info
7779 * Function : freeMacPdschServCellInfo
7781 * Functionality: DeAlloc pdsch serv cell config info
7783 * @params[in] PdschServCellCfg pointer
7786 * ****************************************************************/
7788 void freeMacPdschServCellInfo(PdschServCellCfg *pdsch)
7790 if(pdsch->xOverhead)
7792 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->xOverhead, sizeof(PdschXOverhead));
7794 if(pdsch->codeBlkGrpFlushInd)
7796 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->codeBlkGrpFlushInd, sizeof(bool));
7798 if(pdsch->maxCodeBlkGrpPerTb)
7800 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
7802 if(pdsch->maxMimoLayers)
7804 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->maxMimoLayers, sizeof(uint8_t));
7808 /*******************************************************************
7810 * @brief Free Serving cell Info
7814 * Function : freeMacServingCellInfo
7816 * Functionality: Free Serving cell Info
7818 * @params[in] ServCellCfgInfo *srvCellCfg
7821 * ****************************************************************/
7822 void freeMacServingCellInfo(ServCellCfgInfo *srvCellCfg)
7824 uint8_t timeDomRsrcIdx;
7826 if(srvCellCfg->initDlBwp.pdschPresent)
7828 for(timeDomRsrcIdx = 0; timeDomRsrcIdx < srvCellCfg->initDlBwp.pdschCfg.numTimeDomRsrcAlloc; timeDomRsrcIdx++)
7830 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, \
7831 srvCellCfg->initDlBwp.pdschCfg.timeDomRsrcAllociList[timeDomRsrcIdx].k0, sizeof(uint8_t));
7835 freeMacPdschServCellInfo(&srvCellCfg->pdschServCellCfg);
7836 if(srvCellCfg->bwpInactivityTmr)
7838 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, srvCellCfg->bwpInactivityTmr, sizeof(uint8_t));
7841 if(srvCellCfg->initUlBwp.pucchPresent)
7843 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, srvCellCfg->initUlBwp.pucchCfg.dlDataToUlAck, sizeof(PucchDlDataToUlAck));
7847 /*******************************************************************
7849 * @brief Free cell Grp Cfg Info
7853 * Function : freeUeReCfgCellGrpInfo
7855 * Functionality: Free cell Grp Cfg Info
7857 * @params[in] MacUeCfg* duUeCfg
7860 * ****************************************************************/
7862 void freeUeReCfgCellGrpInfo(MacUeCfg *macUeCfg)
7864 freeMacServingCellInfo(&macUeCfg->spCellCfg.servCellCfg);
7867 /*******************************************************************
7869 * @brief Fills Reconfig SchReqReConfig
7873 * Function : extractSchReqReConfig
7875 * Functionality: Fills Reconfig SchReqReConfig
7877 * @params[in] SchedulingRequestConfig_t *cuSchedReq
7878 * SchedReqCfg* macSchedReq
7881 * ****************************************************************/
7882 void extractSchReqReConfig(SchedulingRequestConfig_t *cuSchedReq, SchedReqCfg *macSchedReq)
7884 uint8_t schReqIdx = 0;
7885 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqListToAdd = NULLP;
7886 struct SchedulingRequestConfig__schedulingRequestToReleaseList *schReqListToRel = NULLP;
7888 if(cuSchedReq->schedulingRequestToAddModList)
7890 schReqListToAdd = cuSchedReq->schedulingRequestToAddModList;
7891 if(schReqListToAdd->list.count)
7893 macSchedReq->addModListCount = schReqListToAdd->list.count;
7894 for(schReqIdx = 0; schReqIdx < schReqListToAdd->list.count; schReqIdx++)
7896 macSchedReq->addModList[schReqIdx].schedReqId = \
7897 schReqListToAdd->list.array[schReqIdx]->schedulingRequestId;
7898 macSchedReq->addModList[schReqIdx].srProhibitTmr = \
7899 *(schReqListToAdd->list.array[schReqIdx]->sr_ProhibitTimer);
7900 macSchedReq->addModList[schReqIdx].srTransMax =\
7901 schReqListToAdd->list.array[schReqIdx]->sr_TransMax;
7905 /* Scheduling Req To release */
7906 if(cuSchedReq->schedulingRequestToReleaseList)
7908 schReqListToRel = cuSchedReq->schedulingRequestToReleaseList;
7909 if(schReqListToRel->list.count)
7911 macSchedReq->relListCount = schReqListToRel->list.count;
7912 for(schReqIdx = 0; schReqIdx < schReqListToRel->list.count; schReqIdx++)
7914 macSchedReq->relList[schReqIdx] = \
7915 *schReqListToRel->list.array[schReqIdx];
7921 /*******************************************************************
7923 * @brief Fills TagReconfig
7927 * Function : extractTagReconfig
7929 * Functionality: Fills extractTagReconfig
7931 * @params[in] TAG_Config_t *cuTagCfg
7935 * ****************************************************************/
7937 void extractTagReconfig(TAG_Config_t *cuTagCfg, TagCfg *macTagCfg)
7940 struct TAG_Config__tag_ToAddModList *tagListToAddMod = NULLP;
7941 struct TAG_Config__tag_ToReleaseList *tagListToRel = NULLP;
7943 /* Tag config to AddMod */
7944 if(cuTagCfg->tag_ToAddModList)
7946 tagListToAddMod = cuTagCfg->tag_ToAddModList;
7947 if(tagListToAddMod->list.count)
7949 macTagCfg->addModListCount = tagListToAddMod->list.count;
7950 for(tagIdx = 0; tagIdx < tagListToAddMod->list.count; tagIdx++)
7952 macTagCfg->addModList[tagIdx].tagId =\
7953 tagListToAddMod->list.array[tagIdx]->tag_Id;
7954 macTagCfg->addModList[tagIdx].timeAlignTimer = \
7956 tagListToAddMod->list.array[tagIdx]->timeAlignmentTimer;
7960 /* Tag config to release */
7961 if(cuTagCfg->tag_ToReleaseList)
7963 tagListToRel = cuTagCfg->tag_ToReleaseList;
7964 if(tagListToRel->list.count)
7966 macTagCfg->relListCount = tagListToRel->list.count;
7967 for(tagIdx = 0; tagIdx < tagListToRel->list.count; tagIdx++)
7969 macTagCfg->relList[tagIdx] = *tagListToRel->list.array[tagIdx];
7975 /*******************************************************************
7977 * @brief Fills PdcchCfg received by CU
7981 * Function : extractPdcchCfg
7983 * Functionality: Fills PdcchCfg received by CU
7985 * @params[in] PDCCH_Config_t *cuPdcchCfg,
7986 * PdcchConfig *duPdcchCfg
7989 * ****************************************************************/
7991 void extractPdcchCfg(PDCCH_Config_t *cuPdcchCfg, PdcchConfig *macPdcchCfg)
7993 uint8_t cRsetIdx = 0;
7994 uint8_t srchSpcIdx = 0;
7996 struct PDCCH_Config__controlResourceSetToAddModList *cRsetToAddModList = NULLP;
7997 struct PDCCH_Config__controlResourceSetToReleaseList *cRsetToRelList = NULLP;
7998 struct PDCCH_Config__searchSpacesToAddModList *srchSpcToAddModList = NULLP;
7999 struct PDCCH_Config__searchSpacesToReleaseList *srchSpcToRelList = NULLP;
8002 /* Control Resource Set To Add/Mod List */
8003 if(cuPdcchCfg->controlResourceSetToAddModList)
8005 cRsetToAddModList = cuPdcchCfg->controlResourceSetToAddModList;
8006 if(cRsetToAddModList->list.count)
8008 macPdcchCfg->numCRsetToAddMod = cRsetToAddModList->list.count;
8009 for(cRsetIdx = 0; cRsetIdx < cRsetToAddModList->list.count; cRsetIdx++)
8011 macPdcchCfg->cRSetToAddModList[cRsetIdx].cRSetId = \
8012 cRsetToAddModList->list.array[cRsetIdx]->controlResourceSetId;
8013 bitStringToInt(&cRsetToAddModList->list.array[cRsetIdx]->frequencyDomainResources,\
8014 macPdcchCfg->cRSetToAddModList[cRsetIdx].freqDomainRsrc);
8015 macPdcchCfg->cRSetToAddModList[cRsetIdx].duration = \
8016 cRsetToAddModList->list.array[cRsetIdx]->duration;
8018 macPdcchCfg->cRSetToAddModList[cRsetIdx].cceRegMappingType = \
8019 cRsetToAddModList->list.array[cRsetIdx]->cce_REG_MappingType.present;
8020 if(macPdcchCfg->cRSetToAddModList[cRsetIdx].cceRegMappingType == CCE_REG_MAPPINGTYPE_PR_INTERLEAVED)
8022 //TODO: handle the case for Interleaved
8024 macPdcchCfg->cRSetToAddModList[cRsetIdx].precoderGranularity = \
8025 cRsetToAddModList->list.array[cRsetIdx]->precoderGranularity;
8026 if(cRsetToAddModList->list.array[cRsetIdx]->pdcch_DMRS_ScramblingID)
8028 macPdcchCfg->cRSetToAddModList[cRsetIdx].dmrsScramblingId= \
8029 *(cRsetToAddModList->list.array[cRsetIdx]->pdcch_DMRS_ScramblingID);
8035 /* Control Resource Set To Release List */
8036 if(cuPdcchCfg->controlResourceSetToReleaseList)
8038 cRsetToRelList = cuPdcchCfg->controlResourceSetToReleaseList;
8039 if(cRsetToRelList->list.count)
8041 macPdcchCfg->numCRsetToRel = cRsetToRelList->list.count;
8042 for(cRsetIdx = 0; cRsetIdx < cRsetToRelList->list.count; cRsetIdx++)
8044 macPdcchCfg->cRSetToRelList[cRsetIdx] = *(cRsetToRelList->list.array[cRsetIdx]);
8049 /* Search space To Add/Mod List */
8050 if(cuPdcchCfg->searchSpacesToAddModList)
8052 srchSpcToAddModList = cuPdcchCfg->searchSpacesToAddModList;
8053 if(srchSpcToAddModList->list.count)
8055 macPdcchCfg->numSearchSpcToAddMod = srchSpcToAddModList->list.count;
8056 for(srchSpcIdx = 0; srchSpcIdx < srchSpcToAddModList->list.count; srchSpcIdx++)
8058 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceId =\
8059 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceId;
8060 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].cRSetId =\
8061 *(srchSpcToAddModList->list.array[srchSpcIdx]->controlResourceSetId);
8062 if(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSlotPeriodicityAndOffset)
8064 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].mSlotPeriodicityAndOffset =\
8065 srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSlotPeriodicityAndOffset->present;
8067 if(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSymbolsWithinSlot)
8069 bitStringToInt(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSymbolsWithinSlot,\
8070 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].mSymbolsWithinSlot);
8072 if(srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates)
8074 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel1 = \
8075 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel1;
8076 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel2 = \
8077 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel2;
8078 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel4 = \
8079 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel4;
8081 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel8 = \
8082 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel8;
8084 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel16 = \
8085 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel16;
8087 if(srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType)
8089 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceType =\
8090 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType->present;
8091 if(macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceType == SEARCHSPACETYPE_PR_UE_SPECIFIC)
8093 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].ueSpecificDciFormat =\
8094 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType->choice.ue_Specific->dci_Formats;
8101 /* Search space To Rel List */
8102 if(cuPdcchCfg->searchSpacesToReleaseList)
8104 srchSpcToRelList = cuPdcchCfg->searchSpacesToReleaseList;
8105 if(srchSpcToRelList->list.count)
8107 macPdcchCfg->numSearchSpcToRel = srchSpcToRelList->list.count;
8108 for(srchSpcIdx = 0; srchSpcIdx < srchSpcToRelList->list.count; srchSpcIdx++)
8110 macPdcchCfg->searchSpcToRelList[srchSpcIdx] =\
8111 *(srchSpcToRelList->list.array[srchSpcIdx]);
8117 /*******************************************************************
8119 * @brief Fills PdschCfg received by CU
8123 * Function : extractPdschCfg
8125 * Functionality: Fills PdschCfg received by CU
8127 * @params[in] PDSCH_Config_t *cuPdschCfg = Information which is send by CU,
8128 * which we have stored in F1UeContextSetupDb,
8129 * PdschConfig *macPdschCfg = Used to Store the information which
8130 * needs to send in other layer, as well as this can be the variable
8131 * which stores the information in DuCb,
8132 * PdschConfig *storedPdschCfg = Null in case of sending the
8133 * information to other layer else it will have stored pdsch
8134 * configuration in copyOfmacUeCfg.
8137 * ****************************************************************/
8139 void extractPdschCfg(PDSCH_Config_t *cuPdschCfg, PdschConfig *macPdschCfg, PdschConfig *storedPdschCfg)
8142 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAlloc = NULLP;
8144 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
8146 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->present == \
8147 PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA_PR_setup)
8149 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)
8151 macPdschCfg->dmrsDlCfgForPdschMapTypeA.addPos = \
8152 *(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition);
8156 macPdschCfg->resourceAllocType = cuPdschCfg->resourceAllocation;
8157 if(cuPdschCfg->pdsch_TimeDomainAllocationList)
8159 timeDomAlloc = cuPdschCfg->pdsch_TimeDomainAllocationList;
8160 if(timeDomAlloc->present ==\
8161 PDSCH_Config__pdsch_TimeDomainAllocationList_PR_setup)
8163 if(timeDomAlloc->choice.setup)
8165 macPdschCfg->numTimeDomRsrcAlloc = timeDomAlloc->choice.setup->list.count;
8166 for(timeDomIdx = 0; timeDomIdx < timeDomAlloc->choice.setup->list.count; timeDomIdx++)
8168 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0 = NULLP;
8169 if(timeDomAlloc->choice.setup->list.array[timeDomIdx]->k0)
8171 if(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0 == NULL)
8175 if(storedPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0)
8177 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0 =\
8178 storedPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0;
8182 DU_ALLOC_SHRABL_BUF(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0, sizeof(uint8_t));
8187 DU_ALLOC_SHRABL_BUF(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0, sizeof(uint8_t));
8189 if(!macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0)
8191 DU_LOG("\nERROR --> DU APP : Memory allocation failed for k0 at extractPdschCfg()");
8195 *(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0) = \
8196 *(timeDomAlloc->choice.setup->list.array[timeDomIdx]->k0);
8198 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].mappingType = \
8199 timeDomAlloc->choice.setup->list.array[timeDomIdx]->mappingType;
8200 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].startSymbolAndLength = \
8201 timeDomAlloc->choice.setup->list.array[timeDomIdx]->startSymbolAndLength;
8206 macPdschCfg->rbgSize = cuPdschCfg->rbg_Size;
8207 if(cuPdschCfg->maxNrofCodeWordsScheduledByDCI)
8208 macPdschCfg->numCodeWordsSchByDci = *(cuPdschCfg->maxNrofCodeWordsScheduledByDCI);
8209 if(cuPdschCfg->prb_BundlingType.present == PDSCH_Config__prb_BundlingType_PR_staticBundling)
8211 macPdschCfg->bundlingType = cuPdschCfg->prb_BundlingType.present;
8212 if(cuPdschCfg->prb_BundlingType.choice.staticBundling)
8214 if(cuPdschCfg->prb_BundlingType.choice.staticBundling->bundleSize)
8216 macPdschCfg->bundlingInfo.StaticBundling.size = \
8217 *(cuPdschCfg->prb_BundlingType.choice.staticBundling->bundleSize);
8221 else if(cuPdschCfg->prb_BundlingType.present == PDSCH_Config__prb_BundlingType_PR_dynamicBundling)
8223 macPdschCfg->bundlingType = cuPdschCfg->prb_BundlingType.present;
8228 /*******************************************************************
8230 * @brief Fills PdschServingCellCfg received by CU
8234 * Function : extractPdschServingCellCfg
8236 * Functionality: Fills PdschCfg received by CU
8238 * @params[in] PDSCH_ServingCellConfig_t *cuPdschSrvCellCfg,
8239 * PdschServCellCfg *macUePdschSrvCellCfg
8240 * @return ROK/RFAILED
8242 * ****************************************************************/
8244 uint8_t extractPdschServingCellCfg(PDSCH_ServingCellConfig_t *cuPdschSrvCellCfg, PdschServCellCfg *macUePdschSrvCellCfg)
8246 if(cuPdschSrvCellCfg->codeBlockGroupTransmission)
8248 if(cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup)
8250 if(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb)
8252 *(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb) = \
8253 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock;
8257 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
8258 if(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb)
8260 *(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb) = \
8261 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock;
8265 DU_LOG("\nERROR --> DU APP : Memory allocation failed for maxCodeBlkGrpPerTb at extractPdschServingCellCfg()");
8269 if(macUePdschSrvCellCfg->codeBlkGrpFlushInd)
8271 *(macUePdschSrvCellCfg->codeBlkGrpFlushInd) = \
8272 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->codeBlockGroupFlushIndicator;
8276 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->codeBlkGrpFlushInd , sizeof(bool));
8277 if(macUePdschSrvCellCfg->codeBlkGrpFlushInd)
8279 *(macUePdschSrvCellCfg->codeBlkGrpFlushInd) = \
8280 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->codeBlockGroupFlushIndicator;
8284 DU_LOG("\nERROR --> DU APP : Memory allocation failed for codeBlkGrpFlushInd at extractPdschServingCellCfg()");
8290 if(cuPdschSrvCellCfg->nrofHARQ_ProcessesForPDSCH)
8292 macUePdschSrvCellCfg->numHarqProcForPdsch = *(cuPdschSrvCellCfg->nrofHARQ_ProcessesForPDSCH);
8294 if(cuPdschSrvCellCfg->ext1)
8296 if(cuPdschSrvCellCfg->ext1->maxMIMO_Layers)
8298 if(macUePdschSrvCellCfg->maxMimoLayers)
8300 *(macUePdschSrvCellCfg->maxMimoLayers) = *(cuPdschSrvCellCfg->ext1->maxMIMO_Layers);
8304 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->maxMimoLayers, sizeof(uint8_t));
8305 if(macUePdschSrvCellCfg->maxMimoLayers)
8307 *(macUePdschSrvCellCfg->maxMimoLayers) = *(cuPdschSrvCellCfg->ext1->maxMIMO_Layers);
8311 DU_LOG("\nERROR --> DU APP : Memory allocation failed for maxMimoLayers at extractPdschServingCellCfg()");
8317 if(cuPdschSrvCellCfg->xOverhead)
8319 if(macUePdschSrvCellCfg->xOverhead)
8321 *(macUePdschSrvCellCfg->xOverhead) = *(cuPdschSrvCellCfg->xOverhead);
8325 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->xOverhead, sizeof(PdschXOverhead));
8326 if(macUePdschSrvCellCfg->xOverhead)
8328 *(macUePdschSrvCellCfg->xOverhead) = *(cuPdschSrvCellCfg->xOverhead);
8332 DU_LOG("\nERROR --> DU APP : Memory allocation failed for xOverhead at extractPdschServingCellCfg()");
8340 /*******************************************************************
8342 * @brief Fills PuschCfg received by CU
8346 * Function : extractPuschCfg
8348 * Functionality: Fills PuschCfg received by CU
8350 * @params[in] BWP_UplinkDedicated__pusch_Config *cuPuschCfg,
8351 * PuschCfg *macPuschCfg
8354 * ****************************************************************/
8356 void extractPuschCfg(struct BWP_UplinkDedicated__pusch_Config *cuPuschCfg, PuschCfg *macPuschCfg)
8358 uint8_t timeDomIdx = 0;
8359 DMRS_UplinkConfig_t *dmrsUlCfg = NULLP;
8360 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList = NULLP;
8362 if(cuPuschCfg->present == BWP_UplinkDedicated__pusch_Config_PR_setup)
8364 if(cuPuschCfg->choice.setup)
8366 if(cuPuschCfg->choice.setup->dataScramblingIdentityPUSCH)
8368 macPuschCfg->dataScramblingId = \
8369 *(cuPuschCfg->choice.setup->dataScramblingIdentityPUSCH);
8371 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA)
8373 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->present == PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA_PR_setup)
8375 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup)
8377 dmrsUlCfg = (cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup);
8378 if(dmrsUlCfg->dmrs_AdditionalPosition)
8380 macPuschCfg->dmrsUlCfgForPuschMapTypeA.addPos =\
8381 *(dmrsUlCfg->dmrs_AdditionalPosition);
8383 if(dmrsUlCfg->transformPrecodingDisabled)
8385 if(dmrsUlCfg->transformPrecodingDisabled->scramblingID0)
8387 macPuschCfg->dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0 = \
8388 *(dmrsUlCfg->transformPrecodingDisabled->scramblingID0);
8394 /*Res Alloc Type for UL */
8395 if(cuPuschCfg->choice.setup->resourceAllocation)
8397 macPuschCfg->resourceAllocType = \
8398 cuPuschCfg->choice.setup->resourceAllocation;
8400 if(cuPuschCfg->choice.setup->pusch_TimeDomainAllocationList)
8402 timeDomAllocList = cuPuschCfg->choice.setup->pusch_TimeDomainAllocationList;
8403 if(timeDomAllocList->present == PUSCH_Config__pusch_TimeDomainAllocationList_PR_setup)
8405 if(timeDomAllocList->choice.setup)
8407 macPuschCfg->numTimeDomRsrcAlloc = timeDomAllocList->choice.setup->list.count;
8408 for(timeDomIdx = 0; timeDomIdx <timeDomAllocList->choice.setup->list.count; timeDomIdx++)
8410 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].k2 = \
8411 *(timeDomAllocList->choice.setup->list.array[timeDomIdx]->k2);
8412 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].mappingType = \
8413 timeDomAllocList->choice.setup->list.array[timeDomIdx]->mappingType;
8414 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].startSymbolAndLength = \
8415 timeDomAllocList->choice.setup->list.array[timeDomIdx]->startSymbolAndLength;
8420 if(cuPuschCfg->choice.setup->transformPrecoder)
8421 macPuschCfg->transformPrecoder = *(cuPuschCfg->choice.setup->transformPrecoder);
8426 /*******************************************************************
8428 * @brief Function to fill pucch Power Control
8432 * Function : extractPucchPowerControl
8434 * Functionality: Function to fill pucch Power Control
8436 * @params[in] PucchPowerControl *pwrCtrl,
8437 * struct PUCCH_PowerControl *cuPwrCtrlCfg
8440 * ****************************************************************/
8442 void extractPucchPowerControl(PucchPowerControl *pwrCtrl, struct PUCCH_PowerControl *cuPwrCtrlCfg)
8446 if(cuPwrCtrlCfg->deltaF_PUCCH_f0)
8447 pwrCtrl->deltaF_Format0 = *cuPwrCtrlCfg->deltaF_PUCCH_f0;
8448 if(cuPwrCtrlCfg->deltaF_PUCCH_f1)
8449 pwrCtrl->deltaF_Format1 = *cuPwrCtrlCfg->deltaF_PUCCH_f1;
8450 if(cuPwrCtrlCfg->deltaF_PUCCH_f2)
8451 pwrCtrl->deltaF_Format2 = *cuPwrCtrlCfg->deltaF_PUCCH_f2;
8452 if(cuPwrCtrlCfg->deltaF_PUCCH_f3)
8453 pwrCtrl->deltaF_Format3 = *cuPwrCtrlCfg->deltaF_PUCCH_f3;
8454 if(cuPwrCtrlCfg->deltaF_PUCCH_f4)
8455 pwrCtrl->deltaF_Format4 = *cuPwrCtrlCfg->deltaF_PUCCH_f4;
8456 if(cuPwrCtrlCfg->p0_Set)
8458 pwrCtrl->p0SetCount = cuPwrCtrlCfg->p0_Set->list.count;
8459 for(arrIdx=0; arrIdx < pwrCtrl->p0SetCount; arrIdx++)
8461 pwrCtrl->p0Set[arrIdx].p0PucchId =\
8462 cuPwrCtrlCfg->p0_Set->list.array[arrIdx]->p0_PUCCH_Id;
8463 pwrCtrl->p0Set[arrIdx].p0PucchVal =\
8464 cuPwrCtrlCfg->p0_Set->list.array[arrIdx]->p0_PUCCH_Value;
8467 if(cuPwrCtrlCfg->pathlossReferenceRSs)
8469 pwrCtrl->pathLossRefRSListCount = cuPwrCtrlCfg->pathlossReferenceRSs->list.count;
8470 for(arrIdx = 0; arrIdx < pwrCtrl->pathLossRefRSListCount; arrIdx++)
8472 pwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId =\
8473 cuPwrCtrlCfg->pathlossReferenceRSs->list.array[arrIdx]->pucch_PathlossReferenceRS_Id;
8478 /*******************************************************************
8480 * @brief Function to extractResrcSetToAddModList sent by CU
8484 * Function : extractResrcSetToAddModList
8486 * Functionality: Fucntion to extractResrcSetToAddModList
8488 * @params[in] PucchResrcSetCfg pointer,
8489 * struct PUCCH_Config__resourceSetToAddModList pointer
8492 * ****************************************************************/
8494 void extractResrcSetToAddModList(PucchResrcSetCfg *macRsrcSetList, struct PUCCH_Config__resourceSetToAddModList *cuRsrcSetList)
8496 uint8_t arrIdx, rsrcListIdx;
8498 macRsrcSetList->resrcSetToAddModListCount = cuRsrcSetList->list.count;
8499 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToAddModListCount; arrIdx++)
8501 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId =\
8502 cuRsrcSetList->list.array[arrIdx]->pucch_ResourceSetId;
8503 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount =\
8504 cuRsrcSetList->list.array[arrIdx]->resourceList.list.count;
8505 for(rsrcListIdx = 0; rsrcListIdx < macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount; rsrcListIdx++)
8507 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx] =\
8508 *cuRsrcSetList->list.array[arrIdx]->resourceList.list.array[rsrcListIdx];
8510 macRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize =\
8511 *cuRsrcSetList->list.array[arrIdx]->maxPayloadMinus1;
8513 }/* End of extractResrcSetToAddModList */
8515 /*******************************************************************
8517 * @brief Fills extractResrcToAddModList sent by CU
8521 * Function : extractResrcToAddModList
8523 * Functionality: Fills extractResrcToAddModList
8525 * @params[in] PucchResrcCfg pointer,
8526 * struct PUCCH_Config__resourceToAddModList pointer
8527 * @return ROk/RFAILED
8529 * ****************************************************************/
8531 uint8_t extractResrcToAddModList(PucchResrcCfg *macResrcList, struct PUCCH_Config__resourceToAddModList *cuResrcList)
8535 macResrcList->resrcToAddModListCount = cuResrcList->list.count;
8536 for(arrIdx = 0; arrIdx < macResrcList->resrcToAddModListCount; arrIdx++)
8538 macResrcList->resrcToAddModList[arrIdx].resrcId =\
8539 cuResrcList->list.array[arrIdx]->pucch_ResourceId;
8540 macResrcList->resrcToAddModList[arrIdx].startPrb =\
8541 cuResrcList->list.array[arrIdx]->startingPRB;
8542 if(cuResrcList->list.array[arrIdx]->intraSlotFrequencyHopping)
8544 macResrcList->resrcToAddModList[arrIdx].intraFreqHop =\
8545 *cuResrcList->list.array[arrIdx]->intraSlotFrequencyHopping;
8547 if(cuResrcList->list.array[arrIdx]->secondHopPRB)
8549 macResrcList->resrcToAddModList[arrIdx].secondPrbHop =\
8550 *cuResrcList->list.array[arrIdx]->secondHopPRB;
8552 /* PUCCH RSRC FORMAT */
8553 if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format0)
8555 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_0;
8556 if(cuResrcList->list.array[arrIdx]->format.choice.format0)
8558 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0, sizeof(PucchFormat0));
8559 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0 == NULLP)
8561 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format0 in extractResrcToAddModList()");
8564 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->initialCyclicShift =\
8565 cuResrcList->list.array[arrIdx]->format.choice.format0->initialCyclicShift;
8566 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->numSymbols =\
8567 cuResrcList->list.array[arrIdx]->format.choice.format0->nrofSymbols;
8568 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->startSymbolIdx =\
8569 cuResrcList->list.array[arrIdx]->format.choice.format0->startingSymbolIndex;
8572 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format1)
8574 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_1;
8575 if(cuResrcList->list.array[arrIdx]->format.choice.format1)
8577 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1, sizeof(PucchFormat1));
8578 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1 == NULLP)
8580 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format1 in extractResrcToAddModList()");
8583 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->initialCyclicShift =\
8584 cuResrcList->list.array[arrIdx]->format.choice.format1->initialCyclicShift;
8585 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->numSymbols =\
8586 cuResrcList->list.array[arrIdx]->format.choice.format1->nrofSymbols;
8587 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->startSymbolIdx =\
8588 cuResrcList->list.array[arrIdx]->format.choice.format1->startingSymbolIndex;
8589 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->timeDomOCC =\
8590 cuResrcList->list.array[arrIdx]->format.choice.format1->timeDomainOCC;
8593 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format2)
8595 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_2;
8596 if(cuResrcList->list.array[arrIdx]->format.choice.format2)
8598 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2, sizeof(PucchFormat2_3));
8599 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2 == NULLP)
8601 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format2 in extractResrcToAddModList()");
8604 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->numPrbs =\
8605 cuResrcList->list.array[arrIdx]->format.choice.format2->nrofPRBs;
8606 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->numSymbols =\
8607 cuResrcList->list.array[arrIdx]->format.choice.format2->nrofSymbols;
8608 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->startSymbolIdx =\
8609 cuResrcList->list.array[arrIdx]->format.choice.format2->startingSymbolIndex;
8612 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format3)
8614 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_3;
8615 if(cuResrcList->list.array[arrIdx]->format.choice.format3)
8617 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3, sizeof(PucchFormat2_3));
8618 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3 == NULLP)
8620 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format3 in extractResrcToAddModList()");
8623 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->numPrbs =\
8624 cuResrcList->list.array[arrIdx]->format.choice.format3->nrofPRBs;
8625 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->numSymbols =\
8626 cuResrcList->list.array[arrIdx]->format.choice.format3->nrofSymbols;
8627 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->startSymbolIdx =\
8628 cuResrcList->list.array[arrIdx]->format.choice.format3->startingSymbolIndex;
8631 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format4)
8633 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_4;
8634 if(cuResrcList->list.array[arrIdx]->format.choice.format4)
8636 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4, sizeof(PucchFormat4));
8637 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4 == NULLP)
8639 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format4 in extractResrcToAddModList()");
8642 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->numSymbols =\
8643 cuResrcList->list.array[arrIdx]->format.choice.format4->nrofSymbols;
8644 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->occLen =\
8645 cuResrcList->list.array[arrIdx]->format.choice.format4->occ_Length;
8646 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->occIdx =\
8647 cuResrcList->list.array[arrIdx]->format.choice.format4->occ_Index;
8648 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->startSymbolIdx =\
8649 cuResrcList->list.array[arrIdx]->format.choice.format4->startingSymbolIndex;
8655 }/* End of extractResrcToAddModList */
8657 /*******************************************************************
8659 * @brief Fills fillPucchSchedReqPeriodAndOffset sent by CU
8663 * Function : fillPucchSchedReqPeriodAndOffset
8665 * Functionality: To fillPucchSchedReqPeriodAndOffset
8667 * @params[in] macPeriodicty,
8668 * SchedulingRequestResourceConfig__periodicityAndOffset pointer
8671 * ****************************************************************/
8673 void fillPucchSchedReqPeriodAndOffset(uint8_t macPeriodicty, uint16_t macOffset,\
8674 struct SchedulingRequestResourceConfig__periodicityAndOffset *cuPeriodicty)
8676 macPeriodicty = cuPeriodicty->present;
8677 switch(macPeriodicty)
8679 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sym2:
8681 macOffset = cuPeriodicty->choice.sym2;
8684 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sym6or7:
8686 macOffset = cuPeriodicty->choice.sym6or7;
8689 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl1:
8691 macOffset = cuPeriodicty->choice.sl1;
8694 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl2:
8696 macOffset = cuPeriodicty->choice.sl2;
8699 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl4:
8701 macOffset = cuPeriodicty->choice.sl4;
8704 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl5:
8706 macOffset = cuPeriodicty->choice.sl5;
8709 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl8:
8711 macOffset = cuPeriodicty->choice.sl8;
8714 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl10:
8716 macOffset = cuPeriodicty->choice.sl10;
8719 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl16:
8721 macOffset = cuPeriodicty->choice.sl16;
8724 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl20:
8726 macOffset = cuPeriodicty->choice.sl20;
8729 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl40:
8731 macOffset = cuPeriodicty->choice.sl40;
8734 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl80:
8736 macOffset = cuPeriodicty->choice.sl80;
8739 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl160:
8741 macOffset = cuPeriodicty->choice.sl160;
8744 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl320:
8746 macOffset = cuPeriodicty->choice.sl320;
8749 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl640:
8751 macOffset = cuPeriodicty->choice.sl640;
8755 DU_LOG("\nERROR --> F1AP : Invalid periodicity %d", macPeriodicty);
8759 /*******************************************************************
8761 * @brief Function to extractPucchFormatCfg sent by CU
8765 * Function : extractPucchFormatCfg
8767 * Functionality: Function to extractPucchFormatCfg
8769 * @params[in] PucchFormatCfg pointer,
8770 * PUCCH_FormatConfig_t pointer
8773 * ****************************************************************/
8775 void extractPucchFormatCfg(PucchFormatCfg *macFormatCfg, PUCCH_FormatConfig_t *cuFormatCfg)
8777 if(cuFormatCfg->interslotFrequencyHopping)
8778 macFormatCfg->interSlotFreqHop = *cuFormatCfg->interslotFrequencyHopping;
8779 if(cuFormatCfg->additionalDMRS)
8780 macFormatCfg->addDmrs = *cuFormatCfg->additionalDMRS;
8781 if(cuFormatCfg->maxCodeRate)
8782 macFormatCfg->maxCodeRate = *cuFormatCfg->maxCodeRate;
8783 if(cuFormatCfg->nrofSlots)
8784 macFormatCfg->numSlots = *cuFormatCfg->nrofSlots;
8785 if(cuFormatCfg->pi2BPSK)
8786 macFormatCfg->pi2BPSK = *cuFormatCfg->pi2BPSK;
8787 if(cuFormatCfg->simultaneousHARQ_ACK_CSI)
8788 macFormatCfg->harqAckCSI = *cuFormatCfg->simultaneousHARQ_ACK_CSI;
8789 }/* End of extractPucchFormatCfg */
8791 /*******************************************************************
8793 * @brief Function to extractSchedReqCfgToAddMod sent by CU
8797 * Function : extractSchedReqCfgToAddMod
8799 * Functionality: Function to extractSchedReqCfgToAddMod
8801 * @params[in] PucchSchedReqCfg pointer,
8802 * PUCCH_Config__schedulingRequestResourceToAddModList pointer
8805 * ****************************************************************/
8807 void extractSchedReqCfgToAddMod(PucchSchedReqCfg *macSchedReqCfg, struct PUCCH_Config__schedulingRequestResourceToAddModList *cuSchedReqList)
8811 macSchedReqCfg->schedAddModListCount = cuSchedReqList->list.count;
8812 for(arrIdx = 0; arrIdx < macSchedReqCfg->schedAddModListCount; arrIdx++)
8814 macSchedReqCfg->schedAddModList[arrIdx].resrcId =\
8815 cuSchedReqList->list.array[arrIdx]->schedulingRequestResourceId;
8816 macSchedReqCfg->schedAddModList[arrIdx].requestId =\
8817 cuSchedReqList->list.array[arrIdx]->schedulingRequestID;
8818 if(cuSchedReqList->list.array[arrIdx]->periodicityAndOffset)
8820 fillPucchSchedReqPeriodAndOffset(macSchedReqCfg->schedAddModList[arrIdx].periodicity,\
8821 macSchedReqCfg->schedAddModList[arrIdx].offset, cuSchedReqList->list.array[arrIdx]->periodicityAndOffset);
8823 if(cuSchedReqList->list.array[arrIdx]->resource)
8825 macSchedReqCfg->schedAddModList[arrIdx].resrc =\
8826 *cuSchedReqList->list.array[arrIdx]->resource;
8830 }/* End of extractSchedReqCfgToAddMod */
8832 /*******************************************************************
8834 * @brief Fills PucchCfg received by CU
8838 * Function : extractPucchCfg
8840 * Functionality: Fills PucchCfg received by CU
8842 * @params[in] BWP_UplinkDedicated__pucch_Config *cuPucchCfg = Information which
8843 * is send by CU, which we have stored in F1UeContextSetupDb,
8844 * PucchCfg *macPucchCfg = Used to Store the information which
8845 * needs to send in other layer, as well as this can be the variable
8846 * which stores the information in DuCb,
8847 * PucchCfg *storedPucchCfg = Null in case of sending the
8848 * information to other layer else it will have Pucch Cfg which
8849 * we have stored in copyOfmacUeCfg.
8850 * @return ROK/RFAILED
8852 * ****************************************************************/
8854 uint8_t extractPucchCfg(struct BWP_UplinkDedicated__pucch_Config *cuPucchCfg, PucchCfg *macPucchCfg,\
8855 PucchCfg *storedPucchCfg)
8859 if(cuPucchCfg->present == BWP_UplinkDedicated__pucch_Config_PR_setup)
8861 if(cuPucchCfg->choice.setup)
8863 /* Resource Set Cfg */
8864 if(cuPucchCfg->choice.setup->resourceSetToAddModList)
8866 DU_ALLOC_SHRABL_BUF(macPucchCfg->resrcSet, sizeof(PucchResrcSetCfg));
8867 if(macPucchCfg->resrcSet == NULLP)
8869 DU_LOG("\nERROR --> F1AP : Failed to extract Resrc set List in extractPucchCfg()");
8872 memset(macPucchCfg->resrcSet, 0, sizeof(PucchResrcSetCfg));
8873 extractResrcSetToAddModList(macPucchCfg->resrcSet, cuPucchCfg->choice.setup->resourceSetToAddModList);
8877 if(cuPucchCfg->choice.setup->resourceToAddModList)
8879 DU_ALLOC_SHRABL_BUF(macPucchCfg->resrc, sizeof(PucchResrcCfg));
8880 if(macPucchCfg->resrc == NULLP)
8882 DU_LOG("\nERROR --> F1AP : Failed to extract Resrc List in extractPucchCfg()");
8885 memset(macPucchCfg->resrc, 0, sizeof(PucchResrcCfg));
8886 extractResrcToAddModList(macPucchCfg->resrc, cuPucchCfg->choice.setup->resourceToAddModList);
8890 if(cuPucchCfg->choice.setup->format1)
8892 DU_ALLOC_SHRABL_BUF(macPucchCfg->format1, sizeof(PucchFormatCfg));
8893 if(macPucchCfg->format1 == NULLP)
8895 DU_LOG("\nERROR --> F1AP : Failed to extract format 1 Cfg in extractPucchCfg()");
8898 memset(macPucchCfg->format1, 0, sizeof(PucchFormatCfg));
8899 extractPucchFormatCfg(macPucchCfg->format1,\
8900 cuPucchCfg->choice.setup->format1->choice.setup);
8904 if(cuPucchCfg->choice.setup->format2)
8906 DU_ALLOC_SHRABL_BUF(macPucchCfg->format2, sizeof(PucchFormatCfg));
8907 if(macPucchCfg->format2 == NULLP)
8909 DU_LOG("\nERROR --> F1AP : Failed to extract format 2 Cfg in extractPucchCfg()");
8912 memset(macPucchCfg->format2, 0, sizeof(PucchFormatCfg));
8913 extractPucchFormatCfg(macPucchCfg->format2,\
8914 cuPucchCfg->choice.setup->format2->choice.setup);
8918 if(cuPucchCfg->choice.setup->format3)
8920 DU_ALLOC_SHRABL_BUF(macPucchCfg->format3, sizeof(PucchFormatCfg));
8921 if(macPucchCfg->format3 == NULLP)
8923 DU_LOG("\nERROR --> F1AP : Failed to extract format 3 Cfg in extractPucchCfg()");
8926 memset(macPucchCfg->format3, 0, sizeof(PucchFormatCfg));
8927 extractPucchFormatCfg(macPucchCfg->format3,\
8928 cuPucchCfg->choice.setup->format3->choice.setup);
8932 if(cuPucchCfg->choice.setup->format4)
8934 DU_ALLOC_SHRABL_BUF(macPucchCfg->format4, sizeof(PucchFormatCfg));
8935 if(macPucchCfg->format4 == NULLP)
8937 DU_LOG("\nERROR --> F1AP : Failed to extract format 4 Cfg in extractPucchCfg()");
8940 memset(macPucchCfg->format4, 0, sizeof(PucchFormatCfg));
8941 extractPucchFormatCfg(macPucchCfg->format4,\
8942 cuPucchCfg->choice.setup->format4->choice.setup);
8945 /* Sched Req List */
8946 if(cuPucchCfg->choice.setup->schedulingRequestResourceToAddModList)
8948 DU_ALLOC_SHRABL_BUF(macPucchCfg->schedReq, sizeof(PucchSchedReqCfg));
8949 if(macPucchCfg->schedReq == NULLP)
8951 DU_LOG("\nERROR --> F1AP : Failed to extract schedReqCfg in extractPucchCfg()");
8954 memset(macPucchCfg->schedReq, 0, sizeof(PucchSchedReqCfg));
8955 extractSchedReqCfgToAddMod(macPucchCfg->schedReq,\
8956 cuPucchCfg->choice.setup->schedulingRequestResourceToAddModList);
8959 /*TODO: Add support for Spatial Info */
8962 if(cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList)
8964 DU_ALLOC_SHRABL_BUF(macPucchCfg->multiCsiCfg, sizeof(PucchMultiCsiCfg));
8965 if(macPucchCfg->multiCsiCfg == NULLP)
8967 DU_LOG("\nERROR --> F1AP : Failed to extract multiCsiCfg in extractPucchCfg()");
8970 memset(macPucchCfg->multiCsiCfg, 0, sizeof(PucchMultiCsiCfg));
8971 macPucchCfg->multiCsiCfg->multiCsiResrcListCount = cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList->list.count;
8972 for(arrIdx =0; arrIdx < macPucchCfg->multiCsiCfg->multiCsiResrcListCount; arrIdx++)
8974 macPucchCfg->multiCsiCfg->multiCsiResrcList[arrIdx] =\
8975 *cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList->list.array[arrIdx];
8979 /* Dl_DataToUL_ACK */
8980 if(cuPucchCfg->choice.setup->dl_DataToUL_ACK)
8984 if(storedPucchCfg->dlDataToUlAck)
8986 macPucchCfg->dlDataToUlAck = storedPucchCfg->dlDataToUlAck;
8990 DU_ALLOC_SHRABL_BUF(macPucchCfg->dlDataToUlAck, sizeof(PucchDlDataToUlAck));
8995 DU_ALLOC_SHRABL_BUF(macPucchCfg->dlDataToUlAck, sizeof(PucchDlDataToUlAck));
8997 if(macPucchCfg->dlDataToUlAck == NULLP)
8999 DU_LOG("\nERROR --> F1AP : Failed to extract Dl_DataToUL_ACK in extractPucchCfg()");
9002 memset(macPucchCfg->dlDataToUlAck, 0, sizeof(PucchDlDataToUlAck));
9003 macPucchCfg->dlDataToUlAck->dlDataToUlAckListCount = cuPucchCfg->choice.setup->dl_DataToUL_ACK->list.count;
9004 for(arrIdx = 0; arrIdx < macPucchCfg->dlDataToUlAck->dlDataToUlAckListCount; arrIdx++)
9006 macPucchCfg->dlDataToUlAck->dlDataToUlAckList[arrIdx] =\
9007 *cuPucchCfg->choice.setup->dl_DataToUL_ACK->list.array[arrIdx];
9012 if(cuPucchCfg->choice.setup->pucch_PowerControl)
9014 DU_ALLOC_SHRABL_BUF(macPucchCfg->powerControl, sizeof(PucchPowerControl));
9015 if(macPucchCfg->powerControl == NULLP)
9017 DU_LOG("\nERROR --> F1AP : Failed to extract power control in extractPucchCfg()");
9020 extractPucchPowerControl(macPucchCfg->powerControl,\
9021 cuPucchCfg->choice.setup->pucch_PowerControl);
9028 /*******************************************************************
9030 * @brief Fills ServingCellReconfig received by CU
9034 * Function : extractSpCellDedicatedCfg
9036 * Functionality: Fills ServingCellReconfig received by CU
9038 * @params[in] ServingCellConfig_t *cuSrvCellCfg = Information which is send by
9039 * CU, which we have stored in F1UeContextSetupDb,
9040 * ServCellCfgInfo *macSrvCellCfg = Used to Store the information
9041 * which needs to send in other layer, as well as this can be the
9042 * variable which stores the information in DuCb,
9043 * ServCellCfgInfo *storedSrvCellCfg = Null in case of sending the
9044 * information to other layer else it will have ServCellCfgInfo which
9045 * we have stored in copyOfmacUeCfg.
9046 * @return ROK/RFAILD
9048 * ****************************************************************/
9049 uint8_t extractSpCellDedicatedCfg(ServingCellConfig_t *cuSrvCellCfg, ServCellCfgInfo *macSrvCellCfg,\
9050 ServCellCfgInfo *storedSrvCellCfg)
9053 BWP_DownlinkDedicated_t *dlBwp = NULLP;
9054 BWP_UplinkDedicated_t *ulBwp = NULLP;
9056 if(cuSrvCellCfg->initialDownlinkBWP)
9058 dlBwp = ((BWP_DownlinkDedicated_t *)(cuSrvCellCfg->initialDownlinkBWP));
9059 if(dlBwp->pdcch_Config)
9061 if(dlBwp->pdcch_Config->choice.setup)
9063 macSrvCellCfg->initDlBwp.pdcchPresent = true;
9064 extractPdcchCfg(dlBwp->pdcch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdcchCfg);
9067 if(dlBwp->pdsch_Config)
9069 if(dlBwp->pdsch_Config->choice.setup)
9071 macSrvCellCfg->initDlBwp.pdschPresent = true;
9073 if(storedSrvCellCfg)
9075 if(!storedSrvCellCfg->initDlBwp.pdschPresent)
9077 extractPdschCfg(dlBwp->pdsch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdschCfg, NULL);
9081 extractPdschCfg(dlBwp->pdsch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdschCfg,\
9082 &storedSrvCellCfg->initDlBwp.pdschCfg);
9087 extractPdschCfg(dlBwp->pdsch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdschCfg, NULL);
9092 if(cuSrvCellCfg->firstActiveDownlinkBWP_Id)
9093 macSrvCellCfg->firstActvDlBwpId = *(cuSrvCellCfg->firstActiveDownlinkBWP_Id);
9094 if(cuSrvCellCfg->defaultDownlinkBWP_Id)
9095 macSrvCellCfg->defaultDlBwpId = *(cuSrvCellCfg->defaultDownlinkBWP_Id);
9096 if(cuSrvCellCfg->bwp_InactivityTimer)
9098 if(macSrvCellCfg->bwpInactivityTmr)
9100 memcpy(macSrvCellCfg->bwpInactivityTmr, cuSrvCellCfg->bwp_InactivityTimer, sizeof(uint8_t));
9104 macSrvCellCfg->bwpInactivityTmr = NULLP;
9105 DU_ALLOC_SHRABL_BUF(macSrvCellCfg->bwpInactivityTmr, sizeof(uint8_t));
9106 if(macSrvCellCfg->bwpInactivityTmr)
9108 memcpy(macSrvCellCfg->bwpInactivityTmr, cuSrvCellCfg->bwp_InactivityTimer, sizeof(uint8_t));
9112 DU_LOG("\nERROR --> F1AP : Memory Alloc failed for bwpInactivityTmr at extractSpCellDedicatedCfg()");
9117 if(cuSrvCellCfg->pdsch_ServingCellConfig)
9119 if(cuSrvCellCfg->pdsch_ServingCellConfig->choice.setup)
9121 ret = extractPdschServingCellCfg(cuSrvCellCfg->pdsch_ServingCellConfig->choice.setup, &macSrvCellCfg->pdschServCellCfg);
9124 DU_LOG("\nERROR --> F1AP : Failed at extractPdschServingCellCfg()");
9129 if(cuSrvCellCfg->uplinkConfig)
9131 if(cuSrvCellCfg->uplinkConfig->initialUplinkBWP)
9133 ulBwp = ((BWP_UplinkDedicated_t *)(cuSrvCellCfg->uplinkConfig->initialUplinkBWP));
9134 if(ulBwp->pusch_Config)
9136 macSrvCellCfg->initUlBwp.puschPresent = true;
9137 extractPuschCfg(ulBwp->pusch_Config, &macSrvCellCfg->initUlBwp.puschCfg);
9139 if(ulBwp->pucch_Config)
9141 macSrvCellCfg->initUlBwp.pucchPresent = true;
9142 memset(&macSrvCellCfg->initUlBwp.pucchCfg, 0, sizeof(PucchCfg));
9143 if(storedSrvCellCfg)
9145 if(!storedSrvCellCfg->initUlBwp.pucchPresent)
9146 extractPucchCfg(ulBwp->pucch_Config, &macSrvCellCfg->initUlBwp.pucchCfg, NULL);
9148 extractPucchCfg(ulBwp->pucch_Config, &macSrvCellCfg->initUlBwp.pucchCfg,\
9149 &storedSrvCellCfg->initUlBwp.pucchCfg);
9153 extractPucchCfg(ulBwp->pucch_Config, &macSrvCellCfg->initUlBwp.pucchCfg, NULL);
9157 if(cuSrvCellCfg->uplinkConfig->firstActiveUplinkBWP_Id)
9158 macSrvCellCfg->firstActvUlBwpId = *(cuSrvCellCfg->uplinkConfig->firstActiveUplinkBWP_Id);
9162 /*******************************************************************
9164 * @brief Fills Reconfig Cell group Info received by CU
9168 * Function : extractUeReCfgCellInfo
9170 * Functionality: Fills Reconfig Cell group Info received by CU
9172 * @params[in] CellGroupConfigRrc_t *cellGrp = CellGroupConfigRrc_t information which
9173 * is send by CU, which we have stored in F1UeContextSetupDb
9174 * MacUeCfg *MacUeCfg = Used to Store the information,
9175 * which needs to send in other layer, as well as this can be
9176 * the variable which stores the information in DuCb,
9177 * MacUeCfg *storedMacUeCfg = Null in case of sending the
9178 * information to other layer else it will have copyOfmacUeCfg
9179 * which we have stored in F1UeContextSetupDb.
9181 * @return ROK/RFAILED
9183 * ****************************************************************/
9184 uint8_t extractUeReCfgCellInfo(CellGroupConfigRrc_t *cellGrp, MacUeCfg *macUeCfg, MacUeCfg *storedMacUeCfg)
9187 MAC_CellGroupConfig_t *macCellGroup = NULLP;
9188 PhysicalCellGroupConfig_t *phyCellGrpCfg = NULLP;
9189 SpCellConfig_t *spcellCfg = NULLP;
9190 ServingCellConfig_t *servCellCfg = NULLP;
9194 /* Fill MacCell Group Reconfig */
9195 if(cellGrp->mac_CellGroupConfig)
9197 macUeCfg->macCellGrpCfgPres = true;
9198 macCellGroup = ((MAC_CellGroupConfig_t *)(cellGrp->mac_CellGroupConfig));
9199 if(macCellGroup->schedulingRequestConfig)
9201 extractSchReqReConfig(macCellGroup->schedulingRequestConfig, &macUeCfg->macCellGrpCfg.schReqCfg);
9203 if(macCellGroup->tag_Config)
9205 extractTagReconfig(macCellGroup->tag_Config, &macUeCfg->macCellGrpCfg.tagCfg);
9207 if(macCellGroup->bsr_Config)
9209 macUeCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer = macCellGroup->bsr_Config->periodicBSR_Timer;
9210 macUeCfg->macCellGrpCfg.bsrTmrCfg.retxTimer = macCellGroup->bsr_Config->retxBSR_Timer;
9211 if(macCellGroup->bsr_Config->logicalChannelSR_DelayTimer)
9213 macUeCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer =\
9214 *(macCellGroup->bsr_Config->logicalChannelSR_DelayTimer);
9217 if(macCellGroup->phr_Config)
9219 if(macCellGroup->phr_Config->present == MAC_CellGroupConfig__phr_Config_PR_setup)
9221 macUeCfg->macCellGrpCfg.phrCfgSetupPres = true;
9222 if(macCellGroup->phr_Config->choice.setup)
9224 macUeCfg->macCellGrpCfg.phrCfg.periodicTimer = \
9225 macCellGroup->phr_Config->choice.setup->phr_PeriodicTimer;
9226 macUeCfg->macCellGrpCfg.phrCfg.prohibitTimer = \
9227 macCellGroup->phr_Config->choice.setup->phr_ProhibitTimer;
9228 macUeCfg->macCellGrpCfg.phrCfg.txPowerFactor = \
9229 macCellGroup->phr_Config->choice.setup->phr_Tx_PowerFactorChange;
9230 macUeCfg->macCellGrpCfg.phrCfg.multiplePHR = \
9231 macCellGroup->phr_Config->choice.setup->multiplePHR;
9232 macUeCfg->macCellGrpCfg.phrCfg.dummy = \
9233 macCellGroup->phr_Config->choice.setup->dummy;
9234 macUeCfg->macCellGrpCfg.phrCfg.phrType2OtherCell = \
9235 macCellGroup->phr_Config->choice.setup->phr_Type2OtherCell;
9236 macUeCfg->macCellGrpCfg.phrCfg.phrOtherCG = \
9237 macCellGroup->phr_Config->choice.setup->phr_ModeOtherCG;
9242 /* Fill Physical Cell Group Reconfig */
9243 if(cellGrp->physicalCellGroupConfig)
9245 macUeCfg->phyCellGrpCfgPres = true;
9246 phyCellGrpCfg = ((PhysicalCellGroupConfig_t *)(cellGrp->physicalCellGroupConfig));
9247 if(phyCellGrpCfg->p_NR_FR1)
9249 if(*(phyCellGrpCfg->p_NR_FR1) != macUeCfg->phyCellGrpCfg.pNrFr1)
9250 macUeCfg->phyCellGrpCfg.pNrFr1 = *(phyCellGrpCfg->p_NR_FR1);
9252 macUeCfg->phyCellGrpCfg.pdschHarqAckCodebook = phyCellGrpCfg->pdsch_HARQ_ACK_Codebook;
9254 /* Fill SpCell Reconfig */
9255 if(cellGrp->spCellConfig)
9257 macUeCfg->spCellCfgPres = true;
9258 spcellCfg = ((SpCellConfig_t *)(cellGrp->spCellConfig));
9259 if(spcellCfg->servCellIndex)
9261 macUeCfg->spCellCfg.servCellIdx = *(spcellCfg->servCellIndex);
9263 /* Fill Serving cell Reconfig info */
9264 if(cellGrp->spCellConfig->spCellConfigDedicated)
9266 servCellCfg = ((ServingCellConfig_t *)(cellGrp->spCellConfig->spCellConfigDedicated));
9269 if(!storedMacUeCfg->spCellCfgPres)
9270 ret = extractSpCellDedicatedCfg(servCellCfg, &macUeCfg->spCellCfg.servCellCfg, NULL);
9272 ret = extractSpCellDedicatedCfg(servCellCfg, &macUeCfg->spCellCfg.servCellCfg,\
9273 &storedMacUeCfg->spCellCfg.servCellCfg);
9277 ret = extractSpCellDedicatedCfg(servCellCfg, &macUeCfg->spCellCfg.servCellCfg, NULL);
9281 DU_LOG("\nERROR --> F1AP : Failed at extractSpCellDedicatedCfg()");
9288 /*******************************************************************
9290 * @brief free the memory allocated by decoder
9294 * Function : freeAperDecodeNrcgi
9296 * Functionality: Free Nrcgi values
9298 * @params[in] NRCGI_t *nrcgi
9301 * ****************************************************************/
9304 void freeAperDecodeNrcgi(NRCGI_t *nrcgi)
9306 if(nrcgi->pLMN_Identity.buf != NULLP)
9308 free(nrcgi->pLMN_Identity.buf);
9310 if(nrcgi->nRCellIdentity.buf != NULLP)
9312 free(nrcgi->nRCellIdentity.buf);
9315 /*******************************************************************
9317 * @brief free the memory allocated by decoder
9321 * Function : freeAperDecodeCuToDuInfo
9323 * Functionality: Free Cu To Du Information
9325 * @params[in] CUtoDURRCInformation_t *rrcMsg
9328 * ****************************************************************/
9331 void freeAperDecodeCuToDuInfo(CUtoDURRCInformation_t *rrcMsg)
9336 if(rrcMsg->uE_CapabilityRAT_ContainerList)
9338 if(rrcMsg->uE_CapabilityRAT_ContainerList->buf)
9339 free(rrcMsg->uE_CapabilityRAT_ContainerList->buf);
9340 free(rrcMsg->uE_CapabilityRAT_ContainerList);
9343 if(rrcMsg->iE_Extensions)
9345 if(rrcMsg->iE_Extensions->list.array)
9347 for(ieIdx= 0; ieIdx < rrcMsg->iE_Extensions->list.count; ieIdx++)
9349 if(rrcMsg->iE_Extensions->list.array[ieIdx])
9351 switch(rrcMsg->iE_Extensions->list.array[ieIdx]->id)
9353 case ProtocolIE_ID_id_CellGroupConfig:
9354 if(rrcMsg->iE_Extensions->list.array[ieIdx]->extensionValue.choice.CellGroupConfig.buf != NULLP)
9356 free(rrcMsg->iE_Extensions->list.array[ieIdx]->extensionValue.choice.CellGroupConfig.buf);
9360 DU_LOG("\nERROR --> F1AP : Invalid Event type %ld at FreeCuToDuInfo()", \
9361 rrcMsg->iE_Extensions->list.array[ieIdx]->id);
9366 for(arrIdx = 0; arrIdx < ieIdx; arrIdx++)
9368 free(rrcMsg->iE_Extensions->list.array[arrIdx]);
9370 free(rrcMsg->iE_Extensions->list.array);
9374 free(rrcMsg->iE_Extensions);
9377 /*******************************************************************
9379 * @brief free the memory allocated by decoder
9383 * Function : freeAperDecodeSplCellList
9385 * Functionality: Free Spl Cell List
9386 where memory allocated by aper_decoder
9388 * @params[in] SCell_ToBeSetup_List_t *spCellLst
9391 * ****************************************************************/
9394 void freeAperDecodeSplCellList(SCell_ToBeSetup_List_t *spCellLst)
9398 if(spCellLst->list.array != NULLP)
9400 for(cellIdx=0; cellIdx<spCellLst->list.count; cellIdx++)
9402 if(cellIdx==0&&spCellLst->list.array[cellIdx]!=NULLP)
9404 freeAperDecodeNrcgi(&spCellLst->list.array[cellIdx]->value.choice.SCell_ToBeSetup_Item.sCell_ID);
9406 if(spCellLst->list.array[cellIdx]!=NULLP)
9408 free(spCellLst->list.array[cellIdx]);
9411 free(spCellLst->list.array);
9414 /*******************************************************************
9416 * @brief free the memory allocated by decoder
9420 * Function : freeAperDecodeSRBSetup
9422 * Functionality: added free part for the memory allocated by aper_decoder
9424 * @params[in] SRBs_ToBeSetup_List_t *srbSet
9427 ****************************************************************/
9430 void freeAperDecodeSRBSetup(SRBs_ToBeSetup_List_t *srbSet)
9433 if(srbSet->list.array != NULLP)
9435 for(srbIdx=0; srbIdx<srbSet->list.count; srbIdx++)
9437 if(srbSet->list.array[srbIdx]!=NULLP)
9439 free(srbSet->list.array[srbIdx]);
9442 free(srbSet->list.array);
9446 /*******************************************************************
9448 * @brief free the memory allocated by decoder
9452 * Function : freeAperDecodeULTnlInfo
9454 * Functionality: added free part for the memory allocated by aper_decoder
9456 * @params[in] ULUPTNLInformation_ToBeSetup_List_t *ulInfo
9459 * ****************************************************************/
9462 void freeAperDecodeULTnlInfo(ULUPTNLInformation_ToBeSetup_List_t *ulInfo)
9465 if(ulInfo->list.array != NULLP)
9467 for(ulIdx=0; ulIdx<ulInfo->list.count; ulIdx++)
9469 if(ulIdx==0&&ulInfo->list.array[ulIdx]!=NULLP)
9471 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel!=NULLP)
9473 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->\
9474 transportLayerAddress.buf != NULLP)
9476 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf\
9479 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf);
9481 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->\
9482 transportLayerAddress.buf);
9484 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel);
9487 if(ulInfo->list.array[ulIdx]!=NULLP)
9489 free(ulInfo->list.array[ulIdx]);
9492 free(ulInfo->list.array);
9495 /*******************************************************************
9497 * @brief free the memory allocated by decoder
9501 * Function : freeAperDecodeDRBSetup
9503 * Functionality: free DRBSetup which is allocated by decoder
9505 * @params[in] DRBs_ToBeSetup_List_t *drbSet
9508 * ****************************************************************/
9510 void freeAperDecodeDRBSetup(DRBs_ToBeSetup_List_t *drbSet)
9512 DRBs_ToBeSetup_Item_t *drbSetItem = NULLP;
9516 if(drbSet->list.array != NULLP)
9518 for(drbIdx=0; drbIdx<drbSet->list.count; drbIdx++)
9520 if(drbIdx==0&&drbSet->list.array[drbIdx] != NULLP)
9522 drbSetItem =&drbSet->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item;
9523 if(drbSetItem->qoSInformation.choice.choice_extension != NULLP)
9525 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9526 qoS_Characteristics.choice.non_Dynamic_5QI !=NULLP)
9528 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9529 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
9531 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9532 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
9535 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sST.buf!=NULLP)
9538 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD!=NULLP)
9541 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD->\
9545 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.\
9546 flows_Mapped_To_DRB_List.list.array != NULLP)
9549 for(flowIdx=0;flowIdx<drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9550 DRB_Information.flows_Mapped_To_DRB_List.list.count; flowIdx++)
9553 if(flowIdx==0&&drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9554 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]!=NULLP)
9556 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9557 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9558 qoSFlowLevelQoSParameters.\
9559 qoS_Characteristics.choice.non_Dynamic_5QI!=NULLP)
9561 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9562 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9563 qoSFlowLevelQoSParameters.\
9564 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
9567 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9568 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9569 qoSFlowLevelQoSParameters.\
9570 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
9574 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9575 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9576 qoSFlowLevelQoSParameters.\
9577 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
9580 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9581 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9582 qoSFlowLevelQoSParameters.\
9583 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
9586 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9588 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9589 qoSFlowLevelQoSParameters.\
9590 qoS_Characteristics.choice.non_Dynamic_5QI);
9593 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9594 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]!=NULLP)
9597 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9598 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]);
9602 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9603 DRB_Information.flows_Mapped_To_DRB_List.list.array);
9606 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9607 DRB_Information.sNSSAI.sD->buf);
9610 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD);
9613 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sST.buf);
9617 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9619 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
9622 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9623 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
9626 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9627 qoS_Characteristics.choice.non_Dynamic_5QI);
9629 free(drbSetItem->qoSInformation.choice.choice_extension);
9631 freeAperDecodeULTnlInfo(&drbSetItem->uLUPTNLInformation_ToBeSetup_List);
9632 if(drbSetItem->uLConfiguration)
9634 free(drbSetItem->uLConfiguration);
9637 if(drbSet->list.array[drbIdx]!=NULLP)
9639 free(drbSet->list.array[drbIdx]);
9642 free(drbSet->list.array);
9647 /*******************************************************************
9649 * @brief builds Mac Cell Cfg
9653 * Function : procUeReCfgCellInfo
9655 * Functionality: builds Mac Cell Cfg
9657 * @params[in] MacUeCfg *macUeCfgToSend = Used to Store the information which
9658 * needs to send in other layer, as well as this can be
9659 * the variable which stores the information in DuCb.
9660 * MacUeCfg *storedMacUeCfg = Null in case of sending the
9661 * information to other layer else it will have copyOfmacUeCfg
9662 * which we have stored in F1UeContextSetupDb
9663 * void *cellInfo = CellGroupConfigRrc_t information which is send
9664 * by CU, which we have stored in F1UeContextSetupDb
9668 * ****************************************************************/
9669 uint8_t procUeReCfgCellInfo(MacUeCfg *macUeCfgToSend,MacUeCfg *storedMacUeCfg, void *cellInfo)
9672 CellGroupConfigRrc_t *cellGrp = NULLP;
9676 cellGrp = (CellGroupConfigRrc_t *)cellInfo;
9677 ret = extractUeReCfgCellInfo(cellGrp, macUeCfgToSend, storedMacUeCfg);
9679 DU_LOG("\nERROR --> F1AP : Failed at procUeReCfgCellInfo()");
9683 freeUeReCfgCellGrpInfo(macUeCfgToSend);
9688 /*******************************************************************
9690 * @brief Filling modulation info in mac ue cfg
9694 * Function : duFillModulationDetails
9696 * Functionality: Filling modulation info in mac ue cfg
9698 * @params[in] MAC UE Config to be updated
9699 * Current UE configuration
9700 * UE NR capability from CU
9701 * @return ROK - success
9704 * ****************************************************************/
9705 void duFillModulationDetails(MacUeCfg *ueCfg, MacUeCfg *oldUeCfg, void *ueCap)
9707 UE_NR_Capability_t *ueNrCap=NULLP;
9711 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
9712 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
9716 ueNrCap = (UE_NR_Capability_t *)ueCap;
9718 /* Filling DL modulation info */
9719 if(ueNrCap->featureSets && ueNrCap->featureSets->featureSetsDownlinkPerCC && \
9720 ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0] && \
9721 ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0]->supportedModulationOrderDL)
9723 switch(*(ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0]->supportedModulationOrderDL))
9725 case ModulationOrder_qpsk:
9727 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
9730 case ModulationOrder_qam16:
9732 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM16;
9735 case ModulationOrder_qam64:
9737 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM64;
9738 ueCfg->dlModInfo.mcsIndex = PDSCH_MCS_INDEX;
9739 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64;
9742 case ModulationOrder_qam256:
9744 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM256;
9749 DU_LOG("\nERROR --> DU APP: Incorrect downlink modulation order received. Reatining old modulation configuration");
9750 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
9757 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
9760 /* Filling UL modulation info */
9761 if(ueNrCap->featureSets && ueNrCap->featureSets->featureSetsUplinkPerCC && \
9762 ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0] && \
9763 ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0]->supportedModulationOrderUL)
9765 switch(*(ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0]->supportedModulationOrderUL))
9767 case ModulationOrder_qpsk:
9769 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
9772 case ModulationOrder_qam16:
9774 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM16;
9775 ueCfg->ulModInfo.mcsIndex = PUSCH_MCS_INDEX;
9776 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64;
9779 case ModulationOrder_qam64:
9781 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM64;
9784 case ModulationOrder_qam256:
9786 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM256;
9791 DU_LOG("\nERROR --> DU APP: Incorrect uplink modulation order received. Reatining old modulation configuration");
9792 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
9799 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
9804 /*******************************************************************
9806 * @brief Function to extract cellGrp Info present in cutoDu cont
9810 * Function : extractCellGrpInfo
9812 * Functionality: Function to extract cellGrp Info present
9815 * @params[in] ProtocolExtensionContainer_4624P16_t pointer
9817 * @return CellGroupConfigRrc_t *
9819 * ****************************************************************/
9821 CellGroupConfigRrc_t *extractCellGrpInfo(ProtocolExtensionContainer_4624P16_t *protocolIeExtn,\
9826 uint16_t recvBufLen =0;
9827 CellGroupConfigRrc_t *cellGrpCfg = NULLP;
9828 CUtoDURRCInformation_ExtIEs_t *extIeInfo = NULLP;
9829 asn_dec_rval_t rval; /* Decoder return value */
9830 memset(&rval, 0, sizeof(asn_dec_rval_t));
9834 for(idx2 = 0; idx2 < protocolIeExtn->list.count; idx2++)
9836 extIeInfo = ((CUtoDURRCInformation_ExtIEs_t *)(protocolIeExtn->list.array[idx2]));
9840 case ProtocolIE_ID_id_CellGroupConfig:
9842 recvBufLen = extIeInfo->extensionValue.choice.CellGroupConfig.size;
9843 /* decoding the CellGroup Buf received */
9844 DU_ALLOC(cellGrpCfg, sizeof(CellGroupConfigRrc_t));
9847 memset(cellGrpCfg, 0, sizeof(CellGroupConfigRrc_t));
9848 rval = aper_decode(0, &asn_DEF_CellGroupConfigRrc, (void **)&cellGrpCfg,
9849 extIeInfo->extensionValue.choice.CellGroupConfig.buf, recvBufLen, 0, 0);
9850 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
9852 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
9855 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, cellGrpCfg);
9856 if(extractRlcCfgToAddMod(cellGrpCfg->rlc_BearerToAddModList, ueCfgDb))
9862 DU_LOG("\nERROR --> F1AP : Invalid IE received CUtoDURRCInformation:%d at decodeCellGrpCfg()", id);
9870 /*******************************************************************
9872 * @brief Fills Srb List received by CU
9876 * Function : procSrbListToSetup
9878 * Functionality: Fills Srb List received by CU
9880 * @params[in] SRBs_ToBeSetup_Item_t *cuSrbItem
9882 * RlcBearerCfg pointer
9885 * ****************************************************************/
9886 uint8_t procSrbListToSetup(SRBs_ToBeSetup_Item_t * srbItem, LcCfg *macLcToAdd, RlcBearerCfg *rlcLcToAdd)
9890 /* Filling RLC INFO */
9891 procRlcLcCfg(srbItem->sRBID, srbItem->sRBID, RB_TYPE_SRB, RLC_AM, CONFIG_ADD, NULL, rlcLcToAdd);
9893 /* Filling MAC INFO */
9894 ret = procMacLcCfg(srbItem->sRBID, RB_TYPE_SRB, CONFIG_ADD, NULL,NULL, NULL, macLcToAdd, NULL);
9897 DU_LOG("\nERROR --> F1AP : Failed at MAC LC Cfg in procSrbListToSetup()");
9905 /*******************************************************************
9907 * @brief extract Srb List received by CU
9911 * Function : extractSrbListToSetup
9913 * Functionality: extract Srb List received by CU
9914 * for both MAC and RLC
9916 * @params[in] SRBs_ToBeSetup_Item_t pointer
9918 * @return ROK/RFAIED
9920 * ****************************************************************/
9922 uint8_t extractSrbListToSetup(SRBs_ToBeSetup_List_t *srbCfg, DuUeCfg *ueCfgDb)
9924 uint8_t ret, srbIdx;
9925 SRBs_ToBeSetup_Item_t *srbItem = NULLP;
9929 for(srbIdx = 0; srbIdx < srbCfg->list.count; srbIdx++)
9931 srbItem = &srbCfg->list.array[srbIdx]->value.choice.SRBs_ToBeSetup_Item;
9932 if(ueCfgDb->numMacLcs > MAX_NUM_LC)
9934 DU_LOG("\nERROR --> F1AP: MAX LC Reached in MAC");
9938 if(ueCfgDb->numRlcLcs > MAX_NUM_LC)
9940 DU_LOG("\nERROR --> F1AP: MAX LC Reached in RLC");
9944 memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(LcCfg));
9945 memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(RlcBearerCfg));
9946 ret = procSrbListToSetup(srbItem, &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs],\
9947 &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs]);
9948 ueCfgDb->numRlcLcs++;
9949 ueCfgDb->numMacLcs++;
9952 DU_LOG("\nERROR --> F1AP: Failed at extractSrbListToSetup()");
9963 /*******************************************************************
9965 * @brief Fills Drb List received by CU
9969 * Function : procDrbListToSetup
9971 * Functionality: Fills Drb List received by CU
9972 * for both MAC and RLC
9974 * @params[in] SRBs_ToBeSetup_Item_t pointer
9976 * RlcBearerCfg pointer
9979 * ****************************************************************/
9981 uint8_t procDrbListToSetup(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbItem,\
9982 DRBs_ToBeSetupMod_Item_t *drbSetupModItem, LcCfg *macLcToAdd, RlcBearerCfg *rlcLcToAdd, UpTnlCfg *upTnlInfo)
9985 if(drbItem != NULLP)
9987 /* Filling RLC INFO */
9988 procRlcLcCfg(drbItem->dRBID, lcId, RB_TYPE_DRB, drbItem->rLCMode, CONFIG_ADD, NULL, rlcLcToAdd);
9990 /* Filling MAC INFO */
9991 if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_ADD, drbItem, NULL, NULL, macLcToAdd, upTnlInfo) != ROK)
9993 DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in procDrbListToSetup()");
9997 else if(drbSetupModItem != NULLP)
9999 procRlcLcCfg(drbSetupModItem->dRBID, lcId, RB_TYPE_DRB, drbSetupModItem->rLCMode, CONFIG_ADD, NULL, rlcLcToAdd);
10001 if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_ADD, NULL, drbSetupModItem, NULL, macLcToAdd, upTnlInfo) != ROK)
10003 DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in procDrbListToSetup()");
10010 /*******************************************************************
10012 * @brief extract Drb List received by CU
10016 * Function : extractDrbListToSetup
10018 * Functionality: extract Drb List received by CU
10019 * for both MAC and RLC
10021 * @params[in] DRBs_ToBeSetup_Item_t pointer
10023 * @return ROK/RFAIED
10025 * ****************************************************************/
10027 uint8_t extractDrbListToSetup(uint8_t lcId, DRBs_ToBeSetup_List_t *drbCfg,DRBs_ToBeSetupMod_List_t *drbSetupModCfg,\
10028 uint8_t drbCount, DuUeCfg *ueCfgDb)
10030 uint8_t ret, drbIdx;
10031 DRBs_ToBeSetup_Item_t *drbItem = NULLP;
10032 DRBs_ToBeSetupMod_ItemIEs_t *drbSetupModItem = NULLP;
10037 for(drbIdx = 0; drbIdx < drbCount; drbIdx++)
10039 if(ueCfgDb->numMacLcs > MAX_NUM_LC)
10041 DU_LOG("\nERROR --> F1AP : MAX LC Reached in MAC at extractDrbListToSetup()");
10045 if(ueCfgDb->numRlcLcs > MAX_NUM_LC)
10047 DU_LOG("\nERROR --> F1AP : MAX LC Reached in RLC at extractDrbListToSetup()");
10051 memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(LcCfg));
10052 memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(RlcBearerCfg));
10056 drbItem = &drbCfg->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item;
10057 ret = procDrbListToSetup(lcId, drbItem, NULL, &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs],\
10058 &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], &ueCfgDb->upTnlInfo[ueCfgDb->numDrb]);
10061 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetup()");
10065 else if(drbSetupModCfg != NULL)
10067 drbSetupModItem = (DRBs_ToBeSetupMod_ItemIEs_t *) drbSetupModCfg->list.array[drbIdx];
10068 ret = procDrbListToSetup(lcId, NULL, &(drbSetupModItem->value.choice.DRBs_ToBeSetupMod_Item) ,\
10069 &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs],\
10070 &ueCfgDb->upTnlInfo[ueCfgDb->numDrb]);
10073 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetup()");
10077 ueCfgDb->numRlcLcs++;
10078 ueCfgDb->numMacLcs++;
10082 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetup()");
10093 /*******************************************************************
10095 * @brief Function to extract Dl RRC Msg received from CU
10099 * Function : extractDlRrcMsg
10101 * Functionality: Function to extract Dl RRC Msg received from CU
10103 * @params[in] F1AP message
10104 * @return ROK - success
10105 * RFAILED - failure
10107 * ****************************************************************/
10109 uint8_t extractDlRrcMsg(uint32_t gnbDuUeF1apId, uint32_t gnbCuUeF1apId, \
10110 F1DlRrcMsg *dlRrcMsg, RRCContainer_t *rrcContainer)
10113 dlRrcMsg->rrcMsgSize = rrcContainer->size;
10114 if(dlRrcMsg->rrcMsgSize > 0)
10116 DU_ALLOC_SHRABL_BUF(dlRrcMsg->rrcMsgPdu, dlRrcMsg->rrcMsgSize);
10117 if(!dlRrcMsg->rrcMsgPdu)
10119 DU_LOG("\nERROR --> DU APP : Memory allocation failed for RRC Msg in extractDlRrcMsg()");
10124 dlRrcMsg->gnbDuUeF1apId = gnbDuUeF1apId;
10125 dlRrcMsg->gnbCuUeF1apId = gnbCuUeF1apId;
10126 dlRrcMsg->srbId = SRB1_LCID;
10127 memcpy(dlRrcMsg->rrcMsgPdu, rrcContainer->buf, dlRrcMsg->rrcMsgSize);
10133 /*******************************************************************
10135 * @brief Extract UE capability info
10139 * Function : extractUeCapability
10141 * Functionality: Extract UE capability info and stores in ue Cb
10143 * @params[in] Octet string of UE capability RAT container list
10144 * @return ROK - success
10145 * RFAILED - failure
10147 * ****************************************************************/
10148 UE_NR_Capability_t *extractUeCapability(UE_CapabilityRAT_ContainerList_t *ueCapablityListBuf, DuUeCb *ueCb)
10151 uint16_t recvBufLen;
10152 asn_dec_rval_t rval;
10153 UE_NR_Capability_t *ueNrCap = NULLP;
10154 UE_CapabilityRAT_ContainerListRRC_t *ueCapRatContList = NULLP;
10156 /* Decoding UE Capability RAT Container List */
10157 recvBufLen = ueCapablityListBuf->size;
10158 DU_ALLOC(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
10159 if(!ueCapRatContList)
10161 DU_LOG("\nERROR --> F1AP : Memory allocation failed in extractUeCapability");
10164 memset(ueCapRatContList, 0, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
10165 memset(&rval, 0, sizeof(asn_dec_rval_t));
10166 rval = aper_decode(0, &asn_DEF_UE_CapabilityRAT_ContainerListRRC, (void **)&ueCapRatContList,
10167 ueCapablityListBuf->buf, recvBufLen, 0, 0);
10168 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
10170 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
10173 xer_fprint(stdout, &asn_DEF_UE_CapabilityRAT_ContainerListRRC, ueCapRatContList);
10175 /* Free encoded buffer after decoding */
10177 for(idx = 0; idx < ueCapRatContList->list.count; idx++)
10179 if(ueCapRatContList->list.array[idx]->rat_Type == RAT_Type_nr)
10181 /* Decoding UE NR Capability */
10182 recvBufLen = ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.size;
10183 DU_ALLOC(ueNrCap, sizeof(UE_NR_Capability_t));
10186 DU_LOG("\nERROR --> F1AP : Memory allocation failed in extractUeCapability");
10187 DU_FREE(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
10190 memset(ueNrCap, 0, sizeof(UE_NR_Capability_t));
10191 memset(&rval, 0, sizeof(asn_dec_rval_t));
10192 rval = aper_decode(0, &asn_DEF_UE_NR_Capability, (void **)&ueNrCap,
10193 ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.buf, recvBufLen, 0, 0);
10194 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
10196 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
10199 xer_fprint(stdout, &asn_DEF_UE_NR_Capability, ueNrCap);
10201 /* Free encoded buffer after decoding */
10202 free(ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.buf);
10204 free(ueCapRatContList->list.array[idx]);
10208 free(ueCapRatContList->list.array);
10209 DU_FREE(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
10213 /*******************************************************************
10215 * @brief free UE context setup request from CU
10219 * Function : freeAperDecodeF1UeContextSetupReq
10221 * Functionality: freeing part for the memory allocated by aper_decoder
10223 * @params[in] F1AP message
10224 * @return ROK - success
10225 * RFAILED - failure
10227 * ****************************************************************/
10228 void freeAperDecodeF1UeContextSetupReq(UEContextSetupRequest_t *ueSetReq)
10232 if(ueSetReq->protocolIEs.list.array != NULLP)
10234 for(ieIdx = 0; ieIdx < ueSetReq->protocolIEs.list.count; ieIdx++)
10236 if(ueSetReq->protocolIEs.list.array[ieIdx])
10238 switch(ueSetReq->protocolIEs.list.array[ieIdx]->id)
10240 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
10242 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
10244 case ProtocolIE_ID_id_SpCell_ID:
10245 freeAperDecodeNrcgi(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.NRCGI);
10247 case ProtocolIE_ID_id_ServCellIndex:
10249 case ProtocolIE_ID_id_SpCellULConfigured:
10251 case ProtocolIE_ID_id_CUtoDURRCInformation:
10253 freeAperDecodeCuToDuInfo(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation);
10255 case ProtocolIE_ID_id_SCell_ToBeSetup_List:
10257 freeAperDecodeSplCellList(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SCell_ToBeSetup_List);
10259 case ProtocolIE_ID_id_SRBs_ToBeSetup_List:
10261 freeAperDecodeSRBSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SRBs_ToBeSetup_List);
10263 case ProtocolIE_ID_id_DRBs_ToBeSetup_List:
10265 freeAperDecodeDRBSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRBs_ToBeSetup_List);
10267 case ProtocolIE_ID_id_RRCContainer:
10270 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf != NULLP)
10273 free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf);
10277 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
10279 case ProtocolIE_ID_id_GNB_DU_UE_AMBR_UL:
10281 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf)
10283 free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf);
10288 DU_LOG("\nERROR --> F1AP: Invalid event type %ld " ,ueSetReq->protocolIEs.list.array[ieIdx]->id);
10290 free(ueSetReq->protocolIEs.list.array[ieIdx]);
10293 free(ueSetReq->protocolIEs.list.array);
10296 /*******************************************************************
10298 * @brief Process UE context setup request from CU
10302 * Function : procF1UeContextSetupReq
10304 * Functionality: Process UE context setup request from CU
10306 * @params[in] F1AP message
10307 * @return ROK - success
10308 * RFAILED - failure
10310 * ****************************************************************/
10311 uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg)
10313 uint8_t ret=0, ieIdx=0, ueIdx=0, lcId=0, cellIdx=0;
10314 bool ueCbFound = false;
10315 uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId=0, bitRateSize=0;
10316 DuUeCb *duUeCb = NULL;
10317 UEContextSetupRequest_t *ueSetReq = NULL;
10318 DRBs_ToBeSetup_List_t *drbCfg = NULL;
10322 ueSetReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextSetupRequest;
10323 for(ieIdx=0; (ieIdx < ueSetReq->protocolIEs.list.count && ret == ROK); ieIdx++)
10325 switch(ueSetReq->protocolIEs.list.array[ieIdx]->id)
10327 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
10329 gnbCuUeF1apId = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID;
10332 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
10334 gnbDuUeF1apId = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID;
10337 case ProtocolIE_ID_id_ServCellIndex:
10339 cellIdx = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.ServCellIndex;
10340 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
10342 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
10343 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
10346 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
10347 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
10350 memset(duUeCb->f1UeDb, 0, sizeof(F1UeContextSetupDb));
10351 duUeCb->f1UeDb->actionType = UE_CTXT_SETUP;
10352 duUeCb->f1UeDb->cellIdx = cellIdx;
10356 DU_LOG("\nERROR --> F1AP: Memory Alloc Failed at procF1UeContextSetupReq()");
10367 DU_LOG("\nERROR --> F1AP: DuUeCb is not found at procF1UeContextSetupReq()");
10372 case ProtocolIE_ID_id_SpCellULConfigured:
10373 /* Indicates whether the gNB-CU requests the gNB-DU to configure the uplink as no UL,
10374 UL, SUL or UL+SUL for the indicated cell for the UE */
10376 case ProtocolIE_ID_id_CUtoDURRCInformation:
10378 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList)
10380 duUeCb->f1UeDb->duUeCfg.ueNrCapability = \
10381 extractUeCapability(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.\
10382 uE_CapabilityRAT_ContainerList, duUeCb);
10384 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.iE_Extensions)
10386 duUeCb->f1UeDb->duUeCfg.cellGrpCfg = extractCellGrpInfo(ueSetReq->protocolIEs.list.array[ieIdx]->\
10387 value.choice.CUtoDURRCInformation.iE_Extensions, &duUeCb->f1UeDb->duUeCfg);
10388 if(!duUeCb->f1UeDb->duUeCfg.cellGrpCfg)
10390 DU_LOG("\nERROR --> F1AP: Failed to extract cell Grp Info");
10391 //TODO: Update the failure cause in ue context Setup Response
10397 case ProtocolIE_ID_id_SCell_ToBeSetup_List:
10399 DU_LOG("\nINFO --> DU_APP: Received SCell_ToBeSetup_List but Not processing the list");
10402 case ProtocolIE_ID_id_SRBs_ToBeSetup_List:
10404 if(extractSrbListToSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SRBs_ToBeSetup_List,\
10405 &duUeCb->f1UeDb->duUeCfg))
10407 DU_LOG("\nERROR --> DU APP : Failed at extractSrbListToSetup()");
10408 //TODO: Update the failure cause in ue context Setup Response
10413 case ProtocolIE_ID_id_DRBs_ToBeSetup_List:
10415 lcId = getDrbLcId(&duUeCb->drbBitMap);
10416 if(lcId != RFAILED)
10418 drbCfg = &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRBs_ToBeSetup_List;
10419 if(extractDrbListToSetup(lcId, drbCfg, NULL, drbCfg->list.count, &duUeCb->f1UeDb->duUeCfg))
10421 DU_LOG("\nERROR --> DU APP : Failed at extractDrbListToSetup()");
10422 //TODO: Update the failure cause in ue context Setup Response
10430 case ProtocolIE_ID_id_RRCContainer:
10432 /* Filling Dl RRC Msg Info */
10433 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
10434 if(!duUeCb->f1UeDb->dlRrcMsg)
10436 DU_LOG("\nERROR --> DU APP : Memory allocation failed for DL RRC Msg in procUeCtxtSetupReq()");
10441 duUeCb->f1UeDb->dlRrcMsgPres = true;
10442 memset(duUeCb->f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
10443 ret = extractDlRrcMsg(gnbDuUeF1apId, gnbCuUeF1apId, duUeCb->f1UeDb->dlRrcMsg,\
10444 &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer);
10448 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
10450 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
10452 duUeCb->f1UeDb->dlRrcMsg->deliveryStatRpt = true;
10456 DU_LOG("\nERROR --> Ignoring delivery report, since rrcContainer is not present");
10460 case ProtocolIE_ID_id_GNB_DU_UE_AMBR_UL:
10462 /* MaximumBitRate Uplink */
10463 bitRateSize = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.size;
10464 if(bitRateSize > 0)
10466 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->duUeCfg.ambrCfg, bitRateSize);
10467 if(!duUeCb->f1UeDb->duUeCfg.ambrCfg)
10469 DU_LOG("\nERROR --> DU APP : Memory allocation failed for bitRate in procUeCtxtSetupReq");
10474 memset(duUeCb->f1UeDb->duUeCfg.ambrCfg, 0, sizeof(AmbrCfg));
10475 memcpy(&duUeCb->f1UeDb->duUeCfg.ambrCfg->ulBr,
10476 ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf, bitRateSize);
10491 /*TODO : Negative case*/
10492 // BuildAndSendUeContextSetupRsp(cellId,ueIdx);
10493 DU_LOG("\nERROR --> F1AP: Failed to process UE CNTXT SETUP REQ at procF1UeContextSetupReq()");
10496 ret = duProcUeContextSetupRequest(duUeCb);
10498 freeAperDecodeF1UeContextSetupReq(ueSetReq);
10502 /*******************************************************************
10503 * @brief Free the memory allocated for Dl Tunnel Info
10507 * Function : freeDlTnlInfo
10510 * Free the memory allocated for Dl Tunnel Info
10512 * @params[in] DLUPTNLInformation_ToBeSetup_List_t *
10515 * ****************************************************************/
10517 void freeDlTnlInfo(DLUPTNLInformation_ToBeSetup_List_t *tnlInfo)
10519 uint8_t arrIdx = 0;
10523 for(arrIdx=0; arrIdx < tnlInfo->list.count; arrIdx++)
10525 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.buf,\
10526 tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.size);
10527 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf,\
10528 tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->gTP_TEID.size);
10529 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel, sizeof(GTPTunnel_t));
10530 DU_FREE(tnlInfo->list.array[arrIdx], sizeof(DLUPTNLInformation_ToBeSetup_Item_t));
10532 DU_FREE(tnlInfo->list.array, tnlInfo->list.size);
10536 /*******************************************************************
10537 * @brief Free the memory allocated for DRB setup List
10541 * Function : freeDrbSetupList
10544 * Free the memory allocated for DRB setup list
10546 * @params[in] DRBs_Setup_List_t *
10549 * ****************************************************************/
10550 void freeDrbSetupList(DRBs_Setup_List_t *drbSetupList)
10552 uint8_t arrIdx = 0;
10553 DRBs_Setup_ItemIEs_t *drbItemIe = NULLP;
10555 for(arrIdx = 0; arrIdx < drbSetupList->list.count; arrIdx++)
10557 drbItemIe = ((DRBs_Setup_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
10558 freeDlTnlInfo(&drbItemIe->value.choice.DRBs_Setup_Item.dLUPTNLInformation_ToBeSetup_List);
10559 DU_FREE(drbSetupList->list.array[arrIdx], sizeof(DRBs_Setup_Item_t));
10561 DU_FREE(drbSetupList->list.array, drbSetupList->list.size);
10564 /*******************************************************************
10565 * @brief Free the memory allocated for UE Setup response
10569 * Function : FreeUeContextSetupRsp
10572 * Free the memory allocated for UE Setup response
10574 * @params[in] F1AP PDU for UE setup response
10575 * @return ROK - success
10576 * RFAILED - failure
10578 * ****************************************************************/
10579 void FreeUeContextSetupRsp(F1AP_PDU_t *f1apMsg)
10582 UEContextSetupResponse_t *ueSetRsp = NULLP;
10586 if(f1apMsg->choice.successfulOutcome)
10588 ueSetRsp = &f1apMsg->choice.successfulOutcome->value.choice.\
10589 UEContextSetupResponse;
10590 if(ueSetRsp->protocolIEs.list.array)
10592 for(idx = 0; idx < ueSetRsp->protocolIEs.list.count; idx++)
10594 if(ueSetRsp->protocolIEs.list.array[idx])
10596 switch(ueSetRsp->protocolIEs.list.array[idx]->id)
10598 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
10600 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
10602 case ProtocolIE_ID_id_DUtoCURRCInformation:
10604 CellGroupConfig_t *cellGrpCfg = NULLP;
10605 cellGrpCfg = &ueSetRsp->protocolIEs.list.array[idx]->value.choice.\
10606 DUtoCURRCInformation.cellGroupConfig;
10607 if(cellGrpCfg->buf != NULLP)
10609 DU_FREE(cellGrpCfg->buf, cellGrpCfg->size);
10610 cellGrpCfg = NULLP;
10614 case ProtocolIE_ID_id_DRBs_Setup_List:
10616 freeDrbSetupList(&ueSetRsp->protocolIEs.list.array[idx]->value.choice.DRBs_Setup_List);
10620 DU_LOG("\nERROR --> DUAPP: Invalid Id %ld at FreeUeContextSetupRsp()",\
10621 ueSetRsp->protocolIEs.list.array[idx]->id);
10624 DU_FREE(ueSetRsp->protocolIEs.list.array[idx],\
10625 sizeof(UEContextSetupResponseIEs_t));
10628 DU_FREE(ueSetRsp->protocolIEs.list.array, \
10629 ueSetRsp->protocolIEs.list.size);
10631 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
10633 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
10637 /*******************************************************************
10639 * @brief Builds Ue context Setup Rsp DU To CU Info
10643 * Function : EncodeUeCntxtDuToCuInfo
10645 * Functionality: Builds Ue context Setup Rsp DU To CU Info
10647 * @params[in] CellGroupConfig_t *, CellGroupConfigRrc_t *
10649 * @return ROK - success
10650 * RFAILED - failure
10652 ******************************************************************/
10654 uint8_t EncodeUeCntxtDuToCuInfo(CellGroupConfig_t *duToCuCellGrp, CellGroupConfigRrc_t *duCellGrpCfg)
10656 asn_enc_rval_t encRetVal;
10658 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, duCellGrpCfg);
10659 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
10661 encRetVal = aper_encode(&asn_DEF_CellGroupConfigRrc, 0, duCellGrpCfg, PrepFinalEncBuf, encBuf);
10662 /* Encode results */
10663 if(encRetVal.encoded == ENCODE_FAIL)
10665 DU_LOG( "\nERROR --> F1AP : Could not encode UeCntxtDuToCuInfo (at %s)\n",\
10666 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
10671 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UeCntxtDuToCuInfo\n");
10672 for(int i=0; i< encBufSize; i++)
10674 printf("%x",encBuf[i]);
10677 duToCuCellGrp->size = encBufSize;
10678 DU_ALLOC(duToCuCellGrp->buf, duToCuCellGrp->size);
10679 if(!duToCuCellGrp->buf)
10681 DU_LOG("\nERROR --> F1AP : Memory allocation failed in UeCntxtDuToCuInfo");
10683 memcpy(duToCuCellGrp->buf, encBuf, duToCuCellGrp->size);
10687 /*******************************************************************
10689 * @brief Fills Dl Gtp tunnel Info
10693 * Function : fillGtpTunnelforDl
10695 * Functionality: Fills Dl Gtp tunnel Info
10699 * @return ROK - success
10700 * RFAILED - failure
10702 * ****************************************************************/
10704 uint8_t fillGtpTunnelforDl(GTPTunnel_t *gtpDl, GtpTnlCfg *gtpUeCfg)
10706 uint8_t bufSize = 0;
10708 gtpDl->transportLayerAddress.size = 4*sizeof(uint8_t);
10709 DU_ALLOC(gtpDl->transportLayerAddress.buf, gtpDl->transportLayerAddress.size);
10710 if(gtpDl->transportLayerAddress.buf == NULLP)
10714 memcpy(gtpDl->transportLayerAddress.buf, >pUeCfg->dlTnlAddress, gtpDl->transportLayerAddress.size);
10717 gtpDl->gTP_TEID.size = 4 * sizeof(uint8_t);
10718 DU_ALLOC(gtpDl->gTP_TEID.buf, gtpDl->gTP_TEID.size);
10719 if(gtpDl->gTP_TEID.buf == NULLP)
10723 bufSize = 3; /*forming an Octect String*/
10724 fillTeIdString(bufSize, gtpUeCfg->teId, gtpDl->gTP_TEID.buf);
10729 /*******************************************************************
10731 * @brief Fills DL Tunnel Setup List
10735 * Function : fillDlTnlSetupList
10737 * Functionality: Fills the DL Tunnel Setup List
10741 * @return ROK - success
10742 * RFAILED - failure
10744 * ****************************************************************/
10746 uint8_t fillDlTnlSetupList(DLUPTNLInformation_ToBeSetup_List_t *dlTnlInfo, UpTnlCfg *tnlCfg)
10748 uint8_t ret = ROK, arrIdx = 0, eleCount = 0;
10751 dlTnlInfo->list.count = eleCount;
10752 dlTnlInfo->list.size = (eleCount * sizeof(DLUPTNLInformation_ToBeSetup_Item_t *));
10754 /* Initialize the DL Tnl Setup List Members */
10755 DU_ALLOC(dlTnlInfo->list.array, dlTnlInfo->list.size);
10756 if(dlTnlInfo->list.array == NULLP)
10758 DU_LOG(" ERROR --> F1AP : Memory allocation for DL Tnl Setup List in fillDlTnlSetupList()");
10761 for(arrIdx=0; arrIdx < eleCount; arrIdx++)
10763 DU_ALLOC(dlTnlInfo->list.array[arrIdx], sizeof(DLUPTNLInformation_ToBeSetup_Item_t));
10764 if(dlTnlInfo->list.array[arrIdx] == NULLP)
10766 DU_LOG(" ERROR --> F1AP : Memory allocation for arrIdx [%d] failed in fillDlTnlSetupList()", arrIdx);
10769 dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.present = UPTransportLayerInformation_PR_gTPTunnel;
10770 DU_ALLOC(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel, sizeof(GTPTunnel_t));
10771 if(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel == NULLP)
10773 DU_LOG(" ERROR --> F1AP : Memory allocation for DL tunnel info in fillDlTnlSetupList()");
10776 ret = fillGtpTunnelforDl(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel,\
10784 /*******************************************************************
10786 * @brief Fills the Drb Setup List for Ue Context Setup Response
10790 * Function : fillDrbSetupList
10792 * Functionality: Fills the Drb Setup List for Ue Context Setup Response
10796 * @return ROK - success
10797 * RFAILED - failure
10799 * ****************************************************************/
10800 uint8_t fillDrbSetupList(DRBs_Setup_List_t *drbSetupList, DuUeCfg *ueCfg)
10802 uint8_t ret = ROK, arrIdx = 0, eleCount = 0;
10803 DRBs_Setup_ItemIEs_t *drbItemIe = NULLP;
10805 eleCount = ueCfg->numDrb;
10806 drbSetupList->list.count = eleCount;
10807 drbSetupList->list.size = \
10808 (eleCount * sizeof(DRBs_Setup_Item_t *));
10810 /* Initialize the Drb Setup List Members */
10811 DU_ALLOC(drbSetupList->list.array, drbSetupList->list.size);
10812 if(drbSetupList->list.array == NULLP)
10814 DU_LOG(" ERROR --> F1AP : Memory allocation for DRB Setup List in fillDrbSetupList()");
10818 for(arrIdx=0; arrIdx < eleCount; arrIdx++)
10820 DU_ALLOC(drbSetupList->list.array[arrIdx], sizeof(DRBs_Setup_Item_t));
10821 if(drbSetupList->list.array[arrIdx] == NULLP)
10823 DU_LOG(" ERROR --> F1AP : Memory allocation for arrIdx [%d] failed in fillDrbSetupList()", arrIdx);
10826 drbItemIe = ((DRBs_Setup_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
10827 drbItemIe->id = ProtocolIE_ID_id_DRBs_Setup_Item;
10828 drbItemIe->criticality = Criticality_reject;
10829 drbItemIe->value.present = DRBs_Setup_ItemIEs__value_PR_DRBs_Setup_Item;
10830 drbItemIe->value.choice.DRBs_Setup_Item.dRBID = ueCfg->upTnlInfo[arrIdx].drbId;
10831 ret = fillDlTnlSetupList(&drbItemIe->value.choice.DRBs_Setup_Item.dLUPTNLInformation_ToBeSetup_List,\
10832 &ueCfg->upTnlInfo[arrIdx]);
10839 /*******************************************************************
10841 * @brief Builds and sends the UE Setup Response
10845 * Function : BuildAndSendUeContextSetupRsp
10847 * Functionality: Constructs the UE Setup Response and sends
10848 * it to the DU through SCTP.
10850 * @params[in] uint8_t cellId,uint8_t ueIdx
10852 * @return ROK - success
10853 * RFAILED - failure
10855 * ****************************************************************/
10856 uint8_t BuildAndSendUeContextSetupRsp(uint8_t cellId,uint8_t ueIdx)
10858 uint8_t idx, ret, cellIdx, elementCnt;
10859 uint32_t gnbCuUeF1apId; /* gNB-CU UE F1AP Id */
10860 uint32_t gnbDuUeF1apId; /* gNB-DU UE F1AP Id */
10861 asn_enc_rval_t encRetVal; /* Encoder return value */
10862 F1AP_PDU_t *f1apMsg = NULLP;
10863 UEContextSetupResponse_t *ueSetRsp = NULLP;
10864 CellGroupConfigRrc_t *cellGrpCfg = NULLP;
10865 DuUeCb *ueCb = NULLP;
10867 DU_LOG("\n INFO --> F1AP : Building UE Context Setup Response for cellId %d, ueIdx %d\n", cellId, ueIdx);
10871 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
10872 if(f1apMsg == NULLP)
10874 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
10879 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
10880 DU_ALLOC(f1apMsg->choice.successfulOutcome,
10881 sizeof(SuccessfulOutcome_t));
10882 if(f1apMsg->choice.successfulOutcome == NULLP)
10884 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
10889 f1apMsg->choice.successfulOutcome->procedureCode = \
10890 ProcedureCode_id_UEContextSetup;
10891 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
10892 f1apMsg->choice.successfulOutcome->value.present = \
10893 SuccessfulOutcome__value_PR_UEContextSetupResponse;
10896 &f1apMsg->choice.successfulOutcome->value.choice.UEContextSetupResponse;
10898 ueSetRsp->protocolIEs.list.count = elementCnt;
10899 ueSetRsp->protocolIEs.list.size = \
10900 elementCnt * sizeof(UEContextSetupResponse_t *);
10902 /* Initialize the UESetup members */
10903 DU_ALLOC(ueSetRsp->protocolIEs.list.array, \
10904 ueSetRsp->protocolIEs.list.size);
10905 if(ueSetRsp->protocolIEs.list.array == NULLP)
10907 DU_LOG(" ERROR --> F1AP : Memory allocation for UE Setup Response failed");
10912 for(idx=0; idx<elementCnt; idx++)
10914 DU_ALLOC(ueSetRsp->protocolIEs.list.array[idx],\
10915 sizeof(UEContextSetupResponseIEs_t));
10916 if(ueSetRsp->protocolIEs.list.array[idx] == NULLP)
10918 DU_LOG(" ERROR --> F1AP : Memory allocation for UE Setup Response failed");
10923 /* Fetching Ue Cb Info*/
10924 GET_CELL_IDX(cellId, cellIdx);
10925 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
10926 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
10927 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
10930 /*GNB CU UE F1AP ID*/
10931 ueSetRsp->protocolIEs.list.array[idx]->id = \
10932 ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
10933 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
10934 ueSetRsp->protocolIEs.list.array[idx]->value.present = \
10935 UEContextSetupResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
10936 ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
10938 /*GNB DU UE F1AP ID*/
10940 ueSetRsp->protocolIEs.list.array[idx]->id = \
10941 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
10942 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
10943 ueSetRsp->protocolIEs.list.array[idx]->value.present = \
10944 UEContextSetupResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
10945 ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
10948 /*DUtoCURRC Information */
10950 ueSetRsp->protocolIEs.list.array[idx]->id = \
10951 ProtocolIE_ID_id_DUtoCURRCInformation;
10952 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
10953 ueSetRsp->protocolIEs.list.array[idx]->value.present =\
10954 UEContextSetupResponseIEs__value_PR_DUtoCURRCInformation;
10957 if(ueCb->f1UeDb->duUeCfg.cellGrpCfg)
10959 cellGrpCfg = (CellGroupConfigRrc_t*)ueCb->f1UeDb->duUeCfg.cellGrpCfg;
10960 ret = EncodeUeCntxtDuToCuInfo(&ueSetRsp->protocolIEs.list.array[idx]->value.\
10961 choice.DUtoCURRCInformation.cellGroupConfig, cellGrpCfg);
10964 DU_LOG("\nERROR --> F1AP : Failed to EncodeUeCntxtDuToCuInfo in BuildAndSendUeContextSetupRsp()");
10965 freeF1UeDb(ueCb->f1UeDb);
10966 ueCb->f1UeDb = NULLP;
10973 DU_LOG("\nERROR --> F1AP : Failed to form DUtoCU RRCInfo at BuildAndSendUeContextSetupRsp()");
10978 /* Drb Setup List */
10980 ueSetRsp->protocolIEs.list.array[idx]->id = \
10981 ProtocolIE_ID_id_DRBs_Setup_List;
10982 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
10983 ueSetRsp->protocolIEs.list.array[idx]->value.present =\
10984 UEContextSetupResponseIEs__value_PR_DRBs_Setup_List;
10985 ret = fillDrbSetupList(&ueSetRsp->protocolIEs.list.array[idx]->value.choice.DRBs_Setup_List,\
10986 &ueCb->f1UeDb->duUeCfg);
10989 DU_LOG("\nERROR --> F1AP : Failed to fillDrbSetupList in BuildAndSendUeContextSetupRsp()");
10990 freeF1UeDb(ueCb->f1UeDb);
10991 ueCb->f1UeDb = NULLP;
10995 /* Free UeContext Db created during Ue context Req */
10996 freeF1UeDb(ueCb->f1UeDb);
10997 ueCb->f1UeDb = NULLP;
10999 /* TODO: To send Drb list */
11000 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
11002 /* Encode the UE context setup response type as APER */
11003 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
11005 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
11007 /* Encode results */
11008 if(encRetVal.encoded == ENCODE_FAIL)
11010 DU_LOG( "\nERROR --> F1AP : Could not encode UE Context Setup Response structure (at %s)\n",\
11011 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
11017 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UE Context Setup Response\n");
11018 for(int i=0; i< encBufSize; i++)
11020 printf("%x",encBuf[i]);
11025 if(sendF1APMsg() != ROK)
11027 DU_LOG("\nERROR --> F1AP : Sending UE Context Setup Response failed");
11033 FreeUeContextSetupRsp(f1apMsg);
11035 }/* End of BuildAndSendUeContextSetupRsp */
11036 /*******************************************************************
11038 * @brief Build And Send Ue Context Rsp
11042 * Function : BuildAndSendUeCtxtRsp
11044 * Functionality : Build And Send Ue Context Rsp
11047 * @return sucess = ROK
11048 * failure = RFAILED
11050 * ****************************************************************/
11051 uint8_t BuildAndSendUeCtxtRsp(uint8_t cellId, uint8_t ueIdx)
11053 uint8_t cellIdx = 0, actionType = 0;
11055 GET_CELL_IDX(cellId, cellIdx);
11056 actionType = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb->actionType;
11060 case UE_CTXT_SETUP:
11062 BuildAndSendUeContextSetupRsp(cellId,ueIdx);
11067 BuildAndSendUeContextModRsp(cellId, ueIdx);
11071 DU_LOG("ERROR --> F1AP: Invalid Action Type %d at BuildAndSendUeCtxtRsp()", actionType);
11078 /*******************************************************************
11080 * @brief deallocating the memory of F1reset msg
11084 * Function : FreeF1ResetReq
11087 * - freeing memory of F1reset request msg
11093 * ****************************************************************/
11094 void FreeF1ResetReq(F1AP_PDU_t *f1apMsg)
11097 Reset_t *f1ResetMsg;
11101 if(f1apMsg->choice.initiatingMessage)
11103 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
11105 if(f1ResetMsg->protocolIEs.list.array)
11107 for(idx=0 ;idx < f1ResetMsg->protocolIEs.list.count ; idx++)
11109 if(f1ResetMsg->protocolIEs.list.array[idx])
11111 DU_FREE(f1ResetMsg->protocolIEs.list.array[idx],sizeof(ResetIEs_t));
11114 DU_FREE(f1ResetMsg->protocolIEs.list.array,f1ResetMsg->protocolIEs.list.size);
11116 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
11118 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
11121 /*******************************************************************
11123 * @brief Build and Send F1reset request
11127 * Function : BuildAndSendF1ResetReq
11130 * - Build and Send F1reset request msg
11133 * @return ROK - success
11134 * RFAILED - failure
11136 * ****************************************************************/
11137 uint8_t BuildAndSendF1ResetReq()
11139 uint8_t elementCnt=0;
11141 uint8_t ret= RFAILED;
11142 Reset_t *f1ResetMsg = NULLP;
11143 F1AP_PDU_t *f1apMsg = NULLP;
11144 asn_enc_rval_t encRetVal;
11145 DU_LOG("\nINFO --> F1AP : Building F1 Reset request \n");
11148 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
11149 if(f1apMsg == NULLP)
11153 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
11154 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
11155 if(f1apMsg->choice.initiatingMessage == NULLP)
11159 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_Reset;
11160 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
11161 f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_Reset;
11163 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
11166 f1ResetMsg->protocolIEs.list.count = elementCnt;
11167 f1ResetMsg->protocolIEs.list.size = elementCnt * sizeof(ResetIEs_t *);
11169 /* Initialize the F1Setup members */
11170 DU_ALLOC(f1ResetMsg->protocolIEs.list.array,f1ResetMsg->protocolIEs.list.size);
11171 if(f1ResetMsg->protocolIEs.list.array == NULLP)
11175 for(idx=0; idx<elementCnt; idx++)
11177 DU_ALLOC(f1ResetMsg->protocolIEs.list.array[idx],sizeof(ResetIEs_t));
11178 if(f1ResetMsg->protocolIEs.list.array[idx] == NULLP)
11186 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID;
11187 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11188 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_TransactionID;
11189 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.TransactionID = 1;
11193 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_Cause;
11194 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_ignore;
11195 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_Cause;
11196 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.Cause.present = Cause_PR_radioNetwork;
11197 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.Cause.choice.radioNetwork = CauseRadioNetwork_action_desirable_for_radio_reasons;
11201 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_ResetType;
11202 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11203 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_ResetType;
11204 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.ResetType.present = ResetType_PR_f1_Interface;
11205 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.ResetType.choice.f1_Interface = ResetAll_reset_all;
11207 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
11209 /* Encode the F1SetupRequest type as APER */
11210 memset(encBuf, 0, ENC_BUF_MAX_LEN);
11212 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
11215 /* Encode results */
11216 if(encRetVal.encoded == ENCODE_FAIL)
11218 DU_LOG("\nERROR --> F1AP : Could not encode F1Reset structure (at %s)\n",\
11219 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
11224 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for F1Reset\n");
11225 for(idx=0; idx< encBufSize; idx++)
11227 printf("%x",encBuf[idx]);
11231 if(sendF1APMsg() != ROK)
11233 DU_LOG("\nERROR --> F1AP : Sending F1 Reset request failed");
11241 FreeF1ResetReq(f1apMsg);
11244 /*******************************************************************
11246 * @brief Build And Send F1ResetAck
11250 * Function : BuildAndSendF1ResetAck
11253 * - Build And Send F1ResetRSP
11255 * @return ROK - success
11256 * RFAILED - failure
11258 * ****************************************************************/
11259 void FreeF1ResetAck(F1AP_PDU_t *f1apMsg)
11262 ResetAcknowledge_t *f1ResetAck;
11266 if(f1apMsg->choice.successfulOutcome)
11268 f1ResetAck= &f1apMsg->choice.successfulOutcome->value.choice.ResetAcknowledge;
11270 if(f1ResetAck->protocolIEs.list.array)
11272 for(idx=0; idx<f1ResetAck->protocolIEs.list.count ; idx++)
11274 if(f1ResetAck->protocolIEs.list.array[idx])
11276 DU_FREE(f1ResetAck->protocolIEs.list.array[idx], sizeof(ResetAcknowledgeIEs_t));
11279 DU_FREE(f1ResetAck->protocolIEs.list.array, f1ResetAck->protocolIEs.list.size );
11281 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
11283 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
11287 /*******************************************************************
11289 * @brief Build And Send F1ResetAck
11293 * Function : BuildAndSendF1ResetAck
11296 * - Build And Send F1ResetRSP
11299 * @return ROK - success
11300 * RFAILED - failure
11302 * ****************************************************************/
11303 uint8_t BuildAndSendF1ResetAck()
11306 uint8_t elementCnt = 0;
11307 uint8_t ret = RFAILED;
11308 F1AP_PDU_t *f1apMsg = NULL;
11309 ResetAcknowledge_t *f1ResetAck = NULLP;
11310 asn_enc_rval_t encRetVal;
11311 DU_LOG("\nINFO --> F1AP : Building F1 Reset Acknowledgment \n");
11314 /* Allocate the memory for F1ResetRequest_t */
11315 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
11316 if(f1apMsg == NULLP)
11318 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11322 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
11324 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
11325 if(f1apMsg->choice.successfulOutcome == NULLP)
11327 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11330 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
11331 f1apMsg->choice.successfulOutcome->value.present = SuccessfulOutcome__value_PR_ResetAcknowledge;
11332 f1ResetAck = &f1apMsg->choice.successfulOutcome->value.choice.ResetAcknowledge;
11336 f1ResetAck->protocolIEs.list.count = elementCnt;
11337 f1ResetAck->protocolIEs.list.size = elementCnt*sizeof(ResetAcknowledgeIEs_t *);
11339 DU_ALLOC(f1ResetAck->protocolIEs.list.array, f1ResetAck->protocolIEs.list.size );
11340 if(f1ResetAck->protocolIEs.list.array == NULLP)
11342 DU_LOG("\nERROR --> F1AP : Memory allocation for F1ResetAckIEs failed");
11346 for(idx=0; idx<elementCnt; idx++)
11348 DU_ALLOC(f1ResetAck->protocolIEs.list.array[idx], sizeof(ResetAcknowledgeIEs_t));
11349 if(f1ResetAck->protocolIEs.list.array[idx] == NULLP)
11356 f1ResetAck->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID;
11357 f1ResetAck->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11358 f1ResetAck->protocolIEs.list.array[idx]->value.present = ResetAcknowledgeIEs__value_PR_TransactionID;
11359 f1ResetAck->protocolIEs.list.array[idx]->value.choice.TransactionID = TRANS_ID;
11361 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
11363 /* Encode the F1SetupRequest type as UPER */
11364 memset(encBuf, 0, ENC_BUF_MAX_LEN);
11366 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
11368 /* Check encode results */
11369 if(encRetVal.encoded == ENCODE_FAIL)
11371 DU_LOG("\nERROR --> F1AP : Could not encode F1ResetAck structure (at %s)\n",\
11372 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
11377 DU_LOG("\nDUBUG --> F1AP : Created APER encoded buffer for F1ResetAck\n");
11378 for(int i=0; i< encBufSize; i++)
11380 printf("%x",encBuf[i]);
11384 if(sendF1APMsg() != ROK)
11386 DU_LOG("\nERROR --> F1AP : Sending F1 Reset Acknowledgement failed");
11394 FreeF1ResetAck(f1apMsg);
11397 /******************************************************************
11399 * @brief free F1 reset msg allocated by aper_decoder
11403 * Function : freeAperDecodeF1ResetMsg
11405 * Functionality: free F1 reset msg allocated by aper_decoder
11407 * @params[in] Reset_t *f1ResetMsg
11410 * ****************************************************************/
11412 void freeAperDecodeF1ResetMsg(Reset_t *f1ResetMsg)
11415 if(f1ResetMsg->protocolIEs.list.array)
11417 for(ieIdx=0 ;ieIdx < f1ResetMsg->protocolIEs.list.count ; ieIdx++)
11419 if(f1ResetMsg->protocolIEs.list.array[ieIdx])
11421 free(f1ResetMsg->protocolIEs.list.array[ieIdx]);
11424 free(f1ResetMsg->protocolIEs.list.array);
11428 /******************************************************************
11430 * @brief Processes DL RRC Message Transfer sent by CU
11434 * Function : procF1ResetReq
11436 * Functionality: Processes DL RRC Message Transfer sent by CU
11438 * @params[in] F1AP_PDU_t ASN decoded F1AP message
11439 * @return ROK - success
11440 * RFAILED - failure
11442 * ****************************************************************/
11443 uint8_t procF1ResetReq(F1AP_PDU_t *f1apMsg)
11445 /* we are currently not supporting Ue release. right now we are supporting only init case of fireset */
11448 Reset_t *f1ResetMsg = NULLP;
11450 DU_LOG("\nINFO --> Processing F1 reset request");
11451 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
11453 for(ieIdx=0; ieIdx<f1ResetMsg->protocolIEs.list.count; ieIdx++)
11455 switch(f1ResetMsg->protocolIEs.list.array[ieIdx]->id)
11457 case ProtocolIE_ID_id_TransactionID:
11460 case ProtocolIE_ID_id_Cause:
11463 case ProtocolIE_ID_id_ResetType:
11472 ret = BuildAndSendF1ResetAck();
11473 DU_LOG("\nINFO --> UE release is not supported for now");
11475 freeAperDecodeF1ResetMsg(f1ResetMsg);
11480 /*******************************************************************
11482 * @brief free the RRC delivery report
11486 * Function : freeRrcDeliveryReport
11488 * Functionality: free the RRC delivery report
11491 * @return ROK - success
11492 * RFAILED - failure
11494 * ****************************************************************/
11495 void freeRrcDeliveryReport(F1AP_PDU_t *f1apMsg )
11498 RRCDeliveryReport_t *rrcDeliveryReport= NULLP;
11502 if(f1apMsg->choice.initiatingMessage)
11504 rrcDeliveryReport = &f1apMsg->choice.initiatingMessage->value.choice.RRCDeliveryReport;
11505 if(rrcDeliveryReport->protocolIEs.list.array)
11507 for(idx =0 ;idx <rrcDeliveryReport->protocolIEs.list.count ;
11510 if(rrcDeliveryReport->protocolIEs.list.array[idx])
11512 DU_FREE(rrcDeliveryReport->protocolIEs.list.array[idx],
11513 sizeof(RRCDeliveryReportIEs_t));
11516 DU_FREE(rrcDeliveryReport->protocolIEs.list.array,
11517 rrcDeliveryReport->protocolIEs.list.size);
11519 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
11522 sizeof(F1AP_PDU_t));
11526 /*******************************************************************
11528 * @brief Builds and sends the RRC delivery report
11532 * Function : BuildAndSendRrcDeliveryReport
11534 * Functionality: Builds and sends the RRC delivery report
11538 * @return ROK - success
11539 * RFAILED - failure
11541 * ****************************************************************/
11542 uint8_t BuildAndSendRrcDeliveryReport(uint32_t gnbCuUeF1apId, \
11543 uint32_t gnbDuUeF1apId, RrcDeliveryReport *rrcDelivery)
11545 uint8_t ret = RFAILED;
11548 uint8_t elementCnt = 0;
11549 F1AP_PDU_t *f1apMsg = NULLP;
11550 asn_enc_rval_t encRetVal;
11551 RRCDeliveryReport_t *rrcDeliveryReport= NULLP;
11555 DU_LOG("\nINFO --> F1AP : Building RRC delivery Message Transfer Message\n");
11556 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
11557 if(f1apMsg == NULLP)
11559 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11562 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
11563 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
11564 if(f1apMsg->choice.initiatingMessage == NULLP)
11566 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11569 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_RRCDeliveryReport;
11570 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
11571 f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_RRCDeliveryReport;
11573 rrcDeliveryReport = &f1apMsg->choice.initiatingMessage->value.choice.RRCDeliveryReport;
11575 rrcDeliveryReport->protocolIEs.list.count = elementCnt;
11576 rrcDeliveryReport->protocolIEs.list.size = elementCnt * sizeof(RRCDeliveryReportIEs_t *);
11578 /* Initialize the F1Setup members */
11579 DU_ALLOC(rrcDeliveryReport->protocolIEs.list.array, rrcDeliveryReport->protocolIEs.list.size);
11580 if(rrcDeliveryReport->protocolIEs.list.array == NULLP)
11582 DU_LOG(" ERROR --> F1AP : Memory allocation for RRC Delivery failed");
11585 for(idx =0 ;idx <elementCnt; idx++)
11587 DU_ALLOC(rrcDeliveryReport->protocolIEs.list.array[idx], sizeof(RRCDeliveryReportIEs_t));
11588 if(rrcDeliveryReport->protocolIEs.list.array[idx] == NULLP)
11596 /*GNB CU UE F1AP ID*/
11597 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
11598 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
11599 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_GNB_CU_UE_F1AP_ID;
11600 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
11602 /*GNB DU UE F1AP ID*/
11604 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
11605 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
11606 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_GNB_DU_UE_F1AP_ID;
11607 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
11609 /*RRC delivery status*/
11611 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_RRCDeliveryStatus;
11612 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_ignore;
11613 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_RRCDeliveryStatus;
11614 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.RRCDeliveryStatus.delivery_status =\
11615 rrcDelivery->rrcDeliveryStatus.deliveryStatus;
11616 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.RRCDeliveryStatus.triggering_message =\
11617 rrcDelivery->rrcDeliveryStatus.triggeringMessage;
11621 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_SRBID;
11622 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_ignore;
11623 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_SRBID;
11624 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.SRBID = rrcDelivery->srbId;
11626 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
11628 /* Encode the RRC DELIVERY REPORT type as APER */
11629 memset(encBuf, 0, ENC_BUF_MAX_LEN);
11631 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
11634 /* Encode results */
11635 if(encRetVal.encoded == ENCODE_FAIL)
11637 DU_LOG("\nERROR --> F1AP : Could not encode RRC Delivery Msg structure (at %s)\n",\
11638 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
11643 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for RRC Delivery Msg \n");
11644 for(idx=0; idx< encBufSize; idx++)
11646 printf("%x",encBuf[idx]);
11651 if(sendF1APMsg() != ROK)
11653 DU_LOG("\nERROR --> F1AP : Sending RRC delivery msg request failed");
11661 freeRrcDeliveryReport(f1apMsg);
11665 /*******************************************************************
11667 * @brief Processes cells to be activated
11671 * Function : extractCellsToBeActivated
11674 * - Processes cells to be activated list received in F1SetupRsp
11677 * @return ROK - success
11678 * RFAILED - failure
11680 * ****************************************************************/
11682 uint8_t extractCellsToBeActivated(Cells_to_be_Activated_List_t cellsToActivate)
11685 uint16_t idx, nci, pci = 0;
11686 Cells_to_be_Activated_List_Item_t cell;
11688 for(idx=0; idx<cellsToActivate.list.count; idx++)
11691 cell = cellsToActivate.list.array[idx]->value.choice.Cells_to_be_Activated_List_Item;
11692 bitStringToInt(&cell.nRCGI.nRCellIdentity, &nci);
11698 ret = duProcCellsToBeActivated(cell.nRCGI.pLMN_Identity.buf, nci, pci);
11702 /******************************************************************
11704 * @brief Processes F1 Setup Response allocated by aper_decoder
11708 * Function : freeF1SetupRsp
11710 * Functionality: free F1 Setup Response allocated by aper_decoder
11712 * @params[in] F1SetupResponse_t *f1SetRspMsg
11715 * ****************************************************************/
11717 void freeAperDecodeF1SetupRsp(F1SetupResponse_t *f1SetRspMsg)
11721 Cells_to_be_Activated_List_t *cellToActivate =NULLP;
11722 RRC_Version_t *rrcVer =NULLP;
11724 if(f1SetRspMsg->protocolIEs.list.array)
11726 for(ieIdx=0; ieIdx<f1SetRspMsg->protocolIEs.list.count; ieIdx++)
11728 if(f1SetRspMsg->protocolIEs.list.array[ieIdx])
11730 switch(f1SetRspMsg->protocolIEs.list.array[ieIdx]->id)
11732 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
11735 &f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.Cells_to_be_Activated_List;
11736 if(cellToActivate->list.array)
11738 for(arrIdx=0; arrIdx<cellToActivate->list.count ; arrIdx++)
11740 if(cellToActivate->list.array[arrIdx])
11743 if(cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.nRCGI.\
11746 if(cellToActivate->list.array[0]->value.choice.\
11747 Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf)
11749 free(cellToActivate->list.array[0]->value.choice.\
11750 Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf);
11753 free(cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.\
11754 nRCGI.pLMN_Identity.buf);
11756 free(cellToActivate->list.array[arrIdx]);
11759 free(cellToActivate->list.array);
11763 case ProtocolIE_ID_id_TransactionID:
11767 case ProtocolIE_ID_id_gNB_CU_Name:
11769 free(f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_Name.buf);
11772 case ProtocolIE_ID_id_GNB_CU_RRC_Version:
11774 rrcVer = &f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.RRC_Version;
11775 if(rrcVer->latest_RRC_Version.buf)
11777 if(rrcVer->iE_Extensions)
11779 if(rrcVer->iE_Extensions->list.array)
11781 if(rrcVer->iE_Extensions->list.array[0])
11783 if(rrcVer->iE_Extensions->list.\
11784 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf)
11786 free(rrcVer->iE_Extensions->list.\
11787 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf);
11789 free(rrcVer->iE_Extensions->list.array[0]);
11791 free(rrcVer->iE_Extensions->list.array);
11793 free(rrcVer->iE_Extensions);
11795 free(rrcVer->latest_RRC_Version.buf);
11802 DU_LOG("\nERROR --> DU_APP : Invalid IE received in F1SetupRsp:%ld",
11803 f1SetRspMsg->protocolIEs.list.array[ieIdx]->id);
11806 free(f1SetRspMsg->protocolIEs.list.array[ieIdx]);
11809 free(f1SetRspMsg->protocolIEs.list.array);
11812 /******************************************************************
11814 * @brief Processes F1 Setup Response sent by CU
11818 * Function : procF1SetupRsp
11820 * Functionality: Processes F1 Setup Response sent by CU
11822 * @params[in] F1AP_PDU_t ASN decoded F1AP message
11823 * @return ROK - success
11824 * RFAILED - failure
11826 * ****************************************************************/
11827 uint8_t procF1SetupRsp(F1AP_PDU_t *f1apMsg)
11831 F1SetupResponse_t *f1SetRspMsg = NULLP;
11832 GNB_CU_Name_t *cuName = NULLP;
11833 F1SetupRsp f1SetRspDb;
11834 RRC_Version_t *rrcVer =NULLP;
11836 memset(&f1SetRspDb, 0, sizeof(F1SetupRsp));
11838 DU_LOG("\nINFO --> F1AP : F1 Setup Response received");
11839 f1SetRspMsg = &f1apMsg->choice.successfulOutcome->value.choice.F1SetupResponse;
11841 for(idx=0; idx<f1SetRspMsg->protocolIEs.list.count; idx++)
11843 switch(f1SetRspMsg->protocolIEs.list.array[idx]->id)
11845 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
11847 extractCellsToBeActivated(f1SetRspMsg->protocolIEs.list.array[idx]->\
11848 value.choice.Cells_to_be_Activated_List);
11851 case ProtocolIE_ID_id_TransactionID:
11853 f1SetRspDb.transId = f1SetRspMsg->protocolIEs.list.array[idx]->\
11854 value.choice.TransactionID;
11857 case ProtocolIE_ID_id_gNB_CU_Name:
11859 cuName = &f1SetRspMsg->protocolIEs.list.array[idx]->\
11860 value.choice.GNB_CU_Name;
11861 strcpy(f1SetRspDb.cuName, (const char*)cuName->buf);
11864 case ProtocolIE_ID_id_GNB_CU_RRC_Version:
11866 rrcVer = &f1SetRspMsg->protocolIEs.list.array[idx]->value.choice.RRC_Version;
11867 strcpy(f1SetRspDb.rrcVersion.rrcVer,
11868 (const char*)rrcVer->latest_RRC_Version.buf);
11872 DU_LOG("\nERROR --> DU_APP : Invalid IE received in F1SetupRsp:%ld",
11873 f1SetRspMsg->protocolIEs.list.array[idx]->id);
11875 duProcF1SetupRsp();
11878 freeAperDecodeF1SetupRsp(f1SetRspMsg);
11881 /*******************************************************************
11883 * @brief free GNB DU config update ack
11887 * Function : freeAperDecodeGnbDuAck
11889 * Functionality: Processes GNB DU config update ack And
11890 * added free part for the memory allocated by aper_decoder
11892 * @params[in] F1AP_PDU_t ASN decoded F1AP message
11893 * @return ROK - success
11894 * RFAILED - failure
11896 * ****************************************************************/
11898 void freeAperDecodeGnbDuAck(GNBDUConfigurationUpdateAcknowledge_t *gnbDuAck)
11902 if(gnbDuAck->protocolIEs.list.array)
11904 for(ieIdx=0; ieIdx < gnbDuAck->protocolIEs.list.count; ieIdx++)
11906 if(gnbDuAck->protocolIEs.list.array[ieIdx])
11908 free(gnbDuAck->protocolIEs.list.array[ieIdx]);
11911 free(gnbDuAck->protocolIEs.list.array);
11915 /*******************************************************************
11917 * @brief Building result of gnb-du config update ack output
11921 * Function : duProcGnbDuCfgUpdAckMsg
11924 * Building output of gnb-du config update ack
11926 * @params[in] transId
11929 * ****************************************************************/
11931 uint8_t duProcGnbDuCfgUpdAckMsg(uint8_t transId)
11933 uint8_t ieIdx=0, arrIdx=0,ret=ROK;
11934 uint8_t ueId =0 , ueIdx =0;
11935 uint16_t cellId =0, cellIdx =0, crnti=0;
11936 CmLList *f1apPduNode = NULLP;
11937 ReservedF1apPduInfo *f1apPduInfo =NULLP;
11938 F1AP_PDU_t *f1apMsgPdu = NULLP;
11939 GNBDUConfigurationUpdate_t *gnbDuConfigUpdate = NULLP;
11940 BIT_STRING_t *cellIdentity=NULLP;
11941 struct Served_Cells_To_Delete_ItemIEs *deleteItemIe=NULLP;
11942 Served_Cells_To_Delete_List_t *cellsToDelete=NULLP;
11943 Served_Cells_To_Delete_Item_t *deleteItem=NULLP;
11945 DU_LOG("\nINFO --> DU APP: GNB-DU config update Ack received ");
11946 f1apPduNode = searchFromReservedF1apPduList(transId);
11947 f1apPduInfo = (ReservedF1apPduInfo *)f1apPduNode->node;
11948 f1apMsgPdu = (F1AP_PDU_t *)f1apPduInfo->f1apMsg;
11952 if(f1apMsgPdu->choice.initiatingMessage)
11954 gnbDuConfigUpdate = &f1apMsgPdu->choice.initiatingMessage->value.choice.GNBDUConfigurationUpdate;
11955 for(ieIdx=0; ieIdx < gnbDuConfigUpdate->protocolIEs.list.count; ieIdx++)
11957 switch(gnbDuConfigUpdate->protocolIEs.list.array[ieIdx]->id)
11959 case ProtocolIE_ID_id_Served_Cells_To_Delete_List:
11961 cellsToDelete = &gnbDuConfigUpdate->protocolIEs.list.array[ieIdx]->value.choice.\
11962 Served_Cells_To_Delete_List;
11963 if(cellsToDelete->list.array)
11965 if(cellsToDelete->list.array[arrIdx])
11967 deleteItemIe = (Served_Cells_To_Delete_ItemIEs_t*)cellsToDelete->list.array[arrIdx];
11968 deleteItem=&deleteItemIe->value.choice.Served_Cells_To_Delete_Item;
11969 if(deleteItem->oldNRCGI.nRCellIdentity.buf)
11971 cellIdentity = &deleteItem->oldNRCGI.nRCellIdentity;
11972 bitStringToInt(cellIdentity, &cellId);
11977 GET_CELL_IDX(cellId, cellIdx);
11978 if(duCb.actvCellLst[cellIdx] != NULLP)
11980 if(duCb.actvCellLst[cellIdx]->numActvUes == 0)
11982 duCb.actvCellLst[cellId-1]->cellStatus = DELETION_IN_PROGRESS;
11983 ret = duSendCellDeletReq(cellId);
11986 DU_LOG("ERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): Failed to send cell delete\
11987 request for cellId[%d]", cellId);
11992 for(ueIdx = 0; ueIdx < duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
11994 crnti = duCb.actvCellLst[cellIdx]->ueCb[ueIdx].crnti;
11995 GET_UE_IDX(crnti,ueId);
11996 ret = BuildAndSendUeContextReleaseReq(cellId, ueId);
11999 DU_LOG("ERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): Failed to build and send UE delete\
12000 request for cellId[%d]", cellId);
12007 DU_LOG("ERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): CellId [%d] not found", cellId);
12020 FreeDUConfigUpdate(f1apMsgPdu);
12021 deleteFromReservedF1apPduList(f1apPduNode);
12025 /*******************************************************************
12027 * @brief Processes GNB DU config update ack
12031 * Function : procF1GNBDUCfgUpdAck
12033 * Functionality: added free part for the memory allocated by aper_decoder
12035 * @params[in] F1AP_PDU_t *f1apMsg
12038 * ****************************************************************/
12039 uint8_t procF1GNBDUCfgUpdAck(F1AP_PDU_t *f1apMsg)
12041 uint8_t ieIdx=0,transId=0;
12042 GNBDUConfigurationUpdateAcknowledge_t *gnbDuAck = NULLP;
12044 DU_LOG("\nINFO --> F1AP : GNB-DU config update acknowledgment");
12045 gnbDuAck = &f1apMsg->choice.successfulOutcome->value.choice.GNBDUConfigurationUpdateAcknowledge;
12047 for(ieIdx=0; ieIdx < gnbDuAck->protocolIEs.list.count; ieIdx++)
12049 switch(gnbDuAck->protocolIEs.list.array[ieIdx]->id)
12051 case ProtocolIE_ID_id_TransactionID:
12053 transId = gnbDuAck->protocolIEs.list.array[ieIdx]->value.choice.TransactionID;
12056 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
12062 DU_LOG("\nERROR --> F1AP: procF1GNBDUCfgUpdAck(): Invalid IE Received: %ld", \
12063 gnbDuAck->protocolIEs.list.array[ieIdx]->id);
12069 duProcGnbDuCfgUpdAckMsg(transId);
12072 /* presently we are not supporting F1 Reset from DU to CU , we are only
12073 * supporting F1 Reset from CU to DU */
12075 if(BuildAndSendF1ResetReq() != ROK)
12081 freeAperDecodeGnbDuAck(gnbDuAck);
12084 /******************************************************************
12086 * @brief free DL RRC Message Transfer allocated by aper_decoder
12090 * Function : freeAperDecodef1DlRrcMsg
12092 * Functionality: free DL RRC Message Transfer allocated by aper_decoder
12094 * @params[in] DLRRCMessageTransfer_t *f1DlRrcMsg
12095 * @return ROK - success
12096 * RFAILED - failure
12098 * ****************************************************************/
12100 void freeAperDecodef1DlRrcMsg(DLRRCMessageTransfer_t *f1DlRrcMsg)
12103 RRCContainer_t *rrcContainer = NULLP;
12105 if(f1DlRrcMsg->protocolIEs.list.array)
12107 for(ieIdx=0; ieIdx<f1DlRrcMsg->protocolIEs.list.count; ieIdx++)
12109 if(f1DlRrcMsg->protocolIEs.list.array[ieIdx])
12111 switch(f1DlRrcMsg->protocolIEs.list.array[ieIdx]->id)
12113 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12115 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12117 case ProtocolIE_ID_id_SRBID:
12119 case ProtocolIE_ID_id_RRCContainer:
12121 rrcContainer =&f1DlRrcMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer;
12122 free(rrcContainer->buf);
12124 case ProtocolIE_ID_id_ExecuteDuplication:
12126 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
12130 free(f1DlRrcMsg->protocolIEs.list.array[ieIdx]);
12133 free(f1DlRrcMsg->protocolIEs.list.array);
12136 /******************************************************************
12138 * @brief Processes DL RRC Message Transfer sent by CU
12142 * Function : procF1DlRrcMsgTrans
12144 * Functionality: Processes DL RRC Message Transfer sent by CU
12146 * @params[in] F1AP_PDU_t ASN decoded F1AP message
12147 * @return ROK - success
12148 * RFAILED - failure
12150 * ****************************************************************/
12151 uint8_t procF1DlRrcMsgTrans(F1AP_PDU_t *f1apMsg)
12154 DLRRCMessageTransfer_t *f1DlRrcMsg = NULLP;
12156 memset(&dlMsg, 0, sizeof(F1DlRrcMsg));
12158 DU_LOG("\nINFO --> DU_APP : DL RRC message transfer Recevied");
12159 f1DlRrcMsg = &f1apMsg->choice.initiatingMessage->value.choice.DLRRCMessageTransfer;
12163 for(idx=0; idx<f1DlRrcMsg->protocolIEs.list.count; idx++)
12165 switch(f1DlRrcMsg->protocolIEs.list.array[idx]->id)
12167 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12169 dlMsg.gnbCuUeF1apId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID;
12172 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12174 dlMsg.gnbDuUeF1apId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID;
12177 case ProtocolIE_ID_id_SRBID:
12179 dlMsg.srbId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.SRBID;
12182 case ProtocolIE_ID_id_ExecuteDuplication:
12183 dlMsg.execDup = true;
12186 case ProtocolIE_ID_id_RRCContainer:
12188 if(f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size > 0)
12190 dlMsg.rrcMsgSize = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size;
12191 DU_ALLOC_SHRABL_BUF(dlMsg.rrcMsgPdu, dlMsg.rrcMsgSize);
12192 if(dlMsg.rrcMsgPdu)
12194 memcpy(dlMsg.rrcMsgPdu, f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.buf,\
12199 DU_LOG("\nERROR --> DU APP : Memory alloc Failed at RRC Container at procF1DlRrcMsgTrans()");
12205 DU_LOG("\nERROR --> DU_APP : RRC Container Size is invalid:%ld",\
12206 f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size);
12211 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
12213 dlMsg.deliveryStatRpt = true;
12217 DU_LOG("\nERROR --> DU_APP : Invalid IE received in DL RRC Msg Transfer:%ld",
12218 f1DlRrcMsg->protocolIEs.list.array[idx]->id);
12222 ret = duProcDlRrcMsg(&dlMsg);
12224 freeAperDecodef1DlRrcMsg(f1DlRrcMsg);
12227 /*******************************************************************
12229 * @brief Builds the DRB to be Setup Mod list
12235 * Functionality: Constructs the DRB to be Setup Mod list
12237 * @params[in] DRBs_SetupMod_List_t *drbSet
12239 * @return ROK - success
12240 * RFAILED - failure
12242 * ****************************************************************/
12244 uint8_t BuildDrbSetupModList(DRBs_SetupMod_List_t *drbSet , DuUeCfg *ueCfg)
12248 struct DRBs_SetupMod_ItemIEs *drbItemIe;
12251 drbSet->list.count = drbCnt;
12252 drbSet->list.size = drbCnt * sizeof(DRBs_SetupMod_ItemIEs_t *);
12253 DU_ALLOC(drbSet->list.array, drbSet->list.size);
12254 if(drbSet->list.array == NULLP)
12256 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDrbToBeSetupModList");
12259 for(arrIdx=0; arrIdx<drbCnt; arrIdx++)
12261 DU_ALLOC(drbSet->list.array[arrIdx], sizeof(DRBs_SetupMod_ItemIEs_t));
12262 if(drbSet->list.array[arrIdx] == NULLP)
12264 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDrbToBeSetupModList");
12268 drbItemIe = (struct DRBs_SetupMod_ItemIEs *)drbSet->list.array[arrIdx];
12269 drbItemIe->id = ProtocolIE_ID_id_DRBs_SetupMod_Item;
12270 drbItemIe->criticality = Criticality_reject;
12271 drbItemIe->value.present = DRBs_SetupMod_ItemIEs__value_PR_DRBs_SetupMod_Item;
12272 drbItemIe->value.choice.DRBs_SetupMod_Item.dRBID = ueCfg->upTnlInfo[arrIdx].drbId;
12273 if(fillDlTnlSetupList(&drbItemIe->value.choice.DRBs_SetupMod_Item.dLUPTNLInformation_ToBeSetup_List,\
12274 &ueCfg->upTnlInfo[arrIdx])!= ROK)
12276 DU_LOG("\nERROR --> F1AP : Failed to fill DlTnl SetupList in BuildDrbToBeSetupModList");
12284 /*******************************************************************
12285 * @brief Free the memory allocated for DRB setup List
12289 * Function : FreeDrbSetupModList
12292 * Free the memory allocated for DRB setup list
12294 * @params[in] DRBs_Setup_List_t *
12297 * ****************************************************************/
12298 void FreeDrbSetupModList(DRBs_SetupMod_List_t *drbSetupList)
12300 uint8_t arrIdx = 0;
12301 DRBs_SetupMod_ItemIEs_t *drbItemIe = NULLP;
12303 for(arrIdx = 0; arrIdx < drbSetupList->list.count; arrIdx++)
12305 drbItemIe = ((DRBs_SetupMod_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
12306 freeDlTnlInfo(&drbItemIe->value.choice.DRBs_SetupMod_Item.dLUPTNLInformation_ToBeSetup_List);
12307 DU_FREE(drbSetupList->list.array[arrIdx], sizeof(DRBs_SetupMod_ItemIEs_t));
12309 DU_FREE(drbSetupList->list.array, drbSetupList->list.size);
12311 /*******************************************************************
12312 * @brief Free the memory allocated for UE Context Mod Response
12316 * Function : FreeUeContextModResp
12319 * Free the memory allocated for UE Context Mod Response
12321 * @params[in] F1AP_PDU_t *f1apMsg
12324 * ****************************************************************/
12326 void FreeUeContextModResp(F1AP_PDU_t *f1apMsg)
12329 UEContextModificationResponse_t *ueContextModifyRes = NULLP;
12332 if(f1apMsg->choice.successfulOutcome)
12334 ueContextModifyRes =&f1apMsg->choice.successfulOutcome->value.choice.UEContextModificationResponse;
12335 if(ueContextModifyRes->protocolIEs.list.array)
12337 for(ieIdx=0 ; ieIdx<ueContextModifyRes->protocolIEs.list.count; ieIdx++)
12339 if(ueContextModifyRes->protocolIEs.list.array[ieIdx])
12341 switch(ueContextModifyRes->protocolIEs.list.array[ieIdx]->id)
12343 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12345 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12347 case ProtocolIE_ID_id_DRBs_SetupMod_List:
12349 FreeDrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
12350 value.choice.DRBs_SetupMod_List));
12354 DU_FREE(ueContextModifyRes->protocolIEs.list.array[ieIdx], sizeof(UEContextModificationResponse_t));
12358 DU_FREE(ueContextModifyRes->protocolIEs.list.array, ueContextModifyRes->protocolIEs.list.size);
12360 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
12362 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
12366 /*****************************************************************i
12368 * @brief Creating the ue context modifcation response and sending
12372 * Function : BuildAndSendUeContextModRsp
12375 * - Creating the ue context modifcation response
12377 * @params[in] uint8_t cellId,uint8_t ueIdx
12378 * @return ROK - success
12379 * RFAILED - failure
12381 * ****************************************************************/
12382 uint8_t BuildAndSendUeContextModRsp(uint8_t cellId,uint8_t ueIdx)
12385 uint8_t cellIdx =0;
12386 uint8_t elementCnt = 0;
12387 uint8_t ret = RFAILED;
12388 uint32_t gnbCuUeF1apId; /* gNB-CU UE F1AP Id */
12389 uint32_t gnbDuUeF1apId; /* gNB-DU UE F1AP Id */
12390 F1AP_PDU_t *f1apMsg = NULLP;
12391 asn_enc_rval_t encRetVal;
12392 UEContextModificationResponse_t *ueContextModifyRes = NULLP;
12393 DuUeCb *ueCb = NULLP;
12395 DU_LOG("\nINFO --> F1AP : Building Ue context modification response\n");
12399 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
12400 if(f1apMsg == NULLP)
12402 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed Ue context modification");
12406 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
12408 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
12409 if(f1apMsg->choice.successfulOutcome == NULLP)
12411 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed Ue context modification");
12414 f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_UEContextModification;
12415 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
12416 f1apMsg->choice.successfulOutcome->value.present = SuccessfulOutcome__value_PR_UEContextModificationResponse;
12418 ueContextModifyRes =&f1apMsg->choice.successfulOutcome->value.choice.UEContextModificationResponse;
12421 ueContextModifyRes->protocolIEs.list.count = elementCnt;
12422 ueContextModifyRes->protocolIEs.list.size = elementCnt*sizeof(UEContextModificationResponse_t*);
12424 /* Initialize the UE context modification members */
12425 DU_ALLOC(ueContextModifyRes->protocolIEs.list.array, ueContextModifyRes->protocolIEs.list.size);
12426 if(ueContextModifyRes->protocolIEs.list.array == NULLP)
12428 DU_LOG("\nERROR --> F1AP : Memory allocation for UE context modifcation Request failed");
12432 for(ieIdx=0 ; ieIdx<elementCnt; ieIdx++)
12434 DU_ALLOC(ueContextModifyRes->protocolIEs.list.array[ieIdx], sizeof(UEContextModificationResponse_t));
12435 if(ueContextModifyRes->protocolIEs.list.array[ieIdx] == NULLP)
12437 DU_LOG("\nERROR --> F1AP : Memory allocation for UE context modifcation Request failed");
12442 /* Fetching Ue Cb Info*/
12443 GET_CELL_IDX(cellId, cellIdx);
12444 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
12445 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
12446 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
12449 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
12450 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
12451 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present =\
12452 UEContextModificationResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
12453 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
12456 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
12457 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
12458 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present=\
12459 UEContextModificationResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
12460 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
12463 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DRBs_SetupMod_List;
12464 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
12465 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present =\
12466 UEContextModificationResponseIEs__value_PR_DRBs_SetupMod_List;
12469 ret = BuildDrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
12470 value.choice.DRBs_SetupMod_List) , &ueCb->f1UeDb->duUeCfg);
12473 DU_LOG( "\nERROR --> F1AP : Failed to build drb setupmod List ");
12476 freeF1UeDb(ueCb->f1UeDb);
12477 ueCb->f1UeDb = NULLP;
12479 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
12481 /* Encode the F1SetupRequest type as APER */
12482 memset(encBuf, 0, ENC_BUF_MAX_LEN);
12484 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,encBuf);
12486 /* Encode results */
12487 if(encRetVal.encoded == ENCODE_FAIL)
12489 DU_LOG( "\nERROR --> F1AP : Could not encode UE Context Setup Request structure (at %s)\n",\
12490 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
12496 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UE Context Modification Response\n");
12497 for(int i=0; i< encBufSize; i++)
12499 printf("%x",encBuf[i]);
12504 if(sendF1APMsg() != ROK)
12506 DU_LOG("\nERROR --> F1AP : Sending UE Context Setup Res Failed");
12512 FreeUeContextModResp(f1apMsg);
12515 /*******************************************************************
12517 * @brief Deallocating the memory allocated by the aper decoder
12522 * Function : freeAperDecodeQosInfo
12524 * Functionality: Deallocating the memory allocated for QOSInfo
12526 * @params[in] QoSFlowLevelQoSParameters_t *drbQos
12530 * ****************************************************************/
12532 void freeAperDecodeQosInfo(QoSFlowLevelQoSParameters_t *drbQos)
12534 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI != NULLP)
12536 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
12538 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
12540 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
12542 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
12544 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI);
12547 /*******************************************************************
12549 * @brief Deallocating the memory allocated by the aper decoder
12550 * for UlTnlInfoforDrb
12554 * Function : freeAperDecodeUlTnlInfoforDrbSetupMod
12556 * Functionality: Deallocating memory allocated for UlTnlInfoforDrb
12558 * @params[in] ULUPTNLInformation_ToBeSetup_List_t *ulInfo
12562 * ****************************************************************/
12563 void freeAperDecodeUlTnlInfoforDrbSetupMod(ULUPTNLInformation_ToBeSetup_List_t *ulInfo)
12567 if(ulInfo->list.array)
12569 for(arrIdx=0; arrIdx<ulInfo->list.count ; arrIdx++)
12571 if(ulInfo->list.array[arrIdx])
12573 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel )
12575 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.buf)
12577 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf)
12579 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\
12582 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\
12583 transportLayerAddress.buf);
12585 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel);
12587 free(ulInfo->list.array[arrIdx]);
12590 free(ulInfo->list.array);
12593 /*******************************************************************
12595 * @brief Deallocating the memory allocated by the aper decoder
12596 * for DrbSetupModItem
12600 * Function : freeAperDecodeDrbSetupModItem
12602 * Functionality: Deallocating memory allocated for DrbSetupModItem
12604 * @params[in] DRBs_ToBeSetupMod_Item_t *drbItem
12608 * ****************************************************************/
12610 void freeAperDecodeDrbSetupModItem(DRBs_ToBeSetupMod_Item_t *drbItem)
12613 SNSSAI_t *snssai =NULLP;
12614 Flows_Mapped_To_DRB_List_t *flowMap = NULLP;
12616 drbItem->qoSInformation.present = QoSInformation_PR_choice_extension;
12617 switch(drbItem->qoSInformation.present)
12619 case QoSInformation_PR_NOTHING:
12621 case QoSInformation_PR_eUTRANQoS:
12623 if(drbItem->qoSInformation.choice.eUTRANQoS)
12625 free(drbItem->qoSInformation.choice.eUTRANQoS);
12629 case QoSInformation_PR_choice_extension:
12631 if(drbItem->qoSInformation.choice.choice_extension)
12633 freeAperDecodeQosInfo(&drbItem->qoSInformation.choice.choice_extension->value.choice.\
12634 DRB_Information.dRB_QoS);
12635 snssai = &drbItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI;
12636 if(snssai->sST.buf)
12638 free(snssai->sST.buf);
12642 if(snssai->sD->buf)
12644 free(snssai->sD->buf);
12649 flowMap = &drbItem->qoSInformation.choice.choice_extension->value.choice.\
12650 DRB_Information.flows_Mapped_To_DRB_List;
12651 if(flowMap->list.array)
12653 for(arrIdx=0; arrIdx<flowMap->list.count; arrIdx++)
12655 if(flowMap->list.array[arrIdx] )
12657 freeAperDecodeQosInfo(&flowMap->list.array[arrIdx]->qoSFlowLevelQoSParameters);
12658 free(flowMap->list.array[arrIdx]);
12661 free(flowMap->list.array);
12664 free(drbItem->qoSInformation.choice.choice_extension);
12670 freeAperDecodeUlTnlInfoforDrbSetupMod(&drbItem->uLUPTNLInformation_ToBeSetup_List);
12671 if(drbItem->uLConfiguration)
12673 free(drbItem->uLConfiguration);
12677 /*******************************************************************
12679 * @brief Deallocating the memory allocated by the aper decoder
12680 * for DrbToBeSetupModList
12684 * Function : freeAperDecodeDrbToBeSetupModList
12686 * Functionality: Deallocating memory allocated for DrbToBeSetupModList
12688 * @params[in] DRBs_ToBeSetupMod_List_t *drbSet
12692 * ****************************************************************/
12694 void freeAperDecodeDrbToBeSetupModList(DRBs_ToBeSetupMod_List_t *drbSet)
12697 struct DRBs_ToBeSetupMod_ItemIEs *drbItemIe;
12699 if(drbSet->list.array)
12701 for(arrIdx=0; arrIdx<drbSet->list.count ; arrIdx++)
12703 if(drbSet->list.array[arrIdx] != NULLP)
12707 drbItemIe = (DRBs_ToBeSetupMod_ItemIEs_t *)drbSet->list.array[arrIdx];
12708 freeAperDecodeDrbSetupModItem(&(drbItemIe->value.choice.DRBs_ToBeSetupMod_Item));
12710 free(drbSet->list.array[arrIdx]);
12713 free(drbSet->list.array);
12717 /*******************************************************************
12719 * @brief Deallocating the memory allocated by the aper decoder
12720 * for UeContextModificationReqMsg
12724 * Function : freeAperDecodeUeContextModificationReqMsg
12726 * Functionality: Deallocating memory allocated for
12727 * UeContextModificationReqMsg
12729 * @params[in] UEContextModificationRequest_t *UeContextModifyReq
12733 * ****************************************************************/
12734 void freeAperDecodeUeContextModificationReqMsg(UEContextModificationRequest_t *UeContextModifyReq )
12736 uint8_t arrIdx, ieId;
12738 if(UeContextModifyReq->protocolIEs.list.array)
12740 for( arrIdx = 0 ; arrIdx<UeContextModifyReq->protocolIEs.list.count ; arrIdx++)
12742 if(UeContextModifyReq->protocolIEs.list.array[arrIdx])
12744 ieId = UeContextModifyReq->protocolIEs.list.array[arrIdx]->id;
12747 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12749 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12751 case ProtocolIE_ID_id_DRBs_ToBeSetupMod_List:
12753 freeAperDecodeDrbToBeSetupModList(&UeContextModifyReq->protocolIEs.list.array[arrIdx]->\
12754 value.choice.DRBs_ToBeSetupMod_List);
12758 free(UeContextModifyReq->protocolIEs.list.array[arrIdx]);
12761 free(UeContextModifyReq->protocolIEs.list.array);
12764 /*******************************************************************
12766 * @brief processing the F1 UeContextModificationReq
12770 * Function : procF1UeContextModificationReq
12772 * Functionality: processing the F1 UeContextModificationReq
12774 * @params[in] F1AP_PDU_t *f1apMsg
12777 * ****************************************************************/
12778 uint8_t procF1UeContextModificationReq(F1AP_PDU_t *f1apMsg)
12780 UEContextModificationRequest_t *ueContextModifyReq = NULLP;
12781 uint8_t ret = ROK, ieIdx = 0, lcId =0,cellIdx=0, ueIdx=0;
12782 DuUeCb *duUeCb = NULLP;
12783 DRBs_ToBeSetupMod_List_t *drbSetupModCfg;
12784 uint32_t gnbCuUeF1apId, gnbDuUeF1apId;
12786 ueContextModifyReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextModificationRequest;
12787 for(ieIdx=0; (ieIdx < ueContextModifyReq->protocolIEs.list.count && ret == ROK); ieIdx++)
12789 switch(ueContextModifyReq->protocolIEs.list.array[ieIdx]->id)
12791 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12793 gnbCuUeF1apId = ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID;
12796 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12798 gnbDuUeF1apId = ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID;
12801 case ProtocolIE_ID_id_DRBs_ToBeSetupMod_List:
12803 for(cellIdx = 0; cellIdx < duCb.numActvCells; cellIdx++)
12805 for(ueIdx = 0; ueIdx < duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
12807 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
12808 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
12811 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
12812 lcId = getDrbLcId(&duUeCb->drbBitMap);
12813 if(lcId != RFAILED)
12815 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
12818 duUeCb->f1UeDb->actionType = UE_CTXT_MOD;
12819 drbSetupModCfg = &ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.\
12820 choice.DRBs_ToBeSetupMod_List;
12821 if(extractDrbListToSetup(lcId, NULL, drbSetupModCfg ,drbSetupModCfg->list.count, \
12822 &duUeCb->f1UeDb->duUeCfg))
12824 DU_LOG("\nERROR --> DU APP : Failed at extractDrbListToSetup()");
12832 if(ueIdx >= duCb.actvCellLst[cellIdx]->numActvUes)
12834 DU_LOG("\nERROR --> DU APP : wrong values of gnbCuUeF1apId and gnbDuUeF1apId ");
12844 ret = duProcUeContextModReq(duUeCb);
12846 freeAperDecodeUeContextModificationReqMsg(ueContextModifyReq);
12849 /*****************************************************************i
12851 * @brief Free memory allocated for UE Context Release Request
12855 * Function : FreeUeContextReleaseReq
12858 * - Free memory allocated for UE Context Release Request
12860 * @params[in] F1AP_PDU_t *f1apMsg
12863 * *************************************************************/
12864 void FreeUeContextReleaseReq(F1AP_PDU_t *f1apMsg)
12867 UEContextReleaseRequest_t *ueReleaseReq = NULLP;
12871 if(f1apMsg->choice.initiatingMessage)
12873 ueReleaseReq =&f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseRequest;
12874 if(ueReleaseReq->protocolIEs.list.array)
12876 for(ieIdx=0 ; ieIdx<ueReleaseReq->protocolIEs.list.count; ieIdx++)
12878 DU_FREE(ueReleaseReq->protocolIEs.list.array[ieIdx], sizeof(UEContextReleaseRequest_t));
12880 DU_FREE(ueReleaseReq->protocolIEs.list.array, ueReleaseReq->protocolIEs.list.size);
12882 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
12884 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
12888 /*****************************************************************i
12890 * @brief Build and Send UE Context Release Request
12894 * Function : BuildAndSendUeContextReleaseReq
12897 * - Build and Send UE Context Release Request
12900 * @return ROK - success
12901 * RFAILED - failure
12903 * *************************************************************/
12904 uint8_t BuildAndSendUeContextReleaseReq(uint16_t cellId, uint8_t ueIdx)
12906 bool memAllocFail = false;
12908 uint8_t ret = RFAILED;
12909 uint16_t cellIdx =0;
12910 uint16_t crnti = 0;
12911 uint8_t elementCnt = 0;
12912 uint32_t gnbCuUeF1apId =0; /* gNB-CU UE F1AP Id */
12913 uint32_t gnbDuUeF1apId =0; /* gNB-DU UE F1AP Id */
12914 asn_enc_rval_t encRetVal;
12915 F1AP_PDU_t *f1apMsg = NULLP;
12916 UEContextReleaseRequest_t *ueReleaseReq = NULLP;
12918 DU_LOG("\nINFO --> Building the UE Context Release Request");
12921 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
12922 if(f1apMsg == NULLP)
12924 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for f1apMsg");
12928 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
12929 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
12930 if(f1apMsg->choice.initiatingMessage == NULLP)
12932 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for\
12933 initiatingMessage");
12936 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_UEContextReleaseRequest;
12937 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
12938 f1apMsg->choice.initiatingMessage->value.present = \
12939 InitiatingMessage__value_PR_UEContextReleaseRequest;
12941 ueReleaseReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseRequest;
12945 ueReleaseReq->protocolIEs.list.count = elementCnt;
12946 ueReleaseReq->protocolIEs.list.size = elementCnt * sizeof(UEContextReleaseRequest_t *);
12948 /* Initialize the F1Setup members */
12949 DU_ALLOC(ueReleaseReq->protocolIEs.list.array,ueReleaseReq->protocolIEs.list.size);
12950 if(ueReleaseReq->protocolIEs.list.array == NULLP)
12952 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for IE array");
12955 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
12957 DU_ALLOC(ueReleaseReq->protocolIEs.list.array[ieIdx],\
12958 sizeof(UEContextReleaseRequest_t));
12959 if(ueReleaseReq->protocolIEs.list.array[ieIdx] == NULLP)
12961 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for IE elements");
12962 memAllocFail = true;
12966 if(memAllocFail == true)
12969 /* Fetching Ue Cb Info*/
12970 GET_CELL_IDX(cellId, cellIdx);
12971 if(duCb.actvCellLst[cellIdx] == NULLP)
12973 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): CellId[%d] does not exist", cellId);
12978 GET_CRNTI(crnti, ueIdx);
12979 if(duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti != crnti)
12981 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): crnti[%d] does not exist", crnti);
12984 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
12985 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
12989 ueReleaseReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
12990 ueReleaseReq->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
12991 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.present = \
12992 UEContextReleaseRequestIEs__value_PR_GNB_CU_UE_F1AP_ID;
12993 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID =gnbCuUeF1apId;
12996 ueReleaseReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
12997 ueReleaseReq->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
12998 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.present =\
12999 UEContextReleaseRequestIEs__value_PR_GNB_DU_UE_F1AP_ID;
13000 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID =gnbDuUeF1apId;
13002 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
13004 /* Encode the F1SetupRequest type as APER */
13005 memset(encBuf, 0, ENC_BUF_MAX_LEN);
13007 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
13008 /* Encode results */
13009 if(encRetVal.encoded == ENCODE_FAIL)
13011 DU_LOG("\nERROR --> F1AP : Could not encode UEContextReleaseRequest structure (at %s)\n",\
13012 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
13017 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UEContextReleaseRequest\n");
13018 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
13020 printf("%x",encBuf[ieIdx]);
13025 if(sendF1APMsg() != ROK)
13027 DU_LOG("\nERROR --> F1AP : Sending UE Context Release Request failed");
13034 FreeUeContextReleaseReq(f1apMsg);
13037 /*****************************************************************i
13039 * @brief Free memory allocated for UE Context Release Complete
13043 * Function : FreeUeContextReleaseComplete
13046 * - Free memory allocated for UE Context Release Complete
13048 * @params[in] F1AP_PDU_t *f1apMsg
13051 * *************************************************************/
13052 void FreeUeContextReleaseComplete(F1AP_PDU_t *f1apMsg)
13055 UEContextReleaseComplete_t *ueReleaseComplete = NULLP;
13059 if(f1apMsg->choice.successfulOutcome)
13061 ueReleaseComplete =&f1apMsg->choice.successfulOutcome->value.choice.UEContextReleaseComplete;
13062 if(ueReleaseComplete->protocolIEs.list.array)
13064 for(ieIdx=0 ; ieIdx<ueReleaseComplete->protocolIEs.list.count; ieIdx++)
13066 DU_FREE(ueReleaseComplete->protocolIEs.list.array[ieIdx], sizeof(UEContextReleaseComplete_t));
13068 DU_FREE(ueReleaseComplete->protocolIEs.list.array, ueReleaseComplete->protocolIEs.list.size);
13070 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
13072 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
13076 /*****************************************************************i
13078 * @brief Build and Send UE Context Release Complete
13082 * Function : BuildAndSendUeContextReleaseComplete
13085 * - Build and Send UE Context Release Complete
13087 * @params[in] cellId, gnbCuUeF1apId, gnbDuUeF1apId
13088 * @return ROK - success
13089 * RFAILED - failure
13091 * *************************************************************/
13092 uint8_t BuildAndSendUeContextReleaseComplete(uint16_t cellId, uint32_t gnbCuUeF1apId, uint32_t gnbDuUeF1apId)
13094 bool memAllocFail = false;
13095 uint8_t ieIdx =0, ret = RFAILED, elementCnt = 0;
13096 asn_enc_rval_t encRetVal;
13097 F1AP_PDU_t *f1apMsg = NULLP;
13098 UEContextReleaseComplete_t *ueReleaseComplete = NULLP;
13100 DU_LOG("\nINFO --> Building the UE Context Release Complete");
13103 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
13104 if(f1apMsg == NULLP)
13106 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for f1apMsg");
13110 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
13111 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
13112 if(f1apMsg->choice.successfulOutcome == NULLP)
13114 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for\
13115 successfulOutcome");
13118 f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_UEContextRelease;
13119 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
13120 f1apMsg->choice.successfulOutcome->value.present = \
13121 SuccessfulOutcome__value_PR_UEContextReleaseComplete;
13123 ueReleaseComplete = &f1apMsg->choice.successfulOutcome->value.choice.UEContextReleaseComplete;
13126 ueReleaseComplete->protocolIEs.list.count = elementCnt;
13127 ueReleaseComplete->protocolIEs.list.size = elementCnt * sizeof(UEContextReleaseComplete_t *);
13129 /* Initialize the UE Release Complete members */
13130 DU_ALLOC(ueReleaseComplete->protocolIEs.list.array,ueReleaseComplete->protocolIEs.list.size);
13131 if(ueReleaseComplete->protocolIEs.list.array == NULLP)
13133 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for IE array");
13136 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
13138 DU_ALLOC(ueReleaseComplete->protocolIEs.list.array[ieIdx],\
13139 sizeof(UEContextReleaseComplete_t));
13140 if(ueReleaseComplete->protocolIEs.list.array[ieIdx] == NULLP)
13142 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for IE\
13144 memAllocFail = true;
13148 if(memAllocFail == true)
13153 ueReleaseComplete->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
13154 ueReleaseComplete->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
13155 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.present = \
13156 UEContextReleaseCompleteIEs__value_PR_GNB_CU_UE_F1AP_ID;
13157 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID =gnbCuUeF1apId;
13160 ueReleaseComplete->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
13161 ueReleaseComplete->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
13162 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.present =\
13163 UEContextReleaseCompleteIEs__value_PR_GNB_DU_UE_F1AP_ID;
13164 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID =gnbDuUeF1apId;
13166 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
13168 /* Encode the F1SetupComplete type as APER */
13169 memset(encBuf, 0, ENC_BUF_MAX_LEN);
13171 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
13172 /* Encode results */
13173 if(encRetVal.encoded == ENCODE_FAIL)
13175 DU_LOG("\nERROR --> F1AP : Could not encode UEContextReleaseComplete structure (at %s)\n",\
13176 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
13181 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UEContextReleaseComplete\n");
13182 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
13184 printf("%x",encBuf[ieIdx]);
13189 if(sendF1APMsg() != ROK)
13191 DU_LOG("\nERROR --> F1AP : Sending UE Context Release Complete failed");
13200 duCb.actvCellLst[cellId-1]->cellStatus = DELETION_IN_PROGRESS;
13201 ret = duSendCellDeletReq(cellId);
13204 DU_LOG("\nERROR --> F1AP: BuildAndSendUeContextReleaseComplete(): Failed to process cell\
13205 Delete req for CellId");
13208 FreeUeContextReleaseComplete(f1apMsg);
13213 /*******************************************************************
13215 * @brief added free part for the memory allocated by aper_decoder
13219 * Function : freeAperDecodeUeContextReleaseCommand
13221 * Functionality: added free part for the memory allocated by aper_decoder
13223 * @params[in] F1AP_PDU_t *f1apMsg
13226 * ****************************************************************/
13227 void freeAperDecodeUeContextReleaseCommand(F1AP_PDU_t *f1apMsg)
13230 UEContextReleaseCommand_t *ueContextReleaseCommand = NULLP;
13232 ueContextReleaseCommand = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseCommand;
13234 if(ueContextReleaseCommand->protocolIEs.list.array)
13236 for(ieIdx=0; ieIdx < ueContextReleaseCommand->protocolIEs.list.count; ieIdx++)
13238 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx])
13240 switch(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id)
13242 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
13244 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
13246 case ProtocolIE_ID_id_Cause:
13248 case ProtocolIE_ID_id_RRCContainer:
13250 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
13252 free(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf);
13257 DU_LOG("\nERROR --> F1AP: freeAperDecodeUeContextReleaseCommand():Invalid IE Received: %ld"\
13258 ,ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id);
13262 free(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]);
13264 free(ueContextReleaseCommand->protocolIEs.list.array);
13267 /*******************************************************************
13269 * @brief processing of UE Context Release Command
13273 * Function : procF1UeContextReleaseCommand
13275 * Functionality: processing of UE Context Release Command
13277 * @params[in] F1AP_PDU_t *f1apMsg
13280 * ****************************************************************/
13281 uint8_t procF1UeContextReleaseCommand(F1AP_PDU_t *f1apMsg)
13283 uint8_t ieIdx=0, ret=ROK, ueIdx=0;
13284 uint16_t cellIdx =0;
13286 uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId=0;
13287 DuUeCb *duUeCb = NULLP;
13288 UEContextReleaseCommand_t *ueContextReleaseCommand = NULLP;
13290 ueContextReleaseCommand = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseCommand;
13292 if(ueContextReleaseCommand->protocolIEs.list.array)
13294 for(ieIdx=0; ieIdx < ueContextReleaseCommand->protocolIEs.list.count; ieIdx++)
13296 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx])
13298 switch(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id)
13300 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
13302 gnbCuUeF1apId= ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
13303 value.choice.GNB_CU_UE_F1AP_ID;
13307 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
13309 gnbDuUeF1apId = ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
13310 value.choice.GNB_DU_UE_F1AP_ID;
13314 case ProtocolIE_ID_id_Cause:
13319 case ProtocolIE_ID_id_RRCContainer:
13321 for(cellIdx = 0; cellIdx < duCb.numActvCells; cellIdx++)
13323 for(ueIdx = 0; ueIdx < duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
13325 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
13326 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
13328 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
13329 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
13332 memset(duUeCb->f1UeDb, 0, sizeof(F1UeContextSetupDb));
13333 duUeCb->f1UeDb->actionType = UE_CTXT_RELEASE;
13334 duUeCb->f1UeDb->cellIdx = cellIdx;
13335 /* Filling Dl RRC Msg Info */
13336 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
13337 if(!duUeCb->f1UeDb->dlRrcMsg)
13339 DU_LOG("\nERROR --> DU APP : procF1UeContextReleaseCommand(): \
13340 Memory allocation failed ");
13345 duUeCb->f1UeDb->dlRrcMsgPres = true;
13346 memset(duUeCb->f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
13347 ret = extractDlRrcMsg(gnbDuUeF1apId, gnbCuUeF1apId, duUeCb->f1UeDb->dlRrcMsg,\
13348 &ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
13349 value.choice.RRCContainer);
13355 DU_LOG("\nERROR --> DU APP : procF1UeContextReleaseCommand(): \
13356 Memory allocation failed ");
13365 if(ueIdxFound == true)
13372 DU_LOG("\nERROR --> F1AP: DuUeCb is not found at procF1UeContextSetupReq()");
13380 DU_LOG("\nERROR --> F1AP: freeAperDecodeUeContextReleaseCommand():Invalid IE Received: %ld"\
13381 ,ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id);
13389 duProcUeContextReleaseCommand(duUeCb);
13391 freeAperDecodeUeContextReleaseCommand(f1apMsg);
13394 /**************************************************************
13396 * @brief Handles received F1AP message and sends back response
13400 * Function : F1APMsgHdlr
13403 * - Decodes received F1AP control message
13404 * - Prepares response message, encodes and sends to SCTP
13407 * @return ROK - success
13408 * RFAILED - failure
13410 * ****************************************************************/
13411 void F1APMsgHdlr(Buffer *mBuf)
13414 char *recvBuf =NULLP;
13416 MsgLen recvBufLen =0;
13417 F1AP_PDU_t *f1apMsg =NULLP;
13418 asn_dec_rval_t rval; /* Decoder return value */
13419 F1AP_PDU_t f1apasnmsg ;
13420 DU_LOG("\nINFO --> F1AP : Received F1AP message buffer");
13421 ODU_PRINT_MSG(mBuf, 0,0);
13423 /* Copy mBuf into char array to decode it */
13424 ODU_GET_MSG_LEN(mBuf, &recvBufLen);
13425 DU_ALLOC(recvBuf, (Size)recvBufLen);
13427 if(recvBuf == NULLP)
13429 DU_LOG("\nERROR --> F1AP : Memory allocation failed");
13432 if(ODU_COPY_MSG_TO_FIX_BUF(mBuf, 0, recvBufLen, (Data *)recvBuf, ©Cnt) != ROK)
13434 DU_LOG("\nERROR --> F1AP : Failed while copying %d", copyCnt);
13438 printf("\nDEBUG --> F1AP : Received flat buffer to be decoded : ");
13439 for(i=0; i< recvBufLen; i++)
13441 printf("%x",recvBuf[i]);
13444 /* Decoding flat buffer into F1AP messsage */
13445 f1apMsg = &f1apasnmsg;
13446 memset(f1apMsg, 0, sizeof(F1AP_PDU_t));
13448 rval = aper_decode(0, &asn_DEF_F1AP_PDU, (void **)&f1apMsg, recvBuf, recvBufLen, 0, 0);
13449 DU_FREE(recvBuf, (Size)recvBufLen);
13451 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
13453 DU_LOG("\nERROR --> F1AP : ASN decode failed");
13457 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
13459 switch(f1apMsg->present)
13461 case F1AP_PDU_PR_successfulOutcome:
13463 switch(f1apMsg->choice.successfulOutcome->value.present)
13465 case SuccessfulOutcome__value_PR_ResetAcknowledge:
13467 DU_LOG("\nINFO --> F1AP : F1ResetAcknowledge is received successfully ");
13470 case SuccessfulOutcome__value_PR_F1SetupResponse:
13472 #ifndef ODU_TEST_STUB
13473 procF1SetupRsp(f1apMsg);
13478 case SuccessfulOutcome__value_PR_GNBDUConfigurationUpdateAcknowledge:
13480 procF1GNBDUCfgUpdAck(f1apMsg);
13486 DU_LOG("\nERROR --> F1AP : Invalid type of SuccessfulOutcome__value_PR_ResetAcknowledge [%d]",\
13487 f1apMsg->choice.successfulOutcome->value.present);
13490 }/* End of switch(successfulOutcome) */
13491 free(f1apMsg->choice.successfulOutcome);
13494 case F1AP_PDU_PR_initiatingMessage:
13496 switch(f1apMsg->choice.initiatingMessage->value.present)
13498 case InitiatingMessage__value_PR_Reset:
13500 procF1ResetReq(f1apMsg);
13503 case InitiatingMessage__value_PR_DLRRCMessageTransfer:
13505 procF1DlRrcMsgTrans(f1apMsg);
13508 case InitiatingMessage__value_PR_UEContextSetupRequest:
13510 procF1UeContextSetupReq(f1apMsg);
13513 case InitiatingMessage__value_PR_UEContextModificationRequest:
13515 procF1UeContextModificationReq(f1apMsg);
13518 case InitiatingMessage__value_PR_UEContextReleaseCommand:
13520 procF1UeContextReleaseCommand(f1apMsg);
13525 DU_LOG("\nERROR --> F1AP : Invalid type of F1AP_PDU_PR_initiatingMessage [%d]",
13526 f1apMsg->choice.initiatingMessage->value.present);
13529 }/* End of switch(initiatingMessage) */
13530 free(f1apMsg->choice.initiatingMessage);
13536 DU_LOG("\nERROR --> F1AP : Invalid type of f1apMsg->present [%d]",f1apMsg->present);
13541 }/* End of switch(f1apMsg->present) */
13543 } /* End of F1APMsgHdlr */
13545 /**********************************************************************
13547 **********************************************************************/