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"
31 #include "InitiatingMessage.h"
32 #include "SuccessfulOutcome.h"
33 #include "du_app_mac_inf.h"
35 #include "du_app_rlc_inf.h"
36 #include "du_mgr_main.h"
39 #include "du_ue_mgr.h"
41 #include "NRFreqInfo.h"
44 #include "NR-Mode-Info.h"
45 #include "ServedPLMNs-List.h"
46 #include "GNB-DU-Served-Cells-List.h"
47 #include "Served-Cell-Information.h"
48 #include "ProtocolExtensionContainer.h"
49 #include "RRC-Version.h"
51 #include "FreqBandNrItem.h"
52 #include "ServedPLMNs-Item.h"
53 #include "GNB-DU-Served-Cells-Item.h"
54 #include "SliceSupportItem.h"
55 #include "FeatureSetUplinkPerCC.h"
56 #include "SliceSupportItem.h"
57 #include "Served-Cells-To-Modify-Item.h"
58 #include "Served-Cells-To-Delete-List.h"
59 #include "Served-Cells-To-Delete-Item.h"
60 #include "QoSInformation.h"
61 #include "ULUPTNLInformation-ToBeSetup-List.h"
62 #include "DRB-Information.h"
63 #include "DRBs-ToBeSetup-Item.h"
64 #include "DRBs-ToBeSetupMod-Item.h"
65 #include "DRBs-ToBeModified-Item.h"
66 #include "CUtoDURRCInformation.h"
67 #include "SCell-ToBeSetup-List.h"
68 #include "SRBs-ToBeSetup-List.h"
69 #include "DRBs-ToBeSetup-List.h"
70 #include "SRBs-ToBeSetup-Item.h"
71 #include "DRBs-ToBeModified-List.h"
72 #include "RRCContainer.h"
73 #include "UE-CapabilityRAT-ContainerList.h"
74 #include "DRBs-Setup-List.h"
75 #include "CellGroupConfig.h"
77 #include "ResetType.h"
78 #include "Cells-to-be-Activated-List.h"
79 #include "GNB-CU-Name.h"
80 #include "SRBs-SetupMod-List.h"
81 #include "DRBs-SetupMod-List.h"
82 #include "DRBs-ToBeSetupMod-List.h"
83 #include "PagingCell-Item.h"
84 #include "PagingCell-list.h"
85 #include "QoS-Characteristics.h"
86 #include "ULUPTNLInformation-ToBeSetup-Item.h"
87 #include "Flows-Mapped-To-DRB-Item.h"
88 #include "NonDynamic5QIDescriptor.h"
89 #include "Dynamic5QIDescriptor.h"
90 #include "FeatureSetDownlinkPerCC.h"
91 #include "FeatureSets.h"
92 #include "UE-NR-Capability.h"
93 #include "UE-CapabilityRAT-Container.h"
94 #include "UE-CapabilityRAT-ContainerListRRC.h"
95 #include "GNB-DU-System-Information.h"
96 #include "CellGroupConfigRrc.h"
97 #include "MAC-CellGroupConfig.h"
98 #include "SchedulingRequestConfig.h"
99 #include "SchedulingRequestToAddMod.h"
100 #include "BSR-Config.h"
101 #include "TAG-Config.h"
103 #include "PHR-Config.h"
104 #include "RLC-Config.h"
105 #include "UL-AM-RLC.h"
106 #include "DL-AM-RLC.h"
107 #include "LogicalChannelConfig.h"
108 #include "RLC-BearerConfig.h"
109 #include "PhysicalCellGroupConfig.h"
110 #include "SpCellConfig.h"
111 #include "TDD-UL-DL-ConfigDedicated.h"
112 #include "ServingCellConfig.h"
113 #include "ControlResourceSet.h"
114 #include "SearchSpace.h"
115 #include "PDCCH-Config.h"
116 #include "PDSCH-TimeDomainResourceAllocation.h"
117 #include "PDSCH-TimeDomainResourceAllocationList.h"
118 #include "PDSCH-CodeBlockGroupTransmission.h"
119 #include "PDSCH-ServingCellConfig.h"
120 #include "DMRS-DownlinkConfig.h"
121 #include "PDSCH-Config.h"
122 #include "BWP-DownlinkDedicated.h"
123 #include "BWP-Downlink.h"
124 #include "PUSCH-TimeDomainResourceAllocation.h"
125 #include "PUSCH-TimeDomainResourceAllocationList.h"
126 #include "DMRS-UplinkConfig.h"
127 #include "PUSCH-Config.h"
128 #include "SRS-ResourceId.h"
129 #include "SRS-Resource.h"
130 #include "SRS-ResourceSet.h"
131 #include "SRS-Config.h"
132 #include "BWP-UplinkDedicated.h"
133 #include "PUSCH-ServingCellConfig.h"
134 #include "UplinkConfig.h"
135 #include "DUtoCURRCContainer.h"
136 #include "GBR-QoSFlowInformation.h"
137 #include "QoSFlowLevelQoSParameters.h"
138 #include "PUCCH-Config.h"
139 #include "PUCCH-ResourceSet.h"
140 #include "PUCCH-Resource.h"
141 #include "PUCCH-PowerControl.h"
142 #include "P0-PUCCH.h"
143 #include "PUCCH-PathlossReferenceRS.h"
144 #include "PUCCH-format0.h"
145 #include "PUCCH-format1.h"
146 #include "PUCCH-format2.h"
147 #include "PUCCH-format3.h"
148 #include "PUCCH-format4.h"
149 #include "PUCCH-FormatConfig.h"
150 #include "SchedulingRequestResourceConfig.h"
151 #include<ProtocolIE-Field.h>
152 #include "ProtocolExtensionField.h"
153 #include "odu_common_codec.h"
155 #include "du_cell_mgr.h"
156 #include "du_f1ap_msg_hdl.h"
157 #include "DRBs-Setup-Item.h"
158 #include "DLUPTNLInformation-ToBeSetup-List.h"
159 #include "DLUPTNLInformation-ToBeSetup-Item.h"
160 #include "UPTransportLayerInformation.h"
161 #include "GTPTunnel.h"
162 #include "SupportedSULFreqBandItem.h"
163 #include "du_e2ap_msg_hdl.h"
164 #include "du_f1ap_conversions.h"
165 #include "CNUEPagingIdentity.h"
166 #include "PCCH-Config.h"
167 #include "SCS-SpecificCarrier.h"
168 #include "FrequencyInfoDL.h"
169 #include "DownlinkConfigCommon.h"
170 #include "FrequencyInfoUL.h"
171 #include "UplinkConfigCommon.h"
172 #include "TDD-UL-DL-ConfigCommon.h"
173 #include "RACH-ConfigDedicated.h"
174 #include "CFRA-SSB-Resource.h"
175 #include "BWP-UplinkCommon.h"
176 #include "ReconfigurationWithSync.h"
177 #include "du_sys_info_hdl.h"
178 #include "DRX-ConfigRrc.h"
181 #include "CmInterface.h"
182 extern StartupConfig g_cfg;
185 DuCfgParams duCfgParam;
187 /******************************************************************
189 * @brief Function to fetch lcId based on DRB Id
193 * Function : fetchLcId
197 * Functionality: Function to fetch lcId based on DRB Id
199 * Returns: lcId - SUCCESS
201 *****************************************************************/
203 uint8_t fetchLcId(uint8_t drbId)
205 uint8_t cellIdx = 0, ueIdx = 0, lcIdx = 0, numLcs = 0, lcId = 0;
207 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
209 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
211 if(duCb.actvCellLst[cellIdx] != NULLP)
213 numLcs = duCb.actvCellLst[cellIdx]->ueCb[ueIdx].duRlcUeCfg.numLcs;
214 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
216 if(duCb.actvCellLst[cellIdx]->ueCb[ueIdx].duRlcUeCfg.rlcLcCfg[lcIdx].rlcBearerCfg.rbId == drbId && \
217 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].duRlcUeCfg.rlcLcCfg[lcIdx].rlcBearerCfg.rbType == RB_TYPE_DRB)
219 lcId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx].duRlcUeCfg.rlcLcCfg[lcIdx].rlcBearerCfg.lcId;
226 DU_LOG("\nERROR --> DU_APP: fetchLcId() failed for drbId %d", drbId);
230 /*******************************************************************
232 * @brief Adding F1AP pdu to reserved pdu list
236 * Function : addToReservedF1apPduList
238 * Functionality: Adding F1AP pdu to reserved pdu list.
239 * These pdu are awaiting aknowledgment from CU
241 * @params[in] uint8_t transId, F1AP_PDU_t *f1apMsg
243 * @return ROK - success
246 * ****************************************************************/
247 void addToReservedF1apPduList(uint8_t transId, F1AP_PDU_t *f1apPdu)
249 CmLList *node = NULLP;
250 ReservedF1apPduInfo *pduInfo = NULLP;
251 DU_ALLOC(pduInfo, sizeof(ReservedF1apPduInfo));
254 DU_ALLOC(node, sizeof(CmLList));
257 pduInfo->transId = transId;
258 pduInfo->f1apMsg = (void*) f1apPdu;
260 node->node = (PTR)pduInfo;
261 cmLListAdd2Tail(&duCb.reservedF1apPduList, node);
266 /*******************************************************************
268 * @brief searching for F1AP pdu from ReservedF1apPduList
272 * Function : searchFromReservedF1apPduList
274 * Functionality: searching for F1AP pdu information
276 * @params[in] uint8_t transId
278 * @return pointer to F1AP_PDU_t
280 * ****************************************************************/
282 CmLList *searchFromReservedF1apPduList(uint8_t transId)
285 ReservedF1apPduInfo *f1apPdu;
286 if(duCb.reservedF1apPduList.count)
288 CM_LLIST_FIRST_NODE(&duCb.reservedF1apPduList, node);
291 f1apPdu = (ReservedF1apPduInfo*)node->node;
292 if(f1apPdu->transId == transId)
302 /*******************************************************************
304 * @brief deleting F1AP pdu information from ReservedF1apPduList
308 * Function : deleteFromReservedF1apPduList
310 * Functionality: deleting pdu information from ReservedF1apPduList
312 * @params[in] CmLList *node
316 * ****************************************************************/
318 void deleteFromReservedF1apPduList(CmLList *node)
320 ReservedF1apPduInfo *f1apPdu;
324 f1apPdu = (ReservedF1apPduInfo *)node->node;
325 cmLListDelFrm(&duCb.reservedF1apPduList, node);
326 DU_FREE(f1apPdu, sizeof(ReservedF1apPduInfo));
327 DU_FREE(node, sizeof(CmLList));
332 /*******************************************************************
334 * @brief Builds Uplink Info for NR
338 * Function : BuildULNRInfo
340 * Functionality: Building NR Uplink Info
342 * @params[in] NRFreqInfo_t *ulnrfreq
343 * @return ROK - success
346 * ****************************************************************/
347 uint8_t BuildULNRInfo(NRFreqInfo_t *ulnrfreq)
350 ulnrfreq->nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.\
351 fdd.ulNrFreqInfo.nrArfcn;
352 ulnrfreq->freqBandListNr.list.count = 1;
353 ulnrfreq->freqBandListNr.list.size = sizeof(FreqBandNrItem_t *);
354 DU_ALLOC(ulnrfreq->freqBandListNr.list.array,ulnrfreq->freqBandListNr.list.size);
355 if(ulnrfreq->freqBandListNr.list.array == NULLP)
359 for(idx=0;idx<ulnrfreq->freqBandListNr.list.count;idx++)
361 DU_ALLOC(ulnrfreq->freqBandListNr.list.array[idx],sizeof(FreqBandNrItem_t));
362 if(ulnrfreq->freqBandListNr.list.array[idx] == NULLP)
367 ulnrfreq->freqBandListNr.list.array[0]->freqBandIndicatorNr = \
368 duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.\
369 freqBand[0].nrFreqBand;
370 ulnrfreq->freqBandListNr.list.array[0]->supportedSULBandList.list.count = SUL_BAND_COUNT;
373 /*******************************************************************
375 * @brief Builds Downlink NR Info
379 * Function : BuildDLNRInfo
381 * Functionality: Building Downlink NR Info
383 * @params[in] NRFreqInfo_t *dlnrfreq
384 * @return ROK - success
387 * ****************************************************************/
388 uint8_t BuildDLNRInfo(NRFreqInfo_t *dlnrfreq)
391 dlnrfreq->nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.\
392 fdd.dlNrFreqInfo.nrArfcn;
393 dlnrfreq->freqBandListNr.list.count = 1;
394 dlnrfreq->freqBandListNr.list.size = sizeof(FreqBandNrItem_t *);
395 DU_ALLOC(dlnrfreq->freqBandListNr.list.array,dlnrfreq->freqBandListNr.list.size);
396 if(dlnrfreq->freqBandListNr.list.array == NULLP)
400 for(idx=0;idx< dlnrfreq->freqBandListNr.list.count;idx++)
402 DU_ALLOC(dlnrfreq->freqBandListNr.list.array[idx],sizeof(FreqBandNrItem_t));
403 if(dlnrfreq->freqBandListNr.list.array[idx] == NULLP)
408 dlnrfreq->freqBandListNr.list.array[0]->freqBandIndicatorNr = \
409 duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.\
410 freqBand[0].nrFreqBand;
411 dlnrfreq->freqBandListNr.list.array[0]->supportedSULBandList.list.count = SUL_BAND_COUNT;
416 /*******************************************************************
418 * @brief Builds Nrcgi
422 * Function : BuildNrcgi
424 * Functionality: Building the PLMN ID and NR Cell id
426 * @params[in] NRCGI_t *nrcgi
427 * @return ROK - success
430 * ****************************************************************/
431 uint8_t BuildNrcgi(NRCGI_t *nrcgi)
434 uint8_t byteSize = 5;
435 /* Allocate Buffer Memory */
436 nrcgi->pLMN_Identity.size = PLMN_SIZE * sizeof(uint8_t);
437 DU_ALLOC(nrcgi->pLMN_Identity.buf, nrcgi->pLMN_Identity.size);
438 if(nrcgi->pLMN_Identity.buf == NULLP)
442 ret = buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
443 nrcgi->pLMN_Identity.buf); // Building PLMN function
449 nrcgi->nRCellIdentity.size = byteSize * sizeof(uint8_t);
450 DU_ALLOC(nrcgi->nRCellIdentity.buf, nrcgi->nRCellIdentity.size);
451 if(nrcgi->nRCellIdentity.buf == NULLP)
455 fillBitString(&nrcgi->nRCellIdentity, ODU_VALUE_FOUR, ODU_VALUE_FIVE, duCfgParam.sib1Params.cellIdentity);
459 /*******************************************************************
461 * @brief Builds FiveGStac
465 * Function : BuildFiveGSTac
467 * Functionality: Building the FiveGSTac
469 * @params[in] OCTET_STRING_t *fivegsTac
470 * @return ROK - success
473 * ****************************************************************/
474 uint8_t BuildFiveGSTac(Served_Cell_Information_t *servcell)
476 DU_ALLOC(servcell->fiveGS_TAC,sizeof(FiveGS_TAC_t));
477 if(servcell->fiveGS_TAC == NULLP)
481 servcell->fiveGS_TAC->size = 3 * sizeof(uint8_t);
482 DU_ALLOC(servcell->fiveGS_TAC->buf,\
483 sizeof(servcell->fiveGS_TAC->size));
484 if(servcell->fiveGS_TAC->buf == NULLP)
488 servcell->fiveGS_TAC->buf[0] = 0;
489 servcell->fiveGS_TAC->buf[1] = 0;
490 servcell->fiveGS_TAC->buf[2] = duCfgParam.srvdCellLst[0].duCellInfo.tac;
494 /*******************************************************************
496 * @brief fill nr frequency information
500 * Function : fillNrTddInfo
502 * Functionality: fill nr frequency information
504 * @params[in] NRFreqInfo_t freqInfo
505 * @return ROK - success
508 * ****************************************************************/
509 uint8_t fillNrTddInfo(TDD_Info_t *tddInfo)
511 uint8_t elementCnt = 1, freqBandListIdx = 0, supportedBandIdx = 0;
512 NRFreqInfo_t *freqInfo = NULLP;
516 DU_LOG("\nERROR --> DU APP : Null pointer received at fillNrTddInfo");
520 freqInfo = &tddInfo->nRFreqInfo;
521 freqInfo->nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn;
523 freqInfo->freqBandListNr.list.count = elementCnt;
524 freqInfo->freqBandListNr.list.size = freqInfo->freqBandListNr.list.count * sizeof(FreqBandNrItem_t *);
525 DU_ALLOC(freqInfo->freqBandListNr.list.array, freqInfo->freqBandListNr.list.size );
526 if(!freqInfo->freqBandListNr.list.array)
528 DU_LOG("\nERROR --> DU APP : Memory allocation failed at fillNrTddInfo");
532 for(freqBandListIdx = 0; freqBandListIdx<freqInfo->freqBandListNr.list.count; freqBandListIdx++)
534 DU_ALLOC(freqInfo->freqBandListNr.list.array[freqBandListIdx], sizeof(FreqBandNrItem_t ));
535 if(!freqInfo->freqBandListNr.list.array[freqBandListIdx])
537 DU_LOG("\nERROR --> DU APP : Memory allocation failed at fillNrTddInfo");
541 freqInfo->freqBandListNr.list.array[freqBandListIdx]->freqBandIndicatorNr = duCfgParam.srvdCellLst[0].duCellInfo.\
542 f1Mode.mode.tdd.nrFreqInfo.freqBand[0].nrFreqBand;
543 freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.count = elementCnt;
544 freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.size = freqInfo->freqBandListNr.list.array[freqBandListIdx]->\
545 supportedSULBandList.list.count * sizeof(SupportedSULFreqBandItem_t*);
547 DU_ALLOC(freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.array,\
548 freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.size);
549 if(!freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.array)
551 DU_LOG("\nERROR --> DU APP : Memory allocation failed at fillNrTddInfo");
555 for(supportedBandIdx = 0; supportedBandIdx<freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.count; supportedBandIdx++)
557 DU_ALLOC(freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.array[supportedBandIdx],\
558 sizeof(SupportedSULFreqBandItem_t));
559 if(!freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.array[supportedBandIdx])
561 DU_LOG("\nERROR --> DU APP : Memory allocation failed at fillNrTddInfo");
565 freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.array[supportedBandIdx]->freqBandIndicatorNr =\
566 duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[0].sulBand[0];
570 tddInfo->transmission_Bandwidth.nRSCS = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs;
571 tddInfo->transmission_Bandwidth.nRNRB = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrb;
576 /*******************************************************************
578 * @brief Builds NR Mode
582 * Function : BuildNrMode
584 * Functionality: Building the NR Mode
586 * @params[in] NR_Mode_Info_t *fdd
587 * @return ROK - success
590 * ****************************************************************/
591 uint8_t BuildNrMode(NR_Mode_Info_t *mode)
593 uint8_t BuildDLNRInforet=0;
594 uint8_t BuildULNRInforet=0;
597 mode->present = NR_Mode_Info_PR_tDD;
599 mode->present = NR_Mode_Info_PR_fDD;
602 if(mode->present == NR_Mode_Info_PR_fDD)
604 DU_ALLOC(mode->choice.fDD,sizeof(FDD_Info_t));
605 if(mode->choice.fDD == NULLP)
607 DU_LOG("\nERROR --> Memory allocation failed in BuildNrMode");
610 BuildULNRInforet = BuildULNRInfo(&mode->choice.fDD->uL_NRFreqInfo);
611 if(BuildULNRInforet != ROK)
613 DU_LOG("\nERROR --> Failed to build UlNrFreqInfo");
616 BuildDLNRInforet = BuildDLNRInfo(&mode->choice.fDD->dL_NRFreqInfo);
617 if(BuildDLNRInforet != ROK)
619 DU_LOG("\nERROR --> Failed to build DlNrFreqInfo");
622 mode->choice.fDD->uL_Transmission_Bandwidth.nRSCS = \
623 duCfgParam.srvdCellLst[0].duCellInfo.\
624 f1Mode.mode.fdd.ulTxBw.nrScs;
625 mode->choice.fDD->uL_Transmission_Bandwidth.nRNRB = \
626 duCfgParam.srvdCellLst[0].duCellInfo.\
627 f1Mode.mode.fdd.ulTxBw.nrb;
628 mode->choice.fDD->dL_Transmission_Bandwidth.nRSCS = \
629 duCfgParam.srvdCellLst[0].duCellInfo.\
630 f1Mode.mode.fdd.dlTxBw.nrScs;
631 mode->choice.fDD->dL_Transmission_Bandwidth.nRNRB = \
632 duCfgParam.srvdCellLst[0].duCellInfo.\
633 f1Mode.mode.fdd.dlTxBw.nrb;
635 else if(mode->present == NR_Mode_Info_PR_tDD)
637 DU_ALLOC(mode->choice.tDD,sizeof(TDD_Info_t));
638 if(mode->choice.tDD == NULLP)
640 DU_LOG("\nERROR --> Memory allocation failed in BuildNrMode");
644 if(fillNrTddInfo(mode->choice.tDD) != ROK)
646 DU_LOG("\nERROR --> Failed to fill Nr TDD information");
654 /*******************************************************************
656 * @brief Builds IE Extensions for Served PLMNs
660 * Function : BuildExtensions
662 * Functionality: Building the IE Extensions
664 * @params[in] struct ProtocolExtensionContainer_4624P3 *buildextend
665 * @return ROK - success
668 * ****************************************************************/
669 uint8_t BuildExtensions(ProtocolExtensionContainer_4624P3_t **ieExtend)
671 uint8_t idx=0, plmnidx=0, sliceLstIdx=0;
672 uint8_t elementCnt=0, extensionCnt=0;
674 extensionCnt=IE_EXTENSION_LIST_COUNT;
675 DU_ALLOC(*ieExtend,sizeof(ProtocolExtensionContainer_4624P3_t));
676 if((*ieExtend) == NULLP)
678 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
681 (*ieExtend)->list.count = extensionCnt;
682 (*ieExtend)->list.size = \
683 extensionCnt * sizeof(ServedPLMNs_ItemExtIEs_t *);
684 DU_ALLOC((*ieExtend)->list.array,(*ieExtend)->list.size);
685 if((*ieExtend)->list.array == NULLP)
687 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
690 for(plmnidx=0;plmnidx<extensionCnt;plmnidx++)
692 DU_ALLOC((*ieExtend)->list.array[plmnidx],\
693 sizeof(ServedPLMNs_ItemExtIEs_t));
694 if((*ieExtend)->list.array[plmnidx] == NULLP)
696 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
701 elementCnt = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].taiSliceSuppLst.numSupportedSlices;
703 (*ieExtend)->list.array[idx]->id = ProtocolIE_ID_id_TAISliceSupportList;
704 (*ieExtend)->list.array[idx]->criticality = Criticality_ignore;
705 (*ieExtend)->list.array[idx]->extensionValue.present = \
706 ServedPLMNs_ItemExtIEs__extensionValue_PR_SliceSupportList;
707 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
708 list.count = elementCnt;
709 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
710 list.size = (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
711 list.count * sizeof(SliceSupportItem_t *);
713 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
714 list.array, elementCnt * sizeof(SliceSupportItem_t *));
715 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
718 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
722 for(sliceLstIdx =0; sliceLstIdx<elementCnt; sliceLstIdx++)
724 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
725 list.array[sliceLstIdx],sizeof(SliceSupportItem_t));
726 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
727 list.array[sliceLstIdx] == NULLP)
729 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
732 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
733 list.array[sliceLstIdx]->sNSSAI.sST.size = sizeof(uint8_t);
734 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList\
735 .list.array[sliceLstIdx]->sNSSAI.sST.buf,(*ieExtend)->list.array[idx]->\
736 extensionValue.choice.SliceSupportList.\
737 list.array[sliceLstIdx]->sNSSAI.sST.size);
738 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList\
739 .list.array[sliceLstIdx]->sNSSAI.sST.buf == NULLP)
741 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
744 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
745 list.array[sliceLstIdx]->sNSSAI.sST.buf[0] = duCfgParam.srvdCellLst[0].duCellInfo.\
746 cellInfo.srvdPlmn[0].taiSliceSuppLst.snssai[sliceLstIdx]->sst;
748 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
749 list.array[sliceLstIdx]->sNSSAI.sD,sizeof(OCTET_STRING_t));
750 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
751 list.array[sliceLstIdx]->sNSSAI.sD == NULLP)
753 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
756 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
757 list.array[sliceLstIdx]->sNSSAI.sD->size = 3 * sizeof(uint8_t);
758 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
759 list.array[sliceLstIdx]->sNSSAI.sD->buf, (*ieExtend)->list.array[idx]->extensionValue.choice.\
760 SliceSupportList.list.array[sliceLstIdx]->sNSSAI.sD->size);
761 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
762 list.array[sliceLstIdx]->sNSSAI.sD->buf == NULLP)
764 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
767 memcpy((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
768 list.array[sliceLstIdx]->sNSSAI.sD->buf, duCfgParam.srvdCellLst[0].duCellInfo.\
769 cellInfo.srvdPlmn[0].taiSliceSuppLst.snssai[sliceLstIdx]->sd, (*ieExtend)->list.array[idx]->\
770 extensionValue.choice.SliceSupportList.list.array[sliceLstIdx]->sNSSAI.sD->size);
774 /*******************************************************************
776 * @brief Builds Served PLMN
780 * Function : BuildServedPlmn
782 * Functionality: Building the Served PLMN
784 * @params[in] GNB_DU_Served_Cells_Item_t *srvCellItem
785 * @return ROK - success
788 * ****************************************************************/
789 uint8_t BuildServedPlmn(ServedPLMNs_List_t *srvplmn)
792 uint8_t servPlmnCnt=1;
793 uint8_t buildPlmnIdret=0;
794 uint8_t BuildExtensionsret=0;
795 srvplmn->list.count = servPlmnCnt;
796 srvplmn->list.size = \
797 servPlmnCnt*sizeof(ServedPLMNs_Item_t *);
798 DU_ALLOC(srvplmn->list.array,srvplmn->list.size);
799 if(srvplmn->list.array == NULLP)
803 for(plmnidx=0; plmnidx<servPlmnCnt; plmnidx++)
805 DU_ALLOC(srvplmn->list.array[plmnidx],\
806 sizeof(ServedPLMNs_Item_t));
807 if(srvplmn->list.array[plmnidx] == NULLP)
812 srvplmn->list.array[0]->pLMN_Identity.size = PLMN_SIZE * sizeof(uint8_t);
813 DU_ALLOC(srvplmn->list.array[0]->pLMN_Identity.buf, srvplmn->list.array[0]->pLMN_Identity.size);
814 buildPlmnIdret = buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
815 srvplmn->list.array[0]->pLMN_Identity.buf);
816 if(buildPlmnIdret!= ROK)
820 BuildExtensionsret = BuildExtensions(&srvplmn->list.array[0]->iE_Extensions);
821 if(BuildExtensionsret!= ROK)
827 /*******************************************************************
829 * @brief Builds Served Cell List
833 * Function : BuildServedCellList
835 * Functionality: Building Served Cell List
837 * @params[in] PLMNID plmn
838 * @return ROK - success
841 * ****************************************************************/
843 uint8_t BuildServedCellList(GNB_DU_Served_Cells_List_t *duServedCell)
845 uint8_t BuildNrcgiret=0;
846 uint8_t BuildFiveGSTacret=0;
847 uint8_t BuildServedPlmnret=0;
848 uint8_t BuildNrModeret=0;
852 GNB_DU_Served_Cells_Item_t *srvCellItem;
853 duServedCell->list.size = plmnCnt * sizeof(GNB_DU_Served_Cells_ItemIEs_t *);
854 duServedCell->list.count = plmnCnt;
856 DU_ALLOC(duServedCell->list.array, duServedCell->list.size);
857 if(duServedCell->list.array == NULLP)
861 for(plmnidx=0; plmnidx<plmnCnt; plmnidx++)
863 DU_ALLOC(duServedCell->list.array[plmnidx],\
864 sizeof(GNB_DU_Served_Cells_ItemIEs_t));
865 if(duServedCell->list.array[plmnidx] == NULLP)
871 duServedCell->list.array[idx]->id = ProtocolIE_ID_id_GNB_DU_Served_Cells_Item;
872 duServedCell->list.array[idx]->criticality = Criticality_reject;
873 duServedCell->list.array[idx]->value.present = \
874 GNB_DU_Served_Cells_ItemIEs__value_PR_GNB_DU_Served_Cells_Item;
876 &duServedCell->list.array[idx]->value.choice.GNB_DU_Served_Cells_Item;
878 BuildNrcgiret = BuildNrcgi(&srvCellItem->served_Cell_Information.nRCGI);
879 if(BuildNrcgiret != ROK)
884 srvCellItem->served_Cell_Information.nRPCI = \
885 duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrPci;
888 BuildFiveGSTacret = BuildFiveGSTac(&srvCellItem->served_Cell_Information);
889 if(BuildFiveGSTacret != ROK)
894 BuildServedPlmnret = BuildServedPlmn(&srvCellItem->served_Cell_Information.servedPLMNs);
895 if(BuildServedPlmnret !=ROK)
899 /*nR Mode Info with FDD*/
900 BuildNrModeret = BuildNrMode(&srvCellItem->served_Cell_Information.nR_Mode_Info);
901 if(BuildNrModeret != ROK)
905 /*Measurement timing Config*/
906 srvCellItem->served_Cell_Information.measurementTimingConfiguration.\
907 size = sizeof(uint8_t);
908 DU_ALLOC(srvCellItem->served_Cell_Information.\
909 measurementTimingConfiguration.buf,srvCellItem->served_Cell_Information.measurementTimingConfiguration.size);
910 if(srvCellItem->served_Cell_Information.\
911 measurementTimingConfiguration.buf == NULLP)
915 srvCellItem->served_Cell_Information.measurementTimingConfiguration.buf[0] = \
916 duCfgParam.srvdCellLst[0].duCellInfo.measTimeCfg;
918 /* GNB DU System Information */
919 DU_ALLOC(srvCellItem->gNB_DU_System_Information,
920 sizeof(GNB_DU_System_Information_t));
921 if(!srvCellItem->gNB_DU_System_Information)
926 srvCellItem->gNB_DU_System_Information->mIB_message.size = duCfgParam.srvdCellLst[0].duSysInfo.mibLen;
927 DU_ALLOC(srvCellItem->gNB_DU_System_Information->mIB_message.buf,
928 srvCellItem->gNB_DU_System_Information->mIB_message.size);
929 if(!srvCellItem->gNB_DU_System_Information->mIB_message.buf)
933 memcpy(srvCellItem->gNB_DU_System_Information->mIB_message.buf, duCfgParam.srvdCellLst[0].duSysInfo.mibMsg, \
934 srvCellItem->gNB_DU_System_Information->mIB_message.size);
937 srvCellItem->gNB_DU_System_Information->sIB1_message.size =\
938 duCfgParam.srvdCellLst[0].duSysInfo.sib1Len;
940 DU_ALLOC(srvCellItem->gNB_DU_System_Information->sIB1_message.buf,
941 srvCellItem->gNB_DU_System_Information->sIB1_message.size);
942 if(!srvCellItem->gNB_DU_System_Information->sIB1_message.buf)
946 for(int x=0; x<srvCellItem->gNB_DU_System_Information->sIB1_message.size; x++)
948 srvCellItem->gNB_DU_System_Information->sIB1_message.buf[x]=\
949 duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg[x];
953 /*******************************************************************
955 * @brief Builds RRC Version
959 * Function : BuildRrcVer
961 * Functionality: Building RRC Version
963 * @params[in] int idx,int elementCnt,RRC_Version_t *rrcver
964 * @return ROK - success
967 * ****************************************************************/
968 uint8_t BuildRrcVer(RRC_Version_t *rrcVer)
972 rrcVer->latest_RRC_Version.size = sizeof(uint8_t);
973 DU_ALLOC(rrcVer->latest_RRC_Version.buf,sizeof(uint8_t));
974 if(rrcVer->latest_RRC_Version.buf == NULLP)
978 rrcVer->latest_RRC_Version.buf[0] = 0;
979 rrcVer->latest_RRC_Version.bits_unused = 5;
980 DU_ALLOC(rrcVer->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P81_t));
981 if(rrcVer->iE_Extensions == NULLP)
985 rrcVer->iE_Extensions->list.count = 1;
986 rrcVer->iE_Extensions->list.size = sizeof(RRC_Version_ExtIEs_t *);
987 DU_ALLOC(rrcVer->iE_Extensions->list.array,rrcVer->iE_Extensions->list.size);
988 if(rrcVer->iE_Extensions->list.array == NULLP)
993 DU_ALLOC(rrcVer->iE_Extensions->list.array[0],\
994 sizeof(RRC_Version_ExtIEs_t));
995 if(rrcVer->iE_Extensions->list.array[0] == NULLP)
999 rrcVer->iE_Extensions->list.array[rrcExt]->id = \
1000 ProtocolIE_ID_id_latest_RRC_Version_Enhanced;
1001 rrcVer->iE_Extensions->list.array[rrcExt]->criticality = Criticality_reject;
1002 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.present =\
1003 RRC_Version_ExtIEs__extensionValue_PR_Latest_RRC_Version_Enhanced;
1004 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice\
1005 .Latest_RRC_Version_Enhanced.size = 3*sizeof(uint8_t);
1006 DU_ALLOC(rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice\
1007 .Latest_RRC_Version_Enhanced.buf,rrcVer->iE_Extensions->list.\
1008 array[rrcExt]->extensionValue.choice.Latest_RRC_Version_Enhanced.size);
1009 if(rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice\
1010 .Latest_RRC_Version_Enhanced.buf == NULLP)
1015 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice.\
1016 Latest_RRC_Version_Enhanced.buf[rrcLatest] = 15;
1018 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice.\
1019 Latest_RRC_Version_Enhanced.buf[rrcLatest] = 5;
1021 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice.\
1022 Latest_RRC_Version_Enhanced.buf[rrcLatest] = 0;
1025 /*******************************************************************
1027 * @brief Sends F1 msg over SCTP
1031 * Function : sendF1APMsg
1033 * Functionality: Sends F1 msg over SCTP
1035 * @params[in] Region region
1037 * @return ROK - success
1040 * ****************************************************************/
1041 uint8_t sendF1APMsg()
1043 Buffer *mBuf = NULLP;
1045 if(ODU_GET_MSG_BUF(DU_APP_MEM_REGION, DU_POOL, &mBuf) == ROK)
1047 if(ODU_ADD_POST_MSG_MULT((Data *)encBuf, encBufSize, mBuf) == ROK)
1049 ODU_PRINT_MSG(mBuf, 0,0);
1051 if(sctpSend(mBuf, F1_INTERFACE) != ROK)
1053 DU_LOG("\nERROR --> F1AP : SCTP Send failed");
1054 ODU_PUT_MSG_BUF(mBuf);
1060 DU_LOG("\nERROR --> F1AP : ODU_ADD_POST_MSG_MULT failed");
1061 ODU_PUT_MSG_BUF(mBuf);
1064 ODU_PUT_MSG_BUF(mBuf);
1068 DU_LOG("\nERROR --> F1AP : Failed to allocate memory");
1074 /*******************************************************************
1076 * @brief deallocating the memory of function BuildAndSendF1SetupReq()
1080 * Function : FreeRrcVer
1082 * Functionality: deallocating the memory of function BuildRrcVer
1084 * @params[in] RRC_Version_t *rrcVer
1088 *****************************************************************/
1089 void FreeRrcVer(RRC_Version_t *rrcVer)
1091 if(rrcVer->latest_RRC_Version.buf != NULLP)
1093 if(rrcVer->iE_Extensions != NULLP)
1095 if(rrcVer->iE_Extensions->list.array != NULLP)
1097 if(rrcVer->iE_Extensions->list.array[0] != NULLP)
1099 if(rrcVer->iE_Extensions->list.array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf
1102 DU_FREE(rrcVer->iE_Extensions->list.array[0]->extensionValue.choice\
1103 .Latest_RRC_Version_Enhanced.buf,rrcVer->iE_Extensions->list.\
1104 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.size);
1106 DU_FREE(rrcVer->iE_Extensions->list.array[0],sizeof(RRC_Version_ExtIEs_t));
1108 DU_FREE(rrcVer->iE_Extensions->list.array,sizeof(RRC_Version_ExtIEs_t*));
1110 DU_FREE(rrcVer->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P81_t));
1112 DU_FREE(rrcVer->latest_RRC_Version.buf,rrcVer->latest_RRC_Version.size);
1116 /*******************************************************************
1118 * @brief Deallocating memory of TDD NrFreqInfo
1122 * Function : freeTddNrFreqInfo
1124 * Functionality: freeTddNrFreqInfo
1126 * @params[in] F1AP_PDU_t *f1apDuCfg
1128 * @return ROK - void
1130 * ****************************************************************/
1131 void freeTddNrFreqInfo(NRFreqInfo_t *freqInfo)
1133 uint8_t freqBandListIdx = 0, supportedBandIdx = 0;
1135 if(freqInfo->freqBandListNr.list.array)
1137 for(freqBandListIdx = 0; freqBandListIdx<freqInfo->freqBandListNr.list.count; freqBandListIdx++)
1139 if(freqInfo->freqBandListNr.list.array[freqBandListIdx])
1141 if(freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.array)
1143 for(supportedBandIdx = 0; supportedBandIdx<freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.count; supportedBandIdx++)
1145 DU_FREE(freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.array[supportedBandIdx],\
1146 sizeof(SupportedSULFreqBandItem_t));
1148 DU_FREE(freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.array,\
1149 freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.size);
1152 DU_FREE(freqInfo->freqBandListNr.list.array[freqBandListIdx], sizeof(FreqBandNrItem_t ));
1155 DU_FREE(freqInfo->freqBandListNr.list.array, freqInfo->freqBandListNr.list.size );
1159 /*******************************************************************
1161 * @brief Deallocating memory allocated for Nr fdd frequencey mode
1165 * Function : freeFddNrFreqInfo
1167 * Functionality:Free memory allocated for Nr fdd frequencey mode
1171 * @return ROK - void
1173 * ****************************************************************/
1174 void freeFddNrFreqInfo(FDD_Info_t *fDD)
1180 if(fDD->uL_NRFreqInfo.freqBandListNr.list.array != NULLP)
1182 DU_FREE(fDD->uL_NRFreqInfo.freqBandListNr.list.\
1183 array[arrIdx], sizeof(FreqBandNrItem_t));
1184 DU_FREE(fDD->uL_NRFreqInfo.freqBandListNr.list.array, \
1185 fDD->uL_NRFreqInfo.freqBandListNr.list.size);
1188 if(fDD->dL_NRFreqInfo.freqBandListNr.list.array != NULLP)
1190 DU_FREE(fDD->dL_NRFreqInfo.freqBandListNr.list.\
1191 array[arrIdx], sizeof(FreqBandNrItem_t));
1192 DU_FREE(fDD->dL_NRFreqInfo.freqBandListNr.list.array,\
1193 fDD->dL_NRFreqInfo.freqBandListNr.list.size);
1195 DU_FREE(fDD,sizeof(FDD_Info_t));
1199 /*******************************************************************
1201 * @brief deallocating the memory of function BuildAndSendF1SetupReq()
1205 * Function : FreeServedCellList
1207 * Functionality: deallocating the memory of function BuildServedCellList
1210 * @params[in] GNB_DU_Served_Cells_List_t *duServedCell
1214 * ****************************************************************/
1215 void FreeServedCellList( GNB_DU_Served_Cells_List_t *duServedCell)
1217 uint8_t plmnCnt=MAX_PLMN;
1218 uint8_t extensionCnt=IE_EXTENSION_LIST_COUNT;
1219 uint8_t plmnIdx=0, sliceIdx=0;
1220 GNB_DU_Served_Cells_Item_t *srvCellItem;
1221 ServedPLMNs_Item_t *servedPlmnItem;
1222 SliceSupportItem_t *sliceSupportItem;
1224 if(duServedCell->list.array!=NULLP)
1226 if(duServedCell->list.array[0]!=NULLP)
1228 srvCellItem= &duServedCell->list.array[0]->value.choice.GNB_DU_Served_Cells_Item;
1230 DU_FREE(srvCellItem->served_Cell_Information.nRCGI.pLMN_Identity.buf,\
1231 srvCellItem->served_Cell_Information.nRCGI.pLMN_Identity.size * sizeof(uint8_t));
1232 DU_FREE(srvCellItem->served_Cell_Information.nRCGI.nRCellIdentity.buf,\
1233 srvCellItem->served_Cell_Information.nRCGI.nRCellIdentity.size * sizeof(uint8_t));
1235 if(srvCellItem->served_Cell_Information.fiveGS_TAC!=NULLP)
1237 DU_FREE(srvCellItem->served_Cell_Information.fiveGS_TAC->buf,\
1238 sizeof(srvCellItem->served_Cell_Information.fiveGS_TAC->size));
1239 DU_FREE(srvCellItem->served_Cell_Information.fiveGS_TAC,sizeof(FiveGS_TAC_t));
1242 if(srvCellItem->served_Cell_Information.servedPLMNs.list.array!=NULLP)
1244 if(srvCellItem->served_Cell_Information.servedPLMNs.list.array[plmnIdx] != NULLP)
1246 servedPlmnItem = srvCellItem->served_Cell_Information.servedPLMNs.list.array[plmnIdx];
1247 DU_FREE(servedPlmnItem->pLMN_Identity.buf, servedPlmnItem->pLMN_Identity.size);
1249 if(servedPlmnItem->iE_Extensions != NULLP)
1251 if(servedPlmnItem->iE_Extensions->list.array != NULLP)
1253 if(servedPlmnItem->iE_Extensions->list.array[0] != NULLP)
1255 if(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.\
1256 SliceSupportList.list.array != NULLP)
1258 for(sliceIdx =0; sliceIdx<servedPlmnItem->iE_Extensions->list.array[0]->\
1259 extensionValue.choice.SliceSupportList.list.count; sliceIdx++)
1261 if(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.\
1262 SliceSupportList.list.array[sliceIdx] != NULLP)
1264 sliceSupportItem = servedPlmnItem->iE_Extensions->list.array[0]->\
1265 extensionValue.choice.SliceSupportList.list.array[sliceIdx];
1267 DU_FREE(sliceSupportItem->sNSSAI.sST.buf, sizeof(uint8_t));
1269 if(sliceSupportItem->sNSSAI.sD != NULLP)
1271 DU_FREE(sliceSupportItem->sNSSAI.sD->buf,\
1272 sliceSupportItem->sNSSAI.sD->size);
1273 DU_FREE(sliceSupportItem->sNSSAI.sD, sizeof(OCTET_STRING_t));
1276 DU_FREE(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.\
1277 choice.SliceSupportList.list.array[sliceIdx], sizeof(SliceSupportItem_t));
1280 DU_FREE(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.\
1281 SliceSupportList.list.array, servedPlmnItem->iE_Extensions->list.array[0]->\
1282 extensionValue.choice.SliceSupportList.list.size);
1284 DU_FREE(servedPlmnItem->iE_Extensions->list.array[0],\
1285 sizeof(ServedPLMNs_ItemExtIEs_t));
1287 DU_FREE(servedPlmnItem->iE_Extensions->list.array,\
1288 extensionCnt*sizeof(ServedPLMNs_ItemExtIEs_t*));
1290 DU_FREE(servedPlmnItem->iE_Extensions, sizeof(ProtocolExtensionContainer_4624P3_t));
1292 DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.array[plmnIdx],\
1293 sizeof(ServedPLMNs_Item_t));
1295 DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.array,\
1296 sizeof(ServedPLMNs_Item_t *));
1299 if(srvCellItem->served_Cell_Information.nR_Mode_Info.present == NR_Mode_Info_PR_fDD)
1301 freeFddNrFreqInfo(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD);
1305 if(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.tDD != NULLP)
1307 freeTddNrFreqInfo(&srvCellItem->served_Cell_Information.nR_Mode_Info.choice.tDD->nRFreqInfo);
1308 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.tDD, sizeof(TDD_Info_t));
1312 DU_FREE(srvCellItem->served_Cell_Information.measurementTimingConfiguration.buf,\
1313 srvCellItem->served_Cell_Information.measurementTimingConfiguration.size);
1315 if(srvCellItem->gNB_DU_System_Information != NULLP)
1317 if(srvCellItem->gNB_DU_System_Information->mIB_message.buf != NULLP)
1319 DU_FREE(srvCellItem->gNB_DU_System_Information->mIB_message.buf,\
1320 srvCellItem->gNB_DU_System_Information->mIB_message.size);
1323 if(srvCellItem->gNB_DU_System_Information->sIB1_message.buf != NULLP)
1325 DU_FREE(srvCellItem->gNB_DU_System_Information->sIB1_message.buf,\
1326 srvCellItem->gNB_DU_System_Information->sIB1_message.size);
1329 DU_FREE(srvCellItem->gNB_DU_System_Information, sizeof(GNB_DU_System_Information_t));
1332 DU_FREE(duServedCell->list.array[0], sizeof(GNB_DU_Served_Cells_ItemIEs_t));
1334 DU_FREE(duServedCell->list.array, plmnCnt * sizeof(GNB_DU_Served_Cells_ItemIEs_t*));
1338 /*******************************************************************
1340 * @brief deallocating the memory of function BuildAndSendF1SetupReq()
1344 * Function : FreeF1SetupReq
1346 * Functionality: deallocating the memory of function BuildAndSendF1SetupReq
1348 * @params[in] F1AP_PDU_t *f1apMsg
1352 * ****************************************************************/
1353 void FreeF1SetupReq(F1AP_PDU_t *f1apMsg)
1355 uint8_t ieIdx, ieIdx2;
1356 F1SetupRequest_t *f1SetupReq=NULLP;
1358 if(f1apMsg != NULLP)
1360 if(f1apMsg->choice.initiatingMessage != NULLP)
1362 f1SetupReq = &f1apMsg->choice.initiatingMessage->value.choice.F1SetupRequest;
1363 if(f1SetupReq->protocolIEs.list.array != NULLP)
1365 for(ieIdx = 0; ieIdx < f1SetupReq->protocolIEs.list.count; ieIdx++)
1367 if(f1SetupReq->protocolIEs.list.array[ieIdx] != NULLP)
1369 switch(f1SetupReq->protocolIEs.list.array[ieIdx]->id)
1371 case ProtocolIE_ID_id_TransactionID:
1373 case ProtocolIE_ID_id_gNB_DU_ID:
1374 DU_FREE(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
1375 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
1377 case ProtocolIE_ID_id_gNB_DU_Name:
1378 DU_FREE(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.buf,\
1379 strlen((char *)duCfgParam.duName));
1381 case ProtocolIE_ID_id_gNB_DU_Served_Cells_List:
1382 FreeServedCellList(&f1SetupReq->protocolIEs.list.\
1383 array[ieIdx]->value.choice.GNB_DU_Served_Cells_List);
1385 case ProtocolIE_ID_id_GNB_DU_RRC_Version:
1386 FreeRrcVer(&f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.RRC_Version);
1389 DU_LOG("\nERROR --> Invalid Event Type %ld", f1SetupReq->protocolIEs.list.array[ieIdx]->id);
1394 for(ieIdx2=0; ieIdx2< ieIdx; ieIdx2++)
1396 DU_FREE(f1SetupReq->protocolIEs.list.array[ieIdx2],sizeof(F1SetupRequestIEs_t));
1398 DU_FREE(f1SetupReq->protocolIEs.list.array,\
1399 f1SetupReq->protocolIEs.list.size);
1401 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
1403 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
1406 /*******************************************************************
1408 * @brief Builds and Send the F1SetupRequest
1412 * Function : BuildAndSendF1SetupReq
1414 * Functionality:Fills the F1SetupRequest
1416 * @return ROK - success
1419 ******************************************************************/
1420 uint8_t BuildAndSendF1SetupReq()
1422 uint8_t ret, ieIdx, elementCnt;
1423 F1AP_PDU_t *f1apMsg = NULLP;
1424 F1SetupRequest_t *f1SetupReq=NULLP;
1425 GNB_DU_Served_Cells_List_t *duServedCell=NULLP;
1426 RRC_Version_t *rrcVer=NULLP;
1427 asn_enc_rval_t encRetVal; /* Encoder return value */
1430 DU_LOG("\nINFO --> F1AP : Building F1 Setup Request\n");
1433 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
1434 if(f1apMsg == NULLP)
1438 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
1439 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
1440 if(f1apMsg->choice.initiatingMessage == NULLP)
1444 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_F1Setup;
1445 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
1446 f1apMsg->choice.initiatingMessage->value.present = \
1447 InitiatingMessage__value_PR_F1SetupRequest;
1449 f1SetupReq = &f1apMsg->choice.initiatingMessage->value.choice.F1SetupRequest;
1453 f1SetupReq->protocolIEs.list.count = elementCnt;
1454 f1SetupReq->protocolIEs.list.size = elementCnt * sizeof(F1SetupRequestIEs_t );
1456 /* Initialize the F1Setup members */
1457 DU_ALLOC(f1SetupReq->protocolIEs.list.array,f1SetupReq->protocolIEs.list.size);
1458 if(f1SetupReq->protocolIEs.list.array == NULLP)
1462 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
1464 DU_ALLOC(f1SetupReq->protocolIEs.list.array[ieIdx],\
1465 sizeof(F1SetupRequestIEs_t));
1466 if(f1SetupReq->protocolIEs.list.array[ieIdx] == NULLP)
1474 f1SetupReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_TransactionID;
1475 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1476 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present =\
1477 F1SetupRequestIEs__value_PR_TransactionID;
1478 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = \
1483 f1SetupReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_ID;
1484 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1485 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = \
1486 F1SetupRequestIEs__value_PR_GNB_DU_ID;
1487 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size =\
1490 DU_ALLOC(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
1491 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
1492 if(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf == \
1498 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf[0] =\
1501 /* DU name IE is of type printableString_t which wireshark is unable to decode.
1502 * However this string is decoded successfully on online decoders.
1503 * Since this is an optional IE and the value received in it are not
1504 * used as of now, eliminating this IE for now to avoid wireshark error.
1507 if(duCfgParam.duName != NULL)
1510 f1SetupReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_Name;
1511 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_ignore;
1512 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = F1SetupRequestIEs__value_PR_GNB_DU_Name;
1513 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.size = strlen((char *)duCfgParam.duName);
1514 DU_ALLOC(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.buf, \
1515 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.size);
1516 if(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.buf == NULLP)
1520 strcpy((char*)f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.buf,
1521 (char*)&duCfgParam.duName);
1525 /*Served Cell list */
1527 f1SetupReq->protocolIEs.list.array[ieIdx]->id = \
1528 ProtocolIE_ID_id_gNB_DU_Served_Cells_List;
1529 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1530 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = \
1531 F1SetupRequestIEs__value_PR_GNB_DU_Served_Cells_List;
1532 duServedCell = &f1SetupReq->protocolIEs.list.\
1533 array[ieIdx]->value.choice.GNB_DU_Served_Cells_List;
1534 if(BuildServedCellList(duServedCell))
1542 f1SetupReq->protocolIEs.list.array[ieIdx]->id = \
1543 ProtocolIE_ID_id_GNB_DU_RRC_Version ;
1544 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1545 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = \
1546 F1SetupRequestIEs__value_PR_RRC_Version;
1547 rrcVer = &f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.RRC_Version;
1548 if(BuildRrcVer(rrcVer))
1553 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
1555 /* Encode the F1SetupRequest type as APER */
1556 memset(encBuf, 0, ENC_BUF_MAX_LEN);
1558 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
1561 /* Encode results */
1562 if(encRetVal.encoded == ENCODE_FAIL)
1564 DU_LOG("\nERROR --> F1AP : Could not encode F1SetupRequest structure (at %s)\n",\
1565 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
1570 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for F1SetupRequest\n");
1571 #ifdef DEBUG_ASN_PRINT
1572 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
1574 printf("%x",encBuf[ieIdx]);
1578 duCb.f1SetupReqAndRspMsg.f1MsgReqBufSize = encBufSize;
1579 DU_ALLOC(duCb.f1SetupReqAndRspMsg.f1MsgReqBuf, encBufSize);
1580 if(duCb.f1SetupReqAndRspMsg.f1MsgReqBuf == NULLP)
1582 DU_LOG("\nERROR --> F1AP : Memory allocation failed to store the encoding of f1setup req");
1585 memcpy(duCb.f1SetupReqAndRspMsg.f1MsgReqBuf, &encBuf, duCb.f1SetupReqAndRspMsg.f1MsgReqBufSize);
1589 if(sendF1APMsg() != ROK)
1591 DU_LOG("\nERROR --> F1AP : Sending F1 Setup request failed");
1599 FreeF1SetupReq(f1apMsg);
1602 }/* End of BuildAndSendF1SetupReq */
1604 /*******************************************************************
1606 * @brief Deallocating memory allocated for Served_Cells_To_Modify_Item_t
1610 * Function : freeCellsToModifyItem
1612 * Functionality: Deallocating memory of variables allocated in
1613 * BuildAndSendDUConfigUpdate function
1615 * @params[in] Served_Cells_To_Modify_Item_t *modifyItem
1617 * @return ROK - void
1619 * ****************************************************************/
1621 void freeCellsToModifyItem(Served_Cells_To_Modify_Item_t *modifyItem)
1623 uint8_t arrIdx=0, servedPlmnIdx=0, sliceLstIdx=0;
1624 ServedPLMNs_Item_t *servedPlmnItem = NULLP;
1625 SliceSupportItem_t *sliceSupportItem = NULLP;
1627 DU_FREE(modifyItem->oldNRCGI.pLMN_Identity.buf, modifyItem->oldNRCGI.pLMN_Identity.size);
1628 DU_FREE(modifyItem->oldNRCGI.nRCellIdentity.buf, modifyItem->oldNRCGI.nRCellIdentity.size);
1630 DU_FREE(modifyItem->served_Cell_Information.nRCGI.pLMN_Identity.buf,\
1631 modifyItem->served_Cell_Information.nRCGI.pLMN_Identity.size);
1632 DU_FREE(modifyItem->served_Cell_Information.nRCGI.nRCellIdentity.buf,\
1633 modifyItem->served_Cell_Information.nRCGI.nRCellIdentity.size);
1635 if(modifyItem->served_Cell_Information.servedPLMNs.list.array != NULLP)
1637 if(modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx] != NULLP)
1639 servedPlmnItem = modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx];
1641 DU_FREE(servedPlmnItem->pLMN_Identity.buf,servedPlmnItem->pLMN_Identity.size);
1643 if(servedPlmnItem->iE_Extensions != NULLP)
1645 if(servedPlmnItem->iE_Extensions->list.array != NULLP)
1647 if(servedPlmnItem->iE_Extensions->list.array[arrIdx] != NULLP)
1649 if(servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.SliceSupportList.\
1650 list.array != NULLP)
1652 for(sliceLstIdx =0; sliceLstIdx<servedPlmnItem->iE_Extensions->list.array[arrIdx]->\
1653 extensionValue.choice.SliceSupportList.list.count; sliceLstIdx++)
1655 if(servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.SliceSupportList.\
1656 list.array[sliceLstIdx] != NULLP)
1659 sliceSupportItem = servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.\
1660 SliceSupportList.list.array[sliceLstIdx];
1662 DU_FREE(sliceSupportItem->sNSSAI.sST.buf, sliceSupportItem->sNSSAI.sST.size);
1663 if(sliceSupportItem->sNSSAI.sD != NULLP)
1665 DU_FREE(sliceSupportItem->sNSSAI.sD->buf, sliceSupportItem->sNSSAI.sD->size);
1666 DU_FREE(sliceSupportItem->sNSSAI.sD,sizeof(OCTET_STRING_t));
1668 DU_FREE(servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.\
1669 SliceSupportList.list.array[sliceLstIdx], sizeof(SliceSupportItem_t));
1672 DU_FREE(servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.\
1673 choice.SliceSupportList.list.array,\
1674 servedPlmnItem->iE_Extensions->list.array[arrIdx]->\
1675 extensionValue.choice.SliceSupportList.list.size);
1678 for(servedPlmnIdx=0; servedPlmnIdx< servedPlmnItem->iE_Extensions->list.count ; servedPlmnIdx++)
1680 DU_FREE(servedPlmnItem->iE_Extensions->list.array[servedPlmnIdx], sizeof(ServedPLMNs_ItemExtIEs_t ));
1682 DU_FREE(servedPlmnItem->iE_Extensions->list.array, servedPlmnItem->iE_Extensions->list.size);
1684 DU_FREE(servedPlmnItem->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P3_t));
1687 for(servedPlmnIdx=0; servedPlmnIdx<modifyItem->served_Cell_Information.servedPLMNs.list.count; servedPlmnIdx++)
1689 DU_FREE(modifyItem->served_Cell_Information.servedPLMNs.list.array[servedPlmnIdx], sizeof(ServedPLMNs_Item_t));
1691 DU_FREE(modifyItem->served_Cell_Information.servedPLMNs.list.array,\
1692 modifyItem->served_Cell_Information.servedPLMNs.list.size);
1695 if(modifyItem->served_Cell_Information.nR_Mode_Info.present == NR_Mode_Info_PR_fDD)
1697 freeFddNrFreqInfo(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD);
1701 if(modifyItem->served_Cell_Information.nR_Mode_Info.choice.tDD)
1703 freeTddNrFreqInfo(&modifyItem->served_Cell_Information.nR_Mode_Info.choice.tDD->nRFreqInfo);
1704 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.tDD, sizeof(TDD_Info_t));
1707 DU_FREE(modifyItem->served_Cell_Information.measurementTimingConfiguration.buf,\
1708 modifyItem->served_Cell_Information.measurementTimingConfiguration.size);
1711 /*******************************************************************
1713 * @brief Deallocating memory of BuildAndSendDUConfigUpdate
1717 * Function : FreeDUConfigUpdate
1719 * Functionality: Deallocating memory of variables allocated in
1720 * BuildAndSendDUConfigUpdate function
1722 * @params[in] F1AP_PDU_t *f1apDuCfg
1724 * @return ROK - void
1726 * ****************************************************************/
1727 void FreeDUConfigUpdate(F1AP_PDU_t *f1apDuCfg)
1729 uint8_t ieIdx=0, cellModifyIdx=0, cellDeleteIdx=0;
1730 GNBDUConfigurationUpdate_t *duCfgUpdate = NULLP;
1731 Served_Cells_To_Modify_List_t *cellsToModify=NULLP;
1732 Served_Cells_To_Delete_List_t *cellsToDelete=NULLP;
1733 Served_Cells_To_Delete_Item_t *deleteItem = NULLP;
1734 Served_Cells_To_Delete_ItemIEs_t *deleteItemIe = NULLP;
1736 if(f1apDuCfg != NULLP)
1738 if(f1apDuCfg->choice.initiatingMessage != NULLP)
1740 duCfgUpdate = &f1apDuCfg->choice.initiatingMessage->\
1741 value.choice.GNBDUConfigurationUpdate;
1742 if(duCfgUpdate->protocolIEs.list.array != NULLP)
1744 for(ieIdx=0; ieIdx<duCfgUpdate->protocolIEs.list.count; ieIdx++)
1746 if(duCfgUpdate->protocolIEs.list.array[ieIdx] != NULLP)
1748 switch(duCfgUpdate->protocolIEs.list.array[ieIdx]->id)
1750 case ProtocolIE_ID_id_Served_Cells_To_Modify_List:
1752 cellsToModify = &duCfgUpdate->protocolIEs.list.array[ieIdx]->\
1753 value.choice.Served_Cells_To_Modify_List;
1754 if(cellsToModify->list.array != NULLP)
1756 for(cellModifyIdx=0; cellModifyIdx<cellsToModify->list.count ;cellModifyIdx++)
1758 if(cellsToModify->list.array[cellModifyIdx] != NULLP)
1760 freeCellsToModifyItem(&cellsToModify->list.array[cellModifyIdx]->value.choice.\
1761 Served_Cells_To_Modify_Item);
1762 DU_FREE(cellsToModify->list.array[cellModifyIdx],\
1763 sizeof(Served_Cells_To_Modify_ItemIEs_t));
1766 DU_FREE(cellsToModify->list.array,cellsToModify->list.size);
1770 case ProtocolIE_ID_id_Served_Cells_To_Delete_List:
1772 cellsToDelete = &duCfgUpdate->protocolIEs.list.array[ieIdx]->\
1773 value.choice.Served_Cells_To_Delete_List;
1774 if(cellsToDelete->list.array != NULLP)
1776 for(cellDeleteIdx=0; cellDeleteIdx<cellsToDelete->list.count ;cellDeleteIdx++)
1778 if(cellsToDelete->list.array[cellDeleteIdx] != NULLP)
1780 deleteItemIe = ((Served_Cells_To_Delete_ItemIEs_t*)\
1781 cellsToDelete->list.array[cellDeleteIdx]);
1782 deleteItem=&deleteItemIe->value.choice.Served_Cells_To_Delete_Item;
1783 DU_FREE(deleteItem->oldNRCGI.pLMN_Identity.buf,\
1784 deleteItem->oldNRCGI.pLMN_Identity.size);
1785 DU_FREE(deleteItem->oldNRCGI.nRCellIdentity.buf,\
1786 deleteItem->oldNRCGI.nRCellIdentity.size);
1787 DU_FREE(cellsToDelete->list.array[cellDeleteIdx],\
1788 sizeof(Served_Cells_To_Delete_ItemIEs_t));
1791 DU_FREE(cellsToDelete->list.array,cellsToDelete->list.size);
1796 case ProtocolIE_ID_id_gNB_DU_ID:
1798 DU_FREE(duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
1799 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
1803 DU_FREE(duCfgUpdate->protocolIEs.list.array[ieIdx],\
1804 sizeof(GNBDUConfigurationUpdateIEs_t));
1807 DU_FREE(duCfgUpdate->protocolIEs.list.array,duCfgUpdate->protocolIEs.list.size);
1809 DU_FREE(f1apDuCfg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
1811 DU_FREE(f1apDuCfg, (Size)sizeof(F1AP_PDU_t));
1815 /*******************************************************************
1817 * @brief Fills Served Plmns required in ServCellInfo IE
1821 * Function : fillServedPlmns
1823 * Functionality: Fills Served Plmns required in ServCellInfo IE
1825 * @params[in] Pointer to ServedPLMNs_List_t *
1827 * @return ROK - success
1830 *****************************************************************/
1832 uint8_t fillServedPlmns(ServedPLMNs_List_t *servedPlmn)
1834 uint8_t ieIdx=0, arrayIdx=0, ieListCnt=0, elementCnt=0, sliceLstIdx=0;
1836 servedPlmn->list.array[arrayIdx]->pLMN_Identity.size = 3*sizeof(uint8_t);
1837 DU_ALLOC(servedPlmn->list.array[arrayIdx]->pLMN_Identity.buf, servedPlmn->list.\
1838 array[arrayIdx]->pLMN_Identity.size);
1839 if(servedPlmn->list.array[arrayIdx]->pLMN_Identity.buf == NULLP)
1841 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
1844 buildPlmnId(duCfgParam.srvdCellLst[arrayIdx].duCellInfo.cellInfo.srvdPlmn[arrayIdx].plmn,\
1845 servedPlmn->list.array[arrayIdx]->pLMN_Identity.buf);
1846 DU_ALLOC(servedPlmn->list.array[arrayIdx]->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P3_t));
1847 if(servedPlmn->list.array[arrayIdx]->iE_Extensions == NULLP)
1849 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
1854 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.count = ieListCnt;
1855 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.size = ieListCnt *sizeof(ServedPLMNs_ItemExtIEs_t *);
1856 DU_ALLOC(servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array,servedPlmn->list.array[arrayIdx]->\
1857 iE_Extensions->list.size);
1858 if(servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array == NULLP)
1860 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
1863 for(ieIdx=arrayIdx;ieIdx<ieListCnt;ieIdx++)
1865 DU_ALLOC(servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx],\
1866 sizeof(ServedPLMNs_ItemExtIEs_t));
1867 if(servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx] == NULLP)
1869 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
1875 elementCnt = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].taiSliceSuppLst.numSupportedSlices;
1876 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx]->id =ProtocolIE_ID_id_TAISliceSupportList;
1877 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx]->criticality = Criticality_ignore;
1878 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx]->extensionValue.present = \
1879 ServedPLMNs_ItemExtIEs__extensionValue_PR_SliceSupportList;
1880 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1881 list.count = elementCnt;
1882 servedPlmn->list.array[arrayIdx]->\
1883 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1884 list.size = elementCnt * sizeof(SliceSupportItem_t *);
1885 DU_ALLOC(servedPlmn->list.array[arrayIdx]->\
1886 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1887 list.array,servedPlmn->list.array[arrayIdx]->\
1888 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.list.size);
1889 if(servedPlmn->list.array[arrayIdx]->\
1890 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1891 list.array == NULLP)
1893 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
1897 for(sliceLstIdx =0; sliceLstIdx< elementCnt; sliceLstIdx++)
1899 DU_ALLOC(servedPlmn->list.array[arrayIdx]->\
1900 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1901 list.array[sliceLstIdx],sizeof( SliceSupportItem_t));
1902 if(servedPlmn->list.array[arrayIdx]->\
1903 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1904 list.array[sliceLstIdx] == NULLP)
1906 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
1910 servedPlmn->list.array[arrayIdx]->\
1911 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1912 list.array[sliceLstIdx]->sNSSAI.sST.size = sizeof(uint8_t);
1913 DU_ALLOC(servedPlmn->list.array[arrayIdx]->\
1914 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1915 list.array[sliceLstIdx]->sNSSAI.sST.buf,servedPlmn->list.array[arrayIdx]->\
1916 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.list.array[sliceLstIdx]->\
1919 if(servedPlmn->list.array[arrayIdx]->\
1920 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1921 list.array[sliceLstIdx]->sNSSAI.sST.buf == NULLP)
1923 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
1926 servedPlmn->list.array[arrayIdx]->\
1927 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1928 list.array[sliceLstIdx]->sNSSAI.sST.buf[arrayIdx] = duCfgParam.srvdCellLst[arrayIdx].duCellInfo.\
1929 cellInfo.srvdPlmn[arrayIdx].taiSliceSuppLst.snssai[sliceLstIdx]->sst;
1931 DU_ALLOC(servedPlmn->list.array[arrayIdx]->\
1932 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1933 list.array[sliceLstIdx]->sNSSAI.sD,sizeof(OCTET_STRING_t));
1934 if(servedPlmn->list.array[arrayIdx]->\
1935 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1936 list.array[sliceLstIdx]->sNSSAI.sD == NULLP)
1938 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
1941 servedPlmn->list.array[arrayIdx]->\
1942 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1943 list.array[sliceLstIdx]->sNSSAI.sD->size = 3 * sizeof(uint8_t);
1944 DU_ALLOC(servedPlmn->list.array[arrayIdx]->\
1945 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1946 list.array[sliceLstIdx]->sNSSAI.sD->buf,servedPlmn->list.array[arrayIdx]->\
1947 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1948 list.array[sliceLstIdx]->sNSSAI.sD->size);
1949 if(servedPlmn->list.array[arrayIdx]->\
1950 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1951 list.array[sliceLstIdx]->sNSSAI.sD->buf == NULLP)
1953 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
1956 memcpy(servedPlmn->list.array[arrayIdx]->\
1957 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1958 list.array[sliceLstIdx]->sNSSAI.sD->buf, duCfgParam.srvdCellLst[arrayIdx].duCellInfo.\
1959 cellInfo.srvdPlmn[arrayIdx].taiSliceSuppLst.snssai[sliceLstIdx]->sd,\
1960 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1961 list.array[sliceLstIdx]->sNSSAI.sD->size);
1966 /*******************************************************************
1968 * @brief Fills Nr Fdd Info required in ServCellInfo IE
1972 * Function : fillNrFddInfo
1974 * Functionality: Fills Nr Fdd Info required in ServCellInfo IE
1976 * @params[in] FDD_Info_t *fDD
1978 * @return ROK - success
1981 *****************************************************************/
1983 uint8_t fillNrFddInfo(FDD_Info_t *fDD)
1985 fDD->uL_NRFreqInfo.nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.\
1986 f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn;
1987 fDD->uL_NRFreqInfo.freqBandListNr.list.count = 1;
1988 fDD->uL_NRFreqInfo.freqBandListNr.list.size = sizeof(FreqBandNrItem_t*);
1989 DU_ALLOC(fDD->uL_NRFreqInfo.freqBandListNr.list.\
1990 array, fDD->uL_NRFreqInfo.freqBandListNr.list.size);
1991 if(fDD->uL_NRFreqInfo.freqBandListNr.list.array == NULLP)
1993 DU_LOG("\nERROR --> Memory allocation failed in fillNrFddInfo");
1997 DU_ALLOC(fDD->uL_NRFreqInfo.freqBandListNr.list.array[0], \
1998 sizeof(FreqBandNrItem_t));
1999 if(fDD->uL_NRFreqInfo.freqBandListNr.list.array[0] == NULLP)
2001 DU_LOG("\nERROR --> Memory allocation failed in fillNrFddInfo");
2005 fDD->uL_NRFreqInfo.freqBandListNr.list.array[0]->freqBandIndicatorNr = \
2006 duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.\
2007 freqBand[0].nrFreqBand;
2008 fDD->uL_NRFreqInfo.freqBandListNr.list.array[0]->supportedSULBandList.list.count=0;
2009 fDD->dL_NRFreqInfo.nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.\
2010 dlNrFreqInfo.nrArfcn;
2011 fDD->dL_NRFreqInfo.freqBandListNr.list.count = 1;
2012 fDD->dL_NRFreqInfo.freqBandListNr.list.size = sizeof(FreqBandNrItem_t *);
2013 DU_ALLOC(fDD->dL_NRFreqInfo.freqBandListNr.list.array, fDD->dL_NRFreqInfo.freqBandListNr.list.size);
2014 if(fDD->dL_NRFreqInfo.freqBandListNr.list.array == NULLP)
2016 DU_LOG("\nERROR --> Memory allocation failed in fillNrFddInfo");
2020 DU_ALLOC(fDD->dL_NRFreqInfo.freqBandListNr.list.array[0], sizeof(FreqBandNrItem_t));
2021 if(fDD->dL_NRFreqInfo.freqBandListNr.list.array[0] == NULLP)
2023 DU_LOG("\nERROR --> Memory allocation failed in fillNrFddInfo");
2027 fDD->dL_NRFreqInfo.freqBandListNr.list.array[0]->freqBandIndicatorNr = \
2028 duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.\
2029 freqBand[0].nrFreqBand;
2030 fDD->dL_NRFreqInfo.freqBandListNr.list.array[0]->supportedSULBandList.list.count=0;
2032 /*Transmission Bandwidth*/
2033 fDD->uL_Transmission_Bandwidth.nRSCS = duCfgParam.srvdCellLst[0].duCellInfo.\
2034 f1Mode.mode.fdd.ulTxBw.nrScs;
2035 fDD->uL_Transmission_Bandwidth.nRNRB = duCfgParam.srvdCellLst[0].duCellInfo.\
2036 f1Mode.mode.fdd.ulTxBw.nrb;
2037 fDD->dL_Transmission_Bandwidth.nRSCS = duCfgParam.srvdCellLst[0].duCellInfo.\
2038 f1Mode.mode.fdd.dlTxBw.nrScs;
2039 fDD->dL_Transmission_Bandwidth.nRNRB = duCfgParam.srvdCellLst[0].duCellInfo.\
2040 f1Mode.mode.fdd.dlTxBw.nrb;
2045 /*******************************************************************
2047 * @brief Fills ServCellInfo IE
2051 * Function : fillServedCellInfo
2053 * Functionality: Fills ServCellInfo
2055 * @params[in] Pointer to Served_Cell_Information_t *
2057 * @return ROK - success
2060 *****************************************************************/
2062 uint8_t fillServedCellInfo(Served_Cell_Information_t *srvCellInfo)
2064 uint8_t ieIdx, ieListCnt;
2067 srvCellInfo->nRCGI.pLMN_Identity.size =3*sizeof(uint8_t);
2068 DU_ALLOC(srvCellInfo->nRCGI.pLMN_Identity.buf,\
2069 srvCellInfo->nRCGI.pLMN_Identity.size);
2070 if(srvCellInfo->nRCGI.pLMN_Identity.buf == NULLP)
2072 DU_LOG("\nERROR --> Memory allocation failed in fillServedCellInfo");
2075 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
2076 srvCellInfo->nRCGI.pLMN_Identity.buf);
2077 srvCellInfo->nRCGI.nRCellIdentity.size =5*sizeof(uint8_t);
2078 DU_ALLOC(srvCellInfo->nRCGI.nRCellIdentity.buf,\
2079 srvCellInfo->nRCGI.nRCellIdentity.size);
2080 if(srvCellInfo->nRCGI.nRCellIdentity.buf == NULLP)
2082 DU_LOG("\nERROR --> Memory allocation failed in fillServedCellInfo");
2086 fillBitString(&srvCellInfo->nRCGI.nRCellIdentity, ODU_VALUE_FOUR, ODU_VALUE_FIVE, duCfgParam.sib1Params.cellIdentity);
2088 srvCellInfo->nRPCI = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrPci;
2092 srvCellInfo->servedPLMNs.list.count = ieListCnt;
2093 srvCellInfo->servedPLMNs.list.size = ieListCnt*sizeof(ServedPLMNs_Item_t *);
2094 DU_ALLOC(srvCellInfo->servedPLMNs.list.array, srvCellInfo->servedPLMNs.list.size);
2095 if(srvCellInfo->servedPLMNs.list.array == NULLP)
2097 DU_LOG("\nERROR --> Memory allocation failed in fillServedCellInfo");
2100 for(ieIdx=0; ieIdx < ieListCnt; ieIdx++)
2102 DU_ALLOC(srvCellInfo->servedPLMNs.list.array[ieIdx], sizeof(ServedPLMNs_Item_t));
2103 if(srvCellInfo->servedPLMNs.list.array[ieIdx]== NULLP)
2105 DU_LOG("\nERROR --> Memory allocation failed in fillServedCellInfo");
2109 if(fillServedPlmns(&srvCellInfo->servedPLMNs))
2111 DU_LOG("\nERROR --> Failed to fill Served Plmn info");
2116 /*nR Mode Info with FDD*/
2117 srvCellInfo->nR_Mode_Info.present = NR_Mode_Info_PR_fDD;
2118 DU_ALLOC(srvCellInfo->nR_Mode_Info.choice.fDD, sizeof(FDD_Info_t));
2119 if(srvCellInfo->nR_Mode_Info.choice.fDD == NULLP)
2121 DU_LOG("\nERROR --> Memory allocation failed in fillServedCellInfo");
2124 if(fillNrFddInfo(srvCellInfo->nR_Mode_Info.choice.fDD))
2126 DU_LOG("\nERROR --> Failed to fill the Nr FDD information");
2130 srvCellInfo->nR_Mode_Info.present = NR_Mode_Info_PR_tDD;
2131 DU_ALLOC(srvCellInfo->nR_Mode_Info.choice.tDD, sizeof(TDD_Info_t));
2132 if(srvCellInfo->nR_Mode_Info.choice.tDD == NULLP)
2134 DU_LOG("\nERROR --> Memory allocation failed in fillServedCellInfo");
2137 if(fillNrTddInfo(srvCellInfo->nR_Mode_Info.choice.tDD) != ROK)
2139 DU_LOG("\nERROR --> Failed to fill the Nr TDD information");
2144 /*Measurement timing Config*/
2145 srvCellInfo->measurementTimingConfiguration.size = sizeof(uint8_t);
2146 DU_ALLOC(srvCellInfo->measurementTimingConfiguration.\
2147 buf,srvCellInfo->measurementTimingConfiguration.size);
2148 if(srvCellInfo->measurementTimingConfiguration.buf == NULLP)
2152 srvCellInfo->measurementTimingConfiguration.\
2153 buf[0] = duCfgParam.srvdCellLst[0].duCellInfo.measTimeCfg;
2158 /*******************************************************************
2160 * @brief Fills ServCellToModItem IE
2164 * Function : fillServCellToModItem
2166 * Functionality: Fills ServCellToModItem IE
2168 * @params[in] Pointer to Served_Cells_To_Modify_Item_t *
2170 * @return ROK - success
2173 *****************************************************************/
2175 uint8_t fillServCellToModItem(Served_Cells_To_Modify_Item_t *modifyItem)
2178 modifyItem->oldNRCGI.pLMN_Identity.size = 3*sizeof(uint8_t);
2179 DU_ALLOC(modifyItem->oldNRCGI.pLMN_Identity.buf,modifyItem->oldNRCGI.pLMN_Identity.size);
2180 if(modifyItem->oldNRCGI.pLMN_Identity.buf == NULLP)
2184 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
2185 modifyItem->oldNRCGI.pLMN_Identity.buf);
2188 modifyItem->oldNRCGI.nRCellIdentity.size = 5*sizeof(uint8_t);
2189 DU_ALLOC(modifyItem->oldNRCGI.nRCellIdentity.buf,\
2190 modifyItem->oldNRCGI.nRCellIdentity.size);
2191 if(modifyItem->oldNRCGI.nRCellIdentity.buf == NULLP)
2195 fillBitString(&modifyItem->oldNRCGI.nRCellIdentity, ODU_VALUE_FOUR, ODU_VALUE_FIVE, duCfgParam.sib1Params.cellIdentity);
2197 if(fillServedCellInfo(&modifyItem->served_Cell_Information))
2203 /*******************************************************************
2205 * @brief Builds ServCellToModList
2209 * Function : buildServCellToModList
2211 * Functionality: Builds the serv cell to Mod List
2213 * @params[in] Pointer to Served_Cells_To_Modify_List_t *
2215 * @return ROK - success
2218 *****************************************************************/
2220 uint8_t buildServCellToModList(Served_Cells_To_Modify_List_t *cellsToModify)
2222 uint8_t ieListCnt, ieIdx;
2223 Served_Cells_To_Modify_Item_t *modifyItem = NULLP;
2226 cellsToModify->list.count = ieListCnt;
2227 cellsToModify->list.size = ieListCnt*sizeof(Served_Cells_To_Modify_ItemIEs_t *);
2228 DU_ALLOC(cellsToModify->list.array,cellsToModify->list.size);
2229 if(cellsToModify->list.array == NULLP)
2233 for(ieIdx=0; ieIdx< ieListCnt; ieIdx++)
2235 DU_ALLOC(cellsToModify->list.array[ieIdx],sizeof(Served_Cells_To_Modify_ItemIEs_t));
2236 if(cellsToModify->list.array[ieIdx] == NULLP)
2241 cellsToModify->list.array[0]->id = ProtocolIE_ID_id_Served_Cells_To_Modify_Item;
2242 cellsToModify->list.array[0]->criticality = Criticality_reject;
2243 cellsToModify->list.array[0]->value.present =\
2244 Served_Cells_To_Modify_ItemIEs__value_PR_Served_Cells_To_Modify_Item;
2245 modifyItem=&cellsToModify->list.array[0]->value.choice.Served_Cells_To_Modify_Item;
2247 if(fillServCellToModItem(modifyItem))
2252 /*******************************************************************
2254 * @brief filling the DeleteItemList
2258 * Function : fillCellToDeleteItem
2260 * Functionality: Filling the DeleteItemIe
2262 * @params[in] Pointer to Served_Cells_To_Delete_ItemIEs_t
2264 * @return ROK - success
2267 *****************************************************************/
2268 uint8_t fillCellToDeleteItem(struct Served_Cells_To_Delete_ItemIEs *deleteItemIe)
2270 Served_Cells_To_Delete_Item_t *deleteItem=NULLP;
2272 deleteItemIe->id = ProtocolIE_ID_id_Served_Cells_To_Delete_Item;
2273 deleteItemIe->criticality = Criticality_reject;
2274 deleteItemIe->value.present =\
2275 Served_Cells_To_Delete_ItemIEs__value_PR_Served_Cells_To_Delete_Item;
2276 deleteItem=&deleteItemIe->value.choice.Served_Cells_To_Delete_Item;
2279 deleteItem->oldNRCGI.pLMN_Identity.size = 3*sizeof(uint8_t);
2280 DU_ALLOC(deleteItem->oldNRCGI.pLMN_Identity.buf,deleteItem->oldNRCGI.pLMN_Identity.size);
2281 if(deleteItem->oldNRCGI.pLMN_Identity.buf == NULLP)
2283 DU_LOG("ERROR --> F1AP: fillCellToDeleteItem(): Failed to allocate the memory");
2286 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
2287 deleteItem->oldNRCGI.pLMN_Identity.buf);
2290 deleteItem->oldNRCGI.nRCellIdentity.size = 5*sizeof(uint8_t);
2291 DU_ALLOC(deleteItem->oldNRCGI.nRCellIdentity.buf,\
2292 deleteItem->oldNRCGI.nRCellIdentity.size);
2293 if(deleteItem->oldNRCGI.nRCellIdentity.buf == NULLP)
2295 DU_LOG("ERROR --> F1AP: fillCellToDeleteItem(): Failed to allocate the memory");
2298 fillBitString(&deleteItem->oldNRCGI.nRCellIdentity, ODU_VALUE_FOUR, ODU_VALUE_FIVE, duCfgParam.sib1Params.cellIdentity);
2301 /*******************************************************************
2303 * @brief Builds ServCellToDeleteList
2307 * Function : buildServCellToDeleteList
2309 * Functionality: Builds the serv cell to delete List
2311 * @params[in] Pointer to Served_Cells_To_Delete_List_t *
2313 * @return ROK - success
2316 *****************************************************************/
2318 uint8_t buildServCellToDeleteList(Served_Cells_To_Delete_List_t *cellsToDelete)
2320 uint8_t ieListCnt, arrIdx;
2323 cellsToDelete->list.count = ieListCnt;
2324 cellsToDelete->list.size = ieListCnt*sizeof(Served_Cells_To_Delete_ItemIEs_t *);
2326 DU_ALLOC(cellsToDelete->list.array,cellsToDelete->list.size);
2327 if(cellsToDelete->list.array == NULLP)
2329 DU_LOG("\nERROR --> F1AP : buildServCellToDeleteList(): Memory allocation failed");
2333 for(arrIdx=0; arrIdx< ieListCnt; arrIdx++)
2335 DU_ALLOC(cellsToDelete->list.array[arrIdx],sizeof(Served_Cells_To_Delete_ItemIEs_t));
2336 if(cellsToDelete->list.array[arrIdx] == NULLP)
2338 DU_LOG("\nERROR --> F1AP : buildServCellToDeleteList(): Memory allocation failed");
2344 if(fillCellToDeleteItem((Served_Cells_To_Delete_ItemIEs_t*)cellsToDelete->list.array[arrIdx]) !=ROK)
2346 DU_LOG("\nERROR --> F1AP: buildServCellToDeleteList(): failed to fill Served_Cells_To_Delete_ItemIEs");
2352 /*******************************************************************
2354 * @brief Builds and sends the DUConfigUpdate
2358 * Function : BuildAndSendDUConfigUpdate
2360 * Functionality: Constructs the DU Update message and sends
2361 * it to the CU through SCTP.
2363 * @params[in] void **buf,Buffer to which encoded pattern is written into
2364 * @params[in] int *size,size of buffer
2366 * @return ROK - success
2369 * ****************************************************************/
2370 uint8_t BuildAndSendDUConfigUpdate(ServCellAction servCellAction)
2372 uint8_t ret =0, ieIdx=0, elementCnt=0;
2373 bool memAlloctionFailure = false;
2374 F1AP_PDU_t *f1apDuCfg = NULLP;
2375 GNBDUConfigurationUpdate_t *duCfgUpdate = NULLP;
2376 asn_enc_rval_t encRetVal; /* Encoder return value */
2378 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
2383 DU_LOG("\nINFO --> F1AP : Building DU config update\n");
2384 /* Allocate the memory for F1DuCfg */
2385 DU_ALLOC(f1apDuCfg, sizeof(F1AP_PDU_t));
2386 if(f1apDuCfg == NULLP)
2388 DU_LOG("\nERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation for F1AP-PDU failed");
2392 f1apDuCfg->present = F1AP_PDU_PR_initiatingMessage;
2393 DU_ALLOC(f1apDuCfg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
2394 if(f1apDuCfg->choice.initiatingMessage == NULLP)
2396 DU_LOG("\nERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation for F1AP-PDU failed");
2400 f1apDuCfg->choice.initiatingMessage->procedureCode = \
2401 ProcedureCode_id_gNBDUConfigurationUpdate;
2402 f1apDuCfg->choice.initiatingMessage->criticality = Criticality_reject;
2403 f1apDuCfg->choice.initiatingMessage->value.present = \
2404 InitiatingMessage__value_PR_GNBDUConfigurationUpdate;
2405 duCfgUpdate = &f1apDuCfg->choice.initiatingMessage->value.\
2406 choice.GNBDUConfigurationUpdate;
2408 duCfgUpdate->protocolIEs.list.count = elementCnt;
2409 duCfgUpdate->protocolIEs.list.size = \
2410 elementCnt * sizeof(GNBDUConfigurationUpdateIEs_t*);
2412 /* Initialize the F1Setup members */
2413 DU_ALLOC(duCfgUpdate->protocolIEs.list.array,duCfgUpdate->protocolIEs.list.size);
2414 if(duCfgUpdate->protocolIEs.list.array == NULLP)
2416 DU_LOG("ERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation failed");
2419 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
2421 DU_ALLOC(duCfgUpdate->protocolIEs.list.array[ieIdx],sizeof(GNBDUConfigurationUpdateIEs_t));
2422 if(duCfgUpdate->protocolIEs.list.array[ieIdx] == NULLP)
2424 DU_LOG("ERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation failed");
2425 memAlloctionFailure = true;
2430 if(memAlloctionFailure == true)
2436 duCfgUpdate->protocolIEs.list.array[ieIdx]->id=ProtocolIE_ID_id_TransactionID;
2437 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
2438 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2439 GNBDUConfigurationUpdateIEs__value_PR_TransactionID;
2440 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = TRANS_ID;
2443 if(servCellAction == SERV_CELL_TO_MODIFY)
2445 /*Served Cell to Modify */
2446 duCfgUpdate->protocolIEs.list.array[ieIdx]->id = \
2447 ProtocolIE_ID_id_Served_Cells_To_Modify_List;
2448 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality =Criticality_reject;
2449 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2450 GNBDUConfigurationUpdateIEs__value_PR_Served_Cells_To_Modify_List;
2451 if(buildServCellToModList(&duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.\
2452 Served_Cells_To_Modify_List))
2454 DU_LOG("ERROR --> DU APP : BuildAndSendDUConfigUpdate(): failed to build ServCellToModList");
2460 /*Served Cell to Delete */
2461 duCfgUpdate->protocolIEs.list.array[ieIdx]->id = \
2462 ProtocolIE_ID_id_Served_Cells_To_Delete_List;
2463 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality =Criticality_reject;
2464 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2465 GNBDUConfigurationUpdateIEs__value_PR_Served_Cells_To_Delete_List;
2466 if(buildServCellToDeleteList(&duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.\
2467 Served_Cells_To_Delete_List)!=ROK)
2469 DU_LOG("ERROR --> DU APP : BuildAndSendDUConfigUpdate(): failed to build ServCellToDeleteList");
2474 // NOTE :GNB DU SYS INFO:MIB AND SIB1 INFORMATION TO BE BUILT AND FILLED HERE
2477 duCfgUpdate->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_ID;
2478 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
2479 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2480 GNBDUConfigurationUpdateIEs__value_PR_GNB_DU_ID;
2481 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size = sizeof(uint8_t);
2482 DU_ALLOC(duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
2483 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
2484 if(duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf == NULLP)
2486 DU_LOG("ERROR --> DU APP : BuildAndSendDUConfigUpdate(): Memory allocation failed for GNB_DU_ID");
2489 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf[0] = duCfgParam.duId;
2491 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apDuCfg);
2493 /* Encode the DU Config Update type as APER */
2494 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
2496 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apDuCfg, PrepFinalEncBuf, encBuf);
2498 /* Checking encode results */
2499 if(encRetVal.encoded == ENCODE_FAIL)
2501 DU_LOG("ERROR --> F1AP : Could not encode DUConfigUpdate structure (at %s)\n",\
2502 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
2507 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for DUConfigUpdate\n");
2508 #ifdef DEBUG_ASN_PRINT
2509 for(ieIdx =0; ieIdx < encBufSize; ieIdx++)
2511 printf("%x",encBuf[ieIdx]);
2516 if(sendF1APMsg() != ROK)
2518 DU_LOG("\nERROR --> F1AP : Sending GNB-DU Config Update failed");
2526 addToReservedF1apPduList(TRANS_ID,f1apDuCfg);
2531 /*******************************************************************
2533 * @brief free the ULRRCMessageTransfer
2537 * Function : FreeULRRCMessageTransfer
2539 * Functionality: Deallocating the memory of variable allocated in
2540 * FreeULRRCMessageTransfer
2544 * @return ROK - void
2546 ******************************************************************/
2547 void FreeULRRCMessageTransfer( F1AP_PDU_t *f1apMsg)
2550 ULRRCMessageTransfer_t *ulRRCMsg;
2552 if(f1apMsg != NULLP)
2554 if(f1apMsg->choice.initiatingMessage != NULLP)
2556 ulRRCMsg = &f1apMsg->choice.initiatingMessage->value.choice.ULRRCMessageTransfer;
2557 if(ulRRCMsg->protocolIEs.list.array != NULLP)
2559 for(idx1=0;idx1<ulRRCMsg->protocolIEs.list.count;idx1++)
2561 if(ulRRCMsg->protocolIEs.list.array[idx1] != NULLP)
2563 if(ulRRCMsg->protocolIEs.list.array[idx1]->value.present ==
2564 ULRRCMessageTransferIEs__value_PR_RRCContainer)
2566 DU_FREE(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf,
2567 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size);
2569 DU_FREE(ulRRCMsg->protocolIEs.list.array[idx1],sizeof(ULRRCMessageTransferIEs_t));
2572 DU_FREE(ulRRCMsg->protocolIEs.list.array,ulRRCMsg->protocolIEs.list.size );
2574 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
2576 DU_FREE(f1apMsg,sizeof(F1AP_PDU_t));
2579 /*******************************************************************
2581 * @brief Builds and sends the ULRRCMessageTransfer
2585 * Function : BuildAndSendULRRCMessageTransfer
2587 * Functionality: Constructs the UL RRC Message Transfer and sends
2588 * it to the CU through SCTP.
2592 * @return ROK - success
2595 * ****************************************************************/
2596 uint8_t BuildAndSendULRRCMessageTransfer(DuUeCb *ueCb, uint8_t lcId, \
2597 uint16_t msgLen, uint8_t *rrcMsg)
2599 uint8_t elementCnt=0, idx1=0, idx=0;
2600 uint8_t ret = RFAILED;
2601 F1AP_PDU_t *f1apMsg = NULLP;
2602 ULRRCMessageTransfer_t *ulRRCMsg = NULLP;
2603 asn_enc_rval_t encRetVal; /* Encoder return value */
2605 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
2609 DU_LOG("\n INFO --> F1AP : Building UL RRC Message Transfer Message\n");
2611 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
2612 if(f1apMsg == NULLP)
2614 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
2617 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
2618 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
2619 if(f1apMsg->choice.initiatingMessage == NULLP)
2621 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
2624 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_ULRRCMessageTransfer;
2625 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
2626 f1apMsg->choice.initiatingMessage->value.present = \
2627 InitiatingMessage__value_PR_ULRRCMessageTransfer;
2629 &f1apMsg->choice.initiatingMessage->value.choice.ULRRCMessageTransfer;
2631 ulRRCMsg->protocolIEs.list.count = elementCnt;
2632 ulRRCMsg->protocolIEs.list.size = \
2633 elementCnt * sizeof(ULRRCMessageTransferIEs_t *);
2635 /* Initialize the F1Setup members */
2636 DU_ALLOC(ulRRCMsg->protocolIEs.list.array, ulRRCMsg->protocolIEs.list.size);
2637 if(ulRRCMsg->protocolIEs.list.array == NULLP)
2639 DU_LOG(" ERROR --> F1AP : Memory allocation for UL RRC MessageTransferIEs failed");
2642 for(idx=0; idx<elementCnt; idx++)
2644 DU_ALLOC(ulRRCMsg->protocolIEs.list.array[idx],sizeof(ULRRCMessageTransferIEs_t));
2645 if(ulRRCMsg->protocolIEs.list.array[idx] == NULLP)
2653 /*GNB CU UE F1AP ID*/
2654 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
2655 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2656 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2657 ULRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID;
2658 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.GNB_CU_UE_F1AP_ID = ueCb->gnbCuUeF1apId;
2660 /*GNB DU UE F1AP ID*/
2662 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
2663 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2664 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2665 ULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
2666 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.GNB_DU_UE_F1AP_ID = ueCb->gnbDuUeF1apId;
2670 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_SRBID;
2671 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2672 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2673 ULRRCMessageTransferIEs__value_PR_SRBID;
2674 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.SRBID = lcId;
2678 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_RRCContainer;
2679 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2680 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2681 ULRRCMessageTransferIEs__value_PR_RRCContainer;
2682 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size = msgLen;
2683 DU_ALLOC(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf,
2684 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size)
2685 if(!ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf)
2687 DU_LOG(" ERROR --> F1AP : Memory allocation for BuildAndSendULRRCMessageTransfer failed");
2690 memset(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf, 0, msgLen);
2691 memcpy(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf, \
2692 rrcMsg, ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size);
2694 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
2696 /* Encode the F1SetupRequest type as APER */
2697 memset(encBuf, 0, ENC_BUF_MAX_LEN);
2699 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
2701 /* Encode results */
2702 if(encRetVal.encoded == ENCODE_FAIL)
2704 DU_LOG( "\nERROR --> F1AP : Could not encode ULRRCMessageTransfer structure (at %s)\n",\
2705 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
2710 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for ULRRCMessageTransfer\n");
2711 #ifdef DEBUG_ASN_PRINT
2712 for(int i=0; i< encBufSize; i++)
2714 printf("%x",encBuf[i]);
2720 if(sendF1APMsg() != ROK)
2722 DU_LOG("\nERROR --> F1AP : Sending UL RRC Message Transfer Failed");
2728 FreeULRRCMessageTransfer(f1apMsg);
2731 }/* End of BuildAndSendULRRCMessageTransfer*/
2733 /*******************************************************************
2735 * @brief Builds tag config
2739 * Function : BuildTagConfig
2741 * Functionality: Builds tag config in MacCellGroupConfig
2743 * @params[in] TAG_Config *tag_Config
2745 * @return ROK - success
2748 * ****************************************************************/
2749 uint8_t BuildTagConfig(DuUeCb *ueCb, struct TAG_Config *tagConfig)
2751 struct TAG_Config__tag_ToAddModList *tagList;
2752 uint8_t idx, elementCnt;
2754 tagConfig->tag_ToReleaseList = NULLP;
2755 tagConfig->tag_ToAddModList = NULLP;
2756 DU_ALLOC(tagConfig->tag_ToAddModList, sizeof(struct TAG_Config__tag_ToAddModList));
2757 if(!tagConfig->tag_ToAddModList)
2759 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildTagConfig");
2764 elementCnt = ODU_VALUE_ONE;
2766 elementCnt = ueCb->duMacUeCfg.macCellGrpCfg.tagCfg.addModListCount;
2768 tagList = tagConfig->tag_ToAddModList;
2769 tagList->list.count = elementCnt;
2770 tagList->list.size = elementCnt * sizeof(struct TAG *);
2772 tagList->list.array = NULLP;
2773 DU_ALLOC(tagList->list.array, tagList->list.size);
2774 if(!tagList->list.array)
2776 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildTagConfig");
2780 for(idx=0; idx<tagList->list.count; idx++)
2782 tagList->list.array[idx] = NULLP;
2783 DU_ALLOC(tagList->list.array[idx], sizeof(struct TAG));
2784 if(!tagList->list.array[idx])
2786 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildTagConfig");
2794 tagList->list.array[idx]->tag_Id = TAG_ID;
2795 tagList->list.array[idx]->timeAlignmentTimer = TIME_ALIGNMENT_TMR;
2799 for(idx=0; idx<tagList->list.count; idx++)
2801 tagList->list.array[idx]->tag_Id = ueCb->duMacUeCfg.macCellGrpCfg.tagCfg.addModList[idx].tagId;
2802 tagList->list.array[idx]->timeAlignmentTimer = ueCb->duMacUeCfg.macCellGrpCfg.tagCfg.addModList[idx].timeAlignTimer;
2809 /*******************************************************************
2811 * @brief Builds PHR Config
2815 * Function : BuildPhrConfig
2817 * Functionality: Builds phrConfig in MacCellGroupConfig
2819 * @params[in] PHR Config *
2821 * @return ROK - success
2824 * ****************************************************************/
2825 uint8_t BuildPhrConfig(DuUeCb *ueCb, struct MAC_CellGroupConfig__phr_Config *phrConfig)
2828 phrConfig->present = MAC_CellGroupConfig__phr_Config_PR_setup;
2829 phrConfig->choice.setup = NULLP;
2830 DU_ALLOC(phrConfig->choice.setup, sizeof(struct PHR_Config));
2831 if(!phrConfig->choice.setup)
2833 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildPhrConfig");
2839 phrConfig->choice.setup->phr_PeriodicTimer = PHR_PERIODIC_TMR;
2840 phrConfig->choice.setup->phr_ProhibitTimer = PHR_PROHIBHIT_TMR;
2841 phrConfig->choice.setup->phr_Tx_PowerFactorChange = PHR_PWR_FACTOR_CHANGE;
2842 phrConfig->choice.setup->multiplePHR = false;
2843 phrConfig->choice.setup->dummy = false;
2844 phrConfig->choice.setup->phr_Type2OtherCell = false;
2845 phrConfig->choice.setup->phr_ModeOtherCG = PHR_MODE_OTHER_CG;
2849 phrConfig->choice.setup->phr_PeriodicTimer = ueCb->duMacUeCfg.macCellGrpCfg.phrCfg.periodicTimer;
2850 phrConfig->choice.setup->phr_ProhibitTimer = ueCb->duMacUeCfg.macCellGrpCfg.phrCfg.prohibitTimer;
2851 phrConfig->choice.setup->phr_Tx_PowerFactorChange = ueCb->duMacUeCfg.macCellGrpCfg.phrCfg.txPowerFactor;
2852 phrConfig->choice.setup->multiplePHR = ueCb->duMacUeCfg.macCellGrpCfg.phrCfg.multiplePHR;
2853 phrConfig->choice.setup->dummy = ueCb->duMacUeCfg.macCellGrpCfg.phrCfg.dummy;
2854 phrConfig->choice.setup->phr_Type2OtherCell = ueCb->duMacUeCfg.macCellGrpCfg.phrCfg.phrType2OtherCell;
2855 phrConfig->choice.setup->phr_ModeOtherCG = ueCb->duMacUeCfg.macCellGrpCfg.phrCfg.phrOtherCG;
2861 /*******************************************************************
2863 * @brief Builds BSR Config
2867 * Function : BuildBsrConfig
2869 * Functionality: Builds BuildBsrConfig in MacCellGroupConfig
2871 * @params[in] BSR_Config *bsrConfig
2873 * @return ROK - success
2876 * ****************************************************************/
2877 uint8_t BuildBsrConfig(DuUeCb *ueCb, struct BSR_Config *bsrConfig)
2881 bsrConfig->periodicBSR_Timer = PERIODIC_BSR_TMR;
2882 bsrConfig->retxBSR_Timer = RETX_BSR_TMR;
2883 bsrConfig->logicalChannelSR_DelayTimer = NULLP;
2887 bsrConfig->periodicBSR_Timer = convertBsrPeriodicTmrValueToEnum(ueCb->duMacUeCfg.macCellGrpCfg.bsrTmrCfg.periodicTimer);
2888 bsrConfig->retxBSR_Timer = convertBsrRetxTmrValueToEnum(ueCb->duMacUeCfg.macCellGrpCfg.bsrTmrCfg.retxTimer);
2890 bsrConfig->logicalChannelSR_DelayTimer = NULLP;
2891 DU_ALLOC(bsrConfig->logicalChannelSR_DelayTimer, sizeof(long));
2892 if(bsrConfig->logicalChannelSR_DelayTimer == NULLP)
2894 DU_LOG("\nERROR --> DU APP: Memory allocation failed in BuildBsrConfig");
2897 *(bsrConfig->logicalChannelSR_DelayTimer) = convertLcSrDelayTmrValueToEnum(ueCb->duMacUeCfg.macCellGrpCfg.bsrTmrCfg.srDelayTimer);
2903 /*******************************************************************
2905 * @brief Builds scheduling request config
2909 * Function : BuildSchedulingReqConfig
2911 * Functionality: Builds BuildSchedulingReqConfig in MacCellGroupConfig
2913 * @params[in] SchedulingRequestConfig *schedulingRequestConfig
2915 * @return ROK - success
2918 * ****************************************************************/
2919 uint8_t BuildSchedulingReqConfig(DuUeCb *ueCb, struct SchedulingRequestConfig *schedulingRequestConfig)
2921 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList;
2922 uint8_t idx, elementCnt;
2924 schedulingRequestConfig->schedulingRequestToAddModList = NULLP;
2925 DU_ALLOC(schedulingRequestConfig->schedulingRequestToAddModList,
2926 sizeof(struct SchedulingRequestConfig__schedulingRequestToAddModList));
2927 if(!schedulingRequestConfig->schedulingRequestToAddModList)
2929 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
2934 elementCnt = ODU_VALUE_ONE;
2936 elementCnt = ueCb->duMacUeCfg.macCellGrpCfg.schReqCfg.addModListCount;
2938 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
2939 schReqList->list.count = elementCnt;
2940 schReqList->list.size = elementCnt * sizeof(struct SchedulingRequestToAddMod *);
2942 schReqList->list.array = NULLP;
2943 DU_ALLOC(schReqList->list.array, schReqList->list.size);
2944 if(!schReqList->list.array)
2946 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
2950 for(idx=0; idx<schReqList->list.count; idx++)
2952 schReqList->list.array[idx] = NULLP;
2953 DU_ALLOC(schReqList->list.array[idx], sizeof(struct SchedulingRequestToAddMod));
2954 if(!schReqList->list.array[idx])
2956 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
2964 schReqList->list.array[idx]->schedulingRequestId = SCH_REQ_ID;
2966 schReqList->list.array[idx]->sr_ProhibitTimer = NULLP;
2967 DU_ALLOC(schReqList->list.array[idx]->sr_ProhibitTimer, sizeof(long));
2968 if(!schReqList->list.array[idx]->sr_ProhibitTimer)
2970 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
2973 *(schReqList->list.array[idx]->sr_ProhibitTimer) = SR_PROHIBIT_TMR;
2974 schReqList->list.array[idx]->sr_TransMax = SR_TRANS_MAX;
2978 for(idx=0; idx<schReqList->list.count; idx++)
2980 schReqList->list.array[idx]->schedulingRequestId = ueCb->duMacUeCfg.macCellGrpCfg.schReqCfg.addModList[idx].schedReqId;
2982 schReqList->list.array[idx]->sr_ProhibitTimer = NULLP;
2983 DU_ALLOC(schReqList->list.array[idx]->sr_ProhibitTimer, sizeof(long));
2984 if(!schReqList->list.array[idx]->sr_ProhibitTimer)
2986 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
2989 *(schReqList->list.array[idx]->sr_ProhibitTimer) = ueCb->duMacUeCfg.macCellGrpCfg.schReqCfg.addModList[idx].srProhibitTmr;
2990 schReqList->list.array[idx]->sr_TransMax = ueCb->duMacUeCfg.macCellGrpCfg.schReqCfg.addModList[idx].srTransMax;
2994 schedulingRequestConfig->schedulingRequestToReleaseList = NULLP;
2999 /*******************************************************************
3001 * @brief Builds RLC Configuration for AM mode
3005 * Function : BuildRlcConfigAm
3008 * Builds AM mode RLC Config in BuildRlcBearerToAddModList
3010 * @params[in] AmBearerCfg *amCfg
3011 * RLC_Config_t *rlcConfig
3013 * @return ROK - success
3016 * ****************************************************************/
3017 uint8_t BuildRlcConfigAm(AmBearerCfg *amCfg, struct RLC_Config *rlcConfig)
3019 rlcConfig->choice.am = NULLP;
3020 DU_ALLOC(rlcConfig->choice.am, sizeof(struct RLC_Config__am));
3021 if(!rlcConfig->choice.am)
3023 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfigAm");
3027 /* Fill AM UL configuration */
3028 rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength = NULLP;
3029 DU_ALLOC(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
3030 if(!rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength)
3032 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfigAm");
3036 /* Fill default AM UL configuration if input pointer to DU database is NULL */
3039 *(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength) = SN_FIELD_LEN;
3040 rlcConfig->choice.am->ul_AM_RLC.t_PollRetransmit = T_POLL_RETRANSMIT;
3041 rlcConfig->choice.am->ul_AM_RLC.pollPDU = POLL_PDU;
3042 rlcConfig->choice.am->ul_AM_RLC.pollByte = POLL_BYTE;
3043 rlcConfig->choice.am->ul_AM_RLC.maxRetxThreshold = MAX_RETX_THRESHOLD;
3047 *(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength) = covertAmSnLenFromIntEnumToRrcEnum(amCfg->dlAmCfg.snLenDl);
3048 rlcConfig->choice.am->ul_AM_RLC.t_PollRetransmit = covertPollRetxTmrValueToEnum(amCfg->dlAmCfg.pollRetxTmr);
3049 rlcConfig->choice.am->ul_AM_RLC.pollPDU = covertPollPduValueToEnum(amCfg->dlAmCfg.pollPdu);
3050 rlcConfig->choice.am->ul_AM_RLC.pollByte = covertPollByteValueToEnum(amCfg->dlAmCfg.pollByte);
3051 rlcConfig->choice.am->ul_AM_RLC.maxRetxThreshold = covertMaxRetxValueToEnum(amCfg->dlAmCfg.maxRetxTh);
3054 /* Fill AM DL configuraion */
3055 rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength = NULLP;
3056 DU_ALLOC(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
3057 if(!rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength)
3059 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfigAm");
3063 /* Fill default AM DL configuration if input pointer to DU database is NULL */
3066 *(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength) = SN_FIELD_LEN;
3067 rlcConfig->choice.am->dl_AM_RLC.t_Reassembly = T_REASSEMBLY;
3068 rlcConfig->choice.am->dl_AM_RLC.t_StatusProhibit = T_STATUS_PROHIBHIT;
3070 else /* Fill AM configuration from DU database */
3072 *(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength) = covertAmSnLenFromIntEnumToRrcEnum(amCfg->ulAmCfg.snLenUl);
3073 rlcConfig->choice.am->dl_AM_RLC.t_Reassembly = convertReasmblTmrValueToEnum(amCfg->ulAmCfg.reAssemTmr);
3074 rlcConfig->choice.am->dl_AM_RLC.t_StatusProhibit = convertProhibitTmrValueToEnum(amCfg->ulAmCfg.statProhTmr);
3079 /*******************************************************************
3081 * @brief Builds RLC Config for UM Bidirection
3085 * Function : BuildRlcConfig UmBiDir
3088 * Builds RLC Config for UM Bidirection in BuildRlcBearerToAddModList
3090 * @params[in] UmBiDirBearerCfg *umBiDirCfg
3091 * RLC_Config_t *rlcConfig
3093 * @return ROK - success
3096 * ****************************************************************/
3097 uint8_t BuildRlcConfigUmBiDir(UmBiDirBearerCfg *umBiDirCfg, struct RLC_Config *rlcConfig)
3099 rlcConfig->choice.um_Bi_Directional = NULLP;
3100 DU_ALLOC(rlcConfig->choice.um_Bi_Directional, sizeof(struct RLC_Config__um_Bi_Directional));
3101 if(rlcConfig->choice.um_Bi_Directional == NULLP)
3103 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfigUmBiDir");
3107 /* Fill UM Bidirectional UL configuration */
3108 rlcConfig->choice.um_Bi_Directional->ul_UM_RLC.sn_FieldLength = NULLP;
3109 DU_ALLOC(rlcConfig->choice.um_Bi_Directional->ul_UM_RLC.sn_FieldLength, sizeof(SN_FieldLengthUM_t));
3110 if(rlcConfig->choice.um_Bi_Directional->ul_UM_RLC.sn_FieldLength == NULLP)
3112 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfigUmBiDir");
3116 if(umBiDirCfg != NULLP)
3118 *(rlcConfig->choice.um_Bi_Directional->ul_UM_RLC.sn_FieldLength) = covertUmSnLenFromIntEnumToRrcEnum(umBiDirCfg->dlUmCfg.snLenDlUm);
3121 /* Fill UM Bidirectional DL configuration */
3122 rlcConfig->choice.um_Bi_Directional->dl_UM_RLC.sn_FieldLength = NULLP;
3123 DU_ALLOC(rlcConfig->choice.um_Bi_Directional->dl_UM_RLC.sn_FieldLength, sizeof(SN_FieldLengthUM_t));
3124 if(rlcConfig->choice.um_Bi_Directional->dl_UM_RLC.sn_FieldLength == NULLP)
3126 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfigUmBiDir");
3130 if(umBiDirCfg != NULLP)
3132 *(rlcConfig->choice.um_Bi_Directional->dl_UM_RLC.sn_FieldLength) = covertUmSnLenFromIntEnumToRrcEnum(umBiDirCfg->ulUmCfg.snLenUlUm);
3133 rlcConfig->choice.um_Bi_Directional->dl_UM_RLC.t_Reassembly = convertReasmblTmrValueToEnum(umBiDirCfg->ulUmCfg.reAssemTmr);
3139 /*******************************************************************
3141 * @brief Builds RLC Config for UM Uni directional UL
3145 * Function : BuildRlcConfigUmUniDirUl
3148 * Builds RLC Config for UM Unidirection UL in BuildRlcBearerToAddModList
3150 * @params[in] UmUniDirDlBearerCfg *umUniDirDlCfg
3151 * RLC_Config_t *rlcConfig
3153 * @return ROK - success
3156 * ****************************************************************/
3157 uint8_t BuildRlcConfigUmUniDirUl(UmUniDirDlBearerCfg *umUniDirDlCfg, RLC_Config_t *rlcConfig)
3159 rlcConfig->choice.um_Uni_Directional_UL = NULLP;
3160 DU_ALLOC(rlcConfig->choice.um_Uni_Directional_UL , sizeof(struct RLC_Config__um_Uni_Directional_UL));
3161 if(rlcConfig->choice.um_Uni_Directional_UL == NULLP)
3163 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfigUmUniDirUl");
3167 rlcConfig->choice.um_Uni_Directional_UL->ul_UM_RLC.sn_FieldLength = NULLP;
3168 DU_ALLOC(rlcConfig->choice.um_Uni_Directional_UL->ul_UM_RLC.sn_FieldLength, sizeof(SN_FieldLengthUM_t));
3169 if(rlcConfig->choice.um_Uni_Directional_UL->ul_UM_RLC.sn_FieldLength == NULLP)
3171 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfigUmUniDirUl");
3175 if(umUniDirDlCfg != NULLP)
3177 *(rlcConfig->choice.um_Uni_Directional_UL->ul_UM_RLC.sn_FieldLength) = covertUmSnLenFromIntEnumToRrcEnum(umUniDirDlCfg->dlUmCfg.snLenDlUm);
3183 /*******************************************************************
3185 * @brief Builds RLC Config for UM Uni directional DL
3189 * Function : BuildRlcConfigUmUniDirDl
3192 * Builds RLC Config for UM Unidirection DL in BuildRlcBearerToAddModList
3194 * @params[in] UmUniDirUlBearerCfg *umUniDirUlCfg
3195 * RLC_Config_t *rlcConfig
3197 * @return ROK - success
3200 * ****************************************************************/
3201 uint8_t BuildRlcConfigUmUniDirDl(UmUniDirUlBearerCfg *umUniDirUlCfg, RLC_Config_t *rlcConfig)
3203 rlcConfig->choice.um_Uni_Directional_DL = NULLP;
3204 DU_ALLOC(rlcConfig->choice.um_Uni_Directional_DL , sizeof(struct RLC_Config__um_Uni_Directional_DL));
3205 if(rlcConfig->choice.um_Uni_Directional_DL == NULLP)
3207 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfigUmUniDirDl");
3211 rlcConfig->choice.um_Uni_Directional_DL->dl_UM_RLC.sn_FieldLength = NULLP;
3212 DU_ALLOC(rlcConfig->choice.um_Uni_Directional_DL->dl_UM_RLC.sn_FieldLength, sizeof(SN_FieldLengthUM_t));
3213 if(rlcConfig->choice.um_Uni_Directional_DL->dl_UM_RLC.sn_FieldLength == NULLP)
3215 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfigUmUniDirDl");
3219 if(umUniDirUlCfg != NULLP)
3221 *(rlcConfig->choice.um_Uni_Directional_DL->dl_UM_RLC.sn_FieldLength) = covertUmSnLenFromIntEnumToRrcEnum(umUniDirUlCfg->ulUmCfg.snLenUlUm);
3222 rlcConfig->choice.um_Uni_Directional_DL->dl_UM_RLC.t_Reassembly = convertReasmblTmrValueToEnum(umUniDirUlCfg->ulUmCfg.reAssemTmr);
3228 /*******************************************************************
3230 * @brief Builds RLC Config
3234 * Function : BuildRlcConfig
3236 * Functionality: Builds RLC Config in BuildRlcBearerToAddModList
3238 * @params[in] RLC_Config_t *rlcConfig
3240 * @return ROK - success
3243 * ****************************************************************/
3244 uint8_t BuildRlcConfig(RlcBearerCfg *rbCfg, struct RLC_Config *rlcConfig)
3247 /* Fill default values if rbCfg is NULL */
3250 rlcConfig->present = RLC_Config_PR_am;
3251 BuildRlcConfigAm(NULLP, rlcConfig);
3253 /* If RbCfg is present, fill RLC configurations from DU Database */
3256 rlcConfig->present = covertRlcModeFromIntEnumToRrcEnum(rbCfg->rlcMode);
3257 switch(rlcConfig->present)
3259 case RLC_Config_PR_am:
3260 BuildRlcConfigAm(rbCfg->u.amCfg, rlcConfig);
3262 case RLC_Config_PR_um_Bi_Directional:
3263 BuildRlcConfigUmBiDir(rbCfg->u.umBiDirCfg, rlcConfig);
3265 case RLC_Config_PR_um_Uni_Directional_UL:
3266 BuildRlcConfigUmUniDirUl(rbCfg->u.umUniDirDlCfg, rlcConfig);
3268 case RLC_Config_PR_um_Uni_Directional_DL:
3269 BuildRlcConfigUmUniDirDl(rbCfg->u.umUniDirUlCfg, rlcConfig);
3271 case RLC_Config_PR_NOTHING:
3280 /*******************************************************************
3282 * @brief Builds MAC LC Config
3286 * Function : BuildMacLCConfig
3288 * Functionality: Builds MAC LC Config in BuildRlcBearerToAddModList
3290 * @params[in] struct LogicalChannelConfig macLcConfig
3292 * @return ROK - success
3295 * ****************************************************************/
3296 uint8_t BuildMacLCConfig(LcCfg *lcCfgDb, struct LogicalChannelConfig *macLcConfig)
3298 macLcConfig->ul_SpecificParameters = NULLP;
3299 DU_ALLOC(macLcConfig->ul_SpecificParameters, sizeof(struct LogicalChannelConfig__ul_SpecificParameters));
3300 if(!macLcConfig->ul_SpecificParameters)
3302 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacLCConfig");
3306 if(lcCfgDb == NULLP)
3308 macLcConfig->ul_SpecificParameters->priority = MAC_LC_PRIORITY;
3309 macLcConfig->ul_SpecificParameters->prioritisedBitRate = PRIORTISIED_BIT_RATE;
3310 macLcConfig->ul_SpecificParameters->bucketSizeDuration = BUCKET_SIZE_DURATION;
3314 macLcConfig->ul_SpecificParameters->priority = lcCfgDb->ulLcCfg.priority;
3315 macLcConfig->ul_SpecificParameters->prioritisedBitRate = lcCfgDb->ulLcCfg.pbr;
3316 macLcConfig->ul_SpecificParameters->bucketSizeDuration = lcCfgDb->ulLcCfg.bsd;
3319 macLcConfig->ul_SpecificParameters->allowedServingCells = NULLP;
3320 macLcConfig->ul_SpecificParameters->allowedSCS_List = NULLP;
3321 macLcConfig->ul_SpecificParameters->maxPUSCH_Duration = NULLP;
3322 macLcConfig->ul_SpecificParameters->configuredGrantType1Allowed = NULLP;
3324 macLcConfig->ul_SpecificParameters->logicalChannelGroup = NULLP;
3325 DU_ALLOC(macLcConfig->ul_SpecificParameters->logicalChannelGroup, sizeof(long));
3326 if(!macLcConfig->ul_SpecificParameters->logicalChannelGroup)
3328 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacLCConfig");
3332 if(lcCfgDb == NULLP)
3333 *(macLcConfig->ul_SpecificParameters->logicalChannelGroup) = LC_GRP;
3335 *(macLcConfig->ul_SpecificParameters->logicalChannelGroup) = lcCfgDb->ulLcCfg.lcGroup;
3337 macLcConfig->ul_SpecificParameters->schedulingRequestID = NULLP;
3338 DU_ALLOC(macLcConfig->ul_SpecificParameters->schedulingRequestID, sizeof(SchedulingRequestId_t));
3339 if(!macLcConfig->ul_SpecificParameters->schedulingRequestID)
3341 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacLCConfig");
3345 if(lcCfgDb == NULLP)
3346 *(macLcConfig->ul_SpecificParameters->schedulingRequestID) = SCH_REQ_ID;
3348 *(macLcConfig->ul_SpecificParameters->schedulingRequestID) = lcCfgDb->ulLcCfg.schReqId;
3350 macLcConfig->ul_SpecificParameters->logicalChannelSR_Mask = false;
3351 macLcConfig->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = false;
3352 macLcConfig->ul_SpecificParameters->bitRateQueryProhibitTimer = NULLP;
3357 /*******************************************************************
3359 * @brief Builds RLC Bearer to Add/Mod list
3363 * Function :BuildRlcBearerToAddModList
3365 * Functionality: Builds RLC Bearer to Add/Mod list in DuToCuRrcContainer
3367 * @params[in] rlc_BearerToAddModList
3369 * @return ROK - success
3372 * ****************************************************************/
3373 uint8_t BuildRlcBearerToAddModList(DuUeCb *ueCb, struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList)
3375 uint8_t idx = 0, lcIdx=0, macLcIdx = 0, elementCnt = 0;
3379 else if(ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY)
3380 elementCnt = ueCb->duRlcUeCfg.numLcs;
3383 for(lcIdx = 0; lcIdx<ueCb->duRlcUeCfg.numLcs; lcIdx++)
3385 if(ueCb->duRlcUeCfg.rlcLcCfg[lcIdx].rlcBearerCfg.isLcAddModRspSent == false)
3389 rlcBearerList->list.count = elementCnt;
3390 rlcBearerList->list.size = elementCnt * sizeof(struct RLC_BearerConfig *);
3392 rlcBearerList->list.array = NULLP;
3393 DU_ALLOC(rlcBearerList->list.array, rlcBearerList->list.size);
3394 if(!rlcBearerList->list.array)
3396 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3400 for(idx=0; idx<rlcBearerList->list.count; idx++)
3402 rlcBearerList->list.array[idx] = NULLP;
3403 DU_ALLOC(rlcBearerList->list.array[idx], sizeof(struct RLC_BearerConfig));
3404 if(!rlcBearerList->list.array[idx])
3406 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3414 rlcBearerList->list.array[idx]->logicalChannelIdentity = SRB1_LCID;
3415 DU_ALLOC(rlcBearerList->list.array[idx]->servedRadioBearer, sizeof(struct RLC_BearerConfig__servedRadioBearer));
3416 if(!rlcBearerList->list.array[idx]->servedRadioBearer)
3418 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3421 rlcBearerList->list.array[idx]->servedRadioBearer->present = RLC_BearerConfig__servedRadioBearer_PR_srb_Identity;
3422 rlcBearerList->list.array[idx]->servedRadioBearer->choice.srb_Identity = SRB1_LCID;
3423 rlcBearerList->list.array[idx]->reestablishRLC = NULLP;
3425 /* Fill RLC related Configurations for this Radio Bearer */
3426 rlcBearerList->list.array[idx]->rlc_Config = NULLP;
3427 DU_ALLOC(rlcBearerList->list.array[idx]->rlc_Config, sizeof(struct RLC_Config));
3428 if(!rlcBearerList->list.array[idx]->rlc_Config)
3430 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3433 if(BuildRlcConfig(NULLP, rlcBearerList->list.array[idx]->rlc_Config) != ROK)
3435 DU_LOG("\nERROR --> F1AP : BuildRlcConfig failed");
3439 /* Fill MAC related configurations for this Radio Bearer */
3440 rlcBearerList->list.array[idx]->mac_LogicalChannelConfig = NULLP;
3441 DU_ALLOC(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig, sizeof(struct LogicalChannelConfig));
3442 if(!rlcBearerList->list.array[idx]->mac_LogicalChannelConfig)
3444 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3447 if(BuildMacLCConfig(NULLP, rlcBearerList->list.array[idx]->mac_LogicalChannelConfig) != ROK)
3449 DU_LOG("\nERROR --> F1AP : BuildMacLCConfig failed");
3456 for(lcIdx=0; lcIdx<ueCb->duRlcUeCfg.numLcs; lcIdx++)
3458 if((ueCb->f1UeDb->actionType != UE_CTXT_CFG_QUERY) && (ueCb->duRlcUeCfg.rlcLcCfg[lcIdx].rlcBearerCfg.isLcAddModRspSent == true))
3461 /* Fill Logical channel identity */
3462 rlcBearerList->list.array[idx]->logicalChannelIdentity = ueCb->duRlcUeCfg.rlcLcCfg[lcIdx].rlcBearerCfg.lcId;
3464 /* Fill Radio Bearer Id and type (DRB/SRB) for this logical channel */
3465 DU_ALLOC(rlcBearerList->list.array[idx]->servedRadioBearer, sizeof(struct RLC_BearerConfig__servedRadioBearer));
3466 if(!rlcBearerList->list.array[idx]->servedRadioBearer)
3468 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3471 rlcBearerList->list.array[idx]->servedRadioBearer->present = \
3472 covertRbTypeFromIntEnumToRrcEnum(ueCb->duRlcUeCfg.rlcLcCfg[lcIdx].rlcBearerCfg.rbType);
3473 switch(rlcBearerList->list.array[idx]->servedRadioBearer->present)
3475 case RLC_BearerConfig__servedRadioBearer_PR_srb_Identity:
3476 rlcBearerList->list.array[idx]->servedRadioBearer->choice.srb_Identity = ueCb->duRlcUeCfg.rlcLcCfg[lcIdx].rlcBearerCfg.rbId;
3478 case RLC_BearerConfig__servedRadioBearer_PR_drb_Identity:
3479 rlcBearerList->list.array[idx]->servedRadioBearer->choice.drb_Identity = ueCb->duRlcUeCfg.rlcLcCfg[lcIdx].rlcBearerCfg.rbId;
3481 case RLC_BearerConfig__servedRadioBearer_PR_NOTHING:
3485 ueCb->duRlcUeCfg.rlcLcCfg[lcIdx].rlcBearerCfg.isLcAddModRspSent = true;
3487 rlcBearerList->list.array[idx]->reestablishRLC = NULLP;
3489 /* Fill RLC related Configurations for this Radio Bearer */
3490 rlcBearerList->list.array[idx]->rlc_Config = NULLP;
3491 DU_ALLOC(rlcBearerList->list.array[idx]->rlc_Config, sizeof(struct RLC_Config));
3492 if(!rlcBearerList->list.array[idx]->rlc_Config)
3494 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3497 if(BuildRlcConfig(&ueCb->duRlcUeCfg.rlcLcCfg[lcIdx].rlcBearerCfg, rlcBearerList->list.array[idx]->rlc_Config) != ROK)
3499 DU_LOG("\nERROR --> F1AP : BuildRlcConfig failed");
3503 /* Fill MAC related configurations for this Radio Bearer */
3504 rlcBearerList->list.array[idx]->mac_LogicalChannelConfig = NULLP;
3505 DU_ALLOC(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig, sizeof(struct LogicalChannelConfig));
3506 if(!rlcBearerList->list.array[idx]->mac_LogicalChannelConfig)
3508 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3511 for(macLcIdx = 0; macLcIdx < ueCb->duMacUeCfg.numLcs; macLcIdx++)
3513 if(ueCb->duMacUeCfg.lcCfgList[macLcIdx].lcConfig.lcId == ueCb->duRlcUeCfg.rlcLcCfg[lcIdx].rlcBearerCfg.lcId)
3515 if(BuildMacLCConfig(&ueCb->duMacUeCfg.lcCfgList[macLcIdx].lcConfig, rlcBearerList->list.array[idx]->mac_LogicalChannelConfig) != ROK)
3517 DU_LOG("\nERROR --> F1AP : BuildMacLCConfig failed");
3530 /*******************************************************************
3532 * @brief Build Control resource set to add/modify list
3536 * Function : BuildControlRSetToAddModList
3538 * Functionality: Build Control resource set to add/modify list
3541 * struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList
3543 * @return ROK - success
3546 * ****************************************************************/
3547 uint8_t BuildControlRSetToAddModList(PdcchConfig *pdcchCfg, struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList)
3551 uint8_t numBytes, bitsUnused;
3552 struct ControlResourceSet *controlRSet;
3553 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
3554 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
3556 if(pdcchCfg == NULLP)
3559 elementCnt = pdcchCfg->numCRsetToAddMod;
3561 controlRSetList->list.count = elementCnt;
3562 controlRSetList->list.size = elementCnt * sizeof(struct ControlResourceSet *);
3564 controlRSetList->list.array = NULLP;
3565 DU_ALLOC(controlRSetList->list.array, controlRSetList->list.size);
3566 if(!controlRSetList->list.array)
3568 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3572 for(idx = 0; idx < elementCnt; idx++)
3574 controlRSetList->list.array[idx] = NULLP;
3575 DU_ALLOC(controlRSetList->list.array[idx], sizeof(struct ControlResourceSet));
3576 if(!controlRSetList->list.array[idx])
3578 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3583 for(idx = 0; idx < elementCnt; idx++)
3585 controlRSet = controlRSetList->list.array[idx];
3587 if(pdcchCfg == NULLP)
3588 controlRSet->controlResourceSetId = PDCCH_CTRL_RSRC_SET_ONE_ID;
3590 controlRSet->controlResourceSetId = pdcchCfg->cRSetToAddModList[idx].cRSetId;
3594 * Bit string stored ff0000000000
3598 controlRSet->frequencyDomainResources.size = numBytes * sizeof(uint8_t);
3600 controlRSet->frequencyDomainResources.buf = NULLP;
3601 DU_ALLOC(controlRSet->frequencyDomainResources.buf, controlRSet->frequencyDomainResources.size);
3602 if(!controlRSet->frequencyDomainResources.buf)
3604 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3608 memset(controlRSet->frequencyDomainResources.buf, 0, FREQ_DOM_RSRC_SIZE);
3610 if(pdcchCfg == NULLP)
3612 coreset0EndPrb = CORESET0_END_PRB;
3613 coreset1StartPrb = coreset0EndPrb + 6;
3614 coreset1NumPrb = CORESET1_NUM_PRB;
3615 /* calculate the PRBs */
3616 fillCoresetFeqDomAllocMap(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
3617 memcpy(controlRSet->frequencyDomainResources.buf, freqDomainResource, FREQ_DOM_RSRC_SIZE);
3618 controlRSet->frequencyDomainResources.bits_unused = bitsUnused;
3620 controlRSet->duration = PDCCH_CTRL_RSRC_SET_ONE_DURATION;
3621 controlRSet->cce_REG_MappingType.present = ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved;
3622 controlRSet->precoderGranularity = PDCCH_CTRL_RSRC_SET_ONE_PRECOD_GRANULARITY;
3626 memcpy(controlRSet->frequencyDomainResources.buf, pdcchCfg->cRSetToAddModList[idx].freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
3627 controlRSet->frequencyDomainResources.bits_unused = bitsUnused;
3628 controlRSet->duration = pdcchCfg->cRSetToAddModList[idx].duration;
3629 controlRSet->cce_REG_MappingType.present = pdcchCfg->cRSetToAddModList[idx].cceRegMappingType;
3630 controlRSet->precoderGranularity = pdcchCfg->cRSetToAddModList[idx].precoderGranularity;
3632 controlRSet->tci_StatesPDCCH_ToAddList = NULLP;
3633 controlRSet->tci_StatesPDCCH_ToReleaseList = NULLP;
3634 controlRSet->tci_PresentInDCI = NULLP;
3637 uint8_t tciStateIdx;
3639 DU_ALLOC(controlRset->tci_StatesPDCCH_ToAddList, \
3640 sizeof(struct ControlResourceSet__tci_StatesPDCCH_ToAddList));
3641 if(!controlRset->tci_StatesPDCCH_ToAddList)
3643 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3648 controlRset->tci_StatesPDCCH_ToAddList->list.count = elementCnt;
3649 controlRset->tci_StatesPDCCH_ToAddList->list.size = elementCnt * sizeof(TCI_StateId_t *);
3650 DU_ALLOC(controlRset->tci_StatesPDCCH_ToAddList->list.array, \
3651 controlRset->tci_StatesPDCCH_ToAddList->list.size)
3652 if(!controlRset->tci_StatesPDCCH_ToAddList->list.array)
3654 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3658 for(tciStateIdx = 0; tciStateIdx <elementCntl; tciStateIdx++)
3660 DU_ALLOC(controlRset->tci_StatesPDCCH_ToAddList->list.array[tciStateIdx], sizeof(TCI_StateId_t));
3661 if(!controlRset->tci_StatesPDCCH_ToAddList->list.array[tciStateIdx])
3663 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3670 *(controlRset->tci_StatesPDCCH_ToAddList->list.array[tciStateIdx]);
3672 DU_ALLOC(controlRset->tci_PresentInDCI, sizeof(long));
3673 if(!controlRset->tci_PresentInDCI)
3675 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3679 *(controlRset->tci_PresentInDCI);
3682 controlRSet->pdcch_DMRS_ScramblingID = NULLP;
3683 DU_ALLOC(controlRSet->pdcch_DMRS_ScramblingID, sizeof(long));
3684 if(!controlRSet->pdcch_DMRS_ScramblingID)
3686 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3689 if(pdcchCfg == NULLP)
3690 *(controlRSet->pdcch_DMRS_ScramblingID) = SCRAMBLING_ID;
3692 *(controlRSet->pdcch_DMRS_ScramblingID) = pdcchCfg->cRSetToAddModList[idx].dmrsScramblingId;
3695 } /* End BuildControlRSetToAddModList */
3697 /*******************************************************************
3699 * @brief Build search space to add/modify list
3703 * Function : BuildSearchSpcToAddModList
3705 * Functionality: Build search space to add/modify list
3708 * @return ROK - success
3711 * ****************************************************************/
3712 uint8_t BuildSearchSpcToAddModList(PdcchConfig *pdcchCfg, struct PDCCH_Config__searchSpacesToAddModList *searchSpcList)
3719 struct SearchSpace *searchSpc;
3721 if(pdcchCfg == NULLP)
3724 elementCnt = pdcchCfg->numSearchSpcToAddMod;
3726 searchSpcList->list.count = elementCnt;
3727 searchSpcList->list.size = elementCnt * sizeof(struct SearchSpace *);
3729 searchSpcList->list.array = NULLP;
3730 DU_ALLOC(searchSpcList->list.array, searchSpcList->list.size);
3731 if(!searchSpcList->list.array)
3733 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3737 for(idx = 0; idx < elementCnt; idx++)
3739 searchSpcList->list.array[idx] = NULLP;
3740 DU_ALLOC(searchSpcList->list.array[idx], sizeof(struct SearchSpace));
3741 if(!searchSpcList->list.array[idx])
3743 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3748 for(idx = 0; idx < elementCnt; idx++)
3750 searchSpc = searchSpcList->list.array[idx];
3752 if(pdcchCfg == NULLP)
3753 searchSpc->searchSpaceId = PDCCH_SRCH_SPC_TWO_ID;
3755 searchSpc->searchSpaceId = pdcchCfg->searchSpcToAddModList[idx].searchSpaceId;
3757 searchSpc->controlResourceSetId = NULLP;
3758 DU_ALLOC(searchSpc->controlResourceSetId, sizeof(ControlResourceSetId_t));
3759 if(!searchSpc->controlResourceSetId)
3761 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3764 if(pdcchCfg == NULLP)
3765 *(searchSpc->controlResourceSetId) = PDCCH_CTRL_RSRC_SET_ONE_ID;
3767 *(searchSpc->controlResourceSetId) = pdcchCfg->searchSpcToAddModList[idx].cRSetId;
3769 searchSpc->monitoringSlotPeriodicityAndOffset = NULLP;
3770 DU_ALLOC(searchSpc->monitoringSlotPeriodicityAndOffset, sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
3771 if(!searchSpc->monitoringSlotPeriodicityAndOffset)
3773 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3776 if(pdcchCfg == NULLP)
3777 searchSpc->monitoringSlotPeriodicityAndOffset->present = SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
3779 searchSpc->monitoringSlotPeriodicityAndOffset->present = pdcchCfg->searchSpcToAddModList[idx].mSlotPeriodicityAndOffset;
3781 searchSpc->duration = NULLP;
3782 searchSpc->monitoringSymbolsWithinSlot = NULLP;
3783 DU_ALLOC(searchSpc->monitoringSymbolsWithinSlot, sizeof(BIT_STRING_t));
3784 if(!searchSpc->monitoringSymbolsWithinSlot)
3786 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3790 /* Values taken from reference logs :
3793 * Bit string stores 8000
3797 searchSpc->monitoringSymbolsWithinSlot->size = numBytes * sizeof(uint8_t);
3798 searchSpc->monitoringSymbolsWithinSlot->buf = NULLP;
3799 DU_ALLOC(searchSpc->monitoringSymbolsWithinSlot->buf, searchSpc->monitoringSymbolsWithinSlot->size);
3800 if(!searchSpc->monitoringSymbolsWithinSlot->buf)
3802 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3805 if(pdcchCfg == NULLP)
3808 searchSpc->monitoringSymbolsWithinSlot->buf[byteIdx++] = PDCCH_SYMBOL_WITHIN_SLOT /* setting MSB to 128 i.e. 0x80 */;
3809 searchSpc->monitoringSymbolsWithinSlot->buf[byteIdx++] = 0;
3812 memcpy(searchSpc->monitoringSymbolsWithinSlot->buf, pdcchCfg->searchSpcToAddModList[idx].mSymbolsWithinSlot, numBytes);
3813 searchSpc->monitoringSymbolsWithinSlot->bits_unused = bitsUnused;
3815 searchSpc->nrofCandidates = NULLP;
3816 DU_ALLOC(searchSpc->nrofCandidates, sizeof(struct SearchSpace__nrofCandidates));
3817 if(!searchSpc->nrofCandidates)
3819 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3823 if(pdcchCfg == NULLP)
3825 searchSpc->nrofCandidates->aggregationLevel1 = PDCCH_SRCH_SPC_TWO_AGG_LVL1_CANDIDATE;
3826 searchSpc->nrofCandidates->aggregationLevel2 = PDCCH_SRCH_SPC_TWO_AGG_LVL2_CANDIDATE;
3827 searchSpc->nrofCandidates->aggregationLevel4 = PDCCH_SRCH_SPC_TWO_AGG_LVL4_CANDIDATE;
3828 searchSpc->nrofCandidates->aggregationLevel8 = PDCCH_SRCH_SPC_TWO_AGG_LVL8_CANDIDATE;
3829 searchSpc->nrofCandidates->aggregationLevel16 = PDCCH_SRCH_SPC_TWO_AGG_LVL16_CANDIDATE;
3833 searchSpc->nrofCandidates->aggregationLevel1 = pdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel1;
3834 searchSpc->nrofCandidates->aggregationLevel2 = pdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel2;
3835 searchSpc->nrofCandidates->aggregationLevel4 = pdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel4;
3836 searchSpc->nrofCandidates->aggregationLevel8 = pdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel8;
3837 searchSpc->nrofCandidates->aggregationLevel16 = pdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel16;
3840 searchSpc->searchSpaceType = NULLP;
3841 DU_ALLOC(searchSpc->searchSpaceType, sizeof(struct SearchSpace__searchSpaceType));
3842 if(!searchSpc->searchSpaceType)
3844 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3847 if(pdcchCfg == NULLP)
3848 searchSpc->searchSpaceType->present = SearchSpace__searchSpaceType_PR_ue_Specific;
3850 searchSpc->searchSpaceType->present = pdcchCfg->searchSpcToAddModList[idx].searchSpaceType;
3852 searchSpc->searchSpaceType->choice.ue_Specific = NULLP;
3853 DU_ALLOC(searchSpc->searchSpaceType->choice.ue_Specific, sizeof(struct SearchSpace__searchSpaceType__ue_Specific));
3854 if(!searchSpc->searchSpaceType->choice.ue_Specific)
3856 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3859 if(pdcchCfg == NULLP)
3860 searchSpc->searchSpaceType->choice.ue_Specific->dci_Formats = PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
3862 searchSpc->searchSpaceType->choice.ue_Specific->dci_Formats = pdcchCfg->searchSpcToAddModList[idx].ueSpecificDciFormat;
3865 }/* End BuildSearchSpcToAddModList */
3867 /*******************************************************************
3869 * @brief Builds BWP DL dedicated PDCCH config
3873 * Function : BuildBWPDlDedPdcchCfg
3875 * Functionality: Builds BWP DL dedicated PDCCH config
3877 * @params[in] struct PDCCH_Config *pdcchCfg
3879 * @return ROK - success
3882 * ****************************************************************/
3883 uint8_t BuildBWPDlDedPdcchCfg(PdcchConfig *pdcchCfgDb, struct PDCCH_Config *pdcchCfg)
3885 pdcchCfg->controlResourceSetToAddModList = NULLP;
3886 DU_ALLOC(pdcchCfg->controlResourceSetToAddModList, sizeof(struct PDCCH_Config__controlResourceSetToAddModList));
3887 if(!pdcchCfg->controlResourceSetToAddModList)
3889 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdcchCfg");
3893 if(BuildControlRSetToAddModList(pdcchCfgDb, pdcchCfg->controlResourceSetToAddModList) != ROK)
3895 DU_LOG("\nERROR --> F1AP : Failed in BuildControlRSetToAddModList()");
3899 pdcchCfg->controlResourceSetToReleaseList = NULLP;
3901 pdcchCfg->searchSpacesToAddModList = NULLP;
3902 DU_ALLOC(pdcchCfg->searchSpacesToAddModList, sizeof(struct PDCCH_Config__searchSpacesToAddModList));
3903 if(!pdcchCfg->searchSpacesToAddModList)
3905 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdcchCfg");
3909 if(BuildSearchSpcToAddModList(pdcchCfgDb, pdcchCfg->searchSpacesToAddModList) != ROK)
3911 DU_LOG("\nERROR --> F1AP : Failed in BuildSearchSpcToAddModList()");
3915 pdcchCfg->searchSpacesToReleaseList = NULLP;
3916 pdcchCfg->downlinkPreemption = NULLP;
3917 pdcchCfg->tpc_PUSCH = NULLP;
3918 pdcchCfg->tpc_PUCCH = NULLP;
3919 pdcchCfg->tpc_SRS = NULLP;
3924 /*******************************************************************
3926 * @brief Builds DMRS DL PDSCH Mapping type A
3930 * Function : BuildDMRSDLPdschMapTypeA
3932 * Functionality: Builds DMRS DL PDSCH Mapping type A
3935 * struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg
3936 * @return ROK - success
3939 * ****************************************************************/
3940 uint8_t BuildDMRSDLPdschMapTypeA(PdschConfig *pdschCfg, struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg)
3942 dmrsDlCfg->present = PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA_PR_setup;
3943 dmrsDlCfg->choice.setup = NULLP;
3944 DU_ALLOC(dmrsDlCfg->choice.setup, sizeof(struct DMRS_DownlinkConfig));
3945 if(!dmrsDlCfg->choice.setup)
3947 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSDLPdschMapTypeA");
3951 dmrsDlCfg->choice.setup->dmrs_Type = NULLP;
3952 dmrsDlCfg->choice.setup->dmrs_AdditionalPosition = NULLP;
3953 DU_ALLOC(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition, sizeof(long));
3954 if(!dmrsDlCfg->choice.setup->dmrs_AdditionalPosition)
3956 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSDLPdschMapTypeA");
3959 if(pdschCfg == NULLP)
3960 *(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition) = DMRS_ADDITIONAL_POS;
3962 *(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition) = pdschCfg->dmrsDlCfgForPdschMapTypeA.addPos;
3964 dmrsDlCfg->choice.setup->maxLength = NULLP;
3965 dmrsDlCfg->choice.setup->scramblingID0 = NULLP;
3966 dmrsDlCfg->choice.setup->scramblingID1 = NULLP;
3967 dmrsDlCfg->choice.setup->phaseTrackingRS = NULLP;
3972 /*******************************************************************
3974 * @brief Builds TCI states to add/modify list
3978 * Function : BuildTCIStatesToAddModList
3980 * Functionality:Builds TCI states to add/modify list
3983 * struct PDSCH_Config__tci_StatesToAddModList *tciStatesList
3985 * @return ROK - success
3988 * ****************************************************************/
3989 uint8_t BuildTCIStatesToAddModList(struct PDSCH_Config__tci_StatesToAddModList *tciStatesList)
3994 /*******************************************************************
3996 * @brief Builds PDSCH time domain allocation list
4000 * Function : BuildPdschTimeDomAllocList
4002 * Functionality: Builds PDSCH time domain allocation list
4005 * struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
4007 * @return ROK - success
4010 * ****************************************************************/
4011 uint8_t BuildPdschTimeDomAllocList(PdschConfig *pdschCfg, struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList)
4015 struct PDSCH_TimeDomainResourceAllocation *timeDomAlloc;
4017 timeDomAllocList->present = PDSCH_Config__pdsch_TimeDomainAllocationList_PR_setup;
4019 timeDomAllocList->choice.setup = NULLP;
4020 DU_ALLOC(timeDomAllocList->choice.setup, sizeof(struct PDSCH_TimeDomainResourceAllocationList));
4021 if(!timeDomAllocList->choice.setup)
4023 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
4027 if(pdschCfg == NULLP)
4030 elementCnt = pdschCfg->numTimeDomRsrcAlloc;
4031 timeDomAllocList->choice.setup->list.count = elementCnt;
4032 timeDomAllocList->choice.setup->list.size = elementCnt * sizeof(struct PDSCH_TimeDomainResourceAllocation *);
4034 timeDomAllocList->choice.setup->list.array = NULLP;
4035 DU_ALLOC(timeDomAllocList->choice.setup->list.array, timeDomAllocList->choice.setup->list.size);
4036 if(!timeDomAllocList->choice.setup->list.array)
4038 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
4042 for(idx = 0; idx < elementCnt; idx++)
4044 timeDomAllocList->choice.setup->list.array[idx] = NULLP;
4045 DU_ALLOC(timeDomAllocList->choice.setup->list.array[idx], \
4046 sizeof(struct PDSCH_TimeDomainResourceAllocation));
4047 if(!timeDomAllocList->choice.setup->list.array[idx])
4049 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
4054 if(pdschCfg == NULLP)
4057 timeDomAlloc = timeDomAllocList->choice.setup->list.array[idx];
4058 DU_ALLOC(timeDomAlloc->k0, sizeof(long));
4059 if(!timeDomAlloc->k0)
4061 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
4064 *(timeDomAlloc->k0) = 0;
4065 timeDomAlloc->mappingType = PDSCH_MAPPING_TYPE_A;
4066 timeDomAlloc->startSymbolAndLength = \
4067 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
4070 timeDomAlloc = timeDomAllocList->choice.setup->list.array[idx];
4071 DU_ALLOC(timeDomAlloc->k0, sizeof(long));
4072 if(!timeDomAlloc->k0)
4074 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
4077 *(timeDomAlloc->k0) = 1;
4078 timeDomAlloc->mappingType = PDSCH_MAPPING_TYPE_A;
4079 timeDomAlloc->startSymbolAndLength = calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
4083 for(idx = 0; idx < elementCnt; idx++)
4085 timeDomAlloc = timeDomAllocList->choice.setup->list.array[idx];
4086 if(pdschCfg->timeDomRsrcAllociList[idx].k0)
4088 DU_ALLOC(timeDomAlloc->k0, sizeof(long));
4089 if(!timeDomAlloc->k0)
4091 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
4094 *(timeDomAlloc->k0) = *(pdschCfg->timeDomRsrcAllociList[idx].k0);
4096 timeDomAlloc->mappingType = pdschCfg->timeDomRsrcAllociList[idx].mappingType;
4097 timeDomAlloc->startSymbolAndLength = pdschCfg->timeDomRsrcAllociList[idx].startSymbolAndLength;
4104 /*******************************************************************
4106 * @brief Builds PDSCH PRB Bundling type
4110 * Function : BuildPdschPrbBundlingType
4112 * Functionality: Builds PDSCH PRB Bundling type
4115 * struct PDSCH_Config__prb_BundlingType *prbBndlType
4117 * @return ROK - success
4120 * ****************************************************************/
4121 uint8_t BuildPdschPrbBundlingType(PdschConfig *pdschCfg, struct PDSCH_Config__prb_BundlingType *prbBndlType)
4123 if(pdschCfg == NULLP)
4124 prbBndlType->present = PDSCH_Config__prb_BundlingType_PR_staticBundling;
4126 prbBndlType->present = pdschCfg->bundlingType;
4128 prbBndlType->choice.staticBundling = NULLP;
4129 DU_ALLOC(prbBndlType->choice.staticBundling, \
4130 sizeof(struct PDSCH_Config__prb_BundlingType__staticBundling));
4131 if(!prbBndlType->choice.staticBundling)
4133 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschPrbBundlingType");
4136 prbBndlType->choice.staticBundling->bundleSize = NULLP;
4141 /*******************************************************************
4143 * @brief Builds BWP DL dedicated PDSCH config
4147 * Function : BuildBWPDlDedPdschCfg
4149 * Functionality: Builds BWP DL dedicated PDSCH config
4151 * @params[in] struct PDSCH_Config *pdschCfg
4153 * @return ROK - success
4156 * ****************************************************************/
4157 uint8_t BuildBWPDlDedPdschCfg(PdschConfig *pdschCfgDb, struct PDSCH_Config *pdschCfg)
4159 pdschCfg->dataScramblingIdentityPDSCH = NULLP;
4161 pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA = NULLP;
4162 DU_ALLOC(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA, sizeof(struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA));
4163 if(!pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
4165 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
4169 if(BuildDMRSDLPdschMapTypeA(pdschCfgDb, pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA) != ROK)
4174 pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeB = NULLP;
4175 pdschCfg->tci_StatesToAddModList = NULLP;
4176 pdschCfg->tci_StatesToReleaseList = NULLP;
4177 pdschCfg->vrb_ToPRB_Interleaver = NULLP;
4179 DU_ALLOC(pdschCfg->tci_StatesToAddModList, sizeof(struct PDSCH_Config__tci_StatesToAddModList));
4180 if(!pdschCfg->tci_StatesToAddModList)
4182 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
4185 if(BuildTCIStatesToAddModList(pdschCfg->tci_StatesToAddModList) != ROK)
4191 if(pdschCfgDb == NULLP)
4192 pdschCfg->resourceAllocation = RES_ALLOC_TYPE;
4194 pdschCfg->resourceAllocation = pdschCfgDb->resourceAllocType;
4196 pdschCfg->pdsch_TimeDomainAllocationList = NULLP;
4197 DU_ALLOC(pdschCfg->pdsch_TimeDomainAllocationList, sizeof(struct PDSCH_Config__pdsch_TimeDomainAllocationList));
4198 if(!pdschCfg->pdsch_TimeDomainAllocationList)
4200 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
4203 if(BuildPdschTimeDomAllocList(pdschCfgDb, pdschCfg->pdsch_TimeDomainAllocationList) != ROK)
4208 pdschCfg->pdsch_AggregationFactor = NULLP;
4209 pdschCfg->rateMatchPatternToAddModList = NULLP;
4210 pdschCfg->rateMatchPatternToReleaseList = NULLP;
4211 pdschCfg->rateMatchPatternGroup1 = NULLP;
4212 pdschCfg->rateMatchPatternGroup2 = NULLP;
4213 if(pdschCfgDb == NULLP)
4214 pdschCfg->rbg_Size = PDSCH_RBG_SIZE;
4216 pdschCfg->rbg_Size = pdschCfgDb->rbgSize;
4217 pdschCfg->mcs_Table = NULLP;
4219 pdschCfg->maxNrofCodeWordsScheduledByDCI = NULLP;
4220 DU_ALLOC(pdschCfg->maxNrofCodeWordsScheduledByDCI, sizeof(long));
4221 if(!pdschCfg->maxNrofCodeWordsScheduledByDCI)
4223 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
4226 if(pdschCfgDb == NULLP)
4227 *(pdschCfg->maxNrofCodeWordsScheduledByDCI) = PDSCH_MAX_CODEWORD_SCH_BY_DCI;
4229 *(pdschCfg->maxNrofCodeWordsScheduledByDCI) = pdschCfgDb->numCodeWordsSchByDci;
4231 if(BuildPdschPrbBundlingType(pdschCfgDb, &pdschCfg->prb_BundlingType) != ROK)
4236 pdschCfg->zp_CSI_RS_ResourceToAddModList = NULLP;
4237 pdschCfg->zp_CSI_RS_ResourceToReleaseList = NULLP;
4238 pdschCfg->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList = NULLP;
4239 pdschCfg->aperiodic_ZP_CSI_RS_ResourceSetsToReleaseList = NULLP;
4240 pdschCfg->sp_ZP_CSI_RS_ResourceSetsToAddModList = NULLP;
4241 pdschCfg->sp_ZP_CSI_RS_ResourceSetsToReleaseList = NULLP;
4242 pdschCfg->p_ZP_CSI_RS_ResourceSet = NULLP;
4247 /*******************************************************************
4249 * @brief Builds intitial DL BWP
4252 * Function : BuildInitialDlBWP
4254 * Functionality: Builds intitial DL BWP in spCellCfgDed
4256 * @params[in] BWP_DownlinkDedicated_t *dlBwp
4258 * @return ROK - success
4261 * ****************************************************************/
4262 uint8_t BuildInitialDlBWP(InitialDlBwp *initiDlBwp, BWP_DownlinkDedicated_t *dlBwp)
4264 PdcchConfig *pdcchCfg = NULLP;
4265 PdschConfig *pdschCfg = NULLP;
4269 if(initiDlBwp->pdcchPresent)
4270 pdcchCfg = &initiDlBwp->pdcchCfg;
4271 if(initiDlBwp->pdschPresent)
4272 pdschCfg = &initiDlBwp->pdschCfg;
4275 dlBwp->pdcch_Config = NULLP;
4276 DU_ALLOC(dlBwp->pdcch_Config, sizeof(struct BWP_DownlinkDedicated__pdcch_Config));
4277 if(!dlBwp->pdcch_Config)
4279 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
4282 dlBwp->pdcch_Config->present = BWP_DownlinkDedicated__pdcch_Config_PR_setup;
4284 dlBwp->pdcch_Config->choice.setup = NULLP;
4285 DU_ALLOC(dlBwp->pdcch_Config->choice.setup, sizeof(struct PDCCH_Config));
4286 if(!dlBwp->pdcch_Config->choice.setup)
4288 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
4291 if(BuildBWPDlDedPdcchCfg(pdcchCfg, dlBwp->pdcch_Config->choice.setup) != ROK)
4296 dlBwp->pdsch_Config = NULLP;
4297 DU_ALLOC(dlBwp->pdsch_Config, sizeof(struct BWP_DownlinkDedicated__pdsch_Config));
4298 if(!dlBwp->pdsch_Config)
4300 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
4303 dlBwp->pdsch_Config->present = BWP_DownlinkDedicated__pdsch_Config_PR_setup;
4305 dlBwp->pdsch_Config->choice.setup = NULLP;
4306 DU_ALLOC(dlBwp->pdsch_Config->choice.setup, sizeof(struct PDSCH_Config));
4307 if(!dlBwp->pdsch_Config->choice.setup)
4309 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
4313 if(BuildBWPDlDedPdschCfg(pdschCfg, dlBwp->pdsch_Config->choice.setup) != ROK)
4318 dlBwp->sps_Config = NULLP;
4319 dlBwp->radioLinkMonitoringConfig = NULLP;
4323 /*******************************************************************
4325 * @brief Builds DMRS UL Pusch Mapping type A
4329 * Function : BuildDMRSULPuschMapTypeA
4331 * Functionality: Builds DMRS UL Pusch Mapping type A
4334 * struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg
4335 * @return ROK - success
4338 * ****************************************************************/
4339 uint8_t BuildDMRSULPuschMapTypeA(DmrsUlCfg *ulDmrsCfgDb, struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg)
4341 dmrsUlCfg->present = PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA_PR_setup;
4342 dmrsUlCfg->choice.setup= NULLP;
4343 DU_ALLOC(dmrsUlCfg->choice.setup, sizeof(DMRS_UplinkConfig_t));
4344 if(!dmrsUlCfg->choice.setup)
4346 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4350 dmrsUlCfg->choice.setup->dmrs_Type = NULLP;
4351 dmrsUlCfg->choice.setup->dmrs_AdditionalPosition = NULLP;
4352 DU_ALLOC(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition, sizeof(long));
4353 if(!dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
4355 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4358 if(ulDmrsCfgDb == NULLP)
4359 *(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition) = DMRS_ADDITIONAL_POS;
4361 *(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition) = ulDmrsCfgDb->addPos;
4363 dmrsUlCfg->choice.setup->phaseTrackingRS = NULLP;
4364 dmrsUlCfg->choice.setup->maxLength = NULLP;
4365 dmrsUlCfg->choice.setup->transformPrecodingDisabled = NULLP;
4366 DU_ALLOC(dmrsUlCfg->choice.setup->transformPrecodingDisabled, sizeof(struct DMRS_UplinkConfig__transformPrecodingDisabled));
4367 if(!dmrsUlCfg->choice.setup->transformPrecodingDisabled)
4369 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4373 dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0 = NULLP;
4374 DU_ALLOC(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0,\
4376 if(!dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0)
4378 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4381 if(ulDmrsCfgDb == NULLP)
4382 *(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0) = SCRAMBLING_ID;
4384 *(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0) = ulDmrsCfgDb->transPrecodDisabled.scramblingId0;
4386 dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID1 = NULLP;
4387 dmrsUlCfg->choice.setup->transformPrecodingEnabled = NULLP;
4391 /*******************************************************************
4393 * @brief Build PUSCH time domain allocation list
4397 * Function : BuildPuschTimeDomAllocList
4399 * Functionality: Build PUSCH time domain allocation list
4402 * struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList
4404 * @return ROK - success
4407 * ****************************************************************/
4408 uint8_t BuildPuschTimeDomAllocList(PuschCfg *puschCfgDb, struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList)
4412 PUSCH_TimeDomainResourceAllocation_t *timeDomAlloc;
4414 timeDomAllocList->present = PUSCH_Config__pusch_TimeDomainAllocationList_PR_setup;
4415 timeDomAllocList->choice.setup = NULLP;
4416 DU_ALLOC(timeDomAllocList->choice.setup, sizeof(struct PUSCH_TimeDomainResourceAllocationList));
4417 if(!timeDomAllocList->choice.setup)
4419 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4423 if(puschCfgDb == NULLP)
4426 elementCnt = puschCfgDb->numTimeDomRsrcAlloc;
4428 timeDomAllocList->choice.setup->list.count = elementCnt;
4429 timeDomAllocList->choice.setup->list.size = elementCnt * sizeof(PUSCH_TimeDomainResourceAllocation_t *);
4430 timeDomAllocList->choice.setup->list.array = NULLP;
4431 DU_ALLOC(timeDomAllocList->choice.setup->list.array, timeDomAllocList->choice.setup->list.size);
4432 if(!timeDomAllocList->choice.setup->list.array)
4434 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4438 for(idx = 0; idx < elementCnt; idx++)
4440 timeDomAllocList->choice.setup->list.array[idx] = NULLP;
4441 DU_ALLOC(timeDomAllocList->choice.setup->list.array[idx], sizeof(PUSCH_TimeDomainResourceAllocation_t));
4442 if(!timeDomAllocList->choice.setup->list.array[idx])
4444 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4449 for(idx = 0; idx < elementCnt; idx++)
4451 timeDomAlloc = timeDomAllocList->choice.setup->list.array[idx];
4452 DU_ALLOC(timeDomAlloc->k2, sizeof(long));
4453 if(!timeDomAlloc->k2)
4455 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4458 if(puschCfgDb == NULLP)
4461 *(timeDomAlloc->k2) = PUSCH_K2_CFG1;
4463 *(timeDomAlloc->k2) = PUSCH_K2_CFG2;
4465 timeDomAlloc->mappingType = PUSCH_MAPPING_TYPE_A;
4466 timeDomAlloc->startSymbolAndLength = calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
4470 *(timeDomAlloc->k2) = puschCfgDb->timeDomRsrcAllocList[idx].k2;
4471 timeDomAlloc->mappingType = puschCfgDb->timeDomRsrcAllocList[idx].mappingType;
4472 timeDomAlloc->startSymbolAndLength = puschCfgDb->timeDomRsrcAllocList[idx].startSymbolAndLength;
4479 /*******************************************************************
4481 * @brief Builds BWP UL dedicated PUSCH Config
4485 * Function : BuildBWPUlDedPuschCfg
4488 * Builds BWP UL dedicated PUSCH Config
4490 * @params[in] : PUSCH_Config_t *puschCfg
4492 * @return ROK - success
4495 * ****************************************************************/
4496 uint8_t BuildBWPUlDedPuschCfg(PuschCfg *puschCfgDb, PUSCH_Config_t *puschCfg)
4498 DmrsUlCfg *ulDmrsCfg = NULLP;
4501 ulDmrsCfg = &puschCfgDb->dmrsUlCfgForPuschMapTypeA;
4503 puschCfg->dataScramblingIdentityPUSCH = NULLP;
4504 DU_ALLOC(puschCfg->dataScramblingIdentityPUSCH, sizeof(long));
4505 if(!puschCfg->dataScramblingIdentityPUSCH)
4507 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4510 if(puschCfgDb == NULLP)
4511 *(puschCfg->dataScramblingIdentityPUSCH) = SCRAMBLING_ID;
4513 *(puschCfg->dataScramblingIdentityPUSCH) = puschCfgDb->dataScramblingId;
4515 puschCfg->txConfig = NULLP;
4516 puschCfg->dmrs_UplinkForPUSCH_MappingTypeA = NULLP;
4517 DU_ALLOC(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA, sizeof(struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA));
4518 if(!puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
4520 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4524 if(BuildDMRSULPuschMapTypeA(ulDmrsCfg, puschCfg->dmrs_UplinkForPUSCH_MappingTypeA) != ROK)
4529 puschCfg->dmrs_UplinkForPUSCH_MappingTypeB = NULLP;
4530 puschCfg->pusch_PowerControl = NULLP;
4531 puschCfg->frequencyHopping = NULLP;
4532 puschCfg->frequencyHoppingOffsetLists = NULLP;
4534 if(puschCfgDb == NULLP)
4535 puschCfg->resourceAllocation = RES_ALLOC_TYPE;
4537 puschCfg->resourceAllocation = puschCfgDb->resourceAllocType;
4539 puschCfg->pusch_TimeDomainAllocationList = NULLP;
4540 DU_ALLOC(puschCfg->pusch_TimeDomainAllocationList, sizeof(struct PUSCH_Config__pusch_TimeDomainAllocationList));
4541 if(!puschCfg->pusch_TimeDomainAllocationList)
4543 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4547 if(BuildPuschTimeDomAllocList(puschCfgDb, puschCfg->pusch_TimeDomainAllocationList) != ROK)
4552 puschCfg->pusch_AggregationFactor = NULLP;
4553 puschCfg->mcs_Table = NULLP;
4554 puschCfg->mcs_TableTransformPrecoder = NULLP;
4555 puschCfg->transformPrecoder = NULLP;
4556 DU_ALLOC(puschCfg->transformPrecoder, sizeof(long));
4557 if(!puschCfg->transformPrecoder)
4559 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4562 if(puschCfgDb == NULLP)
4563 *(puschCfg->transformPrecoder) = PUSCH_TRANSFORM_PRECODER;
4565 *(puschCfg->transformPrecoder) = puschCfgDb->transformPrecoder;
4567 puschCfg->codebookSubset = NULLP;
4568 puschCfg->maxRank = NULLP;
4569 puschCfg->rbg_Size = NULLP;
4570 puschCfg->uci_OnPUSCH = NULLP;
4571 puschCfg->tp_pi2BPSK = NULLP;
4576 /*******************************************************************
4578 * @brief Builds PUCCH resource set add/modify list
4582 * Function : BuildPucchRsrcSetAddModList
4585 * Builds PUCCH resource set add/modify list
4587 * @params[in] : PucchResrcSetCfg *rsrcSetCfgDb
4588 * struct PUCCH_Config__resourceSetToAddModList *rsrcSetAddModList
4590 * @return ROK - success
4593 * ****************************************************************/
4594 uint8_t BuildPucchRsrcSetAddModList(PucchResrcSetCfg *rsrcSetCfgDb, \
4595 struct PUCCH_Config__resourceSetToAddModList *resourceSetToAddModList)
4597 uint8_t elementCnt = 0, rsrcSetIdx = 0, rsrcIdx = 0;
4598 PUCCH_ResourceSet_t *rsrcSet = NULLP;
4600 if(rsrcSetCfgDb == NULLP)
4603 elementCnt = rsrcSetCfgDb->resrcSetToAddModListCount;
4605 resourceSetToAddModList->list.count = elementCnt;
4606 resourceSetToAddModList->list.size = elementCnt * sizeof(PUCCH_ResourceSet_t *);
4607 DU_ALLOC(resourceSetToAddModList->list.array, resourceSetToAddModList->list.size);
4608 if(resourceSetToAddModList->list.array == NULLP)
4610 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcSetAddModList");
4613 for(rsrcSetIdx=0; rsrcSetIdx < resourceSetToAddModList->list.count; rsrcSetIdx++)
4615 DU_ALLOC(resourceSetToAddModList->list.array[rsrcSetIdx], sizeof(PUCCH_ResourceSet_t));
4616 if(resourceSetToAddModList->list.array[rsrcSetIdx] == NULLP)
4618 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcSetAddModList");
4623 for(rsrcSetIdx=0; rsrcSetIdx < resourceSetToAddModList->list.count; rsrcSetIdx++)
4625 rsrcSet = resourceSetToAddModList->list.array[rsrcSetIdx];
4627 /* Resource set Id */
4628 if(rsrcSetCfgDb == NULLP)
4629 rsrcSet->pucch_ResourceSetId = 1;
4631 rsrcSet->pucch_ResourceSetId = rsrcSetCfgDb->resrcSetToAddModList[rsrcSetIdx].resrcSetId;
4633 /* Resource list of a resource set */
4634 if(rsrcSetCfgDb == NULLP)
4637 elementCnt = rsrcSetCfgDb->resrcSetToAddModList[rsrcSetIdx].resrcListCount;
4638 rsrcSet->resourceList.list.count = elementCnt;
4639 rsrcSet->resourceList.list.size = elementCnt * sizeof(PUCCH_ResourceId_t *);
4640 DU_ALLOC(rsrcSet->resourceList.list.array, rsrcSet->resourceList.list.size);
4641 if(rsrcSet->resourceList.list.array == NULLP)
4643 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcSetAddModList");
4647 for(rsrcIdx=0; rsrcIdx < rsrcSet->resourceList.list.count; rsrcIdx++)
4649 DU_ALLOC(rsrcSet->resourceList.list.array[rsrcIdx], sizeof(PUCCH_ResourceId_t));
4650 if(rsrcSet->resourceList.list.array[rsrcIdx] == NULLP)
4652 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcSetAddModList");
4656 for(rsrcIdx=0; rsrcIdx < rsrcSet->resourceList.list.count; rsrcIdx++)
4658 if(rsrcSetCfgDb == NULLP)
4659 *(rsrcSet->resourceList.list.array[rsrcIdx]) = 1;
4661 *(rsrcSet->resourceList.list.array[rsrcIdx]) = rsrcSetCfgDb->resrcSetToAddModList[rsrcSetIdx].resrcList[rsrcIdx];
4664 /* Max payload size (minus 1) in a Resource set */
4665 rsrcSet->maxPayloadMinus1 = NULLP;
4666 if(rsrcSetCfgDb && rsrcSetCfgDb->resrcSetToAddModList[rsrcSetIdx].maxPayLoadSize)
4668 DU_ALLOC(rsrcSet->maxPayloadMinus1, sizeof(long));
4669 if(rsrcSet->maxPayloadMinus1 == NULLP)
4671 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcSetAddModList");
4674 *(rsrcSet->maxPayloadMinus1) = rsrcSetCfgDb->resrcSetToAddModList[rsrcSetIdx].maxPayLoadSize;
4680 /*******************************************************************
4682 * @brief Builds PUCCH resource add/modify list
4686 * Function : BuildPucchRsrcAdddModList
4689 * Builds PUCCH resource add/modify list
4691 * @params[in] : PucchResrcCfg *rsrcSetCfgDb
4692 * struct PUCCH_Config__resourceSetToAddModList *rsrcSetAddModList
4694 * @return ROK - success
4697 * ****************************************************************/
4698 uint8_t BuildPucchRsrcAddModList(PucchResrcCfg *rsrcCfgDb, struct PUCCH_Config__resourceToAddModList *resourceToAddModList)
4700 uint8_t elementCnt = 0, rsrcIdx = 0;
4701 PUCCH_Resource_t *rsrc = NULLP;
4703 if(rsrcCfgDb == NULLP)
4706 elementCnt = rsrcCfgDb->resrcToAddModListCount;
4707 resourceToAddModList->list.count = elementCnt;
4708 resourceToAddModList->list.size = elementCnt * sizeof(PUCCH_Resource_t *);
4709 DU_ALLOC(resourceToAddModList->list.array, resourceToAddModList->list.size);
4710 if(resourceToAddModList->list.array == NULLP)
4712 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcAddModList");
4715 for(rsrcIdx=0; rsrcIdx < resourceToAddModList->list.count; rsrcIdx++)
4717 DU_ALLOC(resourceToAddModList->list.array[rsrcIdx], sizeof(PUCCH_Resource_t));
4718 if(resourceToAddModList->list.array[rsrcIdx] == NULLP)
4720 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcAddModList");
4725 for(rsrcIdx=0; rsrcIdx < resourceToAddModList->list.count; rsrcIdx++)
4727 rsrc = resourceToAddModList->list.array[rsrcIdx];
4729 if(rsrcCfgDb == NULLP)
4731 rsrc->pucch_ResourceId = 1;
4732 rsrc->startingPRB = 0;
4733 rsrc->format.present = PUCCH_Resource__format_PR_format1;
4734 DU_ALLOC(rsrc->format.choice.format1, sizeof(PUCCH_format1_t));
4735 if(rsrc->format.choice.format1 == NULLP)
4737 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcAddModList");
4740 rsrc->format.choice.format1->initialCyclicShift = 0;
4741 rsrc->format.choice.format1->nrofSymbols = 4;
4742 rsrc->format.choice.format1->startingSymbolIndex = 0;
4743 rsrc->format.choice.format1->timeDomainOCC = 0;
4747 rsrc->pucch_ResourceId = rsrcCfgDb->resrcToAddModList[rsrcIdx].resrcId;
4748 rsrc->startingPRB = rsrcCfgDb->resrcToAddModList[rsrcIdx].startPrb;
4749 if(rsrcCfgDb->resrcToAddModList[rsrcIdx].intraFreqHop)
4751 DU_ALLOC(rsrc->intraSlotFrequencyHopping, sizeof(long));
4752 if(rsrc->intraSlotFrequencyHopping == NULLP)
4754 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcAddModList");
4757 *(rsrc->intraSlotFrequencyHopping) = rsrcCfgDb->resrcToAddModList[rsrcIdx].intraFreqHop;
4760 rsrc->intraSlotFrequencyHopping = NULLP;
4762 if(rsrcCfgDb->resrcToAddModList[rsrcIdx].secondPrbHop)
4764 DU_ALLOC(rsrc->secondHopPRB, sizeof(PRB_Id_t));
4765 if(rsrc->secondHopPRB == NULLP)
4767 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcAddModList");
4770 *(rsrc->secondHopPRB) = rsrcCfgDb->resrcToAddModList[rsrcIdx].secondPrbHop;
4773 rsrc->secondHopPRB = NULLP;
4774 rsrc->format.present = covertPucchFormatIntEnumToRrcEnum(rsrcCfgDb->resrcToAddModList[rsrcIdx].pucchFormat);
4776 switch(rsrc->format.present)
4778 case PUCCH_Resource__format_PR_NOTHING:
4780 case PUCCH_Resource__format_PR_format0:
4782 DU_ALLOC(rsrc->format.choice.format0, sizeof(PUCCH_format0_t));
4783 if(rsrc->format.choice.format0 == NULLP)
4785 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcAddModList");
4788 rsrc->format.choice.format0->initialCyclicShift = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format0->initialCyclicShift;
4789 rsrc->format.choice.format0->nrofSymbols = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format0->numSymbols;
4790 rsrc->format.choice.format0->startingSymbolIndex = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format0->startSymbolIdx;
4794 case PUCCH_Resource__format_PR_format1:
4796 DU_ALLOC(rsrc->format.choice.format1, sizeof(PUCCH_format1_t));
4797 if(rsrc->format.choice.format1 == NULLP)
4799 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcAddModList");
4802 rsrc->format.choice.format1->initialCyclicShift = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format1->initialCyclicShift;
4803 rsrc->format.choice.format1->nrofSymbols = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format1->numSymbols;
4804 rsrc->format.choice.format1->startingSymbolIndex = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format1->startSymbolIdx;
4805 rsrc->format.choice.format1->timeDomainOCC = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format1->timeDomOCC;
4809 case PUCCH_Resource__format_PR_format2:
4811 DU_ALLOC(rsrc->format.choice.format2, sizeof(PUCCH_format2_t));
4812 if(rsrc->format.choice.format2 == NULLP)
4814 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcAddModList");
4817 rsrc->format.choice.format2->nrofPRBs = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format2->numPrbs;
4818 rsrc->format.choice.format2->nrofSymbols = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format2->numSymbols;
4819 rsrc->format.choice.format2->startingSymbolIndex = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format2->startSymbolIdx;
4823 case PUCCH_Resource__format_PR_format3:
4825 DU_ALLOC(rsrc->format.choice.format3, sizeof(PUCCH_format3_t));
4826 if(rsrc->format.choice.format3 == NULLP)
4828 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcAddModList");
4831 rsrc->format.choice.format3->nrofPRBs = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format3->numPrbs;
4832 rsrc->format.choice.format3->nrofSymbols = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format3->numSymbols;
4833 rsrc->format.choice.format3->startingSymbolIndex = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format3->startSymbolIdx;
4837 case PUCCH_Resource__format_PR_format4:
4839 DU_ALLOC(rsrc->format.choice.format4, sizeof(PUCCH_format4_t));
4840 if(rsrc->format.choice.format4 == NULLP)
4842 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcAddModList");
4845 rsrc->format.choice.format4->nrofSymbols = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format4->numSymbols;
4846 rsrc->format.choice.format4->occ_Length = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format4->occLen;
4847 rsrc->format.choice.format4->occ_Index = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format4->occIdx;
4848 rsrc->format.choice.format4->startingSymbolIndex = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format4->startSymbolIdx;
4857 /*******************************************************************
4859 * @brief Builds PUCCH format config
4863 * Function : BuildPucchFormat
4865 * Functionality: Builds PUCCH format config
4867 * @params[in] : PucchFormatCfg *formatDb
4868 * PUCCH_FormatConfig_t *format
4870 * @return ROK - success
4873 * ****************************************************************/
4874 uint8_t BuildPucchFormat(PucchFormatCfg *formatDb, PUCCH_FormatConfig_t *format)
4876 /* Inter Slot Fequency hopping */
4877 format->interslotFrequencyHopping = NULLP;
4878 if((formatDb != NULLP) && (formatDb->interSlotFreqHop == true))
4880 DU_ALLOC(format->interslotFrequencyHopping, sizeof(long));
4881 if(format->interslotFrequencyHopping)
4883 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchFormat");
4886 *(format->interslotFrequencyHopping) = PUCCH_FormatConfig__interslotFrequencyHopping_enabled;
4889 /* Additional DMRS */
4890 format->additionalDMRS = NULLP;
4891 if((formatDb != NULLP) && (formatDb->addDmrs == true))
4893 DU_ALLOC(format->additionalDMRS, sizeof(long));
4894 if(format->additionalDMRS)
4896 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchFormat");
4899 *(format->additionalDMRS) = PUCCH_FormatConfig__additionalDMRS_true;
4902 /* Maximum code rate */
4903 format->maxCodeRate = NULLP;
4904 if((formatDb != NULLP) && (formatDb->maxCodeRate != 0))
4906 DU_ALLOC(format->maxCodeRate, sizeof(long));
4907 if(format->maxCodeRate)
4909 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchFormat");
4912 *(format->maxCodeRate) = formatDb->maxCodeRate;
4915 /* Number of slots */
4916 format->nrofSlots = NULLP;
4917 if((formatDb == NULLP) || ((formatDb != NULLP) && (formatDb->numSlots != 0)))
4919 DU_ALLOC(format->nrofSlots, sizeof(long));
4920 if(format->nrofSlots == NULLP)
4922 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchFormat");
4925 if(formatDb == NULLP)
4926 *(format->nrofSlots) = PUCCH_FormatConfig__nrofSlots_n4;
4928 *(format->nrofSlots) = formatDb->numSlots;
4932 format->pi2BPSK = NULLP;
4933 if((formatDb != NULLP) && (formatDb->pi2BPSK == true))
4935 DU_ALLOC(format->pi2BPSK, sizeof(long));
4938 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchFormat");
4941 *(format->pi2BPSK) = PUCCH_FormatConfig__pi2BPSK_enabled;
4944 /* Simultaneous HARQ ACK and CSI */
4945 format->simultaneousHARQ_ACK_CSI = NULLP;
4946 if((formatDb != NULLP) && (formatDb->harqAckCSI == true))
4948 DU_ALLOC(format->simultaneousHARQ_ACK_CSI, sizeof(long));
4949 if(format->simultaneousHARQ_ACK_CSI)
4951 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchFormat");
4954 *(format->simultaneousHARQ_ACK_CSI) = PUCCH_FormatConfig__simultaneousHARQ_ACK_CSI_true;
4961 /*******************************************************************
4963 * @brief Builds PUCCH scheduling request list
4967 * Function : BuildPucchSchReqAddModList
4970 * Builds PUCCH scheduling request list
4972 * @params[in] : PucchSchedReqCfg *schReqDb
4973 * struct PUCCH_Config__schedulingRequestResourceToAddModList *schReqRsrcToAddModList
4975 * @return ROK - success
4978 * ****************************************************************/
4979 uint8_t BuildPucchSchReqAddModList(PucchSchedReqCfg *schReqDb, \
4980 struct PUCCH_Config__schedulingRequestResourceToAddModList *schReqRsrcToAddModList)
4982 uint8_t elementCnt = 0, schReqIdx = 0;
4983 SchedulingRequestResourceConfig_t *schReqRsrc;
4985 elementCnt = schReqDb->schedAddModListCount;
4986 schReqRsrcToAddModList->list.count = elementCnt;
4987 schReqRsrcToAddModList->list.size = elementCnt *sizeof(struct SchedulingRequestResourceConfig *);
4989 schReqRsrcToAddModList->list.array = NULLP;
4990 DU_ALLOC(schReqRsrcToAddModList->list.array, schReqRsrcToAddModList->list.size);
4991 if(schReqRsrcToAddModList->list.array == NULLP)
4993 DU_LOG("\nERROR --> DU APP: Memory allocation failed in BuildPucchSchReqAddModList");
4997 for(schReqIdx = 0; schReqIdx < schReqRsrcToAddModList->list.count; schReqIdx++)
4999 DU_ALLOC(schReqRsrcToAddModList->list.array[schReqIdx], schReqRsrcToAddModList->list.size);
5000 if(schReqRsrcToAddModList->list.array[schReqIdx] == NULLP)
5002 DU_LOG("\nERROR --> DU APP: Memory allocation failed in BuildPucchSchReqAddModList");
5007 for(schReqIdx = 0; schReqIdx < schReqRsrcToAddModList->list.count; schReqIdx++)
5009 schReqRsrc = schReqRsrcToAddModList->list.array[schReqIdx];
5010 schReqRsrc->schedulingRequestResourceId = schReqDb->schedAddModList[schReqIdx].resrcId;
5011 schReqRsrc->schedulingRequestID = schReqDb->schedAddModList[schReqIdx].requestId;
5013 if(schReqDb->schedAddModList[schReqIdx].periodicity)
5015 schReqRsrc->periodicityAndOffset = NULLP;
5016 DU_ALLOC(schReqRsrc->periodicityAndOffset, sizeof(struct SchedulingRequestResourceConfig__periodicityAndOffset));
5017 if(schReqRsrc->periodicityAndOffset == NULLP)
5019 DU_LOG("\nERROR --> DU APP: Memory allocation failed in BuildPucchSchReqAddModList");
5023 schReqRsrc->periodicityAndOffset->present = schReqDb->schedAddModList[schReqIdx].periodicity;
5024 switch(schReqRsrc->periodicityAndOffset->present)
5026 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_NOTHING:
5028 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sym2:
5029 schReqRsrc->periodicityAndOffset->choice.sym2 = schReqDb->schedAddModList[schReqIdx].offset;
5031 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sym6or7:
5032 schReqRsrc->periodicityAndOffset->choice.sym6or7 = schReqDb->schedAddModList[schReqIdx].offset;
5034 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl1:
5035 schReqRsrc->periodicityAndOffset->choice.sl1 = schReqDb->schedAddModList[schReqIdx].offset;
5037 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl2:
5038 schReqRsrc->periodicityAndOffset->choice.sl2 = schReqDb->schedAddModList[schReqIdx].offset;
5040 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl4:
5041 schReqRsrc->periodicityAndOffset->choice.sl4 = schReqDb->schedAddModList[schReqIdx].offset;
5043 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl5:
5044 schReqRsrc->periodicityAndOffset->choice.sl5 = schReqDb->schedAddModList[schReqIdx].offset;
5046 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl8:
5047 schReqRsrc->periodicityAndOffset->choice.sl8 = schReqDb->schedAddModList[schReqIdx].offset;
5049 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl10:
5050 schReqRsrc->periodicityAndOffset->choice.sl10 = schReqDb->schedAddModList[schReqIdx].offset;
5052 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl16:
5053 schReqRsrc->periodicityAndOffset->choice.sl16 = schReqDb->schedAddModList[schReqIdx].offset;
5055 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl20:
5056 schReqRsrc->periodicityAndOffset->choice.sl20 = schReqDb->schedAddModList[schReqIdx].offset;
5058 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl40:
5059 schReqRsrc->periodicityAndOffset->choice.sl40 = schReqDb->schedAddModList[schReqIdx].offset;
5061 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl80:
5062 schReqRsrc->periodicityAndOffset->choice.sl80 = schReqDb->schedAddModList[schReqIdx].offset;
5064 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl160:
5065 schReqRsrc->periodicityAndOffset->choice.sl160 = schReqDb->schedAddModList[schReqIdx].offset;
5067 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl320:
5068 schReqRsrc->periodicityAndOffset->choice.sl320 = schReqDb->schedAddModList[schReqIdx].offset;
5070 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl640:
5071 schReqRsrc->periodicityAndOffset->choice.sl640 = schReqDb->schedAddModList[schReqIdx].offset;
5076 if(schReqDb->schedAddModList[schReqIdx].resrc)
5078 schReqRsrc->resource = NULLP;
5079 DU_ALLOC(schReqRsrc->resource, sizeof(PUCCH_ResourceId_t));
5080 if(schReqRsrc->resource == NULLP)
5082 DU_LOG("\nERROR --> DU APP: Memory allocation failed in BuildPucchSchReqAddModList");
5085 *(schReqRsrc->resource) = schReqDb->schedAddModList[schReqIdx].resrc;
5092 /*******************************************************************
5094 * @brief Builds PUCCH multi csi resource list
5098 * Function : BuildPucchMultiCsiRsrcList
5101 * Builds PUCCH multi csi resource list
5103 * @params[in] : PucchMultiCsiCfg *multiCsiDb
5104 * struct PUCCH_Config__multi_CSI_PUCCH_ResourceList *multiCsiRsrcList
5106 * @return ROK - success
5109 * ****************************************************************/
5110 uint8_t BuildPucchMultiCsiRsrcList(PucchMultiCsiCfg *multiCsiDb, struct PUCCH_Config__multi_CSI_PUCCH_ResourceList *multiCsiRsrcList)
5112 uint8_t elementCnt = 0, rsrcIdx = 0;
5114 elementCnt = multiCsiDb->multiCsiResrcListCount;
5115 multiCsiRsrcList->list.count = elementCnt;
5116 multiCsiRsrcList->list.size = elementCnt * sizeof(PUCCH_ResourceId_t *);
5117 multiCsiRsrcList->list.array = NULLP;
5118 DU_ALLOC(multiCsiRsrcList->list.array, multiCsiRsrcList->list.size);
5119 if(multiCsiRsrcList->list.array == NULLP)
5121 DU_LOG("\nERROR --> DU APP: Memory allocation failed in BuildPucchMultiCsiRsrcList");
5125 for(rsrcIdx = 0; rsrcIdx<multiCsiRsrcList->list.count; rsrcIdx++)
5127 DU_ALLOC(multiCsiRsrcList->list.array[rsrcIdx], sizeof(PUCCH_ResourceId_t));
5128 if(multiCsiRsrcList->list.array[rsrcIdx] == NULLP)
5130 DU_LOG("\nERROR --> DU APP: Memory allocation failed in BuildPucchMultiCsiRsrcList");
5135 for(rsrcIdx = 0; rsrcIdx<multiCsiRsrcList->list.count; rsrcIdx++)
5137 *(multiCsiRsrcList->list.array[rsrcIdx]) = multiCsiDb->multiCsiResrcList[rsrcIdx];
5142 /*******************************************************************
5144 * @brief Builds DL data -to- Ul Ack list
5148 * Function : BuildDlDataToUlAckList
5150 * Functionality: Builds DL data -to- Ul Ack list
5152 * @params[in] : PucchDlDataToUlAck *dlDataToUlAckDb
5153 * struct PUCCH_Config__dl_DataToUL_ACK * dlDataToUlACKList
5155 * @return ROK - success
5158 * ****************************************************************/
5159 uint8_t BuildDlDataToUlAckList(PucchDlDataToUlAck *dlDataToUlAckDb, struct PUCCH_Config__dl_DataToUL_ACK * dlDataToUlACKList)
5161 uint8_t elementCnt = 0, arrIdx = 0;
5163 if(dlDataToUlAckDb == NULLP)
5166 elementCnt = dlDataToUlAckDb->dlDataToUlAckListCount;
5168 dlDataToUlACKList->list.count = elementCnt;
5169 dlDataToUlACKList->list.size = elementCnt * sizeof(long *);
5170 DU_ALLOC(dlDataToUlACKList->list.array, dlDataToUlACKList->list.size);
5171 if(dlDataToUlACKList->list.array == NULLP)
5173 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDlDataToUlAckList");
5177 for(arrIdx = 0; arrIdx < dlDataToUlACKList->list.count; arrIdx++)
5179 DU_ALLOC(dlDataToUlACKList->list.array[arrIdx], sizeof(long));
5180 if(dlDataToUlACKList->list.array[arrIdx] == NULLP)
5182 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDlDataToUlAckList");
5187 if(dlDataToUlAckDb == NULLP)
5190 *(dlDataToUlACKList->list.array[arrIdx++]) = 1;
5191 *(dlDataToUlACKList->list.array[arrIdx]) = 2;
5195 for(arrIdx = 0; arrIdx < dlDataToUlACKList->list.count; arrIdx++)
5197 *(dlDataToUlACKList->list.array[arrIdx]) = dlDataToUlAckDb->dlDataToUlAckList[arrIdx];
5203 /*******************************************************************
5205 * @brief Builds BWP UL dedicated PUCCH Config
5209 * Function : BuildBWPUlDedPucchCfg
5212 * Builds BWP UL dedicated PUCCH Config
5214 * @params[in] : PUCCH_Config_t *pucchCfg
5216 * @return ROK - success
5219 * ****************************************************************/
5220 uint8_t BuildBWPUlDedPucchCfg(PucchCfg *pucchCfgDb, PUCCH_Config_t *pucchCfg)
5222 PucchResrcSetCfg *rsrcSetCfgDb = NULLP;
5223 PucchResrcCfg *rsrcCfgDb = NULLP;
5224 PucchFormatCfg *format1Db = NULLP;
5225 PucchFormatCfg *format2Db = NULLP;
5226 PucchFormatCfg *format3Db = NULLP;
5227 PucchFormatCfg *format4Db = NULLP;
5228 PucchSchedReqCfg *schReqDb = NULLP;
5229 PucchMultiCsiCfg *multiCsiDb = NULLP;
5230 PucchDlDataToUlAck *dlDataToUlAckDb = NULLP;
5234 rsrcSetCfgDb = pucchCfgDb->resrcSet;
5235 rsrcCfgDb = pucchCfgDb->resrc;
5236 format1Db = pucchCfgDb->format1;
5237 format2Db = pucchCfgDb->format2;
5238 format3Db = pucchCfgDb->format3;
5239 format4Db = pucchCfgDb->format4;
5240 schReqDb = pucchCfgDb->schedReq;
5241 multiCsiDb = pucchCfgDb->multiCsiCfg;
5242 dlDataToUlAckDb = pucchCfgDb->dlDataToUlAck;
5246 DU_ALLOC(pucchCfg->resourceSetToAddModList, sizeof(struct PUCCH_Config__resourceSetToAddModList));
5247 if(pucchCfg->resourceSetToAddModList == NULL)
5249 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5253 if(BuildPucchRsrcSetAddModList(rsrcSetCfgDb, pucchCfg->resourceSetToAddModList) != ROK)
5255 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5259 /* PUCCH RESOURCE */
5260 DU_ALLOC(pucchCfg->resourceToAddModList, sizeof(struct PUCCH_Config__resourceToAddModList));
5261 if(pucchCfg->resourceToAddModList == NULLP)
5263 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5267 if(BuildPucchRsrcAddModList(rsrcCfgDb, pucchCfg->resourceToAddModList) != ROK)
5269 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5273 /* PUCCH Format 1 */
5274 DU_ALLOC(pucchCfg->format1, sizeof(struct PUCCH_Config__format1));
5275 if(pucchCfg->format1 == NULLP)
5277 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5281 pucchCfg->format1->present = PUCCH_Config__format1_PR_setup;
5282 DU_ALLOC(pucchCfg->format1->choice.setup, sizeof(PUCCH_FormatConfig_t));
5283 if(pucchCfg->format1->choice.setup == NULLP)
5285 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5289 if(BuildPucchFormat(format1Db, pucchCfg->format1->choice.setup) != ROK)
5291 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5295 /* PUCCH Format 2 */
5298 DU_ALLOC(pucchCfg->format2, sizeof(struct PUCCH_Config__format2));
5299 if(pucchCfg->format2 == NULLP)
5301 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5305 pucchCfg->format2->present = PUCCH_Config__format2_PR_setup;
5306 DU_ALLOC(pucchCfg->format2->choice.setup, sizeof(PUCCH_FormatConfig_t));
5307 if(pucchCfg->format2->choice.setup == NULLP)
5309 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5313 if(BuildPucchFormat(format2Db, pucchCfg->format2->choice.setup) != ROK)
5315 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5320 /* PUCCH Format 3 */
5323 DU_ALLOC(pucchCfg->format3, sizeof(struct PUCCH_Config__format3));
5324 if(pucchCfg->format3 == NULLP)
5326 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5330 pucchCfg->format3->present = PUCCH_Config__format3_PR_setup;
5331 DU_ALLOC(pucchCfg->format3->choice.setup, sizeof(PUCCH_FormatConfig_t));
5332 if(pucchCfg->format3->choice.setup == NULLP)
5334 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5338 if(BuildPucchFormat(format3Db, pucchCfg->format3->choice.setup) != ROK)
5340 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5345 /* PUCCH Format 4 */
5348 DU_ALLOC(pucchCfg->format4, sizeof(struct PUCCH_Config__format4));
5349 if(pucchCfg->format4 == NULLP)
5351 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5355 pucchCfg->format4->present = PUCCH_Config__format4_PR_setup;
5356 DU_ALLOC(pucchCfg->format4->choice.setup, sizeof(PUCCH_FormatConfig_t));
5357 if(pucchCfg->format4->choice.setup == NULLP)
5359 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5363 if(BuildPucchFormat(format4Db, pucchCfg->format4->choice.setup) != ROK)
5365 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5370 /* Scheduling Request */
5371 if(schReqDb && (schReqDb->schedAddModListCount != 0))
5373 pucchCfg->schedulingRequestResourceToAddModList = NULLP;
5374 DU_ALLOC(pucchCfg->schedulingRequestResourceToAddModList, sizeof(struct PUCCH_Config__schedulingRequestResourceToAddModList));
5375 if(pucchCfg->schedulingRequestResourceToAddModList == NULLP)
5377 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5381 if(BuildPucchSchReqAddModList(schReqDb, pucchCfg->schedulingRequestResourceToAddModList) != ROK)
5383 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5389 if(multiCsiDb && (multiCsiDb->multiCsiResrcListCount != 0))
5391 pucchCfg->multi_CSI_PUCCH_ResourceList = NULLP;
5392 DU_ALLOC(pucchCfg->multi_CSI_PUCCH_ResourceList, sizeof(struct PUCCH_Config__multi_CSI_PUCCH_ResourceList));
5393 if(pucchCfg->multi_CSI_PUCCH_ResourceList == NULLP)
5395 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5399 if(BuildPucchMultiCsiRsrcList(multiCsiDb, pucchCfg->multi_CSI_PUCCH_ResourceList) != ROK)
5401 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5406 /* DL DATA TO UL ACK */
5407 DU_ALLOC(pucchCfg->dl_DataToUL_ACK, sizeof(struct PUCCH_Config__dl_DataToUL_ACK));
5408 if(pucchCfg->dl_DataToUL_ACK == NULLP)
5410 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5414 if(BuildDlDataToUlAckList(dlDataToUlAckDb, pucchCfg->dl_DataToUL_ACK) != ROK)
5416 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5420 /* TODO : spatial relation info add/mod list and power control*/
5425 /*******************************************************************
5427 * @brief Fills SRS resource to add/modify list
5431 * Function : BuildSrsRsrcAddModList
5433 * Functionality: Fills SRS resource to add/modify list
5436 * @return ROK - success
5439 * ****************************************************************/
5440 uint8_t BuildSrsRsrcAddModList(struct SRS_Config__srs_ResourceToAddModList *resourceList)
5446 resourceList->list.count = elementCnt;
5447 resourceList->list.size = elementCnt * sizeof(SRS_Resource_t *);
5448 resourceList->list.array = NULLP;
5449 DU_ALLOC(resourceList->list.array, resourceList->list.size);
5450 if(!resourceList->list.array)
5452 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
5456 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
5458 DU_ALLOC(resourceList->list.array[rsrcIdx], sizeof(SRS_Resource_t));
5459 if(!resourceList->list.array[rsrcIdx])
5461 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
5467 resourceList->list.array[rsrcIdx]->srs_ResourceId = SRS_RSRC_ID;
5468 resourceList->list.array[rsrcIdx]->nrofSRS_Ports = SRS_Resource__nrofSRS_Ports_port1;
5469 resourceList->list.array[rsrcIdx]->transmissionComb.present = SRS_Resource__transmissionComb_PR_n2;
5471 resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2 = NULLP;
5472 DU_ALLOC(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2, \
5473 sizeof(struct SRS_Resource__transmissionComb__n2));
5474 if(!resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2)
5476 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
5479 resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2->combOffset_n2\
5480 = SRS_COMB_OFFSET_N2;
5481 resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2->cyclicShift_n2\
5482 = SRS_CYCLIC_SHIFT_N2;
5484 resourceList->list.array[rsrcIdx]->resourceMapping.startPosition = \
5486 resourceList->list.array[rsrcIdx]->resourceMapping.nrofSymbols = \
5487 SRS_Resource__resourceMapping__nrofSymbols_n1;
5488 resourceList->list.array[rsrcIdx]->resourceMapping.repetitionFactor = \
5489 SRS_Resource__resourceMapping__repetitionFactor_n1;
5491 resourceList->list.array[rsrcIdx]->freqDomainPosition = SRS_FREQ_DOM_POS;
5492 resourceList->list.array[rsrcIdx]->freqDomainShift = SRS_FREQ_DOM_SHIFT;
5493 resourceList->list.array[rsrcIdx]->freqHopping.c_SRS = C_SRS;
5494 resourceList->list.array[rsrcIdx]->freqHopping.b_SRS = B_SRS;
5495 resourceList->list.array[rsrcIdx]->freqHopping.b_hop = B_HOP;
5496 resourceList->list.array[rsrcIdx]->groupOrSequenceHopping = \
5497 SRS_Resource__groupOrSequenceHopping_neither;
5499 /* Setting resource type to aperiodic for intergration purposes */
5500 resourceList->list.array[rsrcIdx]->resourceType.present = \
5501 SRS_Resource__resourceType_PR_aperiodic;
5502 resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic = NULLP;
5503 DU_ALLOC(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic,
5504 sizeof(struct SRS_Resource__resourceType__aperiodic));
5505 if(!resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic)
5507 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
5511 resourceList->list.array[rsrcIdx]->sequenceId = SRS_SEQ_ID;
5516 /*******************************************************************
5518 * @brief Build SRS resource set Add/mod list
5522 * Function : BuildSrsRsrcSetAddModList
5524 * Functionality: Build SRS resource set Add/mod list
5527 * @return ROK - success
5530 * ****************************************************************/
5531 uint8_t BuildSrsRsrcSetAddModList
5533 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList
5539 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList;
5542 rsrcSetList->list.count = elementCnt;
5543 rsrcSetList->list.size = elementCnt * sizeof(SRS_ResourceSet_t *);
5544 rsrcSetList->list.array = NULLP;
5545 DU_ALLOC(rsrcSetList->list.array, rsrcSetList->list.size);
5546 if(!rsrcSetList->list.array)
5548 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
5552 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
5554 DU_ALLOC(rsrcSetList->list.array[rSetIdx], sizeof(SRS_ResourceSet_t));
5555 if(!rsrcSetList->list.array[rSetIdx])
5557 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
5563 rsrcSetList->list.array[rSetIdx]->srs_ResourceSetId = SRS_RSET_ID;
5565 /* Fill Resource Id list in resource set */
5566 rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList = NULLP;
5567 DU_ALLOC(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList,\
5568 sizeof(struct SRS_ResourceSet__srs_ResourceIdList));
5569 if(!rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
5571 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
5576 rsrcIdList = rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
5577 rsrcIdList->list.count = elementCnt;
5578 rsrcIdList->list.size = elementCnt * sizeof(SRS_ResourceId_t *);
5579 rsrcIdList->list.array = NULLP;
5580 DU_ALLOC(rsrcIdList->list.array, rsrcIdList->list.size);
5581 if(!rsrcIdList->list.array)
5583 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
5587 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count; rsrcIdx++)
5589 DU_ALLOC(rsrcIdList->list.array[rsrcIdx], sizeof(SRS_ResourceId_t));
5590 if(!rsrcIdList->list.array[rsrcIdx])
5592 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
5598 *rsrcIdList->list.array[rsrcIdx] = SRS_RSRC_ID;
5600 /* Fill resource type */
5601 rsrcSetList->list.array[rSetIdx]->resourceType.present = \
5602 SRS_ResourceSet__resourceType_PR_aperiodic;
5604 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic = NULLP;
5605 DU_ALLOC(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic, \
5606 sizeof(struct SRS_ResourceSet__resourceType__aperiodic));
5607 if(!rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic)
5609 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
5612 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic->aperiodicSRS_ResourceTrigger \
5613 = APERIODIC_SRS_RESRC_TRIGGER;
5615 /* TODO : Fill values for below IEs as expected by Viavi */
5616 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic->csi_RS = NULLP;
5617 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic->slotOffset = NULLP;
5620 rsrcSetList->list.array[rSetIdx]->usage = SRS_ResourceSet__usage_codebook;
5621 rsrcSetList->list.array[rSetIdx]->alpha = NULLP;
5622 rsrcSetList->list.array[rSetIdx]->p0 = NULLP;
5623 rsrcSetList->list.array[rSetIdx]->pathlossReferenceRS = NULLP;
5624 rsrcSetList->list.array[rSetIdx]->srs_PowerControlAdjustmentStates = NULLP;
5629 /*******************************************************************
5631 * @brief Builds BWP UL dedicated SRS Config
5635 * Function : BuildBWPUlDedSrsCfg
5637 * Functionality: Builds BWP UL dedicated SRS Config
5639 * @params[in] SRS Config
5640 * @return ROK - success
5643 * ****************************************************************/
5644 uint8_t BuildBWPUlDedSrsCfg(SRS_Config_t *srsCfg)
5646 srsCfg->srs_ResourceSetToReleaseList = NULLP;
5647 srsCfg->srs_ResourceSetToAddModList = NULLP;
5648 DU_ALLOC(srsCfg->srs_ResourceSetToAddModList, \
5649 sizeof(struct SRS_Config__srs_ResourceSetToAddModList));
5650 if(!srsCfg->srs_ResourceSetToAddModList)
5652 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedSrsCfg");
5655 if(BuildSrsRsrcSetAddModList(srsCfg->srs_ResourceSetToAddModList) != ROK)
5660 srsCfg->srs_ResourceToReleaseList = NULLP;
5662 /* Resource to Add/Modify list */
5663 srsCfg->srs_ResourceToAddModList = NULLP;
5664 DU_ALLOC(srsCfg->srs_ResourceToAddModList, \
5665 sizeof(struct SRS_Config__srs_ResourceToAddModList));
5666 if(!srsCfg->srs_ResourceToAddModList)
5668 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedSrsCfg");
5672 if(BuildSrsRsrcAddModList(srsCfg->srs_ResourceToAddModList) != ROK)
5676 srsCfg->tpc_Accumulation = NULLP;
5683 /*******************************************************************
5685 * @brief Builds Pusch Serving cell Config
5689 * Function : BuildPuschSrvCellCfg
5691 * Functionality: Builds Pusch Serving cell Config
5693 * @params[in] struct UplinkConfig__pusch_ServingCellConfig *puschCfg
5695 * @return ROK - success
5698 * ****************************************************************/
5699 uint8_t BuildPuschSrvCellCfg(struct UplinkConfig__pusch_ServingCellConfig *puschCfg)
5701 puschCfg->present = UplinkConfig__pusch_ServingCellConfig_PR_setup;
5702 puschCfg->choice.setup = NULLP;
5703 DU_ALLOC(puschCfg->choice.setup, sizeof(struct PUSCH_ServingCellConfig));
5704 if(!puschCfg->choice.setup)
5706 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
5710 puschCfg->choice.setup->codeBlockGroupTransmission = NULLP;
5711 puschCfg->choice.setup->rateMatching = NULLP;
5712 puschCfg->choice.setup->xOverhead = NULLP;
5713 puschCfg->choice.setup->ext1 = NULLP;
5715 DU_ALLOC(puschCfg->choice.setup->ext1, sizeof(struct PUSCH_ServingCellConfig__ext1));
5716 if(!puschCfg->choice.setup->ext1)
5718 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
5722 puschCfg->choice.setup->ext1->maxMIMO_Layers = NULLP;
5723 DU_ALLOC(puschCfg->choice.setup->ext1->maxMIMO_Layers, sizeof(long));
5724 if(!puschCfg->choice.setup->ext1->maxMIMO_Layers)
5726 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
5729 *(puschCfg->choice.setup->ext1->maxMIMO_Layers) = PUSCH_MAX_MIMO_LAYERS;
5731 puschCfg->choice.setup->ext1->processingType2Enabled= NULLP;
5732 DU_ALLOC(puschCfg->choice.setup->ext1->processingType2Enabled,sizeof(BOOLEAN_t));
5733 if(!puschCfg->choice.setup->ext1->processingType2Enabled)
5735 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
5738 *(puschCfg->choice.setup->ext1->processingType2Enabled) = PUSCH_PROCESS_TYPE2_ENABLED;
5743 /*******************************************************************
5745 * @brief Builds inital UL BWP
5749 * Function : BuildInitialUlBWP
5751 * Functionality: Builds initial UL BWP
5753 * @params[in] BWP_UplinkDedicated_t *ulBwp
5754 * @return ROK - success
5757 * ****************************************************************/
5758 uint8_t BuildInitialUlBWP(InitialUlBwp *initUlBwp, BWP_UplinkDedicated_t *ulBwp)
5760 PucchCfg *pucchCfg = NULLP;
5761 PuschCfg *puschCfg = NULLP;
5765 if(initUlBwp->pucchPresent)
5766 pucchCfg = &initUlBwp->pucchCfg;
5767 if(initUlBwp->puschPresent)
5768 puschCfg = &initUlBwp->puschCfg;
5771 ulBwp->pucch_Config = NULLP;
5772 DU_ALLOC(ulBwp->pucch_Config, sizeof(struct BWP_UplinkDedicated__pucch_Config));
5773 if(!ulBwp->pucch_Config)
5775 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
5779 ulBwp->pucch_Config->present = BWP_UplinkDedicated__pucch_Config_PR_setup;
5780 ulBwp->pucch_Config->choice.setup = NULLP;
5781 DU_ALLOC(ulBwp->pucch_Config->choice.setup, sizeof(PUCCH_Config_t));
5782 if(!ulBwp->pucch_Config->choice.setup)
5784 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
5788 if(BuildBWPUlDedPucchCfg(pucchCfg, ulBwp->pucch_Config->choice.setup) != ROK)
5793 /* Fill BWP UL dedicated PUSCH config */
5794 ulBwp->pusch_Config = NULLP;
5795 DU_ALLOC(ulBwp->pusch_Config, sizeof(struct BWP_UplinkDedicated__pusch_Config));
5796 if(!ulBwp->pusch_Config)
5798 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
5802 ulBwp->pusch_Config->present = BWP_UplinkDedicated__pusch_Config_PR_setup;
5803 ulBwp->pusch_Config->choice.setup = NULLP;
5804 DU_ALLOC(ulBwp->pusch_Config->choice.setup, sizeof(PUSCH_Config_t));
5805 if(!ulBwp->pusch_Config->choice.setup)
5807 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
5811 if(BuildBWPUlDedPuschCfg(puschCfg, ulBwp->pusch_Config->choice.setup) != ROK)
5816 ulBwp->configuredGrantConfig = NULLP;
5818 /* Fill BPW UL dedicated SRS config */
5819 ulBwp->srs_Config = NULLP;
5820 DU_ALLOC(ulBwp->srs_Config, sizeof(struct BWP_UplinkDedicated__srs_Config));
5821 if(!ulBwp->srs_Config)
5823 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
5827 ulBwp->srs_Config->present = BWP_UplinkDedicated__srs_Config_PR_setup;
5828 ulBwp->srs_Config->choice.setup = NULLP;
5829 DU_ALLOC(ulBwp->srs_Config->choice.setup, sizeof(SRS_Config_t));
5830 if(!ulBwp->srs_Config->choice.setup)
5832 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
5836 if(BuildBWPUlDedSrsCfg(ulBwp->srs_Config->choice.setup) != ROK)
5841 ulBwp->beamFailureRecoveryConfig = NULLP;
5846 /*******************************************************************
5848 * @brief Builds UL config
5851 * Function : BuildUlCfg
5853 * Functionality: Builds UL config in spCellCfgDed
5855 * @params[in] UplinkConfig_t *ulCfg
5857 * @return ROK - success
5860 * ****************************************************************/
5861 uint8_t BuildUlCfg(ServCellRecfgInfo *servCellRecfg, UplinkConfig_t *ulCfg)
5863 InitialUlBwp *initUlBwp = NULLP;
5867 initUlBwp = &servCellRecfg->initUlBwp;
5870 ulCfg->initialUplinkBWP = NULLP;
5871 DU_ALLOC(ulCfg->initialUplinkBWP, sizeof(BWP_UplinkDedicated_t));
5872 if(!ulCfg->initialUplinkBWP)
5874 DU_LOG("\nERROR --> F1AP : Memory Allocation failed in BuildUlCfg");
5878 if(BuildInitialUlBWP(initUlBwp, ulCfg->initialUplinkBWP) != ROK)
5883 ulCfg->uplinkBWP_ToReleaseList = NULLP;
5884 ulCfg->uplinkBWP_ToAddModList = NULLP;
5885 ulCfg->firstActiveUplinkBWP_Id = NULLP;
5886 DU_ALLOC(ulCfg->firstActiveUplinkBWP_Id, sizeof(BWP_Id_t));
5887 if(!ulCfg->firstActiveUplinkBWP_Id)
5889 DU_LOG("\nERROR --> F1AP : Memory Allocation failed in BuildUlCfg");
5892 if(servCellRecfg == NULLP)
5893 *(ulCfg->firstActiveUplinkBWP_Id) = ACTIVE_UL_BWP_ID;
5895 *(ulCfg->firstActiveUplinkBWP_Id) = servCellRecfg->firstActvUlBwpId;
5897 ulCfg->pusch_ServingCellConfig = NULLP;
5898 DU_ALLOC(ulCfg->pusch_ServingCellConfig, sizeof(struct UplinkConfig__pusch_ServingCellConfig));
5899 if(!ulCfg->pusch_ServingCellConfig)
5901 DU_LOG("\nERROR --> F1AP : Memory Allocation failed in BuildUlCfg");
5905 if(BuildPuschSrvCellCfg(ulCfg->pusch_ServingCellConfig) != ROK)
5910 ulCfg->carrierSwitching = NULLP;
5911 ulCfg->ext1 = NULLP;
5915 /*******************************************************************
5917 * @brief Builds PDSCH serving cell config
5920 * Function : BuildPdschSrvCellCfg
5922 * Functionality: Builds PDSCH serving cell config in spCellCfgDed
5924 * @params[in] struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg
5926 * @return ROK - success
5929 * ****************************************************************/
5930 uint8_t BuildPdschSrvCellCfg(PdschServCellCfg *pdschServCellDb, struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg)
5932 pdschCfg->present = ServingCellConfig__pdsch_ServingCellConfig_PR_setup;
5933 pdschCfg->choice.setup = NULLP;
5934 DU_ALLOC(pdschCfg->choice.setup, sizeof( struct PDSCH_ServingCellConfig));
5935 if(!pdschCfg->choice.setup)
5937 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
5941 /* Code Block Group Transmission */
5942 pdschCfg->choice.setup->codeBlockGroupTransmission = NULLP;
5943 if(pdschServCellDb && (pdschServCellDb->maxCodeBlkGrpPerTb || pdschServCellDb->codeBlkGrpFlushInd))
5945 DU_ALLOC(pdschCfg->choice.setup->codeBlockGroupTransmission, sizeof(struct PDSCH_ServingCellConfig__codeBlockGroupTransmission));
5946 if(pdschCfg->choice.setup->codeBlockGroupTransmission == NULLP)
5948 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
5952 pdschCfg->choice.setup->codeBlockGroupTransmission->present = PDSCH_ServingCellConfig__codeBlockGroupTransmission_PR_setup;
5953 pdschCfg->choice.setup->codeBlockGroupTransmission->choice.setup = NULLP;
5954 DU_ALLOC(pdschCfg->choice.setup->codeBlockGroupTransmission->choice.setup, sizeof(struct PDSCH_CodeBlockGroupTransmission ));
5955 if(pdschCfg->choice.setup->codeBlockGroupTransmission->choice.setup == NULLP)
5957 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
5961 pdschCfg->choice.setup->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock = \
5962 *(pdschServCellDb->maxCodeBlkGrpPerTb);
5963 pdschCfg->choice.setup->codeBlockGroupTransmission->choice.setup->codeBlockGroupFlushIndicator = \
5964 *(pdschServCellDb->codeBlkGrpFlushInd);
5968 pdschCfg->choice.setup->xOverhead = NULLP;
5969 if(pdschServCellDb && pdschServCellDb->xOverhead)
5971 DU_ALLOC(pdschCfg->choice.setup->xOverhead, sizeof(long));
5972 if(pdschCfg->choice.setup->xOverhead == NULLP)
5974 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
5977 *(pdschCfg->choice.setup->xOverhead) = *(pdschServCellDb->xOverhead);
5980 /* Number of HARQ processes */
5981 pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH = NULLP;
5982 DU_ALLOC(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH, sizeof(long));
5983 if(!pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH)
5985 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
5989 if(pdschServCellDb == NULLP)
5990 *(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH) = PDSCH_NUM_HARQ_PROC;
5992 *(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH) = pdschServCellDb->numHarqProcForPdsch;
5994 pdschCfg->choice.setup->pucch_Cell = NULLP;
5997 pdschCfg->choice.setup->ext1 = NULLP;
5998 if(pdschServCellDb && pdschServCellDb->maxMimoLayers)
6000 DU_ALLOC(pdschCfg->choice.setup->ext1, sizeof(struct PDSCH_ServingCellConfig__ext1));
6001 if(pdschCfg->choice.setup->ext1 == NULLP)
6003 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
6007 DU_ALLOC(pdschCfg->choice.setup->ext1->maxMIMO_Layers, sizeof(long));
6008 if(pdschCfg->choice.setup->ext1->maxMIMO_Layers == NULLP)
6010 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
6013 *(pdschCfg->choice.setup->ext1->maxMIMO_Layers) = *(pdschServCellDb->maxMimoLayers);
6019 /*******************************************************************
6021 * @brief Builds CSI Meas config
6024 * Function : BuildCsiMeasCfg
6026 * Functionality: Builds CSI Meas config in spCellCfgDed
6028 * @params[in] struct ServingCellConfig__csi_MeasConfig *csiMeasCfg
6030 * @return ROK - success
6033 * ****************************************************************/
6034 uint8_t BuildCsiMeasCfg(struct ServingCellConfig__csi_MeasConfig *csiMeasCfg)
6040 /*******************************************************************
6042 * @brief Builds DL BWP to add/modify list
6045 * Function : BuildDlBwpToAddModList
6047 * Functionality: Builds DL BWP to add/modify list
6049 * @params[in] ServCellRecfgInfo *servCellRecfg,
6050 * struct ServingCellConfig__downlinkBWP_ToAddModList *dlBwpAddModList
6052 * @return ROK - success
6055 * ****************************************************************/
6056 uint8_t BuildDlBwpToAddModList(ServCellRecfgInfo *servCellRecfg, struct ServingCellConfig__downlinkBWP_ToAddModList *dlBwpAddModList)
6058 uint8_t elementCnt, idx;
6060 elementCnt = servCellRecfg->numDlBwpToAddOrMod;
6061 dlBwpAddModList->list.count = elementCnt;
6062 dlBwpAddModList->list.size = elementCnt * sizeof(struct BWP_Downlink *);
6063 dlBwpAddModList->list.array = NULLP;
6064 DU_ALLOC(dlBwpAddModList->list.array, dlBwpAddModList->list.size);
6065 if(dlBwpAddModList->list.array == NULLP)
6067 DU_LOG("\nERROR --> DU APP: Memory allocation failure in BuildDlBwpToAddModList");
6071 for(idx=0; idx<dlBwpAddModList->list.count; idx++)
6073 DU_ALLOC(dlBwpAddModList->list.array[idx], sizeof(BWP_Downlink_t));
6074 if(dlBwpAddModList->list.array[idx] == NULLP)
6076 DU_LOG("\nERROR --> DU APP: Memory allocation failure in BuildDlBwpToAddModList");
6081 for(idx=0; idx<dlBwpAddModList->list.count; idx++)
6083 dlBwpAddModList->list.array[idx]->bwp_Id = servCellRecfg->dlBwpToAddOrModList[idx].bwpId;
6084 dlBwpAddModList->list.array[idx]->bwp_Common = NULLP;
6085 dlBwpAddModList->list.array[idx]->bwp_Dedicated = NULLP;
6090 /*******************************************************************
6092 * @brief Builds Spcell config dedicated
6095 * Function : BuildSpCellCfgDed
6097 * Functionality: Builds sp cell config dedicated in spCellCfg
6099 * @params[in] ServingCellConfig_t srvCellCfg
6101 * @return ROK - success
6104 * ****************************************************************/
6105 uint8_t BuildSpCellCfgDed(DuUeCb *ueCb, ServingCellConfig_t *srvCellCfg)
6107 ServCellRecfgInfo *servCellRecfg = NULLP;
6108 InitialDlBwp *initDlBwp = NULLP;
6109 PdschServCellCfg *pdschServCellDb = NULLP;
6113 servCellRecfg = &ueCb->duMacUeCfg.spCellCfg.servCellCfg;
6114 initDlBwp = &servCellRecfg->initDlBwp;
6115 pdschServCellDb = &servCellRecfg->pdschServCellCfg;
6118 srvCellCfg->tdd_UL_DL_ConfigurationDedicated = NULLP;
6120 srvCellCfg->initialDownlinkBWP = NULLP;
6121 DU_ALLOC(srvCellCfg->initialDownlinkBWP, sizeof(BWP_DownlinkDedicated_t));
6122 if(!srvCellCfg->initialDownlinkBWP)
6124 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
6128 if(BuildInitialDlBWP(initDlBwp, srvCellCfg->initialDownlinkBWP) != ROK)
6130 DU_LOG("\nERROR --> F1AP : BuildInitialDlBWP failed");
6134 srvCellCfg->downlinkBWP_ToReleaseList = NULLP;
6136 srvCellCfg->downlinkBWP_ToAddModList = NULLP;
6137 if(ueCb && ueCb->duMacUeCfg.spCellCfg.servCellCfg.numDlBwpToAddOrMod)
6139 DU_ALLOC(srvCellCfg->downlinkBWP_ToAddModList, sizeof(struct ServingCellConfig__downlinkBWP_ToAddModList));
6140 if(srvCellCfg->downlinkBWP_ToAddModList == NULLP)
6142 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
6146 if(BuildDlBwpToAddModList(&ueCb->duMacUeCfg.spCellCfg.servCellCfg, srvCellCfg->downlinkBWP_ToAddModList) != ROK)
6148 DU_LOG("\nERROR --> F1AP : BuildInitialDlBWP failed");
6153 srvCellCfg->firstActiveDownlinkBWP_Id = NULLP;
6154 DU_ALLOC(srvCellCfg->firstActiveDownlinkBWP_Id, sizeof(long));
6155 if(!srvCellCfg->firstActiveDownlinkBWP_Id)
6157 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
6161 *(srvCellCfg->firstActiveDownlinkBWP_Id) = ACTIVE_DL_BWP_ID;
6163 *(srvCellCfg->firstActiveDownlinkBWP_Id) = ueCb->duMacUeCfg.spCellCfg.servCellCfg.firstActvDlBwpId;
6165 srvCellCfg->bwp_InactivityTimer = NULLP;
6167 srvCellCfg->defaultDownlinkBWP_Id = NULLP;
6168 DU_ALLOC(srvCellCfg->defaultDownlinkBWP_Id, sizeof(long));
6169 if(!srvCellCfg->defaultDownlinkBWP_Id)
6171 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
6175 *(srvCellCfg->defaultDownlinkBWP_Id) = ACTIVE_DL_BWP_ID;
6177 *(srvCellCfg->defaultDownlinkBWP_Id) = ueCb->duMacUeCfg.spCellCfg.servCellCfg.defaultDlBwpId;
6179 srvCellCfg->uplinkConfig = NULLP;
6180 DU_ALLOC(srvCellCfg->uplinkConfig, sizeof(UplinkConfig_t));
6181 if(!srvCellCfg->uplinkConfig)
6183 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
6187 if(BuildUlCfg(servCellRecfg, srvCellCfg->uplinkConfig) != ROK)
6189 DU_LOG("\nERROR --> F1AP : BuildUlCfg failed");
6192 srvCellCfg->supplementaryUplink = NULLP;
6193 srvCellCfg->pdcch_ServingCellConfig = NULLP;
6195 srvCellCfg->pdsch_ServingCellConfig = NULLP;
6196 DU_ALLOC(srvCellCfg->pdsch_ServingCellConfig, sizeof(struct ServingCellConfig__pdsch_ServingCellConfig));
6197 if(!srvCellCfg->pdsch_ServingCellConfig)
6199 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
6203 if(BuildPdschSrvCellCfg(pdschServCellDb, srvCellCfg->pdsch_ServingCellConfig) != ROK)
6205 DU_LOG("\nERROR --> F1AP : BuildPdschSrvCellCfg failed");
6209 srvCellCfg->csi_MeasConfig = NULLP;
6211 DU_ALLOC(srvCellCfg->csi_MeasConfig, sizeof(struct ServingCellConfig__csi_MeasConfig))
6212 if(!srvCellCfg->csi_MeasConfig)
6214 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
6218 if(BuildCsiMeasCfg(srvCellCfg->csi_MeasConfig) != ROK)
6220 DU_LOG("\nF1AP : BuildCsiMeasCfg failed");
6224 srvCellCfg->sCellDeactivationTimer = NULLP;
6225 srvCellCfg->crossCarrierSchedulingConfig = NULLP;
6226 srvCellCfg->tag_Id = TAG_ID;
6227 srvCellCfg->dummy = NULLP;
6228 srvCellCfg->pathlossReferenceLinking = NULLP;
6229 srvCellCfg->servingCellMO = NULLP;
6230 srvCellCfg->ext1 = NULLP;
6235 /*******************************************************************
6237 * @brief Fills SCS specific carrier list in DL frequency info
6241 * Function : BuildScsSpecificCarrierListDl
6243 * Functionality: Fills SCS specific carrier list in DL frequency info
6245 * @params[in] Pointer to struct FrequencyInfoDL__scs_SpecificCarrierList
6247 * @return ROK - success
6250 * ****************************************************************/
6251 uint8_t BuildScsSpecificCarrierListDl(struct FrequencyInfoDL__scs_SpecificCarrierList *scsCarrierList)
6253 uint8_t elementCnt = 0, listIdx = 0;
6254 ScsSpecCarrier duScsSpecCarrier = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.dlScsCarrier;
6256 elementCnt = ODU_VALUE_ONE;
6257 scsCarrierList->list.count = elementCnt;
6258 scsCarrierList->list.size = elementCnt * sizeof(SCS_SpecificCarrier_t *);
6260 DU_ALLOC(scsCarrierList->list.array, scsCarrierList->list.size);
6261 if(!scsCarrierList->list.array)
6263 DU_LOG("\nERROR --> DU APP : Memory allocation failed for scs carrier list array \
6264 in BuildScsSpecificCarrierListDl()");
6268 for(listIdx = 0; listIdx < elementCnt; listIdx++)
6270 DU_ALLOC(scsCarrierList->list.array[listIdx], sizeof(SCS_SpecificCarrier_t));
6271 if(!scsCarrierList->list.array[listIdx])
6273 DU_LOG("\nERROR --> DU APP : Memory allocation failed for SCS Specific Carrier list array \
6274 element in BuildScsSpecificCarrierListDl()");
6280 scsCarrierList->list.array[listIdx]->offsetToCarrier = duScsSpecCarrier.scsOffset;
6281 scsCarrierList->list.array[listIdx]->subcarrierSpacing = duScsSpecCarrier.scs;
6282 scsCarrierList->list.array[listIdx]->carrierBandwidth = duScsSpecCarrier.scsBw;
6287 /*******************************************************************
6289 * @brief Fills DL frequency info in DL config common
6293 * Function : BuildFreqInfoDl
6295 * Functionality: Fills DL frequency info in DL config common
6297 * @params[in] Pointer to DownlinkConfigCommon_t
6299 * @return ROK - success
6302 * ****************************************************************/
6303 uint8_t BuildFreqInfoDl(FrequencyInfoDL_t *frequencyInfoDL)
6305 uint8_t freqBandIdx = 0, elementCnt = 0;
6306 DlCfgCommon dlCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg;
6308 /* TODO : Fill SSB Absolute Frequency */
6310 DU_ALLOC(frequencyInfoDL->absoluteFrequencySSB, sizeof(ARFCN_ValueNR_t));
6311 if(!frequencyInfoDL->absoluteFrequencySSB)
6313 DU_LOG("\nERROR --> DU APP : Memory allocation failed for SSB Absolute Frequency in BuildFreqInfoDl()");
6316 frequencyInfoDL->absoluteFrequencySSB = ?;
6319 /* NR Multi Frequency Band List */
6320 elementCnt = ODU_VALUE_ONE;
6321 frequencyInfoDL->frequencyBandList.list.count = elementCnt;
6322 frequencyInfoDL->frequencyBandList.list.size = elementCnt * sizeof(FreqBandIndicatorNR_t *);
6324 DU_ALLOC(frequencyInfoDL->frequencyBandList.list.array, frequencyInfoDL->frequencyBandList.list.size);
6325 if(!frequencyInfoDL->frequencyBandList.list.array)
6327 DU_LOG("\nERROR --> DU APP : Memory allocation failed for Frequency Band List array in BuildFreqInfoDl()");
6331 for(freqBandIdx = 0; freqBandIdx < elementCnt; freqBandIdx++)
6333 DU_ALLOC(frequencyInfoDL->frequencyBandList.list.array[freqBandIdx], sizeof(FreqBandIndicatorNR_t));
6334 if(!frequencyInfoDL->frequencyBandList.list.array[freqBandIdx])
6336 DU_LOG("\nERROR --> DU APP : Memory allocation failed for frequency band array element in BuildFreqInfoDl()");
6342 *(frequencyInfoDL->frequencyBandList.list.array[freqBandIdx]) = dlCfg.freqBandInd;
6344 /* TODO : Absolute Frequency to Point A */
6345 //frequencyInfoDL->absoluteFrequencyPointA
6347 /* Subcarrier Spacing specifc carrier List */
6348 if((BuildScsSpecificCarrierListDl(&frequencyInfoDL->scs_SpecificCarrierList)) != ROK)
6350 DU_LOG("\nERROR --> DU APP : Failed to fill SCS specific carrier list DL in BuildFreqInfoDl()");
6358 /*******************************************************************
6360 * @brief Fills DL config common in Serving cell config common
6364 * Function : BuildDlConfigCommon
6366 * Functionality: Fills DL config common in Serving cell config common
6368 * @params[in] Pointer to DownlinkConfigCommon_t
6370 * @return ROK - success
6373 * ****************************************************************/
6374 uint8_t BuildDlConfigCommon(DownlinkConfigCommon_t *dlCfgCommon)
6376 /* DL Frequency Info */
6377 DU_ALLOC(dlCfgCommon->frequencyInfoDL, sizeof(FrequencyInfoDL_t));
6378 if(!dlCfgCommon->frequencyInfoDL)
6380 DU_LOG("\nERROR --> DU APP : Memory allocation failed for DL frequency info in BuildDlConfigCommon()");
6383 if((BuildFreqInfoDl(dlCfgCommon->frequencyInfoDL))!= ROK)
6385 DU_LOG("\nERROR --> DU APP : Failed to fill DL frequency info in BuildDlConfigCommon()");
6389 /* DL BWP config common */
6390 DU_ALLOC(dlCfgCommon->initialDownlinkBWP, sizeof(BWP_DownlinkCommon_t));
6391 if(!dlCfgCommon->initialDownlinkBWP)
6393 DU_LOG("\nERROR --> DU APP : Memory allocation failed for DL BWP config common in BuildDlConfigCommon()");
6396 if((BuildBwpDlCommon(dlCfgCommon->initialDownlinkBWP)) != ROK)
6398 DU_LOG("\nERROR --> DU APP : Failed to fill DL DWP config common in BuildDlConfigCommon()");
6405 /*******************************************************************
6407 * @brief Fills SCS specific carrier list in UL frequency Info
6411 * Function : BuildScsSpecificCarrierListUl
6413 * Functionality: Fills SCS specific carrier list in UL frequency Info
6415 * @params[in] Pointer to struct FrequencyInfoUL__scs_SpecificCarrierList
6417 * @return ROK - success
6420 * ****************************************************************/
6421 uint8_t BuildScsSpecificCarrierListUl(struct FrequencyInfoUL__scs_SpecificCarrierList *scsCarrierList)
6423 uint8_t elementCnt = 0, listIdx = 0;
6424 ScsSpecCarrier duScsSpecCarrier = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.ulScsCarrier;
6426 elementCnt = ODU_VALUE_ONE;
6427 scsCarrierList->list.count = elementCnt;
6428 scsCarrierList->list.size = elementCnt * sizeof(SCS_SpecificCarrier_t *);
6430 DU_ALLOC(scsCarrierList->list.array, scsCarrierList->list.size);
6431 if(!scsCarrierList->list.array)
6433 DU_LOG("\nERROR --> DU APP : SCS Specific Carrier list memory allocation failed");
6437 for(listIdx = 0; listIdx < scsCarrierList->list.count; listIdx++)
6439 DU_ALLOC(scsCarrierList->list.array[listIdx], sizeof(SCS_SpecificCarrier_t));
6440 if(!scsCarrierList->list.array[listIdx])
6442 DU_LOG("\nERROR --> DU APP : SCS Specific Carrier list memory allocation failed");
6447 scsCarrierList->list.array[listIdx]->offsetToCarrier = duScsSpecCarrier.scsOffset;
6448 scsCarrierList->list.array[listIdx]->subcarrierSpacing = duScsSpecCarrier.scs;
6449 scsCarrierList->list.array[listIdx]->carrierBandwidth = duScsSpecCarrier.scsBw;
6454 /*******************************************************************
6456 * @brief Fills frequency info in UL config common
6460 * Function : BuildFreqInfoUl
6462 * Functionality: Fills frequency info in UL config common
6464 * @params[in] Pointer to FrequencyInfoUL_t
6466 * @return ROK - success
6469 * ****************************************************************/
6470 uint8_t BuildFreqInfoUl(FrequencyInfoUL_t *frequencyInfoUL)
6472 uint8_t elementCnt = 0, listIdx= 0;
6473 UlCfgCommon ulCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg;
6475 /* NR Multi Frequency Band List */
6476 DU_ALLOC(frequencyInfoUL->frequencyBandList, sizeof(MultiFrequencyBandListNR_t));
6477 if(!frequencyInfoUL->frequencyBandList)
6479 DU_LOG("\nERROR --> DU APP : Memory allocation failed for frequency band list in BuildFreqInfoUl()");
6483 elementCnt = ODU_VALUE_ONE;
6484 frequencyInfoUL->frequencyBandList->list.count = elementCnt;
6485 frequencyInfoUL->frequencyBandList->list.size = elementCnt * sizeof(FreqBandIndicatorNR_t *);
6487 DU_ALLOC(frequencyInfoUL->frequencyBandList->list.array, frequencyInfoUL->frequencyBandList->list.size);
6488 if(!frequencyInfoUL->frequencyBandList->list.array)
6490 DU_LOG("\nERROR --> DU APP : Memory allocation failed for frequency band array in BuildFreqInfoUl()");
6494 for(listIdx = 0; listIdx < elementCnt; listIdx++)
6496 DU_ALLOC(frequencyInfoUL->frequencyBandList->list.array[listIdx], sizeof(FreqBandIndicatorNR_t));
6497 if(!frequencyInfoUL->frequencyBandList->list.array[listIdx])
6499 DU_LOG("\nERROR --> DU APP : Memory allocation failed for frequency band array element in BuildFreqInfoUl()");
6505 *(frequencyInfoUL->frequencyBandList->list.array[listIdx]) = ulCfg.freqBandInd;
6507 /* TODO : Fill Absolute frequency point A */
6509 DU_ALLOC(frequencyInfoUL->absoluteFrequencyPointA, sizeof(ARFCN_ValueNR_t));
6510 if(!frequencyInfoUL->absoluteFrequencyPointA)
6512 DU_LOG("\nERROR --> DU APP : Memory allocation failed for absolute frequency point A in BuildFreqInfoUl()");
6515 *(frequencyInfoUL->absoluteFrequencyPointA) = ?;
6518 /* Subcarrier Spacing specifc carrier */
6519 if((BuildScsSpecificCarrierListUl(&frequencyInfoUL->scs_SpecificCarrierList)) != ROK)
6521 DU_LOG("\nERROR --> DU APP : Failed to fill SCS Specific Carrier list UL in BuildFreqInfoUl()");
6526 DU_ALLOC(frequencyInfoUL->p_Max, sizeof(P_Max_t));
6527 if(!frequencyInfoUL->p_Max)
6529 DU_LOG("\nERROR --> DU APP : UL Frequency Infoo memory allocation failure");
6532 *frequencyInfoUL->p_Max = ulCfg.pMax;
6537 /*******************************************************************
6539 * @brief Fills UL config common in Serving cell config common
6543 * Function : BuildUlConfigCommon
6545 * Functionality: Fills UL config common in Serving cell config common
6547 * @params[in] Pointer to UplinkConfigCommon_t
6549 * @return ROK - success
6552 * ****************************************************************/
6553 uint8_t BuildUlConfigCommon(UplinkConfigCommon_t *ulCfgCommon)
6555 /* UL Frequency Info */
6556 DU_ALLOC(ulCfgCommon->frequencyInfoUL, sizeof(FrequencyInfoUL_t));
6557 if(!ulCfgCommon->frequencyInfoUL)
6559 DU_LOG("\nERROR --> DU APP : Memory allocation failed for UL frequency info in BuildUlConfigCommon()");
6563 if((BuildFreqInfoUl(ulCfgCommon->frequencyInfoUL)) != ROK)
6565 DU_LOG("\nERROR --> DU APP : Failed to fill frequency info UL in BuildUlConfigCommon()");
6570 DU_ALLOC(ulCfgCommon->initialUplinkBWP, sizeof(BWP_UplinkCommon_t));
6571 if(!ulCfgCommon->initialUplinkBWP)
6573 DU_LOG("\nERROR --> DU APP : Memory allocation failed for initial UL BWP in BuildUlConfigCommon()");
6577 if((BuildBwpUlCommon(ulCfgCommon->initialUplinkBWP)) != ROK)
6579 DU_LOG("\nERROR --> DU APP : Failed to fill BWP UL common in BuildUlConfigCommon()");
6583 /* Time Alignment timer */
6584 ulCfgCommon->dummy = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.timeAlignTimerComm;
6589 /*******************************************************************
6591 * @brief Fills SSB position in burst in SP cell config common
6595 * Function : BuildSsbPosInBurst
6598 * Fills SSB position in burst in SP cell config common
6600 * @params[in] Pointer to struct ServingCellConfigCommon__ssb_PositionsInBurst
6602 * @return ROK - success
6605 * ****************************************************************/
6606 uint8_t BuildSsbPosInBurst(struct ServingCellConfigCommon__ssb_PositionsInBurst *ssbPosInBurst)
6608 uint8_t bitStringSizeInBytes = 0;
6610 ssbPosInBurst->present = ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap;
6612 /* As per spec 38.331,in the definition of ServingCellConfigCommon */
6613 bitStringSizeInBytes = 1;
6614 ssbPosInBurst->choice.mediumBitmap.size = bitStringSizeInBytes * sizeof(uint8_t);
6616 DU_ALLOC(ssbPosInBurst->choice.mediumBitmap.buf, ssbPosInBurst->choice.mediumBitmap.size);
6617 if(!ssbPosInBurst->choice.mediumBitmap.buf)
6619 DU_LOG("\nERROR --> DU APP : Memory Allocation failed for medium bit map buffer in BuildSsbPosInBurst()");
6623 if((fillBitString(&ssbPosInBurst->choice.mediumBitmap, 0, bitStringSizeInBytes, \
6624 duCfgParam.sib1Params.srvCellCfgCommSib.ssbPosInBurst)) != ROK)
6626 DU_LOG("\nERROR --> DU APP : Failed to fill medium bit map in BuildSsbPosInBurst()");
6633 /*******************************************************************
6635 * @brief Fills SP cell config common in Reconfig with Sync
6639 * Function : BuildSpCellConfigCommon
6641 * Functionality: Fills SP cell config common in Reconfig with Sync
6643 * @params[in] Pointer to ServingCellConfigCommon_t
6645 * @return ROK - success
6648 * ****************************************************************/
6649 uint8_t BuildSpCellConfigCommon(ServingCellConfigCommon_t *spCellConfigCommon)
6651 /* Physical Cell Identity */
6652 DU_ALLOC(spCellConfigCommon->physCellId, sizeof(PhysCellId_t));
6653 if(!spCellConfigCommon->physCellId)
6655 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for physical cell id in BuildSpCellConfigCommon()");
6658 *(spCellConfigCommon->physCellId) = NR_PCI;
6660 /* Downlink Config Common */
6661 DU_ALLOC(spCellConfigCommon->downlinkConfigCommon, sizeof(DownlinkConfigCommon_t));
6662 if(!spCellConfigCommon->downlinkConfigCommon)
6664 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for DL Config Common in BuildSpCellConfigCommon()");
6667 if((BuildDlConfigCommon(spCellConfigCommon->downlinkConfigCommon)) != ROK)
6669 DU_LOG("\nERROR --> DU APP : Failed to fill DL config commin in BuildSpCellConfigCommon()");
6673 /* Uplinlink Config Common */
6674 DU_ALLOC(spCellConfigCommon->uplinkConfigCommon, sizeof(UplinkConfigCommon_t));
6675 if(!spCellConfigCommon->uplinkConfigCommon)
6677 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for UL Config Common in BuildSpCellConfigCommon()");
6680 if((BuildUlConfigCommon(spCellConfigCommon->uplinkConfigCommon)) != ROK)
6682 DU_LOG("\nERROR --> DU APP : Failed to fill UL config commin in BuildSpCellConfigCommon()");
6686 /* Timing Advance offset */
6687 DU_ALLOC(spCellConfigCommon->n_TimingAdvanceOffset, sizeof(long));
6688 if(!spCellConfigCommon->n_TimingAdvanceOffset)
6690 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for Timing Advance Offset in BuildSpCellConfigCommon()");
6693 *(spCellConfigCommon->n_TimingAdvanceOffset) = ServingCellConfigCommon__n_TimingAdvanceOffset_n0;
6695 /* SSB Position In Burst */
6696 DU_ALLOC(spCellConfigCommon->ssb_PositionsInBurst, sizeof(struct ServingCellConfigCommon__ssb_PositionsInBurst));
6697 if(!spCellConfigCommon->ssb_PositionsInBurst)
6699 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for SSB Position In Burst in BuildSpCellConfigCommon()");
6702 if((BuildSsbPosInBurst(spCellConfigCommon->ssb_PositionsInBurst)) != ROK)
6704 DU_LOG("\nERROR --> DU APP : Failed to fill SSB Position In Burst in BuildSpCellConfigCommon()");
6708 /* SSB Periodicity in Serving cell */
6709 DU_ALLOC(spCellConfigCommon->ssb_periodicityServingCell, sizeof(long));
6710 if(!spCellConfigCommon->ssb_periodicityServingCell)
6712 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for SSB Periodicity serving cell in \
6713 BuildSpCellConfigCommon()");
6716 *(spCellConfigCommon->ssb_periodicityServingCell) = \
6717 convertSsbPeriodicityValueToEnum(duCfgParam.sib1Params.srvCellCfgCommSib.ssbPrdServingCell);
6719 /* DMRS Type A position */
6720 spCellConfigCommon->dmrs_TypeA_Position = convertDmrsTypeAPosValueToEnum(duCfgParam.macCellCfg.dmrsTypeAPos);
6722 /* SSB subcarrier spacing */
6723 DU_ALLOC(spCellConfigCommon->ssbSubcarrierSpacing, sizeof(SubcarrierSpacing_t));
6724 if(!spCellConfigCommon->ssbSubcarrierSpacing)
6726 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for sub-carrier spacing in BuildSpCellConfigCommon()");
6729 *(spCellConfigCommon->ssbSubcarrierSpacing) = duCfgParam.sib1Params.srvCellCfgCommSib.scs;
6731 /* TDD UL-DL configuration common */
6732 DU_ALLOC(spCellConfigCommon->tdd_UL_DL_ConfigurationCommon, sizeof(TDD_UL_DL_ConfigCommon_t));
6733 if(!spCellConfigCommon->tdd_UL_DL_ConfigurationCommon)
6735 DU_LOG("\nERROR --> DU APP : Memory allocation failed for TDD UL-DL config common in BuildSpCellConfigCommon()");
6738 if((BuildTddUlDlCfgComm(spCellConfigCommon->tdd_UL_DL_ConfigurationCommon)) != ROK)
6740 DU_LOG("\nERROR --> DU APP : Failed to fill TDD UL-DL config common in BuildSpCellConfigCommon()");
6744 /* SS PBCH Block Power */
6745 spCellConfigCommon->ss_PBCH_BlockPower = duCfgParam.sib1Params.srvCellCfgCommSib.ssPbchBlockPwr;
6750 /*******************************************************************
6752 * @brief Fills dedicated RACH configuration in Reconfiguration with sync
6756 * Function : BuildRecfgWithSync
6759 * Fills dedicated RACH configuration in Reconfiguration with sync
6761 * @params[in] DU UE CB
6762 * Pointer to Rach config dedicated struct
6764 * @return ROK - success
6767 * ****************************************************************/
6768 uint8_t BuildRachConfigDedicated(DuUeCb *ueCb, struct ReconfigurationWithSync__rach_ConfigDedicated *rachCfgDed)
6770 uint8_t elementCnt = 0, listIdx = 0;
6771 CFRA_t *cfra = NULLP;
6772 struct CFRA__resources__ssb *ssbResource = NULLP;
6773 RachCfgCommon duRachCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.rachCfg;
6775 rachCfgDed->present = ReconfigurationWithSync__rach_ConfigDedicated_PR_uplink;
6778 DU_ALLOC(rachCfgDed->choice.uplink, sizeof(RACH_ConfigDedicated_t));
6779 if(!rachCfgDed->choice.uplink)
6781 DU_LOG("\nERROR --> DU APP : Memory allocation failed for RACH uplink configuration in BuildRachConfigDedicated()");
6785 /* CFRA : Contention free Random Access */
6786 DU_ALLOC(rachCfgDed->choice.uplink->cfra, sizeof(CFRA_t));
6787 if(!rachCfgDed->choice.uplink->cfra)
6789 DU_LOG("\nERROR --> DU APP : Memory allocation failed for CFRA in BuildRachConfigDedicated()");
6792 cfra = rachCfgDed->choice.uplink->cfra;
6794 /* CFRA occassions */
6795 DU_ALLOC(cfra->occasions, sizeof(struct CFRA__occasions));
6796 if(!cfra->occasions)
6798 DU_LOG("\nERROR --> DU APP : Memory allocation failed for CFRA occassion in BuildRachConfigDedicated()");
6802 /* CFRA occassions : RACH generic configuration */
6803 cfra->occasions->rach_ConfigGeneric.prach_ConfigurationIndex = duRachCfg.prachCfgIdx;
6804 cfra->occasions->rach_ConfigGeneric.msg1_FDM = duRachCfg.msg1Fdm;
6805 cfra->occasions->rach_ConfigGeneric.msg1_FrequencyStart = duRachCfg.msg1FreqStart;
6806 cfra->occasions->rach_ConfigGeneric.zeroCorrelationZoneConfig = duRachCfg.zeroCorrZoneCfg;
6807 cfra->occasions->rach_ConfigGeneric.preambleReceivedTargetPower = duRachCfg.preambleRcvdTgtPwr;
6808 cfra->occasions->rach_ConfigGeneric.preambleTransMax = duRachCfg.preambleTransMax;
6809 cfra->occasions->rach_ConfigGeneric.powerRampingStep = duRachCfg.pwrRampingStep;
6810 cfra->occasions->rach_ConfigGeneric.ra_ResponseWindow = duRachCfg.raRspWindow;
6812 /* CFRA occassions : SSB per RACH occasion */
6813 DU_ALLOC(cfra->occasions->ssb_perRACH_Occasion, sizeof(long));
6814 if(!cfra->occasions->ssb_perRACH_Occasion)
6816 DU_LOG("\nERROR --> DU APP : Memory allocation failed for SSB per RACH occassion in BuildRachConfigDedicated()");
6819 *(cfra->occasions->ssb_perRACH_Occasion) = convertCFRASsbPerRachOccasionValueToEnum(duCfgParam.macCellCfg.prachCfg.ssbPerRach);
6822 cfra->resources.present = CFRA__resources_PR_ssb;
6824 /* CFRA resource : SSB */
6825 DU_ALLOC(cfra->resources.choice.ssb, sizeof(struct CFRA__resources__ssb));
6826 if(!cfra->resources.choice.ssb)
6828 DU_LOG("\nERROR --> DU APP : Memory allocation failed for CFRA resource - SSB in BuildRachConfigDedicated()");
6831 ssbResource = cfra->resources.choice.ssb;
6833 /* CFRA SSB resource list */
6834 elementCnt = ueCb->cfraResource.numSsb;
6835 ssbResource->ssb_ResourceList.list.count = elementCnt;
6836 ssbResource->ssb_ResourceList.list.size = elementCnt * sizeof(CFRA_SSB_Resource_t *);
6838 DU_ALLOC(ssbResource->ssb_ResourceList.list.array, ssbResource->ssb_ResourceList.list.size);
6839 if(!ssbResource->ssb_ResourceList.list.array)
6841 DU_LOG("\nERROR --> DU APP : Memory allocation failed for SSB resource list in BuildRachConfigDedicated()");
6845 for(listIdx = 0; listIdx < elementCnt; listIdx++)
6847 DU_ALLOC(ssbResource->ssb_ResourceList.list.array[listIdx], sizeof(CFRA_SSB_Resource_t));
6848 if(!ssbResource->ssb_ResourceList.list.array[listIdx])
6850 DU_LOG("\nERROR --> DU APP : Memory allocation failed for SSB resource list element in BuildRachConfigDedicated()");
6853 ssbResource->ssb_ResourceList.list.array[listIdx]->ssb = ueCb->cfraResource.ssbResource[listIdx].ssbIdx;
6854 ssbResource->ssb_ResourceList.list.array[listIdx]->ra_PreambleIndex = ueCb->cfraResource.ssbResource[listIdx].raPreambleIdx;
6860 /*******************************************************************
6862 * @brief Fills reconfiguration with sync in SP cell config
6866 * Function : BuildRecfgWithSync
6868 * Functionality: Fills reconfiguration with sync in SP cell config
6870 * @params[in] DU UE CB
6871 * Pointer to ReconfigurationWithSync_t
6873 * @return ROK - success
6876 * ****************************************************************/
6877 uint8_t BuildRecfgWithSync(DuUeCb *ueCb, ReconfigurationWithSync_t *recfgWithSync)
6879 /* SP Cell Config Common */
6880 DU_ALLOC(recfgWithSync->spCellConfigCommon, sizeof(ServingCellConfigCommon_t));
6881 if(!recfgWithSync->spCellConfigCommon)
6883 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for spCellConfigCommon in BuildRecfgWithSync()");
6887 if((BuildSpCellConfigCommon(recfgWithSync->spCellConfigCommon)) != ROK)
6889 DU_LOG("\nERROR --> DU APP : Failed to build SpCellConfigCommon in BuildRecfgWithSync()");
6893 /* New UE Identity */
6894 recfgWithSync->newUE_Identity = ueCb->crnti;
6897 recfgWithSync->t304 = ReconfigurationWithSync__t304_ms1000;
6899 /* RACH configuration dedicated */
6900 DU_ALLOC(recfgWithSync->rach_ConfigDedicated, sizeof(struct ReconfigurationWithSync__rach_ConfigDedicated));
6901 if(!recfgWithSync->rach_ConfigDedicated)
6903 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for RACH config dedicated in BuildRecfgWithSync()");
6907 if((BuildRachConfigDedicated(ueCb, recfgWithSync->rach_ConfigDedicated)) != ROK)
6909 DU_LOG("\nERROR --> DU APP : Failed to build RACH config dedicated in BuildRecfgWithSync()");
6916 /*******************************************************************
6918 * @brief Builds Spcell config
6922 * Function : BuildSpCellCfg
6924 * Functionality: Builds sp cell config in DuToCuRrcContainer
6926 * @params[in] SpCellConfig_t spCellCfg
6928 * @return ROK - success
6931 * ****************************************************************/
6932 uint8_t BuildSpCellCfg(DuUeCb *ueCb, SpCellConfig_t *spCellCfg)
6934 spCellCfg->servCellIndex = NULLP;
6935 DU_ALLOC(spCellCfg->servCellIndex, sizeof(long));
6936 if(!spCellCfg->servCellIndex)
6938 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
6943 *(spCellCfg->servCellIndex) = SERV_CELL_IDX;
6945 *(spCellCfg->servCellIndex) = ueCb->duMacUeCfg.spCellCfg.servCellIdx;
6947 spCellCfg->reconfigurationWithSync = NULLP;
6948 if(ueCb && (ueCb->ueState == UE_HANDIN_IN_PROGRESS))
6950 DU_ALLOC(spCellCfg->reconfigurationWithSync, sizeof(ReconfigurationWithSync_t));
6951 if(!spCellCfg->reconfigurationWithSync)
6953 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
6957 if((BuildRecfgWithSync(ueCb, spCellCfg->reconfigurationWithSync)) != ROK)
6959 DU_LOG("\nERROR --> F1AP : Building of reconfiguration with sync failed at BuildSpCellCfg");
6964 spCellCfg->rlf_TimersAndConstants = NULLP;
6965 spCellCfg->rlmInSyncOutOfSyncThreshold = NULLP;
6967 DU_ALLOC(spCellCfg->rlmInSyncOutOfSyncThreshold, sizeof(long));
6968 if(!spCellCfg->rlmInSyncOutOfSyncThreshold)
6970 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
6973 *(spCellCfg->rlmInSyncOutOfSyncThreshold) = RLM_SYNC_OUT_SYNC_THRESHOLD;
6975 spCellCfg->spCellConfigDedicated = NULLP;
6976 DU_ALLOC(spCellCfg->spCellConfigDedicated, sizeof(ServingCellConfig_t));
6977 if(!spCellCfg->spCellConfigDedicated)
6979 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
6982 if(BuildSpCellCfgDed(ueCb, spCellCfg->spCellConfigDedicated) != ROK)
6984 DU_LOG("\nERROR --> F1AP : BuildSpCellCfgDed failed");
6991 /*******************************************************************
6993 * @brief Builds Phy cell group config
6997 * Function : BuildPhyCellGrpCfg
6999 * Functionality: Builds Phy cell group config in DuToCuRrcContainer
7001 * @params[in] PhysicalCellGroupConfig_t *phyCellGrpCfg
7003 * @return ROK - success
7006 * ****************************************************************/
7007 uint8_t BuildPhyCellGrpCfg(DuUeCb *ueCb, PhysicalCellGroupConfig_t *phyCellGrpCfg)
7009 phyCellGrpCfg->harq_ACK_SpatialBundlingPUCCH = NULLP;
7010 phyCellGrpCfg->harq_ACK_SpatialBundlingPUSCH = NULLP;
7012 phyCellGrpCfg->p_NR_FR1 = NULLP;
7013 DU_ALLOC(phyCellGrpCfg->p_NR_FR1, sizeof(long));
7014 if(!phyCellGrpCfg->p_NR_FR1)
7016 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildPhyCellGrpCfg");
7022 *(phyCellGrpCfg->p_NR_FR1) = P_NR_FR1;
7023 phyCellGrpCfg->pdsch_HARQ_ACK_Codebook = PDSCH_HARQ_ACK_CODEBOOK;
7027 *(phyCellGrpCfg->p_NR_FR1) = ueCb->duMacUeCfg.phyCellGrpCfg.pNrFr1;
7028 phyCellGrpCfg->pdsch_HARQ_ACK_Codebook = ueCb->duMacUeCfg.phyCellGrpCfg.pdschHarqAckCodebook;
7031 phyCellGrpCfg->tpc_SRS_RNTI = NULLP;
7032 phyCellGrpCfg->tpc_PUCCH_RNTI = NULLP;
7033 phyCellGrpCfg->tpc_PUSCH_RNTI = NULLP;
7034 phyCellGrpCfg->sp_CSI_RNTI = NULLP;
7035 phyCellGrpCfg->cs_RNTI = NULLP;
7036 phyCellGrpCfg->ext1 = NULLP;
7037 phyCellGrpCfg->ext2 = NULLP;
7042 /*******************************************************************
7044 * @brief fill long cycle offset value of drx
7048 * Function : fillLongCycleOffsetValFromDuCb
7050 * Functionality: fill long cycle offset value of drx
7052 * @params[in] DrxLongCycleStartOffset drxLongCycleStartOffset,
7053 * struct DRX_ConfigRrc__drx_LongCycleStartOffset drx_LongCycleStartOffset
7055 * @return ROK - success
7058 * ****************************************************************/
7059 void fillLongCycleOffsetValFromDuCb(DrxLongCycleStartOffset drxLongCycleStartOffset,\
7060 struct DRX_ConfigRrc__drx_LongCycleStartOffset *drx_LongCycleStartOffset)
7063 drx_LongCycleStartOffset->present = convertLongDrxCycleLengthValueToEnum(drxLongCycleStartOffset.drxLongCycleStartOffsetChoice);
7064 switch(drx_LongCycleStartOffset->present)
7066 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms10:
7068 drx_LongCycleStartOffset->choice.ms10 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7071 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms20:
7073 drx_LongCycleStartOffset->choice.ms20 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7076 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms32:
7078 drx_LongCycleStartOffset->choice.ms32 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7081 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms40:
7083 drx_LongCycleStartOffset->choice.ms40 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7086 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms60:
7088 drx_LongCycleStartOffset->choice.ms60 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7091 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms64:
7093 drx_LongCycleStartOffset->choice.ms64 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7096 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms70:
7098 drx_LongCycleStartOffset->choice.ms70 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7101 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms80:
7103 drx_LongCycleStartOffset->choice.ms80 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7106 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms128:
7108 drx_LongCycleStartOffset->choice.ms128 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7111 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms160:
7113 drx_LongCycleStartOffset->choice.ms160 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7116 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms256:
7118 drx_LongCycleStartOffset->choice.ms256 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7121 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms320:
7123 drx_LongCycleStartOffset->choice.ms320 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7126 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms512:
7128 drx_LongCycleStartOffset->choice.ms512 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7131 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms640:
7133 drx_LongCycleStartOffset->choice.ms640 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7136 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms1024:
7138 drx_LongCycleStartOffset->choice.ms1024 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7141 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms1280:
7143 drx_LongCycleStartOffset->choice.ms1280 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7146 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms2048:
7148 drx_LongCycleStartOffset->choice.ms2048 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7151 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms2560:
7153 drx_LongCycleStartOffset->choice.ms2560 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7156 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms5120:
7158 drx_LongCycleStartOffset->choice.ms5120 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7161 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms10240:
7163 drx_LongCycleStartOffset->choice.ms10240 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7170 /*******************************************************************
7172 * @brief Builds drx config IE
7176 * Function : BuildDrxConfigRrc
7178 * Functionality: Build drx config in MacCellGrpCfg
7180 * @params[in] struct MAC_CellGroupConfig__drx_ConfigRrc
7182 * @return ROK - success
7185 * ****************************************************************/
7186 uint8_t BuildDrxConfigRrc(DuUeCb *ueCb, struct MAC_CellGroupConfig__drx_ConfigRrc *drxCfg)
7188 drxCfg->present = MAC_CellGroupConfig__drx_ConfigRrc_PR_setup;
7189 DU_ALLOC(drxCfg->choice.setup, sizeof(struct DRX_ConfigRrc));
7190 if(!drxCfg->choice.setup)
7192 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDrxConfigRrc");
7195 if(ueCb->duMacUeCfg.macCellGrpCfg.drxCfg.drxOnDurationTimer.onDurationTimerValInMs)
7197 drxCfg->choice.setup->drx_onDurationTimer.present = DRX_ConfigRrc__drx_onDurationTimer_PR_milliSeconds;
7198 drxCfg->choice.setup->drx_onDurationTimer.choice.milliSeconds = convertOnDurationTimerMilliSecondsValueToEnum(ueCb->duMacUeCfg.\
7199 macCellGrpCfg.drxCfg.drxOnDurationTimer.onDurationtimerValue.milliSeconds);
7203 drxCfg->choice.setup->drx_onDurationTimer.present = DRX_ConfigRrc__drx_onDurationTimer_PR_subMilliSeconds;
7204 drxCfg->choice.setup->drx_onDurationTimer.choice.subMilliSeconds = ueCb->duMacUeCfg.macCellGrpCfg.drxCfg.\
7205 drxOnDurationTimer.onDurationtimerValue.subMilliSeconds;
7207 drxCfg->choice.setup->drx_InactivityTimer = convertDrxInactivityTimerValueToEnum(ueCb->duMacUeCfg.macCellGrpCfg.drxCfg.drxInactivityTimer);
7208 drxCfg->choice.setup->drx_HARQ_RTT_TimerDL = ueCb->duMacUeCfg.macCellGrpCfg.drxCfg.drxHarqRttTimerDl;
7209 drxCfg->choice.setup->drx_HARQ_RTT_TimerUL = ueCb->duMacUeCfg.macCellGrpCfg.drxCfg.drxHarqRttTimerUl;
7210 drxCfg->choice.setup->drx_RetransmissionTimerDL = convertDrxRetransmissionTimerDlValueToEnum(ueCb->duMacUeCfg.macCellGrpCfg.drxCfg.\
7211 drxRetransmissionTimerDl);
7212 drxCfg->choice.setup->drx_RetransmissionTimerUL = convertDrxRetransmissionTimerUlValueToEnum(ueCb->duMacUeCfg.macCellGrpCfg.drxCfg.\
7213 drxRetransmissionTimerUl);
7214 drxCfg->choice.setup->drx_SlotOffset = ueCb->duMacUeCfg.macCellGrpCfg.drxCfg.drxSlotOffset;
7215 fillLongCycleOffsetValFromDuCb(ueCb->duMacUeCfg.macCellGrpCfg.drxCfg.drxLongCycleStartOffset, &drxCfg->choice.setup->drx_LongCycleStartOffset);
7217 if(ueCb->duMacUeCfg.macCellGrpCfg.drxCfg.shortDrxPres)
7219 DU_ALLOC(drxCfg->choice.setup->shortDRX, sizeof(struct DRX_ConfigRrc__shortDRX));
7220 if(drxCfg->choice.setup->shortDRX)
7222 drxCfg->choice.setup->shortDRX->drx_ShortCycle = convertShortDrxCycleLengthValueToEnum(ueCb->duMacUeCfg.macCellGrpCfg.drxCfg.\
7223 shortDrx.drxShortCycle);
7224 drxCfg->choice.setup->shortDRX->drx_ShortCycleTimer = ueCb->duMacUeCfg.macCellGrpCfg.drxCfg.shortDrx.drxShortCycleTimer;
7228 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDrxConfigRrc");
7235 /*******************************************************************
7237 * @brief Builds Mac cell group config
7241 * Function : BuildMacCellGrpCfg
7243 * Functionality: Builds Mac cell group config in DuToCuRrcContainer
7245 * @params[in] MAC_CellGroupConfig_t *macCellGrpCfg
7247 * @return ROK - success
7250 * ****************************************************************/
7251 uint8_t BuildMacCellGrpCfg(DuUeCb *ueCb, MAC_CellGroupConfig_t *macCellGrpCfg)
7253 macCellGrpCfg->drx_ConfigRrc = NULLP;
7257 DU_ALLOC(macCellGrpCfg->drx_ConfigRrc, sizeof(struct MAC_CellGroupConfig__drx_ConfigRrc));
7258 if(!macCellGrpCfg->drx_ConfigRrc)
7260 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
7263 if(BuildDrxConfigRrc(ueCb, macCellGrpCfg->drx_ConfigRrc) != ROK)
7265 DU_LOG("\nERROR --> F1AP : failed to build drx config");
7270 macCellGrpCfg->schedulingRequestConfig = NULLP;
7271 DU_ALLOC(macCellGrpCfg->schedulingRequestConfig, sizeof(struct SchedulingRequestConfig));
7272 if(!macCellGrpCfg->schedulingRequestConfig)
7274 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
7278 if(BuildSchedulingReqConfig(ueCb, macCellGrpCfg->schedulingRequestConfig) != ROK)
7280 DU_LOG("\nERROR --> F1AP : BuildSchedulingReqConfig failed");
7284 macCellGrpCfg->bsr_Config = NULLP;
7285 DU_ALLOC(macCellGrpCfg->bsr_Config, sizeof(struct BSR_Config));
7286 if(!macCellGrpCfg->bsr_Config)
7288 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
7292 if(BuildBsrConfig(ueCb, macCellGrpCfg->bsr_Config) != ROK)
7294 DU_LOG("\nERROR --> F1AP : BuildBsrConfig failed");
7298 macCellGrpCfg->tag_Config = NULLP;
7299 DU_ALLOC(macCellGrpCfg->tag_Config, sizeof(struct TAG_Config));
7300 if(!macCellGrpCfg->tag_Config)
7302 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
7306 if(BuildTagConfig(ueCb, macCellGrpCfg->tag_Config) != ROK)
7308 DU_LOG("\nERROR --> F1AP : BuildTagConfig failed");
7312 macCellGrpCfg->phr_Config = NULLP;
7313 DU_ALLOC(macCellGrpCfg->phr_Config, sizeof(struct MAC_CellGroupConfig__phr_Config));
7314 if(!macCellGrpCfg->phr_Config)
7316 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
7320 if(BuildPhrConfig(ueCb, macCellGrpCfg->phr_Config) != ROK)
7322 DU_LOG("\nERROR --> F1AP : BuildPhrConfig failed");
7326 macCellGrpCfg->skipUplinkTxDynamic = false;
7327 macCellGrpCfg->ext1 = NULLP;
7331 /*******************************************************************
7333 * @brief Frees memeory allocated for SearchSpcToAddModList
7337 * Function : FreeSearchSpcToAddModList
7339 * Functionality: Deallocating memory of SearchSpcToAddModList
7341 * @params[in] struct PDCCH_Config__searchSpacesToAddModList *searchSpcList
7345 4221 * ****************************************************************/
7346 void FreeSearchSpcToAddModList(struct PDCCH_Config__searchSpacesToAddModList *searchSpcList)
7350 struct SearchSpace *searchSpc=NULLP;
7352 if(searchSpcList->list.array)
7354 if(searchSpcList->list.array[idx2])
7356 searchSpc = searchSpcList->list.array[idx2];
7357 if(searchSpc->controlResourceSetId)
7359 if(searchSpc->monitoringSlotPeriodicityAndOffset)
7361 if(searchSpc->monitoringSymbolsWithinSlot)
7363 if(searchSpc->monitoringSymbolsWithinSlot->buf)
7365 if(searchSpc->nrofCandidates)
7367 if(searchSpc->searchSpaceType)
7369 DU_FREE(searchSpc->searchSpaceType->choice.ue_Specific,\
7370 sizeof(struct SearchSpace__searchSpaceType__ue_Specific));
7371 DU_FREE(searchSpc->searchSpaceType, sizeof(struct
7372 SearchSpace__searchSpaceType));
7374 DU_FREE(searchSpc->nrofCandidates,
7375 sizeof(struct SearchSpace__nrofCandidates));
7377 DU_FREE(searchSpc->monitoringSymbolsWithinSlot->buf, \
7378 searchSpc->monitoringSymbolsWithinSlot->size);
7380 DU_FREE(searchSpc->monitoringSymbolsWithinSlot,
7381 sizeof(BIT_STRING_t));
7383 DU_FREE(searchSpc->monitoringSlotPeriodicityAndOffset, \
7384 sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
7386 DU_FREE(searchSpc->controlResourceSetId,
7387 sizeof(ControlResourceSetId_t));
7390 for(idx1 = 0; idx1 < searchSpcList->list.count; idx1++)
7392 DU_FREE(searchSpcList->list.array[idx1],
7393 sizeof(struct SearchSpace));
7395 DU_FREE(searchSpcList->list.array,searchSpcList->list.size);
7398 /*******************************************************************
7400 * @brief Frees memory allocated for PdschTimeDomAllocList
7404 * Function : FreePdschTimeDomAllocList
7406 * Functionality: Deallocating memory of PdschTimeDomAllocList
7408 * @params[in] struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
7412 * ****************************************************************/
7413 void FreePdschTimeDomAllocList( struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList)
7417 if(timeDomAllocList->choice.setup)
7419 if(timeDomAllocList->choice.setup->list.array)
7421 for(idx1 = 0; idx1 <timeDomAllocList->choice.setup->list.count ; idx1++)
7423 DU_FREE(timeDomAllocList->choice.setup->list.array[idx1]->k0, sizeof(long));
7424 DU_FREE(timeDomAllocList->choice.setup->list.array[idx1],
7425 sizeof(struct PDSCH_TimeDomainResourceAllocation));
7427 DU_FREE(timeDomAllocList->choice.setup->list.array, \
7428 timeDomAllocList->choice.setup->list.size);
7430 DU_FREE(timeDomAllocList->choice.setup,\
7431 sizeof(struct PDSCH_TimeDomainResourceAllocationList));
7434 /*******************************************************************
7436 * @brief Frees memory allocated for PuschTimeDomAllocList
7440 * Function : FreePuschTimeDomAllocList
7442 * Functionality: Deallocating memory of PuschTimeDomAllocList
7444 * @params[in] PUSCH_Config_t *puschCfg
7448 * ****************************************************************/
7449 void FreePuschTimeDomAllocList(PUSCH_Config_t *puschCfg)
7451 uint8_t rsrcListIdx=0;
7452 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList_t=NULLP;
7454 if(puschCfg->pusch_TimeDomainAllocationList)
7456 timeDomAllocList_t=puschCfg->pusch_TimeDomainAllocationList;
7457 if(timeDomAllocList_t->choice.setup)
7459 if(timeDomAllocList_t->choice.setup->list.array)
7461 for(rsrcListIdx = 0; rsrcListIdx<timeDomAllocList_t->choice.setup->list.count; rsrcListIdx++)
7463 DU_FREE(timeDomAllocList_t->choice.setup->list.array[rsrcListIdx]->k2, sizeof(long));
7464 DU_FREE(timeDomAllocList_t->choice.setup->list.array[rsrcListIdx],\
7465 sizeof(PUSCH_TimeDomainResourceAllocation_t));
7467 DU_FREE(timeDomAllocList_t->choice.setup->list.array, \
7468 timeDomAllocList_t->choice.setup->list.size);
7470 DU_FREE(timeDomAllocList_t->choice.setup, \
7471 sizeof(struct PUSCH_TimeDomainResourceAllocationList));
7473 DU_FREE(puschCfg->transformPrecoder, sizeof(long));
7474 DU_FREE(puschCfg->pusch_TimeDomainAllocationList, \
7475 sizeof(struct PUSCH_Config__pusch_TimeDomainAllocationList));
7480 /*******************************************************************
7482 * @brief Frees memory allocated for Dedicated PUCCH config
7486 * Function : FreeBWPUlDedPucchCfg
7488 * Functionality: Deallocating memory of Dedicated PUCCH cfg
7490 * @params[in] BWP_UplinkDedicated__pucch_Config *ulBwpPucchCfg
7494 * ****************************************************************/
7495 void FreeBWPUlDedPucchCfg(struct BWP_UplinkDedicated__pucch_Config *ulBwpPucchCfg)
7497 uint8_t k1Idx, rsrcIdx, rsrcSetIdx;
7498 PUCCH_Config_t *pucchCfg = NULLP;
7499 PUCCH_ResourceSet_t *rsrcSet = NULLP;
7500 PUCCH_Resource_t *rsrc = NULLP;
7504 if(ulBwpPucchCfg->choice.setup)
7506 pucchCfg = ulBwpPucchCfg->choice.setup;
7508 //Free resource set list
7509 if(pucchCfg->resourceSetToAddModList)
7511 if(pucchCfg->resourceSetToAddModList->list.array)
7513 for(rsrcSetIdx=0; rsrcSetIdx < pucchCfg->resourceSetToAddModList->list.count; rsrcSetIdx++)
7515 rsrcSet = pucchCfg->resourceSetToAddModList->list.array[rsrcSetIdx];
7516 if(rsrcSet->resourceList.list.array)
7518 for(rsrcIdx=0; rsrcIdx < rsrcSet->resourceList.list.count; rsrcIdx++)
7520 DU_FREE(rsrcSet->resourceList.list.array[rsrcIdx], sizeof(PUCCH_ResourceId_t));
7522 DU_FREE(rsrcSet->resourceList.list.array, rsrcSet->resourceList.list.size);
7524 DU_FREE(pucchCfg->resourceSetToAddModList->list.array[rsrcSetIdx], sizeof(PUCCH_ResourceSet_t));
7526 DU_FREE(pucchCfg->resourceSetToAddModList->list.array, pucchCfg->resourceSetToAddModList->list.size);
7528 DU_FREE(pucchCfg->resourceSetToAddModList, sizeof(struct PUCCH_Config__resourceSetToAddModList));
7531 //Free resource list
7532 if(pucchCfg->resourceToAddModList)
7534 if(pucchCfg->resourceToAddModList->list.array)
7536 for(rsrcIdx=0; rsrcIdx < pucchCfg->resourceToAddModList->list.count; rsrcIdx++)
7538 rsrc = pucchCfg->resourceToAddModList->list.array[rsrcIdx];
7539 DU_FREE(rsrc->format.choice.format1, sizeof(PUCCH_format1_t));
7540 DU_FREE(pucchCfg->resourceToAddModList->list.array[rsrcIdx], sizeof(PUCCH_Resource_t));
7542 DU_FREE(pucchCfg->resourceToAddModList->list.array, pucchCfg->resourceToAddModList->list.size);
7544 DU_FREE(pucchCfg->resourceToAddModList, sizeof(struct PUCCH_Config__resourceToAddModList));
7548 if(pucchCfg->format1)
7550 if(pucchCfg->format1->choice.setup)
7552 DU_FREE(pucchCfg->format1->choice.setup->nrofSlots, sizeof(long));
7553 DU_FREE(pucchCfg->format1->choice.setup, sizeof(PUCCH_FormatConfig_t));
7555 DU_FREE(pucchCfg->format1, sizeof(struct PUCCH_Config__format1));
7559 if(pucchCfg->dl_DataToUL_ACK)
7561 if(pucchCfg->dl_DataToUL_ACK->list.array)
7563 for(k1Idx = 0; k1Idx < pucchCfg->dl_DataToUL_ACK->list.count; k1Idx++)
7565 DU_FREE(pucchCfg->dl_DataToUL_ACK->list.array[k1Idx], sizeof(long));
7567 DU_FREE(pucchCfg->dl_DataToUL_ACK->list.array, pucchCfg->dl_DataToUL_ACK->list.size);
7569 DU_FREE(pucchCfg->dl_DataToUL_ACK, sizeof(struct PUCCH_Config__dl_DataToUL_ACK));
7572 DU_FREE(ulBwpPucchCfg->choice.setup, sizeof(PUCCH_Config_t));
7574 DU_FREE(ulBwpPucchCfg, sizeof(struct BWP_UplinkDedicated__pucch_Config));
7578 /*******************************************************************
7580 * @brief Frees memory allocated for InitialUlBWP
7584 * Function : FreeInitialUlBWP
7586 * Functionality: Deallocating memory of InitialUlBWP
7588 * @params[in] BWP_UplinkDedicated_t *ulBwp
7592 * ****************************************************************/
7593 void FreeInitialUlBWP(BWP_UplinkDedicated_t *ulBwp)
7595 uint8_t rSetIdx, rsrcIdx;
7596 SRS_Config_t *srsCfg = NULLP;
7597 PUSCH_Config_t *puschCfg = NULLP;
7598 struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg = NULLP;
7599 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList = NULLP;
7600 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList = NULLP;
7601 struct SRS_Config__srs_ResourceToAddModList *resourceList = NULLP;
7603 FreeBWPUlDedPucchCfg(ulBwp->pucch_Config);
7605 if(ulBwp->pusch_Config)
7607 if(ulBwp->pusch_Config->choice.setup)
7609 puschCfg=ulBwp->pusch_Config->choice.setup;
7610 if(puschCfg->dataScramblingIdentityPUSCH)
7612 if(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
7614 FreePuschTimeDomAllocList(puschCfg);
7615 dmrsUlCfg=puschCfg->dmrs_UplinkForPUSCH_MappingTypeA;
7616 if(dmrsUlCfg->choice.setup)
7618 if(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
7620 if(dmrsUlCfg->choice.setup->transformPrecodingDisabled)
7622 DU_FREE(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0,\
7624 DU_FREE(dmrsUlCfg->choice.setup->transformPrecodingDisabled,
7625 sizeof(struct DMRS_UplinkConfig__transformPrecodingDisabled));
7627 DU_FREE(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition,
7630 DU_FREE(dmrsUlCfg->choice.setup,sizeof(DMRS_UplinkConfig_t));
7632 DU_FREE(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA, \
7633 sizeof(struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA));
7635 DU_FREE(puschCfg->dataScramblingIdentityPUSCH, sizeof(long));
7637 DU_FREE(ulBwp->pusch_Config->choice.setup, sizeof(PUSCH_Config_t));
7639 DU_FREE(ulBwp->pusch_Config, sizeof(struct BWP_UplinkDedicated__pusch_Config));
7641 /* Free SRS-Config */
7642 if(ulBwp->srs_Config)
7644 if(ulBwp->srs_Config->choice.setup)
7646 srsCfg = ulBwp->srs_Config->choice.setup;
7648 /* Free Resource Set to add/mod list */
7649 if(srsCfg->srs_ResourceSetToAddModList)
7651 rsrcSetList = srsCfg->srs_ResourceSetToAddModList;
7652 if(rsrcSetList->list.array)
7656 /* Free SRS resource Id list in this SRS resource set */
7657 if(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
7659 rsrcIdList = rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
7661 if(rsrcIdList->list.array)
7663 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count; rsrcIdx++)
7665 DU_FREE(rsrcIdList->list.array[rsrcIdx], sizeof(SRS_ResourceId_t));
7667 DU_FREE(rsrcIdList->list.array, rsrcIdList->list.size);
7669 DU_FREE(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList,\
7670 sizeof(struct SRS_ResourceSet__srs_ResourceIdList));
7673 /* Free resource type info for this SRS resource set */
7674 DU_FREE(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic, \
7675 sizeof(struct SRS_ResourceSet__resourceType__aperiodic));
7677 /* Free memory for each resource set */
7678 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
7680 DU_FREE(rsrcSetList->list.array[rSetIdx], sizeof(SRS_ResourceSet_t));
7682 DU_FREE(rsrcSetList->list.array, rsrcSetList->list.size);
7684 DU_FREE(srsCfg->srs_ResourceSetToAddModList, \
7685 sizeof(struct SRS_Config__srs_ResourceSetToAddModList));
7688 /* Free resource to add/modd list */
7689 if(srsCfg->srs_ResourceToAddModList)
7691 resourceList = srsCfg->srs_ResourceToAddModList;
7692 if(resourceList->list.array)
7695 DU_FREE(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2,\
7696 sizeof(struct SRS_Resource__transmissionComb__n2));
7697 DU_FREE(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic,\
7698 sizeof(struct SRS_Resource__resourceType__aperiodic));
7700 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
7702 DU_FREE(resourceList->list.array[rsrcIdx], sizeof(SRS_Resource_t));
7704 DU_FREE(resourceList->list.array, resourceList->list.size);
7706 DU_FREE(srsCfg->srs_ResourceToAddModList, \
7707 sizeof(struct SRS_Config__srs_ResourceToAddModList));
7710 DU_FREE(ulBwp->srs_Config->choice.setup, sizeof(SRS_Config_t));
7712 DU_FREE(ulBwp->srs_Config, sizeof(struct BWP_UplinkDedicated__srs_Config));
7716 /*******************************************************************
7718 * @brief Frees memory allocated for initialUplinkBWP
7722 * Function : FreeinitialUplinkBWP
7724 * Functionality: Deallocating memory of initialUplinkBWP
7726 * @params[in] UplinkConfig_t *ulCfg
7731 * ****************************************************************/
7732 void FreeinitialUplinkBWP(UplinkConfig_t *ulCfg)
7734 BWP_UplinkDedicated_t *ulBwp=NULLP;
7735 struct UplinkConfig__pusch_ServingCellConfig *puschCfg=NULLP;
7737 if(ulCfg->initialUplinkBWP)
7739 ulBwp=ulCfg->initialUplinkBWP;
7740 if(ulCfg->firstActiveUplinkBWP_Id)
7742 if(ulCfg->pusch_ServingCellConfig)
7744 puschCfg=ulCfg->pusch_ServingCellConfig;
7745 if(puschCfg->choice.setup)
7747 if(puschCfg->choice.setup->ext1)
7749 DU_FREE(puschCfg->choice.setup->ext1->\
7750 processingType2Enabled,sizeof(BOOLEAN_t));
7751 DU_FREE(puschCfg->choice.setup->ext1->\
7752 maxMIMO_Layers,sizeof(long));
7753 DU_FREE(puschCfg->choice.setup->ext1, \
7754 sizeof(struct PUSCH_ServingCellConfig__ext1));
7756 DU_FREE(puschCfg->choice.setup, sizeof(struct PUSCH_ServingCellConfig));
7758 DU_FREE(ulCfg->pusch_ServingCellConfig, sizeof(struct UplinkConfig__pusch_ServingCellConfig));
7760 DU_FREE(ulCfg->firstActiveUplinkBWP_Id, sizeof(BWP_Id_t));
7762 FreeInitialUlBWP(ulBwp);
7763 DU_FREE(ulCfg->initialUplinkBWP, sizeof(BWP_UplinkDedicated_t));
7766 /*******************************************************************
7768 * @brief Frees emmory allocated for BWPDlDedPdschCfg
7772 * Function : FreeBWPDlDedPdschCfg
7774 * Functionality: Deallocating memory of BWPDlDedPdschCfg
7776 * @params[in] BWP_DownlinkDedicated_t *dlBwp
7781 * ****************************************************************/
7782 void FreeBWPDlDedPdschCfg(BWP_DownlinkDedicated_t *dlBwp)
7784 struct PDSCH_Config *pdschCfg=NULLP;
7785 struct PDSCH_Config__prb_BundlingType *prbBndlType=NULLP;
7786 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList=NULLP;
7787 struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg=NULLP;
7789 if(dlBwp->pdsch_Config->choice.setup)
7791 pdschCfg=dlBwp->pdsch_Config->choice.setup;
7792 if(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
7794 if(pdschCfg->pdsch_TimeDomainAllocationList)
7796 timeDomAllocList=pdschCfg->pdsch_TimeDomainAllocationList;
7797 if(pdschCfg->maxNrofCodeWordsScheduledByDCI)
7799 prbBndlType=&pdschCfg->prb_BundlingType;
7800 DU_FREE(prbBndlType->choice.staticBundling,\
7801 sizeof(struct PDSCH_Config__prb_BundlingType__staticBundling));
7802 DU_FREE(pdschCfg->maxNrofCodeWordsScheduledByDCI, sizeof(long));
7804 FreePdschTimeDomAllocList(timeDomAllocList);
7805 DU_FREE(pdschCfg->pdsch_TimeDomainAllocationList, \
7806 sizeof(struct PDSCH_Config__pdsch_TimeDomainAllocationList));
7808 dmrsDlCfg=pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA;
7809 if(dmrsDlCfg->choice.setup)
7811 DU_FREE(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition,
7813 DU_FREE(dmrsDlCfg->choice.setup, sizeof(struct DMRS_DownlinkConfig));
7815 DU_FREE(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA, \
7816 sizeof(struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA));
7818 DU_FREE(dlBwp->pdsch_Config->choice.setup, sizeof(struct PDSCH_Config));
7821 /*******************************************************************
7823 * @brief Frees emmory allocated for BWPDlDedPdcchCfg
7827 * Function : FreeBWPDlDedPdcchCfg
7829 * Functionality: Deallocating memory of BWPDlDedPdcchCfg
7831 * @params[in] BWP_DownlinkDedicated_t *dlBwp
7836 * ****************************************************************/
7837 void FreeBWPDlDedPdcchCfg(BWP_DownlinkDedicated_t *dlBwp)
7841 struct PDCCH_Config *pdcchCfg=NULLP;
7842 struct ControlResourceSet *controlRSet=NULLP;
7843 struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList=NULLP;
7845 if(dlBwp->pdcch_Config->choice.setup)
7847 pdcchCfg=dlBwp->pdcch_Config->choice.setup;
7848 if(pdcchCfg->controlResourceSetToAddModList)
7850 controlRSetList = pdcchCfg->controlResourceSetToAddModList;
7851 if(controlRSetList->list.array)
7853 controlRSet = controlRSetList->list.array[idx2];
7856 if(controlRSet->frequencyDomainResources.buf)
7858 if(controlRSet->pdcch_DMRS_ScramblingID)
7860 if(pdcchCfg->searchSpacesToAddModList)
7862 FreeSearchSpcToAddModList(pdcchCfg->searchSpacesToAddModList);
7863 DU_FREE(pdcchCfg->searchSpacesToAddModList, \
7864 sizeof(struct PDCCH_Config__searchSpacesToAddModList));
7866 DU_FREE(controlRSet->pdcch_DMRS_ScramblingID, sizeof(long));
7868 DU_FREE(controlRSet->frequencyDomainResources.buf, \
7869 controlRSet->frequencyDomainResources.size);
7872 for(idx1 = 0; idx1 <controlRSetList->list.count; idx1++)
7874 DU_FREE(controlRSetList->list.array[idx1], sizeof(struct ControlResourceSet));
7876 DU_FREE(controlRSetList->list.array, controlRSetList->list.size);
7878 DU_FREE(pdcchCfg->controlResourceSetToAddModList, \
7879 sizeof(struct PDCCH_Config__controlResourceSetToAddModList));
7881 DU_FREE(dlBwp->pdcch_Config->choice.setup, sizeof(struct PDCCH_Config));
7885 /*******************************************************************
7887 * @brief Free SCS specific carrier list in DL frequency info
7891 * Function : FreeScsSpecificCarrierListDl
7893 * Functionality: Free SCS specific carrier list in DL frequency info
7895 * @params[in] Pointer to struct FrequencyInfoDL__scs_SpecificCarrierList
7899 * ****************************************************************/
7900 void FreeScsSpecificCarrierListDl(struct FrequencyInfoDL__scs_SpecificCarrierList *scsCarrierList)
7902 uint8_t listIdx = 0;
7904 if(!scsCarrierList->list.array)
7906 for(listIdx = 0; listIdx < scsCarrierList->list.count; listIdx++)
7908 DU_FREE(scsCarrierList->list.array[listIdx], sizeof(SCS_SpecificCarrier_t));
7910 DU_FREE(scsCarrierList->list.array, scsCarrierList->list.size);
7914 /*******************************************************************
7916 * @brief Free DL frequency info in DL config common
7920 * Function : FreeFreqInfoDl
7922 * Functionality: Free DL frequency info in DL config common
7924 * @params[in] Pointer to DownlinkConfigCommon_t
7928 * ****************************************************************/
7929 void FreeFreqInfoDl(FrequencyInfoDL_t *frequencyInfoDL)
7931 uint8_t freqBandIdx = 0;
7933 /* SSB Absolute Frequency */
7934 DU_FREE(frequencyInfoDL->absoluteFrequencySSB, sizeof(ARFCN_ValueNR_t));
7936 /* NR Multi Frequency Band List */
7937 if(frequencyInfoDL->frequencyBandList.list.array)
7939 for(freqBandIdx = 0; freqBandIdx < frequencyInfoDL->frequencyBandList.list.count; freqBandIdx++)
7941 DU_FREE(frequencyInfoDL->frequencyBandList.list.array[freqBandIdx], sizeof(FreqBandIndicatorNR_t));
7943 DU_FREE(frequencyInfoDL->frequencyBandList.list.array, frequencyInfoDL->frequencyBandList.list.size);
7946 /* Subcarrier Spacing specifc carrier List */
7947 FreeScsSpecificCarrierListDl(&frequencyInfoDL->scs_SpecificCarrierList);
7950 /*******************************************************************
7952 * @brief Free DL config common in Serving cell config common
7956 * Function : FreeDlConfigCommon
7958 * Functionality: Free DL config common in Serving cell config common
7960 * @params[in] Pointer to DownlinkConfigCommon_t
7964 * ****************************************************************/
7965 void FreeDlConfigCommon(DownlinkConfigCommon_t *dlCfgCommon)
7967 /* DL Frequency Info */
7968 if(dlCfgCommon->frequencyInfoDL)
7970 FreeFreqInfoDl(dlCfgCommon->frequencyInfoDL);
7971 DU_FREE(dlCfgCommon->frequencyInfoDL, sizeof(FrequencyInfoDL_t));
7974 /* DL BWP config common */
7975 if(dlCfgCommon->initialDownlinkBWP)
7977 FreeBwpDlCommon(dlCfgCommon->initialDownlinkBWP);
7978 DU_FREE(dlCfgCommon->initialDownlinkBWP, sizeof(BWP_DownlinkCommon_t));
7982 /*******************************************************************
7984 * @brief Free SCS specific carrier list in UL frequency Info
7988 * Function : FreeScsSpecificCarrierListUl
7990 * Functionality: Free SCS specific carrier list in UL frequency Info
7992 * @params[in] Pointer to struct FrequencyInfoUL__scs_SpecificCarrierList
7996 * ****************************************************************/
7997 void FreeScsSpecificCarrierListUl(struct FrequencyInfoUL__scs_SpecificCarrierList *scsCarrierList)
7999 uint8_t listIdx = 0;
8001 if(scsCarrierList->list.array)
8003 for(listIdx = 0; listIdx < scsCarrierList->list.count; listIdx++)
8005 DU_FREE(scsCarrierList->list.array[listIdx], sizeof(SCS_SpecificCarrier_t));
8007 DU_FREE(scsCarrierList->list.array, scsCarrierList->list.size);
8011 /*******************************************************************
8013 * @brief Free frequency info in UL config common
8017 * Function : FreeFreqInfoUl
8019 * Functionality: Free frequency info in UL config common
8021 * @params[in] Pointer to FrequencyInfoUL_t
8025 * ****************************************************************/
8026 void FreeFreqInfoUl(FrequencyInfoUL_t *frequencyInfoUL)
8030 /* NR Multi Frequency Band List */
8031 if(!frequencyInfoUL->frequencyBandList)
8033 if(frequencyInfoUL->frequencyBandList->list.array)
8035 for(listIdx = 0; listIdx < frequencyInfoUL->frequencyBandList->list.count; listIdx++)
8037 DU_FREE(frequencyInfoUL->frequencyBandList->list.array[listIdx], sizeof(FreqBandIndicatorNR_t));
8039 DU_FREE(frequencyInfoUL->frequencyBandList->list.array, frequencyInfoUL->frequencyBandList->list.size);
8041 DU_FREE(frequencyInfoUL->frequencyBandList, sizeof(MultiFrequencyBandListNR_t));
8044 /* Absolute frequency point A */
8045 DU_FREE(frequencyInfoUL->absoluteFrequencyPointA, sizeof(ARFCN_ValueNR_t));
8047 /* Subcarrier Spacing specifc carrier */
8048 FreeScsSpecificCarrierListUl(&frequencyInfoUL->scs_SpecificCarrierList);
8051 DU_FREE(frequencyInfoUL->p_Max, sizeof(P_Max_t));
8054 /*******************************************************************
8056 * @brief Free UL config common in Serving cell config common
8060 * Function : FreeUlConfigCommon
8062 * Functionality: Free UL config common in Serving cell config common
8064 * @params[in] Pointer to UplinkConfigCommon_t
8068 * ****************************************************************/
8069 void FreeUlConfigCommon(UplinkConfigCommon_t *ulCfgCommon)
8071 /* UL Frequency Info */
8072 if(ulCfgCommon->frequencyInfoUL)
8074 FreeFreqInfoUl(ulCfgCommon->frequencyInfoUL);
8075 DU_FREE(ulCfgCommon->frequencyInfoUL, sizeof(FrequencyInfoUL_t));
8079 if(ulCfgCommon->initialUplinkBWP)
8081 FreeBwpUlCommon(ulCfgCommon->initialUplinkBWP);
8082 DU_FREE(ulCfgCommon->initialUplinkBWP, sizeof(BWP_UplinkCommon_t));
8086 /*******************************************************************
8088 * @brief Free SP cell config common in Reconfig with Sync
8092 * Function : FreeSpCellConfigCommon
8094 * Functionality: Free SP cell config common in Reconfig with Sync
8096 * @params[in] Pointer to ServingCellConfigCommon_t
8100 * ****************************************************************/
8101 void FreeSpCellConfigCommon(ServingCellConfigCommon_t *spCellConfigCommon)
8103 /* Free Physical cell identity */
8104 DU_FREE(spCellConfigCommon->physCellId, sizeof(PhysCellId_t));
8106 /* Free Downlink Config common */
8107 if(spCellConfigCommon->downlinkConfigCommon)
8109 FreeDlConfigCommon(spCellConfigCommon->downlinkConfigCommon);
8110 DU_FREE(spCellConfigCommon->downlinkConfigCommon, sizeof(DownlinkConfigCommon_t));
8113 /* Free Uplink Config common */
8114 if(spCellConfigCommon->uplinkConfigCommon)
8116 FreeUlConfigCommon(spCellConfigCommon->uplinkConfigCommon);
8117 DU_FREE(spCellConfigCommon->uplinkConfigCommon, sizeof(UplinkConfigCommon_t));
8120 /* Free Timing Advance offset */
8121 DU_FREE(spCellConfigCommon->n_TimingAdvanceOffset, sizeof(long));
8123 /* Free SSB Position in Burst */
8124 if(spCellConfigCommon->ssb_PositionsInBurst)
8126 DU_FREE(spCellConfigCommon->ssb_PositionsInBurst->choice.mediumBitmap.buf, \
8127 spCellConfigCommon->ssb_PositionsInBurst->choice.mediumBitmap.size);
8128 DU_FREE(spCellConfigCommon->ssb_PositionsInBurst, sizeof(struct ServingCellConfigCommon__ssb_PositionsInBurst));
8131 /* Free SSB Periodicity in Serving cell */
8132 DU_FREE(spCellConfigCommon->ssb_periodicityServingCell, sizeof(long));
8134 /* Free SSB subcarrier spacing */
8135 DU_FREE(spCellConfigCommon->ssbSubcarrierSpacing, sizeof(SubcarrierSpacing_t));
8137 /* TDD UL-DL configuration common */
8138 DU_FREE(spCellConfigCommon->tdd_UL_DL_ConfigurationCommon, sizeof(TDD_UL_DL_ConfigCommon_t));
8141 /*******************************************************************
8143 * @brief Free dedicated RACH configuration in Reconfiguration with sync
8147 * Function : FreeRecfgWithSync
8150 * Free dedicated RACH configuration in Reconfiguration with sync
8152 * @params[in] Pinter to Rach config dedicated struct
8156 * ****************************************************************/
8157 void FreeRachConfigDedicated(struct ReconfigurationWithSync__rach_ConfigDedicated *rachCfgDed)
8159 uint8_t listIdx = 0;
8160 CFRA_t *cfra = NULLP;
8161 struct CFRA__resources__ssb *ssbResource = NULLP;
8164 if(rachCfgDed->choice.uplink)
8166 /* CFRA : Contention free Random Access */
8167 if(rachCfgDed->choice.uplink->cfra)
8169 cfra = rachCfgDed->choice.uplink->cfra;
8171 /* CFRA occassions */
8174 /* CFRA occassions : SSB per RACH occasion */
8175 DU_FREE(cfra->occasions->ssb_perRACH_Occasion, sizeof(long));
8176 DU_FREE(cfra->occasions, sizeof(struct CFRA__occasions));
8180 cfra->resources.present = CFRA__resources_PR_ssb;
8182 /* CFRA resource : SSB */
8183 if(cfra->resources.choice.ssb)
8185 ssbResource = cfra->resources.choice.ssb;
8187 /* CFRA SSB resource list */
8188 if(ssbResource->ssb_ResourceList.list.array)
8190 for(listIdx = 0; listIdx < ssbResource->ssb_ResourceList.list.count; listIdx++)
8192 DU_FREE(ssbResource->ssb_ResourceList.list.array[listIdx], sizeof(CFRA_SSB_Resource_t));
8194 DU_FREE(ssbResource->ssb_ResourceList.list.array, ssbResource->ssb_ResourceList.list.size);
8196 DU_FREE(cfra->resources.choice.ssb, sizeof(struct CFRA__resources__ssb));
8198 DU_FREE(rachCfgDed->choice.uplink->cfra, sizeof(CFRA_t));
8200 DU_FREE(rachCfgDed->choice.uplink, sizeof(RACH_ConfigDedicated_t));
8204 /*******************************************************************
8206 * @brief Frees reconfiguration with sync in SP cell config
8210 * Function : FreeRecfgWithSync
8212 * Functionality: Fress reconfiguration with sync in SP cell config
8214 * @params[in] Pointer to ReconfigurationWithSync_t
8218 * ****************************************************************/
8219 void FreeRecfgWithSync(ReconfigurationWithSync_t *recfgWithSync)
8221 /* Free SP Cell config common */
8222 if(recfgWithSync->spCellConfigCommon)
8224 FreeSpCellConfigCommon(recfgWithSync->spCellConfigCommon);
8225 DU_FREE(recfgWithSync->spCellConfigCommon, sizeof(ServingCellConfigCommon_t));
8228 /* Free Dedicated RACH configuration */
8229 if(recfgWithSync->rach_ConfigDedicated)
8231 FreeRachConfigDedicated(recfgWithSync->rach_ConfigDedicated);
8232 DU_FREE(recfgWithSync->rach_ConfigDedicated, sizeof(struct ReconfigurationWithSync__rach_ConfigDedicated));
8236 /*******************************************************************
8238 * @brief Frees emmory allocated for DUToCURRCContainer
8242 * Function : FreeMemDuToCuRrcCont
8244 * Functionality: Deallocating memory of DuToCuRrcContainer
8246 * @params[in] DuToCuRRCContainer, DuToCuRRCContainer
8248 * @return ROK - success
8251 * ****************************************************************/
8252 uint8_t FreeMemDuToCuRrcCont(CellGroupConfigRrc_t *cellGrpCfg)
8255 SpCellConfig_t *spCellCfg=NULLP;
8256 ServingCellConfig_t *srvCellCfg=NULLP;
8257 BWP_DownlinkDedicated_t *dlBwp=NULLP;
8258 MAC_CellGroupConfig_t *macCellGrpCfg=NULLP;
8259 PhysicalCellGroupConfig_t *phyCellGrpCfg=NULLP;
8260 struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList=NULLP;
8261 struct RLC_Config *rlcConfig=NULLP;
8262 struct LogicalChannelConfig *macLcConfig=NULLP;
8263 struct MAC_CellGroupConfig__drx_ConfigRrc *drxCfg=NULLP;
8264 struct SchedulingRequestConfig *schedulingRequestConfig=NULLP;
8265 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList=NULLP;
8266 struct TAG_Config *tagConfig=NULLP;
8267 struct TAG_Config__tag_ToAddModList *tagList=NULLP;
8268 struct MAC_CellGroupConfig__phr_Config *phrConfig=NULLP;
8269 struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg=NULLP;
8271 rlcBearerList = cellGrpCfg->rlc_BearerToAddModList;
8274 if(rlcBearerList->list.array)
8276 for(idx=0; idx<rlcBearerList->list.count; idx++)
8278 if(rlcBearerList->list.array[idx])
8280 rlcConfig = rlcBearerList->list.array[idx]->rlc_Config;
8281 macLcConfig = rlcBearerList->list.array[idx]->mac_LogicalChannelConfig;
8284 switch(rlcConfig->present)
8286 case RLC_Config_PR_NOTHING:
8289 case RLC_Config_PR_am:
8291 if(rlcConfig->choice.am)
8293 DU_FREE(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
8294 DU_FREE(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
8295 DU_FREE(rlcConfig->choice.am, sizeof(struct RLC_Config__am));
8299 case RLC_Config_PR_um_Bi_Directional:
8301 if(rlcConfig->choice.um_Bi_Directional)
8303 DU_FREE(rlcConfig->choice.um_Bi_Directional->dl_UM_RLC.sn_FieldLength, sizeof(SN_FieldLengthUM_t));
8304 DU_FREE(rlcConfig->choice.um_Bi_Directional->ul_UM_RLC.sn_FieldLength, sizeof(SN_FieldLengthUM_t));
8305 DU_FREE(rlcConfig->choice.um_Bi_Directional, sizeof(struct RLC_Config__um_Bi_Directional));
8309 case RLC_Config_PR_um_Uni_Directional_UL:
8311 if(rlcConfig->choice.um_Uni_Directional_UL)
8313 DU_FREE(rlcConfig->choice.um_Uni_Directional_UL->ul_UM_RLC.sn_FieldLength, sizeof(SN_FieldLengthUM_t));
8314 DU_FREE(rlcConfig->choice.um_Uni_Directional_UL , sizeof(struct RLC_Config__um_Uni_Directional_UL));
8318 case RLC_Config_PR_um_Uni_Directional_DL:
8320 if(rlcConfig->choice.um_Uni_Directional_DL )
8322 DU_FREE(rlcConfig->choice.um_Uni_Directional_DL->dl_UM_RLC.sn_FieldLength, sizeof(SN_FieldLengthUM_t));
8323 DU_FREE(rlcConfig->choice.um_Uni_Directional_DL , sizeof(struct RLC_Config__um_Uni_Directional_DL));
8328 DU_FREE(rlcConfig, sizeof(struct RLC_Config));
8330 DU_FREE(rlcBearerList->list.array[idx]->servedRadioBearer, sizeof(struct RLC_BearerConfig__servedRadioBearer));
8333 if(macLcConfig->ul_SpecificParameters)
8335 DU_FREE(macLcConfig->ul_SpecificParameters->schedulingRequestID, sizeof(SchedulingRequestId_t));
8336 DU_FREE(macLcConfig->ul_SpecificParameters->logicalChannelGroup, sizeof(long));
8337 DU_FREE(macLcConfig->ul_SpecificParameters, sizeof(struct LogicalChannelConfig__ul_SpecificParameters));
8339 DU_FREE(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig, sizeof(struct LogicalChannelConfig));
8341 DU_FREE(rlcBearerList->list.array[idx], sizeof(struct RLC_BearerConfig));
8344 DU_FREE(rlcBearerList->list.array, rlcBearerList->list.size);
8346 DU_FREE(cellGrpCfg->rlc_BearerToAddModList, sizeof(struct CellGroupConfigRrc__rlc_BearerToAddModList));
8349 macCellGrpCfg = cellGrpCfg->mac_CellGroupConfig;
8352 drxCfg = macCellGrpCfg->drx_ConfigRrc;
8356 switch(drxCfg->present)
8358 case MAC_CellGroupConfig__drx_ConfigRrc_PR_NOTHING:
8360 case MAC_CellGroupConfig__drx_ConfigRrc_PR_setup:
8362 if(drxCfg->choice.setup)
8364 DU_FREE(drxCfg->choice.setup->shortDRX, sizeof(struct DRX_ConfigRrc__shortDRX));
8365 DU_FREE(drxCfg->choice.setup, sizeof(struct DRX_ConfigRrc));
8368 case MAC_CellGroupConfig__drx_ConfigRrc_PR_release:
8371 DU_FREE(drxCfg, sizeof(struct MAC_CellGroupConfig__drx_ConfigRrc));
8373 schedulingRequestConfig = macCellGrpCfg->schedulingRequestConfig;
8374 if(schedulingRequestConfig)
8376 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
8379 if(schReqList->list.array)
8381 for(idx=0;idx<schReqList->list.count; idx++)
8383 if(schReqList->list.array[idx])
8385 DU_FREE(schReqList->list.array[idx]->sr_ProhibitTimer, sizeof(long));
8386 DU_FREE(schReqList->list.array[idx], sizeof(struct SchedulingRequestToAddMod));
8389 DU_FREE(schReqList->list.array, schReqList->list.size);
8391 DU_FREE(schedulingRequestConfig->schedulingRequestToAddModList,\
8392 sizeof(struct SchedulingRequestConfig__schedulingRequestToAddModList)); }
8393 DU_FREE(macCellGrpCfg->schedulingRequestConfig, sizeof(struct SchedulingRequestConfig));
8395 if(macCellGrpCfg->bsr_Config)
8397 DU_FREE(macCellGrpCfg->bsr_Config->logicalChannelSR_DelayTimer, sizeof(long));
8398 DU_FREE(macCellGrpCfg->bsr_Config, sizeof(struct BSR_Config));
8400 tagConfig = macCellGrpCfg->tag_Config;
8403 tagList = tagConfig->tag_ToAddModList;
8406 if(tagList->list.array)
8408 for(idx=0; idx<tagList->list.count; idx++)
8410 DU_FREE(tagList->list.array[idx], sizeof(struct TAG));
8412 DU_FREE(tagList->list.array, tagList->list.size);
8414 DU_FREE(tagConfig->tag_ToAddModList, sizeof(struct TAG_Config__tag_ToAddModList));
8416 DU_FREE(tagConfig, sizeof(struct TAG_Config));
8419 phrConfig = macCellGrpCfg->phr_Config;
8422 DU_FREE(phrConfig->choice.setup, sizeof(struct PHR_Config));
8423 DU_FREE(phrConfig, sizeof(struct MAC_CellGroupConfig__phr_Config));
8426 DU_FREE(macCellGrpCfg, sizeof(MAC_CellGroupConfig_t));
8429 phyCellGrpCfg = cellGrpCfg->physicalCellGroupConfig;
8432 DU_FREE(phyCellGrpCfg->p_NR_FR1, sizeof(long));
8433 DU_FREE(phyCellGrpCfg, sizeof(PhysicalCellGroupConfig_t));
8436 spCellCfg = cellGrpCfg->spCellConfig;
8439 /* Free serving cell index */
8440 DU_FREE(spCellCfg->servCellIndex, sizeof(long));
8442 /* Free Reconfiguration with sync */
8443 if(spCellCfg->reconfigurationWithSync)
8445 FreeRecfgWithSync(spCellCfg->reconfigurationWithSync);
8446 DU_FREE(spCellCfg->reconfigurationWithSync, sizeof(ReconfigurationWithSync_t));
8449 /* Free rlmInSyncOutOfSyncThreshold */
8450 DU_FREE(spCellCfg->rlmInSyncOutOfSyncThreshold, sizeof(long));
8452 /* Free SP Cell config dedicated */
8453 if(spCellCfg->spCellConfigDedicated)
8455 srvCellCfg = spCellCfg->spCellConfigDedicated;
8457 /* Free TDD UL-DL config dedicated */
8458 DU_FREE(srvCellCfg->tdd_UL_DL_ConfigurationDedicated, sizeof(TDD_UL_DL_ConfigDedicated_t));
8460 /* Free Initial Downlink BWP */
8461 if(srvCellCfg->initialDownlinkBWP)
8463 dlBwp = srvCellCfg->initialDownlinkBWP;
8465 /* Free DL BWP PDCCH Config */
8466 if(dlBwp->pdcch_Config)
8468 FreeBWPDlDedPdcchCfg(dlBwp);
8469 DU_FREE(dlBwp->pdcch_Config, sizeof(struct BWP_DownlinkDedicated__pdcch_Config));
8472 /* Free DL BWP PDSCH config */
8473 if(dlBwp->pdsch_Config)
8475 FreeBWPDlDedPdschCfg(dlBwp);
8476 DU_FREE(dlBwp->pdsch_Config, sizeof(struct BWP_DownlinkDedicated__pdsch_Config));
8478 DU_FREE(srvCellCfg->initialDownlinkBWP, sizeof(BWP_DownlinkDedicated_t));
8481 /* Free First Active Downlink BWP */
8482 DU_FREE(srvCellCfg->firstActiveDownlinkBWP_Id, sizeof(long));
8484 /* Free Default downlink BWP */
8485 DU_FREE(srvCellCfg->defaultDownlinkBWP_Id, sizeof(long));
8487 /* Free Uplink config */
8488 if(srvCellCfg->uplinkConfig)
8490 FreeinitialUplinkBWP(srvCellCfg->uplinkConfig);
8491 DU_FREE(srvCellCfg->uplinkConfig, sizeof(UplinkConfig_t));
8494 /* Free PDSCH serving cell config */
8495 if(srvCellCfg->pdsch_ServingCellConfig)
8497 pdschCfg= srvCellCfg->pdsch_ServingCellConfig;
8498 if(pdschCfg->choice.setup)
8500 DU_FREE(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH,sizeof(long));
8501 DU_FREE(pdschCfg->choice.setup, sizeof(struct PDSCH_ServingCellConfig));
8503 DU_FREE(srvCellCfg->pdsch_ServingCellConfig, sizeof(struct ServingCellConfig__pdsch_ServingCellConfig));
8506 DU_FREE(spCellCfg->spCellConfigDedicated, sizeof(ServingCellConfig_t));
8508 DU_FREE(spCellCfg,sizeof(SpCellConfig_t));
8513 /*******************************************************************
8515 * @brief Builds CellGroupConfigRrc for DU To CU RRC Container
8519 * Function : BuildCellGroupConfigRrc
8521 * Functionality: Builds and copied Cell group config buffer into
8522 * DuToCuRrcContainer
8524 * @params[in] idx, index in F1AP msg
8525 * DuToCuRRCContainer, DuToCuRRCContainer
8527 * @return ROK - success
8530 * ****************************************************************/
8531 uint8_t BuildCellGroupConfigRrc(DuUeCb *ueCb, OCTET_STRING_t *duToCuRrcContainer)
8534 CellGroupConfigRrc_t cellGrpCfg;
8535 asn_enc_rval_t encRetVal;
8536 memset(&cellGrpCfg, 0, sizeof(CellGroupConfigRrc_t));
8537 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
8541 cellGrpCfg.cellGroupId = CELL_GRP_ID;
8543 cellGrpCfg.rlc_BearerToAddModList = NULLP;
8544 DU_ALLOC(cellGrpCfg.rlc_BearerToAddModList, sizeof(struct CellGroupConfigRrc__rlc_BearerToAddModList));
8545 if(!cellGrpCfg.rlc_BearerToAddModList)
8547 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
8551 if(BuildRlcBearerToAddModList(ueCb, cellGrpCfg.rlc_BearerToAddModList) != ROK)
8553 DU_LOG("\nERROR --> F1AP : BuildRlcBearerToAddModList failed");
8558 cellGrpCfg.rlc_BearerToReleaseList = NULLP;
8559 cellGrpCfg.mac_CellGroupConfig = NULLP;
8560 DU_ALLOC(cellGrpCfg.mac_CellGroupConfig, sizeof(MAC_CellGroupConfig_t));
8561 if(!cellGrpCfg.mac_CellGroupConfig)
8563 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
8567 if(BuildMacCellGrpCfg(ueCb, cellGrpCfg.mac_CellGroupConfig) != ROK)
8569 DU_LOG("\nERROR --> F1AP : BuildMacCellGrpCfg failed");
8574 cellGrpCfg.physicalCellGroupConfig = NULLP;
8575 DU_ALLOC(cellGrpCfg.physicalCellGroupConfig, sizeof(PhysicalCellGroupConfig_t));
8576 if(!cellGrpCfg.physicalCellGroupConfig)
8578 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
8582 if(BuildPhyCellGrpCfg(ueCb, cellGrpCfg.physicalCellGroupConfig) != ROK)
8584 DU_LOG("\nERROR --> F1AP : BuildPhyCellGrpCfg failed");
8589 cellGrpCfg.spCellConfig = NULLP;
8590 DU_ALLOC(cellGrpCfg.spCellConfig, sizeof(SpCellConfig_t));
8591 if(!cellGrpCfg.spCellConfig)
8593 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
8597 if(BuildSpCellCfg(ueCb, cellGrpCfg.spCellConfig) != ROK)
8599 DU_LOG("\nERROR --> F1AP : BuildSpCellCfg failed");
8604 cellGrpCfg.sCellToAddModList = NULLP;
8605 cellGrpCfg.sCellToReleaseList = NULLP;
8606 cellGrpCfg.ext1 = NULLP;
8608 /* encode cellGrpCfg into duToCuRrcContainer */
8609 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, &cellGrpCfg);
8610 memset(encBuf, 0, ENC_BUF_MAX_LEN);
8612 encRetVal = uper_encode(&asn_DEF_CellGroupConfigRrc, 0, &cellGrpCfg, PrepFinalEncBuf, encBuf);
8613 /* Encode results */
8614 if(encRetVal.encoded == ENCODE_FAIL)
8616 DU_LOG( "\nERROR --> F1AP : Could not encode DuToCuRrcContainer (at %s)\n",\
8617 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
8623 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for DuToCuRrcContainer\n");
8624 #ifdef DEBUG_ASN_PRINT
8625 for(int i=0; i< encBufSize; i++)
8627 printf("%x",encBuf[i]);
8632 duToCuRrcContainer->size = encBufSize;
8633 DU_ALLOC(duToCuRrcContainer->buf, duToCuRrcContainer->size);
8634 if(!duToCuRrcContainer->buf)
8636 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDuToCuRrcContainer");
8642 memcpy(duToCuRrcContainer->buf, encBuf, duToCuRrcContainer->size);
8646 FreeMemDuToCuRrcCont(&cellGrpCfg);
8650 /*******************************************************************
8652 * @brief Free memory allocated in InitialULRRCMessage
8656 * Function : freeInitUlRrcMsgTransfer
8658 * Functionality: Free memory allocated in InitialULRRCMessage
8660 * @params[in]F1AP_PDU_t *f1apMsg)
8662 * @return ROK - success
8665 * ****************************************************************/
8667 uint8_t freeInitUlRrcMsgTransfer(F1AP_PDU_t *f1apMsg)
8669 uint8_t ieIdx, arrIdx;
8670 InitialULRRCMessageTransfer_t *initULRRCMsg=NULLP;
8674 if(f1apMsg->choice.initiatingMessage)
8676 initULRRCMsg = &f1apMsg->choice.initiatingMessage->value.\
8677 choice.InitialULRRCMessageTransfer;
8678 if(initULRRCMsg->protocolIEs.list.array)
8680 for(ieIdx = 0; ieIdx < initULRRCMsg->protocolIEs.list.count; ieIdx++)
8682 switch(initULRRCMsg->protocolIEs.list.array[ieIdx]->id)
8684 case ProtocolIE_ID_id_NRCGI:
8686 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.buf)
8688 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.buf)
8690 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.buf,\
8691 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.size);
8693 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.buf,\
8694 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.size);
8698 case ProtocolIE_ID_id_RRCContainer:
8700 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
8702 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf,\
8703 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size);
8707 case ProtocolIE_ID_id_DUtoCURRCContainer:
8709 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.buf)
8711 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.buf,
8712 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.size);
8720 for(arrIdx = 0; arrIdx < ieIdx; arrIdx++)
8722 if(initULRRCMsg->protocolIEs.list.array[arrIdx])
8724 DU_FREE(initULRRCMsg->protocolIEs.list.array[arrIdx],\
8725 sizeof(InitialULRRCMessageTransferIEs_t));
8728 DU_FREE(initULRRCMsg->protocolIEs.list.array, initULRRCMsg->protocolIEs.list.size);
8730 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
8732 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
8736 DU_LOG("\nERROR --> DU_APP : Recevied F1ap Pdu is null at freeInitUlRrcMsgTransfer()");
8742 /*******************************************************************
8744 * @brief Builds and sends the InitialULRRCMessage
8748 * Function : BuildAndSendInitialRrcMsgTransfer
8750 * Functionality: Constructs the Initial UL RRC Message Transfer and sends
8751 * it to the CU through SCTP.
8755 * @return ROK - success
8758 * ****************************************************************/
8759 uint8_t BuildAndSendInitialRrcMsgTransfer(uint32_t gnbDuUeF1apId, uint16_t crnti,
8760 uint16_t rrcContSize, uint8_t *rrcContainer)
8764 uint8_t ieIdx, cellIdx, ueIdx;
8765 DuUeCb *duUeCb = NULLP;
8766 asn_enc_rval_t encRetVal;
8767 F1AP_PDU_t *f1apMsg = NULLP;
8768 InitialULRRCMessageTransfer_t *initULRRCMsg = NULLP;
8769 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
8773 DU_LOG("\n INFO --> F1AP : Building RRC Setup Request\n");
8774 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
8775 if(f1apMsg == NULLP)
8777 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
8780 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
8781 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
8782 if(f1apMsg->choice.initiatingMessage == NULLP)
8784 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
8787 f1apMsg->choice.initiatingMessage->procedureCode =\
8788 ProcedureCode_id_InitialULRRCMessageTransfer;
8789 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
8790 f1apMsg->choice.initiatingMessage->value.present = \
8791 InitiatingMessage__value_PR_InitialULRRCMessageTransfer;
8793 &f1apMsg->choice.initiatingMessage->value.choice.InitialULRRCMessageTransfer;
8795 initULRRCMsg->protocolIEs.list.count = elementCnt;
8796 initULRRCMsg->protocolIEs.list.size = \
8797 elementCnt * sizeof(InitialULRRCMessageTransferIEs_t *);
8798 /* Initialize the F1Setup members */
8799 DU_ALLOC(initULRRCMsg->protocolIEs.list.array,initULRRCMsg->protocolIEs.list.size);
8800 if(initULRRCMsg->protocolIEs.list.array == NULLP)
8802 DU_LOG(" ERROR --> F1AP : Memory allocation for\
8803 RRCSetupRequestMessageTransferIEs failed");
8806 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
8808 DU_ALLOC(initULRRCMsg->protocolIEs.list.array[ieIdx],\
8809 sizeof(InitialULRRCMessageTransferIEs_t));
8810 if(initULRRCMsg->protocolIEs.list.array[ieIdx] == NULLP)
8816 /*GNB DU UE F1AP ID*/
8817 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
8818 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
8819 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
8820 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present = \
8821 InitialULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
8822 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
8827 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
8828 ProtocolIE_ID_id_NRCGI;
8829 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality =Criticality_reject;
8830 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present = \
8831 InitialULRRCMessageTransferIEs__value_PR_NRCGI;
8834 BuildNrcgi(&initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI);
8842 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
8843 ProtocolIE_ID_id_C_RNTI;
8844 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
8845 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
8846 InitialULRRCMessageTransferIEs__value_PR_C_RNTI;
8847 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.C_RNTI = crnti;
8851 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
8852 ProtocolIE_ID_id_RRCContainer;
8853 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
8854 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
8855 InitialULRRCMessageTransferIEs__value_PR_RRCContainer;
8857 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size = rrcContSize;
8858 DU_ALLOC(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf,
8859 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size)
8860 if(!initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
8862 DU_LOG(" ERROR --> F1AP : Memory allocation for RRCSetupRequestMessageTransferIEs failed");
8866 memcpy(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf, rrcContainer,
8867 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size);
8870 /*DUtoCURRCContainer*/
8872 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DUtoCURRCContainer;
8873 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
8874 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
8875 InitialULRRCMessageTransferIEs__value_PR_DUtoCURRCContainer;
8877 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
8879 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
8881 if(duCb.actvCellLst[cellIdx] && (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
8882 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].crnti == crnti))
8884 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
8889 ret = BuildCellGroupConfigRrc(duUeCb, &initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer);
8895 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
8897 /* Encode the Intial UL RRC Message transfer as APER */
8898 memset(encBuf, 0, ENC_BUF_MAX_LEN);
8900 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
8901 /* Encode results */
8902 if(encRetVal.encoded == ENCODE_FAIL)
8904 DU_LOG( "\nERROR --> F1AP : Could not encode Initial UL RRC Message Transfer\
8905 structure (at %s)\n",encRetVal.failed_type ? \
8906 encRetVal.failed_type->name : "unknown");
8913 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for Initial UL RRC\
8914 Message transfer\n");
8915 #ifdef DEBUG_ASN_PRINT
8916 for(int i=0; i< encBufSize; i++)
8918 printf("%x",encBuf[i]);
8923 if(sendF1APMsg() != ROK)
8925 DU_LOG("\nERROR --> F1AP : Sending Initial UL RRC Message Transfer Failed");
8931 freeInitUlRrcMsgTransfer(f1apMsg);
8933 }/* End of BuildAndSendInitialRrcMsgTransfer*/
8935 /***** UE SETUP REQUEST *****/
8937 /******************************************************************
8939 * @brief Function to delete the RLC Lc cfg from UE APP DB
8943 * Function : freeRlcLcCfg
8945 * Functionality: Function to delete the RLC Lc cfg from UE APP DB
8948 *****************************************************************/
8950 void freeRlcLcCfg(RlcBearerCfg *lcCfg)
8952 switch(lcCfg->rlcMode)
8956 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
8959 case RLC_UM_BI_DIRECTIONAL :
8961 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
8964 case RLC_UM_UNI_DIRECTIONAL_UL :
8966 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
8969 case RLC_UM_UNI_DIRECTIONAL_DL :
8971 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
8975 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at freeRlcLcCfg()", lcCfg->rlcMode);
8978 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
8981 /*******************************************************************
8983 * @brief Function to free MacLcCfg
8987 * Function : freeMacLcCfg
8989 * Functionality: Function to free MacLcCfg
8991 * @params[in] LcCfg *lcCfg,
8994 * ****************************************************************/
8996 void freeMacLcCfg(LcCfg *lcCfg)
8998 /* Deleting DRBQOS */
9001 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
9003 /* Deleting SNSSAI */
9006 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
9009 /*******************************************************************
9011 * @brief Free UE NR Capability received in UE Context setup request
9015 * Function : freeAperDecodeUeNrCapability
9018 * Free UE NR Capability received in UE Context setup request
9021 * @return ROK - success
9024 * ****************************************************************/
9025 void freeAperDecodeUeNrCapability(void *ueNrCapability)
9028 FeatureSets_t *featureSets =NULLP;
9029 UE_NR_Capability_t *ueNrCap = (UE_NR_Capability_t *)ueNrCapability;
9031 if(ueNrCap->rf_Parameters.supportedBandListNR.list.array)
9033 for(arrIdx = 0; arrIdx < ueNrCap->rf_Parameters.supportedBandListNR.list.count; arrIdx++)
9035 if(ueNrCap->rf_Parameters.supportedBandListNR.list.array[arrIdx])
9036 free(ueNrCap->rf_Parameters.supportedBandListNR.list.array[arrIdx]);
9038 free(ueNrCap->rf_Parameters.supportedBandListNR.list.array);
9041 if(ueNrCap->featureSets)
9043 featureSets = ueNrCap->featureSets;
9044 if(featureSets->featureSetsDownlinkPerCC)
9046 if(featureSets->featureSetsDownlinkPerCC->list.array)
9048 for(arrIdx = 0; arrIdx < featureSets->featureSetsDownlinkPerCC->list.count; arrIdx++)
9050 if(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx])
9052 if(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]->supportedModulationOrderDL)
9053 free(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]->supportedModulationOrderDL);
9054 free(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]);
9057 free(featureSets->featureSetsDownlinkPerCC->list.array);
9059 free(featureSets->featureSetsDownlinkPerCC);
9061 if(featureSets->featureSetsUplinkPerCC)
9063 if(featureSets->featureSetsUplinkPerCC->list.array)
9065 for(arrIdx = 0; arrIdx < featureSets->featureSetsUplinkPerCC->list.count; arrIdx++)
9067 if(featureSets->featureSetsUplinkPerCC->list.array[arrIdx])
9069 if(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]->supportedModulationOrderUL)
9070 free(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]->supportedModulationOrderUL);
9071 free(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]);
9074 free(featureSets->featureSetsUplinkPerCC->list.array);
9076 free(featureSets->featureSetsUplinkPerCC);
9078 free(ueNrCap->featureSets);
9082 /*******************************************************************
9084 * @brief Function to free PdcchSearchSpcToAddModList
9085 where memory allocated by aper_decoder
9089 * Function : freeAperDecodePdcchSearchSpcToAddModList
9091 * Functionality: Function to free PdcchSearchSpcToAddModList
9093 * @params[in] struct PDCCH_Config__searchSpacesToAddModList *searchSpcList
9096 * ****************************************************************/
9098 void freeAperDecodePdcchSearchSpcToAddModList(struct PDCCH_Config__searchSpacesToAddModList *searchSpcList)
9100 uint8_t searchSpcArrIdx=0;
9101 uint8_t searchSpcArrIdx1=0;
9102 struct SearchSpace *searchSpc=NULLP;
9105 if(searchSpcList->list.array)
9107 if(searchSpcList->list.array[searchSpcArrIdx1])
9109 searchSpc = searchSpcList->list.array[searchSpcArrIdx1];
9110 if(searchSpc->controlResourceSetId)
9112 if(searchSpc->monitoringSlotPeriodicityAndOffset)
9114 if(searchSpc->monitoringSymbolsWithinSlot)
9116 if(searchSpc->monitoringSymbolsWithinSlot->buf)
9118 if(searchSpc->nrofCandidates)
9120 if(searchSpc->searchSpaceType)
9122 free(searchSpc->searchSpaceType->choice.ue_Specific);
9123 free(searchSpc->searchSpaceType);
9125 free(searchSpc->nrofCandidates);
9127 free(searchSpc->monitoringSymbolsWithinSlot->buf);
9129 free(searchSpc->monitoringSymbolsWithinSlot);
9131 free(searchSpc->monitoringSlotPeriodicityAndOffset);
9133 free(searchSpc->controlResourceSetId);
9136 for(searchSpcArrIdx = 0; searchSpcArrIdx < searchSpcList->list.count; searchSpcArrIdx++)
9138 free(searchSpcList->list.array[searchSpcArrIdx]);
9140 free(searchSpcList->list.array);
9143 /*******************************************************************
9145 * @brief Function for free part for the memory allocated by aper_decoder
9149 * Function : freeAperDecodeBWPDlDedPdcchConfig
9151 * Functionality: Function to free BWPDlDedPdcchConfig
9156 * ****************************************************************/
9159 void freeAperDecodeBWPDlDedPdcchConfig(BWP_DownlinkDedicated_t *dlBwp)
9163 struct PDCCH_Config *pdcchCfg=NULLP;
9164 struct ControlResourceSet *controlRSet=NULLP;
9165 struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList=NULLP;
9167 if(dlBwp->pdcch_Config->choice.setup)
9169 pdcchCfg=dlBwp->pdcch_Config->choice.setup;
9170 if(pdcchCfg->controlResourceSetToAddModList)
9172 controlRSetList = pdcchCfg->controlResourceSetToAddModList;
9173 if(controlRSetList->list.array)
9175 controlRSet = controlRSetList->list.array[arrIdx2];
9178 if(controlRSet->frequencyDomainResources.buf)
9180 if(controlRSet->pdcch_DMRS_ScramblingID)
9182 if(pdcchCfg->searchSpacesToAddModList)
9184 freeAperDecodePdcchSearchSpcToAddModList(pdcchCfg->searchSpacesToAddModList);
9185 free(pdcchCfg->searchSpacesToAddModList);
9187 free(controlRSet->pdcch_DMRS_ScramblingID);
9189 free(controlRSet->frequencyDomainResources.buf);
9192 for(arrIdx1 = 0; arrIdx1 <controlRSetList->list.count; arrIdx1++)
9194 free(controlRSetList->list.array[arrIdx1]);
9196 free(controlRSetList->list.array);
9198 free(pdcchCfg->controlResourceSetToAddModList);
9200 free(dlBwp->pdcch_Config->choice.setup);
9203 /*******************************************************************
9205 * @brief Function to free PdschTimeDomAllocationList
9206 * where the memory allocated by aper_decoder
9210 * Function : freeAperDecodePdschTimeDomAllocationList
9212 * Functionality: Function to free PdschTimeDomAllocationList
9214 * @params[in] struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
9217 * ****************************************************************/
9220 void freeAperDecodePdschTimeDomAllocationList( struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList)
9224 if(timeDomAllocList->choice.setup)
9226 if(timeDomAllocList->choice.setup->list.array)
9228 for(arrIdx = 0; arrIdx <timeDomAllocList->choice.setup->list.count ; arrIdx++)
9230 free(timeDomAllocList->choice.setup->list.array[arrIdx]);
9232 free(timeDomAllocList->choice.setup->list.array);
9234 free(timeDomAllocList->choice.setup);
9238 /*******************************************************************
9240 * @brief Function to free BWPDlDedPdschConfig
9241 * where the memory allocated by aper_decoder
9245 * Function : freeAperDecodeBWPDlDedPdschConfig
9247 * Functionality: Function to free BWPDlDedPdschConfig
9249 * @params[in] BWP_DownlinkDedicated_t *dlBwp
9252 * ****************************************************************/
9255 void freeAperDecodeBWPDlDedPdschConfig(BWP_DownlinkDedicated_t *dlBwp)
9257 struct PDSCH_Config *pdschCfg=NULLP;
9258 struct PDSCH_Config__prb_BundlingType *prbBndlType=NULLP;
9259 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList=NULLP;
9260 struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg=NULLP;
9262 if(dlBwp->pdsch_Config->choice.setup)
9264 pdschCfg=dlBwp->pdsch_Config->choice.setup;
9265 if(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
9267 if(pdschCfg->pdsch_TimeDomainAllocationList)
9269 timeDomAllocList=pdschCfg->pdsch_TimeDomainAllocationList;
9270 if(pdschCfg->maxNrofCodeWordsScheduledByDCI)
9272 prbBndlType=&pdschCfg->prb_BundlingType;
9273 free(prbBndlType->choice.staticBundling);
9274 free(pdschCfg->maxNrofCodeWordsScheduledByDCI);
9276 freeAperDecodePdschTimeDomAllocationList(timeDomAllocList);
9277 free(pdschCfg->pdsch_TimeDomainAllocationList);
9279 dmrsDlCfg=pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA;
9280 if(dmrsDlCfg->choice.setup)
9282 free(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition);
9283 free(dmrsDlCfg->choice.setup);
9285 free(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA);
9287 free(dlBwp->pdsch_Config->choice.setup);
9290 /*******************************************************************
9292 * @brief Function to free PuschTimeDomAllocListCfg
9293 where the memory allocated by aper_decoder
9297 * Function : freeAperDecodePuschTimeDomAllocListCfg
9299 * Functionality: Function to free PuschTimeDomAllocListCfg
9301 * @params[in] PUSCH_Config_t *puschCfg
9304 * ****************************************************************/
9307 void freeAperDecodePuschTimeDomAllocListCfg(PUSCH_Config_t *puschCfg)
9311 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList_t=NULLP;
9313 if(puschCfg->pusch_TimeDomainAllocationList)
9315 timeDomAllocList_t=puschCfg->pusch_TimeDomainAllocationList;
9316 if(timeDomAllocList_t->choice.setup)
9318 if(timeDomAllocList_t->choice.setup->list.array)
9320 free(timeDomAllocList_t->choice.setup->list.array[arrIdx1]->k2);
9321 for(arrIdx = 0; arrIdx<timeDomAllocList_t->choice.setup->list.count; arrIdx++)
9323 free(timeDomAllocList_t->choice.setup->list.array[arrIdx]);
9325 free(timeDomAllocList_t->choice.setup->list.array);
9327 free(timeDomAllocList_t->choice.setup);
9329 free(puschCfg->transformPrecoder);
9330 free(puschCfg->pusch_TimeDomainAllocationList);
9333 /*******************************************************************
9335 * @brief Function to free InitialUlBWPConfig where memory allocated by aper_decoder
9339 * Function : freeAperDecodeInitialUlBWPConfig
9341 * Functionality: Function to free InitialUlBWPConfig
9343 * @params[in] BWP_UplinkDedicated_t *ulBwp
9346 * ****************************************************************/
9349 void freeAperDecodeInitialUlBWPConfig(BWP_UplinkDedicated_t *ulBwp)
9353 SRS_Config_t *srsCfg = NULLP;
9354 PUSCH_Config_t *puschCfg = NULLP;
9355 struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg = NULLP;
9356 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList = NULLP;
9357 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList = NULLP;
9358 struct SRS_Config__srs_ResourceToAddModList *resourceList = NULLP;
9360 if(ulBwp->pusch_Config)
9362 if(ulBwp->pusch_Config->choice.setup)
9364 puschCfg=ulBwp->pusch_Config->choice.setup;
9365 if(puschCfg->dataScramblingIdentityPUSCH)
9367 if(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
9369 freeAperDecodePuschTimeDomAllocListCfg(puschCfg);
9370 dmrsUlCfg=puschCfg->dmrs_UplinkForPUSCH_MappingTypeA;
9371 if(dmrsUlCfg->choice.setup)
9373 if(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
9375 if(dmrsUlCfg->choice.setup->transformPrecodingDisabled)
9377 free(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0);
9378 free(dmrsUlCfg->choice.setup->transformPrecodingDisabled);
9380 free(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition);
9382 free(dmrsUlCfg->choice.setup);
9384 free(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA);
9386 free(puschCfg->dataScramblingIdentityPUSCH);
9388 free(ulBwp->pusch_Config->choice.setup);
9390 free(ulBwp->pusch_Config);
9392 /* Free SRS-Config */
9393 if(ulBwp->srs_Config)
9395 if(ulBwp->srs_Config->choice.setup)
9397 srsCfg = ulBwp->srs_Config->choice.setup;
9399 /* Free Resource Set to add/mod list */
9400 if(srsCfg->srs_ResourceSetToAddModList)
9402 rsrcSetList = srsCfg->srs_ResourceSetToAddModList;
9403 if(rsrcSetList->list.array)
9407 /* Free SRS resource Id list in this SRS resource set */
9408 if(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
9411 rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
9413 if(rsrcIdList->list.array)
9415 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count;
9418 free(rsrcIdList->list.array[rsrcIdx]);
9420 free(rsrcIdList->list.array);
9422 free(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList);
9425 /* Free resource type info for this SRS resource set */
9427 free(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic);
9429 /* Free memory for each resource set */
9430 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
9432 free(rsrcSetList->list.array[rSetIdx]);
9434 free(rsrcSetList->list.array);
9436 free(srsCfg->srs_ResourceSetToAddModList);
9439 /* Free resource to add/modd list */
9440 if(srsCfg->srs_ResourceToAddModList)
9442 resourceList = srsCfg->srs_ResourceToAddModList;
9443 if(resourceList->list.array)
9447 free(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2);
9448 free(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic);
9450 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
9452 free(resourceList->list.array[rsrcIdx]);
9454 free(resourceList->list.array);
9456 free(srsCfg->srs_ResourceToAddModList);
9459 free(ulBwp->srs_Config->choice.setup);
9461 free(ulBwp->srs_Config);
9465 /*******************************************************************
9467 * @brief Function to free initialUplinkBWPConfig where memory allocated by aper_decoder
9471 * Function : freeAperDecodeinitialUplinkBWPConfig
9473 * Functionality: Function to free initialUplinkBWPConfig
9475 * @params[in] UplinkConfig_t *ulCfg
9478 * ****************************************************************/
9481 void freeAperDecodeinitialUplinkBWPConfig(UplinkConfig_t *ulCfg)
9483 BWP_UplinkDedicated_t *ulBwp=NULLP;
9484 struct UplinkConfig__pusch_ServingCellConfig *puschCfg=NULLP;
9486 if(ulCfg->initialUplinkBWP)
9488 ulBwp=ulCfg->initialUplinkBWP;
9489 if(ulCfg->firstActiveUplinkBWP_Id)
9491 if(ulCfg->pusch_ServingCellConfig)
9493 puschCfg=ulCfg->pusch_ServingCellConfig;
9494 if(puschCfg->choice.setup)
9496 if(puschCfg->choice.setup->ext1)
9498 free(puschCfg->choice.setup->ext1->processingType2Enabled);
9499 free(puschCfg->choice.setup->ext1->maxMIMO_Layers);
9500 free(puschCfg->choice.setup->ext1);
9502 free(puschCfg->choice.setup);
9504 free(ulCfg->pusch_ServingCellConfig);
9506 free(ulCfg->firstActiveUplinkBWP_Id);
9508 freeAperDecodeInitialUlBWPConfig(ulBwp);
9509 free(ulCfg->initialUplinkBWP);
9513 /*******************************************************************
9515 * @brief Function to free DuUeCfg
9519 * Function : freeDuUeCfg
9521 * Functionality: Function to free DuUeCfg
9523 * @params[in] DuUeCfg *ueCfg
9526 * ****************************************************************/
9527 void freeDuUeCfg(UeCtxtActionType actionType, DuUeCfg *ueCfg)
9531 SpCellConfig_t *spCellCfg = NULLP;
9532 ServingCellConfig_t *srvCellCfg = NULLP;
9533 BWP_DownlinkDedicated_t *dlBwp = NULLP;
9534 MAC_CellGroupConfig_t *macCellGrpCfg = NULLP;
9535 PhysicalCellGroupConfig_t *phyCellGrpCfg = NULLP;
9536 struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList = NULLP;
9537 struct RLC_Config *rlcConfig = NULLP;
9538 struct LogicalChannelConfig *macLcConfig = NULLP;
9539 struct SchedulingRequestConfig *schedulingRequestConfig = NULLP;
9540 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList = NULLP;
9541 struct TAG_Config *tagConfig = NULLP;
9542 struct TAG_Config__tag_ToAddModList *tagList = NULLP;
9543 struct MAC_CellGroupConfig__phr_Config *phrConfig = NULLP;
9544 struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg = NULLP;
9545 CellGroupConfigRrc_t *cellGrpCfg = ueCfg->cellGrpCfg;
9547 if(ueCfg->ueNrCapability)
9549 freeAperDecodeUeNrCapability(ueCfg->ueNrCapability);
9550 DU_FREE(ueCfg->ueNrCapability, sizeof(UE_NR_Capability_t));
9551 ueCfg->ueNrCapability = NULLP;
9554 if(ueCfg->cellGrpCfg)
9556 rlcBearerList = cellGrpCfg->rlc_BearerToAddModList;
9559 if(rlcBearerList->list.array)
9561 for(arrIdx=0; arrIdx<rlcBearerList->list.count; arrIdx++)
9563 if(rlcBearerList->list.array[arrIdx])
9565 rlcConfig = rlcBearerList->list.array[arrIdx]->rlc_Config;
9566 macLcConfig = rlcBearerList->list.array[arrIdx]->mac_LogicalChannelConfig;
9568 if(rlcBearerList->list.array[arrIdx]->servedRadioBearer)
9570 free(rlcBearerList->list.array[arrIdx]->servedRadioBearer);
9574 if(rlcConfig->choice.am)
9576 free(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength);
9577 free(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength);
9578 free(rlcConfig->choice.am);
9580 free(rlcBearerList->list.array[arrIdx]->rlc_Config);
9584 if(macLcConfig->ul_SpecificParameters)
9586 free(macLcConfig->ul_SpecificParameters->schedulingRequestID);
9587 free(macLcConfig->ul_SpecificParameters->logicalChannelGroup);
9588 free(macLcConfig->ul_SpecificParameters);
9590 free(rlcBearerList->list.array[arrIdx]->mac_LogicalChannelConfig);
9592 free(rlcBearerList->list.array[arrIdx]);
9595 free(rlcBearerList->list.array);
9597 free(cellGrpCfg->rlc_BearerToAddModList);
9600 macCellGrpCfg = cellGrpCfg->mac_CellGroupConfig;
9603 schedulingRequestConfig = macCellGrpCfg->schedulingRequestConfig;
9604 if(schedulingRequestConfig)
9606 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
9609 if(schReqList->list.array)
9611 for(arrIdx=0;arrIdx<schReqList->list.count; arrIdx++)
9613 if(schReqList->list.array[arrIdx])
9615 free(schReqList->list.array[arrIdx]->sr_ProhibitTimer);
9616 free(schReqList->list.array[arrIdx]);
9619 free(schReqList->list.array);
9621 free(schedulingRequestConfig->schedulingRequestToAddModList);
9623 free(macCellGrpCfg->schedulingRequestConfig);
9625 if(macCellGrpCfg->bsr_Config)
9627 free(macCellGrpCfg->bsr_Config);
9629 tagConfig = macCellGrpCfg->tag_Config;
9632 tagList = tagConfig->tag_ToAddModList;
9635 if(tagList->list.array)
9637 for(arrIdx=0; arrIdx<tagList->list.count; arrIdx++)
9639 free(tagList->list.array[arrIdx]);
9641 free(tagList->list.array);
9643 free(tagConfig->tag_ToAddModList);
9648 phrConfig = macCellGrpCfg->phr_Config;
9651 free(phrConfig->choice.setup);
9655 free(macCellGrpCfg);
9658 phyCellGrpCfg = cellGrpCfg->physicalCellGroupConfig;
9661 free(phyCellGrpCfg->p_NR_FR1);
9662 free(phyCellGrpCfg);
9665 spCellCfg = cellGrpCfg->spCellConfig;
9668 if(spCellCfg->servCellIndex)
9670 if(spCellCfg->rlmInSyncOutOfSyncThreshold)
9672 if(spCellCfg->spCellConfigDedicated)
9674 srvCellCfg = spCellCfg->spCellConfigDedicated;
9675 if(srvCellCfg->initialDownlinkBWP)
9677 dlBwp = srvCellCfg->initialDownlinkBWP;
9678 if(srvCellCfg->firstActiveDownlinkBWP_Id)
9680 if(srvCellCfg->defaultDownlinkBWP_Id)
9682 if(srvCellCfg->uplinkConfig)
9685 if(srvCellCfg->pdsch_ServingCellConfig)
9688 srvCellCfg->pdsch_ServingCellConfig;
9689 if(pdschCfg->choice.setup)
9692 free(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH);
9693 free(pdschCfg->choice.setup);
9696 free(srvCellCfg->pdsch_ServingCellConfig);
9699 freeAperDecodeinitialUplinkBWPConfig(srvCellCfg->uplinkConfig);
9700 free(srvCellCfg->uplinkConfig);
9702 free(srvCellCfg->defaultDownlinkBWP_Id);
9705 free(srvCellCfg->firstActiveDownlinkBWP_Id);
9707 if(dlBwp->pdcch_Config)
9709 if(dlBwp->pdsch_Config)
9711 freeAperDecodeBWPDlDedPdschConfig(dlBwp);
9712 free(dlBwp->pdsch_Config);
9714 freeAperDecodeBWPDlDedPdcchConfig(dlBwp);
9715 free(dlBwp->pdcch_Config);
9717 free(srvCellCfg->initialDownlinkBWP);
9720 free(spCellCfg->spCellConfigDedicated);
9722 free(spCellCfg->rlmInSyncOutOfSyncThreshold);
9724 free(spCellCfg->servCellIndex);
9728 DU_FREE(ueCfg->cellGrpCfg, sizeof(CellGroupConfigRrc_t));
9729 ueCfg->cellGrpCfg = NULLP;
9734 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCfg->ambrCfg, sizeof(AmbrCfg));
9737 if(actionType != UE_CTXT_CFG_QUERY)
9739 for(lcIdx = 0; lcIdx < ueCfg->numRlcLcs; lcIdx++)
9741 freeRlcLcCfg(&ueCfg->rlcLcCfg[lcIdx].rlcBearerCfg);
9745 for(lcIdx = 0; lcIdx < ueCfg->numMacLcs; lcIdx++)
9747 freeMacLcCfg(&ueCfg->macLcCfg[lcIdx].lcConfig);
9750 for(lcIdx = 0; lcIdx < ueCfg->numDrb; lcIdx++)
9752 DU_FREE(ueCfg->upTnlInfo[lcIdx].tnlCfg1, sizeof(GtpTnlCfg));
9756 /*******************************************************************
9758 * @brief Function to free UecontextSetupDb
9762 * Function : freeF1UeDb
9764 * Functionality: Function to free UecontextSetupDb
9766 * @params[in] UecontextSetupDb *
9769 * ****************************************************************/
9771 void freeF1UeDb(F1UeContextSetupDb *f1UeDb)
9774 if(f1UeDb->dlRrcMsg)
9776 if(f1UeDb->dlRrcMsg->rrcMsgPdu)
9778 //DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,\
9779 f1UeDb->dlRrcMsg->rrcMsgPdu, f1UeDb->dlRrcMsg->rrcMsgSize);
9781 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
9783 freeDuUeCfg(f1UeDb->actionType, &f1UeDb->duUeCfg);
9784 memset(f1UeDb, 0, sizeof(F1UeContextSetupDb));
9785 DU_FREE(f1UeDb, sizeof(F1UeContextSetupDb));
9788 /*******************************************************************
9790 * @brief Function to build Am cfg Info
9794 * Function : extractRlcAmCfg
9796 * Functionality: Function to build Am cfg Info
9798 * @params[in] AmBearerCfg *
9801 * @return ROK/RFAILED
9803 * ****************************************************************/
9805 void extractRlcAmCfg(AmBearerCfg *amCfgToSet, struct RLC_Config__am *rlcAmCfg)
9810 if(rlcAmCfg->dl_AM_RLC.sn_FieldLength)
9812 amCfgToSet->ulAmCfg.snLenUl = covertAmSnLenFromRrcEnumToIntEnum(*(rlcAmCfg->dl_AM_RLC.sn_FieldLength));
9813 /*TODO: Check the timer value when sent by real CU */
9814 amCfgToSet->ulAmCfg.reAssemTmr = convertReasmblTmrEnumToValue(rlcAmCfg->dl_AM_RLC.t_Reassembly);
9815 amCfgToSet->ulAmCfg.statProhTmr = convertProhibitTmrEnumToValue(rlcAmCfg->dl_AM_RLC.t_StatusProhibit);
9819 if(rlcAmCfg->ul_AM_RLC.sn_FieldLength)
9821 amCfgToSet->dlAmCfg.snLenDl = covertAmSnLenFromRrcEnumToIntEnum(*(rlcAmCfg->ul_AM_RLC.sn_FieldLength));
9822 amCfgToSet->dlAmCfg.pollRetxTmr = covertPollRetxTmrEnumToValue(rlcAmCfg->ul_AM_RLC.t_PollRetransmit);
9823 amCfgToSet->dlAmCfg.pollPdu = covertPollPduEnumToValue(rlcAmCfg->ul_AM_RLC.pollPDU);
9824 amCfgToSet->dlAmCfg.pollByte = covertPollByteEnumToValue(rlcAmCfg->ul_AM_RLC.pollByte);
9825 amCfgToSet->dlAmCfg.maxRetxTh = covertMaxRetxEnumToValue(rlcAmCfg->ul_AM_RLC.maxRetxThreshold);
9830 /*******************************************************************
9832 * @brief Function to build Um Bi Info
9836 * Function : extractRlcUmBiCfg
9838 * Functionality: Function to build Um Bi Info
9840 * @params[in] UmBiDirBearerCfg *
9843 * @return ROK/RFAILED
9845 * ****************************************************************/
9847 void extractRlcUmBiCfg(UmBiDirBearerCfg *umBiCfgToSet, struct RLC_Config__um_Bi_Directional *rlcBiCfg)
9851 /* UL UM BI DIR Cfg */
9852 if(rlcBiCfg->dl_UM_RLC.sn_FieldLength)
9854 umBiCfgToSet->ulUmCfg.snLenUlUm = covertUmSnLenFromRrcEnumToIntEnum(*(rlcBiCfg->dl_UM_RLC.sn_FieldLength));
9855 umBiCfgToSet->ulUmCfg.reAssemTmr = convertReasmblTmrEnumToValue(rlcBiCfg->dl_UM_RLC.t_Reassembly);
9858 /* DL UM BI DIR Cfg */
9859 if(rlcBiCfg->ul_UM_RLC.sn_FieldLength)
9860 umBiCfgToSet->dlUmCfg.snLenDlUm = covertUmSnLenFromRrcEnumToIntEnum(*(rlcBiCfg->ul_UM_RLC.sn_FieldLength));
9864 /*******************************************************************
9866 * @brief Function to build Um Ul Info
9870 * Function : extractRlcUmUlCfg
9872 * Functionality: Function to build Um Ul Info
9874 * @params[in] UmUniDirUlBearerCfg *
9877 * @return ROK/RFAILED
9879 * ****************************************************************/
9881 void extractRlcUmUlCfg(UmUniDirUlBearerCfg *umUlCfgToSet, struct RLC_Config__um_Uni_Directional_DL *umUlCfg)
9885 if(umUlCfg->dl_UM_RLC.sn_FieldLength)
9887 umUlCfgToSet->ulUmCfg.snLenUlUm = covertUmSnLenFromRrcEnumToIntEnum(*(umUlCfg->dl_UM_RLC.sn_FieldLength));
9888 umUlCfgToSet->ulUmCfg.reAssemTmr = convertReasmblTmrEnumToValue(umUlCfg->dl_UM_RLC.t_Reassembly);
9893 /*******************************************************************
9895 * @brief Function to build Um Uni Dl Info
9899 * Function : extractRlcUmDlCfg
9901 * Functionality: Function to build Um Uni Dl Info
9903 * @params[in] UmUniDirDlBearerCfg *
9906 * @return ROK/RFAILED
9908 * ****************************************************************/
9909 void extractRlcUmDlCfg(UmUniDirDlBearerCfg *umDlCfgToSet, struct RLC_Config__um_Uni_Directional_UL *umDlCfg)
9913 if(umDlCfg->ul_UM_RLC.sn_FieldLength)
9914 umDlCfgToSet->dlUmCfg.snLenDlUm = covertUmSnLenFromRrcEnumToIntEnum(*(umDlCfg->ul_UM_RLC.sn_FieldLength));
9918 /*******************************************************************
9920 * @brief Function to extractRlcModeCfg
9924 * Function : extractRlcModeCfg
9926 * Functionality: Function to extractRlcModeCfg
9928 * @params[in] RLC_Config_t *
9931 * @return ROK/RFAILED
9933 * ****************************************************************/
9934 void extractRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *rlcDbCfg, RLC_Config_t *lcCfg)
9942 if(lcCfg->choice.am)
9944 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.amCfg, sizeof(AmBearerCfg));
9945 if(rlcDbCfg->u.amCfg)
9946 extractRlcAmCfg(rlcDbCfg->u.amCfg, lcCfg->choice.am);
9950 case RLC_UM_BI_DIRECTIONAL :
9952 if(lcCfg->choice.um_Bi_Directional)
9954 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
9955 if(rlcDbCfg->u.umBiDirCfg)
9956 extractRlcUmBiCfg(rlcDbCfg->u.umBiDirCfg, lcCfg->choice.um_Bi_Directional);
9960 case RLC_UM_UNI_DIRECTIONAL_UL :
9962 if(lcCfg->choice.um_Uni_Directional_DL)
9964 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
9965 if(rlcDbCfg->u.umUniDirUlCfg)
9966 extractRlcUmUlCfg(rlcDbCfg->u.umUniDirUlCfg, lcCfg->choice.um_Uni_Directional_DL);
9970 case RLC_UM_UNI_DIRECTIONAL_DL :
9972 if(lcCfg->choice.um_Uni_Directional_UL)
9974 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
9975 if(rlcDbCfg->u.umUniDirDlCfg)
9976 extractRlcUmDlCfg(rlcDbCfg->u.umUniDirDlCfg, lcCfg->choice.um_Uni_Directional_UL);
9981 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
9987 /*******************************************************************
9989 * @brief Function to extract extractUlLcCfg
9993 * Function : extractUlLcCfg
9995 * Functionality: Function to extract extractUlLcCfg
9997 * @params[in] UlLcCfg *f1UlLcCfg, LogicalChannelConfig_t *ulLcCfg
10000 * ****************************************************************/
10002 void extractUlLcCfg(UlLcCfg *f1UlLcCfg, LogicalChannelConfig_t *ulLcCfg)
10006 if(ulLcCfg->ul_SpecificParameters)
10008 f1UlLcCfg->priority = \
10009 ulLcCfg->ul_SpecificParameters->priority;
10010 if(ulLcCfg->ul_SpecificParameters->logicalChannelGroup)
10012 f1UlLcCfg->lcGroup = \
10013 *(ulLcCfg->ul_SpecificParameters->logicalChannelGroup);
10015 if(ulLcCfg->ul_SpecificParameters->schedulingRequestID)
10017 f1UlLcCfg->schReqId = \
10018 *(ulLcCfg->ul_SpecificParameters->schedulingRequestID);
10021 ulLcCfg->ul_SpecificParameters->prioritisedBitRate;
10023 ulLcCfg->ul_SpecificParameters->bucketSizeDuration;
10028 /*******************************************************************
10030 * @brief Function to extract Snssai Cfg Info from CU
10034 * Function : extractDrbSnssaiCfg
10036 * Functionality: Function to extract Drb Snssai Cfg Info from CU
10038 * @params[in] DRB_Information_t *drbInfo, Snssai *snssai
10039 * @return ROK/RFAILED
10041 * ****************************************************************/
10043 uint8_t extractDrbSnssaiCfg(SNSSAI_t *RecvSnssai, Snssai **snssaiToBeShared)
10045 if(!(*snssaiToBeShared))
10047 DU_ALLOC_SHRABL_BUF((*snssaiToBeShared), sizeof(Snssai));
10048 if(snssaiToBeShared == NULLP)
10050 DU_LOG("\nERROR --> DUAPP : extractDrbSnssaiCfg(): Memory failed at allocating for SNSSAI ");
10056 memcpy(&(*snssaiToBeShared)->sst, RecvSnssai->sST.buf, RecvSnssai->sST.size);
10059 memcpy((*snssaiToBeShared)->sd, RecvSnssai->sD->buf, RecvSnssai->sD->size);
10063 DU_LOG("\nERROR --> DUAPP : extractDrbSnssaiCfg(): Received Null pointer of Snssai->SD");
10070 /*******************************************************************
10072 * @brief Function to procRlcLcCfg
10076 * Function : procRlcLcCfg
10078 * Functionality: Function to procRlcLcCfg
10080 * @params[in] rbId, lcId, rbType, rlcMod
10081 * RLC_Config_t *, RlcBearerCfg * ,
10084 * ****************************************************************/
10086 void procRlcLcCfg(uint8_t rbId, uint8_t lcId, uint8_t rbType, uint8_t rlcMode,\
10087 uint8_t configType, RLC_Config_t *f1RlcCfg, DuRlcBearerCfg *lcCfg, QoSInformation_t *qoSInformation)
10089 DRB_Information_t *drbInfo;
10091 lcCfg->rlcBearerCfg.rbId = rbId;
10092 lcCfg->configType = configType;
10094 if(rbType == RB_TYPE_SRB)
10096 lcCfg->rlcBearerCfg.rbType = RB_TYPE_SRB;
10097 lcCfg->rlcBearerCfg.lcId = rbId;
10098 lcCfg->rlcBearerCfg.lcType = LCH_DCCH;
10099 lcCfg->rlcBearerCfg.rlcMode = RLC_AM;
10101 else if(rbType == RB_TYPE_DRB)
10103 lcCfg->rlcBearerCfg.rbType = RB_TYPE_DRB;
10104 lcCfg->rlcBearerCfg.lcId = lcId;
10105 lcCfg->rlcBearerCfg.lcType = LCH_DTCH;
10106 lcCfg->rlcBearerCfg.rlcMode = rlcMode;
10108 if(f1RlcCfg) /* rlc mode config recived */
10110 extractRlcModeCfg(lcCfg->rlcBearerCfg.rlcMode, &lcCfg->rlcBearerCfg, f1RlcCfg);
10112 if(qoSInformation != NULLP)
10114 if(qoSInformation->present == QoSInformation_PR_choice_extension)
10116 if(qoSInformation->choice.choice_extension->value.present ==\
10117 QoSInformation_ExtIEs__value_PR_DRB_Information)
10119 drbInfo = &qoSInformation->choice.choice_extension->value.choice.DRB_Information;
10120 if(extractDrbSnssaiCfg(&drbInfo->sNSSAI, &lcCfg->rlcBearerCfg.snssai) != ROK)
10122 DU_LOG("\nERROR --> DUAPP: Unable to extract Snssai information at procRlcLcCfg()");
10130 /*******************************************************************
10132 * @brief Fills DrbQos Info received by CU
10136 * Function : extractQosInfo
10138 * Functionality: Fills DrbQos Info received by CU
10140 * @params[in] DrbQosInfo *qosToAdd,
10141 * QoSFlowLevelQoSParameters_t *qosFlowCfg
10144 * ****************************************************************/
10146 void extractQosInfo(DrbQosInfo *qosToAdd, QoSFlowLevelQoSParameters_t *qosFlowCfg)
10148 uint8_t qosCntIdx = 0;
10149 ProtocolExtensionContainer_4624P74_t *qosIeExt = NULLP;
10151 qosToAdd->fiveQiType = qosFlowCfg->qoS_Characteristics.present;
10152 qosToAdd->u.nonDyn5Qi.fiveQi =\
10153 qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->fiveQI;
10154 if(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow)
10156 qosToAdd->u.nonDyn5Qi.avgWindow = \
10157 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
10160 if(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume)
10162 qosToAdd->u.nonDyn5Qi.maxDataBurstVol = \
10163 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
10166 if(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->qoSPriorityLevel)
10168 qosToAdd->u.nonDyn5Qi.priorLevel = \
10169 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->qoSPriorityLevel);
10171 qosToAdd->ngRanRetPri.priorityLevel = \
10172 qosFlowCfg->nGRANallocationRetentionPriority.priorityLevel;
10173 qosToAdd->ngRanRetPri.preEmptionCap = \
10174 qosFlowCfg->nGRANallocationRetentionPriority.pre_emptionCapability;
10175 qosToAdd->ngRanRetPri.preEmptionVul = \
10176 qosFlowCfg->nGRANallocationRetentionPriority.pre_emptionVulnerability;
10177 if(qosFlowCfg->gBR_QoS_Flow_Information)
10179 memcpy(&qosToAdd->grbQosInfo.maxFlowBitRateDl, \
10180 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateDownlink.buf, \
10181 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateDownlink.size);
10182 memcpy(&qosToAdd->grbQosInfo.maxFlowBitRateUl, \
10183 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateUplink.buf, \
10184 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateUplink.size);
10185 memcpy(&qosToAdd->grbQosInfo.guarFlowBitRateDl,\
10186 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateDownlink.buf, \
10187 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateDownlink.size);
10188 memcpy(&qosToAdd->grbQosInfo.guarFlowBitRateUl,\
10189 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateUplink.buf, \
10190 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateUplink.size);
10192 /*Extracting PDU_SESSION_ID*/
10193 qosIeExt = (ProtocolExtensionContainer_4624P74_t *)qosFlowCfg->iE_Extensions;
10196 for(qosCntIdx = 0; qosCntIdx < qosIeExt->list.count; qosCntIdx++)
10198 if(qosIeExt->list.array[qosCntIdx]->extensionValue.present == \
10199 QoSFlowLevelQoSParameters_ExtIEs__extensionValue_PR_PDUSessionID)
10201 qosToAdd->pduSessionId = qosIeExt->list.array[qosCntIdx]->extensionValue.choice.PDUSessionID;
10202 DU_LOG("\nDEBUG --> DU_F1AP : extractQosInfo: PDU SessionID:%d",qosToAdd->pduSessionId);
10206 qosToAdd->ulPduSessAggMaxBitRate = 0;
10209 /*******************************************************************
10211 * @brief Function to extract GTP Tunnel Info from CU
10215 * Function : extractUpTnlInfo
10217 * Functionality: Function to extract GTP Tunnel Info from CU
10219 * @params[in] F1AP message
10220 * @return ROK/RFAILED
10222 * ****************************************************************/
10224 uint8_t extractUpTnlInfo(uint8_t drbId, uint8_t configType,\
10225 ULUPTNLInformation_ToBeSetup_List_t *tnlInfo, UpTnlCfg *upTnlInfo)
10228 uint32_t ipv4_du = 0;
10229 GTPTunnel_t *gtpTunnel = NULLP;
10231 upTnlInfo->drbId = drbId;
10232 upTnlInfo->configType = configType;
10234 cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
10236 cmInetAddr((char *)DU_IP_V4_ADDR, &ipv4_du);
10239 for(tnlIdx=0; tnlIdx < tnlInfo->list.count; tnlIdx++)
10241 if(tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.present == UPTransportLayerInformation_PR_gTPTunnel)
10243 if(tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.choice.gTPTunnel)
10245 gtpTunnel = tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.choice.gTPTunnel;
10246 DU_ALLOC(upTnlInfo->tnlCfg1, sizeof(GtpTnlCfg));
10247 if(upTnlInfo->tnlCfg1 == NULLP)
10249 DU_LOG("\nERROR --> F1AP : extractUpTnlInfo: Failed to allocate mmeory for tunnel cfg 1");
10252 bitStringToInt(>pTunnel->transportLayerAddress, &upTnlInfo->tnlCfg1->ulTnlAddress);
10253 upTnlInfo->tnlCfg1->dlTnlAddress = ipv4_du;
10254 if(gtpTunnel->gTP_TEID.size > 0)
10256 teIdStringToInt(gtpTunnel->gTP_TEID.buf, &upTnlInfo->tnlCfg1->teId);
10265 /*******************************************************************
10267 * @brief Function to extract Drb Qos Cfg Info from CU
10271 * Function : extractDrbQosCfg
10273 * Functionality: Function to extract Drb Qos Cfg Info from CU
10275 * @params[in] DRB_Information_t *drbInfo, LcCfg *macLcToAdd
10276 * @return ROK/RFAILED
10278 * ****************************************************************/
10280 uint8_t extractDrbQosCfg(DRB_Information_t *drbInfo, LcCfg *macLcToAdd )
10282 if(!macLcToAdd->drbQos)
10284 DU_ALLOC_SHRABL_BUF(macLcToAdd->drbQos, sizeof(DrbQosInfo));
10285 if(macLcToAdd->drbQos == NULLP)
10287 DU_LOG("\nERROR --> DUAPP:Memory failed at allocating DrbQos at extractDrbQosCfg()");
10292 if(drbInfo->dRB_QoS.qoS_Characteristics.present == QoS_Characteristics_PR_non_Dynamic_5QI)
10294 extractQosInfo(macLcToAdd->drbQos, &drbInfo->dRB_QoS);
10295 macLcToAdd->dlLcCfg.lcp = macLcToAdd->drbQos->ngRanRetPri.priorityLevel;
10297 if(extractDrbSnssaiCfg(&drbInfo->sNSSAI, &macLcToAdd->snssai) != ROK)
10299 DU_LOG("\nERROR --> DUAPP: Unable to extract Snssai information at extractDrbQosCfg()");
10304 /*******************************************************************
10306 * @brief Function to extract DRB info received from CU
10310 * Function : extractDrbCfg
10312 * Functionality: Function to extract DRB info received from CU
10314 * @params[in] F1AP message
10317 * ****************************************************************/
10318 uint8_t extractDrbCfg(DRBs_ToBeSetup_Item_t *drbItem, DRBs_ToBeSetupMod_Item_t *drbSetupModItem,\
10319 DRBs_ToBeModified_Item_t *drbModItem, DuLcCfg *lcCfgToAdd, UpTnlCfg *upTnlInfo)
10321 DRB_Information_t *drbInfo = NULLP;
10323 if(drbItem != NULLP)
10325 if(extractUpTnlInfo(drbItem->dRBID, CONFIG_ADD, &drbItem->uLUPTNLInformation_ToBeSetup_List, upTnlInfo) != ROK)
10327 DU_LOG("\nERROR --> DUAPP : Failed to extract tunnel Cfg at extractDrbCfg()");
10330 if(drbItem->qoSInformation.present == QoSInformation_PR_choice_extension)
10332 if(drbItem->qoSInformation.choice.choice_extension->value.present == QoSInformation_ExtIEs__value_PR_DRB_Information)
10334 drbInfo = &drbItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information;
10335 if(extractDrbQosCfg(drbInfo , &lcCfgToAdd->lcConfig) != ROK)
10337 DU_LOG("\nERROR --> DUAPP : Failed to extract qos Cfg at extractDrbCfg()");
10343 else if(drbSetupModItem != NULLP)
10345 if(extractUpTnlInfo(drbSetupModItem->dRBID, CONFIG_ADD, &drbSetupModItem->uLUPTNLInformation_ToBeSetup_List,\
10348 DU_LOG("\nERROR --> DUAPP : Failed to extract tunnel Cfg at extractDrbCfg()");
10351 if(drbSetupModItem->qoSInformation.present == QoSInformation_PR_choice_extension)
10353 if(drbSetupModItem->qoSInformation.choice.choice_extension->value.present ==\
10354 QoSInformation_ExtIEs__value_PR_DRB_Information)
10356 drbInfo = &drbSetupModItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information;
10357 if(extractDrbQosCfg(drbInfo , &lcCfgToAdd->lcConfig) != ROK)
10359 DU_LOG("\nERROR --> DUAPP : Failed to extract qos Cfg at extractDrbCfg()");
10366 else if(drbModItem != NULLP)
10368 if(extractUpTnlInfo(drbModItem->dRBID, CONFIG_MOD, &drbModItem->uLUPTNLInformation_ToBeSetup_List,\
10371 DU_LOG("\nERROR --> DUAPP : Failed to extract tunnel Cfg at extractDrbCfg()");
10374 if(drbModItem->qoSInformation != NULLP)
10376 if(drbModItem->qoSInformation->present == QoSInformation_PR_choice_extension)
10378 if(drbModItem->qoSInformation->choice.choice_extension->value.present ==\
10379 QoSInformation_ExtIEs__value_PR_DRB_Information)
10381 drbInfo = &drbModItem->qoSInformation->choice.choice_extension->value.choice.DRB_Information;
10382 if(extractDrbQosCfg(drbInfo , &lcCfgToAdd->lcConfig) != ROK)
10384 DU_LOG("\nERROR --> DUAPP : Failed to extract qos Cfg at extractDrbCfg()");
10395 /*******************************************************************
10397 * @brief Function to extract RB info received from CU
10401 * Function : extractMacRbCfg
10403 * Functionality: Function to extract RB info received from CU
10405 * @params[in] F1AP message
10406 * @return ROK/RFAILED
10408 * ****************************************************************/
10410 uint8_t extractMacRbCfg(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbCfg,\
10411 DRBs_ToBeSetupMod_Item_t *drbSetupModCfg, DRBs_ToBeModified_Item_t *drbModCfg, LogicalChannelConfig_t *ulLcCfg, DuLcCfg *lcCfg, UpTnlCfg *upTnlInfo)
10413 if(drbCfg != NULLP)
10415 if(extractDrbCfg(drbCfg, NULL, NULL, lcCfg, upTnlInfo) != ROK)
10417 DU_LOG("ERROR --> F1AP : Failed to build Drb Qos at extractMacRbCfg()");
10421 else if(drbSetupModCfg != NULLP)
10423 if(extractDrbCfg(NULL, drbSetupModCfg, NULL, lcCfg, upTnlInfo) != ROK)
10425 DU_LOG("ERROR --> F1AP : Failed to build Drb Qos at extractMacRbCfg()");
10429 else if(drbModCfg != NULLP)
10431 if(extractDrbCfg(NULL, NULL, drbModCfg, lcCfg, upTnlInfo) != ROK)
10433 DU_LOG("ERROR --> F1AP : Failed to build Drb Qos at extractMacRbCfg()");
10439 lcCfg->lcConfig.drbQos = NULLP;
10440 lcCfg->lcConfig.snssai = NULLP;
10441 if(lcCfg->lcConfig.lcId == SRB2_LCID)
10442 lcCfg->lcConfig.dlLcCfg.lcp = LC_PRIORITY_3;
10444 lcCfg->lcConfig.dlLcCfg.lcp = LC_PRIORITY_1;
10449 lcCfg->lcConfig.ulLcCfgPres = true;
10450 extractUlLcCfg(&lcCfg->lcConfig.ulLcCfg, ulLcCfg);
10453 lcCfg->lcConfig.ulLcCfgPres = false;
10457 /*******************************************************************
10459 * @brief Function processing LC config info received from CU
10463 * Function : procMacLcCfg
10465 * Functionality: Function processing LC config info received from CU
10467 * @params[in] F1AP message
10468 * @return ROK/RFAILED
10470 * ****************************************************************/
10472 uint8_t procMacLcCfg(uint8_t lcId, uint8_t rbType, uint8_t configType, DRBs_ToBeSetup_Item_t *drbItem,\
10473 DRBs_ToBeSetupMod_Item_t *drbSetupModItem, DRBs_ToBeModified_Item_t *drbModItem, LogicalChannelConfig_t *ulLcCfg,\
10474 DuLcCfg *lcCfg, UpTnlCfg *upTnlInfo)
10478 lcCfg->lcConfig.lcId = lcId;
10479 lcCfg->configType = configType;
10480 if(rbType == RB_TYPE_SRB)
10482 ret = extractMacRbCfg(lcId, NULL, NULL, NULL, ulLcCfg, lcCfg, NULL);
10484 else if(rbType == RB_TYPE_DRB && upTnlInfo != NULLP)
10486 if(drbItem != NULL)
10487 ret = extractMacRbCfg(lcId, drbItem, NULL, NULL, ulLcCfg, lcCfg, upTnlInfo);
10488 else if(drbSetupModItem != NULL)
10489 ret = extractMacRbCfg(lcId, NULL, drbSetupModItem, NULL, ulLcCfg, lcCfg, upTnlInfo);
10490 else if(drbModItem != NULL)
10491 ret = extractMacRbCfg(lcId, NULL, NULL, drbModItem, ulLcCfg, lcCfg, upTnlInfo);
10496 /*******************************************************************
10498 * @brief Function to extract Rlc cfg To Add/Mod in CellGrp Info
10502 * Function : extractRlcCfgToAddMod
10504 * Functionality: Function to extract Rlc cfg To Add/Mod in CellGrp Info
10506 * @params[in] CellGroupConfigRrc__rlc_BearerTo pointer
10508 * @return ROK/RFAILED
10510 * ****************************************************************/
10512 uint8_t extractRlcCfgToAddMod(struct CellGroupConfigRrc__rlc_BearerToAddModList *lcCfg, DuUeCfg *ueCfgDb)
10514 uint8_t idx, rbId, lcId, rlcMode, rbType;
10515 RLC_Config_t *f1RlcCfg = NULLP;
10516 LogicalChannelConfig_t *macUlLcCfg = NULLP;
10518 for(idx = 0; idx < lcCfg->list.count; idx++)
10520 lcId = lcCfg->list.array[idx]->logicalChannelIdentity;
10521 if(lcCfg->list.array[idx]->servedRadioBearer)
10523 /* RadioBearer for SRB/DRB */
10524 if(lcCfg->list.array[idx]->servedRadioBearer->present ==\
10525 RLC_BearerConfig__servedRadioBearer_PR_srb_Identity)
10527 rbId = lcCfg->list.array[idx]->servedRadioBearer->choice.srb_Identity;
10528 rbType = RB_TYPE_SRB;
10530 else if(lcCfg->list.array[idx]->servedRadioBearer->present ==\
10531 RLC_BearerConfig__servedRadioBearer_PR_drb_Identity)
10533 rbId = lcCfg->list.array[idx]->servedRadioBearer->choice.drb_Identity;
10534 rbType = RB_TYPE_DRB;
10538 DU_LOG("\nERROR --> No components present in Bearer config to ADD/MOD");
10541 /* MAC UL LC Config */
10542 if(lcCfg->list.array[idx]->mac_LogicalChannelConfig)
10544 macUlLcCfg = lcCfg->list.array[idx]->mac_LogicalChannelConfig;
10549 DU_LOG("\nERROR --> DUAPP: Received RadioBearer config is NULL");
10552 /* RLC Mode Config */
10553 if(lcCfg->list.array[idx]->rlc_Config)
10555 rlcMode = lcCfg->list.array[idx]->rlc_Config->present;
10556 f1RlcCfg = lcCfg->list.array[idx]->rlc_Config;
10559 /* Filling RLC/MAC Config*/
10560 memset(&ueCfgDb->macLcCfg[idx], 0, sizeof(DuLcCfg));
10561 memset(&ueCfgDb->rlcLcCfg[idx], 0, sizeof(DuRlcBearerCfg));
10562 procRlcLcCfg(rbId, lcId, rbType, rlcMode, CONFIG_UNKNOWN, f1RlcCfg, &(ueCfgDb->rlcLcCfg[idx]), NULLP);
10563 if(procMacLcCfg(lcId, rbType, CONFIG_UNKNOWN, NULL, NULL, NULL, macUlLcCfg, &ueCfgDb->macLcCfg[idx], NULL) != ROK)
10565 DU_LOG("\nERROR --> DU APP : Failed while filling MAC LC config at extractRlcCfgToAddMod()");
10568 (ueCfgDb->numRlcLcs)++;
10569 (ueCfgDb->numMacLcs)++;
10570 DU_LOG("\nDEBUG -> DUAPP: extractRlcCfgToAddMod:RBType:%d, DrbID: %d,lcId:%d, [RLC,MAC,NumDrb]:[%x,%x,%x]",\
10571 rbType, rbId, lcId, ueCfgDb->numRlcLcs, ueCfgDb->numMacLcs, ueCfgDb->numDrb);
10573 //TODO: To send the failure cause in UeContextSetupRsp
10577 /*******************************************************************
10579 * @brief DeAlloc pdsch serv cell config info
10583 * Function : freeMacPdschServCellInfo
10585 * Functionality: DeAlloc pdsch serv cell config info
10587 * @params[in] PdschServCellCfg pointer
10590 * ****************************************************************/
10592 void freeMacPdschServCellInfo(PdschServCellCfg *pdsch)
10594 if(pdsch->xOverhead)
10596 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->xOverhead, sizeof(PdschXOverhead));
10598 if(pdsch->codeBlkGrpFlushInd)
10600 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->codeBlkGrpFlushInd, sizeof(bool));
10602 if(pdsch->maxCodeBlkGrpPerTb)
10604 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
10606 if(pdsch->maxMimoLayers)
10608 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->maxMimoLayers, sizeof(uint8_t));
10612 /*******************************************************************
10614 * @brief Free Serving cell Info
10618 * Function : freeMacServingCellInfo
10620 * Functionality: Free Serving cell Info
10622 * @params[in] ServCellCfgInfo *srvCellCfg
10625 * ****************************************************************/
10626 void freeMacServingCellInfo(ServCellRecfgInfo *srvCellCfg)
10628 uint8_t timeDomRsrcIdx;
10630 if(srvCellCfg->initDlBwp.pdschPresent)
10632 for(timeDomRsrcIdx = 0; timeDomRsrcIdx < srvCellCfg->initDlBwp.pdschCfg.numTimeDomRsrcAlloc; timeDomRsrcIdx++)
10634 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, \
10635 srvCellCfg->initDlBwp.pdschCfg.timeDomRsrcAllociList[timeDomRsrcIdx].k0, sizeof(uint8_t));
10639 freeMacPdschServCellInfo(&srvCellCfg->pdschServCellCfg);
10640 if(srvCellCfg->bwpInactivityTmr)
10642 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, srvCellCfg->bwpInactivityTmr, sizeof(uint8_t));
10645 if(srvCellCfg->initUlBwp.pucchPresent)
10647 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, srvCellCfg->initUlBwp.pucchCfg.dlDataToUlAck, sizeof(PucchDlDataToUlAck));
10651 /*******************************************************************
10653 * @brief Free cell Grp Cfg Info
10657 * Function : freeUeRecfgCellGrpInfo
10659 * Functionality: Free cell Grp Cfg Info
10661 * @params[in] DuMacUeCfg* duUeCfg
10664 * ****************************************************************/
10666 void freeUeRecfgCellGrpInfo(DuMacUeCfg *macUeCfg)
10668 freeMacServingCellInfo(&macUeCfg->spCellCfg.servCellCfg);
10671 /*******************************************************************
10673 * @brief Fills Reconfig SchReqReConfig
10677 * Function : extractSchReqReConfig
10679 * Functionality: Fills Reconfig SchReqReConfig
10681 * @params[in] SchedulingRequestConfig_t *cuSchedReq
10682 * SchedReqCfg* macSchedReq
10685 * ****************************************************************/
10686 void extractSchReqReConfig(SchedulingRequestConfig_t *cuSchedReq, SchedReqCfg *macSchedReq)
10688 uint8_t schReqIdx = 0;
10689 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqListToAdd = NULLP;
10690 struct SchedulingRequestConfig__schedulingRequestToReleaseList *schReqListToRel = NULLP;
10692 if(cuSchedReq->schedulingRequestToAddModList)
10694 schReqListToAdd = cuSchedReq->schedulingRequestToAddModList;
10695 if(schReqListToAdd->list.count)
10697 macSchedReq->addModListCount = schReqListToAdd->list.count;
10698 for(schReqIdx = 0; schReqIdx < schReqListToAdd->list.count; schReqIdx++)
10700 macSchedReq->addModList[schReqIdx].schedReqId = \
10701 schReqListToAdd->list.array[schReqIdx]->schedulingRequestId;
10702 macSchedReq->addModList[schReqIdx].srProhibitTmr = \
10703 *(schReqListToAdd->list.array[schReqIdx]->sr_ProhibitTimer);
10704 macSchedReq->addModList[schReqIdx].srTransMax =\
10705 schReqListToAdd->list.array[schReqIdx]->sr_TransMax;
10709 /* Scheduling Req To release */
10710 if(cuSchedReq->schedulingRequestToReleaseList)
10712 schReqListToRel = cuSchedReq->schedulingRequestToReleaseList;
10713 if(schReqListToRel->list.count)
10715 macSchedReq->relListCount = schReqListToRel->list.count;
10716 for(schReqIdx = 0; schReqIdx < schReqListToRel->list.count; schReqIdx++)
10718 macSchedReq->relList[schReqIdx] = \
10719 *schReqListToRel->list.array[schReqIdx];
10725 /*******************************************************************
10727 * @brief Fills TagReconfig
10731 * Function : extractTagReconfig
10733 * Functionality: Fills extractTagReconfig
10735 * @params[in] TAG_Config_t *cuTagCfg
10736 * TagCfg *macTagCfg
10739 * ****************************************************************/
10741 void extractTagReconfig(TAG_Config_t *cuTagCfg, TagCfg *macTagCfg)
10743 uint8_t tagIdx = 0;
10744 struct TAG_Config__tag_ToAddModList *tagListToAddMod = NULLP;
10745 struct TAG_Config__tag_ToReleaseList *tagListToRel = NULLP;
10747 /* Tag config to AddMod */
10748 if(cuTagCfg->tag_ToAddModList)
10750 tagListToAddMod = cuTagCfg->tag_ToAddModList;
10751 if(tagListToAddMod->list.count)
10753 macTagCfg->addModListCount = tagListToAddMod->list.count;
10754 for(tagIdx = 0; tagIdx < tagListToAddMod->list.count; tagIdx++)
10756 macTagCfg->addModList[tagIdx].tagId =\
10757 tagListToAddMod->list.array[tagIdx]->tag_Id;
10758 macTagCfg->addModList[tagIdx].timeAlignTimer = \
10760 tagListToAddMod->list.array[tagIdx]->timeAlignmentTimer;
10764 /* Tag config to release */
10765 if(cuTagCfg->tag_ToReleaseList)
10767 tagListToRel = cuTagCfg->tag_ToReleaseList;
10768 if(tagListToRel->list.count)
10770 macTagCfg->relListCount = tagListToRel->list.count;
10771 for(tagIdx = 0; tagIdx < tagListToRel->list.count; tagIdx++)
10773 macTagCfg->relList[tagIdx] = *tagListToRel->list.array[tagIdx];
10779 /*******************************************************************
10781 * @brief Fills PdcchCfg received by CU
10785 * Function : extractPdcchCfg
10787 * Functionality: Fills PdcchCfg received by CU
10789 * @params[in] PDCCH_Config_t *cuPdcchCfg,
10790 * PdcchConfig *duPdcchCfg
10793 * ****************************************************************/
10795 void extractPdcchCfg(PDCCH_Config_t *cuPdcchCfg, PdcchConfig *macPdcchCfg)
10797 uint8_t cRsetIdx = 0;
10798 uint8_t srchSpcIdx = 0;
10800 struct PDCCH_Config__controlResourceSetToAddModList *cRsetToAddModList = NULLP;
10801 struct PDCCH_Config__controlResourceSetToReleaseList *cRsetToRelList = NULLP;
10802 struct PDCCH_Config__searchSpacesToAddModList *srchSpcToAddModList = NULLP;
10803 struct PDCCH_Config__searchSpacesToReleaseList *srchSpcToRelList = NULLP;
10806 /* Control Resource Set To Add/Mod List */
10807 if(cuPdcchCfg->controlResourceSetToAddModList)
10809 cRsetToAddModList = cuPdcchCfg->controlResourceSetToAddModList;
10810 if(cRsetToAddModList->list.count)
10812 macPdcchCfg->numCRsetToAddMod = cRsetToAddModList->list.count;
10813 for(cRsetIdx = 0; cRsetIdx < cRsetToAddModList->list.count; cRsetIdx++)
10815 macPdcchCfg->cRSetToAddModList[cRsetIdx].cRSetId = \
10816 cRsetToAddModList->list.array[cRsetIdx]->controlResourceSetId;
10817 //freqDomRsrcBitStringToInt(&cRsetToAddModList->list.array[cRsetIdx]->frequencyDomainResources,\
10818 macPdcchCfg->cRSetToAddModList[cRsetIdx].freqDomainRsrc);
10819 memcpy(macPdcchCfg->cRSetToAddModList[cRsetIdx].freqDomainRsrc, \
10820 cRsetToAddModList->list.array[cRsetIdx]->frequencyDomainResources.buf,
10821 cRsetToAddModList->list.array[cRsetIdx]->frequencyDomainResources.size);
10823 macPdcchCfg->cRSetToAddModList[cRsetIdx].duration = \
10824 cRsetToAddModList->list.array[cRsetIdx]->duration;
10826 macPdcchCfg->cRSetToAddModList[cRsetIdx].cceRegMappingType = \
10827 cRsetToAddModList->list.array[cRsetIdx]->cce_REG_MappingType.present;
10828 if(macPdcchCfg->cRSetToAddModList[cRsetIdx].cceRegMappingType == CCE_REG_MAPPINGTYPE_PR_INTERLEAVED)
10830 //TODO: handle the case for Interleaved
10832 macPdcchCfg->cRSetToAddModList[cRsetIdx].precoderGranularity = \
10833 cRsetToAddModList->list.array[cRsetIdx]->precoderGranularity;
10834 if(cRsetToAddModList->list.array[cRsetIdx]->pdcch_DMRS_ScramblingID)
10836 macPdcchCfg->cRSetToAddModList[cRsetIdx].dmrsScramblingId= \
10837 *(cRsetToAddModList->list.array[cRsetIdx]->pdcch_DMRS_ScramblingID);
10842 /* Control Resource Set To Release List */
10843 if(cuPdcchCfg->controlResourceSetToReleaseList)
10845 cRsetToRelList = cuPdcchCfg->controlResourceSetToReleaseList;
10846 if(cRsetToRelList->list.count)
10848 macPdcchCfg->numCRsetToRel = cRsetToRelList->list.count;
10849 for(cRsetIdx = 0; cRsetIdx < cRsetToRelList->list.count; cRsetIdx++)
10851 macPdcchCfg->cRSetToRelList[cRsetIdx] = *(cRsetToRelList->list.array[cRsetIdx]);
10856 /* Search space To Add/Mod List */
10857 if(cuPdcchCfg->searchSpacesToAddModList)
10859 srchSpcToAddModList = cuPdcchCfg->searchSpacesToAddModList;
10860 if(srchSpcToAddModList->list.count)
10862 macPdcchCfg->numSearchSpcToAddMod = srchSpcToAddModList->list.count;
10863 for(srchSpcIdx = 0; srchSpcIdx < srchSpcToAddModList->list.count; srchSpcIdx++)
10865 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceId =\
10866 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceId;
10867 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].cRSetId =\
10868 *(srchSpcToAddModList->list.array[srchSpcIdx]->controlResourceSetId);
10869 if(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSlotPeriodicityAndOffset)
10871 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].mSlotPeriodicityAndOffset =\
10872 srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSlotPeriodicityAndOffset->present;
10874 if(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSymbolsWithinSlot)
10876 bitStringToInt(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSymbolsWithinSlot,\
10877 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].mSymbolsWithinSlot);
10879 if(srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates)
10881 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel1 = \
10882 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel1;
10883 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel2 = \
10884 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel2;
10885 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel4 = \
10886 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel4;
10888 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel8 = \
10889 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel8;
10891 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel16 = \
10892 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel16;
10894 if(srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType)
10896 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceType =\
10897 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType->present;
10898 if(macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceType == SEARCHSPACETYPE_PR_UE_SPECIFIC)
10900 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].ueSpecificDciFormat =\
10901 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType->choice.ue_Specific->dci_Formats;
10908 /* Search space To Rel List */
10909 if(cuPdcchCfg->searchSpacesToReleaseList)
10911 srchSpcToRelList = cuPdcchCfg->searchSpacesToReleaseList;
10912 if(srchSpcToRelList->list.count)
10914 macPdcchCfg->numSearchSpcToRel = srchSpcToRelList->list.count;
10915 for(srchSpcIdx = 0; srchSpcIdx < srchSpcToRelList->list.count; srchSpcIdx++)
10917 macPdcchCfg->searchSpcToRelList[srchSpcIdx] =\
10918 *(srchSpcToRelList->list.array[srchSpcIdx]);
10924 /*******************************************************************
10926 * @brief Fills PdschCfg received by CU
10930 * Function : extractPdschCfg
10932 * Functionality: Fills PdschCfg received by CU
10934 * @params[in] PDSCH_Config_t *cuPdschCfg = Information which is send by CU,
10935 * which we have stored in F1UeContextSetupDb,
10936 * PdschConfig *macPdschCfg = Used to Store the information which
10937 * needs to send in other layer, as well as this can be the variable
10938 * which stores the information in DuCb,
10939 * PdschConfig *storedPdschCfg = Null in case of sending the
10940 * information to other layer else it will have stored pdsch
10941 * configuration in copyOfmacUeCfg.
10944 * ****************************************************************/
10946 void extractPdschCfg(PDSCH_Config_t *cuPdschCfg, PdschConfig *macPdschCfg, PdschConfig *storedPdschCfg)
10948 uint8_t timeDomIdx;
10949 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAlloc = NULLP;
10951 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
10953 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->present == \
10954 PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA_PR_setup)
10956 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)
10958 macPdschCfg->dmrsDlCfgForPdschMapTypeA.addPos = \
10959 *(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition);
10963 macPdschCfg->resourceAllocType = cuPdschCfg->resourceAllocation;
10964 if(cuPdschCfg->pdsch_TimeDomainAllocationList)
10966 timeDomAlloc = cuPdschCfg->pdsch_TimeDomainAllocationList;
10967 if(timeDomAlloc->present ==\
10968 PDSCH_Config__pdsch_TimeDomainAllocationList_PR_setup)
10970 if(timeDomAlloc->choice.setup)
10972 macPdschCfg->numTimeDomRsrcAlloc = timeDomAlloc->choice.setup->list.count;
10973 for(timeDomIdx = 0; timeDomIdx < timeDomAlloc->choice.setup->list.count; timeDomIdx++)
10975 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0 = NULLP;
10976 if(timeDomAlloc->choice.setup->list.array[timeDomIdx]->k0)
10978 if(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0 == NULL)
10982 if(storedPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0)
10984 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0 =\
10985 storedPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0;
10989 DU_ALLOC_SHRABL_BUF(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0, sizeof(uint8_t));
10994 DU_ALLOC_SHRABL_BUF(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0, sizeof(uint8_t));
10996 if(!macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0)
10998 DU_LOG("\nERROR --> DU APP : Memory allocation failed for k0 at extractPdschCfg()");
11002 *(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0) = \
11003 *(timeDomAlloc->choice.setup->list.array[timeDomIdx]->k0);
11005 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].mappingType = \
11006 timeDomAlloc->choice.setup->list.array[timeDomIdx]->mappingType;
11007 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].startSymbolAndLength = \
11008 timeDomAlloc->choice.setup->list.array[timeDomIdx]->startSymbolAndLength;
11013 macPdschCfg->rbgSize = cuPdschCfg->rbg_Size;
11014 if(cuPdschCfg->maxNrofCodeWordsScheduledByDCI)
11015 macPdschCfg->numCodeWordsSchByDci = *(cuPdschCfg->maxNrofCodeWordsScheduledByDCI);
11016 if(cuPdschCfg->prb_BundlingType.present == PDSCH_Config__prb_BundlingType_PR_staticBundling)
11018 macPdschCfg->bundlingType = cuPdschCfg->prb_BundlingType.present;
11019 if(cuPdschCfg->prb_BundlingType.choice.staticBundling)
11021 if(cuPdschCfg->prb_BundlingType.choice.staticBundling->bundleSize)
11023 macPdschCfg->bundlingInfo.StaticBundling.size = \
11024 *(cuPdschCfg->prb_BundlingType.choice.staticBundling->bundleSize);
11028 else if(cuPdschCfg->prb_BundlingType.present == PDSCH_Config__prb_BundlingType_PR_dynamicBundling)
11030 macPdschCfg->bundlingType = cuPdschCfg->prb_BundlingType.present;
11035 /*******************************************************************
11037 * @brief Fills PdschServingCellCfg received by CU
11041 * Function : extractPdschServingCellCfg
11043 * Functionality: Fills PdschCfg received by CU
11045 * @params[in] PDSCH_ServingCellConfig_t *cuPdschSrvCellCfg,
11046 * PdschServCellCfg *macUePdschSrvCellCfg
11047 * @return ROK/RFAILED
11049 * ****************************************************************/
11051 uint8_t extractPdschServingCellCfg(PDSCH_ServingCellConfig_t *cuPdschSrvCellCfg, PdschServCellCfg *macUePdschSrvCellCfg)
11053 if(cuPdschSrvCellCfg->codeBlockGroupTransmission)
11055 if(cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup)
11057 if(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb)
11059 *(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb) = \
11060 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock;
11064 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
11065 if(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb)
11067 *(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb) = \
11068 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock;
11072 DU_LOG("\nERROR --> DU APP : Memory allocation failed for maxCodeBlkGrpPerTb at extractPdschServingCellCfg()");
11076 if(macUePdschSrvCellCfg->codeBlkGrpFlushInd)
11078 *(macUePdschSrvCellCfg->codeBlkGrpFlushInd) = \
11079 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->codeBlockGroupFlushIndicator;
11083 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->codeBlkGrpFlushInd , sizeof(bool));
11084 if(macUePdschSrvCellCfg->codeBlkGrpFlushInd)
11086 *(macUePdschSrvCellCfg->codeBlkGrpFlushInd) = \
11087 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->codeBlockGroupFlushIndicator;
11091 DU_LOG("\nERROR --> DU APP : Memory allocation failed for codeBlkGrpFlushInd at extractPdschServingCellCfg()");
11097 if(cuPdschSrvCellCfg->nrofHARQ_ProcessesForPDSCH)
11099 macUePdschSrvCellCfg->numHarqProcForPdsch = *(cuPdschSrvCellCfg->nrofHARQ_ProcessesForPDSCH);
11101 if(cuPdschSrvCellCfg->ext1)
11103 if(cuPdschSrvCellCfg->ext1->maxMIMO_Layers)
11105 if(macUePdschSrvCellCfg->maxMimoLayers)
11107 *(macUePdschSrvCellCfg->maxMimoLayers) = *(cuPdschSrvCellCfg->ext1->maxMIMO_Layers);
11111 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->maxMimoLayers, sizeof(uint8_t));
11112 if(macUePdschSrvCellCfg->maxMimoLayers)
11114 *(macUePdschSrvCellCfg->maxMimoLayers) = *(cuPdschSrvCellCfg->ext1->maxMIMO_Layers);
11118 DU_LOG("\nERROR --> DU APP : Memory allocation failed for maxMimoLayers at extractPdschServingCellCfg()");
11124 if(cuPdschSrvCellCfg->xOverhead)
11126 if(macUePdschSrvCellCfg->xOverhead)
11128 *(macUePdschSrvCellCfg->xOverhead) = *(cuPdschSrvCellCfg->xOverhead);
11132 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->xOverhead, sizeof(PdschXOverhead));
11133 if(macUePdschSrvCellCfg->xOverhead)
11135 *(macUePdschSrvCellCfg->xOverhead) = *(cuPdschSrvCellCfg->xOverhead);
11139 DU_LOG("\nERROR --> DU APP : Memory allocation failed for xOverhead at extractPdschServingCellCfg()");
11147 /*******************************************************************
11149 * @brief Fills PuschCfg received by CU
11153 * Function : extractPuschCfg
11155 * Functionality: Fills PuschCfg received by CU
11157 * @params[in] BWP_UplinkDedicated__pusch_Config *cuPuschCfg,
11158 * PuschCfg *macPuschCfg
11161 * ****************************************************************/
11163 void extractPuschCfg(struct BWP_UplinkDedicated__pusch_Config *cuPuschCfg, PuschCfg *macPuschCfg)
11165 uint8_t timeDomIdx = 0;
11166 DMRS_UplinkConfig_t *dmrsUlCfg = NULLP;
11167 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList = NULLP;
11169 if(cuPuschCfg->present == BWP_UplinkDedicated__pusch_Config_PR_setup)
11171 if(cuPuschCfg->choice.setup)
11173 if(cuPuschCfg->choice.setup->dataScramblingIdentityPUSCH)
11175 macPuschCfg->dataScramblingId = \
11176 *(cuPuschCfg->choice.setup->dataScramblingIdentityPUSCH);
11178 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA)
11180 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->present == PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA_PR_setup)
11182 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup)
11184 dmrsUlCfg = (cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup);
11185 if(dmrsUlCfg->dmrs_AdditionalPosition)
11187 macPuschCfg->dmrsUlCfgForPuschMapTypeA.addPos =\
11188 *(dmrsUlCfg->dmrs_AdditionalPosition);
11190 if(dmrsUlCfg->transformPrecodingDisabled)
11192 if(dmrsUlCfg->transformPrecodingDisabled->scramblingID0)
11194 macPuschCfg->dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0 = \
11195 *(dmrsUlCfg->transformPrecodingDisabled->scramblingID0);
11201 /*Res Alloc Type for UL */
11202 if(cuPuschCfg->choice.setup->resourceAllocation)
11204 macPuschCfg->resourceAllocType = \
11205 cuPuschCfg->choice.setup->resourceAllocation;
11207 if(cuPuschCfg->choice.setup->pusch_TimeDomainAllocationList)
11209 timeDomAllocList = cuPuschCfg->choice.setup->pusch_TimeDomainAllocationList;
11210 if(timeDomAllocList->present == PUSCH_Config__pusch_TimeDomainAllocationList_PR_setup)
11212 if(timeDomAllocList->choice.setup)
11214 macPuschCfg->numTimeDomRsrcAlloc = timeDomAllocList->choice.setup->list.count;
11215 for(timeDomIdx = 0; timeDomIdx <timeDomAllocList->choice.setup->list.count; timeDomIdx++)
11217 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].k2 = \
11218 *(timeDomAllocList->choice.setup->list.array[timeDomIdx]->k2);
11219 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].mappingType = \
11220 timeDomAllocList->choice.setup->list.array[timeDomIdx]->mappingType;
11221 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].startSymbolAndLength = \
11222 timeDomAllocList->choice.setup->list.array[timeDomIdx]->startSymbolAndLength;
11227 if(cuPuschCfg->choice.setup->transformPrecoder)
11228 macPuschCfg->transformPrecoder = *(cuPuschCfg->choice.setup->transformPrecoder);
11233 /*******************************************************************
11235 * @brief Function to fill pucch Power Control
11239 * Function : extractPucchPowerControl
11241 * Functionality: Function to fill pucch Power Control
11243 * @params[in] PucchPowerControl *pwrCtrl,
11244 * struct PUCCH_PowerControl *cuPwrCtrlCfg
11247 * ****************************************************************/
11249 void extractPucchPowerControl(PucchPowerControl *pwrCtrl, struct PUCCH_PowerControl *cuPwrCtrlCfg)
11253 if(cuPwrCtrlCfg->deltaF_PUCCH_f0)
11254 pwrCtrl->deltaF_Format0 = *cuPwrCtrlCfg->deltaF_PUCCH_f0;
11255 if(cuPwrCtrlCfg->deltaF_PUCCH_f1)
11256 pwrCtrl->deltaF_Format1 = *cuPwrCtrlCfg->deltaF_PUCCH_f1;
11257 if(cuPwrCtrlCfg->deltaF_PUCCH_f2)
11258 pwrCtrl->deltaF_Format2 = *cuPwrCtrlCfg->deltaF_PUCCH_f2;
11259 if(cuPwrCtrlCfg->deltaF_PUCCH_f3)
11260 pwrCtrl->deltaF_Format3 = *cuPwrCtrlCfg->deltaF_PUCCH_f3;
11261 if(cuPwrCtrlCfg->deltaF_PUCCH_f4)
11262 pwrCtrl->deltaF_Format4 = *cuPwrCtrlCfg->deltaF_PUCCH_f4;
11263 if(cuPwrCtrlCfg->p0_Set)
11265 pwrCtrl->p0SetCount = cuPwrCtrlCfg->p0_Set->list.count;
11266 for(arrIdx=0; arrIdx < pwrCtrl->p0SetCount; arrIdx++)
11268 pwrCtrl->p0Set[arrIdx].p0PucchId =\
11269 cuPwrCtrlCfg->p0_Set->list.array[arrIdx]->p0_PUCCH_Id;
11270 pwrCtrl->p0Set[arrIdx].p0PucchVal =\
11271 cuPwrCtrlCfg->p0_Set->list.array[arrIdx]->p0_PUCCH_Value;
11274 if(cuPwrCtrlCfg->pathlossReferenceRSs)
11276 pwrCtrl->pathLossRefRSListCount = cuPwrCtrlCfg->pathlossReferenceRSs->list.count;
11277 for(arrIdx = 0; arrIdx < pwrCtrl->pathLossRefRSListCount; arrIdx++)
11279 pwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId =\
11280 cuPwrCtrlCfg->pathlossReferenceRSs->list.array[arrIdx]->pucch_PathlossReferenceRS_Id;
11285 /*******************************************************************
11287 * @brief Function to extractResrcSetToAddModList sent by CU
11291 * Function : extractResrcSetToAddModList
11293 * Functionality: Fucntion to extractResrcSetToAddModList
11295 * @params[in] PucchResrcSetCfg pointer,
11296 * struct PUCCH_Config__resourceSetToAddModList pointer
11299 * ****************************************************************/
11301 void extractResrcSetToAddModList(PucchResrcSetCfg *macRsrcSetList, struct PUCCH_Config__resourceSetToAddModList *cuRsrcSetList)
11303 uint8_t arrIdx, rsrcListIdx;
11305 macRsrcSetList->resrcSetToAddModListCount = cuRsrcSetList->list.count;
11306 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToAddModListCount; arrIdx++)
11308 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId =\
11309 cuRsrcSetList->list.array[arrIdx]->pucch_ResourceSetId;
11310 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount =\
11311 cuRsrcSetList->list.array[arrIdx]->resourceList.list.count;
11312 for(rsrcListIdx = 0; rsrcListIdx < macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount; rsrcListIdx++)
11314 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx] =\
11315 *cuRsrcSetList->list.array[arrIdx]->resourceList.list.array[rsrcListIdx];
11318 if(cuRsrcSetList->list.array[arrIdx]->maxPayloadMinus1)
11320 macRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize =\
11321 *cuRsrcSetList->list.array[arrIdx]->maxPayloadMinus1;
11325 macRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize = 0;
11328 }/* End of extractResrcSetToAddModList */
11330 /*******************************************************************
11332 * @brief Fills extractResrcToAddModList sent by CU
11336 * Function : extractResrcToAddModList
11338 * Functionality: Fills extractResrcToAddModList
11340 * @params[in] PucchResrcCfg pointer,
11341 * struct PUCCH_Config__resourceToAddModList pointer
11342 * @return ROk/RFAILED
11344 * ****************************************************************/
11346 uint8_t extractResrcToAddModList(PucchResrcCfg *macResrcList, struct PUCCH_Config__resourceToAddModList *cuResrcList)
11350 macResrcList->resrcToAddModListCount = cuResrcList->list.count;
11351 for(arrIdx = 0; arrIdx < macResrcList->resrcToAddModListCount; arrIdx++)
11353 macResrcList->resrcToAddModList[arrIdx].resrcId =\
11354 cuResrcList->list.array[arrIdx]->pucch_ResourceId;
11355 macResrcList->resrcToAddModList[arrIdx].startPrb =\
11356 cuResrcList->list.array[arrIdx]->startingPRB;
11357 if(cuResrcList->list.array[arrIdx]->intraSlotFrequencyHopping)
11359 macResrcList->resrcToAddModList[arrIdx].intraFreqHop =\
11360 *cuResrcList->list.array[arrIdx]->intraSlotFrequencyHopping;
11362 if(cuResrcList->list.array[arrIdx]->secondHopPRB)
11364 macResrcList->resrcToAddModList[arrIdx].secondPrbHop =\
11365 *cuResrcList->list.array[arrIdx]->secondHopPRB;
11367 /* PUCCH RSRC FORMAT */
11368 if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format0)
11370 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_0;
11371 if(cuResrcList->list.array[arrIdx]->format.choice.format0)
11373 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0, sizeof(PucchFormat0));
11374 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0 == NULLP)
11376 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format0 in extractResrcToAddModList()");
11379 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->initialCyclicShift =\
11380 cuResrcList->list.array[arrIdx]->format.choice.format0->initialCyclicShift;
11381 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->numSymbols =\
11382 cuResrcList->list.array[arrIdx]->format.choice.format0->nrofSymbols;
11383 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->startSymbolIdx =\
11384 cuResrcList->list.array[arrIdx]->format.choice.format0->startingSymbolIndex;
11387 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format1)
11389 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_1;
11390 if(cuResrcList->list.array[arrIdx]->format.choice.format1)
11392 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1, sizeof(PucchFormat1));
11393 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1 == NULLP)
11395 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format1 in extractResrcToAddModList()");
11398 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->initialCyclicShift =\
11399 cuResrcList->list.array[arrIdx]->format.choice.format1->initialCyclicShift;
11400 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->numSymbols =\
11401 cuResrcList->list.array[arrIdx]->format.choice.format1->nrofSymbols;
11402 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->startSymbolIdx =\
11403 cuResrcList->list.array[arrIdx]->format.choice.format1->startingSymbolIndex;
11404 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->timeDomOCC =\
11405 cuResrcList->list.array[arrIdx]->format.choice.format1->timeDomainOCC;
11408 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format2)
11410 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_2;
11411 if(cuResrcList->list.array[arrIdx]->format.choice.format2)
11413 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2, sizeof(PucchFormat2_3));
11414 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2 == NULLP)
11416 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format2 in extractResrcToAddModList()");
11419 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->numPrbs =\
11420 cuResrcList->list.array[arrIdx]->format.choice.format2->nrofPRBs;
11421 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->numSymbols =\
11422 cuResrcList->list.array[arrIdx]->format.choice.format2->nrofSymbols;
11423 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->startSymbolIdx =\
11424 cuResrcList->list.array[arrIdx]->format.choice.format2->startingSymbolIndex;
11427 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format3)
11429 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_3;
11430 if(cuResrcList->list.array[arrIdx]->format.choice.format3)
11432 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3, sizeof(PucchFormat2_3));
11433 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3 == NULLP)
11435 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format3 in extractResrcToAddModList()");
11438 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->numPrbs =\
11439 cuResrcList->list.array[arrIdx]->format.choice.format3->nrofPRBs;
11440 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->numSymbols =\
11441 cuResrcList->list.array[arrIdx]->format.choice.format3->nrofSymbols;
11442 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->startSymbolIdx =\
11443 cuResrcList->list.array[arrIdx]->format.choice.format3->startingSymbolIndex;
11446 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format4)
11448 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_4;
11449 if(cuResrcList->list.array[arrIdx]->format.choice.format4)
11451 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4, sizeof(PucchFormat4));
11452 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4 == NULLP)
11454 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format4 in extractResrcToAddModList()");
11457 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->numSymbols =\
11458 cuResrcList->list.array[arrIdx]->format.choice.format4->nrofSymbols;
11459 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->occLen =\
11460 cuResrcList->list.array[arrIdx]->format.choice.format4->occ_Length;
11461 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->occIdx =\
11462 cuResrcList->list.array[arrIdx]->format.choice.format4->occ_Index;
11463 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->startSymbolIdx =\
11464 cuResrcList->list.array[arrIdx]->format.choice.format4->startingSymbolIndex;
11470 }/* End of extractResrcToAddModList */
11472 /*******************************************************************
11474 * @brief Fills fillPucchSchedReqPeriodAndOffset sent by CU
11478 * Function : fillPucchSchedReqPeriodAndOffset
11480 * Functionality: To fillPucchSchedReqPeriodAndOffset
11482 * @params[in] macPeriodicty,
11483 * SchedulingRequestResourceConfig__periodicityAndOffset pointer
11486 * ****************************************************************/
11488 void fillPucchSchedReqPeriodAndOffset(uint8_t macPeriodicty, uint16_t macOffset,\
11489 struct SchedulingRequestResourceConfig__periodicityAndOffset *cuPeriodicty)
11491 macPeriodicty = cuPeriodicty->present;
11492 switch(macPeriodicty)
11494 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sym2:
11496 macOffset = cuPeriodicty->choice.sym2;
11499 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sym6or7:
11501 macOffset = cuPeriodicty->choice.sym6or7;
11504 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl1:
11506 macOffset = cuPeriodicty->choice.sl1;
11509 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl2:
11511 macOffset = cuPeriodicty->choice.sl2;
11514 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl4:
11516 macOffset = cuPeriodicty->choice.sl4;
11519 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl5:
11521 macOffset = cuPeriodicty->choice.sl5;
11524 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl8:
11526 macOffset = cuPeriodicty->choice.sl8;
11529 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl10:
11531 macOffset = cuPeriodicty->choice.sl10;
11534 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl16:
11536 macOffset = cuPeriodicty->choice.sl16;
11539 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl20:
11541 macOffset = cuPeriodicty->choice.sl20;
11544 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl40:
11546 macOffset = cuPeriodicty->choice.sl40;
11549 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl80:
11551 macOffset = cuPeriodicty->choice.sl80;
11554 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl160:
11556 macOffset = cuPeriodicty->choice.sl160;
11559 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl320:
11561 macOffset = cuPeriodicty->choice.sl320;
11564 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl640:
11566 macOffset = cuPeriodicty->choice.sl640;
11570 DU_LOG("\nERROR --> F1AP : Invalid periodicity %d", macPeriodicty);
11574 /*******************************************************************
11576 * @brief Function to extractPucchFormatCfg sent by CU
11580 * Function : extractPucchFormatCfg
11582 * Functionality: Function to extractPucchFormatCfg
11584 * @params[in] PucchFormatCfg pointer,
11585 * PUCCH_FormatConfig_t pointer
11588 * ****************************************************************/
11590 void extractPucchFormatCfg(PucchFormatCfg *macFormatCfg, PUCCH_FormatConfig_t *cuFormatCfg)
11592 if(cuFormatCfg->interslotFrequencyHopping)
11593 macFormatCfg->interSlotFreqHop = *cuFormatCfg->interslotFrequencyHopping;
11594 if(cuFormatCfg->additionalDMRS)
11595 macFormatCfg->addDmrs = *cuFormatCfg->additionalDMRS;
11596 if(cuFormatCfg->maxCodeRate)
11597 macFormatCfg->maxCodeRate = *cuFormatCfg->maxCodeRate;
11598 if(cuFormatCfg->nrofSlots)
11599 macFormatCfg->numSlots = *cuFormatCfg->nrofSlots;
11600 if(cuFormatCfg->pi2BPSK)
11601 macFormatCfg->pi2BPSK = *cuFormatCfg->pi2BPSK;
11602 if(cuFormatCfg->simultaneousHARQ_ACK_CSI)
11603 macFormatCfg->harqAckCSI = *cuFormatCfg->simultaneousHARQ_ACK_CSI;
11604 }/* End of extractPucchFormatCfg */
11606 /*******************************************************************
11608 * @brief Function to extractSchedReqCfgToAddMod sent by CU
11612 * Function : extractSchedReqCfgToAddMod
11614 * Functionality: Function to extractSchedReqCfgToAddMod
11616 * @params[in] PucchSchedReqCfg pointer,
11617 * PUCCH_Config__schedulingRequestResourceToAddModList pointer
11620 * ****************************************************************/
11622 void extractSchedReqCfgToAddMod(PucchSchedReqCfg *macSchedReqCfg, struct PUCCH_Config__schedulingRequestResourceToAddModList *cuSchedReqList)
11626 macSchedReqCfg->schedAddModListCount = cuSchedReqList->list.count;
11627 for(arrIdx = 0; arrIdx < macSchedReqCfg->schedAddModListCount; arrIdx++)
11629 macSchedReqCfg->schedAddModList[arrIdx].resrcId =\
11630 cuSchedReqList->list.array[arrIdx]->schedulingRequestResourceId;
11631 macSchedReqCfg->schedAddModList[arrIdx].requestId =\
11632 cuSchedReqList->list.array[arrIdx]->schedulingRequestID;
11633 if(cuSchedReqList->list.array[arrIdx]->periodicityAndOffset)
11635 fillPucchSchedReqPeriodAndOffset(macSchedReqCfg->schedAddModList[arrIdx].periodicity,\
11636 macSchedReqCfg->schedAddModList[arrIdx].offset, cuSchedReqList->list.array[arrIdx]->periodicityAndOffset);
11638 if(cuSchedReqList->list.array[arrIdx]->resource)
11640 macSchedReqCfg->schedAddModList[arrIdx].resrc =\
11641 *cuSchedReqList->list.array[arrIdx]->resource;
11645 }/* End of extractSchedReqCfgToAddMod */
11647 /*******************************************************************
11649 * @brief Fills PucchCfg received by CU
11653 * Function : extractPucchCfg
11655 * Functionality: Fills PucchCfg received by CU
11657 * @params[in] BWP_UplinkDedicated__pucch_Config *cuPucchCfg = Information which
11658 * is send by CU, which we have stored in F1UeContextSetupDb,
11659 * PucchCfg *macPucchCfg = Used to Store the information which
11660 * needs to send in other layer, as well as this can be the variable
11661 * which stores the information in DuCb,
11662 * PucchCfg *storedPucchCfg = Null in case of sending the
11663 * information to other layer else it will have Pucch Cfg which
11664 * we have stored in copyOfmacUeCfg.
11665 * @return ROK/RFAILED
11667 * ****************************************************************/
11669 uint8_t extractPucchCfg(struct BWP_UplinkDedicated__pucch_Config *cuPucchCfg, PucchCfg *macPucchCfg,\
11670 PucchCfg *storedPucchCfg)
11674 if(cuPucchCfg->present == BWP_UplinkDedicated__pucch_Config_PR_setup)
11676 if(cuPucchCfg->choice.setup)
11678 /* Resource Set Cfg */
11679 if(cuPucchCfg->choice.setup->resourceSetToAddModList)
11681 DU_ALLOC_SHRABL_BUF(macPucchCfg->resrcSet, sizeof(PucchResrcSetCfg));
11682 if(macPucchCfg->resrcSet == NULLP)
11684 DU_LOG("\nERROR --> F1AP : Failed to extract Resrc set List in extractPucchCfg()");
11687 memset(macPucchCfg->resrcSet, 0, sizeof(PucchResrcSetCfg));
11688 extractResrcSetToAddModList(macPucchCfg->resrcSet, cuPucchCfg->choice.setup->resourceSetToAddModList);
11692 if(cuPucchCfg->choice.setup->resourceToAddModList)
11694 DU_ALLOC_SHRABL_BUF(macPucchCfg->resrc, sizeof(PucchResrcCfg));
11695 if(macPucchCfg->resrc == NULLP)
11697 DU_LOG("\nERROR --> F1AP : Failed to extract Resrc List in extractPucchCfg()");
11700 memset(macPucchCfg->resrc, 0, sizeof(PucchResrcCfg));
11701 extractResrcToAddModList(macPucchCfg->resrc, cuPucchCfg->choice.setup->resourceToAddModList);
11705 if(cuPucchCfg->choice.setup->format1)
11707 DU_ALLOC_SHRABL_BUF(macPucchCfg->format1, sizeof(PucchFormatCfg));
11708 if(macPucchCfg->format1 == NULLP)
11710 DU_LOG("\nERROR --> F1AP : Failed to extract format 1 Cfg in extractPucchCfg()");
11713 memset(macPucchCfg->format1, 0, sizeof(PucchFormatCfg));
11714 extractPucchFormatCfg(macPucchCfg->format1,\
11715 cuPucchCfg->choice.setup->format1->choice.setup);
11719 if(cuPucchCfg->choice.setup->format2)
11721 DU_ALLOC_SHRABL_BUF(macPucchCfg->format2, sizeof(PucchFormatCfg));
11722 if(macPucchCfg->format2 == NULLP)
11724 DU_LOG("\nERROR --> F1AP : Failed to extract format 2 Cfg in extractPucchCfg()");
11727 memset(macPucchCfg->format2, 0, sizeof(PucchFormatCfg));
11728 extractPucchFormatCfg(macPucchCfg->format2,\
11729 cuPucchCfg->choice.setup->format2->choice.setup);
11733 if(cuPucchCfg->choice.setup->format3)
11735 DU_ALLOC_SHRABL_BUF(macPucchCfg->format3, sizeof(PucchFormatCfg));
11736 if(macPucchCfg->format3 == NULLP)
11738 DU_LOG("\nERROR --> F1AP : Failed to extract format 3 Cfg in extractPucchCfg()");
11741 memset(macPucchCfg->format3, 0, sizeof(PucchFormatCfg));
11742 extractPucchFormatCfg(macPucchCfg->format3,\
11743 cuPucchCfg->choice.setup->format3->choice.setup);
11747 if(cuPucchCfg->choice.setup->format4)
11749 DU_ALLOC_SHRABL_BUF(macPucchCfg->format4, sizeof(PucchFormatCfg));
11750 if(macPucchCfg->format4 == NULLP)
11752 DU_LOG("\nERROR --> F1AP : Failed to extract format 4 Cfg in extractPucchCfg()");
11755 memset(macPucchCfg->format4, 0, sizeof(PucchFormatCfg));
11756 extractPucchFormatCfg(macPucchCfg->format4,\
11757 cuPucchCfg->choice.setup->format4->choice.setup);
11760 /* Sched Req List */
11761 if(cuPucchCfg->choice.setup->schedulingRequestResourceToAddModList)
11763 DU_ALLOC_SHRABL_BUF(macPucchCfg->schedReq, sizeof(PucchSchedReqCfg));
11764 if(macPucchCfg->schedReq == NULLP)
11766 DU_LOG("\nERROR --> F1AP : Failed to extract schedReqCfg in extractPucchCfg()");
11769 memset(macPucchCfg->schedReq, 0, sizeof(PucchSchedReqCfg));
11770 extractSchedReqCfgToAddMod(macPucchCfg->schedReq,\
11771 cuPucchCfg->choice.setup->schedulingRequestResourceToAddModList);
11774 /*TODO: Add support for Spatial Info */
11777 if(cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList)
11779 DU_ALLOC_SHRABL_BUF(macPucchCfg->multiCsiCfg, sizeof(PucchMultiCsiCfg));
11780 if(macPucchCfg->multiCsiCfg == NULLP)
11782 DU_LOG("\nERROR --> F1AP : Failed to extract multiCsiCfg in extractPucchCfg()");
11785 memset(macPucchCfg->multiCsiCfg, 0, sizeof(PucchMultiCsiCfg));
11786 macPucchCfg->multiCsiCfg->multiCsiResrcListCount = cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList->list.count;
11787 for(arrIdx =0; arrIdx < macPucchCfg->multiCsiCfg->multiCsiResrcListCount; arrIdx++)
11789 macPucchCfg->multiCsiCfg->multiCsiResrcList[arrIdx] =\
11790 *cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList->list.array[arrIdx];
11794 /* Dl_DataToUL_ACK */
11795 if(cuPucchCfg->choice.setup->dl_DataToUL_ACK)
11799 if(storedPucchCfg->dlDataToUlAck)
11801 macPucchCfg->dlDataToUlAck = storedPucchCfg->dlDataToUlAck;
11805 DU_ALLOC_SHRABL_BUF(macPucchCfg->dlDataToUlAck, sizeof(PucchDlDataToUlAck));
11810 DU_ALLOC_SHRABL_BUF(macPucchCfg->dlDataToUlAck, sizeof(PucchDlDataToUlAck));
11812 if(macPucchCfg->dlDataToUlAck == NULLP)
11814 DU_LOG("\nERROR --> F1AP : Failed to extract Dl_DataToUL_ACK in extractPucchCfg()");
11817 memset(macPucchCfg->dlDataToUlAck, 0, sizeof(PucchDlDataToUlAck));
11818 macPucchCfg->dlDataToUlAck->dlDataToUlAckListCount = cuPucchCfg->choice.setup->dl_DataToUL_ACK->list.count;
11819 for(arrIdx = 0; arrIdx < macPucchCfg->dlDataToUlAck->dlDataToUlAckListCount; arrIdx++)
11821 macPucchCfg->dlDataToUlAck->dlDataToUlAckList[arrIdx] =\
11822 *cuPucchCfg->choice.setup->dl_DataToUL_ACK->list.array[arrIdx];
11826 /* Power Control */
11827 if(cuPucchCfg->choice.setup->pucch_PowerControl)
11829 DU_ALLOC_SHRABL_BUF(macPucchCfg->powerControl, sizeof(PucchPowerControl));
11830 if(macPucchCfg->powerControl == NULLP)
11832 DU_LOG("\nERROR --> F1AP : Failed to extract power control in extractPucchCfg()");
11835 extractPucchPowerControl(macPucchCfg->powerControl,\
11836 cuPucchCfg->choice.setup->pucch_PowerControl);
11843 /*******************************************************************
11845 * @brief Fills ServingCellReconfig received by CU
11849 * Function : extractSpCellDedicatedCfg
11851 * Functionality: Fills ServingCellReconfig received by CU
11853 * @params[in] ServingCellConfig_t *cuSrvCellCfg = Information which is send by
11854 * CU, which we have stored in F1UeContextSetupDb,
11855 * ServCellCfgInfo *macSrvCellCfg = Used to Store the information
11856 * which needs to send in other layer, as well as this can be the
11857 * variable which stores the information in DuCb,
11858 * ServCellCfgInfo *storedSrvCellCfg = Null in case of sending the
11859 * information to other layer else it will have ServCellCfgInfo which
11860 * we have stored in copyOfmacUeCfg.
11861 * @return ROK/RFAILD
11863 * ****************************************************************/
11864 uint8_t extractSpCellDedicatedCfg(ServingCellConfig_t *cuSrvCellCfg, ServCellRecfgInfo *macSrvCellCfg,\
11865 ServCellRecfgInfo *storedSrvCellCfg)
11868 BWP_DownlinkDedicated_t *dlBwp = NULLP;
11869 BWP_UplinkDedicated_t *ulBwp = NULLP;
11871 if(cuSrvCellCfg->initialDownlinkBWP)
11873 dlBwp = ((BWP_DownlinkDedicated_t *)(cuSrvCellCfg->initialDownlinkBWP));
11874 if(dlBwp->pdcch_Config)
11876 if(dlBwp->pdcch_Config->choice.setup)
11878 macSrvCellCfg->initDlBwp.pdcchPresent = true;
11879 if(storedSrvCellCfg)
11881 if(!storedSrvCellCfg->initDlBwp.pdcchPresent)
11883 extractPdcchCfg(dlBwp->pdcch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdcchCfg);
11887 extractPdcchCfg(dlBwp->pdcch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdcchCfg);
11892 extractPdcchCfg(dlBwp->pdcch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdcchCfg);
11896 if(dlBwp->pdsch_Config)
11898 if(dlBwp->pdsch_Config->choice.setup)
11900 macSrvCellCfg->initDlBwp.pdschPresent = true;
11902 if(storedSrvCellCfg)
11904 if(!storedSrvCellCfg->initDlBwp.pdschPresent)
11906 extractPdschCfg(dlBwp->pdsch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdschCfg, NULL);
11910 extractPdschCfg(dlBwp->pdsch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdschCfg,\
11911 &storedSrvCellCfg->initDlBwp.pdschCfg);
11916 extractPdschCfg(dlBwp->pdsch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdschCfg, NULL);
11921 if(cuSrvCellCfg->firstActiveDownlinkBWP_Id)
11922 macSrvCellCfg->firstActvDlBwpId = *(cuSrvCellCfg->firstActiveDownlinkBWP_Id);
11923 if(cuSrvCellCfg->defaultDownlinkBWP_Id)
11924 macSrvCellCfg->defaultDlBwpId = *(cuSrvCellCfg->defaultDownlinkBWP_Id);
11925 if(cuSrvCellCfg->bwp_InactivityTimer)
11927 if(macSrvCellCfg->bwpInactivityTmr)
11929 memcpy(macSrvCellCfg->bwpInactivityTmr, cuSrvCellCfg->bwp_InactivityTimer, sizeof(uint8_t));
11933 macSrvCellCfg->bwpInactivityTmr = NULLP;
11934 DU_ALLOC_SHRABL_BUF(macSrvCellCfg->bwpInactivityTmr, sizeof(uint8_t));
11935 if(macSrvCellCfg->bwpInactivityTmr)
11937 memcpy(macSrvCellCfg->bwpInactivityTmr, cuSrvCellCfg->bwp_InactivityTimer, sizeof(uint8_t));
11941 DU_LOG("\nERROR --> F1AP : Memory Alloc failed for bwpInactivityTmr at extractSpCellDedicatedCfg()");
11946 if(cuSrvCellCfg->pdsch_ServingCellConfig)
11948 if(cuSrvCellCfg->pdsch_ServingCellConfig->choice.setup)
11950 ret = extractPdschServingCellCfg(cuSrvCellCfg->pdsch_ServingCellConfig->choice.setup, &macSrvCellCfg->pdschServCellCfg);
11953 DU_LOG("\nERROR --> F1AP : Failed at extractPdschServingCellCfg()");
11958 if(cuSrvCellCfg->uplinkConfig)
11960 if(cuSrvCellCfg->uplinkConfig->initialUplinkBWP)
11962 ulBwp = ((BWP_UplinkDedicated_t *)(cuSrvCellCfg->uplinkConfig->initialUplinkBWP));
11963 if(ulBwp->pusch_Config)
11965 macSrvCellCfg->initUlBwp.puschPresent = true;
11966 extractPuschCfg(ulBwp->pusch_Config, &macSrvCellCfg->initUlBwp.puschCfg);
11968 if(ulBwp->pucch_Config)
11970 macSrvCellCfg->initUlBwp.pucchPresent = true;
11971 memset(&macSrvCellCfg->initUlBwp.pucchCfg, 0, sizeof(PucchCfg));
11972 if(storedSrvCellCfg)
11974 if(!storedSrvCellCfg->initUlBwp.pucchPresent)
11975 extractPucchCfg(ulBwp->pucch_Config, &macSrvCellCfg->initUlBwp.pucchCfg, NULL);
11977 extractPucchCfg(ulBwp->pucch_Config, &macSrvCellCfg->initUlBwp.pucchCfg,\
11978 &storedSrvCellCfg->initUlBwp.pucchCfg);
11982 extractPucchCfg(ulBwp->pucch_Config, &macSrvCellCfg->initUlBwp.pucchCfg, NULL);
11986 if(cuSrvCellCfg->uplinkConfig->firstActiveUplinkBWP_Id)
11987 macSrvCellCfg->firstActvUlBwpId = *(cuSrvCellCfg->uplinkConfig->firstActiveUplinkBWP_Id);
11994 /*******************************************************************
11996 * @brief fill long cycle offset value of drx in UE structure
12000 * Function : fillLongCycleOffsetValueInUeDb
12002 * Functionality: fill long cycle offset value of drx in UE structure
12004 * @params[in] DrxLongCycleStartOffset drxLongCycleStartOffset,
12005 * struct DRX_ConfigRrc__drx_LongCycleStartOffset drx_LongCycleStartOffset
12007 * @return ROK - success
12008 * RFAILED - failure
12010 * ****************************************************************/
12011 void fillLongCycleOffsetValueInUeDb(DrxLongCycleStartOffset *drxLongCycleStartOffset, struct DRX_ConfigRrc__drx_LongCycleStartOffset *drx_LongCycleStartOffset)
12014 drxLongCycleStartOffset->drxLongCycleStartOffsetChoice = convertLongDrxCycleLengthEnumToValue(drx_LongCycleStartOffset->present);
12015 switch(drx_LongCycleStartOffset->present)
12017 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms10:
12019 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms10;
12022 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms20:
12024 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms20;
12027 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms32:
12029 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms32;
12032 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms40:
12034 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms40;
12037 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms60:
12039 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms60;
12042 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms64:
12044 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms64;
12047 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms70:
12049 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms70;
12052 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms80:
12054 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms80;
12057 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms128:
12059 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms128;
12062 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms160:
12064 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms160;
12067 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms256:
12069 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms256;
12072 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms320:
12074 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms320;
12077 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms512:
12079 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms512;
12082 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms640:
12084 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms640;
12087 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms1024:
12089 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms1024;
12092 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms1280:
12094 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms1280;
12097 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms2048:
12099 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms2048;
12102 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms2560:
12104 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms2560;
12107 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms5120:
12109 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms5120;
12112 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms10240:
12114 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms10240;
12122 /*******************************************************************
12124 * @brief Fills drx configuration structure with the help of drx_ConfigRrc
12125 *which recive from CU or storedDrxCfg which is already stored
12129 * Function : extractDrxConfiguration
12131 * Functionality: Fills Reconfig Cell group Info received by CU
12133 * @params[in] cuMacCellGrpDrxConfig = MAC_CellGroupConfig__drx_ConfigRrc information which
12134 * is send by CU, which we have stored in F1UeContextSetupDb
12135 * DrxCfg * drxCfg = Used to Store the information,
12136 * which needs to send in other layer, as well as this can be
12137 * the variable which stores the information in DuCb,
12138 * DrxCfg *storedDrxCfg = Null in case of sending the
12139 * information to other layer else it will have the drx information
12140 * stored in the copyOfmacUeCfg which we have stored in F1UeContextSetupDb.
12144 * ****************************************************************/
12145 void extractDrxConfiguration(struct MAC_CellGroupConfig__drx_ConfigRrc *cuMacCellGrpDrxConfig, DrxCfg * drxCfg, DrxCfg *storedDrxCfg)
12147 struct DRX_ConfigRrc *cuDrxConfig;
12151 memcpy(drxCfg, storedDrxCfg, sizeof(DrxCfg));
12155 if(cuMacCellGrpDrxConfig)
12157 switch(cuMacCellGrpDrxConfig->present)
12159 case MAC_CellGroupConfig__drx_ConfigRrc_PR_NOTHING:
12162 case MAC_CellGroupConfig__drx_ConfigRrc_PR_setup:
12164 cuDrxConfig = cuMacCellGrpDrxConfig->choice.setup;
12167 switch(cuDrxConfig->drx_onDurationTimer.present)
12169 case DRX_ConfigRrc__drx_onDurationTimer_PR_NOTHING:
12171 case DRX_ConfigRrc__drx_onDurationTimer_PR_milliSeconds:
12173 drxCfg->drxOnDurationTimer.onDurationTimerValInMs = true;
12174 drxCfg->drxOnDurationTimer.onDurationtimerValue.milliSeconds=convertOnDurationTimerMilliSecondsEnumToValue(cuDrxConfig->\
12175 drx_onDurationTimer.choice.milliSeconds);
12178 case DRX_ConfigRrc__drx_onDurationTimer_PR_subMilliSeconds:
12180 drxCfg->drxOnDurationTimer.onDurationTimerValInMs = false;
12181 drxCfg->drxOnDurationTimer.onDurationtimerValue.subMilliSeconds = cuDrxConfig->drx_onDurationTimer.choice.subMilliSeconds;
12186 fillLongCycleOffsetValueInUeDb(&drxCfg->drxLongCycleStartOffset, &cuDrxConfig->drx_LongCycleStartOffset);
12187 drxCfg->drxInactivityTimer = convertDrxInactivityTimerEnumToValue(cuDrxConfig->drx_InactivityTimer);
12188 drxCfg->drxHarqRttTimerDl = cuDrxConfig->drx_HARQ_RTT_TimerDL;
12189 drxCfg->drxHarqRttTimerUl = cuDrxConfig->drx_HARQ_RTT_TimerUL;
12190 drxCfg->drxRetransmissionTimerDl = convertDrxRetransmissionTimerDlEnumToValue(cuDrxConfig->drx_RetransmissionTimerDL);
12191 drxCfg->drxRetransmissionTimerUl = convertDrxRetransmissionTimerUlEnumToValue(cuDrxConfig->drx_RetransmissionTimerUL);
12192 drxCfg->drxSlotOffset = cuDrxConfig->drx_SlotOffset;
12193 if(cuDrxConfig->shortDRX)
12195 drxCfg->shortDrxPres=true;
12196 drxCfg->shortDrx.drxShortCycle = convertShortDrxCycleLengthEnumToValue(cuDrxConfig->shortDRX->drx_ShortCycle);
12197 drxCfg->shortDrx.drxShortCycleTimer = cuDrxConfig->shortDRX->drx_ShortCycleTimer;
12200 drxCfg->shortDrxPres=false;
12205 case MAC_CellGroupConfig__drx_ConfigRrc_PR_release:
12213 /*******************************************************************
12215 * @brief Fills Reconfig Cell group Info received by CU
12219 * Function : extractUeRecfgCellInfo
12221 * Functionality: Fills Reconfig Cell group Info received by CU
12223 * @params[in] CellGroupConfigRrc_t *cellGrp = CellGroupConfigRrc_t information which
12224 * is send by CU, which we have stored in F1UeContextSetupDb
12225 * DuMacUeCfg *MacUeCfg = Used to Store the information,
12226 * which needs to send in other layer, as well as this can be
12227 * the variable which stores the information in DuCb,
12228 * DuMacUeCfg *storedMacUeCfg = Null in case of sending the
12229 * information to other layer else it will have copyOfmacUeCfg
12230 * which we have stored in F1UeContextSetupDb.
12232 * @return ROK/RFAILED
12234 * ****************************************************************/
12235 uint8_t extractUeRecfgCellInfo(CellGroupConfigRrc_t *cellGrp, DuMacUeCfg *macUeCfg, DuMacUeCfg *storedMacUeCfg)
12238 MAC_CellGroupConfig_t *macCellGroup = NULLP;
12239 PhysicalCellGroupConfig_t *phyCellGrpCfg = NULLP;
12240 SpCellConfig_t *spcellCfg = NULLP;
12241 ServingCellConfig_t *servCellCfg = NULLP;
12245 /* Fill MacCell Group Reconfig */
12246 if(cellGrp->mac_CellGroupConfig)
12248 macUeCfg->macCellGrpCfgPres = true;
12249 macCellGroup = ((MAC_CellGroupConfig_t *)(cellGrp->mac_CellGroupConfig));
12252 if(macCellGroup->drx_ConfigRrc)
12256 if(!storedMacUeCfg->macCellGrpCfgPres)
12258 extractDrxConfiguration(macCellGroup->drx_ConfigRrc, &macUeCfg->macCellGrpCfg.drxCfg,NULL);
12262 extractDrxConfiguration(macCellGroup->drx_ConfigRrc, &macUeCfg->macCellGrpCfg.drxCfg, &storedMacUeCfg->macCellGrpCfg.drxCfg);
12267 extractDrxConfiguration(macCellGroup->drx_ConfigRrc, &macUeCfg->macCellGrpCfg.drxCfg,NULL);
12272 if(macCellGroup->schedulingRequestConfig)
12274 extractSchReqReConfig(macCellGroup->schedulingRequestConfig, &macUeCfg->macCellGrpCfg.schReqCfg);
12276 if(macCellGroup->tag_Config)
12278 extractTagReconfig(macCellGroup->tag_Config, &macUeCfg->macCellGrpCfg.tagCfg);
12280 if(macCellGroup->bsr_Config)
12282 macUeCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer = macCellGroup->bsr_Config->periodicBSR_Timer;
12283 macUeCfg->macCellGrpCfg.bsrTmrCfg.retxTimer = macCellGroup->bsr_Config->retxBSR_Timer;
12284 if(macCellGroup->bsr_Config->logicalChannelSR_DelayTimer)
12286 macUeCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer =\
12287 *(macCellGroup->bsr_Config->logicalChannelSR_DelayTimer);
12290 if(macCellGroup->phr_Config)
12292 if(macCellGroup->phr_Config->present == MAC_CellGroupConfig__phr_Config_PR_setup)
12294 macUeCfg->macCellGrpCfg.phrCfgSetupPres = true;
12295 if(macCellGroup->phr_Config->choice.setup)
12297 macUeCfg->macCellGrpCfg.phrCfg.periodicTimer = \
12298 macCellGroup->phr_Config->choice.setup->phr_PeriodicTimer;
12299 macUeCfg->macCellGrpCfg.phrCfg.prohibitTimer = \
12300 macCellGroup->phr_Config->choice.setup->phr_ProhibitTimer;
12301 macUeCfg->macCellGrpCfg.phrCfg.txPowerFactor = \
12302 macCellGroup->phr_Config->choice.setup->phr_Tx_PowerFactorChange;
12303 macUeCfg->macCellGrpCfg.phrCfg.multiplePHR = \
12304 macCellGroup->phr_Config->choice.setup->multiplePHR;
12305 macUeCfg->macCellGrpCfg.phrCfg.dummy = \
12306 macCellGroup->phr_Config->choice.setup->dummy;
12307 macUeCfg->macCellGrpCfg.phrCfg.phrType2OtherCell = \
12308 macCellGroup->phr_Config->choice.setup->phr_Type2OtherCell;
12309 macUeCfg->macCellGrpCfg.phrCfg.phrOtherCG = \
12310 macCellGroup->phr_Config->choice.setup->phr_ModeOtherCG;
12315 /* Fill Physical Cell Group Reconfig */
12316 if(cellGrp->physicalCellGroupConfig)
12318 macUeCfg->phyCellGrpCfgPres = true;
12319 phyCellGrpCfg = ((PhysicalCellGroupConfig_t *)(cellGrp->physicalCellGroupConfig));
12320 if(phyCellGrpCfg->p_NR_FR1)
12322 if(*(phyCellGrpCfg->p_NR_FR1) != macUeCfg->phyCellGrpCfg.pNrFr1)
12323 macUeCfg->phyCellGrpCfg.pNrFr1 = *(phyCellGrpCfg->p_NR_FR1);
12325 macUeCfg->phyCellGrpCfg.pdschHarqAckCodebook = phyCellGrpCfg->pdsch_HARQ_ACK_Codebook;
12327 /* Fill SpCell Reconfig */
12328 if(cellGrp->spCellConfig)
12330 macUeCfg->spCellCfgPres = true;
12331 spcellCfg = ((SpCellConfig_t *)(cellGrp->spCellConfig));
12332 if(spcellCfg->servCellIndex)
12334 macUeCfg->spCellCfg.servCellIdx = *(spcellCfg->servCellIndex);
12336 /* Fill Serving cell Reconfig info */
12337 if(cellGrp->spCellConfig->spCellConfigDedicated)
12339 servCellCfg = ((ServingCellConfig_t *)(cellGrp->spCellConfig->spCellConfigDedicated));
12342 if(!storedMacUeCfg->spCellCfgPres)
12343 ret = extractSpCellDedicatedCfg(servCellCfg, &macUeCfg->spCellCfg.servCellCfg, NULL);
12345 ret = extractSpCellDedicatedCfg(servCellCfg, &macUeCfg->spCellCfg.servCellCfg,\
12346 &storedMacUeCfg->spCellCfg.servCellCfg);
12350 ret = extractSpCellDedicatedCfg(servCellCfg, &macUeCfg->spCellCfg.servCellCfg, NULL);
12354 DU_LOG("\nERROR --> F1AP : Failed at extractSpCellDedicatedCfg()");
12361 /*******************************************************************
12363 * @brief free the memory allocated by decoder
12367 * Function : freeAperDecodeNrcgi
12369 * Functionality: Free Nrcgi values
12371 * @params[in] NRCGI_t *nrcgi
12374 * ****************************************************************/
12377 void freeAperDecodeNrcgi(NRCGI_t *nrcgi)
12379 if(nrcgi->pLMN_Identity.buf != NULLP)
12381 free(nrcgi->pLMN_Identity.buf);
12383 if(nrcgi->nRCellIdentity.buf != NULLP)
12385 free(nrcgi->nRCellIdentity.buf);
12388 /*******************************************************************
12390 * @brief free the memory allocated by decoder
12394 * Function : freeAperDecodeCuToDuInfo
12396 * Functionality: Free Cu To Du Information
12398 * @params[in] CUtoDURRCInformation_t *rrcMsg
12401 * ****************************************************************/
12404 void freeAperDecodeCuToDuInfo(CUtoDURRCInformation_t *rrcMsg)
12409 if(rrcMsg->uE_CapabilityRAT_ContainerList)
12411 if(rrcMsg->uE_CapabilityRAT_ContainerList->buf)
12412 free(rrcMsg->uE_CapabilityRAT_ContainerList->buf);
12413 free(rrcMsg->uE_CapabilityRAT_ContainerList);
12416 if(rrcMsg->iE_Extensions)
12418 if(rrcMsg->iE_Extensions->list.array)
12420 for(ieIdx= 0; ieIdx < rrcMsg->iE_Extensions->list.count; ieIdx++)
12422 if(rrcMsg->iE_Extensions->list.array[ieIdx])
12424 switch(rrcMsg->iE_Extensions->list.array[ieIdx]->id)
12426 case ProtocolIE_ID_id_CellGroupConfig:
12427 if(rrcMsg->iE_Extensions->list.array[ieIdx]->extensionValue.choice.CellGroupConfig.buf != NULLP)
12429 free(rrcMsg->iE_Extensions->list.array[ieIdx]->extensionValue.choice.CellGroupConfig.buf);
12433 DU_LOG("\nERROR --> F1AP : Invalid Event type %ld at FreeCuToDuInfo()", \
12434 rrcMsg->iE_Extensions->list.array[ieIdx]->id);
12439 for(arrIdx = 0; arrIdx < ieIdx; arrIdx++)
12441 free(rrcMsg->iE_Extensions->list.array[arrIdx]);
12443 free(rrcMsg->iE_Extensions->list.array);
12447 free(rrcMsg->iE_Extensions);
12450 /*******************************************************************
12452 * @brief free the memory allocated by decoder
12456 * Function : freeAperDecodeSplCellList
12458 * Functionality: Free Spl Cell List
12459 where memory allocated by aper_decoder
12461 * @params[in] SCell_ToBeSetup_List_t *spCellLst
12464 * ****************************************************************/
12467 void freeAperDecodeSplCellList(SCell_ToBeSetup_List_t *spCellLst)
12469 uint8_t cellIdx =0;
12471 if(spCellLst->list.array != NULLP)
12473 for(cellIdx=0; cellIdx<spCellLst->list.count; cellIdx++)
12475 if(cellIdx==0&&spCellLst->list.array[cellIdx]!=NULLP)
12477 freeAperDecodeNrcgi(&spCellLst->list.array[cellIdx]->value.choice.SCell_ToBeSetup_Item.sCell_ID);
12479 if(spCellLst->list.array[cellIdx]!=NULLP)
12481 free(spCellLst->list.array[cellIdx]);
12484 free(spCellLst->list.array);
12487 /*******************************************************************
12489 * @brief free the memory allocated by decoder
12493 * Function : freeAperDecodeSRBSetup
12495 * Functionality: added free part for the memory allocated by aper_decoder
12497 * @params[in] SRBs_ToBeSetup_List_t *srbSet
12500 ****************************************************************/
12503 void freeAperDecodeSRBSetup(SRBs_ToBeSetup_List_t *srbSet)
12506 if(srbSet->list.array != NULLP)
12508 for(srbIdx=0; srbIdx<srbSet->list.count; srbIdx++)
12510 if(srbSet->list.array[srbIdx]!=NULLP)
12512 free(srbSet->list.array[srbIdx]);
12515 free(srbSet->list.array);
12519 /*******************************************************************
12521 * @brief free the memory allocated by decoder
12525 * Function : freeAperDecodeULTnlInfo
12527 * Functionality: added free part for the memory allocated by aper_decoder
12529 * @params[in] ULUPTNLInformation_ToBeSetup_List_t *ulInfo
12532 * ****************************************************************/
12535 void freeAperDecodeULTnlInfo(ULUPTNLInformation_ToBeSetup_List_t *ulInfo)
12538 if(ulInfo->list.array != NULLP)
12540 for(ulIdx=0; ulIdx<ulInfo->list.count; ulIdx++)
12542 if(ulIdx==0&&ulInfo->list.array[ulIdx]!=NULLP)
12544 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel!=NULLP)
12546 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->\
12547 transportLayerAddress.buf != NULLP)
12549 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf\
12552 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf);
12554 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->\
12555 transportLayerAddress.buf);
12557 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel);
12560 if(ulInfo->list.array[ulIdx]!=NULLP)
12562 free(ulInfo->list.array[ulIdx]);
12565 free(ulInfo->list.array);
12568 /*******************************************************************
12570 * @brief free the memory allocated by decoder
12574 * Function : freeAperDecodeDRBSetup
12576 * Functionality: free DRBSetup which is allocated by decoder
12578 * @params[in] DRBs_ToBeSetup_List_t *drbSet
12581 * ****************************************************************/
12583 void freeAperDecodeDRBSetup(DRBs_ToBeSetup_List_t *drbSet)
12585 DRBs_ToBeSetup_Item_t *drbSetItem = NULLP;
12586 uint8_t flowIdx =0;
12589 if(drbSet->list.array != NULLP)
12591 for(drbIdx=0; drbIdx<drbSet->list.count; drbIdx++)
12593 if(drbIdx==0&&drbSet->list.array[drbIdx] != NULLP)
12595 drbSetItem =&drbSet->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item;
12596 if(drbSetItem->qoSInformation.choice.choice_extension != NULLP)
12598 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
12599 qoS_Characteristics.choice.non_Dynamic_5QI !=NULLP)
12601 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
12602 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
12604 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
12605 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
12608 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sST.buf!=NULLP)
12611 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD!=NULLP)
12614 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD->\
12618 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.\
12619 flows_Mapped_To_DRB_List.list.array != NULLP)
12622 for(flowIdx=0;flowIdx<drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
12623 DRB_Information.flows_Mapped_To_DRB_List.list.count; flowIdx++)
12626 if(flowIdx==0&&drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
12627 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]!=NULLP)
12629 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
12630 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
12631 qoSFlowLevelQoSParameters.\
12632 qoS_Characteristics.choice.non_Dynamic_5QI!=NULLP)
12634 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
12635 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
12636 qoSFlowLevelQoSParameters.\
12637 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
12640 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
12641 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
12642 qoSFlowLevelQoSParameters.\
12643 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
12647 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
12648 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
12649 qoSFlowLevelQoSParameters.\
12650 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
12653 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
12654 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
12655 qoSFlowLevelQoSParameters.\
12656 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
12659 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
12661 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
12662 qoSFlowLevelQoSParameters.\
12663 qoS_Characteristics.choice.non_Dynamic_5QI);
12666 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
12667 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]!=NULLP)
12670 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
12671 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]);
12675 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
12676 DRB_Information.flows_Mapped_To_DRB_List.list.array);
12679 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
12680 DRB_Information.sNSSAI.sD->buf);
12683 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD);
12686 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sST.buf);
12690 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
12692 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
12695 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
12696 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
12699 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
12700 qoS_Characteristics.choice.non_Dynamic_5QI);
12702 free(drbSetItem->qoSInformation.choice.choice_extension);
12704 freeAperDecodeULTnlInfo(&drbSetItem->uLUPTNLInformation_ToBeSetup_List);
12705 if(drbSetItem->uLConfiguration)
12707 free(drbSetItem->uLConfiguration);
12710 if(drbSet->list.array[drbIdx]!=NULLP)
12712 free(drbSet->list.array[drbIdx]);
12715 free(drbSet->list.array);
12720 /*******************************************************************
12722 * @brief builds Mac Cell Cfg
12726 * Function : procUeRecfgCellInfo
12728 * Functionality: builds Mac Cell Cfg
12730 * @params[in] DuMacUeCfg *macUeCfgToSend = Used to Store the information which
12731 * needs to send in other layer, as well as this can be
12732 * the variable which stores the information in DuCb.
12733 * DuMacUeCfg *storedMacUeCfg = Null in case of sending the
12734 * information to other layer else it will have copyOfmacUeCfg
12735 * which we have stored in F1UeContextSetupDb
12736 * void *cellInfo = CellGroupConfigRrc_t information which is send
12737 * by CU, which we have stored in F1UeContextSetupDb
12741 * ****************************************************************/
12742 uint8_t procUeRecfgCellInfo(DuMacUeCfg *macUeCfgToSend, DuMacUeCfg *storedMacUeCfg, void *cellInfo)
12745 CellGroupConfigRrc_t *cellGrp = NULLP;
12749 cellGrp = (CellGroupConfigRrc_t *)cellInfo;
12750 ret = extractUeRecfgCellInfo(cellGrp, macUeCfgToSend, storedMacUeCfg);
12752 DU_LOG("\nERROR --> F1AP : Failed at procUeRecfgCellInfo()");
12756 freeUeRecfgCellGrpInfo(macUeCfgToSend);
12761 /*******************************************************************
12763 * @brief Filling modulation info in mac ue cfg
12767 * Function : duFillModulationDetails
12769 * Functionality: Filling modulation info in mac ue cfg
12771 * @params[in] MAC UE Config to be updated
12772 * Current UE configuration
12773 * UE NR capability from CU
12774 * @return ROK - success
12775 * RFAILED - failure
12777 * ****************************************************************/
12778 void duFillModulationDetails(DuMacUeCfg *ueCfg, DuMacUeCfg *oldUeCfg, void *ueCap)
12780 UE_NR_Capability_t *ueNrCap=NULLP;
12782 if(!ueCap && oldUeCfg)
12784 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
12785 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
12789 ueNrCap = (UE_NR_Capability_t *)ueCap;
12791 /* Filling DL modulation info */
12792 if(ueNrCap->featureSets && ueNrCap->featureSets->featureSetsDownlinkPerCC && \
12793 ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0] && \
12794 ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0]->supportedModulationOrderDL)
12796 switch(*(ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0]->supportedModulationOrderDL))
12798 case ModulationOrder_qpsk:
12800 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
12803 case ModulationOrder_qam16:
12805 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM16;
12808 case ModulationOrder_qam64:
12810 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM64;
12811 ueCfg->dlModInfo.mcsIndex = PDSCH_MCS_INDEX;
12812 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64;
12815 case ModulationOrder_qam256:
12817 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM256;
12822 DU_LOG("\nERROR --> DU APP: Incorrect downlink modulation order received. Reatining old modulation configuration");
12824 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
12832 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
12835 /* Filling UL modulation info */
12836 if(ueNrCap->featureSets && ueNrCap->featureSets->featureSetsUplinkPerCC && \
12837 ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0] && \
12838 ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0]->supportedModulationOrderUL)
12840 switch(*(ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0]->supportedModulationOrderUL))
12842 case ModulationOrder_qpsk:
12844 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
12847 case ModulationOrder_qam16:
12849 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM16;
12850 ueCfg->ulModInfo.mcsIndex = PUSCH_MCS_INDEX;
12851 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64;
12854 case ModulationOrder_qam64:
12856 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM64;
12859 case ModulationOrder_qam256:
12861 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM256;
12866 DU_LOG("\nERROR --> DU APP: Incorrect uplink modulation order received. Reatining old modulation configuration");
12868 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
12876 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
12881 /*******************************************************************
12883 * @brief Function to extract info from CU to DU RRC container extension
12887 * Function : extractCuToDuRrcInfoExt
12889 * Functionality: Function to extract info from CU to DU RRC container
12892 * @params[in] ProtocolExtensionContainer_4624P16_t pointer
12897 * ****************************************************************/
12898 uint8_t extractCuToDuRrcInfoExt(ProtocolExtensionContainer_4624P16_t *protocolIeExtn, DuUeCfg *ueCfgDb)
12901 uint16_t recvBufLen =0;
12902 CellGroupConfigRrc_t *cellGrpCfg = NULLP;
12903 CUtoDURRCInformation_ExtIEs_t *extIeInfo = NULLP;
12904 asn_dec_rval_t rval; /* Decoder return value */
12905 memset(&rval, 0, sizeof(asn_dec_rval_t));
12909 for(ieIdx = 0; ieIdx < protocolIeExtn->list.count; ieIdx++)
12911 extIeInfo = ((CUtoDURRCInformation_ExtIEs_t *)(protocolIeExtn->list.array[ieIdx]));
12912 switch(extIeInfo->id)
12914 case ProtocolIE_ID_id_CellGroupConfig:
12916 /* decoding the CellGroup Buf received */
12917 recvBufLen = extIeInfo->extensionValue.choice.CellGroupConfig.size;
12918 DU_ALLOC(cellGrpCfg, sizeof(CellGroupConfigRrc_t));
12921 memset(cellGrpCfg, 0, sizeof(CellGroupConfigRrc_t));
12922 rval = uper_decode(0, &asn_DEF_CellGroupConfigRrc, (void **)&cellGrpCfg,
12923 extIeInfo->extensionValue.choice.CellGroupConfig.buf, recvBufLen, 0, 0);
12924 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
12926 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
12929 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, cellGrpCfg);
12931 if(extractRlcCfgToAddMod(cellGrpCfg->rlc_BearerToAddModList, ueCfgDb))
12933 ueCfgDb->cellGrpCfg = cellGrpCfg;
12938 case ProtocolIE_ID_id_HandoverPreparationInformation:
12940 DU_LOG("\nINFO --> F1AP : Received HANDOVER PREPARATION INFO in UE CONTEXT SETUP REQUEST");
12945 DU_LOG("\nERROR --> F1AP : Invalid IE received CUtoDURRCInformation: %ld at decodeCellGrpCfg()", extIeInfo->id);
12953 /*******************************************************************
12955 * @brief Fills Srb List received by CU
12959 * Function : procSrbListToSetup
12961 * Functionality: Fills Srb List received by CU
12963 * @params[in] SRBs_ToBeSetup_Item_t *cuSrbItem
12965 * RlcBearerCfg pointer
12968 * ****************************************************************/
12969 uint8_t procSrbListToSetup(SRBs_ToBeSetup_Item_t * srbItem, DuLcCfg *duMacLcToAdd, DuRlcBearerCfg *rlcLcToAdd)
12972 /* Filling RLC INFO */
12973 procRlcLcCfg(srbItem->sRBID, srbItem->sRBID, RB_TYPE_SRB, RLC_AM, CONFIG_ADD, NULL, rlcLcToAdd, NULL);
12975 /* Filling MAC INFO */
12976 if(procMacLcCfg(srbItem->sRBID, RB_TYPE_SRB, CONFIG_ADD, NULL,NULL, NULL, NULL, duMacLcToAdd, NULL) != ROK)
12978 DU_LOG("\nERROR --> F1AP : Failed at MAC LC Cfg in procSrbListToSetup()");
12987 /*******************************************************************
12989 * @brief extract Srb List received by CU
12993 * Function : extractSrbListToSetup
12995 * Functionality: extract Srb List received by CU
12996 * for both MAC and RLC
12998 * @params[in] SRBs_ToBeSetup_Item_t pointer
13000 * @return ROK/RFAIED
13002 * ****************************************************************/
13004 uint8_t extractSrbListToSetup(SRBs_ToBeSetup_List_t *srbCfg, DuUeCfg *ueCfgDb)
13006 uint8_t ret = ROK, srbIdx = 0, rlcLcIdx = 0;
13007 SRBs_ToBeSetup_Item_t *srbItem = NULLP;
13008 DuLcCfg *macLcCtxt = NULLP;
13009 DuRlcBearerCfg *rlcLcCtxt = NULLP;
13013 for(srbIdx = 0; srbIdx < srbCfg->list.count; srbIdx++)
13018 srbItem = &srbCfg->list.array[srbIdx]->value.choice.SRBs_ToBeSetup_Item;
13019 if(ueCfgDb->numMacLcs > MAX_NUM_LC)
13021 DU_LOG("\nERROR --> F1AP: MAX LC Reached in MAC");
13025 if(ueCfgDb->numRlcLcs > MAX_NUM_LC)
13027 DU_LOG("\nERROR --> F1AP: MAX LC Reached in RLC");
13032 for(rlcLcIdx = 0; rlcLcIdx < ueCfgDb->numMacLcs; rlcLcIdx++)
13034 if(ueCfgDb->rlcLcCfg[rlcLcIdx].rlcBearerCfg.rbId == srbItem->sRBID && ueCfgDb->rlcLcCfg[rlcLcIdx].rlcBearerCfg.rbType == RB_TYPE_SRB)
13036 macLcCtxt = &ueCfgDb->macLcCfg[rlcLcIdx];
13037 rlcLcCtxt = &ueCfgDb->rlcLcCfg[rlcLcIdx];
13043 memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(DuLcCfg));
13044 macLcCtxt = &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs];
13045 ueCfgDb->numMacLcs++;
13049 memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(DuRlcBearerCfg));
13050 rlcLcCtxt = &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs];
13051 ueCfgDb->numRlcLcs++;
13054 ret = procSrbListToSetup(srbItem, macLcCtxt, rlcLcCtxt);
13056 DU_LOG("\nDEBUG --> DUAPP: extractSrbListToSetup: SRBID: %ld [RLC,MAC,NumDrb]:[%x,%x,%x]",\
13057 srbItem->sRBID, ueCfgDb->numRlcLcs, ueCfgDb->numMacLcs, ueCfgDb->numDrb);
13060 DU_LOG("\nERROR --> F1AP: Failed at extractSrbListToSetup()");
13071 /*******************************************************************
13073 * @brief Fills Drb List received by CU
13077 * Function : procDrbListToSetupMod
13079 * Functionality: Fills Drb List received by CU
13080 * for both MAC and RLC
13082 * @params[in] DRBs_ToBeSetup_Item_t , DRBs_ToBeSetupMod_Item_t,
13083 * DRBs_ToBeModified_Item_t , lcId, DuLcCfg pointer,
13084 * RlcBearerCfg , UpTnlCfg, RlcUeCfg
13087 * ****************************************************************/
13089 uint8_t procDrbListToSetupMod(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbItem,\
13090 DRBs_ToBeSetupMod_Item_t *drbSetupModItem, DRBs_ToBeModified_Item_t *drbModItem, DuLcCfg *macLcToAdd, DuRlcBearerCfg *rlcLcToAdd, UpTnlCfg *upTnlInfo, DuRlcUeCfg *storedRlcUeCfg)
13092 uint8_t cfgIdx = 0;
13093 RlcMode rlcModeInfo;
13095 if(drbItem != NULLP)
13097 /* Filling RLC INFO */
13098 procRlcLcCfg(drbItem->dRBID, lcId, RB_TYPE_DRB, drbItem->rLCMode, CONFIG_ADD, NULL, rlcLcToAdd, &drbItem->\
13101 /* Filling MAC INFO */
13102 if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_ADD, drbItem, NULL, NULL, NULL, macLcToAdd, upTnlInfo) != ROK)
13104 DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in procDrbListToSetupMod()");
13108 else if(drbSetupModItem != NULLP)
13110 procRlcLcCfg(drbSetupModItem->dRBID, lcId, RB_TYPE_DRB, drbSetupModItem->rLCMode, CONFIG_ADD, NULL, rlcLcToAdd,
13111 &drbSetupModItem->qoSInformation);
13113 if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_ADD, NULL, drbSetupModItem, NULL, NULL, macLcToAdd, upTnlInfo) != ROK)
13115 DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in procDrbListToSetupMod()");
13119 else if(drbModItem != NULLP)
13121 /* Drb to Mod IEs doesnot have rlcMode to be modified
13122 * in ASN. Hence no change in RLC configurations */
13123 if(storedRlcUeCfg != NULLP)
13125 for(cfgIdx = 0; cfgIdx < storedRlcUeCfg->numLcs; cfgIdx++)
13127 if(storedRlcUeCfg->rlcLcCfg[cfgIdx].rlcBearerCfg.lcId == lcId)
13129 rlcModeInfo = storedRlcUeCfg->rlcLcCfg[cfgIdx].rlcBearerCfg.rlcMode;
13135 procRlcLcCfg(drbModItem->dRBID, lcId, RB_TYPE_DRB, rlcModeInfo, CONFIG_MOD, NULL, rlcLcToAdd, drbModItem->qoSInformation);
13136 if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_MOD, NULL, NULL, drbModItem, NULL, macLcToAdd, upTnlInfo) != ROK)
13138 DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in procDrbListToSetupMod()");
13145 /*******************************************************************
13147 * @brief extract Drb List received by CU
13151 * Function : extractDrbListToSetupMod
13153 * Functionality: extract Drb List received by CU
13154 * for both MAC and RLC
13156 * @params[in] DRBs_ToBeSetup_Item_t pointer
13158 * @return ROK/RFAIED
13160 * ****************************************************************/
13162 uint8_t extractDrbListToSetupMod(DRBs_ToBeSetup_List_t *drbCfg, DRBs_ToBeSetupMod_List_t *drbSetupModCfg,\
13163 DRBs_ToBeModified_List_t *drbModCfg, uint8_t drbCount, DuUeCfg *ueCfgDb, uint32_t *drbBitMap, DuRlcUeCfg *rlcUeCfg)
13166 uint8_t drbIdx = 0, rlcLcIdx = 0;
13167 uint8_t drbId = 0, lcId = 0;
13168 DRBs_ToBeSetup_Item_t *drbItem = NULLP;
13169 DRBs_ToBeSetupMod_ItemIEs_t *drbSetupModItem = NULLP;
13170 DRBs_ToBeModified_ItemIEs_t *drbModItem = NULLP;
13171 DuLcCfg *macLcCtxt = NULLP;
13172 DuRlcBearerCfg *rlcLcCtxt = NULLP;
13177 for(drbIdx = 0; drbIdx < drbCount; drbIdx++)
13182 if(ueCfgDb->numMacLcs > MAX_NUM_LC)
13184 DU_LOG("\nERROR --> F1AP : MAX LC Reached in MAC at extractDrbListToSetupMod()");
13188 if(ueCfgDb->numRlcLcs > MAX_NUM_LC)
13190 DU_LOG("\nERROR --> F1AP : MAX LC Reached in RLC at extractDrbListToSetupMod()");
13195 if(drbModCfg != NULLP)
13197 drbModItem = (DRBs_ToBeModified_ItemIEs_t *) drbModCfg->list.array[drbIdx];
13198 drbId = drbModItem->value.choice.DRBs_ToBeModified_Item.dRBID;
13200 else if(drbCfg != NULLP)
13201 drbId = drbCfg->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item.dRBID;
13202 else if(drbSetupModCfg != NULL)
13204 drbSetupModItem = (DRBs_ToBeSetupMod_ItemIEs_t *) drbSetupModCfg->list.array[drbIdx];
13205 drbId = drbSetupModItem->value.choice.DRBs_ToBeSetupMod_Item.dRBID;
13208 for(rlcLcIdx = 0; rlcLcIdx < ueCfgDb->numRlcLcs; rlcLcIdx++)
13210 if(ueCfgDb->rlcLcCfg[rlcLcIdx].rlcBearerCfg.rbId == drbId && \
13211 ueCfgDb->rlcLcCfg[rlcLcIdx].rlcBearerCfg.rbType == RB_TYPE_DRB)
13213 macLcCtxt = &ueCfgDb->macLcCfg[rlcLcIdx];
13214 rlcLcCtxt = &ueCfgDb->rlcLcCfg[rlcLcIdx];
13220 memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(DuLcCfg));
13221 macLcCtxt = &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs];
13222 ueCfgDb->numMacLcs++;
13226 memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(RlcBearerCfg));
13227 rlcLcCtxt = &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs];
13228 ueCfgDb->numRlcLcs++;
13231 if(drbModCfg != NULLP)
13233 lcId = fetchLcId(drbId);
13234 if(lcId < MIN_DRB_LCID)
13236 DU_LOG("\nERROR --> F1AP : Failed fetching LCID %d in extractDrbListToSetupMod() for Modified List", lcId);
13239 ret = procDrbListToSetupMod(lcId, NULL, NULL, &(drbModItem->value.choice.DRBs_ToBeModified_Item),\
13240 macLcCtxt, rlcLcCtxt, &ueCfgDb->upTnlInfo[ueCfgDb->numDrb], rlcUeCfg);
13243 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetupMod() for Modified List");
13246 ueCfgDb->numDrbModified++;
13250 lcId = getDrbLcId(drbBitMap);
13251 if(lcId == RFAILED)
13253 DU_LOG("\nERROR --> F1AP : InCorrect LCID extractDrbListToSetupMod()");
13259 drbItem = &drbCfg->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item;
13260 ret = procDrbListToSetupMod(lcId, drbItem, NULL, NULL, macLcCtxt, rlcLcCtxt, &ueCfgDb->upTnlInfo[ueCfgDb->numDrb], rlcUeCfg);
13263 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetupMod() for DrbSetup List");
13267 else if(drbSetupModCfg != NULL)
13269 ret = procDrbListToSetupMod(lcId, NULL, &(drbSetupModItem->value.choice.DRBs_ToBeSetupMod_Item), NULL,\
13270 macLcCtxt, rlcLcCtxt, &ueCfgDb->upTnlInfo[ueCfgDb->numDrb], rlcUeCfg);
13273 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetupMod() for DrbSetupMod List");
13276 ueCfgDb->numDrbSetupMod++;
13281 DU_LOG("\nDEBUG --> DUAPP: extractDrbListToSetupMod:lcId:%x ,BitMap:%x, [RLC,MAC,NumDrb]:[%x,%x,%x]",\
13282 lcId,*drbBitMap, ueCfgDb->numRlcLcs, ueCfgDb->numMacLcs, ueCfgDb->numDrb);
13285 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetupMod()");
13296 /*******************************************************************
13298 * @brief extract Drb List received from CU
13302 * Function : extractDrbListToRelease
13304 * Functionality: extract Drb List received from CU
13305 * for both MAC and RLC
13307 * @params[in] DRBs_ToBeReleased_Item_t pointer
13309 * @return ROK/RFAIED
13311 * ****************************************************************/
13313 uint8_t extractDrbListToRelease(uint8_t ueId, DRBs_ToBeReleased_List_t *drbToRel, uint8_t drbCount, DuUeCfg *ueCfgDb, DuRlcUeCfg *rlcUeCfg)
13315 uint8_t ret = ROK, teIdx = 0;
13316 uint8_t drbIdx = 0, rlcLcIdx = 0;
13317 uint8_t drbId = 0, lcId = 0;
13318 DRBs_ToBeReleased_ItemIEs_t *drbRelItem = NULLP;
13319 DuLcCfg *macLcCtxt = NULLP;
13320 DuRlcBearerCfg *rlcLcCtxt = NULLP;
13325 for(drbIdx = 0; drbIdx < drbCount; drbIdx++)
13330 if(drbToRel != NULLP)
13332 drbRelItem = (DRBs_ToBeReleased_ItemIEs_t *) drbToRel->list.array[drbIdx];
13333 drbId = drbRelItem->value.choice.DRBs_ToBeReleased_Item.dRBID;
13337 DU_LOG("ERROR --> DU APP : DrbToRelease pointer is NULL in extractDrbListToRelease");
13341 for(rlcLcIdx = 0; rlcLcIdx < ueCfgDb->numRlcLcs; rlcLcIdx++)
13343 if(ueCfgDb->rlcLcCfg[rlcLcIdx].rlcBearerCfg.rbId == drbId && ueCfgDb->rlcLcCfg[rlcLcIdx].rlcBearerCfg.rbType == RB_TYPE_DRB)
13345 macLcCtxt = &ueCfgDb->macLcCfg[rlcLcIdx];
13346 rlcLcCtxt = &ueCfgDb->rlcLcCfg[rlcLcIdx];
13353 memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(DuLcCfg));
13354 macLcCtxt = &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs];
13355 ueCfgDb->numMacLcs++;
13359 memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(DuRlcBearerCfg));
13360 rlcLcCtxt = &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs];
13361 ueCfgDb->numRlcLcs++;
13363 lcId = fetchLcId(drbId);
13364 if(lcId < MIN_DRB_LCID)
13366 DU_LOG("\nERROR --> F1AP : Failed fetching LCID %d in extractDrbListToRelease() for Modified List", lcId);
13370 /* Filling RLC INFO */
13371 procRlcLcCfg(drbId, lcId, RB_TYPE_DRB, rlcLcCtxt->rlcBearerCfg.rlcMode, CONFIG_DEL, NULL, rlcLcCtxt, NULLP);
13372 /* Filling MAC INFO */
13373 if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_DEL, NULL, NULL, NULL, NULL, macLcCtxt, NULLP) != ROK)
13375 DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in extractDrbListToRelease()");
13378 ueCfgDb->upTnlInfo[ueCfgDb->numDrb].configType = CONFIG_DEL;
13379 ueCfgDb->upTnlInfo[ueCfgDb->numDrb].drbId = drbId;
13380 ueCfgDb->upTnlInfo[ueCfgDb->numDrb].ueId = ueId;
13382 for(teIdx = 0; teIdx < duCb.numTeId; teIdx++)
13384 if((duCb.upTnlCfg[teIdx]->ueId == ueCfgDb->upTnlInfo[ueCfgDb->numDrb].ueId) && \
13385 (duCb.upTnlCfg[teIdx]->drbId == ueCfgDb->upTnlInfo[ueCfgDb->numDrb].drbId))
13387 DU_ALLOC(ueCfgDb->upTnlInfo[ueCfgDb->numDrb].tnlCfg1, sizeof(GtpTnlCfg));
13388 memcpy(ueCfgDb->upTnlInfo[ueCfgDb->numDrb].tnlCfg1, duCb.upTnlCfg[teIdx]->tnlCfg1, sizeof(GtpTnlCfg));
13396 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToRelease() for Modified List");
13400 DU_LOG("\nDEBUG --> DUAPP: extractDrbListToRelease():lcId:%x, [RLC,MAC,NumDrb]:[%x,%x,%x]",\
13401 lcId,ueCfgDb->numRlcLcs, ueCfgDb->numMacLcs, ueCfgDb->numDrb);
13410 /*******************************************************************
13412 * @brief Function to extract Dl RRC Msg received from CU
13416 * Function : extractDlRrcMsg
13418 * Functionality: Function to extract Dl RRC Msg received from CU
13420 * @params[in] F1AP message
13421 * @return ROK - success
13422 * RFAILED - failure
13424 * ****************************************************************/
13426 uint8_t extractDlRrcMsg(uint32_t gnbDuUeF1apId, uint32_t gnbCuUeF1apId, \
13427 F1DlRrcMsg *dlRrcMsg, RRCContainer_t *rrcContainer)
13430 dlRrcMsg->rrcMsgSize = rrcContainer->size;
13431 if(dlRrcMsg->rrcMsgSize > 0)
13433 DU_ALLOC_SHRABL_BUF(dlRrcMsg->rrcMsgPdu, dlRrcMsg->rrcMsgSize);
13434 if(!dlRrcMsg->rrcMsgPdu)
13436 DU_LOG("\nERROR --> DU APP : Memory allocation failed for RRC Msg in extractDlRrcMsg()");
13441 dlRrcMsg->gnbDuUeF1apId = gnbDuUeF1apId;
13442 dlRrcMsg->gnbCuUeF1apId = gnbCuUeF1apId;
13443 dlRrcMsg->srbId = SRB1_LCID;
13444 memcpy(dlRrcMsg->rrcMsgPdu, rrcContainer->buf, dlRrcMsg->rrcMsgSize);
13450 /*******************************************************************
13452 * @brief Extract UE capability info
13456 * Function : extractUeCapability
13458 * Functionality: Extract UE capability info and stores in ue Cb
13460 * @params[in] Octet string of UE capability RAT container list
13461 * @return ROK - success
13462 * RFAILED - failure
13464 * ****************************************************************/
13465 UE_NR_Capability_t *extractUeCapability(UE_CapabilityRAT_ContainerList_t *ueCapablityListBuf, DuUeCb *ueCb)
13468 uint16_t recvBufLen;
13469 asn_dec_rval_t rval;
13470 UE_NR_Capability_t *ueNrCap = NULLP;
13471 UE_CapabilityRAT_ContainerListRRC_t *ueCapRatContList = NULLP;
13473 /* Decoding UE Capability RAT Container List */
13474 recvBufLen = ueCapablityListBuf->size;
13475 DU_ALLOC(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
13476 if(!ueCapRatContList)
13478 DU_LOG("\nERROR --> F1AP : Memory allocation failed in extractUeCapability");
13481 memset(ueCapRatContList, 0, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
13482 memset(&rval, 0, sizeof(asn_dec_rval_t));
13483 rval = uper_decode(0, &asn_DEF_UE_CapabilityRAT_ContainerListRRC, (void **)&ueCapRatContList,
13484 ueCapablityListBuf->buf, recvBufLen, 0, 0);
13485 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
13487 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
13490 xer_fprint(stdout, &asn_DEF_UE_CapabilityRAT_ContainerListRRC, ueCapRatContList);
13492 /* Free encoded buffer after decoding */
13494 for(idx = 0; idx < ueCapRatContList->list.count; idx++)
13496 if(ueCapRatContList->list.array[idx]->rat_Type == RAT_Type_nr)
13498 /* Decoding UE NR Capability */
13499 recvBufLen = ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.size;
13500 DU_ALLOC(ueNrCap, sizeof(UE_NR_Capability_t));
13503 DU_LOG("\nERROR --> F1AP : Memory allocation failed in extractUeCapability");
13504 DU_FREE(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
13507 memset(ueNrCap, 0, sizeof(UE_NR_Capability_t));
13508 memset(&rval, 0, sizeof(asn_dec_rval_t));
13509 rval = uper_decode(0, &asn_DEF_UE_NR_Capability, (void **)&ueNrCap,
13510 ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.buf, recvBufLen, 0, 0);
13511 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
13513 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
13516 xer_fprint(stdout, &asn_DEF_UE_NR_Capability, ueNrCap);
13518 /* Free encoded buffer after decoding */
13519 free(ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.buf);
13521 free(ueCapRatContList->list.array[idx]);
13525 free(ueCapRatContList->list.array);
13526 DU_FREE(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
13530 /*******************************************************************
13532 * @brief free UE context setup request from CU
13536 * Function : freeAperDecodeF1UeContextSetupReq
13538 * Functionality: freeing part for the memory allocated by aper_decoder
13540 * @params[in] F1AP message
13541 * @return ROK - success
13542 * RFAILED - failure
13544 * ****************************************************************/
13545 void freeAperDecodeF1UeContextSetupReq(UEContextSetupRequest_t *ueSetReq)
13549 if(ueSetReq->protocolIEs.list.array != NULLP)
13551 for(ieIdx = 0; ieIdx < ueSetReq->protocolIEs.list.count; ieIdx++)
13553 if(ueSetReq->protocolIEs.list.array[ieIdx])
13555 switch(ueSetReq->protocolIEs.list.array[ieIdx]->id)
13557 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
13559 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
13561 case ProtocolIE_ID_id_SpCell_ID:
13562 freeAperDecodeNrcgi(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.NRCGI);
13564 case ProtocolIE_ID_id_ServCellIndex:
13566 case ProtocolIE_ID_id_SpCellULConfigured:
13568 case ProtocolIE_ID_id_CUtoDURRCInformation:
13570 freeAperDecodeCuToDuInfo(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation);
13572 case ProtocolIE_ID_id_SCell_ToBeSetup_List:
13574 freeAperDecodeSplCellList(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SCell_ToBeSetup_List);
13576 case ProtocolIE_ID_id_SRBs_ToBeSetup_List:
13578 freeAperDecodeSRBSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SRBs_ToBeSetup_List);
13580 case ProtocolIE_ID_id_DRBs_ToBeSetup_List:
13582 freeAperDecodeDRBSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRBs_ToBeSetup_List);
13584 case ProtocolIE_ID_id_RRCContainer:
13587 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf != NULLP)
13590 free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf);
13594 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
13596 case ProtocolIE_ID_id_GNB_DU_UE_AMBR_UL:
13598 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf)
13600 free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf);
13605 case ProtocolIE_ID_id_DRXCycle:
13607 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRXCycle.shortDRXCycleLength)
13608 free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRXCycle.shortDRXCycleLength);
13609 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRXCycle.shortDRXCycleTimer)
13610 free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRXCycle.shortDRXCycleTimer);
13615 DU_LOG("\nERROR --> F1AP: Invalid event type %ld " ,ueSetReq->protocolIEs.list.array[ieIdx]->id);
13617 free(ueSetReq->protocolIEs.list.array[ieIdx]);
13620 free(ueSetReq->protocolIEs.list.array);
13623 /*******************************************************************
13625 * @brief Process UE context setup request from CU
13629 * Function : procF1UeContextSetupReq
13631 * Functionality: Process UE context setup request from CU
13633 * @params[in] F1AP message
13634 * @return ROK - success
13635 * RFAILED - failure
13637 * ****************************************************************/
13638 uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg)
13641 uint8_t ret=0, ieIdx=0, ieExtIdx = 0;
13642 //uint8_t servCellIdx = 0;
13643 bool ueCbFound = false, hoInProgress = false;
13644 uint16_t cellIdx=0;
13645 uint64_t nrCellId = 0;
13646 uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId=0, bitRateSize=0;
13647 DuUeCb *duUeCb = NULL;
13648 UEContextSetupRequest_t *ueSetReq = NULL;
13649 DRBs_ToBeSetup_List_t *drbCfg = NULL;
13650 CUtoDURRCInformation_t *rrcInfo = NULL;
13652 DRXCycle_t *drxCycle;
13656 ueSetReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextSetupRequest;
13657 for(ieIdx=0; (ieIdx < ueSetReq->protocolIEs.list.count && ret == ROK); ieIdx++)
13659 switch(ueSetReq->protocolIEs.list.array[ieIdx]->id)
13661 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
13663 gnbCuUeF1apId = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID;
13667 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
13669 gnbDuUeF1apId = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID;
13673 case ProtocolIE_ID_id_SpCell_ID:
13675 bitStringToInt(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity, &nrCellId);
13677 GET_CELL_IDX(nrCellId, cellIdx);
13678 if(!duCb.actvCellLst[cellIdx])
13680 DU_LOG("\nERROR --> F1AP : Cell Id [%lu] not found", nrCellId);
13686 case ProtocolIE_ID_id_ServCellIndex:
13688 //servCellIdx = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.ServCellIndex;
13692 case ProtocolIE_ID_id_SpCellULConfigured:
13694 /* Indicates whether the gNB-CU requests the gNB-DU to configure the uplink as no UL,
13695 UL, SUL or UL+SUL for the indicated cell for the UE */
13699 case ProtocolIE_ID_id_CUtoDURRCInformation:
13701 rrcInfo = &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation;
13703 /* Search if UE context is present */
13704 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
13706 if(duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId)
13709 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
13714 /* Check if UE Handover scenario */
13715 if(rrcInfo->iE_Extensions)
13717 for(ieExtIdx = 0; ieExtIdx < rrcInfo->iE_Extensions->list.count; ieExtIdx++)
13719 if(rrcInfo->iE_Extensions->list.array[ieExtIdx]->id == ProtocolIE_ID_id_HandoverPreparationInformation)
13721 hoInProgress = true;
13727 /* If UE context is not present, but UE is in handover */
13728 if(!ueCbFound && hoInProgress)
13730 ueIdx = getFreeBitFromUeBitMap(nrCellId);
13732 gnbDuUeF1apId = ueIdx +1;
13735 DU_LOG("\nERROR --> F1AP : No free UE IDX found in UE bit map of cell Id [%lu]", nrCellId);
13739 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
13740 duUeCb->f1UeDb = NULL;
13741 duUeCb->gnbCuUeF1apId = gnbCuUeF1apId;
13742 duUeCb->gnbDuUeF1apId = gnbDuUeF1apId;
13743 GET_CRNTI(duUeCb->crnti, duUeCb->gnbDuUeF1apId);
13744 duUeCb->ueState = UE_HANDIN_IN_PROGRESS;
13749 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
13752 memset(duUeCb->f1UeDb, 0, sizeof(F1UeContextSetupDb));
13753 duUeCb->f1UeDb->actionType = UE_CTXT_SETUP;
13754 duUeCb->f1UeDb->cellIdx = cellIdx;
13758 DU_LOG("\nERROR --> F1AP: Memory Alloc Failed at procF1UeContextSetupReq()");
13765 DU_LOG("\nERROR --> F1AP: DuUeCb is not found at procF1UeContextSetupReq()");
13770 /* Extract UE capability info */
13771 if(rrcInfo->uE_CapabilityRAT_ContainerList)
13773 duUeCb->f1UeDb->duUeCfg.ueNrCapability = extractUeCapability(rrcInfo->uE_CapabilityRAT_ContainerList, duUeCb);
13776 /* Extract IE extension */
13777 if(rrcInfo->iE_Extensions)
13779 if(extractCuToDuRrcInfoExt(rrcInfo->iE_Extensions, &duUeCb->f1UeDb->duUeCfg) != ROK)
13781 DU_LOG("\nERROR --> F1AP: Failed to extract CU to DU RRC information extension IE");
13782 //TODO: Update the failure cause in ue context Setup Response
13790 case ProtocolIE_ID_id_DRXCycle:
13792 duUeCb->f1UeDb->duUeCfg.drxCyclePres = true;
13793 drxCycle = &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRXCycle;
13794 duUeCb->f1UeDb->duUeCfg.drxCycle.drxLongCycleLength = convertLongDrxCycleLengthEnumToValue(drxCycle->longDRXCycleLength);
13795 if(drxCycle->shortDRXCycleLength)
13797 duUeCb->f1UeDb->duUeCfg.drxCycle.shortDrxCyclePres = true;
13798 duUeCb->f1UeDb->duUeCfg.drxCycle.shortDrxCycle.drxShortCycle = \
13799 convertShortDrxCycleLengthEnumToValue(*(drxCycle->shortDRXCycleLength));
13801 if(drxCycle->shortDRXCycleTimer)
13802 duUeCb->f1UeDb->duUeCfg.drxCycle.shortDrxCycle.drxShortCycleTimer = *(drxCycle->shortDRXCycleTimer);
13808 case ProtocolIE_ID_id_SRBs_ToBeSetup_List:
13810 if(extractSrbListToSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SRBs_ToBeSetup_List,\
13811 &duUeCb->f1UeDb->duUeCfg))
13813 DU_LOG("\nERROR --> DU APP : Failed at extractSrbListToSetup()");
13814 //TODO: Update the failure cause in ue context Setup Response
13820 case ProtocolIE_ID_id_DRBs_ToBeSetup_List:
13822 drbCfg = &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRBs_ToBeSetup_List;
13824 if(extractDrbListToSetupMod(drbCfg, NULL, NULL, drbCfg->list.count, &duUeCb->f1UeDb->duUeCfg, &duUeCb->drbBitMap, NULLP))
13826 DU_LOG("\nERROR --> DU APP : Failed at extractDrbListToSetupMod()");
13827 //TODO: Update the failure cause in ue context Setup Response
13832 case ProtocolIE_ID_id_RRCContainer:
13834 /* Filling Dl RRC Msg Info */
13835 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
13836 if(!duUeCb->f1UeDb->dlRrcMsg)
13838 DU_LOG("\nERROR --> DU APP : Memory allocation failed for DL RRC Msg in procUeCtxtSetupReq()");
13843 duUeCb->f1UeDb->dlRrcMsgPres = true;
13844 memset(duUeCb->f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
13845 ret = extractDlRrcMsg(gnbDuUeF1apId, gnbCuUeF1apId, duUeCb->f1UeDb->dlRrcMsg,\
13846 &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer);
13851 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
13853 if(duUeCb->f1UeDb->dlRrcMsg)
13855 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
13857 duUeCb->f1UeDb->dlRrcMsg->deliveryStatRpt = true;
13861 DU_LOG("\nERROR --> Ignoring delivery report, since rrcContainer is not present");
13867 case ProtocolIE_ID_id_GNB_DU_UE_AMBR_UL:
13869 /* MaximumBitRate Uplink */
13870 bitRateSize = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.size;
13871 if(bitRateSize > 0)
13873 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->duUeCfg.ambrCfg, bitRateSize);
13874 if(!duUeCb->f1UeDb->duUeCfg.ambrCfg)
13876 DU_LOG("\nERROR --> DU APP : Memory allocation failed for bitRate in procUeCtxtSetupReq");
13881 memset(duUeCb->f1UeDb->duUeCfg.ambrCfg, 0, sizeof(AmbrCfg));
13882 memcpy(&duUeCb->f1UeDb->duUeCfg.ambrCfg->ulBr,
13883 ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf, bitRateSize);
13895 } /* End of switch */
13897 /* In case of any failure in any IE */
13900 // BuildAndSendUeContextSetupRsp(cellId,ueId);
13901 DU_LOG("\nERROR --> F1AP: Failed to process UE CNTXT SETUP REQ at procF1UeContextSetupReq()");
13904 } /* End of for loop of IEs */
13907 ret = duProcUeContextSetupRequest(duUeCb);
13909 freeAperDecodeF1UeContextSetupReq(ueSetReq);
13913 /*******************************************************************
13914 * @brief Free the memory allocated for Dl Tunnel Info
13918 * Function : freeDlTnlInfo
13921 * Free the memory allocated for Dl Tunnel Info
13923 * @params[in] DLUPTNLInformation_ToBeSetup_List_t *
13926 * ****************************************************************/
13928 void freeDlTnlInfo(DLUPTNLInformation_ToBeSetup_List_t *tnlInfo)
13930 uint8_t arrIdx = 0;
13934 for(arrIdx=0; arrIdx < tnlInfo->list.count; arrIdx++)
13936 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.buf,\
13937 tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.size);
13938 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf,\
13939 tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->gTP_TEID.size);
13940 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel, sizeof(GTPTunnel_t));
13941 DU_FREE(tnlInfo->list.array[arrIdx], sizeof(DLUPTNLInformation_ToBeSetup_Item_t));
13943 DU_FREE(tnlInfo->list.array, tnlInfo->list.size);
13947 /*******************************************************************
13948 * @brief Free the memory allocated for DRB setup List
13952 * Function : freeDrbSetupList
13955 * Free the memory allocated for DRB setup list
13957 * @params[in] DRBs_Setup_List_t *
13960 * ****************************************************************/
13961 void freeDrbSetupList(DRBs_Setup_List_t *drbSetupList)
13963 uint8_t arrIdx = 0;
13964 DRBs_Setup_ItemIEs_t *drbItemIe = NULLP;
13966 for(arrIdx = 0; arrIdx < drbSetupList->list.count; arrIdx++)
13968 drbItemIe = ((DRBs_Setup_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
13969 freeDlTnlInfo(&drbItemIe->value.choice.DRBs_Setup_Item.dLUPTNLInformation_ToBeSetup_List);
13970 DU_FREE(drbSetupList->list.array[arrIdx], sizeof(DRBs_Setup_Item_t));
13972 DU_FREE(drbSetupList->list.array, drbSetupList->list.size);
13975 /*******************************************************************
13976 * @brief Free the memory allocated for UE Setup response
13980 * Function : FreeUeContextSetupRsp
13983 * Free the memory allocated for UE Setup response
13985 * @params[in] F1AP PDU for UE setup response
13986 * @return ROK - success
13987 * RFAILED - failure
13989 * ****************************************************************/
13990 void FreeUeContextSetupRsp(F1AP_PDU_t *f1apMsg)
13993 UEContextSetupResponse_t *ueSetRsp = NULLP;
13997 if(f1apMsg->choice.successfulOutcome)
13999 ueSetRsp = &f1apMsg->choice.successfulOutcome->value.choice.\
14000 UEContextSetupResponse;
14001 if(ueSetRsp->protocolIEs.list.array)
14003 for(idx = 0; idx < ueSetRsp->protocolIEs.list.count; idx++)
14005 if(ueSetRsp->protocolIEs.list.array[idx])
14007 switch(ueSetRsp->protocolIEs.list.array[idx]->id)
14009 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
14011 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
14013 case ProtocolIE_ID_id_C_RNTI:
14015 case ProtocolIE_ID_id_DUtoCURRCInformation:
14017 CellGroupConfig_t *cellGrpCfg = NULLP;
14018 cellGrpCfg = &ueSetRsp->protocolIEs.list.array[idx]->value.choice.\
14019 DUtoCURRCInformation.cellGroupConfig;
14020 if(cellGrpCfg->buf != NULLP)
14022 DU_FREE(cellGrpCfg->buf, cellGrpCfg->size);
14023 cellGrpCfg = NULLP;
14027 case ProtocolIE_ID_id_DRBs_Setup_List:
14029 freeDrbSetupList(&ueSetRsp->protocolIEs.list.array[idx]->value.choice.DRBs_Setup_List);
14033 DU_LOG("\nERROR --> DUAPP: Invalid Id %ld at FreeUeContextSetupRsp()",\
14034 ueSetRsp->protocolIEs.list.array[idx]->id);
14037 DU_FREE(ueSetRsp->protocolIEs.list.array[idx],\
14038 sizeof(UEContextSetupResponseIEs_t));
14041 DU_FREE(ueSetRsp->protocolIEs.list.array, \
14042 ueSetRsp->protocolIEs.list.size);
14044 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
14046 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
14050 /*******************************************************************
14052 * @brief Builds Ue context Setup Rsp DU To CU Info
14056 * Function : EncodeUeCntxtDuToCuInfo
14058 * Functionality: Builds Ue context Setup Rsp DU To CU Info
14060 * @params[in] CellGroupConfig_t *, CellGroupConfigRrc_t *
14062 * @return ROK - success
14063 * RFAILED - failure
14065 ******************************************************************/
14067 uint8_t EncodeUeCntxtDuToCuInfo(CellGroupConfig_t *duToCuCellGrp, CellGroupConfigRrc_t *duCellGrpCfg)
14069 asn_enc_rval_t encRetVal;
14071 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, duCellGrpCfg);
14072 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
14074 encRetVal = uper_encode(&asn_DEF_CellGroupConfigRrc, 0, duCellGrpCfg, PrepFinalEncBuf, encBuf);
14075 /* Encode results */
14076 if(encRetVal.encoded == ENCODE_FAIL)
14078 DU_LOG( "\nERROR --> F1AP : Could not encode UeCntxtDuToCuInfo (at %s)\n",\
14079 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
14084 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UeCntxtDuToCuInfo\n");
14085 #ifdef DEBUG_ASN_PRINT
14086 for(int i=0; i< encBufSize; i++)
14088 printf("%x",encBuf[i]);
14092 duToCuCellGrp->size = encBufSize;
14093 DU_ALLOC(duToCuCellGrp->buf, duToCuCellGrp->size);
14094 if(!duToCuCellGrp->buf)
14096 DU_LOG("\nERROR --> F1AP : Memory allocation failed in UeCntxtDuToCuInfo");
14098 memcpy(duToCuCellGrp->buf, encBuf, duToCuCellGrp->size);
14102 /*******************************************************************
14104 * @brief Fills Dl Gtp tunnel Info
14108 * Function : fillGtpTunnelforDl
14110 * Functionality: Fills Dl Gtp tunnel Info
14114 * @return ROK - success
14115 * RFAILED - failure
14117 * ****************************************************************/
14119 uint8_t fillGtpTunnelforDl(GTPTunnel_t *gtpDl, GtpTnlCfg *gtpUeCfg)
14121 uint8_t bufSize = 0;
14123 gtpDl->transportLayerAddress.size = 4*sizeof(uint8_t);
14124 DU_ALLOC(gtpDl->transportLayerAddress.buf, gtpDl->transportLayerAddress.size);
14125 if(gtpDl->transportLayerAddress.buf == NULLP)
14129 memcpy(gtpDl->transportLayerAddress.buf, >pUeCfg->dlTnlAddress, gtpDl->transportLayerAddress.size);
14132 gtpDl->gTP_TEID.size = 4 * sizeof(uint8_t);
14133 DU_ALLOC(gtpDl->gTP_TEID.buf, gtpDl->gTP_TEID.size);
14134 if(gtpDl->gTP_TEID.buf == NULLP)
14138 bufSize = 3; /*forming an Octect String*/
14139 fillTeIdString(bufSize, gtpUeCfg->teId, gtpDl->gTP_TEID.buf);
14144 /*******************************************************************
14146 * @brief Fills DL Tunnel Setup List
14150 * Function : fillDlTnlSetupList
14152 * Functionality: Fills the DL Tunnel Setup List
14156 * @return ROK - success
14157 * RFAILED - failure
14159 * ****************************************************************/
14161 uint8_t fillDlTnlSetupList(DLUPTNLInformation_ToBeSetup_List_t *dlTnlInfo, UpTnlCfg *tnlCfg)
14163 uint8_t ret = ROK, arrIdx = 0, eleCount = 0;
14166 dlTnlInfo->list.count = eleCount;
14167 dlTnlInfo->list.size = (eleCount * sizeof(DLUPTNLInformation_ToBeSetup_Item_t *));
14169 /* Initialize the DL Tnl Setup List Members */
14170 DU_ALLOC(dlTnlInfo->list.array, dlTnlInfo->list.size);
14171 if(dlTnlInfo->list.array == NULLP)
14173 DU_LOG(" ERROR --> F1AP : Memory allocation for DL Tnl Setup List in fillDlTnlSetupList()");
14176 for(arrIdx=0; arrIdx < eleCount; arrIdx++)
14178 DU_ALLOC(dlTnlInfo->list.array[arrIdx], sizeof(DLUPTNLInformation_ToBeSetup_Item_t));
14179 if(dlTnlInfo->list.array[arrIdx] == NULLP)
14181 DU_LOG(" ERROR --> F1AP : Memory allocation for arrIdx [%d] failed in fillDlTnlSetupList()", arrIdx);
14184 dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.present = UPTransportLayerInformation_PR_gTPTunnel;
14185 DU_ALLOC(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel, sizeof(GTPTunnel_t));
14186 if(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel == NULLP)
14188 DU_LOG(" ERROR --> F1AP : Memory allocation for DL tunnel info in fillDlTnlSetupList()");
14191 ret = fillGtpTunnelforDl(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel,\
14199 /*******************************************************************
14201 * @brief Fills the Drb Setup List for Ue Context Setup Response
14205 * Function : fillDrbSetupList
14207 * Functionality: Fills the Drb Setup List for Ue Context Setup Response
14211 * @return ROK - success
14212 * RFAILED - failure
14214 * ****************************************************************/
14215 uint8_t fillDrbSetupList(DRBs_Setup_List_t *drbSetupList, DuUeCfg *ueCfg)
14217 uint8_t ret = ROK, arrIdx = 0, eleCount = 0;
14218 DRBs_Setup_ItemIEs_t *drbItemIe = NULLP;
14220 eleCount = ueCfg->numDrb;
14221 drbSetupList->list.count = eleCount;
14222 drbSetupList->list.size = \
14223 (eleCount * sizeof(DRBs_Setup_Item_t *));
14225 /* Initialize the Drb Setup List Members */
14226 DU_ALLOC(drbSetupList->list.array, drbSetupList->list.size);
14227 if(drbSetupList->list.array == NULLP)
14229 DU_LOG(" ERROR --> F1AP : Memory allocation for DRB Setup List in fillDrbSetupList()");
14233 for(arrIdx=0; arrIdx < eleCount; arrIdx++)
14235 DU_ALLOC(drbSetupList->list.array[arrIdx], sizeof(DRBs_Setup_Item_t));
14236 if(drbSetupList->list.array[arrIdx] == NULLP)
14238 DU_LOG(" ERROR --> F1AP : Memory allocation for arrIdx [%d] failed in fillDrbSetupList()", arrIdx);
14241 drbItemIe = ((DRBs_Setup_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
14242 drbItemIe->id = ProtocolIE_ID_id_DRBs_Setup_Item;
14243 drbItemIe->criticality = Criticality_reject;
14244 drbItemIe->value.present = DRBs_Setup_ItemIEs__value_PR_DRBs_Setup_Item;
14245 drbItemIe->value.choice.DRBs_Setup_Item.dRBID = ueCfg->upTnlInfo[arrIdx].drbId;
14246 ret = fillDlTnlSetupList(&drbItemIe->value.choice.DRBs_Setup_Item.dLUPTNLInformation_ToBeSetup_List,\
14247 &ueCfg->upTnlInfo[arrIdx]);
14254 /*******************************************************************
14256 * @brief Builds and sends the UE Setup Response
14260 * Function : BuildAndSendUeContextSetupRsp
14262 * Functionality: Constructs the UE Setup Response and sends
14263 * it to the DU through SCTP.
14265 * @params[in] uint8_t cellId,uint8_t ueId
14267 * @return ROK - success
14268 * RFAILED - failure
14270 * ****************************************************************/
14271 uint8_t BuildAndSendUeContextSetupRsp(uint8_t cellId,uint8_t ueId)
14273 uint8_t idx, ret, cellIdx, elementCnt;
14274 uint32_t gnbCuUeF1apId; /* gNB-CU UE F1AP Id */
14275 uint32_t gnbDuUeF1apId; /* gNB-DU UE F1AP Id */
14276 asn_enc_rval_t encRetVal; /* Encoder return value */
14277 F1AP_PDU_t *f1apMsg = NULLP;
14278 UEContextSetupResponse_t *ueSetRsp = NULLP;
14279 DuUeCb *ueCb = NULLP;
14281 DU_LOG("\n INFO --> F1AP : Building UE Context Setup Response for cellId %d, ueId %d\n", cellId, ueId);
14285 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
14286 if(f1apMsg == NULLP)
14288 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
14293 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
14294 DU_ALLOC(f1apMsg->choice.successfulOutcome,
14295 sizeof(SuccessfulOutcome_t));
14296 if(f1apMsg->choice.successfulOutcome == NULLP)
14298 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
14303 f1apMsg->choice.successfulOutcome->procedureCode = \
14304 ProcedureCode_id_UEContextSetup;
14305 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
14306 f1apMsg->choice.successfulOutcome->value.present = \
14307 SuccessfulOutcome__value_PR_UEContextSetupResponse;
14310 &f1apMsg->choice.successfulOutcome->value.choice.UEContextSetupResponse;
14312 ueSetRsp->protocolIEs.list.count = elementCnt;
14313 ueSetRsp->protocolIEs.list.size = \
14314 elementCnt * sizeof(UEContextSetupResponse_t *);
14316 /* Initialize the UESetup members */
14317 DU_ALLOC(ueSetRsp->protocolIEs.list.array, \
14318 ueSetRsp->protocolIEs.list.size);
14319 if(ueSetRsp->protocolIEs.list.array == NULLP)
14321 DU_LOG(" ERROR --> F1AP : Memory allocation for UE Setup Response failed");
14326 for(idx=0; idx<elementCnt; idx++)
14328 DU_ALLOC(ueSetRsp->protocolIEs.list.array[idx],\
14329 sizeof(UEContextSetupResponseIEs_t));
14330 if(ueSetRsp->protocolIEs.list.array[idx] == NULLP)
14332 DU_LOG(" ERROR --> F1AP : Memory allocation for UE Setup Response failed");
14337 /* Fetching Ue Cb Info*/
14338 GET_CELL_IDX(cellId, cellIdx);
14339 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
14340 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
14341 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1];
14344 /*GNB CU UE F1AP ID*/
14345 ueSetRsp->protocolIEs.list.array[idx]->id = \
14346 ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
14347 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
14348 ueSetRsp->protocolIEs.list.array[idx]->value.present = \
14349 UEContextSetupResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
14350 ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
14352 /*GNB DU UE F1AP ID*/
14354 ueSetRsp->protocolIEs.list.array[idx]->id = \
14355 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
14356 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
14357 ueSetRsp->protocolIEs.list.array[idx]->value.present = \
14358 UEContextSetupResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
14359 ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
14362 /*DUtoCURRC Information */
14364 ueSetRsp->protocolIEs.list.array[idx]->id = \
14365 ProtocolIE_ID_id_DUtoCURRCInformation;
14366 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
14367 ueSetRsp->protocolIEs.list.array[idx]->value.present =\
14368 UEContextSetupResponseIEs__value_PR_DUtoCURRCInformation;
14369 BuildCellGroupConfigRrc(ueCb, &ueSetRsp->protocolIEs.list.array[idx]->value.choice.DUtoCURRCInformation.cellGroupConfig);
14373 ueSetRsp->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_C_RNTI;
14374 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
14375 ueSetRsp->protocolIEs.list.array[idx]->value.present = UEContextSetupResponseIEs__value_PR_C_RNTI;
14376 ueSetRsp->protocolIEs.list.array[idx]->value.choice.C_RNTI = ueCb->crnti;
14379 /* Drb Setup List */
14381 ueSetRsp->protocolIEs.list.array[idx]->id = \
14382 ProtocolIE_ID_id_DRBs_Setup_List;
14383 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
14384 ueSetRsp->protocolIEs.list.array[idx]->value.present =\
14385 UEContextSetupResponseIEs__value_PR_DRBs_Setup_List;
14386 ret = fillDrbSetupList(&ueSetRsp->protocolIEs.list.array[idx]->value.choice.DRBs_Setup_List,\
14387 &ueCb->f1UeDb->duUeCfg);
14390 DU_LOG("\nERROR --> F1AP : Failed to fillDrbSetupList in BuildAndSendUeContextSetupRsp()");
14391 freeF1UeDb(ueCb->f1UeDb);
14392 ueCb->f1UeDb = NULLP;
14396 /* Free UeContext Db created during Ue context Req */
14397 freeF1UeDb(ueCb->f1UeDb);
14398 ueCb->f1UeDb = NULLP;
14400 /* TODO: To send Drb list */
14401 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
14403 /* Encode the UE context setup response type as APER */
14404 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
14406 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
14408 /* Encode results */
14409 if(encRetVal.encoded == ENCODE_FAIL)
14411 DU_LOG( "\nERROR --> F1AP : Could not encode UE Context Setup Response structure (at %s)\n",\
14412 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
14418 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UE Context Setup Response\n");
14419 #ifdef DEBUG_ASN_PRINT
14420 for(int i=0; i< encBufSize; i++)
14422 printf("%x",encBuf[i]);
14428 if(sendF1APMsg() != ROK)
14430 DU_LOG("\nERROR --> F1AP : Sending UE Context Setup Response failed");
14436 FreeUeContextSetupRsp(f1apMsg);
14438 }/* End of BuildAndSendUeContextSetupRsp */
14440 /*******************************************************************
14442 * @brief Build And Send Ue Context Rsp
14446 * Function : BuildAndSendUeCtxtRsp
14448 * Functionality : Build And Send Ue Context Rsp
14451 * @return sucess = ROK
14452 * failure = RFAILED
14454 * ****************************************************************/
14455 uint8_t BuildAndSendUeCtxtRsp(uint8_t cellId, uint8_t ueId)
14457 uint8_t cellIdx = 0, actionType = 0;
14459 GET_CELL_IDX(cellId, cellIdx);
14460 actionType = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].f1UeDb->actionType;
14464 case UE_CTXT_SETUP:
14466 if((BuildAndSendUeContextSetupRsp(cellId,ueId)) != ROK)
14468 DU_LOG("\nERROR --> F1AP : Failed at BuildAndSendUeContextSetupRsp()");
14475 if((BuildAndSendUeContextModRsp(&duCb.actvCellLst[cellIdx]->ueCb[ueId-1])) != ROK)
14477 DU_LOG("\nERROR --> F1AP : Failed at BuildAndSendUeContextModRsp");
14483 DU_LOG("ERROR --> F1AP: Invalid Action Type %d at BuildAndSendUeCtxtRsp()", actionType);
14490 /*******************************************************************
14492 * @brief deallocating the memory of F1reset msg
14496 * Function : FreeF1ResetReq
14499 * - freeing memory of F1reset request msg
14505 * ****************************************************************/
14506 void FreeF1ResetReq(F1AP_PDU_t *f1apMsg)
14509 Reset_t *f1ResetMsg;
14513 if(f1apMsg->choice.initiatingMessage)
14515 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
14517 if(f1ResetMsg->protocolIEs.list.array)
14519 for(idx=0 ;idx < f1ResetMsg->protocolIEs.list.count ; idx++)
14521 if(f1ResetMsg->protocolIEs.list.array[idx])
14523 DU_FREE(f1ResetMsg->protocolIEs.list.array[idx],sizeof(ResetIEs_t));
14526 DU_FREE(f1ResetMsg->protocolIEs.list.array,f1ResetMsg->protocolIEs.list.size);
14528 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
14530 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
14533 /*******************************************************************
14535 * @brief Build and Send F1reset request
14539 * Function : BuildAndSendF1ResetReq
14542 * - Build and Send F1reset request msg
14545 * @return ROK - success
14546 * RFAILED - failure
14548 * ****************************************************************/
14549 uint8_t BuildAndSendF1ResetReq()
14551 uint8_t elementCnt=0;
14553 uint8_t ret= RFAILED;
14554 Reset_t *f1ResetMsg = NULLP;
14555 F1AP_PDU_t *f1apMsg = NULLP;
14556 asn_enc_rval_t encRetVal;
14557 DU_LOG("\nINFO --> F1AP : Building F1 Reset request \n");
14560 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
14561 if(f1apMsg == NULLP)
14565 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
14566 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
14567 if(f1apMsg->choice.initiatingMessage == NULLP)
14571 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_Reset;
14572 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
14573 f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_Reset;
14575 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
14578 f1ResetMsg->protocolIEs.list.count = elementCnt;
14579 f1ResetMsg->protocolIEs.list.size = elementCnt * sizeof(ResetIEs_t *);
14581 /* Initialize the F1Setup members */
14582 DU_ALLOC(f1ResetMsg->protocolIEs.list.array,f1ResetMsg->protocolIEs.list.size);
14583 if(f1ResetMsg->protocolIEs.list.array == NULLP)
14587 for(idx=0; idx<elementCnt; idx++)
14589 DU_ALLOC(f1ResetMsg->protocolIEs.list.array[idx],sizeof(ResetIEs_t));
14590 if(f1ResetMsg->protocolIEs.list.array[idx] == NULLP)
14598 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID;
14599 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
14600 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_TransactionID;
14601 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.TransactionID = 1;
14605 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_Cause;
14606 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_ignore;
14607 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_Cause;
14608 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.Cause.present = Cause_PR_radioNetwork;
14609 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.Cause.choice.radioNetwork = CauseRadioNetwork_action_desirable_for_radio_reasons;
14613 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_ResetType;
14614 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
14615 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_ResetType;
14616 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.ResetType.present = ResetType_PR_f1_Interface;
14617 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.ResetType.choice.f1_Interface = ResetAll_reset_all;
14619 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
14621 /* Encode the F1SetupRequest type as APER */
14622 memset(encBuf, 0, ENC_BUF_MAX_LEN);
14624 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
14627 /* Encode results */
14628 if(encRetVal.encoded == ENCODE_FAIL)
14630 DU_LOG("\nERROR --> F1AP : Could not encode F1Reset structure (at %s)\n",\
14631 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
14636 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for F1Reset\n");
14637 #ifdef DEBUG_ASN_PRINT
14638 for(idx=0; idx< encBufSize; idx++)
14640 printf("%x",encBuf[idx]);
14645 if(sendF1APMsg() != ROK)
14647 DU_LOG("\nERROR --> F1AP : Sending F1 Reset request failed");
14655 FreeF1ResetReq(f1apMsg);
14658 /*******************************************************************
14660 * @brief Build And Send F1ResetAck
14664 * Function : BuildAndSendF1ResetAck
14667 * - Build And Send F1ResetRSP
14669 * @return ROK - success
14670 * RFAILED - failure
14672 * ****************************************************************/
14673 void FreeF1ResetAck(F1AP_PDU_t *f1apMsg)
14676 ResetAcknowledge_t *f1ResetAck;
14680 if(f1apMsg->choice.successfulOutcome)
14682 f1ResetAck= &f1apMsg->choice.successfulOutcome->value.choice.ResetAcknowledge;
14684 if(f1ResetAck->protocolIEs.list.array)
14686 for(idx=0; idx<f1ResetAck->protocolIEs.list.count ; idx++)
14688 if(f1ResetAck->protocolIEs.list.array[idx])
14690 DU_FREE(f1ResetAck->protocolIEs.list.array[idx], sizeof(ResetAcknowledgeIEs_t));
14693 DU_FREE(f1ResetAck->protocolIEs.list.array, f1ResetAck->protocolIEs.list.size );
14695 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
14697 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
14701 /*******************************************************************
14703 * @brief Build And Send F1ResetAck
14707 * Function : BuildAndSendF1ResetAck
14710 * - Build And Send F1ResetRSP
14713 * @return ROK - success
14714 * RFAILED - failure
14716 * ****************************************************************/
14717 uint8_t BuildAndSendF1ResetAck()
14720 uint8_t elementCnt = 0;
14721 uint8_t ret = RFAILED;
14722 F1AP_PDU_t *f1apMsg = NULL;
14723 ResetAcknowledge_t *f1ResetAck = NULLP;
14724 asn_enc_rval_t encRetVal;
14725 DU_LOG("\nINFO --> F1AP : Building F1 Reset Acknowledgment \n");
14728 /* Allocate the memory for F1ResetRequest_t */
14729 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
14730 if(f1apMsg == NULLP)
14732 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed");
14736 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
14738 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
14739 if(f1apMsg->choice.successfulOutcome == NULLP)
14741 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed");
14744 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
14745 f1apMsg->choice.successfulOutcome->value.present = SuccessfulOutcome__value_PR_ResetAcknowledge;
14746 f1ResetAck = &f1apMsg->choice.successfulOutcome->value.choice.ResetAcknowledge;
14750 f1ResetAck->protocolIEs.list.count = elementCnt;
14751 f1ResetAck->protocolIEs.list.size = elementCnt*sizeof(ResetAcknowledgeIEs_t *);
14753 DU_ALLOC(f1ResetAck->protocolIEs.list.array, f1ResetAck->protocolIEs.list.size );
14754 if(f1ResetAck->protocolIEs.list.array == NULLP)
14756 DU_LOG("\nERROR --> F1AP : Memory allocation for F1ResetAckIEs failed");
14760 for(idx=0; idx<elementCnt; idx++)
14762 DU_ALLOC(f1ResetAck->protocolIEs.list.array[idx], sizeof(ResetAcknowledgeIEs_t));
14763 if(f1ResetAck->protocolIEs.list.array[idx] == NULLP)
14770 f1ResetAck->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID;
14771 f1ResetAck->protocolIEs.list.array[idx]->criticality = Criticality_reject;
14772 f1ResetAck->protocolIEs.list.array[idx]->value.present = ResetAcknowledgeIEs__value_PR_TransactionID;
14773 f1ResetAck->protocolIEs.list.array[idx]->value.choice.TransactionID = TRANS_ID;
14775 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
14777 /* Encode the F1SetupRequest type as UPER */
14778 memset(encBuf, 0, ENC_BUF_MAX_LEN);
14780 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
14782 /* Check encode results */
14783 if(encRetVal.encoded == ENCODE_FAIL)
14785 DU_LOG("\nERROR --> F1AP : Could not encode F1ResetAck structure (at %s)\n",\
14786 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
14791 DU_LOG("\nDUBUG --> F1AP : Created APER encoded buffer for F1ResetAck\n");
14792 #ifdef DEBUG_ASN_PRINT
14793 for(int i=0; i< encBufSize; i++)
14795 printf("%x",encBuf[i]);
14800 if(sendF1APMsg() != ROK)
14802 DU_LOG("\nERROR --> F1AP : Sending F1 Reset Acknowledgement failed");
14810 FreeF1ResetAck(f1apMsg);
14813 /******************************************************************
14815 * @brief free F1 reset msg allocated by aper_decoder
14819 * Function : freeAperDecodeF1ResetMsg
14821 * Functionality: free F1 reset msg allocated by aper_decoder
14823 * @params[in] Reset_t *f1ResetMsg
14826 * ****************************************************************/
14828 void freeAperDecodeF1ResetMsg(Reset_t *f1ResetMsg)
14831 if(f1ResetMsg->protocolIEs.list.array)
14833 for(ieIdx=0 ;ieIdx < f1ResetMsg->protocolIEs.list.count ; ieIdx++)
14835 if(f1ResetMsg->protocolIEs.list.array[ieIdx])
14837 free(f1ResetMsg->protocolIEs.list.array[ieIdx]);
14840 free(f1ResetMsg->protocolIEs.list.array);
14844 /******************************************************************
14846 * @brief Processes DL RRC Message Transfer sent by CU
14850 * Function : procF1ResetReq
14852 * Functionality: Processes DL RRC Message Transfer sent by CU
14854 * @params[in] F1AP_PDU_t ASN decoded F1AP message
14855 * @return ROK - success
14856 * RFAILED - failure
14858 * ****************************************************************/
14859 uint8_t procF1ResetReq(F1AP_PDU_t *f1apMsg)
14861 /* we are currently not supporting Ue release. right now we are supporting only init case of fireset */
14864 Reset_t *f1ResetMsg = NULLP;
14866 DU_LOG("\nINFO --> Processing F1 reset request");
14867 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
14869 for(ieIdx=0; ieIdx<f1ResetMsg->protocolIEs.list.count; ieIdx++)
14871 switch(f1ResetMsg->protocolIEs.list.array[ieIdx]->id)
14873 case ProtocolIE_ID_id_TransactionID:
14876 case ProtocolIE_ID_id_Cause:
14879 case ProtocolIE_ID_id_ResetType:
14888 ret = BuildAndSendF1ResetAck();
14889 DU_LOG("\nINFO --> UE release is not supported for now");
14891 freeAperDecodeF1ResetMsg(f1ResetMsg);
14896 /*******************************************************************
14898 * @brief free the RRC delivery report
14902 * Function : freeRrcDeliveryReport
14904 * Functionality: free the RRC delivery report
14907 * @return ROK - success
14908 * RFAILED - failure
14910 * ****************************************************************/
14911 void freeRrcDeliveryReport(F1AP_PDU_t *f1apMsg )
14914 RRCDeliveryReport_t *rrcDeliveryReport= NULLP;
14918 if(f1apMsg->choice.initiatingMessage)
14920 rrcDeliveryReport = &f1apMsg->choice.initiatingMessage->value.choice.RRCDeliveryReport;
14921 if(rrcDeliveryReport->protocolIEs.list.array)
14923 for(idx =0 ;idx <rrcDeliveryReport->protocolIEs.list.count ;
14926 if(rrcDeliveryReport->protocolIEs.list.array[idx])
14928 DU_FREE(rrcDeliveryReport->protocolIEs.list.array[idx],
14929 sizeof(RRCDeliveryReportIEs_t));
14932 DU_FREE(rrcDeliveryReport->protocolIEs.list.array,
14933 rrcDeliveryReport->protocolIEs.list.size);
14935 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
14938 sizeof(F1AP_PDU_t));
14942 /*******************************************************************
14944 * @brief Builds and sends the RRC delivery report
14948 * Function : BuildAndSendRrcDeliveryReport
14950 * Functionality: Builds and sends the RRC delivery report
14954 * @return ROK - success
14955 * RFAILED - failure
14957 * ****************************************************************/
14958 uint8_t BuildAndSendRrcDeliveryReport(uint32_t gnbCuUeF1apId, \
14959 uint32_t gnbDuUeF1apId, RrcDeliveryReport *rrcDelivery)
14961 uint8_t ret = RFAILED;
14964 uint8_t elementCnt = 0;
14965 F1AP_PDU_t *f1apMsg = NULLP;
14966 asn_enc_rval_t encRetVal;
14967 RRCDeliveryReport_t *rrcDeliveryReport= NULLP;
14971 DU_LOG("\nINFO --> F1AP : Building RRC delivery Message Transfer Message\n");
14972 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
14973 if(f1apMsg == NULLP)
14975 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
14978 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
14979 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
14980 if(f1apMsg->choice.initiatingMessage == NULLP)
14982 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
14985 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_RRCDeliveryReport;
14986 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
14987 f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_RRCDeliveryReport;
14989 rrcDeliveryReport = &f1apMsg->choice.initiatingMessage->value.choice.RRCDeliveryReport;
14991 rrcDeliveryReport->protocolIEs.list.count = elementCnt;
14992 rrcDeliveryReport->protocolIEs.list.size = elementCnt * sizeof(RRCDeliveryReportIEs_t *);
14994 /* Initialize the F1Setup members */
14995 DU_ALLOC(rrcDeliveryReport->protocolIEs.list.array, rrcDeliveryReport->protocolIEs.list.size);
14996 if(rrcDeliveryReport->protocolIEs.list.array == NULLP)
14998 DU_LOG(" ERROR --> F1AP : Memory allocation for RRC Delivery failed");
15001 for(idx =0 ;idx <elementCnt; idx++)
15003 DU_ALLOC(rrcDeliveryReport->protocolIEs.list.array[idx], sizeof(RRCDeliveryReportIEs_t));
15004 if(rrcDeliveryReport->protocolIEs.list.array[idx] == NULLP)
15012 /*GNB CU UE F1AP ID*/
15013 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
15014 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
15015 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_GNB_CU_UE_F1AP_ID;
15016 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
15018 /*GNB DU UE F1AP ID*/
15020 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
15021 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
15022 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_GNB_DU_UE_F1AP_ID;
15023 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
15025 /*RRC delivery status*/
15027 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_RRCDeliveryStatus;
15028 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_ignore;
15029 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_RRCDeliveryStatus;
15030 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.RRCDeliveryStatus.delivery_status =\
15031 rrcDelivery->rrcDeliveryStatus.deliveryStatus;
15032 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.RRCDeliveryStatus.triggering_message =\
15033 rrcDelivery->rrcDeliveryStatus.triggeringMessage;
15037 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_SRBID;
15038 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_ignore;
15039 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_SRBID;
15040 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.SRBID = rrcDelivery->srbId;
15042 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
15044 /* Encode the RRC DELIVERY REPORT type as APER */
15045 memset(encBuf, 0, ENC_BUF_MAX_LEN);
15047 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
15050 /* Encode results */
15051 if(encRetVal.encoded == ENCODE_FAIL)
15053 DU_LOG("\nERROR --> F1AP : Could not encode RRC Delivery Msg structure (at %s)\n",\
15054 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
15059 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for RRC Delivery Msg \n");
15060 #ifdef DEBUG_ASN_PRINT
15061 for(idx=0; idx< encBufSize; idx++)
15063 printf("%x",encBuf[idx]);
15069 if(sendF1APMsg() != ROK)
15071 DU_LOG("\nERROR --> F1AP : Sending RRC delivery msg request failed");
15079 freeRrcDeliveryReport(f1apMsg);
15083 /*******************************************************************
15085 * @brief Processes cells to be activated
15089 * Function : extractCellsToBeActivated
15092 * - Processes cells to be activated list received in F1SetupRsp
15095 * @return ROK - success
15096 * RFAILED - failure
15098 * ****************************************************************/
15100 uint8_t extractCellsToBeActivated(Cells_to_be_Activated_List_t cellsToActivate)
15103 uint16_t idx, pci = 0;
15105 Cells_to_be_Activated_List_Item_t cell;
15107 for(idx=0; idx<cellsToActivate.list.count; idx++)
15110 cell = cellsToActivate.list.array[idx]->value.choice.Cells_to_be_Activated_List_Item;
15111 bitStringToInt(&cell.nRCGI.nRCellIdentity, &nci);
15117 ret = duProcCellsToBeActivated(cell.nRCGI.pLMN_Identity.buf, nci, pci);
15121 /******************************************************************
15123 * @brief Processes F1 Setup Response allocated by aper_decoder
15127 * Function : freeF1SetupRsp
15129 * Functionality: free F1 Setup Response allocated by aper_decoder
15131 * @params[in] F1SetupResponse_t *f1SetRspMsg
15134 * ****************************************************************/
15136 void freeAperDecodeF1SetupRsp(F1SetupResponse_t *f1SetRspMsg)
15140 Cells_to_be_Activated_List_t *cellToActivate =NULLP;
15141 RRC_Version_t *rrcVer =NULLP;
15143 if(f1SetRspMsg->protocolIEs.list.array)
15145 for(ieIdx=0; ieIdx<f1SetRspMsg->protocolIEs.list.count; ieIdx++)
15147 if(f1SetRspMsg->protocolIEs.list.array[ieIdx])
15149 switch(f1SetRspMsg->protocolIEs.list.array[ieIdx]->id)
15151 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
15154 &f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.Cells_to_be_Activated_List;
15155 if(cellToActivate->list.array)
15157 for(arrIdx=0; arrIdx<cellToActivate->list.count ; arrIdx++)
15159 if(cellToActivate->list.array[arrIdx])
15162 if(cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.nRCGI.\
15165 if(cellToActivate->list.array[0]->value.choice.\
15166 Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf)
15168 free(cellToActivate->list.array[0]->value.choice.\
15169 Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf);
15172 free(cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.\
15173 nRCGI.pLMN_Identity.buf);
15175 free(cellToActivate->list.array[arrIdx]);
15178 free(cellToActivate->list.array);
15182 case ProtocolIE_ID_id_TransactionID:
15186 case ProtocolIE_ID_id_gNB_CU_Name:
15188 free(f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_Name.buf);
15191 case ProtocolIE_ID_id_GNB_CU_RRC_Version:
15193 rrcVer = &f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.RRC_Version;
15194 if(rrcVer->latest_RRC_Version.buf)
15196 if(rrcVer->iE_Extensions)
15198 if(rrcVer->iE_Extensions->list.array)
15200 if(rrcVer->iE_Extensions->list.array[0])
15202 if(rrcVer->iE_Extensions->list.\
15203 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf)
15205 free(rrcVer->iE_Extensions->list.\
15206 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf);
15208 free(rrcVer->iE_Extensions->list.array[0]);
15210 free(rrcVer->iE_Extensions->list.array);
15212 free(rrcVer->iE_Extensions);
15214 free(rrcVer->latest_RRC_Version.buf);
15221 DU_LOG("\nERROR --> DU_APP : Invalid IE received in F1SetupRsp:%ld",
15222 f1SetRspMsg->protocolIEs.list.array[ieIdx]->id);
15225 free(f1SetRspMsg->protocolIEs.list.array[ieIdx]);
15228 free(f1SetRspMsg->protocolIEs.list.array);
15231 /******************************************************************
15233 * @brief Processes F1 Setup Response sent by CU
15237 * Function : procF1SetupRsp
15239 * Functionality: Processes F1 Setup Response sent by CU
15241 * @params[in] F1AP_PDU_t ASN decoded F1AP message
15242 * @return ROK - success
15243 * RFAILED - failure
15245 * ****************************************************************/
15246 uint8_t procF1SetupRsp(F1AP_PDU_t *f1apMsg, MsgLen recvBufLen, char *recvBuf)
15250 F1SetupResponse_t *f1SetRspMsg = NULLP;
15251 GNB_CU_Name_t *cuName = NULLP;
15252 F1SetupRsp f1SetRspDb;
15253 RRC_Version_t *rrcVer =NULLP;
15255 memset(&f1SetRspDb, 0, sizeof(F1SetupRsp));
15257 DU_LOG("\nINFO --> F1AP : F1 Setup Response received");
15258 f1SetRspMsg = &f1apMsg->choice.successfulOutcome->value.choice.F1SetupResponse;
15260 for(idx=0; idx<f1SetRspMsg->protocolIEs.list.count; idx++)
15262 switch(f1SetRspMsg->protocolIEs.list.array[idx]->id)
15264 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
15266 extractCellsToBeActivated(f1SetRspMsg->protocolIEs.list.array[idx]->\
15267 value.choice.Cells_to_be_Activated_List);
15270 case ProtocolIE_ID_id_TransactionID:
15272 f1SetRspDb.transId = f1SetRspMsg->protocolIEs.list.array[idx]->\
15273 value.choice.TransactionID;
15276 case ProtocolIE_ID_id_gNB_CU_Name:
15278 cuName = &f1SetRspMsg->protocolIEs.list.array[idx]->\
15279 value.choice.GNB_CU_Name;
15280 strcpy(f1SetRspDb.cuName, (const char*)cuName->buf);
15283 case ProtocolIE_ID_id_GNB_CU_RRC_Version:
15285 rrcVer = &f1SetRspMsg->protocolIEs.list.array[idx]->value.choice.RRC_Version;
15286 strcpy(f1SetRspDb.rrcVersion.rrcVer,
15287 (const char*)rrcVer->latest_RRC_Version.buf);
15291 DU_LOG("\nERROR --> DU_APP : Invalid IE received in F1SetupRsp:%ld",
15292 f1SetRspMsg->protocolIEs.list.array[idx]->id);
15294 duProcF1SetupRsp();
15297 freeAperDecodeF1SetupRsp(f1SetRspMsg);
15299 duCb.f1SetupReqAndRspMsg.f1MsgRspBufSize = recvBufLen;
15300 DU_ALLOC(duCb.f1SetupReqAndRspMsg.f1MsgRspBuf, duCb.f1SetupReqAndRspMsg.f1MsgRspBufSize);
15301 if(duCb.f1SetupReqAndRspMsg.f1MsgReqBuf == NULLP)
15303 DU_LOG("\nERROR --> F1AP : Memory allocation failed to store the buf of F1setup response");
15306 memcpy(duCb.f1SetupReqAndRspMsg.f1MsgRspBuf, recvBuf, recvBufLen);
15308 if(BuildAndSendE2SetupReq() != ROK)
15310 DU_LOG("\nERROR --> F1AP : Failed to build and send E2 setup request ");
15315 /*******************************************************************
15317 * @brief free GNB DU config update ack
15321 * Function : freeAperDecodeGnbDuAck
15323 * Functionality: Processes GNB DU config update ack And
15324 * added free part for the memory allocated by aper_decoder
15326 * @params[in] F1AP_PDU_t ASN decoded F1AP message
15327 * @return ROK - success
15328 * RFAILED - failure
15330 * ****************************************************************/
15332 void freeAperDecodeGnbDuAck(GNBDUConfigurationUpdateAcknowledge_t *gnbDuAck)
15336 if(gnbDuAck->protocolIEs.list.array)
15338 for(ieIdx=0; ieIdx < gnbDuAck->protocolIEs.list.count; ieIdx++)
15340 if(gnbDuAck->protocolIEs.list.array[ieIdx])
15342 free(gnbDuAck->protocolIEs.list.array[ieIdx]);
15345 free(gnbDuAck->protocolIEs.list.array);
15349 /*******************************************************************
15351 * @brief Building result of gnb-du config update ack output
15355 * Function : duProcGnbDuCfgUpdAckMsg
15358 * Building output of gnb-du config update ack
15360 * @params[in] transId
15363 * ****************************************************************/
15365 uint8_t duProcGnbDuCfgUpdAckMsg(uint8_t transId)
15367 uint8_t ieIdx=0, arrIdx=0,ret=ROK;
15368 uint8_t ueId =0 , ueIdx =0, totalActiveUe = 0;
15369 uint16_t cellIdx =0, crnti=0;
15370 uint64_t cellId =0;
15371 CmLList *f1apPduNode = NULLP;
15372 ReservedF1apPduInfo *f1apPduInfo =NULLP;
15373 F1AP_PDU_t *f1apMsgPdu = NULLP;
15374 GNBDUConfigurationUpdate_t *gnbDuConfigUpdate = NULLP;
15375 BIT_STRING_t *cellIdentity=NULLP;
15376 struct Served_Cells_To_Delete_ItemIEs *deleteItemIe=NULLP;
15377 Served_Cells_To_Delete_List_t *cellsToDelete=NULLP;
15378 Served_Cells_To_Delete_Item_t *deleteItem=NULLP;
15380 DU_LOG("\nINFO --> DU APP: GNB-DU config update Ack received ");
15381 f1apPduNode = searchFromReservedF1apPduList(transId);
15382 f1apPduInfo = (ReservedF1apPduInfo *)f1apPduNode->node;
15383 f1apMsgPdu = (F1AP_PDU_t *)f1apPduInfo->f1apMsg;
15387 if(f1apMsgPdu->choice.initiatingMessage)
15389 gnbDuConfigUpdate = &f1apMsgPdu->choice.initiatingMessage->value.choice.GNBDUConfigurationUpdate;
15390 for(ieIdx=0; ieIdx < gnbDuConfigUpdate->protocolIEs.list.count; ieIdx++)
15392 switch(gnbDuConfigUpdate->protocolIEs.list.array[ieIdx]->id)
15394 case ProtocolIE_ID_id_Served_Cells_To_Delete_List:
15396 cellsToDelete = &gnbDuConfigUpdate->protocolIEs.list.array[ieIdx]->value.choice.\
15397 Served_Cells_To_Delete_List;
15398 if(cellsToDelete->list.array)
15400 if(cellsToDelete->list.array[arrIdx])
15402 deleteItemIe = (Served_Cells_To_Delete_ItemIEs_t*)cellsToDelete->list.array[arrIdx];
15403 deleteItem=&deleteItemIe->value.choice.Served_Cells_To_Delete_Item;
15404 if(deleteItem->oldNRCGI.nRCellIdentity.buf)
15406 cellIdentity = &deleteItem->oldNRCGI.nRCellIdentity;
15407 bitStringToInt(cellIdentity, &cellId);
15409 GET_CELL_IDX(cellId, cellIdx);
15410 if(duCb.actvCellLst[cellIdx] != NULLP)
15412 duCb.actvCellLst[cellId-1]->cellStatus = DELETION_IN_PROGRESS;
15418 if(duCb.actvCellLst[cellIdx] != NULLP)
15420 if(duCb.actvCellLst[cellIdx]->numActvUes == 0)
15422 ret = duSendCellDeletReq(cellId);
15425 DU_LOG("\nERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): Failed to send cell delete\
15426 request for cellId[%lu]", cellId);
15431 totalActiveUe = duCb.actvCellLst[cellIdx]->numActvUes;
15432 while(totalActiveUe)
15434 if(duCb.actvCellLst[cellIdx]->ueCb[ueIdx].ueState != UE_ACTIVE)
15440 crnti = duCb.actvCellLst[cellIdx]->ueCb[ueIdx].crnti;
15441 GET_UE_ID(crnti,ueId);
15442 /* Sending Ue Context release request only for maximum supporting UEs */
15443 ret = BuildAndSendUeContextReleaseReq(cellId, ueId);
15446 DU_LOG("\nERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): Failed to build and send UE delete\
15447 request for cellId[%lu]", cellId);
15456 DU_LOG("\nERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): CellId [%lu] not found", cellId);
15469 FreeDUConfigUpdate(f1apMsgPdu);
15470 deleteFromReservedF1apPduList(f1apPduNode);
15474 /*******************************************************************
15476 * @brief Processes GNB DU config update ack
15480 * Function : procF1GNBDUCfgUpdAck
15482 * Functionality: added free part for the memory allocated by aper_decoder
15484 * @params[in] F1AP_PDU_t *f1apMsg
15487 * ****************************************************************/
15488 uint8_t procF1GNBDUCfgUpdAck(F1AP_PDU_t *f1apMsg)
15490 uint8_t ieIdx=0,transId=0;
15491 GNBDUConfigurationUpdateAcknowledge_t *gnbDuAck = NULLP;
15493 DU_LOG("\nINFO --> F1AP : GNB-DU config update acknowledgment");
15494 gnbDuAck = &f1apMsg->choice.successfulOutcome->value.choice.GNBDUConfigurationUpdateAcknowledge;
15496 for(ieIdx=0; ieIdx < gnbDuAck->protocolIEs.list.count; ieIdx++)
15498 switch(gnbDuAck->protocolIEs.list.array[ieIdx]->id)
15500 case ProtocolIE_ID_id_TransactionID:
15502 transId = gnbDuAck->protocolIEs.list.array[ieIdx]->value.choice.TransactionID;
15505 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
15511 DU_LOG("\nERROR --> F1AP: procF1GNBDUCfgUpdAck(): Invalid IE Received: %ld", \
15512 gnbDuAck->protocolIEs.list.array[ieIdx]->id);
15518 duProcGnbDuCfgUpdAckMsg(transId);
15521 /* presently we are not supporting F1 Reset from DU to CU , we are only
15522 * supporting F1 Reset from CU to DU */
15524 if(BuildAndSendF1ResetReq() != ROK)
15530 freeAperDecodeGnbDuAck(gnbDuAck);
15533 /******************************************************************
15535 * @brief free DL RRC Message Transfer allocated by aper_decoder
15539 * Function : freeAperDecodef1DlRrcMsg
15541 * Functionality: free DL RRC Message Transfer allocated by aper_decoder
15543 * @params[in] DLRRCMessageTransfer_t *f1DlRrcMsg
15544 * @return ROK - success
15545 * RFAILED - failure
15547 * ****************************************************************/
15549 void freeAperDecodef1DlRrcMsg(DLRRCMessageTransfer_t *f1DlRrcMsg)
15552 RRCContainer_t *rrcContainer = NULLP;
15554 if(f1DlRrcMsg->protocolIEs.list.array)
15556 for(ieIdx=0; ieIdx<f1DlRrcMsg->protocolIEs.list.count; ieIdx++)
15558 if(f1DlRrcMsg->protocolIEs.list.array[ieIdx])
15560 switch(f1DlRrcMsg->protocolIEs.list.array[ieIdx]->id)
15562 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
15564 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
15566 case ProtocolIE_ID_id_SRBID:
15568 case ProtocolIE_ID_id_RRCContainer:
15570 rrcContainer =&f1DlRrcMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer;
15571 free(rrcContainer->buf);
15573 case ProtocolIE_ID_id_ExecuteDuplication:
15575 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
15579 free(f1DlRrcMsg->protocolIEs.list.array[ieIdx]);
15582 free(f1DlRrcMsg->protocolIEs.list.array);
15585 /******************************************************************
15587 * @brief Processes DL RRC Message Transfer sent by CU
15591 * Function : procF1DlRrcMsgTrans
15593 * Functionality: Processes DL RRC Message Transfer sent by CU
15595 * @params[in] F1AP_PDU_t ASN decoded F1AP message
15596 * @return ROK - success
15597 * RFAILED - failure
15599 * ****************************************************************/
15600 uint8_t procF1DlRrcMsgTrans(F1AP_PDU_t *f1apMsg)
15603 DLRRCMessageTransfer_t *f1DlRrcMsg = NULLP;
15605 memset(&dlMsg, 0, sizeof(F1DlRrcMsg));
15607 DU_LOG("\nINFO --> DU_APP : DL RRC message transfer Recevied");
15608 f1DlRrcMsg = &f1apMsg->choice.initiatingMessage->value.choice.DLRRCMessageTransfer;
15612 for(idx=0; idx<f1DlRrcMsg->protocolIEs.list.count; idx++)
15614 switch(f1DlRrcMsg->protocolIEs.list.array[idx]->id)
15616 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
15618 dlMsg.gnbCuUeF1apId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID;
15621 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
15623 dlMsg.gnbDuUeF1apId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID;
15626 case ProtocolIE_ID_id_SRBID:
15628 dlMsg.srbId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.SRBID;
15631 case ProtocolIE_ID_id_ExecuteDuplication:
15632 dlMsg.execDup = true;
15635 case ProtocolIE_ID_id_RRCContainer:
15637 if(f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size > 0)
15639 dlMsg.rrcMsgSize = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size;
15640 DU_ALLOC_SHRABL_BUF(dlMsg.rrcMsgPdu, dlMsg.rrcMsgSize);
15641 if(dlMsg.rrcMsgPdu)
15643 memcpy(dlMsg.rrcMsgPdu, f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.buf,\
15648 DU_LOG("\nERROR --> DU APP : Memory alloc Failed at RRC Container at procF1DlRrcMsgTrans()");
15654 DU_LOG("\nERROR --> DU_APP : RRC Container Size is invalid:%ld",\
15655 f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size);
15660 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
15662 dlMsg.deliveryStatRpt = true;
15666 DU_LOG("\nERROR --> DU_APP : Invalid IE received in DL RRC Msg Transfer:%ld",
15667 f1DlRrcMsg->protocolIEs.list.array[idx]->id);
15671 ret = duProcDlRrcMsg(&dlMsg);
15673 freeAperDecodef1DlRrcMsg(f1DlRrcMsg);
15676 /*******************************************************************
15678 * @brief Builds the DRB to be Setup Mod list
15684 * Functionality: Constructs the DRB to be Setup Mod list
15686 * @params[in] DRBs_SetupMod_List_t *drbSet
15688 * @return ROK - success
15689 * RFAILED - failure
15691 * ****************************************************************/
15692 uint8_t BuildSrbSetupModList(SRBs_SetupMod_List_t *srbList, DuUeCfg *ueCfg)
15694 uint8_t srbIdx = 0;
15695 struct SRBs_SetupMod_ItemIEs *srbItemIe;
15697 srbList->list.count = ueCfg->numRlcLcs;
15698 srbList->list.size = srbList->list.count * sizeof(SRBs_SetupMod_ItemIEs_t *);
15700 DU_ALLOC(srbList->list.array, srbList->list.size);
15701 if(srbList->list.array == NULLP)
15703 DU_LOG("\nERROR --> DU APP : Memory allocation failed in BuildSrbSetupModList");
15707 for(srbIdx = 0; srbIdx < srbList->list.count; srbIdx++)
15709 DU_ALLOC(srbList->list.array[srbIdx], sizeof(SRBs_SetupMod_ItemIEs_t));
15710 if(srbList->list.array[srbIdx] == NULLP)
15712 DU_LOG("\nERROR --> DU APP : Memory allocation failed in BuildSrbSetupModList");
15717 for(srbIdx=0; srbIdx < srbList->list.count; srbIdx++)
15719 srbItemIe = (struct SRBs_SetupMod_ItemIEs *)srbList->list.array[srbIdx];
15720 srbItemIe->id = ProtocolIE_ID_id_SRBs_SetupMod_Item;
15721 srbItemIe->criticality = Criticality_reject;
15722 srbItemIe->value.present = SRBs_SetupMod_ItemIEs__value_PR_SRBs_SetupMod_Item;
15723 srbItemIe->value.choice.SRBs_SetupMod_Item.sRBID = ueCfg->rlcLcCfg[srbIdx].rlcBearerCfg.rbId;
15724 srbItemIe->value.choice.SRBs_SetupMod_Item.lCID = ueCfg->rlcLcCfg[srbIdx].rlcBearerCfg.lcId;
15729 /*******************************************************************
15731 * @brief Builds the DRB to be Setup Mod list
15737 * Functionality: Constructs the DRB to be Setup Mod list
15739 * @params[in] DRBs_SetupMod_List_t *drbSet
15741 * @return ROK - success
15742 * RFAILED - failure
15744 * ****************************************************************/
15746 uint8_t BuildDrbSetupModList(DRBs_SetupMod_List_t *drbSet , DuUeCfg *ueCfg)
15750 struct DRBs_SetupMod_ItemIEs *drbItemIe;
15752 drbCnt = ueCfg->numDrbSetupMod;
15754 drbSet->list.count = drbCnt;
15755 drbSet->list.size = drbCnt * sizeof(DRBs_SetupMod_ItemIEs_t *);
15756 DU_ALLOC(drbSet->list.array, drbSet->list.size);
15757 if(drbSet->list.array == NULLP)
15759 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDrbToBeSetupModList");
15762 for(arrIdx=0; arrIdx<drbCnt; arrIdx++)
15764 DU_ALLOC(drbSet->list.array[arrIdx], sizeof(DRBs_SetupMod_ItemIEs_t));
15765 if(drbSet->list.array[arrIdx] == NULLP)
15767 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDrbToBeSetupModList");
15771 drbItemIe = (struct DRBs_SetupMod_ItemIEs *)drbSet->list.array[arrIdx];
15772 drbItemIe->id = ProtocolIE_ID_id_DRBs_SetupMod_Item;
15773 drbItemIe->criticality = Criticality_reject;
15774 drbItemIe->value.present = DRBs_SetupMod_ItemIEs__value_PR_DRBs_SetupMod_Item;
15775 drbItemIe->value.choice.DRBs_SetupMod_Item.dRBID = ueCfg->upTnlInfo[arrIdx].drbId;
15776 if(fillDlTnlSetupList(&drbItemIe->value.choice.DRBs_SetupMod_Item.dLUPTNLInformation_ToBeSetup_List,\
15777 &ueCfg->upTnlInfo[arrIdx])!= ROK)
15779 DU_LOG("\nERROR --> F1AP : Failed to fill DlTnl SetupList in BuildDrbToBeSetupModList");
15787 /*******************************************************************
15788 * @brief Free the memory allocated for DRB setup List
15792 * Function : FreeDrbSetupModList
15795 * Free the memory allocated for DRB setup list
15797 * @params[in] DRBs_Setup_List_t *
15800 * ****************************************************************/
15801 void FreeDrbSetupModList(DRBs_SetupMod_List_t *drbSetupList)
15803 uint8_t arrIdx = 0;
15804 DRBs_SetupMod_ItemIEs_t *drbItemIe = NULLP;
15806 for(arrIdx = 0; arrIdx < drbSetupList->list.count; arrIdx++)
15808 drbItemIe = ((DRBs_SetupMod_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
15809 freeDlTnlInfo(&drbItemIe->value.choice.DRBs_SetupMod_Item.dLUPTNLInformation_ToBeSetup_List);
15810 DU_FREE(drbSetupList->list.array[arrIdx], sizeof(DRBs_SetupMod_ItemIEs_t));
15812 DU_FREE(drbSetupList->list.array, drbSetupList->list.size);
15815 /*******************************************************************
15817 * @brief Builds the DRB to be Mod list
15823 * Functionality: Constructs the DRB to be Mod list
15825 * @params[in] DRBs_Modified_List_t *drbModList
15827 * @return ROK - success
15828 * RFAILED - failure
15830 * ****************************************************************/
15832 uint8_t BuildDrbModList(DRBs_Modified_List_t *drbModList, DuUeCfg *ueCfg)
15834 uint8_t arrIdx =0, drbIdx = 0;
15836 struct DRBs_Modified_ItemIEs *drbItemIe;
15838 drbCnt = ueCfg->numDrbModified;
15840 drbModList->list.count = drbCnt;
15841 drbModList->list.size = drbCnt * sizeof(DRBs_Modified_ItemIEs_t *);
15842 DU_ALLOC(drbModList->list.array, drbModList->list.size);
15843 if(drbModList->list.array == NULLP)
15845 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDrbModList()");
15850 for(arrIdx = 0; arrIdx < ueCfg->numMacLcs; arrIdx++)
15852 if(ueCfg->macLcCfg[arrIdx].configType == CONFIG_MOD)
15854 DU_ALLOC(drbModList->list.array[drbIdx], sizeof(DRBs_Modified_ItemIEs_t));
15855 if(drbModList->list.array[drbIdx] == NULLP)
15857 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDrbModList");
15861 drbItemIe = (struct DRBs_Modified_ItemIEs *)drbModList->list.array[drbIdx];
15862 drbItemIe->id = ProtocolIE_ID_id_DRBs_Modified_Item;
15863 drbItemIe->criticality = Criticality_reject;
15864 drbItemIe->value.present = DRBs_Modified_ItemIEs__value_PR_DRBs_Modified_Item;
15865 drbItemIe->value.choice.DRBs_Modified_Item.dRBID = ueCfg->upTnlInfo[arrIdx].drbId;
15866 if(fillDlTnlSetupList(&drbItemIe->value.choice.DRBs_Modified_Item.dLUPTNLInformation_ToBeSetup_List,\
15867 &ueCfg->upTnlInfo[arrIdx])!= ROK)
15869 DU_LOG("\nERROR --> F1AP : Failed to fill DlTnl SetupList in BuildDrbModList");
15879 /*******************************************************************
15880 * @brief Free the memory allocated for DRB Mod List
15884 * Function : FreeDrbModList
15887 * Free the memory allocated for DRB modified list
15889 * @params[in] DRBs_Modified_List_t *
15892 * ****************************************************************/
15893 void FreeDrbModList(DRBs_Modified_List_t *drbModList)
15895 uint8_t arrIdx = 0;
15896 DRBs_Modified_ItemIEs_t *drbItemIe = NULLP;
15898 for(arrIdx = 0; arrIdx < drbModList->list.count; arrIdx++)
15900 drbItemIe = ((DRBs_Modified_ItemIEs_t *)drbModList->list.array[arrIdx]);
15901 freeDlTnlInfo(&drbItemIe->value.choice.DRBs_Modified_Item.dLUPTNLInformation_ToBeSetup_List);
15902 DU_FREE(drbModList->list.array[arrIdx], sizeof(DRBs_Modified_ItemIEs_t));
15904 DU_FREE(drbModList->list.array, drbModList->list.size);
15907 /*******************************************************************
15908 * @brief Free the memory allocated for SRB setup List
15912 * Function : FreeSrbSetupModList
15915 * Free the memory allocated for SRB setup list
15917 * @params[in] SRBs_Setup_List_t *
15920 * ****************************************************************/
15921 void FreeSrbSetupModList(SRBs_SetupMod_List_t *srbSetupList)
15923 uint8_t srbIdx = 0;
15925 for(srbIdx = 0; srbIdx < srbSetupList->list.count; srbIdx++)
15926 DU_FREE(srbSetupList->list.array[srbIdx], sizeof(SRBs_SetupMod_ItemIEs_t));
15927 DU_FREE(srbSetupList->list.array, srbSetupList->list.size);
15930 /*******************************************************************
15931 * @brief Free the memory allocated for UE Context Mod Response
15935 * Function : FreeUeContextModResp
15938 * Free the memory allocated for UE Context Mod Response
15940 * @params[in] F1AP_PDU_t *f1apMsg
15943 * ****************************************************************/
15945 void FreeUeContextModResp(F1AP_PDU_t *f1apMsg)
15948 UEContextModificationResponse_t *ueContextModifyRes = NULLP;
15951 if(f1apMsg->choice.successfulOutcome)
15953 ueContextModifyRes =&f1apMsg->choice.successfulOutcome->value.choice.UEContextModificationResponse;
15954 if(ueContextModifyRes->protocolIEs.list.array)
15956 for(ieIdx=0 ; ieIdx<ueContextModifyRes->protocolIEs.list.count; ieIdx++)
15958 if(ueContextModifyRes->protocolIEs.list.array[ieIdx])
15960 switch(ueContextModifyRes->protocolIEs.list.array[ieIdx]->id)
15962 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
15964 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
15966 case ProtocolIE_ID_id_DRBs_SetupMod_List:
15968 FreeDrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
15969 value.choice.DRBs_SetupMod_List));
15972 case ProtocolIE_ID_id_DRBs_Modified_List:
15974 FreeDrbModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
15975 value.choice.DRBs_Modified_List));
15978 case ProtocolIE_ID_id_SRBs_SetupMod_List:
15980 FreeSrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.\
15981 SRBs_SetupMod_List));
15985 DU_FREE(ueContextModifyRes->protocolIEs.list.array[ieIdx], sizeof(UEContextModificationResponse_t));
15989 DU_FREE(ueContextModifyRes->protocolIEs.list.array, ueContextModifyRes->protocolIEs.list.size);
15991 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
15993 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
15997 /*****************************************************************i
15999 * @brief Creating the ue context modifcation response and sending
16003 * Function : BuildAndSendUeContextModRsp
16006 * - Creating the ue context modifcation response
16008 * @params[in] uint8_t cellId,uint8_t ueId
16009 * @return ROK - success
16010 * RFAILED - failure
16012 * ****************************************************************/
16013 uint8_t BuildAndSendUeContextModRsp(DuUeCb *ueCb)
16015 uint8_t ieIdx = 0, tnlIdx = 0, rbIdx = 0;
16016 uint8_t elementCnt = 0;
16017 uint8_t ret = RFAILED;
16018 F1AP_PDU_t *f1apMsg = NULLP;
16019 asn_enc_rval_t encRetVal;
16020 UEContextModificationResponse_t *ueContextModifyRes = NULLP;
16022 DU_LOG("\nINFO --> F1AP : Building UE context modification response\n");
16026 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
16027 if(f1apMsg == NULLP)
16029 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed Ue context modification");
16033 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
16035 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
16036 if(f1apMsg->choice.successfulOutcome == NULLP)
16038 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed Ue context modification");
16041 f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_UEContextModification;
16042 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
16043 f1apMsg->choice.successfulOutcome->value.present = SuccessfulOutcome__value_PR_UEContextModificationResponse;
16045 ueContextModifyRes =&f1apMsg->choice.successfulOutcome->value.choice.UEContextModificationResponse;
16047 if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
16050 if(ueCb->f1UeDb->duUeCfg.numDrbSetupMod)
16052 if(ueCb->f1UeDb->duUeCfg.numDrbModified)
16055 if(ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY)
16059 if(ueCb->f1UeDb->actionType == UE_CTXT_RRC_RECFG_COMPLETE)
16061 ueContextModifyRes->protocolIEs.list.count = elementCnt;
16062 ueContextModifyRes->protocolIEs.list.size = elementCnt*sizeof(UEContextModificationResponse_t*);
16064 /* Initialize the UE context modification members */
16065 DU_ALLOC(ueContextModifyRes->protocolIEs.list.array, ueContextModifyRes->protocolIEs.list.size);
16066 if(ueContextModifyRes->protocolIEs.list.array == NULLP)
16068 DU_LOG("\nERROR --> F1AP : Memory allocation for UE context modifcation Request failed");
16072 for(ieIdx=0 ; ieIdx<elementCnt; ieIdx++)
16074 DU_ALLOC(ueContextModifyRes->protocolIEs.list.array[ieIdx], sizeof(UEContextModificationResponse_t));
16075 if(ueContextModifyRes->protocolIEs.list.array[ieIdx] == NULLP)
16077 DU_LOG("\nERROR --> F1AP : Memory allocation for UE context modifcation Request failed");
16083 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
16084 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
16085 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present =\
16086 UEContextModificationResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
16087 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID = ueCb->gnbCuUeF1apId;
16090 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
16091 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
16092 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present=\
16093 UEContextModificationResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
16094 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID = ueCb->gnbDuUeF1apId;
16096 if(ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY)
16099 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DUtoCURRCInformation;
16100 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
16101 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present = \
16102 UEContextModificationResponseIEs__value_PR_DUtoCURRCInformation;
16103 BuildCellGroupConfigRrc(ueCb, &ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCInformation.cellGroupConfig);
16106 if((ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY) || \
16107 ((ueCb->f1UeDb->actionType == UE_CTXT_MOD) && (ueCb->f1UeDb->duUeCfg.numDrbSetupMod)))
16110 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DRBs_SetupMod_List;
16111 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
16112 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present =\
16113 UEContextModificationResponseIEs__value_PR_DRBs_SetupMod_List;
16114 if(ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY)
16116 for(tnlIdx = 0; tnlIdx < duCb.numTeId; tnlIdx++)
16118 if(duCb.upTnlCfg[tnlIdx]->ueId == ueCb->gnbDuUeF1apId)
16120 memcpy(&ueCb->f1UeDb->duUeCfg.upTnlInfo[ueCb->f1UeDb->duUeCfg.numDrbSetupMod++], duCb.upTnlCfg[tnlIdx], sizeof(UpTnlCfg));
16124 ret = BuildDrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
16125 value.choice.DRBs_SetupMod_List) , &ueCb->f1UeDb->duUeCfg);
16128 DU_LOG( "\nERROR --> F1AP : Failed to build DRB setupmod List ");
16133 if((ueCb->f1UeDb->actionType == UE_CTXT_MOD) && (ueCb->f1UeDb->duUeCfg.numDrbModified))
16136 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DRBs_Modified_List;
16137 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
16138 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present =\
16139 UEContextModificationResponseIEs__value_PR_DRBs_Modified_List;
16140 ret = BuildDrbModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
16141 value.choice.DRBs_Modified_List) , &ueCb->f1UeDb->duUeCfg);
16144 DU_LOG( "\nERROR --> F1AP : Failed to build DRB Modified List ");
16149 if(ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY)
16152 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_SRBs_SetupMod_List;
16153 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
16154 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present = \
16155 UEContextModificationResponseIEs__value_PR_SRBs_SetupMod_List;
16156 for(rbIdx = 0; rbIdx < ueCb->duRlcUeCfg.numLcs; rbIdx++)
16158 if(ueCb->duRlcUeCfg.rlcLcCfg[rbIdx].rlcBearerCfg.rbType == RB_TYPE_SRB)
16160 memcpy(&ueCb->f1UeDb->duUeCfg.rlcLcCfg[ueCb->f1UeDb->duUeCfg.numRlcLcs++], &ueCb->duRlcUeCfg.rlcLcCfg[rbIdx],\
16161 sizeof(DuRlcBearerCfg));
16164 ret = BuildSrbSetupModList(&ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.SRBs_SetupMod_List, \
16165 &ueCb->f1UeDb->duUeCfg);
16168 DU_LOG( "\nERROR --> F1AP : Failed to build SRB setupmod List ");
16173 freeF1UeDb(ueCb->f1UeDb);
16174 ueCb->f1UeDb = NULLP;
16176 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
16178 /* Encode the F1SetupRequest type as APER */
16179 memset(encBuf, 0, ENC_BUF_MAX_LEN);
16181 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,encBuf);
16183 /* Encode results */
16184 if(encRetVal.encoded == ENCODE_FAIL)
16186 DU_LOG( "\nERROR --> F1AP : Could not encode UE Modification Response structure (at %s)\n",\
16187 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
16193 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UE Context Modification Response\n");
16194 #ifdef DEBUG_ASN_PRINT
16195 for(int i=0; i< encBufSize; i++)
16197 printf("%x",encBuf[i]);
16203 if(sendF1APMsg() != ROK && (ret == ROK))
16205 DU_LOG("\nERROR --> F1AP : Sending UE Modification Res Failed");
16213 FreeUeContextModResp(f1apMsg);
16217 /*******************************************************************
16219 * @brief Deallocating the memory allocated by the aper decoder
16224 * Function : freeAperDecodeQosInfo
16226 * Functionality: Deallocating the memory allocated for QOSInfo
16228 * @params[in] QoSFlowLevelQoSParameters_t *drbQos
16232 * ****************************************************************/
16234 void freeAperDecodeQosInfo(QoSFlowLevelQoSParameters_t *drbQos)
16236 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI != NULLP)
16238 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
16240 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
16242 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
16244 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
16246 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI);
16249 /*******************************************************************
16251 * @brief Deallocating the memory allocated by the aper decoder
16252 * for UlTnlInfoforDrb
16256 * Function : freeAperDecodeUlTnlInfoforDrbSetupMod
16258 * Functionality: Deallocating memory allocated for UlTnlInfoforDrb
16260 * @params[in] ULUPTNLInformation_ToBeSetup_List_t *ulInfo
16264 * ****************************************************************/
16265 void freeAperDecodeUlTnlInfoforDrbSetupMod(ULUPTNLInformation_ToBeSetup_List_t *ulInfo)
16269 if(ulInfo->list.array)
16271 for(arrIdx=0; arrIdx<ulInfo->list.count ; arrIdx++)
16273 if(ulInfo->list.array[arrIdx])
16275 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel )
16277 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.buf)
16279 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf)
16281 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\
16284 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\
16285 transportLayerAddress.buf);
16287 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel);
16289 free(ulInfo->list.array[arrIdx]);
16292 free(ulInfo->list.array);
16296 /*******************************************************************
16298 * @brief Deallocating the memory allocated by the aper decoder
16299 * for DrbSetupModItem
16303 * Function : freeAperDecodeDrbSetupModItem
16305 * Functionality: Deallocating memory allocated for DrbSetupModItem
16307 * @params[in] DRBs_ToBeSetupMod_Item_t *drbItem
16311 * ****************************************************************/
16313 void freeAperDecodeDrbSetupModItem(DRBs_ToBeSetupMod_Item_t *drbItem)
16316 SNSSAI_t *snssai =NULLP;
16317 Flows_Mapped_To_DRB_List_t *flowMap = NULLP;
16319 drbItem->qoSInformation.present = QoSInformation_PR_choice_extension;
16320 switch(drbItem->qoSInformation.present)
16322 case QoSInformation_PR_NOTHING:
16324 case QoSInformation_PR_eUTRANQoS:
16326 if(drbItem->qoSInformation.choice.eUTRANQoS)
16328 free(drbItem->qoSInformation.choice.eUTRANQoS);
16332 case QoSInformation_PR_choice_extension:
16334 if(drbItem->qoSInformation.choice.choice_extension)
16336 freeAperDecodeQosInfo(&drbItem->qoSInformation.choice.choice_extension->value.choice.\
16337 DRB_Information.dRB_QoS);
16338 snssai = &drbItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI;
16339 if(snssai->sST.buf)
16341 free(snssai->sST.buf);
16345 if(snssai->sD->buf)
16347 free(snssai->sD->buf);
16352 flowMap = &drbItem->qoSInformation.choice.choice_extension->value.choice.\
16353 DRB_Information.flows_Mapped_To_DRB_List;
16354 if(flowMap->list.array)
16356 for(arrIdx=0; arrIdx<flowMap->list.count; arrIdx++)
16358 if(flowMap->list.array[arrIdx] )
16360 freeAperDecodeQosInfo(&flowMap->list.array[arrIdx]->qoSFlowLevelQoSParameters);
16361 free(flowMap->list.array[arrIdx]);
16364 free(flowMap->list.array);
16367 free(drbItem->qoSInformation.choice.choice_extension);
16373 freeAperDecodeUlTnlInfoforDrbSetupMod(&drbItem->uLUPTNLInformation_ToBeSetup_List);
16374 if(drbItem->uLConfiguration)
16376 free(drbItem->uLConfiguration);
16380 /*******************************************************************
16382 * @brief Deallocating the memory allocated by the aper decoder
16383 * for DrbToBeSetupModList
16387 * Function : freeAperDecodeDrbToBeSetupModList
16389 * Functionality: Deallocating memory allocated for DrbToBeSetupModList
16391 * @params[in] DRBs_ToBeSetupMod_List_t *drbSet
16395 * ****************************************************************/
16397 void freeAperDecodeDrbToBeSetupModList(DRBs_ToBeSetupMod_List_t *drbSet)
16400 struct DRBs_ToBeSetupMod_ItemIEs *drbItemIe;
16402 if(drbSet->list.array)
16404 for(arrIdx=0; arrIdx<drbSet->list.count ; arrIdx++)
16406 if(drbSet->list.array[arrIdx] != NULLP)
16410 drbItemIe = (DRBs_ToBeSetupMod_ItemIEs_t *)drbSet->list.array[arrIdx];
16411 freeAperDecodeDrbSetupModItem(&(drbItemIe->value.choice.DRBs_ToBeSetupMod_Item));
16413 free(drbSet->list.array[arrIdx]);
16416 free(drbSet->list.array);
16421 /*******************************************************************
16423 * @brief Deallocating the memory allocated by the aper decoder
16424 * for DrbSetupModItem
16428 * Function : freeAperDecodeDrbModifiedItem
16430 * Functionality: Deallocating memory allocated for DrbModifedItem
16432 * @params[in] DRBs_ToBeModified_Item_t *drbItem
16436 * ****************************************************************/
16438 void freeAperDecodeDrbModifiedItem(DRBs_ToBeModified_Item_t *drbItem)
16441 SNSSAI_t *snssai =NULLP;
16442 Flows_Mapped_To_DRB_List_t *flowMap = NULLP;
16444 if(drbItem->qoSInformation != NULLP)
16446 drbItem->qoSInformation->present = QoSInformation_PR_choice_extension;
16447 switch(drbItem->qoSInformation->present)
16449 case QoSInformation_PR_NOTHING:
16451 case QoSInformation_PR_eUTRANQoS:
16453 if(drbItem->qoSInformation->choice.eUTRANQoS)
16455 free(drbItem->qoSInformation->choice.eUTRANQoS);
16459 case QoSInformation_PR_choice_extension:
16461 if(drbItem->qoSInformation->choice.choice_extension)
16463 freeAperDecodeQosInfo(&drbItem->qoSInformation->choice.choice_extension->value.choice.\
16464 DRB_Information.dRB_QoS);
16465 snssai = &drbItem->qoSInformation->choice.choice_extension->value.choice.DRB_Information.sNSSAI;
16466 if(snssai->sST.buf)
16468 free(snssai->sST.buf);
16472 if(snssai->sD->buf)
16474 free(snssai->sD->buf);
16479 flowMap = &drbItem->qoSInformation->choice.choice_extension->value.choice.\
16480 DRB_Information.flows_Mapped_To_DRB_List;
16481 if(flowMap->list.array)
16483 for(arrIdx=0; arrIdx<flowMap->list.count; arrIdx++)
16485 if(flowMap->list.array[arrIdx] )
16487 freeAperDecodeQosInfo(&flowMap->list.array[arrIdx]->qoSFlowLevelQoSParameters);
16488 free(flowMap->list.array[arrIdx]);
16491 free(flowMap->list.array);
16494 free(drbItem->qoSInformation->choice.choice_extension);
16499 free(drbItem->qoSInformation);
16501 freeAperDecodeUlTnlInfoforDrbSetupMod(&drbItem->uLUPTNLInformation_ToBeSetup_List);
16502 if(drbItem->uLConfiguration)
16504 free(drbItem->uLConfiguration);
16508 /*******************************************************************
16510 * @brief Deallocating the memory allocated by the aper decoder
16511 * for DrbToBeSetupModList
16515 * Function : freeAperDecodeDrbToBeModifiedList
16517 * Functionality: Deallocating memory allocated for DrbToBeModifiedList
16519 * @params[in] DRBs_ToBeModified_List_t *drbSet
16523 * ****************************************************************/
16525 void freeAperDecodeDrbToBeModifiedList(DRBs_ToBeModified_List_t *drbSet)
16528 struct DRBs_ToBeModified_ItemIEs *drbItemIe;
16530 if(drbSet->list.array)
16532 for(arrIdx=0; arrIdx<drbSet->list.count ; arrIdx++)
16534 if(drbSet->list.array[arrIdx] != NULLP)
16538 drbItemIe = (DRBs_ToBeModified_ItemIEs_t *)drbSet->list.array[arrIdx];
16539 freeAperDecodeDrbModifiedItem(&(drbItemIe->value.choice.DRBs_ToBeModified_Item));
16541 free(drbSet->list.array[arrIdx]);
16544 free(drbSet->list.array);
16549 /*******************************************************************
16551 * @brief Deallocating the memory allocated by the aper decoder
16552 * for DrbToBeSetupModList
16556 * Function : freeAperDecodeDrbToBeReleasedList
16558 * Functionality: Deallocating memory allocated for DrbToBeReleasedList
16560 * @params[in] DRBs_ToBeReleased_List_t *drbSet
16564 * ****************************************************************/
16566 void freeAperDecodeDrbToBeReleasedList(DRBs_ToBeReleased_List_t *drbSet)
16570 if(drbSet->list.array)
16572 for(arrIdx=0; arrIdx<drbSet->list.count ; arrIdx++)
16574 if(drbSet->list.array[arrIdx] != NULLP)
16576 free(drbSet->list.array[arrIdx]);
16579 free(drbSet->list.array);
16583 /*******************************************************************
16585 * @brief Deallocating the memory allocated by the aper decoder
16586 * for UeContextModificationReqMsg
16590 * Function : freeAperDecodeUeContextModificationReqMsg
16592 * Functionality: Deallocating memory allocated for
16593 * UeContextModificationReqMsg
16595 * @params[in] UEContextModificationRequest_t *UeContextModifyReq
16599 * ****************************************************************/
16600 void freeAperDecodeUeContextModificationReqMsg(UEContextModificationRequest_t *ueContextModifyReq )
16602 uint8_t arrIdx, ieId;
16604 if(ueContextModifyReq->protocolIEs.list.array)
16606 for( arrIdx = 0 ; arrIdx<ueContextModifyReq->protocolIEs.list.count ; arrIdx++)
16608 if(ueContextModifyReq->protocolIEs.list.array[arrIdx])
16610 ieId = ueContextModifyReq->protocolIEs.list.array[arrIdx]->id;
16613 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
16615 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
16617 case ProtocolIE_ID_id_DRBs_ToBeSetupMod_List:
16619 freeAperDecodeDrbToBeSetupModList(&ueContextModifyReq->protocolIEs.list.array[arrIdx]->\
16620 value.choice.DRBs_ToBeSetupMod_List);
16623 case ProtocolIE_ID_id_DRBs_ToBeModified_List:
16625 freeAperDecodeDrbToBeModifiedList(&ueContextModifyReq->protocolIEs.list.array[arrIdx]->\
16626 value.choice.DRBs_ToBeModified_List);
16629 case ProtocolIE_ID_id_DRBs_ToBeReleased_List:
16631 freeAperDecodeDrbToBeReleasedList(&ueContextModifyReq->protocolIEs.list.array[arrIdx]->\
16632 value.choice.DRBs_ToBeReleased_List);
16635 case ProtocolIE_ID_id_TransmissionActionIndicator:
16637 case ProtocolIE_ID_id_RRCContainer:
16639 free(ueContextModifyReq->protocolIEs.list.array[arrIdx]->value.choice.RRCContainer.buf);
16642 free(ueContextModifyReq->protocolIEs.list.array[arrIdx]);
16645 free(ueContextModifyReq->protocolIEs.list.array);
16648 /*******************************************************************
16650 * @brief processing the F1 UeContextModificationReq
16654 * Function : procF1UeContextModificationReq
16656 * Functionality: processing the F1 UeContextModificationReq
16658 * @params[in] F1AP_PDU_t *f1apMsg
16661 * ****************************************************************/
16662 uint8_t procF1UeContextModificationReq(F1AP_PDU_t *f1apMsg)
16664 UEContextModificationRequest_t *ueContextModifyReq = NULLP;
16665 uint8_t ret = ROK, ieIdx = 0, cellIdx=0;
16666 DuUeCb *duUeCb = NULLP;
16667 DRBs_ToBeSetupMod_List_t *drbSetupModCfg = NULLP;
16668 DRBs_ToBeModified_List_t *drbModifiedCfg = NULLP;
16669 DRBs_ToBeReleased_List_t *drbToRelease = NULLP;
16670 uint32_t gnbCuUeF1apId, gnbDuUeF1apId;
16672 ueContextModifyReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextModificationRequest;
16673 for(ieIdx=0; (ieIdx < ueContextModifyReq->protocolIEs.list.count && ret == ROK); ieIdx++)
16675 switch(ueContextModifyReq->protocolIEs.list.array[ieIdx]->id)
16677 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
16679 gnbCuUeF1apId = ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID;
16682 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
16684 gnbDuUeF1apId = ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID;
16685 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
16687 if(duCb.actvCellLst[cellIdx])
16689 if((duCb.actvCellLst[cellIdx]->ueCb[gnbDuUeF1apId-1].gnbDuUeF1apId == gnbDuUeF1apId)&&\
16690 (duCb.actvCellLst[cellIdx]->ueCb[gnbDuUeF1apId-1].gnbCuUeF1apId == gnbCuUeF1apId))
16692 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[gnbDuUeF1apId-1];
16693 if(duUeCb->f1UeDb == NULLP)
16695 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
16696 duUeCb->f1UeDb->cellIdx = cellIdx;
16697 duUeCb->f1UeDb->actionType = UE_CTXT_MOD;
16703 if(duUeCb == NULLP)
16705 DU_LOG("\nERROR --> DU APP : wrong values of gnbCuUeF1apId and gnbDuUeF1apId ");
16711 case ProtocolIE_ID_id_RRCContainer:
16713 /* Filling Dl RRC Msg Info */
16714 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
16715 if(!duUeCb->f1UeDb->dlRrcMsg)
16717 DU_LOG("\nERROR --> DU APP : procF1UeContextReleaseCommand(): \
16718 Memory allocation failed ");
16723 duUeCb->f1UeDb->dlRrcMsgPres = true;
16724 memset(duUeCb->f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
16725 ret = extractDlRrcMsg(gnbDuUeF1apId, gnbCuUeF1apId, duUeCb->f1UeDb->dlRrcMsg,\
16726 &ueContextModifyReq->protocolIEs.list.array[ieIdx]->\
16727 value.choice.RRCContainer);
16733 case ProtocolIE_ID_id_DRBs_ToBeSetupMod_List:
16734 case ProtocolIE_ID_id_DRBs_ToBeModified_List:
16735 case ProtocolIE_ID_id_DRBs_ToBeReleased_List:
16739 /*DRBs to be Added*/
16740 if(ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.present ==\
16741 UEContextModificationRequestIEs__value_PR_DRBs_ToBeSetupMod_List)
16743 drbSetupModCfg = &ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.\
16744 choice.DRBs_ToBeSetupMod_List;
16746 if(extractDrbListToSetupMod(NULL, drbSetupModCfg, NULL, drbSetupModCfg->list.count,\
16747 &duUeCb->f1UeDb->duUeCfg, &duUeCb->drbBitMap, NULL))
16749 DU_LOG("\nERROR --> DU APP : Failed at extractDrbListToSetupMod() for DrbSetupModList");
16754 /*DRBs to be Modified*/
16755 if(ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.present == \
16756 UEContextModificationRequestIEs__value_PR_DRBs_ToBeModified_List)
16759 drbModifiedCfg = &ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.\
16760 choice.DRBs_ToBeModified_List;
16761 if(extractDrbListToSetupMod(NULL, NULL, drbModifiedCfg, drbModifiedCfg->list.count,\
16762 &duUeCb->f1UeDb->duUeCfg, &duUeCb->drbBitMap, &duUeCb->duRlcUeCfg))
16764 DU_LOG("\nERROR --> DU APP : Failed at extractDrbListToSetupMod() for DrbModifiedList");
16768 /*DRBs to be Released*/
16769 if(ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.present == \
16770 UEContextModificationRequestIEs__value_PR_DRBs_ToBeReleased_List)
16773 drbToRelease = &ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.\
16774 choice.DRBs_ToBeReleased_List;
16775 if(extractDrbListToRelease(gnbDuUeF1apId, drbToRelease, drbToRelease->list.count,\
16776 &duUeCb->f1UeDb->duUeCfg, &duUeCb->duRlcUeCfg))
16778 DU_LOG("\nERROR --> DU APP : Failed at extractDrbListToSetupMod() for DrbModifiedList");
16786 case ProtocolIE_ID_id_GNB_DUConfigurationQuery:
16788 DU_LOG("\nINFO --> DU APP : Received GNB DU Configuration Query in UE Context Modification Request from CU");
16791 duUeCb->f1UeDb->actionType = UE_CTXT_CFG_QUERY;
16796 case ProtocolIE_ID_id_RRCReconfigurationCompleteIndicator:
16798 if(ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.RRCReconfigurationCompleteIndicator == \
16799 RRCReconfigurationCompleteIndicator_true)
16801 duUeCb->f1UeDb->actionType = UE_CTXT_RRC_RECFG_COMPLETE;
16805 case ProtocolIE_ID_id_TransmissionActionIndicator:
16809 if(ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.TransmissionActionIndicator == TransmissionActionIndicator_stop)
16811 duUeCb->f1UeDb->duUeCfg.dataTransmissionAction = STOP_TRANSMISSION;
16815 duUeCb->f1UeDb->duUeCfg.dataTransmissionAction = RESTART_TRANSMISSION;
16821 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
16823 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
16825 duUeCb->f1UeDb->dlRrcMsg->deliveryStatRpt = true;
16830 case ProtocolIE_ID_id_DRXConfigurationIndicator:
16832 duUeCb->f1UeDb->duUeCfg.drxConfigIndicatorRelease = true;
16842 ret = duProcUeContextModReq(duUeCb);
16844 freeAperDecodeUeContextModificationReqMsg(ueContextModifyReq);
16848 /*****************************************************************i
16850 * @brief Free memory allocated for UE Context Release Request
16854 * Function : FreeUeContextReleaseReq
16857 * - Free memory allocated for UE Context Release Request
16859 * @params[in] F1AP_PDU_t *f1apMsg
16862 * *************************************************************/
16863 void FreeUeContextReleaseReq(F1AP_PDU_t *f1apMsg)
16866 UEContextReleaseRequest_t *ueReleaseReq = NULLP;
16870 if(f1apMsg->choice.initiatingMessage)
16872 ueReleaseReq =&f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseRequest;
16873 if(ueReleaseReq->protocolIEs.list.array)
16875 for(ieIdx=0 ; ieIdx<ueReleaseReq->protocolIEs.list.count; ieIdx++)
16877 DU_FREE(ueReleaseReq->protocolIEs.list.array[ieIdx], sizeof(UEContextReleaseRequest_t));
16879 DU_FREE(ueReleaseReq->protocolIEs.list.array, ueReleaseReq->protocolIEs.list.size);
16881 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
16883 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
16887 /*****************************************************************i
16889 * @brief Build and Send UE Context Release Request
16893 * Function : BuildAndSendUeContextReleaseReq
16896 * - Build and Send UE Context Release Request
16899 * @return ROK - success
16900 * RFAILED - failure
16902 * *************************************************************/
16903 uint8_t BuildAndSendUeContextReleaseReq(uint16_t cellId, uint8_t ueId)
16905 bool memAllocFail = false;
16907 uint8_t ret = RFAILED;
16908 uint16_t cellIdx =0;
16909 uint16_t crnti = 0;
16910 uint8_t elementCnt = 0;
16911 uint32_t gnbCuUeF1apId =0; /* gNB-CU UE F1AP Id */
16912 uint32_t gnbDuUeF1apId =0; /* gNB-DU UE F1AP Id */
16913 asn_enc_rval_t encRetVal;
16914 F1AP_PDU_t *f1apMsg = NULLP;
16915 UEContextReleaseRequest_t *ueReleaseReq = NULLP;
16917 DU_LOG("\nINFO --> Building the UE Context Release Request");
16920 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
16921 if(f1apMsg == NULLP)
16923 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for f1apMsg");
16927 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
16928 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
16929 if(f1apMsg->choice.initiatingMessage == NULLP)
16931 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for\
16932 initiatingMessage");
16935 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_UEContextReleaseRequest;
16936 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
16937 f1apMsg->choice.initiatingMessage->value.present = \
16938 InitiatingMessage__value_PR_UEContextReleaseRequest;
16940 ueReleaseReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseRequest;
16944 ueReleaseReq->protocolIEs.list.count = elementCnt;
16945 ueReleaseReq->protocolIEs.list.size = elementCnt * sizeof(UEContextReleaseRequest_t *);
16947 /* Initialize the F1Setup members */
16948 DU_ALLOC(ueReleaseReq->protocolIEs.list.array,ueReleaseReq->protocolIEs.list.size);
16949 if(ueReleaseReq->protocolIEs.list.array == NULLP)
16951 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for IE array");
16954 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
16956 DU_ALLOC(ueReleaseReq->protocolIEs.list.array[ieIdx],\
16957 sizeof(UEContextReleaseRequest_t));
16958 if(ueReleaseReq->protocolIEs.list.array[ieIdx] == NULLP)
16960 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for IE elements");
16961 memAllocFail = true;
16965 if(memAllocFail == true)
16968 /* Fetching Ue Cb Info*/
16969 GET_CELL_IDX(cellId, cellIdx);
16970 if(duCb.actvCellLst[cellIdx] == NULLP)
16972 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): CellId[%d] does not exist", cellId);
16977 GET_CRNTI(crnti, ueId);
16978 if(duCb.actvCellLst[cellIdx]->ueCb[ueId-1].crnti != crnti)
16980 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): crnti[%d] does not exist", crnti);
16983 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
16984 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
16988 ueReleaseReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
16989 ueReleaseReq->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
16990 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.present = \
16991 UEContextReleaseRequestIEs__value_PR_GNB_CU_UE_F1AP_ID;
16992 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID =gnbCuUeF1apId;
16995 ueReleaseReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
16996 ueReleaseReq->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
16997 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.present =\
16998 UEContextReleaseRequestIEs__value_PR_GNB_DU_UE_F1AP_ID;
16999 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID =gnbDuUeF1apId;
17001 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
17003 /* Encode the F1SetupRequest type as APER */
17004 memset(encBuf, 0, ENC_BUF_MAX_LEN);
17006 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
17007 /* Encode results */
17008 if(encRetVal.encoded == ENCODE_FAIL)
17010 DU_LOG("\nERROR --> F1AP : Could not encode UEContextReleaseRequest structure (at %s)\n",\
17011 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
17016 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UEContextReleaseRequest\n");
17017 #ifdef DEBUG_ASN_PRINT
17018 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
17020 printf("%x",encBuf[ieIdx]);
17026 if(sendF1APMsg() != ROK)
17028 DU_LOG("\nERROR --> F1AP : Sending UE Context Release Request failed");
17035 FreeUeContextReleaseReq(f1apMsg);
17038 /*****************************************************************i
17040 * @brief Free memory allocated for UE Context Release Complete
17044 * Function : FreeUeContextReleaseComplete
17047 * - Free memory allocated for UE Context Release Complete
17049 * @params[in] F1AP_PDU_t *f1apMsg
17052 * *************************************************************/
17053 void FreeUeContextReleaseComplete(F1AP_PDU_t *f1apMsg)
17056 UEContextReleaseComplete_t *ueReleaseComplete = NULLP;
17060 if(f1apMsg->choice.successfulOutcome)
17062 ueReleaseComplete =&f1apMsg->choice.successfulOutcome->value.choice.UEContextReleaseComplete;
17063 if(ueReleaseComplete->protocolIEs.list.array)
17065 for(ieIdx=0 ; ieIdx<ueReleaseComplete->protocolIEs.list.count; ieIdx++)
17067 DU_FREE(ueReleaseComplete->protocolIEs.list.array[ieIdx], sizeof(UEContextReleaseComplete_t));
17069 DU_FREE(ueReleaseComplete->protocolIEs.list.array, ueReleaseComplete->protocolIEs.list.size);
17071 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
17073 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
17077 /*****************************************************************i
17079 * @brief Build and Send UE Context Release Complete
17083 * Function : BuildAndSendUeContextReleaseComplete
17086 * - Build and Send UE Context Release Complete
17088 * @params[in] cellId, gnbCuUeF1apId, gnbDuUeF1apId
17089 * @return ROK - success
17090 * RFAILED - failure
17092 * *************************************************************/
17093 uint8_t BuildAndSendUeContextReleaseComplete(uint16_t cellId, uint32_t gnbCuUeF1apId, uint32_t gnbDuUeF1apId)
17095 bool memAllocFail = false;
17096 uint8_t ieIdx =0, ret = RFAILED, elementCnt = 0;
17097 asn_enc_rval_t encRetVal;
17098 F1AP_PDU_t *f1apMsg = NULLP;
17099 UEContextReleaseComplete_t *ueReleaseComplete = NULLP;
17101 DU_LOG("\nINFO --> Building the UE Context Release Complete");
17104 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
17105 if(f1apMsg == NULLP)
17107 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for f1apMsg");
17111 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
17112 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
17113 if(f1apMsg->choice.successfulOutcome == NULLP)
17115 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for\
17116 successfulOutcome");
17119 f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_UEContextRelease;
17120 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
17121 f1apMsg->choice.successfulOutcome->value.present = \
17122 SuccessfulOutcome__value_PR_UEContextReleaseComplete;
17124 ueReleaseComplete = &f1apMsg->choice.successfulOutcome->value.choice.UEContextReleaseComplete;
17127 ueReleaseComplete->protocolIEs.list.count = elementCnt;
17128 ueReleaseComplete->protocolIEs.list.size = elementCnt * sizeof(UEContextReleaseComplete_t *);
17130 /* Initialize the UE Release Complete members */
17131 DU_ALLOC(ueReleaseComplete->protocolIEs.list.array,ueReleaseComplete->protocolIEs.list.size);
17132 if(ueReleaseComplete->protocolIEs.list.array == NULLP)
17134 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for IE array");
17137 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
17139 DU_ALLOC(ueReleaseComplete->protocolIEs.list.array[ieIdx],\
17140 sizeof(UEContextReleaseComplete_t));
17141 if(ueReleaseComplete->protocolIEs.list.array[ieIdx] == NULLP)
17143 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for IE\
17145 memAllocFail = true;
17149 if(memAllocFail == true)
17154 ueReleaseComplete->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
17155 ueReleaseComplete->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
17156 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.present = \
17157 UEContextReleaseCompleteIEs__value_PR_GNB_CU_UE_F1AP_ID;
17158 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID =gnbCuUeF1apId;
17161 ueReleaseComplete->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
17162 ueReleaseComplete->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
17163 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.present =\
17164 UEContextReleaseCompleteIEs__value_PR_GNB_DU_UE_F1AP_ID;
17165 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID =gnbDuUeF1apId;
17167 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
17169 /* Encode the F1SetupComplete type as APER */
17170 memset(encBuf, 0, ENC_BUF_MAX_LEN);
17172 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
17173 /* Encode results */
17174 if(encRetVal.encoded == ENCODE_FAIL)
17176 DU_LOG("\nERROR --> F1AP : Could not encode UEContextReleaseComplete structure (at %s)\n",\
17177 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
17182 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UEContextReleaseComplete\n");
17183 #ifdef DEBUG_ASN_PRINT
17184 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
17186 printf("%x",encBuf[ieIdx]);
17192 if(sendF1APMsg() != ROK)
17194 DU_LOG("\nERROR --> F1AP : Sending UE Context Release Complete failed");
17201 if((ret == ROK) && (duCb.actvCellLst[cellId-1]) && (duCb.actvCellLst[cellId-1]->cellStatus == DELETION_IN_PROGRESS)
17202 && (duCb.actvCellLst[cellId-1]->numActvUes == 0))
17204 ret = duSendCellDeletReq(cellId);
17207 DU_LOG("\nERROR --> F1AP: BuildAndSendUeContextReleaseComplete(): Failed to process cell\
17208 Delete req for CellId");
17211 FreeUeContextReleaseComplete(f1apMsg);
17216 /*******************************************************************
17218 * @brief added free part for the memory allocated by aper_decoder
17222 * Function : freeAperDecodeUeContextReleaseCommand
17224 * Functionality: added free part for the memory allocated by aper_decoder
17226 * @params[in] F1AP_PDU_t *f1apMsg
17229 * ****************************************************************/
17230 void freeAperDecodeUeContextReleaseCommand(F1AP_PDU_t *f1apMsg)
17233 UEContextReleaseCommand_t *ueContextReleaseCommand = NULLP;
17235 ueContextReleaseCommand = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseCommand;
17237 if(ueContextReleaseCommand->protocolIEs.list.array)
17239 for(ieIdx=0; ieIdx < ueContextReleaseCommand->protocolIEs.list.count; ieIdx++)
17241 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx])
17243 switch(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id)
17245 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
17247 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
17249 case ProtocolIE_ID_id_Cause:
17251 case ProtocolIE_ID_id_RRCContainer:
17253 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
17255 free(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf);
17260 DU_LOG("\nERROR --> F1AP: freeAperDecodeUeContextReleaseCommand():Invalid IE Received: %ld"\
17261 ,ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id);
17265 free(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]);
17267 free(ueContextReleaseCommand->protocolIEs.list.array);
17270 /*******************************************************************
17272 * @brief processing of UE Context Release Command
17276 * Function : procF1UeContextReleaseCommand
17278 * Functionality: processing of UE Context Release Command
17280 * @params[in] F1AP_PDU_t *f1apMsg
17283 * ****************************************************************/
17284 uint8_t procF1UeContextReleaseCommand(F1AP_PDU_t *f1apMsg)
17286 uint8_t ieIdx=0, ret=ROK, ueIdx=0;
17287 uint16_t cellIdx =0, cellId = 0;
17288 bool ueIdxFound = false;
17289 uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId=0;
17290 DuUeCb *duUeCb = NULLP;
17291 UEContextReleaseCommand_t *ueContextReleaseCommand = NULLP;
17293 ueContextReleaseCommand = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseCommand;
17295 if(ueContextReleaseCommand->protocolIEs.list.array)
17297 for(ieIdx=0; ieIdx < ueContextReleaseCommand->protocolIEs.list.count; ieIdx++)
17299 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx])
17301 switch(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id)
17303 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
17305 gnbCuUeF1apId= ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
17306 value.choice.GNB_CU_UE_F1AP_ID;
17310 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
17312 gnbDuUeF1apId = ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
17313 value.choice.GNB_DU_UE_F1AP_ID;
17317 case ProtocolIE_ID_id_Cause:
17319 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
17321 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
17323 if(duCb.actvCellLst[cellIdx] && (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
17324 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
17326 cellId = duCb.actvCellLst[cellIdx]->cellId;
17327 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
17332 if(ueIdxFound == true)
17340 DU_LOG("\nERROR --> F1AP: procF1UeContextReleaseCommand(): Ue Information is not available");
17346 case ProtocolIE_ID_id_RRCContainer:
17348 if(ueIdxFound == true)
17350 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
17353 memset(duUeCb->f1UeDb, 0, sizeof(F1UeContextSetupDb));
17354 duUeCb->f1UeDb->actionType = UE_CTXT_RELEASE;
17355 duUeCb->f1UeDb->cellIdx = cellIdx;
17356 /* Filling Dl RRC Msg Info */
17357 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
17358 if(!duUeCb->f1UeDb->dlRrcMsg)
17360 DU_LOG("\nERROR --> DU APP : procF1UeContextReleaseCommand(): \
17361 Memory allocation failed ");
17366 duUeCb->f1UeDb->dlRrcMsgPres = true;
17367 memset(duUeCb->f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
17368 ret = extractDlRrcMsg(gnbDuUeF1apId, gnbCuUeF1apId, duUeCb->f1UeDb->dlRrcMsg,\
17369 &ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
17370 value.choice.RRCContainer);
17376 DU_LOG("\nERROR --> DU APP : procF1UeContextReleaseCommand(): \
17377 Memory allocation failed ");
17385 DU_LOG("\nERROR --> F1AP: freeAperDecodeUeContextReleaseCommand():Invalid IE Received: %ld"\
17386 ,ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id);
17394 duProcUeContextReleaseCommand(cellId, duUeCb);
17396 freeAperDecodeUeContextReleaseCommand(f1apMsg);
17400 /**************************************************************
17402 * @brief free the memory allocated by aper decoder for paging
17406 * Function : freeAperDecodePagingMsg
17409 * - free the memory allocated by aper decoder for
17410 * the paging f1ap msg
17412 * @params[in] Paging_t *paging
17413 * @return ROK - success
17414 * RFAILED - failure
17416 ****************************************************************/
17417 void freeAperDecodePagingMsg(Paging_t *paging)
17419 uint8_t ieIdx, cellIdx;
17420 PagingCell_ItemIEs_t *pagingCellItemIes;
17421 PagingCell_Item_t *pagingCellItem;
17422 PagingCell_list_t *pagingCelllist;
17426 if(paging->protocolIEs.list.array)
17428 for(ieIdx=0 ; ieIdx<paging->protocolIEs.list.count; ieIdx++)
17430 if(paging->protocolIEs.list.array[ieIdx])
17432 switch(paging->protocolIEs.list.array[ieIdx]->id)
17434 case ProtocolIE_ID_id_UEIdentityIndexValue:
17436 free(paging->protocolIEs.list.array[ieIdx]->value.choice.UEIdentityIndexValue.choice.indexLength10.buf);
17439 case ProtocolIE_ID_id_PagingIdentity:
17441 if(paging->protocolIEs.list.array[ieIdx]->value.choice.PagingIdentity.present == PagingIdentity_PR_cNUEPagingIdentity)
17443 if(paging->protocolIEs.list.array[ieIdx]->value.choice.PagingIdentity.choice.cNUEPagingIdentity)
17445 if(paging->protocolIEs.list.array[ieIdx]->value.choice.PagingIdentity.choice.cNUEPagingIdentity->present == \
17446 CNUEPagingIdentity_PR_fiveG_S_TMSI)
17448 free(paging->protocolIEs.list.array[ieIdx]->value.choice.PagingIdentity.choice.cNUEPagingIdentity->choice.fiveG_S_TMSI.buf);
17450 free(paging->protocolIEs.list.array[ieIdx]->value.choice.PagingIdentity.choice.cNUEPagingIdentity);
17455 case ProtocolIE_ID_id_PagingCell_List:
17457 pagingCelllist = &paging->protocolIEs.list.array[ieIdx]->value.choice.PagingCell_list;
17458 if(pagingCelllist->list.array)
17460 for(cellIdx = 0; cellIdx < pagingCelllist->list.count; cellIdx++)
17462 if(pagingCelllist->list.array[cellIdx])
17464 pagingCellItemIes = (PagingCell_ItemIEs_t *)pagingCelllist->list.array[cellIdx];
17465 if(pagingCellItemIes->id == ProtocolIE_ID_id_PagingCell_Item)
17467 pagingCellItem = &pagingCellItemIes->value.choice.PagingCell_Item;
17468 free(pagingCellItem->nRCGI.pLMN_Identity.buf);
17469 free(pagingCellItem->nRCGI.nRCellIdentity.buf);
17471 free(pagingCelllist->list.array[cellIdx]);
17474 free(pagingCelllist->list.array);
17479 free(paging->protocolIEs.list.array[ieIdx]);
17482 free(paging->protocolIEs.list.array);
17488 /**************************************************************
17490 * @brief processing the paging f1ap msg received from CU
17494 * Function : procPagingMsg
17497 * - processing the paging f1ap msg received from CU
17499 * @params[in] F1AP_PDU_t *f1apMsg
17500 * @return ROK - success
17501 * RFAILED - failure
17504 ****************************************************************/
17505 uint8_t procPagingMsg(F1AP_PDU_t *f1apMsg)
17507 uint8_t ieIdx = 0, cellListIdx = 0;
17508 uint64_t cellId = 0;
17509 Paging_t *paging = NULLP;
17510 PagingCell_list_t *pagingCelllist = NULLP;
17511 PagingCell_ItemIEs_t *pagingCellItemIes = NULLP;
17512 PagingCell_Item_t *pagingCellItem = NULLP;
17513 DuPagingMsg *tmpPagingParam = NULLP;
17515 paging = &f1apMsg->choice.initiatingMessage->value.choice.Paging;
17518 if(paging->protocolIEs.list.array)
17520 DU_ALLOC(tmpPagingParam, sizeof(DuPagingMsg));
17521 if(tmpPagingParam == NULLP)
17523 DU_LOG("\nERROR --> DU APP : Memory Allocation Failure in procPagingMsg");
17524 freeAperDecodePagingMsg(paging);
17527 for(ieIdx=0 ; ieIdx<paging->protocolIEs.list.count; ieIdx++)
17529 if(paging->protocolIEs.list.array[ieIdx])
17531 switch(paging->protocolIEs.list.array[ieIdx]->id)
17533 case ProtocolIE_ID_id_UEIdentityIndexValue:
17535 bitStringToInt(&paging->protocolIEs.list.array[ieIdx]->value.choice.UEIdentityIndexValue.choice.indexLength10,\
17536 &tmpPagingParam->pagUeId);
17540 case ProtocolIE_ID_id_PagingIdentity:
17542 switch(paging->protocolIEs.list.array[ieIdx]->value.choice.PagingIdentity.present)
17544 case PagingIdentity_PR_cNUEPagingIdentity:
17546 if(paging->protocolIEs.list.array[ieIdx]->value.choice.PagingIdentity.choice.cNUEPagingIdentity)
17548 bitStringToInt(&paging->protocolIEs.list.array[ieIdx]->value.choice.PagingIdentity.choice.\
17549 cNUEPagingIdentity->choice.fiveG_S_TMSI, &tmpPagingParam->sTmsi);
17554 case PagingIdentity_PR_rANUEPagingIdentity:
17556 /*TODO: This Identifier is specific to RAN Initiated Paging – Connected Mode Paging*/
17561 DU_LOG("ERROR --> DU APP: Invalid UE Paging Identity, Skipping this Paging Message:");
17567 case ProtocolIE_ID_id_PagingDRX:
17569 tmpPagingParam->pagingDrxPres = TRUE;
17570 tmpPagingParam->pagingDrx = convertPagingCycleEnumToValue(paging->protocolIEs.list.array[ieIdx]->value.choice.PagingDRX);
17574 case ProtocolIE_ID_id_PagingPriority:
17576 tmpPagingParam->pagPriority = paging->protocolIEs.list.array[ieIdx]->value.choice.PagingPriority;
17580 case ProtocolIE_ID_id_PagingCell_List:
17582 pagingCelllist = &paging->protocolIEs.list.array[ieIdx]->value.choice.PagingCell_list;
17583 if(pagingCelllist->list.array)
17585 for(cellListIdx = 0; cellListIdx < pagingCelllist->list.count; cellListIdx++)
17587 if(pagingCelllist->list.array[cellListIdx])
17589 pagingCellItemIes = (PagingCell_ItemIEs_t *)pagingCelllist->list.array[cellListIdx];
17590 pagingCellItem = &pagingCellItemIes->value.choice.PagingCell_Item;
17591 bitStringToInt(&pagingCellItem->nRCGI.nRCellIdentity, &cellId);
17592 if(processPagingMsg(cellId, tmpPagingParam) != ROK)
17594 DU_LOG("\nERROR --> DU APP : Paging Processing Failed at CellId:%lu",cellId);
17604 DU_LOG("\nERROR --> F1AP : Incorrect Paging IE option");
17612 DU_FREE(tmpPagingParam, sizeof(DuPagingMsg));
17613 freeAperDecodePagingMsg(paging);
17618 /**************************************************************
17620 * @brief Handles received F1AP message and sends back response
17624 * Function : F1APMsgHdlr
17627 * - Decodes received F1AP control message
17628 * - Prepares response message, encodes and sends to SCTP
17631 * @return ROK - success
17632 * RFAILED - failure
17634 * ****************************************************************/
17635 void F1APMsgHdlr(Buffer *mBuf)
17638 char *recvBuf =NULLP;
17640 MsgLen recvBufLen =0;
17641 F1AP_PDU_t *f1apMsg =NULLP;
17642 asn_dec_rval_t rval; /* Decoder return value */
17643 F1AP_PDU_t f1apasnmsg ;
17644 DU_LOG("\nINFO --> F1AP : Received F1AP message buffer");
17645 ODU_PRINT_MSG(mBuf, 0,0);
17647 /* Copy mBuf into char array to decode it */
17648 ODU_GET_MSG_LEN(mBuf, &recvBufLen);
17649 DU_ALLOC(recvBuf, (Size)recvBufLen);
17651 if(recvBuf == NULLP)
17653 DU_LOG("\nERROR --> F1AP : Memory allocation failed");
17656 if(ODU_COPY_MSG_TO_FIX_BUF(mBuf, 0, recvBufLen, (Data *)recvBuf, ©Cnt) != ROK)
17658 DU_LOG("\nERROR --> F1AP : Failed while copying %d", copyCnt);
17662 #ifdef DEBUG_ASN_PRINT
17663 printf("\nDEBUG --> F1AP : Received flat buffer to be decoded : ");
17664 for(i=0; i< recvBufLen; i++)
17666 printf("%x",recvBuf[i]);
17670 /* Decoding flat buffer into F1AP messsage */
17671 f1apMsg = &f1apasnmsg;
17672 memset(f1apMsg, 0, sizeof(F1AP_PDU_t));
17674 rval = aper_decode(0, &asn_DEF_F1AP_PDU, (void **)&f1apMsg, recvBuf, recvBufLen, 0, 0);
17676 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
17678 DU_LOG("\nERROR --> F1AP : ASN decode failed");
17682 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
17684 switch(f1apMsg->present)
17686 case F1AP_PDU_PR_successfulOutcome:
17688 switch(f1apMsg->choice.successfulOutcome->value.present)
17690 case SuccessfulOutcome__value_PR_ResetAcknowledge:
17692 DU_LOG("\nINFO --> F1AP : F1ResetAcknowledge is received successfully ");
17695 case SuccessfulOutcome__value_PR_F1SetupResponse:
17697 #ifndef ODU_TEST_STUB
17698 procF1SetupRsp(f1apMsg, recvBufLen, recvBuf);
17703 case SuccessfulOutcome__value_PR_GNBDUConfigurationUpdateAcknowledge:
17705 procF1GNBDUCfgUpdAck(f1apMsg);
17711 DU_LOG("\nERROR --> F1AP : Invalid type of SuccessfulOutcome__value_PR_ResetAcknowledge [%d]",\
17712 f1apMsg->choice.successfulOutcome->value.present);
17715 }/* End of switch(successfulOutcome) */
17716 free(f1apMsg->choice.successfulOutcome);
17719 case F1AP_PDU_PR_initiatingMessage:
17721 switch(f1apMsg->choice.initiatingMessage->value.present)
17723 case InitiatingMessage__value_PR_Reset:
17725 procF1ResetReq(f1apMsg);
17728 case InitiatingMessage__value_PR_DLRRCMessageTransfer:
17730 procF1DlRrcMsgTrans(f1apMsg);
17733 case InitiatingMessage__value_PR_UEContextSetupRequest:
17735 procF1UeContextSetupReq(f1apMsg);
17738 case InitiatingMessage__value_PR_UEContextModificationRequest:
17740 procF1UeContextModificationReq(f1apMsg);
17743 case InitiatingMessage__value_PR_UEContextReleaseCommand:
17745 procF1UeContextReleaseCommand(f1apMsg);
17748 case InitiatingMessage__value_PR_Paging:
17750 procPagingMsg(f1apMsg);
17755 DU_LOG("\nERROR --> F1AP : Invalid type of F1AP_PDU_PR_initiatingMessage [%d]",
17756 f1apMsg->choice.initiatingMessage->value.present);
17759 }/* End of switch(initiatingMessage) */
17760 free(f1apMsg->choice.initiatingMessage);
17766 DU_LOG("\nERROR --> F1AP : Invalid type of f1apMsg->present [%d]",f1apMsg->present);
17771 }/* End of switch(f1apMsg->present) */
17773 DU_FREE(recvBuf, (Size)recvBufLen);
17774 } /* End of F1APMsgHdlr */
17776 /**********************************************************************
17778 **********************************************************************/