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)
959 uint8_t idx=0, plmnidx=0, sliceLstIdx=0;
960 uint8_t elementCnt=0, extensionCnt=0;
962 extensionCnt=IE_EXTENSION_LIST_COUNT;
963 DU_ALLOC(*ieExtend,sizeof(ProtocolExtensionContainer_4624P3_t));
964 if((*ieExtend) == NULLP)
966 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
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)
975 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
978 for(plmnidx=0;plmnidx<extensionCnt;plmnidx++)
980 DU_ALLOC((*ieExtend)->list.array[plmnidx],\
981 sizeof(ServedPLMNs_ItemExtIEs_t));
982 if((*ieExtend)->list.array[plmnidx] == NULLP)
984 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
989 elementCnt = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].taiSliceSuppLst.numSupportedSlices;
991 (*ieExtend)->list.array[idx]->id = ProtocolIE_ID_id_TAISliceSupportList;
992 (*ieExtend)->list.array[idx]->criticality = Criticality_ignore;
993 (*ieExtend)->list.array[idx]->extensionValue.present = \
994 ServedPLMNs_ItemExtIEs__extensionValue_PR_SliceSupportList;
995 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
996 list.count = elementCnt;
997 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
998 list.size = (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
999 list.count * sizeof(SliceSupportItem_t *);
1001 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1002 list.array, elementCnt * sizeof(SliceSupportItem_t *));
1003 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1004 list.array == NULLP)
1006 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
1010 for(sliceLstIdx =0; sliceLstIdx<elementCnt; sliceLstIdx++)
1012 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1013 list.array[sliceLstIdx],sizeof(SliceSupportItem_t));
1014 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1015 list.array[sliceLstIdx] == NULLP)
1017 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
1020 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1021 list.array[sliceLstIdx]->sNSSAI.sST.size = sizeof(uint8_t);
1022 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList\
1023 .list.array[sliceLstIdx]->sNSSAI.sST.buf,(*ieExtend)->list.array[idx]->\
1024 extensionValue.choice.SliceSupportList.\
1025 list.array[sliceLstIdx]->sNSSAI.sST.size);
1026 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList\
1027 .list.array[sliceLstIdx]->sNSSAI.sST.buf == NULLP)
1029 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
1032 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1033 list.array[sliceLstIdx]->sNSSAI.sST.buf[0] = duCfgParam.srvdCellLst[0].duCellInfo.\
1034 cellInfo.srvdPlmn[0].taiSliceSuppLst.snssai[sliceLstIdx]->sst;
1036 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1037 list.array[sliceLstIdx]->sNSSAI.sD,sizeof(OCTET_STRING_t));
1038 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1039 list.array[sliceLstIdx]->sNSSAI.sD == NULLP)
1041 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
1044 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1045 list.array[sliceLstIdx]->sNSSAI.sD->size = 3 * sizeof(uint8_t);
1046 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1047 list.array[sliceLstIdx]->sNSSAI.sD->buf, (*ieExtend)->list.array[idx]->extensionValue.choice.\
1048 SliceSupportList.list.array[sliceLstIdx]->sNSSAI.sD->size);
1049 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1050 list.array[sliceLstIdx]->sNSSAI.sD->buf == NULLP)
1052 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
1055 memcpy((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
1056 list.array[sliceLstIdx]->sNSSAI.sD->buf, duCfgParam.srvdCellLst[0].duCellInfo.\
1057 cellInfo.srvdPlmn[0].taiSliceSuppLst.snssai[sliceLstIdx]->sd, (*ieExtend)->list.array[idx]->\
1058 extensionValue.choice.SliceSupportList.list.array[sliceLstIdx]->sNSSAI.sD->size);
1062 /*******************************************************************
1064 * @brief Builds Served PLMN
1068 * Function : BuildServedPlmn
1070 * Functionality: Building the Served PLMN
1072 * @params[in] GNB_DU_Served_Cells_Item_t *srvCellItem
1073 * @return ROK - success
1076 * ****************************************************************/
1077 uint8_t BuildServedPlmn(ServedPLMNs_List_t *srvplmn)
1080 uint8_t servPlmnCnt=1;
1081 uint8_t buildPlmnIdret=0;
1082 uint8_t BuildExtensionsret=0;
1083 srvplmn->list.count = servPlmnCnt;
1084 srvplmn->list.size = \
1085 servPlmnCnt*sizeof(ServedPLMNs_Item_t *);
1086 DU_ALLOC(srvplmn->list.array,srvplmn->list.size);
1087 if(srvplmn->list.array == NULLP)
1091 for(plmnidx=0; plmnidx<servPlmnCnt; plmnidx++)
1093 DU_ALLOC(srvplmn->list.array[plmnidx],\
1094 sizeof(ServedPLMNs_Item_t));
1095 if(srvplmn->list.array[plmnidx] == NULLP)
1100 srvplmn->list.array[0]->pLMN_Identity.size = PLMN_SIZE * sizeof(uint8_t);
1101 DU_ALLOC(srvplmn->list.array[0]->pLMN_Identity.buf, srvplmn->list.array[0]->pLMN_Identity.size);
1102 buildPlmnIdret = buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
1103 srvplmn->list.array[0]->pLMN_Identity.buf);
1104 if(buildPlmnIdret!= ROK)
1108 BuildExtensionsret = BuildExtensions(&srvplmn->list.array[0]->iE_Extensions);
1109 if(BuildExtensionsret!= ROK)
1115 /*******************************************************************
1117 * @brief Builds Served Cell List
1121 * Function : BuildServedCellList
1123 * Functionality: Building Served Cell List
1125 * @params[in] PLMNID plmn
1126 * @return ROK - success
1129 * ****************************************************************/
1131 uint8_t BuildServedCellList(GNB_DU_Served_Cells_List_t *duServedCell)
1133 uint8_t BuildNrcgiret=0;
1134 uint8_t BuildFiveGSTacret=0;
1135 uint8_t BuildServedPlmnret=0;
1136 uint8_t BuildNrModeret=0;
1140 GNB_DU_Served_Cells_Item_t *srvCellItem;
1141 duServedCell->list.size = plmnCnt * sizeof(GNB_DU_Served_Cells_ItemIEs_t *);
1142 duServedCell->list.count = plmnCnt;
1144 DU_ALLOC(duServedCell->list.array, duServedCell->list.size);
1145 if(duServedCell->list.array == NULLP)
1149 for(plmnidx=0; plmnidx<plmnCnt; plmnidx++)
1151 DU_ALLOC(duServedCell->list.array[plmnidx],\
1152 sizeof(GNB_DU_Served_Cells_ItemIEs_t));
1153 if(duServedCell->list.array[plmnidx] == NULLP)
1159 duServedCell->list.array[idx]->id = ProtocolIE_ID_id_GNB_DU_Served_Cells_Item;
1160 duServedCell->list.array[idx]->criticality = Criticality_reject;
1161 duServedCell->list.array[idx]->value.present = \
1162 GNB_DU_Served_Cells_ItemIEs__value_PR_GNB_DU_Served_Cells_Item;
1164 &duServedCell->list.array[idx]->value.choice.GNB_DU_Served_Cells_Item;
1166 BuildNrcgiret = BuildNrcgi(&srvCellItem->served_Cell_Information.nRCGI);
1167 if(BuildNrcgiret != ROK)
1172 srvCellItem->served_Cell_Information.nRPCI = \
1173 duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrPci;
1176 BuildFiveGSTacret = BuildFiveGSTac(&srvCellItem->served_Cell_Information);
1177 if(BuildFiveGSTacret != ROK)
1182 BuildServedPlmnret = BuildServedPlmn(&srvCellItem->served_Cell_Information.servedPLMNs);
1183 if(BuildServedPlmnret !=ROK)
1187 /*nR Mode Info with FDD*/
1188 BuildNrModeret = BuildNrMode(&srvCellItem->served_Cell_Information.nR_Mode_Info);
1189 if(BuildNrModeret != ROK)
1193 /*Measurement timing Config*/
1194 srvCellItem->served_Cell_Information.measurementTimingConfiguration.\
1195 size = sizeof(uint8_t);
1196 DU_ALLOC(srvCellItem->served_Cell_Information.\
1197 measurementTimingConfiguration.buf,srvCellItem->served_Cell_Information.measurementTimingConfiguration.size);
1198 if(srvCellItem->served_Cell_Information.\
1199 measurementTimingConfiguration.buf == NULLP)
1203 srvCellItem->served_Cell_Information.measurementTimingConfiguration.buf[0] = \
1204 duCfgParam.srvdCellLst[0].duCellInfo.measTimeCfg;
1206 /* GNB DU System Information */
1207 DU_ALLOC(srvCellItem->gNB_DU_System_Information,
1208 sizeof(GNB_DU_System_Information_t));
1209 if(!srvCellItem->gNB_DU_System_Information)
1214 srvCellItem->gNB_DU_System_Information->mIB_message.size = duCfgParam.srvdCellLst[0].duSysInfo.mibLen;
1215 DU_ALLOC(srvCellItem->gNB_DU_System_Information->mIB_message.buf,
1216 srvCellItem->gNB_DU_System_Information->mIB_message.size);
1217 if(!srvCellItem->gNB_DU_System_Information->mIB_message.buf)
1221 memcpy(srvCellItem->gNB_DU_System_Information->mIB_message.buf, duCfgParam.srvdCellLst[0].duSysInfo.mibMsg, \
1222 srvCellItem->gNB_DU_System_Information->mIB_message.size);
1225 srvCellItem->gNB_DU_System_Information->sIB1_message.size =\
1226 duCfgParam.srvdCellLst[0].duSysInfo.sib1Len;
1228 DU_ALLOC(srvCellItem->gNB_DU_System_Information->sIB1_message.buf,
1229 srvCellItem->gNB_DU_System_Information->sIB1_message.size);
1230 if(!srvCellItem->gNB_DU_System_Information->sIB1_message.buf)
1234 for(int x=0; x<srvCellItem->gNB_DU_System_Information->sIB1_message.size; x++)
1236 srvCellItem->gNB_DU_System_Information->sIB1_message.buf[x]=\
1237 duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg[x];
1241 /*******************************************************************
1243 * @brief Builds RRC Version
1247 * Function : BuildRrcVer
1249 * Functionality: Building RRC Version
1251 * @params[in] int idx,int elementCnt,RRC_Version_t *rrcver
1252 * @return ROK - success
1255 * ****************************************************************/
1256 uint8_t BuildRrcVer(RRC_Version_t *rrcVer)
1260 rrcVer->latest_RRC_Version.size = sizeof(uint8_t);
1261 DU_ALLOC(rrcVer->latest_RRC_Version.buf,sizeof(uint8_t));
1262 if(rrcVer->latest_RRC_Version.buf == NULLP)
1266 rrcVer->latest_RRC_Version.buf[0] = 0;
1267 rrcVer->latest_RRC_Version.bits_unused = 5;
1268 DU_ALLOC(rrcVer->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P81_t));
1269 if(rrcVer->iE_Extensions == NULLP)
1273 rrcVer->iE_Extensions->list.count = 1;
1274 rrcVer->iE_Extensions->list.size = sizeof(RRC_Version_ExtIEs_t *);
1275 DU_ALLOC(rrcVer->iE_Extensions->list.array,rrcVer->iE_Extensions->list.size);
1276 if(rrcVer->iE_Extensions->list.array == NULLP)
1281 DU_ALLOC(rrcVer->iE_Extensions->list.array[0],\
1282 sizeof(RRC_Version_ExtIEs_t));
1283 if(rrcVer->iE_Extensions->list.array[0] == NULLP)
1287 rrcVer->iE_Extensions->list.array[rrcExt]->id = \
1288 ProtocolIE_ID_id_latest_RRC_Version_Enhanced;
1289 rrcVer->iE_Extensions->list.array[rrcExt]->criticality = Criticality_reject;
1290 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.present =\
1291 RRC_Version_ExtIEs__extensionValue_PR_Latest_RRC_Version_Enhanced;
1292 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice\
1293 .Latest_RRC_Version_Enhanced.size = 3*sizeof(uint8_t);
1294 DU_ALLOC(rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice\
1295 .Latest_RRC_Version_Enhanced.buf,rrcVer->iE_Extensions->list.\
1296 array[rrcExt]->extensionValue.choice.Latest_RRC_Version_Enhanced.size);
1297 if(rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice\
1298 .Latest_RRC_Version_Enhanced.buf == NULLP)
1303 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice.\
1304 Latest_RRC_Version_Enhanced.buf[rrcLatest] = 15;
1306 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice.\
1307 Latest_RRC_Version_Enhanced.buf[rrcLatest] = 5;
1309 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice.\
1310 Latest_RRC_Version_Enhanced.buf[rrcLatest] = 0;
1313 /*******************************************************************
1315 * @brief Sends F1 msg over SCTP
1319 * Function : sendF1APMsg
1321 * Functionality: Sends F1 msg over SCTP
1323 * @params[in] Region region
1325 * @return ROK - success
1328 * ****************************************************************/
1329 uint8_t sendF1APMsg()
1331 Buffer *mBuf = NULLP;
1333 if(ODU_GET_MSG_BUF(DU_APP_MEM_REGION, DU_POOL, &mBuf) == ROK)
1335 if(ODU_ADD_POST_MSG_MULT((Data *)encBuf, encBufSize, mBuf) == ROK)
1337 ODU_PRINT_MSG(mBuf, 0,0);
1339 if(sctpSend(mBuf, F1_INTERFACE) != ROK)
1341 DU_LOG("\nERROR --> F1AP : SCTP Send failed");
1342 ODU_PUT_MSG_BUF(mBuf);
1348 DU_LOG("\nERROR --> F1AP : ODU_ADD_POST_MSG_MULT failed");
1349 ODU_PUT_MSG_BUF(mBuf);
1352 ODU_PUT_MSG_BUF(mBuf);
1356 DU_LOG("\nERROR --> F1AP : Failed to allocate memory");
1362 /*******************************************************************
1364 * @brief deallocating the memory of function BuildAndSendF1SetupReq()
1368 * Function : FreeRrcVer
1370 * Functionality: deallocating the memory of function BuildRrcVer
1372 * @params[in] RRC_Version_t *rrcVer
1376 *****************************************************************/
1377 void FreeRrcVer(RRC_Version_t *rrcVer)
1379 if(rrcVer->latest_RRC_Version.buf != NULLP)
1381 if(rrcVer->iE_Extensions != NULLP)
1383 if(rrcVer->iE_Extensions->list.array != NULLP)
1385 if(rrcVer->iE_Extensions->list.array[0] != NULLP)
1387 if(rrcVer->iE_Extensions->list.array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf
1390 DU_FREE(rrcVer->iE_Extensions->list.array[0]->extensionValue.choice\
1391 .Latest_RRC_Version_Enhanced.buf,rrcVer->iE_Extensions->list.\
1392 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.size);
1394 DU_FREE(rrcVer->iE_Extensions->list.array[0],sizeof(RRC_Version_ExtIEs_t));
1396 DU_FREE(rrcVer->iE_Extensions->list.array,sizeof(RRC_Version_ExtIEs_t*));
1398 DU_FREE(rrcVer->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P81_t));
1400 DU_FREE(rrcVer->latest_RRC_Version.buf,rrcVer->latest_RRC_Version.size);
1403 /*******************************************************************
1405 * @brief deallocating the memory of function BuildAndSendF1SetupReq()
1409 * Function : FreeServedCellList
1411 * Functionality: deallocating the memory of function BuildServedCellList
1414 * @params[in] GNB_DU_Served_Cells_List_t *duServedCell
1418 * ****************************************************************/
1419 void FreeServedCellList( GNB_DU_Served_Cells_List_t *duServedCell)
1421 uint8_t plmnCnt=MAX_PLMN;
1422 uint8_t extensionCnt=IE_EXTENSION_LIST_COUNT;
1423 uint8_t plmnIdx=0, sliceIdx=0;
1424 GNB_DU_Served_Cells_Item_t *srvCellItem;
1425 ServedPLMNs_Item_t *servedPlmnItem;
1426 SliceSupportItem_t *sliceSupportItem;
1428 if(duServedCell->list.array!=NULLP)
1430 if(duServedCell->list.array[0]!=NULLP)
1432 srvCellItem= &duServedCell->list.array[0]->value.choice.GNB_DU_Served_Cells_Item;
1434 DU_FREE(srvCellItem->served_Cell_Information.nRCGI.pLMN_Identity.buf,\
1435 srvCellItem->served_Cell_Information.nRCGI.pLMN_Identity.size * sizeof(uint8_t));
1436 DU_FREE(srvCellItem->served_Cell_Information.nRCGI.nRCellIdentity.buf,\
1437 srvCellItem->served_Cell_Information.nRCGI.nRCellIdentity.size * sizeof(uint8_t));
1439 if(srvCellItem->served_Cell_Information.fiveGS_TAC!=NULLP)
1441 DU_FREE(srvCellItem->served_Cell_Information.fiveGS_TAC->buf,\
1442 sizeof(srvCellItem->served_Cell_Information.fiveGS_TAC->size));
1443 DU_FREE(srvCellItem->served_Cell_Information.fiveGS_TAC,sizeof(FiveGS_TAC_t));
1446 if(srvCellItem->served_Cell_Information.servedPLMNs.list.array!=NULLP)
1448 if(srvCellItem->served_Cell_Information.servedPLMNs.list.array[plmnIdx] != NULLP)
1450 servedPlmnItem = srvCellItem->served_Cell_Information.servedPLMNs.list.array[plmnIdx];
1451 DU_FREE(servedPlmnItem->pLMN_Identity.buf, servedPlmnItem->pLMN_Identity.size);
1453 if(servedPlmnItem->iE_Extensions != NULLP)
1455 if(servedPlmnItem->iE_Extensions->list.array != NULLP)
1457 if(servedPlmnItem->iE_Extensions->list.array[0] != NULLP)
1459 if(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.\
1460 SliceSupportList.list.array != NULLP)
1462 for(sliceIdx =0; sliceIdx<servedPlmnItem->iE_Extensions->list.array[0]->\
1463 extensionValue.choice.SliceSupportList.list.count; sliceIdx++)
1465 if(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.\
1466 SliceSupportList.list.array[sliceIdx] != NULLP)
1468 sliceSupportItem = servedPlmnItem->iE_Extensions->list.array[0]->\
1469 extensionValue.choice.SliceSupportList.list.array[sliceIdx];
1471 DU_FREE(sliceSupportItem->sNSSAI.sST.buf, sizeof(uint8_t));
1473 if(sliceSupportItem->sNSSAI.sD != NULLP)
1475 DU_FREE(sliceSupportItem->sNSSAI.sD->buf,\
1476 sliceSupportItem->sNSSAI.sD->size);
1477 DU_FREE(sliceSupportItem->sNSSAI.sD, sizeof(OCTET_STRING_t));
1480 DU_FREE(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.\
1481 choice.SliceSupportList.list.array[sliceIdx], sizeof(SliceSupportItem_t));
1484 DU_FREE(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.\
1485 SliceSupportList.list.array, servedPlmnItem->iE_Extensions->list.array[0]->\
1486 extensionValue.choice.SliceSupportList.list.size);
1488 DU_FREE(servedPlmnItem->iE_Extensions->list.array[0],\
1489 sizeof(ServedPLMNs_ItemExtIEs_t));
1491 DU_FREE(servedPlmnItem->iE_Extensions->list.array,\
1492 extensionCnt*sizeof(ServedPLMNs_ItemExtIEs_t*));
1494 DU_FREE(servedPlmnItem->iE_Extensions, sizeof(ProtocolExtensionContainer_4624P3_t));
1496 DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.array[plmnIdx],\
1497 sizeof(ServedPLMNs_Item_t));
1499 DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.array,\
1500 sizeof(ServedPLMNs_Item_t *));
1503 if(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD != NULLP)
1505 if(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.\
1506 freqBandListNr.list.array != NULLP)
1508 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->\
1509 uL_NRFreqInfo.freqBandListNr.list.array[0],sizeof(FreqBandNrItem_t));
1510 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->\
1511 uL_NRFreqInfo.freqBandListNr.list.array,sizeof(FreqBandNrItem_t*));
1514 if(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.\
1515 freqBandListNr.list.array)
1517 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.\
1518 freqBandListNr.list.array[0],sizeof(FreqBandNrItem_t));
1519 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.\
1520 freqBandListNr.list.array,sizeof(FreqBandNrItem_t *));
1522 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD, sizeof(FDD_Info_t));
1525 DU_FREE(srvCellItem->served_Cell_Information.measurementTimingConfiguration.buf,\
1526 srvCellItem->served_Cell_Information.measurementTimingConfiguration.size);
1528 if(srvCellItem->gNB_DU_System_Information != NULLP)
1530 if(srvCellItem->gNB_DU_System_Information->mIB_message.buf != NULLP)
1532 DU_FREE(srvCellItem->gNB_DU_System_Information->mIB_message.buf,\
1533 srvCellItem->gNB_DU_System_Information->mIB_message.size);
1536 if(srvCellItem->gNB_DU_System_Information->sIB1_message.buf != NULLP)
1538 DU_FREE(srvCellItem->gNB_DU_System_Information->sIB1_message.buf,\
1539 srvCellItem->gNB_DU_System_Information->sIB1_message.size);
1542 DU_FREE(srvCellItem->gNB_DU_System_Information, sizeof(GNB_DU_System_Information_t));
1545 DU_FREE(duServedCell->list.array[0], sizeof(GNB_DU_Served_Cells_ItemIEs_t));
1547 DU_FREE(duServedCell->list.array, plmnCnt * sizeof(GNB_DU_Served_Cells_ItemIEs_t*));
1551 /*******************************************************************
1553 * @brief deallocating the memory of function BuildAndSendF1SetupReq()
1557 * Function : FreeF1SetupReq
1559 * Functionality: deallocating the memory of function BuildAndSendF1SetupReq
1561 * @params[in] F1AP_PDU_t *f1apMsg
1565 * ****************************************************************/
1566 void FreeF1SetupReq(F1AP_PDU_t *f1apMsg)
1568 uint8_t ieIdx, ieIdx2;
1569 F1SetupRequest_t *f1SetupReq=NULLP;
1571 if(f1apMsg != NULLP)
1573 if(f1apMsg->choice.initiatingMessage != NULLP)
1575 f1SetupReq = &f1apMsg->choice.initiatingMessage->value.choice.F1SetupRequest;
1576 if(f1SetupReq->protocolIEs.list.array != NULLP)
1578 for(ieIdx = 0; ieIdx < f1SetupReq->protocolIEs.list.count; ieIdx++)
1580 if(f1SetupReq->protocolIEs.list.array[ieIdx] != NULLP)
1582 switch(f1SetupReq->protocolIEs.list.array[ieIdx]->id)
1584 case ProtocolIE_ID_id_TransactionID:
1586 case ProtocolIE_ID_id_gNB_DU_ID:
1587 DU_FREE(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
1588 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
1590 case ProtocolIE_ID_id_gNB_DU_Name:
1591 DU_FREE(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.buf,\
1592 strlen((char *)duCfgParam.duName));
1594 case ProtocolIE_ID_id_gNB_DU_Served_Cells_List:
1595 FreeServedCellList(&f1SetupReq->protocolIEs.list.\
1596 array[ieIdx]->value.choice.GNB_DU_Served_Cells_List);
1598 case ProtocolIE_ID_id_GNB_DU_RRC_Version:
1599 FreeRrcVer(&f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.RRC_Version);
1602 DU_LOG("\nERROR --> Invalid Event Type %ld", f1SetupReq->protocolIEs.list.array[ieIdx]->id);
1607 for(ieIdx2=0; ieIdx2< ieIdx; ieIdx2++)
1609 DU_FREE(f1SetupReq->protocolIEs.list.array[ieIdx2],sizeof(F1SetupRequestIEs_t));
1611 DU_FREE(f1SetupReq->protocolIEs.list.array,\
1612 f1SetupReq->protocolIEs.list.size);
1614 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
1616 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
1619 /*******************************************************************
1621 * @brief Builds and Send the F1SetupRequest
1625 * Function : BuildAndSendF1SetupReq
1627 * Functionality:Fills the F1SetupRequest
1629 * @return ROK - success
1632 ******************************************************************/
1633 uint8_t BuildAndSendF1SetupReq()
1635 uint8_t ret, ieIdx, elementCnt;
1636 F1AP_PDU_t *f1apMsg = NULLP;
1637 F1SetupRequest_t *f1SetupReq=NULLP;
1638 GNB_DU_Served_Cells_List_t *duServedCell=NULLP;
1639 RRC_Version_t *rrcVer=NULLP;
1640 asn_enc_rval_t encRetVal; /* Encoder return value */
1643 DU_LOG("\nINFO --> F1AP : Building F1 Setup Request\n");
1646 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
1647 if(f1apMsg == NULLP)
1651 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
1652 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
1653 if(f1apMsg->choice.initiatingMessage == NULLP)
1657 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_F1Setup;
1658 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
1659 f1apMsg->choice.initiatingMessage->value.present = \
1660 InitiatingMessage__value_PR_F1SetupRequest;
1662 f1SetupReq = &f1apMsg->choice.initiatingMessage->value.choice.F1SetupRequest;
1664 elementCnt = (duCfgParam.duName != NULL) ? 5 : 4;
1666 f1SetupReq->protocolIEs.list.count = elementCnt;
1667 f1SetupReq->protocolIEs.list.size = elementCnt * sizeof(F1SetupRequestIEs_t );
1669 /* Initialize the F1Setup members */
1670 DU_ALLOC(f1SetupReq->protocolIEs.list.array,f1SetupReq->protocolIEs.list.size);
1671 if(f1SetupReq->protocolIEs.list.array == NULLP)
1675 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
1677 DU_ALLOC(f1SetupReq->protocolIEs.list.array[ieIdx],\
1678 sizeof(F1SetupRequestIEs_t));
1679 if(f1SetupReq->protocolIEs.list.array[ieIdx] == NULLP)
1687 f1SetupReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_TransactionID;
1688 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1689 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present =\
1690 F1SetupRequestIEs__value_PR_TransactionID;
1691 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = \
1696 f1SetupReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_ID;
1697 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1698 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = \
1699 F1SetupRequestIEs__value_PR_GNB_DU_ID;
1700 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size =\
1703 DU_ALLOC(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
1704 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
1705 if(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf == \
1711 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf[0] =\
1715 if(duCfgParam.duName != NULL)
1718 f1SetupReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_Name;
1719 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_ignore;
1720 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = F1SetupRequestIEs__value_PR_GNB_DU_Name;
1721 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.size =\
1722 strlen((char *)duCfgParam.duName);
1723 DU_ALLOC(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.\
1724 GNB_DU_Name.buf, strlen((char *)duCfgParam.duName));
1725 if(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.\
1730 strcpy((char*)f1SetupReq->protocolIEs.list.array[ieIdx]->value.\
1731 choice.GNB_DU_Name.buf,
1732 (char*)&duCfgParam.duName);
1736 /*Served Cell list */
1738 f1SetupReq->protocolIEs.list.array[ieIdx]->id = \
1739 ProtocolIE_ID_id_gNB_DU_Served_Cells_List;
1740 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1741 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = \
1742 F1SetupRequestIEs__value_PR_GNB_DU_Served_Cells_List;
1743 duServedCell = &f1SetupReq->protocolIEs.list.\
1744 array[ieIdx]->value.choice.GNB_DU_Served_Cells_List;
1745 if(BuildServedCellList(duServedCell))
1751 f1SetupReq->protocolIEs.list.array[ieIdx]->id = \
1752 ProtocolIE_ID_id_GNB_DU_RRC_Version ;
1753 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1754 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = \
1755 F1SetupRequestIEs__value_PR_RRC_Version;
1756 rrcVer = &f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.RRC_Version;
1757 if(BuildRrcVer(rrcVer))
1761 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
1763 /* Encode the F1SetupRequest type as APER */
1764 memset(encBuf, 0, ENC_BUF_MAX_LEN);
1766 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
1769 /* Encode results */
1770 if(encRetVal.encoded == ENCODE_FAIL)
1772 DU_LOG("\nERROR --> F1AP : Could not encode F1SetupRequest structure (at %s)\n",\
1773 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
1778 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for F1SetupRequest\n");
1779 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
1781 printf("%x",encBuf[ieIdx]);
1786 if(sendF1APMsg() != ROK)
1788 DU_LOG("\nERROR --> F1AP : Sending F1 Setup request failed");
1796 FreeF1SetupReq(f1apMsg);
1799 }/* End of BuildAndSendF1SetupReq */
1801 /*******************************************************************
1803 * @brief Deallocating memory allocated for Served_Cells_To_Modify_Item_t
1807 * Function : freeCellsToModifyItem
1809 * Functionality: Deallocating memory of variables allocated in
1810 * BuildAndSendDUConfigUpdate function
1812 * @params[in] Served_Cells_To_Modify_Item_t *modifyItem
1814 * @return ROK - void
1816 * ****************************************************************/
1818 void freeCellsToModifyItem(Served_Cells_To_Modify_Item_t *modifyItem)
1820 uint8_t arrIdx=0, servedPlmnIdx=0, sliceLstIdx=0;
1821 ServedPLMNs_Item_t *servedPlmnItem = NULLP;
1822 SliceSupportItem_t *sliceSupportItem = NULLP;
1824 DU_FREE(modifyItem->oldNRCGI.pLMN_Identity.buf, modifyItem->oldNRCGI.pLMN_Identity.size);
1825 DU_FREE(modifyItem->oldNRCGI.nRCellIdentity.buf, modifyItem->oldNRCGI.nRCellIdentity.size);
1827 DU_FREE(modifyItem->served_Cell_Information.nRCGI.pLMN_Identity.buf,\
1828 modifyItem->served_Cell_Information.nRCGI.pLMN_Identity.size);
1829 DU_FREE(modifyItem->served_Cell_Information.nRCGI.nRCellIdentity.buf,\
1830 modifyItem->served_Cell_Information.nRCGI.nRCellIdentity.size);
1832 if(modifyItem->served_Cell_Information.servedPLMNs.list.array != NULLP)
1834 if(modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx] != NULLP)
1836 servedPlmnItem = modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx];
1838 DU_FREE(servedPlmnItem->pLMN_Identity.buf,servedPlmnItem->pLMN_Identity.size);
1840 if(servedPlmnItem->iE_Extensions != NULLP)
1842 if(servedPlmnItem->iE_Extensions->list.array != NULLP)
1844 if(servedPlmnItem->iE_Extensions->list.array[arrIdx] != NULLP)
1846 if(servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.SliceSupportList.\
1847 list.array != NULLP)
1849 for(sliceLstIdx =0; sliceLstIdx<servedPlmnItem->iE_Extensions->list.array[arrIdx]->\
1850 extensionValue.choice.SliceSupportList.list.count; sliceLstIdx++)
1852 if(servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.SliceSupportList.\
1853 list.array[sliceLstIdx] != NULLP)
1856 sliceSupportItem = servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.\
1857 SliceSupportList.list.array[sliceLstIdx];
1859 DU_FREE(sliceSupportItem->sNSSAI.sST.buf, sliceSupportItem->sNSSAI.sST.size);
1860 if(sliceSupportItem->sNSSAI.sD != NULLP)
1862 DU_FREE(sliceSupportItem->sNSSAI.sD->buf, sliceSupportItem->sNSSAI.sD->size);
1863 DU_FREE(sliceSupportItem->sNSSAI.sD,sizeof(OCTET_STRING_t));
1865 DU_FREE(servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.\
1866 SliceSupportList.list.array[sliceLstIdx], sizeof(SliceSupportItem_t));
1869 DU_FREE(servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.\
1870 choice.SliceSupportList.list.array,\
1871 servedPlmnItem->iE_Extensions->list.array[arrIdx]->\
1872 extensionValue.choice.SliceSupportList.list.size);
1875 for(servedPlmnIdx=0; servedPlmnIdx< servedPlmnItem->iE_Extensions->list.count ; servedPlmnIdx++)
1877 DU_FREE(servedPlmnItem->iE_Extensions->list.array[servedPlmnIdx], sizeof(ServedPLMNs_ItemExtIEs_t ));
1879 DU_FREE(servedPlmnItem->iE_Extensions->list.array, servedPlmnItem->iE_Extensions->list.size);
1881 DU_FREE(servedPlmnItem->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P3_t));
1884 for(servedPlmnIdx=0; servedPlmnIdx<modifyItem->served_Cell_Information.servedPLMNs.list.count; servedPlmnIdx++)
1886 DU_FREE(modifyItem->served_Cell_Information.servedPLMNs.list.array[servedPlmnIdx], sizeof(ServedPLMNs_Item_t));
1888 DU_FREE(modifyItem->served_Cell_Information.servedPLMNs.list.array,\
1889 modifyItem->served_Cell_Information.servedPLMNs.list.size);
1892 if(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD != NULLP)
1894 if(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array != NULLP)
1896 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.list.\
1897 array[arrIdx], sizeof(FreqBandNrItem_t));
1898 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array, \
1899 modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->uL_NRFreqInfo.freqBandListNr.list.size);
1902 if(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array != NULLP)
1904 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.freqBandListNr.list.\
1905 array[arrIdx], sizeof(FreqBandNrItem_t));
1906 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array,\
1907 modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD->dL_NRFreqInfo.freqBandListNr.list.size);
1909 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD,sizeof(FDD_Info_t));
1912 DU_FREE(modifyItem->served_Cell_Information.measurementTimingConfiguration.buf,\
1913 modifyItem->served_Cell_Information.measurementTimingConfiguration.size);
1916 /*******************************************************************
1918 * @brief Deallocating memory of BuildAndSendDUConfigUpdate
1922 * Function : FreeDUConfigUpdate
1924 * Functionality: Deallocating memory of variables allocated in
1925 * BuildAndSendDUConfigUpdate function
1927 * @params[in] F1AP_PDU_t *f1apDuCfg
1929 * @return ROK - void
1931 * ****************************************************************/
1932 void FreeDUConfigUpdate(F1AP_PDU_t *f1apDuCfg)
1934 uint8_t ieIdx=0, cellModifyIdx=0, cellDeleteIdx=0;
1935 GNBDUConfigurationUpdate_t *duCfgUpdate = NULLP;
1936 Served_Cells_To_Modify_List_t *cellsToModify=NULLP;
1937 Served_Cells_To_Delete_List_t *cellsToDelete=NULLP;
1938 Served_Cells_To_Delete_Item_t *deleteItem = NULLP;
1939 Served_Cells_To_Delete_ItemIEs_t *deleteItemIe = NULLP;
1941 if(f1apDuCfg != NULLP)
1943 if(f1apDuCfg->choice.initiatingMessage != NULLP)
1945 duCfgUpdate = &f1apDuCfg->choice.initiatingMessage->\
1946 value.choice.GNBDUConfigurationUpdate;
1947 if(duCfgUpdate->protocolIEs.list.array != NULLP)
1949 for(ieIdx=0; ieIdx<duCfgUpdate->protocolIEs.list.count; ieIdx++)
1951 if(duCfgUpdate->protocolIEs.list.array[ieIdx] != NULLP)
1953 switch(duCfgUpdate->protocolIEs.list.array[ieIdx]->id)
1955 case ProtocolIE_ID_id_Served_Cells_To_Modify_List:
1957 cellsToModify = &duCfgUpdate->protocolIEs.list.array[ieIdx]->\
1958 value.choice.Served_Cells_To_Modify_List;
1959 if(cellsToModify->list.array != NULLP)
1961 for(cellModifyIdx=0; cellModifyIdx<cellsToModify->list.count ;cellModifyIdx++)
1963 if(cellsToModify->list.array[cellModifyIdx] != NULLP)
1965 freeCellsToModifyItem(&cellsToModify->list.array[cellModifyIdx]->value.choice.\
1966 Served_Cells_To_Modify_Item);
1967 DU_FREE(cellsToModify->list.array[cellModifyIdx],\
1968 sizeof(Served_Cells_To_Modify_ItemIEs_t));
1971 DU_FREE(cellsToModify->list.array,cellsToModify->list.size);
1975 case ProtocolIE_ID_id_Served_Cells_To_Delete_List:
1977 cellsToDelete = &duCfgUpdate->protocolIEs.list.array[ieIdx]->\
1978 value.choice.Served_Cells_To_Delete_List;
1979 if(cellsToDelete->list.array != NULLP)
1981 for(cellDeleteIdx=0; cellDeleteIdx<cellsToDelete->list.count ;cellDeleteIdx++)
1983 if(cellsToDelete->list.array[cellDeleteIdx] != NULLP)
1985 deleteItemIe = ((Served_Cells_To_Delete_ItemIEs_t*)\
1986 cellsToDelete->list.array[cellDeleteIdx]);
1987 deleteItem=&deleteItemIe->value.choice.Served_Cells_To_Delete_Item;
1988 DU_FREE(deleteItem->oldNRCGI.pLMN_Identity.buf,\
1989 deleteItem->oldNRCGI.pLMN_Identity.size);
1990 DU_FREE(deleteItem->oldNRCGI.nRCellIdentity.buf,\
1991 deleteItem->oldNRCGI.nRCellIdentity.size);
1992 DU_FREE(cellsToDelete->list.array[cellDeleteIdx],\
1993 sizeof(Served_Cells_To_Delete_ItemIEs_t));
1996 DU_FREE(cellsToDelete->list.array,cellsToDelete->list.size);
2001 case ProtocolIE_ID_id_gNB_DU_ID:
2003 DU_FREE(duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
2004 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
2008 DU_FREE(duCfgUpdate->protocolIEs.list.array[ieIdx],\
2009 sizeof(GNBDUConfigurationUpdateIEs_t));
2012 DU_FREE(duCfgUpdate->protocolIEs.list.array,duCfgUpdate->protocolIEs.list.size);
2014 DU_FREE(f1apDuCfg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
2016 DU_FREE(f1apDuCfg, (Size)sizeof(F1AP_PDU_t));
2020 /*******************************************************************
2022 * @brief Fills Served Plmns required in ServCellInfo IE
2026 * Function : fillServedPlmns
2028 * Functionality: Fills Served Plmns required in ServCellInfo IE
2030 * @params[in] Pointer to ServedPLMNs_List_t *
2032 * @return ROK - success
2035 *****************************************************************/
2037 uint8_t fillServedPlmns(ServedPLMNs_List_t *servedPlmn)
2039 uint8_t ieIdx=0, arrayIdx=0, ieListCnt=0, elementCnt=0, sliceLstIdx=0;
2041 servedPlmn->list.array[arrayIdx]->pLMN_Identity.size = 3*sizeof(uint8_t);
2042 DU_ALLOC(servedPlmn->list.array[arrayIdx]->pLMN_Identity.buf, servedPlmn->list.\
2043 array[arrayIdx]->pLMN_Identity.size);
2044 if(servedPlmn->list.array[arrayIdx]->pLMN_Identity.buf == NULLP)
2046 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
2049 buildPlmnId(duCfgParam.srvdCellLst[arrayIdx].duCellInfo.cellInfo.srvdPlmn[arrayIdx].plmn,\
2050 servedPlmn->list.array[arrayIdx]->pLMN_Identity.buf);
2051 DU_ALLOC(servedPlmn->list.array[arrayIdx]->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P3_t));
2052 if(servedPlmn->list.array[arrayIdx]->iE_Extensions == NULLP)
2054 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
2059 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.count = ieListCnt;
2060 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.size = ieListCnt *sizeof(ServedPLMNs_ItemExtIEs_t *);
2061 DU_ALLOC(servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array,servedPlmn->list.array[arrayIdx]->\
2062 iE_Extensions->list.size);
2063 if(servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array == NULLP)
2065 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
2068 for(ieIdx=arrayIdx;ieIdx<ieListCnt;ieIdx++)
2070 DU_ALLOC(servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx],\
2071 sizeof(ServedPLMNs_ItemExtIEs_t));
2072 if(servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx] == NULLP)
2074 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
2080 elementCnt = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].taiSliceSuppLst.numSupportedSlices;
2081 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx]->id =ProtocolIE_ID_id_TAISliceSupportList;
2082 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx]->criticality = Criticality_ignore;
2083 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx]->extensionValue.present = \
2084 ServedPLMNs_ItemExtIEs__extensionValue_PR_SliceSupportList;
2085 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2086 list.count = elementCnt;
2087 servedPlmn->list.array[arrayIdx]->\
2088 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2089 list.size = elementCnt * sizeof(SliceSupportItem_t *);
2090 DU_ALLOC(servedPlmn->list.array[arrayIdx]->\
2091 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2092 list.array,servedPlmn->list.array[arrayIdx]->\
2093 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.list.size);
2094 if(servedPlmn->list.array[arrayIdx]->\
2095 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2096 list.array == NULLP)
2098 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
2102 for(sliceLstIdx =0; sliceLstIdx< elementCnt; sliceLstIdx++)
2104 DU_ALLOC(servedPlmn->list.array[arrayIdx]->\
2105 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2106 list.array[sliceLstIdx],sizeof( SliceSupportItem_t));
2107 if(servedPlmn->list.array[arrayIdx]->\
2108 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2109 list.array[sliceLstIdx] == NULLP)
2111 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
2115 servedPlmn->list.array[arrayIdx]->\
2116 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2117 list.array[sliceLstIdx]->sNSSAI.sST.size = sizeof(uint8_t);
2118 DU_ALLOC(servedPlmn->list.array[arrayIdx]->\
2119 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2120 list.array[sliceLstIdx]->sNSSAI.sST.buf,servedPlmn->list.array[arrayIdx]->\
2121 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.list.array[sliceLstIdx]->\
2124 if(servedPlmn->list.array[arrayIdx]->\
2125 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2126 list.array[sliceLstIdx]->sNSSAI.sST.buf == NULLP)
2128 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
2131 servedPlmn->list.array[arrayIdx]->\
2132 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2133 list.array[sliceLstIdx]->sNSSAI.sST.buf[arrayIdx] = duCfgParam.srvdCellLst[arrayIdx].duCellInfo.\
2134 cellInfo.srvdPlmn[arrayIdx].taiSliceSuppLst.snssai[sliceLstIdx]->sst;
2136 DU_ALLOC(servedPlmn->list.array[arrayIdx]->\
2137 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2138 list.array[sliceLstIdx]->sNSSAI.sD,sizeof(OCTET_STRING_t));
2139 if(servedPlmn->list.array[arrayIdx]->\
2140 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2141 list.array[sliceLstIdx]->sNSSAI.sD == NULLP)
2143 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
2146 servedPlmn->list.array[arrayIdx]->\
2147 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2148 list.array[sliceLstIdx]->sNSSAI.sD->size = 3 * sizeof(uint8_t);
2149 DU_ALLOC(servedPlmn->list.array[arrayIdx]->\
2150 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2151 list.array[sliceLstIdx]->sNSSAI.sD->buf,servedPlmn->list.array[arrayIdx]->\
2152 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2153 list.array[sliceLstIdx]->sNSSAI.sD->size);
2154 if(servedPlmn->list.array[arrayIdx]->\
2155 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2156 list.array[sliceLstIdx]->sNSSAI.sD->buf == NULLP)
2158 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
2161 memcpy(servedPlmn->list.array[arrayIdx]->\
2162 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2163 list.array[sliceLstIdx]->sNSSAI.sD->buf, duCfgParam.srvdCellLst[arrayIdx].duCellInfo.\
2164 cellInfo.srvdPlmn[arrayIdx].taiSliceSuppLst.snssai[sliceLstIdx]->sd,\
2165 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
2166 list.array[sliceLstIdx]->sNSSAI.sD->size);
2171 /*******************************************************************
2173 * @brief Fills Nr Fdd Info required in ServCellInfo IE
2177 * Function : fillNrFddInfo
2179 * Functionality: Fills Nr Fdd Info required in ServCellInfo IE
2181 * @params[in] Pointer to NR_Mode_Info_t *
2183 * @return ROK - success
2186 *****************************************************************/
2188 uint8_t fillNrFddInfo(NR_Mode_Info_t *nrFdd)
2190 nrFdd->choice.fDD->uL_NRFreqInfo.nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.\
2191 f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn;
2192 nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.count = 1;
2193 nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.size = sizeof(FreqBandNrItem_t*);
2194 DU_ALLOC(nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.\
2195 array, nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.size);
2196 if(nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array == NULLP)
2200 DU_ALLOC(nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array[0], \
2201 sizeof(FreqBandNrItem_t));
2202 if(nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array[0] == NULLP)
2206 nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array[0]->freqBandIndicatorNr = \
2207 duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.\
2208 freqBand[0].nrFreqBand;
2209 nrFdd->choice.fDD->uL_NRFreqInfo.freqBandListNr.list.array[0]->supportedSULBandList.list.count=0;
2210 nrFdd->choice.fDD->dL_NRFreqInfo.nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.\
2211 dlNrFreqInfo.nrArfcn;
2212 nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.count = 1;
2213 nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.size = sizeof(FreqBandNrItem_t *);
2214 DU_ALLOC(nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array,nrFdd->\
2215 choice.fDD->dL_NRFreqInfo.freqBandListNr.list.size);
2216 if(nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array == NULLP)
2220 DU_ALLOC(nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array[0],\
2221 sizeof(FreqBandNrItem_t));
2222 if(nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array[0] == NULLP)
2226 nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array[0]->freqBandIndicatorNr = \
2227 duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.\
2228 freqBand[0].nrFreqBand;
2229 nrFdd->choice.fDD->dL_NRFreqInfo.freqBandListNr.list.array[0]->supportedSULBandList.list.count=0;
2231 /*Transmission Bandwidth*/
2232 nrFdd->choice.fDD->uL_Transmission_Bandwidth.nRSCS = duCfgParam.srvdCellLst[0].duCellInfo.\
2233 f1Mode.mode.fdd.ulTxBw.nrScs;
2234 nrFdd->choice.fDD->uL_Transmission_Bandwidth.nRNRB = duCfgParam.srvdCellLst[0].duCellInfo.\
2235 f1Mode.mode.fdd.ulTxBw.nrb;
2236 nrFdd->choice.fDD->dL_Transmission_Bandwidth.nRSCS = duCfgParam.srvdCellLst[0].duCellInfo.\
2237 f1Mode.mode.fdd.dlTxBw.nrScs;
2238 nrFdd->choice.fDD->dL_Transmission_Bandwidth.nRNRB = duCfgParam.srvdCellLst[0].duCellInfo.\
2239 f1Mode.mode.fdd.dlTxBw.nrb;
2244 /*******************************************************************
2246 * @brief Fills ServCellInfo IE
2250 * Function : fillServedCellInfo
2252 * Functionality: Fills ServCellInfo
2254 * @params[in] Pointer to Served_Cell_Information_t *
2256 * @return ROK - success
2259 *****************************************************************/
2261 uint8_t fillServedCellInfo(Served_Cell_Information_t *srvCellInfo)
2263 uint8_t tmp, ieIdx, ieListCnt;
2266 srvCellInfo->nRCGI.pLMN_Identity.size =3*sizeof(uint8_t);
2267 DU_ALLOC(srvCellInfo->nRCGI.pLMN_Identity.buf,\
2268 srvCellInfo->nRCGI.pLMN_Identity.size);
2269 if(srvCellInfo->nRCGI.pLMN_Identity.buf == NULLP)
2273 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
2274 srvCellInfo->nRCGI.pLMN_Identity.buf);
2275 srvCellInfo->nRCGI.nRCellIdentity.size =5*sizeof(uint8_t);
2276 DU_ALLOC(srvCellInfo->nRCGI.nRCellIdentity.buf,\
2277 srvCellInfo->nRCGI.nRCellIdentity.size);
2278 if(srvCellInfo->nRCGI.nRCellIdentity.buf == NULLP)
2282 for (tmp = 0 ; tmp < srvCellInfo->\
2283 nRCGI.nRCellIdentity.size-1 ; tmp++)
2285 srvCellInfo->nRCGI.nRCellIdentity.buf[tmp] = 0;
2287 srvCellInfo->nRCGI.nRCellIdentity.buf[4] = 16;
2288 srvCellInfo->nRCGI.nRCellIdentity.bits_unused =4;
2291 srvCellInfo->nRPCI = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrPci;
2295 srvCellInfo->servedPLMNs.list.count = ieListCnt;
2296 srvCellInfo->servedPLMNs.list.size = ieListCnt*sizeof(ServedPLMNs_Item_t *);
2297 DU_ALLOC(srvCellInfo->servedPLMNs.list.array,\
2298 srvCellInfo->servedPLMNs.list.size);
2299 if(srvCellInfo->servedPLMNs.list.array == NULLP)
2303 for(ieIdx=0; ieIdx < ieListCnt; ieIdx++)
2305 DU_ALLOC(srvCellInfo->servedPLMNs.list.array[ieIdx],\
2306 sizeof(ServedPLMNs_Item_t));
2307 if(srvCellInfo->servedPLMNs.list.array[ieIdx]== NULLP)
2312 if(fillServedPlmns(&srvCellInfo->servedPLMNs))
2317 /*nR Mode Info with FDD*/
2318 srvCellInfo->nR_Mode_Info.present = NR_Mode_Info_PR_fDD;
2319 DU_ALLOC(srvCellInfo->nR_Mode_Info.choice.fDD,\
2320 sizeof(FDD_Info_t));
2321 if(srvCellInfo->nR_Mode_Info.choice.fDD == NULLP)
2325 if(fillNrFddInfo(&srvCellInfo->nR_Mode_Info))
2328 /*Measurement timing Config*/
2329 srvCellInfo->measurementTimingConfiguration.size = sizeof(uint8_t);
2330 DU_ALLOC(srvCellInfo->measurementTimingConfiguration.\
2331 buf,srvCellInfo->measurementTimingConfiguration.size);
2332 if(srvCellInfo->measurementTimingConfiguration.buf == NULLP)
2336 srvCellInfo->measurementTimingConfiguration.\
2337 buf[0] = duCfgParam.srvdCellLst[0].duCellInfo.measTimeCfg;
2342 /*******************************************************************
2344 * @brief Fills ServCellToModItem IE
2348 * Function : fillServCellToModItem
2350 * Functionality: Fills ServCellToModItem IE
2352 * @params[in] Pointer to Served_Cells_To_Modify_Item_t *
2354 * @return ROK - success
2357 *****************************************************************/
2359 uint8_t fillServCellToModItem(Served_Cells_To_Modify_Item_t *modifyItem)
2364 modifyItem->oldNRCGI.pLMN_Identity.size = 3*sizeof(uint8_t);
2365 DU_ALLOC(modifyItem->oldNRCGI.pLMN_Identity.buf,modifyItem->oldNRCGI.pLMN_Identity.size);
2366 if(modifyItem->oldNRCGI.pLMN_Identity.buf == NULLP)
2370 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
2371 modifyItem->oldNRCGI.pLMN_Identity.buf);
2374 modifyItem->oldNRCGI.nRCellIdentity.size = 5*sizeof(uint8_t);
2375 DU_ALLOC(modifyItem->oldNRCGI.nRCellIdentity.buf,\
2376 modifyItem->oldNRCGI.nRCellIdentity.size);
2377 if(modifyItem->oldNRCGI.nRCellIdentity.buf == NULLP)
2381 for(ieIdx = 0; ieIdx < modifyItem->oldNRCGI.nRCellIdentity.size-1; ieIdx++)
2383 modifyItem->oldNRCGI.nRCellIdentity.buf[ieIdx] = 0;
2385 modifyItem->oldNRCGI.nRCellIdentity.buf[4] = 16;
2386 modifyItem->oldNRCGI.nRCellIdentity.bits_unused = 4;
2388 if(fillServedCellInfo(&modifyItem->served_Cell_Information))
2394 /*******************************************************************
2396 * @brief Builds ServCellToModList
2400 * Function : buildServCellToModList
2402 * Functionality: Builds the serv cell to Mod List
2404 * @params[in] Pointer to Served_Cells_To_Modify_List_t *
2406 * @return ROK - success
2409 *****************************************************************/
2411 uint8_t buildServCellToModList(Served_Cells_To_Modify_List_t *cellsToModify)
2413 uint8_t ieListCnt, ieIdx;
2414 Served_Cells_To_Modify_Item_t *modifyItem = NULLP;
2417 cellsToModify->list.count = ieListCnt;
2418 cellsToModify->list.size = ieListCnt*sizeof(Served_Cells_To_Modify_ItemIEs_t *);
2419 DU_ALLOC(cellsToModify->list.array,cellsToModify->list.size);
2420 if(cellsToModify->list.array == NULLP)
2424 for(ieIdx=0; ieIdx< ieListCnt; ieIdx++)
2426 DU_ALLOC(cellsToModify->list.array[ieIdx],sizeof(Served_Cells_To_Modify_ItemIEs_t));
2427 if(cellsToModify->list.array[ieIdx] == NULLP)
2432 cellsToModify->list.array[0]->id = ProtocolIE_ID_id_Served_Cells_To_Modify_Item;
2433 cellsToModify->list.array[0]->criticality = Criticality_reject;
2434 cellsToModify->list.array[0]->value.present =\
2435 Served_Cells_To_Modify_ItemIEs__value_PR_Served_Cells_To_Modify_Item;
2436 modifyItem=&cellsToModify->list.array[0]->value.choice.Served_Cells_To_Modify_Item;
2438 if(fillServCellToModItem(modifyItem))
2443 /*******************************************************************
2445 * @brief filling the DeleteItemList
2449 * Function : fillCellToDeleteItem
2451 * Functionality: Filling the DeleteItemIe
2453 * @params[in] Pointer to Served_Cells_To_Delete_ItemIEs_t
2455 * @return ROK - success
2458 *****************************************************************/
2459 uint8_t fillCellToDeleteItem(struct Served_Cells_To_Delete_ItemIEs *deleteItemIe)
2462 Served_Cells_To_Delete_Item_t *deleteItem=NULLP;
2464 deleteItemIe->id = ProtocolIE_ID_id_Served_Cells_To_Delete_Item;
2465 deleteItemIe->criticality = Criticality_reject;
2466 deleteItemIe->value.present =\
2467 Served_Cells_To_Delete_ItemIEs__value_PR_Served_Cells_To_Delete_Item;
2468 deleteItem=&deleteItemIe->value.choice.Served_Cells_To_Delete_Item;
2471 deleteItem->oldNRCGI.pLMN_Identity.size = 3*sizeof(uint8_t);
2472 DU_ALLOC(deleteItem->oldNRCGI.pLMN_Identity.buf,deleteItem->oldNRCGI.pLMN_Identity.size);
2473 if(deleteItem->oldNRCGI.pLMN_Identity.buf == NULLP)
2475 DU_LOG("ERROR --> F1AP: fillCellToDeleteItem(): Failed to allocate the memory");
2478 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
2479 deleteItem->oldNRCGI.pLMN_Identity.buf);
2482 deleteItem->oldNRCGI.nRCellIdentity.size = 5*sizeof(uint8_t);
2483 DU_ALLOC(deleteItem->oldNRCGI.nRCellIdentity.buf,\
2484 deleteItem->oldNRCGI.nRCellIdentity.size);
2485 if(deleteItem->oldNRCGI.nRCellIdentity.buf == NULLP)
2487 DU_LOG("ERROR --> F1AP: fillCellToDeleteItem(): Failed to allocate the memory");
2490 for(arrIdx = 0; arrIdx < deleteItem->oldNRCGI.nRCellIdentity.size-1; arrIdx++)
2492 deleteItem->oldNRCGI.nRCellIdentity.buf[arrIdx] = 0;
2494 deleteItem->oldNRCGI.nRCellIdentity.buf[4] = 16;
2495 deleteItem->oldNRCGI.nRCellIdentity.bits_unused = 4;
2498 /*******************************************************************
2500 * @brief Builds ServCellToDeleteList
2504 * Function : buildServCellToDeleteList
2506 * Functionality: Builds the serv cell to delete List
2508 * @params[in] Pointer to Served_Cells_To_Delete_List_t *
2510 * @return ROK - success
2513 *****************************************************************/
2515 uint8_t buildServCellToDeleteList(Served_Cells_To_Delete_List_t *cellsToDelete)
2517 uint8_t ieListCnt, arrIdx;
2520 cellsToDelete->list.count = ieListCnt;
2521 cellsToDelete->list.size = ieListCnt*sizeof(Served_Cells_To_Delete_ItemIEs_t *);
2523 DU_ALLOC(cellsToDelete->list.array,cellsToDelete->list.size);
2524 if(cellsToDelete->list.array == NULLP)
2526 DU_LOG("\nERROR --> F1AP : buildServCellToDeleteList(): Memory allocation failed");
2530 for(arrIdx=0; arrIdx< ieListCnt; arrIdx++)
2532 DU_ALLOC(cellsToDelete->list.array[arrIdx],sizeof(Served_Cells_To_Delete_ItemIEs_t));
2533 if(cellsToDelete->list.array[arrIdx] == NULLP)
2535 DU_LOG("\nERROR --> F1AP : buildServCellToDeleteList(): Memory allocation failed");
2541 if(fillCellToDeleteItem((Served_Cells_To_Delete_ItemIEs_t*)cellsToDelete->list.array[arrIdx]) !=ROK)
2543 DU_LOG("\nERROR --> F1AP: buildServCellToDeleteList(): failed to fill Served_Cells_To_Delete_ItemIEs");
2549 /*******************************************************************
2551 * @brief Builds and sends the DUConfigUpdate
2555 * Function : BuildAndSendDUConfigUpdate
2557 * Functionality: Constructs the DU Update message and sends
2558 * it to the CU through SCTP.
2560 * @params[in] void **buf,Buffer to which encoded pattern is written into
2561 * @params[in] int *size,size of buffer
2563 * @return ROK - success
2566 * ****************************************************************/
2567 uint8_t BuildAndSendDUConfigUpdate(ServCellAction servCellAction)
2569 uint8_t ret =0, ieIdx=0, elementCnt=0;
2570 bool memAlloctionFailure = false;
2571 F1AP_PDU_t *f1apDuCfg = NULLP;
2572 GNBDUConfigurationUpdate_t *duCfgUpdate = NULLP;
2573 asn_enc_rval_t encRetVal; /* Encoder return value */
2575 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
2580 DU_LOG("\nINFO --> F1AP : Building DU config update\n");
2581 /* Allocate the memory for F1DuCfg */
2582 DU_ALLOC(f1apDuCfg, sizeof(F1AP_PDU_t));
2583 if(f1apDuCfg == NULLP)
2585 DU_LOG("\nERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation for F1AP-PDU failed");
2589 f1apDuCfg->present = F1AP_PDU_PR_initiatingMessage;
2590 DU_ALLOC(f1apDuCfg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
2591 if(f1apDuCfg->choice.initiatingMessage == NULLP)
2593 DU_LOG("\nERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation for F1AP-PDU failed");
2597 f1apDuCfg->choice.initiatingMessage->procedureCode = \
2598 ProcedureCode_id_gNBDUConfigurationUpdate;
2599 f1apDuCfg->choice.initiatingMessage->criticality = Criticality_reject;
2600 f1apDuCfg->choice.initiatingMessage->value.present = \
2601 InitiatingMessage__value_PR_GNBDUConfigurationUpdate;
2602 duCfgUpdate = &f1apDuCfg->choice.initiatingMessage->value.\
2603 choice.GNBDUConfigurationUpdate;
2605 duCfgUpdate->protocolIEs.list.count = elementCnt;
2606 duCfgUpdate->protocolIEs.list.size = \
2607 elementCnt * sizeof(GNBDUConfigurationUpdateIEs_t*);
2609 /* Initialize the F1Setup members */
2610 DU_ALLOC(duCfgUpdate->protocolIEs.list.array,duCfgUpdate->protocolIEs.list.size);
2611 if(duCfgUpdate->protocolIEs.list.array == NULLP)
2613 DU_LOG("ERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation failed");
2616 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
2618 DU_ALLOC(duCfgUpdate->protocolIEs.list.array[ieIdx],sizeof(GNBDUConfigurationUpdateIEs_t));
2619 if(duCfgUpdate->protocolIEs.list.array[ieIdx] == NULLP)
2621 DU_LOG("ERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation failed");
2622 memAlloctionFailure = true;
2627 if(memAlloctionFailure == true)
2633 duCfgUpdate->protocolIEs.list.array[ieIdx]->id=ProtocolIE_ID_id_TransactionID;
2634 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
2635 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2636 GNBDUConfigurationUpdateIEs__value_PR_TransactionID;
2637 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = TRANS_ID;
2640 if(servCellAction == SERV_CELL_TO_MODIFY)
2642 /*Served Cell to Modify */
2643 duCfgUpdate->protocolIEs.list.array[ieIdx]->id = \
2644 ProtocolIE_ID_id_Served_Cells_To_Modify_List;
2645 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality =Criticality_reject;
2646 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2647 GNBDUConfigurationUpdateIEs__value_PR_Served_Cells_To_Modify_List;
2648 if(buildServCellToModList(&duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.\
2649 Served_Cells_To_Modify_List))
2651 DU_LOG("ERROR --> DU APP : BuildAndSendDUConfigUpdate(): failed to build ServCellToModList");
2657 /*Served Cell to Delete */
2658 duCfgUpdate->protocolIEs.list.array[ieIdx]->id = \
2659 ProtocolIE_ID_id_Served_Cells_To_Delete_List;
2660 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality =Criticality_reject;
2661 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2662 GNBDUConfigurationUpdateIEs__value_PR_Served_Cells_To_Delete_List;
2663 if(buildServCellToDeleteList(&duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.\
2664 Served_Cells_To_Delete_List)!=ROK)
2666 DU_LOG("ERROR --> DU APP : BuildAndSendDUConfigUpdate(): failed to build ServCellToDeleteList");
2671 // NOTE :GNB DU SYS INFO:MIB AND SIB1 INFORMATION TO BE BUILT AND FILLED HERE
2674 duCfgUpdate->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_ID;
2675 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
2676 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2677 GNBDUConfigurationUpdateIEs__value_PR_GNB_DU_ID;
2678 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size = sizeof(uint8_t);
2679 DU_ALLOC(duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
2680 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
2681 if(duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf == NULLP)
2683 DU_LOG("ERROR --> DU APP : BuildAndSendDUConfigUpdate(): Memory allocation failed for GNB_DU_ID");
2686 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf[0] = duCfgParam.duId;
2688 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apDuCfg);
2690 /* Encode the DU Config Update type as APER */
2691 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
2693 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apDuCfg, PrepFinalEncBuf, encBuf);
2695 /* Checking encode results */
2696 if(encRetVal.encoded == ENCODE_FAIL)
2698 DU_LOG("ERROR --> F1AP : Could not encode DUConfigUpdate structure (at %s)\n",\
2699 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
2704 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for DUConfigUpdate\n");
2705 for(ieIdx =0; ieIdx < encBufSize; ieIdx++)
2707 printf("%x",encBuf[ieIdx]);
2711 if(sendF1APMsg() != ROK)
2713 DU_LOG("\nERROR --> F1AP : Sending GNB-DU Config Update failed");
2721 addToReservedF1apPduList(TRANS_ID,f1apDuCfg);
2726 /*******************************************************************
2728 * @brief free the ULRRCMessageTransfer
2732 * Function : FreeULRRCMessageTransfer
2734 * Functionality: Deallocating the memory of variable allocated in
2735 * FreeULRRCMessageTransfer
2739 * @return ROK - void
2741 ******************************************************************/
2742 void FreeULRRCMessageTransfer( F1AP_PDU_t *f1apMsg)
2745 ULRRCMessageTransfer_t *ulRRCMsg;
2747 if(f1apMsg != NULLP)
2749 if(f1apMsg->choice.initiatingMessage != NULLP)
2751 ulRRCMsg = &f1apMsg->choice.initiatingMessage->value.choice.ULRRCMessageTransfer;
2752 if(ulRRCMsg->protocolIEs.list.array != NULLP)
2754 for(idx1=0;idx1<ulRRCMsg->protocolIEs.list.count;idx1++)
2756 if(ulRRCMsg->protocolIEs.list.array[idx1] != NULLP)
2758 if(ulRRCMsg->protocolIEs.list.array[idx1]->value.present ==
2759 ULRRCMessageTransferIEs__value_PR_RRCContainer)
2761 DU_FREE(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf,
2762 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size);
2764 DU_FREE(ulRRCMsg->protocolIEs.list.array[idx1],sizeof(ULRRCMessageTransferIEs_t));
2767 DU_FREE(ulRRCMsg->protocolIEs.list.array,ulRRCMsg->protocolIEs.list.size );
2769 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
2771 DU_FREE(f1apMsg,sizeof(F1AP_PDU_t));
2774 /*******************************************************************
2776 * @brief Builds and sends the ULRRCMessageTransfer
2780 * Function : BuildAndSendULRRCMessageTransfer
2782 * Functionality: Constructs the UL RRC Message Transfer and sends
2783 * it to the CU through SCTP.
2787 * @return ROK - success
2790 * ****************************************************************/
2791 uint8_t BuildAndSendULRRCMessageTransfer(DuUeCb ueCb, uint8_t lcId, \
2792 uint16_t msgLen, uint8_t *rrcMsg)
2794 uint8_t elementCnt =0;
2797 F1AP_PDU_t *f1apMsg = NULLP;
2798 ULRRCMessageTransfer_t *ulRRCMsg = NULLP;
2799 asn_enc_rval_t encRetVal; /* Encoder return value */
2800 uint8_t ret =RFAILED;
2802 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
2806 DU_LOG("\n INFO --> F1AP : Building UL RRC Message Transfer Message\n");
2808 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
2809 if(f1apMsg == NULLP)
2811 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
2814 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
2815 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
2816 if(f1apMsg->choice.initiatingMessage == NULLP)
2818 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
2821 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_ULRRCMessageTransfer;
2822 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
2823 f1apMsg->choice.initiatingMessage->value.present = \
2824 InitiatingMessage__value_PR_ULRRCMessageTransfer;
2826 &f1apMsg->choice.initiatingMessage->value.choice.ULRRCMessageTransfer;
2828 ulRRCMsg->protocolIEs.list.count = elementCnt;
2829 ulRRCMsg->protocolIEs.list.size = \
2830 elementCnt * sizeof(ULRRCMessageTransferIEs_t *);
2832 /* Initialize the F1Setup members */
2833 DU_ALLOC(ulRRCMsg->protocolIEs.list.array, ulRRCMsg->protocolIEs.list.size);
2834 if(ulRRCMsg->protocolIEs.list.array == NULLP)
2836 DU_LOG(" ERROR --> F1AP : Memory allocation for UL RRC MessageTransferIEs failed");
2839 for(idx=0; idx<elementCnt; idx++)
2841 DU_ALLOC(ulRRCMsg->protocolIEs.list.array[idx],sizeof(ULRRCMessageTransferIEs_t));
2842 if(ulRRCMsg->protocolIEs.list.array[idx] == NULLP)
2850 /*GNB CU UE F1AP ID*/
2851 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
2852 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2853 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2854 ULRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID;
2855 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.GNB_CU_UE_F1AP_ID = ueCb.gnbCuUeF1apId;
2857 /*GNB DU UE F1AP ID*/
2859 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
2860 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2861 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2862 ULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
2863 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.GNB_DU_UE_F1AP_ID = ueCb.gnbDuUeF1apId;
2867 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_SRBID;
2868 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2869 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2870 ULRRCMessageTransferIEs__value_PR_SRBID;
2871 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.SRBID = lcId;
2875 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_RRCContainer;
2876 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2877 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2878 ULRRCMessageTransferIEs__value_PR_RRCContainer;
2879 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size = msgLen;
2880 DU_ALLOC(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf,
2881 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size)
2882 if(!ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf)
2884 DU_LOG(" ERROR --> F1AP : Memory allocation for BuildAndSendULRRCMessageTransfer failed");
2887 memset(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf, 0, msgLen);
2888 memcpy(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf, \
2889 rrcMsg, ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size);
2891 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
2893 /* Encode the F1SetupRequest type as APER */
2894 memset(encBuf, 0, ENC_BUF_MAX_LEN);
2896 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
2898 /* Encode results */
2899 if(encRetVal.encoded == ENCODE_FAIL)
2901 DU_LOG( "\nERROR --> F1AP : Could not encode ULRRCMessageTransfer structure (at %s)\n",\
2902 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
2907 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for ULRRCMessageTransfer\n");
2908 for(int i=0; i< encBufSize; i++)
2910 printf("%x",encBuf[i]);
2915 if(sendF1APMsg() != ROK)
2917 DU_LOG("\nERROR --> F1AP : Sending UL RRC Message Transfer Failed");
2923 FreeULRRCMessageTransfer(f1apMsg);
2926 }/* End of BuildAndSendULRRCMessageTransfer*/
2928 /*******************************************************************
2930 * @brief Builds tag config
2934 * Function : BuildTagConfig
2936 * Functionality: Builds tag config in MacCellGroupConfig
2938 * @params[in] TAG_Config *tag_Config
2940 * @return ROK - success
2943 * ****************************************************************/
2944 uint8_t BuildTagConfig(struct TAG_Config *tagConfig)
2946 struct TAG_Config__tag_ToAddModList *tagList;
2947 uint8_t idx, elementCnt;
2949 tagConfig->tag_ToReleaseList = NULLP;
2950 tagConfig->tag_ToAddModList = NULLP;
2951 DU_ALLOC(tagConfig->tag_ToAddModList, sizeof(struct TAG_Config__tag_ToAddModList));
2952 if(!tagConfig->tag_ToAddModList)
2954 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildTagConfig");
2958 elementCnt = 1; //ODU_VALUE_ONE;
2959 tagList = tagConfig->tag_ToAddModList;
2960 tagList->list.count = elementCnt;
2961 tagList->list.size = elementCnt * sizeof(struct TAG *);
2963 tagList->list.array = NULLP;
2964 DU_ALLOC(tagList->list.array, tagList->list.size);
2965 if(!tagList->list.array)
2967 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildTagConfig");
2971 for(idx=0; idx<tagList->list.count; idx++)
2973 tagList->list.array[idx] = NULLP;
2974 DU_ALLOC(tagList->list.array[idx], sizeof(struct TAG));
2975 if(!tagList->list.array[idx])
2977 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildTagConfig");
2983 tagList->list.array[idx]->tag_Id = TAG_ID;
2984 tagList->list.array[idx]->timeAlignmentTimer = TIME_ALIGNMENT_TMR;
2989 /*******************************************************************
2991 * @brief Builds PHR Config
2995 * Function : BuildPhrConfig
2997 * Functionality: Builds phrConfig in MacCellGroupConfig
2999 * @params[in] PHR Config *
3001 * @return ROK - success
3004 * ****************************************************************/
3005 uint8_t BuildPhrConfig(struct MAC_CellGroupConfig__phr_Config *phrConfig)
3008 phrConfig->present = MAC_CellGroupConfig__phr_Config_PR_setup;
3009 phrConfig->choice.setup = NULLP;
3010 DU_ALLOC(phrConfig->choice.setup, sizeof(struct PHR_Config));
3011 if(!phrConfig->choice.setup)
3013 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildPhrConfig");
3017 phrConfig->choice.setup->phr_PeriodicTimer = PHR_PERIODIC_TMR;
3018 phrConfig->choice.setup->phr_ProhibitTimer = PHR_PROHIBHIT_TMR;
3019 phrConfig->choice.setup->phr_Tx_PowerFactorChange = PHR_PWR_FACTOR_CHANGE;
3020 phrConfig->choice.setup->multiplePHR = false;
3021 phrConfig->choice.setup->dummy = false;
3022 phrConfig->choice.setup->phr_Type2OtherCell = false;
3023 phrConfig->choice.setup->phr_ModeOtherCG = PHR_MODE_OTHER_CG;
3028 /*******************************************************************
3030 * @brief Builds BSR Config
3034 * Function : BuildBsrConfig
3036 * Functionality: Builds BuildBsrConfig in MacCellGroupConfig
3038 * @params[in] BSR_Config *bsrConfig
3040 * @return ROK - success
3043 * ****************************************************************/
3044 uint8_t BuildBsrConfig(struct BSR_Config *bsrConfig)
3046 bsrConfig->periodicBSR_Timer = PERIODIC_BSR_TMR;
3047 bsrConfig->retxBSR_Timer = RETX_BSR_TMR;
3048 bsrConfig->logicalChannelSR_DelayTimer = NULLP;
3053 /*******************************************************************
3055 * @brief Builds scheduling request config
3059 * Function : BuildSchedulingReqConfig
3061 * Functionality: Builds BuildSchedulingReqConfig in MacCellGroupConfig
3063 * @params[in] SchedulingRequestConfig *schedulingRequestConfig
3065 * @return ROK - success
3068 * ****************************************************************/
3069 uint8_t BuildSchedulingReqConfig(struct SchedulingRequestConfig *schedulingRequestConfig)
3071 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList;
3072 uint8_t idx, elementCnt;
3074 schedulingRequestConfig->schedulingRequestToAddModList = NULLP;
3075 DU_ALLOC(schedulingRequestConfig->schedulingRequestToAddModList,
3076 sizeof(struct SchedulingRequestConfig__schedulingRequestToAddModList));
3077 if(!schedulingRequestConfig->schedulingRequestToAddModList)
3079 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
3083 elementCnt = 1; //ODU_VALUE_ONE;
3084 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
3085 schReqList->list.count = elementCnt;
3086 schReqList->list.size = elementCnt * sizeof(struct SchedulingRequestToAddMod *);
3088 schReqList->list.array = NULLP;
3089 DU_ALLOC(schReqList->list.array, schReqList->list.size);
3090 if(!schReqList->list.array)
3092 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
3096 for(idx=0;idx<schReqList->list.count; idx++)
3098 schReqList->list.array[idx] = NULLP;
3099 DU_ALLOC(schReqList->list.array[idx], sizeof(struct SchedulingRequestToAddMod));
3100 if(!schReqList->list.array[idx])
3102 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
3108 schReqList->list.array[idx]->schedulingRequestId = SCH_REQ_ID;
3110 schReqList->list.array[idx]->sr_ProhibitTimer = NULLP;
3111 DU_ALLOC(schReqList->list.array[idx]->sr_ProhibitTimer, sizeof(long));
3112 if(!schReqList->list.array[idx]->sr_ProhibitTimer)
3114 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
3117 *(schReqList->list.array[idx]->sr_ProhibitTimer) = SR_PROHIBIT_TMR;
3118 schReqList->list.array[idx]->sr_TransMax = SR_TRANS_MAX;
3119 schedulingRequestConfig->schedulingRequestToReleaseList = NULLP;
3124 /*******************************************************************
3126 * @brief Builds RLC Config
3130 * Function : BuildRlcConfig
3132 * Functionality: Builds RLC Config in BuildRlcBearerToAddModList
3134 * @params[in] RLC_Config *rlcConfig
3136 * @return ROK - success
3139 * ****************************************************************/
3140 uint8_t BuildRlcConfig(struct RLC_Config *rlcConfig)
3143 rlcConfig->present = RLC_Config_PR_am;
3145 rlcConfig->choice.am = NULLP;
3146 DU_ALLOC(rlcConfig->choice.am, sizeof(struct RLC_Config__am));
3147 if(!rlcConfig->choice.am)
3149 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfig");
3154 rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength = NULLP;
3155 DU_ALLOC(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
3156 if(!rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength)
3158 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfig");
3161 *(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength) = SN_FIELD_LEN;
3162 rlcConfig->choice.am->ul_AM_RLC.t_PollRetransmit = T_POLL_RETRANSMIT;
3163 rlcConfig->choice.am->ul_AM_RLC.pollPDU = POLL_PDU;
3164 rlcConfig->choice.am->ul_AM_RLC.pollByte = POLL_BYTE;
3165 rlcConfig->choice.am->ul_AM_RLC.maxRetxThreshold = MAX_RETX_THRESHOLD;
3168 rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength = NULLP;
3169 DU_ALLOC(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
3170 if(!rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength)
3172 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfig");
3175 *(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength) = SN_FIELD_LEN;
3176 rlcConfig->choice.am->dl_AM_RLC.t_Reassembly = T_REASSEMBLY;
3177 rlcConfig->choice.am->dl_AM_RLC.t_StatusProhibit = T_STATUS_PROHIBHIT;
3182 /*******************************************************************
3184 * @brief Builds MAC LC Config
3188 * Function : BuildMacLCConfig
3190 * Functionality: Builds MAC LC Config in BuildRlcBearerToAddModList
3192 * @params[in] struct LogicalChannelConfig macLcConfig
3194 * @return ROK - success
3197 * ****************************************************************/
3198 uint8_t BuildMacLCConfig(struct LogicalChannelConfig *macLcConfig)
3201 macLcConfig->ul_SpecificParameters = NULLP;
3202 DU_ALLOC(macLcConfig->ul_SpecificParameters, sizeof(struct LogicalChannelConfig__ul_SpecificParameters));
3203 if(!macLcConfig->ul_SpecificParameters)
3205 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacLCConfig");
3209 macLcConfig->ul_SpecificParameters->priority = MAC_LC_PRIORITY;
3210 macLcConfig->ul_SpecificParameters->prioritisedBitRate = PRIORTISIED_BIT_RATE;
3211 macLcConfig->ul_SpecificParameters->bucketSizeDuration = BUCKET_SIZE_DURATION;
3212 macLcConfig->ul_SpecificParameters->allowedServingCells = NULLP;
3213 macLcConfig->ul_SpecificParameters->allowedSCS_List = NULLP;
3214 macLcConfig->ul_SpecificParameters->maxPUSCH_Duration = NULLP;
3215 macLcConfig->ul_SpecificParameters->configuredGrantType1Allowed = NULLP;
3217 macLcConfig->ul_SpecificParameters->logicalChannelGroup = NULLP;
3218 DU_ALLOC(macLcConfig->ul_SpecificParameters->logicalChannelGroup, sizeof(long));
3219 if(!macLcConfig->ul_SpecificParameters->logicalChannelGroup)
3221 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacLCConfig");
3224 *(macLcConfig->ul_SpecificParameters->logicalChannelGroup) = LC_GRP;
3226 macLcConfig->ul_SpecificParameters->schedulingRequestID = NULLP;
3227 DU_ALLOC(macLcConfig->ul_SpecificParameters->schedulingRequestID, sizeof(SchedulingRequestId_t));
3228 if(!macLcConfig->ul_SpecificParameters->schedulingRequestID)
3230 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacLCConfig");
3233 *(macLcConfig->ul_SpecificParameters->schedulingRequestID) = SCH_REQ_ID;
3235 macLcConfig->ul_SpecificParameters->logicalChannelSR_Mask = false;
3236 macLcConfig->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = false;
3237 macLcConfig->ul_SpecificParameters->bitRateQueryProhibitTimer = NULLP;
3242 /*******************************************************************
3244 * @brief Builds RLC Bearer to Add/Mod list
3248 * Function :BuildRlcBearerToAddModList
3250 * Functionality: Builds RLC Bearer to Add/Mod list in DuToCuRrcContainer
3252 * @params[in] rlc_BearerToAddModList
3254 * @return ROK - success
3257 * ****************************************************************/
3258 uint8_t BuildRlcBearerToAddModList(struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList)
3260 uint8_t idx, elementCnt;
3263 rlcBearerList->list.count = elementCnt;
3264 rlcBearerList->list.size = elementCnt * sizeof(struct RLC_BearerConfig *);
3266 rlcBearerList->list.array = NULLP;
3267 DU_ALLOC(rlcBearerList->list.array, rlcBearerList->list.size);
3268 if(!rlcBearerList->list.array)
3270 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3274 for(idx=0; idx<rlcBearerList->list.count; idx++)
3276 rlcBearerList->list.array[idx] = NULLP;
3277 DU_ALLOC(rlcBearerList->list.array[idx], sizeof(struct RLC_BearerConfig));
3278 if(!rlcBearerList->list.array[idx])
3280 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3286 rlcBearerList->list.array[idx]->logicalChannelIdentity = SRB1_LCID;
3288 DU_ALLOC(rlcBearerList->list.array[idx]->servedRadioBearer, \
3289 sizeof(struct RLC_BearerConfig__servedRadioBearer));
3290 if(!rlcBearerList->list.array[idx]->servedRadioBearer)
3292 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3296 rlcBearerList->list.array[idx]->servedRadioBearer->present = \
3297 RLC_BearerConfig__servedRadioBearer_PR_srb_Identity;
3298 rlcBearerList->list.array[idx]->servedRadioBearer->choice.srb_Identity = \
3301 rlcBearerList->list.array[idx]->reestablishRLC = NULLP;
3302 rlcBearerList->list.array[idx]->rlc_Config = NULLP;
3303 DU_ALLOC(rlcBearerList->list.array[idx]->rlc_Config, sizeof(struct RLC_Config));
3304 if(!rlcBearerList->list.array[idx]->rlc_Config)
3306 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3310 if(BuildRlcConfig(rlcBearerList->list.array[idx]->rlc_Config) != ROK)
3312 DU_LOG("\nERROR --> F1AP : BuildRlcConfig failed");
3316 rlcBearerList->list.array[idx]->mac_LogicalChannelConfig = NULLP;
3317 DU_ALLOC(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig, \
3318 sizeof(struct LogicalChannelConfig));
3319 if(!rlcBearerList->list.array[idx]->mac_LogicalChannelConfig)
3321 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3325 if(BuildMacLCConfig(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig) != ROK)
3327 DU_LOG("\nERROR --> F1AP : BuildMacLCConfig failed");
3334 /*******************************************************************
3336 * @brief Build Control resource set to add/modify list
3340 * Function : BuildControlRSetToAddModList
3342 * Functionality: Build Control resource set to add/modify list
3345 * struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList
3347 * @return ROK - success
3350 * ****************************************************************/
3351 uint8_t BuildControlRSetToAddModList
3353 struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList
3358 uint8_t numBytes, bitsUnused;
3359 struct ControlResourceSet *controlRSet;
3360 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
3361 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
3365 controlRSetList->list.count = elementCnt;
3366 controlRSetList->list.size = \
3367 elementCnt * sizeof(struct ControlResourceSet *);
3369 controlRSetList->list.array = NULLP;
3370 DU_ALLOC(controlRSetList->list.array, controlRSetList->list.size);
3371 if(!controlRSetList->list.array)
3373 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3377 for(idx = 0; idx < elementCnt; idx++)
3379 controlRSetList->list.array[idx] = NULLP;
3380 DU_ALLOC(controlRSetList->list.array[idx], sizeof(struct ControlResourceSet));
3381 if(!controlRSetList->list.array[idx])
3383 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3389 controlRSet = controlRSetList->list.array[idx];
3391 controlRSet->controlResourceSetId = PDCCH_CTRL_RSRC_SET_ONE_ID;
3395 * Bit string stored ff0000000000
3399 controlRSet->frequencyDomainResources.size = numBytes * sizeof(uint8_t);
3401 controlRSet->frequencyDomainResources.buf = NULLP;
3402 DU_ALLOC(controlRSet->frequencyDomainResources.buf, \
3403 controlRSet->frequencyDomainResources.size);
3404 if(!controlRSet->frequencyDomainResources.buf)
3406 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3410 memset(controlRSet->frequencyDomainResources.buf, 0, FREQ_DOM_RSRC_SIZE);
3411 coreset0EndPrb = CORESET0_END_PRB;
3412 coreset1StartPrb = coreset0EndPrb + 6;
3413 coreset1NumPrb = CORESET1_NUM_PRB;
3414 /* calculate the PRBs */
3415 fillCoresetFeqDomAllocMap(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
3416 memcpy(controlRSet->frequencyDomainResources.buf, freqDomainResource, FREQ_DOM_RSRC_SIZE);
3417 controlRSet->frequencyDomainResources.bits_unused = bitsUnused;
3419 controlRSet->duration = PDCCH_CTRL_RSRC_SET_ONE_DURATION;
3420 controlRSet->cce_REG_MappingType.present = \
3421 ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved;
3423 controlRSet->precoderGranularity = PDCCH_CTRL_RSRC_SET_ONE_PRECOD_GRANULARITY;
3424 controlRSet->tci_StatesPDCCH_ToAddList = NULLP;
3425 controlRSet->tci_StatesPDCCH_ToReleaseList = NULLP;
3426 controlRSet->tci_PresentInDCI = NULLP;
3428 uint8_t tciStateIdx;
3430 DU_ALLOC(controlRset->tci_StatesPDCCH_ToAddList, \
3431 sizeof(struct ControlResourceSet__tci_StatesPDCCH_ToAddList));
3432 if(!controlRset->tci_StatesPDCCH_ToAddList)
3434 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3439 controlRset->tci_StatesPDCCH_ToAddList->list.count = elementCnt;
3440 controlRset->tci_StatesPDCCH_ToAddList->list.size = elementCnt * sizeof(TCI_StateId_t *);
3441 DU_ALLOC(controlRset->tci_StatesPDCCH_ToAddList->list.array, \
3442 controlRset->tci_StatesPDCCH_ToAddList->list.size)
3443 if(!controlRset->tci_StatesPDCCH_ToAddList->list.array)
3445 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3449 for(tciStateIdx = 0; tciStateIdx <elementCntl; tciStateIdx++)
3451 DU_ALLOC(controlRset->tci_StatesPDCCH_ToAddList->list.array[tciStateIdx], sizeof(TCI_StateId_t));
3452 if(!controlRset->tci_StatesPDCCH_ToAddList->list.array[tciStateIdx])
3454 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3461 *(controlRset->tci_StatesPDCCH_ToAddList->list.array[tciStateIdx]);
3463 DU_ALLOC(controlRset->tci_PresentInDCI, sizeof(long));
3464 if(!controlRset->tci_PresentInDCI)
3466 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3470 *(controlRset->tci_PresentInDCI);
3473 controlRSet->pdcch_DMRS_ScramblingID = NULLP;
3474 DU_ALLOC(controlRSet->pdcch_DMRS_ScramblingID, sizeof(long));
3475 if(!controlRSet->pdcch_DMRS_ScramblingID)
3477 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3480 *(controlRSet->pdcch_DMRS_ScramblingID) = SCRAMBLING_ID;
3483 } /* End BuildControlRSetToAddModList */
3485 /*******************************************************************
3487 * @brief Build search space to add/modify list
3491 * Function : BuildSearchSpcToAddModList
3493 * Functionality: Build search space to add/modify list
3496 * @return ROK - success
3499 * ****************************************************************/
3500 uint8_t BuildSearchSpcToAddModList
3502 struct PDCCH_Config__searchSpacesToAddModList *searchSpcList
3510 struct SearchSpace *searchSpc;
3513 searchSpcList->list.count = elementCnt;
3514 searchSpcList->list.size = elementCnt * sizeof(struct SearchSpace *);
3516 searchSpcList->list.array = NULLP;
3517 DU_ALLOC(searchSpcList->list.array, searchSpcList->list.size);
3518 if(!searchSpcList->list.array)
3520 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3524 for(idx = 0; idx < elementCnt; idx++)
3526 searchSpcList->list.array[idx] = NULLP;
3527 DU_ALLOC(searchSpcList->list.array[idx], sizeof(struct SearchSpace));
3528 if(!searchSpcList->list.array[idx])
3530 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3536 searchSpc = searchSpcList->list.array[idx];
3538 searchSpc->searchSpaceId = PDCCH_SRCH_SPC_TWO_ID;
3540 searchSpc->controlResourceSetId = NULLP;
3541 DU_ALLOC(searchSpc->controlResourceSetId, sizeof(ControlResourceSetId_t));
3542 if(!searchSpc->controlResourceSetId)
3544 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3547 *(searchSpc->controlResourceSetId) = PDCCH_CTRL_RSRC_SET_ONE_ID;
3549 searchSpc->monitoringSlotPeriodicityAndOffset = NULLP;
3550 DU_ALLOC(searchSpc->monitoringSlotPeriodicityAndOffset, \
3551 sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
3552 if(!searchSpc->monitoringSlotPeriodicityAndOffset)
3554 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3557 searchSpc->monitoringSlotPeriodicityAndOffset->present = \
3558 SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
3560 searchSpc->duration = NULLP;
3561 searchSpc->monitoringSymbolsWithinSlot = NULLP;
3562 DU_ALLOC(searchSpc->monitoringSymbolsWithinSlot, sizeof(BIT_STRING_t));
3563 if(!searchSpc->monitoringSymbolsWithinSlot)
3565 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3569 /* Values taken from reference logs :
3572 * Bit string stores 8000
3577 searchSpc->monitoringSymbolsWithinSlot->size = numBytes * sizeof(uint8_t);
3578 searchSpc->monitoringSymbolsWithinSlot->buf = NULLP;
3579 DU_ALLOC(searchSpc->monitoringSymbolsWithinSlot->buf, \
3580 searchSpc->monitoringSymbolsWithinSlot->size);
3581 if(!searchSpc->monitoringSymbolsWithinSlot->buf)
3583 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3588 searchSpc->monitoringSymbolsWithinSlot->buf[byteIdx++] = \
3589 PDCCH_SYMBOL_WITHIN_SLOT /* setting MSB to 128 i.e. 0x80 */;
3590 searchSpc->monitoringSymbolsWithinSlot->buf[byteIdx++] = 0;
3591 searchSpc->monitoringSymbolsWithinSlot->bits_unused = bitsUnused;
3593 searchSpc->nrofCandidates = NULLP;
3594 DU_ALLOC(searchSpc->nrofCandidates, sizeof(struct SearchSpace__nrofCandidates));
3595 if(!searchSpc->nrofCandidates)
3597 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3601 searchSpc->nrofCandidates->aggregationLevel1 = \
3602 PDCCH_SRCH_SPC_TWO_AGG_LVL1_CANDIDATE;
3603 searchSpc->nrofCandidates->aggregationLevel2 = \
3604 PDCCH_SRCH_SPC_TWO_AGG_LVL2_CANDIDATE;
3605 searchSpc->nrofCandidates->aggregationLevel4 = \
3606 PDCCH_SRCH_SPC_TWO_AGG_LVL4_CANDIDATE;
3607 searchSpc->nrofCandidates->aggregationLevel8 = \
3608 PDCCH_SRCH_SPC_TWO_AGG_LVL8_CANDIDATE;
3609 searchSpc->nrofCandidates->aggregationLevel16 = \
3610 PDCCH_SRCH_SPC_TWO_AGG_LVL16_CANDIDATE;
3612 searchSpc->searchSpaceType = NULLP;
3613 DU_ALLOC(searchSpc->searchSpaceType, sizeof(struct SearchSpace__searchSpaceType));
3614 if(!searchSpc->searchSpaceType)
3616 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3620 searchSpc->searchSpaceType->present = SearchSpace__searchSpaceType_PR_ue_Specific;
3622 searchSpc->searchSpaceType->choice.ue_Specific = NULLP;
3623 DU_ALLOC(searchSpc->searchSpaceType->choice.ue_Specific, \
3624 sizeof(struct SearchSpace__searchSpaceType__ue_Specific));
3625 if(!searchSpc->searchSpaceType->choice.ue_Specific)
3627 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3630 searchSpc->searchSpaceType->choice.ue_Specific->dci_Formats = \
3631 PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
3634 }/* End BuildSearchSpcToAddModList */
3636 /*******************************************************************
3638 * @brief Builds BWP DL dedicated PDCCH config
3642 * Function : BuildBWPDlDedPdcchCfg
3644 * Functionality: Builds BWP DL dedicated PDCCH config
3646 * @params[in] struct PDCCH_Config *pdcchCfg
3648 * @return ROK - success
3651 * ****************************************************************/
3652 uint8_t BuildBWPDlDedPdcchCfg(struct PDCCH_Config *pdcchCfg)
3654 pdcchCfg->controlResourceSetToAddModList = NULLP;
3655 DU_ALLOC(pdcchCfg->controlResourceSetToAddModList, \
3656 sizeof(struct PDCCH_Config__controlResourceSetToAddModList));
3657 if(!pdcchCfg->controlResourceSetToAddModList)
3659 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdcchCfg");
3663 if(BuildControlRSetToAddModList(pdcchCfg->controlResourceSetToAddModList) != ROK)
3668 pdcchCfg->controlResourceSetToReleaseList = NULLP;
3670 pdcchCfg->searchSpacesToAddModList = NULLP;
3671 DU_ALLOC(pdcchCfg->searchSpacesToAddModList, \
3672 sizeof(struct PDCCH_Config__searchSpacesToAddModList));
3673 if(!pdcchCfg->searchSpacesToAddModList)
3675 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdcchCfg");
3679 if(BuildSearchSpcToAddModList(pdcchCfg->searchSpacesToAddModList) != ROK)
3684 pdcchCfg->searchSpacesToReleaseList = NULLP;
3685 pdcchCfg->downlinkPreemption = NULLP;
3686 pdcchCfg->tpc_PUSCH = NULLP;
3687 pdcchCfg->tpc_PUCCH = NULLP;
3688 pdcchCfg->tpc_SRS = NULLP;
3693 /*******************************************************************
3695 * @brief Builds DMRS DL PDSCH Mapping type A
3699 * Function : BuildDMRSDLPdschMapTypeA
3701 * Functionality: Builds DMRS DL PDSCH Mapping type A
3704 * struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg
3705 * @return ROK - success
3708 * ****************************************************************/
3709 uint8_t BuildDMRSDLPdschMapTypeA
3711 struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg
3714 dmrsDlCfg->present = PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA_PR_setup;
3715 dmrsDlCfg->choice.setup = NULLP;
3716 DU_ALLOC(dmrsDlCfg->choice.setup, sizeof(struct DMRS_DownlinkConfig));
3717 if(!dmrsDlCfg->choice.setup)
3719 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
3723 dmrsDlCfg->choice.setup->dmrs_Type = NULLP;
3724 dmrsDlCfg->choice.setup->dmrs_AdditionalPosition = NULLP;
3725 DU_ALLOC(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition, sizeof(long));
3726 if(!dmrsDlCfg->choice.setup->dmrs_AdditionalPosition)
3728 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSDLPdschMapTypeA");
3731 *(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition) = DMRS_ADDITIONAL_POS;
3733 dmrsDlCfg->choice.setup->maxLength = NULLP;
3734 dmrsDlCfg->choice.setup->scramblingID0 = NULLP;
3735 dmrsDlCfg->choice.setup->scramblingID1 = NULLP;
3736 dmrsDlCfg->choice.setup->phaseTrackingRS = NULLP;
3741 /*******************************************************************
3743 * @brief Builds TCI states to add/modify list
3747 * Function : BuildTCIStatesToAddModList
3749 * Functionality:Builds TCI states to add/modify list
3752 * struct PDSCH_Config__tci_StatesToAddModList *tciStatesList
3754 * @return ROK - success
3757 * ****************************************************************/
3758 uint8_t BuildTCIStatesToAddModList(struct PDSCH_Config__tci_StatesToAddModList *tciStatesList)
3763 /*******************************************************************
3765 * @brief Builds PDSCH time domain allocation list
3769 * Function : BuildPdschTimeDomAllocList
3771 * Functionality: Builds PDSCH time domain allocation list
3774 * struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
3776 * @return ROK - success
3779 * ****************************************************************/
3780 uint8_t BuildPdschTimeDomAllocList
3782 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
3787 struct PDSCH_TimeDomainResourceAllocation *timeDomAlloc;
3789 timeDomAllocList->present = \
3790 PDSCH_Config__pdsch_TimeDomainAllocationList_PR_setup;
3792 timeDomAllocList->choice.setup = NULLP;
3793 DU_ALLOC(timeDomAllocList->choice.setup, \
3794 sizeof(struct PDSCH_TimeDomainResourceAllocationList));
3795 if(!timeDomAllocList->choice.setup)
3797 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
3802 timeDomAllocList->choice.setup->list.count = elementCnt;
3803 timeDomAllocList->choice.setup->list.size = \
3804 elementCnt * sizeof(struct PDSCH_TimeDomainResourceAllocation *);
3806 timeDomAllocList->choice.setup->list.array = NULLP;
3807 DU_ALLOC(timeDomAllocList->choice.setup->list.array, \
3808 timeDomAllocList->choice.setup->list.size);
3809 if(!timeDomAllocList->choice.setup->list.array)
3811 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
3815 for(idx = 0; idx < elementCnt; idx++)
3817 timeDomAllocList->choice.setup->list.array[idx] = NULLP;
3818 DU_ALLOC(timeDomAllocList->choice.setup->list.array[idx], \
3819 sizeof(struct PDSCH_TimeDomainResourceAllocation));
3820 if(!timeDomAllocList->choice.setup->list.array[idx])
3822 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
3828 timeDomAlloc = timeDomAllocList->choice.setup->list.array[idx];
3829 DU_ALLOC(timeDomAlloc->k0, sizeof(long));
3830 if(!timeDomAlloc->k0)
3832 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
3835 *(timeDomAlloc->k0) = 0;
3836 timeDomAlloc->mappingType = PDSCH_MAPPING_TYPE_A;
3837 timeDomAlloc->startSymbolAndLength = \
3838 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
3841 timeDomAlloc = timeDomAllocList->choice.setup->list.array[idx];
3842 DU_ALLOC(timeDomAlloc->k0, sizeof(long));
3843 if(!timeDomAlloc->k0)
3845 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
3848 *(timeDomAlloc->k0) = 1;
3849 timeDomAlloc->mappingType = PDSCH_MAPPING_TYPE_A;
3850 timeDomAlloc->startSymbolAndLength = calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
3855 /*******************************************************************
3857 * @brief Builds PDSCH PRB Bundling type
3861 * Function : BuildPdschPrbBundlingType
3863 * Functionality: Builds PDSCH PRB Bundling type
3866 * struct PDSCH_Config__prb_BundlingType *prbBndlType
3868 * @return ROK - success
3871 * ****************************************************************/
3872 uint8_t BuildPdschPrbBundlingType
3874 struct PDSCH_Config__prb_BundlingType *prbBndlType
3877 prbBndlType->present = PDSCH_Config__prb_BundlingType_PR_staticBundling;
3879 prbBndlType->choice.staticBundling = NULLP;
3880 DU_ALLOC(prbBndlType->choice.staticBundling, \
3881 sizeof(struct PDSCH_Config__prb_BundlingType__staticBundling));
3882 if(!prbBndlType->choice.staticBundling)
3884 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschPrbBundlingType");
3887 prbBndlType->choice.staticBundling->bundleSize = NULLP;
3892 /*******************************************************************
3894 * @brief Builds BWP DL dedicated PDSCH config
3898 * Function : BuildBWPDlDedPdschCfg
3900 * Functionality: Builds BWP DL dedicated PDSCH config
3902 * @params[in] struct PDSCH_Config *pdschCfg
3904 * @return ROK - success
3907 * ****************************************************************/
3908 uint8_t BuildBWPDlDedPdschCfg(struct PDSCH_Config *pdschCfg)
3910 pdschCfg->dataScramblingIdentityPDSCH = NULLP;
3912 pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA = NULLP;
3913 DU_ALLOC(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA, \
3914 sizeof(struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA));
3915 if(!pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
3917 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
3921 if(BuildDMRSDLPdschMapTypeA(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA) != ROK)
3926 pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeB = NULLP;
3927 pdschCfg->tci_StatesToAddModList = NULLP;
3928 pdschCfg->tci_StatesToReleaseList = NULLP;
3929 pdschCfg->vrb_ToPRB_Interleaver = NULLP;
3931 DU_ALLOC(pdschCfg->tci_StatesToAddModList, sizeof(struct PDSCH_Config__tci_StatesToAddModList));
3932 if(!pdschCfg->tci_StatesToAddModList)
3934 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
3937 if(BuildTCIStatesToAddModList(pdschCfg->tci_StatesToAddModList) != ROK)
3943 pdschCfg->resourceAllocation = RES_ALLOC_TYPE;
3945 pdschCfg->pdsch_TimeDomainAllocationList = NULLP;
3946 DU_ALLOC(pdschCfg->pdsch_TimeDomainAllocationList, \
3947 sizeof(struct PDSCH_Config__pdsch_TimeDomainAllocationList));
3948 if(!pdschCfg->pdsch_TimeDomainAllocationList)
3950 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
3954 if(BuildPdschTimeDomAllocList(pdschCfg->pdsch_TimeDomainAllocationList) != ROK)
3959 pdschCfg->pdsch_AggregationFactor = NULLP;
3960 pdschCfg->rateMatchPatternToAddModList = NULLP;
3961 pdschCfg->rateMatchPatternToReleaseList = NULLP;
3962 pdschCfg->rateMatchPatternGroup1 = NULLP;
3963 pdschCfg->rateMatchPatternGroup2 = NULLP;
3964 pdschCfg->rbg_Size = PDSCH_RBG_SIZE;
3965 pdschCfg->mcs_Table = NULLP;
3967 pdschCfg->maxNrofCodeWordsScheduledByDCI = NULLP;
3968 DU_ALLOC(pdschCfg->maxNrofCodeWordsScheduledByDCI, sizeof(long));
3969 if(!pdschCfg->maxNrofCodeWordsScheduledByDCI)
3971 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
3974 *(pdschCfg->maxNrofCodeWordsScheduledByDCI) = PDSCH_MAX_CODEWORD_SCH_BY_DCI;
3976 if(BuildPdschPrbBundlingType(&pdschCfg->prb_BundlingType) != ROK)
3981 pdschCfg->zp_CSI_RS_ResourceToAddModList = NULLP;
3982 pdschCfg->zp_CSI_RS_ResourceToReleaseList = NULLP;
3983 pdschCfg->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList = NULLP;
3984 pdschCfg->aperiodic_ZP_CSI_RS_ResourceSetsToReleaseList = NULLP;
3985 pdschCfg->sp_ZP_CSI_RS_ResourceSetsToAddModList = NULLP;
3986 pdschCfg->sp_ZP_CSI_RS_ResourceSetsToReleaseList = NULLP;
3987 pdschCfg->p_ZP_CSI_RS_ResourceSet = NULLP;
3992 /*******************************************************************
3994 * @brief Builds intitial DL BWP
3997 * Function : BuildInitialDlBWP
3999 * Functionality: Builds intitial DL BWP in spCellCfgDed
4001 * @params[in] BWP_DownlinkDedicated_t *dlBwp
4003 * @return ROK - success
4006 * ****************************************************************/
4007 uint8_t BuildInitialDlBWP(BWP_DownlinkDedicated_t *dlBwp)
4009 dlBwp->pdcch_Config = NULLP;
4010 DU_ALLOC(dlBwp->pdcch_Config, sizeof(struct BWP_DownlinkDedicated__pdcch_Config));
4011 if(!dlBwp->pdcch_Config)
4013 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
4016 dlBwp->pdcch_Config->present = BWP_DownlinkDedicated__pdcch_Config_PR_setup;
4018 dlBwp->pdcch_Config->choice.setup = NULLP;
4019 DU_ALLOC(dlBwp->pdcch_Config->choice.setup, sizeof(struct PDCCH_Config));
4020 if(!dlBwp->pdcch_Config->choice.setup)
4022 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
4025 if(BuildBWPDlDedPdcchCfg(dlBwp->pdcch_Config->choice.setup) != ROK)
4030 dlBwp->pdsch_Config = NULLP;
4031 DU_ALLOC(dlBwp->pdsch_Config, sizeof(struct BWP_DownlinkDedicated__pdsch_Config));
4032 if(!dlBwp->pdsch_Config)
4034 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
4037 dlBwp->pdsch_Config->present = BWP_DownlinkDedicated__pdsch_Config_PR_setup;
4039 dlBwp->pdsch_Config->choice.setup = NULLP;
4040 DU_ALLOC(dlBwp->pdsch_Config->choice.setup, sizeof(struct PDSCH_Config));
4041 if(!dlBwp->pdsch_Config->choice.setup)
4043 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
4047 if(BuildBWPDlDedPdschCfg(dlBwp->pdsch_Config->choice.setup) != ROK)
4052 dlBwp->sps_Config = NULLP;
4053 dlBwp->radioLinkMonitoringConfig = NULLP;
4057 /*******************************************************************
4059 * @brief Builds DMRS UL Pusch Mapping type A
4063 * Function : BuildDMRSULPuschMapTypeA
4065 * Functionality: Builds DMRS UL Pusch Mapping type A
4068 * struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg
4069 * @return ROK - success
4072 * ****************************************************************/
4073 uint8_t BuildDMRSULPuschMapTypeA
4075 struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg
4078 dmrsUlCfg->present = PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA_PR_setup;
4079 dmrsUlCfg->choice.setup= NULLP;
4080 DU_ALLOC(dmrsUlCfg->choice.setup, sizeof(DMRS_UplinkConfig_t));
4081 if(!dmrsUlCfg->choice.setup)
4083 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4087 dmrsUlCfg->choice.setup->dmrs_Type = NULLP;
4088 dmrsUlCfg->choice.setup->dmrs_AdditionalPosition = NULLP;
4089 DU_ALLOC(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition, sizeof(long));
4090 if(!dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
4092 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4095 *(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition) = DMRS_ADDITIONAL_POS;
4097 dmrsUlCfg->choice.setup->phaseTrackingRS = NULLP;
4098 dmrsUlCfg->choice.setup->maxLength = NULLP;
4099 dmrsUlCfg->choice.setup->transformPrecodingDisabled = NULLP;
4100 DU_ALLOC(dmrsUlCfg->choice.setup->transformPrecodingDisabled, \
4101 sizeof(struct DMRS_UplinkConfig__transformPrecodingDisabled));
4102 if(!dmrsUlCfg->choice.setup->transformPrecodingDisabled)
4104 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4108 dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0 = NULLP;
4109 DU_ALLOC(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0,\
4111 if(!dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0)
4113 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4116 *(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0) = SCRAMBLING_ID;
4118 dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID1 = NULLP;
4119 dmrsUlCfg->choice.setup->transformPrecodingEnabled = NULLP;
4123 /*******************************************************************
4125 * @brief Build PUSCH time domain allocation list
4129 * Function : BuildPuschTimeDomAllocList
4131 * Functionality: Build PUSCH time domain allocation list
4134 * struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList
4136 * @return ROK - success
4139 * ****************************************************************/
4140 uint8_t BuildPuschTimeDomAllocList
4142 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList
4147 PUSCH_TimeDomainResourceAllocation_t *timeDomAlloc;
4149 timeDomAllocList->present = PUSCH_Config__pusch_TimeDomainAllocationList_PR_setup;
4150 timeDomAllocList->choice.setup = NULLP;
4151 DU_ALLOC(timeDomAllocList->choice.setup, \
4152 sizeof(struct PUSCH_TimeDomainResourceAllocationList));
4153 if(!timeDomAllocList->choice.setup)
4155 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4160 timeDomAllocList->choice.setup->list.count = elementCnt;
4161 timeDomAllocList->choice.setup->list.size = \
4162 elementCnt * sizeof(PUSCH_TimeDomainResourceAllocation_t *);
4163 timeDomAllocList->choice.setup->list.array = NULLP;
4164 DU_ALLOC(timeDomAllocList->choice.setup->list.array, \
4165 timeDomAllocList->choice.setup->list.size);
4166 if(!timeDomAllocList->choice.setup->list.array)
4168 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4172 for(idx = 0; idx < elementCnt; idx++)
4174 timeDomAllocList->choice.setup->list.array[idx] = NULLP;
4175 DU_ALLOC(timeDomAllocList->choice.setup->list.array[idx],\
4176 sizeof(PUSCH_TimeDomainResourceAllocation_t));
4177 if(!timeDomAllocList->choice.setup->list.array[idx])
4179 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4185 timeDomAlloc = timeDomAllocList->choice.setup->list.array[idx];
4186 DU_ALLOC(timeDomAlloc->k2, sizeof(long));
4187 if(!timeDomAlloc->k2)
4189 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4192 *(timeDomAlloc->k2) = PUSCH_K2_CFG1;
4193 timeDomAlloc->mappingType = PUSCH_MAPPING_TYPE_A;
4194 timeDomAlloc->startSymbolAndLength = calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
4197 timeDomAlloc = timeDomAllocList->choice.setup->list.array[idx];
4198 DU_ALLOC(timeDomAlloc->k2, sizeof(long));
4199 if(!timeDomAlloc->k2)
4201 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4204 *(timeDomAlloc->k2) = PUSCH_K2_CFG2;
4205 timeDomAlloc->mappingType = PUSCH_MAPPING_TYPE_A;
4206 timeDomAlloc->startSymbolAndLength = calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
4211 /*******************************************************************
4213 * @brief Builds BWP UL dedicated PUSCH Config
4217 * Function : BuildBWPUlDedPuschCfg
4220 * Builds BWP UL dedicated PUSCH Config
4222 * @params[in] : PUSCH_Config_t *puschCfg
4224 * @return ROK - success
4227 * ****************************************************************/
4228 uint8_t BuildBWPUlDedPuschCfg(PUSCH_Config_t *puschCfg)
4230 puschCfg->dataScramblingIdentityPUSCH = NULLP;
4231 DU_ALLOC(puschCfg->dataScramblingIdentityPUSCH, sizeof(long));
4232 if(!puschCfg->dataScramblingIdentityPUSCH)
4234 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4237 *(puschCfg->dataScramblingIdentityPUSCH) = SCRAMBLING_ID;
4239 puschCfg->txConfig = NULLP;
4240 puschCfg->dmrs_UplinkForPUSCH_MappingTypeA = NULLP;
4241 DU_ALLOC(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA, \
4242 sizeof(struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA));
4243 if(!puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
4245 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4249 if(BuildDMRSULPuschMapTypeA(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA) != ROK)
4254 puschCfg->dmrs_UplinkForPUSCH_MappingTypeB = NULLP;
4255 puschCfg->pusch_PowerControl = NULLP;
4256 puschCfg->frequencyHopping = NULLP;
4257 puschCfg->frequencyHoppingOffsetLists = NULLP;
4258 puschCfg->resourceAllocation = RES_ALLOC_TYPE;
4260 puschCfg->pusch_TimeDomainAllocationList = NULLP;
4261 DU_ALLOC(puschCfg->pusch_TimeDomainAllocationList, \
4262 sizeof(struct PUSCH_Config__pusch_TimeDomainAllocationList));
4263 if(!puschCfg->pusch_TimeDomainAllocationList)
4265 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4269 if(BuildPuschTimeDomAllocList(puschCfg->pusch_TimeDomainAllocationList) != ROK)
4274 puschCfg->pusch_AggregationFactor = NULLP;
4275 puschCfg->mcs_Table = NULLP;
4276 puschCfg->mcs_TableTransformPrecoder = NULLP;
4277 puschCfg->transformPrecoder = NULLP;
4278 DU_ALLOC(puschCfg->transformPrecoder, sizeof(long));
4279 if(!puschCfg->transformPrecoder)
4281 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4284 *(puschCfg->transformPrecoder) = PUSCH_TRANSFORM_PRECODER;
4286 puschCfg->codebookSubset = NULLP;
4287 puschCfg->maxRank = NULLP;
4288 puschCfg->rbg_Size = NULLP;
4289 puschCfg->uci_OnPUSCH = NULLP;
4290 puschCfg->tp_pi2BPSK = NULLP;
4295 /*******************************************************************
4297 * @brief Builds BWP UL dedicated PUCCH Config
4301 * Function : BuildBWPUlDedPucchCfg
4304 * Builds BWP UL dedicated PUCCH Config
4306 * @params[in] : PUCCH_Config_t *pucchCfg
4308 * @return ROK - success
4311 * ****************************************************************/
4312 uint8_t BuildBWPUlDedPucchCfg(PUCCH_Config_t *pucchCfg)
4314 uint8_t arrIdx, elementCnt;
4316 DU_ALLOC(pucchCfg->dl_DataToUL_ACK, sizeof(struct PUCCH_Config__dl_DataToUL_ACK));
4317 if(pucchCfg->dl_DataToUL_ACK == NULLP)
4319 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
4324 pucchCfg->dl_DataToUL_ACK->list.count = elementCnt;
4325 pucchCfg->dl_DataToUL_ACK->list.size = elementCnt * sizeof(long *);
4326 DU_ALLOC(pucchCfg->dl_DataToUL_ACK->list.array, pucchCfg->dl_DataToUL_ACK->list.size);
4327 if(pucchCfg->dl_DataToUL_ACK->list.array == NULLP)
4329 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
4333 for(arrIdx = 0; arrIdx < pucchCfg->dl_DataToUL_ACK->list.count; arrIdx++)
4335 DU_ALLOC(pucchCfg->dl_DataToUL_ACK->list.array[arrIdx], sizeof(long));
4336 if(pucchCfg->dl_DataToUL_ACK->list.array[arrIdx] == NULLP)
4338 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
4344 *(pucchCfg->dl_DataToUL_ACK->list.array[arrIdx++]) = 1;
4345 *(pucchCfg->dl_DataToUL_ACK->list.array[arrIdx]) = 2;
4349 /*******************************************************************
4351 * @brief Fills SRS resource to add/modify list
4355 * Function : BuildSrsRsrcAddModList
4357 * Functionality: Fills SRS resource to add/modify list
4360 * @return ROK - success
4363 * ****************************************************************/
4364 uint8_t BuildSrsRsrcAddModList(struct SRS_Config__srs_ResourceToAddModList *resourceList)
4370 resourceList->list.count = elementCnt;
4371 resourceList->list.size = elementCnt * sizeof(SRS_Resource_t *);
4372 resourceList->list.array = NULLP;
4373 DU_ALLOC(resourceList->list.array, resourceList->list.size);
4374 if(!resourceList->list.array)
4376 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
4380 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
4382 DU_ALLOC(resourceList->list.array[rsrcIdx], sizeof(SRS_Resource_t));
4383 if(!resourceList->list.array[rsrcIdx])
4385 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
4391 resourceList->list.array[rsrcIdx]->srs_ResourceId = SRS_RSRC_ID;
4392 resourceList->list.array[rsrcIdx]->nrofSRS_Ports = SRS_Resource__nrofSRS_Ports_port1;
4393 resourceList->list.array[rsrcIdx]->transmissionComb.present = SRS_Resource__transmissionComb_PR_n2;
4395 resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2 = NULLP;
4396 DU_ALLOC(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2, \
4397 sizeof(struct SRS_Resource__transmissionComb__n2));
4398 if(!resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2)
4400 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
4403 resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2->combOffset_n2\
4404 = SRS_COMB_OFFSET_N2;
4405 resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2->cyclicShift_n2\
4406 = SRS_CYCLIC_SHIFT_N2;
4408 resourceList->list.array[rsrcIdx]->resourceMapping.startPosition = \
4410 resourceList->list.array[rsrcIdx]->resourceMapping.nrofSymbols = \
4411 SRS_Resource__resourceMapping__nrofSymbols_n1;
4412 resourceList->list.array[rsrcIdx]->resourceMapping.repetitionFactor = \
4413 SRS_Resource__resourceMapping__repetitionFactor_n1;
4415 resourceList->list.array[rsrcIdx]->freqDomainPosition = SRS_FREQ_DOM_POS;
4416 resourceList->list.array[rsrcIdx]->freqDomainShift = SRS_FREQ_DOM_SHIFT;
4417 resourceList->list.array[rsrcIdx]->freqHopping.c_SRS = C_SRS;
4418 resourceList->list.array[rsrcIdx]->freqHopping.b_SRS = B_SRS;
4419 resourceList->list.array[rsrcIdx]->freqHopping.b_hop = B_HOP;
4420 resourceList->list.array[rsrcIdx]->groupOrSequenceHopping = \
4421 SRS_Resource__groupOrSequenceHopping_neither;
4423 /* Setting resource type to aperiodic for intergration purposes */
4424 resourceList->list.array[rsrcIdx]->resourceType.present = \
4425 SRS_Resource__resourceType_PR_aperiodic;
4426 resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic = NULLP;
4427 DU_ALLOC(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic,
4428 sizeof(struct SRS_Resource__resourceType__aperiodic));
4429 if(!resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic)
4431 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
4434 resourceList->list.array[rsrcIdx]->sequenceId = SRS_SEQ_ID;
4439 /*******************************************************************
4441 * @brief Build SRS resource set Add/mod list
4445 * Function : BuildSrsRsrcSetAddModList
4447 * Functionality: Build SRS resource set Add/mod list
4450 * @return ROK - success
4453 * ****************************************************************/
4454 uint8_t BuildSrsRsrcSetAddModList
4456 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList
4462 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList;
4465 rsrcSetList->list.count = elementCnt;
4466 rsrcSetList->list.size = elementCnt * sizeof(SRS_ResourceSet_t *);
4467 rsrcSetList->list.array = NULLP;
4468 DU_ALLOC(rsrcSetList->list.array, rsrcSetList->list.size);
4469 if(!rsrcSetList->list.array)
4471 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4475 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
4477 DU_ALLOC(rsrcSetList->list.array[rSetIdx], sizeof(SRS_ResourceSet_t));
4478 if(!rsrcSetList->list.array[rSetIdx])
4480 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4486 rsrcSetList->list.array[rSetIdx]->srs_ResourceSetId = SRS_RSET_ID;
4488 /* Fill Resource Id list in resource set */
4489 rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList = NULLP;
4490 DU_ALLOC(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList,\
4491 sizeof(struct SRS_ResourceSet__srs_ResourceIdList));
4492 if(!rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
4494 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4499 rsrcIdList = rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
4500 rsrcIdList->list.count = elementCnt;
4501 rsrcIdList->list.size = elementCnt * sizeof(SRS_ResourceId_t *);
4502 rsrcIdList->list.array = NULLP;
4503 DU_ALLOC(rsrcIdList->list.array, rsrcIdList->list.size);
4504 if(!rsrcIdList->list.array)
4506 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4510 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count; rsrcIdx++)
4512 DU_ALLOC(rsrcIdList->list.array[rsrcIdx], sizeof(SRS_ResourceId_t));
4513 if(!rsrcIdList->list.array[rsrcIdx])
4515 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4521 *rsrcIdList->list.array[rsrcIdx] = SRS_RSRC_ID;
4523 /* Fill resource type */
4524 rsrcSetList->list.array[rSetIdx]->resourceType.present = \
4525 SRS_ResourceSet__resourceType_PR_aperiodic;
4527 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic = NULLP;
4528 DU_ALLOC(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic, \
4529 sizeof(struct SRS_ResourceSet__resourceType__aperiodic));
4530 if(!rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic)
4532 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
4535 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic->aperiodicSRS_ResourceTrigger \
4536 = APERIODIC_SRS_RESRC_TRIGGER;
4538 /* TODO : Fill values for below IEs as expected by Viavi */
4539 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic->csi_RS = NULLP;
4540 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic->slotOffset = NULLP;
4543 rsrcSetList->list.array[rSetIdx]->usage = SRS_ResourceSet__usage_codebook;
4544 rsrcSetList->list.array[rSetIdx]->alpha = NULLP;
4545 rsrcSetList->list.array[rSetIdx]->p0 = NULLP;
4546 rsrcSetList->list.array[rSetIdx]->pathlossReferenceRS = NULLP;
4547 rsrcSetList->list.array[rSetIdx]->srs_PowerControlAdjustmentStates = NULLP;
4552 /*******************************************************************
4554 * @brief Builds BWP UL dedicated SRS Config
4558 * Function : BuildBWPUlDedSrsCfg
4560 * Functionality: Builds BWP UL dedicated SRS Config
4562 * @params[in] SRS Config
4563 * @return ROK - success
4566 * ****************************************************************/
4567 uint8_t BuildBWPUlDedSrsCfg(SRS_Config_t *srsCfg)
4569 srsCfg->srs_ResourceSetToReleaseList = NULLP;
4570 srsCfg->srs_ResourceSetToAddModList = NULLP;
4571 DU_ALLOC(srsCfg->srs_ResourceSetToAddModList, \
4572 sizeof(struct SRS_Config__srs_ResourceSetToAddModList));
4573 if(!srsCfg->srs_ResourceSetToAddModList)
4575 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedSrsCfg");
4578 if(BuildSrsRsrcSetAddModList(srsCfg->srs_ResourceSetToAddModList) != ROK)
4583 srsCfg->srs_ResourceToReleaseList = NULLP;
4585 /* Resource to Add/Modify list */
4586 srsCfg->srs_ResourceToAddModList = NULLP;
4587 DU_ALLOC(srsCfg->srs_ResourceToAddModList, \
4588 sizeof(struct SRS_Config__srs_ResourceToAddModList));
4589 if(!srsCfg->srs_ResourceToAddModList)
4591 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedSrsCfg");
4595 if(BuildSrsRsrcAddModList(srsCfg->srs_ResourceToAddModList) != ROK)
4600 srsCfg->tpc_Accumulation = NULLP;
4607 /*******************************************************************
4609 * @brief Builds Pusch Serving cell Config
4613 * Function : BuildPuschSrvCellCfg
4615 * Functionality: Builds Pusch Serving cell Config
4617 * @params[in] struct UplinkConfig__pusch_ServingCellConfig *puschCfg
4619 * @return ROK - success
4622 * ****************************************************************/
4623 uint8_t BuildPuschSrvCellCfg(struct UplinkConfig__pusch_ServingCellConfig *puschCfg)
4625 puschCfg->present = UplinkConfig__pusch_ServingCellConfig_PR_setup;
4626 puschCfg->choice.setup = NULLP;
4627 DU_ALLOC(puschCfg->choice.setup, sizeof(struct PUSCH_ServingCellConfig));
4628 if(!puschCfg->choice.setup)
4630 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
4634 puschCfg->choice.setup->codeBlockGroupTransmission = NULLP;
4635 puschCfg->choice.setup->rateMatching = NULLP;
4636 puschCfg->choice.setup->xOverhead = NULLP;
4637 puschCfg->choice.setup->ext1 = NULLP;
4638 DU_ALLOC(puschCfg->choice.setup->ext1, sizeof(struct PUSCH_ServingCellConfig__ext1));
4639 if(!puschCfg->choice.setup->ext1)
4641 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
4645 puschCfg->choice.setup->ext1->maxMIMO_Layers = NULLP;
4646 DU_ALLOC(puschCfg->choice.setup->ext1->maxMIMO_Layers, sizeof(long));
4647 if(!puschCfg->choice.setup->ext1->maxMIMO_Layers)
4649 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
4652 *(puschCfg->choice.setup->ext1->maxMIMO_Layers) = PUSCH_MAX_MIMO_LAYERS;
4654 puschCfg->choice.setup->ext1->processingType2Enabled= NULLP;
4655 DU_ALLOC(puschCfg->choice.setup->ext1->processingType2Enabled,sizeof(BOOLEAN_t));
4656 if(!puschCfg->choice.setup->ext1->processingType2Enabled)
4658 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
4661 *(puschCfg->choice.setup->ext1->processingType2Enabled) = PUSCH_PROCESS_TYPE2_ENABLED;
4665 /*******************************************************************
4667 * @brief Builds inital UL BWP
4671 * Function : BuildInitialUlBWP
4673 * Functionality: Builds initial UL BWP
4675 * @params[in] BWP_UplinkDedicated_t *ulBwp
4676 * @return ROK - success
4679 * ****************************************************************/
4680 uint8_t BuildInitialUlBWP(BWP_UplinkDedicated_t *ulBwp)
4682 ulBwp->pucch_Config = NULLP;
4683 DU_ALLOC(ulBwp->pucch_Config, sizeof(struct BWP_UplinkDedicated__pucch_Config));
4684 if(!ulBwp->pucch_Config)
4686 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4690 ulBwp->pucch_Config->present = BWP_UplinkDedicated__pucch_Config_PR_setup;
4691 ulBwp->pucch_Config->choice.setup = NULLP;
4692 DU_ALLOC(ulBwp->pucch_Config->choice.setup, sizeof(PUCCH_Config_t));
4693 if(!ulBwp->pucch_Config->choice.setup)
4695 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4699 if(BuildBWPUlDedPucchCfg(ulBwp->pucch_Config->choice.setup) != ROK)
4704 /* Fill BWP UL dedicated PUSCH config */
4705 ulBwp->pusch_Config = NULLP;
4706 DU_ALLOC(ulBwp->pusch_Config, sizeof(struct BWP_UplinkDedicated__pusch_Config));
4707 if(!ulBwp->pusch_Config)
4709 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4713 ulBwp->pusch_Config->present = BWP_UplinkDedicated__pusch_Config_PR_setup;
4714 ulBwp->pusch_Config->choice.setup = NULLP;
4715 DU_ALLOC(ulBwp->pusch_Config->choice.setup, sizeof(PUSCH_Config_t));
4716 if(!ulBwp->pusch_Config->choice.setup)
4718 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4722 if(BuildBWPUlDedPuschCfg(ulBwp->pusch_Config->choice.setup) != ROK)
4727 ulBwp->configuredGrantConfig = NULLP;
4729 /* Fill BPW UL dedicated SRS config */
4730 ulBwp->srs_Config = NULLP;
4731 DU_ALLOC(ulBwp->srs_Config, sizeof(struct BWP_UplinkDedicated__srs_Config));
4732 if(!ulBwp->srs_Config)
4734 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4738 ulBwp->srs_Config->present = BWP_UplinkDedicated__srs_Config_PR_setup;
4739 ulBwp->srs_Config->choice.setup = NULLP;
4740 DU_ALLOC(ulBwp->srs_Config->choice.setup, sizeof(SRS_Config_t));
4741 if(!ulBwp->srs_Config->choice.setup)
4743 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
4747 if(BuildBWPUlDedSrsCfg(ulBwp->srs_Config->choice.setup) != ROK)
4752 ulBwp->beamFailureRecoveryConfig = NULLP;
4757 /*******************************************************************
4759 * @brief Builds UL config
4762 * Function : BuildUlCfg
4764 * Functionality: Builds UL config in spCellCfgDed
4766 * @params[in] UplinkConfig_t *ulCfg
4768 * @return ROK - success
4771 * ****************************************************************/
4772 uint8_t BuildUlCfg(UplinkConfig_t *ulCfg)
4774 ulCfg->initialUplinkBWP = NULLP;
4775 DU_ALLOC(ulCfg->initialUplinkBWP, sizeof(BWP_UplinkDedicated_t));
4776 if(!ulCfg->initialUplinkBWP)
4778 DU_LOG("\nERROR --> F1AP : Memory Allocation failed in BuildUlCfg");
4782 if(BuildInitialUlBWP(ulCfg->initialUplinkBWP) != ROK)
4787 ulCfg->uplinkBWP_ToReleaseList = NULLP;
4788 ulCfg->uplinkBWP_ToAddModList = NULLP;
4789 ulCfg->firstActiveUplinkBWP_Id = NULLP;
4790 DU_ALLOC(ulCfg->firstActiveUplinkBWP_Id, sizeof(BWP_Id_t));
4791 if(!ulCfg->firstActiveUplinkBWP_Id)
4793 DU_LOG("\nERROR --> F1AP : Memory Allocation failed in BuildUlCfg");
4796 *(ulCfg->firstActiveUplinkBWP_Id) = ACTIVE_UL_BWP_ID;
4798 ulCfg->pusch_ServingCellConfig = NULLP;
4799 DU_ALLOC(ulCfg->pusch_ServingCellConfig, \
4800 sizeof(struct UplinkConfig__pusch_ServingCellConfig));
4801 if(!ulCfg->pusch_ServingCellConfig)
4803 DU_LOG("\nERROR --> F1AP : Memory Allocation failed in BuildUlCfg");
4807 if(BuildPuschSrvCellCfg(ulCfg->pusch_ServingCellConfig) != ROK)
4812 ulCfg->carrierSwitching = NULLP;
4813 ulCfg->ext1 = NULLP;
4817 /*******************************************************************
4819 * @brief Builds PDSCH serving cell config
4822 * Function : BuildPdschSrvCellCfg
4824 * Functionality: Builds PDSCH serving cell config in spCellCfgDed
4826 * @params[in] struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg
4828 * @return ROK - success
4831 * ****************************************************************/
4832 uint8_t BuildPdschSrvCellCfg(struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg)
4834 pdschCfg->present = ServingCellConfig__pdsch_ServingCellConfig_PR_setup;
4835 pdschCfg->choice.setup = NULLP;
4836 DU_ALLOC(pdschCfg->choice.setup, sizeof( struct PDSCH_ServingCellConfig));
4837 if(!pdschCfg->choice.setup)
4839 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
4843 pdschCfg->choice.setup->codeBlockGroupTransmission = NULLP;
4844 pdschCfg->choice.setup->xOverhead = NULLP;
4845 pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH = NULLP;
4846 DU_ALLOC(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH, sizeof(long));
4847 if(!pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH)
4849 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
4852 *(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH)= PDSCH_NUM_HARQ_PROC;
4853 pdschCfg->choice.setup->pucch_Cell = NULLP;
4854 pdschCfg->choice.setup->ext1 = NULLP;
4859 /*******************************************************************
4861 * @brief Builds CSI Meas config
4864 * Function : BuildCsiMeasCfg
4866 * Functionality: Builds CSI Meas config in spCellCfgDed
4868 * @params[in] struct ServingCellConfig__csi_MeasConfig *csiMeasCfg
4870 * @return ROK - success
4873 * ****************************************************************/
4874 uint8_t BuildCsiMeasCfg(struct ServingCellConfig__csi_MeasConfig *csiMeasCfg)
4880 /*******************************************************************
4882 * @brief Builds Spcell config dedicated
4885 * Function : BuildSpCellCfgDed
4887 * Functionality: Builds sp cell config dedicated in spCellCfg
4889 * @params[in] ServingCellConfig_t srvCellCfg
4891 * @return ROK - success
4894 * ****************************************************************/
4895 uint8_t BuildSpCellCfgDed(ServingCellConfig_t *srvCellCfg)
4897 srvCellCfg->tdd_UL_DL_ConfigurationDedicated = NULLP;
4898 DU_ALLOC(srvCellCfg->tdd_UL_DL_ConfigurationDedicated, sizeof(TDD_UL_DL_ConfigDedicated_t));
4899 if(!srvCellCfg->tdd_UL_DL_ConfigurationDedicated)
4901 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4905 srvCellCfg->initialDownlinkBWP = NULLP;
4906 DU_ALLOC(srvCellCfg->initialDownlinkBWP, sizeof(BWP_DownlinkDedicated_t));
4907 if(!srvCellCfg->initialDownlinkBWP)
4909 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4913 if(BuildInitialDlBWP(srvCellCfg->initialDownlinkBWP) != ROK)
4915 DU_LOG("\nERROR --> F1AP : BuildInitialDlBWP failed");
4918 srvCellCfg->downlinkBWP_ToReleaseList = NULLP;
4919 srvCellCfg->downlinkBWP_ToAddModList = NULLP;
4921 srvCellCfg->firstActiveDownlinkBWP_Id = NULLP;
4922 DU_ALLOC(srvCellCfg->firstActiveDownlinkBWP_Id, sizeof(long));
4923 if(!srvCellCfg->firstActiveDownlinkBWP_Id)
4925 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4928 *(srvCellCfg->firstActiveDownlinkBWP_Id) = ACTIVE_DL_BWP_ID;
4930 srvCellCfg->bwp_InactivityTimer = NULLP;
4932 srvCellCfg->defaultDownlinkBWP_Id = NULLP;
4933 DU_ALLOC(srvCellCfg->defaultDownlinkBWP_Id, sizeof(long));
4934 if(!srvCellCfg->defaultDownlinkBWP_Id)
4936 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4939 *(srvCellCfg->defaultDownlinkBWP_Id) = ACTIVE_DL_BWP_ID;
4941 srvCellCfg->uplinkConfig = NULLP;
4942 DU_ALLOC(srvCellCfg->uplinkConfig, sizeof(UplinkConfig_t));
4943 if(!srvCellCfg->uplinkConfig)
4945 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4949 if(BuildUlCfg(srvCellCfg->uplinkConfig) != ROK)
4951 DU_LOG("\nERROR --> F1AP : BuildUlCfg failed");
4954 srvCellCfg->supplementaryUplink = NULLP;
4955 srvCellCfg->pdcch_ServingCellConfig = NULLP;
4957 srvCellCfg->pdsch_ServingCellConfig = NULLP;
4958 DU_ALLOC(srvCellCfg->pdsch_ServingCellConfig, sizeof(struct ServingCellConfig__pdsch_ServingCellConfig));
4959 if(!srvCellCfg->pdsch_ServingCellConfig)
4961 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4965 if(BuildPdschSrvCellCfg(srvCellCfg->pdsch_ServingCellConfig) != ROK)
4967 DU_LOG("\nERROR --> F1AP : BuildPdschSrvCellCfg failed");
4971 srvCellCfg->csi_MeasConfig = NULLP;
4973 DU_ALLOC(srvCellCfg->csi_MeasConfig, sizeof(struct ServingCellConfig__csi_MeasConfig))
4974 if(!srvCellCfg->csi_MeasConfig)
4976 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
4980 if(BuildCsiMeasCfg(srvCellCfg->csi_MeasConfig) != ROK)
4982 DU_LOG("\nF1AP : BuildCsiMeasCfg failed");
4986 srvCellCfg->sCellDeactivationTimer = NULLP;
4987 srvCellCfg->crossCarrierSchedulingConfig = NULLP;
4988 srvCellCfg->tag_Id = TAG_ID;
4989 srvCellCfg->dummy = NULLP;
4990 srvCellCfg->pathlossReferenceLinking = NULLP;
4991 srvCellCfg->servingCellMO = NULLP;
4992 srvCellCfg->ext1 = NULLP;
4996 /*******************************************************************
4998 * @brief Builds Spcell config
5002 * Function : BuildSpCellCfg
5004 * Functionality: Builds sp cell config in DuToCuRrcContainer
5006 * @params[in] SpCellConfig_t spCellCfg
5008 * @return ROK - success
5011 * ****************************************************************/
5012 uint8_t BuildSpCellCfg(SpCellConfig_t *spCellCfg)
5015 spCellCfg->servCellIndex = NULLP;
5016 DU_ALLOC(spCellCfg->servCellIndex, sizeof(long));
5017 if(!spCellCfg->servCellIndex)
5019 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
5022 *(spCellCfg->servCellIndex) = SERV_CELL_IDX;
5024 spCellCfg->reconfigurationWithSync = NULLP;
5025 spCellCfg->rlf_TimersAndConstants = NULLP;
5026 spCellCfg->rlmInSyncOutOfSyncThreshold = NULLP;
5027 DU_ALLOC(spCellCfg->rlmInSyncOutOfSyncThreshold, sizeof(long));
5028 if(!spCellCfg->rlmInSyncOutOfSyncThreshold)
5030 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
5033 *(spCellCfg->rlmInSyncOutOfSyncThreshold) = RLM_SYNC_OUT_SYNC_THRESHOLD;
5035 spCellCfg->spCellConfigDedicated = NULLP;
5036 DU_ALLOC(spCellCfg->spCellConfigDedicated, sizeof(ServingCellConfig_t));
5037 if(!spCellCfg->spCellConfigDedicated)
5039 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
5042 if(BuildSpCellCfgDed(spCellCfg->spCellConfigDedicated) != ROK)
5044 DU_LOG("\nERROR --> F1AP : BuildSpCellCfgDed failed");
5049 /*******************************************************************
5051 * @brief Builds Phy cell group config
5055 * Function : BuildPhyCellGrpCfg
5057 * Functionality: Builds Phy cell group config in DuToCuRrcContainer
5059 * @params[in] PhysicalCellGroupConfig_t *phyCellGrpCfg
5061 * @return ROK - success
5064 * ****************************************************************/
5065 uint8_t BuildPhyCellGrpCfg(PhysicalCellGroupConfig_t *phyCellGrpCfg)
5067 phyCellGrpCfg->harq_ACK_SpatialBundlingPUCCH = NULLP;
5068 phyCellGrpCfg->harq_ACK_SpatialBundlingPUSCH = NULLP;
5070 phyCellGrpCfg->p_NR_FR1 = NULLP;
5071 DU_ALLOC(phyCellGrpCfg->p_NR_FR1, sizeof(long));
5072 if(!phyCellGrpCfg->p_NR_FR1)
5074 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildPhyCellGrpCfg");
5077 *(phyCellGrpCfg->p_NR_FR1) = P_NR_FR1;
5078 phyCellGrpCfg->pdsch_HARQ_ACK_Codebook = PDSCH_HARQ_ACK_CODEBOOK;
5079 phyCellGrpCfg->tpc_SRS_RNTI = NULLP;
5080 phyCellGrpCfg->tpc_PUCCH_RNTI = NULLP;
5081 phyCellGrpCfg->tpc_PUSCH_RNTI = NULLP;
5082 phyCellGrpCfg->sp_CSI_RNTI = NULLP;
5083 phyCellGrpCfg->cs_RNTI = NULLP;
5084 phyCellGrpCfg->ext1 = NULLP;
5085 phyCellGrpCfg->ext2 = NULLP;
5089 /*******************************************************************
5091 * @brief Builds Mac cell group config
5095 * Function : BuildMacCellGrpCfg
5097 * Functionality: Builds Mac cell group config in DuToCuRrcContainer
5099 * @params[in] MAC_CellGroupConfig_t *macCellGrpCfg
5101 * @return ROK - success
5104 * ****************************************************************/
5105 uint8_t BuildMacCellGrpCfg(MAC_CellGroupConfig_t *macCellGrpCfg)
5107 macCellGrpCfg->drx_Config = NULLP;
5108 macCellGrpCfg->schedulingRequestConfig = NULLP;
5109 DU_ALLOC(macCellGrpCfg->schedulingRequestConfig, sizeof(struct SchedulingRequestConfig));
5110 if(!macCellGrpCfg->schedulingRequestConfig)
5112 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
5116 if(BuildSchedulingReqConfig(macCellGrpCfg->schedulingRequestConfig) != ROK)
5118 DU_LOG("\nERROR --> F1AP : BuildSchedulingReqConfig failed");
5122 macCellGrpCfg->bsr_Config = NULLP;
5123 DU_ALLOC(macCellGrpCfg->bsr_Config, sizeof(struct BSR_Config));
5124 if(!macCellGrpCfg->bsr_Config)
5126 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
5130 if(BuildBsrConfig(macCellGrpCfg->bsr_Config) != ROK)
5132 DU_LOG("\nERROR --> F1AP : BuildBsrConfig failed");
5136 macCellGrpCfg->tag_Config = NULLP;
5137 DU_ALLOC(macCellGrpCfg->tag_Config, sizeof(struct TAG_Config));
5138 if(!macCellGrpCfg->tag_Config)
5140 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
5144 if(BuildTagConfig(macCellGrpCfg->tag_Config) != ROK)
5146 DU_LOG("\nERROR --> F1AP : BuildTagConfig failed");
5150 macCellGrpCfg->phr_Config = NULLP;
5151 DU_ALLOC(macCellGrpCfg->phr_Config, sizeof(struct MAC_CellGroupConfig__phr_Config));
5152 if(!macCellGrpCfg->phr_Config)
5154 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
5158 if(BuildPhrConfig(macCellGrpCfg->phr_Config) != ROK)
5160 DU_LOG("\nERROR --> F1AP : BuildPhrConfig failed");
5164 macCellGrpCfg->skipUplinkTxDynamic = false;
5165 macCellGrpCfg->ext1 = NULLP;
5169 /*******************************************************************
5171 * @brief Frees memeory allocated for SearchSpcToAddModList
5175 * Function : FreeSearchSpcToAddModList
5177 * Functionality: Deallocating memory of SearchSpcToAddModList
5179 * @params[in] struct PDCCH_Config__searchSpacesToAddModList *searchSpcList
5183 4221 * ****************************************************************/
5184 void FreeSearchSpcToAddModList(struct PDCCH_Config__searchSpacesToAddModList *searchSpcList)
5188 struct SearchSpace *searchSpc=NULLP;
5190 if(searchSpcList->list.array)
5192 if(searchSpcList->list.array[idx2])
5194 searchSpc = searchSpcList->list.array[idx2];
5195 if(searchSpc->controlResourceSetId)
5197 if(searchSpc->monitoringSlotPeriodicityAndOffset)
5199 if(searchSpc->monitoringSymbolsWithinSlot)
5201 if(searchSpc->monitoringSymbolsWithinSlot->buf)
5203 if(searchSpc->nrofCandidates)
5205 if(searchSpc->searchSpaceType)
5207 DU_FREE(searchSpc->searchSpaceType->choice.ue_Specific,\
5208 sizeof(struct SearchSpace__searchSpaceType__ue_Specific));
5209 DU_FREE(searchSpc->searchSpaceType, sizeof(struct
5210 SearchSpace__searchSpaceType));
5212 DU_FREE(searchSpc->nrofCandidates,
5213 sizeof(struct SearchSpace__nrofCandidates));
5215 DU_FREE(searchSpc->monitoringSymbolsWithinSlot->buf, \
5216 searchSpc->monitoringSymbolsWithinSlot->size);
5218 DU_FREE(searchSpc->monitoringSymbolsWithinSlot,
5219 sizeof(BIT_STRING_t));
5221 DU_FREE(searchSpc->monitoringSlotPeriodicityAndOffset, \
5222 sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
5224 DU_FREE(searchSpc->controlResourceSetId,
5225 sizeof(ControlResourceSetId_t));
5228 for(idx1 = 0; idx1 < searchSpcList->list.count; idx1++)
5230 DU_FREE(searchSpcList->list.array[idx1],
5231 sizeof(struct SearchSpace));
5233 DU_FREE(searchSpcList->list.array,searchSpcList->list.size);
5236 /*******************************************************************
5238 * @brief Frees memory allocated for PdschTimeDomAllocList
5242 * Function : FreePdschTimeDomAllocList
5244 * Functionality: Deallocating memory of PdschTimeDomAllocList
5246 * @params[in] struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
5250 * ****************************************************************/
5251 void FreePdschTimeDomAllocList( struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList)
5255 if(timeDomAllocList->choice.setup)
5257 if(timeDomAllocList->choice.setup->list.array)
5259 for(idx1 = 0; idx1 <timeDomAllocList->choice.setup->list.count ; idx1++)
5261 DU_FREE(timeDomAllocList->choice.setup->list.array[idx1]->k0, sizeof(long));
5262 DU_FREE(timeDomAllocList->choice.setup->list.array[idx1],
5263 sizeof(struct PDSCH_TimeDomainResourceAllocation));
5265 DU_FREE(timeDomAllocList->choice.setup->list.array, \
5266 timeDomAllocList->choice.setup->list.size);
5268 DU_FREE(timeDomAllocList->choice.setup,\
5269 sizeof(struct PDSCH_TimeDomainResourceAllocationList));
5272 /*******************************************************************
5274 * @brief Frees memory allocated for PuschTimeDomAllocList
5278 * Function : FreePuschTimeDomAllocList
5280 * Functionality: Deallocating memory of PuschTimeDomAllocList
5282 * @params[in] PUSCH_Config_t *puschCfg
5286 * ****************************************************************/
5287 void FreePuschTimeDomAllocList(PUSCH_Config_t *puschCfg)
5289 uint8_t rsrcListIdx=0;
5290 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList_t=NULLP;
5292 if(puschCfg->pusch_TimeDomainAllocationList)
5294 timeDomAllocList_t=puschCfg->pusch_TimeDomainAllocationList;
5295 if(timeDomAllocList_t->choice.setup)
5297 if(timeDomAllocList_t->choice.setup->list.array)
5299 for(rsrcListIdx = 0; rsrcListIdx<timeDomAllocList_t->choice.setup->list.count; rsrcListIdx++)
5301 DU_FREE(timeDomAllocList_t->choice.setup->list.array[rsrcListIdx]->k2, sizeof(long));
5302 DU_FREE(timeDomAllocList_t->choice.setup->list.array[rsrcListIdx],\
5303 sizeof(PUSCH_TimeDomainResourceAllocation_t));
5305 DU_FREE(timeDomAllocList_t->choice.setup->list.array, \
5306 timeDomAllocList_t->choice.setup->list.size);
5308 DU_FREE(timeDomAllocList_t->choice.setup, \
5309 sizeof(struct PUSCH_TimeDomainResourceAllocationList));
5311 DU_FREE(puschCfg->transformPrecoder, sizeof(long));
5312 DU_FREE(puschCfg->pusch_TimeDomainAllocationList, \
5313 sizeof(struct PUSCH_Config__pusch_TimeDomainAllocationList));
5317 /*******************************************************************
5319 * @brief Frees memory allocated for InitialUlBWP
5323 * Function : FreeInitialUlBWP
5325 * Functionality: Deallocating memory of InitialUlBWP
5327 * @params[in] BWP_UplinkDedicated_t *ulBwp
5331 * ****************************************************************/
5332 void FreeInitialUlBWP(BWP_UplinkDedicated_t *ulBwp)
5334 uint8_t rSetIdx, rsrcIdx, k1Idx;
5335 SRS_Config_t *srsCfg = NULLP;
5336 PUSCH_Config_t *puschCfg = NULLP;
5337 PUCCH_Config_t *pucchCfg = NULLP;
5338 struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg = NULLP;
5339 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList = NULLP;
5340 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList = NULLP;
5341 struct SRS_Config__srs_ResourceToAddModList *resourceList = NULLP;
5343 if(ulBwp->pucch_Config)
5345 if(ulBwp->pucch_Config->choice.setup)
5347 pucchCfg = ulBwp->pucch_Config->choice.setup;
5348 if(pucchCfg->dl_DataToUL_ACK)
5350 if(pucchCfg->dl_DataToUL_ACK->list.array)
5352 for(k1Idx = 0; k1Idx < pucchCfg->dl_DataToUL_ACK->list.count; k1Idx++)
5354 DU_FREE(pucchCfg->dl_DataToUL_ACK->list.array[k1Idx], sizeof(long));
5356 DU_FREE(pucchCfg->dl_DataToUL_ACK->list.array, pucchCfg->dl_DataToUL_ACK->list.size);
5358 DU_FREE(pucchCfg->dl_DataToUL_ACK, sizeof(struct PUCCH_Config__dl_DataToUL_ACK));
5360 DU_FREE(ulBwp->pucch_Config->choice.setup, sizeof(PUCCH_Config_t));
5362 DU_FREE(ulBwp->pucch_Config, sizeof(struct BWP_UplinkDedicated__pucch_Config));
5365 if(ulBwp->pusch_Config)
5367 if(ulBwp->pusch_Config->choice.setup)
5369 puschCfg=ulBwp->pusch_Config->choice.setup;
5370 if(puschCfg->dataScramblingIdentityPUSCH)
5372 if(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
5374 FreePuschTimeDomAllocList(puschCfg);
5375 dmrsUlCfg=puschCfg->dmrs_UplinkForPUSCH_MappingTypeA;
5376 if(dmrsUlCfg->choice.setup)
5378 if(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
5380 if(dmrsUlCfg->choice.setup->transformPrecodingDisabled)
5382 DU_FREE(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0,\
5384 DU_FREE(dmrsUlCfg->choice.setup->transformPrecodingDisabled,
5385 sizeof(struct DMRS_UplinkConfig__transformPrecodingDisabled));
5387 DU_FREE(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition,
5390 DU_FREE(dmrsUlCfg->choice.setup,sizeof(DMRS_UplinkConfig_t));
5392 DU_FREE(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA, \
5393 sizeof(struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA));
5395 DU_FREE(puschCfg->dataScramblingIdentityPUSCH, sizeof(long));
5397 DU_FREE(ulBwp->pusch_Config->choice.setup, sizeof(PUSCH_Config_t));
5399 DU_FREE(ulBwp->pusch_Config, sizeof(struct BWP_UplinkDedicated__pusch_Config));
5401 /* Free SRS-Config */
5402 if(ulBwp->srs_Config)
5404 if(ulBwp->srs_Config->choice.setup)
5406 srsCfg = ulBwp->srs_Config->choice.setup;
5408 /* Free Resource Set to add/mod list */
5409 if(srsCfg->srs_ResourceSetToAddModList)
5411 rsrcSetList = srsCfg->srs_ResourceSetToAddModList;
5412 if(rsrcSetList->list.array)
5416 /* Free SRS resource Id list in this SRS resource set */
5417 if(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
5419 rsrcIdList = rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
5421 if(rsrcIdList->list.array)
5423 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count; rsrcIdx++)
5425 DU_FREE(rsrcIdList->list.array[rsrcIdx], sizeof(SRS_ResourceId_t));
5427 DU_FREE(rsrcIdList->list.array, rsrcIdList->list.size);
5429 DU_FREE(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList,\
5430 sizeof(struct SRS_ResourceSet__srs_ResourceIdList));
5433 /* Free resource type info for this SRS resource set */
5434 DU_FREE(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic, \
5435 sizeof(struct SRS_ResourceSet__resourceType__aperiodic));
5437 /* Free memory for each resource set */
5438 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
5440 DU_FREE(rsrcSetList->list.array[rSetIdx], sizeof(SRS_ResourceSet_t));
5442 DU_FREE(rsrcSetList->list.array, rsrcSetList->list.size);
5444 DU_FREE(srsCfg->srs_ResourceSetToAddModList, \
5445 sizeof(struct SRS_Config__srs_ResourceSetToAddModList));
5448 /* Free resource to add/modd list */
5449 if(srsCfg->srs_ResourceToAddModList)
5451 resourceList = srsCfg->srs_ResourceToAddModList;
5452 if(resourceList->list.array)
5455 DU_FREE(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2,\
5456 sizeof(struct SRS_Resource__transmissionComb__n2));
5457 DU_FREE(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic,\
5458 sizeof(struct SRS_Resource__resourceType__aperiodic));
5460 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
5462 DU_FREE(resourceList->list.array[rsrcIdx], sizeof(SRS_Resource_t));
5464 DU_FREE(resourceList->list.array, resourceList->list.size);
5466 DU_FREE(srsCfg->srs_ResourceToAddModList, \
5467 sizeof(struct SRS_Config__srs_ResourceToAddModList));
5470 DU_FREE(ulBwp->srs_Config->choice.setup, sizeof(SRS_Config_t));
5472 DU_FREE(ulBwp->srs_Config, sizeof(struct BWP_UplinkDedicated__srs_Config));
5476 /*******************************************************************
5478 * @brief Frees memory allocated for initialUplinkBWP
5482 * Function : FreeinitialUplinkBWP
5484 * Functionality: Deallocating memory of initialUplinkBWP
5486 * @params[in] UplinkConfig_t *ulCfg
5491 * ****************************************************************/
5492 void FreeinitialUplinkBWP(UplinkConfig_t *ulCfg)
5494 BWP_UplinkDedicated_t *ulBwp=NULLP;
5495 struct UplinkConfig__pusch_ServingCellConfig *puschCfg=NULLP;
5497 if(ulCfg->initialUplinkBWP)
5499 ulBwp=ulCfg->initialUplinkBWP;
5500 if(ulCfg->firstActiveUplinkBWP_Id)
5502 if(ulCfg->pusch_ServingCellConfig)
5504 puschCfg=ulCfg->pusch_ServingCellConfig;
5505 if(puschCfg->choice.setup)
5507 if(puschCfg->choice.setup->ext1)
5509 DU_FREE(puschCfg->choice.setup->ext1->\
5510 processingType2Enabled,sizeof(BOOLEAN_t));
5511 DU_FREE(puschCfg->choice.setup->ext1->\
5512 maxMIMO_Layers,sizeof(long));
5513 DU_FREE(puschCfg->choice.setup->ext1, \
5514 sizeof(struct PUSCH_ServingCellConfig__ext1));
5516 DU_FREE(puschCfg->choice.setup, sizeof(struct PUSCH_ServingCellConfig));
5518 DU_FREE(ulCfg->pusch_ServingCellConfig, sizeof(struct UplinkConfig__pusch_ServingCellConfig));
5520 DU_FREE(ulCfg->firstActiveUplinkBWP_Id, sizeof(BWP_Id_t));
5522 FreeInitialUlBWP(ulBwp);
5523 DU_FREE(ulCfg->initialUplinkBWP, sizeof(BWP_UplinkDedicated_t));
5526 /*******************************************************************
5528 * @brief Frees emmory allocated for BWPDlDedPdschCfg
5532 * Function : FreeBWPDlDedPdschCfg
5534 * Functionality: Deallocating memory of BWPDlDedPdschCfg
5536 * @params[in] BWP_DownlinkDedicated_t *dlBwp
5541 * ****************************************************************/
5542 void FreeBWPDlDedPdschCfg(BWP_DownlinkDedicated_t *dlBwp)
5544 struct PDSCH_Config *pdschCfg=NULLP;
5545 struct PDSCH_Config__prb_BundlingType *prbBndlType=NULLP;
5546 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList=NULLP;
5547 struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg=NULLP;
5549 if(dlBwp->pdsch_Config->choice.setup)
5551 pdschCfg=dlBwp->pdsch_Config->choice.setup;
5552 if(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
5554 if(pdschCfg->pdsch_TimeDomainAllocationList)
5556 timeDomAllocList=pdschCfg->pdsch_TimeDomainAllocationList;
5557 if(pdschCfg->maxNrofCodeWordsScheduledByDCI)
5559 prbBndlType=&pdschCfg->prb_BundlingType;
5560 DU_FREE(prbBndlType->choice.staticBundling,\
5561 sizeof(struct PDSCH_Config__prb_BundlingType__staticBundling));
5562 DU_FREE(pdschCfg->maxNrofCodeWordsScheduledByDCI, sizeof(long));
5564 FreePdschTimeDomAllocList(timeDomAllocList);
5565 DU_FREE(pdschCfg->pdsch_TimeDomainAllocationList, \
5566 sizeof(struct PDSCH_Config__pdsch_TimeDomainAllocationList));
5568 dmrsDlCfg=pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA;
5569 if(dmrsDlCfg->choice.setup)
5571 DU_FREE(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition,
5573 DU_FREE(dmrsDlCfg->choice.setup, sizeof(struct DMRS_DownlinkConfig));
5575 DU_FREE(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA, \
5576 sizeof(struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA));
5578 DU_FREE(dlBwp->pdsch_Config->choice.setup, sizeof(struct PDSCH_Config));
5581 /*******************************************************************
5583 * @brief Frees emmory allocated for BWPDlDedPdcchCfg
5587 * Function : FreeBWPDlDedPdcchCfg
5589 * Functionality: Deallocating memory of BWPDlDedPdcchCfg
5591 * @params[in] BWP_DownlinkDedicated_t *dlBwp
5596 * ****************************************************************/
5597 void FreeBWPDlDedPdcchCfg(BWP_DownlinkDedicated_t *dlBwp)
5601 struct PDCCH_Config *pdcchCfg=NULLP;
5602 struct ControlResourceSet *controlRSet=NULLP;
5603 struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList=NULLP;
5605 if(dlBwp->pdcch_Config->choice.setup)
5607 pdcchCfg=dlBwp->pdcch_Config->choice.setup;
5608 if(pdcchCfg->controlResourceSetToAddModList)
5610 controlRSetList = pdcchCfg->controlResourceSetToAddModList;
5611 if(controlRSetList->list.array)
5613 controlRSet = controlRSetList->list.array[idx2];
5616 if(controlRSet->frequencyDomainResources.buf)
5618 if(controlRSet->pdcch_DMRS_ScramblingID)
5620 if(pdcchCfg->searchSpacesToAddModList)
5622 FreeSearchSpcToAddModList(pdcchCfg->searchSpacesToAddModList);
5623 DU_FREE(pdcchCfg->searchSpacesToAddModList, \
5624 sizeof(struct PDCCH_Config__searchSpacesToAddModList));
5626 DU_FREE(controlRSet->pdcch_DMRS_ScramblingID, sizeof(long));
5628 DU_FREE(controlRSet->frequencyDomainResources.buf, \
5629 controlRSet->frequencyDomainResources.size);
5632 for(idx1 = 0; idx1 <controlRSetList->list.count; idx1++)
5634 DU_FREE(controlRSetList->list.array[idx1], sizeof(struct ControlResourceSet));
5636 DU_FREE(controlRSetList->list.array, controlRSetList->list.size);
5638 DU_FREE(pdcchCfg->controlResourceSetToAddModList, \
5639 sizeof(struct PDCCH_Config__controlResourceSetToAddModList));
5641 DU_FREE(dlBwp->pdcch_Config->choice.setup, sizeof(struct PDCCH_Config));
5645 /*******************************************************************
5647 * @brief Frees emmory allocated for DUToCURRCContainer
5651 * Function : FreeMemDuToCuRrcCont
5653 * Functionality: Deallocating memory of DuToCuRrcContainer
5655 * @params[in] DuToCuRRCContainer, DuToCuRRCContainer
5657 * @return ROK - success
5660 * ****************************************************************/
5661 uint8_t FreeMemDuToCuRrcCont(CellGroupConfigRrc_t *cellGrpCfg)
5664 SpCellConfig_t *spCellCfg=NULLP;
5665 ServingCellConfig_t *srvCellCfg=NULLP;
5666 BWP_DownlinkDedicated_t *dlBwp=NULLP;
5667 MAC_CellGroupConfig_t *macCellGrpCfg=NULLP;
5668 PhysicalCellGroupConfig_t *phyCellGrpCfg=NULLP;
5669 struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList=NULLP;
5670 struct RLC_Config *rlcConfig=NULLP;
5671 struct LogicalChannelConfig *macLcConfig=NULLP;
5672 struct SchedulingRequestConfig *schedulingRequestConfig=NULLP;
5673 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList=NULLP;
5674 struct TAG_Config *tagConfig=NULLP;
5675 struct TAG_Config__tag_ToAddModList *tagList=NULLP;
5676 struct MAC_CellGroupConfig__phr_Config *phrConfig=NULLP;
5677 struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg=NULLP;
5679 rlcBearerList = cellGrpCfg->rlc_BearerToAddModList;
5682 if(rlcBearerList->list.array)
5684 for(idx=0; idx<rlcBearerList->list.count; idx++)
5686 if(rlcBearerList->list.array[idx])
5688 rlcConfig = rlcBearerList->list.array[idx]->rlc_Config;
5689 macLcConfig = rlcBearerList->list.array[idx]->mac_LogicalChannelConfig;
5692 if(rlcConfig->choice.am)
5694 DU_FREE(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
5695 DU_FREE(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
5696 DU_FREE(rlcConfig->choice.am, sizeof(struct RLC_Config__am));
5698 DU_FREE(rlcConfig, sizeof(struct RLC_Config));
5700 DU_FREE(rlcBearerList->list.array[idx]->servedRadioBearer, sizeof(struct RLC_BearerConfig__servedRadioBearer));
5703 if(macLcConfig->ul_SpecificParameters)
5705 DU_FREE(macLcConfig->ul_SpecificParameters->schedulingRequestID, sizeof(SchedulingRequestId_t));
5706 DU_FREE(macLcConfig->ul_SpecificParameters->logicalChannelGroup, sizeof(long));
5707 DU_FREE(macLcConfig->ul_SpecificParameters, sizeof(struct LogicalChannelConfig__ul_SpecificParameters));
5709 DU_FREE(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig, sizeof(struct LogicalChannelConfig));
5711 DU_FREE(rlcBearerList->list.array[idx], sizeof(struct RLC_BearerConfig));
5714 DU_FREE(rlcBearerList->list.array, rlcBearerList->list.size);
5716 DU_FREE(cellGrpCfg->rlc_BearerToAddModList, sizeof(struct CellGroupConfigRrc__rlc_BearerToAddModList));
5719 macCellGrpCfg = cellGrpCfg->mac_CellGroupConfig;
5722 schedulingRequestConfig = macCellGrpCfg->schedulingRequestConfig;
5723 if(schedulingRequestConfig)
5725 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
5728 if(schReqList->list.array)
5730 for(idx=0;idx<schReqList->list.count; idx++)
5732 if(schReqList->list.array[idx])
5734 DU_FREE(schReqList->list.array[idx]->sr_ProhibitTimer, sizeof(long));
5735 DU_FREE(schReqList->list.array[idx], sizeof(struct SchedulingRequestToAddMod));
5738 DU_FREE(schReqList->list.array, schReqList->list.size);
5740 DU_FREE(schedulingRequestConfig->schedulingRequestToAddModList,\
5741 sizeof(struct SchedulingRequestConfig__schedulingRequestToAddModList)); }
5742 DU_FREE(macCellGrpCfg->schedulingRequestConfig, sizeof(struct SchedulingRequestConfig));
5744 if(macCellGrpCfg->bsr_Config)
5746 DU_FREE(macCellGrpCfg->bsr_Config, sizeof(struct BSR_Config));
5748 tagConfig = macCellGrpCfg->tag_Config;
5751 tagList = tagConfig->tag_ToAddModList;
5754 if(tagList->list.array)
5756 for(idx=0; idx<tagList->list.count; idx++)
5758 DU_FREE(tagList->list.array[idx], sizeof(struct TAG));
5760 DU_FREE(tagList->list.array, tagList->list.size);
5762 DU_FREE(tagConfig->tag_ToAddModList, sizeof(struct TAG_Config__tag_ToAddModList));
5764 DU_FREE(tagConfig, sizeof(struct TAG_Config));
5767 phrConfig = macCellGrpCfg->phr_Config;
5770 DU_FREE(phrConfig->choice.setup, sizeof(struct PHR_Config));
5771 DU_FREE(phrConfig, sizeof(struct MAC_CellGroupConfig__phr_Config));
5774 DU_FREE(macCellGrpCfg, sizeof(MAC_CellGroupConfig_t));
5777 phyCellGrpCfg = cellGrpCfg->physicalCellGroupConfig;
5780 DU_FREE(phyCellGrpCfg->p_NR_FR1, sizeof(long));
5781 DU_FREE(phyCellGrpCfg, sizeof(PhysicalCellGroupConfig_t));
5784 spCellCfg = cellGrpCfg->spCellConfig;
5787 if(spCellCfg->servCellIndex)
5789 if(spCellCfg->rlmInSyncOutOfSyncThreshold)
5791 if(spCellCfg->spCellConfigDedicated)
5793 srvCellCfg = spCellCfg->spCellConfigDedicated;
5794 if(srvCellCfg->tdd_UL_DL_ConfigurationDedicated)
5796 if(srvCellCfg->initialDownlinkBWP)
5798 dlBwp = srvCellCfg->initialDownlinkBWP;
5799 if(srvCellCfg->firstActiveDownlinkBWP_Id)
5801 if(srvCellCfg->defaultDownlinkBWP_Id)
5803 if(srvCellCfg->uplinkConfig)
5805 if(srvCellCfg->pdsch_ServingCellConfig)
5807 pdschCfg= srvCellCfg->pdsch_ServingCellConfig;
5808 if(pdschCfg->choice.setup)
5810 DU_FREE(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH,sizeof(long));
5811 DU_FREE(pdschCfg->choice.setup, sizeof( struct PDSCH_ServingCellConfig));
5813 DU_FREE(srvCellCfg->pdsch_ServingCellConfig, sizeof(struct
5814 ServingCellConfig__pdsch_ServingCellConfig));
5816 FreeinitialUplinkBWP(srvCellCfg->uplinkConfig);
5817 DU_FREE(srvCellCfg->uplinkConfig, sizeof(UplinkConfig_t));
5819 DU_FREE(srvCellCfg->defaultDownlinkBWP_Id, sizeof(long));
5821 DU_FREE(srvCellCfg->firstActiveDownlinkBWP_Id, sizeof(long));
5823 if(dlBwp->pdcch_Config)
5825 if(dlBwp->pdsch_Config)
5827 FreeBWPDlDedPdschCfg(dlBwp);
5828 DU_FREE(dlBwp->pdsch_Config, sizeof(struct BWP_DownlinkDedicated__pdsch_Config));
5830 FreeBWPDlDedPdcchCfg(dlBwp);
5831 DU_FREE(dlBwp->pdcch_Config, sizeof(struct BWP_DownlinkDedicated__pdcch_Config));
5833 DU_FREE(srvCellCfg->initialDownlinkBWP, sizeof(BWP_DownlinkDedicated_t));
5835 DU_FREE(srvCellCfg->tdd_UL_DL_ConfigurationDedicated, sizeof(TDD_UL_DL_ConfigDedicated_t));
5837 DU_FREE(spCellCfg->spCellConfigDedicated, sizeof(ServingCellConfig_t));
5839 DU_FREE(spCellCfg->rlmInSyncOutOfSyncThreshold, sizeof(long));
5841 DU_FREE(spCellCfg->servCellIndex, sizeof(long));
5843 DU_FREE(spCellCfg,sizeof(SpCellConfig_t));
5847 /*******************************************************************
5849 * @brief Builds DU To CU RRC Container
5853 * Function : BuildDuToCuRrcContainer
5855 * Functionality: Builds DuToCuRrcContainer
5857 * @params[in] idx, index in F1AP msg
5858 * DuToCuRRCContainer, DuToCuRRCContainer
5860 * @return ROK - success
5863 * ****************************************************************/
5864 uint8_t BuildDuToCuRrcContainer(DUtoCURRCContainer_t *duToCuRrcContainer)
5867 CellGroupConfigRrc_t cellGrpCfg;
5868 asn_enc_rval_t encRetVal;
5869 memset(&cellGrpCfg, 0, sizeof(CellGroupConfigRrc_t));
5870 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
5874 cellGrpCfg.cellGroupId = CELL_GRP_ID;
5876 cellGrpCfg.rlc_BearerToAddModList = NULLP;
5877 DU_ALLOC(cellGrpCfg.rlc_BearerToAddModList, sizeof(struct CellGroupConfigRrc__rlc_BearerToAddModList));
5878 if(!cellGrpCfg.rlc_BearerToAddModList)
5880 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5884 if(BuildRlcBearerToAddModList(cellGrpCfg.rlc_BearerToAddModList) != ROK)
5886 DU_LOG("\nERROR --> F1AP : BuildRlcBearerToAddModList failed");
5891 cellGrpCfg.rlc_BearerToReleaseList = NULLP;
5892 cellGrpCfg.mac_CellGroupConfig = NULLP;
5893 DU_ALLOC(cellGrpCfg.mac_CellGroupConfig, sizeof(MAC_CellGroupConfig_t));
5894 if(!cellGrpCfg.mac_CellGroupConfig)
5896 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5900 if(BuildMacCellGrpCfg(cellGrpCfg.mac_CellGroupConfig) != ROK)
5902 DU_LOG("\nERROR --> F1AP : BuildMacCellGrpCfg failed");
5907 cellGrpCfg.physicalCellGroupConfig = NULLP;
5908 DU_ALLOC(cellGrpCfg.physicalCellGroupConfig, sizeof(PhysicalCellGroupConfig_t));
5909 if(!cellGrpCfg.physicalCellGroupConfig)
5911 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5915 if(BuildPhyCellGrpCfg(cellGrpCfg.physicalCellGroupConfig) != ROK)
5917 DU_LOG("\nERROR --> F1AP : BuildPhyCellGrpCfg failed");
5922 cellGrpCfg.spCellConfig = NULLP;
5923 DU_ALLOC(cellGrpCfg.spCellConfig, sizeof(SpCellConfig_t));
5924 if(!cellGrpCfg.spCellConfig)
5926 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
5930 if(BuildSpCellCfg(cellGrpCfg.spCellConfig) != ROK)
5932 DU_LOG("\nERROR --> F1AP : BuildSpCellCfg failed");
5937 cellGrpCfg.sCellToAddModList = NULLP;
5938 cellGrpCfg.sCellToReleaseList = NULLP;
5939 cellGrpCfg.ext1 = NULLP;
5941 /* encode cellGrpCfg into duToCuRrcContainer */
5942 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, &cellGrpCfg);
5943 memset(encBuf, 0, ENC_BUF_MAX_LEN);
5945 encRetVal = aper_encode(&asn_DEF_CellGroupConfigRrc, 0, &cellGrpCfg, PrepFinalEncBuf, encBuf);
5946 /* Encode results */
5947 if(encRetVal.encoded == ENCODE_FAIL)
5949 DU_LOG( "\nERROR --> F1AP : Could not encode DuToCuRrcContainer (at %s)\n",\
5950 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
5956 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for DuToCuRrcContainer\n");
5957 for(int i=0; i< encBufSize; i++)
5959 printf("%x",encBuf[i]);
5963 duToCuRrcContainer->size = encBufSize;
5964 DU_ALLOC(duToCuRrcContainer->buf, duToCuRrcContainer->size);
5965 if(!duToCuRrcContainer->buf)
5967 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDuToCuRrcContainer");
5973 memcpy(duToCuRrcContainer->buf, encBuf, duToCuRrcContainer->size);
5977 FreeMemDuToCuRrcCont(&cellGrpCfg);
5981 /*******************************************************************
5983 * @brief Free memory allocated in InitialULRRCMessage
5987 * Function : freeInitUlRrcMsgTransfer
5989 * Functionality: Free memory allocated in InitialULRRCMessage
5991 * @params[in]F1AP_PDU_t *f1apMsg)
5993 * @return ROK - success
5996 * ****************************************************************/
5998 uint8_t freeInitUlRrcMsgTransfer(F1AP_PDU_t *f1apMsg)
6000 uint8_t ieIdx, arrIdx;
6001 InitialULRRCMessageTransfer_t *initULRRCMsg=NULLP;
6005 if(f1apMsg->choice.initiatingMessage)
6007 initULRRCMsg = &f1apMsg->choice.initiatingMessage->value.\
6008 choice.InitialULRRCMessageTransfer;
6009 if(initULRRCMsg->protocolIEs.list.array)
6011 for(ieIdx = 0; ieIdx < initULRRCMsg->protocolIEs.list.count; ieIdx++)
6013 switch(initULRRCMsg->protocolIEs.list.array[ieIdx]->id)
6015 case ProtocolIE_ID_id_NRCGI:
6017 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.buf)
6019 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.buf)
6021 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.buf,\
6022 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.size);
6024 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.buf,\
6025 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.size);
6029 case ProtocolIE_ID_id_RRCContainer:
6031 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
6033 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf,\
6034 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size);
6038 case ProtocolIE_ID_id_DUtoCURRCContainer:
6040 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.buf)
6042 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.buf,
6043 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.size);
6051 for(arrIdx = 0; arrIdx < ieIdx; arrIdx++)
6053 if(initULRRCMsg->protocolIEs.list.array[arrIdx])
6055 DU_FREE(initULRRCMsg->protocolIEs.list.array[arrIdx],\
6056 sizeof(InitialULRRCMessageTransferIEs_t));
6059 DU_FREE(initULRRCMsg->protocolIEs.list.array, initULRRCMsg->protocolIEs.list.size);
6061 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
6063 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
6067 DU_LOG("\nERROR --> DU_APP : Recevied F1ap Pdu is null at freeInitUlRrcMsgTransfer()");
6073 /*******************************************************************
6075 * @brief Builds and sends the InitialULRRCMessage
6079 * Function : BuildAndSendInitialRrcMsgTransfer
6081 * Functionality: Constructs the Initial UL RRC Message Transfer and sends
6082 * it to the CU through SCTP.
6086 * @return ROK - success
6089 * ****************************************************************/
6090 uint8_t BuildAndSendInitialRrcMsgTransfer(uint32_t gnbDuUeF1apId, uint16_t crnti,
6091 uint16_t rrcContSize, uint8_t *rrcContainer)
6096 asn_enc_rval_t encRetVal;
6097 F1AP_PDU_t *f1apMsg = NULLP;
6098 InitialULRRCMessageTransfer_t *initULRRCMsg = NULLP;
6099 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
6103 DU_LOG("\n INFO --> F1AP : Building RRC Setup Request\n");
6104 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
6105 if(f1apMsg == NULLP)
6107 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
6110 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
6111 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
6112 if(f1apMsg->choice.initiatingMessage == NULLP)
6114 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
6117 f1apMsg->choice.initiatingMessage->procedureCode =\
6118 ProcedureCode_id_InitialULRRCMessageTransfer;
6119 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
6120 f1apMsg->choice.initiatingMessage->value.present = \
6121 InitiatingMessage__value_PR_InitialULRRCMessageTransfer;
6123 &f1apMsg->choice.initiatingMessage->value.choice.InitialULRRCMessageTransfer;
6125 initULRRCMsg->protocolIEs.list.count = elementCnt;
6126 initULRRCMsg->protocolIEs.list.size = \
6127 elementCnt * sizeof(InitialULRRCMessageTransferIEs_t *);
6128 /* Initialize the F1Setup members */
6129 DU_ALLOC(initULRRCMsg->protocolIEs.list.array,initULRRCMsg->protocolIEs.list.size);
6130 if(initULRRCMsg->protocolIEs.list.array == NULLP)
6132 DU_LOG(" ERROR --> F1AP : Memory allocation for\
6133 RRCSetupRequestMessageTransferIEs failed");
6136 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
6138 DU_ALLOC(initULRRCMsg->protocolIEs.list.array[ieIdx],\
6139 sizeof(InitialULRRCMessageTransferIEs_t));
6140 if(initULRRCMsg->protocolIEs.list.array[ieIdx] == NULLP)
6146 /*GNB DU UE F1AP ID*/
6147 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6148 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
6149 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6150 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present = \
6151 InitialULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
6152 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
6157 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6158 ProtocolIE_ID_id_NRCGI;
6159 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality =Criticality_reject;
6160 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present = \
6161 InitialULRRCMessageTransferIEs__value_PR_NRCGI;
6164 BuildNrcgi(&initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI);
6172 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6173 ProtocolIE_ID_id_C_RNTI;
6174 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6175 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
6176 InitialULRRCMessageTransferIEs__value_PR_C_RNTI;
6177 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.C_RNTI = crnti;
6181 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
6182 ProtocolIE_ID_id_RRCContainer;
6183 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6184 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
6185 InitialULRRCMessageTransferIEs__value_PR_RRCContainer;
6187 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size = rrcContSize;
6188 DU_ALLOC(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf,
6189 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size)
6190 if(!initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
6192 DU_LOG(" ERROR --> F1AP : Memory allocation for RRCSetupRequestMessageTransferIEs failed");
6196 memcpy(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf, rrcContainer,
6197 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size);
6200 /*DUtoCURRCContainer*/
6202 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DUtoCURRCContainer;
6203 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
6204 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
6205 InitialULRRCMessageTransferIEs__value_PR_DUtoCURRCContainer;
6207 ret = BuildDuToCuRrcContainer(&initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer);
6213 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
6215 /* Encode the F1SetupRequest type as APER */
6216 memset(encBuf, 0, ENC_BUF_MAX_LEN);
6218 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
6219 /* Encode results */
6220 if(encRetVal.encoded == ENCODE_FAIL)
6222 DU_LOG( "\nERROR --> F1AP : Could not encode Initial UL RRC Message Transfer\
6223 structure (at %s)\n",encRetVal.failed_type ? \
6224 encRetVal.failed_type->name : "unknown");
6231 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for Initial UL RRC\
6232 Message transfer\n");
6233 for(int i=0; i< encBufSize; i++)
6235 printf("%x",encBuf[i]);
6239 if(sendF1APMsg() != ROK)
6241 DU_LOG("\nERROR --> F1AP : Sending Initial UL RRC Message Transfer Failed");
6247 freeInitUlRrcMsgTransfer(f1apMsg);
6249 }/* End of BuildAndSendInitialRrcMsgTransfer*/
6251 /***** UE SETUP REQUEST *****/
6253 /*******************************************************************
6255 * @brief Free Qos And Snssai Drb Info
6259 * Function : freeDrbQosAndSnssaiInfo
6261 * Functionality: Free Qos And Snssai Drb Info
6263 * @params[in] LcCfg *lcCfg,
6266 * ****************************************************************/
6267 void freeDrbQosAndSnssaiInfo(LcCfg *lcCfg)
6271 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
6275 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
6279 /******************************************************************
6281 * @brief Function to delete the RLC Lc cfg from UE APP DB
6285 * Function : freeRlcLcCfg
6287 * Functionality: Function to delete the RLC Lc cfg from UE APP DB
6290 *****************************************************************/
6292 void freeRlcLcCfg(RlcBearerCfg *lcCfg)
6294 switch(lcCfg->rlcMode)
6300 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
6304 case RLC_UM_BI_DIRECTIONAL :
6306 if(lcCfg->u.umBiDirCfg)
6308 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
6312 case RLC_UM_UNI_DIRECTIONAL_UL :
6314 if(lcCfg->u.umUniDirUlCfg)
6316 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
6321 case RLC_UM_UNI_DIRECTIONAL_DL :
6323 if(lcCfg->u.umUniDirDlCfg)
6325 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
6330 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at freeRlcLcCfg()", lcCfg->rlcMode);
6333 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
6336 /*******************************************************************
6338 * @brief Function to free MacLcCfg
6342 * Function : freeMacLcCfg
6344 * Functionality: Function to free MacLcCfg
6346 * @params[in] LcCfg *lcCfg,
6349 * ****************************************************************/
6351 void freeMacLcCfg(LcCfg *lcCfg)
6353 /* Deleting DRBQOS */
6356 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
6358 /* Deleting SNSSAI */
6361 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
6364 /*******************************************************************
6366 * @brief Free UE NR Capability received in UE Context setup request
6370 * Function : freeAperDecodeUeNrCapability
6373 * Free UE NR Capability received in UE Context setup request
6376 * @return ROK - success
6379 * ****************************************************************/
6380 void freeAperDecodeUeNrCapability(void *ueNrCapability)
6383 FeatureSets_t *featureSets =NULLP;
6384 UE_NR_Capability_t *ueNrCap = (UE_NR_Capability_t *)ueNrCapability;
6386 if(ueNrCap->rf_Parameters.supportedBandListNR.list.array)
6388 for(arrIdx = 0; arrIdx < ueNrCap->rf_Parameters.supportedBandListNR.list.count; arrIdx++)
6390 if(ueNrCap->rf_Parameters.supportedBandListNR.list.array[arrIdx])
6391 free(ueNrCap->rf_Parameters.supportedBandListNR.list.array[arrIdx]);
6393 free(ueNrCap->rf_Parameters.supportedBandListNR.list.array);
6396 if(ueNrCap->featureSets)
6398 featureSets = ueNrCap->featureSets;
6399 if(featureSets->featureSetsDownlinkPerCC)
6401 if(featureSets->featureSetsDownlinkPerCC->list.array)
6403 for(arrIdx = 0; arrIdx < featureSets->featureSetsDownlinkPerCC->list.count; arrIdx++)
6405 if(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx])
6407 if(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]->supportedModulationOrderDL)
6408 free(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]->supportedModulationOrderDL);
6409 free(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]);
6412 free(featureSets->featureSetsDownlinkPerCC->list.array);
6414 free(featureSets->featureSetsDownlinkPerCC);
6416 if(featureSets->featureSetsUplinkPerCC)
6418 if(featureSets->featureSetsUplinkPerCC->list.array)
6420 for(arrIdx = 0; arrIdx < featureSets->featureSetsUplinkPerCC->list.count; arrIdx++)
6422 if(featureSets->featureSetsUplinkPerCC->list.array[arrIdx])
6424 if(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]->supportedModulationOrderUL)
6425 free(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]->supportedModulationOrderUL);
6426 free(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]);
6429 free(featureSets->featureSetsUplinkPerCC->list.array);
6431 free(featureSets->featureSetsUplinkPerCC);
6433 free(ueNrCap->featureSets);
6437 /*******************************************************************
6439 * @brief Function to free PdcchSearchSpcToAddModList
6440 where memory allocated by aper_decoder
6444 * Function : freeAperDecodePdcchSearchSpcToAddModList
6446 * Functionality: Function to free PdcchSearchSpcToAddModList
6448 * @params[in] struct PDCCH_Config__searchSpacesToAddModList *searchSpcList
6451 * ****************************************************************/
6453 void freeAperDecodePdcchSearchSpcToAddModList(struct PDCCH_Config__searchSpacesToAddModList *searchSpcList)
6455 uint8_t searchSpcArrIdx=0;
6456 uint8_t searchSpcArrIdx1=0;
6457 struct SearchSpace *searchSpc=NULLP;
6460 if(searchSpcList->list.array)
6462 if(searchSpcList->list.array[searchSpcArrIdx1])
6464 searchSpc = searchSpcList->list.array[searchSpcArrIdx1];
6465 if(searchSpc->controlResourceSetId)
6467 if(searchSpc->monitoringSlotPeriodicityAndOffset)
6469 if(searchSpc->monitoringSymbolsWithinSlot)
6471 if(searchSpc->monitoringSymbolsWithinSlot->buf)
6473 if(searchSpc->nrofCandidates)
6475 if(searchSpc->searchSpaceType)
6477 free(searchSpc->searchSpaceType->choice.ue_Specific);
6478 free(searchSpc->searchSpaceType);
6480 free(searchSpc->nrofCandidates);
6482 free(searchSpc->monitoringSymbolsWithinSlot->buf);
6484 free(searchSpc->monitoringSymbolsWithinSlot);
6486 free(searchSpc->monitoringSlotPeriodicityAndOffset);
6488 free(searchSpc->controlResourceSetId);
6491 for(searchSpcArrIdx = 0; searchSpcArrIdx < searchSpcList->list.count; searchSpcArrIdx++)
6493 free(searchSpcList->list.array[searchSpcArrIdx]);
6495 free(searchSpcList->list.array);
6498 /*******************************************************************
6500 * @brief Function for free part for the memory allocated by aper_decoder
6504 * Function : freeAperDecodeBWPDlDedPdcchConfig
6506 * Functionality: Function to free BWPDlDedPdcchConfig
6511 * ****************************************************************/
6514 void freeAperDecodeBWPDlDedPdcchConfig(BWP_DownlinkDedicated_t *dlBwp)
6518 struct PDCCH_Config *pdcchCfg=NULLP;
6519 struct ControlResourceSet *controlRSet=NULLP;
6520 struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList=NULLP;
6522 if(dlBwp->pdcch_Config->choice.setup)
6524 pdcchCfg=dlBwp->pdcch_Config->choice.setup;
6525 if(pdcchCfg->controlResourceSetToAddModList)
6527 controlRSetList = pdcchCfg->controlResourceSetToAddModList;
6528 if(controlRSetList->list.array)
6530 controlRSet = controlRSetList->list.array[arrIdx2];
6533 if(controlRSet->frequencyDomainResources.buf)
6535 if(controlRSet->pdcch_DMRS_ScramblingID)
6537 if(pdcchCfg->searchSpacesToAddModList)
6539 freeAperDecodePdcchSearchSpcToAddModList(pdcchCfg->searchSpacesToAddModList);
6540 free(pdcchCfg->searchSpacesToAddModList);
6542 free(controlRSet->pdcch_DMRS_ScramblingID);
6544 free(controlRSet->frequencyDomainResources.buf);
6547 for(arrIdx1 = 0; arrIdx1 <controlRSetList->list.count; arrIdx1++)
6549 free(controlRSetList->list.array[arrIdx1]);
6551 free(controlRSetList->list.array);
6553 free(pdcchCfg->controlResourceSetToAddModList);
6555 free(dlBwp->pdcch_Config->choice.setup);
6558 /*******************************************************************
6560 * @brief Function to free PdschTimeDomAllocationList
6561 * where the memory allocated by aper_decoder
6565 * Function : freeAperDecodePdschTimeDomAllocationList
6567 * Functionality: Function to free PdschTimeDomAllocationList
6569 * @params[in] struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
6572 * ****************************************************************/
6575 void freeAperDecodePdschTimeDomAllocationList( struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList)
6579 if(timeDomAllocList->choice.setup)
6581 if(timeDomAllocList->choice.setup->list.array)
6583 for(arrIdx = 0; arrIdx <timeDomAllocList->choice.setup->list.count ; arrIdx++)
6585 free(timeDomAllocList->choice.setup->list.array[arrIdx]);
6587 free(timeDomAllocList->choice.setup->list.array);
6589 free(timeDomAllocList->choice.setup);
6593 /*******************************************************************
6595 * @brief Function to free BWPDlDedPdschConfig
6596 * where the memory allocated by aper_decoder
6600 * Function : freeAperDecodeBWPDlDedPdschConfig
6602 * Functionality: Function to free BWPDlDedPdschConfig
6604 * @params[in] BWP_DownlinkDedicated_t *dlBwp
6607 * ****************************************************************/
6610 void freeAperDecodeBWPDlDedPdschConfig(BWP_DownlinkDedicated_t *dlBwp)
6612 struct PDSCH_Config *pdschCfg=NULLP;
6613 struct PDSCH_Config__prb_BundlingType *prbBndlType=NULLP;
6614 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList=NULLP;
6615 struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg=NULLP;
6617 if(dlBwp->pdsch_Config->choice.setup)
6619 pdschCfg=dlBwp->pdsch_Config->choice.setup;
6620 if(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
6622 if(pdschCfg->pdsch_TimeDomainAllocationList)
6624 timeDomAllocList=pdschCfg->pdsch_TimeDomainAllocationList;
6625 if(pdschCfg->maxNrofCodeWordsScheduledByDCI)
6627 prbBndlType=&pdschCfg->prb_BundlingType;
6628 free(prbBndlType->choice.staticBundling);
6629 free(pdschCfg->maxNrofCodeWordsScheduledByDCI);
6631 freeAperDecodePdschTimeDomAllocationList(timeDomAllocList);
6632 free(pdschCfg->pdsch_TimeDomainAllocationList);
6634 dmrsDlCfg=pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA;
6635 if(dmrsDlCfg->choice.setup)
6637 free(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition);
6638 free(dmrsDlCfg->choice.setup);
6640 free(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA);
6642 free(dlBwp->pdsch_Config->choice.setup);
6645 /*******************************************************************
6647 * @brief Function to free PuschTimeDomAllocListCfg
6648 where the memory allocated by aper_decoder
6652 * Function : freeAperDecodePuschTimeDomAllocListCfg
6654 * Functionality: Function to free PuschTimeDomAllocListCfg
6656 * @params[in] PUSCH_Config_t *puschCfg
6659 * ****************************************************************/
6662 void freeAperDecodePuschTimeDomAllocListCfg(PUSCH_Config_t *puschCfg)
6666 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList_t=NULLP;
6668 if(puschCfg->pusch_TimeDomainAllocationList)
6670 timeDomAllocList_t=puschCfg->pusch_TimeDomainAllocationList;
6671 if(timeDomAllocList_t->choice.setup)
6673 if(timeDomAllocList_t->choice.setup->list.array)
6675 free(timeDomAllocList_t->choice.setup->list.array[arrIdx1]->k2);
6676 for(arrIdx = 0; arrIdx<timeDomAllocList_t->choice.setup->list.count; arrIdx++)
6678 free(timeDomAllocList_t->choice.setup->list.array[arrIdx]);
6680 free(timeDomAllocList_t->choice.setup->list.array);
6682 free(timeDomAllocList_t->choice.setup);
6684 free(puschCfg->transformPrecoder);
6685 free(puschCfg->pusch_TimeDomainAllocationList);
6688 /*******************************************************************
6690 * @brief Function to free InitialUlBWPConfig where memory allocated by aper_decoder
6694 * Function : freeAperDecodeInitialUlBWPConfig
6696 * Functionality: Function to free InitialUlBWPConfig
6698 * @params[in] BWP_UplinkDedicated_t *ulBwp
6701 * ****************************************************************/
6704 void freeAperDecodeInitialUlBWPConfig(BWP_UplinkDedicated_t *ulBwp)
6708 SRS_Config_t *srsCfg = NULLP;
6709 PUSCH_Config_t *puschCfg = NULLP;
6710 struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg = NULLP;
6711 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList = NULLP;
6712 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList = NULLP;
6713 struct SRS_Config__srs_ResourceToAddModList *resourceList = NULLP;
6715 if(ulBwp->pusch_Config)
6717 if(ulBwp->pusch_Config->choice.setup)
6719 puschCfg=ulBwp->pusch_Config->choice.setup;
6720 if(puschCfg->dataScramblingIdentityPUSCH)
6722 if(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
6724 freeAperDecodePuschTimeDomAllocListCfg(puschCfg);
6725 dmrsUlCfg=puschCfg->dmrs_UplinkForPUSCH_MappingTypeA;
6726 if(dmrsUlCfg->choice.setup)
6728 if(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
6730 if(dmrsUlCfg->choice.setup->transformPrecodingDisabled)
6732 free(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0);
6733 free(dmrsUlCfg->choice.setup->transformPrecodingDisabled);
6735 free(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition);
6737 free(dmrsUlCfg->choice.setup);
6739 free(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA);
6741 free(puschCfg->dataScramblingIdentityPUSCH);
6743 free(ulBwp->pusch_Config->choice.setup);
6745 free(ulBwp->pusch_Config);
6747 /* Free SRS-Config */
6748 if(ulBwp->srs_Config)
6750 if(ulBwp->srs_Config->choice.setup)
6752 srsCfg = ulBwp->srs_Config->choice.setup;
6754 /* Free Resource Set to add/mod list */
6755 if(srsCfg->srs_ResourceSetToAddModList)
6757 rsrcSetList = srsCfg->srs_ResourceSetToAddModList;
6758 if(rsrcSetList->list.array)
6762 /* Free SRS resource Id list in this SRS resource set */
6763 if(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
6766 rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
6768 if(rsrcIdList->list.array)
6770 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count;
6773 free(rsrcIdList->list.array[rsrcIdx]);
6775 free(rsrcIdList->list.array);
6777 free(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList);
6780 /* Free resource type info for this SRS resource set */
6782 free(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic);
6784 /* Free memory for each resource set */
6785 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
6787 free(rsrcSetList->list.array[rSetIdx]);
6789 free(rsrcSetList->list.array);
6791 free(srsCfg->srs_ResourceSetToAddModList);
6794 /* Free resource to add/modd list */
6795 if(srsCfg->srs_ResourceToAddModList)
6797 resourceList = srsCfg->srs_ResourceToAddModList;
6798 if(resourceList->list.array)
6802 free(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2);
6803 free(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic);
6805 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
6807 free(resourceList->list.array[rsrcIdx]);
6809 free(resourceList->list.array);
6811 free(srsCfg->srs_ResourceToAddModList);
6814 free(ulBwp->srs_Config->choice.setup);
6816 free(ulBwp->srs_Config);
6820 /*******************************************************************
6822 * @brief Function to free initialUplinkBWPConfig where memory allocated by aper_decoder
6826 * Function : freeAperDecodeinitialUplinkBWPConfig
6828 * Functionality: Function to free initialUplinkBWPConfig
6830 * @params[in] UplinkConfig_t *ulCfg
6833 * ****************************************************************/
6836 void freeAperDecodeinitialUplinkBWPConfig(UplinkConfig_t *ulCfg)
6838 BWP_UplinkDedicated_t *ulBwp=NULLP;
6839 struct UplinkConfig__pusch_ServingCellConfig *puschCfg=NULLP;
6841 if(ulCfg->initialUplinkBWP)
6843 ulBwp=ulCfg->initialUplinkBWP;
6844 if(ulCfg->firstActiveUplinkBWP_Id)
6846 if(ulCfg->pusch_ServingCellConfig)
6848 puschCfg=ulCfg->pusch_ServingCellConfig;
6849 if(puschCfg->choice.setup)
6851 if(puschCfg->choice.setup->ext1)
6853 free(puschCfg->choice.setup->ext1->processingType2Enabled);
6854 free(puschCfg->choice.setup->ext1->maxMIMO_Layers);
6855 free(puschCfg->choice.setup->ext1);
6857 free(puschCfg->choice.setup);
6859 free(ulCfg->pusch_ServingCellConfig);
6861 free(ulCfg->firstActiveUplinkBWP_Id);
6863 freeAperDecodeInitialUlBWPConfig(ulBwp);
6864 free(ulCfg->initialUplinkBWP);
6868 /*******************************************************************
6870 * @brief Function to free DuUeCfg
6874 * Function : freeDuUeCfg
6876 * Functionality: Function to free DuUeCfg
6878 * @params[in] DuUeCfg *ueCfg
6881 * ****************************************************************/
6882 void freeDuUeCfg(DuUeCfg *ueCfg)
6886 SpCellConfig_t *spCellCfg = NULLP;
6887 ServingCellConfig_t *srvCellCfg = NULLP;
6888 BWP_DownlinkDedicated_t *dlBwp = NULLP;
6889 MAC_CellGroupConfig_t *macCellGrpCfg = NULLP;
6890 PhysicalCellGroupConfig_t *phyCellGrpCfg = NULLP;
6891 struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList = NULLP;
6892 struct RLC_Config *rlcConfig = NULLP;
6893 struct LogicalChannelConfig *macLcConfig = NULLP;
6894 struct SchedulingRequestConfig *schedulingRequestConfig = NULLP;
6895 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList = NULLP;
6896 struct TAG_Config *tagConfig = NULLP;
6897 struct TAG_Config__tag_ToAddModList *tagList = NULLP;
6898 struct MAC_CellGroupConfig__phr_Config *phrConfig = NULLP;
6899 struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg = NULLP;
6900 CellGroupConfigRrc_t *cellGrpCfg = ueCfg->cellGrpCfg;
6902 if(ueCfg->ueNrCapability)
6904 freeAperDecodeUeNrCapability(ueCfg->ueNrCapability);
6905 DU_FREE(ueCfg->ueNrCapability, sizeof(UE_NR_Capability_t));
6906 ueCfg->ueNrCapability = NULLP;
6909 if(ueCfg->cellGrpCfg)
6912 rlcBearerList = cellGrpCfg->rlc_BearerToAddModList;
6915 if(rlcBearerList->list.array)
6917 for(arrIdx=0; arrIdx<rlcBearerList->list.count; arrIdx++)
6919 if(rlcBearerList->list.array[arrIdx])
6921 rlcConfig = rlcBearerList->list.array[arrIdx]->rlc_Config;
6922 macLcConfig = rlcBearerList->list.array[arrIdx]->mac_LogicalChannelConfig;
6924 if(rlcBearerList->list.array[arrIdx]->servedRadioBearer)
6926 free(rlcBearerList->list.array[arrIdx]->servedRadioBearer);
6930 if(rlcConfig->choice.am)
6932 free(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength);
6933 free(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength);
6934 free(rlcConfig->choice.am);
6936 free(rlcBearerList->list.array[arrIdx]->rlc_Config);
6940 if(macLcConfig->ul_SpecificParameters)
6942 free(macLcConfig->ul_SpecificParameters->schedulingRequestID);
6943 free(macLcConfig->ul_SpecificParameters->logicalChannelGroup);
6944 free(macLcConfig->ul_SpecificParameters);
6946 free(rlcBearerList->list.array[arrIdx]->mac_LogicalChannelConfig);
6948 free(rlcBearerList->list.array[arrIdx]);
6951 free(rlcBearerList->list.array);
6953 free(cellGrpCfg->rlc_BearerToAddModList);
6956 macCellGrpCfg = cellGrpCfg->mac_CellGroupConfig;
6959 schedulingRequestConfig = macCellGrpCfg->schedulingRequestConfig;
6960 if(schedulingRequestConfig)
6962 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
6965 if(schReqList->list.array)
6967 for(arrIdx=0;arrIdx<schReqList->list.count; arrIdx++)
6969 if(schReqList->list.array[arrIdx])
6971 free(schReqList->list.array[arrIdx]->sr_ProhibitTimer);
6972 free(schReqList->list.array[arrIdx]);
6975 free(schReqList->list.array);
6977 free(schedulingRequestConfig->schedulingRequestToAddModList);
6979 free(macCellGrpCfg->schedulingRequestConfig);
6981 if(macCellGrpCfg->bsr_Config)
6983 free(macCellGrpCfg->bsr_Config);
6985 tagConfig = macCellGrpCfg->tag_Config;
6988 tagList = tagConfig->tag_ToAddModList;
6991 if(tagList->list.array)
6993 for(arrIdx=0; arrIdx<tagList->list.count; arrIdx++)
6995 free(tagList->list.array[arrIdx]);
6997 free(tagList->list.array);
6999 free(tagConfig->tag_ToAddModList);
7004 phrConfig = macCellGrpCfg->phr_Config;
7007 free(phrConfig->choice.setup);
7011 free(macCellGrpCfg);
7014 phyCellGrpCfg = cellGrpCfg->physicalCellGroupConfig;
7017 free(phyCellGrpCfg->p_NR_FR1);
7018 free(phyCellGrpCfg);
7021 spCellCfg = cellGrpCfg->spCellConfig;
7024 if(spCellCfg->servCellIndex)
7026 if(spCellCfg->rlmInSyncOutOfSyncThreshold)
7028 if(spCellCfg->spCellConfigDedicated)
7030 srvCellCfg = spCellCfg->spCellConfigDedicated;
7031 if(srvCellCfg->initialDownlinkBWP)
7033 dlBwp = srvCellCfg->initialDownlinkBWP;
7034 if(srvCellCfg->firstActiveDownlinkBWP_Id)
7036 if(srvCellCfg->defaultDownlinkBWP_Id)
7038 if(srvCellCfg->uplinkConfig)
7041 if(srvCellCfg->pdsch_ServingCellConfig)
7044 srvCellCfg->pdsch_ServingCellConfig;
7045 if(pdschCfg->choice.setup)
7048 free(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH);
7049 free(pdschCfg->choice.setup);
7052 free(srvCellCfg->pdsch_ServingCellConfig);
7055 freeAperDecodeinitialUplinkBWPConfig(srvCellCfg->uplinkConfig);
7056 free(srvCellCfg->uplinkConfig);
7058 free(srvCellCfg->defaultDownlinkBWP_Id);
7061 free(srvCellCfg->firstActiveDownlinkBWP_Id);
7063 if(dlBwp->pdcch_Config)
7065 if(dlBwp->pdsch_Config)
7067 freeAperDecodeBWPDlDedPdschConfig(dlBwp);
7068 free(dlBwp->pdsch_Config);
7070 freeAperDecodeBWPDlDedPdcchConfig(dlBwp);
7071 free(dlBwp->pdcch_Config);
7073 free(srvCellCfg->initialDownlinkBWP);
7076 free(spCellCfg->spCellConfigDedicated);
7078 free(spCellCfg->rlmInSyncOutOfSyncThreshold);
7080 free(spCellCfg->servCellIndex);
7084 DU_FREE(ueCfg->cellGrpCfg, sizeof(CellGroupConfigRrc_t));
7085 ueCfg->cellGrpCfg = NULLP;
7089 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCfg->ambrCfg, sizeof(AmbrCfg));
7091 for(lcIdx = 0; lcIdx < ueCfg->numRlcLcs; lcIdx++)
7093 freeRlcLcCfg(&ueCfg->rlcLcCfg[lcIdx]);
7095 for(lcIdx = 0; lcIdx < ueCfg->numMacLcs; lcIdx++)
7097 freeMacLcCfg(&ueCfg->macLcCfg[lcIdx]);
7099 for(lcIdx = 0; lcIdx < ueCfg->numDrb; lcIdx++)
7101 DU_FREE(ueCfg->upTnlInfo[lcIdx].tnlCfg1, sizeof(GtpTnlCfg));
7105 /*******************************************************************
7107 * @brief Function to free UecontextSetupDb
7111 * Function : freeF1UeDb
7113 * Functionality: Function to free UecontextSetupDb
7115 * @params[in] UecontextSetupDb *
7118 * ****************************************************************/
7120 void freeF1UeDb(F1UeContextSetupDb *f1UeDb)
7123 if(f1UeDb->dlRrcMsg)
7125 if(f1UeDb->dlRrcMsg->rrcMsgPdu)
7127 //DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,\
7128 f1UeDb->dlRrcMsg->rrcMsgPdu, f1UeDb->dlRrcMsg->rrcMsgSize);
7130 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
7132 freeDuUeCfg(&f1UeDb->duUeCfg);
7133 memset(f1UeDb, 0, sizeof(F1UeContextSetupDb));
7134 DU_FREE(f1UeDb, sizeof(F1UeContextSetupDb));
7137 /*******************************************************************
7139 * @brief Function to build Am cfg Info
7143 * Function : extractRlcAmCfg
7145 * Functionality: Function to build Am cfg Info
7147 * @params[in] AmBearerCfg *
7150 * @return ROK/RFAILED
7152 * ****************************************************************/
7154 void extractRlcAmCfg(AmBearerCfg *amCfgToSet, struct RLC_Config__am *rlcAmCfg)
7159 if(rlcAmCfg->dl_AM_RLC.sn_FieldLength)
7161 amCfgToSet->ulAmCfg.snLenUl = *(rlcAmCfg->dl_AM_RLC.sn_FieldLength);
7162 /*TODO: Check the timer value when sent by real CU */
7163 amCfgToSet->ulAmCfg.reAssemTmr = rlcAmCfg->dl_AM_RLC.t_Reassembly;
7164 amCfgToSet->ulAmCfg.statProhTmr = rlcAmCfg->dl_AM_RLC.t_StatusProhibit;
7168 if(rlcAmCfg->ul_AM_RLC.sn_FieldLength)
7170 amCfgToSet->dlAmCfg.snLenDl = *(rlcAmCfg->ul_AM_RLC.sn_FieldLength);
7171 amCfgToSet->dlAmCfg.pollRetxTmr = rlcAmCfg->ul_AM_RLC.t_PollRetransmit;
7172 amCfgToSet->dlAmCfg.pollPdu = rlcAmCfg->ul_AM_RLC.pollPDU;
7173 amCfgToSet->dlAmCfg.pollByte = rlcAmCfg->ul_AM_RLC.pollByte;
7174 amCfgToSet->dlAmCfg.maxRetxTh = rlcAmCfg->ul_AM_RLC.maxRetxThreshold;
7179 /*******************************************************************
7181 * @brief Function to build Um Bi Info
7185 * Function : extractRlcUmBiCfg
7187 * Functionality: Function to build Um Bi Info
7189 * @params[in] UmBiDirBearerCfg *
7192 * @return ROK/RFAILED
7194 * ****************************************************************/
7196 void extractRlcUmBiCfg(UmBiDirBearerCfg *umBiCfgToSet, struct RLC_Config__um_Bi_Directional *rlcBiCfg)
7200 /* UL UM BI DIR Cfg */
7201 if(rlcBiCfg->dl_UM_RLC.sn_FieldLength)
7203 umBiCfgToSet->ulUmCfg.snLenUlUm = *(rlcBiCfg->dl_UM_RLC.sn_FieldLength);
7204 umBiCfgToSet->ulUmCfg.reAssemTmr = rlcBiCfg->dl_UM_RLC.t_Reassembly;
7207 /* DL UM BI DIR Cfg */
7208 if(rlcBiCfg->ul_UM_RLC.sn_FieldLength)
7209 umBiCfgToSet->dlUmCfg.snLenDlUm = *(rlcBiCfg->ul_UM_RLC.sn_FieldLength);
7213 /*******************************************************************
7215 * @brief Function to build Um Ul Info
7219 * Function : extractRlcUmUlCfg
7221 * Functionality: Function to build Um Ul Info
7223 * @params[in] UmUniDirUlBearerCfg *
7226 * @return ROK/RFAILED
7228 * ****************************************************************/
7230 void extractRlcUmUlCfg(UmUniDirUlBearerCfg *umUlCfgToSet, struct RLC_Config__um_Uni_Directional_DL *umUlCfg)
7234 if(umUlCfg->dl_UM_RLC.sn_FieldLength)
7236 umUlCfgToSet->ulUmCfg.snLenUlUm = *(umUlCfg->dl_UM_RLC.sn_FieldLength);
7237 umUlCfgToSet->ulUmCfg.reAssemTmr = umUlCfg->dl_UM_RLC.t_Reassembly;
7242 /*******************************************************************
7244 * @brief Function to build Um Uni Dl Info
7248 * Function : extractRlcUmDlCfg
7250 * Functionality: Function to build Um Uni Dl Info
7252 * @params[in] UmUniDirDlBearerCfg *
7255 * @return ROK/RFAILED
7257 * ****************************************************************/
7258 void extractRlcUmDlCfg(UmUniDirDlBearerCfg *umDlCfgToSet, struct RLC_Config__um_Uni_Directional_UL *umDlCfg)
7262 if(umDlCfg->ul_UM_RLC.sn_FieldLength)
7263 umDlCfgToSet->dlUmCfg.snLenDlUm = *(umDlCfg->ul_UM_RLC.sn_FieldLength);
7267 /*******************************************************************
7269 * @brief Function to extractRlcModeCfg
7273 * Function : extractRlcModeCfg
7275 * Functionality: Function to extractRlcModeCfg
7277 * @params[in] RLC_Config_t *
7280 * @return ROK/RFAILED
7282 * ****************************************************************/
7283 void extractRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *rlcDbCfg, RLC_Config_t *lcCfg)
7291 if(lcCfg->choice.am)
7293 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.amCfg, sizeof(AmBearerCfg));
7294 if(rlcDbCfg->u.amCfg)
7295 extractRlcAmCfg(rlcDbCfg->u.amCfg, lcCfg->choice.am);
7299 case RLC_UM_BI_DIRECTIONAL :
7301 if(lcCfg->choice.um_Bi_Directional)
7303 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
7304 if(rlcDbCfg->u.umBiDirCfg)
7305 extractRlcUmBiCfg(rlcDbCfg->u.umBiDirCfg, lcCfg->choice.um_Bi_Directional);
7309 case RLC_UM_UNI_DIRECTIONAL_UL :
7311 if(lcCfg->choice.um_Uni_Directional_DL)
7313 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
7314 if(rlcDbCfg->u.umUniDirUlCfg)
7315 extractRlcUmUlCfg(rlcDbCfg->u.umUniDirUlCfg, lcCfg->choice.um_Uni_Directional_DL);
7319 case RLC_UM_UNI_DIRECTIONAL_DL :
7321 if(lcCfg->choice.um_Uni_Directional_UL)
7323 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
7324 if(rlcDbCfg->u.umUniDirDlCfg)
7325 extractRlcUmDlCfg(rlcDbCfg->u.umUniDirDlCfg, lcCfg->choice.um_Uni_Directional_UL);
7330 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
7336 /*******************************************************************
7338 * @brief Function to extract extractUlLcCfg
7342 * Function : extractUlLcCfg
7344 * Functionality: Function to extract extractUlLcCfg
7346 * @params[in] UlLcCfg *f1UlLcCfg, LogicalChannelConfig_t *ulLcCfg
7349 * ****************************************************************/
7351 void extractUlLcCfg(UlLcCfg *f1UlLcCfg, LogicalChannelConfig_t *ulLcCfg)
7355 if(ulLcCfg->ul_SpecificParameters)
7357 f1UlLcCfg->priority = \
7358 ulLcCfg->ul_SpecificParameters->priority;
7359 if(ulLcCfg->ul_SpecificParameters->logicalChannelGroup)
7361 f1UlLcCfg->lcGroup = \
7362 *(ulLcCfg->ul_SpecificParameters->logicalChannelGroup);
7364 if(ulLcCfg->ul_SpecificParameters->schedulingRequestID)
7366 f1UlLcCfg->schReqId = \
7367 *(ulLcCfg->ul_SpecificParameters->schedulingRequestID);
7370 ulLcCfg->ul_SpecificParameters->prioritisedBitRate;
7372 ulLcCfg->ul_SpecificParameters->bucketSizeDuration;
7377 /*******************************************************************
7379 * @brief Function to extract Snssai Cfg Info from CU
7383 * Function : extractDrbSnssaiCfg
7385 * Functionality: Function to extract Drb Snssai Cfg Info from CU
7387 * @params[in] DRB_Information_t *drbInfo, Snssai *snssai
7388 * @return ROK/RFAILED
7390 * ****************************************************************/
7392 uint8_t extractDrbSnssaiCfg(SNSSAI_t *RecvSnssai, Snssai **snssaiToBeShared)
7394 if(!(*snssaiToBeShared))
7396 DU_ALLOC_SHRABL_BUF((*snssaiToBeShared), sizeof(Snssai));
7397 if(snssaiToBeShared == NULLP)
7399 DU_LOG("\nERROR --> DUAPP : extractDrbSnssaiCfg(): Memory failed at allocating for SNSSAI ");
7405 memcpy(&(*snssaiToBeShared)->sst, RecvSnssai->sST.buf, RecvSnssai->sST.size);
7408 memcpy((*snssaiToBeShared)->sd, RecvSnssai->sD->buf, RecvSnssai->sD->size);
7412 DU_LOG("\nERROR --> DUAPP : extractDrbSnssaiCfg(): Received Null pointer of Snssai->SD");
7419 /*******************************************************************
7421 * @brief Function to procRlcLcCfg
7425 * Function : procRlcLcCfg
7427 * Functionality: Function to procRlcLcCfg
7429 * @params[in] rbId, lcId, rbType, rlcMod
7430 * RLC_Config_t *, RlcBearerCfg * ,
7433 * ****************************************************************/
7435 void procRlcLcCfg(uint8_t rbId, uint8_t lcId, uint8_t rbType, uint8_t rlcMode,\
7436 uint8_t configType, RLC_Config_t *f1RlcCfg, RlcBearerCfg *lcCfg, QoSInformation_t *qoSInformation)
7438 DRB_Information_t *drbInfo;
7441 lcCfg->configType = configType;
7443 if(rbType == RB_TYPE_SRB)
7445 lcCfg->rbType = RB_TYPE_SRB;
7447 lcCfg->lcType = LCH_DCCH;
7448 lcCfg->rlcMode = RLC_AM;
7450 else if(rbType == RB_TYPE_DRB)
7452 lcCfg->rbType = RB_TYPE_DRB;
7454 lcCfg->lcType = LCH_DTCH;
7455 lcCfg->rlcMode = rlcMode;
7457 if(f1RlcCfg) /* rlc mode config recived */
7459 extractRlcModeCfg(lcCfg->rlcMode, lcCfg, f1RlcCfg);
7461 if(qoSInformation != NULLP)
7463 if(qoSInformation->present == QoSInformation_PR_choice_extension)
7465 if(qoSInformation->choice.choice_extension->value.present ==\
7466 QoSInformation_ExtIEs__value_PR_DRB_Information)
7468 drbInfo = &qoSInformation->choice.choice_extension->value.choice.DRB_Information;
7469 if(extractDrbSnssaiCfg(&drbInfo->sNSSAI, &lcCfg->snssai) != ROK)
7471 DU_LOG("\nERROR --> DUAPP: Unable to extract Snssai information at procRlcLcCfg()");
7479 /*******************************************************************
7481 * @brief Fills DrbQos Info received by CU
7485 * Function : extractQosInfo
7487 * Functionality: Fills DrbQos Info received by CU
7489 * @params[in] DrbQosInfo *qosToAdd,
7490 * QoSFlowLevelQoSParameters_t *qosFlowCfg
7493 * ****************************************************************/
7495 void extractQosInfo(DrbQosInfo *qosToAdd, QoSFlowLevelQoSParameters_t *qosFlowCfg)
7497 uint8_t qosCntIdx = 0;
7498 ProtocolExtensionContainer_4624P74_t *qosIeExt = NULLP;
7500 qosToAdd->fiveQiType = qosFlowCfg->qoS_Characteristics.present;
7501 qosToAdd->u.nonDyn5Qi.fiveQi =\
7502 qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->fiveQI;
7503 if(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow)
7505 qosToAdd->u.nonDyn5Qi.avgWindow = \
7506 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
7508 qosToAdd->u.nonDyn5Qi.maxDataBurstVol = \
7509 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
7510 if(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->qoSPriorityLevel)
7512 qosToAdd->u.nonDyn5Qi.priorLevel = \
7513 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->qoSPriorityLevel);
7515 qosToAdd->ngRanRetPri.priorityLevel = \
7516 qosFlowCfg->nGRANallocationRetentionPriority.priorityLevel;
7517 qosToAdd->ngRanRetPri.preEmptionCap = \
7518 qosFlowCfg->nGRANallocationRetentionPriority.pre_emptionCapability;
7519 qosToAdd->ngRanRetPri.preEmptionVul = \
7520 qosFlowCfg->nGRANallocationRetentionPriority.pre_emptionVulnerability;
7521 if(qosFlowCfg->gBR_QoS_Flow_Information)
7523 memcpy(&qosToAdd->grbQosInfo.maxFlowBitRateDl, \
7524 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateDownlink.buf, \
7525 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateDownlink.size);
7526 memcpy(&qosToAdd->grbQosInfo.maxFlowBitRateUl, \
7527 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateUplink.buf, \
7528 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateUplink.size);
7529 memcpy(&qosToAdd->grbQosInfo.guarFlowBitRateDl,\
7530 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateDownlink.buf, \
7531 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateDownlink.size);
7532 memcpy(&qosToAdd->grbQosInfo.guarFlowBitRateUl,\
7533 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateUplink.buf, \
7534 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateUplink.size);
7536 /*Extracting PDU_SESSION_ID*/
7537 qosIeExt = (ProtocolExtensionContainer_4624P74_t *)qosFlowCfg->iE_Extensions;
7540 for(qosCntIdx = 0; qosCntIdx < qosIeExt->list.count; qosCntIdx++)
7542 if(qosIeExt->list.array[qosCntIdx]->extensionValue.present == \
7543 QoSFlowLevelQoSParameters_ExtIEs__extensionValue_PR_PDUSessionID)
7545 qosToAdd->pduSessionId = qosIeExt->list.array[qosCntIdx]->extensionValue.choice.PDUSessionID;
7546 DU_LOG("\nDEBUG --> DU_F1AP : extractQosInfo: PDU SessionID:%d",qosToAdd->pduSessionId);
7550 qosToAdd->ulPduSessAggMaxBitRate = 0;
7553 /*******************************************************************
7555 * @brief Function to extract GTP Tunnel Info from CU
7559 * Function : extractUpTnlInfo
7561 * Functionality: Function to extract GTP Tunnel Info from CU
7563 * @params[in] F1AP message
7564 * @return ROK/RFAILED
7566 * ****************************************************************/
7568 uint8_t extractUpTnlInfo(uint8_t drbId, uint8_t configType,\
7569 ULUPTNLInformation_ToBeSetup_List_t *tnlInfo, UpTnlCfg *upTnlInfo)
7572 uint32_t ipv4_du = 0;
7573 GTPTunnel_t *gtpTunnel = NULLP;
7575 upTnlInfo->drbId = drbId;
7576 upTnlInfo->configType = configType;
7578 cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
7580 cmInetAddr((char *)DU_IP_V4_ADDR, &ipv4_du);
7583 for(tnlIdx=0; tnlIdx < tnlInfo->list.count; tnlIdx++)
7585 if(tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.present == UPTransportLayerInformation_PR_gTPTunnel)
7587 if(tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.choice.gTPTunnel)
7589 gtpTunnel = tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.choice.gTPTunnel;
7590 DU_ALLOC(upTnlInfo->tnlCfg1, sizeof(GtpTnlCfg));
7591 if(upTnlInfo->tnlCfg1 == NULLP)
7593 DU_LOG("\nERROR --> F1AP : extractUpTnlInfo: Failed to allocate mmeory for tunnel cfg 1");
7596 bitStringToInt(>pTunnel->transportLayerAddress, &upTnlInfo->tnlCfg1->ulTnlAddress);
7597 upTnlInfo->tnlCfg1->dlTnlAddress = ipv4_du;
7598 if(gtpTunnel->gTP_TEID.size > 0)
7600 teIdStringToInt(gtpTunnel->gTP_TEID.buf, &upTnlInfo->tnlCfg1->teId);
7609 /*******************************************************************
7611 * @brief Function to extract Drb Qos Cfg Info from CU
7615 * Function : extractDrbQosCfg
7617 * Functionality: Function to extract Drb Qos Cfg Info from CU
7619 * @params[in] DRB_Information_t *drbInfo, LcCfg *macLcToAdd
7620 * @return ROK/RFAILED
7622 * ****************************************************************/
7624 uint8_t extractDrbQosCfg(DRB_Information_t *drbInfo, LcCfg *macLcToAdd )
7626 if(!macLcToAdd->drbQos)
7628 DU_ALLOC_SHRABL_BUF(macLcToAdd->drbQos, sizeof(DrbQosInfo));
7629 if(macLcToAdd->drbQos == NULLP)
7631 DU_LOG("\nERROR --> DUAPP:Memory failed at allocating DrbQos at extractDrbQosCfg()");
7636 if(drbInfo->dRB_QoS.qoS_Characteristics.present == QoS_Characteristics_PR_non_Dynamic_5QI)
7638 extractQosInfo(macLcToAdd->drbQos, &drbInfo->dRB_QoS);
7639 macLcToAdd->dlLcCfg.lcp = macLcToAdd->drbQos->ngRanRetPri.priorityLevel;
7641 if(extractDrbSnssaiCfg(&drbInfo->sNSSAI, &macLcToAdd->snssai) != ROK)
7643 DU_LOG("\nERROR --> DUAPP: Unable to extract Snssai information at extractDrbQosCfg()");
7648 /*******************************************************************
7650 * @brief Function to extract DRB info received from CU
7654 * Function : extractDrbCfg
7656 * Functionality: Function to extract DRB info received from CU
7658 * @params[in] F1AP message
7661 * ****************************************************************/
7662 uint8_t extractDrbCfg(DRBs_ToBeSetup_Item_t *drbItem, DRBs_ToBeSetupMod_Item_t *drbSetupModItem,\
7663 DRBs_ToBeModified_Item_t *drbModItem, LcCfg *macLcToAdd, UpTnlCfg *upTnlInfo)
7665 DRB_Information_t *drbInfo = NULLP;
7667 if(drbItem != NULLP)
7669 if(extractUpTnlInfo(drbItem->dRBID, CONFIG_ADD, &drbItem->uLUPTNLInformation_ToBeSetup_List, upTnlInfo) != ROK)
7671 DU_LOG("\nERROR --> DUAPP : Failed to extract tunnel Cfg at extractDrbCfg()");
7674 if(drbItem->qoSInformation.present == QoSInformation_PR_choice_extension)
7676 if(drbItem->qoSInformation.choice.choice_extension->value.present == QoSInformation_ExtIEs__value_PR_DRB_Information)
7678 drbInfo = &drbItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information;
7679 if(extractDrbQosCfg(drbInfo , macLcToAdd) != ROK)
7681 DU_LOG("\nERROR --> DUAPP : Failed to extract qos Cfg at extractDrbCfg()");
7687 else if(drbSetupModItem != NULLP)
7689 if(extractUpTnlInfo(drbSetupModItem->dRBID, CONFIG_ADD, &drbSetupModItem->uLUPTNLInformation_ToBeSetup_List,\
7692 DU_LOG("\nERROR --> DUAPP : Failed to extract tunnel Cfg at extractDrbCfg()");
7695 if(drbSetupModItem->qoSInformation.present == QoSInformation_PR_choice_extension)
7697 if(drbSetupModItem->qoSInformation.choice.choice_extension->value.present ==\
7698 QoSInformation_ExtIEs__value_PR_DRB_Information)
7700 drbInfo = &drbSetupModItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information;
7701 if(extractDrbQosCfg(drbInfo , macLcToAdd) != ROK)
7703 DU_LOG("\nERROR --> DUAPP : Failed to extract qos Cfg at extractDrbCfg()");
7710 else if(drbModItem != NULLP)
7712 if(extractUpTnlInfo(drbModItem->dRBID, CONFIG_MOD, &drbModItem->uLUPTNLInformation_ToBeSetup_List,\
7715 DU_LOG("\nERROR --> DUAPP : Failed to extract tunnel Cfg at extractDrbCfg()");
7718 if(drbModItem->qoSInformation != NULLP)
7720 if(drbModItem->qoSInformation->present == QoSInformation_PR_choice_extension)
7722 if(drbModItem->qoSInformation->choice.choice_extension->value.present ==\
7723 QoSInformation_ExtIEs__value_PR_DRB_Information)
7725 drbInfo = &drbModItem->qoSInformation->choice.choice_extension->value.choice.DRB_Information;
7726 if(extractDrbQosCfg(drbInfo , macLcToAdd) != ROK)
7728 DU_LOG("\nERROR --> DUAPP : Failed to extract qos Cfg at extractDrbCfg()");
7739 /*******************************************************************
7741 * @brief Function to extract RB info received from CU
7745 * Function : extractMacRbCfg
7747 * Functionality: Function to extract RB info received from CU
7749 * @params[in] F1AP message
7750 * @return ROK/RFAILED
7752 * ****************************************************************/
7754 uint8_t extractMacRbCfg(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbCfg,\
7755 DRBs_ToBeSetupMod_Item_t *drbSetupModCfg, DRBs_ToBeModified_Item_t *drbModCfg, LogicalChannelConfig_t *ulLcCfg, LcCfg *lcCfg, UpTnlCfg *upTnlInfo)
7759 if(extractDrbCfg(drbCfg, NULL, NULL, lcCfg, upTnlInfo) != ROK)
7761 DU_LOG("ERROR --> F1AP : Failed to build Drb Qos at extractMacRbCfg()");
7765 else if(drbSetupModCfg != NULLP)
7767 if(extractDrbCfg(NULL, drbSetupModCfg, NULL, lcCfg, upTnlInfo) != ROK)
7769 DU_LOG("ERROR --> F1AP : Failed to build Drb Qos at extractMacRbCfg()");
7773 else if(drbModCfg != NULLP)
7775 if(extractDrbCfg(NULL, NULL, drbModCfg, lcCfg, upTnlInfo) != ROK)
7777 DU_LOG("ERROR --> F1AP : Failed to build Drb Qos at extractMacRbCfg()");
7783 lcCfg->drbQos = NULLP;
7784 lcCfg->snssai = NULLP;
7785 if(lcCfg->lcId == SRB2_LCID)
7786 lcCfg->dlLcCfg.lcp = LC_PRIORITY_3;
7788 lcCfg->dlLcCfg.lcp = LC_PRIORITY_1;
7792 lcCfg->ulLcCfgPres = true;
7793 extractUlLcCfg(&lcCfg->ulLcCfg, ulLcCfg);
7796 lcCfg->ulLcCfgPres = false;
7800 /*******************************************************************
7802 * @brief Function processing LC config info received from CU
7806 * Function : procMacLcCfg
7808 * Functionality: Function processing LC config info received from CU
7810 * @params[in] F1AP message
7811 * @return ROK/RFAILED
7813 * ****************************************************************/
7815 uint8_t procMacLcCfg(uint8_t lcId, uint8_t rbType, uint8_t configType, DRBs_ToBeSetup_Item_t *drbItem,\
7816 DRBs_ToBeSetupMod_Item_t *drbSetupModItem, DRBs_ToBeModified_Item_t *drbModItem, LogicalChannelConfig_t *ulLcCfg,\
7817 LcCfg *lcCfg, UpTnlCfg *upTnlInfo)
7822 lcCfg->configType = configType;
7823 if(rbType == RB_TYPE_SRB)
7825 ret = extractMacRbCfg(lcId, NULL, NULL, NULL, ulLcCfg, lcCfg, NULL);
7827 else if(rbType == RB_TYPE_DRB)
7830 ret = extractMacRbCfg(lcId, drbItem, NULL, NULL, ulLcCfg, lcCfg, upTnlInfo);
7831 else if(drbSetupModItem != NULL)
7832 ret = extractMacRbCfg(lcId, NULL, drbSetupModItem, NULL, ulLcCfg, lcCfg, upTnlInfo);
7833 else if(drbModItem != NULL)
7834 ret = extractMacRbCfg(lcId, NULL, NULL, drbModItem, ulLcCfg, lcCfg, upTnlInfo);
7839 /*******************************************************************
7841 * @brief Function to extract Rlc cfg To Add/Mod in CellGrp Info
7845 * Function : extractRlcCfgToAddMod
7847 * Functionality: Function to extract Rlc cfg To Add/Mod in CellGrp Info
7849 * @params[in] CellGroupConfigRrc__rlc_BearerTo pointer
7851 * @return ROK/RFAILED
7853 * ****************************************************************/
7855 uint8_t extractRlcCfgToAddMod(struct CellGroupConfigRrc__rlc_BearerToAddModList *lcCfg, DuUeCfg *ueCfgDb)
7857 uint8_t idx, rbId, lcId, rlcMode, rbType;
7858 RLC_Config_t *f1RlcCfg = NULLP;
7859 LogicalChannelConfig_t *macUlLcCfg = NULLP;
7861 for(idx = 0; idx < lcCfg->list.count; idx++)
7863 lcId = lcCfg->list.array[idx]->logicalChannelIdentity;
7864 if(lcCfg->list.array[idx]->servedRadioBearer)
7866 /* RadioBearer for SRB/DRB */
7867 if(lcCfg->list.array[idx]->servedRadioBearer->present ==\
7868 RLC_BearerConfig__servedRadioBearer_PR_srb_Identity)
7870 rbId = lcCfg->list.array[idx]->servedRadioBearer->choice.srb_Identity;
7871 rbType = RB_TYPE_SRB;
7873 else if(lcCfg->list.array[idx]->servedRadioBearer->present ==\
7874 RLC_BearerConfig__servedRadioBearer_PR_drb_Identity)
7876 rbId = lcCfg->list.array[idx]->servedRadioBearer->choice.drb_Identity;
7877 rbType = RB_TYPE_DRB;
7881 DU_LOG("\nERROR --> No components present in Bearer config to ADD/MOD");
7884 /* MAC UL LC Config */
7885 if(lcCfg->list.array[idx]->mac_LogicalChannelConfig)
7887 macUlLcCfg = lcCfg->list.array[idx]->mac_LogicalChannelConfig;
7892 DU_LOG("\nERROR --> DUAPP: Received RadioBearer config is NULL");
7895 /* RLC Mode Config */
7896 if(lcCfg->list.array[idx]->rlc_Config)
7898 rlcMode = lcCfg->list.array[idx]->rlc_Config->present;
7899 f1RlcCfg = lcCfg->list.array[idx]->rlc_Config;
7902 /* Filling RLC/MAC Config*/
7903 memset(&ueCfgDb->macLcCfg[idx], 0, sizeof(LcCfg));
7904 memset(&ueCfgDb->rlcLcCfg[idx], 0, sizeof(RlcBearerCfg));
7905 procRlcLcCfg(rbId, lcId, rbType, rlcMode, CONFIG_UNKNOWN, f1RlcCfg, &(ueCfgDb->rlcLcCfg[idx]), NULLP);
7906 if(procMacLcCfg(lcId, rbType, CONFIG_UNKNOWN, NULL, NULL, NULL, macUlLcCfg, &ueCfgDb->macLcCfg[idx], NULL) != ROK)
7908 DU_LOG("\nERROR --> DU APP : Failed while filling MAC LC config at extractRlcCfgToAddMod()");
7911 (ueCfgDb->numRlcLcs)++;
7912 (ueCfgDb->numMacLcs)++;
7913 DU_LOG("\nDEBUG -> DUAPP: extractRlcCfgToAddMod:RBType:%d, DrbID: %d,lcId:%d, [RLC,MAC,NumDrb]:[%x,%x,%x]",\
7914 rbType, rbId, lcId, ueCfgDb->numRlcLcs, ueCfgDb->numMacLcs, ueCfgDb->numDrb);
7916 //TODO: To send the failure cause in UeContextSetupRsp
7920 /*******************************************************************
7922 * @brief DeAlloc pdsch serv cell config info
7926 * Function : freeMacPdschServCellInfo
7928 * Functionality: DeAlloc pdsch serv cell config info
7930 * @params[in] PdschServCellCfg pointer
7933 * ****************************************************************/
7935 void freeMacPdschServCellInfo(PdschServCellCfg *pdsch)
7937 if(pdsch->xOverhead)
7939 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->xOverhead, sizeof(PdschXOverhead));
7941 if(pdsch->codeBlkGrpFlushInd)
7943 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->codeBlkGrpFlushInd, sizeof(bool));
7945 if(pdsch->maxCodeBlkGrpPerTb)
7947 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
7949 if(pdsch->maxMimoLayers)
7951 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->maxMimoLayers, sizeof(uint8_t));
7955 /*******************************************************************
7957 * @brief Free Serving cell Info
7961 * Function : freeMacServingCellInfo
7963 * Functionality: Free Serving cell Info
7965 * @params[in] ServCellCfgInfo *srvCellCfg
7968 * ****************************************************************/
7969 void freeMacServingCellInfo(ServCellCfgInfo *srvCellCfg)
7971 uint8_t timeDomRsrcIdx;
7973 if(srvCellCfg->initDlBwp.pdschPresent)
7975 for(timeDomRsrcIdx = 0; timeDomRsrcIdx < srvCellCfg->initDlBwp.pdschCfg.numTimeDomRsrcAlloc; timeDomRsrcIdx++)
7977 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, \
7978 srvCellCfg->initDlBwp.pdschCfg.timeDomRsrcAllociList[timeDomRsrcIdx].k0, sizeof(uint8_t));
7982 freeMacPdschServCellInfo(&srvCellCfg->pdschServCellCfg);
7983 if(srvCellCfg->bwpInactivityTmr)
7985 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, srvCellCfg->bwpInactivityTmr, sizeof(uint8_t));
7988 if(srvCellCfg->initUlBwp.pucchPresent)
7990 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, srvCellCfg->initUlBwp.pucchCfg.dlDataToUlAck, sizeof(PucchDlDataToUlAck));
7994 /*******************************************************************
7996 * @brief Free cell Grp Cfg Info
8000 * Function : freeUeReCfgCellGrpInfo
8002 * Functionality: Free cell Grp Cfg Info
8004 * @params[in] MacUeCfg* duUeCfg
8007 * ****************************************************************/
8009 void freeUeReCfgCellGrpInfo(MacUeCfg *macUeCfg)
8011 freeMacServingCellInfo(&macUeCfg->spCellCfg.servCellCfg);
8014 /*******************************************************************
8016 * @brief Fills Reconfig SchReqReConfig
8020 * Function : extractSchReqReConfig
8022 * Functionality: Fills Reconfig SchReqReConfig
8024 * @params[in] SchedulingRequestConfig_t *cuSchedReq
8025 * SchedReqCfg* macSchedReq
8028 * ****************************************************************/
8029 void extractSchReqReConfig(SchedulingRequestConfig_t *cuSchedReq, SchedReqCfg *macSchedReq)
8031 uint8_t schReqIdx = 0;
8032 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqListToAdd = NULLP;
8033 struct SchedulingRequestConfig__schedulingRequestToReleaseList *schReqListToRel = NULLP;
8035 if(cuSchedReq->schedulingRequestToAddModList)
8037 schReqListToAdd = cuSchedReq->schedulingRequestToAddModList;
8038 if(schReqListToAdd->list.count)
8040 macSchedReq->addModListCount = schReqListToAdd->list.count;
8041 for(schReqIdx = 0; schReqIdx < schReqListToAdd->list.count; schReqIdx++)
8043 macSchedReq->addModList[schReqIdx].schedReqId = \
8044 schReqListToAdd->list.array[schReqIdx]->schedulingRequestId;
8045 macSchedReq->addModList[schReqIdx].srProhibitTmr = \
8046 *(schReqListToAdd->list.array[schReqIdx]->sr_ProhibitTimer);
8047 macSchedReq->addModList[schReqIdx].srTransMax =\
8048 schReqListToAdd->list.array[schReqIdx]->sr_TransMax;
8052 /* Scheduling Req To release */
8053 if(cuSchedReq->schedulingRequestToReleaseList)
8055 schReqListToRel = cuSchedReq->schedulingRequestToReleaseList;
8056 if(schReqListToRel->list.count)
8058 macSchedReq->relListCount = schReqListToRel->list.count;
8059 for(schReqIdx = 0; schReqIdx < schReqListToRel->list.count; schReqIdx++)
8061 macSchedReq->relList[schReqIdx] = \
8062 *schReqListToRel->list.array[schReqIdx];
8068 /*******************************************************************
8070 * @brief Fills TagReconfig
8074 * Function : extractTagReconfig
8076 * Functionality: Fills extractTagReconfig
8078 * @params[in] TAG_Config_t *cuTagCfg
8082 * ****************************************************************/
8084 void extractTagReconfig(TAG_Config_t *cuTagCfg, TagCfg *macTagCfg)
8087 struct TAG_Config__tag_ToAddModList *tagListToAddMod = NULLP;
8088 struct TAG_Config__tag_ToReleaseList *tagListToRel = NULLP;
8090 /* Tag config to AddMod */
8091 if(cuTagCfg->tag_ToAddModList)
8093 tagListToAddMod = cuTagCfg->tag_ToAddModList;
8094 if(tagListToAddMod->list.count)
8096 macTagCfg->addModListCount = tagListToAddMod->list.count;
8097 for(tagIdx = 0; tagIdx < tagListToAddMod->list.count; tagIdx++)
8099 macTagCfg->addModList[tagIdx].tagId =\
8100 tagListToAddMod->list.array[tagIdx]->tag_Id;
8101 macTagCfg->addModList[tagIdx].timeAlignTimer = \
8103 tagListToAddMod->list.array[tagIdx]->timeAlignmentTimer;
8107 /* Tag config to release */
8108 if(cuTagCfg->tag_ToReleaseList)
8110 tagListToRel = cuTagCfg->tag_ToReleaseList;
8111 if(tagListToRel->list.count)
8113 macTagCfg->relListCount = tagListToRel->list.count;
8114 for(tagIdx = 0; tagIdx < tagListToRel->list.count; tagIdx++)
8116 macTagCfg->relList[tagIdx] = *tagListToRel->list.array[tagIdx];
8122 /*******************************************************************
8124 * @brief Fills PdcchCfg received by CU
8128 * Function : extractPdcchCfg
8130 * Functionality: Fills PdcchCfg received by CU
8132 * @params[in] PDCCH_Config_t *cuPdcchCfg,
8133 * PdcchConfig *duPdcchCfg
8136 * ****************************************************************/
8138 void extractPdcchCfg(PDCCH_Config_t *cuPdcchCfg, PdcchConfig *macPdcchCfg)
8140 uint8_t cRsetIdx = 0;
8141 uint8_t srchSpcIdx = 0;
8143 struct PDCCH_Config__controlResourceSetToAddModList *cRsetToAddModList = NULLP;
8144 struct PDCCH_Config__controlResourceSetToReleaseList *cRsetToRelList = NULLP;
8145 struct PDCCH_Config__searchSpacesToAddModList *srchSpcToAddModList = NULLP;
8146 struct PDCCH_Config__searchSpacesToReleaseList *srchSpcToRelList = NULLP;
8149 /* Control Resource Set To Add/Mod List */
8150 if(cuPdcchCfg->controlResourceSetToAddModList)
8152 cRsetToAddModList = cuPdcchCfg->controlResourceSetToAddModList;
8153 if(cRsetToAddModList->list.count)
8155 macPdcchCfg->numCRsetToAddMod = cRsetToAddModList->list.count;
8156 for(cRsetIdx = 0; cRsetIdx < cRsetToAddModList->list.count; cRsetIdx++)
8158 macPdcchCfg->cRSetToAddModList[cRsetIdx].cRSetId = \
8159 cRsetToAddModList->list.array[cRsetIdx]->controlResourceSetId;
8160 //freqDomRsrcBitStringToInt(&cRsetToAddModList->list.array[cRsetIdx]->frequencyDomainResources,\
8161 macPdcchCfg->cRSetToAddModList[cRsetIdx].freqDomainRsrc);
8162 memcpy(macPdcchCfg->cRSetToAddModList[cRsetIdx].freqDomainRsrc, \
8163 cRsetToAddModList->list.array[cRsetIdx]->frequencyDomainResources.buf,
8164 cRsetToAddModList->list.array[cRsetIdx]->frequencyDomainResources.size);
8166 macPdcchCfg->cRSetToAddModList[cRsetIdx].duration = \
8167 cRsetToAddModList->list.array[cRsetIdx]->duration;
8169 macPdcchCfg->cRSetToAddModList[cRsetIdx].cceRegMappingType = \
8170 cRsetToAddModList->list.array[cRsetIdx]->cce_REG_MappingType.present;
8171 if(macPdcchCfg->cRSetToAddModList[cRsetIdx].cceRegMappingType == CCE_REG_MAPPINGTYPE_PR_INTERLEAVED)
8173 //TODO: handle the case for Interleaved
8175 macPdcchCfg->cRSetToAddModList[cRsetIdx].precoderGranularity = \
8176 cRsetToAddModList->list.array[cRsetIdx]->precoderGranularity;
8177 if(cRsetToAddModList->list.array[cRsetIdx]->pdcch_DMRS_ScramblingID)
8179 macPdcchCfg->cRSetToAddModList[cRsetIdx].dmrsScramblingId= \
8180 *(cRsetToAddModList->list.array[cRsetIdx]->pdcch_DMRS_ScramblingID);
8185 /* Control Resource Set To Release List */
8186 if(cuPdcchCfg->controlResourceSetToReleaseList)
8188 cRsetToRelList = cuPdcchCfg->controlResourceSetToReleaseList;
8189 if(cRsetToRelList->list.count)
8191 macPdcchCfg->numCRsetToRel = cRsetToRelList->list.count;
8192 for(cRsetIdx = 0; cRsetIdx < cRsetToRelList->list.count; cRsetIdx++)
8194 macPdcchCfg->cRSetToRelList[cRsetIdx] = *(cRsetToRelList->list.array[cRsetIdx]);
8199 /* Search space To Add/Mod List */
8200 if(cuPdcchCfg->searchSpacesToAddModList)
8202 srchSpcToAddModList = cuPdcchCfg->searchSpacesToAddModList;
8203 if(srchSpcToAddModList->list.count)
8205 macPdcchCfg->numSearchSpcToAddMod = srchSpcToAddModList->list.count;
8206 for(srchSpcIdx = 0; srchSpcIdx < srchSpcToAddModList->list.count; srchSpcIdx++)
8208 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceId =\
8209 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceId;
8210 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].cRSetId =\
8211 *(srchSpcToAddModList->list.array[srchSpcIdx]->controlResourceSetId);
8212 if(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSlotPeriodicityAndOffset)
8214 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].mSlotPeriodicityAndOffset =\
8215 srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSlotPeriodicityAndOffset->present;
8217 if(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSymbolsWithinSlot)
8219 bitStringToInt(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSymbolsWithinSlot,\
8220 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].mSymbolsWithinSlot);
8222 if(srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates)
8224 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel1 = \
8225 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel1;
8226 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel2 = \
8227 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel2;
8228 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel4 = \
8229 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel4;
8231 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel8 = \
8232 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel8;
8234 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel16 = \
8235 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel16;
8237 if(srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType)
8239 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceType =\
8240 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType->present;
8241 if(macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceType == SEARCHSPACETYPE_PR_UE_SPECIFIC)
8243 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].ueSpecificDciFormat =\
8244 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType->choice.ue_Specific->dci_Formats;
8251 /* Search space To Rel List */
8252 if(cuPdcchCfg->searchSpacesToReleaseList)
8254 srchSpcToRelList = cuPdcchCfg->searchSpacesToReleaseList;
8255 if(srchSpcToRelList->list.count)
8257 macPdcchCfg->numSearchSpcToRel = srchSpcToRelList->list.count;
8258 for(srchSpcIdx = 0; srchSpcIdx < srchSpcToRelList->list.count; srchSpcIdx++)
8260 macPdcchCfg->searchSpcToRelList[srchSpcIdx] =\
8261 *(srchSpcToRelList->list.array[srchSpcIdx]);
8267 /*******************************************************************
8269 * @brief Fills PdschCfg received by CU
8273 * Function : extractPdschCfg
8275 * Functionality: Fills PdschCfg received by CU
8277 * @params[in] PDSCH_Config_t *cuPdschCfg = Information which is send by CU,
8278 * which we have stored in F1UeContextSetupDb,
8279 * PdschConfig *macPdschCfg = Used to Store the information which
8280 * needs to send in other layer, as well as this can be the variable
8281 * which stores the information in DuCb,
8282 * PdschConfig *storedPdschCfg = Null in case of sending the
8283 * information to other layer else it will have stored pdsch
8284 * configuration in copyOfmacUeCfg.
8287 * ****************************************************************/
8289 void extractPdschCfg(PDSCH_Config_t *cuPdschCfg, PdschConfig *macPdschCfg, PdschConfig *storedPdschCfg)
8292 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAlloc = NULLP;
8294 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
8296 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->present == \
8297 PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA_PR_setup)
8299 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)
8301 macPdschCfg->dmrsDlCfgForPdschMapTypeA.addPos = \
8302 *(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition);
8306 macPdschCfg->resourceAllocType = cuPdschCfg->resourceAllocation;
8307 if(cuPdschCfg->pdsch_TimeDomainAllocationList)
8309 timeDomAlloc = cuPdschCfg->pdsch_TimeDomainAllocationList;
8310 if(timeDomAlloc->present ==\
8311 PDSCH_Config__pdsch_TimeDomainAllocationList_PR_setup)
8313 if(timeDomAlloc->choice.setup)
8315 macPdschCfg->numTimeDomRsrcAlloc = timeDomAlloc->choice.setup->list.count;
8316 for(timeDomIdx = 0; timeDomIdx < timeDomAlloc->choice.setup->list.count; timeDomIdx++)
8318 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0 = NULLP;
8319 if(timeDomAlloc->choice.setup->list.array[timeDomIdx]->k0)
8321 if(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0 == NULL)
8325 if(storedPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0)
8327 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0 =\
8328 storedPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0;
8332 DU_ALLOC_SHRABL_BUF(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0, sizeof(uint8_t));
8337 DU_ALLOC_SHRABL_BUF(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0, sizeof(uint8_t));
8339 if(!macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0)
8341 DU_LOG("\nERROR --> DU APP : Memory allocation failed for k0 at extractPdschCfg()");
8345 *(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0) = \
8346 *(timeDomAlloc->choice.setup->list.array[timeDomIdx]->k0);
8348 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].mappingType = \
8349 timeDomAlloc->choice.setup->list.array[timeDomIdx]->mappingType;
8350 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].startSymbolAndLength = \
8351 timeDomAlloc->choice.setup->list.array[timeDomIdx]->startSymbolAndLength;
8356 macPdschCfg->rbgSize = cuPdschCfg->rbg_Size;
8357 if(cuPdschCfg->maxNrofCodeWordsScheduledByDCI)
8358 macPdschCfg->numCodeWordsSchByDci = *(cuPdschCfg->maxNrofCodeWordsScheduledByDCI);
8359 if(cuPdschCfg->prb_BundlingType.present == PDSCH_Config__prb_BundlingType_PR_staticBundling)
8361 macPdschCfg->bundlingType = cuPdschCfg->prb_BundlingType.present;
8362 if(cuPdschCfg->prb_BundlingType.choice.staticBundling)
8364 if(cuPdschCfg->prb_BundlingType.choice.staticBundling->bundleSize)
8366 macPdschCfg->bundlingInfo.StaticBundling.size = \
8367 *(cuPdschCfg->prb_BundlingType.choice.staticBundling->bundleSize);
8371 else if(cuPdschCfg->prb_BundlingType.present == PDSCH_Config__prb_BundlingType_PR_dynamicBundling)
8373 macPdschCfg->bundlingType = cuPdschCfg->prb_BundlingType.present;
8378 /*******************************************************************
8380 * @brief Fills PdschServingCellCfg received by CU
8384 * Function : extractPdschServingCellCfg
8386 * Functionality: Fills PdschCfg received by CU
8388 * @params[in] PDSCH_ServingCellConfig_t *cuPdschSrvCellCfg,
8389 * PdschServCellCfg *macUePdschSrvCellCfg
8390 * @return ROK/RFAILED
8392 * ****************************************************************/
8394 uint8_t extractPdschServingCellCfg(PDSCH_ServingCellConfig_t *cuPdschSrvCellCfg, PdschServCellCfg *macUePdschSrvCellCfg)
8396 if(cuPdschSrvCellCfg->codeBlockGroupTransmission)
8398 if(cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup)
8400 if(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb)
8402 *(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb) = \
8403 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock;
8407 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
8408 if(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb)
8410 *(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb) = \
8411 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock;
8415 DU_LOG("\nERROR --> DU APP : Memory allocation failed for maxCodeBlkGrpPerTb at extractPdschServingCellCfg()");
8419 if(macUePdschSrvCellCfg->codeBlkGrpFlushInd)
8421 *(macUePdschSrvCellCfg->codeBlkGrpFlushInd) = \
8422 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->codeBlockGroupFlushIndicator;
8426 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->codeBlkGrpFlushInd , sizeof(bool));
8427 if(macUePdschSrvCellCfg->codeBlkGrpFlushInd)
8429 *(macUePdschSrvCellCfg->codeBlkGrpFlushInd) = \
8430 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->codeBlockGroupFlushIndicator;
8434 DU_LOG("\nERROR --> DU APP : Memory allocation failed for codeBlkGrpFlushInd at extractPdschServingCellCfg()");
8440 if(cuPdschSrvCellCfg->nrofHARQ_ProcessesForPDSCH)
8442 macUePdschSrvCellCfg->numHarqProcForPdsch = *(cuPdschSrvCellCfg->nrofHARQ_ProcessesForPDSCH);
8444 if(cuPdschSrvCellCfg->ext1)
8446 if(cuPdschSrvCellCfg->ext1->maxMIMO_Layers)
8448 if(macUePdschSrvCellCfg->maxMimoLayers)
8450 *(macUePdschSrvCellCfg->maxMimoLayers) = *(cuPdschSrvCellCfg->ext1->maxMIMO_Layers);
8454 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->maxMimoLayers, sizeof(uint8_t));
8455 if(macUePdschSrvCellCfg->maxMimoLayers)
8457 *(macUePdschSrvCellCfg->maxMimoLayers) = *(cuPdschSrvCellCfg->ext1->maxMIMO_Layers);
8461 DU_LOG("\nERROR --> DU APP : Memory allocation failed for maxMimoLayers at extractPdschServingCellCfg()");
8467 if(cuPdschSrvCellCfg->xOverhead)
8469 if(macUePdschSrvCellCfg->xOverhead)
8471 *(macUePdschSrvCellCfg->xOverhead) = *(cuPdschSrvCellCfg->xOverhead);
8475 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->xOverhead, sizeof(PdschXOverhead));
8476 if(macUePdschSrvCellCfg->xOverhead)
8478 *(macUePdschSrvCellCfg->xOverhead) = *(cuPdschSrvCellCfg->xOverhead);
8482 DU_LOG("\nERROR --> DU APP : Memory allocation failed for xOverhead at extractPdschServingCellCfg()");
8490 /*******************************************************************
8492 * @brief Fills PuschCfg received by CU
8496 * Function : extractPuschCfg
8498 * Functionality: Fills PuschCfg received by CU
8500 * @params[in] BWP_UplinkDedicated__pusch_Config *cuPuschCfg,
8501 * PuschCfg *macPuschCfg
8504 * ****************************************************************/
8506 void extractPuschCfg(struct BWP_UplinkDedicated__pusch_Config *cuPuschCfg, PuschCfg *macPuschCfg)
8508 uint8_t timeDomIdx = 0;
8509 DMRS_UplinkConfig_t *dmrsUlCfg = NULLP;
8510 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList = NULLP;
8512 if(cuPuschCfg->present == BWP_UplinkDedicated__pusch_Config_PR_setup)
8514 if(cuPuschCfg->choice.setup)
8516 if(cuPuschCfg->choice.setup->dataScramblingIdentityPUSCH)
8518 macPuschCfg->dataScramblingId = \
8519 *(cuPuschCfg->choice.setup->dataScramblingIdentityPUSCH);
8521 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA)
8523 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->present == PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA_PR_setup)
8525 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup)
8527 dmrsUlCfg = (cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup);
8528 if(dmrsUlCfg->dmrs_AdditionalPosition)
8530 macPuschCfg->dmrsUlCfgForPuschMapTypeA.addPos =\
8531 *(dmrsUlCfg->dmrs_AdditionalPosition);
8533 if(dmrsUlCfg->transformPrecodingDisabled)
8535 if(dmrsUlCfg->transformPrecodingDisabled->scramblingID0)
8537 macPuschCfg->dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0 = \
8538 *(dmrsUlCfg->transformPrecodingDisabled->scramblingID0);
8544 /*Res Alloc Type for UL */
8545 if(cuPuschCfg->choice.setup->resourceAllocation)
8547 macPuschCfg->resourceAllocType = \
8548 cuPuschCfg->choice.setup->resourceAllocation;
8550 if(cuPuschCfg->choice.setup->pusch_TimeDomainAllocationList)
8552 timeDomAllocList = cuPuschCfg->choice.setup->pusch_TimeDomainAllocationList;
8553 if(timeDomAllocList->present == PUSCH_Config__pusch_TimeDomainAllocationList_PR_setup)
8555 if(timeDomAllocList->choice.setup)
8557 macPuschCfg->numTimeDomRsrcAlloc = timeDomAllocList->choice.setup->list.count;
8558 for(timeDomIdx = 0; timeDomIdx <timeDomAllocList->choice.setup->list.count; timeDomIdx++)
8560 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].k2 = \
8561 *(timeDomAllocList->choice.setup->list.array[timeDomIdx]->k2);
8562 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].mappingType = \
8563 timeDomAllocList->choice.setup->list.array[timeDomIdx]->mappingType;
8564 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].startSymbolAndLength = \
8565 timeDomAllocList->choice.setup->list.array[timeDomIdx]->startSymbolAndLength;
8570 if(cuPuschCfg->choice.setup->transformPrecoder)
8571 macPuschCfg->transformPrecoder = *(cuPuschCfg->choice.setup->transformPrecoder);
8576 /*******************************************************************
8578 * @brief Function to fill pucch Power Control
8582 * Function : extractPucchPowerControl
8584 * Functionality: Function to fill pucch Power Control
8586 * @params[in] PucchPowerControl *pwrCtrl,
8587 * struct PUCCH_PowerControl *cuPwrCtrlCfg
8590 * ****************************************************************/
8592 void extractPucchPowerControl(PucchPowerControl *pwrCtrl, struct PUCCH_PowerControl *cuPwrCtrlCfg)
8596 if(cuPwrCtrlCfg->deltaF_PUCCH_f0)
8597 pwrCtrl->deltaF_Format0 = *cuPwrCtrlCfg->deltaF_PUCCH_f0;
8598 if(cuPwrCtrlCfg->deltaF_PUCCH_f1)
8599 pwrCtrl->deltaF_Format1 = *cuPwrCtrlCfg->deltaF_PUCCH_f1;
8600 if(cuPwrCtrlCfg->deltaF_PUCCH_f2)
8601 pwrCtrl->deltaF_Format2 = *cuPwrCtrlCfg->deltaF_PUCCH_f2;
8602 if(cuPwrCtrlCfg->deltaF_PUCCH_f3)
8603 pwrCtrl->deltaF_Format3 = *cuPwrCtrlCfg->deltaF_PUCCH_f3;
8604 if(cuPwrCtrlCfg->deltaF_PUCCH_f4)
8605 pwrCtrl->deltaF_Format4 = *cuPwrCtrlCfg->deltaF_PUCCH_f4;
8606 if(cuPwrCtrlCfg->p0_Set)
8608 pwrCtrl->p0SetCount = cuPwrCtrlCfg->p0_Set->list.count;
8609 for(arrIdx=0; arrIdx < pwrCtrl->p0SetCount; arrIdx++)
8611 pwrCtrl->p0Set[arrIdx].p0PucchId =\
8612 cuPwrCtrlCfg->p0_Set->list.array[arrIdx]->p0_PUCCH_Id;
8613 pwrCtrl->p0Set[arrIdx].p0PucchVal =\
8614 cuPwrCtrlCfg->p0_Set->list.array[arrIdx]->p0_PUCCH_Value;
8617 if(cuPwrCtrlCfg->pathlossReferenceRSs)
8619 pwrCtrl->pathLossRefRSListCount = cuPwrCtrlCfg->pathlossReferenceRSs->list.count;
8620 for(arrIdx = 0; arrIdx < pwrCtrl->pathLossRefRSListCount; arrIdx++)
8622 pwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId =\
8623 cuPwrCtrlCfg->pathlossReferenceRSs->list.array[arrIdx]->pucch_PathlossReferenceRS_Id;
8628 /*******************************************************************
8630 * @brief Function to extractResrcSetToAddModList sent by CU
8634 * Function : extractResrcSetToAddModList
8636 * Functionality: Fucntion to extractResrcSetToAddModList
8638 * @params[in] PucchResrcSetCfg pointer,
8639 * struct PUCCH_Config__resourceSetToAddModList pointer
8642 * ****************************************************************/
8644 void extractResrcSetToAddModList(PucchResrcSetCfg *macRsrcSetList, struct PUCCH_Config__resourceSetToAddModList *cuRsrcSetList)
8646 uint8_t arrIdx, rsrcListIdx;
8648 macRsrcSetList->resrcSetToAddModListCount = cuRsrcSetList->list.count;
8649 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToAddModListCount; arrIdx++)
8651 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId =\
8652 cuRsrcSetList->list.array[arrIdx]->pucch_ResourceSetId;
8653 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount =\
8654 cuRsrcSetList->list.array[arrIdx]->resourceList.list.count;
8655 for(rsrcListIdx = 0; rsrcListIdx < macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount; rsrcListIdx++)
8657 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx] =\
8658 *cuRsrcSetList->list.array[arrIdx]->resourceList.list.array[rsrcListIdx];
8660 macRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize =\
8661 *cuRsrcSetList->list.array[arrIdx]->maxPayloadMinus1;
8663 }/* End of extractResrcSetToAddModList */
8665 /*******************************************************************
8667 * @brief Fills extractResrcToAddModList sent by CU
8671 * Function : extractResrcToAddModList
8673 * Functionality: Fills extractResrcToAddModList
8675 * @params[in] PucchResrcCfg pointer,
8676 * struct PUCCH_Config__resourceToAddModList pointer
8677 * @return ROk/RFAILED
8679 * ****************************************************************/
8681 uint8_t extractResrcToAddModList(PucchResrcCfg *macResrcList, struct PUCCH_Config__resourceToAddModList *cuResrcList)
8685 macResrcList->resrcToAddModListCount = cuResrcList->list.count;
8686 for(arrIdx = 0; arrIdx < macResrcList->resrcToAddModListCount; arrIdx++)
8688 macResrcList->resrcToAddModList[arrIdx].resrcId =\
8689 cuResrcList->list.array[arrIdx]->pucch_ResourceId;
8690 macResrcList->resrcToAddModList[arrIdx].startPrb =\
8691 cuResrcList->list.array[arrIdx]->startingPRB;
8692 if(cuResrcList->list.array[arrIdx]->intraSlotFrequencyHopping)
8694 macResrcList->resrcToAddModList[arrIdx].intraFreqHop =\
8695 *cuResrcList->list.array[arrIdx]->intraSlotFrequencyHopping;
8697 if(cuResrcList->list.array[arrIdx]->secondHopPRB)
8699 macResrcList->resrcToAddModList[arrIdx].secondPrbHop =\
8700 *cuResrcList->list.array[arrIdx]->secondHopPRB;
8702 /* PUCCH RSRC FORMAT */
8703 if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format0)
8705 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_0;
8706 if(cuResrcList->list.array[arrIdx]->format.choice.format0)
8708 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0, sizeof(PucchFormat0));
8709 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0 == NULLP)
8711 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format0 in extractResrcToAddModList()");
8714 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->initialCyclicShift =\
8715 cuResrcList->list.array[arrIdx]->format.choice.format0->initialCyclicShift;
8716 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->numSymbols =\
8717 cuResrcList->list.array[arrIdx]->format.choice.format0->nrofSymbols;
8718 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->startSymbolIdx =\
8719 cuResrcList->list.array[arrIdx]->format.choice.format0->startingSymbolIndex;
8722 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format1)
8724 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_1;
8725 if(cuResrcList->list.array[arrIdx]->format.choice.format1)
8727 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1, sizeof(PucchFormat1));
8728 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1 == NULLP)
8730 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format1 in extractResrcToAddModList()");
8733 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->initialCyclicShift =\
8734 cuResrcList->list.array[arrIdx]->format.choice.format1->initialCyclicShift;
8735 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->numSymbols =\
8736 cuResrcList->list.array[arrIdx]->format.choice.format1->nrofSymbols;
8737 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->startSymbolIdx =\
8738 cuResrcList->list.array[arrIdx]->format.choice.format1->startingSymbolIndex;
8739 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->timeDomOCC =\
8740 cuResrcList->list.array[arrIdx]->format.choice.format1->timeDomainOCC;
8743 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format2)
8745 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_2;
8746 if(cuResrcList->list.array[arrIdx]->format.choice.format2)
8748 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2, sizeof(PucchFormat2_3));
8749 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2 == NULLP)
8751 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format2 in extractResrcToAddModList()");
8754 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->numPrbs =\
8755 cuResrcList->list.array[arrIdx]->format.choice.format2->nrofPRBs;
8756 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->numSymbols =\
8757 cuResrcList->list.array[arrIdx]->format.choice.format2->nrofSymbols;
8758 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->startSymbolIdx =\
8759 cuResrcList->list.array[arrIdx]->format.choice.format2->startingSymbolIndex;
8762 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format3)
8764 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_3;
8765 if(cuResrcList->list.array[arrIdx]->format.choice.format3)
8767 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3, sizeof(PucchFormat2_3));
8768 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3 == NULLP)
8770 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format3 in extractResrcToAddModList()");
8773 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->numPrbs =\
8774 cuResrcList->list.array[arrIdx]->format.choice.format3->nrofPRBs;
8775 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->numSymbols =\
8776 cuResrcList->list.array[arrIdx]->format.choice.format3->nrofSymbols;
8777 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->startSymbolIdx =\
8778 cuResrcList->list.array[arrIdx]->format.choice.format3->startingSymbolIndex;
8781 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format4)
8783 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_4;
8784 if(cuResrcList->list.array[arrIdx]->format.choice.format4)
8786 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4, sizeof(PucchFormat4));
8787 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4 == NULLP)
8789 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format4 in extractResrcToAddModList()");
8792 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->numSymbols =\
8793 cuResrcList->list.array[arrIdx]->format.choice.format4->nrofSymbols;
8794 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->occLen =\
8795 cuResrcList->list.array[arrIdx]->format.choice.format4->occ_Length;
8796 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->occIdx =\
8797 cuResrcList->list.array[arrIdx]->format.choice.format4->occ_Index;
8798 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->startSymbolIdx =\
8799 cuResrcList->list.array[arrIdx]->format.choice.format4->startingSymbolIndex;
8805 }/* End of extractResrcToAddModList */
8807 /*******************************************************************
8809 * @brief Fills fillPucchSchedReqPeriodAndOffset sent by CU
8813 * Function : fillPucchSchedReqPeriodAndOffset
8815 * Functionality: To fillPucchSchedReqPeriodAndOffset
8817 * @params[in] macPeriodicty,
8818 * SchedulingRequestResourceConfig__periodicityAndOffset pointer
8821 * ****************************************************************/
8823 void fillPucchSchedReqPeriodAndOffset(uint8_t macPeriodicty, uint16_t macOffset,\
8824 struct SchedulingRequestResourceConfig__periodicityAndOffset *cuPeriodicty)
8826 macPeriodicty = cuPeriodicty->present;
8827 switch(macPeriodicty)
8829 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sym2:
8831 macOffset = cuPeriodicty->choice.sym2;
8834 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sym6or7:
8836 macOffset = cuPeriodicty->choice.sym6or7;
8839 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl1:
8841 macOffset = cuPeriodicty->choice.sl1;
8844 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl2:
8846 macOffset = cuPeriodicty->choice.sl2;
8849 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl4:
8851 macOffset = cuPeriodicty->choice.sl4;
8854 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl5:
8856 macOffset = cuPeriodicty->choice.sl5;
8859 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl8:
8861 macOffset = cuPeriodicty->choice.sl8;
8864 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl10:
8866 macOffset = cuPeriodicty->choice.sl10;
8869 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl16:
8871 macOffset = cuPeriodicty->choice.sl16;
8874 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl20:
8876 macOffset = cuPeriodicty->choice.sl20;
8879 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl40:
8881 macOffset = cuPeriodicty->choice.sl40;
8884 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl80:
8886 macOffset = cuPeriodicty->choice.sl80;
8889 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl160:
8891 macOffset = cuPeriodicty->choice.sl160;
8894 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl320:
8896 macOffset = cuPeriodicty->choice.sl320;
8899 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl640:
8901 macOffset = cuPeriodicty->choice.sl640;
8905 DU_LOG("\nERROR --> F1AP : Invalid periodicity %d", macPeriodicty);
8909 /*******************************************************************
8911 * @brief Function to extractPucchFormatCfg sent by CU
8915 * Function : extractPucchFormatCfg
8917 * Functionality: Function to extractPucchFormatCfg
8919 * @params[in] PucchFormatCfg pointer,
8920 * PUCCH_FormatConfig_t pointer
8923 * ****************************************************************/
8925 void extractPucchFormatCfg(PucchFormatCfg *macFormatCfg, PUCCH_FormatConfig_t *cuFormatCfg)
8927 if(cuFormatCfg->interslotFrequencyHopping)
8928 macFormatCfg->interSlotFreqHop = *cuFormatCfg->interslotFrequencyHopping;
8929 if(cuFormatCfg->additionalDMRS)
8930 macFormatCfg->addDmrs = *cuFormatCfg->additionalDMRS;
8931 if(cuFormatCfg->maxCodeRate)
8932 macFormatCfg->maxCodeRate = *cuFormatCfg->maxCodeRate;
8933 if(cuFormatCfg->nrofSlots)
8934 macFormatCfg->numSlots = *cuFormatCfg->nrofSlots;
8935 if(cuFormatCfg->pi2BPSK)
8936 macFormatCfg->pi2BPSK = *cuFormatCfg->pi2BPSK;
8937 if(cuFormatCfg->simultaneousHARQ_ACK_CSI)
8938 macFormatCfg->harqAckCSI = *cuFormatCfg->simultaneousHARQ_ACK_CSI;
8939 }/* End of extractPucchFormatCfg */
8941 /*******************************************************************
8943 * @brief Function to extractSchedReqCfgToAddMod sent by CU
8947 * Function : extractSchedReqCfgToAddMod
8949 * Functionality: Function to extractSchedReqCfgToAddMod
8951 * @params[in] PucchSchedReqCfg pointer,
8952 * PUCCH_Config__schedulingRequestResourceToAddModList pointer
8955 * ****************************************************************/
8957 void extractSchedReqCfgToAddMod(PucchSchedReqCfg *macSchedReqCfg, struct PUCCH_Config__schedulingRequestResourceToAddModList *cuSchedReqList)
8961 macSchedReqCfg->schedAddModListCount = cuSchedReqList->list.count;
8962 for(arrIdx = 0; arrIdx < macSchedReqCfg->schedAddModListCount; arrIdx++)
8964 macSchedReqCfg->schedAddModList[arrIdx].resrcId =\
8965 cuSchedReqList->list.array[arrIdx]->schedulingRequestResourceId;
8966 macSchedReqCfg->schedAddModList[arrIdx].requestId =\
8967 cuSchedReqList->list.array[arrIdx]->schedulingRequestID;
8968 if(cuSchedReqList->list.array[arrIdx]->periodicityAndOffset)
8970 fillPucchSchedReqPeriodAndOffset(macSchedReqCfg->schedAddModList[arrIdx].periodicity,\
8971 macSchedReqCfg->schedAddModList[arrIdx].offset, cuSchedReqList->list.array[arrIdx]->periodicityAndOffset);
8973 if(cuSchedReqList->list.array[arrIdx]->resource)
8975 macSchedReqCfg->schedAddModList[arrIdx].resrc =\
8976 *cuSchedReqList->list.array[arrIdx]->resource;
8980 }/* End of extractSchedReqCfgToAddMod */
8982 /*******************************************************************
8984 * @brief Fills PucchCfg received by CU
8988 * Function : extractPucchCfg
8990 * Functionality: Fills PucchCfg received by CU
8992 * @params[in] BWP_UplinkDedicated__pucch_Config *cuPucchCfg = Information which
8993 * is send by CU, which we have stored in F1UeContextSetupDb,
8994 * PucchCfg *macPucchCfg = Used to Store the information which
8995 * needs to send in other layer, as well as this can be the variable
8996 * which stores the information in DuCb,
8997 * PucchCfg *storedPucchCfg = Null in case of sending the
8998 * information to other layer else it will have Pucch Cfg which
8999 * we have stored in copyOfmacUeCfg.
9000 * @return ROK/RFAILED
9002 * ****************************************************************/
9004 uint8_t extractPucchCfg(struct BWP_UplinkDedicated__pucch_Config *cuPucchCfg, PucchCfg *macPucchCfg,\
9005 PucchCfg *storedPucchCfg)
9009 if(cuPucchCfg->present == BWP_UplinkDedicated__pucch_Config_PR_setup)
9011 if(cuPucchCfg->choice.setup)
9013 /* Resource Set Cfg */
9014 if(cuPucchCfg->choice.setup->resourceSetToAddModList)
9016 DU_ALLOC_SHRABL_BUF(macPucchCfg->resrcSet, sizeof(PucchResrcSetCfg));
9017 if(macPucchCfg->resrcSet == NULLP)
9019 DU_LOG("\nERROR --> F1AP : Failed to extract Resrc set List in extractPucchCfg()");
9022 memset(macPucchCfg->resrcSet, 0, sizeof(PucchResrcSetCfg));
9023 extractResrcSetToAddModList(macPucchCfg->resrcSet, cuPucchCfg->choice.setup->resourceSetToAddModList);
9027 if(cuPucchCfg->choice.setup->resourceToAddModList)
9029 DU_ALLOC_SHRABL_BUF(macPucchCfg->resrc, sizeof(PucchResrcCfg));
9030 if(macPucchCfg->resrc == NULLP)
9032 DU_LOG("\nERROR --> F1AP : Failed to extract Resrc List in extractPucchCfg()");
9035 memset(macPucchCfg->resrc, 0, sizeof(PucchResrcCfg));
9036 extractResrcToAddModList(macPucchCfg->resrc, cuPucchCfg->choice.setup->resourceToAddModList);
9040 if(cuPucchCfg->choice.setup->format1)
9042 DU_ALLOC_SHRABL_BUF(macPucchCfg->format1, sizeof(PucchFormatCfg));
9043 if(macPucchCfg->format1 == NULLP)
9045 DU_LOG("\nERROR --> F1AP : Failed to extract format 1 Cfg in extractPucchCfg()");
9048 memset(macPucchCfg->format1, 0, sizeof(PucchFormatCfg));
9049 extractPucchFormatCfg(macPucchCfg->format1,\
9050 cuPucchCfg->choice.setup->format1->choice.setup);
9054 if(cuPucchCfg->choice.setup->format2)
9056 DU_ALLOC_SHRABL_BUF(macPucchCfg->format2, sizeof(PucchFormatCfg));
9057 if(macPucchCfg->format2 == NULLP)
9059 DU_LOG("\nERROR --> F1AP : Failed to extract format 2 Cfg in extractPucchCfg()");
9062 memset(macPucchCfg->format2, 0, sizeof(PucchFormatCfg));
9063 extractPucchFormatCfg(macPucchCfg->format2,\
9064 cuPucchCfg->choice.setup->format2->choice.setup);
9068 if(cuPucchCfg->choice.setup->format3)
9070 DU_ALLOC_SHRABL_BUF(macPucchCfg->format3, sizeof(PucchFormatCfg));
9071 if(macPucchCfg->format3 == NULLP)
9073 DU_LOG("\nERROR --> F1AP : Failed to extract format 3 Cfg in extractPucchCfg()");
9076 memset(macPucchCfg->format3, 0, sizeof(PucchFormatCfg));
9077 extractPucchFormatCfg(macPucchCfg->format3,\
9078 cuPucchCfg->choice.setup->format3->choice.setup);
9082 if(cuPucchCfg->choice.setup->format4)
9084 DU_ALLOC_SHRABL_BUF(macPucchCfg->format4, sizeof(PucchFormatCfg));
9085 if(macPucchCfg->format4 == NULLP)
9087 DU_LOG("\nERROR --> F1AP : Failed to extract format 4 Cfg in extractPucchCfg()");
9090 memset(macPucchCfg->format4, 0, sizeof(PucchFormatCfg));
9091 extractPucchFormatCfg(macPucchCfg->format4,\
9092 cuPucchCfg->choice.setup->format4->choice.setup);
9095 /* Sched Req List */
9096 if(cuPucchCfg->choice.setup->schedulingRequestResourceToAddModList)
9098 DU_ALLOC_SHRABL_BUF(macPucchCfg->schedReq, sizeof(PucchSchedReqCfg));
9099 if(macPucchCfg->schedReq == NULLP)
9101 DU_LOG("\nERROR --> F1AP : Failed to extract schedReqCfg in extractPucchCfg()");
9104 memset(macPucchCfg->schedReq, 0, sizeof(PucchSchedReqCfg));
9105 extractSchedReqCfgToAddMod(macPucchCfg->schedReq,\
9106 cuPucchCfg->choice.setup->schedulingRequestResourceToAddModList);
9109 /*TODO: Add support for Spatial Info */
9112 if(cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList)
9114 DU_ALLOC_SHRABL_BUF(macPucchCfg->multiCsiCfg, sizeof(PucchMultiCsiCfg));
9115 if(macPucchCfg->multiCsiCfg == NULLP)
9117 DU_LOG("\nERROR --> F1AP : Failed to extract multiCsiCfg in extractPucchCfg()");
9120 memset(macPucchCfg->multiCsiCfg, 0, sizeof(PucchMultiCsiCfg));
9121 macPucchCfg->multiCsiCfg->multiCsiResrcListCount = cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList->list.count;
9122 for(arrIdx =0; arrIdx < macPucchCfg->multiCsiCfg->multiCsiResrcListCount; arrIdx++)
9124 macPucchCfg->multiCsiCfg->multiCsiResrcList[arrIdx] =\
9125 *cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList->list.array[arrIdx];
9129 /* Dl_DataToUL_ACK */
9130 if(cuPucchCfg->choice.setup->dl_DataToUL_ACK)
9134 if(storedPucchCfg->dlDataToUlAck)
9136 macPucchCfg->dlDataToUlAck = storedPucchCfg->dlDataToUlAck;
9140 DU_ALLOC_SHRABL_BUF(macPucchCfg->dlDataToUlAck, sizeof(PucchDlDataToUlAck));
9145 DU_ALLOC_SHRABL_BUF(macPucchCfg->dlDataToUlAck, sizeof(PucchDlDataToUlAck));
9147 if(macPucchCfg->dlDataToUlAck == NULLP)
9149 DU_LOG("\nERROR --> F1AP : Failed to extract Dl_DataToUL_ACK in extractPucchCfg()");
9152 memset(macPucchCfg->dlDataToUlAck, 0, sizeof(PucchDlDataToUlAck));
9153 macPucchCfg->dlDataToUlAck->dlDataToUlAckListCount = cuPucchCfg->choice.setup->dl_DataToUL_ACK->list.count;
9154 for(arrIdx = 0; arrIdx < macPucchCfg->dlDataToUlAck->dlDataToUlAckListCount; arrIdx++)
9156 macPucchCfg->dlDataToUlAck->dlDataToUlAckList[arrIdx] =\
9157 *cuPucchCfg->choice.setup->dl_DataToUL_ACK->list.array[arrIdx];
9162 if(cuPucchCfg->choice.setup->pucch_PowerControl)
9164 DU_ALLOC_SHRABL_BUF(macPucchCfg->powerControl, sizeof(PucchPowerControl));
9165 if(macPucchCfg->powerControl == NULLP)
9167 DU_LOG("\nERROR --> F1AP : Failed to extract power control in extractPucchCfg()");
9170 extractPucchPowerControl(macPucchCfg->powerControl,\
9171 cuPucchCfg->choice.setup->pucch_PowerControl);
9178 /*******************************************************************
9180 * @brief Fills ServingCellReconfig received by CU
9184 * Function : extractSpCellDedicatedCfg
9186 * Functionality: Fills ServingCellReconfig received by CU
9188 * @params[in] ServingCellConfig_t *cuSrvCellCfg = Information which is send by
9189 * CU, which we have stored in F1UeContextSetupDb,
9190 * ServCellCfgInfo *macSrvCellCfg = Used to Store the information
9191 * which needs to send in other layer, as well as this can be the
9192 * variable which stores the information in DuCb,
9193 * ServCellCfgInfo *storedSrvCellCfg = Null in case of sending the
9194 * information to other layer else it will have ServCellCfgInfo which
9195 * we have stored in copyOfmacUeCfg.
9196 * @return ROK/RFAILD
9198 * ****************************************************************/
9199 uint8_t extractSpCellDedicatedCfg(ServingCellConfig_t *cuSrvCellCfg, ServCellCfgInfo *macSrvCellCfg,\
9200 ServCellCfgInfo *storedSrvCellCfg)
9203 BWP_DownlinkDedicated_t *dlBwp = NULLP;
9204 BWP_UplinkDedicated_t *ulBwp = NULLP;
9206 if(cuSrvCellCfg->initialDownlinkBWP)
9208 dlBwp = ((BWP_DownlinkDedicated_t *)(cuSrvCellCfg->initialDownlinkBWP));
9209 if(dlBwp->pdcch_Config)
9211 if(dlBwp->pdcch_Config->choice.setup)
9213 macSrvCellCfg->initDlBwp.pdcchPresent = true;
9214 if(storedSrvCellCfg)
9216 if(!storedSrvCellCfg->initDlBwp.pdcchPresent)
9218 extractPdcchCfg(dlBwp->pdcch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdcchCfg);
9222 extractPdcchCfg(dlBwp->pdcch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdcchCfg);
9227 extractPdcchCfg(dlBwp->pdcch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdcchCfg);
9231 if(dlBwp->pdsch_Config)
9233 if(dlBwp->pdsch_Config->choice.setup)
9235 macSrvCellCfg->initDlBwp.pdschPresent = true;
9237 if(storedSrvCellCfg)
9239 if(!storedSrvCellCfg->initDlBwp.pdschPresent)
9241 extractPdschCfg(dlBwp->pdsch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdschCfg, NULL);
9245 extractPdschCfg(dlBwp->pdsch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdschCfg,\
9246 &storedSrvCellCfg->initDlBwp.pdschCfg);
9251 extractPdschCfg(dlBwp->pdsch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdschCfg, NULL);
9256 if(cuSrvCellCfg->firstActiveDownlinkBWP_Id)
9257 macSrvCellCfg->firstActvDlBwpId = *(cuSrvCellCfg->firstActiveDownlinkBWP_Id);
9258 if(cuSrvCellCfg->defaultDownlinkBWP_Id)
9259 macSrvCellCfg->defaultDlBwpId = *(cuSrvCellCfg->defaultDownlinkBWP_Id);
9260 if(cuSrvCellCfg->bwp_InactivityTimer)
9262 if(macSrvCellCfg->bwpInactivityTmr)
9264 memcpy(macSrvCellCfg->bwpInactivityTmr, cuSrvCellCfg->bwp_InactivityTimer, sizeof(uint8_t));
9268 macSrvCellCfg->bwpInactivityTmr = NULLP;
9269 DU_ALLOC_SHRABL_BUF(macSrvCellCfg->bwpInactivityTmr, sizeof(uint8_t));
9270 if(macSrvCellCfg->bwpInactivityTmr)
9272 memcpy(macSrvCellCfg->bwpInactivityTmr, cuSrvCellCfg->bwp_InactivityTimer, sizeof(uint8_t));
9276 DU_LOG("\nERROR --> F1AP : Memory Alloc failed for bwpInactivityTmr at extractSpCellDedicatedCfg()");
9281 if(cuSrvCellCfg->pdsch_ServingCellConfig)
9283 if(cuSrvCellCfg->pdsch_ServingCellConfig->choice.setup)
9285 ret = extractPdschServingCellCfg(cuSrvCellCfg->pdsch_ServingCellConfig->choice.setup, &macSrvCellCfg->pdschServCellCfg);
9288 DU_LOG("\nERROR --> F1AP : Failed at extractPdschServingCellCfg()");
9293 if(cuSrvCellCfg->uplinkConfig)
9295 if(cuSrvCellCfg->uplinkConfig->initialUplinkBWP)
9297 ulBwp = ((BWP_UplinkDedicated_t *)(cuSrvCellCfg->uplinkConfig->initialUplinkBWP));
9298 if(ulBwp->pusch_Config)
9300 macSrvCellCfg->initUlBwp.puschPresent = true;
9301 extractPuschCfg(ulBwp->pusch_Config, &macSrvCellCfg->initUlBwp.puschCfg);
9303 if(ulBwp->pucch_Config)
9305 macSrvCellCfg->initUlBwp.pucchPresent = true;
9306 memset(&macSrvCellCfg->initUlBwp.pucchCfg, 0, sizeof(PucchCfg));
9307 if(storedSrvCellCfg)
9309 if(!storedSrvCellCfg->initUlBwp.pucchPresent)
9310 extractPucchCfg(ulBwp->pucch_Config, &macSrvCellCfg->initUlBwp.pucchCfg, NULL);
9312 extractPucchCfg(ulBwp->pucch_Config, &macSrvCellCfg->initUlBwp.pucchCfg,\
9313 &storedSrvCellCfg->initUlBwp.pucchCfg);
9317 extractPucchCfg(ulBwp->pucch_Config, &macSrvCellCfg->initUlBwp.pucchCfg, NULL);
9321 if(cuSrvCellCfg->uplinkConfig->firstActiveUplinkBWP_Id)
9322 macSrvCellCfg->firstActvUlBwpId = *(cuSrvCellCfg->uplinkConfig->firstActiveUplinkBWP_Id);
9326 /*******************************************************************
9328 * @brief Fills Reconfig Cell group Info received by CU
9332 * Function : extractUeReCfgCellInfo
9334 * Functionality: Fills Reconfig Cell group Info received by CU
9336 * @params[in] CellGroupConfigRrc_t *cellGrp = CellGroupConfigRrc_t information which
9337 * is send by CU, which we have stored in F1UeContextSetupDb
9338 * MacUeCfg *MacUeCfg = Used to Store the information,
9339 * which needs to send in other layer, as well as this can be
9340 * the variable which stores the information in DuCb,
9341 * MacUeCfg *storedMacUeCfg = Null in case of sending the
9342 * information to other layer else it will have copyOfmacUeCfg
9343 * which we have stored in F1UeContextSetupDb.
9345 * @return ROK/RFAILED
9347 * ****************************************************************/
9348 uint8_t extractUeReCfgCellInfo(CellGroupConfigRrc_t *cellGrp, MacUeCfg *macUeCfg, MacUeCfg *storedMacUeCfg)
9351 MAC_CellGroupConfig_t *macCellGroup = NULLP;
9352 PhysicalCellGroupConfig_t *phyCellGrpCfg = NULLP;
9353 SpCellConfig_t *spcellCfg = NULLP;
9354 ServingCellConfig_t *servCellCfg = NULLP;
9358 /* Fill MacCell Group Reconfig */
9359 if(cellGrp->mac_CellGroupConfig)
9361 macUeCfg->macCellGrpCfgPres = true;
9362 macCellGroup = ((MAC_CellGroupConfig_t *)(cellGrp->mac_CellGroupConfig));
9363 if(macCellGroup->schedulingRequestConfig)
9365 extractSchReqReConfig(macCellGroup->schedulingRequestConfig, &macUeCfg->macCellGrpCfg.schReqCfg);
9367 if(macCellGroup->tag_Config)
9369 extractTagReconfig(macCellGroup->tag_Config, &macUeCfg->macCellGrpCfg.tagCfg);
9371 if(macCellGroup->bsr_Config)
9373 macUeCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer = macCellGroup->bsr_Config->periodicBSR_Timer;
9374 macUeCfg->macCellGrpCfg.bsrTmrCfg.retxTimer = macCellGroup->bsr_Config->retxBSR_Timer;
9375 if(macCellGroup->bsr_Config->logicalChannelSR_DelayTimer)
9377 macUeCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer =\
9378 *(macCellGroup->bsr_Config->logicalChannelSR_DelayTimer);
9381 if(macCellGroup->phr_Config)
9383 if(macCellGroup->phr_Config->present == MAC_CellGroupConfig__phr_Config_PR_setup)
9385 macUeCfg->macCellGrpCfg.phrCfgSetupPres = true;
9386 if(macCellGroup->phr_Config->choice.setup)
9388 macUeCfg->macCellGrpCfg.phrCfg.periodicTimer = \
9389 macCellGroup->phr_Config->choice.setup->phr_PeriodicTimer;
9390 macUeCfg->macCellGrpCfg.phrCfg.prohibitTimer = \
9391 macCellGroup->phr_Config->choice.setup->phr_ProhibitTimer;
9392 macUeCfg->macCellGrpCfg.phrCfg.txPowerFactor = \
9393 macCellGroup->phr_Config->choice.setup->phr_Tx_PowerFactorChange;
9394 macUeCfg->macCellGrpCfg.phrCfg.multiplePHR = \
9395 macCellGroup->phr_Config->choice.setup->multiplePHR;
9396 macUeCfg->macCellGrpCfg.phrCfg.dummy = \
9397 macCellGroup->phr_Config->choice.setup->dummy;
9398 macUeCfg->macCellGrpCfg.phrCfg.phrType2OtherCell = \
9399 macCellGroup->phr_Config->choice.setup->phr_Type2OtherCell;
9400 macUeCfg->macCellGrpCfg.phrCfg.phrOtherCG = \
9401 macCellGroup->phr_Config->choice.setup->phr_ModeOtherCG;
9406 /* Fill Physical Cell Group Reconfig */
9407 if(cellGrp->physicalCellGroupConfig)
9409 macUeCfg->phyCellGrpCfgPres = true;
9410 phyCellGrpCfg = ((PhysicalCellGroupConfig_t *)(cellGrp->physicalCellGroupConfig));
9411 if(phyCellGrpCfg->p_NR_FR1)
9413 if(*(phyCellGrpCfg->p_NR_FR1) != macUeCfg->phyCellGrpCfg.pNrFr1)
9414 macUeCfg->phyCellGrpCfg.pNrFr1 = *(phyCellGrpCfg->p_NR_FR1);
9416 macUeCfg->phyCellGrpCfg.pdschHarqAckCodebook = phyCellGrpCfg->pdsch_HARQ_ACK_Codebook;
9418 /* Fill SpCell Reconfig */
9419 if(cellGrp->spCellConfig)
9421 macUeCfg->spCellCfgPres = true;
9422 spcellCfg = ((SpCellConfig_t *)(cellGrp->spCellConfig));
9423 if(spcellCfg->servCellIndex)
9425 macUeCfg->spCellCfg.servCellIdx = *(spcellCfg->servCellIndex);
9427 /* Fill Serving cell Reconfig info */
9428 if(cellGrp->spCellConfig->spCellConfigDedicated)
9430 servCellCfg = ((ServingCellConfig_t *)(cellGrp->spCellConfig->spCellConfigDedicated));
9433 if(!storedMacUeCfg->spCellCfgPres)
9434 ret = extractSpCellDedicatedCfg(servCellCfg, &macUeCfg->spCellCfg.servCellCfg, NULL);
9436 ret = extractSpCellDedicatedCfg(servCellCfg, &macUeCfg->spCellCfg.servCellCfg,\
9437 &storedMacUeCfg->spCellCfg.servCellCfg);
9441 ret = extractSpCellDedicatedCfg(servCellCfg, &macUeCfg->spCellCfg.servCellCfg, NULL);
9445 DU_LOG("\nERROR --> F1AP : Failed at extractSpCellDedicatedCfg()");
9452 /*******************************************************************
9454 * @brief free the memory allocated by decoder
9458 * Function : freeAperDecodeNrcgi
9460 * Functionality: Free Nrcgi values
9462 * @params[in] NRCGI_t *nrcgi
9465 * ****************************************************************/
9468 void freeAperDecodeNrcgi(NRCGI_t *nrcgi)
9470 if(nrcgi->pLMN_Identity.buf != NULLP)
9472 free(nrcgi->pLMN_Identity.buf);
9474 if(nrcgi->nRCellIdentity.buf != NULLP)
9476 free(nrcgi->nRCellIdentity.buf);
9479 /*******************************************************************
9481 * @brief free the memory allocated by decoder
9485 * Function : freeAperDecodeCuToDuInfo
9487 * Functionality: Free Cu To Du Information
9489 * @params[in] CUtoDURRCInformation_t *rrcMsg
9492 * ****************************************************************/
9495 void freeAperDecodeCuToDuInfo(CUtoDURRCInformation_t *rrcMsg)
9500 if(rrcMsg->uE_CapabilityRAT_ContainerList)
9502 if(rrcMsg->uE_CapabilityRAT_ContainerList->buf)
9503 free(rrcMsg->uE_CapabilityRAT_ContainerList->buf);
9504 free(rrcMsg->uE_CapabilityRAT_ContainerList);
9507 if(rrcMsg->iE_Extensions)
9509 if(rrcMsg->iE_Extensions->list.array)
9511 for(ieIdx= 0; ieIdx < rrcMsg->iE_Extensions->list.count; ieIdx++)
9513 if(rrcMsg->iE_Extensions->list.array[ieIdx])
9515 switch(rrcMsg->iE_Extensions->list.array[ieIdx]->id)
9517 case ProtocolIE_ID_id_CellGroupConfig:
9518 if(rrcMsg->iE_Extensions->list.array[ieIdx]->extensionValue.choice.CellGroupConfig.buf != NULLP)
9520 free(rrcMsg->iE_Extensions->list.array[ieIdx]->extensionValue.choice.CellGroupConfig.buf);
9524 DU_LOG("\nERROR --> F1AP : Invalid Event type %ld at FreeCuToDuInfo()", \
9525 rrcMsg->iE_Extensions->list.array[ieIdx]->id);
9530 for(arrIdx = 0; arrIdx < ieIdx; arrIdx++)
9532 free(rrcMsg->iE_Extensions->list.array[arrIdx]);
9534 free(rrcMsg->iE_Extensions->list.array);
9538 free(rrcMsg->iE_Extensions);
9541 /*******************************************************************
9543 * @brief free the memory allocated by decoder
9547 * Function : freeAperDecodeSplCellList
9549 * Functionality: Free Spl Cell List
9550 where memory allocated by aper_decoder
9552 * @params[in] SCell_ToBeSetup_List_t *spCellLst
9555 * ****************************************************************/
9558 void freeAperDecodeSplCellList(SCell_ToBeSetup_List_t *spCellLst)
9562 if(spCellLst->list.array != NULLP)
9564 for(cellIdx=0; cellIdx<spCellLst->list.count; cellIdx++)
9566 if(cellIdx==0&&spCellLst->list.array[cellIdx]!=NULLP)
9568 freeAperDecodeNrcgi(&spCellLst->list.array[cellIdx]->value.choice.SCell_ToBeSetup_Item.sCell_ID);
9570 if(spCellLst->list.array[cellIdx]!=NULLP)
9572 free(spCellLst->list.array[cellIdx]);
9575 free(spCellLst->list.array);
9578 /*******************************************************************
9580 * @brief free the memory allocated by decoder
9584 * Function : freeAperDecodeSRBSetup
9586 * Functionality: added free part for the memory allocated by aper_decoder
9588 * @params[in] SRBs_ToBeSetup_List_t *srbSet
9591 ****************************************************************/
9594 void freeAperDecodeSRBSetup(SRBs_ToBeSetup_List_t *srbSet)
9597 if(srbSet->list.array != NULLP)
9599 for(srbIdx=0; srbIdx<srbSet->list.count; srbIdx++)
9601 if(srbSet->list.array[srbIdx]!=NULLP)
9603 free(srbSet->list.array[srbIdx]);
9606 free(srbSet->list.array);
9610 /*******************************************************************
9612 * @brief free the memory allocated by decoder
9616 * Function : freeAperDecodeULTnlInfo
9618 * Functionality: added free part for the memory allocated by aper_decoder
9620 * @params[in] ULUPTNLInformation_ToBeSetup_List_t *ulInfo
9623 * ****************************************************************/
9626 void freeAperDecodeULTnlInfo(ULUPTNLInformation_ToBeSetup_List_t *ulInfo)
9629 if(ulInfo->list.array != NULLP)
9631 for(ulIdx=0; ulIdx<ulInfo->list.count; ulIdx++)
9633 if(ulIdx==0&&ulInfo->list.array[ulIdx]!=NULLP)
9635 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel!=NULLP)
9637 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->\
9638 transportLayerAddress.buf != NULLP)
9640 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf\
9643 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf);
9645 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->\
9646 transportLayerAddress.buf);
9648 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel);
9651 if(ulInfo->list.array[ulIdx]!=NULLP)
9653 free(ulInfo->list.array[ulIdx]);
9656 free(ulInfo->list.array);
9659 /*******************************************************************
9661 * @brief free the memory allocated by decoder
9665 * Function : freeAperDecodeDRBSetup
9667 * Functionality: free DRBSetup which is allocated by decoder
9669 * @params[in] DRBs_ToBeSetup_List_t *drbSet
9672 * ****************************************************************/
9674 void freeAperDecodeDRBSetup(DRBs_ToBeSetup_List_t *drbSet)
9676 DRBs_ToBeSetup_Item_t *drbSetItem = NULLP;
9680 if(drbSet->list.array != NULLP)
9682 for(drbIdx=0; drbIdx<drbSet->list.count; drbIdx++)
9684 if(drbIdx==0&&drbSet->list.array[drbIdx] != NULLP)
9686 drbSetItem =&drbSet->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item;
9687 if(drbSetItem->qoSInformation.choice.choice_extension != NULLP)
9689 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9690 qoS_Characteristics.choice.non_Dynamic_5QI !=NULLP)
9692 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9693 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
9695 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9696 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
9699 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sST.buf!=NULLP)
9702 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD!=NULLP)
9705 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD->\
9709 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.\
9710 flows_Mapped_To_DRB_List.list.array != NULLP)
9713 for(flowIdx=0;flowIdx<drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9714 DRB_Information.flows_Mapped_To_DRB_List.list.count; flowIdx++)
9717 if(flowIdx==0&&drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9718 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]!=NULLP)
9720 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9721 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9722 qoSFlowLevelQoSParameters.\
9723 qoS_Characteristics.choice.non_Dynamic_5QI!=NULLP)
9725 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9726 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9727 qoSFlowLevelQoSParameters.\
9728 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
9731 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9732 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9733 qoSFlowLevelQoSParameters.\
9734 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
9738 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9739 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9740 qoSFlowLevelQoSParameters.\
9741 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
9744 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9745 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9746 qoSFlowLevelQoSParameters.\
9747 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
9750 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9752 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
9753 qoSFlowLevelQoSParameters.\
9754 qoS_Characteristics.choice.non_Dynamic_5QI);
9757 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9758 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]!=NULLP)
9761 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9762 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]);
9766 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9767 DRB_Information.flows_Mapped_To_DRB_List.list.array);
9770 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
9771 DRB_Information.sNSSAI.sD->buf);
9774 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD);
9777 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sST.buf);
9781 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9783 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
9786 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9787 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
9790 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
9791 qoS_Characteristics.choice.non_Dynamic_5QI);
9793 free(drbSetItem->qoSInformation.choice.choice_extension);
9795 freeAperDecodeULTnlInfo(&drbSetItem->uLUPTNLInformation_ToBeSetup_List);
9796 if(drbSetItem->uLConfiguration)
9798 free(drbSetItem->uLConfiguration);
9801 if(drbSet->list.array[drbIdx]!=NULLP)
9803 free(drbSet->list.array[drbIdx]);
9806 free(drbSet->list.array);
9811 /*******************************************************************
9813 * @brief builds Mac Cell Cfg
9817 * Function : procUeReCfgCellInfo
9819 * Functionality: builds Mac Cell Cfg
9821 * @params[in] MacUeCfg *macUeCfgToSend = Used to Store the information which
9822 * needs to send in other layer, as well as this can be
9823 * the variable which stores the information in DuCb.
9824 * MacUeCfg *storedMacUeCfg = Null in case of sending the
9825 * information to other layer else it will have copyOfmacUeCfg
9826 * which we have stored in F1UeContextSetupDb
9827 * void *cellInfo = CellGroupConfigRrc_t information which is send
9828 * by CU, which we have stored in F1UeContextSetupDb
9832 * ****************************************************************/
9833 uint8_t procUeReCfgCellInfo(MacUeCfg *macUeCfgToSend,MacUeCfg *storedMacUeCfg, void *cellInfo)
9836 CellGroupConfigRrc_t *cellGrp = NULLP;
9840 cellGrp = (CellGroupConfigRrc_t *)cellInfo;
9841 ret = extractUeReCfgCellInfo(cellGrp, macUeCfgToSend, storedMacUeCfg);
9843 DU_LOG("\nERROR --> F1AP : Failed at procUeReCfgCellInfo()");
9847 freeUeReCfgCellGrpInfo(macUeCfgToSend);
9852 /*******************************************************************
9854 * @brief Filling modulation info in mac ue cfg
9858 * Function : duFillModulationDetails
9860 * Functionality: Filling modulation info in mac ue cfg
9862 * @params[in] MAC UE Config to be updated
9863 * Current UE configuration
9864 * UE NR capability from CU
9865 * @return ROK - success
9868 * ****************************************************************/
9869 void duFillModulationDetails(MacUeCfg *ueCfg, MacUeCfg *oldUeCfg, void *ueCap)
9871 UE_NR_Capability_t *ueNrCap=NULLP;
9875 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
9876 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
9880 ueNrCap = (UE_NR_Capability_t *)ueCap;
9882 /* Filling DL modulation info */
9883 if(ueNrCap->featureSets && ueNrCap->featureSets->featureSetsDownlinkPerCC && \
9884 ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0] && \
9885 ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0]->supportedModulationOrderDL)
9887 switch(*(ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0]->supportedModulationOrderDL))
9889 case ModulationOrder_qpsk:
9891 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
9894 case ModulationOrder_qam16:
9896 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM16;
9899 case ModulationOrder_qam64:
9901 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM64;
9902 ueCfg->dlModInfo.mcsIndex = PDSCH_MCS_INDEX;
9903 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64;
9906 case ModulationOrder_qam256:
9908 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM256;
9913 DU_LOG("\nERROR --> DU APP: Incorrect downlink modulation order received. Reatining old modulation configuration");
9914 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
9921 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
9924 /* Filling UL modulation info */
9925 if(ueNrCap->featureSets && ueNrCap->featureSets->featureSetsUplinkPerCC && \
9926 ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0] && \
9927 ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0]->supportedModulationOrderUL)
9929 switch(*(ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0]->supportedModulationOrderUL))
9931 case ModulationOrder_qpsk:
9933 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
9936 case ModulationOrder_qam16:
9938 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM16;
9939 ueCfg->ulModInfo.mcsIndex = PUSCH_MCS_INDEX;
9940 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64;
9943 case ModulationOrder_qam64:
9945 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM64;
9948 case ModulationOrder_qam256:
9950 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM256;
9955 DU_LOG("\nERROR --> DU APP: Incorrect uplink modulation order received. Reatining old modulation configuration");
9956 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
9963 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
9968 /*******************************************************************
9970 * @brief Function to extract cellGrp Info present in cutoDu cont
9974 * Function : extractCellGrpInfo
9976 * Functionality: Function to extract cellGrp Info present
9979 * @params[in] ProtocolExtensionContainer_4624P16_t pointer
9981 * @return CellGroupConfigRrc_t *
9983 * ****************************************************************/
9985 CellGroupConfigRrc_t *extractCellGrpInfo(ProtocolExtensionContainer_4624P16_t *protocolIeExtn,\
9990 uint16_t recvBufLen =0;
9991 CellGroupConfigRrc_t *cellGrpCfg = NULLP;
9992 CUtoDURRCInformation_ExtIEs_t *extIeInfo = NULLP;
9993 asn_dec_rval_t rval; /* Decoder return value */
9994 memset(&rval, 0, sizeof(asn_dec_rval_t));
9998 for(idx2 = 0; idx2 < protocolIeExtn->list.count; idx2++)
10000 extIeInfo = ((CUtoDURRCInformation_ExtIEs_t *)(protocolIeExtn->list.array[idx2]));
10001 id = extIeInfo->id;
10004 case ProtocolIE_ID_id_CellGroupConfig:
10006 recvBufLen = extIeInfo->extensionValue.choice.CellGroupConfig.size;
10007 /* decoding the CellGroup Buf received */
10008 DU_ALLOC(cellGrpCfg, sizeof(CellGroupConfigRrc_t));
10011 memset(cellGrpCfg, 0, sizeof(CellGroupConfigRrc_t));
10012 rval = aper_decode(0, &asn_DEF_CellGroupConfigRrc, (void **)&cellGrpCfg,
10013 extIeInfo->extensionValue.choice.CellGroupConfig.buf, recvBufLen, 0, 0);
10014 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
10016 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
10019 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, cellGrpCfg);
10020 if(extractRlcCfgToAddMod(cellGrpCfg->rlc_BearerToAddModList, ueCfgDb))
10026 DU_LOG("\nERROR --> F1AP : Invalid IE received CUtoDURRCInformation:%d at decodeCellGrpCfg()", id);
10034 /*******************************************************************
10036 * @brief Fills Srb List received by CU
10040 * Function : procSrbListToSetup
10042 * Functionality: Fills Srb List received by CU
10044 * @params[in] SRBs_ToBeSetup_Item_t *cuSrbItem
10046 * RlcBearerCfg pointer
10049 * ****************************************************************/
10050 uint8_t procSrbListToSetup(SRBs_ToBeSetup_Item_t * srbItem, LcCfg *macLcToAdd, RlcBearerCfg *rlcLcToAdd)
10053 /* Filling RLC INFO */
10054 procRlcLcCfg(srbItem->sRBID, srbItem->sRBID, RB_TYPE_SRB, RLC_AM, CONFIG_ADD, NULL, rlcLcToAdd, NULL);
10056 /* Filling MAC INFO */
10057 if(procMacLcCfg(srbItem->sRBID, RB_TYPE_SRB, CONFIG_ADD, NULL,NULL, NULL, NULL, macLcToAdd, NULL) != ROK)
10059 DU_LOG("\nERROR --> F1AP : Failed at MAC LC Cfg in procSrbListToSetup()");
10068 /*******************************************************************
10070 * @brief extract Srb List received by CU
10074 * Function : extractSrbListToSetup
10076 * Functionality: extract Srb List received by CU
10077 * for both MAC and RLC
10079 * @params[in] SRBs_ToBeSetup_Item_t pointer
10081 * @return ROK/RFAIED
10083 * ****************************************************************/
10085 uint8_t extractSrbListToSetup(SRBs_ToBeSetup_List_t *srbCfg, DuUeCfg *ueCfgDb)
10087 uint8_t ret, srbIdx;
10088 SRBs_ToBeSetup_Item_t *srbItem = NULLP;
10092 for(srbIdx = 0; srbIdx < srbCfg->list.count; srbIdx++)
10094 srbItem = &srbCfg->list.array[srbIdx]->value.choice.SRBs_ToBeSetup_Item;
10095 if(ueCfgDb->numMacLcs > MAX_NUM_LC)
10097 DU_LOG("\nERROR --> F1AP: MAX LC Reached in MAC");
10101 if(ueCfgDb->numRlcLcs > MAX_NUM_LC)
10103 DU_LOG("\nERROR --> F1AP: MAX LC Reached in RLC");
10107 memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(LcCfg));
10108 memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(RlcBearerCfg));
10109 ret = procSrbListToSetup(srbItem, &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs],\
10110 &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs]);
10111 ueCfgDb->numRlcLcs++;
10112 ueCfgDb->numMacLcs++;
10113 DU_LOG("\nDEBUG --> DUAPP: extractSrbListToSetup: SRBID: %d [RLC,MAC,NumDrb]:[%x,%x,%x]",\
10114 srbItem->sRBID, ueCfgDb->numRlcLcs, ueCfgDb->numMacLcs, ueCfgDb->numDrb);
10117 DU_LOG("\nERROR --> F1AP: Failed at extractSrbListToSetup()");
10128 /*******************************************************************
10130 * @brief Fills Drb List received by CU
10134 * Function : procDrbListToSetupMod
10136 * Functionality: Fills Drb List received by CU
10137 * for both MAC and RLC
10139 * @params[in] DRBs_ToBeSetup_Item_t , DRBs_ToBeSetupMod_Item_t,
10140 * DRBs_ToBeModified_Item_t , lcId, LcCfg pointer,
10141 * RlcBearerCfg , UpTnlCfg, RlcUeCfg
10144 * ****************************************************************/
10146 uint8_t procDrbListToSetupMod(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbItem,\
10147 DRBs_ToBeSetupMod_Item_t *drbSetupModItem, DRBs_ToBeModified_Item_t *drbModItem, LcCfg *macLcToAdd, RlcBearerCfg *rlcLcToAdd, UpTnlCfg *upTnlInfo, RlcUeCfg *storedRlcUeCfg)
10149 uint8_t cfgIdx = 0;
10150 RlcMode rlcModeInfo;
10152 if(drbItem != NULLP)
10154 /* Filling RLC INFO */
10155 procRlcLcCfg(drbItem->dRBID, lcId, RB_TYPE_DRB, drbItem->rLCMode, CONFIG_ADD, NULL, rlcLcToAdd, &drbItem->\
10158 /* Filling MAC INFO */
10159 if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_ADD, drbItem, NULL, NULL, NULL, macLcToAdd, upTnlInfo) != ROK)
10161 DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in procDrbListToSetupMod()");
10165 else if(drbSetupModItem != NULLP)
10167 procRlcLcCfg(drbSetupModItem->dRBID, lcId, RB_TYPE_DRB, drbSetupModItem->rLCMode, CONFIG_ADD, NULL, rlcLcToAdd,
10168 &drbSetupModItem->qoSInformation);
10170 if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_ADD, NULL, drbSetupModItem, NULL, NULL, macLcToAdd, upTnlInfo) != ROK)
10172 DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in procDrbListToSetupMod()");
10176 else if(drbModItem != NULLP)
10178 /* Drb to Mod IEs doesnot have rlcMode to be modified
10179 * in ASN. Hence no change in RLC configurations */
10180 if(storedRlcUeCfg != NULLP)
10182 for(cfgIdx = 0; cfgIdx < storedRlcUeCfg->numLcs; cfgIdx++)
10184 if(storedRlcUeCfg->rlcLcCfg[cfgIdx].lcId == lcId)
10186 rlcModeInfo = storedRlcUeCfg->rlcLcCfg[cfgIdx].rlcMode;
10192 procRlcLcCfg(drbModItem->dRBID, lcId, RB_TYPE_DRB, rlcModeInfo, CONFIG_MOD, NULL, rlcLcToAdd, drbModItem->qoSInformation);
10193 if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_MOD, NULL, NULL, drbModItem, NULL, macLcToAdd, upTnlInfo) != ROK)
10195 DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in procDrbListToSetupMod()");
10202 /*******************************************************************
10204 * @brief extract Drb List received by CU
10208 * Function : extractDrbListToSetupMod
10210 * Functionality: extract Drb List received by CU
10211 * for both MAC and RLC
10213 * @params[in] DRBs_ToBeSetup_Item_t pointer
10215 * @return ROK/RFAIED
10217 * ****************************************************************/
10219 uint8_t extractDrbListToSetupMod(DRBs_ToBeSetup_List_t *drbCfg, DRBs_ToBeSetupMod_List_t *drbSetupModCfg,\
10220 DRBs_ToBeModified_List_t *drbModCfg, uint8_t drbCount, DuUeCfg *ueCfgDb, uint32_t *drbBitMap, RlcUeCfg *rlcUeCfg)
10222 uint8_t ret, drbIdx, lcId = 0;
10223 DRBs_ToBeSetup_Item_t *drbItem = NULLP;
10224 DRBs_ToBeSetupMod_ItemIEs_t *drbSetupModItem = NULLP;
10225 DRBs_ToBeModified_ItemIEs_t *drbModItem = NULLP;
10230 for(drbIdx = 0; drbIdx < drbCount; drbIdx++)
10232 if(ueCfgDb->numMacLcs > MAX_NUM_LC)
10234 DU_LOG("\nERROR --> F1AP : MAX LC Reached in MAC at extractDrbListToSetupMod()");
10238 if(ueCfgDb->numRlcLcs > MAX_NUM_LC)
10240 DU_LOG("\nERROR --> F1AP : MAX LC Reached in RLC at extractDrbListToSetupMod()");
10244 memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(LcCfg));
10245 memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(RlcBearerCfg));
10247 if(drbModCfg != NULLP)
10249 drbModItem = (DRBs_ToBeModified_ItemIEs_t *) drbModCfg->list.array[drbIdx];
10250 lcId = fetchLcId(drbModItem->value.choice.DRBs_ToBeModified_Item.dRBID);
10251 if(lcId < MIN_DRB_LCID)
10253 DU_LOG("\nERROR --> F1AP : Failed fetching LCID %d in extractDrbListToSetupMod() for Modified List", lcId);
10256 ret = procDrbListToSetupMod(lcId, NULL, NULL, &(drbModItem->value.choice.DRBs_ToBeModified_Item),\
10257 &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs],\
10258 &ueCfgDb->upTnlInfo[ueCfgDb->numDrb], rlcUeCfg);
10261 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetupMod() for Modified List");
10268 lcId = getDrbLcId(drbBitMap);
10269 if(lcId == RFAILED)
10271 DU_LOG("\nERROR --> F1AP : InCorrect LCID extractDrbListToSetupMod()");
10277 drbItem = &drbCfg->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item;
10278 ret = procDrbListToSetupMod(lcId, drbItem, NULL, NULL, &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs],\
10279 &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], &ueCfgDb->upTnlInfo[ueCfgDb->numDrb], rlcUeCfg);
10282 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetupMod() for DrbSetup List");
10286 else if(drbSetupModCfg != NULL)
10288 drbSetupModItem = (DRBs_ToBeSetupMod_ItemIEs_t *) drbSetupModCfg->list.array[drbIdx];
10289 ret = procDrbListToSetupMod(lcId, NULL, &(drbSetupModItem->value.choice.DRBs_ToBeSetupMod_Item), NULL,\
10290 &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs],\
10291 &ueCfgDb->upTnlInfo[ueCfgDb->numDrb], rlcUeCfg);
10294 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetupMod() for DrbSetupMod List");
10299 ueCfgDb->numRlcLcs++;
10300 ueCfgDb->numMacLcs++;
10303 DU_LOG("\nDEBUG --> DUAPP: extractDrbListToSetupMod:lcId:%x ,BitMap:%x, [RLC,MAC,NumDrb]:[%x,%x,%x]",\
10304 lcId,*drbBitMap, ueCfgDb->numRlcLcs, ueCfgDb->numMacLcs, ueCfgDb->numDrb);
10307 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetupMod()");
10318 /*******************************************************************
10320 * @brief Function to extract Dl RRC Msg received from CU
10324 * Function : extractDlRrcMsg
10326 * Functionality: Function to extract Dl RRC Msg received from CU
10328 * @params[in] F1AP message
10329 * @return ROK - success
10330 * RFAILED - failure
10332 * ****************************************************************/
10334 uint8_t extractDlRrcMsg(uint32_t gnbDuUeF1apId, uint32_t gnbCuUeF1apId, \
10335 F1DlRrcMsg *dlRrcMsg, RRCContainer_t *rrcContainer)
10338 dlRrcMsg->rrcMsgSize = rrcContainer->size;
10339 if(dlRrcMsg->rrcMsgSize > 0)
10341 DU_ALLOC_SHRABL_BUF(dlRrcMsg->rrcMsgPdu, dlRrcMsg->rrcMsgSize);
10342 if(!dlRrcMsg->rrcMsgPdu)
10344 DU_LOG("\nERROR --> DU APP : Memory allocation failed for RRC Msg in extractDlRrcMsg()");
10349 dlRrcMsg->gnbDuUeF1apId = gnbDuUeF1apId;
10350 dlRrcMsg->gnbCuUeF1apId = gnbCuUeF1apId;
10351 dlRrcMsg->srbId = SRB1_LCID;
10352 memcpy(dlRrcMsg->rrcMsgPdu, rrcContainer->buf, dlRrcMsg->rrcMsgSize);
10358 /*******************************************************************
10360 * @brief Extract UE capability info
10364 * Function : extractUeCapability
10366 * Functionality: Extract UE capability info and stores in ue Cb
10368 * @params[in] Octet string of UE capability RAT container list
10369 * @return ROK - success
10370 * RFAILED - failure
10372 * ****************************************************************/
10373 UE_NR_Capability_t *extractUeCapability(UE_CapabilityRAT_ContainerList_t *ueCapablityListBuf, DuUeCb *ueCb)
10376 uint16_t recvBufLen;
10377 asn_dec_rval_t rval;
10378 UE_NR_Capability_t *ueNrCap = NULLP;
10379 UE_CapabilityRAT_ContainerListRRC_t *ueCapRatContList = NULLP;
10381 /* Decoding UE Capability RAT Container List */
10382 recvBufLen = ueCapablityListBuf->size;
10383 DU_ALLOC(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
10384 if(!ueCapRatContList)
10386 DU_LOG("\nERROR --> F1AP : Memory allocation failed in extractUeCapability");
10389 memset(ueCapRatContList, 0, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
10390 memset(&rval, 0, sizeof(asn_dec_rval_t));
10391 rval = aper_decode(0, &asn_DEF_UE_CapabilityRAT_ContainerListRRC, (void **)&ueCapRatContList,
10392 ueCapablityListBuf->buf, recvBufLen, 0, 0);
10393 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
10395 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
10398 xer_fprint(stdout, &asn_DEF_UE_CapabilityRAT_ContainerListRRC, ueCapRatContList);
10400 /* Free encoded buffer after decoding */
10402 for(idx = 0; idx < ueCapRatContList->list.count; idx++)
10404 if(ueCapRatContList->list.array[idx]->rat_Type == RAT_Type_nr)
10406 /* Decoding UE NR Capability */
10407 recvBufLen = ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.size;
10408 DU_ALLOC(ueNrCap, sizeof(UE_NR_Capability_t));
10411 DU_LOG("\nERROR --> F1AP : Memory allocation failed in extractUeCapability");
10412 DU_FREE(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
10415 memset(ueNrCap, 0, sizeof(UE_NR_Capability_t));
10416 memset(&rval, 0, sizeof(asn_dec_rval_t));
10417 rval = aper_decode(0, &asn_DEF_UE_NR_Capability, (void **)&ueNrCap,
10418 ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.buf, recvBufLen, 0, 0);
10419 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
10421 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
10424 xer_fprint(stdout, &asn_DEF_UE_NR_Capability, ueNrCap);
10426 /* Free encoded buffer after decoding */
10427 free(ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.buf);
10429 free(ueCapRatContList->list.array[idx]);
10433 free(ueCapRatContList->list.array);
10434 DU_FREE(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
10438 /*******************************************************************
10440 * @brief free UE context setup request from CU
10444 * Function : freeAperDecodeF1UeContextSetupReq
10446 * Functionality: freeing part for the memory allocated by aper_decoder
10448 * @params[in] F1AP message
10449 * @return ROK - success
10450 * RFAILED - failure
10452 * ****************************************************************/
10453 void freeAperDecodeF1UeContextSetupReq(UEContextSetupRequest_t *ueSetReq)
10457 if(ueSetReq->protocolIEs.list.array != NULLP)
10459 for(ieIdx = 0; ieIdx < ueSetReq->protocolIEs.list.count; ieIdx++)
10461 if(ueSetReq->protocolIEs.list.array[ieIdx])
10463 switch(ueSetReq->protocolIEs.list.array[ieIdx]->id)
10465 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
10467 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
10469 case ProtocolIE_ID_id_SpCell_ID:
10470 freeAperDecodeNrcgi(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.NRCGI);
10472 case ProtocolIE_ID_id_ServCellIndex:
10474 case ProtocolIE_ID_id_SpCellULConfigured:
10476 case ProtocolIE_ID_id_CUtoDURRCInformation:
10478 freeAperDecodeCuToDuInfo(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation);
10480 case ProtocolIE_ID_id_SCell_ToBeSetup_List:
10482 freeAperDecodeSplCellList(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SCell_ToBeSetup_List);
10484 case ProtocolIE_ID_id_SRBs_ToBeSetup_List:
10486 freeAperDecodeSRBSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SRBs_ToBeSetup_List);
10488 case ProtocolIE_ID_id_DRBs_ToBeSetup_List:
10490 freeAperDecodeDRBSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRBs_ToBeSetup_List);
10492 case ProtocolIE_ID_id_RRCContainer:
10495 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf != NULLP)
10498 free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf);
10502 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
10504 case ProtocolIE_ID_id_GNB_DU_UE_AMBR_UL:
10506 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf)
10508 free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf);
10513 DU_LOG("\nERROR --> F1AP: Invalid event type %ld " ,ueSetReq->protocolIEs.list.array[ieIdx]->id);
10515 free(ueSetReq->protocolIEs.list.array[ieIdx]);
10518 free(ueSetReq->protocolIEs.list.array);
10521 /*******************************************************************
10523 * @brief Process UE context setup request from CU
10527 * Function : procF1UeContextSetupReq
10529 * Functionality: Process UE context setup request from CU
10531 * @params[in] F1AP message
10532 * @return ROK - success
10533 * RFAILED - failure
10535 * ****************************************************************/
10536 uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg)
10538 uint8_t ret=0, ieIdx=0, ueIdx=0, cellIdx=0;
10539 bool ueCbFound = false;
10540 uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId=0, bitRateSize=0;
10541 DuUeCb *duUeCb = NULL;
10542 UEContextSetupRequest_t *ueSetReq = NULL;
10543 DRBs_ToBeSetup_List_t *drbCfg = NULL;
10547 ueSetReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextSetupRequest;
10548 for(ieIdx=0; (ieIdx < ueSetReq->protocolIEs.list.count && ret == ROK); ieIdx++)
10550 switch(ueSetReq->protocolIEs.list.array[ieIdx]->id)
10552 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
10554 gnbCuUeF1apId = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID;
10557 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
10559 gnbDuUeF1apId = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID;
10562 case ProtocolIE_ID_id_ServCellIndex:
10564 cellIdx = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.ServCellIndex;
10565 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
10567 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
10568 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
10571 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
10572 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
10575 memset(duUeCb->f1UeDb, 0, sizeof(F1UeContextSetupDb));
10576 duUeCb->f1UeDb->actionType = UE_CTXT_SETUP;
10577 duUeCb->f1UeDb->cellIdx = cellIdx;
10581 DU_LOG("\nERROR --> F1AP: Memory Alloc Failed at procF1UeContextSetupReq()");
10592 DU_LOG("\nERROR --> F1AP: DuUeCb is not found at procF1UeContextSetupReq()");
10597 case ProtocolIE_ID_id_SpCellULConfigured:
10598 /* Indicates whether the gNB-CU requests the gNB-DU to configure the uplink as no UL,
10599 UL, SUL or UL+SUL for the indicated cell for the UE */
10601 case ProtocolIE_ID_id_CUtoDURRCInformation:
10603 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.uE_CapabilityRAT_ContainerList)
10605 duUeCb->f1UeDb->duUeCfg.ueNrCapability = \
10606 extractUeCapability(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.\
10607 uE_CapabilityRAT_ContainerList, duUeCb);
10609 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation.iE_Extensions)
10611 duUeCb->f1UeDb->duUeCfg.cellGrpCfg = extractCellGrpInfo(ueSetReq->protocolIEs.list.array[ieIdx]->\
10612 value.choice.CUtoDURRCInformation.iE_Extensions, &duUeCb->f1UeDb->duUeCfg);
10613 if(!duUeCb->f1UeDb->duUeCfg.cellGrpCfg)
10615 DU_LOG("\nERROR --> F1AP: Failed to extract cell Grp Info");
10616 //TODO: Update the failure cause in ue context Setup Response
10622 case ProtocolIE_ID_id_SCell_ToBeSetup_List:
10624 DU_LOG("\nINFO --> DU_APP: Received SCell_ToBeSetup_List but Not processing the list");
10627 case ProtocolIE_ID_id_SRBs_ToBeSetup_List:
10629 if(extractSrbListToSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SRBs_ToBeSetup_List,\
10630 &duUeCb->f1UeDb->duUeCfg))
10632 DU_LOG("\nERROR --> DU APP : Failed at extractSrbListToSetup()");
10633 //TODO: Update the failure cause in ue context Setup Response
10638 case ProtocolIE_ID_id_DRBs_ToBeSetup_List:
10640 drbCfg = &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRBs_ToBeSetup_List;
10642 if(extractDrbListToSetupMod(drbCfg, NULL, NULL, drbCfg->list.count, &duUeCb->f1UeDb->duUeCfg, &duUeCb->drbBitMap, NULLP))
10644 DU_LOG("\nERROR --> DU APP : Failed at extractDrbListToSetupMod()");
10645 //TODO: Update the failure cause in ue context Setup Response
10650 case ProtocolIE_ID_id_RRCContainer:
10652 /* Filling Dl RRC Msg Info */
10653 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
10654 if(!duUeCb->f1UeDb->dlRrcMsg)
10656 DU_LOG("\nERROR --> DU APP : Memory allocation failed for DL RRC Msg in procUeCtxtSetupReq()");
10661 duUeCb->f1UeDb->dlRrcMsgPres = true;
10662 memset(duUeCb->f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
10663 ret = extractDlRrcMsg(gnbDuUeF1apId, gnbCuUeF1apId, duUeCb->f1UeDb->dlRrcMsg,\
10664 &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer);
10668 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
10670 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
10672 duUeCb->f1UeDb->dlRrcMsg->deliveryStatRpt = true;
10676 DU_LOG("\nERROR --> Ignoring delivery report, since rrcContainer is not present");
10680 case ProtocolIE_ID_id_GNB_DU_UE_AMBR_UL:
10682 /* MaximumBitRate Uplink */
10683 bitRateSize = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.size;
10684 if(bitRateSize > 0)
10686 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->duUeCfg.ambrCfg, bitRateSize);
10687 if(!duUeCb->f1UeDb->duUeCfg.ambrCfg)
10689 DU_LOG("\nERROR --> DU APP : Memory allocation failed for bitRate in procUeCtxtSetupReq");
10694 memset(duUeCb->f1UeDb->duUeCfg.ambrCfg, 0, sizeof(AmbrCfg));
10695 memcpy(&duUeCb->f1UeDb->duUeCfg.ambrCfg->ulBr,
10696 ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf, bitRateSize);
10711 /*TODO : Negative case*/
10712 // BuildAndSendUeContextSetupRsp(cellId,ueIdx);
10713 DU_LOG("\nERROR --> F1AP: Failed to process UE CNTXT SETUP REQ at procF1UeContextSetupReq()");
10716 ret = duProcUeContextSetupRequest(duUeCb);
10718 freeAperDecodeF1UeContextSetupReq(ueSetReq);
10722 /*******************************************************************
10723 * @brief Free the memory allocated for Dl Tunnel Info
10727 * Function : freeDlTnlInfo
10730 * Free the memory allocated for Dl Tunnel Info
10732 * @params[in] DLUPTNLInformation_ToBeSetup_List_t *
10735 * ****************************************************************/
10737 void freeDlTnlInfo(DLUPTNLInformation_ToBeSetup_List_t *tnlInfo)
10739 uint8_t arrIdx = 0;
10743 for(arrIdx=0; arrIdx < tnlInfo->list.count; arrIdx++)
10745 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.buf,\
10746 tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.size);
10747 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf,\
10748 tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->gTP_TEID.size);
10749 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel, sizeof(GTPTunnel_t));
10750 DU_FREE(tnlInfo->list.array[arrIdx], sizeof(DLUPTNLInformation_ToBeSetup_Item_t));
10752 DU_FREE(tnlInfo->list.array, tnlInfo->list.size);
10756 /*******************************************************************
10757 * @brief Free the memory allocated for DRB setup List
10761 * Function : freeDrbSetupList
10764 * Free the memory allocated for DRB setup list
10766 * @params[in] DRBs_Setup_List_t *
10769 * ****************************************************************/
10770 void freeDrbSetupList(DRBs_Setup_List_t *drbSetupList)
10772 uint8_t arrIdx = 0;
10773 DRBs_Setup_ItemIEs_t *drbItemIe = NULLP;
10775 for(arrIdx = 0; arrIdx < drbSetupList->list.count; arrIdx++)
10777 drbItemIe = ((DRBs_Setup_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
10778 freeDlTnlInfo(&drbItemIe->value.choice.DRBs_Setup_Item.dLUPTNLInformation_ToBeSetup_List);
10779 DU_FREE(drbSetupList->list.array[arrIdx], sizeof(DRBs_Setup_Item_t));
10781 DU_FREE(drbSetupList->list.array, drbSetupList->list.size);
10784 /*******************************************************************
10785 * @brief Free the memory allocated for UE Setup response
10789 * Function : FreeUeContextSetupRsp
10792 * Free the memory allocated for UE Setup response
10794 * @params[in] F1AP PDU for UE setup response
10795 * @return ROK - success
10796 * RFAILED - failure
10798 * ****************************************************************/
10799 void FreeUeContextSetupRsp(F1AP_PDU_t *f1apMsg)
10802 UEContextSetupResponse_t *ueSetRsp = NULLP;
10806 if(f1apMsg->choice.successfulOutcome)
10808 ueSetRsp = &f1apMsg->choice.successfulOutcome->value.choice.\
10809 UEContextSetupResponse;
10810 if(ueSetRsp->protocolIEs.list.array)
10812 for(idx = 0; idx < ueSetRsp->protocolIEs.list.count; idx++)
10814 if(ueSetRsp->protocolIEs.list.array[idx])
10816 switch(ueSetRsp->protocolIEs.list.array[idx]->id)
10818 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
10820 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
10822 case ProtocolIE_ID_id_DUtoCURRCInformation:
10824 CellGroupConfig_t *cellGrpCfg = NULLP;
10825 cellGrpCfg = &ueSetRsp->protocolIEs.list.array[idx]->value.choice.\
10826 DUtoCURRCInformation.cellGroupConfig;
10827 if(cellGrpCfg->buf != NULLP)
10829 DU_FREE(cellGrpCfg->buf, cellGrpCfg->size);
10830 cellGrpCfg = NULLP;
10834 case ProtocolIE_ID_id_DRBs_Setup_List:
10836 freeDrbSetupList(&ueSetRsp->protocolIEs.list.array[idx]->value.choice.DRBs_Setup_List);
10840 DU_LOG("\nERROR --> DUAPP: Invalid Id %ld at FreeUeContextSetupRsp()",\
10841 ueSetRsp->protocolIEs.list.array[idx]->id);
10844 DU_FREE(ueSetRsp->protocolIEs.list.array[idx],\
10845 sizeof(UEContextSetupResponseIEs_t));
10848 DU_FREE(ueSetRsp->protocolIEs.list.array, \
10849 ueSetRsp->protocolIEs.list.size);
10851 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
10853 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
10857 /*******************************************************************
10859 * @brief Builds Ue context Setup Rsp DU To CU Info
10863 * Function : EncodeUeCntxtDuToCuInfo
10865 * Functionality: Builds Ue context Setup Rsp DU To CU Info
10867 * @params[in] CellGroupConfig_t *, CellGroupConfigRrc_t *
10869 * @return ROK - success
10870 * RFAILED - failure
10872 ******************************************************************/
10874 uint8_t EncodeUeCntxtDuToCuInfo(CellGroupConfig_t *duToCuCellGrp, CellGroupConfigRrc_t *duCellGrpCfg)
10876 asn_enc_rval_t encRetVal;
10878 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, duCellGrpCfg);
10879 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
10881 encRetVal = aper_encode(&asn_DEF_CellGroupConfigRrc, 0, duCellGrpCfg, PrepFinalEncBuf, encBuf);
10882 /* Encode results */
10883 if(encRetVal.encoded == ENCODE_FAIL)
10885 DU_LOG( "\nERROR --> F1AP : Could not encode UeCntxtDuToCuInfo (at %s)\n",\
10886 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
10891 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UeCntxtDuToCuInfo\n");
10892 for(int i=0; i< encBufSize; i++)
10894 printf("%x",encBuf[i]);
10897 duToCuCellGrp->size = encBufSize;
10898 DU_ALLOC(duToCuCellGrp->buf, duToCuCellGrp->size);
10899 if(!duToCuCellGrp->buf)
10901 DU_LOG("\nERROR --> F1AP : Memory allocation failed in UeCntxtDuToCuInfo");
10903 memcpy(duToCuCellGrp->buf, encBuf, duToCuCellGrp->size);
10907 /*******************************************************************
10909 * @brief Fills Dl Gtp tunnel Info
10913 * Function : fillGtpTunnelforDl
10915 * Functionality: Fills Dl Gtp tunnel Info
10919 * @return ROK - success
10920 * RFAILED - failure
10922 * ****************************************************************/
10924 uint8_t fillGtpTunnelforDl(GTPTunnel_t *gtpDl, GtpTnlCfg *gtpUeCfg)
10926 uint8_t bufSize = 0;
10928 gtpDl->transportLayerAddress.size = 4*sizeof(uint8_t);
10929 DU_ALLOC(gtpDl->transportLayerAddress.buf, gtpDl->transportLayerAddress.size);
10930 if(gtpDl->transportLayerAddress.buf == NULLP)
10934 memcpy(gtpDl->transportLayerAddress.buf, >pUeCfg->dlTnlAddress, gtpDl->transportLayerAddress.size);
10937 gtpDl->gTP_TEID.size = 4 * sizeof(uint8_t);
10938 DU_ALLOC(gtpDl->gTP_TEID.buf, gtpDl->gTP_TEID.size);
10939 if(gtpDl->gTP_TEID.buf == NULLP)
10943 bufSize = 3; /*forming an Octect String*/
10944 fillTeIdString(bufSize, gtpUeCfg->teId, gtpDl->gTP_TEID.buf);
10949 /*******************************************************************
10951 * @brief Fills DL Tunnel Setup List
10955 * Function : fillDlTnlSetupList
10957 * Functionality: Fills the DL Tunnel Setup List
10961 * @return ROK - success
10962 * RFAILED - failure
10964 * ****************************************************************/
10966 uint8_t fillDlTnlSetupList(DLUPTNLInformation_ToBeSetup_List_t *dlTnlInfo, UpTnlCfg *tnlCfg)
10968 uint8_t ret = ROK, arrIdx = 0, eleCount = 0;
10971 dlTnlInfo->list.count = eleCount;
10972 dlTnlInfo->list.size = (eleCount * sizeof(DLUPTNLInformation_ToBeSetup_Item_t *));
10974 /* Initialize the DL Tnl Setup List Members */
10975 DU_ALLOC(dlTnlInfo->list.array, dlTnlInfo->list.size);
10976 if(dlTnlInfo->list.array == NULLP)
10978 DU_LOG(" ERROR --> F1AP : Memory allocation for DL Tnl Setup List in fillDlTnlSetupList()");
10981 for(arrIdx=0; arrIdx < eleCount; arrIdx++)
10983 DU_ALLOC(dlTnlInfo->list.array[arrIdx], sizeof(DLUPTNLInformation_ToBeSetup_Item_t));
10984 if(dlTnlInfo->list.array[arrIdx] == NULLP)
10986 DU_LOG(" ERROR --> F1AP : Memory allocation for arrIdx [%d] failed in fillDlTnlSetupList()", arrIdx);
10989 dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.present = UPTransportLayerInformation_PR_gTPTunnel;
10990 DU_ALLOC(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel, sizeof(GTPTunnel_t));
10991 if(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel == NULLP)
10993 DU_LOG(" ERROR --> F1AP : Memory allocation for DL tunnel info in fillDlTnlSetupList()");
10996 ret = fillGtpTunnelforDl(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel,\
11004 /*******************************************************************
11006 * @brief Fills the Drb Setup List for Ue Context Setup Response
11010 * Function : fillDrbSetupList
11012 * Functionality: Fills the Drb Setup List for Ue Context Setup Response
11016 * @return ROK - success
11017 * RFAILED - failure
11019 * ****************************************************************/
11020 uint8_t fillDrbSetupList(DRBs_Setup_List_t *drbSetupList, DuUeCfg *ueCfg)
11022 uint8_t ret = ROK, arrIdx = 0, eleCount = 0;
11023 DRBs_Setup_ItemIEs_t *drbItemIe = NULLP;
11025 eleCount = ueCfg->numDrb;
11026 drbSetupList->list.count = eleCount;
11027 drbSetupList->list.size = \
11028 (eleCount * sizeof(DRBs_Setup_Item_t *));
11030 /* Initialize the Drb Setup List Members */
11031 DU_ALLOC(drbSetupList->list.array, drbSetupList->list.size);
11032 if(drbSetupList->list.array == NULLP)
11034 DU_LOG(" ERROR --> F1AP : Memory allocation for DRB Setup List in fillDrbSetupList()");
11038 for(arrIdx=0; arrIdx < eleCount; arrIdx++)
11040 DU_ALLOC(drbSetupList->list.array[arrIdx], sizeof(DRBs_Setup_Item_t));
11041 if(drbSetupList->list.array[arrIdx] == NULLP)
11043 DU_LOG(" ERROR --> F1AP : Memory allocation for arrIdx [%d] failed in fillDrbSetupList()", arrIdx);
11046 drbItemIe = ((DRBs_Setup_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
11047 drbItemIe->id = ProtocolIE_ID_id_DRBs_Setup_Item;
11048 drbItemIe->criticality = Criticality_reject;
11049 drbItemIe->value.present = DRBs_Setup_ItemIEs__value_PR_DRBs_Setup_Item;
11050 drbItemIe->value.choice.DRBs_Setup_Item.dRBID = ueCfg->upTnlInfo[arrIdx].drbId;
11051 ret = fillDlTnlSetupList(&drbItemIe->value.choice.DRBs_Setup_Item.dLUPTNLInformation_ToBeSetup_List,\
11052 &ueCfg->upTnlInfo[arrIdx]);
11059 /*******************************************************************
11061 * @brief Builds and sends the UE Setup Response
11065 * Function : BuildAndSendUeContextSetupRsp
11067 * Functionality: Constructs the UE Setup Response and sends
11068 * it to the DU through SCTP.
11070 * @params[in] uint8_t cellId,uint8_t ueIdx
11072 * @return ROK - success
11073 * RFAILED - failure
11075 * ****************************************************************/
11076 uint8_t BuildAndSendUeContextSetupRsp(uint8_t cellId,uint8_t ueIdx)
11078 uint8_t idx, ret, cellIdx, elementCnt;
11079 uint32_t gnbCuUeF1apId; /* gNB-CU UE F1AP Id */
11080 uint32_t gnbDuUeF1apId; /* gNB-DU UE F1AP Id */
11081 asn_enc_rval_t encRetVal; /* Encoder return value */
11082 F1AP_PDU_t *f1apMsg = NULLP;
11083 UEContextSetupResponse_t *ueSetRsp = NULLP;
11084 CellGroupConfigRrc_t *cellGrpCfg = NULLP;
11085 DuUeCb *ueCb = NULLP;
11087 DU_LOG("\n INFO --> F1AP : Building UE Context Setup Response for cellId %d, ueIdx %d\n", cellId, ueIdx);
11091 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
11092 if(f1apMsg == NULLP)
11094 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11099 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
11100 DU_ALLOC(f1apMsg->choice.successfulOutcome,
11101 sizeof(SuccessfulOutcome_t));
11102 if(f1apMsg->choice.successfulOutcome == NULLP)
11104 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11109 f1apMsg->choice.successfulOutcome->procedureCode = \
11110 ProcedureCode_id_UEContextSetup;
11111 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
11112 f1apMsg->choice.successfulOutcome->value.present = \
11113 SuccessfulOutcome__value_PR_UEContextSetupResponse;
11116 &f1apMsg->choice.successfulOutcome->value.choice.UEContextSetupResponse;
11118 ueSetRsp->protocolIEs.list.count = elementCnt;
11119 ueSetRsp->protocolIEs.list.size = \
11120 elementCnt * sizeof(UEContextSetupResponse_t *);
11122 /* Initialize the UESetup members */
11123 DU_ALLOC(ueSetRsp->protocolIEs.list.array, \
11124 ueSetRsp->protocolIEs.list.size);
11125 if(ueSetRsp->protocolIEs.list.array == NULLP)
11127 DU_LOG(" ERROR --> F1AP : Memory allocation for UE Setup Response failed");
11132 for(idx=0; idx<elementCnt; idx++)
11134 DU_ALLOC(ueSetRsp->protocolIEs.list.array[idx],\
11135 sizeof(UEContextSetupResponseIEs_t));
11136 if(ueSetRsp->protocolIEs.list.array[idx] == NULLP)
11138 DU_LOG(" ERROR --> F1AP : Memory allocation for UE Setup Response failed");
11143 /* Fetching Ue Cb Info*/
11144 GET_CELL_IDX(cellId, cellIdx);
11145 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
11146 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
11147 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
11150 /*GNB CU UE F1AP ID*/
11151 ueSetRsp->protocolIEs.list.array[idx]->id = \
11152 ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
11153 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11154 ueSetRsp->protocolIEs.list.array[idx]->value.present = \
11155 UEContextSetupResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
11156 ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
11158 /*GNB DU UE F1AP ID*/
11160 ueSetRsp->protocolIEs.list.array[idx]->id = \
11161 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
11162 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11163 ueSetRsp->protocolIEs.list.array[idx]->value.present = \
11164 UEContextSetupResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
11165 ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
11168 /*DUtoCURRC Information */
11170 ueSetRsp->protocolIEs.list.array[idx]->id = \
11171 ProtocolIE_ID_id_DUtoCURRCInformation;
11172 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11173 ueSetRsp->protocolIEs.list.array[idx]->value.present =\
11174 UEContextSetupResponseIEs__value_PR_DUtoCURRCInformation;
11177 if(ueCb->f1UeDb->duUeCfg.cellGrpCfg)
11179 cellGrpCfg = (CellGroupConfigRrc_t*)ueCb->f1UeDb->duUeCfg.cellGrpCfg;
11180 ret = EncodeUeCntxtDuToCuInfo(&ueSetRsp->protocolIEs.list.array[idx]->value.\
11181 choice.DUtoCURRCInformation.cellGroupConfig, cellGrpCfg);
11184 DU_LOG("\nERROR --> F1AP : Failed to EncodeUeCntxtDuToCuInfo in BuildAndSendUeContextSetupRsp()");
11185 freeF1UeDb(ueCb->f1UeDb);
11186 ueCb->f1UeDb = NULLP;
11193 DU_LOG("\nERROR --> F1AP : Failed to form DUtoCU RRCInfo at BuildAndSendUeContextSetupRsp()");
11198 /* Drb Setup List */
11200 ueSetRsp->protocolIEs.list.array[idx]->id = \
11201 ProtocolIE_ID_id_DRBs_Setup_List;
11202 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11203 ueSetRsp->protocolIEs.list.array[idx]->value.present =\
11204 UEContextSetupResponseIEs__value_PR_DRBs_Setup_List;
11205 ret = fillDrbSetupList(&ueSetRsp->protocolIEs.list.array[idx]->value.choice.DRBs_Setup_List,\
11206 &ueCb->f1UeDb->duUeCfg);
11209 DU_LOG("\nERROR --> F1AP : Failed to fillDrbSetupList in BuildAndSendUeContextSetupRsp()");
11210 freeF1UeDb(ueCb->f1UeDb);
11211 ueCb->f1UeDb = NULLP;
11215 /* Free UeContext Db created during Ue context Req */
11216 freeF1UeDb(ueCb->f1UeDb);
11217 ueCb->f1UeDb = NULLP;
11219 /* TODO: To send Drb list */
11220 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
11222 /* Encode the UE context setup response type as APER */
11223 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
11225 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
11227 /* Encode results */
11228 if(encRetVal.encoded == ENCODE_FAIL)
11230 DU_LOG( "\nERROR --> F1AP : Could not encode UE Context Setup Response structure (at %s)\n",\
11231 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
11237 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UE Context Setup Response\n");
11238 for(int i=0; i< encBufSize; i++)
11240 printf("%x",encBuf[i]);
11245 if(sendF1APMsg() != ROK)
11247 DU_LOG("\nERROR --> F1AP : Sending UE Context Setup Response failed");
11253 FreeUeContextSetupRsp(f1apMsg);
11255 }/* End of BuildAndSendUeContextSetupRsp */
11256 /*******************************************************************
11258 * @brief Build And Send Ue Context Rsp
11262 * Function : BuildAndSendUeCtxtRsp
11264 * Functionality : Build And Send Ue Context Rsp
11267 * @return sucess = ROK
11268 * failure = RFAILED
11270 * ****************************************************************/
11271 uint8_t BuildAndSendUeCtxtRsp(uint8_t cellId, uint8_t ueIdx)
11273 uint8_t cellIdx = 0, actionType = 0;
11275 GET_CELL_IDX(cellId, cellIdx);
11276 actionType = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].f1UeDb->actionType;
11280 case UE_CTXT_SETUP:
11282 BuildAndSendUeContextSetupRsp(cellId,ueIdx);
11287 BuildAndSendUeContextModRsp(cellId, ueIdx);
11291 DU_LOG("ERROR --> F1AP: Invalid Action Type %d at BuildAndSendUeCtxtRsp()", actionType);
11298 /*******************************************************************
11300 * @brief deallocating the memory of F1reset msg
11304 * Function : FreeF1ResetReq
11307 * - freeing memory of F1reset request msg
11313 * ****************************************************************/
11314 void FreeF1ResetReq(F1AP_PDU_t *f1apMsg)
11317 Reset_t *f1ResetMsg;
11321 if(f1apMsg->choice.initiatingMessage)
11323 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
11325 if(f1ResetMsg->protocolIEs.list.array)
11327 for(idx=0 ;idx < f1ResetMsg->protocolIEs.list.count ; idx++)
11329 if(f1ResetMsg->protocolIEs.list.array[idx])
11331 DU_FREE(f1ResetMsg->protocolIEs.list.array[idx],sizeof(ResetIEs_t));
11334 DU_FREE(f1ResetMsg->protocolIEs.list.array,f1ResetMsg->protocolIEs.list.size);
11336 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
11338 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
11341 /*******************************************************************
11343 * @brief Build and Send F1reset request
11347 * Function : BuildAndSendF1ResetReq
11350 * - Build and Send F1reset request msg
11353 * @return ROK - success
11354 * RFAILED - failure
11356 * ****************************************************************/
11357 uint8_t BuildAndSendF1ResetReq()
11359 uint8_t elementCnt=0;
11361 uint8_t ret= RFAILED;
11362 Reset_t *f1ResetMsg = NULLP;
11363 F1AP_PDU_t *f1apMsg = NULLP;
11364 asn_enc_rval_t encRetVal;
11365 DU_LOG("\nINFO --> F1AP : Building F1 Reset request \n");
11368 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
11369 if(f1apMsg == NULLP)
11373 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
11374 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
11375 if(f1apMsg->choice.initiatingMessage == NULLP)
11379 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_Reset;
11380 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
11381 f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_Reset;
11383 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
11386 f1ResetMsg->protocolIEs.list.count = elementCnt;
11387 f1ResetMsg->protocolIEs.list.size = elementCnt * sizeof(ResetIEs_t *);
11389 /* Initialize the F1Setup members */
11390 DU_ALLOC(f1ResetMsg->protocolIEs.list.array,f1ResetMsg->protocolIEs.list.size);
11391 if(f1ResetMsg->protocolIEs.list.array == NULLP)
11395 for(idx=0; idx<elementCnt; idx++)
11397 DU_ALLOC(f1ResetMsg->protocolIEs.list.array[idx],sizeof(ResetIEs_t));
11398 if(f1ResetMsg->protocolIEs.list.array[idx] == NULLP)
11406 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID;
11407 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11408 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_TransactionID;
11409 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.TransactionID = 1;
11413 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_Cause;
11414 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_ignore;
11415 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_Cause;
11416 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.Cause.present = Cause_PR_radioNetwork;
11417 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.Cause.choice.radioNetwork = CauseRadioNetwork_action_desirable_for_radio_reasons;
11421 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_ResetType;
11422 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11423 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_ResetType;
11424 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.ResetType.present = ResetType_PR_f1_Interface;
11425 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.ResetType.choice.f1_Interface = ResetAll_reset_all;
11427 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
11429 /* Encode the F1SetupRequest type as APER */
11430 memset(encBuf, 0, ENC_BUF_MAX_LEN);
11432 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
11435 /* Encode results */
11436 if(encRetVal.encoded == ENCODE_FAIL)
11438 DU_LOG("\nERROR --> F1AP : Could not encode F1Reset structure (at %s)\n",\
11439 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
11444 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for F1Reset\n");
11445 for(idx=0; idx< encBufSize; idx++)
11447 printf("%x",encBuf[idx]);
11451 if(sendF1APMsg() != ROK)
11453 DU_LOG("\nERROR --> F1AP : Sending F1 Reset request failed");
11461 FreeF1ResetReq(f1apMsg);
11464 /*******************************************************************
11466 * @brief Build And Send F1ResetAck
11470 * Function : BuildAndSendF1ResetAck
11473 * - Build And Send F1ResetRSP
11475 * @return ROK - success
11476 * RFAILED - failure
11478 * ****************************************************************/
11479 void FreeF1ResetAck(F1AP_PDU_t *f1apMsg)
11482 ResetAcknowledge_t *f1ResetAck;
11486 if(f1apMsg->choice.successfulOutcome)
11488 f1ResetAck= &f1apMsg->choice.successfulOutcome->value.choice.ResetAcknowledge;
11490 if(f1ResetAck->protocolIEs.list.array)
11492 for(idx=0; idx<f1ResetAck->protocolIEs.list.count ; idx++)
11494 if(f1ResetAck->protocolIEs.list.array[idx])
11496 DU_FREE(f1ResetAck->protocolIEs.list.array[idx], sizeof(ResetAcknowledgeIEs_t));
11499 DU_FREE(f1ResetAck->protocolIEs.list.array, f1ResetAck->protocolIEs.list.size );
11501 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
11503 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
11507 /*******************************************************************
11509 * @brief Build And Send F1ResetAck
11513 * Function : BuildAndSendF1ResetAck
11516 * - Build And Send F1ResetRSP
11519 * @return ROK - success
11520 * RFAILED - failure
11522 * ****************************************************************/
11523 uint8_t BuildAndSendF1ResetAck()
11526 uint8_t elementCnt = 0;
11527 uint8_t ret = RFAILED;
11528 F1AP_PDU_t *f1apMsg = NULL;
11529 ResetAcknowledge_t *f1ResetAck = NULLP;
11530 asn_enc_rval_t encRetVal;
11531 DU_LOG("\nINFO --> F1AP : Building F1 Reset Acknowledgment \n");
11534 /* Allocate the memory for F1ResetRequest_t */
11535 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
11536 if(f1apMsg == NULLP)
11538 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11542 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
11544 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
11545 if(f1apMsg->choice.successfulOutcome == NULLP)
11547 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11550 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
11551 f1apMsg->choice.successfulOutcome->value.present = SuccessfulOutcome__value_PR_ResetAcknowledge;
11552 f1ResetAck = &f1apMsg->choice.successfulOutcome->value.choice.ResetAcknowledge;
11556 f1ResetAck->protocolIEs.list.count = elementCnt;
11557 f1ResetAck->protocolIEs.list.size = elementCnt*sizeof(ResetAcknowledgeIEs_t *);
11559 DU_ALLOC(f1ResetAck->protocolIEs.list.array, f1ResetAck->protocolIEs.list.size );
11560 if(f1ResetAck->protocolIEs.list.array == NULLP)
11562 DU_LOG("\nERROR --> F1AP : Memory allocation for F1ResetAckIEs failed");
11566 for(idx=0; idx<elementCnt; idx++)
11568 DU_ALLOC(f1ResetAck->protocolIEs.list.array[idx], sizeof(ResetAcknowledgeIEs_t));
11569 if(f1ResetAck->protocolIEs.list.array[idx] == NULLP)
11576 f1ResetAck->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID;
11577 f1ResetAck->protocolIEs.list.array[idx]->criticality = Criticality_reject;
11578 f1ResetAck->protocolIEs.list.array[idx]->value.present = ResetAcknowledgeIEs__value_PR_TransactionID;
11579 f1ResetAck->protocolIEs.list.array[idx]->value.choice.TransactionID = TRANS_ID;
11581 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
11583 /* Encode the F1SetupRequest type as UPER */
11584 memset(encBuf, 0, ENC_BUF_MAX_LEN);
11586 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
11588 /* Check encode results */
11589 if(encRetVal.encoded == ENCODE_FAIL)
11591 DU_LOG("\nERROR --> F1AP : Could not encode F1ResetAck structure (at %s)\n",\
11592 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
11597 DU_LOG("\nDUBUG --> F1AP : Created APER encoded buffer for F1ResetAck\n");
11598 for(int i=0; i< encBufSize; i++)
11600 printf("%x",encBuf[i]);
11604 if(sendF1APMsg() != ROK)
11606 DU_LOG("\nERROR --> F1AP : Sending F1 Reset Acknowledgement failed");
11614 FreeF1ResetAck(f1apMsg);
11617 /******************************************************************
11619 * @brief free F1 reset msg allocated by aper_decoder
11623 * Function : freeAperDecodeF1ResetMsg
11625 * Functionality: free F1 reset msg allocated by aper_decoder
11627 * @params[in] Reset_t *f1ResetMsg
11630 * ****************************************************************/
11632 void freeAperDecodeF1ResetMsg(Reset_t *f1ResetMsg)
11635 if(f1ResetMsg->protocolIEs.list.array)
11637 for(ieIdx=0 ;ieIdx < f1ResetMsg->protocolIEs.list.count ; ieIdx++)
11639 if(f1ResetMsg->protocolIEs.list.array[ieIdx])
11641 free(f1ResetMsg->protocolIEs.list.array[ieIdx]);
11644 free(f1ResetMsg->protocolIEs.list.array);
11648 /******************************************************************
11650 * @brief Processes DL RRC Message Transfer sent by CU
11654 * Function : procF1ResetReq
11656 * Functionality: Processes DL RRC Message Transfer sent by CU
11658 * @params[in] F1AP_PDU_t ASN decoded F1AP message
11659 * @return ROK - success
11660 * RFAILED - failure
11662 * ****************************************************************/
11663 uint8_t procF1ResetReq(F1AP_PDU_t *f1apMsg)
11665 /* we are currently not supporting Ue release. right now we are supporting only init case of fireset */
11668 Reset_t *f1ResetMsg = NULLP;
11670 DU_LOG("\nINFO --> Processing F1 reset request");
11671 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
11673 for(ieIdx=0; ieIdx<f1ResetMsg->protocolIEs.list.count; ieIdx++)
11675 switch(f1ResetMsg->protocolIEs.list.array[ieIdx]->id)
11677 case ProtocolIE_ID_id_TransactionID:
11680 case ProtocolIE_ID_id_Cause:
11683 case ProtocolIE_ID_id_ResetType:
11692 ret = BuildAndSendF1ResetAck();
11693 DU_LOG("\nINFO --> UE release is not supported for now");
11695 freeAperDecodeF1ResetMsg(f1ResetMsg);
11700 /*******************************************************************
11702 * @brief free the RRC delivery report
11706 * Function : freeRrcDeliveryReport
11708 * Functionality: free the RRC delivery report
11711 * @return ROK - success
11712 * RFAILED - failure
11714 * ****************************************************************/
11715 void freeRrcDeliveryReport(F1AP_PDU_t *f1apMsg )
11718 RRCDeliveryReport_t *rrcDeliveryReport= NULLP;
11722 if(f1apMsg->choice.initiatingMessage)
11724 rrcDeliveryReport = &f1apMsg->choice.initiatingMessage->value.choice.RRCDeliveryReport;
11725 if(rrcDeliveryReport->protocolIEs.list.array)
11727 for(idx =0 ;idx <rrcDeliveryReport->protocolIEs.list.count ;
11730 if(rrcDeliveryReport->protocolIEs.list.array[idx])
11732 DU_FREE(rrcDeliveryReport->protocolIEs.list.array[idx],
11733 sizeof(RRCDeliveryReportIEs_t));
11736 DU_FREE(rrcDeliveryReport->protocolIEs.list.array,
11737 rrcDeliveryReport->protocolIEs.list.size);
11739 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
11742 sizeof(F1AP_PDU_t));
11746 /*******************************************************************
11748 * @brief Builds and sends the RRC delivery report
11752 * Function : BuildAndSendRrcDeliveryReport
11754 * Functionality: Builds and sends the RRC delivery report
11758 * @return ROK - success
11759 * RFAILED - failure
11761 * ****************************************************************/
11762 uint8_t BuildAndSendRrcDeliveryReport(uint32_t gnbCuUeF1apId, \
11763 uint32_t gnbDuUeF1apId, RrcDeliveryReport *rrcDelivery)
11765 uint8_t ret = RFAILED;
11768 uint8_t elementCnt = 0;
11769 F1AP_PDU_t *f1apMsg = NULLP;
11770 asn_enc_rval_t encRetVal;
11771 RRCDeliveryReport_t *rrcDeliveryReport= NULLP;
11775 DU_LOG("\nINFO --> F1AP : Building RRC delivery Message Transfer Message\n");
11776 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
11777 if(f1apMsg == NULLP)
11779 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11782 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
11783 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
11784 if(f1apMsg->choice.initiatingMessage == NULLP)
11786 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
11789 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_RRCDeliveryReport;
11790 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
11791 f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_RRCDeliveryReport;
11793 rrcDeliveryReport = &f1apMsg->choice.initiatingMessage->value.choice.RRCDeliveryReport;
11795 rrcDeliveryReport->protocolIEs.list.count = elementCnt;
11796 rrcDeliveryReport->protocolIEs.list.size = elementCnt * sizeof(RRCDeliveryReportIEs_t *);
11798 /* Initialize the F1Setup members */
11799 DU_ALLOC(rrcDeliveryReport->protocolIEs.list.array, rrcDeliveryReport->protocolIEs.list.size);
11800 if(rrcDeliveryReport->protocolIEs.list.array == NULLP)
11802 DU_LOG(" ERROR --> F1AP : Memory allocation for RRC Delivery failed");
11805 for(idx =0 ;idx <elementCnt; idx++)
11807 DU_ALLOC(rrcDeliveryReport->protocolIEs.list.array[idx], sizeof(RRCDeliveryReportIEs_t));
11808 if(rrcDeliveryReport->protocolIEs.list.array[idx] == NULLP)
11816 /*GNB CU UE F1AP ID*/
11817 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
11818 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
11819 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_GNB_CU_UE_F1AP_ID;
11820 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
11822 /*GNB DU UE F1AP ID*/
11824 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
11825 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
11826 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_GNB_DU_UE_F1AP_ID;
11827 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
11829 /*RRC delivery status*/
11831 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_RRCDeliveryStatus;
11832 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_ignore;
11833 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_RRCDeliveryStatus;
11834 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.RRCDeliveryStatus.delivery_status =\
11835 rrcDelivery->rrcDeliveryStatus.deliveryStatus;
11836 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.RRCDeliveryStatus.triggering_message =\
11837 rrcDelivery->rrcDeliveryStatus.triggeringMessage;
11841 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_SRBID;
11842 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_ignore;
11843 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_SRBID;
11844 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.SRBID = rrcDelivery->srbId;
11846 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
11848 /* Encode the RRC DELIVERY REPORT type as APER */
11849 memset(encBuf, 0, ENC_BUF_MAX_LEN);
11851 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
11854 /* Encode results */
11855 if(encRetVal.encoded == ENCODE_FAIL)
11857 DU_LOG("\nERROR --> F1AP : Could not encode RRC Delivery Msg structure (at %s)\n",\
11858 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
11863 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for RRC Delivery Msg \n");
11864 for(idx=0; idx< encBufSize; idx++)
11866 printf("%x",encBuf[idx]);
11871 if(sendF1APMsg() != ROK)
11873 DU_LOG("\nERROR --> F1AP : Sending RRC delivery msg request failed");
11881 freeRrcDeliveryReport(f1apMsg);
11885 /*******************************************************************
11887 * @brief Processes cells to be activated
11891 * Function : extractCellsToBeActivated
11894 * - Processes cells to be activated list received in F1SetupRsp
11897 * @return ROK - success
11898 * RFAILED - failure
11900 * ****************************************************************/
11902 uint8_t extractCellsToBeActivated(Cells_to_be_Activated_List_t cellsToActivate)
11905 uint16_t idx, nci, pci = 0;
11906 Cells_to_be_Activated_List_Item_t cell;
11908 for(idx=0; idx<cellsToActivate.list.count; idx++)
11911 cell = cellsToActivate.list.array[idx]->value.choice.Cells_to_be_Activated_List_Item;
11912 bitStringToInt(&cell.nRCGI.nRCellIdentity, &nci);
11918 ret = duProcCellsToBeActivated(cell.nRCGI.pLMN_Identity.buf, nci, pci);
11922 /******************************************************************
11924 * @brief Processes F1 Setup Response allocated by aper_decoder
11928 * Function : freeF1SetupRsp
11930 * Functionality: free F1 Setup Response allocated by aper_decoder
11932 * @params[in] F1SetupResponse_t *f1SetRspMsg
11935 * ****************************************************************/
11937 void freeAperDecodeF1SetupRsp(F1SetupResponse_t *f1SetRspMsg)
11941 Cells_to_be_Activated_List_t *cellToActivate =NULLP;
11942 RRC_Version_t *rrcVer =NULLP;
11944 if(f1SetRspMsg->protocolIEs.list.array)
11946 for(ieIdx=0; ieIdx<f1SetRspMsg->protocolIEs.list.count; ieIdx++)
11948 if(f1SetRspMsg->protocolIEs.list.array[ieIdx])
11950 switch(f1SetRspMsg->protocolIEs.list.array[ieIdx]->id)
11952 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
11955 &f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.Cells_to_be_Activated_List;
11956 if(cellToActivate->list.array)
11958 for(arrIdx=0; arrIdx<cellToActivate->list.count ; arrIdx++)
11960 if(cellToActivate->list.array[arrIdx])
11963 if(cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.nRCGI.\
11966 if(cellToActivate->list.array[0]->value.choice.\
11967 Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf)
11969 free(cellToActivate->list.array[0]->value.choice.\
11970 Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf);
11973 free(cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.\
11974 nRCGI.pLMN_Identity.buf);
11976 free(cellToActivate->list.array[arrIdx]);
11979 free(cellToActivate->list.array);
11983 case ProtocolIE_ID_id_TransactionID:
11987 case ProtocolIE_ID_id_gNB_CU_Name:
11989 free(f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_Name.buf);
11992 case ProtocolIE_ID_id_GNB_CU_RRC_Version:
11994 rrcVer = &f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.RRC_Version;
11995 if(rrcVer->latest_RRC_Version.buf)
11997 if(rrcVer->iE_Extensions)
11999 if(rrcVer->iE_Extensions->list.array)
12001 if(rrcVer->iE_Extensions->list.array[0])
12003 if(rrcVer->iE_Extensions->list.\
12004 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf)
12006 free(rrcVer->iE_Extensions->list.\
12007 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf);
12009 free(rrcVer->iE_Extensions->list.array[0]);
12011 free(rrcVer->iE_Extensions->list.array);
12013 free(rrcVer->iE_Extensions);
12015 free(rrcVer->latest_RRC_Version.buf);
12022 DU_LOG("\nERROR --> DU_APP : Invalid IE received in F1SetupRsp:%ld",
12023 f1SetRspMsg->protocolIEs.list.array[ieIdx]->id);
12026 free(f1SetRspMsg->protocolIEs.list.array[ieIdx]);
12029 free(f1SetRspMsg->protocolIEs.list.array);
12032 /******************************************************************
12034 * @brief Processes F1 Setup Response sent by CU
12038 * Function : procF1SetupRsp
12040 * Functionality: Processes F1 Setup Response sent by CU
12042 * @params[in] F1AP_PDU_t ASN decoded F1AP message
12043 * @return ROK - success
12044 * RFAILED - failure
12046 * ****************************************************************/
12047 uint8_t procF1SetupRsp(F1AP_PDU_t *f1apMsg)
12051 F1SetupResponse_t *f1SetRspMsg = NULLP;
12052 GNB_CU_Name_t *cuName = NULLP;
12053 F1SetupRsp f1SetRspDb;
12054 RRC_Version_t *rrcVer =NULLP;
12056 memset(&f1SetRspDb, 0, sizeof(F1SetupRsp));
12058 DU_LOG("\nINFO --> F1AP : F1 Setup Response received");
12059 f1SetRspMsg = &f1apMsg->choice.successfulOutcome->value.choice.F1SetupResponse;
12061 for(idx=0; idx<f1SetRspMsg->protocolIEs.list.count; idx++)
12063 switch(f1SetRspMsg->protocolIEs.list.array[idx]->id)
12065 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
12067 extractCellsToBeActivated(f1SetRspMsg->protocolIEs.list.array[idx]->\
12068 value.choice.Cells_to_be_Activated_List);
12071 case ProtocolIE_ID_id_TransactionID:
12073 f1SetRspDb.transId = f1SetRspMsg->protocolIEs.list.array[idx]->\
12074 value.choice.TransactionID;
12077 case ProtocolIE_ID_id_gNB_CU_Name:
12079 cuName = &f1SetRspMsg->protocolIEs.list.array[idx]->\
12080 value.choice.GNB_CU_Name;
12081 strcpy(f1SetRspDb.cuName, (const char*)cuName->buf);
12084 case ProtocolIE_ID_id_GNB_CU_RRC_Version:
12086 rrcVer = &f1SetRspMsg->protocolIEs.list.array[idx]->value.choice.RRC_Version;
12087 strcpy(f1SetRspDb.rrcVersion.rrcVer,
12088 (const char*)rrcVer->latest_RRC_Version.buf);
12092 DU_LOG("\nERROR --> DU_APP : Invalid IE received in F1SetupRsp:%ld",
12093 f1SetRspMsg->protocolIEs.list.array[idx]->id);
12095 duProcF1SetupRsp();
12098 freeAperDecodeF1SetupRsp(f1SetRspMsg);
12101 /*******************************************************************
12103 * @brief free GNB DU config update ack
12107 * Function : freeAperDecodeGnbDuAck
12109 * Functionality: Processes GNB DU config update ack And
12110 * added free part for the memory allocated by aper_decoder
12112 * @params[in] F1AP_PDU_t ASN decoded F1AP message
12113 * @return ROK - success
12114 * RFAILED - failure
12116 * ****************************************************************/
12118 void freeAperDecodeGnbDuAck(GNBDUConfigurationUpdateAcknowledge_t *gnbDuAck)
12122 if(gnbDuAck->protocolIEs.list.array)
12124 for(ieIdx=0; ieIdx < gnbDuAck->protocolIEs.list.count; ieIdx++)
12126 if(gnbDuAck->protocolIEs.list.array[ieIdx])
12128 free(gnbDuAck->protocolIEs.list.array[ieIdx]);
12131 free(gnbDuAck->protocolIEs.list.array);
12135 /*******************************************************************
12137 * @brief Building result of gnb-du config update ack output
12141 * Function : duProcGnbDuCfgUpdAckMsg
12144 * Building output of gnb-du config update ack
12146 * @params[in] transId
12149 * ****************************************************************/
12151 uint8_t duProcGnbDuCfgUpdAckMsg(uint8_t transId)
12153 uint8_t ieIdx=0, arrIdx=0,ret=ROK;
12154 uint8_t ueId =0 , ueIdx =0;
12155 uint16_t cellId =0, cellIdx =0, crnti=0;
12156 CmLList *f1apPduNode = NULLP;
12157 ReservedF1apPduInfo *f1apPduInfo =NULLP;
12158 F1AP_PDU_t *f1apMsgPdu = NULLP;
12159 GNBDUConfigurationUpdate_t *gnbDuConfigUpdate = NULLP;
12160 BIT_STRING_t *cellIdentity=NULLP;
12161 struct Served_Cells_To_Delete_ItemIEs *deleteItemIe=NULLP;
12162 Served_Cells_To_Delete_List_t *cellsToDelete=NULLP;
12163 Served_Cells_To_Delete_Item_t *deleteItem=NULLP;
12165 DU_LOG("\nINFO --> DU APP: GNB-DU config update Ack received ");
12166 f1apPduNode = searchFromReservedF1apPduList(transId);
12167 f1apPduInfo = (ReservedF1apPduInfo *)f1apPduNode->node;
12168 f1apMsgPdu = (F1AP_PDU_t *)f1apPduInfo->f1apMsg;
12172 if(f1apMsgPdu->choice.initiatingMessage)
12174 gnbDuConfigUpdate = &f1apMsgPdu->choice.initiatingMessage->value.choice.GNBDUConfigurationUpdate;
12175 for(ieIdx=0; ieIdx < gnbDuConfigUpdate->protocolIEs.list.count; ieIdx++)
12177 switch(gnbDuConfigUpdate->protocolIEs.list.array[ieIdx]->id)
12179 case ProtocolIE_ID_id_Served_Cells_To_Delete_List:
12181 cellsToDelete = &gnbDuConfigUpdate->protocolIEs.list.array[ieIdx]->value.choice.\
12182 Served_Cells_To_Delete_List;
12183 if(cellsToDelete->list.array)
12185 if(cellsToDelete->list.array[arrIdx])
12187 deleteItemIe = (Served_Cells_To_Delete_ItemIEs_t*)cellsToDelete->list.array[arrIdx];
12188 deleteItem=&deleteItemIe->value.choice.Served_Cells_To_Delete_Item;
12189 if(deleteItem->oldNRCGI.nRCellIdentity.buf)
12191 cellIdentity = &deleteItem->oldNRCGI.nRCellIdentity;
12192 bitStringToInt(cellIdentity, &cellId);
12197 GET_CELL_IDX(cellId, cellIdx);
12198 if(duCb.actvCellLst[cellIdx] != NULLP)
12200 if(duCb.actvCellLst[cellIdx]->numActvUes == 0)
12202 duCb.actvCellLst[cellId-1]->cellStatus = DELETION_IN_PROGRESS;
12203 ret = duSendCellDeletReq(cellId);
12206 DU_LOG("ERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): Failed to send cell delete\
12207 request for cellId[%d]", cellId);
12212 for(ueIdx = 0; ueIdx < duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
12214 crnti = duCb.actvCellLst[cellIdx]->ueCb[ueIdx].crnti;
12215 GET_UE_IDX(crnti,ueId);
12216 ret = BuildAndSendUeContextReleaseReq(cellId, ueId);
12219 DU_LOG("ERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): Failed to build and send UE delete\
12220 request for cellId[%d]", cellId);
12227 DU_LOG("ERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): CellId [%d] not found", cellId);
12240 FreeDUConfigUpdate(f1apMsgPdu);
12241 deleteFromReservedF1apPduList(f1apPduNode);
12245 /*******************************************************************
12247 * @brief Processes GNB DU config update ack
12251 * Function : procF1GNBDUCfgUpdAck
12253 * Functionality: added free part for the memory allocated by aper_decoder
12255 * @params[in] F1AP_PDU_t *f1apMsg
12258 * ****************************************************************/
12259 uint8_t procF1GNBDUCfgUpdAck(F1AP_PDU_t *f1apMsg)
12261 uint8_t ieIdx=0,transId=0;
12262 GNBDUConfigurationUpdateAcknowledge_t *gnbDuAck = NULLP;
12264 DU_LOG("\nINFO --> F1AP : GNB-DU config update acknowledgment");
12265 gnbDuAck = &f1apMsg->choice.successfulOutcome->value.choice.GNBDUConfigurationUpdateAcknowledge;
12267 for(ieIdx=0; ieIdx < gnbDuAck->protocolIEs.list.count; ieIdx++)
12269 switch(gnbDuAck->protocolIEs.list.array[ieIdx]->id)
12271 case ProtocolIE_ID_id_TransactionID:
12273 transId = gnbDuAck->protocolIEs.list.array[ieIdx]->value.choice.TransactionID;
12276 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
12282 DU_LOG("\nERROR --> F1AP: procF1GNBDUCfgUpdAck(): Invalid IE Received: %ld", \
12283 gnbDuAck->protocolIEs.list.array[ieIdx]->id);
12289 duProcGnbDuCfgUpdAckMsg(transId);
12292 /* presently we are not supporting F1 Reset from DU to CU , we are only
12293 * supporting F1 Reset from CU to DU */
12295 if(BuildAndSendF1ResetReq() != ROK)
12301 freeAperDecodeGnbDuAck(gnbDuAck);
12304 /******************************************************************
12306 * @brief free DL RRC Message Transfer allocated by aper_decoder
12310 * Function : freeAperDecodef1DlRrcMsg
12312 * Functionality: free DL RRC Message Transfer allocated by aper_decoder
12314 * @params[in] DLRRCMessageTransfer_t *f1DlRrcMsg
12315 * @return ROK - success
12316 * RFAILED - failure
12318 * ****************************************************************/
12320 void freeAperDecodef1DlRrcMsg(DLRRCMessageTransfer_t *f1DlRrcMsg)
12323 RRCContainer_t *rrcContainer = NULLP;
12325 if(f1DlRrcMsg->protocolIEs.list.array)
12327 for(ieIdx=0; ieIdx<f1DlRrcMsg->protocolIEs.list.count; ieIdx++)
12329 if(f1DlRrcMsg->protocolIEs.list.array[ieIdx])
12331 switch(f1DlRrcMsg->protocolIEs.list.array[ieIdx]->id)
12333 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12335 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12337 case ProtocolIE_ID_id_SRBID:
12339 case ProtocolIE_ID_id_RRCContainer:
12341 rrcContainer =&f1DlRrcMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer;
12342 free(rrcContainer->buf);
12344 case ProtocolIE_ID_id_ExecuteDuplication:
12346 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
12350 free(f1DlRrcMsg->protocolIEs.list.array[ieIdx]);
12353 free(f1DlRrcMsg->protocolIEs.list.array);
12356 /******************************************************************
12358 * @brief Processes DL RRC Message Transfer sent by CU
12362 * Function : procF1DlRrcMsgTrans
12364 * Functionality: Processes DL RRC Message Transfer sent by CU
12366 * @params[in] F1AP_PDU_t ASN decoded F1AP message
12367 * @return ROK - success
12368 * RFAILED - failure
12370 * ****************************************************************/
12371 uint8_t procF1DlRrcMsgTrans(F1AP_PDU_t *f1apMsg)
12374 DLRRCMessageTransfer_t *f1DlRrcMsg = NULLP;
12376 memset(&dlMsg, 0, sizeof(F1DlRrcMsg));
12378 DU_LOG("\nINFO --> DU_APP : DL RRC message transfer Recevied");
12379 f1DlRrcMsg = &f1apMsg->choice.initiatingMessage->value.choice.DLRRCMessageTransfer;
12383 for(idx=0; idx<f1DlRrcMsg->protocolIEs.list.count; idx++)
12385 switch(f1DlRrcMsg->protocolIEs.list.array[idx]->id)
12387 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12389 dlMsg.gnbCuUeF1apId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID;
12392 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12394 dlMsg.gnbDuUeF1apId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID;
12397 case ProtocolIE_ID_id_SRBID:
12399 dlMsg.srbId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.SRBID;
12402 case ProtocolIE_ID_id_ExecuteDuplication:
12403 dlMsg.execDup = true;
12406 case ProtocolIE_ID_id_RRCContainer:
12408 if(f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size > 0)
12410 dlMsg.rrcMsgSize = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size;
12411 DU_ALLOC_SHRABL_BUF(dlMsg.rrcMsgPdu, dlMsg.rrcMsgSize);
12412 if(dlMsg.rrcMsgPdu)
12414 memcpy(dlMsg.rrcMsgPdu, f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.buf,\
12419 DU_LOG("\nERROR --> DU APP : Memory alloc Failed at RRC Container at procF1DlRrcMsgTrans()");
12425 DU_LOG("\nERROR --> DU_APP : RRC Container Size is invalid:%ld",\
12426 f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size);
12431 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
12433 dlMsg.deliveryStatRpt = true;
12437 DU_LOG("\nERROR --> DU_APP : Invalid IE received in DL RRC Msg Transfer:%ld",
12438 f1DlRrcMsg->protocolIEs.list.array[idx]->id);
12442 ret = duProcDlRrcMsg(&dlMsg);
12444 freeAperDecodef1DlRrcMsg(f1DlRrcMsg);
12447 /*******************************************************************
12449 * @brief Builds the DRB to be Setup Mod list
12455 * Functionality: Constructs the DRB to be Setup Mod list
12457 * @params[in] DRBs_SetupMod_List_t *drbSet
12459 * @return ROK - success
12460 * RFAILED - failure
12462 * ****************************************************************/
12464 uint8_t BuildDrbSetupModList(DRBs_SetupMod_List_t *drbSet , DuUeCfg *ueCfg)
12468 struct DRBs_SetupMod_ItemIEs *drbItemIe;
12471 drbSet->list.count = drbCnt;
12472 drbSet->list.size = drbCnt * sizeof(DRBs_SetupMod_ItemIEs_t *);
12473 DU_ALLOC(drbSet->list.array, drbSet->list.size);
12474 if(drbSet->list.array == NULLP)
12476 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDrbToBeSetupModList");
12479 for(arrIdx=0; arrIdx<drbCnt; arrIdx++)
12481 DU_ALLOC(drbSet->list.array[arrIdx], sizeof(DRBs_SetupMod_ItemIEs_t));
12482 if(drbSet->list.array[arrIdx] == NULLP)
12484 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDrbToBeSetupModList");
12488 drbItemIe = (struct DRBs_SetupMod_ItemIEs *)drbSet->list.array[arrIdx];
12489 drbItemIe->id = ProtocolIE_ID_id_DRBs_SetupMod_Item;
12490 drbItemIe->criticality = Criticality_reject;
12491 drbItemIe->value.present = DRBs_SetupMod_ItemIEs__value_PR_DRBs_SetupMod_Item;
12492 drbItemIe->value.choice.DRBs_SetupMod_Item.dRBID = ueCfg->upTnlInfo[arrIdx].drbId;
12493 if(fillDlTnlSetupList(&drbItemIe->value.choice.DRBs_SetupMod_Item.dLUPTNLInformation_ToBeSetup_List,\
12494 &ueCfg->upTnlInfo[arrIdx])!= ROK)
12496 DU_LOG("\nERROR --> F1AP : Failed to fill DlTnl SetupList in BuildDrbToBeSetupModList");
12504 /*******************************************************************
12505 * @brief Free the memory allocated for DRB setup List
12509 * Function : FreeDrbSetupModList
12512 * Free the memory allocated for DRB setup list
12514 * @params[in] DRBs_Setup_List_t *
12517 * ****************************************************************/
12518 void FreeDrbSetupModList(DRBs_SetupMod_List_t *drbSetupList)
12520 uint8_t arrIdx = 0;
12521 DRBs_SetupMod_ItemIEs_t *drbItemIe = NULLP;
12523 for(arrIdx = 0; arrIdx < drbSetupList->list.count; arrIdx++)
12525 drbItemIe = ((DRBs_SetupMod_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
12526 freeDlTnlInfo(&drbItemIe->value.choice.DRBs_SetupMod_Item.dLUPTNLInformation_ToBeSetup_List);
12527 DU_FREE(drbSetupList->list.array[arrIdx], sizeof(DRBs_SetupMod_ItemIEs_t));
12529 DU_FREE(drbSetupList->list.array, drbSetupList->list.size);
12531 /*******************************************************************
12532 * @brief Free the memory allocated for UE Context Mod Response
12536 * Function : FreeUeContextModResp
12539 * Free the memory allocated for UE Context Mod Response
12541 * @params[in] F1AP_PDU_t *f1apMsg
12544 * ****************************************************************/
12546 void FreeUeContextModResp(F1AP_PDU_t *f1apMsg)
12549 UEContextModificationResponse_t *ueContextModifyRes = NULLP;
12552 if(f1apMsg->choice.successfulOutcome)
12554 ueContextModifyRes =&f1apMsg->choice.successfulOutcome->value.choice.UEContextModificationResponse;
12555 if(ueContextModifyRes->protocolIEs.list.array)
12557 for(ieIdx=0 ; ieIdx<ueContextModifyRes->protocolIEs.list.count; ieIdx++)
12559 if(ueContextModifyRes->protocolIEs.list.array[ieIdx])
12561 switch(ueContextModifyRes->protocolIEs.list.array[ieIdx]->id)
12563 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12565 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12567 case ProtocolIE_ID_id_DRBs_SetupMod_List:
12569 FreeDrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
12570 value.choice.DRBs_SetupMod_List));
12574 DU_FREE(ueContextModifyRes->protocolIEs.list.array[ieIdx], sizeof(UEContextModificationResponse_t));
12578 DU_FREE(ueContextModifyRes->protocolIEs.list.array, ueContextModifyRes->protocolIEs.list.size);
12580 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
12582 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
12586 /*****************************************************************i
12588 * @brief Creating the ue context modifcation response and sending
12592 * Function : BuildAndSendUeContextModRsp
12595 * - Creating the ue context modifcation response
12597 * @params[in] uint8_t cellId,uint8_t ueIdx
12598 * @return ROK - success
12599 * RFAILED - failure
12601 * ****************************************************************/
12602 uint8_t BuildAndSendUeContextModRsp(uint8_t cellId,uint8_t ueIdx)
12605 uint8_t cellIdx =0;
12606 uint8_t elementCnt = 0;
12607 uint8_t ret = RFAILED;
12608 uint32_t gnbCuUeF1apId; /* gNB-CU UE F1AP Id */
12609 uint32_t gnbDuUeF1apId; /* gNB-DU UE F1AP Id */
12610 F1AP_PDU_t *f1apMsg = NULLP;
12611 asn_enc_rval_t encRetVal;
12612 UEContextModificationResponse_t *ueContextModifyRes = NULLP;
12613 DuUeCb *ueCb = NULLP;
12615 DU_LOG("\nINFO --> F1AP : Building Ue context modification response\n");
12619 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
12620 if(f1apMsg == NULLP)
12622 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed Ue context modification");
12626 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
12628 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
12629 if(f1apMsg->choice.successfulOutcome == NULLP)
12631 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed Ue context modification");
12634 f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_UEContextModification;
12635 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
12636 f1apMsg->choice.successfulOutcome->value.present = SuccessfulOutcome__value_PR_UEContextModificationResponse;
12638 ueContextModifyRes =&f1apMsg->choice.successfulOutcome->value.choice.UEContextModificationResponse;
12641 ueContextModifyRes->protocolIEs.list.count = elementCnt;
12642 ueContextModifyRes->protocolIEs.list.size = elementCnt*sizeof(UEContextModificationResponse_t*);
12644 /* Initialize the UE context modification members */
12645 DU_ALLOC(ueContextModifyRes->protocolIEs.list.array, ueContextModifyRes->protocolIEs.list.size);
12646 if(ueContextModifyRes->protocolIEs.list.array == NULLP)
12648 DU_LOG("\nERROR --> F1AP : Memory allocation for UE context modifcation Request failed");
12652 for(ieIdx=0 ; ieIdx<elementCnt; ieIdx++)
12654 DU_ALLOC(ueContextModifyRes->protocolIEs.list.array[ieIdx], sizeof(UEContextModificationResponse_t));
12655 if(ueContextModifyRes->protocolIEs.list.array[ieIdx] == NULLP)
12657 DU_LOG("\nERROR --> F1AP : Memory allocation for UE context modifcation Request failed");
12662 /* Fetching Ue Cb Info*/
12663 GET_CELL_IDX(cellId, cellIdx);
12664 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
12665 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
12666 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1];
12669 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
12670 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
12671 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present =\
12672 UEContextModificationResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
12673 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
12676 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
12677 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
12678 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present=\
12679 UEContextModificationResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
12680 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
12683 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DRBs_SetupMod_List;
12684 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
12685 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present =\
12686 UEContextModificationResponseIEs__value_PR_DRBs_SetupMod_List;
12689 ret = BuildDrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
12690 value.choice.DRBs_SetupMod_List) , &ueCb->f1UeDb->duUeCfg);
12693 DU_LOG( "\nERROR --> F1AP : Failed to build drb setupmod List ");
12696 freeF1UeDb(ueCb->f1UeDb);
12697 ueCb->f1UeDb = NULLP;
12699 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
12701 /* Encode the F1SetupRequest type as APER */
12702 memset(encBuf, 0, ENC_BUF_MAX_LEN);
12704 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,encBuf);
12706 /* Encode results */
12707 if(encRetVal.encoded == ENCODE_FAIL)
12709 DU_LOG( "\nERROR --> F1AP : Could not encode UE Context Setup Request structure (at %s)\n",\
12710 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
12716 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UE Context Modification Response\n");
12717 for(int i=0; i< encBufSize; i++)
12719 printf("%x",encBuf[i]);
12724 if(sendF1APMsg() != ROK)
12726 DU_LOG("\nERROR --> F1AP : Sending UE Context Setup Res Failed");
12732 FreeUeContextModResp(f1apMsg);
12735 /*******************************************************************
12737 * @brief Deallocating the memory allocated by the aper decoder
12742 * Function : freeAperDecodeQosInfo
12744 * Functionality: Deallocating the memory allocated for QOSInfo
12746 * @params[in] QoSFlowLevelQoSParameters_t *drbQos
12750 * ****************************************************************/
12752 void freeAperDecodeQosInfo(QoSFlowLevelQoSParameters_t *drbQos)
12754 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI != NULLP)
12756 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
12758 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
12760 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
12762 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
12764 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI);
12767 /*******************************************************************
12769 * @brief Deallocating the memory allocated by the aper decoder
12770 * for UlTnlInfoforDrb
12774 * Function : freeAperDecodeUlTnlInfoforDrbSetupMod
12776 * Functionality: Deallocating memory allocated for UlTnlInfoforDrb
12778 * @params[in] ULUPTNLInformation_ToBeSetup_List_t *ulInfo
12782 * ****************************************************************/
12783 void freeAperDecodeUlTnlInfoforDrbSetupMod(ULUPTNLInformation_ToBeSetup_List_t *ulInfo)
12787 if(ulInfo->list.array)
12789 for(arrIdx=0; arrIdx<ulInfo->list.count ; arrIdx++)
12791 if(ulInfo->list.array[arrIdx])
12793 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel )
12795 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.buf)
12797 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf)
12799 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\
12802 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\
12803 transportLayerAddress.buf);
12805 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel);
12807 free(ulInfo->list.array[arrIdx]);
12810 free(ulInfo->list.array);
12813 /*******************************************************************
12815 * @brief Deallocating the memory allocated by the aper decoder
12816 * for DrbSetupModItem
12820 * Function : freeAperDecodeDrbSetupModItem
12822 * Functionality: Deallocating memory allocated for DrbSetupModItem
12824 * @params[in] DRBs_ToBeSetupMod_Item_t *drbItem
12828 * ****************************************************************/
12830 void freeAperDecodeDrbSetupModItem(DRBs_ToBeSetupMod_Item_t *drbItem)
12833 SNSSAI_t *snssai =NULLP;
12834 Flows_Mapped_To_DRB_List_t *flowMap = NULLP;
12836 drbItem->qoSInformation.present = QoSInformation_PR_choice_extension;
12837 switch(drbItem->qoSInformation.present)
12839 case QoSInformation_PR_NOTHING:
12841 case QoSInformation_PR_eUTRANQoS:
12843 if(drbItem->qoSInformation.choice.eUTRANQoS)
12845 free(drbItem->qoSInformation.choice.eUTRANQoS);
12849 case QoSInformation_PR_choice_extension:
12851 if(drbItem->qoSInformation.choice.choice_extension)
12853 freeAperDecodeQosInfo(&drbItem->qoSInformation.choice.choice_extension->value.choice.\
12854 DRB_Information.dRB_QoS);
12855 snssai = &drbItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI;
12856 if(snssai->sST.buf)
12858 free(snssai->sST.buf);
12862 if(snssai->sD->buf)
12864 free(snssai->sD->buf);
12869 flowMap = &drbItem->qoSInformation.choice.choice_extension->value.choice.\
12870 DRB_Information.flows_Mapped_To_DRB_List;
12871 if(flowMap->list.array)
12873 for(arrIdx=0; arrIdx<flowMap->list.count; arrIdx++)
12875 if(flowMap->list.array[arrIdx] )
12877 freeAperDecodeQosInfo(&flowMap->list.array[arrIdx]->qoSFlowLevelQoSParameters);
12878 free(flowMap->list.array[arrIdx]);
12881 free(flowMap->list.array);
12884 free(drbItem->qoSInformation.choice.choice_extension);
12890 freeAperDecodeUlTnlInfoforDrbSetupMod(&drbItem->uLUPTNLInformation_ToBeSetup_List);
12891 if(drbItem->uLConfiguration)
12893 free(drbItem->uLConfiguration);
12897 /*******************************************************************
12899 * @brief Deallocating the memory allocated by the aper decoder
12900 * for DrbToBeSetupModList
12904 * Function : freeAperDecodeDrbToBeSetupModList
12906 * Functionality: Deallocating memory allocated for DrbToBeSetupModList
12908 * @params[in] DRBs_ToBeSetupMod_List_t *drbSet
12912 * ****************************************************************/
12914 void freeAperDecodeDrbToBeSetupModList(DRBs_ToBeSetupMod_List_t *drbSet)
12917 struct DRBs_ToBeSetupMod_ItemIEs *drbItemIe;
12919 if(drbSet->list.array)
12921 for(arrIdx=0; arrIdx<drbSet->list.count ; arrIdx++)
12923 if(drbSet->list.array[arrIdx] != NULLP)
12927 drbItemIe = (DRBs_ToBeSetupMod_ItemIEs_t *)drbSet->list.array[arrIdx];
12928 freeAperDecodeDrbSetupModItem(&(drbItemIe->value.choice.DRBs_ToBeSetupMod_Item));
12930 free(drbSet->list.array[arrIdx]);
12933 free(drbSet->list.array);
12937 /*******************************************************************
12939 * @brief Deallocating the memory allocated by the aper decoder
12940 * for UeContextModificationReqMsg
12944 * Function : freeAperDecodeUeContextModificationReqMsg
12946 * Functionality: Deallocating memory allocated for
12947 * UeContextModificationReqMsg
12949 * @params[in] UEContextModificationRequest_t *UeContextModifyReq
12953 * ****************************************************************/
12954 void freeAperDecodeUeContextModificationReqMsg(UEContextModificationRequest_t *UeContextModifyReq )
12956 uint8_t arrIdx, ieId;
12958 if(UeContextModifyReq->protocolIEs.list.array)
12960 for( arrIdx = 0 ; arrIdx<UeContextModifyReq->protocolIEs.list.count ; arrIdx++)
12962 if(UeContextModifyReq->protocolIEs.list.array[arrIdx])
12964 ieId = UeContextModifyReq->protocolIEs.list.array[arrIdx]->id;
12967 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
12969 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
12971 case ProtocolIE_ID_id_DRBs_ToBeSetupMod_List:
12973 freeAperDecodeDrbToBeSetupModList(&UeContextModifyReq->protocolIEs.list.array[arrIdx]->\
12974 value.choice.DRBs_ToBeSetupMod_List);
12978 free(UeContextModifyReq->protocolIEs.list.array[arrIdx]);
12981 free(UeContextModifyReq->protocolIEs.list.array);
12984 /*******************************************************************
12986 * @brief processing the F1 UeContextModificationReq
12990 * Function : procF1UeContextModificationReq
12992 * Functionality: processing the F1 UeContextModificationReq
12994 * @params[in] F1AP_PDU_t *f1apMsg
12997 * ****************************************************************/
12998 uint8_t procF1UeContextModificationReq(F1AP_PDU_t *f1apMsg)
13000 UEContextModificationRequest_t *ueContextModifyReq = NULLP;
13001 uint8_t ret = ROK, ieIdx = 0, cellIdx=0, ueIdx=0;
13002 DuUeCb *duUeCb = NULLP;
13003 DRBs_ToBeSetupMod_List_t *drbSetupModCfg;
13004 DRBs_ToBeModified_List_t *drbModifiedCfg;
13005 uint32_t gnbCuUeF1apId, gnbDuUeF1apId;
13007 ueContextModifyReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextModificationRequest;
13008 for(ieIdx=0; (ieIdx < ueContextModifyReq->protocolIEs.list.count && ret == ROK); ieIdx++)
13010 switch(ueContextModifyReq->protocolIEs.list.array[ieIdx]->id)
13012 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
13014 gnbCuUeF1apId = ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID;
13017 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
13019 gnbDuUeF1apId = ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID;
13022 case ProtocolIE_ID_id_DRBs_ToBeSetupMod_List:
13023 case ProtocolIE_ID_id_DRBs_ToBeModified_List:
13025 for(cellIdx = 0; cellIdx < duCb.numActvCells; cellIdx++)
13027 for(ueIdx = 0; ueIdx < duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
13029 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
13030 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
13033 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
13034 if(duUeCb->f1UeDb == NULLP)
13036 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
13040 duUeCb->f1UeDb->actionType = UE_CTXT_MOD;
13041 if(ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.present ==\
13042 UEContextModificationRequestIEs__value_PR_DRBs_ToBeSetupMod_List)
13044 drbSetupModCfg = &ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.\
13045 choice.DRBs_ToBeSetupMod_List;
13047 if(extractDrbListToSetupMod(NULL, drbSetupModCfg, NULL, drbSetupModCfg->list.count,\
13048 &duUeCb->f1UeDb->duUeCfg, &duUeCb->drbBitMap, NULL))
13050 DU_LOG("\nERROR --> DU APP : Failed at extractDrbListToSetupMod() for DrbSetupModList");
13055 if(ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.present == \
13056 UEContextModificationRequestIEs__value_PR_DRBs_ToBeModified_List)
13059 drbModifiedCfg = &ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.\
13060 choice.DRBs_ToBeModified_List;
13061 if(extractDrbListToSetupMod(NULL, NULL, drbModifiedCfg, drbSetupModCfg->list.count,\
13062 &duUeCb->f1UeDb->duUeCfg, &duUeCb->drbBitMap, &duUeCb->rlcUeCfg))
13064 DU_LOG("\nERROR --> DU APP : Failed at extractDrbListToSetupMod() for DrbModifiedList");
13072 if(ueIdx >= duCb.actvCellLst[cellIdx]->numActvUes)
13074 DU_LOG("\nERROR --> DU APP : wrong values of gnbCuUeF1apId and gnbDuUeF1apId ");
13084 ret = duProcUeContextModReq(duUeCb);
13086 freeAperDecodeUeContextModificationReqMsg(ueContextModifyReq);
13089 /*****************************************************************i
13091 * @brief Free memory allocated for UE Context Release Request
13095 * Function : FreeUeContextReleaseReq
13098 * - Free memory allocated for UE Context Release Request
13100 * @params[in] F1AP_PDU_t *f1apMsg
13103 * *************************************************************/
13104 void FreeUeContextReleaseReq(F1AP_PDU_t *f1apMsg)
13107 UEContextReleaseRequest_t *ueReleaseReq = NULLP;
13111 if(f1apMsg->choice.initiatingMessage)
13113 ueReleaseReq =&f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseRequest;
13114 if(ueReleaseReq->protocolIEs.list.array)
13116 for(ieIdx=0 ; ieIdx<ueReleaseReq->protocolIEs.list.count; ieIdx++)
13118 DU_FREE(ueReleaseReq->protocolIEs.list.array[ieIdx], sizeof(UEContextReleaseRequest_t));
13120 DU_FREE(ueReleaseReq->protocolIEs.list.array, ueReleaseReq->protocolIEs.list.size);
13122 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
13124 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
13128 /*****************************************************************i
13130 * @brief Build and Send UE Context Release Request
13134 * Function : BuildAndSendUeContextReleaseReq
13137 * - Build and Send UE Context Release Request
13140 * @return ROK - success
13141 * RFAILED - failure
13143 * *************************************************************/
13144 uint8_t BuildAndSendUeContextReleaseReq(uint16_t cellId, uint8_t ueIdx)
13146 bool memAllocFail = false;
13148 uint8_t ret = RFAILED;
13149 uint16_t cellIdx =0;
13150 uint16_t crnti = 0;
13151 uint8_t elementCnt = 0;
13152 uint32_t gnbCuUeF1apId =0; /* gNB-CU UE F1AP Id */
13153 uint32_t gnbDuUeF1apId =0; /* gNB-DU UE F1AP Id */
13154 asn_enc_rval_t encRetVal;
13155 F1AP_PDU_t *f1apMsg = NULLP;
13156 UEContextReleaseRequest_t *ueReleaseReq = NULLP;
13158 DU_LOG("\nINFO --> Building the UE Context Release Request");
13161 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
13162 if(f1apMsg == NULLP)
13164 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for f1apMsg");
13168 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
13169 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
13170 if(f1apMsg->choice.initiatingMessage == NULLP)
13172 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for\
13173 initiatingMessage");
13176 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_UEContextReleaseRequest;
13177 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
13178 f1apMsg->choice.initiatingMessage->value.present = \
13179 InitiatingMessage__value_PR_UEContextReleaseRequest;
13181 ueReleaseReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseRequest;
13185 ueReleaseReq->protocolIEs.list.count = elementCnt;
13186 ueReleaseReq->protocolIEs.list.size = elementCnt * sizeof(UEContextReleaseRequest_t *);
13188 /* Initialize the F1Setup members */
13189 DU_ALLOC(ueReleaseReq->protocolIEs.list.array,ueReleaseReq->protocolIEs.list.size);
13190 if(ueReleaseReq->protocolIEs.list.array == NULLP)
13192 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for IE array");
13195 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
13197 DU_ALLOC(ueReleaseReq->protocolIEs.list.array[ieIdx],\
13198 sizeof(UEContextReleaseRequest_t));
13199 if(ueReleaseReq->protocolIEs.list.array[ieIdx] == NULLP)
13201 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for IE elements");
13202 memAllocFail = true;
13206 if(memAllocFail == true)
13209 /* Fetching Ue Cb Info*/
13210 GET_CELL_IDX(cellId, cellIdx);
13211 if(duCb.actvCellLst[cellIdx] == NULLP)
13213 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): CellId[%d] does not exist", cellId);
13218 GET_CRNTI(crnti, ueIdx);
13219 if(duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].crnti != crnti)
13221 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): crnti[%d] does not exist", crnti);
13224 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbDuUeF1apId;
13225 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx-1].gnbCuUeF1apId;
13229 ueReleaseReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
13230 ueReleaseReq->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
13231 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.present = \
13232 UEContextReleaseRequestIEs__value_PR_GNB_CU_UE_F1AP_ID;
13233 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID =gnbCuUeF1apId;
13236 ueReleaseReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
13237 ueReleaseReq->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
13238 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.present =\
13239 UEContextReleaseRequestIEs__value_PR_GNB_DU_UE_F1AP_ID;
13240 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID =gnbDuUeF1apId;
13242 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
13244 /* Encode the F1SetupRequest type as APER */
13245 memset(encBuf, 0, ENC_BUF_MAX_LEN);
13247 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
13248 /* Encode results */
13249 if(encRetVal.encoded == ENCODE_FAIL)
13251 DU_LOG("\nERROR --> F1AP : Could not encode UEContextReleaseRequest structure (at %s)\n",\
13252 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
13257 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UEContextReleaseRequest\n");
13258 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
13260 printf("%x",encBuf[ieIdx]);
13265 if(sendF1APMsg() != ROK)
13267 DU_LOG("\nERROR --> F1AP : Sending UE Context Release Request failed");
13274 FreeUeContextReleaseReq(f1apMsg);
13277 /*****************************************************************i
13279 * @brief Free memory allocated for UE Context Release Complete
13283 * Function : FreeUeContextReleaseComplete
13286 * - Free memory allocated for UE Context Release Complete
13288 * @params[in] F1AP_PDU_t *f1apMsg
13291 * *************************************************************/
13292 void FreeUeContextReleaseComplete(F1AP_PDU_t *f1apMsg)
13295 UEContextReleaseComplete_t *ueReleaseComplete = NULLP;
13299 if(f1apMsg->choice.successfulOutcome)
13301 ueReleaseComplete =&f1apMsg->choice.successfulOutcome->value.choice.UEContextReleaseComplete;
13302 if(ueReleaseComplete->protocolIEs.list.array)
13304 for(ieIdx=0 ; ieIdx<ueReleaseComplete->protocolIEs.list.count; ieIdx++)
13306 DU_FREE(ueReleaseComplete->protocolIEs.list.array[ieIdx], sizeof(UEContextReleaseComplete_t));
13308 DU_FREE(ueReleaseComplete->protocolIEs.list.array, ueReleaseComplete->protocolIEs.list.size);
13310 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
13312 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
13316 /*****************************************************************i
13318 * @brief Build and Send UE Context Release Complete
13322 * Function : BuildAndSendUeContextReleaseComplete
13325 * - Build and Send UE Context Release Complete
13327 * @params[in] cellId, gnbCuUeF1apId, gnbDuUeF1apId
13328 * @return ROK - success
13329 * RFAILED - failure
13331 * *************************************************************/
13332 uint8_t BuildAndSendUeContextReleaseComplete(uint16_t cellId, uint32_t gnbCuUeF1apId, uint32_t gnbDuUeF1apId)
13334 bool memAllocFail = false;
13335 uint8_t ieIdx =0, ret = RFAILED, elementCnt = 0;
13336 asn_enc_rval_t encRetVal;
13337 F1AP_PDU_t *f1apMsg = NULLP;
13338 UEContextReleaseComplete_t *ueReleaseComplete = NULLP;
13340 DU_LOG("\nINFO --> Building the UE Context Release Complete");
13343 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
13344 if(f1apMsg == NULLP)
13346 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for f1apMsg");
13350 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
13351 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
13352 if(f1apMsg->choice.successfulOutcome == NULLP)
13354 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for\
13355 successfulOutcome");
13358 f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_UEContextRelease;
13359 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
13360 f1apMsg->choice.successfulOutcome->value.present = \
13361 SuccessfulOutcome__value_PR_UEContextReleaseComplete;
13363 ueReleaseComplete = &f1apMsg->choice.successfulOutcome->value.choice.UEContextReleaseComplete;
13366 ueReleaseComplete->protocolIEs.list.count = elementCnt;
13367 ueReleaseComplete->protocolIEs.list.size = elementCnt * sizeof(UEContextReleaseComplete_t *);
13369 /* Initialize the UE Release Complete members */
13370 DU_ALLOC(ueReleaseComplete->protocolIEs.list.array,ueReleaseComplete->protocolIEs.list.size);
13371 if(ueReleaseComplete->protocolIEs.list.array == NULLP)
13373 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for IE array");
13376 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
13378 DU_ALLOC(ueReleaseComplete->protocolIEs.list.array[ieIdx],\
13379 sizeof(UEContextReleaseComplete_t));
13380 if(ueReleaseComplete->protocolIEs.list.array[ieIdx] == NULLP)
13382 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for IE\
13384 memAllocFail = true;
13388 if(memAllocFail == true)
13393 ueReleaseComplete->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
13394 ueReleaseComplete->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
13395 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.present = \
13396 UEContextReleaseCompleteIEs__value_PR_GNB_CU_UE_F1AP_ID;
13397 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID =gnbCuUeF1apId;
13400 ueReleaseComplete->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
13401 ueReleaseComplete->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
13402 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.present =\
13403 UEContextReleaseCompleteIEs__value_PR_GNB_DU_UE_F1AP_ID;
13404 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID =gnbDuUeF1apId;
13406 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
13408 /* Encode the F1SetupComplete type as APER */
13409 memset(encBuf, 0, ENC_BUF_MAX_LEN);
13411 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
13412 /* Encode results */
13413 if(encRetVal.encoded == ENCODE_FAIL)
13415 DU_LOG("\nERROR --> F1AP : Could not encode UEContextReleaseComplete structure (at %s)\n",\
13416 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
13421 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UEContextReleaseComplete\n");
13422 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
13424 printf("%x",encBuf[ieIdx]);
13429 if(sendF1APMsg() != ROK)
13431 DU_LOG("\nERROR --> F1AP : Sending UE Context Release Complete failed");
13440 duCb.actvCellLst[cellId-1]->cellStatus = DELETION_IN_PROGRESS;
13441 ret = duSendCellDeletReq(cellId);
13444 DU_LOG("\nERROR --> F1AP: BuildAndSendUeContextReleaseComplete(): Failed to process cell\
13445 Delete req for CellId");
13448 FreeUeContextReleaseComplete(f1apMsg);
13453 /*******************************************************************
13455 * @brief added free part for the memory allocated by aper_decoder
13459 * Function : freeAperDecodeUeContextReleaseCommand
13461 * Functionality: added free part for the memory allocated by aper_decoder
13463 * @params[in] F1AP_PDU_t *f1apMsg
13466 * ****************************************************************/
13467 void freeAperDecodeUeContextReleaseCommand(F1AP_PDU_t *f1apMsg)
13470 UEContextReleaseCommand_t *ueContextReleaseCommand = NULLP;
13472 ueContextReleaseCommand = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseCommand;
13474 if(ueContextReleaseCommand->protocolIEs.list.array)
13476 for(ieIdx=0; ieIdx < ueContextReleaseCommand->protocolIEs.list.count; ieIdx++)
13478 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx])
13480 switch(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id)
13482 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
13484 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
13486 case ProtocolIE_ID_id_Cause:
13488 case ProtocolIE_ID_id_RRCContainer:
13490 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
13492 free(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf);
13497 DU_LOG("\nERROR --> F1AP: freeAperDecodeUeContextReleaseCommand():Invalid IE Received: %ld"\
13498 ,ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id);
13502 free(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]);
13504 free(ueContextReleaseCommand->protocolIEs.list.array);
13507 /*******************************************************************
13509 * @brief processing of UE Context Release Command
13513 * Function : procF1UeContextReleaseCommand
13515 * Functionality: processing of UE Context Release Command
13517 * @params[in] F1AP_PDU_t *f1apMsg
13520 * ****************************************************************/
13521 uint8_t procF1UeContextReleaseCommand(F1AP_PDU_t *f1apMsg)
13523 uint8_t ieIdx=0, ret=ROK, ueIdx=0;
13524 uint16_t cellIdx =0;
13526 uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId=0;
13527 DuUeCb *duUeCb = NULLP;
13528 UEContextReleaseCommand_t *ueContextReleaseCommand = NULLP;
13530 ueContextReleaseCommand = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseCommand;
13532 if(ueContextReleaseCommand->protocolIEs.list.array)
13534 for(ieIdx=0; ieIdx < ueContextReleaseCommand->protocolIEs.list.count; ieIdx++)
13536 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx])
13538 switch(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id)
13540 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
13542 gnbCuUeF1apId= ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
13543 value.choice.GNB_CU_UE_F1AP_ID;
13547 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
13549 gnbDuUeF1apId = ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
13550 value.choice.GNB_DU_UE_F1AP_ID;
13554 case ProtocolIE_ID_id_Cause:
13559 case ProtocolIE_ID_id_RRCContainer:
13561 for(cellIdx = 0; cellIdx < duCb.numActvCells; cellIdx++)
13563 for(ueIdx = 0; ueIdx < duCb.actvCellLst[cellIdx]->numActvUes; ueIdx++)
13565 if((duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
13566 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
13568 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
13569 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
13572 memset(duUeCb->f1UeDb, 0, sizeof(F1UeContextSetupDb));
13573 duUeCb->f1UeDb->actionType = UE_CTXT_RELEASE;
13574 duUeCb->f1UeDb->cellIdx = cellIdx;
13575 /* Filling Dl RRC Msg Info */
13576 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
13577 if(!duUeCb->f1UeDb->dlRrcMsg)
13579 DU_LOG("\nERROR --> DU APP : procF1UeContextReleaseCommand(): \
13580 Memory allocation failed ");
13585 duUeCb->f1UeDb->dlRrcMsgPres = true;
13586 memset(duUeCb->f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
13587 ret = extractDlRrcMsg(gnbDuUeF1apId, gnbCuUeF1apId, duUeCb->f1UeDb->dlRrcMsg,\
13588 &ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
13589 value.choice.RRCContainer);
13595 DU_LOG("\nERROR --> DU APP : procF1UeContextReleaseCommand(): \
13596 Memory allocation failed ");
13605 if(ueIdxFound == true)
13612 DU_LOG("\nERROR --> F1AP: DuUeCb is not found at procF1UeContextSetupReq()");
13620 DU_LOG("\nERROR --> F1AP: freeAperDecodeUeContextReleaseCommand():Invalid IE Received: %ld"\
13621 ,ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id);
13629 duProcUeContextReleaseCommand(duUeCb);
13631 freeAperDecodeUeContextReleaseCommand(f1apMsg);
13634 /**************************************************************
13636 * @brief Handles received F1AP message and sends back response
13640 * Function : F1APMsgHdlr
13643 * - Decodes received F1AP control message
13644 * - Prepares response message, encodes and sends to SCTP
13647 * @return ROK - success
13648 * RFAILED - failure
13650 * ****************************************************************/
13651 void F1APMsgHdlr(Buffer *mBuf)
13654 char *recvBuf =NULLP;
13656 MsgLen recvBufLen =0;
13657 F1AP_PDU_t *f1apMsg =NULLP;
13658 asn_dec_rval_t rval; /* Decoder return value */
13659 F1AP_PDU_t f1apasnmsg ;
13660 DU_LOG("\nINFO --> F1AP : Received F1AP message buffer");
13661 ODU_PRINT_MSG(mBuf, 0,0);
13663 /* Copy mBuf into char array to decode it */
13664 ODU_GET_MSG_LEN(mBuf, &recvBufLen);
13665 DU_ALLOC(recvBuf, (Size)recvBufLen);
13667 if(recvBuf == NULLP)
13669 DU_LOG("\nERROR --> F1AP : Memory allocation failed");
13672 if(ODU_COPY_MSG_TO_FIX_BUF(mBuf, 0, recvBufLen, (Data *)recvBuf, ©Cnt) != ROK)
13674 DU_LOG("\nERROR --> F1AP : Failed while copying %d", copyCnt);
13678 printf("\nDEBUG --> F1AP : Received flat buffer to be decoded : ");
13679 for(i=0; i< recvBufLen; i++)
13681 printf("%x",recvBuf[i]);
13684 /* Decoding flat buffer into F1AP messsage */
13685 f1apMsg = &f1apasnmsg;
13686 memset(f1apMsg, 0, sizeof(F1AP_PDU_t));
13688 rval = aper_decode(0, &asn_DEF_F1AP_PDU, (void **)&f1apMsg, recvBuf, recvBufLen, 0, 0);
13689 DU_FREE(recvBuf, (Size)recvBufLen);
13691 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
13693 DU_LOG("\nERROR --> F1AP : ASN decode failed");
13697 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
13699 switch(f1apMsg->present)
13701 case F1AP_PDU_PR_successfulOutcome:
13703 switch(f1apMsg->choice.successfulOutcome->value.present)
13705 case SuccessfulOutcome__value_PR_ResetAcknowledge:
13707 DU_LOG("\nINFO --> F1AP : F1ResetAcknowledge is received successfully ");
13710 case SuccessfulOutcome__value_PR_F1SetupResponse:
13712 #ifndef ODU_TEST_STUB
13713 procF1SetupRsp(f1apMsg);
13718 case SuccessfulOutcome__value_PR_GNBDUConfigurationUpdateAcknowledge:
13720 procF1GNBDUCfgUpdAck(f1apMsg);
13726 DU_LOG("\nERROR --> F1AP : Invalid type of SuccessfulOutcome__value_PR_ResetAcknowledge [%d]",\
13727 f1apMsg->choice.successfulOutcome->value.present);
13730 }/* End of switch(successfulOutcome) */
13731 free(f1apMsg->choice.successfulOutcome);
13734 case F1AP_PDU_PR_initiatingMessage:
13736 switch(f1apMsg->choice.initiatingMessage->value.present)
13738 case InitiatingMessage__value_PR_Reset:
13740 procF1ResetReq(f1apMsg);
13743 case InitiatingMessage__value_PR_DLRRCMessageTransfer:
13745 procF1DlRrcMsgTrans(f1apMsg);
13748 case InitiatingMessage__value_PR_UEContextSetupRequest:
13750 procF1UeContextSetupReq(f1apMsg);
13753 case InitiatingMessage__value_PR_UEContextModificationRequest:
13755 procF1UeContextModificationReq(f1apMsg);
13758 case InitiatingMessage__value_PR_UEContextReleaseCommand:
13760 procF1UeContextReleaseCommand(f1apMsg);
13765 DU_LOG("\nERROR --> F1AP : Invalid type of F1AP_PDU_PR_initiatingMessage [%d]",
13766 f1apMsg->choice.initiatingMessage->value.present);
13769 }/* End of switch(initiatingMessage) */
13770 free(f1apMsg->choice.initiatingMessage);
13776 DU_LOG("\nERROR --> F1AP : Invalid type of f1apMsg->present [%d]",f1apMsg->present);
13781 }/* End of switch(f1apMsg->present) */
13783 } /* End of F1APMsgHdlr */
13785 /**********************************************************************
13787 **********************************************************************/