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 "du_app_mac_inf.h"
33 #include "du_app_rlc_inf.h"
34 #include "du_mgr_main.h"
37 #include "du_ue_mgr.h"
39 #include "FeatureSetUplinkPerCC.h"
40 #include "FeatureSetDownlinkPerCC.h"
41 #include "FeatureSets.h"
42 #include "UE-NR-Capability.h"
43 #include "UE-CapabilityRAT-Container.h"
44 #include "UE-CapabilityRAT-ContainerListRRC.h"
45 #include "GNB-DU-System-Information.h"
46 #include "CellGroupConfigRrc.h"
47 #include "MAC-CellGroupConfig.h"
48 #include "SchedulingRequestConfig.h"
49 #include "SchedulingRequestToAddMod.h"
50 #include "BSR-Config.h"
51 #include "TAG-Config.h"
53 #include "PHR-Config.h"
54 #include "RLC-Config.h"
55 #include "UL-AM-RLC.h"
56 #include "DL-AM-RLC.h"
57 #include "LogicalChannelConfig.h"
58 #include "RLC-BearerConfig.h"
59 #include "PhysicalCellGroupConfig.h"
60 #include "SpCellConfig.h"
61 #include "TDD-UL-DL-ConfigDedicated.h"
62 #include "ServingCellConfig.h"
63 #include "ControlResourceSet.h"
64 #include "SearchSpace.h"
65 #include "PDCCH-Config.h"
66 #include "PDSCH-TimeDomainResourceAllocation.h"
67 #include "PDSCH-TimeDomainResourceAllocationList.h"
68 #include "PDSCH-CodeBlockGroupTransmission.h"
69 #include "PDSCH-ServingCellConfig.h"
70 #include "DMRS-DownlinkConfig.h"
71 #include "PDSCH-Config.h"
72 #include "BWP-DownlinkDedicated.h"
73 #include "BWP-Downlink.h"
74 #include "PUSCH-TimeDomainResourceAllocation.h"
75 #include "PUSCH-TimeDomainResourceAllocationList.h"
76 #include "DMRS-UplinkConfig.h"
77 #include "PUSCH-Config.h"
78 #include "SRS-ResourceId.h"
79 #include "SRS-Resource.h"
80 #include "SRS-ResourceSet.h"
81 #include "SRS-Config.h"
82 #include "BWP-UplinkDedicated.h"
83 #include "PUSCH-ServingCellConfig.h"
84 #include "UplinkConfig.h"
85 #include "DUtoCURRCContainer.h"
86 #include "GBR-QoSFlowInformation.h"
87 #include "QoSFlowLevelQoSParameters.h"
88 #include "PUCCH-Config.h"
89 #include "PUCCH-ResourceSet.h"
90 #include "PUCCH-Resource.h"
91 #include "PUCCH-PowerControl.h"
93 #include "PUCCH-PathlossReferenceRS.h"
94 #include "PUCCH-format0.h"
95 #include "PUCCH-format1.h"
96 #include "PUCCH-format2.h"
97 #include "PUCCH-format3.h"
98 #include "PUCCH-format4.h"
99 #include "PUCCH-FormatConfig.h"
100 #include "SchedulingRequestResourceConfig.h"
101 #include<ProtocolIE-Field.h>
102 #include "ProtocolExtensionField.h"
103 #include "odu_common_codec.h"
105 #include "du_cell_mgr.h"
106 #include "du_f1ap_msg_hdl.h"
107 #include "DRBs-Setup-Item.h"
108 #include "DLUPTNLInformation-ToBeSetup-List.h"
109 #include "DLUPTNLInformation-ToBeSetup-Item.h"
110 #include "UPTransportLayerInformation.h"
111 #include "GTPTunnel.h"
112 #include "SupportedSULFreqBandItem.h"
113 #include "du_e2ap_msg_hdl.h"
114 #include "du_f1ap_conversions.h"
115 #include "CNUEPagingIdentity.h"
116 #include "PCCH-Config.h"
117 #include "SCS-SpecificCarrier.h"
118 #include "FrequencyInfoDL.h"
119 #include "DownlinkConfigCommon.h"
120 #include "FrequencyInfoUL.h"
121 #include "UplinkConfigCommon.h"
122 #include "TDD-UL-DL-ConfigCommon.h"
123 #include "RACH-ConfigDedicated.h"
124 #include "CFRA-SSB-Resource.h"
125 #include "BWP-UplinkCommon.h"
126 #include "ReconfigurationWithSync.h"
127 #include "du_sys_info_hdl.h"
128 #include "DRX-ConfigRrc.h"
131 #include "CmInterface.h"
132 extern StartupConfig g_cfg;
135 DuCfgParams duCfgParam;
137 /******************************************************************
139 * @brief Function to fetch lcId based on DRB Id
143 * Function : fetchLcId
147 * Functionality: Function to fetch lcId based on DRB Id
149 * Returns: lcId - SUCCESS
151 *****************************************************************/
153 uint8_t fetchLcId(uint8_t drbId)
155 uint8_t cellIdx = 0, ueIdx = 0, lcIdx = 0, numLcs = 0, lcId = 0;
157 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
159 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
161 if(duCb.actvCellLst[cellIdx] != NULLP)
163 numLcs = duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg.numLcs;
164 for(lcIdx = 0; lcIdx < numLcs; lcIdx++)
166 if(duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg.rlcLcCfg[lcIdx].rbId == drbId && \
167 duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg.rlcLcCfg[lcIdx].rbType == RB_TYPE_DRB)
169 lcId = duCb.actvCellLst[cellIdx]->ueCb[ueIdx].rlcUeCfg.rlcLcCfg[lcIdx].lcId;
176 DU_LOG("\nERROR --> DU_APP: fetchLcId() failed for drbId %d", drbId);
180 /*******************************************************************
182 * @brief Adding F1AP pdu to reserved pdu list
186 * Function : addToReservedF1apPduList
188 * Functionality: Adding F1AP pdu to reserved pdu list.
189 * These pdu are awaiting aknowledgment from CU
191 * @params[in] uint8_t transId, F1AP_PDU_t *f1apMsg
193 * @return ROK - success
196 * ****************************************************************/
197 void addToReservedF1apPduList(uint8_t transId, F1AP_PDU_t *f1apPdu)
199 CmLList *node = NULLP;
200 ReservedF1apPduInfo *pduInfo = NULLP;
201 DU_ALLOC(pduInfo, sizeof(ReservedF1apPduInfo));
204 DU_ALLOC(node, sizeof(CmLList));
207 pduInfo->transId = transId;
208 pduInfo->f1apMsg = (void*) f1apPdu;
210 node->node = (PTR)pduInfo;
211 cmLListAdd2Tail(&duCb.reservedF1apPduList, node);
216 /*******************************************************************
218 * @brief searching for F1AP pdu from ReservedF1apPduList
222 * Function : searchFromReservedF1apPduList
224 * Functionality: searching for F1AP pdu information
226 * @params[in] uint8_t transId
228 * @return pointer to F1AP_PDU_t
230 * ****************************************************************/
232 CmLList *searchFromReservedF1apPduList(uint8_t transId)
235 ReservedF1apPduInfo *f1apPdu;
236 if(duCb.reservedF1apPduList.count)
238 CM_LLIST_FIRST_NODE(&duCb.reservedF1apPduList, node);
241 f1apPdu = (ReservedF1apPduInfo*)node->node;
242 if(f1apPdu->transId == transId)
252 /*******************************************************************
254 * @brief deleting F1AP pdu information from ReservedF1apPduList
258 * Function : deleteFromReservedF1apPduList
260 * Functionality: deleting pdu information from ReservedF1apPduList
262 * @params[in] CmLList *node
266 * ****************************************************************/
268 void deleteFromReservedF1apPduList(CmLList *node)
270 ReservedF1apPduInfo *f1apPdu;
274 f1apPdu = (ReservedF1apPduInfo *)node->node;
275 cmLListDelFrm(&duCb.reservedF1apPduList, node);
276 DU_FREE(f1apPdu, sizeof(ReservedF1apPduInfo));
277 DU_FREE(node, sizeof(CmLList));
282 /*******************************************************************
284 * @brief Builds Uplink Info for NR
288 * Function : BuildULNRInfo
290 * Functionality: Building NR Uplink Info
292 * @params[in] NRFreqInfo_t *ulnrfreq
293 * @return ROK - success
296 * ****************************************************************/
297 uint8_t BuildULNRInfo(NRFreqInfo_t *ulnrfreq)
300 ulnrfreq->nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.\
301 fdd.ulNrFreqInfo.nrArfcn;
302 ulnrfreq->freqBandListNr.list.count = 1;
303 ulnrfreq->freqBandListNr.list.size = sizeof(FreqBandNrItem_t *);
304 DU_ALLOC(ulnrfreq->freqBandListNr.list.array,ulnrfreq->freqBandListNr.list.size);
305 if(ulnrfreq->freqBandListNr.list.array == NULLP)
309 for(idx=0;idx<ulnrfreq->freqBandListNr.list.count;idx++)
311 DU_ALLOC(ulnrfreq->freqBandListNr.list.array[idx],sizeof(FreqBandNrItem_t));
312 if(ulnrfreq->freqBandListNr.list.array[idx] == NULLP)
317 ulnrfreq->freqBandListNr.list.array[0]->freqBandIndicatorNr = \
318 duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.\
319 freqBand[0].nrFreqBand;
320 ulnrfreq->freqBandListNr.list.array[0]->supportedSULBandList.list.count = SUL_BAND_COUNT;
323 /*******************************************************************
325 * @brief Builds Downlink NR Info
329 * Function : BuildDLNRInfo
331 * Functionality: Building Downlink NR Info
333 * @params[in] NRFreqInfo_t *dlnrfreq
334 * @return ROK - success
337 * ****************************************************************/
338 uint8_t BuildDLNRInfo(NRFreqInfo_t *dlnrfreq)
341 dlnrfreq->nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.\
342 fdd.dlNrFreqInfo.nrArfcn;
343 dlnrfreq->freqBandListNr.list.count = 1;
344 dlnrfreq->freqBandListNr.list.size = sizeof(FreqBandNrItem_t *);
345 DU_ALLOC(dlnrfreq->freqBandListNr.list.array,dlnrfreq->freqBandListNr.list.size);
346 if(dlnrfreq->freqBandListNr.list.array == NULLP)
350 for(idx=0;idx< dlnrfreq->freqBandListNr.list.count;idx++)
352 DU_ALLOC(dlnrfreq->freqBandListNr.list.array[idx],sizeof(FreqBandNrItem_t));
353 if(dlnrfreq->freqBandListNr.list.array[idx] == NULLP)
358 dlnrfreq->freqBandListNr.list.array[0]->freqBandIndicatorNr = \
359 duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.\
360 freqBand[0].nrFreqBand;
361 dlnrfreq->freqBandListNr.list.array[0]->supportedSULBandList.list.count = SUL_BAND_COUNT;
366 /*******************************************************************
368 * @brief Builds Nrcgi
372 * Function : BuildNrcgi
374 * Functionality: Building the PLMN ID and NR Cell id
376 * @params[in] NRCGI_t *nrcgi
377 * @return ROK - success
380 * ****************************************************************/
381 uint8_t BuildNrcgi(NRCGI_t *nrcgi)
384 uint8_t byteSize = 5;
385 /* Allocate Buffer Memory */
386 nrcgi->pLMN_Identity.size = PLMN_SIZE * sizeof(uint8_t);
387 DU_ALLOC(nrcgi->pLMN_Identity.buf, nrcgi->pLMN_Identity.size);
388 if(nrcgi->pLMN_Identity.buf == NULLP)
392 ret = buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
393 nrcgi->pLMN_Identity.buf); // Building PLMN function
399 nrcgi->nRCellIdentity.size = byteSize * sizeof(uint8_t);
400 DU_ALLOC(nrcgi->nRCellIdentity.buf, nrcgi->nRCellIdentity.size);
401 if(nrcgi->nRCellIdentity.buf == NULLP)
405 fillBitString(&nrcgi->nRCellIdentity, ODU_VALUE_FOUR, ODU_VALUE_FIVE, duCfgParam.sib1Params.cellIdentity);
409 /*******************************************************************
411 * @brief Builds FiveGStac
415 * Function : BuildFiveGSTac
417 * Functionality: Building the FiveGSTac
419 * @params[in] OCTET_STRING_t *fivegsTac
420 * @return ROK - success
423 * ****************************************************************/
424 uint8_t BuildFiveGSTac(Served_Cell_Information_t *servcell)
426 DU_ALLOC(servcell->fiveGS_TAC,sizeof(FiveGS_TAC_t));
427 if(servcell->fiveGS_TAC == NULLP)
431 servcell->fiveGS_TAC->size = 3 * sizeof(uint8_t);
432 DU_ALLOC(servcell->fiveGS_TAC->buf,\
433 sizeof(servcell->fiveGS_TAC->size));
434 if(servcell->fiveGS_TAC->buf == NULLP)
438 servcell->fiveGS_TAC->buf[0] = 0;
439 servcell->fiveGS_TAC->buf[1] = 0;
440 servcell->fiveGS_TAC->buf[2] = duCfgParam.srvdCellLst[0].duCellInfo.tac;
444 /*******************************************************************
446 * @brief fill nr frequency information
450 * Function : fillNrTddInfo
452 * Functionality: fill nr frequency information
454 * @params[in] NRFreqInfo_t freqInfo
455 * @return ROK - success
458 * ****************************************************************/
459 uint8_t fillNrTddInfo(TDD_Info_t *tddInfo)
461 uint8_t elementCnt = 1, freqBandListIdx = 0, supportedBandIdx = 0;
462 NRFreqInfo_t *freqInfo = NULLP;
466 DU_LOG("\nERROR --> DU APP : Null pointer received at fillNrTddInfo");
470 freqInfo = &tddInfo->nRFreqInfo;
471 freqInfo->nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.nrArfcn;
473 freqInfo->freqBandListNr.list.count = elementCnt;
474 freqInfo->freqBandListNr.list.size = freqInfo->freqBandListNr.list.count * sizeof(FreqBandNrItem_t *);
475 DU_ALLOC(freqInfo->freqBandListNr.list.array, freqInfo->freqBandListNr.list.size );
476 if(!freqInfo->freqBandListNr.list.array)
478 DU_LOG("\nERROR --> DU APP : Memory allocation failed at fillNrTddInfo");
482 for(freqBandListIdx = 0; freqBandListIdx<freqInfo->freqBandListNr.list.count; freqBandListIdx++)
484 DU_ALLOC(freqInfo->freqBandListNr.list.array[freqBandListIdx], sizeof(FreqBandNrItem_t ));
485 if(!freqInfo->freqBandListNr.list.array[freqBandListIdx])
487 DU_LOG("\nERROR --> DU APP : Memory allocation failed at fillNrTddInfo");
491 freqInfo->freqBandListNr.list.array[freqBandListIdx]->freqBandIndicatorNr = duCfgParam.srvdCellLst[0].duCellInfo.\
492 f1Mode.mode.tdd.nrFreqInfo.freqBand[0].nrFreqBand;
493 freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.count = elementCnt;
494 freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.size = freqInfo->freqBandListNr.list.array[freqBandListIdx]->\
495 supportedSULBandList.list.count * sizeof(SupportedSULFreqBandItem_t*);
497 DU_ALLOC(freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.array,\
498 freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.size);
499 if(!freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.array)
501 DU_LOG("\nERROR --> DU APP : Memory allocation failed at fillNrTddInfo");
505 for(supportedBandIdx = 0; supportedBandIdx<freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.count; supportedBandIdx++)
507 DU_ALLOC(freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.array[supportedBandIdx],\
508 sizeof(SupportedSULFreqBandItem_t));
509 if(!freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.array[supportedBandIdx])
511 DU_LOG("\nERROR --> DU APP : Memory allocation failed at fillNrTddInfo");
515 freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.array[supportedBandIdx]->freqBandIndicatorNr =\
516 duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.freqBand[0].sulBand[0];
520 tddInfo->transmission_Bandwidth.nRSCS = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrScs;
521 tddInfo->transmission_Bandwidth.nRNRB = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.tdd.nrFreqInfo.sulInfo.sulTxBw.nrb;
526 /*******************************************************************
528 * @brief Builds NR Mode
532 * Function : BuildNrMode
534 * Functionality: Building the NR Mode
536 * @params[in] NR_Mode_Info_t *fdd
537 * @return ROK - success
540 * ****************************************************************/
541 uint8_t BuildNrMode(NR_Mode_Info_t *mode)
543 uint8_t BuildDLNRInforet=0;
544 uint8_t BuildULNRInforet=0;
547 mode->present = NR_Mode_Info_PR_tDD;
549 mode->present = NR_Mode_Info_PR_fDD;
552 if(mode->present == NR_Mode_Info_PR_fDD)
554 DU_ALLOC(mode->choice.fDD,sizeof(FDD_Info_t));
555 if(mode->choice.fDD == NULLP)
557 DU_LOG("\nERROR --> Memory allocation failed in BuildNrMode");
560 BuildULNRInforet = BuildULNRInfo(&mode->choice.fDD->uL_NRFreqInfo);
561 if(BuildULNRInforet != ROK)
563 DU_LOG("\nERROR --> Failed to build UlNrFreqInfo");
566 BuildDLNRInforet = BuildDLNRInfo(&mode->choice.fDD->dL_NRFreqInfo);
567 if(BuildDLNRInforet != ROK)
569 DU_LOG("\nERROR --> Failed to build DlNrFreqInfo");
572 mode->choice.fDD->uL_Transmission_Bandwidth.nRSCS = \
573 duCfgParam.srvdCellLst[0].duCellInfo.\
574 f1Mode.mode.fdd.ulTxBw.nrScs;
575 mode->choice.fDD->uL_Transmission_Bandwidth.nRNRB = \
576 duCfgParam.srvdCellLst[0].duCellInfo.\
577 f1Mode.mode.fdd.ulTxBw.nrb;
578 mode->choice.fDD->dL_Transmission_Bandwidth.nRSCS = \
579 duCfgParam.srvdCellLst[0].duCellInfo.\
580 f1Mode.mode.fdd.dlTxBw.nrScs;
581 mode->choice.fDD->dL_Transmission_Bandwidth.nRNRB = \
582 duCfgParam.srvdCellLst[0].duCellInfo.\
583 f1Mode.mode.fdd.dlTxBw.nrb;
585 else if(mode->present == NR_Mode_Info_PR_tDD)
587 DU_ALLOC(mode->choice.tDD,sizeof(TDD_Info_t));
588 if(mode->choice.tDD == NULLP)
590 DU_LOG("\nERROR --> Memory allocation failed in BuildNrMode");
594 if(fillNrTddInfo(mode->choice.tDD) != ROK)
596 DU_LOG("\nERROR --> Failed to fill Nr TDD information");
604 /*******************************************************************
606 * @brief Builds IE Extensions for Served PLMNs
610 * Function : BuildExtensions
612 * Functionality: Building the IE Extensions
614 * @params[in] struct ProtocolExtensionContainer_4624P3 *buildextend
615 * @return ROK - success
618 * ****************************************************************/
619 uint8_t BuildExtensions(ProtocolExtensionContainer_4624P3_t **ieExtend)
621 uint8_t idx=0, plmnidx=0, sliceLstIdx=0;
622 uint8_t elementCnt=0, extensionCnt=0;
624 extensionCnt=IE_EXTENSION_LIST_COUNT;
625 DU_ALLOC(*ieExtend,sizeof(ProtocolExtensionContainer_4624P3_t));
626 if((*ieExtend) == NULLP)
628 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
631 (*ieExtend)->list.count = extensionCnt;
632 (*ieExtend)->list.size = \
633 extensionCnt * sizeof(ServedPLMNs_ItemExtIEs_t *);
634 DU_ALLOC((*ieExtend)->list.array,(*ieExtend)->list.size);
635 if((*ieExtend)->list.array == NULLP)
637 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
640 for(plmnidx=0;plmnidx<extensionCnt;plmnidx++)
642 DU_ALLOC((*ieExtend)->list.array[plmnidx],\
643 sizeof(ServedPLMNs_ItemExtIEs_t));
644 if((*ieExtend)->list.array[plmnidx] == NULLP)
646 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
651 elementCnt = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].taiSliceSuppLst.numSupportedSlices;
653 (*ieExtend)->list.array[idx]->id = ProtocolIE_ID_id_TAISliceSupportList;
654 (*ieExtend)->list.array[idx]->criticality = Criticality_ignore;
655 (*ieExtend)->list.array[idx]->extensionValue.present = \
656 ServedPLMNs_ItemExtIEs__extensionValue_PR_SliceSupportList;
657 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
658 list.count = elementCnt;
659 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
660 list.size = (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
661 list.count * sizeof(SliceSupportItem_t *);
663 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
664 list.array, elementCnt * sizeof(SliceSupportItem_t *));
665 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
668 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
672 for(sliceLstIdx =0; sliceLstIdx<elementCnt; sliceLstIdx++)
674 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
675 list.array[sliceLstIdx],sizeof(SliceSupportItem_t));
676 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
677 list.array[sliceLstIdx] == NULLP)
679 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
682 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
683 list.array[sliceLstIdx]->sNSSAI.sST.size = sizeof(uint8_t);
684 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList\
685 .list.array[sliceLstIdx]->sNSSAI.sST.buf,(*ieExtend)->list.array[idx]->\
686 extensionValue.choice.SliceSupportList.\
687 list.array[sliceLstIdx]->sNSSAI.sST.size);
688 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList\
689 .list.array[sliceLstIdx]->sNSSAI.sST.buf == NULLP)
691 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
694 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
695 list.array[sliceLstIdx]->sNSSAI.sST.buf[0] = duCfgParam.srvdCellLst[0].duCellInfo.\
696 cellInfo.srvdPlmn[0].taiSliceSuppLst.snssai[sliceLstIdx]->sst;
698 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
699 list.array[sliceLstIdx]->sNSSAI.sD,sizeof(OCTET_STRING_t));
700 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
701 list.array[sliceLstIdx]->sNSSAI.sD == NULLP)
703 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
706 (*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
707 list.array[sliceLstIdx]->sNSSAI.sD->size = 3 * sizeof(uint8_t);
708 DU_ALLOC((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
709 list.array[sliceLstIdx]->sNSSAI.sD->buf, (*ieExtend)->list.array[idx]->extensionValue.choice.\
710 SliceSupportList.list.array[sliceLstIdx]->sNSSAI.sD->size);
711 if((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
712 list.array[sliceLstIdx]->sNSSAI.sD->buf == NULLP)
714 DU_LOG("ERROR --> DU_APP : BuildExtensions(): Memory allocation failed");
717 memcpy((*ieExtend)->list.array[idx]->extensionValue.choice.SliceSupportList.\
718 list.array[sliceLstIdx]->sNSSAI.sD->buf, duCfgParam.srvdCellLst[0].duCellInfo.\
719 cellInfo.srvdPlmn[0].taiSliceSuppLst.snssai[sliceLstIdx]->sd, (*ieExtend)->list.array[idx]->\
720 extensionValue.choice.SliceSupportList.list.array[sliceLstIdx]->sNSSAI.sD->size);
724 /*******************************************************************
726 * @brief Builds Served PLMN
730 * Function : BuildServedPlmn
732 * Functionality: Building the Served PLMN
734 * @params[in] GNB_DU_Served_Cells_Item_t *srvCellItem
735 * @return ROK - success
738 * ****************************************************************/
739 uint8_t BuildServedPlmn(ServedPLMNs_List_t *srvplmn)
742 uint8_t servPlmnCnt=1;
743 uint8_t buildPlmnIdret=0;
744 uint8_t BuildExtensionsret=0;
745 srvplmn->list.count = servPlmnCnt;
746 srvplmn->list.size = \
747 servPlmnCnt*sizeof(ServedPLMNs_Item_t *);
748 DU_ALLOC(srvplmn->list.array,srvplmn->list.size);
749 if(srvplmn->list.array == NULLP)
753 for(plmnidx=0; plmnidx<servPlmnCnt; plmnidx++)
755 DU_ALLOC(srvplmn->list.array[plmnidx],\
756 sizeof(ServedPLMNs_Item_t));
757 if(srvplmn->list.array[plmnidx] == NULLP)
762 srvplmn->list.array[0]->pLMN_Identity.size = PLMN_SIZE * sizeof(uint8_t);
763 DU_ALLOC(srvplmn->list.array[0]->pLMN_Identity.buf, srvplmn->list.array[0]->pLMN_Identity.size);
764 buildPlmnIdret = buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
765 srvplmn->list.array[0]->pLMN_Identity.buf);
766 if(buildPlmnIdret!= ROK)
770 BuildExtensionsret = BuildExtensions(&srvplmn->list.array[0]->iE_Extensions);
771 if(BuildExtensionsret!= ROK)
777 /*******************************************************************
779 * @brief Builds Served Cell List
783 * Function : BuildServedCellList
785 * Functionality: Building Served Cell List
787 * @params[in] PLMNID plmn
788 * @return ROK - success
791 * ****************************************************************/
793 uint8_t BuildServedCellList(GNB_DU_Served_Cells_List_t *duServedCell)
795 uint8_t BuildNrcgiret=0;
796 uint8_t BuildFiveGSTacret=0;
797 uint8_t BuildServedPlmnret=0;
798 uint8_t BuildNrModeret=0;
802 GNB_DU_Served_Cells_Item_t *srvCellItem;
803 duServedCell->list.size = plmnCnt * sizeof(GNB_DU_Served_Cells_ItemIEs_t *);
804 duServedCell->list.count = plmnCnt;
806 DU_ALLOC(duServedCell->list.array, duServedCell->list.size);
807 if(duServedCell->list.array == NULLP)
811 for(plmnidx=0; plmnidx<plmnCnt; plmnidx++)
813 DU_ALLOC(duServedCell->list.array[plmnidx],\
814 sizeof(GNB_DU_Served_Cells_ItemIEs_t));
815 if(duServedCell->list.array[plmnidx] == NULLP)
821 duServedCell->list.array[idx]->id = ProtocolIE_ID_id_GNB_DU_Served_Cells_Item;
822 duServedCell->list.array[idx]->criticality = Criticality_reject;
823 duServedCell->list.array[idx]->value.present = \
824 GNB_DU_Served_Cells_ItemIEs__value_PR_GNB_DU_Served_Cells_Item;
826 &duServedCell->list.array[idx]->value.choice.GNB_DU_Served_Cells_Item;
828 BuildNrcgiret = BuildNrcgi(&srvCellItem->served_Cell_Information.nRCGI);
829 if(BuildNrcgiret != ROK)
834 srvCellItem->served_Cell_Information.nRPCI = \
835 duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrPci;
838 BuildFiveGSTacret = BuildFiveGSTac(&srvCellItem->served_Cell_Information);
839 if(BuildFiveGSTacret != ROK)
844 BuildServedPlmnret = BuildServedPlmn(&srvCellItem->served_Cell_Information.servedPLMNs);
845 if(BuildServedPlmnret !=ROK)
849 /*nR Mode Info with FDD*/
850 BuildNrModeret = BuildNrMode(&srvCellItem->served_Cell_Information.nR_Mode_Info);
851 if(BuildNrModeret != ROK)
855 /*Measurement timing Config*/
856 srvCellItem->served_Cell_Information.measurementTimingConfiguration.\
857 size = sizeof(uint8_t);
858 DU_ALLOC(srvCellItem->served_Cell_Information.\
859 measurementTimingConfiguration.buf,srvCellItem->served_Cell_Information.measurementTimingConfiguration.size);
860 if(srvCellItem->served_Cell_Information.\
861 measurementTimingConfiguration.buf == NULLP)
865 srvCellItem->served_Cell_Information.measurementTimingConfiguration.buf[0] = \
866 duCfgParam.srvdCellLst[0].duCellInfo.measTimeCfg;
868 /* GNB DU System Information */
869 DU_ALLOC(srvCellItem->gNB_DU_System_Information,
870 sizeof(GNB_DU_System_Information_t));
871 if(!srvCellItem->gNB_DU_System_Information)
876 srvCellItem->gNB_DU_System_Information->mIB_message.size = duCfgParam.srvdCellLst[0].duSysInfo.mibLen;
877 DU_ALLOC(srvCellItem->gNB_DU_System_Information->mIB_message.buf,
878 srvCellItem->gNB_DU_System_Information->mIB_message.size);
879 if(!srvCellItem->gNB_DU_System_Information->mIB_message.buf)
883 memcpy(srvCellItem->gNB_DU_System_Information->mIB_message.buf, duCfgParam.srvdCellLst[0].duSysInfo.mibMsg, \
884 srvCellItem->gNB_DU_System_Information->mIB_message.size);
887 srvCellItem->gNB_DU_System_Information->sIB1_message.size =\
888 duCfgParam.srvdCellLst[0].duSysInfo.sib1Len;
890 DU_ALLOC(srvCellItem->gNB_DU_System_Information->sIB1_message.buf,
891 srvCellItem->gNB_DU_System_Information->sIB1_message.size);
892 if(!srvCellItem->gNB_DU_System_Information->sIB1_message.buf)
896 for(int x=0; x<srvCellItem->gNB_DU_System_Information->sIB1_message.size; x++)
898 srvCellItem->gNB_DU_System_Information->sIB1_message.buf[x]=\
899 duCfgParam.srvdCellLst[0].duSysInfo.sib1Msg[x];
903 /*******************************************************************
905 * @brief Builds RRC Version
909 * Function : BuildRrcVer
911 * Functionality: Building RRC Version
913 * @params[in] int idx,int elementCnt,RRC_Version_t *rrcver
914 * @return ROK - success
917 * ****************************************************************/
918 uint8_t BuildRrcVer(RRC_Version_t *rrcVer)
922 rrcVer->latest_RRC_Version.size = sizeof(uint8_t);
923 DU_ALLOC(rrcVer->latest_RRC_Version.buf,sizeof(uint8_t));
924 if(rrcVer->latest_RRC_Version.buf == NULLP)
928 rrcVer->latest_RRC_Version.buf[0] = 0;
929 rrcVer->latest_RRC_Version.bits_unused = 5;
930 DU_ALLOC(rrcVer->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P81_t));
931 if(rrcVer->iE_Extensions == NULLP)
935 rrcVer->iE_Extensions->list.count = 1;
936 rrcVer->iE_Extensions->list.size = sizeof(RRC_Version_ExtIEs_t *);
937 DU_ALLOC(rrcVer->iE_Extensions->list.array,rrcVer->iE_Extensions->list.size);
938 if(rrcVer->iE_Extensions->list.array == NULLP)
943 DU_ALLOC(rrcVer->iE_Extensions->list.array[0],\
944 sizeof(RRC_Version_ExtIEs_t));
945 if(rrcVer->iE_Extensions->list.array[0] == NULLP)
949 rrcVer->iE_Extensions->list.array[rrcExt]->id = \
950 ProtocolIE_ID_id_latest_RRC_Version_Enhanced;
951 rrcVer->iE_Extensions->list.array[rrcExt]->criticality = Criticality_reject;
952 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.present =\
953 RRC_Version_ExtIEs__extensionValue_PR_Latest_RRC_Version_Enhanced;
954 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice\
955 .Latest_RRC_Version_Enhanced.size = 3*sizeof(uint8_t);
956 DU_ALLOC(rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice\
957 .Latest_RRC_Version_Enhanced.buf,rrcVer->iE_Extensions->list.\
958 array[rrcExt]->extensionValue.choice.Latest_RRC_Version_Enhanced.size);
959 if(rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice\
960 .Latest_RRC_Version_Enhanced.buf == NULLP)
965 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice.\
966 Latest_RRC_Version_Enhanced.buf[rrcLatest] = 15;
968 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice.\
969 Latest_RRC_Version_Enhanced.buf[rrcLatest] = 5;
971 rrcVer->iE_Extensions->list.array[rrcExt]->extensionValue.choice.\
972 Latest_RRC_Version_Enhanced.buf[rrcLatest] = 0;
975 /*******************************************************************
977 * @brief Sends F1 msg over SCTP
981 * Function : sendF1APMsg
983 * Functionality: Sends F1 msg over SCTP
985 * @params[in] Region region
987 * @return ROK - success
990 * ****************************************************************/
991 uint8_t sendF1APMsg()
993 Buffer *mBuf = NULLP;
995 if(ODU_GET_MSG_BUF(DU_APP_MEM_REGION, DU_POOL, &mBuf) == ROK)
997 if(ODU_ADD_POST_MSG_MULT((Data *)encBuf, encBufSize, mBuf) == ROK)
999 ODU_PRINT_MSG(mBuf, 0,0);
1001 if(sctpSend(mBuf, F1_INTERFACE) != ROK)
1003 DU_LOG("\nERROR --> F1AP : SCTP Send failed");
1004 ODU_PUT_MSG_BUF(mBuf);
1010 DU_LOG("\nERROR --> F1AP : ODU_ADD_POST_MSG_MULT failed");
1011 ODU_PUT_MSG_BUF(mBuf);
1014 ODU_PUT_MSG_BUF(mBuf);
1018 DU_LOG("\nERROR --> F1AP : Failed to allocate memory");
1024 /*******************************************************************
1026 * @brief deallocating the memory of function BuildAndSendF1SetupReq()
1030 * Function : FreeRrcVer
1032 * Functionality: deallocating the memory of function BuildRrcVer
1034 * @params[in] RRC_Version_t *rrcVer
1038 *****************************************************************/
1039 void FreeRrcVer(RRC_Version_t *rrcVer)
1041 if(rrcVer->latest_RRC_Version.buf != NULLP)
1043 if(rrcVer->iE_Extensions != NULLP)
1045 if(rrcVer->iE_Extensions->list.array != NULLP)
1047 if(rrcVer->iE_Extensions->list.array[0] != NULLP)
1049 if(rrcVer->iE_Extensions->list.array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf
1052 DU_FREE(rrcVer->iE_Extensions->list.array[0]->extensionValue.choice\
1053 .Latest_RRC_Version_Enhanced.buf,rrcVer->iE_Extensions->list.\
1054 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.size);
1056 DU_FREE(rrcVer->iE_Extensions->list.array[0],sizeof(RRC_Version_ExtIEs_t));
1058 DU_FREE(rrcVer->iE_Extensions->list.array,sizeof(RRC_Version_ExtIEs_t*));
1060 DU_FREE(rrcVer->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P81_t));
1062 DU_FREE(rrcVer->latest_RRC_Version.buf,rrcVer->latest_RRC_Version.size);
1066 /*******************************************************************
1068 * @brief Deallocating memory of TDD NrFreqInfo
1072 * Function : freeTddNrFreqInfo
1074 * Functionality: freeTddNrFreqInfo
1076 * @params[in] F1AP_PDU_t *f1apDuCfg
1078 * @return ROK - void
1080 * ****************************************************************/
1081 void freeTddNrFreqInfo(NRFreqInfo_t *freqInfo)
1083 uint8_t freqBandListIdx = 0, supportedBandIdx = 0;
1085 if(freqInfo->freqBandListNr.list.array)
1087 for(freqBandListIdx = 0; freqBandListIdx<freqInfo->freqBandListNr.list.count; freqBandListIdx++)
1089 if(freqInfo->freqBandListNr.list.array[freqBandListIdx])
1091 if(freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.array)
1093 for(supportedBandIdx = 0; supportedBandIdx<freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.count; supportedBandIdx++)
1095 DU_FREE(freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.array[supportedBandIdx],\
1096 sizeof(SupportedSULFreqBandItem_t));
1098 DU_FREE(freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.array,\
1099 freqInfo->freqBandListNr.list.array[freqBandListIdx]->supportedSULBandList.list.size);
1102 DU_FREE(freqInfo->freqBandListNr.list.array[freqBandListIdx], sizeof(FreqBandNrItem_t ));
1105 DU_FREE(freqInfo->freqBandListNr.list.array, freqInfo->freqBandListNr.list.size );
1109 /*******************************************************************
1111 * @brief Deallocating memory allocated for Nr fdd frequencey mode
1115 * Function : freeFddNrFreqInfo
1117 * Functionality:Free memory allocated for Nr fdd frequencey mode
1121 * @return ROK - void
1123 * ****************************************************************/
1124 void freeFddNrFreqInfo(FDD_Info_t *fDD)
1130 if(fDD->uL_NRFreqInfo.freqBandListNr.list.array != NULLP)
1132 DU_FREE(fDD->uL_NRFreqInfo.freqBandListNr.list.\
1133 array[arrIdx], sizeof(FreqBandNrItem_t));
1134 DU_FREE(fDD->uL_NRFreqInfo.freqBandListNr.list.array, \
1135 fDD->uL_NRFreqInfo.freqBandListNr.list.size);
1138 if(fDD->dL_NRFreqInfo.freqBandListNr.list.array != NULLP)
1140 DU_FREE(fDD->dL_NRFreqInfo.freqBandListNr.list.\
1141 array[arrIdx], sizeof(FreqBandNrItem_t));
1142 DU_FREE(fDD->dL_NRFreqInfo.freqBandListNr.list.array,\
1143 fDD->dL_NRFreqInfo.freqBandListNr.list.size);
1145 DU_FREE(fDD,sizeof(FDD_Info_t));
1149 /*******************************************************************
1151 * @brief deallocating the memory of function BuildAndSendF1SetupReq()
1155 * Function : FreeServedCellList
1157 * Functionality: deallocating the memory of function BuildServedCellList
1160 * @params[in] GNB_DU_Served_Cells_List_t *duServedCell
1164 * ****************************************************************/
1165 void FreeServedCellList( GNB_DU_Served_Cells_List_t *duServedCell)
1167 uint8_t plmnCnt=MAX_PLMN;
1168 uint8_t extensionCnt=IE_EXTENSION_LIST_COUNT;
1169 uint8_t plmnIdx=0, sliceIdx=0;
1170 GNB_DU_Served_Cells_Item_t *srvCellItem;
1171 ServedPLMNs_Item_t *servedPlmnItem;
1172 SliceSupportItem_t *sliceSupportItem;
1174 if(duServedCell->list.array!=NULLP)
1176 if(duServedCell->list.array[0]!=NULLP)
1178 srvCellItem= &duServedCell->list.array[0]->value.choice.GNB_DU_Served_Cells_Item;
1180 DU_FREE(srvCellItem->served_Cell_Information.nRCGI.pLMN_Identity.buf,\
1181 srvCellItem->served_Cell_Information.nRCGI.pLMN_Identity.size * sizeof(uint8_t));
1182 DU_FREE(srvCellItem->served_Cell_Information.nRCGI.nRCellIdentity.buf,\
1183 srvCellItem->served_Cell_Information.nRCGI.nRCellIdentity.size * sizeof(uint8_t));
1185 if(srvCellItem->served_Cell_Information.fiveGS_TAC!=NULLP)
1187 DU_FREE(srvCellItem->served_Cell_Information.fiveGS_TAC->buf,\
1188 sizeof(srvCellItem->served_Cell_Information.fiveGS_TAC->size));
1189 DU_FREE(srvCellItem->served_Cell_Information.fiveGS_TAC,sizeof(FiveGS_TAC_t));
1192 if(srvCellItem->served_Cell_Information.servedPLMNs.list.array!=NULLP)
1194 if(srvCellItem->served_Cell_Information.servedPLMNs.list.array[plmnIdx] != NULLP)
1196 servedPlmnItem = srvCellItem->served_Cell_Information.servedPLMNs.list.array[plmnIdx];
1197 DU_FREE(servedPlmnItem->pLMN_Identity.buf, servedPlmnItem->pLMN_Identity.size);
1199 if(servedPlmnItem->iE_Extensions != NULLP)
1201 if(servedPlmnItem->iE_Extensions->list.array != NULLP)
1203 if(servedPlmnItem->iE_Extensions->list.array[0] != NULLP)
1205 if(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.\
1206 SliceSupportList.list.array != NULLP)
1208 for(sliceIdx =0; sliceIdx<servedPlmnItem->iE_Extensions->list.array[0]->\
1209 extensionValue.choice.SliceSupportList.list.count; sliceIdx++)
1211 if(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.\
1212 SliceSupportList.list.array[sliceIdx] != NULLP)
1214 sliceSupportItem = servedPlmnItem->iE_Extensions->list.array[0]->\
1215 extensionValue.choice.SliceSupportList.list.array[sliceIdx];
1217 DU_FREE(sliceSupportItem->sNSSAI.sST.buf, sizeof(uint8_t));
1219 if(sliceSupportItem->sNSSAI.sD != NULLP)
1221 DU_FREE(sliceSupportItem->sNSSAI.sD->buf,\
1222 sliceSupportItem->sNSSAI.sD->size);
1223 DU_FREE(sliceSupportItem->sNSSAI.sD, sizeof(OCTET_STRING_t));
1226 DU_FREE(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.\
1227 choice.SliceSupportList.list.array[sliceIdx], sizeof(SliceSupportItem_t));
1230 DU_FREE(servedPlmnItem->iE_Extensions->list.array[0]->extensionValue.choice.\
1231 SliceSupportList.list.array, servedPlmnItem->iE_Extensions->list.array[0]->\
1232 extensionValue.choice.SliceSupportList.list.size);
1234 DU_FREE(servedPlmnItem->iE_Extensions->list.array[0],\
1235 sizeof(ServedPLMNs_ItemExtIEs_t));
1237 DU_FREE(servedPlmnItem->iE_Extensions->list.array,\
1238 extensionCnt*sizeof(ServedPLMNs_ItemExtIEs_t*));
1240 DU_FREE(servedPlmnItem->iE_Extensions, sizeof(ProtocolExtensionContainer_4624P3_t));
1242 DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.array[plmnIdx],\
1243 sizeof(ServedPLMNs_Item_t));
1245 DU_FREE(srvCellItem->served_Cell_Information.servedPLMNs.list.array,\
1246 sizeof(ServedPLMNs_Item_t *));
1249 if(srvCellItem->served_Cell_Information.nR_Mode_Info.present == NR_Mode_Info_PR_fDD)
1251 freeFddNrFreqInfo(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.fDD);
1255 if(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.tDD != NULLP)
1257 freeTddNrFreqInfo(&srvCellItem->served_Cell_Information.nR_Mode_Info.choice.tDD->nRFreqInfo);
1258 DU_FREE(srvCellItem->served_Cell_Information.nR_Mode_Info.choice.tDD, sizeof(TDD_Info_t));
1262 DU_FREE(srvCellItem->served_Cell_Information.measurementTimingConfiguration.buf,\
1263 srvCellItem->served_Cell_Information.measurementTimingConfiguration.size);
1265 if(srvCellItem->gNB_DU_System_Information != NULLP)
1267 if(srvCellItem->gNB_DU_System_Information->mIB_message.buf != NULLP)
1269 DU_FREE(srvCellItem->gNB_DU_System_Information->mIB_message.buf,\
1270 srvCellItem->gNB_DU_System_Information->mIB_message.size);
1273 if(srvCellItem->gNB_DU_System_Information->sIB1_message.buf != NULLP)
1275 DU_FREE(srvCellItem->gNB_DU_System_Information->sIB1_message.buf,\
1276 srvCellItem->gNB_DU_System_Information->sIB1_message.size);
1279 DU_FREE(srvCellItem->gNB_DU_System_Information, sizeof(GNB_DU_System_Information_t));
1282 DU_FREE(duServedCell->list.array[0], sizeof(GNB_DU_Served_Cells_ItemIEs_t));
1284 DU_FREE(duServedCell->list.array, plmnCnt * sizeof(GNB_DU_Served_Cells_ItemIEs_t*));
1288 /*******************************************************************
1290 * @brief deallocating the memory of function BuildAndSendF1SetupReq()
1294 * Function : FreeF1SetupReq
1296 * Functionality: deallocating the memory of function BuildAndSendF1SetupReq
1298 * @params[in] F1AP_PDU_t *f1apMsg
1302 * ****************************************************************/
1303 void FreeF1SetupReq(F1AP_PDU_t *f1apMsg)
1305 uint8_t ieIdx, ieIdx2;
1306 F1SetupRequest_t *f1SetupReq=NULLP;
1308 if(f1apMsg != NULLP)
1310 if(f1apMsg->choice.initiatingMessage != NULLP)
1312 f1SetupReq = &f1apMsg->choice.initiatingMessage->value.choice.F1SetupRequest;
1313 if(f1SetupReq->protocolIEs.list.array != NULLP)
1315 for(ieIdx = 0; ieIdx < f1SetupReq->protocolIEs.list.count; ieIdx++)
1317 if(f1SetupReq->protocolIEs.list.array[ieIdx] != NULLP)
1319 switch(f1SetupReq->protocolIEs.list.array[ieIdx]->id)
1321 case ProtocolIE_ID_id_TransactionID:
1323 case ProtocolIE_ID_id_gNB_DU_ID:
1324 DU_FREE(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
1325 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
1327 case ProtocolIE_ID_id_gNB_DU_Name:
1328 DU_FREE(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.buf,\
1329 strlen((char *)duCfgParam.duName));
1331 case ProtocolIE_ID_id_gNB_DU_Served_Cells_List:
1332 FreeServedCellList(&f1SetupReq->protocolIEs.list.\
1333 array[ieIdx]->value.choice.GNB_DU_Served_Cells_List);
1335 case ProtocolIE_ID_id_GNB_DU_RRC_Version:
1336 FreeRrcVer(&f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.RRC_Version);
1339 DU_LOG("\nERROR --> Invalid Event Type %ld", f1SetupReq->protocolIEs.list.array[ieIdx]->id);
1344 for(ieIdx2=0; ieIdx2< ieIdx; ieIdx2++)
1346 DU_FREE(f1SetupReq->protocolIEs.list.array[ieIdx2],sizeof(F1SetupRequestIEs_t));
1348 DU_FREE(f1SetupReq->protocolIEs.list.array,\
1349 f1SetupReq->protocolIEs.list.size);
1351 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
1353 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
1356 /*******************************************************************
1358 * @brief Builds and Send the F1SetupRequest
1362 * Function : BuildAndSendF1SetupReq
1364 * Functionality:Fills the F1SetupRequest
1366 * @return ROK - success
1369 ******************************************************************/
1370 uint8_t BuildAndSendF1SetupReq()
1372 uint8_t ret, ieIdx, elementCnt;
1373 F1AP_PDU_t *f1apMsg = NULLP;
1374 F1SetupRequest_t *f1SetupReq=NULLP;
1375 GNB_DU_Served_Cells_List_t *duServedCell=NULLP;
1376 RRC_Version_t *rrcVer=NULLP;
1377 asn_enc_rval_t encRetVal; /* Encoder return value */
1380 DU_LOG("\nINFO --> F1AP : Building F1 Setup Request\n");
1383 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
1384 if(f1apMsg == NULLP)
1388 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
1389 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
1390 if(f1apMsg->choice.initiatingMessage == NULLP)
1394 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_F1Setup;
1395 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
1396 f1apMsg->choice.initiatingMessage->value.present = \
1397 InitiatingMessage__value_PR_F1SetupRequest;
1399 f1SetupReq = &f1apMsg->choice.initiatingMessage->value.choice.F1SetupRequest;
1401 elementCnt = (duCfgParam.duName != NULL) ? 5 : 4;
1403 f1SetupReq->protocolIEs.list.count = elementCnt;
1404 f1SetupReq->protocolIEs.list.size = elementCnt * sizeof(F1SetupRequestIEs_t );
1406 /* Initialize the F1Setup members */
1407 DU_ALLOC(f1SetupReq->protocolIEs.list.array,f1SetupReq->protocolIEs.list.size);
1408 if(f1SetupReq->protocolIEs.list.array == NULLP)
1412 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
1414 DU_ALLOC(f1SetupReq->protocolIEs.list.array[ieIdx],\
1415 sizeof(F1SetupRequestIEs_t));
1416 if(f1SetupReq->protocolIEs.list.array[ieIdx] == NULLP)
1424 f1SetupReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_TransactionID;
1425 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1426 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present =\
1427 F1SetupRequestIEs__value_PR_TransactionID;
1428 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = \
1433 f1SetupReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_ID;
1434 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1435 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = \
1436 F1SetupRequestIEs__value_PR_GNB_DU_ID;
1437 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size =\
1440 DU_ALLOC(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
1441 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
1442 if(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf == \
1448 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf[0] =\
1452 if(duCfgParam.duName != NULL)
1455 f1SetupReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_Name;
1456 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_ignore;
1457 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = F1SetupRequestIEs__value_PR_GNB_DU_Name;
1458 f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.size =\
1459 strlen((char *)duCfgParam.duName);
1460 DU_ALLOC(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.\
1461 GNB_DU_Name.buf, strlen((char *)duCfgParam.duName));
1462 if(f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_Name.\
1467 strcpy((char*)f1SetupReq->protocolIEs.list.array[ieIdx]->value.\
1468 choice.GNB_DU_Name.buf,
1469 (char*)&duCfgParam.duName);
1473 /*Served Cell list */
1475 f1SetupReq->protocolIEs.list.array[ieIdx]->id = \
1476 ProtocolIE_ID_id_gNB_DU_Served_Cells_List;
1477 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1478 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = \
1479 F1SetupRequestIEs__value_PR_GNB_DU_Served_Cells_List;
1480 duServedCell = &f1SetupReq->protocolIEs.list.\
1481 array[ieIdx]->value.choice.GNB_DU_Served_Cells_List;
1482 if(BuildServedCellList(duServedCell))
1488 f1SetupReq->protocolIEs.list.array[ieIdx]->id = \
1489 ProtocolIE_ID_id_GNB_DU_RRC_Version ;
1490 f1SetupReq->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
1491 f1SetupReq->protocolIEs.list.array[ieIdx]->value.present = \
1492 F1SetupRequestIEs__value_PR_RRC_Version;
1493 rrcVer = &f1SetupReq->protocolIEs.list.array[ieIdx]->value.choice.RRC_Version;
1494 if(BuildRrcVer(rrcVer))
1498 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
1500 /* Encode the F1SetupRequest type as APER */
1501 memset(encBuf, 0, ENC_BUF_MAX_LEN);
1503 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
1506 /* Encode results */
1507 if(encRetVal.encoded == ENCODE_FAIL)
1509 DU_LOG("\nERROR --> F1AP : Could not encode F1SetupRequest structure (at %s)\n",\
1510 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
1515 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for F1SetupRequest\n");
1516 #ifdef DEBUG_ASN_PRINT
1517 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
1519 printf("%x",encBuf[ieIdx]);
1523 duCb.f1SetupReqAndRspMsg.f1MsgReqBufSize = encBufSize;
1524 DU_ALLOC(duCb.f1SetupReqAndRspMsg.f1MsgReqBuf, encBufSize);
1525 if(duCb.f1SetupReqAndRspMsg.f1MsgReqBuf == NULLP)
1527 DU_LOG("\nERROR --> F1AP : Memory allocation failed to store the encoding of f1setup req");
1530 memcpy(duCb.f1SetupReqAndRspMsg.f1MsgReqBuf, &encBuf, duCb.f1SetupReqAndRspMsg.f1MsgReqBufSize);
1534 if(sendF1APMsg() != ROK)
1536 DU_LOG("\nERROR --> F1AP : Sending F1 Setup request failed");
1544 FreeF1SetupReq(f1apMsg);
1547 }/* End of BuildAndSendF1SetupReq */
1549 /*******************************************************************
1551 * @brief Deallocating memory allocated for Served_Cells_To_Modify_Item_t
1555 * Function : freeCellsToModifyItem
1557 * Functionality: Deallocating memory of variables allocated in
1558 * BuildAndSendDUConfigUpdate function
1560 * @params[in] Served_Cells_To_Modify_Item_t *modifyItem
1562 * @return ROK - void
1564 * ****************************************************************/
1566 void freeCellsToModifyItem(Served_Cells_To_Modify_Item_t *modifyItem)
1568 uint8_t arrIdx=0, servedPlmnIdx=0, sliceLstIdx=0;
1569 ServedPLMNs_Item_t *servedPlmnItem = NULLP;
1570 SliceSupportItem_t *sliceSupportItem = NULLP;
1572 DU_FREE(modifyItem->oldNRCGI.pLMN_Identity.buf, modifyItem->oldNRCGI.pLMN_Identity.size);
1573 DU_FREE(modifyItem->oldNRCGI.nRCellIdentity.buf, modifyItem->oldNRCGI.nRCellIdentity.size);
1575 DU_FREE(modifyItem->served_Cell_Information.nRCGI.pLMN_Identity.buf,\
1576 modifyItem->served_Cell_Information.nRCGI.pLMN_Identity.size);
1577 DU_FREE(modifyItem->served_Cell_Information.nRCGI.nRCellIdentity.buf,\
1578 modifyItem->served_Cell_Information.nRCGI.nRCellIdentity.size);
1580 if(modifyItem->served_Cell_Information.servedPLMNs.list.array != NULLP)
1582 if(modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx] != NULLP)
1584 servedPlmnItem = modifyItem->served_Cell_Information.servedPLMNs.list.array[arrIdx];
1586 DU_FREE(servedPlmnItem->pLMN_Identity.buf,servedPlmnItem->pLMN_Identity.size);
1588 if(servedPlmnItem->iE_Extensions != NULLP)
1590 if(servedPlmnItem->iE_Extensions->list.array != NULLP)
1592 if(servedPlmnItem->iE_Extensions->list.array[arrIdx] != NULLP)
1594 if(servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.SliceSupportList.\
1595 list.array != NULLP)
1597 for(sliceLstIdx =0; sliceLstIdx<servedPlmnItem->iE_Extensions->list.array[arrIdx]->\
1598 extensionValue.choice.SliceSupportList.list.count; sliceLstIdx++)
1600 if(servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.SliceSupportList.\
1601 list.array[sliceLstIdx] != NULLP)
1604 sliceSupportItem = servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.\
1605 SliceSupportList.list.array[sliceLstIdx];
1607 DU_FREE(sliceSupportItem->sNSSAI.sST.buf, sliceSupportItem->sNSSAI.sST.size);
1608 if(sliceSupportItem->sNSSAI.sD != NULLP)
1610 DU_FREE(sliceSupportItem->sNSSAI.sD->buf, sliceSupportItem->sNSSAI.sD->size);
1611 DU_FREE(sliceSupportItem->sNSSAI.sD,sizeof(OCTET_STRING_t));
1613 DU_FREE(servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.choice.\
1614 SliceSupportList.list.array[sliceLstIdx], sizeof(SliceSupportItem_t));
1617 DU_FREE(servedPlmnItem->iE_Extensions->list.array[arrIdx]->extensionValue.\
1618 choice.SliceSupportList.list.array,\
1619 servedPlmnItem->iE_Extensions->list.array[arrIdx]->\
1620 extensionValue.choice.SliceSupportList.list.size);
1623 for(servedPlmnIdx=0; servedPlmnIdx< servedPlmnItem->iE_Extensions->list.count ; servedPlmnIdx++)
1625 DU_FREE(servedPlmnItem->iE_Extensions->list.array[servedPlmnIdx], sizeof(ServedPLMNs_ItemExtIEs_t ));
1627 DU_FREE(servedPlmnItem->iE_Extensions->list.array, servedPlmnItem->iE_Extensions->list.size);
1629 DU_FREE(servedPlmnItem->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P3_t));
1632 for(servedPlmnIdx=0; servedPlmnIdx<modifyItem->served_Cell_Information.servedPLMNs.list.count; servedPlmnIdx++)
1634 DU_FREE(modifyItem->served_Cell_Information.servedPLMNs.list.array[servedPlmnIdx], sizeof(ServedPLMNs_Item_t));
1636 DU_FREE(modifyItem->served_Cell_Information.servedPLMNs.list.array,\
1637 modifyItem->served_Cell_Information.servedPLMNs.list.size);
1640 if(modifyItem->served_Cell_Information.nR_Mode_Info.present == NR_Mode_Info_PR_fDD)
1642 freeFddNrFreqInfo(modifyItem->served_Cell_Information.nR_Mode_Info.choice.fDD);
1646 if(modifyItem->served_Cell_Information.nR_Mode_Info.choice.tDD)
1648 freeTddNrFreqInfo(&modifyItem->served_Cell_Information.nR_Mode_Info.choice.tDD->nRFreqInfo);
1649 DU_FREE(modifyItem->served_Cell_Information.nR_Mode_Info.choice.tDD, sizeof(TDD_Info_t));
1652 DU_FREE(modifyItem->served_Cell_Information.measurementTimingConfiguration.buf,\
1653 modifyItem->served_Cell_Information.measurementTimingConfiguration.size);
1656 /*******************************************************************
1658 * @brief Deallocating memory of BuildAndSendDUConfigUpdate
1662 * Function : FreeDUConfigUpdate
1664 * Functionality: Deallocating memory of variables allocated in
1665 * BuildAndSendDUConfigUpdate function
1667 * @params[in] F1AP_PDU_t *f1apDuCfg
1669 * @return ROK - void
1671 * ****************************************************************/
1672 void FreeDUConfigUpdate(F1AP_PDU_t *f1apDuCfg)
1674 uint8_t ieIdx=0, cellModifyIdx=0, cellDeleteIdx=0;
1675 GNBDUConfigurationUpdate_t *duCfgUpdate = NULLP;
1676 Served_Cells_To_Modify_List_t *cellsToModify=NULLP;
1677 Served_Cells_To_Delete_List_t *cellsToDelete=NULLP;
1678 Served_Cells_To_Delete_Item_t *deleteItem = NULLP;
1679 Served_Cells_To_Delete_ItemIEs_t *deleteItemIe = NULLP;
1681 if(f1apDuCfg != NULLP)
1683 if(f1apDuCfg->choice.initiatingMessage != NULLP)
1685 duCfgUpdate = &f1apDuCfg->choice.initiatingMessage->\
1686 value.choice.GNBDUConfigurationUpdate;
1687 if(duCfgUpdate->protocolIEs.list.array != NULLP)
1689 for(ieIdx=0; ieIdx<duCfgUpdate->protocolIEs.list.count; ieIdx++)
1691 if(duCfgUpdate->protocolIEs.list.array[ieIdx] != NULLP)
1693 switch(duCfgUpdate->protocolIEs.list.array[ieIdx]->id)
1695 case ProtocolIE_ID_id_Served_Cells_To_Modify_List:
1697 cellsToModify = &duCfgUpdate->protocolIEs.list.array[ieIdx]->\
1698 value.choice.Served_Cells_To_Modify_List;
1699 if(cellsToModify->list.array != NULLP)
1701 for(cellModifyIdx=0; cellModifyIdx<cellsToModify->list.count ;cellModifyIdx++)
1703 if(cellsToModify->list.array[cellModifyIdx] != NULLP)
1705 freeCellsToModifyItem(&cellsToModify->list.array[cellModifyIdx]->value.choice.\
1706 Served_Cells_To_Modify_Item);
1707 DU_FREE(cellsToModify->list.array[cellModifyIdx],\
1708 sizeof(Served_Cells_To_Modify_ItemIEs_t));
1711 DU_FREE(cellsToModify->list.array,cellsToModify->list.size);
1715 case ProtocolIE_ID_id_Served_Cells_To_Delete_List:
1717 cellsToDelete = &duCfgUpdate->protocolIEs.list.array[ieIdx]->\
1718 value.choice.Served_Cells_To_Delete_List;
1719 if(cellsToDelete->list.array != NULLP)
1721 for(cellDeleteIdx=0; cellDeleteIdx<cellsToDelete->list.count ;cellDeleteIdx++)
1723 if(cellsToDelete->list.array[cellDeleteIdx] != NULLP)
1725 deleteItemIe = ((Served_Cells_To_Delete_ItemIEs_t*)\
1726 cellsToDelete->list.array[cellDeleteIdx]);
1727 deleteItem=&deleteItemIe->value.choice.Served_Cells_To_Delete_Item;
1728 DU_FREE(deleteItem->oldNRCGI.pLMN_Identity.buf,\
1729 deleteItem->oldNRCGI.pLMN_Identity.size);
1730 DU_FREE(deleteItem->oldNRCGI.nRCellIdentity.buf,\
1731 deleteItem->oldNRCGI.nRCellIdentity.size);
1732 DU_FREE(cellsToDelete->list.array[cellDeleteIdx],\
1733 sizeof(Served_Cells_To_Delete_ItemIEs_t));
1736 DU_FREE(cellsToDelete->list.array,cellsToDelete->list.size);
1741 case ProtocolIE_ID_id_gNB_DU_ID:
1743 DU_FREE(duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
1744 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
1748 DU_FREE(duCfgUpdate->protocolIEs.list.array[ieIdx],\
1749 sizeof(GNBDUConfigurationUpdateIEs_t));
1752 DU_FREE(duCfgUpdate->protocolIEs.list.array,duCfgUpdate->protocolIEs.list.size);
1754 DU_FREE(f1apDuCfg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
1756 DU_FREE(f1apDuCfg, (Size)sizeof(F1AP_PDU_t));
1760 /*******************************************************************
1762 * @brief Fills Served Plmns required in ServCellInfo IE
1766 * Function : fillServedPlmns
1768 * Functionality: Fills Served Plmns required in ServCellInfo IE
1770 * @params[in] Pointer to ServedPLMNs_List_t *
1772 * @return ROK - success
1775 *****************************************************************/
1777 uint8_t fillServedPlmns(ServedPLMNs_List_t *servedPlmn)
1779 uint8_t ieIdx=0, arrayIdx=0, ieListCnt=0, elementCnt=0, sliceLstIdx=0;
1781 servedPlmn->list.array[arrayIdx]->pLMN_Identity.size = 3*sizeof(uint8_t);
1782 DU_ALLOC(servedPlmn->list.array[arrayIdx]->pLMN_Identity.buf, servedPlmn->list.\
1783 array[arrayIdx]->pLMN_Identity.size);
1784 if(servedPlmn->list.array[arrayIdx]->pLMN_Identity.buf == NULLP)
1786 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
1789 buildPlmnId(duCfgParam.srvdCellLst[arrayIdx].duCellInfo.cellInfo.srvdPlmn[arrayIdx].plmn,\
1790 servedPlmn->list.array[arrayIdx]->pLMN_Identity.buf);
1791 DU_ALLOC(servedPlmn->list.array[arrayIdx]->iE_Extensions,sizeof(ProtocolExtensionContainer_4624P3_t));
1792 if(servedPlmn->list.array[arrayIdx]->iE_Extensions == NULLP)
1794 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
1799 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.count = ieListCnt;
1800 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.size = ieListCnt *sizeof(ServedPLMNs_ItemExtIEs_t *);
1801 DU_ALLOC(servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array,servedPlmn->list.array[arrayIdx]->\
1802 iE_Extensions->list.size);
1803 if(servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array == NULLP)
1805 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
1808 for(ieIdx=arrayIdx;ieIdx<ieListCnt;ieIdx++)
1810 DU_ALLOC(servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx],\
1811 sizeof(ServedPLMNs_ItemExtIEs_t));
1812 if(servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx] == NULLP)
1814 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
1820 elementCnt = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.srvdPlmn[0].taiSliceSuppLst.numSupportedSlices;
1821 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx]->id =ProtocolIE_ID_id_TAISliceSupportList;
1822 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx]->criticality = Criticality_ignore;
1823 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx]->extensionValue.present = \
1824 ServedPLMNs_ItemExtIEs__extensionValue_PR_SliceSupportList;
1825 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1826 list.count = elementCnt;
1827 servedPlmn->list.array[arrayIdx]->\
1828 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1829 list.size = elementCnt * sizeof(SliceSupportItem_t *);
1830 DU_ALLOC(servedPlmn->list.array[arrayIdx]->\
1831 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1832 list.array,servedPlmn->list.array[arrayIdx]->\
1833 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.list.size);
1834 if(servedPlmn->list.array[arrayIdx]->\
1835 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1836 list.array == NULLP)
1838 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
1842 for(sliceLstIdx =0; sliceLstIdx< elementCnt; sliceLstIdx++)
1844 DU_ALLOC(servedPlmn->list.array[arrayIdx]->\
1845 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1846 list.array[sliceLstIdx],sizeof( SliceSupportItem_t));
1847 if(servedPlmn->list.array[arrayIdx]->\
1848 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1849 list.array[sliceLstIdx] == NULLP)
1851 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
1855 servedPlmn->list.array[arrayIdx]->\
1856 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1857 list.array[sliceLstIdx]->sNSSAI.sST.size = sizeof(uint8_t);
1858 DU_ALLOC(servedPlmn->list.array[arrayIdx]->\
1859 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1860 list.array[sliceLstIdx]->sNSSAI.sST.buf,servedPlmn->list.array[arrayIdx]->\
1861 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.list.array[sliceLstIdx]->\
1864 if(servedPlmn->list.array[arrayIdx]->\
1865 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1866 list.array[sliceLstIdx]->sNSSAI.sST.buf == NULLP)
1868 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
1871 servedPlmn->list.array[arrayIdx]->\
1872 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1873 list.array[sliceLstIdx]->sNSSAI.sST.buf[arrayIdx] = duCfgParam.srvdCellLst[arrayIdx].duCellInfo.\
1874 cellInfo.srvdPlmn[arrayIdx].taiSliceSuppLst.snssai[sliceLstIdx]->sst;
1876 DU_ALLOC(servedPlmn->list.array[arrayIdx]->\
1877 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1878 list.array[sliceLstIdx]->sNSSAI.sD,sizeof(OCTET_STRING_t));
1879 if(servedPlmn->list.array[arrayIdx]->\
1880 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1881 list.array[sliceLstIdx]->sNSSAI.sD == NULLP)
1883 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
1886 servedPlmn->list.array[arrayIdx]->\
1887 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1888 list.array[sliceLstIdx]->sNSSAI.sD->size = 3 * sizeof(uint8_t);
1889 DU_ALLOC(servedPlmn->list.array[arrayIdx]->\
1890 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1891 list.array[sliceLstIdx]->sNSSAI.sD->buf,servedPlmn->list.array[arrayIdx]->\
1892 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1893 list.array[sliceLstIdx]->sNSSAI.sD->size);
1894 if(servedPlmn->list.array[arrayIdx]->\
1895 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1896 list.array[sliceLstIdx]->sNSSAI.sD->buf == NULLP)
1898 DU_LOG("ERROR --> DU_APP : fillServedPlmns(): Memory allocation failed");
1901 memcpy(servedPlmn->list.array[arrayIdx]->\
1902 iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1903 list.array[sliceLstIdx]->sNSSAI.sD->buf, duCfgParam.srvdCellLst[arrayIdx].duCellInfo.\
1904 cellInfo.srvdPlmn[arrayIdx].taiSliceSuppLst.snssai[sliceLstIdx]->sd,\
1905 servedPlmn->list.array[arrayIdx]->iE_Extensions->list.array[ieIdx]->extensionValue.choice.SliceSupportList.\
1906 list.array[sliceLstIdx]->sNSSAI.sD->size);
1911 /*******************************************************************
1913 * @brief Fills Nr Fdd Info required in ServCellInfo IE
1917 * Function : fillNrFddInfo
1919 * Functionality: Fills Nr Fdd Info required in ServCellInfo IE
1921 * @params[in] FDD_Info_t *fDD
1923 * @return ROK - success
1926 *****************************************************************/
1928 uint8_t fillNrFddInfo(FDD_Info_t *fDD)
1930 fDD->uL_NRFreqInfo.nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.\
1931 f1Mode.mode.fdd.ulNrFreqInfo.nrArfcn;
1932 fDD->uL_NRFreqInfo.freqBandListNr.list.count = 1;
1933 fDD->uL_NRFreqInfo.freqBandListNr.list.size = sizeof(FreqBandNrItem_t*);
1934 DU_ALLOC(fDD->uL_NRFreqInfo.freqBandListNr.list.\
1935 array, fDD->uL_NRFreqInfo.freqBandListNr.list.size);
1936 if(fDD->uL_NRFreqInfo.freqBandListNr.list.array == NULLP)
1938 DU_LOG("\nERROR --> Memory allocation failed in fillNrFddInfo");
1942 DU_ALLOC(fDD->uL_NRFreqInfo.freqBandListNr.list.array[0], \
1943 sizeof(FreqBandNrItem_t));
1944 if(fDD->uL_NRFreqInfo.freqBandListNr.list.array[0] == NULLP)
1946 DU_LOG("\nERROR --> Memory allocation failed in fillNrFddInfo");
1950 fDD->uL_NRFreqInfo.freqBandListNr.list.array[0]->freqBandIndicatorNr = \
1951 duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.ulNrFreqInfo.\
1952 freqBand[0].nrFreqBand;
1953 fDD->uL_NRFreqInfo.freqBandListNr.list.array[0]->supportedSULBandList.list.count=0;
1954 fDD->dL_NRFreqInfo.nRARFCN = duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.\
1955 dlNrFreqInfo.nrArfcn;
1956 fDD->dL_NRFreqInfo.freqBandListNr.list.count = 1;
1957 fDD->dL_NRFreqInfo.freqBandListNr.list.size = sizeof(FreqBandNrItem_t *);
1958 DU_ALLOC(fDD->dL_NRFreqInfo.freqBandListNr.list.array, fDD->dL_NRFreqInfo.freqBandListNr.list.size);
1959 if(fDD->dL_NRFreqInfo.freqBandListNr.list.array == NULLP)
1961 DU_LOG("\nERROR --> Memory allocation failed in fillNrFddInfo");
1965 DU_ALLOC(fDD->dL_NRFreqInfo.freqBandListNr.list.array[0], sizeof(FreqBandNrItem_t));
1966 if(fDD->dL_NRFreqInfo.freqBandListNr.list.array[0] == NULLP)
1968 DU_LOG("\nERROR --> Memory allocation failed in fillNrFddInfo");
1972 fDD->dL_NRFreqInfo.freqBandListNr.list.array[0]->freqBandIndicatorNr = \
1973 duCfgParam.srvdCellLst[0].duCellInfo.f1Mode.mode.fdd.dlNrFreqInfo.\
1974 freqBand[0].nrFreqBand;
1975 fDD->dL_NRFreqInfo.freqBandListNr.list.array[0]->supportedSULBandList.list.count=0;
1977 /*Transmission Bandwidth*/
1978 fDD->uL_Transmission_Bandwidth.nRSCS = duCfgParam.srvdCellLst[0].duCellInfo.\
1979 f1Mode.mode.fdd.ulTxBw.nrScs;
1980 fDD->uL_Transmission_Bandwidth.nRNRB = duCfgParam.srvdCellLst[0].duCellInfo.\
1981 f1Mode.mode.fdd.ulTxBw.nrb;
1982 fDD->dL_Transmission_Bandwidth.nRSCS = duCfgParam.srvdCellLst[0].duCellInfo.\
1983 f1Mode.mode.fdd.dlTxBw.nrScs;
1984 fDD->dL_Transmission_Bandwidth.nRNRB = duCfgParam.srvdCellLst[0].duCellInfo.\
1985 f1Mode.mode.fdd.dlTxBw.nrb;
1990 /*******************************************************************
1992 * @brief Fills ServCellInfo IE
1996 * Function : fillServedCellInfo
1998 * Functionality: Fills ServCellInfo
2000 * @params[in] Pointer to Served_Cell_Information_t *
2002 * @return ROK - success
2005 *****************************************************************/
2007 uint8_t fillServedCellInfo(Served_Cell_Information_t *srvCellInfo)
2009 uint8_t ieIdx, ieListCnt;
2012 srvCellInfo->nRCGI.pLMN_Identity.size =3*sizeof(uint8_t);
2013 DU_ALLOC(srvCellInfo->nRCGI.pLMN_Identity.buf,\
2014 srvCellInfo->nRCGI.pLMN_Identity.size);
2015 if(srvCellInfo->nRCGI.pLMN_Identity.buf == NULLP)
2017 DU_LOG("\nERROR --> Memory allocation failed in fillServedCellInfo");
2020 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
2021 srvCellInfo->nRCGI.pLMN_Identity.buf);
2022 srvCellInfo->nRCGI.nRCellIdentity.size =5*sizeof(uint8_t);
2023 DU_ALLOC(srvCellInfo->nRCGI.nRCellIdentity.buf,\
2024 srvCellInfo->nRCGI.nRCellIdentity.size);
2025 if(srvCellInfo->nRCGI.nRCellIdentity.buf == NULLP)
2027 DU_LOG("\nERROR --> Memory allocation failed in fillServedCellInfo");
2031 fillBitString(&srvCellInfo->nRCGI.nRCellIdentity, ODU_VALUE_FOUR, ODU_VALUE_FIVE, duCfgParam.sib1Params.cellIdentity);
2033 srvCellInfo->nRPCI = duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrPci;
2037 srvCellInfo->servedPLMNs.list.count = ieListCnt;
2038 srvCellInfo->servedPLMNs.list.size = ieListCnt*sizeof(ServedPLMNs_Item_t *);
2039 DU_ALLOC(srvCellInfo->servedPLMNs.list.array, srvCellInfo->servedPLMNs.list.size);
2040 if(srvCellInfo->servedPLMNs.list.array == NULLP)
2042 DU_LOG("\nERROR --> Memory allocation failed in fillServedCellInfo");
2045 for(ieIdx=0; ieIdx < ieListCnt; ieIdx++)
2047 DU_ALLOC(srvCellInfo->servedPLMNs.list.array[ieIdx], sizeof(ServedPLMNs_Item_t));
2048 if(srvCellInfo->servedPLMNs.list.array[ieIdx]== NULLP)
2050 DU_LOG("\nERROR --> Memory allocation failed in fillServedCellInfo");
2054 if(fillServedPlmns(&srvCellInfo->servedPLMNs))
2056 DU_LOG("\nERROR --> Failed to fill Served Plmn info");
2061 /*nR Mode Info with FDD*/
2062 srvCellInfo->nR_Mode_Info.present = NR_Mode_Info_PR_fDD;
2063 DU_ALLOC(srvCellInfo->nR_Mode_Info.choice.fDD, sizeof(FDD_Info_t));
2064 if(srvCellInfo->nR_Mode_Info.choice.fDD == NULLP)
2066 DU_LOG("\nERROR --> Memory allocation failed in fillServedCellInfo");
2069 if(fillNrFddInfo(srvCellInfo->nR_Mode_Info.choice.fDD))
2071 DU_LOG("\nERROR --> Failed to fill the Nr FDD information");
2075 srvCellInfo->nR_Mode_Info.present = NR_Mode_Info_PR_tDD;
2076 DU_ALLOC(srvCellInfo->nR_Mode_Info.choice.tDD, sizeof(TDD_Info_t));
2077 if(srvCellInfo->nR_Mode_Info.choice.tDD == NULLP)
2079 DU_LOG("\nERROR --> Memory allocation failed in fillServedCellInfo");
2082 if(fillNrTddInfo(srvCellInfo->nR_Mode_Info.choice.tDD) != ROK)
2084 DU_LOG("\nERROR --> Failed to fill the Nr TDD information");
2089 /*Measurement timing Config*/
2090 srvCellInfo->measurementTimingConfiguration.size = sizeof(uint8_t);
2091 DU_ALLOC(srvCellInfo->measurementTimingConfiguration.\
2092 buf,srvCellInfo->measurementTimingConfiguration.size);
2093 if(srvCellInfo->measurementTimingConfiguration.buf == NULLP)
2097 srvCellInfo->measurementTimingConfiguration.\
2098 buf[0] = duCfgParam.srvdCellLst[0].duCellInfo.measTimeCfg;
2103 /*******************************************************************
2105 * @brief Fills ServCellToModItem IE
2109 * Function : fillServCellToModItem
2111 * Functionality: Fills ServCellToModItem IE
2113 * @params[in] Pointer to Served_Cells_To_Modify_Item_t *
2115 * @return ROK - success
2118 *****************************************************************/
2120 uint8_t fillServCellToModItem(Served_Cells_To_Modify_Item_t *modifyItem)
2123 modifyItem->oldNRCGI.pLMN_Identity.size = 3*sizeof(uint8_t);
2124 DU_ALLOC(modifyItem->oldNRCGI.pLMN_Identity.buf,modifyItem->oldNRCGI.pLMN_Identity.size);
2125 if(modifyItem->oldNRCGI.pLMN_Identity.buf == NULLP)
2129 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
2130 modifyItem->oldNRCGI.pLMN_Identity.buf);
2133 modifyItem->oldNRCGI.nRCellIdentity.size = 5*sizeof(uint8_t);
2134 DU_ALLOC(modifyItem->oldNRCGI.nRCellIdentity.buf,\
2135 modifyItem->oldNRCGI.nRCellIdentity.size);
2136 if(modifyItem->oldNRCGI.nRCellIdentity.buf == NULLP)
2140 fillBitString(&modifyItem->oldNRCGI.nRCellIdentity, ODU_VALUE_FOUR, ODU_VALUE_FIVE, duCfgParam.sib1Params.cellIdentity);
2142 if(fillServedCellInfo(&modifyItem->served_Cell_Information))
2148 /*******************************************************************
2150 * @brief Builds ServCellToModList
2154 * Function : buildServCellToModList
2156 * Functionality: Builds the serv cell to Mod List
2158 * @params[in] Pointer to Served_Cells_To_Modify_List_t *
2160 * @return ROK - success
2163 *****************************************************************/
2165 uint8_t buildServCellToModList(Served_Cells_To_Modify_List_t *cellsToModify)
2167 uint8_t ieListCnt, ieIdx;
2168 Served_Cells_To_Modify_Item_t *modifyItem = NULLP;
2171 cellsToModify->list.count = ieListCnt;
2172 cellsToModify->list.size = ieListCnt*sizeof(Served_Cells_To_Modify_ItemIEs_t *);
2173 DU_ALLOC(cellsToModify->list.array,cellsToModify->list.size);
2174 if(cellsToModify->list.array == NULLP)
2178 for(ieIdx=0; ieIdx< ieListCnt; ieIdx++)
2180 DU_ALLOC(cellsToModify->list.array[ieIdx],sizeof(Served_Cells_To_Modify_ItemIEs_t));
2181 if(cellsToModify->list.array[ieIdx] == NULLP)
2186 cellsToModify->list.array[0]->id = ProtocolIE_ID_id_Served_Cells_To_Modify_Item;
2187 cellsToModify->list.array[0]->criticality = Criticality_reject;
2188 cellsToModify->list.array[0]->value.present =\
2189 Served_Cells_To_Modify_ItemIEs__value_PR_Served_Cells_To_Modify_Item;
2190 modifyItem=&cellsToModify->list.array[0]->value.choice.Served_Cells_To_Modify_Item;
2192 if(fillServCellToModItem(modifyItem))
2197 /*******************************************************************
2199 * @brief filling the DeleteItemList
2203 * Function : fillCellToDeleteItem
2205 * Functionality: Filling the DeleteItemIe
2207 * @params[in] Pointer to Served_Cells_To_Delete_ItemIEs_t
2209 * @return ROK - success
2212 *****************************************************************/
2213 uint8_t fillCellToDeleteItem(struct Served_Cells_To_Delete_ItemIEs *deleteItemIe)
2215 Served_Cells_To_Delete_Item_t *deleteItem=NULLP;
2217 deleteItemIe->id = ProtocolIE_ID_id_Served_Cells_To_Delete_Item;
2218 deleteItemIe->criticality = Criticality_reject;
2219 deleteItemIe->value.present =\
2220 Served_Cells_To_Delete_ItemIEs__value_PR_Served_Cells_To_Delete_Item;
2221 deleteItem=&deleteItemIe->value.choice.Served_Cells_To_Delete_Item;
2224 deleteItem->oldNRCGI.pLMN_Identity.size = 3*sizeof(uint8_t);
2225 DU_ALLOC(deleteItem->oldNRCGI.pLMN_Identity.buf,deleteItem->oldNRCGI.pLMN_Identity.size);
2226 if(deleteItem->oldNRCGI.pLMN_Identity.buf == NULLP)
2228 DU_LOG("ERROR --> F1AP: fillCellToDeleteItem(): Failed to allocate the memory");
2231 buildPlmnId(duCfgParam.srvdCellLst[0].duCellInfo.cellInfo.nrCgi.plmn,\
2232 deleteItem->oldNRCGI.pLMN_Identity.buf);
2235 deleteItem->oldNRCGI.nRCellIdentity.size = 5*sizeof(uint8_t);
2236 DU_ALLOC(deleteItem->oldNRCGI.nRCellIdentity.buf,\
2237 deleteItem->oldNRCGI.nRCellIdentity.size);
2238 if(deleteItem->oldNRCGI.nRCellIdentity.buf == NULLP)
2240 DU_LOG("ERROR --> F1AP: fillCellToDeleteItem(): Failed to allocate the memory");
2243 fillBitString(&deleteItem->oldNRCGI.nRCellIdentity, ODU_VALUE_FOUR, ODU_VALUE_FIVE, duCfgParam.sib1Params.cellIdentity);
2246 /*******************************************************************
2248 * @brief Builds ServCellToDeleteList
2252 * Function : buildServCellToDeleteList
2254 * Functionality: Builds the serv cell to delete List
2256 * @params[in] Pointer to Served_Cells_To_Delete_List_t *
2258 * @return ROK - success
2261 *****************************************************************/
2263 uint8_t buildServCellToDeleteList(Served_Cells_To_Delete_List_t *cellsToDelete)
2265 uint8_t ieListCnt, arrIdx;
2268 cellsToDelete->list.count = ieListCnt;
2269 cellsToDelete->list.size = ieListCnt*sizeof(Served_Cells_To_Delete_ItemIEs_t *);
2271 DU_ALLOC(cellsToDelete->list.array,cellsToDelete->list.size);
2272 if(cellsToDelete->list.array == NULLP)
2274 DU_LOG("\nERROR --> F1AP : buildServCellToDeleteList(): Memory allocation failed");
2278 for(arrIdx=0; arrIdx< ieListCnt; arrIdx++)
2280 DU_ALLOC(cellsToDelete->list.array[arrIdx],sizeof(Served_Cells_To_Delete_ItemIEs_t));
2281 if(cellsToDelete->list.array[arrIdx] == NULLP)
2283 DU_LOG("\nERROR --> F1AP : buildServCellToDeleteList(): Memory allocation failed");
2289 if(fillCellToDeleteItem((Served_Cells_To_Delete_ItemIEs_t*)cellsToDelete->list.array[arrIdx]) !=ROK)
2291 DU_LOG("\nERROR --> F1AP: buildServCellToDeleteList(): failed to fill Served_Cells_To_Delete_ItemIEs");
2297 /*******************************************************************
2299 * @brief Builds and sends the DUConfigUpdate
2303 * Function : BuildAndSendDUConfigUpdate
2305 * Functionality: Constructs the DU Update message and sends
2306 * it to the CU through SCTP.
2308 * @params[in] void **buf,Buffer to which encoded pattern is written into
2309 * @params[in] int *size,size of buffer
2311 * @return ROK - success
2314 * ****************************************************************/
2315 uint8_t BuildAndSendDUConfigUpdate(ServCellAction servCellAction)
2317 uint8_t ret =0, ieIdx=0, elementCnt=0;
2318 bool memAlloctionFailure = false;
2319 F1AP_PDU_t *f1apDuCfg = NULLP;
2320 GNBDUConfigurationUpdate_t *duCfgUpdate = NULLP;
2321 asn_enc_rval_t encRetVal; /* Encoder return value */
2323 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
2328 DU_LOG("\nINFO --> F1AP : Building DU config update\n");
2329 /* Allocate the memory for F1DuCfg */
2330 DU_ALLOC(f1apDuCfg, sizeof(F1AP_PDU_t));
2331 if(f1apDuCfg == NULLP)
2333 DU_LOG("\nERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation for F1AP-PDU failed");
2337 f1apDuCfg->present = F1AP_PDU_PR_initiatingMessage;
2338 DU_ALLOC(f1apDuCfg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
2339 if(f1apDuCfg->choice.initiatingMessage == NULLP)
2341 DU_LOG("\nERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation for F1AP-PDU failed");
2345 f1apDuCfg->choice.initiatingMessage->procedureCode = \
2346 ProcedureCode_id_gNBDUConfigurationUpdate;
2347 f1apDuCfg->choice.initiatingMessage->criticality = Criticality_reject;
2348 f1apDuCfg->choice.initiatingMessage->value.present = \
2349 InitiatingMessage__value_PR_GNBDUConfigurationUpdate;
2350 duCfgUpdate = &f1apDuCfg->choice.initiatingMessage->value.\
2351 choice.GNBDUConfigurationUpdate;
2353 duCfgUpdate->protocolIEs.list.count = elementCnt;
2354 duCfgUpdate->protocolIEs.list.size = \
2355 elementCnt * sizeof(GNBDUConfigurationUpdateIEs_t*);
2357 /* Initialize the F1Setup members */
2358 DU_ALLOC(duCfgUpdate->protocolIEs.list.array,duCfgUpdate->protocolIEs.list.size);
2359 if(duCfgUpdate->protocolIEs.list.array == NULLP)
2361 DU_LOG("ERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation failed");
2364 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
2366 DU_ALLOC(duCfgUpdate->protocolIEs.list.array[ieIdx],sizeof(GNBDUConfigurationUpdateIEs_t));
2367 if(duCfgUpdate->protocolIEs.list.array[ieIdx] == NULLP)
2369 DU_LOG("ERROR --> F1AP : BuildAndSendDUConfigUpdate(): Memory allocation failed");
2370 memAlloctionFailure = true;
2375 if(memAlloctionFailure == true)
2381 duCfgUpdate->protocolIEs.list.array[ieIdx]->id=ProtocolIE_ID_id_TransactionID;
2382 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
2383 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2384 GNBDUConfigurationUpdateIEs__value_PR_TransactionID;
2385 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.TransactionID = TRANS_ID;
2388 if(servCellAction == SERV_CELL_TO_MODIFY)
2390 /*Served Cell to Modify */
2391 duCfgUpdate->protocolIEs.list.array[ieIdx]->id = \
2392 ProtocolIE_ID_id_Served_Cells_To_Modify_List;
2393 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality =Criticality_reject;
2394 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2395 GNBDUConfigurationUpdateIEs__value_PR_Served_Cells_To_Modify_List;
2396 if(buildServCellToModList(&duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.\
2397 Served_Cells_To_Modify_List))
2399 DU_LOG("ERROR --> DU APP : BuildAndSendDUConfigUpdate(): failed to build ServCellToModList");
2405 /*Served Cell to Delete */
2406 duCfgUpdate->protocolIEs.list.array[ieIdx]->id = \
2407 ProtocolIE_ID_id_Served_Cells_To_Delete_List;
2408 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality =Criticality_reject;
2409 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2410 GNBDUConfigurationUpdateIEs__value_PR_Served_Cells_To_Delete_List;
2411 if(buildServCellToDeleteList(&duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.\
2412 Served_Cells_To_Delete_List)!=ROK)
2414 DU_LOG("ERROR --> DU APP : BuildAndSendDUConfigUpdate(): failed to build ServCellToDeleteList");
2419 // NOTE :GNB DU SYS INFO:MIB AND SIB1 INFORMATION TO BE BUILT AND FILLED HERE
2422 duCfgUpdate->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_ID;
2423 duCfgUpdate->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
2424 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.present = \
2425 GNBDUConfigurationUpdateIEs__value_PR_GNB_DU_ID;
2426 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size = sizeof(uint8_t);
2427 DU_ALLOC(duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf,\
2428 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.size);
2429 if(duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf == NULLP)
2431 DU_LOG("ERROR --> DU APP : BuildAndSendDUConfigUpdate(): Memory allocation failed for GNB_DU_ID");
2434 duCfgUpdate->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_ID.buf[0] = duCfgParam.duId;
2436 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apDuCfg);
2438 /* Encode the DU Config Update type as APER */
2439 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
2441 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apDuCfg, PrepFinalEncBuf, encBuf);
2443 /* Checking encode results */
2444 if(encRetVal.encoded == ENCODE_FAIL)
2446 DU_LOG("ERROR --> F1AP : Could not encode DUConfigUpdate structure (at %s)\n",\
2447 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
2452 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for DUConfigUpdate\n");
2453 #ifdef DEBUG_ASN_PRINT
2454 for(ieIdx =0; ieIdx < encBufSize; ieIdx++)
2456 printf("%x",encBuf[ieIdx]);
2461 if(sendF1APMsg() != ROK)
2463 DU_LOG("\nERROR --> F1AP : Sending GNB-DU Config Update failed");
2471 addToReservedF1apPduList(TRANS_ID,f1apDuCfg);
2476 /*******************************************************************
2478 * @brief free the ULRRCMessageTransfer
2482 * Function : FreeULRRCMessageTransfer
2484 * Functionality: Deallocating the memory of variable allocated in
2485 * FreeULRRCMessageTransfer
2489 * @return ROK - void
2491 ******************************************************************/
2492 void FreeULRRCMessageTransfer( F1AP_PDU_t *f1apMsg)
2495 ULRRCMessageTransfer_t *ulRRCMsg;
2497 if(f1apMsg != NULLP)
2499 if(f1apMsg->choice.initiatingMessage != NULLP)
2501 ulRRCMsg = &f1apMsg->choice.initiatingMessage->value.choice.ULRRCMessageTransfer;
2502 if(ulRRCMsg->protocolIEs.list.array != NULLP)
2504 for(idx1=0;idx1<ulRRCMsg->protocolIEs.list.count;idx1++)
2506 if(ulRRCMsg->protocolIEs.list.array[idx1] != NULLP)
2508 if(ulRRCMsg->protocolIEs.list.array[idx1]->value.present ==
2509 ULRRCMessageTransferIEs__value_PR_RRCContainer)
2511 DU_FREE(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf,
2512 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size);
2514 DU_FREE(ulRRCMsg->protocolIEs.list.array[idx1],sizeof(ULRRCMessageTransferIEs_t));
2517 DU_FREE(ulRRCMsg->protocolIEs.list.array,ulRRCMsg->protocolIEs.list.size );
2519 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
2521 DU_FREE(f1apMsg,sizeof(F1AP_PDU_t));
2524 /*******************************************************************
2526 * @brief Builds and sends the ULRRCMessageTransfer
2530 * Function : BuildAndSendULRRCMessageTransfer
2532 * Functionality: Constructs the UL RRC Message Transfer and sends
2533 * it to the CU through SCTP.
2537 * @return ROK - success
2540 * ****************************************************************/
2541 uint8_t BuildAndSendULRRCMessageTransfer(DuUeCb *ueCb, uint8_t lcId, \
2542 uint16_t msgLen, uint8_t *rrcMsg)
2544 uint8_t elementCnt=0, idx1=0, idx=0;
2545 uint8_t ret = RFAILED;
2546 F1AP_PDU_t *f1apMsg = NULLP;
2547 ULRRCMessageTransfer_t *ulRRCMsg = NULLP;
2548 asn_enc_rval_t encRetVal; /* Encoder return value */
2550 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
2554 DU_LOG("\n INFO --> F1AP : Building UL RRC Message Transfer Message\n");
2556 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
2557 if(f1apMsg == NULLP)
2559 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
2562 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
2563 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
2564 if(f1apMsg->choice.initiatingMessage == NULLP)
2566 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
2569 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_ULRRCMessageTransfer;
2570 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
2571 f1apMsg->choice.initiatingMessage->value.present = \
2572 InitiatingMessage__value_PR_ULRRCMessageTransfer;
2574 &f1apMsg->choice.initiatingMessage->value.choice.ULRRCMessageTransfer;
2576 ulRRCMsg->protocolIEs.list.count = elementCnt;
2577 ulRRCMsg->protocolIEs.list.size = \
2578 elementCnt * sizeof(ULRRCMessageTransferIEs_t *);
2580 /* Initialize the F1Setup members */
2581 DU_ALLOC(ulRRCMsg->protocolIEs.list.array, ulRRCMsg->protocolIEs.list.size);
2582 if(ulRRCMsg->protocolIEs.list.array == NULLP)
2584 DU_LOG(" ERROR --> F1AP : Memory allocation for UL RRC MessageTransferIEs failed");
2587 for(idx=0; idx<elementCnt; idx++)
2589 DU_ALLOC(ulRRCMsg->protocolIEs.list.array[idx],sizeof(ULRRCMessageTransferIEs_t));
2590 if(ulRRCMsg->protocolIEs.list.array[idx] == NULLP)
2598 /*GNB CU UE F1AP ID*/
2599 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
2600 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2601 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2602 ULRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID;
2603 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.GNB_CU_UE_F1AP_ID = ueCb->gnbCuUeF1apId;
2605 /*GNB DU UE F1AP ID*/
2607 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
2608 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2609 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2610 ULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
2611 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.GNB_DU_UE_F1AP_ID = ueCb->gnbDuUeF1apId;
2615 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_SRBID;
2616 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2617 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2618 ULRRCMessageTransferIEs__value_PR_SRBID;
2619 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.SRBID = lcId;
2623 ulRRCMsg->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_RRCContainer;
2624 ulRRCMsg->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
2625 ulRRCMsg->protocolIEs.list.array[idx1]->value.present = \
2626 ULRRCMessageTransferIEs__value_PR_RRCContainer;
2627 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size = msgLen;
2628 DU_ALLOC(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf,
2629 ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size)
2630 if(!ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf)
2632 DU_LOG(" ERROR --> F1AP : Memory allocation for BuildAndSendULRRCMessageTransfer failed");
2635 memset(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf, 0, msgLen);
2636 memcpy(ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.buf, \
2637 rrcMsg, ulRRCMsg->protocolIEs.list.array[idx1]->value.choice.RRCContainer.size);
2639 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
2641 /* Encode the F1SetupRequest type as APER */
2642 memset(encBuf, 0, ENC_BUF_MAX_LEN);
2644 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
2646 /* Encode results */
2647 if(encRetVal.encoded == ENCODE_FAIL)
2649 DU_LOG( "\nERROR --> F1AP : Could not encode ULRRCMessageTransfer structure (at %s)\n",\
2650 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
2655 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for ULRRCMessageTransfer\n");
2656 #ifdef DEBUG_ASN_PRINT
2657 for(int i=0; i< encBufSize; i++)
2659 printf("%x",encBuf[i]);
2665 if(sendF1APMsg() != ROK)
2667 DU_LOG("\nERROR --> F1AP : Sending UL RRC Message Transfer Failed");
2673 FreeULRRCMessageTransfer(f1apMsg);
2676 }/* End of BuildAndSendULRRCMessageTransfer*/
2678 /*******************************************************************
2680 * @brief Builds tag config
2684 * Function : BuildTagConfig
2686 * Functionality: Builds tag config in MacCellGroupConfig
2688 * @params[in] TAG_Config *tag_Config
2690 * @return ROK - success
2693 * ****************************************************************/
2694 uint8_t BuildTagConfig(DuUeCb *ueCb, struct TAG_Config *tagConfig)
2696 struct TAG_Config__tag_ToAddModList *tagList;
2697 uint8_t idx, elementCnt;
2699 tagConfig->tag_ToReleaseList = NULLP;
2700 tagConfig->tag_ToAddModList = NULLP;
2701 DU_ALLOC(tagConfig->tag_ToAddModList, sizeof(struct TAG_Config__tag_ToAddModList));
2702 if(!tagConfig->tag_ToAddModList)
2704 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildTagConfig");
2709 elementCnt = ODU_VALUE_ONE;
2711 elementCnt = ueCb->macUeCfg.macCellGrpCfg.tagCfg.addModListCount;
2713 tagList = tagConfig->tag_ToAddModList;
2714 tagList->list.count = elementCnt;
2715 tagList->list.size = elementCnt * sizeof(struct TAG *);
2717 tagList->list.array = NULLP;
2718 DU_ALLOC(tagList->list.array, tagList->list.size);
2719 if(!tagList->list.array)
2721 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildTagConfig");
2725 for(idx=0; idx<tagList->list.count; idx++)
2727 tagList->list.array[idx] = NULLP;
2728 DU_ALLOC(tagList->list.array[idx], sizeof(struct TAG));
2729 if(!tagList->list.array[idx])
2731 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildTagConfig");
2739 tagList->list.array[idx]->tag_Id = TAG_ID;
2740 tagList->list.array[idx]->timeAlignmentTimer = TIME_ALIGNMENT_TMR;
2744 for(idx=0; idx<tagList->list.count; idx++)
2746 tagList->list.array[idx]->tag_Id = ueCb->macUeCfg.macCellGrpCfg.tagCfg.addModList[idx].tagId;
2747 tagList->list.array[idx]->timeAlignmentTimer = ueCb->macUeCfg.macCellGrpCfg.tagCfg.addModList[idx].timeAlignTimer;
2754 /*******************************************************************
2756 * @brief Builds PHR Config
2760 * Function : BuildPhrConfig
2762 * Functionality: Builds phrConfig in MacCellGroupConfig
2764 * @params[in] PHR Config *
2766 * @return ROK - success
2769 * ****************************************************************/
2770 uint8_t BuildPhrConfig(DuUeCb *ueCb, struct MAC_CellGroupConfig__phr_Config *phrConfig)
2773 phrConfig->present = MAC_CellGroupConfig__phr_Config_PR_setup;
2774 phrConfig->choice.setup = NULLP;
2775 DU_ALLOC(phrConfig->choice.setup, sizeof(struct PHR_Config));
2776 if(!phrConfig->choice.setup)
2778 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildPhrConfig");
2784 phrConfig->choice.setup->phr_PeriodicTimer = PHR_PERIODIC_TMR;
2785 phrConfig->choice.setup->phr_ProhibitTimer = PHR_PROHIBHIT_TMR;
2786 phrConfig->choice.setup->phr_Tx_PowerFactorChange = PHR_PWR_FACTOR_CHANGE;
2787 phrConfig->choice.setup->multiplePHR = false;
2788 phrConfig->choice.setup->dummy = false;
2789 phrConfig->choice.setup->phr_Type2OtherCell = false;
2790 phrConfig->choice.setup->phr_ModeOtherCG = PHR_MODE_OTHER_CG;
2794 phrConfig->choice.setup->phr_PeriodicTimer = ueCb->macUeCfg.macCellGrpCfg.phrCfg.periodicTimer;
2795 phrConfig->choice.setup->phr_ProhibitTimer = ueCb->macUeCfg.macCellGrpCfg.phrCfg.prohibitTimer;
2796 phrConfig->choice.setup->phr_Tx_PowerFactorChange = ueCb->macUeCfg.macCellGrpCfg.phrCfg.txPowerFactor;
2797 phrConfig->choice.setup->multiplePHR = ueCb->macUeCfg.macCellGrpCfg.phrCfg.multiplePHR;
2798 phrConfig->choice.setup->dummy = ueCb->macUeCfg.macCellGrpCfg.phrCfg.dummy;
2799 phrConfig->choice.setup->phr_Type2OtherCell = ueCb->macUeCfg.macCellGrpCfg.phrCfg.phrType2OtherCell;
2800 phrConfig->choice.setup->phr_ModeOtherCG = ueCb->macUeCfg.macCellGrpCfg.phrCfg.phrOtherCG;
2806 /*******************************************************************
2808 * @brief Builds BSR Config
2812 * Function : BuildBsrConfig
2814 * Functionality: Builds BuildBsrConfig in MacCellGroupConfig
2816 * @params[in] BSR_Config *bsrConfig
2818 * @return ROK - success
2821 * ****************************************************************/
2822 uint8_t BuildBsrConfig(DuUeCb *ueCb, struct BSR_Config *bsrConfig)
2826 bsrConfig->periodicBSR_Timer = PERIODIC_BSR_TMR;
2827 bsrConfig->retxBSR_Timer = RETX_BSR_TMR;
2828 bsrConfig->logicalChannelSR_DelayTimer = NULLP;
2832 bsrConfig->periodicBSR_Timer = convertBsrPeriodicTmrValueToEnum(ueCb->macUeCfg.macCellGrpCfg.bsrTmrCfg.periodicTimer);
2833 bsrConfig->retxBSR_Timer = convertBsrRetxTmrValueToEnum(ueCb->macUeCfg.macCellGrpCfg.bsrTmrCfg.retxTimer);
2835 bsrConfig->logicalChannelSR_DelayTimer = NULLP;
2836 DU_ALLOC(bsrConfig->logicalChannelSR_DelayTimer, sizeof(long));
2837 if(bsrConfig->logicalChannelSR_DelayTimer == NULLP)
2839 DU_LOG("\nERROR --> DU APP: Memory allocation failed in BuildBsrConfig");
2842 *(bsrConfig->logicalChannelSR_DelayTimer) = convertLcSrDelayTmrValueToEnum(ueCb->macUeCfg.macCellGrpCfg.bsrTmrCfg.srDelayTimer);
2848 /*******************************************************************
2850 * @brief Builds scheduling request config
2854 * Function : BuildSchedulingReqConfig
2856 * Functionality: Builds BuildSchedulingReqConfig in MacCellGroupConfig
2858 * @params[in] SchedulingRequestConfig *schedulingRequestConfig
2860 * @return ROK - success
2863 * ****************************************************************/
2864 uint8_t BuildSchedulingReqConfig(DuUeCb *ueCb, struct SchedulingRequestConfig *schedulingRequestConfig)
2866 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList;
2867 uint8_t idx, elementCnt;
2869 schedulingRequestConfig->schedulingRequestToAddModList = NULLP;
2870 DU_ALLOC(schedulingRequestConfig->schedulingRequestToAddModList,
2871 sizeof(struct SchedulingRequestConfig__schedulingRequestToAddModList));
2872 if(!schedulingRequestConfig->schedulingRequestToAddModList)
2874 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
2879 elementCnt = ODU_VALUE_ONE;
2881 elementCnt = ueCb->macUeCfg.macCellGrpCfg.schReqCfg.addModListCount;
2883 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
2884 schReqList->list.count = elementCnt;
2885 schReqList->list.size = elementCnt * sizeof(struct SchedulingRequestToAddMod *);
2887 schReqList->list.array = NULLP;
2888 DU_ALLOC(schReqList->list.array, schReqList->list.size);
2889 if(!schReqList->list.array)
2891 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
2895 for(idx=0; idx<schReqList->list.count; idx++)
2897 schReqList->list.array[idx] = NULLP;
2898 DU_ALLOC(schReqList->list.array[idx], sizeof(struct SchedulingRequestToAddMod));
2899 if(!schReqList->list.array[idx])
2901 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
2909 schReqList->list.array[idx]->schedulingRequestId = SCH_REQ_ID;
2911 schReqList->list.array[idx]->sr_ProhibitTimer = NULLP;
2912 DU_ALLOC(schReqList->list.array[idx]->sr_ProhibitTimer, sizeof(long));
2913 if(!schReqList->list.array[idx]->sr_ProhibitTimer)
2915 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
2918 *(schReqList->list.array[idx]->sr_ProhibitTimer) = SR_PROHIBIT_TMR;
2919 schReqList->list.array[idx]->sr_TransMax = SR_TRANS_MAX;
2923 for(idx=0; idx<schReqList->list.count; idx++)
2925 schReqList->list.array[idx]->schedulingRequestId = ueCb->macUeCfg.macCellGrpCfg.schReqCfg.addModList[idx].schedReqId;
2927 schReqList->list.array[idx]->sr_ProhibitTimer = NULLP;
2928 DU_ALLOC(schReqList->list.array[idx]->sr_ProhibitTimer, sizeof(long));
2929 if(!schReqList->list.array[idx]->sr_ProhibitTimer)
2931 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSchedulingReqConfig");
2934 *(schReqList->list.array[idx]->sr_ProhibitTimer) = ueCb->macUeCfg.macCellGrpCfg.schReqCfg.addModList[idx].srProhibitTmr;
2935 schReqList->list.array[idx]->sr_TransMax = ueCb->macUeCfg.macCellGrpCfg.schReqCfg.addModList[idx].srTransMax;
2939 schedulingRequestConfig->schedulingRequestToReleaseList = NULLP;
2944 /*******************************************************************
2946 * @brief Builds RLC Configuration for AM mode
2950 * Function : BuildRlcConfigAm
2953 * Builds AM mode RLC Config in BuildRlcBearerToAddModList
2955 * @params[in] AmBearerCfg *amCfg
2956 * RLC_Config_t *rlcConfig
2958 * @return ROK - success
2961 * ****************************************************************/
2962 uint8_t BuildRlcConfigAm(AmBearerCfg *amCfg, struct RLC_Config *rlcConfig)
2964 rlcConfig->choice.am = NULLP;
2965 DU_ALLOC(rlcConfig->choice.am, sizeof(struct RLC_Config__am));
2966 if(!rlcConfig->choice.am)
2968 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfigAm");
2972 /* Fill AM UL configuration */
2973 rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength = NULLP;
2974 DU_ALLOC(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
2975 if(!rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength)
2977 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfigAm");
2981 /* Fill default AM UL configuration if input pointer to DU database is NULL */
2984 *(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength) = SN_FIELD_LEN;
2985 rlcConfig->choice.am->ul_AM_RLC.t_PollRetransmit = T_POLL_RETRANSMIT;
2986 rlcConfig->choice.am->ul_AM_RLC.pollPDU = POLL_PDU;
2987 rlcConfig->choice.am->ul_AM_RLC.pollByte = POLL_BYTE;
2988 rlcConfig->choice.am->ul_AM_RLC.maxRetxThreshold = MAX_RETX_THRESHOLD;
2992 *(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength) = covertAmSnLenFromIntEnumToRrcEnum(amCfg->dlAmCfg.snLenDl);
2993 rlcConfig->choice.am->ul_AM_RLC.t_PollRetransmit = covertPollRetxTmrValueToEnum(amCfg->dlAmCfg.pollRetxTmr);
2994 rlcConfig->choice.am->ul_AM_RLC.pollPDU = covertPollPduValueToEnum(amCfg->dlAmCfg.pollPdu);
2995 rlcConfig->choice.am->ul_AM_RLC.pollByte = covertPollByteValueToEnum(amCfg->dlAmCfg.pollByte);
2996 rlcConfig->choice.am->ul_AM_RLC.maxRetxThreshold = covertMaxRetxValueToEnum(amCfg->dlAmCfg.maxRetxTh);
2999 /* Fill AM DL configuraion */
3000 rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength = NULLP;
3001 DU_ALLOC(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
3002 if(!rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength)
3004 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfigAm");
3008 /* Fill default AM DL configuration if input pointer to DU database is NULL */
3011 *(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength) = SN_FIELD_LEN;
3012 rlcConfig->choice.am->dl_AM_RLC.t_Reassembly = T_REASSEMBLY;
3013 rlcConfig->choice.am->dl_AM_RLC.t_StatusProhibit = T_STATUS_PROHIBHIT;
3015 else /* Fill AM configuration from DU database */
3017 *(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength) = covertAmSnLenFromIntEnumToRrcEnum(amCfg->ulAmCfg.snLenUl);
3018 rlcConfig->choice.am->dl_AM_RLC.t_Reassembly = convertReasmblTmrValueToEnum(amCfg->ulAmCfg.reAssemTmr);
3019 rlcConfig->choice.am->dl_AM_RLC.t_StatusProhibit = convertProhibitTmrValueToEnum(amCfg->ulAmCfg.statProhTmr);
3024 /*******************************************************************
3026 * @brief Builds RLC Config for UM Bidirection
3030 * Function : BuildRlcConfig UmBiDir
3033 * Builds RLC Config for UM Bidirection in BuildRlcBearerToAddModList
3035 * @params[in] UmBiDirBearerCfg *umBiDirCfg
3036 * RLC_Config_t *rlcConfig
3038 * @return ROK - success
3041 * ****************************************************************/
3042 uint8_t BuildRlcConfigUmBiDir(UmBiDirBearerCfg *umBiDirCfg, struct RLC_Config *rlcConfig)
3044 rlcConfig->choice.um_Bi_Directional = NULLP;
3045 DU_ALLOC(rlcConfig->choice.um_Bi_Directional, sizeof(struct RLC_Config__um_Bi_Directional));
3046 if(rlcConfig->choice.um_Bi_Directional == NULLP)
3048 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfigUmBiDir");
3052 /* Fill UM Bidirectional UL configuration */
3053 rlcConfig->choice.um_Bi_Directional->ul_UM_RLC.sn_FieldLength = NULLP;
3054 DU_ALLOC(rlcConfig->choice.um_Bi_Directional->ul_UM_RLC.sn_FieldLength, sizeof(SN_FieldLengthUM_t));
3055 if(rlcConfig->choice.um_Bi_Directional->ul_UM_RLC.sn_FieldLength == NULLP)
3057 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfigUmBiDir");
3061 if(umBiDirCfg != NULLP)
3063 *(rlcConfig->choice.um_Bi_Directional->ul_UM_RLC.sn_FieldLength) = covertUmSnLenFromIntEnumToRrcEnum(umBiDirCfg->dlUmCfg.snLenDlUm);
3066 /* Fill UM Bidirectional DL configuration */
3067 rlcConfig->choice.um_Bi_Directional->dl_UM_RLC.sn_FieldLength = NULLP;
3068 DU_ALLOC(rlcConfig->choice.um_Bi_Directional->dl_UM_RLC.sn_FieldLength, sizeof(SN_FieldLengthUM_t));
3069 if(rlcConfig->choice.um_Bi_Directional->dl_UM_RLC.sn_FieldLength == NULLP)
3071 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfigUmBiDir");
3075 if(umBiDirCfg != NULLP)
3077 *(rlcConfig->choice.um_Bi_Directional->dl_UM_RLC.sn_FieldLength) = covertUmSnLenFromIntEnumToRrcEnum(umBiDirCfg->ulUmCfg.snLenUlUm);
3078 rlcConfig->choice.um_Bi_Directional->dl_UM_RLC.t_Reassembly = convertReasmblTmrValueToEnum(umBiDirCfg->ulUmCfg.reAssemTmr);
3084 /*******************************************************************
3086 * @brief Builds RLC Config for UM Uni directional UL
3090 * Function : BuildRlcConfigUmUniDirUl
3093 * Builds RLC Config for UM Unidirection UL in BuildRlcBearerToAddModList
3095 * @params[in] UmUniDirDlBearerCfg *umUniDirDlCfg
3096 * RLC_Config_t *rlcConfig
3098 * @return ROK - success
3101 * ****************************************************************/
3102 uint8_t BuildRlcConfigUmUniDirUl(UmUniDirDlBearerCfg *umUniDirDlCfg, RLC_Config_t *rlcConfig)
3104 rlcConfig->choice.um_Uni_Directional_UL = NULLP;
3105 DU_ALLOC(rlcConfig->choice.um_Uni_Directional_UL , sizeof(struct RLC_Config__um_Uni_Directional_UL));
3106 if(rlcConfig->choice.um_Uni_Directional_UL == NULLP)
3108 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfigUmUniDirUl");
3112 rlcConfig->choice.um_Uni_Directional_UL->ul_UM_RLC.sn_FieldLength = NULLP;
3113 DU_ALLOC(rlcConfig->choice.um_Uni_Directional_UL->ul_UM_RLC.sn_FieldLength, sizeof(SN_FieldLengthUM_t));
3114 if(rlcConfig->choice.um_Uni_Directional_UL->ul_UM_RLC.sn_FieldLength == NULLP)
3116 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfigUmUniDirUl");
3120 if(umUniDirDlCfg != NULLP)
3122 *(rlcConfig->choice.um_Uni_Directional_UL->ul_UM_RLC.sn_FieldLength) = covertUmSnLenFromIntEnumToRrcEnum(umUniDirDlCfg->dlUmCfg.snLenDlUm);
3128 /*******************************************************************
3130 * @brief Builds RLC Config for UM Uni directional DL
3134 * Function : BuildRlcConfigUmUniDirDl
3137 * Builds RLC Config for UM Unidirection DL in BuildRlcBearerToAddModList
3139 * @params[in] UmUniDirUlBearerCfg *umUniDirUlCfg
3140 * RLC_Config_t *rlcConfig
3142 * @return ROK - success
3145 * ****************************************************************/
3146 uint8_t BuildRlcConfigUmUniDirDl(UmUniDirUlBearerCfg *umUniDirUlCfg, RLC_Config_t *rlcConfig)
3148 rlcConfig->choice.um_Uni_Directional_DL = NULLP;
3149 DU_ALLOC(rlcConfig->choice.um_Uni_Directional_DL , sizeof(struct RLC_Config__um_Uni_Directional_DL));
3150 if(rlcConfig->choice.um_Uni_Directional_DL == NULLP)
3152 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfigUmUniDirDl");
3156 rlcConfig->choice.um_Uni_Directional_DL->dl_UM_RLC.sn_FieldLength = NULLP;
3157 DU_ALLOC(rlcConfig->choice.um_Uni_Directional_DL->dl_UM_RLC.sn_FieldLength, sizeof(SN_FieldLengthUM_t));
3158 if(rlcConfig->choice.um_Uni_Directional_DL->dl_UM_RLC.sn_FieldLength == NULLP)
3160 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcConfigUmUniDirDl");
3164 if(umUniDirUlCfg != NULLP)
3166 *(rlcConfig->choice.um_Uni_Directional_DL->dl_UM_RLC.sn_FieldLength) = covertUmSnLenFromIntEnumToRrcEnum(umUniDirUlCfg->ulUmCfg.snLenUlUm);
3167 rlcConfig->choice.um_Uni_Directional_DL->dl_UM_RLC.t_Reassembly = convertReasmblTmrValueToEnum(umUniDirUlCfg->ulUmCfg.reAssemTmr);
3173 /*******************************************************************
3175 * @brief Builds RLC Config
3179 * Function : BuildRlcConfig
3181 * Functionality: Builds RLC Config in BuildRlcBearerToAddModList
3183 * @params[in] RLC_Config_t *rlcConfig
3185 * @return ROK - success
3188 * ****************************************************************/
3189 uint8_t BuildRlcConfig(RlcBearerCfg *rbCfg, struct RLC_Config *rlcConfig)
3192 /* Fill default values if rbCfg is NULL */
3195 rlcConfig->present = RLC_Config_PR_am;
3196 BuildRlcConfigAm(NULLP, rlcConfig);
3198 /* If RbCfg is present, fill RLC configurations from DU Database */
3201 rlcConfig->present = covertRlcModeFromIntEnumToRrcEnum(rbCfg->rlcMode);
3202 switch(rlcConfig->present)
3204 case RLC_Config_PR_am:
3205 BuildRlcConfigAm(rbCfg->u.amCfg, rlcConfig);
3207 case RLC_Config_PR_um_Bi_Directional:
3208 BuildRlcConfigUmBiDir(rbCfg->u.umBiDirCfg, rlcConfig);
3210 case RLC_Config_PR_um_Uni_Directional_UL:
3211 BuildRlcConfigUmUniDirUl(rbCfg->u.umUniDirDlCfg, rlcConfig);
3213 case RLC_Config_PR_um_Uni_Directional_DL:
3214 BuildRlcConfigUmUniDirDl(rbCfg->u.umUniDirUlCfg, rlcConfig);
3216 case RLC_Config_PR_NOTHING:
3225 /*******************************************************************
3227 * @brief Builds MAC LC Config
3231 * Function : BuildMacLCConfig
3233 * Functionality: Builds MAC LC Config in BuildRlcBearerToAddModList
3235 * @params[in] struct LogicalChannelConfig macLcConfig
3237 * @return ROK - success
3240 * ****************************************************************/
3241 uint8_t BuildMacLCConfig(LcCfg *lcCfgDb, struct LogicalChannelConfig *macLcConfig)
3243 macLcConfig->ul_SpecificParameters = NULLP;
3244 DU_ALLOC(macLcConfig->ul_SpecificParameters, sizeof(struct LogicalChannelConfig__ul_SpecificParameters));
3245 if(!macLcConfig->ul_SpecificParameters)
3247 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacLCConfig");
3251 if(lcCfgDb == NULLP)
3253 macLcConfig->ul_SpecificParameters->priority = MAC_LC_PRIORITY;
3254 macLcConfig->ul_SpecificParameters->prioritisedBitRate = PRIORTISIED_BIT_RATE;
3255 macLcConfig->ul_SpecificParameters->bucketSizeDuration = BUCKET_SIZE_DURATION;
3259 macLcConfig->ul_SpecificParameters->priority = lcCfgDb->ulLcCfg.priority;
3260 macLcConfig->ul_SpecificParameters->prioritisedBitRate = lcCfgDb->ulLcCfg.pbr;
3261 macLcConfig->ul_SpecificParameters->bucketSizeDuration = lcCfgDb->ulLcCfg.bsd;
3264 macLcConfig->ul_SpecificParameters->allowedServingCells = NULLP;
3265 macLcConfig->ul_SpecificParameters->allowedSCS_List = NULLP;
3266 macLcConfig->ul_SpecificParameters->maxPUSCH_Duration = NULLP;
3267 macLcConfig->ul_SpecificParameters->configuredGrantType1Allowed = NULLP;
3269 macLcConfig->ul_SpecificParameters->logicalChannelGroup = NULLP;
3270 DU_ALLOC(macLcConfig->ul_SpecificParameters->logicalChannelGroup, sizeof(long));
3271 if(!macLcConfig->ul_SpecificParameters->logicalChannelGroup)
3273 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacLCConfig");
3277 if(lcCfgDb == NULLP)
3278 *(macLcConfig->ul_SpecificParameters->logicalChannelGroup) = LC_GRP;
3280 *(macLcConfig->ul_SpecificParameters->logicalChannelGroup) = lcCfgDb->ulLcCfg.lcGroup;
3282 macLcConfig->ul_SpecificParameters->schedulingRequestID = NULLP;
3283 DU_ALLOC(macLcConfig->ul_SpecificParameters->schedulingRequestID, sizeof(SchedulingRequestId_t));
3284 if(!macLcConfig->ul_SpecificParameters->schedulingRequestID)
3286 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacLCConfig");
3290 if(lcCfgDb == NULLP)
3291 *(macLcConfig->ul_SpecificParameters->schedulingRequestID) = SCH_REQ_ID;
3293 *(macLcConfig->ul_SpecificParameters->schedulingRequestID) = lcCfgDb->ulLcCfg.schReqId;
3295 macLcConfig->ul_SpecificParameters->logicalChannelSR_Mask = false;
3296 macLcConfig->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = false;
3297 macLcConfig->ul_SpecificParameters->bitRateQueryProhibitTimer = NULLP;
3302 /*******************************************************************
3304 * @brief Builds RLC Bearer to Add/Mod list
3308 * Function :BuildRlcBearerToAddModList
3310 * Functionality: Builds RLC Bearer to Add/Mod list in DuToCuRrcContainer
3312 * @params[in] rlc_BearerToAddModList
3314 * @return ROK - success
3317 * ****************************************************************/
3318 uint8_t BuildRlcBearerToAddModList(DuUeCb *ueCb, struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList)
3320 uint8_t idx = 0, lcIdx=0, macLcIdx = 0, elementCnt = 0;
3324 else if(ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY)
3325 elementCnt = ueCb->rlcUeCfg.numLcs;
3328 for(lcIdx = 0; lcIdx<ueCb->rlcUeCfg.numLcs; lcIdx++)
3330 if(ueCb->rlcUeCfg.rlcLcCfg[lcIdx].isLcAddModRspSent == false)
3334 rlcBearerList->list.count = elementCnt;
3335 rlcBearerList->list.size = elementCnt * sizeof(struct RLC_BearerConfig *);
3337 rlcBearerList->list.array = NULLP;
3338 DU_ALLOC(rlcBearerList->list.array, rlcBearerList->list.size);
3339 if(!rlcBearerList->list.array)
3341 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3345 for(idx=0; idx<rlcBearerList->list.count; idx++)
3347 rlcBearerList->list.array[idx] = NULLP;
3348 DU_ALLOC(rlcBearerList->list.array[idx], sizeof(struct RLC_BearerConfig));
3349 if(!rlcBearerList->list.array[idx])
3351 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3359 rlcBearerList->list.array[idx]->logicalChannelIdentity = SRB1_LCID;
3360 DU_ALLOC(rlcBearerList->list.array[idx]->servedRadioBearer, sizeof(struct RLC_BearerConfig__servedRadioBearer));
3361 if(!rlcBearerList->list.array[idx]->servedRadioBearer)
3363 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3366 rlcBearerList->list.array[idx]->servedRadioBearer->present = RLC_BearerConfig__servedRadioBearer_PR_srb_Identity;
3367 rlcBearerList->list.array[idx]->servedRadioBearer->choice.srb_Identity = SRB1_LCID;
3368 rlcBearerList->list.array[idx]->reestablishRLC = NULLP;
3370 /* Fill RLC related Configurations for this Radio Bearer */
3371 rlcBearerList->list.array[idx]->rlc_Config = NULLP;
3372 DU_ALLOC(rlcBearerList->list.array[idx]->rlc_Config, sizeof(struct RLC_Config));
3373 if(!rlcBearerList->list.array[idx]->rlc_Config)
3375 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3378 if(BuildRlcConfig(NULLP, rlcBearerList->list.array[idx]->rlc_Config) != ROK)
3380 DU_LOG("\nERROR --> F1AP : BuildRlcConfig failed");
3384 /* Fill MAC related configurations for this Radio Bearer */
3385 rlcBearerList->list.array[idx]->mac_LogicalChannelConfig = NULLP;
3386 DU_ALLOC(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig, sizeof(struct LogicalChannelConfig));
3387 if(!rlcBearerList->list.array[idx]->mac_LogicalChannelConfig)
3389 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3392 if(BuildMacLCConfig(NULLP, rlcBearerList->list.array[idx]->mac_LogicalChannelConfig) != ROK)
3394 DU_LOG("\nERROR --> F1AP : BuildMacLCConfig failed");
3401 for(lcIdx=0; lcIdx<ueCb->rlcUeCfg.numLcs; lcIdx++)
3403 if((ueCb->f1UeDb->actionType != UE_CTXT_CFG_QUERY) && (ueCb->rlcUeCfg.rlcLcCfg[lcIdx].isLcAddModRspSent == true))
3406 /* Fill Logical channel identity */
3407 rlcBearerList->list.array[idx]->logicalChannelIdentity = ueCb->rlcUeCfg.rlcLcCfg[lcIdx].lcId;
3409 /* Fill Radio Bearer Id and type (DRB/SRB) for this logical channel */
3410 DU_ALLOC(rlcBearerList->list.array[idx]->servedRadioBearer, sizeof(struct RLC_BearerConfig__servedRadioBearer));
3411 if(!rlcBearerList->list.array[idx]->servedRadioBearer)
3413 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3416 rlcBearerList->list.array[idx]->servedRadioBearer->present = \
3417 covertRbTypeFromIntEnumToRrcEnum(ueCb->rlcUeCfg.rlcLcCfg[lcIdx].rbType);
3418 switch(rlcBearerList->list.array[idx]->servedRadioBearer->present)
3420 case RLC_BearerConfig__servedRadioBearer_PR_srb_Identity:
3421 rlcBearerList->list.array[idx]->servedRadioBearer->choice.srb_Identity = ueCb->rlcUeCfg.rlcLcCfg[lcIdx].rbId;
3423 case RLC_BearerConfig__servedRadioBearer_PR_drb_Identity:
3424 rlcBearerList->list.array[idx]->servedRadioBearer->choice.drb_Identity = ueCb->rlcUeCfg.rlcLcCfg[lcIdx].rbId;
3426 case RLC_BearerConfig__servedRadioBearer_PR_NOTHING:
3430 ueCb->rlcUeCfg.rlcLcCfg[lcIdx].isLcAddModRspSent = true;
3432 rlcBearerList->list.array[idx]->reestablishRLC = NULLP;
3434 /* Fill RLC related Configurations for this Radio Bearer */
3435 rlcBearerList->list.array[idx]->rlc_Config = NULLP;
3436 DU_ALLOC(rlcBearerList->list.array[idx]->rlc_Config, sizeof(struct RLC_Config));
3437 if(!rlcBearerList->list.array[idx]->rlc_Config)
3439 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3442 if(BuildRlcConfig(&ueCb->rlcUeCfg.rlcLcCfg[lcIdx], rlcBearerList->list.array[idx]->rlc_Config) != ROK)
3444 DU_LOG("\nERROR --> F1AP : BuildRlcConfig failed");
3448 /* Fill MAC related configurations for this Radio Bearer */
3449 rlcBearerList->list.array[idx]->mac_LogicalChannelConfig = NULLP;
3450 DU_ALLOC(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig, sizeof(struct LogicalChannelConfig));
3451 if(!rlcBearerList->list.array[idx]->mac_LogicalChannelConfig)
3453 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildRlcBearerToAddModList");
3456 for(macLcIdx = 0; macLcIdx < ueCb->macUeCfg.numLcs; macLcIdx++)
3458 if(ueCb->macUeCfg.lcCfgList[macLcIdx].lcId == ueCb->rlcUeCfg.rlcLcCfg[lcIdx].lcId)
3460 if(BuildMacLCConfig(&ueCb->macUeCfg.lcCfgList[macLcIdx], rlcBearerList->list.array[idx]->mac_LogicalChannelConfig) != ROK)
3462 DU_LOG("\nERROR --> F1AP : BuildMacLCConfig failed");
3475 /*******************************************************************
3477 * @brief Build Control resource set to add/modify list
3481 * Function : BuildControlRSetToAddModList
3483 * Functionality: Build Control resource set to add/modify list
3486 * struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList
3488 * @return ROK - success
3491 * ****************************************************************/
3492 uint8_t BuildControlRSetToAddModList(PdcchConfig *pdcchCfg, struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList)
3496 uint8_t numBytes, bitsUnused;
3497 struct ControlResourceSet *controlRSet;
3498 uint8_t freqDomainResource[FREQ_DOM_RSRC_SIZE] = {0};
3499 uint8_t coreset0EndPrb, coreset1StartPrb, coreset1NumPrb;
3501 if(pdcchCfg == NULLP)
3504 elementCnt = pdcchCfg->numCRsetToAddMod;
3506 controlRSetList->list.count = elementCnt;
3507 controlRSetList->list.size = elementCnt * sizeof(struct ControlResourceSet *);
3509 controlRSetList->list.array = NULLP;
3510 DU_ALLOC(controlRSetList->list.array, controlRSetList->list.size);
3511 if(!controlRSetList->list.array)
3513 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3517 for(idx = 0; idx < elementCnt; idx++)
3519 controlRSetList->list.array[idx] = NULLP;
3520 DU_ALLOC(controlRSetList->list.array[idx], sizeof(struct ControlResourceSet));
3521 if(!controlRSetList->list.array[idx])
3523 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3528 for(idx = 0; idx < elementCnt; idx++)
3530 controlRSet = controlRSetList->list.array[idx];
3532 if(pdcchCfg == NULLP)
3533 controlRSet->controlResourceSetId = PDCCH_CTRL_RSRC_SET_ONE_ID;
3535 controlRSet->controlResourceSetId = pdcchCfg->cRSetToAddModList[idx].cRSetId;
3539 * Bit string stored ff0000000000
3543 controlRSet->frequencyDomainResources.size = numBytes * sizeof(uint8_t);
3545 controlRSet->frequencyDomainResources.buf = NULLP;
3546 DU_ALLOC(controlRSet->frequencyDomainResources.buf, controlRSet->frequencyDomainResources.size);
3547 if(!controlRSet->frequencyDomainResources.buf)
3549 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3553 memset(controlRSet->frequencyDomainResources.buf, 0, FREQ_DOM_RSRC_SIZE);
3555 if(pdcchCfg == NULLP)
3557 coreset0EndPrb = CORESET0_END_PRB;
3558 coreset1StartPrb = coreset0EndPrb + 6;
3559 coreset1NumPrb = CORESET1_NUM_PRB;
3560 /* calculate the PRBs */
3561 fillCoresetFeqDomAllocMap(((coreset1StartPrb)/6), (coreset1NumPrb/6), freqDomainResource);
3562 memcpy(controlRSet->frequencyDomainResources.buf, freqDomainResource, FREQ_DOM_RSRC_SIZE);
3563 controlRSet->frequencyDomainResources.bits_unused = bitsUnused;
3565 controlRSet->duration = PDCCH_CTRL_RSRC_SET_ONE_DURATION;
3566 controlRSet->cce_REG_MappingType.present = ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved;
3567 controlRSet->precoderGranularity = PDCCH_CTRL_RSRC_SET_ONE_PRECOD_GRANULARITY;
3571 memcpy(controlRSet->frequencyDomainResources.buf, pdcchCfg->cRSetToAddModList[idx].freqDomainRsrc, FREQ_DOM_RSRC_SIZE);
3572 controlRSet->frequencyDomainResources.bits_unused = bitsUnused;
3573 controlRSet->duration = pdcchCfg->cRSetToAddModList[idx].duration;
3574 controlRSet->cce_REG_MappingType.present = pdcchCfg->cRSetToAddModList[idx].cceRegMappingType;
3575 controlRSet->precoderGranularity = pdcchCfg->cRSetToAddModList[idx].precoderGranularity;
3577 controlRSet->tci_StatesPDCCH_ToAddList = NULLP;
3578 controlRSet->tci_StatesPDCCH_ToReleaseList = NULLP;
3579 controlRSet->tci_PresentInDCI = NULLP;
3582 uint8_t tciStateIdx;
3584 DU_ALLOC(controlRset->tci_StatesPDCCH_ToAddList, \
3585 sizeof(struct ControlResourceSet__tci_StatesPDCCH_ToAddList));
3586 if(!controlRset->tci_StatesPDCCH_ToAddList)
3588 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3593 controlRset->tci_StatesPDCCH_ToAddList->list.count = elementCnt;
3594 controlRset->tci_StatesPDCCH_ToAddList->list.size = elementCnt * sizeof(TCI_StateId_t *);
3595 DU_ALLOC(controlRset->tci_StatesPDCCH_ToAddList->list.array, \
3596 controlRset->tci_StatesPDCCH_ToAddList->list.size)
3597 if(!controlRset->tci_StatesPDCCH_ToAddList->list.array)
3599 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3603 for(tciStateIdx = 0; tciStateIdx <elementCntl; tciStateIdx++)
3605 DU_ALLOC(controlRset->tci_StatesPDCCH_ToAddList->list.array[tciStateIdx], sizeof(TCI_StateId_t));
3606 if(!controlRset->tci_StatesPDCCH_ToAddList->list.array[tciStateIdx])
3608 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3615 *(controlRset->tci_StatesPDCCH_ToAddList->list.array[tciStateIdx]);
3617 DU_ALLOC(controlRset->tci_PresentInDCI, sizeof(long));
3618 if(!controlRset->tci_PresentInDCI)
3620 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3624 *(controlRset->tci_PresentInDCI);
3627 controlRSet->pdcch_DMRS_ScramblingID = NULLP;
3628 DU_ALLOC(controlRSet->pdcch_DMRS_ScramblingID, sizeof(long));
3629 if(!controlRSet->pdcch_DMRS_ScramblingID)
3631 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildControlRSetToAddModList");
3634 if(pdcchCfg == NULLP)
3635 *(controlRSet->pdcch_DMRS_ScramblingID) = SCRAMBLING_ID;
3637 *(controlRSet->pdcch_DMRS_ScramblingID) = pdcchCfg->cRSetToAddModList[idx].dmrsScramblingId;
3640 } /* End BuildControlRSetToAddModList */
3642 /*******************************************************************
3644 * @brief Build search space to add/modify list
3648 * Function : BuildSearchSpcToAddModList
3650 * Functionality: Build search space to add/modify list
3653 * @return ROK - success
3656 * ****************************************************************/
3657 uint8_t BuildSearchSpcToAddModList(PdcchConfig *pdcchCfg, struct PDCCH_Config__searchSpacesToAddModList *searchSpcList)
3664 struct SearchSpace *searchSpc;
3666 if(pdcchCfg == NULLP)
3669 elementCnt = pdcchCfg->numSearchSpcToAddMod;
3671 searchSpcList->list.count = elementCnt;
3672 searchSpcList->list.size = elementCnt * sizeof(struct SearchSpace *);
3674 searchSpcList->list.array = NULLP;
3675 DU_ALLOC(searchSpcList->list.array, searchSpcList->list.size);
3676 if(!searchSpcList->list.array)
3678 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3682 for(idx = 0; idx < elementCnt; idx++)
3684 searchSpcList->list.array[idx] = NULLP;
3685 DU_ALLOC(searchSpcList->list.array[idx], sizeof(struct SearchSpace));
3686 if(!searchSpcList->list.array[idx])
3688 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3693 for(idx = 0; idx < elementCnt; idx++)
3695 searchSpc = searchSpcList->list.array[idx];
3697 if(pdcchCfg == NULLP)
3698 searchSpc->searchSpaceId = PDCCH_SRCH_SPC_TWO_ID;
3700 searchSpc->searchSpaceId = pdcchCfg->searchSpcToAddModList[idx].searchSpaceId;
3702 searchSpc->controlResourceSetId = NULLP;
3703 DU_ALLOC(searchSpc->controlResourceSetId, sizeof(ControlResourceSetId_t));
3704 if(!searchSpc->controlResourceSetId)
3706 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3709 if(pdcchCfg == NULLP)
3710 *(searchSpc->controlResourceSetId) = PDCCH_CTRL_RSRC_SET_ONE_ID;
3712 *(searchSpc->controlResourceSetId) = pdcchCfg->searchSpcToAddModList[idx].cRSetId;
3714 searchSpc->monitoringSlotPeriodicityAndOffset = NULLP;
3715 DU_ALLOC(searchSpc->monitoringSlotPeriodicityAndOffset, sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
3716 if(!searchSpc->monitoringSlotPeriodicityAndOffset)
3718 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3721 if(pdcchCfg == NULLP)
3722 searchSpc->monitoringSlotPeriodicityAndOffset->present = SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
3724 searchSpc->monitoringSlotPeriodicityAndOffset->present = pdcchCfg->searchSpcToAddModList[idx].mSlotPeriodicityAndOffset;
3726 searchSpc->duration = NULLP;
3727 searchSpc->monitoringSymbolsWithinSlot = NULLP;
3728 DU_ALLOC(searchSpc->monitoringSymbolsWithinSlot, sizeof(BIT_STRING_t));
3729 if(!searchSpc->monitoringSymbolsWithinSlot)
3731 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3735 /* Values taken from reference logs :
3738 * Bit string stores 8000
3742 searchSpc->monitoringSymbolsWithinSlot->size = numBytes * sizeof(uint8_t);
3743 searchSpc->monitoringSymbolsWithinSlot->buf = NULLP;
3744 DU_ALLOC(searchSpc->monitoringSymbolsWithinSlot->buf, searchSpc->monitoringSymbolsWithinSlot->size);
3745 if(!searchSpc->monitoringSymbolsWithinSlot->buf)
3747 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3750 if(pdcchCfg == NULLP)
3753 searchSpc->monitoringSymbolsWithinSlot->buf[byteIdx++] = PDCCH_SYMBOL_WITHIN_SLOT /* setting MSB to 128 i.e. 0x80 */;
3754 searchSpc->monitoringSymbolsWithinSlot->buf[byteIdx++] = 0;
3757 memcpy(searchSpc->monitoringSymbolsWithinSlot->buf, pdcchCfg->searchSpcToAddModList[idx].mSymbolsWithinSlot, numBytes);
3758 searchSpc->monitoringSymbolsWithinSlot->bits_unused = bitsUnused;
3760 searchSpc->nrofCandidates = NULLP;
3761 DU_ALLOC(searchSpc->nrofCandidates, sizeof(struct SearchSpace__nrofCandidates));
3762 if(!searchSpc->nrofCandidates)
3764 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3768 if(pdcchCfg == NULLP)
3770 searchSpc->nrofCandidates->aggregationLevel1 = PDCCH_SRCH_SPC_TWO_AGG_LVL1_CANDIDATE;
3771 searchSpc->nrofCandidates->aggregationLevel2 = PDCCH_SRCH_SPC_TWO_AGG_LVL2_CANDIDATE;
3772 searchSpc->nrofCandidates->aggregationLevel4 = PDCCH_SRCH_SPC_TWO_AGG_LVL4_CANDIDATE;
3773 searchSpc->nrofCandidates->aggregationLevel8 = PDCCH_SRCH_SPC_TWO_AGG_LVL8_CANDIDATE;
3774 searchSpc->nrofCandidates->aggregationLevel16 = PDCCH_SRCH_SPC_TWO_AGG_LVL16_CANDIDATE;
3778 searchSpc->nrofCandidates->aggregationLevel1 = pdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel1;
3779 searchSpc->nrofCandidates->aggregationLevel2 = pdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel2;
3780 searchSpc->nrofCandidates->aggregationLevel4 = pdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel4;
3781 searchSpc->nrofCandidates->aggregationLevel8 = pdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel8;
3782 searchSpc->nrofCandidates->aggregationLevel16 = pdcchCfg->searchSpcToAddModList[idx].numCandidatesAggLevel16;
3785 searchSpc->searchSpaceType = NULLP;
3786 DU_ALLOC(searchSpc->searchSpaceType, sizeof(struct SearchSpace__searchSpaceType));
3787 if(!searchSpc->searchSpaceType)
3789 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3792 if(pdcchCfg == NULLP)
3793 searchSpc->searchSpaceType->present = SearchSpace__searchSpaceType_PR_ue_Specific;
3795 searchSpc->searchSpaceType->present = pdcchCfg->searchSpcToAddModList[idx].searchSpaceType;
3797 searchSpc->searchSpaceType->choice.ue_Specific = NULLP;
3798 DU_ALLOC(searchSpc->searchSpaceType->choice.ue_Specific, sizeof(struct SearchSpace__searchSpaceType__ue_Specific));
3799 if(!searchSpc->searchSpaceType->choice.ue_Specific)
3801 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSearchSpcToAddModList");
3804 if(pdcchCfg == NULLP)
3805 searchSpc->searchSpaceType->choice.ue_Specific->dci_Formats = PDCCH_SRCH_SPC_TWO_UE_SPEC_DCI_FORMAT;
3807 searchSpc->searchSpaceType->choice.ue_Specific->dci_Formats = pdcchCfg->searchSpcToAddModList[idx].ueSpecificDciFormat;
3810 }/* End BuildSearchSpcToAddModList */
3812 /*******************************************************************
3814 * @brief Builds BWP DL dedicated PDCCH config
3818 * Function : BuildBWPDlDedPdcchCfg
3820 * Functionality: Builds BWP DL dedicated PDCCH config
3822 * @params[in] struct PDCCH_Config *pdcchCfg
3824 * @return ROK - success
3827 * ****************************************************************/
3828 uint8_t BuildBWPDlDedPdcchCfg(PdcchConfig *pdcchCfgDb, struct PDCCH_Config *pdcchCfg)
3830 pdcchCfg->controlResourceSetToAddModList = NULLP;
3831 DU_ALLOC(pdcchCfg->controlResourceSetToAddModList, sizeof(struct PDCCH_Config__controlResourceSetToAddModList));
3832 if(!pdcchCfg->controlResourceSetToAddModList)
3834 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdcchCfg");
3838 if(BuildControlRSetToAddModList(pdcchCfgDb, pdcchCfg->controlResourceSetToAddModList) != ROK)
3840 DU_LOG("\nERROR --> F1AP : Failed in BuildControlRSetToAddModList()");
3844 pdcchCfg->controlResourceSetToReleaseList = NULLP;
3846 pdcchCfg->searchSpacesToAddModList = NULLP;
3847 DU_ALLOC(pdcchCfg->searchSpacesToAddModList, sizeof(struct PDCCH_Config__searchSpacesToAddModList));
3848 if(!pdcchCfg->searchSpacesToAddModList)
3850 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdcchCfg");
3854 if(BuildSearchSpcToAddModList(pdcchCfgDb, pdcchCfg->searchSpacesToAddModList) != ROK)
3856 DU_LOG("\nERROR --> F1AP : Failed in BuildSearchSpcToAddModList()");
3860 pdcchCfg->searchSpacesToReleaseList = NULLP;
3861 pdcchCfg->downlinkPreemption = NULLP;
3862 pdcchCfg->tpc_PUSCH = NULLP;
3863 pdcchCfg->tpc_PUCCH = NULLP;
3864 pdcchCfg->tpc_SRS = NULLP;
3869 /*******************************************************************
3871 * @brief Builds DMRS DL PDSCH Mapping type A
3875 * Function : BuildDMRSDLPdschMapTypeA
3877 * Functionality: Builds DMRS DL PDSCH Mapping type A
3880 * struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg
3881 * @return ROK - success
3884 * ****************************************************************/
3885 uint8_t BuildDMRSDLPdschMapTypeA(PdschConfig *pdschCfg, struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg)
3887 dmrsDlCfg->present = PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA_PR_setup;
3888 dmrsDlCfg->choice.setup = NULLP;
3889 DU_ALLOC(dmrsDlCfg->choice.setup, sizeof(struct DMRS_DownlinkConfig));
3890 if(!dmrsDlCfg->choice.setup)
3892 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSDLPdschMapTypeA");
3896 dmrsDlCfg->choice.setup->dmrs_Type = NULLP;
3897 dmrsDlCfg->choice.setup->dmrs_AdditionalPosition = NULLP;
3898 DU_ALLOC(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition, sizeof(long));
3899 if(!dmrsDlCfg->choice.setup->dmrs_AdditionalPosition)
3901 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSDLPdschMapTypeA");
3904 if(pdschCfg == NULLP)
3905 *(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition) = DMRS_ADDITIONAL_POS;
3907 *(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition) = pdschCfg->dmrsDlCfgForPdschMapTypeA.addPos;
3909 dmrsDlCfg->choice.setup->maxLength = NULLP;
3910 dmrsDlCfg->choice.setup->scramblingID0 = NULLP;
3911 dmrsDlCfg->choice.setup->scramblingID1 = NULLP;
3912 dmrsDlCfg->choice.setup->phaseTrackingRS = NULLP;
3917 /*******************************************************************
3919 * @brief Builds TCI states to add/modify list
3923 * Function : BuildTCIStatesToAddModList
3925 * Functionality:Builds TCI states to add/modify list
3928 * struct PDSCH_Config__tci_StatesToAddModList *tciStatesList
3930 * @return ROK - success
3933 * ****************************************************************/
3934 uint8_t BuildTCIStatesToAddModList(struct PDSCH_Config__tci_StatesToAddModList *tciStatesList)
3939 /*******************************************************************
3941 * @brief Builds PDSCH time domain allocation list
3945 * Function : BuildPdschTimeDomAllocList
3947 * Functionality: Builds PDSCH time domain allocation list
3950 * struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
3952 * @return ROK - success
3955 * ****************************************************************/
3956 uint8_t BuildPdschTimeDomAllocList(PdschConfig *pdschCfg, struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList)
3960 struct PDSCH_TimeDomainResourceAllocation *timeDomAlloc;
3962 timeDomAllocList->present = PDSCH_Config__pdsch_TimeDomainAllocationList_PR_setup;
3964 timeDomAllocList->choice.setup = NULLP;
3965 DU_ALLOC(timeDomAllocList->choice.setup, sizeof(struct PDSCH_TimeDomainResourceAllocationList));
3966 if(!timeDomAllocList->choice.setup)
3968 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
3972 if(pdschCfg == NULLP)
3975 elementCnt = pdschCfg->numTimeDomRsrcAlloc;
3976 timeDomAllocList->choice.setup->list.count = elementCnt;
3977 timeDomAllocList->choice.setup->list.size = elementCnt * sizeof(struct PDSCH_TimeDomainResourceAllocation *);
3979 timeDomAllocList->choice.setup->list.array = NULLP;
3980 DU_ALLOC(timeDomAllocList->choice.setup->list.array, timeDomAllocList->choice.setup->list.size);
3981 if(!timeDomAllocList->choice.setup->list.array)
3983 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
3987 for(idx = 0; idx < elementCnt; idx++)
3989 timeDomAllocList->choice.setup->list.array[idx] = NULLP;
3990 DU_ALLOC(timeDomAllocList->choice.setup->list.array[idx], \
3991 sizeof(struct PDSCH_TimeDomainResourceAllocation));
3992 if(!timeDomAllocList->choice.setup->list.array[idx])
3994 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
3999 if(pdschCfg == NULLP)
4002 timeDomAlloc = timeDomAllocList->choice.setup->list.array[idx];
4003 DU_ALLOC(timeDomAlloc->k0, sizeof(long));
4004 if(!timeDomAlloc->k0)
4006 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
4009 *(timeDomAlloc->k0) = 0;
4010 timeDomAlloc->mappingType = PDSCH_MAPPING_TYPE_A;
4011 timeDomAlloc->startSymbolAndLength = \
4012 calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
4015 timeDomAlloc = timeDomAllocList->choice.setup->list.array[idx];
4016 DU_ALLOC(timeDomAlloc->k0, sizeof(long));
4017 if(!timeDomAlloc->k0)
4019 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
4022 *(timeDomAlloc->k0) = 1;
4023 timeDomAlloc->mappingType = PDSCH_MAPPING_TYPE_A;
4024 timeDomAlloc->startSymbolAndLength = calcSliv(PDSCH_START_SYMBOL, PDSCH_LENGTH_SYMBOL);
4028 for(idx = 0; idx < elementCnt; idx++)
4030 timeDomAlloc = timeDomAllocList->choice.setup->list.array[idx];
4031 DU_ALLOC(timeDomAlloc->k0, sizeof(long));
4032 if(!timeDomAlloc->k0)
4034 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschTimeDomAllocList");
4037 if(pdschCfg->timeDomRsrcAllociList[idx].k0)
4038 *(timeDomAlloc->k0) = *(pdschCfg->timeDomRsrcAllociList[idx].k0);
4039 timeDomAlloc->mappingType = pdschCfg->timeDomRsrcAllociList[idx].mappingType;
4040 timeDomAlloc->startSymbolAndLength = pdschCfg->timeDomRsrcAllociList[idx].startSymbolAndLength;
4047 /*******************************************************************
4049 * @brief Builds PDSCH PRB Bundling type
4053 * Function : BuildPdschPrbBundlingType
4055 * Functionality: Builds PDSCH PRB Bundling type
4058 * struct PDSCH_Config__prb_BundlingType *prbBndlType
4060 * @return ROK - success
4063 * ****************************************************************/
4064 uint8_t BuildPdschPrbBundlingType(PdschConfig *pdschCfg, struct PDSCH_Config__prb_BundlingType *prbBndlType)
4066 if(pdschCfg == NULLP)
4067 prbBndlType->present = PDSCH_Config__prb_BundlingType_PR_staticBundling;
4069 prbBndlType->present = pdschCfg->bundlingType;
4071 prbBndlType->choice.staticBundling = NULLP;
4072 DU_ALLOC(prbBndlType->choice.staticBundling, \
4073 sizeof(struct PDSCH_Config__prb_BundlingType__staticBundling));
4074 if(!prbBndlType->choice.staticBundling)
4076 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschPrbBundlingType");
4079 prbBndlType->choice.staticBundling->bundleSize = NULLP;
4084 /*******************************************************************
4086 * @brief Builds BWP DL dedicated PDSCH config
4090 * Function : BuildBWPDlDedPdschCfg
4092 * Functionality: Builds BWP DL dedicated PDSCH config
4094 * @params[in] struct PDSCH_Config *pdschCfg
4096 * @return ROK - success
4099 * ****************************************************************/
4100 uint8_t BuildBWPDlDedPdschCfg(PdschConfig *pdschCfgDb, struct PDSCH_Config *pdschCfg)
4102 pdschCfg->dataScramblingIdentityPDSCH = NULLP;
4104 pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA = NULLP;
4105 DU_ALLOC(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA, sizeof(struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA));
4106 if(!pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
4108 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
4112 if(BuildDMRSDLPdschMapTypeA(pdschCfgDb, pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA) != ROK)
4117 pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeB = NULLP;
4118 pdschCfg->tci_StatesToAddModList = NULLP;
4119 pdschCfg->tci_StatesToReleaseList = NULLP;
4120 pdschCfg->vrb_ToPRB_Interleaver = NULLP;
4122 DU_ALLOC(pdschCfg->tci_StatesToAddModList, sizeof(struct PDSCH_Config__tci_StatesToAddModList));
4123 if(!pdschCfg->tci_StatesToAddModList)
4125 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
4128 if(BuildTCIStatesToAddModList(pdschCfg->tci_StatesToAddModList) != ROK)
4134 if(pdschCfgDb == NULLP)
4135 pdschCfg->resourceAllocation = RES_ALLOC_TYPE;
4137 pdschCfg->resourceAllocation = pdschCfgDb->resourceAllocType;
4139 pdschCfg->pdsch_TimeDomainAllocationList = NULLP;
4140 DU_ALLOC(pdschCfg->pdsch_TimeDomainAllocationList, sizeof(struct PDSCH_Config__pdsch_TimeDomainAllocationList));
4141 if(!pdschCfg->pdsch_TimeDomainAllocationList)
4143 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
4146 if(BuildPdschTimeDomAllocList(pdschCfgDb, pdschCfg->pdsch_TimeDomainAllocationList) != ROK)
4151 pdschCfg->pdsch_AggregationFactor = NULLP;
4152 pdschCfg->rateMatchPatternToAddModList = NULLP;
4153 pdschCfg->rateMatchPatternToReleaseList = NULLP;
4154 pdschCfg->rateMatchPatternGroup1 = NULLP;
4155 pdschCfg->rateMatchPatternGroup2 = NULLP;
4156 if(pdschCfgDb == NULLP)
4157 pdschCfg->rbg_Size = PDSCH_RBG_SIZE;
4159 pdschCfg->rbg_Size = pdschCfgDb->rbgSize;
4160 pdschCfg->mcs_Table = NULLP;
4162 pdschCfg->maxNrofCodeWordsScheduledByDCI = NULLP;
4163 DU_ALLOC(pdschCfg->maxNrofCodeWordsScheduledByDCI, sizeof(long));
4164 if(!pdschCfg->maxNrofCodeWordsScheduledByDCI)
4166 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPDlDedPdschCfg");
4169 if(pdschCfgDb == NULLP)
4170 *(pdschCfg->maxNrofCodeWordsScheduledByDCI) = PDSCH_MAX_CODEWORD_SCH_BY_DCI;
4172 *(pdschCfg->maxNrofCodeWordsScheduledByDCI) = pdschCfgDb->numCodeWordsSchByDci;
4174 if(BuildPdschPrbBundlingType(pdschCfgDb, &pdschCfg->prb_BundlingType) != ROK)
4179 pdschCfg->zp_CSI_RS_ResourceToAddModList = NULLP;
4180 pdschCfg->zp_CSI_RS_ResourceToReleaseList = NULLP;
4181 pdschCfg->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList = NULLP;
4182 pdschCfg->aperiodic_ZP_CSI_RS_ResourceSetsToReleaseList = NULLP;
4183 pdschCfg->sp_ZP_CSI_RS_ResourceSetsToAddModList = NULLP;
4184 pdschCfg->sp_ZP_CSI_RS_ResourceSetsToReleaseList = NULLP;
4185 pdschCfg->p_ZP_CSI_RS_ResourceSet = NULLP;
4190 /*******************************************************************
4192 * @brief Builds intitial DL BWP
4195 * Function : BuildInitialDlBWP
4197 * Functionality: Builds intitial DL BWP in spCellCfgDed
4199 * @params[in] BWP_DownlinkDedicated_t *dlBwp
4201 * @return ROK - success
4204 * ****************************************************************/
4205 uint8_t BuildInitialDlBWP(InitialDlBwp *initiDlBwp, BWP_DownlinkDedicated_t *dlBwp)
4207 PdcchConfig *pdcchCfg = NULLP;
4208 PdschConfig *pdschCfg = NULLP;
4212 if(initiDlBwp->pdcchPresent)
4213 pdcchCfg = &initiDlBwp->pdcchCfg;
4214 if(initiDlBwp->pdschPresent)
4215 pdschCfg = &initiDlBwp->pdschCfg;
4218 dlBwp->pdcch_Config = NULLP;
4219 DU_ALLOC(dlBwp->pdcch_Config, sizeof(struct BWP_DownlinkDedicated__pdcch_Config));
4220 if(!dlBwp->pdcch_Config)
4222 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
4225 dlBwp->pdcch_Config->present = BWP_DownlinkDedicated__pdcch_Config_PR_setup;
4227 dlBwp->pdcch_Config->choice.setup = NULLP;
4228 DU_ALLOC(dlBwp->pdcch_Config->choice.setup, sizeof(struct PDCCH_Config));
4229 if(!dlBwp->pdcch_Config->choice.setup)
4231 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
4234 if(BuildBWPDlDedPdcchCfg(pdcchCfg, dlBwp->pdcch_Config->choice.setup) != ROK)
4239 dlBwp->pdsch_Config = NULLP;
4240 DU_ALLOC(dlBwp->pdsch_Config, sizeof(struct BWP_DownlinkDedicated__pdsch_Config));
4241 if(!dlBwp->pdsch_Config)
4243 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
4246 dlBwp->pdsch_Config->present = BWP_DownlinkDedicated__pdsch_Config_PR_setup;
4248 dlBwp->pdsch_Config->choice.setup = NULLP;
4249 DU_ALLOC(dlBwp->pdsch_Config->choice.setup, sizeof(struct PDSCH_Config));
4250 if(!dlBwp->pdsch_Config->choice.setup)
4252 DU_LOG("\nERROR --> F1AP : Memory Allocation failure in BuildInitialDlBWP");
4256 if(BuildBWPDlDedPdschCfg(pdschCfg, dlBwp->pdsch_Config->choice.setup) != ROK)
4261 dlBwp->sps_Config = NULLP;
4262 dlBwp->radioLinkMonitoringConfig = NULLP;
4266 /*******************************************************************
4268 * @brief Builds DMRS UL Pusch Mapping type A
4272 * Function : BuildDMRSULPuschMapTypeA
4274 * Functionality: Builds DMRS UL Pusch Mapping type A
4277 * struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg
4278 * @return ROK - success
4281 * ****************************************************************/
4282 uint8_t BuildDMRSULPuschMapTypeA(DmrsUlCfg *ulDmrsCfgDb, struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg)
4284 dmrsUlCfg->present = PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA_PR_setup;
4285 dmrsUlCfg->choice.setup= NULLP;
4286 DU_ALLOC(dmrsUlCfg->choice.setup, sizeof(DMRS_UplinkConfig_t));
4287 if(!dmrsUlCfg->choice.setup)
4289 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4293 dmrsUlCfg->choice.setup->dmrs_Type = NULLP;
4294 dmrsUlCfg->choice.setup->dmrs_AdditionalPosition = NULLP;
4295 DU_ALLOC(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition, sizeof(long));
4296 if(!dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
4298 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4301 if(ulDmrsCfgDb == NULLP)
4302 *(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition) = DMRS_ADDITIONAL_POS;
4304 *(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition) = ulDmrsCfgDb->addPos;
4306 dmrsUlCfg->choice.setup->phaseTrackingRS = NULLP;
4307 dmrsUlCfg->choice.setup->maxLength = NULLP;
4308 dmrsUlCfg->choice.setup->transformPrecodingDisabled = NULLP;
4309 DU_ALLOC(dmrsUlCfg->choice.setup->transformPrecodingDisabled, sizeof(struct DMRS_UplinkConfig__transformPrecodingDisabled));
4310 if(!dmrsUlCfg->choice.setup->transformPrecodingDisabled)
4312 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4316 dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0 = NULLP;
4317 DU_ALLOC(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0,\
4319 if(!dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0)
4321 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDMRSULPuschMapTypeA");
4324 if(ulDmrsCfgDb == NULLP)
4325 *(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0) = SCRAMBLING_ID;
4327 *(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0) = ulDmrsCfgDb->transPrecodDisabled.scramblingId0;
4329 dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID1 = NULLP;
4330 dmrsUlCfg->choice.setup->transformPrecodingEnabled = NULLP;
4334 /*******************************************************************
4336 * @brief Build PUSCH time domain allocation list
4340 * Function : BuildPuschTimeDomAllocList
4342 * Functionality: Build PUSCH time domain allocation list
4345 * struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList
4347 * @return ROK - success
4350 * ****************************************************************/
4351 uint8_t BuildPuschTimeDomAllocList(PuschCfg *puschCfgDb, struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList)
4355 PUSCH_TimeDomainResourceAllocation_t *timeDomAlloc;
4357 timeDomAllocList->present = PUSCH_Config__pusch_TimeDomainAllocationList_PR_setup;
4358 timeDomAllocList->choice.setup = NULLP;
4359 DU_ALLOC(timeDomAllocList->choice.setup, sizeof(struct PUSCH_TimeDomainResourceAllocationList));
4360 if(!timeDomAllocList->choice.setup)
4362 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4366 if(puschCfgDb == NULLP)
4369 elementCnt = puschCfgDb->numTimeDomRsrcAlloc;
4371 timeDomAllocList->choice.setup->list.count = elementCnt;
4372 timeDomAllocList->choice.setup->list.size = elementCnt * sizeof(PUSCH_TimeDomainResourceAllocation_t *);
4373 timeDomAllocList->choice.setup->list.array = NULLP;
4374 DU_ALLOC(timeDomAllocList->choice.setup->list.array, timeDomAllocList->choice.setup->list.size);
4375 if(!timeDomAllocList->choice.setup->list.array)
4377 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4381 for(idx = 0; idx < elementCnt; idx++)
4383 timeDomAllocList->choice.setup->list.array[idx] = NULLP;
4384 DU_ALLOC(timeDomAllocList->choice.setup->list.array[idx], sizeof(PUSCH_TimeDomainResourceAllocation_t));
4385 if(!timeDomAllocList->choice.setup->list.array[idx])
4387 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4392 for(idx = 0; idx < elementCnt; idx++)
4394 timeDomAlloc = timeDomAllocList->choice.setup->list.array[idx];
4395 DU_ALLOC(timeDomAlloc->k2, sizeof(long));
4396 if(!timeDomAlloc->k2)
4398 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschTimeDomAllocList");
4401 if(puschCfgDb == NULLP)
4404 *(timeDomAlloc->k2) = PUSCH_K2_CFG1;
4406 *(timeDomAlloc->k2) = PUSCH_K2_CFG2;
4408 timeDomAlloc->mappingType = PUSCH_MAPPING_TYPE_A;
4409 timeDomAlloc->startSymbolAndLength = calcSliv(PUSCH_START_SYMBOL, PUSCH_LENGTH_SYMBOL);
4413 *(timeDomAlloc->k2) = puschCfgDb->timeDomRsrcAllocList[idx].k2;
4414 timeDomAlloc->mappingType = puschCfgDb->timeDomRsrcAllocList[idx].mappingType;
4415 timeDomAlloc->startSymbolAndLength = puschCfgDb->timeDomRsrcAllocList[idx].startSymbolAndLength;
4422 /*******************************************************************
4424 * @brief Builds BWP UL dedicated PUSCH Config
4428 * Function : BuildBWPUlDedPuschCfg
4431 * Builds BWP UL dedicated PUSCH Config
4433 * @params[in] : PUSCH_Config_t *puschCfg
4435 * @return ROK - success
4438 * ****************************************************************/
4439 uint8_t BuildBWPUlDedPuschCfg(PuschCfg *puschCfgDb, PUSCH_Config_t *puschCfg)
4441 DmrsUlCfg *ulDmrsCfg = NULLP;
4444 ulDmrsCfg = &puschCfgDb->dmrsUlCfgForPuschMapTypeA;
4446 puschCfg->dataScramblingIdentityPUSCH = NULLP;
4447 DU_ALLOC(puschCfg->dataScramblingIdentityPUSCH, sizeof(long));
4448 if(!puschCfg->dataScramblingIdentityPUSCH)
4450 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4453 if(puschCfgDb == NULLP)
4454 *(puschCfg->dataScramblingIdentityPUSCH) = SCRAMBLING_ID;
4456 *(puschCfg->dataScramblingIdentityPUSCH) = puschCfgDb->dataScramblingId;
4458 puschCfg->txConfig = NULLP;
4459 puschCfg->dmrs_UplinkForPUSCH_MappingTypeA = NULLP;
4460 DU_ALLOC(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA, sizeof(struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA));
4461 if(!puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
4463 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4467 if(BuildDMRSULPuschMapTypeA(ulDmrsCfg, puschCfg->dmrs_UplinkForPUSCH_MappingTypeA) != ROK)
4472 puschCfg->dmrs_UplinkForPUSCH_MappingTypeB = NULLP;
4473 puschCfg->pusch_PowerControl = NULLP;
4474 puschCfg->frequencyHopping = NULLP;
4475 puschCfg->frequencyHoppingOffsetLists = NULLP;
4477 if(puschCfgDb == NULLP)
4478 puschCfg->resourceAllocation = RES_ALLOC_TYPE;
4480 puschCfg->resourceAllocation = puschCfgDb->resourceAllocType;
4482 puschCfg->pusch_TimeDomainAllocationList = NULLP;
4483 DU_ALLOC(puschCfg->pusch_TimeDomainAllocationList, sizeof(struct PUSCH_Config__pusch_TimeDomainAllocationList));
4484 if(!puschCfg->pusch_TimeDomainAllocationList)
4486 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4490 if(BuildPuschTimeDomAllocList(puschCfgDb, puschCfg->pusch_TimeDomainAllocationList) != ROK)
4495 puschCfg->pusch_AggregationFactor = NULLP;
4496 puschCfg->mcs_Table = NULLP;
4497 puschCfg->mcs_TableTransformPrecoder = NULLP;
4498 puschCfg->transformPrecoder = NULLP;
4499 DU_ALLOC(puschCfg->transformPrecoder, sizeof(long));
4500 if(!puschCfg->transformPrecoder)
4502 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPuschCfg");
4505 if(puschCfgDb == NULLP)
4506 *(puschCfg->transformPrecoder) = PUSCH_TRANSFORM_PRECODER;
4508 *(puschCfg->transformPrecoder) = puschCfgDb->transformPrecoder;
4510 puschCfg->codebookSubset = NULLP;
4511 puschCfg->maxRank = NULLP;
4512 puschCfg->rbg_Size = NULLP;
4513 puschCfg->uci_OnPUSCH = NULLP;
4514 puschCfg->tp_pi2BPSK = NULLP;
4519 /*******************************************************************
4521 * @brief Builds PUCCH resource set add/modify list
4525 * Function : BuildPucchRsrcSetAddModList
4528 * Builds PUCCH resource set add/modify list
4530 * @params[in] : PucchResrcSetCfg *rsrcSetCfgDb
4531 * struct PUCCH_Config__resourceSetToAddModList *rsrcSetAddModList
4533 * @return ROK - success
4536 * ****************************************************************/
4537 uint8_t BuildPucchRsrcSetAddModList(PucchResrcSetCfg *rsrcSetCfgDb, \
4538 struct PUCCH_Config__resourceSetToAddModList *resourceSetToAddModList)
4540 uint8_t elementCnt = 0, rsrcSetIdx = 0, rsrcIdx = 0;
4541 PUCCH_ResourceSet_t *rsrcSet = NULLP;
4543 if(rsrcSetCfgDb == NULLP)
4546 elementCnt = rsrcSetCfgDb->resrcSetToAddModListCount;
4548 resourceSetToAddModList->list.count = elementCnt;
4549 resourceSetToAddModList->list.size = elementCnt * sizeof(PUCCH_ResourceSet_t *);
4550 DU_ALLOC(resourceSetToAddModList->list.array, resourceSetToAddModList->list.size);
4551 if(resourceSetToAddModList->list.array == NULLP)
4553 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcSetAddModList");
4556 for(rsrcSetIdx=0; rsrcSetIdx < resourceSetToAddModList->list.count; rsrcSetIdx++)
4558 DU_ALLOC(resourceSetToAddModList->list.array[rsrcSetIdx], sizeof(PUCCH_ResourceSet_t));
4559 if(resourceSetToAddModList->list.array[rsrcSetIdx] == NULLP)
4561 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcSetAddModList");
4566 for(rsrcSetIdx=0; rsrcSetIdx < resourceSetToAddModList->list.count; rsrcSetIdx++)
4568 rsrcSet = resourceSetToAddModList->list.array[rsrcSetIdx];
4570 /* Resource set Id */
4571 if(rsrcSetCfgDb == NULLP)
4572 rsrcSet->pucch_ResourceSetId = 1;
4574 rsrcSet->pucch_ResourceSetId = rsrcSetCfgDb->resrcSetToAddModList[rsrcSetIdx].resrcSetId;
4576 /* Resource list of a resource set */
4577 if(rsrcSetCfgDb == NULLP)
4580 elementCnt = rsrcSetCfgDb->resrcSetToAddModList[rsrcSetIdx].resrcListCount;
4581 rsrcSet->resourceList.list.count = elementCnt;
4582 rsrcSet->resourceList.list.size = elementCnt * sizeof(PUCCH_ResourceId_t *);
4583 DU_ALLOC(rsrcSet->resourceList.list.array, rsrcSet->resourceList.list.size);
4584 if(rsrcSet->resourceList.list.array == NULLP)
4586 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcSetAddModList");
4590 for(rsrcIdx=0; rsrcIdx < rsrcSet->resourceList.list.count; rsrcIdx++)
4592 DU_ALLOC(rsrcSet->resourceList.list.array[rsrcIdx], sizeof(PUCCH_ResourceId_t));
4593 if(rsrcSet->resourceList.list.array[rsrcIdx] == NULLP)
4595 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcSetAddModList");
4599 for(rsrcIdx=0; rsrcIdx < rsrcSet->resourceList.list.count; rsrcIdx++)
4601 if(rsrcSetCfgDb == NULLP)
4602 *(rsrcSet->resourceList.list.array[rsrcIdx]) = 1;
4604 *(rsrcSet->resourceList.list.array[rsrcIdx]) = rsrcSetCfgDb->resrcSetToAddModList[rsrcSetIdx].resrcList[rsrcIdx];
4607 /* Max payload size (minus 1) in a Resource set */
4608 rsrcSet->maxPayloadMinus1 = NULLP;
4609 if(rsrcSetCfgDb && rsrcSetCfgDb->resrcSetToAddModList[rsrcSetIdx].maxPayLoadSize)
4611 DU_ALLOC(rsrcSet->maxPayloadMinus1, sizeof(long));
4612 if(rsrcSet->maxPayloadMinus1 == NULLP)
4614 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcSetAddModList");
4617 *(rsrcSet->maxPayloadMinus1) = rsrcSetCfgDb->resrcSetToAddModList[rsrcSetIdx].maxPayLoadSize;
4623 /*******************************************************************
4625 * @brief Builds PUCCH resource add/modify list
4629 * Function : BuildPucchRsrcAdddModList
4632 * Builds PUCCH resource add/modify list
4634 * @params[in] : PucchResrcCfg *rsrcSetCfgDb
4635 * struct PUCCH_Config__resourceSetToAddModList *rsrcSetAddModList
4637 * @return ROK - success
4640 * ****************************************************************/
4641 uint8_t BuildPucchRsrcAddModList(PucchResrcCfg *rsrcCfgDb, struct PUCCH_Config__resourceToAddModList *resourceToAddModList)
4643 uint8_t elementCnt = 0, rsrcIdx = 0;
4644 PUCCH_Resource_t *rsrc = NULLP;
4646 if(rsrcCfgDb == NULLP)
4649 elementCnt = rsrcCfgDb->resrcToAddModListCount;
4650 resourceToAddModList->list.count = elementCnt;
4651 resourceToAddModList->list.size = elementCnt * sizeof(PUCCH_Resource_t *);
4652 DU_ALLOC(resourceToAddModList->list.array, resourceToAddModList->list.size);
4653 if(resourceToAddModList->list.array == NULLP)
4655 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcAddModList");
4658 for(rsrcIdx=0; rsrcIdx < resourceToAddModList->list.count; rsrcIdx++)
4660 DU_ALLOC(resourceToAddModList->list.array[rsrcIdx], sizeof(PUCCH_Resource_t));
4661 if(resourceToAddModList->list.array[rsrcIdx] == NULLP)
4663 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcAddModList");
4668 for(rsrcIdx=0; rsrcIdx < resourceToAddModList->list.count; rsrcIdx++)
4670 rsrc = resourceToAddModList->list.array[rsrcIdx];
4672 if(rsrcCfgDb == NULLP)
4674 rsrc->pucch_ResourceId = 1;
4675 rsrc->startingPRB = 0;
4676 rsrc->format.present = PUCCH_Resource__format_PR_format1;
4677 DU_ALLOC(rsrc->format.choice.format1, sizeof(PUCCH_format1_t));
4678 if(rsrc->format.choice.format1 == NULLP)
4680 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcAddModList");
4683 rsrc->format.choice.format1->initialCyclicShift = 0;
4684 rsrc->format.choice.format1->nrofSymbols = 4;
4685 rsrc->format.choice.format1->startingSymbolIndex = 0;
4686 rsrc->format.choice.format1->timeDomainOCC = 0;
4690 rsrc->pucch_ResourceId = rsrcCfgDb->resrcToAddModList[rsrcIdx].resrcId;
4691 rsrc->startingPRB = rsrcCfgDb->resrcToAddModList[rsrcIdx].startPrb;
4692 if(rsrcCfgDb->resrcToAddModList[rsrcIdx].intraFreqHop)
4694 DU_ALLOC(rsrc->intraSlotFrequencyHopping, sizeof(long));
4695 if(rsrc->intraSlotFrequencyHopping == NULLP)
4697 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcAddModList");
4700 *(rsrc->intraSlotFrequencyHopping) = rsrcCfgDb->resrcToAddModList[rsrcIdx].intraFreqHop;
4703 rsrc->intraSlotFrequencyHopping = NULLP;
4705 if(rsrcCfgDb->resrcToAddModList[rsrcIdx].secondPrbHop)
4707 DU_ALLOC(rsrc->secondHopPRB, sizeof(PRB_Id_t));
4708 if(rsrc->secondHopPRB == NULLP)
4710 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcAddModList");
4713 *(rsrc->secondHopPRB) = rsrcCfgDb->resrcToAddModList[rsrcIdx].secondPrbHop;
4716 rsrc->secondHopPRB = NULLP;
4717 rsrc->format.present = covertPucchFormatIntEnumToRrcEnum(rsrcCfgDb->resrcToAddModList[rsrcIdx].pucchFormat);
4719 switch(rsrc->format.present)
4721 case PUCCH_Resource__format_PR_NOTHING:
4723 case PUCCH_Resource__format_PR_format0:
4725 DU_ALLOC(rsrc->format.choice.format0, sizeof(PUCCH_format0_t));
4726 if(rsrc->format.choice.format0 == NULLP)
4728 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcAddModList");
4731 rsrc->format.choice.format0->initialCyclicShift = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format0->initialCyclicShift;
4732 rsrc->format.choice.format0->nrofSymbols = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format0->numSymbols;
4733 rsrc->format.choice.format0->startingSymbolIndex = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format0->startSymbolIdx;
4737 case PUCCH_Resource__format_PR_format1:
4739 DU_ALLOC(rsrc->format.choice.format1, sizeof(PUCCH_format1_t));
4740 if(rsrc->format.choice.format1 == NULLP)
4742 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcAddModList");
4745 rsrc->format.choice.format1->initialCyclicShift = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format1->initialCyclicShift;
4746 rsrc->format.choice.format1->nrofSymbols = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format1->numSymbols;
4747 rsrc->format.choice.format1->startingSymbolIndex = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format1->startSymbolIdx;
4748 rsrc->format.choice.format1->timeDomainOCC = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format1->timeDomOCC;
4752 case PUCCH_Resource__format_PR_format2:
4754 DU_ALLOC(rsrc->format.choice.format2, sizeof(PUCCH_format2_t));
4755 if(rsrc->format.choice.format2 == NULLP)
4757 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcAddModList");
4760 rsrc->format.choice.format2->nrofPRBs = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format2->numPrbs;
4761 rsrc->format.choice.format2->nrofSymbols = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format2->numSymbols;
4762 rsrc->format.choice.format2->startingSymbolIndex = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format2->startSymbolIdx;
4766 case PUCCH_Resource__format_PR_format3:
4768 DU_ALLOC(rsrc->format.choice.format3, sizeof(PUCCH_format3_t));
4769 if(rsrc->format.choice.format3 == NULLP)
4771 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcAddModList");
4774 rsrc->format.choice.format3->nrofPRBs = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format3->numPrbs;
4775 rsrc->format.choice.format3->nrofSymbols = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format3->numSymbols;
4776 rsrc->format.choice.format3->startingSymbolIndex = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format3->startSymbolIdx;
4780 case PUCCH_Resource__format_PR_format4:
4782 DU_ALLOC(rsrc->format.choice.format4, sizeof(PUCCH_format4_t));
4783 if(rsrc->format.choice.format4 == NULLP)
4785 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchRsrcAddModList");
4788 rsrc->format.choice.format4->nrofSymbols = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format4->numSymbols;
4789 rsrc->format.choice.format4->occ_Length = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format4->occLen;
4790 rsrc->format.choice.format4->occ_Index = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format4->occIdx;
4791 rsrc->format.choice.format4->startingSymbolIndex = rsrcCfgDb->resrcToAddModList[rsrcIdx].PucchFormat.format4->startSymbolIdx;
4800 /*******************************************************************
4802 * @brief Builds PUCCH format config
4806 * Function : BuildPucchFormat
4808 * Functionality: Builds PUCCH format config
4810 * @params[in] : PucchFormatCfg *formatDb
4811 * PUCCH_FormatConfig_t *format
4813 * @return ROK - success
4816 * ****************************************************************/
4817 uint8_t BuildPucchFormat(PucchFormatCfg *formatDb, PUCCH_FormatConfig_t *format)
4819 /* Inter Slot Fequency hopping */
4820 format->interslotFrequencyHopping = NULLP;
4821 if((formatDb != NULLP) && (formatDb->interSlotFreqHop == true))
4823 DU_ALLOC(format->interslotFrequencyHopping, sizeof(long));
4824 if(format->interslotFrequencyHopping)
4826 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchFormat");
4829 *(format->interslotFrequencyHopping) = PUCCH_FormatConfig__interslotFrequencyHopping_enabled;
4832 /* Additional DMRS */
4833 format->additionalDMRS = NULLP;
4834 if((formatDb != NULLP) && (formatDb->addDmrs == true))
4836 DU_ALLOC(format->additionalDMRS, sizeof(long));
4837 if(format->additionalDMRS)
4839 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchFormat");
4842 *(format->additionalDMRS) = PUCCH_FormatConfig__additionalDMRS_true;
4845 /* Maximum code rate */
4846 format->maxCodeRate = NULLP;
4847 if((formatDb != NULLP) && (formatDb->maxCodeRate != 0))
4849 DU_ALLOC(format->maxCodeRate, sizeof(long));
4850 if(format->maxCodeRate)
4852 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchFormat");
4855 *(format->maxCodeRate) = formatDb->maxCodeRate;
4858 /* Number of slots */
4859 format->nrofSlots = NULLP;
4860 if((formatDb == NULLP) || ((formatDb != NULLP) && (formatDb->numSlots != 0)))
4862 DU_ALLOC(format->nrofSlots, sizeof(long));
4863 if(format->nrofSlots == NULLP)
4865 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchFormat");
4868 if(formatDb == NULLP)
4869 *(format->nrofSlots) = PUCCH_FormatConfig__nrofSlots_n4;
4871 *(format->nrofSlots) = formatDb->numSlots;
4875 format->pi2BPSK = NULLP;
4876 if((formatDb != NULLP) && (formatDb->pi2BPSK == true))
4878 DU_ALLOC(format->pi2BPSK, sizeof(long));
4881 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchFormat");
4884 *(format->pi2BPSK) = PUCCH_FormatConfig__pi2BPSK_enabled;
4887 /* Simultaneous HARQ ACK and CSI */
4888 format->simultaneousHARQ_ACK_CSI = NULLP;
4889 if((formatDb != NULLP) && (formatDb->harqAckCSI == true))
4891 DU_ALLOC(format->simultaneousHARQ_ACK_CSI, sizeof(long));
4892 if(format->simultaneousHARQ_ACK_CSI)
4894 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPucchFormat");
4897 *(format->simultaneousHARQ_ACK_CSI) = PUCCH_FormatConfig__simultaneousHARQ_ACK_CSI_true;
4904 /*******************************************************************
4906 * @brief Builds PUCCH scheduling request list
4910 * Function : BuildPucchSchReqAddModList
4913 * Builds PUCCH scheduling request list
4915 * @params[in] : PucchSchedReqCfg *schReqDb
4916 * struct PUCCH_Config__schedulingRequestResourceToAddModList *schReqRsrcToAddModList
4918 * @return ROK - success
4921 * ****************************************************************/
4922 uint8_t BuildPucchSchReqAddModList(PucchSchedReqCfg *schReqDb, \
4923 struct PUCCH_Config__schedulingRequestResourceToAddModList *schReqRsrcToAddModList)
4925 uint8_t elementCnt = 0, schReqIdx = 0;
4926 SchedulingRequestResourceConfig_t *schReqRsrc;
4928 elementCnt = schReqDb->schedAddModListCount;
4929 schReqRsrcToAddModList->list.count = elementCnt;
4930 schReqRsrcToAddModList->list.size = elementCnt *sizeof(struct SchedulingRequestResourceConfig *);
4932 schReqRsrcToAddModList->list.array = NULLP;
4933 DU_ALLOC(schReqRsrcToAddModList->list.array, schReqRsrcToAddModList->list.size);
4934 if(schReqRsrcToAddModList->list.array == NULLP)
4936 DU_LOG("\nERROR --> DU APP: Memory allocation failed in BuildPucchSchReqAddModList");
4940 for(schReqIdx = 0; schReqIdx < schReqRsrcToAddModList->list.count; schReqIdx++)
4942 DU_ALLOC(schReqRsrcToAddModList->list.array[schReqIdx], schReqRsrcToAddModList->list.size);
4943 if(schReqRsrcToAddModList->list.array[schReqIdx] == NULLP)
4945 DU_LOG("\nERROR --> DU APP: Memory allocation failed in BuildPucchSchReqAddModList");
4950 for(schReqIdx = 0; schReqIdx < schReqRsrcToAddModList->list.count; schReqIdx++)
4952 schReqRsrc = schReqRsrcToAddModList->list.array[schReqIdx];
4953 schReqRsrc->schedulingRequestResourceId = schReqDb->schedAddModList[schReqIdx].resrcId;
4954 schReqRsrc->schedulingRequestID = schReqDb->schedAddModList[schReqIdx].requestId;
4956 if(schReqDb->schedAddModList[schReqIdx].periodicity)
4958 schReqRsrc->periodicityAndOffset = NULLP;
4959 DU_ALLOC(schReqRsrc->periodicityAndOffset, sizeof(struct SchedulingRequestResourceConfig__periodicityAndOffset));
4960 if(schReqRsrc->periodicityAndOffset == NULLP)
4962 DU_LOG("\nERROR --> DU APP: Memory allocation failed in BuildPucchSchReqAddModList");
4966 schReqRsrc->periodicityAndOffset->present = schReqDb->schedAddModList[schReqIdx].periodicity;
4967 switch(schReqRsrc->periodicityAndOffset->present)
4969 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_NOTHING:
4971 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sym2:
4972 schReqRsrc->periodicityAndOffset->choice.sym2 = schReqDb->schedAddModList[schReqIdx].offset;
4974 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sym6or7:
4975 schReqRsrc->periodicityAndOffset->choice.sym6or7 = schReqDb->schedAddModList[schReqIdx].offset;
4977 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl1:
4978 schReqRsrc->periodicityAndOffset->choice.sl1 = schReqDb->schedAddModList[schReqIdx].offset;
4980 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl2:
4981 schReqRsrc->periodicityAndOffset->choice.sl2 = schReqDb->schedAddModList[schReqIdx].offset;
4983 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl4:
4984 schReqRsrc->periodicityAndOffset->choice.sl4 = schReqDb->schedAddModList[schReqIdx].offset;
4986 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl5:
4987 schReqRsrc->periodicityAndOffset->choice.sl5 = schReqDb->schedAddModList[schReqIdx].offset;
4989 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl8:
4990 schReqRsrc->periodicityAndOffset->choice.sl8 = schReqDb->schedAddModList[schReqIdx].offset;
4992 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl10:
4993 schReqRsrc->periodicityAndOffset->choice.sl10 = schReqDb->schedAddModList[schReqIdx].offset;
4995 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl16:
4996 schReqRsrc->periodicityAndOffset->choice.sl16 = schReqDb->schedAddModList[schReqIdx].offset;
4998 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl20:
4999 schReqRsrc->periodicityAndOffset->choice.sl20 = schReqDb->schedAddModList[schReqIdx].offset;
5001 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl40:
5002 schReqRsrc->periodicityAndOffset->choice.sl40 = schReqDb->schedAddModList[schReqIdx].offset;
5004 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl80:
5005 schReqRsrc->periodicityAndOffset->choice.sl80 = schReqDb->schedAddModList[schReqIdx].offset;
5007 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl160:
5008 schReqRsrc->periodicityAndOffset->choice.sl160 = schReqDb->schedAddModList[schReqIdx].offset;
5010 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl320:
5011 schReqRsrc->periodicityAndOffset->choice.sl320 = schReqDb->schedAddModList[schReqIdx].offset;
5013 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl640:
5014 schReqRsrc->periodicityAndOffset->choice.sl640 = schReqDb->schedAddModList[schReqIdx].offset;
5019 if(schReqDb->schedAddModList[schReqIdx].resrc)
5021 schReqRsrc->resource = NULLP;
5022 DU_ALLOC(schReqRsrc->resource, sizeof(PUCCH_ResourceId_t));
5023 if(schReqRsrc->resource == NULLP)
5025 DU_LOG("\nERROR --> DU APP: Memory allocation failed in BuildPucchSchReqAddModList");
5028 *(schReqRsrc->resource) = schReqDb->schedAddModList[schReqIdx].resrc;
5035 /*******************************************************************
5037 * @brief Builds PUCCH multi csi resource list
5041 * Function : BuildPucchMultiCsiRsrcList
5044 * Builds PUCCH multi csi resource list
5046 * @params[in] : PucchMultiCsiCfg *multiCsiDb
5047 * struct PUCCH_Config__multi_CSI_PUCCH_ResourceList *multiCsiRsrcList
5049 * @return ROK - success
5052 * ****************************************************************/
5053 uint8_t BuildPucchMultiCsiRsrcList(PucchMultiCsiCfg *multiCsiDb, struct PUCCH_Config__multi_CSI_PUCCH_ResourceList *multiCsiRsrcList)
5055 uint8_t elementCnt = 0, rsrcIdx = 0;
5057 elementCnt = multiCsiDb->multiCsiResrcListCount;
5058 multiCsiRsrcList->list.count = elementCnt;
5059 multiCsiRsrcList->list.size = elementCnt * sizeof(PUCCH_ResourceId_t *);
5060 multiCsiRsrcList->list.array = NULLP;
5061 DU_ALLOC(multiCsiRsrcList->list.array, multiCsiRsrcList->list.size);
5062 if(multiCsiRsrcList->list.array == NULLP)
5064 DU_LOG("\nERROR --> DU APP: Memory allocation failed in BuildPucchMultiCsiRsrcList");
5068 for(rsrcIdx = 0; rsrcIdx<multiCsiRsrcList->list.count; rsrcIdx++)
5070 DU_ALLOC(multiCsiRsrcList->list.array[rsrcIdx], sizeof(PUCCH_ResourceId_t));
5071 if(multiCsiRsrcList->list.array[rsrcIdx] == NULLP)
5073 DU_LOG("\nERROR --> DU APP: Memory allocation failed in BuildPucchMultiCsiRsrcList");
5078 for(rsrcIdx = 0; rsrcIdx<multiCsiRsrcList->list.count; rsrcIdx++)
5080 *(multiCsiRsrcList->list.array[rsrcIdx]) = multiCsiDb->multiCsiResrcList[rsrcIdx];
5085 /*******************************************************************
5087 * @brief Builds DL data -to- Ul Ack list
5091 * Function : BuildDlDataToUlAckList
5093 * Functionality: Builds DL data -to- Ul Ack list
5095 * @params[in] : PucchDlDataToUlAck *dlDataToUlAckDb
5096 * struct PUCCH_Config__dl_DataToUL_ACK * dlDataToUlACKList
5098 * @return ROK - success
5101 * ****************************************************************/
5102 uint8_t BuildDlDataToUlAckList(PucchDlDataToUlAck *dlDataToUlAckDb, struct PUCCH_Config__dl_DataToUL_ACK * dlDataToUlACKList)
5104 uint8_t elementCnt = 0, arrIdx = 0;
5106 if(dlDataToUlAckDb == NULLP)
5109 elementCnt = dlDataToUlAckDb->dlDataToUlAckListCount;
5111 dlDataToUlACKList->list.count = elementCnt;
5112 dlDataToUlACKList->list.size = elementCnt * sizeof(long *);
5113 DU_ALLOC(dlDataToUlACKList->list.array, dlDataToUlACKList->list.size);
5114 if(dlDataToUlACKList->list.array == NULLP)
5116 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDlDataToUlAckList");
5120 for(arrIdx = 0; arrIdx < dlDataToUlACKList->list.count; arrIdx++)
5122 DU_ALLOC(dlDataToUlACKList->list.array[arrIdx], sizeof(long));
5123 if(dlDataToUlACKList->list.array[arrIdx] == NULLP)
5125 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDlDataToUlAckList");
5130 if(dlDataToUlAckDb == NULLP)
5133 *(dlDataToUlACKList->list.array[arrIdx++]) = 1;
5134 *(dlDataToUlACKList->list.array[arrIdx]) = 2;
5138 for(arrIdx = 0; arrIdx < dlDataToUlACKList->list.count; arrIdx++)
5140 *(dlDataToUlACKList->list.array[arrIdx]) = dlDataToUlAckDb->dlDataToUlAckList[arrIdx];
5146 /*******************************************************************
5148 * @brief Builds BWP UL dedicated PUCCH Config
5152 * Function : BuildBWPUlDedPucchCfg
5155 * Builds BWP UL dedicated PUCCH Config
5157 * @params[in] : PUCCH_Config_t *pucchCfg
5159 * @return ROK - success
5162 * ****************************************************************/
5163 uint8_t BuildBWPUlDedPucchCfg(PucchCfg *pucchCfgDb, PUCCH_Config_t *pucchCfg)
5165 PucchResrcSetCfg *rsrcSetCfgDb = NULLP;
5166 PucchResrcCfg *rsrcCfgDb = NULLP;
5167 PucchFormatCfg *format1Db = NULLP;
5168 PucchFormatCfg *format2Db = NULLP;
5169 PucchFormatCfg *format3Db = NULLP;
5170 PucchFormatCfg *format4Db = NULLP;
5171 PucchSchedReqCfg *schReqDb = NULLP;
5172 PucchMultiCsiCfg *multiCsiDb = NULLP;
5173 PucchDlDataToUlAck *dlDataToUlAckDb = NULLP;
5177 rsrcSetCfgDb = pucchCfgDb->resrcSet;
5178 rsrcCfgDb = pucchCfgDb->resrc;
5179 format1Db = pucchCfgDb->format1;
5180 format2Db = pucchCfgDb->format2;
5181 format3Db = pucchCfgDb->format3;
5182 format4Db = pucchCfgDb->format4;
5183 schReqDb = pucchCfgDb->schedReq;
5184 multiCsiDb = pucchCfgDb->multiCsiCfg;
5185 dlDataToUlAckDb = pucchCfgDb->dlDataToUlAck;
5189 DU_ALLOC(pucchCfg->resourceSetToAddModList, sizeof(struct PUCCH_Config__resourceSetToAddModList));
5190 if(pucchCfg->resourceSetToAddModList == NULL)
5192 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5196 if(BuildPucchRsrcSetAddModList(rsrcSetCfgDb, pucchCfg->resourceSetToAddModList) != ROK)
5198 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5202 /* PUCCH RESOURCE */
5203 DU_ALLOC(pucchCfg->resourceToAddModList, sizeof(struct PUCCH_Config__resourceToAddModList));
5204 if(pucchCfg->resourceToAddModList == NULLP)
5206 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5210 if(BuildPucchRsrcAddModList(rsrcCfgDb, pucchCfg->resourceToAddModList) != ROK)
5212 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5216 /* PUCCH Format 1 */
5217 DU_ALLOC(pucchCfg->format1, sizeof(struct PUCCH_Config__format1));
5218 if(pucchCfg->format1 == NULLP)
5220 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5224 pucchCfg->format1->present = PUCCH_Config__format1_PR_setup;
5225 DU_ALLOC(pucchCfg->format1->choice.setup, sizeof(PUCCH_FormatConfig_t));
5226 if(pucchCfg->format1->choice.setup == NULLP)
5228 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5232 if(BuildPucchFormat(format1Db, pucchCfg->format1->choice.setup) != ROK)
5234 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5238 /* PUCCH Format 2 */
5241 DU_ALLOC(pucchCfg->format2, sizeof(struct PUCCH_Config__format2));
5242 if(pucchCfg->format2 == NULLP)
5244 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5248 pucchCfg->format2->present = PUCCH_Config__format2_PR_setup;
5249 DU_ALLOC(pucchCfg->format2->choice.setup, sizeof(PUCCH_FormatConfig_t));
5250 if(pucchCfg->format2->choice.setup == NULLP)
5252 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5256 if(BuildPucchFormat(format2Db, pucchCfg->format2->choice.setup) != ROK)
5258 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5263 /* PUCCH Format 3 */
5266 DU_ALLOC(pucchCfg->format3, sizeof(struct PUCCH_Config__format3));
5267 if(pucchCfg->format3 == NULLP)
5269 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5273 pucchCfg->format3->present = PUCCH_Config__format3_PR_setup;
5274 DU_ALLOC(pucchCfg->format3->choice.setup, sizeof(PUCCH_FormatConfig_t));
5275 if(pucchCfg->format3->choice.setup == NULLP)
5277 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5281 if(BuildPucchFormat(format3Db, pucchCfg->format3->choice.setup) != ROK)
5283 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5288 /* PUCCH Format 4 */
5291 DU_ALLOC(pucchCfg->format4, sizeof(struct PUCCH_Config__format4));
5292 if(pucchCfg->format4 == NULLP)
5294 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5298 pucchCfg->format4->present = PUCCH_Config__format4_PR_setup;
5299 DU_ALLOC(pucchCfg->format4->choice.setup, sizeof(PUCCH_FormatConfig_t));
5300 if(pucchCfg->format4->choice.setup == NULLP)
5302 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5306 if(BuildPucchFormat(format4Db, pucchCfg->format4->choice.setup) != ROK)
5308 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5313 /* Scheduling Request */
5314 if(schReqDb && (schReqDb->schedAddModListCount != 0))
5316 pucchCfg->schedulingRequestResourceToAddModList = NULLP;
5317 DU_ALLOC(pucchCfg->schedulingRequestResourceToAddModList, sizeof(struct PUCCH_Config__schedulingRequestResourceToAddModList));
5318 if(pucchCfg->schedulingRequestResourceToAddModList == NULLP)
5320 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5324 if(BuildPucchSchReqAddModList(schReqDb, pucchCfg->schedulingRequestResourceToAddModList) != ROK)
5326 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5332 if(multiCsiDb && (multiCsiDb->multiCsiResrcListCount != 0))
5334 pucchCfg->multi_CSI_PUCCH_ResourceList = NULLP;
5335 DU_ALLOC(pucchCfg->multi_CSI_PUCCH_ResourceList, sizeof(struct PUCCH_Config__multi_CSI_PUCCH_ResourceList));
5336 if(pucchCfg->multi_CSI_PUCCH_ResourceList == NULLP)
5338 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5342 if(BuildPucchMultiCsiRsrcList(multiCsiDb, pucchCfg->multi_CSI_PUCCH_ResourceList) != ROK)
5344 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5349 /* DL DATA TO UL ACK */
5350 DU_ALLOC(pucchCfg->dl_DataToUL_ACK, sizeof(struct PUCCH_Config__dl_DataToUL_ACK));
5351 if(pucchCfg->dl_DataToUL_ACK == NULLP)
5353 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5357 if(BuildDlDataToUlAckList(dlDataToUlAckDb, pucchCfg->dl_DataToUL_ACK) != ROK)
5359 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedPucchCfg");
5363 /* TODO : spatial relation info add/mod list and power control*/
5368 /*******************************************************************
5370 * @brief Fills SRS resource to add/modify list
5374 * Function : BuildSrsRsrcAddModList
5376 * Functionality: Fills SRS resource to add/modify list
5379 * @return ROK - success
5382 * ****************************************************************/
5383 uint8_t BuildSrsRsrcAddModList(struct SRS_Config__srs_ResourceToAddModList *resourceList)
5389 resourceList->list.count = elementCnt;
5390 resourceList->list.size = elementCnt * sizeof(SRS_Resource_t *);
5391 resourceList->list.array = NULLP;
5392 DU_ALLOC(resourceList->list.array, resourceList->list.size);
5393 if(!resourceList->list.array)
5395 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
5399 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
5401 DU_ALLOC(resourceList->list.array[rsrcIdx], sizeof(SRS_Resource_t));
5402 if(!resourceList->list.array[rsrcIdx])
5404 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
5410 resourceList->list.array[rsrcIdx]->srs_ResourceId = SRS_RSRC_ID;
5411 resourceList->list.array[rsrcIdx]->nrofSRS_Ports = SRS_Resource__nrofSRS_Ports_port1;
5412 resourceList->list.array[rsrcIdx]->transmissionComb.present = SRS_Resource__transmissionComb_PR_n2;
5414 resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2 = NULLP;
5415 DU_ALLOC(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2, \
5416 sizeof(struct SRS_Resource__transmissionComb__n2));
5417 if(!resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2)
5419 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
5422 resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2->combOffset_n2\
5423 = SRS_COMB_OFFSET_N2;
5424 resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2->cyclicShift_n2\
5425 = SRS_CYCLIC_SHIFT_N2;
5427 resourceList->list.array[rsrcIdx]->resourceMapping.startPosition = \
5429 resourceList->list.array[rsrcIdx]->resourceMapping.nrofSymbols = \
5430 SRS_Resource__resourceMapping__nrofSymbols_n1;
5431 resourceList->list.array[rsrcIdx]->resourceMapping.repetitionFactor = \
5432 SRS_Resource__resourceMapping__repetitionFactor_n1;
5434 resourceList->list.array[rsrcIdx]->freqDomainPosition = SRS_FREQ_DOM_POS;
5435 resourceList->list.array[rsrcIdx]->freqDomainShift = SRS_FREQ_DOM_SHIFT;
5436 resourceList->list.array[rsrcIdx]->freqHopping.c_SRS = C_SRS;
5437 resourceList->list.array[rsrcIdx]->freqHopping.b_SRS = B_SRS;
5438 resourceList->list.array[rsrcIdx]->freqHopping.b_hop = B_HOP;
5439 resourceList->list.array[rsrcIdx]->groupOrSequenceHopping = \
5440 SRS_Resource__groupOrSequenceHopping_neither;
5442 /* Setting resource type to aperiodic for intergration purposes */
5443 resourceList->list.array[rsrcIdx]->resourceType.present = \
5444 SRS_Resource__resourceType_PR_aperiodic;
5445 resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic = NULLP;
5446 DU_ALLOC(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic,
5447 sizeof(struct SRS_Resource__resourceType__aperiodic));
5448 if(!resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic)
5450 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcAddModList");
5453 resourceList->list.array[rsrcIdx]->sequenceId = SRS_SEQ_ID;
5458 /*******************************************************************
5460 * @brief Build SRS resource set Add/mod list
5464 * Function : BuildSrsRsrcSetAddModList
5466 * Functionality: Build SRS resource set Add/mod list
5469 * @return ROK - success
5472 * ****************************************************************/
5473 uint8_t BuildSrsRsrcSetAddModList
5475 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList
5481 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList;
5484 rsrcSetList->list.count = elementCnt;
5485 rsrcSetList->list.size = elementCnt * sizeof(SRS_ResourceSet_t *);
5486 rsrcSetList->list.array = NULLP;
5487 DU_ALLOC(rsrcSetList->list.array, rsrcSetList->list.size);
5488 if(!rsrcSetList->list.array)
5490 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
5494 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
5496 DU_ALLOC(rsrcSetList->list.array[rSetIdx], sizeof(SRS_ResourceSet_t));
5497 if(!rsrcSetList->list.array[rSetIdx])
5499 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
5505 rsrcSetList->list.array[rSetIdx]->srs_ResourceSetId = SRS_RSET_ID;
5507 /* Fill Resource Id list in resource set */
5508 rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList = NULLP;
5509 DU_ALLOC(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList,\
5510 sizeof(struct SRS_ResourceSet__srs_ResourceIdList));
5511 if(!rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
5513 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
5518 rsrcIdList = rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
5519 rsrcIdList->list.count = elementCnt;
5520 rsrcIdList->list.size = elementCnt * sizeof(SRS_ResourceId_t *);
5521 rsrcIdList->list.array = NULLP;
5522 DU_ALLOC(rsrcIdList->list.array, rsrcIdList->list.size);
5523 if(!rsrcIdList->list.array)
5525 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
5529 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count; rsrcIdx++)
5531 DU_ALLOC(rsrcIdList->list.array[rsrcIdx], sizeof(SRS_ResourceId_t));
5532 if(!rsrcIdList->list.array[rsrcIdx])
5534 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
5540 *rsrcIdList->list.array[rsrcIdx] = SRS_RSRC_ID;
5542 /* Fill resource type */
5543 rsrcSetList->list.array[rSetIdx]->resourceType.present = \
5544 SRS_ResourceSet__resourceType_PR_aperiodic;
5546 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic = NULLP;
5547 DU_ALLOC(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic, \
5548 sizeof(struct SRS_ResourceSet__resourceType__aperiodic));
5549 if(!rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic)
5551 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildSrsRsrcSetAddModList");
5554 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic->aperiodicSRS_ResourceTrigger \
5555 = APERIODIC_SRS_RESRC_TRIGGER;
5557 /* TODO : Fill values for below IEs as expected by Viavi */
5558 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic->csi_RS = NULLP;
5559 rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic->slotOffset = NULLP;
5562 rsrcSetList->list.array[rSetIdx]->usage = SRS_ResourceSet__usage_codebook;
5563 rsrcSetList->list.array[rSetIdx]->alpha = NULLP;
5564 rsrcSetList->list.array[rSetIdx]->p0 = NULLP;
5565 rsrcSetList->list.array[rSetIdx]->pathlossReferenceRS = NULLP;
5566 rsrcSetList->list.array[rSetIdx]->srs_PowerControlAdjustmentStates = NULLP;
5571 /*******************************************************************
5573 * @brief Builds BWP UL dedicated SRS Config
5577 * Function : BuildBWPUlDedSrsCfg
5579 * Functionality: Builds BWP UL dedicated SRS Config
5581 * @params[in] SRS Config
5582 * @return ROK - success
5585 * ****************************************************************/
5586 uint8_t BuildBWPUlDedSrsCfg(SRS_Config_t *srsCfg)
5588 srsCfg->srs_ResourceSetToReleaseList = NULLP;
5589 srsCfg->srs_ResourceSetToAddModList = NULLP;
5590 DU_ALLOC(srsCfg->srs_ResourceSetToAddModList, \
5591 sizeof(struct SRS_Config__srs_ResourceSetToAddModList));
5592 if(!srsCfg->srs_ResourceSetToAddModList)
5594 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedSrsCfg");
5597 if(BuildSrsRsrcSetAddModList(srsCfg->srs_ResourceSetToAddModList) != ROK)
5602 srsCfg->srs_ResourceToReleaseList = NULLP;
5604 /* Resource to Add/Modify list */
5605 srsCfg->srs_ResourceToAddModList = NULLP;
5606 DU_ALLOC(srsCfg->srs_ResourceToAddModList, \
5607 sizeof(struct SRS_Config__srs_ResourceToAddModList));
5608 if(!srsCfg->srs_ResourceToAddModList)
5610 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildBWPUlDedSrsCfg");
5614 if(BuildSrsRsrcAddModList(srsCfg->srs_ResourceToAddModList) != ROK)
5619 srsCfg->tpc_Accumulation = NULLP;
5626 /*******************************************************************
5628 * @brief Builds Pusch Serving cell Config
5632 * Function : BuildPuschSrvCellCfg
5634 * Functionality: Builds Pusch Serving cell Config
5636 * @params[in] struct UplinkConfig__pusch_ServingCellConfig *puschCfg
5638 * @return ROK - success
5641 * ****************************************************************/
5642 uint8_t BuildPuschSrvCellCfg(struct UplinkConfig__pusch_ServingCellConfig *puschCfg)
5644 puschCfg->present = UplinkConfig__pusch_ServingCellConfig_PR_setup;
5645 puschCfg->choice.setup = NULLP;
5646 DU_ALLOC(puschCfg->choice.setup, sizeof(struct PUSCH_ServingCellConfig));
5647 if(!puschCfg->choice.setup)
5649 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
5653 puschCfg->choice.setup->codeBlockGroupTransmission = NULLP;
5654 puschCfg->choice.setup->rateMatching = NULLP;
5655 puschCfg->choice.setup->xOverhead = NULLP;
5656 puschCfg->choice.setup->ext1 = NULLP;
5657 DU_ALLOC(puschCfg->choice.setup->ext1, sizeof(struct PUSCH_ServingCellConfig__ext1));
5658 if(!puschCfg->choice.setup->ext1)
5660 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
5664 puschCfg->choice.setup->ext1->maxMIMO_Layers = NULLP;
5665 DU_ALLOC(puschCfg->choice.setup->ext1->maxMIMO_Layers, sizeof(long));
5666 if(!puschCfg->choice.setup->ext1->maxMIMO_Layers)
5668 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
5671 *(puschCfg->choice.setup->ext1->maxMIMO_Layers) = PUSCH_MAX_MIMO_LAYERS;
5673 puschCfg->choice.setup->ext1->processingType2Enabled= NULLP;
5674 DU_ALLOC(puschCfg->choice.setup->ext1->processingType2Enabled,sizeof(BOOLEAN_t));
5675 if(!puschCfg->choice.setup->ext1->processingType2Enabled)
5677 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPuschSrvCellCfg");
5680 *(puschCfg->choice.setup->ext1->processingType2Enabled) = PUSCH_PROCESS_TYPE2_ENABLED;
5684 /*******************************************************************
5686 * @brief Builds inital UL BWP
5690 * Function : BuildInitialUlBWP
5692 * Functionality: Builds initial UL BWP
5694 * @params[in] BWP_UplinkDedicated_t *ulBwp
5695 * @return ROK - success
5698 * ****************************************************************/
5699 uint8_t BuildInitialUlBWP(InitialUlBwp *initUlBwp, BWP_UplinkDedicated_t *ulBwp)
5701 PucchCfg *pucchCfg = NULLP;
5702 PuschCfg *puschCfg = NULLP;
5706 if(initUlBwp->pucchPresent)
5707 pucchCfg = &initUlBwp->pucchCfg;
5708 if(initUlBwp->puschPresent)
5709 puschCfg = &initUlBwp->puschCfg;
5712 ulBwp->pucch_Config = NULLP;
5713 DU_ALLOC(ulBwp->pucch_Config, sizeof(struct BWP_UplinkDedicated__pucch_Config));
5714 if(!ulBwp->pucch_Config)
5716 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
5720 ulBwp->pucch_Config->present = BWP_UplinkDedicated__pucch_Config_PR_setup;
5721 ulBwp->pucch_Config->choice.setup = NULLP;
5722 DU_ALLOC(ulBwp->pucch_Config->choice.setup, sizeof(PUCCH_Config_t));
5723 if(!ulBwp->pucch_Config->choice.setup)
5725 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
5729 if(BuildBWPUlDedPucchCfg(pucchCfg, ulBwp->pucch_Config->choice.setup) != ROK)
5734 /* Fill BWP UL dedicated PUSCH config */
5735 ulBwp->pusch_Config = NULLP;
5736 DU_ALLOC(ulBwp->pusch_Config, sizeof(struct BWP_UplinkDedicated__pusch_Config));
5737 if(!ulBwp->pusch_Config)
5739 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
5743 ulBwp->pusch_Config->present = BWP_UplinkDedicated__pusch_Config_PR_setup;
5744 ulBwp->pusch_Config->choice.setup = NULLP;
5745 DU_ALLOC(ulBwp->pusch_Config->choice.setup, sizeof(PUSCH_Config_t));
5746 if(!ulBwp->pusch_Config->choice.setup)
5748 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
5752 if(BuildBWPUlDedPuschCfg(puschCfg, ulBwp->pusch_Config->choice.setup) != ROK)
5757 ulBwp->configuredGrantConfig = NULLP;
5759 /* Fill BPW UL dedicated SRS config */
5760 ulBwp->srs_Config = NULLP;
5761 DU_ALLOC(ulBwp->srs_Config, sizeof(struct BWP_UplinkDedicated__srs_Config));
5762 if(!ulBwp->srs_Config)
5764 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
5768 ulBwp->srs_Config->present = BWP_UplinkDedicated__srs_Config_PR_setup;
5769 ulBwp->srs_Config->choice.setup = NULLP;
5770 DU_ALLOC(ulBwp->srs_Config->choice.setup, sizeof(SRS_Config_t));
5771 if(!ulBwp->srs_Config->choice.setup)
5773 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildInitialUlBWP");
5777 if(BuildBWPUlDedSrsCfg(ulBwp->srs_Config->choice.setup) != ROK)
5782 ulBwp->beamFailureRecoveryConfig = NULLP;
5787 /*******************************************************************
5789 * @brief Builds UL config
5792 * Function : BuildUlCfg
5794 * Functionality: Builds UL config in spCellCfgDed
5796 * @params[in] UplinkConfig_t *ulCfg
5798 * @return ROK - success
5801 * ****************************************************************/
5802 uint8_t BuildUlCfg(ServCellCfgInfo *servCellCfg, UplinkConfig_t *ulCfg)
5804 InitialUlBwp *initUlBwp = NULLP;
5808 initUlBwp = &servCellCfg->initUlBwp;
5811 ulCfg->initialUplinkBWP = NULLP;
5812 DU_ALLOC(ulCfg->initialUplinkBWP, sizeof(BWP_UplinkDedicated_t));
5813 if(!ulCfg->initialUplinkBWP)
5815 DU_LOG("\nERROR --> F1AP : Memory Allocation failed in BuildUlCfg");
5819 if(BuildInitialUlBWP(initUlBwp, ulCfg->initialUplinkBWP) != ROK)
5824 ulCfg->uplinkBWP_ToReleaseList = NULLP;
5825 ulCfg->uplinkBWP_ToAddModList = NULLP;
5826 ulCfg->firstActiveUplinkBWP_Id = NULLP;
5827 DU_ALLOC(ulCfg->firstActiveUplinkBWP_Id, sizeof(BWP_Id_t));
5828 if(!ulCfg->firstActiveUplinkBWP_Id)
5830 DU_LOG("\nERROR --> F1AP : Memory Allocation failed in BuildUlCfg");
5833 if(servCellCfg == NULLP)
5834 *(ulCfg->firstActiveUplinkBWP_Id) = ACTIVE_UL_BWP_ID;
5836 *(ulCfg->firstActiveUplinkBWP_Id) = servCellCfg->firstActvUlBwpId;
5838 ulCfg->pusch_ServingCellConfig = NULLP;
5839 DU_ALLOC(ulCfg->pusch_ServingCellConfig, sizeof(struct UplinkConfig__pusch_ServingCellConfig));
5840 if(!ulCfg->pusch_ServingCellConfig)
5842 DU_LOG("\nERROR --> F1AP : Memory Allocation failed in BuildUlCfg");
5846 if(BuildPuschSrvCellCfg(ulCfg->pusch_ServingCellConfig) != ROK)
5851 ulCfg->carrierSwitching = NULLP;
5852 ulCfg->ext1 = NULLP;
5856 /*******************************************************************
5858 * @brief Builds PDSCH serving cell config
5861 * Function : BuildPdschSrvCellCfg
5863 * Functionality: Builds PDSCH serving cell config in spCellCfgDed
5865 * @params[in] struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg
5867 * @return ROK - success
5870 * ****************************************************************/
5871 uint8_t BuildPdschSrvCellCfg(PdschServCellCfg *pdschServCellDb, struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg)
5873 pdschCfg->present = ServingCellConfig__pdsch_ServingCellConfig_PR_setup;
5874 pdschCfg->choice.setup = NULLP;
5875 DU_ALLOC(pdschCfg->choice.setup, sizeof( struct PDSCH_ServingCellConfig));
5876 if(!pdschCfg->choice.setup)
5878 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
5882 /* Code Block Group Transmission */
5883 pdschCfg->choice.setup->codeBlockGroupTransmission = NULLP;
5884 if(pdschServCellDb && (pdschServCellDb->maxCodeBlkGrpPerTb || pdschServCellDb->codeBlkGrpFlushInd))
5886 DU_ALLOC(pdschCfg->choice.setup->codeBlockGroupTransmission, sizeof(struct PDSCH_ServingCellConfig__codeBlockGroupTransmission));
5887 if(pdschCfg->choice.setup->codeBlockGroupTransmission == NULLP)
5889 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
5893 pdschCfg->choice.setup->codeBlockGroupTransmission->present = PDSCH_ServingCellConfig__codeBlockGroupTransmission_PR_setup;
5894 pdschCfg->choice.setup->codeBlockGroupTransmission->choice.setup = NULLP;
5895 DU_ALLOC(pdschCfg->choice.setup->codeBlockGroupTransmission->choice.setup, sizeof(struct PDSCH_CodeBlockGroupTransmission ));
5896 if(pdschCfg->choice.setup->codeBlockGroupTransmission->choice.setup == NULLP)
5898 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
5902 pdschCfg->choice.setup->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock = \
5903 *(pdschServCellDb->maxCodeBlkGrpPerTb);
5904 pdschCfg->choice.setup->codeBlockGroupTransmission->choice.setup->codeBlockGroupFlushIndicator = \
5905 *(pdschServCellDb->codeBlkGrpFlushInd);
5909 pdschCfg->choice.setup->xOverhead = NULLP;
5910 if(pdschServCellDb && pdschServCellDb->xOverhead)
5912 DU_ALLOC(pdschCfg->choice.setup->xOverhead, sizeof(long));
5913 if(pdschCfg->choice.setup->xOverhead == NULLP)
5915 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
5918 *(pdschCfg->choice.setup->xOverhead) = *(pdschServCellDb->xOverhead);
5921 /* Number of HARQ processes */
5922 pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH = NULLP;
5923 DU_ALLOC(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH, sizeof(long));
5924 if(!pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH)
5926 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
5930 if(pdschServCellDb == NULLP)
5931 *(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH) = PDSCH_NUM_HARQ_PROC;
5933 *(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH) = pdschServCellDb->numHarqProcForPdsch;
5935 pdschCfg->choice.setup->pucch_Cell = NULLP;
5938 pdschCfg->choice.setup->ext1 = NULLP;
5939 if(pdschServCellDb && pdschServCellDb->maxMimoLayers)
5941 DU_ALLOC(pdschCfg->choice.setup->ext1, sizeof(struct PDSCH_ServingCellConfig__ext1));
5942 if(pdschCfg->choice.setup->ext1 == NULLP)
5944 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
5948 DU_ALLOC(pdschCfg->choice.setup->ext1->maxMIMO_Layers, sizeof(long));
5949 if(pdschCfg->choice.setup->ext1->maxMIMO_Layers == NULLP)
5951 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildPdschSrvCellCfg");
5954 *(pdschCfg->choice.setup->ext1->maxMIMO_Layers) = *(pdschServCellDb->maxMimoLayers);
5960 /*******************************************************************
5962 * @brief Builds CSI Meas config
5965 * Function : BuildCsiMeasCfg
5967 * Functionality: Builds CSI Meas config in spCellCfgDed
5969 * @params[in] struct ServingCellConfig__csi_MeasConfig *csiMeasCfg
5971 * @return ROK - success
5974 * ****************************************************************/
5975 uint8_t BuildCsiMeasCfg(struct ServingCellConfig__csi_MeasConfig *csiMeasCfg)
5981 /*******************************************************************
5983 * @brief Builds DL BWP to add/modify list
5986 * Function : BuildDlBwpToAddModList
5988 * Functionality: Builds DL BWP to add/modify list
5990 * @params[in] ServCellCfgInfo *servCellCfg,
5991 * struct ServingCellConfig__downlinkBWP_ToAddModList *dlBwpAddModList
5993 * @return ROK - success
5996 * ****************************************************************/
5997 uint8_t BuildDlBwpToAddModList(ServCellCfgInfo *servCellCfg, struct ServingCellConfig__downlinkBWP_ToAddModList *dlBwpAddModList)
5999 uint8_t elementCnt, idx;
6001 elementCnt = servCellCfg->numDlBwpToAdd;
6002 dlBwpAddModList->list.count = elementCnt;
6003 dlBwpAddModList->list.size = elementCnt * sizeof(struct BWP_Downlink *);
6004 dlBwpAddModList->list.array = NULLP;
6005 DU_ALLOC(dlBwpAddModList->list.array, dlBwpAddModList->list.size);
6006 if(dlBwpAddModList->list.array == NULLP)
6008 DU_LOG("\nERROR --> DU APP: Memory allocation failure in BuildDlBwpToAddModList");
6012 for(idx=0; idx<dlBwpAddModList->list.count; idx++)
6014 DU_ALLOC(dlBwpAddModList->list.array[idx], sizeof(BWP_Downlink_t));
6015 if(dlBwpAddModList->list.array[idx] == NULLP)
6017 DU_LOG("\nERROR --> DU APP: Memory allocation failure in BuildDlBwpToAddModList");
6022 for(idx=0; idx<dlBwpAddModList->list.count; idx++)
6024 dlBwpAddModList->list.array[idx]->bwp_Id = servCellCfg->DlBwpToAddList[idx].bwpId;
6025 dlBwpAddModList->list.array[idx]->bwp_Common = NULLP;
6026 dlBwpAddModList->list.array[idx]->bwp_Dedicated = NULLP;
6031 /*******************************************************************
6033 * @brief Builds Spcell config dedicated
6036 * Function : BuildSpCellCfgDed
6038 * Functionality: Builds sp cell config dedicated in spCellCfg
6040 * @params[in] ServingCellConfig_t srvCellCfg
6042 * @return ROK - success
6045 * ****************************************************************/
6046 uint8_t BuildSpCellCfgDed(DuUeCb *ueCb, ServingCellConfig_t *srvCellCfg)
6048 ServCellCfgInfo *servCellCfg = NULLP;
6049 InitialDlBwp *initDlBwp = NULLP;
6050 PdschServCellCfg *pdschServCellDb = NULLP;
6054 servCellCfg = &ueCb->macUeCfg.spCellCfg.servCellCfg;
6055 initDlBwp = &servCellCfg->initDlBwp;
6056 pdschServCellDb = &servCellCfg->pdschServCellCfg;
6059 srvCellCfg->tdd_UL_DL_ConfigurationDedicated = NULLP;
6060 DU_ALLOC(srvCellCfg->tdd_UL_DL_ConfigurationDedicated, sizeof(TDD_UL_DL_ConfigDedicated_t));
6061 if(!srvCellCfg->tdd_UL_DL_ConfigurationDedicated)
6063 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
6067 srvCellCfg->initialDownlinkBWP = NULLP;
6068 DU_ALLOC(srvCellCfg->initialDownlinkBWP, sizeof(BWP_DownlinkDedicated_t));
6069 if(!srvCellCfg->initialDownlinkBWP)
6071 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
6075 if(BuildInitialDlBWP(initDlBwp, srvCellCfg->initialDownlinkBWP) != ROK)
6077 DU_LOG("\nERROR --> F1AP : BuildInitialDlBWP failed");
6081 srvCellCfg->downlinkBWP_ToReleaseList = NULLP;
6083 srvCellCfg->downlinkBWP_ToAddModList = NULLP;
6084 if(ueCb && ueCb->macUeCfg.spCellCfg.servCellCfg.numDlBwpToAdd)
6086 DU_ALLOC(srvCellCfg->downlinkBWP_ToAddModList, sizeof(struct ServingCellConfig__downlinkBWP_ToAddModList));
6087 if(srvCellCfg->downlinkBWP_ToAddModList == NULLP)
6089 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
6093 if(BuildDlBwpToAddModList(&ueCb->macUeCfg.spCellCfg.servCellCfg, srvCellCfg->downlinkBWP_ToAddModList) != ROK)
6095 DU_LOG("\nERROR --> F1AP : BuildInitialDlBWP failed");
6100 srvCellCfg->firstActiveDownlinkBWP_Id = NULLP;
6101 DU_ALLOC(srvCellCfg->firstActiveDownlinkBWP_Id, sizeof(long));
6102 if(!srvCellCfg->firstActiveDownlinkBWP_Id)
6104 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
6108 *(srvCellCfg->firstActiveDownlinkBWP_Id) = ACTIVE_DL_BWP_ID;
6110 *(srvCellCfg->firstActiveDownlinkBWP_Id) = ueCb->macUeCfg.spCellCfg.servCellCfg.firstActvDlBwpId;
6112 srvCellCfg->bwp_InactivityTimer = NULLP;
6114 srvCellCfg->defaultDownlinkBWP_Id = NULLP;
6115 DU_ALLOC(srvCellCfg->defaultDownlinkBWP_Id, sizeof(long));
6116 if(!srvCellCfg->defaultDownlinkBWP_Id)
6118 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
6122 *(srvCellCfg->defaultDownlinkBWP_Id) = ACTIVE_DL_BWP_ID;
6124 *(srvCellCfg->defaultDownlinkBWP_Id) = ueCb->macUeCfg.spCellCfg.servCellCfg.defaultDlBwpId;
6126 srvCellCfg->uplinkConfig = NULLP;
6127 DU_ALLOC(srvCellCfg->uplinkConfig, sizeof(UplinkConfig_t));
6128 if(!srvCellCfg->uplinkConfig)
6130 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
6134 if(BuildUlCfg(servCellCfg, srvCellCfg->uplinkConfig) != ROK)
6136 DU_LOG("\nERROR --> F1AP : BuildUlCfg failed");
6139 srvCellCfg->supplementaryUplink = NULLP;
6140 srvCellCfg->pdcch_ServingCellConfig = NULLP;
6142 srvCellCfg->pdsch_ServingCellConfig = NULLP;
6143 DU_ALLOC(srvCellCfg->pdsch_ServingCellConfig, sizeof(struct ServingCellConfig__pdsch_ServingCellConfig));
6144 if(!srvCellCfg->pdsch_ServingCellConfig)
6146 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
6150 if(BuildPdschSrvCellCfg(pdschServCellDb, srvCellCfg->pdsch_ServingCellConfig) != ROK)
6152 DU_LOG("\nERROR --> F1AP : BuildPdschSrvCellCfg failed");
6156 srvCellCfg->csi_MeasConfig = NULLP;
6158 DU_ALLOC(srvCellCfg->csi_MeasConfig, sizeof(struct ServingCellConfig__csi_MeasConfig))
6159 if(!srvCellCfg->csi_MeasConfig)
6161 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfgDed");
6165 if(BuildCsiMeasCfg(srvCellCfg->csi_MeasConfig) != ROK)
6167 DU_LOG("\nF1AP : BuildCsiMeasCfg failed");
6171 srvCellCfg->sCellDeactivationTimer = NULLP;
6172 srvCellCfg->crossCarrierSchedulingConfig = NULLP;
6173 srvCellCfg->tag_Id = TAG_ID;
6174 srvCellCfg->dummy = NULLP;
6175 srvCellCfg->pathlossReferenceLinking = NULLP;
6176 srvCellCfg->servingCellMO = NULLP;
6177 srvCellCfg->ext1 = NULLP;
6182 /*******************************************************************
6184 * @brief Fills SCS specific carrier list in DL frequency info
6188 * Function : BuildScsSpecificCarrierListDl
6190 * Functionality: Fills SCS specific carrier list in DL frequency info
6192 * @params[in] Pointer to struct FrequencyInfoDL__scs_SpecificCarrierList
6194 * @return ROK - success
6197 * ****************************************************************/
6198 uint8_t BuildScsSpecificCarrierListDl(struct FrequencyInfoDL__scs_SpecificCarrierList *scsCarrierList)
6200 uint8_t elementCnt = 0, listIdx = 0;
6201 ScsSpecCarrier duScsSpecCarrier = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg.dlScsCarrier;
6203 elementCnt = ODU_VALUE_ONE;
6204 scsCarrierList->list.count = elementCnt;
6205 scsCarrierList->list.size = elementCnt * sizeof(SCS_SpecificCarrier_t *);
6207 DU_ALLOC(scsCarrierList->list.array, scsCarrierList->list.size);
6208 if(!scsCarrierList->list.array)
6210 DU_LOG("\nERROR --> DU APP : Memory allocation failed for scs carrier list array \
6211 in BuildScsSpecificCarrierListDl()");
6215 for(listIdx = 0; listIdx < elementCnt; listIdx++)
6217 DU_ALLOC(scsCarrierList->list.array[listIdx], sizeof(SCS_SpecificCarrier_t));
6218 if(!scsCarrierList->list.array[listIdx])
6220 DU_LOG("\nERROR --> DU APP : Memory allocation failed for SCS Specific Carrier list array \
6221 element in BuildScsSpecificCarrierListDl()");
6227 scsCarrierList->list.array[listIdx]->offsetToCarrier = duScsSpecCarrier.scsOffset;
6228 scsCarrierList->list.array[listIdx]->subcarrierSpacing = duScsSpecCarrier.scs;
6229 scsCarrierList->list.array[listIdx]->carrierBandwidth = duScsSpecCarrier.scsBw;
6234 /*******************************************************************
6236 * @brief Fills DL frequency info in DL config common
6240 * Function : BuildFreqInfoDl
6242 * Functionality: Fills DL frequency info in DL config common
6244 * @params[in] Pointer to DownlinkConfigCommon_t
6246 * @return ROK - success
6249 * ****************************************************************/
6250 uint8_t BuildFreqInfoDl(FrequencyInfoDL_t *frequencyInfoDL)
6252 uint8_t freqBandIdx = 0, elementCnt = 0;
6253 DlCfgCommon dlCfg = duCfgParam.sib1Params.srvCellCfgCommSib.dlCfg;
6255 /* TODO : Fill SSB Absolute Frequency */
6257 DU_ALLOC(frequencyInfoDL->absoluteFrequencySSB, sizeof(ARFCN_ValueNR_t));
6258 if(!frequencyInfoDL->absoluteFrequencySSB)
6260 DU_LOG("\nERROR --> DU APP : Memory allocation failed for SSB Absolute Frequency in BuildFreqInfoDl()");
6263 frequencyInfoDL->absoluteFrequencySSB = ?;
6266 /* NR Multi Frequency Band List */
6267 elementCnt = ODU_VALUE_ONE;
6268 frequencyInfoDL->frequencyBandList.list.count = elementCnt;
6269 frequencyInfoDL->frequencyBandList.list.size = elementCnt * sizeof(FreqBandIndicatorNR_t *);
6271 DU_ALLOC(frequencyInfoDL->frequencyBandList.list.array, frequencyInfoDL->frequencyBandList.list.size);
6272 if(!frequencyInfoDL->frequencyBandList.list.array)
6274 DU_LOG("\nERROR --> DU APP : Memory allocation failed for Frequency Band List array in BuildFreqInfoDl()");
6278 for(freqBandIdx = 0; freqBandIdx < elementCnt; freqBandIdx++)
6280 DU_ALLOC(frequencyInfoDL->frequencyBandList.list.array[freqBandIdx], sizeof(FreqBandIndicatorNR_t));
6281 if(!frequencyInfoDL->frequencyBandList.list.array[freqBandIdx])
6283 DU_LOG("\nERROR --> DU APP : Memory allocation failed for frequency band array element in BuildFreqInfoDl()");
6289 *(frequencyInfoDL->frequencyBandList.list.array[freqBandIdx]) = dlCfg.freqBandInd;
6291 /* TODO : Absolute Frequency to Point A */
6292 //frequencyInfoDL->absoluteFrequencyPointA
6294 /* Subcarrier Spacing specifc carrier List */
6295 if((BuildScsSpecificCarrierListDl(&frequencyInfoDL->scs_SpecificCarrierList)) != ROK)
6297 DU_LOG("\nERROR --> DU APP : Failed to fill SCS specific carrier list DL in BuildFreqInfoDl()");
6305 /*******************************************************************
6307 * @brief Fills DL config common in Serving cell config common
6311 * Function : BuildDlConfigCommon
6313 * Functionality: Fills DL config common in Serving cell config common
6315 * @params[in] Pointer to DownlinkConfigCommon_t
6317 * @return ROK - success
6320 * ****************************************************************/
6321 uint8_t BuildDlConfigCommon(DownlinkConfigCommon_t *dlCfgCommon)
6323 /* DL Frequency Info */
6324 DU_ALLOC(dlCfgCommon->frequencyInfoDL, sizeof(FrequencyInfoDL_t));
6325 if(!dlCfgCommon->frequencyInfoDL)
6327 DU_LOG("\nERROR --> DU APP : Memory allocation failed for DL frequency info in BuildDlConfigCommon()");
6330 if((BuildFreqInfoDl(dlCfgCommon->frequencyInfoDL))!= ROK)
6332 DU_LOG("\nERROR --> DU APP : Failed to fill DL frequency info in BuildDlConfigCommon()");
6336 /* DL BWP config common */
6337 DU_ALLOC(dlCfgCommon->initialDownlinkBWP, sizeof(BWP_DownlinkCommon_t));
6338 if(!dlCfgCommon->initialDownlinkBWP)
6340 DU_LOG("\nERROR --> DU APP : Memory allocation failed for DL BWP config common in BuildDlConfigCommon()");
6343 if((BuildBwpDlCommon(dlCfgCommon->initialDownlinkBWP)) != ROK)
6345 DU_LOG("\nERROR --> DU APP : Failed to fill DL DWP config common in BuildDlConfigCommon()");
6352 /*******************************************************************
6354 * @brief Fills SCS specific carrier list in UL frequency Info
6358 * Function : BuildScsSpecificCarrierListUl
6360 * Functionality: Fills SCS specific carrier list in UL frequency Info
6362 * @params[in] Pointer to struct FrequencyInfoUL__scs_SpecificCarrierList
6364 * @return ROK - success
6367 * ****************************************************************/
6368 uint8_t BuildScsSpecificCarrierListUl(struct FrequencyInfoUL__scs_SpecificCarrierList *scsCarrierList)
6370 uint8_t elementCnt = 0, listIdx = 0;
6371 ScsSpecCarrier duScsSpecCarrier = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.ulScsCarrier;
6373 elementCnt = ODU_VALUE_ONE;
6374 scsCarrierList->list.count = elementCnt;
6375 scsCarrierList->list.size = elementCnt * sizeof(SCS_SpecificCarrier_t *);
6377 DU_ALLOC(scsCarrierList->list.array, scsCarrierList->list.size);
6378 if(!scsCarrierList->list.array)
6380 DU_LOG("\nERROR --> DU APP : SCS Specific Carrier list memory allocation failed");
6384 for(listIdx = 0; listIdx < scsCarrierList->list.count; listIdx++)
6386 DU_ALLOC(scsCarrierList->list.array[listIdx], sizeof(SCS_SpecificCarrier_t));
6387 if(!scsCarrierList->list.array[listIdx])
6389 DU_LOG("\nERROR --> DU APP : SCS Specific Carrier list memory allocation failed");
6394 scsCarrierList->list.array[listIdx]->offsetToCarrier = duScsSpecCarrier.scsOffset;
6395 scsCarrierList->list.array[listIdx]->subcarrierSpacing = duScsSpecCarrier.scs;
6396 scsCarrierList->list.array[listIdx]->carrierBandwidth = duScsSpecCarrier.scsBw;
6401 /*******************************************************************
6403 * @brief Fills frequency info in UL config common
6407 * Function : BuildFreqInfoUl
6409 * Functionality: Fills frequency info in UL config common
6411 * @params[in] Pointer to FrequencyInfoUL_t
6413 * @return ROK - success
6416 * ****************************************************************/
6417 uint8_t BuildFreqInfoUl(FrequencyInfoUL_t *frequencyInfoUL)
6419 uint8_t elementCnt = 0, listIdx= 0;
6420 UlCfgCommon ulCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg;
6422 /* NR Multi Frequency Band List */
6423 DU_ALLOC(frequencyInfoUL->frequencyBandList, sizeof(MultiFrequencyBandListNR_t));
6424 if(!frequencyInfoUL->frequencyBandList)
6426 DU_LOG("\nERROR --> DU APP : Memory allocation failed for frequency band list in BuildFreqInfoUl()");
6430 elementCnt = ODU_VALUE_ONE;
6431 frequencyInfoUL->frequencyBandList->list.count = elementCnt;
6432 frequencyInfoUL->frequencyBandList->list.size = elementCnt * sizeof(FreqBandIndicatorNR_t *);
6434 DU_ALLOC(frequencyInfoUL->frequencyBandList->list.array, frequencyInfoUL->frequencyBandList->list.size);
6435 if(!frequencyInfoUL->frequencyBandList->list.array)
6437 DU_LOG("\nERROR --> DU APP : Memory allocation failed for frequency band array in BuildFreqInfoUl()");
6441 for(listIdx = 0; listIdx < elementCnt; listIdx++)
6443 DU_ALLOC(frequencyInfoUL->frequencyBandList->list.array[listIdx], sizeof(FreqBandIndicatorNR_t));
6444 if(!frequencyInfoUL->frequencyBandList->list.array[listIdx])
6446 DU_LOG("\nERROR --> DU APP : Memory allocation failed for frequency band array element in BuildFreqInfoUl()");
6452 *(frequencyInfoUL->frequencyBandList->list.array[listIdx]) = ulCfg.freqBandInd;
6454 /* TODO : Fill Absolute frequency point A */
6456 DU_ALLOC(frequencyInfoUL->absoluteFrequencyPointA, sizeof(ARFCN_ValueNR_t));
6457 if(!frequencyInfoUL->absoluteFrequencyPointA)
6459 DU_LOG("\nERROR --> DU APP : Memory allocation failed for absolute frequency point A in BuildFreqInfoUl()");
6462 *(frequencyInfoUL->absoluteFrequencyPointA) = ?;
6465 /* Subcarrier Spacing specifc carrier */
6466 if((BuildScsSpecificCarrierListUl(&frequencyInfoUL->scs_SpecificCarrierList)) != ROK)
6468 DU_LOG("\nERROR --> DU APP : Failed to fill SCS Specific Carrier list UL in BuildFreqInfoUl()");
6473 DU_ALLOC(frequencyInfoUL->p_Max, sizeof(P_Max_t));
6474 if(!frequencyInfoUL->p_Max)
6476 DU_LOG("\nERROR --> DU APP : UL Frequency Infoo memory allocation failure");
6479 *frequencyInfoUL->p_Max = ulCfg.pMax;
6484 /*******************************************************************
6486 * @brief Fills UL config common in Serving cell config common
6490 * Function : BuildUlConfigCommon
6492 * Functionality: Fills UL config common in Serving cell config common
6494 * @params[in] Pointer to UplinkConfigCommon_t
6496 * @return ROK - success
6499 * ****************************************************************/
6500 uint8_t BuildUlConfigCommon(UplinkConfigCommon_t *ulCfgCommon)
6502 /* UL Frequency Info */
6503 DU_ALLOC(ulCfgCommon->frequencyInfoUL, sizeof(FrequencyInfoUL_t));
6504 if(!ulCfgCommon->frequencyInfoUL)
6506 DU_LOG("\nERROR --> DU APP : Memory allocation failed for UL frequency info in BuildUlConfigCommon()");
6510 if((BuildFreqInfoUl(ulCfgCommon->frequencyInfoUL)) != ROK)
6512 DU_LOG("\nERROR --> DU APP : Failed to fill frequency info UL in BuildUlConfigCommon()");
6517 DU_ALLOC(ulCfgCommon->initialUplinkBWP, sizeof(BWP_UplinkCommon_t));
6518 if(!ulCfgCommon->initialUplinkBWP)
6520 DU_LOG("\nERROR --> DU APP : Memory allocation failed for initial UL BWP in BuildUlConfigCommon()");
6524 if((BuildBwpUlCommon(ulCfgCommon->initialUplinkBWP)) != ROK)
6526 DU_LOG("\nERROR --> DU APP : Failed to fill BWP UL common in BuildUlConfigCommon()");
6530 /* Time Alignment timer */
6531 ulCfgCommon->dummy = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.timeAlignTimerComm;
6536 /*******************************************************************
6538 * @brief Fills SSB position in burst in SP cell config common
6542 * Function : BuildSsbPosInBurst
6545 * Fills SSB position in burst in SP cell config common
6547 * @params[in] Pointer to struct ServingCellConfigCommon__ssb_PositionsInBurst
6549 * @return ROK - success
6552 * ****************************************************************/
6553 uint8_t BuildSsbPosInBurst(struct ServingCellConfigCommon__ssb_PositionsInBurst *ssbPosInBurst)
6555 uint8_t bitStringSizeInBytes = 0;
6557 ssbPosInBurst->present = ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap;
6559 /* As per spec 38.331,in the definition of ServingCellConfigCommon */
6560 bitStringSizeInBytes = 1;
6561 ssbPosInBurst->choice.mediumBitmap.size = bitStringSizeInBytes * sizeof(uint8_t);
6563 DU_ALLOC(ssbPosInBurst->choice.mediumBitmap.buf, ssbPosInBurst->choice.mediumBitmap.size);
6564 if(!ssbPosInBurst->choice.mediumBitmap.buf)
6566 DU_LOG("\nERROR --> DU APP : Memory Allocation failed for medium bit map buffer in BuildSsbPosInBurst()");
6570 if((fillBitString(&ssbPosInBurst->choice.mediumBitmap, 0, bitStringSizeInBytes, \
6571 duCfgParam.sib1Params.srvCellCfgCommSib.ssbPosInBurst)) != ROK)
6573 DU_LOG("\nERROR --> DU APP : Failed to fill medium bit map in BuildSsbPosInBurst()");
6580 /*******************************************************************
6582 * @brief Fills SP cell config common in Reconfig with Sync
6586 * Function : BuildSpCellConfigCommon
6588 * Functionality: Fills SP cell config common in Reconfig with Sync
6590 * @params[in] Pointer to ServingCellConfigCommon_t
6592 * @return ROK - success
6595 * ****************************************************************/
6596 uint8_t BuildSpCellConfigCommon(ServingCellConfigCommon_t *spCellConfigCommon)
6598 /* Physical Cell Identity */
6599 DU_ALLOC(spCellConfigCommon->physCellId, sizeof(PhysCellId_t));
6600 if(!spCellConfigCommon->physCellId)
6602 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for physical cell id in BuildSpCellConfigCommon()");
6605 *(spCellConfigCommon->physCellId) = NR_PCI;
6607 /* Downlink Config Common */
6608 DU_ALLOC(spCellConfigCommon->downlinkConfigCommon, sizeof(DownlinkConfigCommon_t));
6609 if(!spCellConfigCommon->downlinkConfigCommon)
6611 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for DL Config Common in BuildSpCellConfigCommon()");
6614 if((BuildDlConfigCommon(spCellConfigCommon->downlinkConfigCommon)) != ROK)
6616 DU_LOG("\nERROR --> DU APP : Failed to fill DL config commin in BuildSpCellConfigCommon()");
6620 /* Uplinlink Config Common */
6621 DU_ALLOC(spCellConfigCommon->uplinkConfigCommon, sizeof(UplinkConfigCommon_t));
6622 if(!spCellConfigCommon->uplinkConfigCommon)
6624 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for UL Config Common in BuildSpCellConfigCommon()");
6627 if((BuildUlConfigCommon(spCellConfigCommon->uplinkConfigCommon)) != ROK)
6629 DU_LOG("\nERROR --> DU APP : Failed to fill UL config commin in BuildSpCellConfigCommon()");
6633 /* Timing Advance offset */
6634 DU_ALLOC(spCellConfigCommon->n_TimingAdvanceOffset, sizeof(long));
6635 if(!spCellConfigCommon->n_TimingAdvanceOffset)
6637 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for Timing Advance Offset in BuildSpCellConfigCommon()");
6640 *(spCellConfigCommon->n_TimingAdvanceOffset) = ServingCellConfigCommon__n_TimingAdvanceOffset_n0;
6642 /* SSB Position In Burst */
6643 DU_ALLOC(spCellConfigCommon->ssb_PositionsInBurst, sizeof(struct ServingCellConfigCommon__ssb_PositionsInBurst));
6644 if(!spCellConfigCommon->ssb_PositionsInBurst)
6646 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for SSB Position In Burst in BuildSpCellConfigCommon()");
6649 if((BuildSsbPosInBurst(spCellConfigCommon->ssb_PositionsInBurst)) != ROK)
6651 DU_LOG("\nERROR --> DU APP : Failed to fill SSB Position In Burst in BuildSpCellConfigCommon()");
6655 /* SSB Periodicity in Serving cell */
6656 DU_ALLOC(spCellConfigCommon->ssb_periodicityServingCell, sizeof(long));
6657 if(!spCellConfigCommon->ssb_periodicityServingCell)
6659 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for SSB Periodicity serving cell in \
6660 BuildSpCellConfigCommon()");
6663 *(spCellConfigCommon->ssb_periodicityServingCell) = \
6664 convertSsbPeriodicityValueToEnum(duCfgParam.sib1Params.srvCellCfgCommSib.ssbPrdServingCell);
6666 /* DMRS Type A position */
6667 spCellConfigCommon->dmrs_TypeA_Position = convertDmrsTypeAPosValueToEnum(duCfgParam.macCellCfg.dmrsTypeAPos);
6669 /* SSB subcarrier spacing */
6670 DU_ALLOC(spCellConfigCommon->ssbSubcarrierSpacing, sizeof(SubcarrierSpacing_t));
6671 if(!spCellConfigCommon->ssbSubcarrierSpacing)
6673 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for sub-carrier spacing in BuildSpCellConfigCommon()");
6676 *(spCellConfigCommon->ssbSubcarrierSpacing) = duCfgParam.sib1Params.srvCellCfgCommSib.scs;
6678 /* TDD UL-DL configuration common */
6679 DU_ALLOC(spCellConfigCommon->tdd_UL_DL_ConfigurationCommon, sizeof(TDD_UL_DL_ConfigCommon_t));
6680 if(!spCellConfigCommon->tdd_UL_DL_ConfigurationCommon)
6682 DU_LOG("\nERROR --> DU APP : Memory allocation failed for TDD UL-DL config common in BuildSpCellConfigCommon()");
6685 if((BuildTddUlDlCfgComm(spCellConfigCommon->tdd_UL_DL_ConfigurationCommon)) != ROK)
6687 DU_LOG("\nERROR --> DU APP : Failed to fill TDD UL-DL config common in BuildSpCellConfigCommon()");
6691 /* SS PBCH Block Power */
6692 spCellConfigCommon->ss_PBCH_BlockPower = duCfgParam.sib1Params.srvCellCfgCommSib.ssPbchBlockPwr;
6697 /*******************************************************************
6699 * @brief Fills dedicated RACH configuration in Reconfiguration with sync
6703 * Function : BuildRecfgWithSync
6706 * Fills dedicated RACH configuration in Reconfiguration with sync
6708 * @params[in] DU UE CB
6709 * Pointer to Rach config dedicated struct
6711 * @return ROK - success
6714 * ****************************************************************/
6715 uint8_t BuildRachConfigDedicated(DuUeCb *ueCb, struct ReconfigurationWithSync__rach_ConfigDedicated *rachCfgDed)
6717 uint8_t elementCnt = 0, listIdx = 0;
6718 CFRA_t *cfra = NULLP;
6719 struct CFRA__resources__ssb *ssbResource = NULLP;
6720 RachCfgCommon duRachCfg = duCfgParam.sib1Params.srvCellCfgCommSib.ulCfg.rachCfg;
6722 rachCfgDed->present = ReconfigurationWithSync__rach_ConfigDedicated_PR_uplink;
6725 DU_ALLOC(rachCfgDed->choice.uplink, sizeof(RACH_ConfigDedicated_t));
6726 if(!rachCfgDed->choice.uplink)
6728 DU_LOG("\nERROR --> DU APP : Memory allocation failed for RACH uplink configuration in BuildRachConfigDedicated()");
6732 /* CFRA : Contention free Random Access */
6733 DU_ALLOC(rachCfgDed->choice.uplink->cfra, sizeof(CFRA_t));
6734 if(!rachCfgDed->choice.uplink->cfra)
6736 DU_LOG("\nERROR --> DU APP : Memory allocation failed for CFRA in BuildRachConfigDedicated()");
6739 cfra = rachCfgDed->choice.uplink->cfra;
6741 /* CFRA occassions */
6742 DU_ALLOC(cfra->occasions, sizeof(struct CFRA__occasions));
6743 if(!cfra->occasions)
6745 DU_LOG("\nERROR --> DU APP : Memory allocation failed for CFRA occassion in BuildRachConfigDedicated()");
6749 /* CFRA occassions : RACH generic configuration */
6750 cfra->occasions->rach_ConfigGeneric.prach_ConfigurationIndex = duRachCfg.prachCfgIdx;
6751 cfra->occasions->rach_ConfigGeneric.msg1_FDM = duRachCfg.msg1Fdm;
6752 cfra->occasions->rach_ConfigGeneric.msg1_FrequencyStart = duRachCfg.msg1FreqStart;
6753 cfra->occasions->rach_ConfigGeneric.zeroCorrelationZoneConfig = duRachCfg.zeroCorrZoneCfg;
6754 cfra->occasions->rach_ConfigGeneric.preambleReceivedTargetPower = duRachCfg.preambleRcvdTgtPwr;
6755 cfra->occasions->rach_ConfigGeneric.preambleTransMax = duRachCfg.preambleTransMax;
6756 cfra->occasions->rach_ConfigGeneric.powerRampingStep = duRachCfg.pwrRampingStep;
6757 cfra->occasions->rach_ConfigGeneric.ra_ResponseWindow = duRachCfg.raRspWindow;
6759 /* CFRA occassions : SSB per RACH occasion */
6760 DU_ALLOC(cfra->occasions->ssb_perRACH_Occasion, sizeof(long));
6761 if(!cfra->occasions->ssb_perRACH_Occasion)
6763 DU_LOG("\nERROR --> DU APP : Memory allocation failed for SSB per RACH occassion in BuildRachConfigDedicated()");
6766 *(cfra->occasions->ssb_perRACH_Occasion) = convertCFRASsbPerRachOccasionValueToEnum(duCfgParam.macCellCfg.prachCfg.ssbPerRach);
6769 cfra->resources.present = CFRA__resources_PR_ssb;
6771 /* CFRA resource : SSB */
6772 DU_ALLOC(cfra->resources.choice.ssb, sizeof(struct CFRA__resources__ssb));
6773 if(!cfra->resources.choice.ssb)
6775 DU_LOG("\nERROR --> DU APP : Memory allocation failed for CFRA resource - SSB in BuildRachConfigDedicated()");
6778 ssbResource = cfra->resources.choice.ssb;
6780 /* CFRA SSB resource list */
6781 elementCnt = ueCb->cfraResource.numSsb;
6782 ssbResource->ssb_ResourceList.list.count = elementCnt;
6783 ssbResource->ssb_ResourceList.list.size = elementCnt * sizeof(CFRA_SSB_Resource_t *);
6785 DU_ALLOC(ssbResource->ssb_ResourceList.list.array, ssbResource->ssb_ResourceList.list.size);
6786 if(!ssbResource->ssb_ResourceList.list.array)
6788 DU_LOG("\nERROR --> DU APP : Memory allocation failed for SSB resource list in BuildRachConfigDedicated()");
6792 for(listIdx = 0; listIdx < elementCnt; listIdx++)
6794 DU_ALLOC(ssbResource->ssb_ResourceList.list.array[listIdx], sizeof(CFRA_SSB_Resource_t));
6795 if(!ssbResource->ssb_ResourceList.list.array[listIdx])
6797 DU_LOG("\nERROR --> DU APP : Memory allocation failed for SSB resource list element in BuildRachConfigDedicated()");
6800 ssbResource->ssb_ResourceList.list.array[listIdx]->ssb = ueCb->cfraResource.ssbResource[listIdx].ssbIdx;
6801 ssbResource->ssb_ResourceList.list.array[listIdx]->ra_PreambleIndex = ueCb->cfraResource.ssbResource[listIdx].raPreambleIdx;
6807 /*******************************************************************
6809 * @brief Fills reconfiguration with sync in SP cell config
6813 * Function : BuildRecfgWithSync
6815 * Functionality: Fills reconfiguration with sync in SP cell config
6817 * @params[in] DU UE CB
6818 * Pointer to ReconfigurationWithSync_t
6820 * @return ROK - success
6823 * ****************************************************************/
6824 uint8_t BuildRecfgWithSync(DuUeCb *ueCb, ReconfigurationWithSync_t *recfgWithSync)
6826 /* SP Cell Config Common */
6827 DU_ALLOC(recfgWithSync->spCellConfigCommon, sizeof(ServingCellConfigCommon_t));
6828 if(!recfgWithSync->spCellConfigCommon)
6830 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for spCellConfigCommon in BuildRecfgWithSync()");
6834 if((BuildSpCellConfigCommon(recfgWithSync->spCellConfigCommon)) != ROK)
6836 DU_LOG("\nERROR --> DU APP : Failed to build SpCellConfigCommon in BuildRecfgWithSync()");
6840 /* New UE Identity */
6841 recfgWithSync->newUE_Identity = ueCb->crnti;
6844 recfgWithSync->t304 = ReconfigurationWithSync__t304_ms1000;
6846 /* RACH configuration dedicated */
6847 DU_ALLOC(recfgWithSync->rach_ConfigDedicated, sizeof(struct ReconfigurationWithSync__rach_ConfigDedicated));
6848 if(!recfgWithSync->rach_ConfigDedicated)
6850 DU_LOG("\nERROR --> DU APP : Failed to allocate memory for RACH config dedicated in BuildRecfgWithSync()");
6854 if((BuildRachConfigDedicated(ueCb, recfgWithSync->rach_ConfigDedicated)) != ROK)
6856 DU_LOG("\nERROR --> DU APP : Failed to build RACH config dedicated in BuildRecfgWithSync()");
6863 /*******************************************************************
6865 * @brief Builds Spcell config
6869 * Function : BuildSpCellCfg
6871 * Functionality: Builds sp cell config in DuToCuRrcContainer
6873 * @params[in] SpCellConfig_t spCellCfg
6875 * @return ROK - success
6878 * ****************************************************************/
6879 uint8_t BuildSpCellCfg(DuUeCb *ueCb, SpCellConfig_t *spCellCfg)
6881 spCellCfg->servCellIndex = NULLP;
6882 DU_ALLOC(spCellCfg->servCellIndex, sizeof(long));
6883 if(!spCellCfg->servCellIndex)
6885 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
6890 *(spCellCfg->servCellIndex) = SERV_CELL_IDX;
6892 *(spCellCfg->servCellIndex) = ueCb->macUeCfg.spCellCfg.servCellIdx;
6894 spCellCfg->reconfigurationWithSync = NULLP;
6895 if(ueCb && (ueCb->ueState == UE_HANDIN_IN_PROGRESS))
6897 DU_ALLOC(spCellCfg->reconfigurationWithSync, sizeof(ReconfigurationWithSync_t));
6898 if(!spCellCfg->reconfigurationWithSync)
6900 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
6904 if((BuildRecfgWithSync(ueCb, spCellCfg->reconfigurationWithSync)) != ROK)
6906 DU_LOG("\nERROR --> F1AP : Building of reconfiguration with sync failed at BuildSpCellCfg");
6911 spCellCfg->rlf_TimersAndConstants = NULLP;
6912 spCellCfg->rlmInSyncOutOfSyncThreshold = NULLP;
6914 DU_ALLOC(spCellCfg->rlmInSyncOutOfSyncThreshold, sizeof(long));
6915 if(!spCellCfg->rlmInSyncOutOfSyncThreshold)
6917 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
6920 *(spCellCfg->rlmInSyncOutOfSyncThreshold) = RLM_SYNC_OUT_SYNC_THRESHOLD;
6922 spCellCfg->spCellConfigDedicated = NULLP;
6923 DU_ALLOC(spCellCfg->spCellConfigDedicated, sizeof(ServingCellConfig_t));
6924 if(!spCellCfg->spCellConfigDedicated)
6926 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildSpCellCfg");
6929 if(BuildSpCellCfgDed(ueCb, spCellCfg->spCellConfigDedicated) != ROK)
6931 DU_LOG("\nERROR --> F1AP : BuildSpCellCfgDed failed");
6938 /*******************************************************************
6940 * @brief Builds Phy cell group config
6944 * Function : BuildPhyCellGrpCfg
6946 * Functionality: Builds Phy cell group config in DuToCuRrcContainer
6948 * @params[in] PhysicalCellGroupConfig_t *phyCellGrpCfg
6950 * @return ROK - success
6953 * ****************************************************************/
6954 uint8_t BuildPhyCellGrpCfg(DuUeCb *ueCb, PhysicalCellGroupConfig_t *phyCellGrpCfg)
6956 phyCellGrpCfg->harq_ACK_SpatialBundlingPUCCH = NULLP;
6957 phyCellGrpCfg->harq_ACK_SpatialBundlingPUSCH = NULLP;
6959 phyCellGrpCfg->p_NR_FR1 = NULLP;
6960 DU_ALLOC(phyCellGrpCfg->p_NR_FR1, sizeof(long));
6961 if(!phyCellGrpCfg->p_NR_FR1)
6963 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildPhyCellGrpCfg");
6969 *(phyCellGrpCfg->p_NR_FR1) = P_NR_FR1;
6970 phyCellGrpCfg->pdsch_HARQ_ACK_Codebook = PDSCH_HARQ_ACK_CODEBOOK;
6974 *(phyCellGrpCfg->p_NR_FR1) = ueCb->macUeCfg.phyCellGrpCfg.pNrFr1;
6975 phyCellGrpCfg->pdsch_HARQ_ACK_Codebook = ueCb->macUeCfg.phyCellGrpCfg.pdschHarqAckCodebook;
6978 phyCellGrpCfg->tpc_SRS_RNTI = NULLP;
6979 phyCellGrpCfg->tpc_PUCCH_RNTI = NULLP;
6980 phyCellGrpCfg->tpc_PUSCH_RNTI = NULLP;
6981 phyCellGrpCfg->sp_CSI_RNTI = NULLP;
6982 phyCellGrpCfg->cs_RNTI = NULLP;
6983 phyCellGrpCfg->ext1 = NULLP;
6984 phyCellGrpCfg->ext2 = NULLP;
6989 /*******************************************************************
6991 * @brief fill long cycle offset value of drx
6995 * Function : fillLongCycleOffsetValFromDuCb
6997 * Functionality: fill long cycle offset value of drx
6999 * @params[in] DrxLongCycleStartOffset drxLongCycleStartOffset,
7000 * struct DRX_ConfigRrc__drx_LongCycleStartOffset drx_LongCycleStartOffset
7002 * @return ROK - success
7005 * ****************************************************************/
7006 void fillLongCycleOffsetValFromDuCb(DrxLongCycleStartOffset drxLongCycleStartOffset,\
7007 struct DRX_ConfigRrc__drx_LongCycleStartOffset *drx_LongCycleStartOffset)
7010 drx_LongCycleStartOffset->present = convertLongDrxCycleLengthValueToEnum(drxLongCycleStartOffset.drxLongCycleStartOffsetChoice);
7011 switch(drx_LongCycleStartOffset->present)
7013 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms10:
7015 drx_LongCycleStartOffset->choice.ms10 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7018 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms20:
7020 drx_LongCycleStartOffset->choice.ms20 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7023 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms32:
7025 drx_LongCycleStartOffset->choice.ms32 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7028 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms40:
7030 drx_LongCycleStartOffset->choice.ms40 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7033 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms60:
7035 drx_LongCycleStartOffset->choice.ms60 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7038 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms64:
7040 drx_LongCycleStartOffset->choice.ms64 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7043 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms70:
7045 drx_LongCycleStartOffset->choice.ms70 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7048 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms80:
7050 drx_LongCycleStartOffset->choice.ms80 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7053 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms128:
7055 drx_LongCycleStartOffset->choice.ms128 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7058 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms160:
7060 drx_LongCycleStartOffset->choice.ms160 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7063 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms256:
7065 drx_LongCycleStartOffset->choice.ms256 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7068 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms320:
7070 drx_LongCycleStartOffset->choice.ms320 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7073 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms512:
7075 drx_LongCycleStartOffset->choice.ms512 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7078 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms640:
7080 drx_LongCycleStartOffset->choice.ms640 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7083 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms1024:
7085 drx_LongCycleStartOffset->choice.ms1024 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7088 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms1280:
7090 drx_LongCycleStartOffset->choice.ms1280 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7093 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms2048:
7095 drx_LongCycleStartOffset->choice.ms2048 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7098 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms2560:
7100 drx_LongCycleStartOffset->choice.ms2560 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7103 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms5120:
7105 drx_LongCycleStartOffset->choice.ms5120 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7108 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms10240:
7110 drx_LongCycleStartOffset->choice.ms10240 = drxLongCycleStartOffset.drxLongCycleStartOffsetVal;
7117 /*******************************************************************
7119 * @brief Builds drx config IE
7123 * Function : BuildDrxConfigRrc
7125 * Functionality: Build drx config in MacCellGrpCfg
7127 * @params[in] struct MAC_CellGroupConfig__drx_ConfigRrc
7129 * @return ROK - success
7132 * ****************************************************************/
7133 uint8_t BuildDrxConfigRrc(DuUeCb *ueCb, struct MAC_CellGroupConfig__drx_ConfigRrc *drxCfg)
7135 drxCfg->present = MAC_CellGroupConfig__drx_ConfigRrc_PR_setup;
7136 DU_ALLOC(drxCfg->choice.setup, sizeof(struct DRX_ConfigRrc));
7137 if(!drxCfg->choice.setup)
7139 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDrxConfigRrc");
7142 if(ueCb->macUeCfg.macCellGrpCfg.drxCfg.drxOnDurationTimer.onDurationTimerValInMs)
7144 drxCfg->choice.setup->drx_onDurationTimer.present = DRX_ConfigRrc__drx_onDurationTimer_PR_milliSeconds;
7145 drxCfg->choice.setup->drx_onDurationTimer.choice.milliSeconds = convertOnDurationTimerMilliSecondsValueToEnum(ueCb->macUeCfg.\
7146 macCellGrpCfg.drxCfg.drxOnDurationTimer.onDurationtimerValue.milliSeconds);
7150 drxCfg->choice.setup->drx_onDurationTimer.present = DRX_ConfigRrc__drx_onDurationTimer_PR_subMilliSeconds;
7151 drxCfg->choice.setup->drx_onDurationTimer.choice.subMilliSeconds = ueCb->macUeCfg.macCellGrpCfg.drxCfg.\
7152 drxOnDurationTimer.onDurationtimerValue.subMilliSeconds;
7154 drxCfg->choice.setup->drx_InactivityTimer = convertDrxInactivityTimerValueToEnum(ueCb->macUeCfg.macCellGrpCfg.drxCfg.drxInactivityTimer);
7155 drxCfg->choice.setup->drx_HARQ_RTT_TimerDL = ueCb->macUeCfg.macCellGrpCfg.drxCfg.drxHarqRttTimerDl;
7156 drxCfg->choice.setup->drx_HARQ_RTT_TimerUL = ueCb->macUeCfg.macCellGrpCfg.drxCfg.drxHarqRttTimerUl;
7157 drxCfg->choice.setup->drx_RetransmissionTimerDL = convertDrxRetransmissionTimerDlValueToEnum(ueCb->macUeCfg.macCellGrpCfg.drxCfg.\
7158 drxRetransmissionTimerDl);
7159 drxCfg->choice.setup->drx_RetransmissionTimerUL = convertDrxRetransmissionTimerUlValueToEnum(ueCb->macUeCfg.macCellGrpCfg.drxCfg.\
7160 drxRetransmissionTimerUl);
7161 drxCfg->choice.setup->drx_SlotOffset = ueCb->macUeCfg.macCellGrpCfg.drxCfg.drxSlotOffset;
7162 fillLongCycleOffsetValFromDuCb(ueCb->macUeCfg.macCellGrpCfg.drxCfg.drxLongCycleStartOffset, &drxCfg->choice.setup->drx_LongCycleStartOffset);
7164 if(ueCb->macUeCfg.macCellGrpCfg.drxCfg.shortDrxPres)
7166 DU_ALLOC(drxCfg->choice.setup->shortDRX, sizeof(struct DRX_ConfigRrc__shortDRX));
7167 if(drxCfg->choice.setup->shortDRX)
7169 drxCfg->choice.setup->shortDRX->drx_ShortCycle = convertShortDrxCycleLengthValueToEnum(ueCb->macUeCfg.macCellGrpCfg.drxCfg.\
7170 shortDrx.drxShortCycle);
7171 drxCfg->choice.setup->shortDRX->drx_ShortCycleTimer = ueCb->macUeCfg.macCellGrpCfg.drxCfg.shortDrx.drxShortCycleTimer;
7175 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDrxConfigRrc");
7182 /*******************************************************************
7184 * @brief Builds Mac cell group config
7188 * Function : BuildMacCellGrpCfg
7190 * Functionality: Builds Mac cell group config in DuToCuRrcContainer
7192 * @params[in] MAC_CellGroupConfig_t *macCellGrpCfg
7194 * @return ROK - success
7197 * ****************************************************************/
7198 uint8_t BuildMacCellGrpCfg(DuUeCb *ueCb, MAC_CellGroupConfig_t *macCellGrpCfg)
7200 macCellGrpCfg->drx_ConfigRrc = NULLP;
7204 DU_ALLOC(macCellGrpCfg->drx_ConfigRrc, sizeof(struct MAC_CellGroupConfig__drx_ConfigRrc));
7205 if(!macCellGrpCfg->drx_ConfigRrc)
7207 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
7210 if(BuildDrxConfigRrc(ueCb, macCellGrpCfg->drx_ConfigRrc) != ROK)
7212 DU_LOG("\nERROR --> F1AP : failed to build drx config");
7217 macCellGrpCfg->schedulingRequestConfig = NULLP;
7218 DU_ALLOC(macCellGrpCfg->schedulingRequestConfig, sizeof(struct SchedulingRequestConfig));
7219 if(!macCellGrpCfg->schedulingRequestConfig)
7221 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
7225 if(BuildSchedulingReqConfig(ueCb, macCellGrpCfg->schedulingRequestConfig) != ROK)
7227 DU_LOG("\nERROR --> F1AP : BuildSchedulingReqConfig failed");
7231 macCellGrpCfg->bsr_Config = NULLP;
7232 DU_ALLOC(macCellGrpCfg->bsr_Config, sizeof(struct BSR_Config));
7233 if(!macCellGrpCfg->bsr_Config)
7235 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
7239 if(BuildBsrConfig(ueCb, macCellGrpCfg->bsr_Config) != ROK)
7241 DU_LOG("\nERROR --> F1AP : BuildBsrConfig failed");
7245 macCellGrpCfg->tag_Config = NULLP;
7246 DU_ALLOC(macCellGrpCfg->tag_Config, sizeof(struct TAG_Config));
7247 if(!macCellGrpCfg->tag_Config)
7249 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
7253 if(BuildTagConfig(ueCb, macCellGrpCfg->tag_Config) != ROK)
7255 DU_LOG("\nERROR --> F1AP : BuildTagConfig failed");
7259 macCellGrpCfg->phr_Config = NULLP;
7260 DU_ALLOC(macCellGrpCfg->phr_Config, sizeof(struct MAC_CellGroupConfig__phr_Config));
7261 if(!macCellGrpCfg->phr_Config)
7263 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildMacCellGrpCfg");
7267 if(BuildPhrConfig(ueCb, macCellGrpCfg->phr_Config) != ROK)
7269 DU_LOG("\nERROR --> F1AP : BuildPhrConfig failed");
7273 macCellGrpCfg->skipUplinkTxDynamic = false;
7274 macCellGrpCfg->ext1 = NULLP;
7278 /*******************************************************************
7280 * @brief Frees memeory allocated for SearchSpcToAddModList
7284 * Function : FreeSearchSpcToAddModList
7286 * Functionality: Deallocating memory of SearchSpcToAddModList
7288 * @params[in] struct PDCCH_Config__searchSpacesToAddModList *searchSpcList
7292 4221 * ****************************************************************/
7293 void FreeSearchSpcToAddModList(struct PDCCH_Config__searchSpacesToAddModList *searchSpcList)
7297 struct SearchSpace *searchSpc=NULLP;
7299 if(searchSpcList->list.array)
7301 if(searchSpcList->list.array[idx2])
7303 searchSpc = searchSpcList->list.array[idx2];
7304 if(searchSpc->controlResourceSetId)
7306 if(searchSpc->monitoringSlotPeriodicityAndOffset)
7308 if(searchSpc->monitoringSymbolsWithinSlot)
7310 if(searchSpc->monitoringSymbolsWithinSlot->buf)
7312 if(searchSpc->nrofCandidates)
7314 if(searchSpc->searchSpaceType)
7316 DU_FREE(searchSpc->searchSpaceType->choice.ue_Specific,\
7317 sizeof(struct SearchSpace__searchSpaceType__ue_Specific));
7318 DU_FREE(searchSpc->searchSpaceType, sizeof(struct
7319 SearchSpace__searchSpaceType));
7321 DU_FREE(searchSpc->nrofCandidates,
7322 sizeof(struct SearchSpace__nrofCandidates));
7324 DU_FREE(searchSpc->monitoringSymbolsWithinSlot->buf, \
7325 searchSpc->monitoringSymbolsWithinSlot->size);
7327 DU_FREE(searchSpc->monitoringSymbolsWithinSlot,
7328 sizeof(BIT_STRING_t));
7330 DU_FREE(searchSpc->monitoringSlotPeriodicityAndOffset, \
7331 sizeof(struct SearchSpace__monitoringSlotPeriodicityAndOffset));
7333 DU_FREE(searchSpc->controlResourceSetId,
7334 sizeof(ControlResourceSetId_t));
7337 for(idx1 = 0; idx1 < searchSpcList->list.count; idx1++)
7339 DU_FREE(searchSpcList->list.array[idx1],
7340 sizeof(struct SearchSpace));
7342 DU_FREE(searchSpcList->list.array,searchSpcList->list.size);
7345 /*******************************************************************
7347 * @brief Frees memory allocated for PdschTimeDomAllocList
7351 * Function : FreePdschTimeDomAllocList
7353 * Functionality: Deallocating memory of PdschTimeDomAllocList
7355 * @params[in] struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
7359 * ****************************************************************/
7360 void FreePdschTimeDomAllocList( struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList)
7364 if(timeDomAllocList->choice.setup)
7366 if(timeDomAllocList->choice.setup->list.array)
7368 for(idx1 = 0; idx1 <timeDomAllocList->choice.setup->list.count ; idx1++)
7370 DU_FREE(timeDomAllocList->choice.setup->list.array[idx1]->k0, sizeof(long));
7371 DU_FREE(timeDomAllocList->choice.setup->list.array[idx1],
7372 sizeof(struct PDSCH_TimeDomainResourceAllocation));
7374 DU_FREE(timeDomAllocList->choice.setup->list.array, \
7375 timeDomAllocList->choice.setup->list.size);
7377 DU_FREE(timeDomAllocList->choice.setup,\
7378 sizeof(struct PDSCH_TimeDomainResourceAllocationList));
7381 /*******************************************************************
7383 * @brief Frees memory allocated for PuschTimeDomAllocList
7387 * Function : FreePuschTimeDomAllocList
7389 * Functionality: Deallocating memory of PuschTimeDomAllocList
7391 * @params[in] PUSCH_Config_t *puschCfg
7395 * ****************************************************************/
7396 void FreePuschTimeDomAllocList(PUSCH_Config_t *puschCfg)
7398 uint8_t rsrcListIdx=0;
7399 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList_t=NULLP;
7401 if(puschCfg->pusch_TimeDomainAllocationList)
7403 timeDomAllocList_t=puschCfg->pusch_TimeDomainAllocationList;
7404 if(timeDomAllocList_t->choice.setup)
7406 if(timeDomAllocList_t->choice.setup->list.array)
7408 for(rsrcListIdx = 0; rsrcListIdx<timeDomAllocList_t->choice.setup->list.count; rsrcListIdx++)
7410 DU_FREE(timeDomAllocList_t->choice.setup->list.array[rsrcListIdx]->k2, sizeof(long));
7411 DU_FREE(timeDomAllocList_t->choice.setup->list.array[rsrcListIdx],\
7412 sizeof(PUSCH_TimeDomainResourceAllocation_t));
7414 DU_FREE(timeDomAllocList_t->choice.setup->list.array, \
7415 timeDomAllocList_t->choice.setup->list.size);
7417 DU_FREE(timeDomAllocList_t->choice.setup, \
7418 sizeof(struct PUSCH_TimeDomainResourceAllocationList));
7420 DU_FREE(puschCfg->transformPrecoder, sizeof(long));
7421 DU_FREE(puschCfg->pusch_TimeDomainAllocationList, \
7422 sizeof(struct PUSCH_Config__pusch_TimeDomainAllocationList));
7427 /*******************************************************************
7429 * @brief Frees memory allocated for Dedicated PUCCH config
7433 * Function : FreeBWPUlDedPucchCfg
7435 * Functionality: Deallocating memory of Dedicated PUCCH cfg
7437 * @params[in] BWP_UplinkDedicated__pucch_Config *ulBwpPucchCfg
7441 * ****************************************************************/
7442 void FreeBWPUlDedPucchCfg(struct BWP_UplinkDedicated__pucch_Config *ulBwpPucchCfg)
7444 uint8_t k1Idx, rsrcIdx, rsrcSetIdx;
7445 PUCCH_Config_t *pucchCfg = NULLP;
7446 PUCCH_ResourceSet_t *rsrcSet = NULLP;
7447 PUCCH_Resource_t *rsrc = NULLP;
7451 if(ulBwpPucchCfg->choice.setup)
7453 pucchCfg = ulBwpPucchCfg->choice.setup;
7455 //Free resource set list
7456 if(pucchCfg->resourceSetToAddModList)
7458 if(pucchCfg->resourceSetToAddModList->list.array)
7460 for(rsrcSetIdx=0; rsrcSetIdx < pucchCfg->resourceSetToAddModList->list.count; rsrcSetIdx++)
7462 rsrcSet = pucchCfg->resourceSetToAddModList->list.array[rsrcSetIdx];
7463 if(rsrcSet->resourceList.list.array)
7465 for(rsrcIdx=0; rsrcIdx < rsrcSet->resourceList.list.count; rsrcIdx++)
7467 DU_FREE(rsrcSet->resourceList.list.array[rsrcIdx], sizeof(PUCCH_ResourceId_t));
7469 DU_FREE(rsrcSet->resourceList.list.array, rsrcSet->resourceList.list.size);
7471 DU_FREE(pucchCfg->resourceSetToAddModList->list.array[rsrcSetIdx], sizeof(PUCCH_ResourceSet_t));
7473 DU_FREE(pucchCfg->resourceSetToAddModList->list.array, pucchCfg->resourceSetToAddModList->list.size);
7475 DU_FREE(pucchCfg->resourceSetToAddModList, sizeof(struct PUCCH_Config__resourceSetToAddModList));
7478 //Free resource list
7479 if(pucchCfg->resourceToAddModList)
7481 if(pucchCfg->resourceToAddModList->list.array)
7483 for(rsrcIdx=0; rsrcIdx < pucchCfg->resourceToAddModList->list.count; rsrcIdx++)
7485 rsrc = pucchCfg->resourceToAddModList->list.array[rsrcIdx];
7486 DU_FREE(rsrc->format.choice.format1, sizeof(PUCCH_format1_t));
7487 DU_FREE(pucchCfg->resourceToAddModList->list.array[rsrcIdx], sizeof(PUCCH_Resource_t));
7489 DU_FREE(pucchCfg->resourceToAddModList->list.array, pucchCfg->resourceToAddModList->list.size);
7491 DU_FREE(pucchCfg->resourceToAddModList, sizeof(struct PUCCH_Config__resourceToAddModList));
7495 if(pucchCfg->format1)
7497 if(pucchCfg->format1->choice.setup)
7499 DU_FREE(pucchCfg->format1->choice.setup->nrofSlots, sizeof(long));
7500 DU_FREE(pucchCfg->format1->choice.setup, sizeof(PUCCH_FormatConfig_t));
7502 DU_FREE(pucchCfg->format1, sizeof(struct PUCCH_Config__format1));
7506 if(pucchCfg->dl_DataToUL_ACK)
7508 if(pucchCfg->dl_DataToUL_ACK->list.array)
7510 for(k1Idx = 0; k1Idx < pucchCfg->dl_DataToUL_ACK->list.count; k1Idx++)
7512 DU_FREE(pucchCfg->dl_DataToUL_ACK->list.array[k1Idx], sizeof(long));
7514 DU_FREE(pucchCfg->dl_DataToUL_ACK->list.array, pucchCfg->dl_DataToUL_ACK->list.size);
7516 DU_FREE(pucchCfg->dl_DataToUL_ACK, sizeof(struct PUCCH_Config__dl_DataToUL_ACK));
7519 DU_FREE(ulBwpPucchCfg->choice.setup, sizeof(PUCCH_Config_t));
7521 DU_FREE(ulBwpPucchCfg, sizeof(struct BWP_UplinkDedicated__pucch_Config));
7525 /*******************************************************************
7527 * @brief Frees memory allocated for InitialUlBWP
7531 * Function : FreeInitialUlBWP
7533 * Functionality: Deallocating memory of InitialUlBWP
7535 * @params[in] BWP_UplinkDedicated_t *ulBwp
7539 * ****************************************************************/
7540 void FreeInitialUlBWP(BWP_UplinkDedicated_t *ulBwp)
7542 uint8_t rSetIdx, rsrcIdx;
7543 SRS_Config_t *srsCfg = NULLP;
7544 PUSCH_Config_t *puschCfg = NULLP;
7545 struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg = NULLP;
7546 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList = NULLP;
7547 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList = NULLP;
7548 struct SRS_Config__srs_ResourceToAddModList *resourceList = NULLP;
7550 FreeBWPUlDedPucchCfg(ulBwp->pucch_Config);
7552 if(ulBwp->pusch_Config)
7554 if(ulBwp->pusch_Config->choice.setup)
7556 puschCfg=ulBwp->pusch_Config->choice.setup;
7557 if(puschCfg->dataScramblingIdentityPUSCH)
7559 if(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
7561 FreePuschTimeDomAllocList(puschCfg);
7562 dmrsUlCfg=puschCfg->dmrs_UplinkForPUSCH_MappingTypeA;
7563 if(dmrsUlCfg->choice.setup)
7565 if(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
7567 if(dmrsUlCfg->choice.setup->transformPrecodingDisabled)
7569 DU_FREE(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0,\
7571 DU_FREE(dmrsUlCfg->choice.setup->transformPrecodingDisabled,
7572 sizeof(struct DMRS_UplinkConfig__transformPrecodingDisabled));
7574 DU_FREE(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition,
7577 DU_FREE(dmrsUlCfg->choice.setup,sizeof(DMRS_UplinkConfig_t));
7579 DU_FREE(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA, \
7580 sizeof(struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA));
7582 DU_FREE(puschCfg->dataScramblingIdentityPUSCH, sizeof(long));
7584 DU_FREE(ulBwp->pusch_Config->choice.setup, sizeof(PUSCH_Config_t));
7586 DU_FREE(ulBwp->pusch_Config, sizeof(struct BWP_UplinkDedicated__pusch_Config));
7588 /* Free SRS-Config */
7589 if(ulBwp->srs_Config)
7591 if(ulBwp->srs_Config->choice.setup)
7593 srsCfg = ulBwp->srs_Config->choice.setup;
7595 /* Free Resource Set to add/mod list */
7596 if(srsCfg->srs_ResourceSetToAddModList)
7598 rsrcSetList = srsCfg->srs_ResourceSetToAddModList;
7599 if(rsrcSetList->list.array)
7603 /* Free SRS resource Id list in this SRS resource set */
7604 if(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
7606 rsrcIdList = rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
7608 if(rsrcIdList->list.array)
7610 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count; rsrcIdx++)
7612 DU_FREE(rsrcIdList->list.array[rsrcIdx], sizeof(SRS_ResourceId_t));
7614 DU_FREE(rsrcIdList->list.array, rsrcIdList->list.size);
7616 DU_FREE(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList,\
7617 sizeof(struct SRS_ResourceSet__srs_ResourceIdList));
7620 /* Free resource type info for this SRS resource set */
7621 DU_FREE(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic, \
7622 sizeof(struct SRS_ResourceSet__resourceType__aperiodic));
7624 /* Free memory for each resource set */
7625 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
7627 DU_FREE(rsrcSetList->list.array[rSetIdx], sizeof(SRS_ResourceSet_t));
7629 DU_FREE(rsrcSetList->list.array, rsrcSetList->list.size);
7631 DU_FREE(srsCfg->srs_ResourceSetToAddModList, \
7632 sizeof(struct SRS_Config__srs_ResourceSetToAddModList));
7635 /* Free resource to add/modd list */
7636 if(srsCfg->srs_ResourceToAddModList)
7638 resourceList = srsCfg->srs_ResourceToAddModList;
7639 if(resourceList->list.array)
7642 DU_FREE(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2,\
7643 sizeof(struct SRS_Resource__transmissionComb__n2));
7644 DU_FREE(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic,\
7645 sizeof(struct SRS_Resource__resourceType__aperiodic));
7647 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
7649 DU_FREE(resourceList->list.array[rsrcIdx], sizeof(SRS_Resource_t));
7651 DU_FREE(resourceList->list.array, resourceList->list.size);
7653 DU_FREE(srsCfg->srs_ResourceToAddModList, \
7654 sizeof(struct SRS_Config__srs_ResourceToAddModList));
7657 DU_FREE(ulBwp->srs_Config->choice.setup, sizeof(SRS_Config_t));
7659 DU_FREE(ulBwp->srs_Config, sizeof(struct BWP_UplinkDedicated__srs_Config));
7663 /*******************************************************************
7665 * @brief Frees memory allocated for initialUplinkBWP
7669 * Function : FreeinitialUplinkBWP
7671 * Functionality: Deallocating memory of initialUplinkBWP
7673 * @params[in] UplinkConfig_t *ulCfg
7678 * ****************************************************************/
7679 void FreeinitialUplinkBWP(UplinkConfig_t *ulCfg)
7681 BWP_UplinkDedicated_t *ulBwp=NULLP;
7682 struct UplinkConfig__pusch_ServingCellConfig *puschCfg=NULLP;
7684 if(ulCfg->initialUplinkBWP)
7686 ulBwp=ulCfg->initialUplinkBWP;
7687 if(ulCfg->firstActiveUplinkBWP_Id)
7689 if(ulCfg->pusch_ServingCellConfig)
7691 puschCfg=ulCfg->pusch_ServingCellConfig;
7692 if(puschCfg->choice.setup)
7694 if(puschCfg->choice.setup->ext1)
7696 DU_FREE(puschCfg->choice.setup->ext1->\
7697 processingType2Enabled,sizeof(BOOLEAN_t));
7698 DU_FREE(puschCfg->choice.setup->ext1->\
7699 maxMIMO_Layers,sizeof(long));
7700 DU_FREE(puschCfg->choice.setup->ext1, \
7701 sizeof(struct PUSCH_ServingCellConfig__ext1));
7703 DU_FREE(puschCfg->choice.setup, sizeof(struct PUSCH_ServingCellConfig));
7705 DU_FREE(ulCfg->pusch_ServingCellConfig, sizeof(struct UplinkConfig__pusch_ServingCellConfig));
7707 DU_FREE(ulCfg->firstActiveUplinkBWP_Id, sizeof(BWP_Id_t));
7709 FreeInitialUlBWP(ulBwp);
7710 DU_FREE(ulCfg->initialUplinkBWP, sizeof(BWP_UplinkDedicated_t));
7713 /*******************************************************************
7715 * @brief Frees emmory allocated for BWPDlDedPdschCfg
7719 * Function : FreeBWPDlDedPdschCfg
7721 * Functionality: Deallocating memory of BWPDlDedPdschCfg
7723 * @params[in] BWP_DownlinkDedicated_t *dlBwp
7728 * ****************************************************************/
7729 void FreeBWPDlDedPdschCfg(BWP_DownlinkDedicated_t *dlBwp)
7731 struct PDSCH_Config *pdschCfg=NULLP;
7732 struct PDSCH_Config__prb_BundlingType *prbBndlType=NULLP;
7733 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList=NULLP;
7734 struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg=NULLP;
7736 if(dlBwp->pdsch_Config->choice.setup)
7738 pdschCfg=dlBwp->pdsch_Config->choice.setup;
7739 if(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
7741 if(pdschCfg->pdsch_TimeDomainAllocationList)
7743 timeDomAllocList=pdschCfg->pdsch_TimeDomainAllocationList;
7744 if(pdschCfg->maxNrofCodeWordsScheduledByDCI)
7746 prbBndlType=&pdschCfg->prb_BundlingType;
7747 DU_FREE(prbBndlType->choice.staticBundling,\
7748 sizeof(struct PDSCH_Config__prb_BundlingType__staticBundling));
7749 DU_FREE(pdschCfg->maxNrofCodeWordsScheduledByDCI, sizeof(long));
7751 FreePdschTimeDomAllocList(timeDomAllocList);
7752 DU_FREE(pdschCfg->pdsch_TimeDomainAllocationList, \
7753 sizeof(struct PDSCH_Config__pdsch_TimeDomainAllocationList));
7755 dmrsDlCfg=pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA;
7756 if(dmrsDlCfg->choice.setup)
7758 DU_FREE(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition,
7760 DU_FREE(dmrsDlCfg->choice.setup, sizeof(struct DMRS_DownlinkConfig));
7762 DU_FREE(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA, \
7763 sizeof(struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA));
7765 DU_FREE(dlBwp->pdsch_Config->choice.setup, sizeof(struct PDSCH_Config));
7768 /*******************************************************************
7770 * @brief Frees emmory allocated for BWPDlDedPdcchCfg
7774 * Function : FreeBWPDlDedPdcchCfg
7776 * Functionality: Deallocating memory of BWPDlDedPdcchCfg
7778 * @params[in] BWP_DownlinkDedicated_t *dlBwp
7783 * ****************************************************************/
7784 void FreeBWPDlDedPdcchCfg(BWP_DownlinkDedicated_t *dlBwp)
7788 struct PDCCH_Config *pdcchCfg=NULLP;
7789 struct ControlResourceSet *controlRSet=NULLP;
7790 struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList=NULLP;
7792 if(dlBwp->pdcch_Config->choice.setup)
7794 pdcchCfg=dlBwp->pdcch_Config->choice.setup;
7795 if(pdcchCfg->controlResourceSetToAddModList)
7797 controlRSetList = pdcchCfg->controlResourceSetToAddModList;
7798 if(controlRSetList->list.array)
7800 controlRSet = controlRSetList->list.array[idx2];
7803 if(controlRSet->frequencyDomainResources.buf)
7805 if(controlRSet->pdcch_DMRS_ScramblingID)
7807 if(pdcchCfg->searchSpacesToAddModList)
7809 FreeSearchSpcToAddModList(pdcchCfg->searchSpacesToAddModList);
7810 DU_FREE(pdcchCfg->searchSpacesToAddModList, \
7811 sizeof(struct PDCCH_Config__searchSpacesToAddModList));
7813 DU_FREE(controlRSet->pdcch_DMRS_ScramblingID, sizeof(long));
7815 DU_FREE(controlRSet->frequencyDomainResources.buf, \
7816 controlRSet->frequencyDomainResources.size);
7819 for(idx1 = 0; idx1 <controlRSetList->list.count; idx1++)
7821 DU_FREE(controlRSetList->list.array[idx1], sizeof(struct ControlResourceSet));
7823 DU_FREE(controlRSetList->list.array, controlRSetList->list.size);
7825 DU_FREE(pdcchCfg->controlResourceSetToAddModList, \
7826 sizeof(struct PDCCH_Config__controlResourceSetToAddModList));
7828 DU_FREE(dlBwp->pdcch_Config->choice.setup, sizeof(struct PDCCH_Config));
7832 /*******************************************************************
7834 * @brief Free SCS specific carrier list in DL frequency info
7838 * Function : FreeScsSpecificCarrierListDl
7840 * Functionality: Free SCS specific carrier list in DL frequency info
7842 * @params[in] Pointer to struct FrequencyInfoDL__scs_SpecificCarrierList
7846 * ****************************************************************/
7847 void FreeScsSpecificCarrierListDl(struct FrequencyInfoDL__scs_SpecificCarrierList *scsCarrierList)
7849 uint8_t listIdx = 0;
7851 if(!scsCarrierList->list.array)
7853 for(listIdx = 0; listIdx < scsCarrierList->list.count; listIdx++)
7855 DU_FREE(scsCarrierList->list.array[listIdx], sizeof(SCS_SpecificCarrier_t));
7857 DU_FREE(scsCarrierList->list.array, scsCarrierList->list.size);
7861 /*******************************************************************
7863 * @brief Free DL frequency info in DL config common
7867 * Function : FreeFreqInfoDl
7869 * Functionality: Free DL frequency info in DL config common
7871 * @params[in] Pointer to DownlinkConfigCommon_t
7875 * ****************************************************************/
7876 void FreeFreqInfoDl(FrequencyInfoDL_t *frequencyInfoDL)
7878 uint8_t freqBandIdx = 0;
7880 /* SSB Absolute Frequency */
7881 DU_FREE(frequencyInfoDL->absoluteFrequencySSB, sizeof(ARFCN_ValueNR_t));
7883 /* NR Multi Frequency Band List */
7884 if(frequencyInfoDL->frequencyBandList.list.array)
7886 for(freqBandIdx = 0; freqBandIdx < frequencyInfoDL->frequencyBandList.list.count; freqBandIdx++)
7888 DU_FREE(frequencyInfoDL->frequencyBandList.list.array[freqBandIdx], sizeof(FreqBandIndicatorNR_t));
7890 DU_FREE(frequencyInfoDL->frequencyBandList.list.array, frequencyInfoDL->frequencyBandList.list.size);
7893 /* Subcarrier Spacing specifc carrier List */
7894 FreeScsSpecificCarrierListDl(&frequencyInfoDL->scs_SpecificCarrierList);
7897 /*******************************************************************
7899 * @brief Free DL config common in Serving cell config common
7903 * Function : FreeDlConfigCommon
7905 * Functionality: Free DL config common in Serving cell config common
7907 * @params[in] Pointer to DownlinkConfigCommon_t
7911 * ****************************************************************/
7912 void FreeDlConfigCommon(DownlinkConfigCommon_t *dlCfgCommon)
7914 /* DL Frequency Info */
7915 if(dlCfgCommon->frequencyInfoDL)
7917 FreeFreqInfoDl(dlCfgCommon->frequencyInfoDL);
7918 DU_FREE(dlCfgCommon->frequencyInfoDL, sizeof(FrequencyInfoDL_t));
7921 /* DL BWP config common */
7922 if(dlCfgCommon->initialDownlinkBWP)
7924 FreeBwpDlCommon(dlCfgCommon->initialDownlinkBWP);
7925 DU_FREE(dlCfgCommon->initialDownlinkBWP, sizeof(BWP_DownlinkCommon_t));
7929 /*******************************************************************
7931 * @brief Free SCS specific carrier list in UL frequency Info
7935 * Function : FreeScsSpecificCarrierListUl
7937 * Functionality: Free SCS specific carrier list in UL frequency Info
7939 * @params[in] Pointer to struct FrequencyInfoUL__scs_SpecificCarrierList
7943 * ****************************************************************/
7944 void FreeScsSpecificCarrierListUl(struct FrequencyInfoUL__scs_SpecificCarrierList *scsCarrierList)
7946 uint8_t listIdx = 0;
7948 if(scsCarrierList->list.array)
7950 for(listIdx = 0; listIdx < scsCarrierList->list.count; listIdx++)
7952 DU_FREE(scsCarrierList->list.array[listIdx], sizeof(SCS_SpecificCarrier_t));
7954 DU_FREE(scsCarrierList->list.array, scsCarrierList->list.size);
7958 /*******************************************************************
7960 * @brief Free frequency info in UL config common
7964 * Function : FreeFreqInfoUl
7966 * Functionality: Free frequency info in UL config common
7968 * @params[in] Pointer to FrequencyInfoUL_t
7972 * ****************************************************************/
7973 void FreeFreqInfoUl(FrequencyInfoUL_t *frequencyInfoUL)
7977 /* NR Multi Frequency Band List */
7978 if(!frequencyInfoUL->frequencyBandList)
7980 if(frequencyInfoUL->frequencyBandList->list.array)
7982 for(listIdx = 0; listIdx < frequencyInfoUL->frequencyBandList->list.count; listIdx++)
7984 DU_FREE(frequencyInfoUL->frequencyBandList->list.array[listIdx], sizeof(FreqBandIndicatorNR_t));
7986 DU_FREE(frequencyInfoUL->frequencyBandList->list.array, frequencyInfoUL->frequencyBandList->list.size);
7988 DU_FREE(frequencyInfoUL->frequencyBandList, sizeof(MultiFrequencyBandListNR_t));
7991 /* Absolute frequency point A */
7992 DU_FREE(frequencyInfoUL->absoluteFrequencyPointA, sizeof(ARFCN_ValueNR_t));
7994 /* Subcarrier Spacing specifc carrier */
7995 FreeScsSpecificCarrierListUl(&frequencyInfoUL->scs_SpecificCarrierList);
7998 DU_FREE(frequencyInfoUL->p_Max, sizeof(P_Max_t));
8001 /*******************************************************************
8003 * @brief Free UL config common in Serving cell config common
8007 * Function : FreeUlConfigCommon
8009 * Functionality: Free UL config common in Serving cell config common
8011 * @params[in] Pointer to UplinkConfigCommon_t
8015 * ****************************************************************/
8016 void FreeUlConfigCommon(UplinkConfigCommon_t *ulCfgCommon)
8018 /* UL Frequency Info */
8019 if(ulCfgCommon->frequencyInfoUL)
8021 FreeFreqInfoUl(ulCfgCommon->frequencyInfoUL);
8022 DU_FREE(ulCfgCommon->frequencyInfoUL, sizeof(FrequencyInfoUL_t));
8026 if(ulCfgCommon->initialUplinkBWP)
8028 FreeBwpUlCommon(ulCfgCommon->initialUplinkBWP);
8029 DU_FREE(ulCfgCommon->initialUplinkBWP, sizeof(BWP_UplinkCommon_t));
8033 /*******************************************************************
8035 * @brief Free SP cell config common in Reconfig with Sync
8039 * Function : FreeSpCellConfigCommon
8041 * Functionality: Free SP cell config common in Reconfig with Sync
8043 * @params[in] Pointer to ServingCellConfigCommon_t
8047 * ****************************************************************/
8048 void FreeSpCellConfigCommon(ServingCellConfigCommon_t *spCellConfigCommon)
8050 /* Free Physical cell identity */
8051 DU_FREE(spCellConfigCommon->physCellId, sizeof(PhysCellId_t));
8053 /* Free Downlink Config common */
8054 if(spCellConfigCommon->downlinkConfigCommon)
8056 FreeDlConfigCommon(spCellConfigCommon->downlinkConfigCommon);
8057 DU_FREE(spCellConfigCommon->downlinkConfigCommon, sizeof(DownlinkConfigCommon_t));
8060 /* Free Uplink Config common */
8061 if(spCellConfigCommon->uplinkConfigCommon)
8063 FreeUlConfigCommon(spCellConfigCommon->uplinkConfigCommon);
8064 DU_FREE(spCellConfigCommon->uplinkConfigCommon, sizeof(UplinkConfigCommon_t));
8067 /* Free Timing Advance offset */
8068 DU_FREE(spCellConfigCommon->n_TimingAdvanceOffset, sizeof(long));
8070 /* Free SSB Position in Burst */
8071 if(spCellConfigCommon->ssb_PositionsInBurst)
8073 DU_FREE(spCellConfigCommon->ssb_PositionsInBurst->choice.mediumBitmap.buf, \
8074 spCellConfigCommon->ssb_PositionsInBurst->choice.mediumBitmap.size);
8075 DU_FREE(spCellConfigCommon->ssb_PositionsInBurst, sizeof(struct ServingCellConfigCommon__ssb_PositionsInBurst));
8078 /* Free SSB Periodicity in Serving cell */
8079 DU_FREE(spCellConfigCommon->ssb_periodicityServingCell, sizeof(long));
8081 /* Free SSB subcarrier spacing */
8082 DU_FREE(spCellConfigCommon->ssbSubcarrierSpacing, sizeof(SubcarrierSpacing_t));
8084 /* TDD UL-DL configuration common */
8085 DU_FREE(spCellConfigCommon->tdd_UL_DL_ConfigurationCommon, sizeof(TDD_UL_DL_ConfigCommon_t));
8088 /*******************************************************************
8090 * @brief Free dedicated RACH configuration in Reconfiguration with sync
8094 * Function : FreeRecfgWithSync
8097 * Free dedicated RACH configuration in Reconfiguration with sync
8099 * @params[in] Pinter to Rach config dedicated struct
8103 * ****************************************************************/
8104 void FreeRachConfigDedicated(struct ReconfigurationWithSync__rach_ConfigDedicated *rachCfgDed)
8106 uint8_t listIdx = 0;
8107 CFRA_t *cfra = NULLP;
8108 struct CFRA__resources__ssb *ssbResource = NULLP;
8111 if(rachCfgDed->choice.uplink)
8113 /* CFRA : Contention free Random Access */
8114 if(rachCfgDed->choice.uplink->cfra)
8116 cfra = rachCfgDed->choice.uplink->cfra;
8118 /* CFRA occassions */
8121 /* CFRA occassions : SSB per RACH occasion */
8122 DU_FREE(cfra->occasions->ssb_perRACH_Occasion, sizeof(long));
8123 DU_FREE(cfra->occasions, sizeof(struct CFRA__occasions));
8127 cfra->resources.present = CFRA__resources_PR_ssb;
8129 /* CFRA resource : SSB */
8130 if(cfra->resources.choice.ssb)
8132 ssbResource = cfra->resources.choice.ssb;
8134 /* CFRA SSB resource list */
8135 if(ssbResource->ssb_ResourceList.list.array)
8137 for(listIdx = 0; listIdx < ssbResource->ssb_ResourceList.list.count; listIdx++)
8139 DU_FREE(ssbResource->ssb_ResourceList.list.array[listIdx], sizeof(CFRA_SSB_Resource_t));
8141 DU_FREE(ssbResource->ssb_ResourceList.list.array, ssbResource->ssb_ResourceList.list.size);
8143 DU_FREE(cfra->resources.choice.ssb, sizeof(struct CFRA__resources__ssb));
8145 DU_FREE(rachCfgDed->choice.uplink->cfra, sizeof(CFRA_t));
8147 DU_FREE(rachCfgDed->choice.uplink, sizeof(RACH_ConfigDedicated_t));
8151 /*******************************************************************
8153 * @brief Frees reconfiguration with sync in SP cell config
8157 * Function : FreeRecfgWithSync
8159 * Functionality: Fress reconfiguration with sync in SP cell config
8161 * @params[in] Pointer to ReconfigurationWithSync_t
8165 * ****************************************************************/
8166 void FreeRecfgWithSync(ReconfigurationWithSync_t *recfgWithSync)
8168 /* Free SP Cell config common */
8169 if(recfgWithSync->spCellConfigCommon)
8171 FreeSpCellConfigCommon(recfgWithSync->spCellConfigCommon);
8172 DU_FREE(recfgWithSync->spCellConfigCommon, sizeof(ServingCellConfigCommon_t));
8175 /* Free Dedicated RACH configuration */
8176 if(recfgWithSync->rach_ConfigDedicated)
8178 FreeRachConfigDedicated(recfgWithSync->rach_ConfigDedicated);
8179 DU_FREE(recfgWithSync->rach_ConfigDedicated, sizeof(struct ReconfigurationWithSync__rach_ConfigDedicated));
8183 /*******************************************************************
8185 * @brief Frees emmory allocated for DUToCURRCContainer
8189 * Function : FreeMemDuToCuRrcCont
8191 * Functionality: Deallocating memory of DuToCuRrcContainer
8193 * @params[in] DuToCuRRCContainer, DuToCuRRCContainer
8195 * @return ROK - success
8198 * ****************************************************************/
8199 uint8_t FreeMemDuToCuRrcCont(CellGroupConfigRrc_t *cellGrpCfg)
8202 SpCellConfig_t *spCellCfg=NULLP;
8203 ServingCellConfig_t *srvCellCfg=NULLP;
8204 BWP_DownlinkDedicated_t *dlBwp=NULLP;
8205 MAC_CellGroupConfig_t *macCellGrpCfg=NULLP;
8206 PhysicalCellGroupConfig_t *phyCellGrpCfg=NULLP;
8207 struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList=NULLP;
8208 struct RLC_Config *rlcConfig=NULLP;
8209 struct LogicalChannelConfig *macLcConfig=NULLP;
8210 struct MAC_CellGroupConfig__drx_ConfigRrc *drxCfg=NULLP;
8211 struct SchedulingRequestConfig *schedulingRequestConfig=NULLP;
8212 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList=NULLP;
8213 struct TAG_Config *tagConfig=NULLP;
8214 struct TAG_Config__tag_ToAddModList *tagList=NULLP;
8215 struct MAC_CellGroupConfig__phr_Config *phrConfig=NULLP;
8216 struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg=NULLP;
8218 rlcBearerList = cellGrpCfg->rlc_BearerToAddModList;
8221 if(rlcBearerList->list.array)
8223 for(idx=0; idx<rlcBearerList->list.count; idx++)
8225 if(rlcBearerList->list.array[idx])
8227 rlcConfig = rlcBearerList->list.array[idx]->rlc_Config;
8228 macLcConfig = rlcBearerList->list.array[idx]->mac_LogicalChannelConfig;
8231 switch(rlcConfig->present)
8233 case RLC_Config_PR_NOTHING:
8236 case RLC_Config_PR_am:
8238 if(rlcConfig->choice.am)
8240 DU_FREE(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
8241 DU_FREE(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength, sizeof(SN_FieldLengthAM_t));
8242 DU_FREE(rlcConfig->choice.am, sizeof(struct RLC_Config__am));
8246 case RLC_Config_PR_um_Bi_Directional:
8248 if(rlcConfig->choice.um_Bi_Directional)
8250 DU_FREE(rlcConfig->choice.um_Bi_Directional->dl_UM_RLC.sn_FieldLength, sizeof(SN_FieldLengthUM_t));
8251 DU_FREE(rlcConfig->choice.um_Bi_Directional->ul_UM_RLC.sn_FieldLength, sizeof(SN_FieldLengthUM_t));
8252 DU_FREE(rlcConfig->choice.um_Bi_Directional, sizeof(struct RLC_Config__um_Bi_Directional));
8256 case RLC_Config_PR_um_Uni_Directional_UL:
8258 if(rlcConfig->choice.um_Uni_Directional_UL)
8260 DU_FREE(rlcConfig->choice.um_Uni_Directional_UL->ul_UM_RLC.sn_FieldLength, sizeof(SN_FieldLengthUM_t));
8261 DU_FREE(rlcConfig->choice.um_Uni_Directional_UL , sizeof(struct RLC_Config__um_Uni_Directional_UL));
8265 case RLC_Config_PR_um_Uni_Directional_DL:
8267 if(rlcConfig->choice.um_Uni_Directional_DL )
8269 DU_FREE(rlcConfig->choice.um_Uni_Directional_DL->dl_UM_RLC.sn_FieldLength, sizeof(SN_FieldLengthUM_t));
8270 DU_FREE(rlcConfig->choice.um_Uni_Directional_DL , sizeof(struct RLC_Config__um_Uni_Directional_DL));
8275 DU_FREE(rlcConfig, sizeof(struct RLC_Config));
8277 DU_FREE(rlcBearerList->list.array[idx]->servedRadioBearer, sizeof(struct RLC_BearerConfig__servedRadioBearer));
8280 if(macLcConfig->ul_SpecificParameters)
8282 DU_FREE(macLcConfig->ul_SpecificParameters->schedulingRequestID, sizeof(SchedulingRequestId_t));
8283 DU_FREE(macLcConfig->ul_SpecificParameters->logicalChannelGroup, sizeof(long));
8284 DU_FREE(macLcConfig->ul_SpecificParameters, sizeof(struct LogicalChannelConfig__ul_SpecificParameters));
8286 DU_FREE(rlcBearerList->list.array[idx]->mac_LogicalChannelConfig, sizeof(struct LogicalChannelConfig));
8288 DU_FREE(rlcBearerList->list.array[idx], sizeof(struct RLC_BearerConfig));
8291 DU_FREE(rlcBearerList->list.array, rlcBearerList->list.size);
8293 DU_FREE(cellGrpCfg->rlc_BearerToAddModList, sizeof(struct CellGroupConfigRrc__rlc_BearerToAddModList));
8296 macCellGrpCfg = cellGrpCfg->mac_CellGroupConfig;
8299 drxCfg = macCellGrpCfg->drx_ConfigRrc;
8303 switch(drxCfg->present)
8305 case MAC_CellGroupConfig__drx_ConfigRrc_PR_NOTHING:
8307 case MAC_CellGroupConfig__drx_ConfigRrc_PR_setup:
8309 if(drxCfg->choice.setup)
8311 DU_FREE(drxCfg->choice.setup->shortDRX, sizeof(struct DRX_ConfigRrc__shortDRX));
8312 DU_FREE(drxCfg->choice.setup, sizeof(struct DRX_ConfigRrc));
8315 case MAC_CellGroupConfig__drx_ConfigRrc_PR_release:
8318 DU_FREE(drxCfg, sizeof(struct MAC_CellGroupConfig__drx_ConfigRrc));
8320 schedulingRequestConfig = macCellGrpCfg->schedulingRequestConfig;
8321 if(schedulingRequestConfig)
8323 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
8326 if(schReqList->list.array)
8328 for(idx=0;idx<schReqList->list.count; idx++)
8330 if(schReqList->list.array[idx])
8332 DU_FREE(schReqList->list.array[idx]->sr_ProhibitTimer, sizeof(long));
8333 DU_FREE(schReqList->list.array[idx], sizeof(struct SchedulingRequestToAddMod));
8336 DU_FREE(schReqList->list.array, schReqList->list.size);
8338 DU_FREE(schedulingRequestConfig->schedulingRequestToAddModList,\
8339 sizeof(struct SchedulingRequestConfig__schedulingRequestToAddModList)); }
8340 DU_FREE(macCellGrpCfg->schedulingRequestConfig, sizeof(struct SchedulingRequestConfig));
8342 if(macCellGrpCfg->bsr_Config)
8344 DU_FREE(macCellGrpCfg->bsr_Config->logicalChannelSR_DelayTimer, sizeof(long));
8345 DU_FREE(macCellGrpCfg->bsr_Config, sizeof(struct BSR_Config));
8347 tagConfig = macCellGrpCfg->tag_Config;
8350 tagList = tagConfig->tag_ToAddModList;
8353 if(tagList->list.array)
8355 for(idx=0; idx<tagList->list.count; idx++)
8357 DU_FREE(tagList->list.array[idx], sizeof(struct TAG));
8359 DU_FREE(tagList->list.array, tagList->list.size);
8361 DU_FREE(tagConfig->tag_ToAddModList, sizeof(struct TAG_Config__tag_ToAddModList));
8363 DU_FREE(tagConfig, sizeof(struct TAG_Config));
8366 phrConfig = macCellGrpCfg->phr_Config;
8369 DU_FREE(phrConfig->choice.setup, sizeof(struct PHR_Config));
8370 DU_FREE(phrConfig, sizeof(struct MAC_CellGroupConfig__phr_Config));
8373 DU_FREE(macCellGrpCfg, sizeof(MAC_CellGroupConfig_t));
8376 phyCellGrpCfg = cellGrpCfg->physicalCellGroupConfig;
8379 DU_FREE(phyCellGrpCfg->p_NR_FR1, sizeof(long));
8380 DU_FREE(phyCellGrpCfg, sizeof(PhysicalCellGroupConfig_t));
8383 spCellCfg = cellGrpCfg->spCellConfig;
8386 /* Free serving cell index */
8387 DU_FREE(spCellCfg->servCellIndex, sizeof(long));
8389 /* Free Reconfiguration with sync */
8390 if(spCellCfg->reconfigurationWithSync)
8392 FreeRecfgWithSync(spCellCfg->reconfigurationWithSync);
8393 DU_FREE(spCellCfg->reconfigurationWithSync, sizeof(ReconfigurationWithSync_t));
8396 /* Free rlmInSyncOutOfSyncThreshold */
8397 DU_FREE(spCellCfg->rlmInSyncOutOfSyncThreshold, sizeof(long));
8399 /* Free SP Cell config dedicated */
8400 if(spCellCfg->spCellConfigDedicated)
8402 srvCellCfg = spCellCfg->spCellConfigDedicated;
8404 /* Free TDD UL-DL config dedicated */
8405 DU_FREE(srvCellCfg->tdd_UL_DL_ConfigurationDedicated, sizeof(TDD_UL_DL_ConfigDedicated_t));
8407 /* Free Initial Downlink BWP */
8408 if(srvCellCfg->initialDownlinkBWP)
8410 dlBwp = srvCellCfg->initialDownlinkBWP;
8412 /* Free DL BWP PDCCH Config */
8413 if(dlBwp->pdcch_Config)
8415 FreeBWPDlDedPdcchCfg(dlBwp);
8416 DU_FREE(dlBwp->pdcch_Config, sizeof(struct BWP_DownlinkDedicated__pdcch_Config));
8419 /* Free DL BWP PDSCH config */
8420 if(dlBwp->pdsch_Config)
8422 FreeBWPDlDedPdschCfg(dlBwp);
8423 DU_FREE(dlBwp->pdsch_Config, sizeof(struct BWP_DownlinkDedicated__pdsch_Config));
8425 DU_FREE(srvCellCfg->initialDownlinkBWP, sizeof(BWP_DownlinkDedicated_t));
8428 /* Free First Active Downlink BWP */
8429 DU_FREE(srvCellCfg->firstActiveDownlinkBWP_Id, sizeof(long));
8431 /* Free Default downlink BWP */
8432 DU_FREE(srvCellCfg->defaultDownlinkBWP_Id, sizeof(long));
8434 /* Free Uplink config */
8435 if(srvCellCfg->uplinkConfig)
8437 FreeinitialUplinkBWP(srvCellCfg->uplinkConfig);
8438 DU_FREE(srvCellCfg->uplinkConfig, sizeof(UplinkConfig_t));
8441 /* Free PDSCH serving cell config */
8442 if(srvCellCfg->pdsch_ServingCellConfig)
8444 pdschCfg= srvCellCfg->pdsch_ServingCellConfig;
8445 if(pdschCfg->choice.setup)
8447 DU_FREE(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH,sizeof(long));
8448 DU_FREE(pdschCfg->choice.setup, sizeof(struct PDSCH_ServingCellConfig));
8450 DU_FREE(srvCellCfg->pdsch_ServingCellConfig, sizeof(struct ServingCellConfig__pdsch_ServingCellConfig));
8453 DU_FREE(spCellCfg->spCellConfigDedicated, sizeof(ServingCellConfig_t));
8455 DU_FREE(spCellCfg,sizeof(SpCellConfig_t));
8460 /*******************************************************************
8462 * @brief Builds CellGroupConfigRrc for DU To CU RRC Container
8466 * Function : BuildCellGroupConfigRrc
8468 * Functionality: Builds and copied Cell group config buffer into
8469 * DuToCuRrcContainer
8471 * @params[in] idx, index in F1AP msg
8472 * DuToCuRRCContainer, DuToCuRRCContainer
8474 * @return ROK - success
8477 * ****************************************************************/
8478 uint8_t BuildCellGroupConfigRrc(DuUeCb *ueCb, OCTET_STRING_t *duToCuRrcContainer)
8481 CellGroupConfigRrc_t cellGrpCfg;
8482 asn_enc_rval_t encRetVal;
8483 memset(&cellGrpCfg, 0, sizeof(CellGroupConfigRrc_t));
8484 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
8488 cellGrpCfg.cellGroupId = CELL_GRP_ID;
8490 cellGrpCfg.rlc_BearerToAddModList = NULLP;
8491 DU_ALLOC(cellGrpCfg.rlc_BearerToAddModList, sizeof(struct CellGroupConfigRrc__rlc_BearerToAddModList));
8492 if(!cellGrpCfg.rlc_BearerToAddModList)
8494 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
8498 if(BuildRlcBearerToAddModList(ueCb, cellGrpCfg.rlc_BearerToAddModList) != ROK)
8500 DU_LOG("\nERROR --> F1AP : BuildRlcBearerToAddModList failed");
8505 cellGrpCfg.rlc_BearerToReleaseList = NULLP;
8506 cellGrpCfg.mac_CellGroupConfig = NULLP;
8507 DU_ALLOC(cellGrpCfg.mac_CellGroupConfig, sizeof(MAC_CellGroupConfig_t));
8508 if(!cellGrpCfg.mac_CellGroupConfig)
8510 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
8514 if(BuildMacCellGrpCfg(ueCb, cellGrpCfg.mac_CellGroupConfig) != ROK)
8516 DU_LOG("\nERROR --> F1AP : BuildMacCellGrpCfg failed");
8521 cellGrpCfg.physicalCellGroupConfig = NULLP;
8522 DU_ALLOC(cellGrpCfg.physicalCellGroupConfig, sizeof(PhysicalCellGroupConfig_t));
8523 if(!cellGrpCfg.physicalCellGroupConfig)
8525 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
8529 if(BuildPhyCellGrpCfg(ueCb, cellGrpCfg.physicalCellGroupConfig) != ROK)
8531 DU_LOG("\nERROR --> F1AP : BuildPhyCellGrpCfg failed");
8536 cellGrpCfg.spCellConfig = NULLP;
8537 DU_ALLOC(cellGrpCfg.spCellConfig, sizeof(SpCellConfig_t));
8538 if(!cellGrpCfg.spCellConfig)
8540 DU_LOG("\nERROR --> F1AP : Memory allocation failure in BuildDuToCuRrcContainer");
8544 if(BuildSpCellCfg(ueCb, cellGrpCfg.spCellConfig) != ROK)
8546 DU_LOG("\nERROR --> F1AP : BuildSpCellCfg failed");
8551 cellGrpCfg.sCellToAddModList = NULLP;
8552 cellGrpCfg.sCellToReleaseList = NULLP;
8553 cellGrpCfg.ext1 = NULLP;
8555 /* encode cellGrpCfg into duToCuRrcContainer */
8556 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, &cellGrpCfg);
8557 memset(encBuf, 0, ENC_BUF_MAX_LEN);
8559 encRetVal = aper_encode(&asn_DEF_CellGroupConfigRrc, 0, &cellGrpCfg, PrepFinalEncBuf, encBuf);
8560 /* Encode results */
8561 if(encRetVal.encoded == ENCODE_FAIL)
8563 DU_LOG( "\nERROR --> F1AP : Could not encode DuToCuRrcContainer (at %s)\n",\
8564 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
8570 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for DuToCuRrcContainer\n");
8571 #ifdef DEBUG_ASN_PRINT
8572 for(int i=0; i< encBufSize; i++)
8574 printf("%x",encBuf[i]);
8579 duToCuRrcContainer->size = encBufSize;
8580 DU_ALLOC(duToCuRrcContainer->buf, duToCuRrcContainer->size);
8581 if(!duToCuRrcContainer->buf)
8583 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDuToCuRrcContainer");
8589 memcpy(duToCuRrcContainer->buf, encBuf, duToCuRrcContainer->size);
8593 FreeMemDuToCuRrcCont(&cellGrpCfg);
8597 /*******************************************************************
8599 * @brief Free memory allocated in InitialULRRCMessage
8603 * Function : freeInitUlRrcMsgTransfer
8605 * Functionality: Free memory allocated in InitialULRRCMessage
8607 * @params[in]F1AP_PDU_t *f1apMsg)
8609 * @return ROK - success
8612 * ****************************************************************/
8614 uint8_t freeInitUlRrcMsgTransfer(F1AP_PDU_t *f1apMsg)
8616 uint8_t ieIdx, arrIdx;
8617 InitialULRRCMessageTransfer_t *initULRRCMsg=NULLP;
8621 if(f1apMsg->choice.initiatingMessage)
8623 initULRRCMsg = &f1apMsg->choice.initiatingMessage->value.\
8624 choice.InitialULRRCMessageTransfer;
8625 if(initULRRCMsg->protocolIEs.list.array)
8627 for(ieIdx = 0; ieIdx < initULRRCMsg->protocolIEs.list.count; ieIdx++)
8629 switch(initULRRCMsg->protocolIEs.list.array[ieIdx]->id)
8631 case ProtocolIE_ID_id_NRCGI:
8633 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.buf)
8635 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.buf)
8637 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.buf,\
8638 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity.size);
8640 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.buf,\
8641 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.pLMN_Identity.size);
8645 case ProtocolIE_ID_id_RRCContainer:
8647 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
8649 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf,\
8650 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size);
8654 case ProtocolIE_ID_id_DUtoCURRCContainer:
8656 if(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.buf)
8658 DU_FREE(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.buf,
8659 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer.size);
8667 for(arrIdx = 0; arrIdx < ieIdx; arrIdx++)
8669 if(initULRRCMsg->protocolIEs.list.array[arrIdx])
8671 DU_FREE(initULRRCMsg->protocolIEs.list.array[arrIdx],\
8672 sizeof(InitialULRRCMessageTransferIEs_t));
8675 DU_FREE(initULRRCMsg->protocolIEs.list.array, initULRRCMsg->protocolIEs.list.size);
8677 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
8679 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
8683 DU_LOG("\nERROR --> DU_APP : Recevied F1ap Pdu is null at freeInitUlRrcMsgTransfer()");
8689 /*******************************************************************
8691 * @brief Builds and sends the InitialULRRCMessage
8695 * Function : BuildAndSendInitialRrcMsgTransfer
8697 * Functionality: Constructs the Initial UL RRC Message Transfer and sends
8698 * it to the CU through SCTP.
8702 * @return ROK - success
8705 * ****************************************************************/
8706 uint8_t BuildAndSendInitialRrcMsgTransfer(uint32_t gnbDuUeF1apId, uint16_t crnti,
8707 uint16_t rrcContSize, uint8_t *rrcContainer)
8711 uint8_t ieIdx, cellIdx, ueIdx;
8712 DuUeCb *duUeCb = NULLP;
8713 asn_enc_rval_t encRetVal;
8714 F1AP_PDU_t *f1apMsg = NULLP;
8715 InitialULRRCMessageTransfer_t *initULRRCMsg = NULLP;
8716 memset(&encRetVal, 0, sizeof(asn_enc_rval_t));
8720 DU_LOG("\n INFO --> F1AP : Building RRC Setup Request\n");
8721 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
8722 if(f1apMsg == NULLP)
8724 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
8727 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
8728 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
8729 if(f1apMsg->choice.initiatingMessage == NULLP)
8731 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
8734 f1apMsg->choice.initiatingMessage->procedureCode =\
8735 ProcedureCode_id_InitialULRRCMessageTransfer;
8736 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
8737 f1apMsg->choice.initiatingMessage->value.present = \
8738 InitiatingMessage__value_PR_InitialULRRCMessageTransfer;
8740 &f1apMsg->choice.initiatingMessage->value.choice.InitialULRRCMessageTransfer;
8742 initULRRCMsg->protocolIEs.list.count = elementCnt;
8743 initULRRCMsg->protocolIEs.list.size = \
8744 elementCnt * sizeof(InitialULRRCMessageTransferIEs_t *);
8745 /* Initialize the F1Setup members */
8746 DU_ALLOC(initULRRCMsg->protocolIEs.list.array,initULRRCMsg->protocolIEs.list.size);
8747 if(initULRRCMsg->protocolIEs.list.array == NULLP)
8749 DU_LOG(" ERROR --> F1AP : Memory allocation for\
8750 RRCSetupRequestMessageTransferIEs failed");
8753 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
8755 DU_ALLOC(initULRRCMsg->protocolIEs.list.array[ieIdx],\
8756 sizeof(InitialULRRCMessageTransferIEs_t));
8757 if(initULRRCMsg->protocolIEs.list.array[ieIdx] == NULLP)
8763 /*GNB DU UE F1AP ID*/
8764 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
8765 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
8766 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
8767 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present = \
8768 InitialULRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
8769 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
8774 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
8775 ProtocolIE_ID_id_NRCGI;
8776 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality =Criticality_reject;
8777 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present = \
8778 InitialULRRCMessageTransferIEs__value_PR_NRCGI;
8781 BuildNrcgi(&initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.NRCGI);
8789 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
8790 ProtocolIE_ID_id_C_RNTI;
8791 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
8792 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
8793 InitialULRRCMessageTransferIEs__value_PR_C_RNTI;
8794 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.C_RNTI = crnti;
8798 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = \
8799 ProtocolIE_ID_id_RRCContainer;
8800 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
8801 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
8802 InitialULRRCMessageTransferIEs__value_PR_RRCContainer;
8804 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size = rrcContSize;
8805 DU_ALLOC(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf,
8806 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size)
8807 if(!initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
8809 DU_LOG(" ERROR --> F1AP : Memory allocation for RRCSetupRequestMessageTransferIEs failed");
8813 memcpy(initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf, rrcContainer,
8814 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.size);
8817 /*DUtoCURRCContainer*/
8819 initULRRCMsg->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DUtoCURRCContainer;
8820 initULRRCMsg->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
8821 initULRRCMsg->protocolIEs.list.array[ieIdx]->value.present =\
8822 InitialULRRCMessageTransferIEs__value_PR_DUtoCURRCContainer;
8824 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
8826 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
8828 if(duCb.actvCellLst[cellIdx] && (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
8829 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].crnti == crnti))
8831 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
8836 ret = BuildCellGroupConfigRrc(duUeCb, &initULRRCMsg->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCContainer);
8842 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
8844 /* Encode the Intial UL RRC Message transfer as APER */
8845 memset(encBuf, 0, ENC_BUF_MAX_LEN);
8847 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
8848 /* Encode results */
8849 if(encRetVal.encoded == ENCODE_FAIL)
8851 DU_LOG( "\nERROR --> F1AP : Could not encode Initial UL RRC Message Transfer\
8852 structure (at %s)\n",encRetVal.failed_type ? \
8853 encRetVal.failed_type->name : "unknown");
8860 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for Initial UL RRC\
8861 Message transfer\n");
8862 #ifdef DEBUG_ASN_PRINT
8863 for(int i=0; i< encBufSize; i++)
8865 printf("%x",encBuf[i]);
8870 if(sendF1APMsg() != ROK)
8872 DU_LOG("\nERROR --> F1AP : Sending Initial UL RRC Message Transfer Failed");
8878 freeInitUlRrcMsgTransfer(f1apMsg);
8880 }/* End of BuildAndSendInitialRrcMsgTransfer*/
8882 /***** UE SETUP REQUEST *****/
8884 /*******************************************************************
8886 * @brief Free Qos And Snssai Drb Info
8890 * Function : freeDrbQosAndSnssaiInfo
8892 * Functionality: Free Qos And Snssai Drb Info
8894 * @params[in] LcCfg *lcCfg,
8897 * ****************************************************************/
8898 void freeDrbQosAndSnssaiInfo(LcCfg *lcCfg)
8902 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
8906 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
8910 /******************************************************************
8912 * @brief Function to delete the RLC Lc cfg from UE APP DB
8916 * Function : freeRlcLcCfg
8918 * Functionality: Function to delete the RLC Lc cfg from UE APP DB
8921 *****************************************************************/
8923 void freeRlcLcCfg(RlcBearerCfg *lcCfg)
8925 switch(lcCfg->rlcMode)
8929 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.amCfg, sizeof(AmBearerCfg));
8932 case RLC_UM_BI_DIRECTIONAL :
8934 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
8937 case RLC_UM_UNI_DIRECTIONAL_UL :
8939 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
8942 case RLC_UM_UNI_DIRECTIONAL_DL :
8944 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
8948 DU_LOG("\nERROR --> DU_APP: Invalid Rlc Mode %d at freeRlcLcCfg()", lcCfg->rlcMode);
8951 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
8954 /*******************************************************************
8956 * @brief Function to free MacLcCfg
8960 * Function : freeMacLcCfg
8962 * Functionality: Function to free MacLcCfg
8964 * @params[in] LcCfg *lcCfg,
8967 * ****************************************************************/
8969 void freeMacLcCfg(LcCfg *lcCfg)
8971 /* Deleting DRBQOS */
8974 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->drbQos, sizeof(DrbQosInfo));
8976 /* Deleting SNSSAI */
8979 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, lcCfg->snssai, sizeof(Snssai));
8982 /*******************************************************************
8984 * @brief Free UE NR Capability received in UE Context setup request
8988 * Function : freeAperDecodeUeNrCapability
8991 * Free UE NR Capability received in UE Context setup request
8994 * @return ROK - success
8997 * ****************************************************************/
8998 void freeAperDecodeUeNrCapability(void *ueNrCapability)
9001 FeatureSets_t *featureSets =NULLP;
9002 UE_NR_Capability_t *ueNrCap = (UE_NR_Capability_t *)ueNrCapability;
9004 if(ueNrCap->rf_Parameters.supportedBandListNR.list.array)
9006 for(arrIdx = 0; arrIdx < ueNrCap->rf_Parameters.supportedBandListNR.list.count; arrIdx++)
9008 if(ueNrCap->rf_Parameters.supportedBandListNR.list.array[arrIdx])
9009 free(ueNrCap->rf_Parameters.supportedBandListNR.list.array[arrIdx]);
9011 free(ueNrCap->rf_Parameters.supportedBandListNR.list.array);
9014 if(ueNrCap->featureSets)
9016 featureSets = ueNrCap->featureSets;
9017 if(featureSets->featureSetsDownlinkPerCC)
9019 if(featureSets->featureSetsDownlinkPerCC->list.array)
9021 for(arrIdx = 0; arrIdx < featureSets->featureSetsDownlinkPerCC->list.count; arrIdx++)
9023 if(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx])
9025 if(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]->supportedModulationOrderDL)
9026 free(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]->supportedModulationOrderDL);
9027 free(featureSets->featureSetsDownlinkPerCC->list.array[arrIdx]);
9030 free(featureSets->featureSetsDownlinkPerCC->list.array);
9032 free(featureSets->featureSetsDownlinkPerCC);
9034 if(featureSets->featureSetsUplinkPerCC)
9036 if(featureSets->featureSetsUplinkPerCC->list.array)
9038 for(arrIdx = 0; arrIdx < featureSets->featureSetsUplinkPerCC->list.count; arrIdx++)
9040 if(featureSets->featureSetsUplinkPerCC->list.array[arrIdx])
9042 if(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]->supportedModulationOrderUL)
9043 free(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]->supportedModulationOrderUL);
9044 free(featureSets->featureSetsUplinkPerCC->list.array[arrIdx]);
9047 free(featureSets->featureSetsUplinkPerCC->list.array);
9049 free(featureSets->featureSetsUplinkPerCC);
9051 free(ueNrCap->featureSets);
9055 /*******************************************************************
9057 * @brief Function to free PdcchSearchSpcToAddModList
9058 where memory allocated by aper_decoder
9062 * Function : freeAperDecodePdcchSearchSpcToAddModList
9064 * Functionality: Function to free PdcchSearchSpcToAddModList
9066 * @params[in] struct PDCCH_Config__searchSpacesToAddModList *searchSpcList
9069 * ****************************************************************/
9071 void freeAperDecodePdcchSearchSpcToAddModList(struct PDCCH_Config__searchSpacesToAddModList *searchSpcList)
9073 uint8_t searchSpcArrIdx=0;
9074 uint8_t searchSpcArrIdx1=0;
9075 struct SearchSpace *searchSpc=NULLP;
9078 if(searchSpcList->list.array)
9080 if(searchSpcList->list.array[searchSpcArrIdx1])
9082 searchSpc = searchSpcList->list.array[searchSpcArrIdx1];
9083 if(searchSpc->controlResourceSetId)
9085 if(searchSpc->monitoringSlotPeriodicityAndOffset)
9087 if(searchSpc->monitoringSymbolsWithinSlot)
9089 if(searchSpc->monitoringSymbolsWithinSlot->buf)
9091 if(searchSpc->nrofCandidates)
9093 if(searchSpc->searchSpaceType)
9095 free(searchSpc->searchSpaceType->choice.ue_Specific);
9096 free(searchSpc->searchSpaceType);
9098 free(searchSpc->nrofCandidates);
9100 free(searchSpc->monitoringSymbolsWithinSlot->buf);
9102 free(searchSpc->monitoringSymbolsWithinSlot);
9104 free(searchSpc->monitoringSlotPeriodicityAndOffset);
9106 free(searchSpc->controlResourceSetId);
9109 for(searchSpcArrIdx = 0; searchSpcArrIdx < searchSpcList->list.count; searchSpcArrIdx++)
9111 free(searchSpcList->list.array[searchSpcArrIdx]);
9113 free(searchSpcList->list.array);
9116 /*******************************************************************
9118 * @brief Function for free part for the memory allocated by aper_decoder
9122 * Function : freeAperDecodeBWPDlDedPdcchConfig
9124 * Functionality: Function to free BWPDlDedPdcchConfig
9129 * ****************************************************************/
9132 void freeAperDecodeBWPDlDedPdcchConfig(BWP_DownlinkDedicated_t *dlBwp)
9136 struct PDCCH_Config *pdcchCfg=NULLP;
9137 struct ControlResourceSet *controlRSet=NULLP;
9138 struct PDCCH_Config__controlResourceSetToAddModList *controlRSetList=NULLP;
9140 if(dlBwp->pdcch_Config->choice.setup)
9142 pdcchCfg=dlBwp->pdcch_Config->choice.setup;
9143 if(pdcchCfg->controlResourceSetToAddModList)
9145 controlRSetList = pdcchCfg->controlResourceSetToAddModList;
9146 if(controlRSetList->list.array)
9148 controlRSet = controlRSetList->list.array[arrIdx2];
9151 if(controlRSet->frequencyDomainResources.buf)
9153 if(controlRSet->pdcch_DMRS_ScramblingID)
9155 if(pdcchCfg->searchSpacesToAddModList)
9157 freeAperDecodePdcchSearchSpcToAddModList(pdcchCfg->searchSpacesToAddModList);
9158 free(pdcchCfg->searchSpacesToAddModList);
9160 free(controlRSet->pdcch_DMRS_ScramblingID);
9162 free(controlRSet->frequencyDomainResources.buf);
9165 for(arrIdx1 = 0; arrIdx1 <controlRSetList->list.count; arrIdx1++)
9167 free(controlRSetList->list.array[arrIdx1]);
9169 free(controlRSetList->list.array);
9171 free(pdcchCfg->controlResourceSetToAddModList);
9173 free(dlBwp->pdcch_Config->choice.setup);
9176 /*******************************************************************
9178 * @brief Function to free PdschTimeDomAllocationList
9179 * where the memory allocated by aper_decoder
9183 * Function : freeAperDecodePdschTimeDomAllocationList
9185 * Functionality: Function to free PdschTimeDomAllocationList
9187 * @params[in] struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList
9190 * ****************************************************************/
9193 void freeAperDecodePdschTimeDomAllocationList( struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList)
9197 if(timeDomAllocList->choice.setup)
9199 if(timeDomAllocList->choice.setup->list.array)
9201 for(arrIdx = 0; arrIdx <timeDomAllocList->choice.setup->list.count ; arrIdx++)
9203 free(timeDomAllocList->choice.setup->list.array[arrIdx]);
9205 free(timeDomAllocList->choice.setup->list.array);
9207 free(timeDomAllocList->choice.setup);
9211 /*******************************************************************
9213 * @brief Function to free BWPDlDedPdschConfig
9214 * where the memory allocated by aper_decoder
9218 * Function : freeAperDecodeBWPDlDedPdschConfig
9220 * Functionality: Function to free BWPDlDedPdschConfig
9222 * @params[in] BWP_DownlinkDedicated_t *dlBwp
9225 * ****************************************************************/
9228 void freeAperDecodeBWPDlDedPdschConfig(BWP_DownlinkDedicated_t *dlBwp)
9230 struct PDSCH_Config *pdschCfg=NULLP;
9231 struct PDSCH_Config__prb_BundlingType *prbBndlType=NULLP;
9232 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAllocList=NULLP;
9233 struct PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA *dmrsDlCfg=NULLP;
9235 if(dlBwp->pdsch_Config->choice.setup)
9237 pdschCfg=dlBwp->pdsch_Config->choice.setup;
9238 if(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
9240 if(pdschCfg->pdsch_TimeDomainAllocationList)
9242 timeDomAllocList=pdschCfg->pdsch_TimeDomainAllocationList;
9243 if(pdschCfg->maxNrofCodeWordsScheduledByDCI)
9245 prbBndlType=&pdschCfg->prb_BundlingType;
9246 free(prbBndlType->choice.staticBundling);
9247 free(pdschCfg->maxNrofCodeWordsScheduledByDCI);
9249 freeAperDecodePdschTimeDomAllocationList(timeDomAllocList);
9250 free(pdschCfg->pdsch_TimeDomainAllocationList);
9252 dmrsDlCfg=pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA;
9253 if(dmrsDlCfg->choice.setup)
9255 free(dmrsDlCfg->choice.setup->dmrs_AdditionalPosition);
9256 free(dmrsDlCfg->choice.setup);
9258 free(pdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA);
9260 free(dlBwp->pdsch_Config->choice.setup);
9263 /*******************************************************************
9265 * @brief Function to free PuschTimeDomAllocListCfg
9266 where the memory allocated by aper_decoder
9270 * Function : freeAperDecodePuschTimeDomAllocListCfg
9272 * Functionality: Function to free PuschTimeDomAllocListCfg
9274 * @params[in] PUSCH_Config_t *puschCfg
9277 * ****************************************************************/
9280 void freeAperDecodePuschTimeDomAllocListCfg(PUSCH_Config_t *puschCfg)
9284 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList_t=NULLP;
9286 if(puschCfg->pusch_TimeDomainAllocationList)
9288 timeDomAllocList_t=puschCfg->pusch_TimeDomainAllocationList;
9289 if(timeDomAllocList_t->choice.setup)
9291 if(timeDomAllocList_t->choice.setup->list.array)
9293 free(timeDomAllocList_t->choice.setup->list.array[arrIdx1]->k2);
9294 for(arrIdx = 0; arrIdx<timeDomAllocList_t->choice.setup->list.count; arrIdx++)
9296 free(timeDomAllocList_t->choice.setup->list.array[arrIdx]);
9298 free(timeDomAllocList_t->choice.setup->list.array);
9300 free(timeDomAllocList_t->choice.setup);
9302 free(puschCfg->transformPrecoder);
9303 free(puschCfg->pusch_TimeDomainAllocationList);
9306 /*******************************************************************
9308 * @brief Function to free InitialUlBWPConfig where memory allocated by aper_decoder
9312 * Function : freeAperDecodeInitialUlBWPConfig
9314 * Functionality: Function to free InitialUlBWPConfig
9316 * @params[in] BWP_UplinkDedicated_t *ulBwp
9319 * ****************************************************************/
9322 void freeAperDecodeInitialUlBWPConfig(BWP_UplinkDedicated_t *ulBwp)
9326 SRS_Config_t *srsCfg = NULLP;
9327 PUSCH_Config_t *puschCfg = NULLP;
9328 struct PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA *dmrsUlCfg = NULLP;
9329 struct SRS_Config__srs_ResourceSetToAddModList *rsrcSetList = NULLP;
9330 struct SRS_ResourceSet__srs_ResourceIdList *rsrcIdList = NULLP;
9331 struct SRS_Config__srs_ResourceToAddModList *resourceList = NULLP;
9333 if(ulBwp->pusch_Config)
9335 if(ulBwp->pusch_Config->choice.setup)
9337 puschCfg=ulBwp->pusch_Config->choice.setup;
9338 if(puschCfg->dataScramblingIdentityPUSCH)
9340 if(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA)
9342 freeAperDecodePuschTimeDomAllocListCfg(puschCfg);
9343 dmrsUlCfg=puschCfg->dmrs_UplinkForPUSCH_MappingTypeA;
9344 if(dmrsUlCfg->choice.setup)
9346 if(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition)
9348 if(dmrsUlCfg->choice.setup->transformPrecodingDisabled)
9350 free(dmrsUlCfg->choice.setup->transformPrecodingDisabled->scramblingID0);
9351 free(dmrsUlCfg->choice.setup->transformPrecodingDisabled);
9353 free(dmrsUlCfg->choice.setup->dmrs_AdditionalPosition);
9355 free(dmrsUlCfg->choice.setup);
9357 free(puschCfg->dmrs_UplinkForPUSCH_MappingTypeA);
9359 free(puschCfg->dataScramblingIdentityPUSCH);
9361 free(ulBwp->pusch_Config->choice.setup);
9363 free(ulBwp->pusch_Config);
9365 /* Free SRS-Config */
9366 if(ulBwp->srs_Config)
9368 if(ulBwp->srs_Config->choice.setup)
9370 srsCfg = ulBwp->srs_Config->choice.setup;
9372 /* Free Resource Set to add/mod list */
9373 if(srsCfg->srs_ResourceSetToAddModList)
9375 rsrcSetList = srsCfg->srs_ResourceSetToAddModList;
9376 if(rsrcSetList->list.array)
9380 /* Free SRS resource Id list in this SRS resource set */
9381 if(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList)
9384 rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList;
9386 if(rsrcIdList->list.array)
9388 for(rsrcIdx = 0; rsrcIdx < rsrcIdList->list.count;
9391 free(rsrcIdList->list.array[rsrcIdx]);
9393 free(rsrcIdList->list.array);
9395 free(rsrcSetList->list.array[rSetIdx]->srs_ResourceIdList);
9398 /* Free resource type info for this SRS resource set */
9400 free(rsrcSetList->list.array[rSetIdx]->resourceType.choice.aperiodic);
9402 /* Free memory for each resource set */
9403 for(rSetIdx = 0; rSetIdx < rsrcSetList->list.count; rSetIdx++)
9405 free(rsrcSetList->list.array[rSetIdx]);
9407 free(rsrcSetList->list.array);
9409 free(srsCfg->srs_ResourceSetToAddModList);
9412 /* Free resource to add/modd list */
9413 if(srsCfg->srs_ResourceToAddModList)
9415 resourceList = srsCfg->srs_ResourceToAddModList;
9416 if(resourceList->list.array)
9420 free(resourceList->list.array[rsrcIdx]->transmissionComb.choice.n2);
9421 free(resourceList->list.array[rsrcIdx]->resourceType.choice.aperiodic);
9423 for(rsrcIdx = 0; rsrcIdx < resourceList->list.count; rsrcIdx++)
9425 free(resourceList->list.array[rsrcIdx]);
9427 free(resourceList->list.array);
9429 free(srsCfg->srs_ResourceToAddModList);
9432 free(ulBwp->srs_Config->choice.setup);
9434 free(ulBwp->srs_Config);
9438 /*******************************************************************
9440 * @brief Function to free initialUplinkBWPConfig where memory allocated by aper_decoder
9444 * Function : freeAperDecodeinitialUplinkBWPConfig
9446 * Functionality: Function to free initialUplinkBWPConfig
9448 * @params[in] UplinkConfig_t *ulCfg
9451 * ****************************************************************/
9454 void freeAperDecodeinitialUplinkBWPConfig(UplinkConfig_t *ulCfg)
9456 BWP_UplinkDedicated_t *ulBwp=NULLP;
9457 struct UplinkConfig__pusch_ServingCellConfig *puschCfg=NULLP;
9459 if(ulCfg->initialUplinkBWP)
9461 ulBwp=ulCfg->initialUplinkBWP;
9462 if(ulCfg->firstActiveUplinkBWP_Id)
9464 if(ulCfg->pusch_ServingCellConfig)
9466 puschCfg=ulCfg->pusch_ServingCellConfig;
9467 if(puschCfg->choice.setup)
9469 if(puschCfg->choice.setup->ext1)
9471 free(puschCfg->choice.setup->ext1->processingType2Enabled);
9472 free(puschCfg->choice.setup->ext1->maxMIMO_Layers);
9473 free(puschCfg->choice.setup->ext1);
9475 free(puschCfg->choice.setup);
9477 free(ulCfg->pusch_ServingCellConfig);
9479 free(ulCfg->firstActiveUplinkBWP_Id);
9481 freeAperDecodeInitialUlBWPConfig(ulBwp);
9482 free(ulCfg->initialUplinkBWP);
9486 /*******************************************************************
9488 * @brief Function to free DuUeCfg
9492 * Function : freeDuUeCfg
9494 * Functionality: Function to free DuUeCfg
9496 * @params[in] DuUeCfg *ueCfg
9499 * ****************************************************************/
9500 void freeDuUeCfg(UeCtxtActionType actionType, DuUeCfg *ueCfg)
9504 SpCellConfig_t *spCellCfg = NULLP;
9505 ServingCellConfig_t *srvCellCfg = NULLP;
9506 BWP_DownlinkDedicated_t *dlBwp = NULLP;
9507 MAC_CellGroupConfig_t *macCellGrpCfg = NULLP;
9508 PhysicalCellGroupConfig_t *phyCellGrpCfg = NULLP;
9509 struct CellGroupConfigRrc__rlc_BearerToAddModList *rlcBearerList = NULLP;
9510 struct RLC_Config *rlcConfig = NULLP;
9511 struct LogicalChannelConfig *macLcConfig = NULLP;
9512 struct SchedulingRequestConfig *schedulingRequestConfig = NULLP;
9513 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqList = NULLP;
9514 struct TAG_Config *tagConfig = NULLP;
9515 struct TAG_Config__tag_ToAddModList *tagList = NULLP;
9516 struct MAC_CellGroupConfig__phr_Config *phrConfig = NULLP;
9517 struct ServingCellConfig__pdsch_ServingCellConfig *pdschCfg = NULLP;
9518 CellGroupConfigRrc_t *cellGrpCfg = ueCfg->cellGrpCfg;
9520 if(ueCfg->ueNrCapability)
9522 freeAperDecodeUeNrCapability(ueCfg->ueNrCapability);
9523 DU_FREE(ueCfg->ueNrCapability, sizeof(UE_NR_Capability_t));
9524 ueCfg->ueNrCapability = NULLP;
9527 if(ueCfg->cellGrpCfg)
9529 rlcBearerList = cellGrpCfg->rlc_BearerToAddModList;
9532 if(rlcBearerList->list.array)
9534 for(arrIdx=0; arrIdx<rlcBearerList->list.count; arrIdx++)
9536 if(rlcBearerList->list.array[arrIdx])
9538 rlcConfig = rlcBearerList->list.array[arrIdx]->rlc_Config;
9539 macLcConfig = rlcBearerList->list.array[arrIdx]->mac_LogicalChannelConfig;
9541 if(rlcBearerList->list.array[arrIdx]->servedRadioBearer)
9543 free(rlcBearerList->list.array[arrIdx]->servedRadioBearer);
9547 if(rlcConfig->choice.am)
9549 free(rlcConfig->choice.am->ul_AM_RLC.sn_FieldLength);
9550 free(rlcConfig->choice.am->dl_AM_RLC.sn_FieldLength);
9551 free(rlcConfig->choice.am);
9553 free(rlcBearerList->list.array[arrIdx]->rlc_Config);
9557 if(macLcConfig->ul_SpecificParameters)
9559 free(macLcConfig->ul_SpecificParameters->schedulingRequestID);
9560 free(macLcConfig->ul_SpecificParameters->logicalChannelGroup);
9561 free(macLcConfig->ul_SpecificParameters);
9563 free(rlcBearerList->list.array[arrIdx]->mac_LogicalChannelConfig);
9565 free(rlcBearerList->list.array[arrIdx]);
9568 free(rlcBearerList->list.array);
9570 free(cellGrpCfg->rlc_BearerToAddModList);
9573 macCellGrpCfg = cellGrpCfg->mac_CellGroupConfig;
9576 schedulingRequestConfig = macCellGrpCfg->schedulingRequestConfig;
9577 if(schedulingRequestConfig)
9579 schReqList = schedulingRequestConfig->schedulingRequestToAddModList;
9582 if(schReqList->list.array)
9584 for(arrIdx=0;arrIdx<schReqList->list.count; arrIdx++)
9586 if(schReqList->list.array[arrIdx])
9588 free(schReqList->list.array[arrIdx]->sr_ProhibitTimer);
9589 free(schReqList->list.array[arrIdx]);
9592 free(schReqList->list.array);
9594 free(schedulingRequestConfig->schedulingRequestToAddModList);
9596 free(macCellGrpCfg->schedulingRequestConfig);
9598 if(macCellGrpCfg->bsr_Config)
9600 free(macCellGrpCfg->bsr_Config);
9602 tagConfig = macCellGrpCfg->tag_Config;
9605 tagList = tagConfig->tag_ToAddModList;
9608 if(tagList->list.array)
9610 for(arrIdx=0; arrIdx<tagList->list.count; arrIdx++)
9612 free(tagList->list.array[arrIdx]);
9614 free(tagList->list.array);
9616 free(tagConfig->tag_ToAddModList);
9621 phrConfig = macCellGrpCfg->phr_Config;
9624 free(phrConfig->choice.setup);
9628 free(macCellGrpCfg);
9631 phyCellGrpCfg = cellGrpCfg->physicalCellGroupConfig;
9634 free(phyCellGrpCfg->p_NR_FR1);
9635 free(phyCellGrpCfg);
9638 spCellCfg = cellGrpCfg->spCellConfig;
9641 if(spCellCfg->servCellIndex)
9643 if(spCellCfg->rlmInSyncOutOfSyncThreshold)
9645 if(spCellCfg->spCellConfigDedicated)
9647 srvCellCfg = spCellCfg->spCellConfigDedicated;
9648 if(srvCellCfg->initialDownlinkBWP)
9650 dlBwp = srvCellCfg->initialDownlinkBWP;
9651 if(srvCellCfg->firstActiveDownlinkBWP_Id)
9653 if(srvCellCfg->defaultDownlinkBWP_Id)
9655 if(srvCellCfg->uplinkConfig)
9658 if(srvCellCfg->pdsch_ServingCellConfig)
9661 srvCellCfg->pdsch_ServingCellConfig;
9662 if(pdschCfg->choice.setup)
9665 free(pdschCfg->choice.setup->nrofHARQ_ProcessesForPDSCH);
9666 free(pdschCfg->choice.setup);
9669 free(srvCellCfg->pdsch_ServingCellConfig);
9672 freeAperDecodeinitialUplinkBWPConfig(srvCellCfg->uplinkConfig);
9673 free(srvCellCfg->uplinkConfig);
9675 free(srvCellCfg->defaultDownlinkBWP_Id);
9678 free(srvCellCfg->firstActiveDownlinkBWP_Id);
9680 if(dlBwp->pdcch_Config)
9682 if(dlBwp->pdsch_Config)
9684 freeAperDecodeBWPDlDedPdschConfig(dlBwp);
9685 free(dlBwp->pdsch_Config);
9687 freeAperDecodeBWPDlDedPdcchConfig(dlBwp);
9688 free(dlBwp->pdcch_Config);
9690 free(srvCellCfg->initialDownlinkBWP);
9693 free(spCellCfg->spCellConfigDedicated);
9695 free(spCellCfg->rlmInSyncOutOfSyncThreshold);
9697 free(spCellCfg->servCellIndex);
9701 DU_FREE(ueCfg->cellGrpCfg, sizeof(CellGroupConfigRrc_t));
9702 ueCfg->cellGrpCfg = NULLP;
9707 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, ueCfg->ambrCfg, sizeof(AmbrCfg));
9710 if(actionType != UE_CTXT_CFG_QUERY)
9712 for(lcIdx = 0; lcIdx < ueCfg->numRlcLcs; lcIdx++)
9714 freeRlcLcCfg(&ueCfg->rlcLcCfg[lcIdx]);
9718 for(lcIdx = 0; lcIdx < ueCfg->numMacLcs; lcIdx++)
9720 freeMacLcCfg(&ueCfg->macLcCfg[lcIdx]);
9723 for(lcIdx = 0; lcIdx < ueCfg->numDrb; lcIdx++)
9725 DU_FREE(ueCfg->upTnlInfo[lcIdx].tnlCfg1, sizeof(GtpTnlCfg));
9729 /*******************************************************************
9731 * @brief Function to free UecontextSetupDb
9735 * Function : freeF1UeDb
9737 * Functionality: Function to free UecontextSetupDb
9739 * @params[in] UecontextSetupDb *
9742 * ****************************************************************/
9744 void freeF1UeDb(F1UeContextSetupDb *f1UeDb)
9747 if(f1UeDb->dlRrcMsg)
9749 if(f1UeDb->dlRrcMsg->rrcMsgPdu)
9751 //DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL,\
9752 f1UeDb->dlRrcMsg->rrcMsgPdu, f1UeDb->dlRrcMsg->rrcMsgSize);
9754 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
9756 freeDuUeCfg(f1UeDb->actionType, &f1UeDb->duUeCfg);
9757 memset(f1UeDb, 0, sizeof(F1UeContextSetupDb));
9758 DU_FREE(f1UeDb, sizeof(F1UeContextSetupDb));
9761 /*******************************************************************
9763 * @brief Function to build Am cfg Info
9767 * Function : extractRlcAmCfg
9769 * Functionality: Function to build Am cfg Info
9771 * @params[in] AmBearerCfg *
9774 * @return ROK/RFAILED
9776 * ****************************************************************/
9778 void extractRlcAmCfg(AmBearerCfg *amCfgToSet, struct RLC_Config__am *rlcAmCfg)
9783 if(rlcAmCfg->dl_AM_RLC.sn_FieldLength)
9785 amCfgToSet->ulAmCfg.snLenUl = covertAmSnLenFromRrcEnumToIntEnum(*(rlcAmCfg->dl_AM_RLC.sn_FieldLength));
9786 /*TODO: Check the timer value when sent by real CU */
9787 amCfgToSet->ulAmCfg.reAssemTmr = convertReasmblTmrEnumToValue(rlcAmCfg->dl_AM_RLC.t_Reassembly);
9788 amCfgToSet->ulAmCfg.statProhTmr = convertProhibitTmrEnumToValue(rlcAmCfg->dl_AM_RLC.t_StatusProhibit);
9792 if(rlcAmCfg->ul_AM_RLC.sn_FieldLength)
9794 amCfgToSet->dlAmCfg.snLenDl = covertAmSnLenFromRrcEnumToIntEnum(*(rlcAmCfg->ul_AM_RLC.sn_FieldLength));
9795 amCfgToSet->dlAmCfg.pollRetxTmr = covertPollRetxTmrEnumToValue(rlcAmCfg->ul_AM_RLC.t_PollRetransmit);
9796 amCfgToSet->dlAmCfg.pollPdu = covertPollPduEnumToValue(rlcAmCfg->ul_AM_RLC.pollPDU);
9797 amCfgToSet->dlAmCfg.pollByte = covertPollByteEnumToValue(rlcAmCfg->ul_AM_RLC.pollByte);
9798 amCfgToSet->dlAmCfg.maxRetxTh = covertMaxRetxEnumToValue(rlcAmCfg->ul_AM_RLC.maxRetxThreshold);
9803 /*******************************************************************
9805 * @brief Function to build Um Bi Info
9809 * Function : extractRlcUmBiCfg
9811 * Functionality: Function to build Um Bi Info
9813 * @params[in] UmBiDirBearerCfg *
9816 * @return ROK/RFAILED
9818 * ****************************************************************/
9820 void extractRlcUmBiCfg(UmBiDirBearerCfg *umBiCfgToSet, struct RLC_Config__um_Bi_Directional *rlcBiCfg)
9824 /* UL UM BI DIR Cfg */
9825 if(rlcBiCfg->dl_UM_RLC.sn_FieldLength)
9827 umBiCfgToSet->ulUmCfg.snLenUlUm = covertUmSnLenFromRrcEnumToIntEnum(*(rlcBiCfg->dl_UM_RLC.sn_FieldLength));
9828 umBiCfgToSet->ulUmCfg.reAssemTmr = convertReasmblTmrEnumToValue(rlcBiCfg->dl_UM_RLC.t_Reassembly);
9831 /* DL UM BI DIR Cfg */
9832 if(rlcBiCfg->ul_UM_RLC.sn_FieldLength)
9833 umBiCfgToSet->dlUmCfg.snLenDlUm = covertUmSnLenFromRrcEnumToIntEnum(*(rlcBiCfg->ul_UM_RLC.sn_FieldLength));
9837 /*******************************************************************
9839 * @brief Function to build Um Ul Info
9843 * Function : extractRlcUmUlCfg
9845 * Functionality: Function to build Um Ul Info
9847 * @params[in] UmUniDirUlBearerCfg *
9850 * @return ROK/RFAILED
9852 * ****************************************************************/
9854 void extractRlcUmUlCfg(UmUniDirUlBearerCfg *umUlCfgToSet, struct RLC_Config__um_Uni_Directional_DL *umUlCfg)
9858 if(umUlCfg->dl_UM_RLC.sn_FieldLength)
9860 umUlCfgToSet->ulUmCfg.snLenUlUm = covertUmSnLenFromRrcEnumToIntEnum(*(umUlCfg->dl_UM_RLC.sn_FieldLength));
9861 umUlCfgToSet->ulUmCfg.reAssemTmr = convertReasmblTmrEnumToValue(umUlCfg->dl_UM_RLC.t_Reassembly);
9866 /*******************************************************************
9868 * @brief Function to build Um Uni Dl Info
9872 * Function : extractRlcUmDlCfg
9874 * Functionality: Function to build Um Uni Dl Info
9876 * @params[in] UmUniDirDlBearerCfg *
9879 * @return ROK/RFAILED
9881 * ****************************************************************/
9882 void extractRlcUmDlCfg(UmUniDirDlBearerCfg *umDlCfgToSet, struct RLC_Config__um_Uni_Directional_UL *umDlCfg)
9886 if(umDlCfg->ul_UM_RLC.sn_FieldLength)
9887 umDlCfgToSet->dlUmCfg.snLenDlUm = covertUmSnLenFromRrcEnumToIntEnum(*(umDlCfg->ul_UM_RLC.sn_FieldLength));
9891 /*******************************************************************
9893 * @brief Function to extractRlcModeCfg
9897 * Function : extractRlcModeCfg
9899 * Functionality: Function to extractRlcModeCfg
9901 * @params[in] RLC_Config_t *
9904 * @return ROK/RFAILED
9906 * ****************************************************************/
9907 void extractRlcModeCfg(uint8_t rlcMode, RlcBearerCfg *rlcDbCfg, RLC_Config_t *lcCfg)
9915 if(lcCfg->choice.am)
9917 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.amCfg, sizeof(AmBearerCfg));
9918 if(rlcDbCfg->u.amCfg)
9919 extractRlcAmCfg(rlcDbCfg->u.amCfg, lcCfg->choice.am);
9923 case RLC_UM_BI_DIRECTIONAL :
9925 if(lcCfg->choice.um_Bi_Directional)
9927 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umBiDirCfg, sizeof(UmBiDirBearerCfg));
9928 if(rlcDbCfg->u.umBiDirCfg)
9929 extractRlcUmBiCfg(rlcDbCfg->u.umBiDirCfg, lcCfg->choice.um_Bi_Directional);
9933 case RLC_UM_UNI_DIRECTIONAL_UL :
9935 if(lcCfg->choice.um_Uni_Directional_DL)
9937 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umUniDirUlCfg, sizeof(UmUniDirUlBearerCfg));
9938 if(rlcDbCfg->u.umUniDirUlCfg)
9939 extractRlcUmUlCfg(rlcDbCfg->u.umUniDirUlCfg, lcCfg->choice.um_Uni_Directional_DL);
9943 case RLC_UM_UNI_DIRECTIONAL_DL :
9945 if(lcCfg->choice.um_Uni_Directional_UL)
9947 DU_ALLOC_SHRABL_BUF(rlcDbCfg->u.umUniDirDlCfg, sizeof(UmUniDirDlBearerCfg));
9948 if(rlcDbCfg->u.umUniDirDlCfg)
9949 extractRlcUmDlCfg(rlcDbCfg->u.umUniDirDlCfg, lcCfg->choice.um_Uni_Directional_UL);
9954 DU_LOG("\nERROR --> DUAPP: Invalid rlcMode %d at extractRlcCfgToAddMod()", rlcMode);
9960 /*******************************************************************
9962 * @brief Function to extract extractUlLcCfg
9966 * Function : extractUlLcCfg
9968 * Functionality: Function to extract extractUlLcCfg
9970 * @params[in] UlLcCfg *f1UlLcCfg, LogicalChannelConfig_t *ulLcCfg
9973 * ****************************************************************/
9975 void extractUlLcCfg(UlLcCfg *f1UlLcCfg, LogicalChannelConfig_t *ulLcCfg)
9979 if(ulLcCfg->ul_SpecificParameters)
9981 f1UlLcCfg->priority = \
9982 ulLcCfg->ul_SpecificParameters->priority;
9983 if(ulLcCfg->ul_SpecificParameters->logicalChannelGroup)
9985 f1UlLcCfg->lcGroup = \
9986 *(ulLcCfg->ul_SpecificParameters->logicalChannelGroup);
9988 if(ulLcCfg->ul_SpecificParameters->schedulingRequestID)
9990 f1UlLcCfg->schReqId = \
9991 *(ulLcCfg->ul_SpecificParameters->schedulingRequestID);
9994 ulLcCfg->ul_SpecificParameters->prioritisedBitRate;
9996 ulLcCfg->ul_SpecificParameters->bucketSizeDuration;
10001 /*******************************************************************
10003 * @brief Function to extract Snssai Cfg Info from CU
10007 * Function : extractDrbSnssaiCfg
10009 * Functionality: Function to extract Drb Snssai Cfg Info from CU
10011 * @params[in] DRB_Information_t *drbInfo, Snssai *snssai
10012 * @return ROK/RFAILED
10014 * ****************************************************************/
10016 uint8_t extractDrbSnssaiCfg(SNSSAI_t *RecvSnssai, Snssai **snssaiToBeShared)
10018 if(!(*snssaiToBeShared))
10020 DU_ALLOC_SHRABL_BUF((*snssaiToBeShared), sizeof(Snssai));
10021 if(snssaiToBeShared == NULLP)
10023 DU_LOG("\nERROR --> DUAPP : extractDrbSnssaiCfg(): Memory failed at allocating for SNSSAI ");
10029 memcpy(&(*snssaiToBeShared)->sst, RecvSnssai->sST.buf, RecvSnssai->sST.size);
10032 memcpy((*snssaiToBeShared)->sd, RecvSnssai->sD->buf, RecvSnssai->sD->size);
10036 DU_LOG("\nERROR --> DUAPP : extractDrbSnssaiCfg(): Received Null pointer of Snssai->SD");
10043 /*******************************************************************
10045 * @brief Function to procRlcLcCfg
10049 * Function : procRlcLcCfg
10051 * Functionality: Function to procRlcLcCfg
10053 * @params[in] rbId, lcId, rbType, rlcMod
10054 * RLC_Config_t *, RlcBearerCfg * ,
10057 * ****************************************************************/
10059 void procRlcLcCfg(uint8_t rbId, uint8_t lcId, uint8_t rbType, uint8_t rlcMode,\
10060 uint8_t configType, RLC_Config_t *f1RlcCfg, RlcBearerCfg *lcCfg, QoSInformation_t *qoSInformation)
10062 DRB_Information_t *drbInfo;
10064 lcCfg->rbId = rbId;
10065 lcCfg->configType = configType;
10067 if(rbType == RB_TYPE_SRB)
10069 lcCfg->rbType = RB_TYPE_SRB;
10070 lcCfg->lcId = rbId;
10071 lcCfg->lcType = LCH_DCCH;
10072 lcCfg->rlcMode = RLC_AM;
10074 else if(rbType == RB_TYPE_DRB)
10076 lcCfg->rbType = RB_TYPE_DRB;
10077 lcCfg->lcId = lcId;
10078 lcCfg->lcType = LCH_DTCH;
10079 lcCfg->rlcMode = rlcMode;
10081 if(f1RlcCfg) /* rlc mode config recived */
10083 extractRlcModeCfg(lcCfg->rlcMode, lcCfg, f1RlcCfg);
10085 if(qoSInformation != NULLP)
10087 if(qoSInformation->present == QoSInformation_PR_choice_extension)
10089 if(qoSInformation->choice.choice_extension->value.present ==\
10090 QoSInformation_ExtIEs__value_PR_DRB_Information)
10092 drbInfo = &qoSInformation->choice.choice_extension->value.choice.DRB_Information;
10093 if(extractDrbSnssaiCfg(&drbInfo->sNSSAI, &lcCfg->snssai) != ROK)
10095 DU_LOG("\nERROR --> DUAPP: Unable to extract Snssai information at procRlcLcCfg()");
10103 /*******************************************************************
10105 * @brief Fills DrbQos Info received by CU
10109 * Function : extractQosInfo
10111 * Functionality: Fills DrbQos Info received by CU
10113 * @params[in] DrbQosInfo *qosToAdd,
10114 * QoSFlowLevelQoSParameters_t *qosFlowCfg
10117 * ****************************************************************/
10119 void extractQosInfo(DrbQosInfo *qosToAdd, QoSFlowLevelQoSParameters_t *qosFlowCfg)
10121 uint8_t qosCntIdx = 0;
10122 ProtocolExtensionContainer_4624P74_t *qosIeExt = NULLP;
10124 qosToAdd->fiveQiType = qosFlowCfg->qoS_Characteristics.present;
10125 qosToAdd->u.nonDyn5Qi.fiveQi =\
10126 qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->fiveQI;
10127 if(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow)
10129 qosToAdd->u.nonDyn5Qi.avgWindow = \
10130 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
10133 if(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume)
10135 qosToAdd->u.nonDyn5Qi.maxDataBurstVol = \
10136 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
10139 if(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->qoSPriorityLevel)
10141 qosToAdd->u.nonDyn5Qi.priorLevel = \
10142 *(qosFlowCfg->qoS_Characteristics.choice.non_Dynamic_5QI->qoSPriorityLevel);
10144 qosToAdd->ngRanRetPri.priorityLevel = \
10145 qosFlowCfg->nGRANallocationRetentionPriority.priorityLevel;
10146 qosToAdd->ngRanRetPri.preEmptionCap = \
10147 qosFlowCfg->nGRANallocationRetentionPriority.pre_emptionCapability;
10148 qosToAdd->ngRanRetPri.preEmptionVul = \
10149 qosFlowCfg->nGRANallocationRetentionPriority.pre_emptionVulnerability;
10150 if(qosFlowCfg->gBR_QoS_Flow_Information)
10152 memcpy(&qosToAdd->grbQosInfo.maxFlowBitRateDl, \
10153 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateDownlink.buf, \
10154 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateDownlink.size);
10155 memcpy(&qosToAdd->grbQosInfo.maxFlowBitRateUl, \
10156 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateUplink.buf, \
10157 qosFlowCfg->gBR_QoS_Flow_Information->maxFlowBitRateUplink.size);
10158 memcpy(&qosToAdd->grbQosInfo.guarFlowBitRateDl,\
10159 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateDownlink.buf, \
10160 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateDownlink.size);
10161 memcpy(&qosToAdd->grbQosInfo.guarFlowBitRateUl,\
10162 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateUplink.buf, \
10163 qosFlowCfg->gBR_QoS_Flow_Information->guaranteedFlowBitRateUplink.size);
10165 /*Extracting PDU_SESSION_ID*/
10166 qosIeExt = (ProtocolExtensionContainer_4624P74_t *)qosFlowCfg->iE_Extensions;
10169 for(qosCntIdx = 0; qosCntIdx < qosIeExt->list.count; qosCntIdx++)
10171 if(qosIeExt->list.array[qosCntIdx]->extensionValue.present == \
10172 QoSFlowLevelQoSParameters_ExtIEs__extensionValue_PR_PDUSessionID)
10174 qosToAdd->pduSessionId = qosIeExt->list.array[qosCntIdx]->extensionValue.choice.PDUSessionID;
10175 DU_LOG("\nDEBUG --> DU_F1AP : extractQosInfo: PDU SessionID:%d",qosToAdd->pduSessionId);
10179 qosToAdd->ulPduSessAggMaxBitRate = 0;
10182 /*******************************************************************
10184 * @brief Function to extract GTP Tunnel Info from CU
10188 * Function : extractUpTnlInfo
10190 * Functionality: Function to extract GTP Tunnel Info from CU
10192 * @params[in] F1AP message
10193 * @return ROK/RFAILED
10195 * ****************************************************************/
10197 uint8_t extractUpTnlInfo(uint8_t drbId, uint8_t configType,\
10198 ULUPTNLInformation_ToBeSetup_List_t *tnlInfo, UpTnlCfg *upTnlInfo)
10201 uint32_t ipv4_du = 0;
10202 GTPTunnel_t *gtpTunnel = NULLP;
10204 upTnlInfo->drbId = drbId;
10205 upTnlInfo->configType = configType;
10207 cmInetAddr((S8*)g_cfg.DU_IPV4_Addr, &ipv4_du);
10209 cmInetAddr((char *)DU_IP_V4_ADDR, &ipv4_du);
10212 for(tnlIdx=0; tnlIdx < tnlInfo->list.count; tnlIdx++)
10214 if(tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.present == UPTransportLayerInformation_PR_gTPTunnel)
10216 if(tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.choice.gTPTunnel)
10218 gtpTunnel = tnlInfo->list.array[tnlIdx]->uLUPTNLInformation.choice.gTPTunnel;
10219 DU_ALLOC(upTnlInfo->tnlCfg1, sizeof(GtpTnlCfg));
10220 if(upTnlInfo->tnlCfg1 == NULLP)
10222 DU_LOG("\nERROR --> F1AP : extractUpTnlInfo: Failed to allocate mmeory for tunnel cfg 1");
10225 bitStringToInt(>pTunnel->transportLayerAddress, &upTnlInfo->tnlCfg1->ulTnlAddress);
10226 upTnlInfo->tnlCfg1->dlTnlAddress = ipv4_du;
10227 if(gtpTunnel->gTP_TEID.size > 0)
10229 teIdStringToInt(gtpTunnel->gTP_TEID.buf, &upTnlInfo->tnlCfg1->teId);
10238 /*******************************************************************
10240 * @brief Function to extract Drb Qos Cfg Info from CU
10244 * Function : extractDrbQosCfg
10246 * Functionality: Function to extract Drb Qos Cfg Info from CU
10248 * @params[in] DRB_Information_t *drbInfo, LcCfg *macLcToAdd
10249 * @return ROK/RFAILED
10251 * ****************************************************************/
10253 uint8_t extractDrbQosCfg(DRB_Information_t *drbInfo, LcCfg *macLcToAdd )
10255 if(!macLcToAdd->drbQos)
10257 DU_ALLOC_SHRABL_BUF(macLcToAdd->drbQos, sizeof(DrbQosInfo));
10258 if(macLcToAdd->drbQos == NULLP)
10260 DU_LOG("\nERROR --> DUAPP:Memory failed at allocating DrbQos at extractDrbQosCfg()");
10265 if(drbInfo->dRB_QoS.qoS_Characteristics.present == QoS_Characteristics_PR_non_Dynamic_5QI)
10267 extractQosInfo(macLcToAdd->drbQos, &drbInfo->dRB_QoS);
10268 macLcToAdd->dlLcCfg.lcp = macLcToAdd->drbQos->ngRanRetPri.priorityLevel;
10270 if(extractDrbSnssaiCfg(&drbInfo->sNSSAI, &macLcToAdd->snssai) != ROK)
10272 DU_LOG("\nERROR --> DUAPP: Unable to extract Snssai information at extractDrbQosCfg()");
10277 /*******************************************************************
10279 * @brief Function to extract DRB info received from CU
10283 * Function : extractDrbCfg
10285 * Functionality: Function to extract DRB info received from CU
10287 * @params[in] F1AP message
10290 * ****************************************************************/
10291 uint8_t extractDrbCfg(DRBs_ToBeSetup_Item_t *drbItem, DRBs_ToBeSetupMod_Item_t *drbSetupModItem,\
10292 DRBs_ToBeModified_Item_t *drbModItem, LcCfg *macLcToAdd, UpTnlCfg *upTnlInfo)
10294 DRB_Information_t *drbInfo = NULLP;
10296 if(drbItem != NULLP)
10298 if(extractUpTnlInfo(drbItem->dRBID, CONFIG_ADD, &drbItem->uLUPTNLInformation_ToBeSetup_List, upTnlInfo) != ROK)
10300 DU_LOG("\nERROR --> DUAPP : Failed to extract tunnel Cfg at extractDrbCfg()");
10303 if(drbItem->qoSInformation.present == QoSInformation_PR_choice_extension)
10305 if(drbItem->qoSInformation.choice.choice_extension->value.present == QoSInformation_ExtIEs__value_PR_DRB_Information)
10307 drbInfo = &drbItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information;
10308 if(extractDrbQosCfg(drbInfo , macLcToAdd) != ROK)
10310 DU_LOG("\nERROR --> DUAPP : Failed to extract qos Cfg at extractDrbCfg()");
10316 else if(drbSetupModItem != NULLP)
10318 if(extractUpTnlInfo(drbSetupModItem->dRBID, CONFIG_ADD, &drbSetupModItem->uLUPTNLInformation_ToBeSetup_List,\
10321 DU_LOG("\nERROR --> DUAPP : Failed to extract tunnel Cfg at extractDrbCfg()");
10324 if(drbSetupModItem->qoSInformation.present == QoSInformation_PR_choice_extension)
10326 if(drbSetupModItem->qoSInformation.choice.choice_extension->value.present ==\
10327 QoSInformation_ExtIEs__value_PR_DRB_Information)
10329 drbInfo = &drbSetupModItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information;
10330 if(extractDrbQosCfg(drbInfo , macLcToAdd) != ROK)
10332 DU_LOG("\nERROR --> DUAPP : Failed to extract qos Cfg at extractDrbCfg()");
10339 else if(drbModItem != NULLP)
10341 if(extractUpTnlInfo(drbModItem->dRBID, CONFIG_MOD, &drbModItem->uLUPTNLInformation_ToBeSetup_List,\
10344 DU_LOG("\nERROR --> DUAPP : Failed to extract tunnel Cfg at extractDrbCfg()");
10347 if(drbModItem->qoSInformation != NULLP)
10349 if(drbModItem->qoSInformation->present == QoSInformation_PR_choice_extension)
10351 if(drbModItem->qoSInformation->choice.choice_extension->value.present ==\
10352 QoSInformation_ExtIEs__value_PR_DRB_Information)
10354 drbInfo = &drbModItem->qoSInformation->choice.choice_extension->value.choice.DRB_Information;
10355 if(extractDrbQosCfg(drbInfo , macLcToAdd) != ROK)
10357 DU_LOG("\nERROR --> DUAPP : Failed to extract qos Cfg at extractDrbCfg()");
10368 /*******************************************************************
10370 * @brief Function to extract RB info received from CU
10374 * Function : extractMacRbCfg
10376 * Functionality: Function to extract RB info received from CU
10378 * @params[in] F1AP message
10379 * @return ROK/RFAILED
10381 * ****************************************************************/
10383 uint8_t extractMacRbCfg(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbCfg,\
10384 DRBs_ToBeSetupMod_Item_t *drbSetupModCfg, DRBs_ToBeModified_Item_t *drbModCfg, LogicalChannelConfig_t *ulLcCfg, LcCfg *lcCfg, UpTnlCfg *upTnlInfo)
10386 if(drbCfg != NULLP)
10388 if(extractDrbCfg(drbCfg, NULL, NULL, lcCfg, upTnlInfo) != ROK)
10390 DU_LOG("ERROR --> F1AP : Failed to build Drb Qos at extractMacRbCfg()");
10394 else if(drbSetupModCfg != NULLP)
10396 if(extractDrbCfg(NULL, drbSetupModCfg, NULL, lcCfg, upTnlInfo) != ROK)
10398 DU_LOG("ERROR --> F1AP : Failed to build Drb Qos at extractMacRbCfg()");
10402 else if(drbModCfg != NULLP)
10404 if(extractDrbCfg(NULL, NULL, drbModCfg, lcCfg, upTnlInfo) != ROK)
10406 DU_LOG("ERROR --> F1AP : Failed to build Drb Qos at extractMacRbCfg()");
10412 lcCfg->drbQos = NULLP;
10413 lcCfg->snssai = NULLP;
10414 if(lcCfg->lcId == SRB2_LCID)
10415 lcCfg->dlLcCfg.lcp = LC_PRIORITY_3;
10417 lcCfg->dlLcCfg.lcp = LC_PRIORITY_1;
10421 lcCfg->ulLcCfgPres = true;
10422 extractUlLcCfg(&lcCfg->ulLcCfg, ulLcCfg);
10425 lcCfg->ulLcCfgPres = false;
10429 /*******************************************************************
10431 * @brief Function processing LC config info received from CU
10435 * Function : procMacLcCfg
10437 * Functionality: Function processing LC config info received from CU
10439 * @params[in] F1AP message
10440 * @return ROK/RFAILED
10442 * ****************************************************************/
10444 uint8_t procMacLcCfg(uint8_t lcId, uint8_t rbType, uint8_t configType, DRBs_ToBeSetup_Item_t *drbItem,\
10445 DRBs_ToBeSetupMod_Item_t *drbSetupModItem, DRBs_ToBeModified_Item_t *drbModItem, LogicalChannelConfig_t *ulLcCfg,\
10446 LcCfg *lcCfg, UpTnlCfg *upTnlInfo)
10450 lcCfg->lcId = lcId;
10451 lcCfg->configType = configType;
10452 if(rbType == RB_TYPE_SRB)
10454 ret = extractMacRbCfg(lcId, NULL, NULL, NULL, ulLcCfg, lcCfg, NULL);
10456 else if(rbType == RB_TYPE_DRB)
10458 if(drbItem != NULL)
10459 ret = extractMacRbCfg(lcId, drbItem, NULL, NULL, ulLcCfg, lcCfg, upTnlInfo);
10460 else if(drbSetupModItem != NULL)
10461 ret = extractMacRbCfg(lcId, NULL, drbSetupModItem, NULL, ulLcCfg, lcCfg, upTnlInfo);
10462 else if(drbModItem != NULL)
10463 ret = extractMacRbCfg(lcId, NULL, NULL, drbModItem, ulLcCfg, lcCfg, upTnlInfo);
10468 /*******************************************************************
10470 * @brief Function to extract Rlc cfg To Add/Mod in CellGrp Info
10474 * Function : extractRlcCfgToAddMod
10476 * Functionality: Function to extract Rlc cfg To Add/Mod in CellGrp Info
10478 * @params[in] CellGroupConfigRrc__rlc_BearerTo pointer
10480 * @return ROK/RFAILED
10482 * ****************************************************************/
10484 uint8_t extractRlcCfgToAddMod(struct CellGroupConfigRrc__rlc_BearerToAddModList *lcCfg, DuUeCfg *ueCfgDb)
10486 uint8_t idx, rbId, lcId, rlcMode, rbType;
10487 RLC_Config_t *f1RlcCfg = NULLP;
10488 LogicalChannelConfig_t *macUlLcCfg = NULLP;
10490 for(idx = 0; idx < lcCfg->list.count; idx++)
10492 lcId = lcCfg->list.array[idx]->logicalChannelIdentity;
10493 if(lcCfg->list.array[idx]->servedRadioBearer)
10495 /* RadioBearer for SRB/DRB */
10496 if(lcCfg->list.array[idx]->servedRadioBearer->present ==\
10497 RLC_BearerConfig__servedRadioBearer_PR_srb_Identity)
10499 rbId = lcCfg->list.array[idx]->servedRadioBearer->choice.srb_Identity;
10500 rbType = RB_TYPE_SRB;
10502 else if(lcCfg->list.array[idx]->servedRadioBearer->present ==\
10503 RLC_BearerConfig__servedRadioBearer_PR_drb_Identity)
10505 rbId = lcCfg->list.array[idx]->servedRadioBearer->choice.drb_Identity;
10506 rbType = RB_TYPE_DRB;
10510 DU_LOG("\nERROR --> No components present in Bearer config to ADD/MOD");
10513 /* MAC UL LC Config */
10514 if(lcCfg->list.array[idx]->mac_LogicalChannelConfig)
10516 macUlLcCfg = lcCfg->list.array[idx]->mac_LogicalChannelConfig;
10521 DU_LOG("\nERROR --> DUAPP: Received RadioBearer config is NULL");
10524 /* RLC Mode Config */
10525 if(lcCfg->list.array[idx]->rlc_Config)
10527 rlcMode = lcCfg->list.array[idx]->rlc_Config->present;
10528 f1RlcCfg = lcCfg->list.array[idx]->rlc_Config;
10531 /* Filling RLC/MAC Config*/
10532 memset(&ueCfgDb->macLcCfg[idx], 0, sizeof(LcCfg));
10533 memset(&ueCfgDb->rlcLcCfg[idx], 0, sizeof(RlcBearerCfg));
10534 procRlcLcCfg(rbId, lcId, rbType, rlcMode, CONFIG_UNKNOWN, f1RlcCfg, &(ueCfgDb->rlcLcCfg[idx]), NULLP);
10535 if(procMacLcCfg(lcId, rbType, CONFIG_UNKNOWN, NULL, NULL, NULL, macUlLcCfg, &ueCfgDb->macLcCfg[idx], NULL) != ROK)
10537 DU_LOG("\nERROR --> DU APP : Failed while filling MAC LC config at extractRlcCfgToAddMod()");
10540 (ueCfgDb->numRlcLcs)++;
10541 (ueCfgDb->numMacLcs)++;
10542 DU_LOG("\nDEBUG -> DUAPP: extractRlcCfgToAddMod:RBType:%d, DrbID: %d,lcId:%d, [RLC,MAC,NumDrb]:[%x,%x,%x]",\
10543 rbType, rbId, lcId, ueCfgDb->numRlcLcs, ueCfgDb->numMacLcs, ueCfgDb->numDrb);
10545 //TODO: To send the failure cause in UeContextSetupRsp
10549 /*******************************************************************
10551 * @brief DeAlloc pdsch serv cell config info
10555 * Function : freeMacPdschServCellInfo
10557 * Functionality: DeAlloc pdsch serv cell config info
10559 * @params[in] PdschServCellCfg pointer
10562 * ****************************************************************/
10564 void freeMacPdschServCellInfo(PdschServCellCfg *pdsch)
10566 if(pdsch->xOverhead)
10568 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->xOverhead, sizeof(PdschXOverhead));
10570 if(pdsch->codeBlkGrpFlushInd)
10572 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->codeBlkGrpFlushInd, sizeof(bool));
10574 if(pdsch->maxCodeBlkGrpPerTb)
10576 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
10578 if(pdsch->maxMimoLayers)
10580 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, pdsch->maxMimoLayers, sizeof(uint8_t));
10584 /*******************************************************************
10586 * @brief Free Serving cell Info
10590 * Function : freeMacServingCellInfo
10592 * Functionality: Free Serving cell Info
10594 * @params[in] ServCellCfgInfo *srvCellCfg
10597 * ****************************************************************/
10598 void freeMacServingCellInfo(ServCellCfgInfo *srvCellCfg)
10600 uint8_t timeDomRsrcIdx;
10602 if(srvCellCfg->initDlBwp.pdschPresent)
10604 for(timeDomRsrcIdx = 0; timeDomRsrcIdx < srvCellCfg->initDlBwp.pdschCfg.numTimeDomRsrcAlloc; timeDomRsrcIdx++)
10606 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, \
10607 srvCellCfg->initDlBwp.pdschCfg.timeDomRsrcAllociList[timeDomRsrcIdx].k0, sizeof(uint8_t));
10611 freeMacPdschServCellInfo(&srvCellCfg->pdschServCellCfg);
10612 if(srvCellCfg->bwpInactivityTmr)
10614 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, srvCellCfg->bwpInactivityTmr, sizeof(uint8_t));
10617 if(srvCellCfg->initUlBwp.pucchPresent)
10619 DU_FREE_SHRABL_BUF(DU_APP_MEM_REGION, DU_POOL, srvCellCfg->initUlBwp.pucchCfg.dlDataToUlAck, sizeof(PucchDlDataToUlAck));
10623 /*******************************************************************
10625 * @brief Free cell Grp Cfg Info
10629 * Function : freeUeReCfgCellGrpInfo
10631 * Functionality: Free cell Grp Cfg Info
10633 * @params[in] MacUeCfg* duUeCfg
10636 * ****************************************************************/
10638 void freeUeReCfgCellGrpInfo(MacUeCfg *macUeCfg)
10640 freeMacServingCellInfo(&macUeCfg->spCellCfg.servCellCfg);
10643 /*******************************************************************
10645 * @brief Fills Reconfig SchReqReConfig
10649 * Function : extractSchReqReConfig
10651 * Functionality: Fills Reconfig SchReqReConfig
10653 * @params[in] SchedulingRequestConfig_t *cuSchedReq
10654 * SchedReqCfg* macSchedReq
10657 * ****************************************************************/
10658 void extractSchReqReConfig(SchedulingRequestConfig_t *cuSchedReq, SchedReqCfg *macSchedReq)
10660 uint8_t schReqIdx = 0;
10661 struct SchedulingRequestConfig__schedulingRequestToAddModList *schReqListToAdd = NULLP;
10662 struct SchedulingRequestConfig__schedulingRequestToReleaseList *schReqListToRel = NULLP;
10664 if(cuSchedReq->schedulingRequestToAddModList)
10666 schReqListToAdd = cuSchedReq->schedulingRequestToAddModList;
10667 if(schReqListToAdd->list.count)
10669 macSchedReq->addModListCount = schReqListToAdd->list.count;
10670 for(schReqIdx = 0; schReqIdx < schReqListToAdd->list.count; schReqIdx++)
10672 macSchedReq->addModList[schReqIdx].schedReqId = \
10673 schReqListToAdd->list.array[schReqIdx]->schedulingRequestId;
10674 macSchedReq->addModList[schReqIdx].srProhibitTmr = \
10675 *(schReqListToAdd->list.array[schReqIdx]->sr_ProhibitTimer);
10676 macSchedReq->addModList[schReqIdx].srTransMax =\
10677 schReqListToAdd->list.array[schReqIdx]->sr_TransMax;
10681 /* Scheduling Req To release */
10682 if(cuSchedReq->schedulingRequestToReleaseList)
10684 schReqListToRel = cuSchedReq->schedulingRequestToReleaseList;
10685 if(schReqListToRel->list.count)
10687 macSchedReq->relListCount = schReqListToRel->list.count;
10688 for(schReqIdx = 0; schReqIdx < schReqListToRel->list.count; schReqIdx++)
10690 macSchedReq->relList[schReqIdx] = \
10691 *schReqListToRel->list.array[schReqIdx];
10697 /*******************************************************************
10699 * @brief Fills TagReconfig
10703 * Function : extractTagReconfig
10705 * Functionality: Fills extractTagReconfig
10707 * @params[in] TAG_Config_t *cuTagCfg
10708 * TagCfg *macTagCfg
10711 * ****************************************************************/
10713 void extractTagReconfig(TAG_Config_t *cuTagCfg, TagCfg *macTagCfg)
10715 uint8_t tagIdx = 0;
10716 struct TAG_Config__tag_ToAddModList *tagListToAddMod = NULLP;
10717 struct TAG_Config__tag_ToReleaseList *tagListToRel = NULLP;
10719 /* Tag config to AddMod */
10720 if(cuTagCfg->tag_ToAddModList)
10722 tagListToAddMod = cuTagCfg->tag_ToAddModList;
10723 if(tagListToAddMod->list.count)
10725 macTagCfg->addModListCount = tagListToAddMod->list.count;
10726 for(tagIdx = 0; tagIdx < tagListToAddMod->list.count; tagIdx++)
10728 macTagCfg->addModList[tagIdx].tagId =\
10729 tagListToAddMod->list.array[tagIdx]->tag_Id;
10730 macTagCfg->addModList[tagIdx].timeAlignTimer = \
10732 tagListToAddMod->list.array[tagIdx]->timeAlignmentTimer;
10736 /* Tag config to release */
10737 if(cuTagCfg->tag_ToReleaseList)
10739 tagListToRel = cuTagCfg->tag_ToReleaseList;
10740 if(tagListToRel->list.count)
10742 macTagCfg->relListCount = tagListToRel->list.count;
10743 for(tagIdx = 0; tagIdx < tagListToRel->list.count; tagIdx++)
10745 macTagCfg->relList[tagIdx] = *tagListToRel->list.array[tagIdx];
10751 /*******************************************************************
10753 * @brief Fills PdcchCfg received by CU
10757 * Function : extractPdcchCfg
10759 * Functionality: Fills PdcchCfg received by CU
10761 * @params[in] PDCCH_Config_t *cuPdcchCfg,
10762 * PdcchConfig *duPdcchCfg
10765 * ****************************************************************/
10767 void extractPdcchCfg(PDCCH_Config_t *cuPdcchCfg, PdcchConfig *macPdcchCfg)
10769 uint8_t cRsetIdx = 0;
10770 uint8_t srchSpcIdx = 0;
10772 struct PDCCH_Config__controlResourceSetToAddModList *cRsetToAddModList = NULLP;
10773 struct PDCCH_Config__controlResourceSetToReleaseList *cRsetToRelList = NULLP;
10774 struct PDCCH_Config__searchSpacesToAddModList *srchSpcToAddModList = NULLP;
10775 struct PDCCH_Config__searchSpacesToReleaseList *srchSpcToRelList = NULLP;
10778 /* Control Resource Set To Add/Mod List */
10779 if(cuPdcchCfg->controlResourceSetToAddModList)
10781 cRsetToAddModList = cuPdcchCfg->controlResourceSetToAddModList;
10782 if(cRsetToAddModList->list.count)
10784 macPdcchCfg->numCRsetToAddMod = cRsetToAddModList->list.count;
10785 for(cRsetIdx = 0; cRsetIdx < cRsetToAddModList->list.count; cRsetIdx++)
10787 macPdcchCfg->cRSetToAddModList[cRsetIdx].cRSetId = \
10788 cRsetToAddModList->list.array[cRsetIdx]->controlResourceSetId;
10789 //freqDomRsrcBitStringToInt(&cRsetToAddModList->list.array[cRsetIdx]->frequencyDomainResources,\
10790 macPdcchCfg->cRSetToAddModList[cRsetIdx].freqDomainRsrc);
10791 memcpy(macPdcchCfg->cRSetToAddModList[cRsetIdx].freqDomainRsrc, \
10792 cRsetToAddModList->list.array[cRsetIdx]->frequencyDomainResources.buf,
10793 cRsetToAddModList->list.array[cRsetIdx]->frequencyDomainResources.size);
10795 macPdcchCfg->cRSetToAddModList[cRsetIdx].duration = \
10796 cRsetToAddModList->list.array[cRsetIdx]->duration;
10798 macPdcchCfg->cRSetToAddModList[cRsetIdx].cceRegMappingType = \
10799 cRsetToAddModList->list.array[cRsetIdx]->cce_REG_MappingType.present;
10800 if(macPdcchCfg->cRSetToAddModList[cRsetIdx].cceRegMappingType == CCE_REG_MAPPINGTYPE_PR_INTERLEAVED)
10802 //TODO: handle the case for Interleaved
10804 macPdcchCfg->cRSetToAddModList[cRsetIdx].precoderGranularity = \
10805 cRsetToAddModList->list.array[cRsetIdx]->precoderGranularity;
10806 if(cRsetToAddModList->list.array[cRsetIdx]->pdcch_DMRS_ScramblingID)
10808 macPdcchCfg->cRSetToAddModList[cRsetIdx].dmrsScramblingId= \
10809 *(cRsetToAddModList->list.array[cRsetIdx]->pdcch_DMRS_ScramblingID);
10814 /* Control Resource Set To Release List */
10815 if(cuPdcchCfg->controlResourceSetToReleaseList)
10817 cRsetToRelList = cuPdcchCfg->controlResourceSetToReleaseList;
10818 if(cRsetToRelList->list.count)
10820 macPdcchCfg->numCRsetToRel = cRsetToRelList->list.count;
10821 for(cRsetIdx = 0; cRsetIdx < cRsetToRelList->list.count; cRsetIdx++)
10823 macPdcchCfg->cRSetToRelList[cRsetIdx] = *(cRsetToRelList->list.array[cRsetIdx]);
10828 /* Search space To Add/Mod List */
10829 if(cuPdcchCfg->searchSpacesToAddModList)
10831 srchSpcToAddModList = cuPdcchCfg->searchSpacesToAddModList;
10832 if(srchSpcToAddModList->list.count)
10834 macPdcchCfg->numSearchSpcToAddMod = srchSpcToAddModList->list.count;
10835 for(srchSpcIdx = 0; srchSpcIdx < srchSpcToAddModList->list.count; srchSpcIdx++)
10837 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceId =\
10838 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceId;
10839 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].cRSetId =\
10840 *(srchSpcToAddModList->list.array[srchSpcIdx]->controlResourceSetId);
10841 if(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSlotPeriodicityAndOffset)
10843 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].mSlotPeriodicityAndOffset =\
10844 srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSlotPeriodicityAndOffset->present;
10846 if(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSymbolsWithinSlot)
10848 bitStringToInt(srchSpcToAddModList->list.array[srchSpcIdx]->monitoringSymbolsWithinSlot,\
10849 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].mSymbolsWithinSlot);
10851 if(srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates)
10853 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel1 = \
10854 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel1;
10855 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel2 = \
10856 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel2;
10857 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel4 = \
10858 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel4;
10860 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel8 = \
10861 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel8;
10863 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].numCandidatesAggLevel16 = \
10864 srchSpcToAddModList->list.array[srchSpcIdx]->nrofCandidates->aggregationLevel16;
10866 if(srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType)
10868 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceType =\
10869 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType->present;
10870 if(macPdcchCfg->searchSpcToAddModList[srchSpcIdx].searchSpaceType == SEARCHSPACETYPE_PR_UE_SPECIFIC)
10872 macPdcchCfg->searchSpcToAddModList[srchSpcIdx].ueSpecificDciFormat =\
10873 srchSpcToAddModList->list.array[srchSpcIdx]->searchSpaceType->choice.ue_Specific->dci_Formats;
10880 /* Search space To Rel List */
10881 if(cuPdcchCfg->searchSpacesToReleaseList)
10883 srchSpcToRelList = cuPdcchCfg->searchSpacesToReleaseList;
10884 if(srchSpcToRelList->list.count)
10886 macPdcchCfg->numSearchSpcToRel = srchSpcToRelList->list.count;
10887 for(srchSpcIdx = 0; srchSpcIdx < srchSpcToRelList->list.count; srchSpcIdx++)
10889 macPdcchCfg->searchSpcToRelList[srchSpcIdx] =\
10890 *(srchSpcToRelList->list.array[srchSpcIdx]);
10896 /*******************************************************************
10898 * @brief Fills PdschCfg received by CU
10902 * Function : extractPdschCfg
10904 * Functionality: Fills PdschCfg received by CU
10906 * @params[in] PDSCH_Config_t *cuPdschCfg = Information which is send by CU,
10907 * which we have stored in F1UeContextSetupDb,
10908 * PdschConfig *macPdschCfg = Used to Store the information which
10909 * needs to send in other layer, as well as this can be the variable
10910 * which stores the information in DuCb,
10911 * PdschConfig *storedPdschCfg = Null in case of sending the
10912 * information to other layer else it will have stored pdsch
10913 * configuration in copyOfmacUeCfg.
10916 * ****************************************************************/
10918 void extractPdschCfg(PDSCH_Config_t *cuPdschCfg, PdschConfig *macPdschCfg, PdschConfig *storedPdschCfg)
10920 uint8_t timeDomIdx;
10921 struct PDSCH_Config__pdsch_TimeDomainAllocationList *timeDomAlloc = NULLP;
10923 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA)
10925 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->present == \
10926 PDSCH_Config__dmrs_DownlinkForPDSCH_MappingTypeA_PR_setup)
10928 if(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup)
10930 macPdschCfg->dmrsDlCfgForPdschMapTypeA.addPos = \
10931 *(cuPdschCfg->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition);
10935 macPdschCfg->resourceAllocType = cuPdschCfg->resourceAllocation;
10936 if(cuPdschCfg->pdsch_TimeDomainAllocationList)
10938 timeDomAlloc = cuPdschCfg->pdsch_TimeDomainAllocationList;
10939 if(timeDomAlloc->present ==\
10940 PDSCH_Config__pdsch_TimeDomainAllocationList_PR_setup)
10942 if(timeDomAlloc->choice.setup)
10944 macPdschCfg->numTimeDomRsrcAlloc = timeDomAlloc->choice.setup->list.count;
10945 for(timeDomIdx = 0; timeDomIdx < timeDomAlloc->choice.setup->list.count; timeDomIdx++)
10947 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0 = NULLP;
10948 if(timeDomAlloc->choice.setup->list.array[timeDomIdx]->k0)
10950 if(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0 == NULL)
10954 if(storedPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0)
10956 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0 =\
10957 storedPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0;
10961 DU_ALLOC_SHRABL_BUF(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0, sizeof(uint8_t));
10966 DU_ALLOC_SHRABL_BUF(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0, sizeof(uint8_t));
10968 if(!macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0)
10970 DU_LOG("\nERROR --> DU APP : Memory allocation failed for k0 at extractPdschCfg()");
10974 *(macPdschCfg->timeDomRsrcAllociList[timeDomIdx].k0) = \
10975 *(timeDomAlloc->choice.setup->list.array[timeDomIdx]->k0);
10977 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].mappingType = \
10978 timeDomAlloc->choice.setup->list.array[timeDomIdx]->mappingType;
10979 macPdschCfg->timeDomRsrcAllociList[timeDomIdx].startSymbolAndLength = \
10980 timeDomAlloc->choice.setup->list.array[timeDomIdx]->startSymbolAndLength;
10985 macPdschCfg->rbgSize = cuPdschCfg->rbg_Size;
10986 if(cuPdschCfg->maxNrofCodeWordsScheduledByDCI)
10987 macPdschCfg->numCodeWordsSchByDci = *(cuPdschCfg->maxNrofCodeWordsScheduledByDCI);
10988 if(cuPdschCfg->prb_BundlingType.present == PDSCH_Config__prb_BundlingType_PR_staticBundling)
10990 macPdschCfg->bundlingType = cuPdschCfg->prb_BundlingType.present;
10991 if(cuPdschCfg->prb_BundlingType.choice.staticBundling)
10993 if(cuPdschCfg->prb_BundlingType.choice.staticBundling->bundleSize)
10995 macPdschCfg->bundlingInfo.StaticBundling.size = \
10996 *(cuPdschCfg->prb_BundlingType.choice.staticBundling->bundleSize);
11000 else if(cuPdschCfg->prb_BundlingType.present == PDSCH_Config__prb_BundlingType_PR_dynamicBundling)
11002 macPdschCfg->bundlingType = cuPdschCfg->prb_BundlingType.present;
11007 /*******************************************************************
11009 * @brief Fills PdschServingCellCfg received by CU
11013 * Function : extractPdschServingCellCfg
11015 * Functionality: Fills PdschCfg received by CU
11017 * @params[in] PDSCH_ServingCellConfig_t *cuPdschSrvCellCfg,
11018 * PdschServCellCfg *macUePdschSrvCellCfg
11019 * @return ROK/RFAILED
11021 * ****************************************************************/
11023 uint8_t extractPdschServingCellCfg(PDSCH_ServingCellConfig_t *cuPdschSrvCellCfg, PdschServCellCfg *macUePdschSrvCellCfg)
11025 if(cuPdschSrvCellCfg->codeBlockGroupTransmission)
11027 if(cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup)
11029 if(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb)
11031 *(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb) = \
11032 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock;
11036 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb, sizeof(MaxCodeBlkGrpPerTB));
11037 if(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb)
11039 *(macUePdschSrvCellCfg->maxCodeBlkGrpPerTb) = \
11040 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->maxCodeBlockGroupsPerTransportBlock;
11044 DU_LOG("\nERROR --> DU APP : Memory allocation failed for maxCodeBlkGrpPerTb at extractPdschServingCellCfg()");
11048 if(macUePdschSrvCellCfg->codeBlkGrpFlushInd)
11050 *(macUePdschSrvCellCfg->codeBlkGrpFlushInd) = \
11051 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->codeBlockGroupFlushIndicator;
11055 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->codeBlkGrpFlushInd , sizeof(bool));
11056 if(macUePdschSrvCellCfg->codeBlkGrpFlushInd)
11058 *(macUePdschSrvCellCfg->codeBlkGrpFlushInd) = \
11059 cuPdschSrvCellCfg->codeBlockGroupTransmission->choice.setup->codeBlockGroupFlushIndicator;
11063 DU_LOG("\nERROR --> DU APP : Memory allocation failed for codeBlkGrpFlushInd at extractPdschServingCellCfg()");
11069 if(cuPdschSrvCellCfg->nrofHARQ_ProcessesForPDSCH)
11071 macUePdschSrvCellCfg->numHarqProcForPdsch = *(cuPdschSrvCellCfg->nrofHARQ_ProcessesForPDSCH);
11073 if(cuPdschSrvCellCfg->ext1)
11075 if(cuPdschSrvCellCfg->ext1->maxMIMO_Layers)
11077 if(macUePdschSrvCellCfg->maxMimoLayers)
11079 *(macUePdschSrvCellCfg->maxMimoLayers) = *(cuPdschSrvCellCfg->ext1->maxMIMO_Layers);
11083 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->maxMimoLayers, sizeof(uint8_t));
11084 if(macUePdschSrvCellCfg->maxMimoLayers)
11086 *(macUePdschSrvCellCfg->maxMimoLayers) = *(cuPdschSrvCellCfg->ext1->maxMIMO_Layers);
11090 DU_LOG("\nERROR --> DU APP : Memory allocation failed for maxMimoLayers at extractPdschServingCellCfg()");
11096 if(cuPdschSrvCellCfg->xOverhead)
11098 if(macUePdschSrvCellCfg->xOverhead)
11100 *(macUePdschSrvCellCfg->xOverhead) = *(cuPdschSrvCellCfg->xOverhead);
11104 DU_ALLOC_SHRABL_BUF(macUePdschSrvCellCfg->xOverhead, sizeof(PdschXOverhead));
11105 if(macUePdschSrvCellCfg->xOverhead)
11107 *(macUePdschSrvCellCfg->xOverhead) = *(cuPdschSrvCellCfg->xOverhead);
11111 DU_LOG("\nERROR --> DU APP : Memory allocation failed for xOverhead at extractPdschServingCellCfg()");
11119 /*******************************************************************
11121 * @brief Fills PuschCfg received by CU
11125 * Function : extractPuschCfg
11127 * Functionality: Fills PuschCfg received by CU
11129 * @params[in] BWP_UplinkDedicated__pusch_Config *cuPuschCfg,
11130 * PuschCfg *macPuschCfg
11133 * ****************************************************************/
11135 void extractPuschCfg(struct BWP_UplinkDedicated__pusch_Config *cuPuschCfg, PuschCfg *macPuschCfg)
11137 uint8_t timeDomIdx = 0;
11138 DMRS_UplinkConfig_t *dmrsUlCfg = NULLP;
11139 struct PUSCH_Config__pusch_TimeDomainAllocationList *timeDomAllocList = NULLP;
11141 if(cuPuschCfg->present == BWP_UplinkDedicated__pusch_Config_PR_setup)
11143 if(cuPuschCfg->choice.setup)
11145 if(cuPuschCfg->choice.setup->dataScramblingIdentityPUSCH)
11147 macPuschCfg->dataScramblingId = \
11148 *(cuPuschCfg->choice.setup->dataScramblingIdentityPUSCH);
11150 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA)
11152 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->present == PUSCH_Config__dmrs_UplinkForPUSCH_MappingTypeA_PR_setup)
11154 if(cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup)
11156 dmrsUlCfg = (cuPuschCfg->choice.setup->dmrs_UplinkForPUSCH_MappingTypeA->choice.setup);
11157 if(dmrsUlCfg->dmrs_AdditionalPosition)
11159 macPuschCfg->dmrsUlCfgForPuschMapTypeA.addPos =\
11160 *(dmrsUlCfg->dmrs_AdditionalPosition);
11162 if(dmrsUlCfg->transformPrecodingDisabled)
11164 if(dmrsUlCfg->transformPrecodingDisabled->scramblingID0)
11166 macPuschCfg->dmrsUlCfgForPuschMapTypeA.transPrecodDisabled.scramblingId0 = \
11167 *(dmrsUlCfg->transformPrecodingDisabled->scramblingID0);
11173 /*Res Alloc Type for UL */
11174 if(cuPuschCfg->choice.setup->resourceAllocation)
11176 macPuschCfg->resourceAllocType = \
11177 cuPuschCfg->choice.setup->resourceAllocation;
11179 if(cuPuschCfg->choice.setup->pusch_TimeDomainAllocationList)
11181 timeDomAllocList = cuPuschCfg->choice.setup->pusch_TimeDomainAllocationList;
11182 if(timeDomAllocList->present == PUSCH_Config__pusch_TimeDomainAllocationList_PR_setup)
11184 if(timeDomAllocList->choice.setup)
11186 macPuschCfg->numTimeDomRsrcAlloc = timeDomAllocList->choice.setup->list.count;
11187 for(timeDomIdx = 0; timeDomIdx <timeDomAllocList->choice.setup->list.count; timeDomIdx++)
11189 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].k2 = \
11190 *(timeDomAllocList->choice.setup->list.array[timeDomIdx]->k2);
11191 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].mappingType = \
11192 timeDomAllocList->choice.setup->list.array[timeDomIdx]->mappingType;
11193 macPuschCfg->timeDomRsrcAllocList[timeDomIdx].startSymbolAndLength = \
11194 timeDomAllocList->choice.setup->list.array[timeDomIdx]->startSymbolAndLength;
11199 if(cuPuschCfg->choice.setup->transformPrecoder)
11200 macPuschCfg->transformPrecoder = *(cuPuschCfg->choice.setup->transformPrecoder);
11205 /*******************************************************************
11207 * @brief Function to fill pucch Power Control
11211 * Function : extractPucchPowerControl
11213 * Functionality: Function to fill pucch Power Control
11215 * @params[in] PucchPowerControl *pwrCtrl,
11216 * struct PUCCH_PowerControl *cuPwrCtrlCfg
11219 * ****************************************************************/
11221 void extractPucchPowerControl(PucchPowerControl *pwrCtrl, struct PUCCH_PowerControl *cuPwrCtrlCfg)
11225 if(cuPwrCtrlCfg->deltaF_PUCCH_f0)
11226 pwrCtrl->deltaF_Format0 = *cuPwrCtrlCfg->deltaF_PUCCH_f0;
11227 if(cuPwrCtrlCfg->deltaF_PUCCH_f1)
11228 pwrCtrl->deltaF_Format1 = *cuPwrCtrlCfg->deltaF_PUCCH_f1;
11229 if(cuPwrCtrlCfg->deltaF_PUCCH_f2)
11230 pwrCtrl->deltaF_Format2 = *cuPwrCtrlCfg->deltaF_PUCCH_f2;
11231 if(cuPwrCtrlCfg->deltaF_PUCCH_f3)
11232 pwrCtrl->deltaF_Format3 = *cuPwrCtrlCfg->deltaF_PUCCH_f3;
11233 if(cuPwrCtrlCfg->deltaF_PUCCH_f4)
11234 pwrCtrl->deltaF_Format4 = *cuPwrCtrlCfg->deltaF_PUCCH_f4;
11235 if(cuPwrCtrlCfg->p0_Set)
11237 pwrCtrl->p0SetCount = cuPwrCtrlCfg->p0_Set->list.count;
11238 for(arrIdx=0; arrIdx < pwrCtrl->p0SetCount; arrIdx++)
11240 pwrCtrl->p0Set[arrIdx].p0PucchId =\
11241 cuPwrCtrlCfg->p0_Set->list.array[arrIdx]->p0_PUCCH_Id;
11242 pwrCtrl->p0Set[arrIdx].p0PucchVal =\
11243 cuPwrCtrlCfg->p0_Set->list.array[arrIdx]->p0_PUCCH_Value;
11246 if(cuPwrCtrlCfg->pathlossReferenceRSs)
11248 pwrCtrl->pathLossRefRSListCount = cuPwrCtrlCfg->pathlossReferenceRSs->list.count;
11249 for(arrIdx = 0; arrIdx < pwrCtrl->pathLossRefRSListCount; arrIdx++)
11251 pwrCtrl->pathLossRefRSList[arrIdx].pathLossRefRSId =\
11252 cuPwrCtrlCfg->pathlossReferenceRSs->list.array[arrIdx]->pucch_PathlossReferenceRS_Id;
11257 /*******************************************************************
11259 * @brief Function to extractResrcSetToAddModList sent by CU
11263 * Function : extractResrcSetToAddModList
11265 * Functionality: Fucntion to extractResrcSetToAddModList
11267 * @params[in] PucchResrcSetCfg pointer,
11268 * struct PUCCH_Config__resourceSetToAddModList pointer
11271 * ****************************************************************/
11273 void extractResrcSetToAddModList(PucchResrcSetCfg *macRsrcSetList, struct PUCCH_Config__resourceSetToAddModList *cuRsrcSetList)
11275 uint8_t arrIdx, rsrcListIdx;
11277 macRsrcSetList->resrcSetToAddModListCount = cuRsrcSetList->list.count;
11278 for(arrIdx = 0; arrIdx < macRsrcSetList->resrcSetToAddModListCount; arrIdx++)
11280 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcSetId =\
11281 cuRsrcSetList->list.array[arrIdx]->pucch_ResourceSetId;
11282 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount =\
11283 cuRsrcSetList->list.array[arrIdx]->resourceList.list.count;
11284 for(rsrcListIdx = 0; rsrcListIdx < macRsrcSetList->resrcSetToAddModList[arrIdx].resrcListCount; rsrcListIdx++)
11286 macRsrcSetList->resrcSetToAddModList[arrIdx].resrcList[rsrcListIdx] =\
11287 *cuRsrcSetList->list.array[arrIdx]->resourceList.list.array[rsrcListIdx];
11290 if(cuRsrcSetList->list.array[arrIdx]->maxPayloadMinus1)
11292 macRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize =\
11293 *cuRsrcSetList->list.array[arrIdx]->maxPayloadMinus1;
11297 macRsrcSetList->resrcSetToAddModList[arrIdx].maxPayLoadSize = 0;
11300 }/* End of extractResrcSetToAddModList */
11302 /*******************************************************************
11304 * @brief Fills extractResrcToAddModList sent by CU
11308 * Function : extractResrcToAddModList
11310 * Functionality: Fills extractResrcToAddModList
11312 * @params[in] PucchResrcCfg pointer,
11313 * struct PUCCH_Config__resourceToAddModList pointer
11314 * @return ROk/RFAILED
11316 * ****************************************************************/
11318 uint8_t extractResrcToAddModList(PucchResrcCfg *macResrcList, struct PUCCH_Config__resourceToAddModList *cuResrcList)
11322 macResrcList->resrcToAddModListCount = cuResrcList->list.count;
11323 for(arrIdx = 0; arrIdx < macResrcList->resrcToAddModListCount; arrIdx++)
11325 macResrcList->resrcToAddModList[arrIdx].resrcId =\
11326 cuResrcList->list.array[arrIdx]->pucch_ResourceId;
11327 macResrcList->resrcToAddModList[arrIdx].startPrb =\
11328 cuResrcList->list.array[arrIdx]->startingPRB;
11329 if(cuResrcList->list.array[arrIdx]->intraSlotFrequencyHopping)
11331 macResrcList->resrcToAddModList[arrIdx].intraFreqHop =\
11332 *cuResrcList->list.array[arrIdx]->intraSlotFrequencyHopping;
11334 if(cuResrcList->list.array[arrIdx]->secondHopPRB)
11336 macResrcList->resrcToAddModList[arrIdx].secondPrbHop =\
11337 *cuResrcList->list.array[arrIdx]->secondHopPRB;
11339 /* PUCCH RSRC FORMAT */
11340 if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format0)
11342 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_0;
11343 if(cuResrcList->list.array[arrIdx]->format.choice.format0)
11345 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0, sizeof(PucchFormat0));
11346 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0 == NULLP)
11348 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format0 in extractResrcToAddModList()");
11351 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->initialCyclicShift =\
11352 cuResrcList->list.array[arrIdx]->format.choice.format0->initialCyclicShift;
11353 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->numSymbols =\
11354 cuResrcList->list.array[arrIdx]->format.choice.format0->nrofSymbols;
11355 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format0->startSymbolIdx =\
11356 cuResrcList->list.array[arrIdx]->format.choice.format0->startingSymbolIndex;
11359 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format1)
11361 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_1;
11362 if(cuResrcList->list.array[arrIdx]->format.choice.format1)
11364 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1, sizeof(PucchFormat1));
11365 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1 == NULLP)
11367 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format1 in extractResrcToAddModList()");
11370 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->initialCyclicShift =\
11371 cuResrcList->list.array[arrIdx]->format.choice.format1->initialCyclicShift;
11372 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->numSymbols =\
11373 cuResrcList->list.array[arrIdx]->format.choice.format1->nrofSymbols;
11374 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->startSymbolIdx =\
11375 cuResrcList->list.array[arrIdx]->format.choice.format1->startingSymbolIndex;
11376 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format1->timeDomOCC =\
11377 cuResrcList->list.array[arrIdx]->format.choice.format1->timeDomainOCC;
11380 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format2)
11382 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_2;
11383 if(cuResrcList->list.array[arrIdx]->format.choice.format2)
11385 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2, sizeof(PucchFormat2_3));
11386 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2 == NULLP)
11388 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format2 in extractResrcToAddModList()");
11391 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->numPrbs =\
11392 cuResrcList->list.array[arrIdx]->format.choice.format2->nrofPRBs;
11393 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->numSymbols =\
11394 cuResrcList->list.array[arrIdx]->format.choice.format2->nrofSymbols;
11395 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format2->startSymbolIdx =\
11396 cuResrcList->list.array[arrIdx]->format.choice.format2->startingSymbolIndex;
11399 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format3)
11401 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_3;
11402 if(cuResrcList->list.array[arrIdx]->format.choice.format3)
11404 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3, sizeof(PucchFormat2_3));
11405 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3 == NULLP)
11407 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format3 in extractResrcToAddModList()");
11410 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->numPrbs =\
11411 cuResrcList->list.array[arrIdx]->format.choice.format3->nrofPRBs;
11412 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->numSymbols =\
11413 cuResrcList->list.array[arrIdx]->format.choice.format3->nrofSymbols;
11414 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format3->startSymbolIdx =\
11415 cuResrcList->list.array[arrIdx]->format.choice.format3->startingSymbolIndex;
11418 else if(cuResrcList->list.array[arrIdx]->format.present == PUCCH_Resource__format_PR_format4)
11420 macResrcList->resrcToAddModList[arrIdx].pucchFormat = PUCCH_FORMAT_4;
11421 if(cuResrcList->list.array[arrIdx]->format.choice.format4)
11423 DU_ALLOC_SHRABL_BUF(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4, sizeof(PucchFormat4));
11424 if(macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4 == NULLP)
11426 DU_LOG("\nERROR --> F1AP : Failed to allocate memory for Format4 in extractResrcToAddModList()");
11429 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->numSymbols =\
11430 cuResrcList->list.array[arrIdx]->format.choice.format4->nrofSymbols;
11431 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->occLen =\
11432 cuResrcList->list.array[arrIdx]->format.choice.format4->occ_Length;
11433 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->occIdx =\
11434 cuResrcList->list.array[arrIdx]->format.choice.format4->occ_Index;
11435 macResrcList->resrcToAddModList[arrIdx].PucchFormat.format4->startSymbolIdx =\
11436 cuResrcList->list.array[arrIdx]->format.choice.format4->startingSymbolIndex;
11442 }/* End of extractResrcToAddModList */
11444 /*******************************************************************
11446 * @brief Fills fillPucchSchedReqPeriodAndOffset sent by CU
11450 * Function : fillPucchSchedReqPeriodAndOffset
11452 * Functionality: To fillPucchSchedReqPeriodAndOffset
11454 * @params[in] macPeriodicty,
11455 * SchedulingRequestResourceConfig__periodicityAndOffset pointer
11458 * ****************************************************************/
11460 void fillPucchSchedReqPeriodAndOffset(uint8_t macPeriodicty, uint16_t macOffset,\
11461 struct SchedulingRequestResourceConfig__periodicityAndOffset *cuPeriodicty)
11463 macPeriodicty = cuPeriodicty->present;
11464 switch(macPeriodicty)
11466 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sym2:
11468 macOffset = cuPeriodicty->choice.sym2;
11471 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sym6or7:
11473 macOffset = cuPeriodicty->choice.sym6or7;
11476 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl1:
11478 macOffset = cuPeriodicty->choice.sl1;
11481 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl2:
11483 macOffset = cuPeriodicty->choice.sl2;
11486 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl4:
11488 macOffset = cuPeriodicty->choice.sl4;
11491 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl5:
11493 macOffset = cuPeriodicty->choice.sl5;
11496 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl8:
11498 macOffset = cuPeriodicty->choice.sl8;
11501 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl10:
11503 macOffset = cuPeriodicty->choice.sl10;
11506 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl16:
11508 macOffset = cuPeriodicty->choice.sl16;
11511 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl20:
11513 macOffset = cuPeriodicty->choice.sl20;
11516 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl40:
11518 macOffset = cuPeriodicty->choice.sl40;
11521 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl80:
11523 macOffset = cuPeriodicty->choice.sl80;
11526 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl160:
11528 macOffset = cuPeriodicty->choice.sl160;
11531 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl320:
11533 macOffset = cuPeriodicty->choice.sl320;
11536 case SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl640:
11538 macOffset = cuPeriodicty->choice.sl640;
11542 DU_LOG("\nERROR --> F1AP : Invalid periodicity %d", macPeriodicty);
11546 /*******************************************************************
11548 * @brief Function to extractPucchFormatCfg sent by CU
11552 * Function : extractPucchFormatCfg
11554 * Functionality: Function to extractPucchFormatCfg
11556 * @params[in] PucchFormatCfg pointer,
11557 * PUCCH_FormatConfig_t pointer
11560 * ****************************************************************/
11562 void extractPucchFormatCfg(PucchFormatCfg *macFormatCfg, PUCCH_FormatConfig_t *cuFormatCfg)
11564 if(cuFormatCfg->interslotFrequencyHopping)
11565 macFormatCfg->interSlotFreqHop = *cuFormatCfg->interslotFrequencyHopping;
11566 if(cuFormatCfg->additionalDMRS)
11567 macFormatCfg->addDmrs = *cuFormatCfg->additionalDMRS;
11568 if(cuFormatCfg->maxCodeRate)
11569 macFormatCfg->maxCodeRate = *cuFormatCfg->maxCodeRate;
11570 if(cuFormatCfg->nrofSlots)
11571 macFormatCfg->numSlots = *cuFormatCfg->nrofSlots;
11572 if(cuFormatCfg->pi2BPSK)
11573 macFormatCfg->pi2BPSK = *cuFormatCfg->pi2BPSK;
11574 if(cuFormatCfg->simultaneousHARQ_ACK_CSI)
11575 macFormatCfg->harqAckCSI = *cuFormatCfg->simultaneousHARQ_ACK_CSI;
11576 }/* End of extractPucchFormatCfg */
11578 /*******************************************************************
11580 * @brief Function to extractSchedReqCfgToAddMod sent by CU
11584 * Function : extractSchedReqCfgToAddMod
11586 * Functionality: Function to extractSchedReqCfgToAddMod
11588 * @params[in] PucchSchedReqCfg pointer,
11589 * PUCCH_Config__schedulingRequestResourceToAddModList pointer
11592 * ****************************************************************/
11594 void extractSchedReqCfgToAddMod(PucchSchedReqCfg *macSchedReqCfg, struct PUCCH_Config__schedulingRequestResourceToAddModList *cuSchedReqList)
11598 macSchedReqCfg->schedAddModListCount = cuSchedReqList->list.count;
11599 for(arrIdx = 0; arrIdx < macSchedReqCfg->schedAddModListCount; arrIdx++)
11601 macSchedReqCfg->schedAddModList[arrIdx].resrcId =\
11602 cuSchedReqList->list.array[arrIdx]->schedulingRequestResourceId;
11603 macSchedReqCfg->schedAddModList[arrIdx].requestId =\
11604 cuSchedReqList->list.array[arrIdx]->schedulingRequestID;
11605 if(cuSchedReqList->list.array[arrIdx]->periodicityAndOffset)
11607 fillPucchSchedReqPeriodAndOffset(macSchedReqCfg->schedAddModList[arrIdx].periodicity,\
11608 macSchedReqCfg->schedAddModList[arrIdx].offset, cuSchedReqList->list.array[arrIdx]->periodicityAndOffset);
11610 if(cuSchedReqList->list.array[arrIdx]->resource)
11612 macSchedReqCfg->schedAddModList[arrIdx].resrc =\
11613 *cuSchedReqList->list.array[arrIdx]->resource;
11617 }/* End of extractSchedReqCfgToAddMod */
11619 /*******************************************************************
11621 * @brief Fills PucchCfg received by CU
11625 * Function : extractPucchCfg
11627 * Functionality: Fills PucchCfg received by CU
11629 * @params[in] BWP_UplinkDedicated__pucch_Config *cuPucchCfg = Information which
11630 * is send by CU, which we have stored in F1UeContextSetupDb,
11631 * PucchCfg *macPucchCfg = Used to Store the information which
11632 * needs to send in other layer, as well as this can be the variable
11633 * which stores the information in DuCb,
11634 * PucchCfg *storedPucchCfg = Null in case of sending the
11635 * information to other layer else it will have Pucch Cfg which
11636 * we have stored in copyOfmacUeCfg.
11637 * @return ROK/RFAILED
11639 * ****************************************************************/
11641 uint8_t extractPucchCfg(struct BWP_UplinkDedicated__pucch_Config *cuPucchCfg, PucchCfg *macPucchCfg,\
11642 PucchCfg *storedPucchCfg)
11646 if(cuPucchCfg->present == BWP_UplinkDedicated__pucch_Config_PR_setup)
11648 if(cuPucchCfg->choice.setup)
11650 /* Resource Set Cfg */
11651 if(cuPucchCfg->choice.setup->resourceSetToAddModList)
11653 DU_ALLOC_SHRABL_BUF(macPucchCfg->resrcSet, sizeof(PucchResrcSetCfg));
11654 if(macPucchCfg->resrcSet == NULLP)
11656 DU_LOG("\nERROR --> F1AP : Failed to extract Resrc set List in extractPucchCfg()");
11659 memset(macPucchCfg->resrcSet, 0, sizeof(PucchResrcSetCfg));
11660 extractResrcSetToAddModList(macPucchCfg->resrcSet, cuPucchCfg->choice.setup->resourceSetToAddModList);
11664 if(cuPucchCfg->choice.setup->resourceToAddModList)
11666 DU_ALLOC_SHRABL_BUF(macPucchCfg->resrc, sizeof(PucchResrcCfg));
11667 if(macPucchCfg->resrc == NULLP)
11669 DU_LOG("\nERROR --> F1AP : Failed to extract Resrc List in extractPucchCfg()");
11672 memset(macPucchCfg->resrc, 0, sizeof(PucchResrcCfg));
11673 extractResrcToAddModList(macPucchCfg->resrc, cuPucchCfg->choice.setup->resourceToAddModList);
11677 if(cuPucchCfg->choice.setup->format1)
11679 DU_ALLOC_SHRABL_BUF(macPucchCfg->format1, sizeof(PucchFormatCfg));
11680 if(macPucchCfg->format1 == NULLP)
11682 DU_LOG("\nERROR --> F1AP : Failed to extract format 1 Cfg in extractPucchCfg()");
11685 memset(macPucchCfg->format1, 0, sizeof(PucchFormatCfg));
11686 extractPucchFormatCfg(macPucchCfg->format1,\
11687 cuPucchCfg->choice.setup->format1->choice.setup);
11691 if(cuPucchCfg->choice.setup->format2)
11693 DU_ALLOC_SHRABL_BUF(macPucchCfg->format2, sizeof(PucchFormatCfg));
11694 if(macPucchCfg->format2 == NULLP)
11696 DU_LOG("\nERROR --> F1AP : Failed to extract format 2 Cfg in extractPucchCfg()");
11699 memset(macPucchCfg->format2, 0, sizeof(PucchFormatCfg));
11700 extractPucchFormatCfg(macPucchCfg->format2,\
11701 cuPucchCfg->choice.setup->format2->choice.setup);
11705 if(cuPucchCfg->choice.setup->format3)
11707 DU_ALLOC_SHRABL_BUF(macPucchCfg->format3, sizeof(PucchFormatCfg));
11708 if(macPucchCfg->format3 == NULLP)
11710 DU_LOG("\nERROR --> F1AP : Failed to extract format 3 Cfg in extractPucchCfg()");
11713 memset(macPucchCfg->format3, 0, sizeof(PucchFormatCfg));
11714 extractPucchFormatCfg(macPucchCfg->format3,\
11715 cuPucchCfg->choice.setup->format3->choice.setup);
11719 if(cuPucchCfg->choice.setup->format4)
11721 DU_ALLOC_SHRABL_BUF(macPucchCfg->format4, sizeof(PucchFormatCfg));
11722 if(macPucchCfg->format4 == NULLP)
11724 DU_LOG("\nERROR --> F1AP : Failed to extract format 4 Cfg in extractPucchCfg()");
11727 memset(macPucchCfg->format4, 0, sizeof(PucchFormatCfg));
11728 extractPucchFormatCfg(macPucchCfg->format4,\
11729 cuPucchCfg->choice.setup->format4->choice.setup);
11732 /* Sched Req List */
11733 if(cuPucchCfg->choice.setup->schedulingRequestResourceToAddModList)
11735 DU_ALLOC_SHRABL_BUF(macPucchCfg->schedReq, sizeof(PucchSchedReqCfg));
11736 if(macPucchCfg->schedReq == NULLP)
11738 DU_LOG("\nERROR --> F1AP : Failed to extract schedReqCfg in extractPucchCfg()");
11741 memset(macPucchCfg->schedReq, 0, sizeof(PucchSchedReqCfg));
11742 extractSchedReqCfgToAddMod(macPucchCfg->schedReq,\
11743 cuPucchCfg->choice.setup->schedulingRequestResourceToAddModList);
11746 /*TODO: Add support for Spatial Info */
11749 if(cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList)
11751 DU_ALLOC_SHRABL_BUF(macPucchCfg->multiCsiCfg, sizeof(PucchMultiCsiCfg));
11752 if(macPucchCfg->multiCsiCfg == NULLP)
11754 DU_LOG("\nERROR --> F1AP : Failed to extract multiCsiCfg in extractPucchCfg()");
11757 memset(macPucchCfg->multiCsiCfg, 0, sizeof(PucchMultiCsiCfg));
11758 macPucchCfg->multiCsiCfg->multiCsiResrcListCount = cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList->list.count;
11759 for(arrIdx =0; arrIdx < macPucchCfg->multiCsiCfg->multiCsiResrcListCount; arrIdx++)
11761 macPucchCfg->multiCsiCfg->multiCsiResrcList[arrIdx] =\
11762 *cuPucchCfg->choice.setup->multi_CSI_PUCCH_ResourceList->list.array[arrIdx];
11766 /* Dl_DataToUL_ACK */
11767 if(cuPucchCfg->choice.setup->dl_DataToUL_ACK)
11771 if(storedPucchCfg->dlDataToUlAck)
11773 macPucchCfg->dlDataToUlAck = storedPucchCfg->dlDataToUlAck;
11777 DU_ALLOC_SHRABL_BUF(macPucchCfg->dlDataToUlAck, sizeof(PucchDlDataToUlAck));
11782 DU_ALLOC_SHRABL_BUF(macPucchCfg->dlDataToUlAck, sizeof(PucchDlDataToUlAck));
11784 if(macPucchCfg->dlDataToUlAck == NULLP)
11786 DU_LOG("\nERROR --> F1AP : Failed to extract Dl_DataToUL_ACK in extractPucchCfg()");
11789 memset(macPucchCfg->dlDataToUlAck, 0, sizeof(PucchDlDataToUlAck));
11790 macPucchCfg->dlDataToUlAck->dlDataToUlAckListCount = cuPucchCfg->choice.setup->dl_DataToUL_ACK->list.count;
11791 for(arrIdx = 0; arrIdx < macPucchCfg->dlDataToUlAck->dlDataToUlAckListCount; arrIdx++)
11793 macPucchCfg->dlDataToUlAck->dlDataToUlAckList[arrIdx] =\
11794 *cuPucchCfg->choice.setup->dl_DataToUL_ACK->list.array[arrIdx];
11798 /* Power Control */
11799 if(cuPucchCfg->choice.setup->pucch_PowerControl)
11801 DU_ALLOC_SHRABL_BUF(macPucchCfg->powerControl, sizeof(PucchPowerControl));
11802 if(macPucchCfg->powerControl == NULLP)
11804 DU_LOG("\nERROR --> F1AP : Failed to extract power control in extractPucchCfg()");
11807 extractPucchPowerControl(macPucchCfg->powerControl,\
11808 cuPucchCfg->choice.setup->pucch_PowerControl);
11815 /*******************************************************************
11817 * @brief Fills ServingCellReconfig received by CU
11821 * Function : extractSpCellDedicatedCfg
11823 * Functionality: Fills ServingCellReconfig received by CU
11825 * @params[in] ServingCellConfig_t *cuSrvCellCfg = Information which is send by
11826 * CU, which we have stored in F1UeContextSetupDb,
11827 * ServCellCfgInfo *macSrvCellCfg = Used to Store the information
11828 * which needs to send in other layer, as well as this can be the
11829 * variable which stores the information in DuCb,
11830 * ServCellCfgInfo *storedSrvCellCfg = Null in case of sending the
11831 * information to other layer else it will have ServCellCfgInfo which
11832 * we have stored in copyOfmacUeCfg.
11833 * @return ROK/RFAILD
11835 * ****************************************************************/
11836 uint8_t extractSpCellDedicatedCfg(ServingCellConfig_t *cuSrvCellCfg, ServCellCfgInfo *macSrvCellCfg,\
11837 ServCellCfgInfo *storedSrvCellCfg)
11840 BWP_DownlinkDedicated_t *dlBwp = NULLP;
11841 BWP_UplinkDedicated_t *ulBwp = NULLP;
11843 if(cuSrvCellCfg->initialDownlinkBWP)
11845 dlBwp = ((BWP_DownlinkDedicated_t *)(cuSrvCellCfg->initialDownlinkBWP));
11846 if(dlBwp->pdcch_Config)
11848 if(dlBwp->pdcch_Config->choice.setup)
11850 macSrvCellCfg->initDlBwp.pdcchPresent = true;
11851 if(storedSrvCellCfg)
11853 if(!storedSrvCellCfg->initDlBwp.pdcchPresent)
11855 extractPdcchCfg(dlBwp->pdcch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdcchCfg);
11859 extractPdcchCfg(dlBwp->pdcch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdcchCfg);
11864 extractPdcchCfg(dlBwp->pdcch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdcchCfg);
11868 if(dlBwp->pdsch_Config)
11870 if(dlBwp->pdsch_Config->choice.setup)
11872 macSrvCellCfg->initDlBwp.pdschPresent = true;
11874 if(storedSrvCellCfg)
11876 if(!storedSrvCellCfg->initDlBwp.pdschPresent)
11878 extractPdschCfg(dlBwp->pdsch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdschCfg, NULL);
11882 extractPdschCfg(dlBwp->pdsch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdschCfg,\
11883 &storedSrvCellCfg->initDlBwp.pdschCfg);
11888 extractPdschCfg(dlBwp->pdsch_Config->choice.setup, &macSrvCellCfg->initDlBwp.pdschCfg, NULL);
11893 if(cuSrvCellCfg->firstActiveDownlinkBWP_Id)
11894 macSrvCellCfg->firstActvDlBwpId = *(cuSrvCellCfg->firstActiveDownlinkBWP_Id);
11895 if(cuSrvCellCfg->defaultDownlinkBWP_Id)
11896 macSrvCellCfg->defaultDlBwpId = *(cuSrvCellCfg->defaultDownlinkBWP_Id);
11897 if(cuSrvCellCfg->bwp_InactivityTimer)
11899 if(macSrvCellCfg->bwpInactivityTmr)
11901 memcpy(macSrvCellCfg->bwpInactivityTmr, cuSrvCellCfg->bwp_InactivityTimer, sizeof(uint8_t));
11905 macSrvCellCfg->bwpInactivityTmr = NULLP;
11906 DU_ALLOC_SHRABL_BUF(macSrvCellCfg->bwpInactivityTmr, sizeof(uint8_t));
11907 if(macSrvCellCfg->bwpInactivityTmr)
11909 memcpy(macSrvCellCfg->bwpInactivityTmr, cuSrvCellCfg->bwp_InactivityTimer, sizeof(uint8_t));
11913 DU_LOG("\nERROR --> F1AP : Memory Alloc failed for bwpInactivityTmr at extractSpCellDedicatedCfg()");
11918 if(cuSrvCellCfg->pdsch_ServingCellConfig)
11920 if(cuSrvCellCfg->pdsch_ServingCellConfig->choice.setup)
11922 ret = extractPdschServingCellCfg(cuSrvCellCfg->pdsch_ServingCellConfig->choice.setup, &macSrvCellCfg->pdschServCellCfg);
11925 DU_LOG("\nERROR --> F1AP : Failed at extractPdschServingCellCfg()");
11930 if(cuSrvCellCfg->uplinkConfig)
11932 if(cuSrvCellCfg->uplinkConfig->initialUplinkBWP)
11934 ulBwp = ((BWP_UplinkDedicated_t *)(cuSrvCellCfg->uplinkConfig->initialUplinkBWP));
11935 if(ulBwp->pusch_Config)
11937 macSrvCellCfg->initUlBwp.puschPresent = true;
11938 extractPuschCfg(ulBwp->pusch_Config, &macSrvCellCfg->initUlBwp.puschCfg);
11940 if(ulBwp->pucch_Config)
11942 macSrvCellCfg->initUlBwp.pucchPresent = true;
11943 memset(&macSrvCellCfg->initUlBwp.pucchCfg, 0, sizeof(PucchCfg));
11944 if(storedSrvCellCfg)
11946 if(!storedSrvCellCfg->initUlBwp.pucchPresent)
11947 extractPucchCfg(ulBwp->pucch_Config, &macSrvCellCfg->initUlBwp.pucchCfg, NULL);
11949 extractPucchCfg(ulBwp->pucch_Config, &macSrvCellCfg->initUlBwp.pucchCfg,\
11950 &storedSrvCellCfg->initUlBwp.pucchCfg);
11954 extractPucchCfg(ulBwp->pucch_Config, &macSrvCellCfg->initUlBwp.pucchCfg, NULL);
11958 if(cuSrvCellCfg->uplinkConfig->firstActiveUplinkBWP_Id)
11959 macSrvCellCfg->firstActvUlBwpId = *(cuSrvCellCfg->uplinkConfig->firstActiveUplinkBWP_Id);
11966 /*******************************************************************
11968 * @brief fill long cycle offset value of drx in UE structure
11972 * Function : fillLongCycleOffsetValueInUeDb
11974 * Functionality: fill long cycle offset value of drx in UE structure
11976 * @params[in] DrxLongCycleStartOffset drxLongCycleStartOffset,
11977 * struct DRX_ConfigRrc__drx_LongCycleStartOffset drx_LongCycleStartOffset
11979 * @return ROK - success
11980 * RFAILED - failure
11982 * ****************************************************************/
11983 void fillLongCycleOffsetValueInUeDb(DrxLongCycleStartOffset *drxLongCycleStartOffset, struct DRX_ConfigRrc__drx_LongCycleStartOffset *drx_LongCycleStartOffset)
11986 drxLongCycleStartOffset->drxLongCycleStartOffsetChoice = convertLongDrxCycleLengthEnumToValue(drx_LongCycleStartOffset->present);
11987 switch(drx_LongCycleStartOffset->present)
11989 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms10:
11991 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms10;
11994 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms20:
11996 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms20;
11999 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms32:
12001 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms32;
12004 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms40:
12006 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms40;
12009 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms60:
12011 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms60;
12014 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms64:
12016 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms64;
12019 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms70:
12021 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms70;
12024 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms80:
12026 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms80;
12029 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms128:
12031 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms128;
12034 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms160:
12036 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms160;
12039 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms256:
12041 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms256;
12044 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms320:
12046 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms320;
12049 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms512:
12051 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms512;
12054 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms640:
12056 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms640;
12059 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms1024:
12061 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms1024;
12064 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms1280:
12066 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms1280;
12069 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms2048:
12071 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms2048;
12074 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms2560:
12076 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms2560;
12079 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms5120:
12081 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms5120;
12084 case DRX_ConfigRrc__drx_LongCycleStartOffset_PR_ms10240:
12086 drxLongCycleStartOffset->drxLongCycleStartOffsetVal = drx_LongCycleStartOffset->choice.ms10240;
12094 /*******************************************************************
12096 * @brief Fills drx configuration structure with the help of drx_ConfigRrc
12097 *which recive from CU or storedDrxCfg which is already stored
12101 * Function : extractDrxConfiguration
12103 * Functionality: Fills Reconfig Cell group Info received by CU
12105 * @params[in] cuMacCellGrpDrxConfig = MAC_CellGroupConfig__drx_ConfigRrc information which
12106 * is send by CU, which we have stored in F1UeContextSetupDb
12107 * DrxCfg * drxCfg = Used to Store the information,
12108 * which needs to send in other layer, as well as this can be
12109 * the variable which stores the information in DuCb,
12110 * DrxCfg *storedDrxCfg = Null in case of sending the
12111 * information to other layer else it will have the drx information
12112 * stored in the copyOfmacUeCfg which we have stored in F1UeContextSetupDb.
12116 * ****************************************************************/
12117 void extractDrxConfiguration(struct MAC_CellGroupConfig__drx_ConfigRrc *cuMacCellGrpDrxConfig, DrxCfg * drxCfg, DrxCfg *storedDrxCfg)
12119 struct DRX_ConfigRrc *cuDrxConfig;
12123 memcpy(drxCfg, storedDrxCfg, sizeof(DrxCfg));
12127 if(cuMacCellGrpDrxConfig)
12129 switch(cuMacCellGrpDrxConfig->present)
12131 case MAC_CellGroupConfig__drx_ConfigRrc_PR_NOTHING:
12134 case MAC_CellGroupConfig__drx_ConfigRrc_PR_setup:
12136 cuDrxConfig = cuMacCellGrpDrxConfig->choice.setup;
12139 switch(cuDrxConfig->drx_onDurationTimer.present)
12141 case DRX_ConfigRrc__drx_onDurationTimer_PR_NOTHING:
12143 case DRX_ConfigRrc__drx_onDurationTimer_PR_milliSeconds:
12145 drxCfg->drxOnDurationTimer.onDurationTimerValInMs = true;
12146 drxCfg->drxOnDurationTimer.onDurationtimerValue.milliSeconds=convertOnDurationTimerMilliSecondsEnumToValue(cuDrxConfig->\
12147 drx_onDurationTimer.choice.milliSeconds);
12150 case DRX_ConfigRrc__drx_onDurationTimer_PR_subMilliSeconds:
12152 drxCfg->drxOnDurationTimer.onDurationTimerValInMs = false;
12153 drxCfg->drxOnDurationTimer.onDurationtimerValue.subMilliSeconds = cuDrxConfig->drx_onDurationTimer.choice.subMilliSeconds;
12158 fillLongCycleOffsetValueInUeDb(&drxCfg->drxLongCycleStartOffset, &cuDrxConfig->drx_LongCycleStartOffset);
12159 drxCfg->drxInactivityTimer = convertDrxInactivityTimerEnumToValue(cuDrxConfig->drx_InactivityTimer);
12160 drxCfg->drxHarqRttTimerDl = cuDrxConfig->drx_HARQ_RTT_TimerDL;
12161 drxCfg->drxHarqRttTimerUl = cuDrxConfig->drx_HARQ_RTT_TimerUL;
12162 drxCfg->drxRetransmissionTimerDl = convertDrxRetransmissionTimerDlEnumToValue(cuDrxConfig->drx_RetransmissionTimerDL);
12163 drxCfg->drxRetransmissionTimerUl = convertDrxRetransmissionTimerUlEnumToValue(cuDrxConfig->drx_RetransmissionTimerUL);
12164 drxCfg->drxSlotOffset = cuDrxConfig->drx_SlotOffset;
12165 if(cuDrxConfig->shortDRX)
12167 drxCfg->shortDrxPres=true;
12168 drxCfg->shortDrx.drxShortCycle = convertShortDrxCycleLengthEnumToValue(cuDrxConfig->shortDRX->drx_ShortCycle);
12169 drxCfg->shortDrx.drxShortCycleTimer = cuDrxConfig->shortDRX->drx_ShortCycleTimer;
12172 drxCfg->shortDrxPres=false;
12177 case MAC_CellGroupConfig__drx_ConfigRrc_PR_release:
12185 /*******************************************************************
12187 * @brief Fills Reconfig Cell group Info received by CU
12191 * Function : extractUeReCfgCellInfo
12193 * Functionality: Fills Reconfig Cell group Info received by CU
12195 * @params[in] CellGroupConfigRrc_t *cellGrp = CellGroupConfigRrc_t information which
12196 * is send by CU, which we have stored in F1UeContextSetupDb
12197 * MacUeCfg *MacUeCfg = Used to Store the information,
12198 * which needs to send in other layer, as well as this can be
12199 * the variable which stores the information in DuCb,
12200 * MacUeCfg *storedMacUeCfg = Null in case of sending the
12201 * information to other layer else it will have copyOfmacUeCfg
12202 * which we have stored in F1UeContextSetupDb.
12204 * @return ROK/RFAILED
12206 * ****************************************************************/
12207 uint8_t extractUeReCfgCellInfo(CellGroupConfigRrc_t *cellGrp, MacUeCfg *macUeCfg, MacUeCfg *storedMacUeCfg)
12210 MAC_CellGroupConfig_t *macCellGroup = NULLP;
12211 PhysicalCellGroupConfig_t *phyCellGrpCfg = NULLP;
12212 SpCellConfig_t *spcellCfg = NULLP;
12213 ServingCellConfig_t *servCellCfg = NULLP;
12217 /* Fill MacCell Group Reconfig */
12218 if(cellGrp->mac_CellGroupConfig)
12220 macUeCfg->macCellGrpCfgPres = true;
12221 macCellGroup = ((MAC_CellGroupConfig_t *)(cellGrp->mac_CellGroupConfig));
12224 if(macCellGroup->drx_ConfigRrc)
12228 if(!storedMacUeCfg->macCellGrpCfgPres)
12230 extractDrxConfiguration(macCellGroup->drx_ConfigRrc, &macUeCfg->macCellGrpCfg.drxCfg,NULL);
12234 extractDrxConfiguration(macCellGroup->drx_ConfigRrc, &macUeCfg->macCellGrpCfg.drxCfg, &storedMacUeCfg->macCellGrpCfg.drxCfg);
12239 extractDrxConfiguration(macCellGroup->drx_ConfigRrc, &macUeCfg->macCellGrpCfg.drxCfg,NULL);
12244 if(macCellGroup->schedulingRequestConfig)
12246 extractSchReqReConfig(macCellGroup->schedulingRequestConfig, &macUeCfg->macCellGrpCfg.schReqCfg);
12248 if(macCellGroup->tag_Config)
12250 extractTagReconfig(macCellGroup->tag_Config, &macUeCfg->macCellGrpCfg.tagCfg);
12252 if(macCellGroup->bsr_Config)
12254 macUeCfg->macCellGrpCfg.bsrTmrCfg.periodicTimer = macCellGroup->bsr_Config->periodicBSR_Timer;
12255 macUeCfg->macCellGrpCfg.bsrTmrCfg.retxTimer = macCellGroup->bsr_Config->retxBSR_Timer;
12256 if(macCellGroup->bsr_Config->logicalChannelSR_DelayTimer)
12258 macUeCfg->macCellGrpCfg.bsrTmrCfg.srDelayTimer =\
12259 *(macCellGroup->bsr_Config->logicalChannelSR_DelayTimer);
12262 if(macCellGroup->phr_Config)
12264 if(macCellGroup->phr_Config->present == MAC_CellGroupConfig__phr_Config_PR_setup)
12266 macUeCfg->macCellGrpCfg.phrCfgSetupPres = true;
12267 if(macCellGroup->phr_Config->choice.setup)
12269 macUeCfg->macCellGrpCfg.phrCfg.periodicTimer = \
12270 macCellGroup->phr_Config->choice.setup->phr_PeriodicTimer;
12271 macUeCfg->macCellGrpCfg.phrCfg.prohibitTimer = \
12272 macCellGroup->phr_Config->choice.setup->phr_ProhibitTimer;
12273 macUeCfg->macCellGrpCfg.phrCfg.txPowerFactor = \
12274 macCellGroup->phr_Config->choice.setup->phr_Tx_PowerFactorChange;
12275 macUeCfg->macCellGrpCfg.phrCfg.multiplePHR = \
12276 macCellGroup->phr_Config->choice.setup->multiplePHR;
12277 macUeCfg->macCellGrpCfg.phrCfg.dummy = \
12278 macCellGroup->phr_Config->choice.setup->dummy;
12279 macUeCfg->macCellGrpCfg.phrCfg.phrType2OtherCell = \
12280 macCellGroup->phr_Config->choice.setup->phr_Type2OtherCell;
12281 macUeCfg->macCellGrpCfg.phrCfg.phrOtherCG = \
12282 macCellGroup->phr_Config->choice.setup->phr_ModeOtherCG;
12287 /* Fill Physical Cell Group Reconfig */
12288 if(cellGrp->physicalCellGroupConfig)
12290 macUeCfg->phyCellGrpCfgPres = true;
12291 phyCellGrpCfg = ((PhysicalCellGroupConfig_t *)(cellGrp->physicalCellGroupConfig));
12292 if(phyCellGrpCfg->p_NR_FR1)
12294 if(*(phyCellGrpCfg->p_NR_FR1) != macUeCfg->phyCellGrpCfg.pNrFr1)
12295 macUeCfg->phyCellGrpCfg.pNrFr1 = *(phyCellGrpCfg->p_NR_FR1);
12297 macUeCfg->phyCellGrpCfg.pdschHarqAckCodebook = phyCellGrpCfg->pdsch_HARQ_ACK_Codebook;
12299 /* Fill SpCell Reconfig */
12300 if(cellGrp->spCellConfig)
12302 macUeCfg->spCellCfgPres = true;
12303 spcellCfg = ((SpCellConfig_t *)(cellGrp->spCellConfig));
12304 if(spcellCfg->servCellIndex)
12306 macUeCfg->spCellCfg.servCellIdx = *(spcellCfg->servCellIndex);
12308 /* Fill Serving cell Reconfig info */
12309 if(cellGrp->spCellConfig->spCellConfigDedicated)
12311 servCellCfg = ((ServingCellConfig_t *)(cellGrp->spCellConfig->spCellConfigDedicated));
12314 if(!storedMacUeCfg->spCellCfgPres)
12315 ret = extractSpCellDedicatedCfg(servCellCfg, &macUeCfg->spCellCfg.servCellCfg, NULL);
12317 ret = extractSpCellDedicatedCfg(servCellCfg, &macUeCfg->spCellCfg.servCellCfg,\
12318 &storedMacUeCfg->spCellCfg.servCellCfg);
12322 ret = extractSpCellDedicatedCfg(servCellCfg, &macUeCfg->spCellCfg.servCellCfg, NULL);
12326 DU_LOG("\nERROR --> F1AP : Failed at extractSpCellDedicatedCfg()");
12333 /*******************************************************************
12335 * @brief free the memory allocated by decoder
12339 * Function : freeAperDecodeNrcgi
12341 * Functionality: Free Nrcgi values
12343 * @params[in] NRCGI_t *nrcgi
12346 * ****************************************************************/
12349 void freeAperDecodeNrcgi(NRCGI_t *nrcgi)
12351 if(nrcgi->pLMN_Identity.buf != NULLP)
12353 free(nrcgi->pLMN_Identity.buf);
12355 if(nrcgi->nRCellIdentity.buf != NULLP)
12357 free(nrcgi->nRCellIdentity.buf);
12360 /*******************************************************************
12362 * @brief free the memory allocated by decoder
12366 * Function : freeAperDecodeCuToDuInfo
12368 * Functionality: Free Cu To Du Information
12370 * @params[in] CUtoDURRCInformation_t *rrcMsg
12373 * ****************************************************************/
12376 void freeAperDecodeCuToDuInfo(CUtoDURRCInformation_t *rrcMsg)
12381 if(rrcMsg->uE_CapabilityRAT_ContainerList)
12383 if(rrcMsg->uE_CapabilityRAT_ContainerList->buf)
12384 free(rrcMsg->uE_CapabilityRAT_ContainerList->buf);
12385 free(rrcMsg->uE_CapabilityRAT_ContainerList);
12388 if(rrcMsg->iE_Extensions)
12390 if(rrcMsg->iE_Extensions->list.array)
12392 for(ieIdx= 0; ieIdx < rrcMsg->iE_Extensions->list.count; ieIdx++)
12394 if(rrcMsg->iE_Extensions->list.array[ieIdx])
12396 switch(rrcMsg->iE_Extensions->list.array[ieIdx]->id)
12398 case ProtocolIE_ID_id_CellGroupConfig:
12399 if(rrcMsg->iE_Extensions->list.array[ieIdx]->extensionValue.choice.CellGroupConfig.buf != NULLP)
12401 free(rrcMsg->iE_Extensions->list.array[ieIdx]->extensionValue.choice.CellGroupConfig.buf);
12405 DU_LOG("\nERROR --> F1AP : Invalid Event type %ld at FreeCuToDuInfo()", \
12406 rrcMsg->iE_Extensions->list.array[ieIdx]->id);
12411 for(arrIdx = 0; arrIdx < ieIdx; arrIdx++)
12413 free(rrcMsg->iE_Extensions->list.array[arrIdx]);
12415 free(rrcMsg->iE_Extensions->list.array);
12419 free(rrcMsg->iE_Extensions);
12422 /*******************************************************************
12424 * @brief free the memory allocated by decoder
12428 * Function : freeAperDecodeSplCellList
12430 * Functionality: Free Spl Cell List
12431 where memory allocated by aper_decoder
12433 * @params[in] SCell_ToBeSetup_List_t *spCellLst
12436 * ****************************************************************/
12439 void freeAperDecodeSplCellList(SCell_ToBeSetup_List_t *spCellLst)
12441 uint8_t cellIdx =0;
12443 if(spCellLst->list.array != NULLP)
12445 for(cellIdx=0; cellIdx<spCellLst->list.count; cellIdx++)
12447 if(cellIdx==0&&spCellLst->list.array[cellIdx]!=NULLP)
12449 freeAperDecodeNrcgi(&spCellLst->list.array[cellIdx]->value.choice.SCell_ToBeSetup_Item.sCell_ID);
12451 if(spCellLst->list.array[cellIdx]!=NULLP)
12453 free(spCellLst->list.array[cellIdx]);
12456 free(spCellLst->list.array);
12459 /*******************************************************************
12461 * @brief free the memory allocated by decoder
12465 * Function : freeAperDecodeSRBSetup
12467 * Functionality: added free part for the memory allocated by aper_decoder
12469 * @params[in] SRBs_ToBeSetup_List_t *srbSet
12472 ****************************************************************/
12475 void freeAperDecodeSRBSetup(SRBs_ToBeSetup_List_t *srbSet)
12478 if(srbSet->list.array != NULLP)
12480 for(srbIdx=0; srbIdx<srbSet->list.count; srbIdx++)
12482 if(srbSet->list.array[srbIdx]!=NULLP)
12484 free(srbSet->list.array[srbIdx]);
12487 free(srbSet->list.array);
12491 /*******************************************************************
12493 * @brief free the memory allocated by decoder
12497 * Function : freeAperDecodeULTnlInfo
12499 * Functionality: added free part for the memory allocated by aper_decoder
12501 * @params[in] ULUPTNLInformation_ToBeSetup_List_t *ulInfo
12504 * ****************************************************************/
12507 void freeAperDecodeULTnlInfo(ULUPTNLInformation_ToBeSetup_List_t *ulInfo)
12510 if(ulInfo->list.array != NULLP)
12512 for(ulIdx=0; ulIdx<ulInfo->list.count; ulIdx++)
12514 if(ulIdx==0&&ulInfo->list.array[ulIdx]!=NULLP)
12516 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel!=NULLP)
12518 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->\
12519 transportLayerAddress.buf != NULLP)
12521 if(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf\
12524 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf);
12526 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel->\
12527 transportLayerAddress.buf);
12529 free(ulInfo->list.array[ulIdx]->uLUPTNLInformation.choice.gTPTunnel);
12532 if(ulInfo->list.array[ulIdx]!=NULLP)
12534 free(ulInfo->list.array[ulIdx]);
12537 free(ulInfo->list.array);
12540 /*******************************************************************
12542 * @brief free the memory allocated by decoder
12546 * Function : freeAperDecodeDRBSetup
12548 * Functionality: free DRBSetup which is allocated by decoder
12550 * @params[in] DRBs_ToBeSetup_List_t *drbSet
12553 * ****************************************************************/
12555 void freeAperDecodeDRBSetup(DRBs_ToBeSetup_List_t *drbSet)
12557 DRBs_ToBeSetup_Item_t *drbSetItem = NULLP;
12558 uint8_t flowIdx =0;
12561 if(drbSet->list.array != NULLP)
12563 for(drbIdx=0; drbIdx<drbSet->list.count; drbIdx++)
12565 if(drbIdx==0&&drbSet->list.array[drbIdx] != NULLP)
12567 drbSetItem =&drbSet->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item;
12568 if(drbSetItem->qoSInformation.choice.choice_extension != NULLP)
12570 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
12571 qoS_Characteristics.choice.non_Dynamic_5QI !=NULLP)
12573 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
12574 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
12576 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
12577 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
12580 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sST.buf!=NULLP)
12583 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD!=NULLP)
12586 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD->\
12590 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.\
12591 flows_Mapped_To_DRB_List.list.array != NULLP)
12594 for(flowIdx=0;flowIdx<drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
12595 DRB_Information.flows_Mapped_To_DRB_List.list.count; flowIdx++)
12598 if(flowIdx==0&&drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
12599 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]!=NULLP)
12601 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
12602 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
12603 qoSFlowLevelQoSParameters.\
12604 qoS_Characteristics.choice.non_Dynamic_5QI!=NULLP)
12606 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
12607 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
12608 qoSFlowLevelQoSParameters.\
12609 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
12612 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
12613 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
12614 qoSFlowLevelQoSParameters.\
12615 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
12619 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
12620 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
12621 qoSFlowLevelQoSParameters.\
12622 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
12625 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
12626 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
12627 qoSFlowLevelQoSParameters.\
12628 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
12631 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
12633 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]->\
12634 qoSFlowLevelQoSParameters.\
12635 qoS_Characteristics.choice.non_Dynamic_5QI);
12638 if(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
12639 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]!=NULLP)
12642 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
12643 DRB_Information.flows_Mapped_To_DRB_List.list.array[flowIdx]);
12647 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
12648 DRB_Information.flows_Mapped_To_DRB_List.list.array);
12651 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.\
12652 DRB_Information.sNSSAI.sD->buf);
12655 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sD);
12658 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI.sST.buf);
12662 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
12664 qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
12667 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
12668 qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
12671 free(drbSetItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.dRB_QoS.\
12672 qoS_Characteristics.choice.non_Dynamic_5QI);
12674 free(drbSetItem->qoSInformation.choice.choice_extension);
12676 freeAperDecodeULTnlInfo(&drbSetItem->uLUPTNLInformation_ToBeSetup_List);
12677 if(drbSetItem->uLConfiguration)
12679 free(drbSetItem->uLConfiguration);
12682 if(drbSet->list.array[drbIdx]!=NULLP)
12684 free(drbSet->list.array[drbIdx]);
12687 free(drbSet->list.array);
12692 /*******************************************************************
12694 * @brief builds Mac Cell Cfg
12698 * Function : procUeReCfgCellInfo
12700 * Functionality: builds Mac Cell Cfg
12702 * @params[in] MacUeCfg *macUeCfgToSend = Used to Store the information which
12703 * needs to send in other layer, as well as this can be
12704 * the variable which stores the information in DuCb.
12705 * MacUeCfg *storedMacUeCfg = Null in case of sending the
12706 * information to other layer else it will have copyOfmacUeCfg
12707 * which we have stored in F1UeContextSetupDb
12708 * void *cellInfo = CellGroupConfigRrc_t information which is send
12709 * by CU, which we have stored in F1UeContextSetupDb
12713 * ****************************************************************/
12714 uint8_t procUeReCfgCellInfo(MacUeCfg *macUeCfgToSend, MacUeCfg *storedMacUeCfg, void *cellInfo)
12717 CellGroupConfigRrc_t *cellGrp = NULLP;
12721 cellGrp = (CellGroupConfigRrc_t *)cellInfo;
12722 ret = extractUeReCfgCellInfo(cellGrp, macUeCfgToSend, storedMacUeCfg);
12724 DU_LOG("\nERROR --> F1AP : Failed at procUeReCfgCellInfo()");
12728 freeUeReCfgCellGrpInfo(macUeCfgToSend);
12733 /*******************************************************************
12735 * @brief Filling modulation info in mac ue cfg
12739 * Function : duFillModulationDetails
12741 * Functionality: Filling modulation info in mac ue cfg
12743 * @params[in] MAC UE Config to be updated
12744 * Current UE configuration
12745 * UE NR capability from CU
12746 * @return ROK - success
12747 * RFAILED - failure
12749 * ****************************************************************/
12750 void duFillModulationDetails(MacUeCfg *ueCfg, MacUeCfg *oldUeCfg, void *ueCap)
12752 UE_NR_Capability_t *ueNrCap=NULLP;
12754 if(!ueCap && oldUeCfg)
12756 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
12757 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
12761 ueNrCap = (UE_NR_Capability_t *)ueCap;
12763 /* Filling DL modulation info */
12764 if(ueNrCap->featureSets && ueNrCap->featureSets->featureSetsDownlinkPerCC && \
12765 ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0] && \
12766 ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0]->supportedModulationOrderDL)
12768 switch(*(ueNrCap->featureSets->featureSetsDownlinkPerCC->list.array[0]->supportedModulationOrderDL))
12770 case ModulationOrder_qpsk:
12772 ueCfg->dlModInfo.modOrder = MOD_ORDER_QPSK;
12775 case ModulationOrder_qam16:
12777 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM16;
12780 case ModulationOrder_qam64:
12782 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM64;
12783 ueCfg->dlModInfo.mcsIndex = PDSCH_MCS_INDEX;
12784 ueCfg->dlModInfo.mcsTable = MCS_TABLE_QAM64;
12787 case ModulationOrder_qam256:
12789 ueCfg->dlModInfo.modOrder = MOD_ORDER_QAM256;
12794 DU_LOG("\nERROR --> DU APP: Incorrect downlink modulation order received. Reatining old modulation configuration");
12796 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
12804 memcpy(&ueCfg->dlModInfo, &oldUeCfg->dlModInfo, sizeof(ModulationInfo));
12807 /* Filling UL modulation info */
12808 if(ueNrCap->featureSets && ueNrCap->featureSets->featureSetsUplinkPerCC && \
12809 ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0] && \
12810 ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0]->supportedModulationOrderUL)
12812 switch(*(ueNrCap->featureSets->featureSetsUplinkPerCC->list.array[0]->supportedModulationOrderUL))
12814 case ModulationOrder_qpsk:
12816 ueCfg->ulModInfo.modOrder = MOD_ORDER_QPSK;
12819 case ModulationOrder_qam16:
12821 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM16;
12822 ueCfg->ulModInfo.mcsIndex = PUSCH_MCS_INDEX;
12823 ueCfg->ulModInfo.mcsTable = MCS_TABLE_QAM64;
12826 case ModulationOrder_qam64:
12828 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM64;
12831 case ModulationOrder_qam256:
12833 ueCfg->ulModInfo.modOrder = MOD_ORDER_QAM256;
12838 DU_LOG("\nERROR --> DU APP: Incorrect uplink modulation order received. Reatining old modulation configuration");
12840 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
12848 memcpy(&ueCfg->ulModInfo, &oldUeCfg->ulModInfo, sizeof(ModulationInfo));
12853 /*******************************************************************
12855 * @brief Function to extract info from CU to DU RRC container extension
12859 * Function : extractCuToDuRrcInfoExt
12861 * Functionality: Function to extract info from CU to DU RRC container
12864 * @params[in] ProtocolExtensionContainer_4624P16_t pointer
12869 * ****************************************************************/
12870 uint8_t extractCuToDuRrcInfoExt(ProtocolExtensionContainer_4624P16_t *protocolIeExtn, DuUeCfg *ueCfgDb)
12873 uint16_t recvBufLen =0;
12874 CellGroupConfigRrc_t *cellGrpCfg = NULLP;
12875 CUtoDURRCInformation_ExtIEs_t *extIeInfo = NULLP;
12876 asn_dec_rval_t rval; /* Decoder return value */
12877 memset(&rval, 0, sizeof(asn_dec_rval_t));
12881 for(ieIdx = 0; ieIdx < protocolIeExtn->list.count; ieIdx++)
12883 extIeInfo = ((CUtoDURRCInformation_ExtIEs_t *)(protocolIeExtn->list.array[ieIdx]));
12884 switch(extIeInfo->id)
12886 case ProtocolIE_ID_id_CellGroupConfig:
12888 /* decoding the CellGroup Buf received */
12889 recvBufLen = extIeInfo->extensionValue.choice.CellGroupConfig.size;
12890 DU_ALLOC(cellGrpCfg, sizeof(CellGroupConfigRrc_t));
12893 memset(cellGrpCfg, 0, sizeof(CellGroupConfigRrc_t));
12894 rval = aper_decode(0, &asn_DEF_CellGroupConfigRrc, (void **)&cellGrpCfg,
12895 extIeInfo->extensionValue.choice.CellGroupConfig.buf, recvBufLen, 0, 0);
12896 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
12898 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
12901 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, cellGrpCfg);
12903 if(extractRlcCfgToAddMod(cellGrpCfg->rlc_BearerToAddModList, ueCfgDb))
12905 ueCfgDb->cellGrpCfg = cellGrpCfg;
12910 case ProtocolIE_ID_id_HandoverPreparationInformation:
12912 DU_LOG("\nINFO --> F1AP : Received HANDOVER PREPARATION INFO in UE CONTEXT SETUP REQUEST");
12917 DU_LOG("\nERROR --> F1AP : Invalid IE received CUtoDURRCInformation: %ld at decodeCellGrpCfg()", extIeInfo->id);
12925 /*******************************************************************
12927 * @brief Fills Srb List received by CU
12931 * Function : procSrbListToSetup
12933 * Functionality: Fills Srb List received by CU
12935 * @params[in] SRBs_ToBeSetup_Item_t *cuSrbItem
12937 * RlcBearerCfg pointer
12940 * ****************************************************************/
12941 uint8_t procSrbListToSetup(SRBs_ToBeSetup_Item_t * srbItem, LcCfg *macLcToAdd, RlcBearerCfg *rlcLcToAdd)
12944 /* Filling RLC INFO */
12945 procRlcLcCfg(srbItem->sRBID, srbItem->sRBID, RB_TYPE_SRB, RLC_AM, CONFIG_ADD, NULL, rlcLcToAdd, NULL);
12947 /* Filling MAC INFO */
12948 if(procMacLcCfg(srbItem->sRBID, RB_TYPE_SRB, CONFIG_ADD, NULL,NULL, NULL, NULL, macLcToAdd, NULL) != ROK)
12950 DU_LOG("\nERROR --> F1AP : Failed at MAC LC Cfg in procSrbListToSetup()");
12959 /*******************************************************************
12961 * @brief extract Srb List received by CU
12965 * Function : extractSrbListToSetup
12967 * Functionality: extract Srb List received by CU
12968 * for both MAC and RLC
12970 * @params[in] SRBs_ToBeSetup_Item_t pointer
12972 * @return ROK/RFAIED
12974 * ****************************************************************/
12976 uint8_t extractSrbListToSetup(SRBs_ToBeSetup_List_t *srbCfg, DuUeCfg *ueCfgDb)
12978 uint8_t ret = ROK, srbIdx = 0, rlcLcIdx = 0;
12979 SRBs_ToBeSetup_Item_t *srbItem = NULLP;
12980 LcCfg *macLcCtxt = NULLP;
12981 RlcBearerCfg *rlcLcCtxt = NULLP;
12985 for(srbIdx = 0; srbIdx < srbCfg->list.count; srbIdx++)
12990 srbItem = &srbCfg->list.array[srbIdx]->value.choice.SRBs_ToBeSetup_Item;
12991 if(ueCfgDb->numMacLcs > MAX_NUM_LC)
12993 DU_LOG("\nERROR --> F1AP: MAX LC Reached in MAC");
12997 if(ueCfgDb->numRlcLcs > MAX_NUM_LC)
12999 DU_LOG("\nERROR --> F1AP: MAX LC Reached in RLC");
13004 for(rlcLcIdx = 0; rlcLcIdx < ueCfgDb->numMacLcs; rlcLcIdx++)
13006 if(ueCfgDb->rlcLcCfg[rlcLcIdx].rbId == srbItem->sRBID && ueCfgDb->rlcLcCfg[rlcLcIdx].rbType == RB_TYPE_SRB)
13008 macLcCtxt = &ueCfgDb->macLcCfg[rlcLcIdx];
13009 rlcLcCtxt = &ueCfgDb->rlcLcCfg[rlcLcIdx];
13015 memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(LcCfg));
13016 macLcCtxt = &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs];
13017 ueCfgDb->numMacLcs++;
13021 memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(RlcBearerCfg));
13022 rlcLcCtxt = &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs];
13023 ueCfgDb->numRlcLcs++;
13026 ret = procSrbListToSetup(srbItem, macLcCtxt, rlcLcCtxt);
13028 DU_LOG("\nDEBUG --> DUAPP: extractSrbListToSetup: SRBID: %ld [RLC,MAC,NumDrb]:[%x,%x,%x]",\
13029 srbItem->sRBID, ueCfgDb->numRlcLcs, ueCfgDb->numMacLcs, ueCfgDb->numDrb);
13032 DU_LOG("\nERROR --> F1AP: Failed at extractSrbListToSetup()");
13043 /*******************************************************************
13045 * @brief Fills Drb List received by CU
13049 * Function : procDrbListToSetupMod
13051 * Functionality: Fills Drb List received by CU
13052 * for both MAC and RLC
13054 * @params[in] DRBs_ToBeSetup_Item_t , DRBs_ToBeSetupMod_Item_t,
13055 * DRBs_ToBeModified_Item_t , lcId, LcCfg pointer,
13056 * RlcBearerCfg , UpTnlCfg, RlcUeCfg
13059 * ****************************************************************/
13061 uint8_t procDrbListToSetupMod(uint8_t lcId, DRBs_ToBeSetup_Item_t *drbItem,\
13062 DRBs_ToBeSetupMod_Item_t *drbSetupModItem, DRBs_ToBeModified_Item_t *drbModItem, LcCfg *macLcToAdd, RlcBearerCfg *rlcLcToAdd, UpTnlCfg *upTnlInfo, RlcUeCfg *storedRlcUeCfg)
13064 uint8_t cfgIdx = 0;
13065 RlcMode rlcModeInfo;
13067 if(drbItem != NULLP)
13069 /* Filling RLC INFO */
13070 procRlcLcCfg(drbItem->dRBID, lcId, RB_TYPE_DRB, drbItem->rLCMode, CONFIG_ADD, NULL, rlcLcToAdd, &drbItem->\
13073 /* Filling MAC INFO */
13074 if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_ADD, drbItem, NULL, NULL, NULL, macLcToAdd, upTnlInfo) != ROK)
13076 DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in procDrbListToSetupMod()");
13080 else if(drbSetupModItem != NULLP)
13082 procRlcLcCfg(drbSetupModItem->dRBID, lcId, RB_TYPE_DRB, drbSetupModItem->rLCMode, CONFIG_ADD, NULL, rlcLcToAdd,
13083 &drbSetupModItem->qoSInformation);
13085 if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_ADD, NULL, drbSetupModItem, NULL, NULL, macLcToAdd, upTnlInfo) != ROK)
13087 DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in procDrbListToSetupMod()");
13091 else if(drbModItem != NULLP)
13093 /* Drb to Mod IEs doesnot have rlcMode to be modified
13094 * in ASN. Hence no change in RLC configurations */
13095 if(storedRlcUeCfg != NULLP)
13097 for(cfgIdx = 0; cfgIdx < storedRlcUeCfg->numLcs; cfgIdx++)
13099 if(storedRlcUeCfg->rlcLcCfg[cfgIdx].lcId == lcId)
13101 rlcModeInfo = storedRlcUeCfg->rlcLcCfg[cfgIdx].rlcMode;
13107 procRlcLcCfg(drbModItem->dRBID, lcId, RB_TYPE_DRB, rlcModeInfo, CONFIG_MOD, NULL, rlcLcToAdd, drbModItem->qoSInformation);
13108 if(procMacLcCfg(lcId, RB_TYPE_DRB, CONFIG_MOD, NULL, NULL, drbModItem, NULL, macLcToAdd, upTnlInfo) != ROK)
13110 DU_LOG("\nERROR --> F1AP : Failed at RLC LC Cfg in procDrbListToSetupMod()");
13117 /*******************************************************************
13119 * @brief extract Drb List received by CU
13123 * Function : extractDrbListToSetupMod
13125 * Functionality: extract Drb List received by CU
13126 * for both MAC and RLC
13128 * @params[in] DRBs_ToBeSetup_Item_t pointer
13130 * @return ROK/RFAIED
13132 * ****************************************************************/
13134 uint8_t extractDrbListToSetupMod(DRBs_ToBeSetup_List_t *drbCfg, DRBs_ToBeSetupMod_List_t *drbSetupModCfg,\
13135 DRBs_ToBeModified_List_t *drbModCfg, uint8_t drbCount, DuUeCfg *ueCfgDb, uint32_t *drbBitMap, RlcUeCfg *rlcUeCfg)
13138 uint8_t drbIdx = 0, rlcLcIdx = 0;
13139 uint8_t drbId = 0, lcId = 0;
13140 DRBs_ToBeSetup_Item_t *drbItem = NULLP;
13141 DRBs_ToBeSetupMod_ItemIEs_t *drbSetupModItem = NULLP;
13142 DRBs_ToBeModified_ItemIEs_t *drbModItem = NULLP;
13143 LcCfg *macLcCtxt = NULLP;
13144 RlcBearerCfg *rlcLcCtxt = NULLP;
13149 for(drbIdx = 0; drbIdx < drbCount; drbIdx++)
13154 if(ueCfgDb->numMacLcs > MAX_NUM_LC)
13156 DU_LOG("\nERROR --> F1AP : MAX LC Reached in MAC at extractDrbListToSetupMod()");
13160 if(ueCfgDb->numRlcLcs > MAX_NUM_LC)
13162 DU_LOG("\nERROR --> F1AP : MAX LC Reached in RLC at extractDrbListToSetupMod()");
13167 if(drbModCfg != NULLP)
13169 drbModItem = (DRBs_ToBeModified_ItemIEs_t *) drbModCfg->list.array[drbIdx];
13170 drbId = drbModItem->value.choice.DRBs_ToBeModified_Item.dRBID;
13172 else if(drbCfg != NULLP)
13173 drbId = drbCfg->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item.dRBID;
13174 else if(drbSetupModCfg != NULL)
13176 drbSetupModItem = (DRBs_ToBeSetupMod_ItemIEs_t *) drbSetupModCfg->list.array[drbIdx];
13177 drbId = drbSetupModItem->value.choice.DRBs_ToBeSetupMod_Item.dRBID;
13180 for(rlcLcIdx = 0; rlcLcIdx < ueCfgDb->numRlcLcs; rlcLcIdx++)
13182 if(ueCfgDb->rlcLcCfg[rlcLcIdx].rbId == drbId && ueCfgDb->rlcLcCfg[rlcLcIdx].rbType == RB_TYPE_DRB)
13184 macLcCtxt = &ueCfgDb->macLcCfg[rlcLcIdx];
13185 rlcLcCtxt = &ueCfgDb->rlcLcCfg[rlcLcIdx];
13191 memset(&ueCfgDb->macLcCfg[ueCfgDb->numMacLcs], 0, sizeof(LcCfg));
13192 macLcCtxt = &ueCfgDb->macLcCfg[ueCfgDb->numMacLcs];
13193 ueCfgDb->numMacLcs++;
13197 memset(&ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs], 0, sizeof(RlcBearerCfg));
13198 rlcLcCtxt = &ueCfgDb->rlcLcCfg[ueCfgDb->numRlcLcs];
13199 ueCfgDb->numRlcLcs++;
13202 if(drbModCfg != NULLP)
13204 lcId = fetchLcId(drbId);
13205 if(lcId < MIN_DRB_LCID)
13207 DU_LOG("\nERROR --> F1AP : Failed fetching LCID %d in extractDrbListToSetupMod() for Modified List", lcId);
13210 ret = procDrbListToSetupMod(lcId, NULL, NULL, &(drbModItem->value.choice.DRBs_ToBeModified_Item),\
13211 macLcCtxt, rlcLcCtxt, &ueCfgDb->upTnlInfo[ueCfgDb->numDrb], rlcUeCfg);
13214 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetupMod() for Modified List");
13220 lcId = getDrbLcId(drbBitMap);
13221 if(lcId == RFAILED)
13223 DU_LOG("\nERROR --> F1AP : InCorrect LCID extractDrbListToSetupMod()");
13229 drbItem = &drbCfg->list.array[drbIdx]->value.choice.DRBs_ToBeSetup_Item;
13230 ret = procDrbListToSetupMod(lcId, drbItem, NULL, NULL, macLcCtxt, rlcLcCtxt, &ueCfgDb->upTnlInfo[ueCfgDb->numDrb], rlcUeCfg);
13233 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetupMod() for DrbSetup List");
13237 else if(drbSetupModCfg != NULL)
13239 ret = procDrbListToSetupMod(lcId, NULL, &(drbSetupModItem->value.choice.DRBs_ToBeSetupMod_Item), NULL,\
13240 macLcCtxt, rlcLcCtxt, &ueCfgDb->upTnlInfo[ueCfgDb->numDrb], rlcUeCfg);
13243 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetupMod() for DrbSetupMod List");
13246 ueCfgDb->numDrbSetupMod++;
13251 DU_LOG("\nDEBUG --> DUAPP: extractDrbListToSetupMod:lcId:%x ,BitMap:%x, [RLC,MAC,NumDrb]:[%x,%x,%x]",\
13252 lcId,*drbBitMap, ueCfgDb->numRlcLcs, ueCfgDb->numMacLcs, ueCfgDb->numDrb);
13255 DU_LOG("\nERROR --> F1AP : Failed at extractDrbListToSetupMod()");
13266 /*******************************************************************
13268 * @brief Function to extract Dl RRC Msg received from CU
13272 * Function : extractDlRrcMsg
13274 * Functionality: Function to extract Dl RRC Msg received from CU
13276 * @params[in] F1AP message
13277 * @return ROK - success
13278 * RFAILED - failure
13280 * ****************************************************************/
13282 uint8_t extractDlRrcMsg(uint32_t gnbDuUeF1apId, uint32_t gnbCuUeF1apId, \
13283 F1DlRrcMsg *dlRrcMsg, RRCContainer_t *rrcContainer)
13286 dlRrcMsg->rrcMsgSize = rrcContainer->size;
13287 if(dlRrcMsg->rrcMsgSize > 0)
13289 DU_ALLOC_SHRABL_BUF(dlRrcMsg->rrcMsgPdu, dlRrcMsg->rrcMsgSize);
13290 if(!dlRrcMsg->rrcMsgPdu)
13292 DU_LOG("\nERROR --> DU APP : Memory allocation failed for RRC Msg in extractDlRrcMsg()");
13297 dlRrcMsg->gnbDuUeF1apId = gnbDuUeF1apId;
13298 dlRrcMsg->gnbCuUeF1apId = gnbCuUeF1apId;
13299 dlRrcMsg->srbId = SRB1_LCID;
13300 memcpy(dlRrcMsg->rrcMsgPdu, rrcContainer->buf, dlRrcMsg->rrcMsgSize);
13306 /*******************************************************************
13308 * @brief Extract UE capability info
13312 * Function : extractUeCapability
13314 * Functionality: Extract UE capability info and stores in ue Cb
13316 * @params[in] Octet string of UE capability RAT container list
13317 * @return ROK - success
13318 * RFAILED - failure
13320 * ****************************************************************/
13321 UE_NR_Capability_t *extractUeCapability(UE_CapabilityRAT_ContainerList_t *ueCapablityListBuf, DuUeCb *ueCb)
13324 uint16_t recvBufLen;
13325 asn_dec_rval_t rval;
13326 UE_NR_Capability_t *ueNrCap = NULLP;
13327 UE_CapabilityRAT_ContainerListRRC_t *ueCapRatContList = NULLP;
13329 /* Decoding UE Capability RAT Container List */
13330 recvBufLen = ueCapablityListBuf->size;
13331 DU_ALLOC(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
13332 if(!ueCapRatContList)
13334 DU_LOG("\nERROR --> F1AP : Memory allocation failed in extractUeCapability");
13337 memset(ueCapRatContList, 0, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
13338 memset(&rval, 0, sizeof(asn_dec_rval_t));
13339 rval = aper_decode(0, &asn_DEF_UE_CapabilityRAT_ContainerListRRC, (void **)&ueCapRatContList,
13340 ueCapablityListBuf->buf, recvBufLen, 0, 0);
13341 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
13343 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
13346 xer_fprint(stdout, &asn_DEF_UE_CapabilityRAT_ContainerListRRC, ueCapRatContList);
13348 /* Free encoded buffer after decoding */
13350 for(idx = 0; idx < ueCapRatContList->list.count; idx++)
13352 if(ueCapRatContList->list.array[idx]->rat_Type == RAT_Type_nr)
13354 /* Decoding UE NR Capability */
13355 recvBufLen = ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.size;
13356 DU_ALLOC(ueNrCap, sizeof(UE_NR_Capability_t));
13359 DU_LOG("\nERROR --> F1AP : Memory allocation failed in extractUeCapability");
13360 DU_FREE(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
13363 memset(ueNrCap, 0, sizeof(UE_NR_Capability_t));
13364 memset(&rval, 0, sizeof(asn_dec_rval_t));
13365 rval = aper_decode(0, &asn_DEF_UE_NR_Capability, (void **)&ueNrCap,
13366 ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.buf, recvBufLen, 0, 0);
13367 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
13369 DU_LOG("\nERROR --> F1AP : ASN decode failed at decodeCellGrpCfg()");
13372 xer_fprint(stdout, &asn_DEF_UE_NR_Capability, ueNrCap);
13374 /* Free encoded buffer after decoding */
13375 free(ueCapRatContList->list.array[idx]->ue_CapabilityRAT_Container.buf);
13377 free(ueCapRatContList->list.array[idx]);
13381 free(ueCapRatContList->list.array);
13382 DU_FREE(ueCapRatContList, sizeof(UE_CapabilityRAT_ContainerListRRC_t));
13386 /*******************************************************************
13388 * @brief free UE context setup request from CU
13392 * Function : freeAperDecodeF1UeContextSetupReq
13394 * Functionality: freeing part for the memory allocated by aper_decoder
13396 * @params[in] F1AP message
13397 * @return ROK - success
13398 * RFAILED - failure
13400 * ****************************************************************/
13401 void freeAperDecodeF1UeContextSetupReq(UEContextSetupRequest_t *ueSetReq)
13405 if(ueSetReq->protocolIEs.list.array != NULLP)
13407 for(ieIdx = 0; ieIdx < ueSetReq->protocolIEs.list.count; ieIdx++)
13409 if(ueSetReq->protocolIEs.list.array[ieIdx])
13411 switch(ueSetReq->protocolIEs.list.array[ieIdx]->id)
13413 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
13415 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
13417 case ProtocolIE_ID_id_SpCell_ID:
13418 freeAperDecodeNrcgi(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.NRCGI);
13420 case ProtocolIE_ID_id_ServCellIndex:
13422 case ProtocolIE_ID_id_SpCellULConfigured:
13424 case ProtocolIE_ID_id_CUtoDURRCInformation:
13426 freeAperDecodeCuToDuInfo(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation);
13428 case ProtocolIE_ID_id_SCell_ToBeSetup_List:
13430 freeAperDecodeSplCellList(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SCell_ToBeSetup_List);
13432 case ProtocolIE_ID_id_SRBs_ToBeSetup_List:
13434 freeAperDecodeSRBSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SRBs_ToBeSetup_List);
13436 case ProtocolIE_ID_id_DRBs_ToBeSetup_List:
13438 freeAperDecodeDRBSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRBs_ToBeSetup_List);
13440 case ProtocolIE_ID_id_RRCContainer:
13443 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf != NULLP)
13446 free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf);
13450 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
13452 case ProtocolIE_ID_id_GNB_DU_UE_AMBR_UL:
13454 if(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf)
13456 free(ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf);
13461 DU_LOG("\nERROR --> F1AP: Invalid event type %ld " ,ueSetReq->protocolIEs.list.array[ieIdx]->id);
13463 free(ueSetReq->protocolIEs.list.array[ieIdx]);
13466 free(ueSetReq->protocolIEs.list.array);
13469 /*******************************************************************
13471 * @brief Process UE context setup request from CU
13475 * Function : procF1UeContextSetupReq
13477 * Functionality: Process UE context setup request from CU
13479 * @params[in] F1AP message
13480 * @return ROK - success
13481 * RFAILED - failure
13483 * ****************************************************************/
13484 uint8_t procF1UeContextSetupReq(F1AP_PDU_t *f1apMsg)
13487 uint8_t ret=0, ieIdx=0, ieExtIdx = 0, servCellIdx = 0;
13488 bool ueCbFound = false, hoInProgress = false;
13489 uint16_t cellIdx=0;
13490 uint64_t nrCellId = 0;
13491 uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId=0, bitRateSize=0;
13492 DuUeCb *duUeCb = NULL;
13493 UEContextSetupRequest_t *ueSetReq = NULL;
13494 DRBs_ToBeSetup_List_t *drbCfg = NULL;
13495 CUtoDURRCInformation_t *rrcInfo = NULL;
13496 DRXCycle_t *drxCycle;
13500 ueSetReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextSetupRequest;
13501 for(ieIdx=0; (ieIdx < ueSetReq->protocolIEs.list.count && ret == ROK); ieIdx++)
13503 switch(ueSetReq->protocolIEs.list.array[ieIdx]->id)
13505 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
13507 gnbCuUeF1apId = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID;
13511 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
13513 gnbDuUeF1apId = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID;
13517 case ProtocolIE_ID_id_SpCell_ID:
13519 bitStringToInt(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.NRCGI.nRCellIdentity, &nrCellId);
13521 GET_CELL_IDX(nrCellId, cellIdx);
13522 if(!duCb.actvCellLst[cellIdx])
13524 DU_LOG("\nERROR --> F1AP : Cell Id [%lu] not found", nrCellId);
13530 case ProtocolIE_ID_id_ServCellIndex:
13532 servCellIdx = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.ServCellIndex;
13536 case ProtocolIE_ID_id_SpCellULConfigured:
13538 /* Indicates whether the gNB-CU requests the gNB-DU to configure the uplink as no UL,
13539 UL, SUL or UL+SUL for the indicated cell for the UE */
13543 case ProtocolIE_ID_id_CUtoDURRCInformation:
13545 rrcInfo = &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.CUtoDURRCInformation;
13547 /* Search if UE context is present */
13548 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
13550 if(duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId)
13553 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
13558 /* Check if UE Handover scenario */
13559 if(rrcInfo->iE_Extensions)
13561 for(ieExtIdx = 0; ieExtIdx < rrcInfo->iE_Extensions->list.count; ieExtIdx++)
13563 if(rrcInfo->iE_Extensions->list.array[ieExtIdx]->id == ProtocolIE_ID_id_HandoverPreparationInformation)
13565 hoInProgress = true;
13571 /* If UE context is not present, but UE is in handover */
13572 if(!ueCbFound && hoInProgress)
13574 ueIdx = getFreeBitFromUeBitMap(nrCellId);
13576 gnbDuUeF1apId = ueIdx +1;
13579 DU_LOG("\nERROR --> F1AP : No free UE IDX found in UE bit map of cell Id [%lu]", nrCellId);
13583 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
13584 duUeCb->f1UeDb = NULL;
13585 duUeCb->gnbCuUeF1apId = gnbCuUeF1apId;
13586 duUeCb->gnbDuUeF1apId = gnbDuUeF1apId;
13587 GET_CRNTI(duUeCb->crnti, duUeCb->gnbDuUeF1apId);
13588 duUeCb->ueState = UE_HANDIN_IN_PROGRESS;
13593 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
13596 memset(duUeCb->f1UeDb, 0, sizeof(F1UeContextSetupDb));
13597 duUeCb->f1UeDb->actionType = UE_CTXT_SETUP;
13598 duUeCb->f1UeDb->cellIdx = cellIdx;
13602 DU_LOG("\nERROR --> F1AP: Memory Alloc Failed at procF1UeContextSetupReq()");
13609 DU_LOG("\nERROR --> F1AP: DuUeCb is not found at procF1UeContextSetupReq()");
13614 /* Extract UE capability info */
13615 if(rrcInfo->uE_CapabilityRAT_ContainerList)
13617 duUeCb->f1UeDb->duUeCfg.ueNrCapability = extractUeCapability(rrcInfo->uE_CapabilityRAT_ContainerList, duUeCb);
13620 /* Extract IE extension */
13621 if(rrcInfo->iE_Extensions)
13623 if(extractCuToDuRrcInfoExt(rrcInfo->iE_Extensions, &duUeCb->f1UeDb->duUeCfg) != ROK)
13625 DU_LOG("\nERROR --> F1AP: Failed to extract CU to DU RRC information extension IE");
13626 //TODO: Update the failure cause in ue context Setup Response
13634 case ProtocolIE_ID_id_DRXCycle:
13636 duUeCb->f1UeDb->duUeCfg.drxCyclePres = true;
13637 drxCycle = &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRXCycle;
13638 duUeCb->f1UeDb->duUeCfg.drxCycle.drxLongCycleLength = convertLongDrxCycleLengthEnumToValue(drxCycle->longDRXCycleLength);
13639 if(drxCycle->shortDRXCycleLength)
13641 duUeCb->f1UeDb->duUeCfg.drxCycle.shortDrxCyclePres = true;
13642 duUeCb->f1UeDb->duUeCfg.drxCycle.shortDrxCycle.drxShortCycle = \
13643 convertShortDrxCycleLengthEnumToValue(*(drxCycle->shortDRXCycleLength));
13645 if(drxCycle->shortDRXCycleTimer)
13646 duUeCb->f1UeDb->duUeCfg.drxCycle.shortDrxCycle.drxShortCycleTimer = *(drxCycle->shortDRXCycleTimer);
13652 case ProtocolIE_ID_id_SRBs_ToBeSetup_List:
13654 if(extractSrbListToSetup(&ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.SRBs_ToBeSetup_List,\
13655 &duUeCb->f1UeDb->duUeCfg))
13657 DU_LOG("\nERROR --> DU APP : Failed at extractSrbListToSetup()");
13658 //TODO: Update the failure cause in ue context Setup Response
13664 case ProtocolIE_ID_id_DRBs_ToBeSetup_List:
13666 drbCfg = &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.DRBs_ToBeSetup_List;
13668 if(extractDrbListToSetupMod(drbCfg, NULL, NULL, drbCfg->list.count, &duUeCb->f1UeDb->duUeCfg, &duUeCb->drbBitMap, NULLP))
13670 DU_LOG("\nERROR --> DU APP : Failed at extractDrbListToSetupMod()");
13671 //TODO: Update the failure cause in ue context Setup Response
13676 case ProtocolIE_ID_id_RRCContainer:
13678 /* Filling Dl RRC Msg Info */
13679 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
13680 if(!duUeCb->f1UeDb->dlRrcMsg)
13682 DU_LOG("\nERROR --> DU APP : Memory allocation failed for DL RRC Msg in procUeCtxtSetupReq()");
13687 duUeCb->f1UeDb->dlRrcMsgPres = true;
13688 memset(duUeCb->f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
13689 ret = extractDlRrcMsg(gnbDuUeF1apId, gnbCuUeF1apId, duUeCb->f1UeDb->dlRrcMsg,\
13690 &ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer);
13695 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
13697 if(duUeCb->f1UeDb->dlRrcMsg)
13699 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
13701 duUeCb->f1UeDb->dlRrcMsg->deliveryStatRpt = true;
13705 DU_LOG("\nERROR --> Ignoring delivery report, since rrcContainer is not present");
13711 case ProtocolIE_ID_id_GNB_DU_UE_AMBR_UL:
13713 /* MaximumBitRate Uplink */
13714 bitRateSize = ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.size;
13715 if(bitRateSize > 0)
13717 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->duUeCfg.ambrCfg, bitRateSize);
13718 if(!duUeCb->f1UeDb->duUeCfg.ambrCfg)
13720 DU_LOG("\nERROR --> DU APP : Memory allocation failed for bitRate in procUeCtxtSetupReq");
13725 memset(duUeCb->f1UeDb->duUeCfg.ambrCfg, 0, sizeof(AmbrCfg));
13726 memcpy(&duUeCb->f1UeDb->duUeCfg.ambrCfg->ulBr,
13727 ueSetReq->protocolIEs.list.array[ieIdx]->value.choice.BitRate.buf, bitRateSize);
13739 } /* End of switch */
13741 /* In case of any failure in any IE */
13744 // BuildAndSendUeContextSetupRsp(cellId,ueId);
13745 DU_LOG("\nERROR --> F1AP: Failed to process UE CNTXT SETUP REQ at procF1UeContextSetupReq()");
13748 } /* End of for loop of IEs */
13751 ret = duProcUeContextSetupRequest(duUeCb);
13753 freeAperDecodeF1UeContextSetupReq(ueSetReq);
13757 /*******************************************************************
13758 * @brief Free the memory allocated for Dl Tunnel Info
13762 * Function : freeDlTnlInfo
13765 * Free the memory allocated for Dl Tunnel Info
13767 * @params[in] DLUPTNLInformation_ToBeSetup_List_t *
13770 * ****************************************************************/
13772 void freeDlTnlInfo(DLUPTNLInformation_ToBeSetup_List_t *tnlInfo)
13774 uint8_t arrIdx = 0;
13778 for(arrIdx=0; arrIdx < tnlInfo->list.count; arrIdx++)
13780 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.buf,\
13781 tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.size);
13782 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf,\
13783 tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel->gTP_TEID.size);
13784 DU_FREE(tnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel, sizeof(GTPTunnel_t));
13785 DU_FREE(tnlInfo->list.array[arrIdx], sizeof(DLUPTNLInformation_ToBeSetup_Item_t));
13787 DU_FREE(tnlInfo->list.array, tnlInfo->list.size);
13791 /*******************************************************************
13792 * @brief Free the memory allocated for DRB setup List
13796 * Function : freeDrbSetupList
13799 * Free the memory allocated for DRB setup list
13801 * @params[in] DRBs_Setup_List_t *
13804 * ****************************************************************/
13805 void freeDrbSetupList(DRBs_Setup_List_t *drbSetupList)
13807 uint8_t arrIdx = 0;
13808 DRBs_Setup_ItemIEs_t *drbItemIe = NULLP;
13810 for(arrIdx = 0; arrIdx < drbSetupList->list.count; arrIdx++)
13812 drbItemIe = ((DRBs_Setup_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
13813 freeDlTnlInfo(&drbItemIe->value.choice.DRBs_Setup_Item.dLUPTNLInformation_ToBeSetup_List);
13814 DU_FREE(drbSetupList->list.array[arrIdx], sizeof(DRBs_Setup_Item_t));
13816 DU_FREE(drbSetupList->list.array, drbSetupList->list.size);
13819 /*******************************************************************
13820 * @brief Free the memory allocated for UE Setup response
13824 * Function : FreeUeContextSetupRsp
13827 * Free the memory allocated for UE Setup response
13829 * @params[in] F1AP PDU for UE setup response
13830 * @return ROK - success
13831 * RFAILED - failure
13833 * ****************************************************************/
13834 void FreeUeContextSetupRsp(F1AP_PDU_t *f1apMsg)
13837 UEContextSetupResponse_t *ueSetRsp = NULLP;
13841 if(f1apMsg->choice.successfulOutcome)
13843 ueSetRsp = &f1apMsg->choice.successfulOutcome->value.choice.\
13844 UEContextSetupResponse;
13845 if(ueSetRsp->protocolIEs.list.array)
13847 for(idx = 0; idx < ueSetRsp->protocolIEs.list.count; idx++)
13849 if(ueSetRsp->protocolIEs.list.array[idx])
13851 switch(ueSetRsp->protocolIEs.list.array[idx]->id)
13853 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
13855 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
13857 case ProtocolIE_ID_id_DUtoCURRCInformation:
13859 CellGroupConfig_t *cellGrpCfg = NULLP;
13860 cellGrpCfg = &ueSetRsp->protocolIEs.list.array[idx]->value.choice.\
13861 DUtoCURRCInformation.cellGroupConfig;
13862 if(cellGrpCfg->buf != NULLP)
13864 DU_FREE(cellGrpCfg->buf, cellGrpCfg->size);
13865 cellGrpCfg = NULLP;
13869 case ProtocolIE_ID_id_DRBs_Setup_List:
13871 freeDrbSetupList(&ueSetRsp->protocolIEs.list.array[idx]->value.choice.DRBs_Setup_List);
13875 DU_LOG("\nERROR --> DUAPP: Invalid Id %ld at FreeUeContextSetupRsp()",\
13876 ueSetRsp->protocolIEs.list.array[idx]->id);
13879 DU_FREE(ueSetRsp->protocolIEs.list.array[idx],\
13880 sizeof(UEContextSetupResponseIEs_t));
13883 DU_FREE(ueSetRsp->protocolIEs.list.array, \
13884 ueSetRsp->protocolIEs.list.size);
13886 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
13888 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
13892 /*******************************************************************
13894 * @brief Builds Ue context Setup Rsp DU To CU Info
13898 * Function : EncodeUeCntxtDuToCuInfo
13900 * Functionality: Builds Ue context Setup Rsp DU To CU Info
13902 * @params[in] CellGroupConfig_t *, CellGroupConfigRrc_t *
13904 * @return ROK - success
13905 * RFAILED - failure
13907 ******************************************************************/
13909 uint8_t EncodeUeCntxtDuToCuInfo(CellGroupConfig_t *duToCuCellGrp, CellGroupConfigRrc_t *duCellGrpCfg)
13911 asn_enc_rval_t encRetVal;
13913 xer_fprint(stdout, &asn_DEF_CellGroupConfigRrc, duCellGrpCfg);
13914 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
13916 encRetVal = aper_encode(&asn_DEF_CellGroupConfigRrc, 0, duCellGrpCfg, PrepFinalEncBuf, encBuf);
13917 /* Encode results */
13918 if(encRetVal.encoded == ENCODE_FAIL)
13920 DU_LOG( "\nERROR --> F1AP : Could not encode UeCntxtDuToCuInfo (at %s)\n",\
13921 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
13926 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UeCntxtDuToCuInfo\n");
13927 #ifdef DEBUG_ASN_PRINT
13928 for(int i=0; i< encBufSize; i++)
13930 printf("%x",encBuf[i]);
13934 duToCuCellGrp->size = encBufSize;
13935 DU_ALLOC(duToCuCellGrp->buf, duToCuCellGrp->size);
13936 if(!duToCuCellGrp->buf)
13938 DU_LOG("\nERROR --> F1AP : Memory allocation failed in UeCntxtDuToCuInfo");
13940 memcpy(duToCuCellGrp->buf, encBuf, duToCuCellGrp->size);
13944 /*******************************************************************
13946 * @brief Fills Dl Gtp tunnel Info
13950 * Function : fillGtpTunnelforDl
13952 * Functionality: Fills Dl Gtp tunnel Info
13956 * @return ROK - success
13957 * RFAILED - failure
13959 * ****************************************************************/
13961 uint8_t fillGtpTunnelforDl(GTPTunnel_t *gtpDl, GtpTnlCfg *gtpUeCfg)
13963 uint8_t bufSize = 0;
13965 gtpDl->transportLayerAddress.size = 4*sizeof(uint8_t);
13966 DU_ALLOC(gtpDl->transportLayerAddress.buf, gtpDl->transportLayerAddress.size);
13967 if(gtpDl->transportLayerAddress.buf == NULLP)
13971 memcpy(gtpDl->transportLayerAddress.buf, >pUeCfg->dlTnlAddress, gtpDl->transportLayerAddress.size);
13974 gtpDl->gTP_TEID.size = 4 * sizeof(uint8_t);
13975 DU_ALLOC(gtpDl->gTP_TEID.buf, gtpDl->gTP_TEID.size);
13976 if(gtpDl->gTP_TEID.buf == NULLP)
13980 bufSize = 3; /*forming an Octect String*/
13981 fillTeIdString(bufSize, gtpUeCfg->teId, gtpDl->gTP_TEID.buf);
13986 /*******************************************************************
13988 * @brief Fills DL Tunnel Setup List
13992 * Function : fillDlTnlSetupList
13994 * Functionality: Fills the DL Tunnel Setup List
13998 * @return ROK - success
13999 * RFAILED - failure
14001 * ****************************************************************/
14003 uint8_t fillDlTnlSetupList(DLUPTNLInformation_ToBeSetup_List_t *dlTnlInfo, UpTnlCfg *tnlCfg)
14005 uint8_t ret = ROK, arrIdx = 0, eleCount = 0;
14008 dlTnlInfo->list.count = eleCount;
14009 dlTnlInfo->list.size = (eleCount * sizeof(DLUPTNLInformation_ToBeSetup_Item_t *));
14011 /* Initialize the DL Tnl Setup List Members */
14012 DU_ALLOC(dlTnlInfo->list.array, dlTnlInfo->list.size);
14013 if(dlTnlInfo->list.array == NULLP)
14015 DU_LOG(" ERROR --> F1AP : Memory allocation for DL Tnl Setup List in fillDlTnlSetupList()");
14018 for(arrIdx=0; arrIdx < eleCount; arrIdx++)
14020 DU_ALLOC(dlTnlInfo->list.array[arrIdx], sizeof(DLUPTNLInformation_ToBeSetup_Item_t));
14021 if(dlTnlInfo->list.array[arrIdx] == NULLP)
14023 DU_LOG(" ERROR --> F1AP : Memory allocation for arrIdx [%d] failed in fillDlTnlSetupList()", arrIdx);
14026 dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.present = UPTransportLayerInformation_PR_gTPTunnel;
14027 DU_ALLOC(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel, sizeof(GTPTunnel_t));
14028 if(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel == NULLP)
14030 DU_LOG(" ERROR --> F1AP : Memory allocation for DL tunnel info in fillDlTnlSetupList()");
14033 ret = fillGtpTunnelforDl(dlTnlInfo->list.array[arrIdx]->dLUPTNLInformation.choice.gTPTunnel,\
14041 /*******************************************************************
14043 * @brief Fills the Drb Setup List for Ue Context Setup Response
14047 * Function : fillDrbSetupList
14049 * Functionality: Fills the Drb Setup List for Ue Context Setup Response
14053 * @return ROK - success
14054 * RFAILED - failure
14056 * ****************************************************************/
14057 uint8_t fillDrbSetupList(DRBs_Setup_List_t *drbSetupList, DuUeCfg *ueCfg)
14059 uint8_t ret = ROK, arrIdx = 0, eleCount = 0;
14060 DRBs_Setup_ItemIEs_t *drbItemIe = NULLP;
14062 eleCount = ueCfg->numDrb;
14063 drbSetupList->list.count = eleCount;
14064 drbSetupList->list.size = \
14065 (eleCount * sizeof(DRBs_Setup_Item_t *));
14067 /* Initialize the Drb Setup List Members */
14068 DU_ALLOC(drbSetupList->list.array, drbSetupList->list.size);
14069 if(drbSetupList->list.array == NULLP)
14071 DU_LOG(" ERROR --> F1AP : Memory allocation for DRB Setup List in fillDrbSetupList()");
14075 for(arrIdx=0; arrIdx < eleCount; arrIdx++)
14077 DU_ALLOC(drbSetupList->list.array[arrIdx], sizeof(DRBs_Setup_Item_t));
14078 if(drbSetupList->list.array[arrIdx] == NULLP)
14080 DU_LOG(" ERROR --> F1AP : Memory allocation for arrIdx [%d] failed in fillDrbSetupList()", arrIdx);
14083 drbItemIe = ((DRBs_Setup_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
14084 drbItemIe->id = ProtocolIE_ID_id_DRBs_Setup_Item;
14085 drbItemIe->criticality = Criticality_reject;
14086 drbItemIe->value.present = DRBs_Setup_ItemIEs__value_PR_DRBs_Setup_Item;
14087 drbItemIe->value.choice.DRBs_Setup_Item.dRBID = ueCfg->upTnlInfo[arrIdx].drbId;
14088 ret = fillDlTnlSetupList(&drbItemIe->value.choice.DRBs_Setup_Item.dLUPTNLInformation_ToBeSetup_List,\
14089 &ueCfg->upTnlInfo[arrIdx]);
14096 /*******************************************************************
14098 * @brief Builds and sends the UE Setup Response
14102 * Function : BuildAndSendUeContextSetupRsp
14104 * Functionality: Constructs the UE Setup Response and sends
14105 * it to the DU through SCTP.
14107 * @params[in] uint8_t cellId,uint8_t ueId
14109 * @return ROK - success
14110 * RFAILED - failure
14112 * ****************************************************************/
14113 uint8_t BuildAndSendUeContextSetupRsp(uint8_t cellId,uint8_t ueId)
14115 uint8_t idx, ret, cellIdx, elementCnt;
14116 uint32_t gnbCuUeF1apId; /* gNB-CU UE F1AP Id */
14117 uint32_t gnbDuUeF1apId; /* gNB-DU UE F1AP Id */
14118 asn_enc_rval_t encRetVal; /* Encoder return value */
14119 F1AP_PDU_t *f1apMsg = NULLP;
14120 UEContextSetupResponse_t *ueSetRsp = NULLP;
14121 DuUeCb *ueCb = NULLP;
14123 DU_LOG("\n INFO --> F1AP : Building UE Context Setup Response for cellId %d, ueId %d\n", cellId, ueId);
14127 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
14128 if(f1apMsg == NULLP)
14130 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
14135 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
14136 DU_ALLOC(f1apMsg->choice.successfulOutcome,
14137 sizeof(SuccessfulOutcome_t));
14138 if(f1apMsg->choice.successfulOutcome == NULLP)
14140 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
14145 f1apMsg->choice.successfulOutcome->procedureCode = \
14146 ProcedureCode_id_UEContextSetup;
14147 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
14148 f1apMsg->choice.successfulOutcome->value.present = \
14149 SuccessfulOutcome__value_PR_UEContextSetupResponse;
14152 &f1apMsg->choice.successfulOutcome->value.choice.UEContextSetupResponse;
14154 ueSetRsp->protocolIEs.list.count = elementCnt;
14155 ueSetRsp->protocolIEs.list.size = \
14156 elementCnt * sizeof(UEContextSetupResponse_t *);
14158 /* Initialize the UESetup members */
14159 DU_ALLOC(ueSetRsp->protocolIEs.list.array, \
14160 ueSetRsp->protocolIEs.list.size);
14161 if(ueSetRsp->protocolIEs.list.array == NULLP)
14163 DU_LOG(" ERROR --> F1AP : Memory allocation for UE Setup Response failed");
14168 for(idx=0; idx<elementCnt; idx++)
14170 DU_ALLOC(ueSetRsp->protocolIEs.list.array[idx],\
14171 sizeof(UEContextSetupResponseIEs_t));
14172 if(ueSetRsp->protocolIEs.list.array[idx] == NULLP)
14174 DU_LOG(" ERROR --> F1AP : Memory allocation for UE Setup Response failed");
14179 /* Fetching Ue Cb Info*/
14180 GET_CELL_IDX(cellId, cellIdx);
14181 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
14182 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
14183 ueCb = &duCb.actvCellLst[cellIdx]->ueCb[ueId-1];
14186 /*GNB CU UE F1AP ID*/
14187 ueSetRsp->protocolIEs.list.array[idx]->id = \
14188 ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
14189 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
14190 ueSetRsp->protocolIEs.list.array[idx]->value.present = \
14191 UEContextSetupResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
14192 ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
14194 /*GNB DU UE F1AP ID*/
14196 ueSetRsp->protocolIEs.list.array[idx]->id = \
14197 ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
14198 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
14199 ueSetRsp->protocolIEs.list.array[idx]->value.present = \
14200 UEContextSetupResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
14201 ueSetRsp->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
14204 /*DUtoCURRC Information */
14206 ueSetRsp->protocolIEs.list.array[idx]->id = \
14207 ProtocolIE_ID_id_DUtoCURRCInformation;
14208 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
14209 ueSetRsp->protocolIEs.list.array[idx]->value.present =\
14210 UEContextSetupResponseIEs__value_PR_DUtoCURRCInformation;
14211 BuildCellGroupConfigRrc(ueCb, &ueSetRsp->protocolIEs.list.array[idx]->value.choice.DUtoCURRCInformation.cellGroupConfig);
14215 ueSetRsp->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_C_RNTI;
14216 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
14217 ueSetRsp->protocolIEs.list.array[idx]->value.present = UEContextSetupResponseIEs__value_PR_C_RNTI;
14218 ueSetRsp->protocolIEs.list.array[idx]->value.choice.C_RNTI = ueCb->crnti;
14221 /* Drb Setup List */
14223 ueSetRsp->protocolIEs.list.array[idx]->id = \
14224 ProtocolIE_ID_id_DRBs_Setup_List;
14225 ueSetRsp->protocolIEs.list.array[idx]->criticality = Criticality_reject;
14226 ueSetRsp->protocolIEs.list.array[idx]->value.present =\
14227 UEContextSetupResponseIEs__value_PR_DRBs_Setup_List;
14228 ret = fillDrbSetupList(&ueSetRsp->protocolIEs.list.array[idx]->value.choice.DRBs_Setup_List,\
14229 &ueCb->f1UeDb->duUeCfg);
14232 DU_LOG("\nERROR --> F1AP : Failed to fillDrbSetupList in BuildAndSendUeContextSetupRsp()");
14233 freeF1UeDb(ueCb->f1UeDb);
14234 ueCb->f1UeDb = NULLP;
14238 /* Free UeContext Db created during Ue context Req */
14239 freeF1UeDb(ueCb->f1UeDb);
14240 ueCb->f1UeDb = NULLP;
14242 /* TODO: To send Drb list */
14243 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
14245 /* Encode the UE context setup response type as APER */
14246 memset((uint8_t *)encBuf, 0, ENC_BUF_MAX_LEN);
14248 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
14250 /* Encode results */
14251 if(encRetVal.encoded == ENCODE_FAIL)
14253 DU_LOG( "\nERROR --> F1AP : Could not encode UE Context Setup Response structure (at %s)\n",\
14254 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
14260 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UE Context Setup Response\n");
14261 #ifdef DEBUG_ASN_PRINT
14262 for(int i=0; i< encBufSize; i++)
14264 printf("%x",encBuf[i]);
14270 if(sendF1APMsg() != ROK)
14272 DU_LOG("\nERROR --> F1AP : Sending UE Context Setup Response failed");
14278 FreeUeContextSetupRsp(f1apMsg);
14280 }/* End of BuildAndSendUeContextSetupRsp */
14281 /*******************************************************************
14283 * @brief Build And Send Ue Context Rsp
14287 * Function : BuildAndSendUeCtxtRsp
14289 * Functionality : Build And Send Ue Context Rsp
14292 * @return sucess = ROK
14293 * failure = RFAILED
14295 * ****************************************************************/
14296 uint8_t BuildAndSendUeCtxtRsp(uint8_t cellId, uint8_t ueId)
14298 uint8_t cellIdx = 0, actionType = 0;
14300 GET_CELL_IDX(cellId, cellIdx);
14301 actionType = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].f1UeDb->actionType;
14305 case UE_CTXT_SETUP:
14307 if((BuildAndSendUeContextSetupRsp(cellId,ueId)) != ROK)
14309 DU_LOG("\nERROR --> F1AP : Failed at BuildAndSendUeContextSetupRsp()");
14316 if((BuildAndSendUeContextModRsp(&duCb.actvCellLst[cellIdx]->ueCb[ueId-1])) != ROK)
14318 DU_LOG("\nERROR --> F1AP : Failed at BuildAndSendUeContextModRsp");
14324 DU_LOG("ERROR --> F1AP: Invalid Action Type %d at BuildAndSendUeCtxtRsp()", actionType);
14331 /*******************************************************************
14333 * @brief deallocating the memory of F1reset msg
14337 * Function : FreeF1ResetReq
14340 * - freeing memory of F1reset request msg
14346 * ****************************************************************/
14347 void FreeF1ResetReq(F1AP_PDU_t *f1apMsg)
14350 Reset_t *f1ResetMsg;
14354 if(f1apMsg->choice.initiatingMessage)
14356 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
14358 if(f1ResetMsg->protocolIEs.list.array)
14360 for(idx=0 ;idx < f1ResetMsg->protocolIEs.list.count ; idx++)
14362 if(f1ResetMsg->protocolIEs.list.array[idx])
14364 DU_FREE(f1ResetMsg->protocolIEs.list.array[idx],sizeof(ResetIEs_t));
14367 DU_FREE(f1ResetMsg->protocolIEs.list.array,f1ResetMsg->protocolIEs.list.size);
14369 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
14371 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
14374 /*******************************************************************
14376 * @brief Build and Send F1reset request
14380 * Function : BuildAndSendF1ResetReq
14383 * - Build and Send F1reset request msg
14386 * @return ROK - success
14387 * RFAILED - failure
14389 * ****************************************************************/
14390 uint8_t BuildAndSendF1ResetReq()
14392 uint8_t elementCnt=0;
14394 uint8_t ret= RFAILED;
14395 Reset_t *f1ResetMsg = NULLP;
14396 F1AP_PDU_t *f1apMsg = NULLP;
14397 asn_enc_rval_t encRetVal;
14398 DU_LOG("\nINFO --> F1AP : Building F1 Reset request \n");
14401 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
14402 if(f1apMsg == NULLP)
14406 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
14407 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
14408 if(f1apMsg->choice.initiatingMessage == NULLP)
14412 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_Reset;
14413 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
14414 f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_Reset;
14416 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
14419 f1ResetMsg->protocolIEs.list.count = elementCnt;
14420 f1ResetMsg->protocolIEs.list.size = elementCnt * sizeof(ResetIEs_t *);
14422 /* Initialize the F1Setup members */
14423 DU_ALLOC(f1ResetMsg->protocolIEs.list.array,f1ResetMsg->protocolIEs.list.size);
14424 if(f1ResetMsg->protocolIEs.list.array == NULLP)
14428 for(idx=0; idx<elementCnt; idx++)
14430 DU_ALLOC(f1ResetMsg->protocolIEs.list.array[idx],sizeof(ResetIEs_t));
14431 if(f1ResetMsg->protocolIEs.list.array[idx] == NULLP)
14439 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID;
14440 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
14441 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_TransactionID;
14442 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.TransactionID = 1;
14446 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_Cause;
14447 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_ignore;
14448 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_Cause;
14449 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.Cause.present = Cause_PR_radioNetwork;
14450 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.Cause.choice.radioNetwork = CauseRadioNetwork_action_desirable_for_radio_reasons;
14454 f1ResetMsg->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_ResetType;
14455 f1ResetMsg->protocolIEs.list.array[idx]->criticality = Criticality_reject;
14456 f1ResetMsg->protocolIEs.list.array[idx]->value.present = ResetIEs__value_PR_ResetType;
14457 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.ResetType.present = ResetType_PR_f1_Interface;
14458 f1ResetMsg->protocolIEs.list.array[idx]->value.choice.ResetType.choice.f1_Interface = ResetAll_reset_all;
14460 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
14462 /* Encode the F1SetupRequest type as APER */
14463 memset(encBuf, 0, ENC_BUF_MAX_LEN);
14465 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
14468 /* Encode results */
14469 if(encRetVal.encoded == ENCODE_FAIL)
14471 DU_LOG("\nERROR --> F1AP : Could not encode F1Reset structure (at %s)\n",\
14472 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
14477 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for F1Reset\n");
14478 #ifdef DEBUG_ASN_PRINT
14479 for(idx=0; idx< encBufSize; idx++)
14481 printf("%x",encBuf[idx]);
14486 if(sendF1APMsg() != ROK)
14488 DU_LOG("\nERROR --> F1AP : Sending F1 Reset request failed");
14496 FreeF1ResetReq(f1apMsg);
14499 /*******************************************************************
14501 * @brief Build And Send F1ResetAck
14505 * Function : BuildAndSendF1ResetAck
14508 * - Build And Send F1ResetRSP
14510 * @return ROK - success
14511 * RFAILED - failure
14513 * ****************************************************************/
14514 void FreeF1ResetAck(F1AP_PDU_t *f1apMsg)
14517 ResetAcknowledge_t *f1ResetAck;
14521 if(f1apMsg->choice.successfulOutcome)
14523 f1ResetAck= &f1apMsg->choice.successfulOutcome->value.choice.ResetAcknowledge;
14525 if(f1ResetAck->protocolIEs.list.array)
14527 for(idx=0; idx<f1ResetAck->protocolIEs.list.count ; idx++)
14529 if(f1ResetAck->protocolIEs.list.array[idx])
14531 DU_FREE(f1ResetAck->protocolIEs.list.array[idx], sizeof(ResetAcknowledgeIEs_t));
14534 DU_FREE(f1ResetAck->protocolIEs.list.array, f1ResetAck->protocolIEs.list.size );
14536 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
14538 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
14542 /*******************************************************************
14544 * @brief Build And Send F1ResetAck
14548 * Function : BuildAndSendF1ResetAck
14551 * - Build And Send F1ResetRSP
14554 * @return ROK - success
14555 * RFAILED - failure
14557 * ****************************************************************/
14558 uint8_t BuildAndSendF1ResetAck()
14561 uint8_t elementCnt = 0;
14562 uint8_t ret = RFAILED;
14563 F1AP_PDU_t *f1apMsg = NULL;
14564 ResetAcknowledge_t *f1ResetAck = NULLP;
14565 asn_enc_rval_t encRetVal;
14566 DU_LOG("\nINFO --> F1AP : Building F1 Reset Acknowledgment \n");
14569 /* Allocate the memory for F1ResetRequest_t */
14570 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
14571 if(f1apMsg == NULLP)
14573 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed");
14577 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
14579 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
14580 if(f1apMsg->choice.successfulOutcome == NULLP)
14582 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed");
14585 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
14586 f1apMsg->choice.successfulOutcome->value.present = SuccessfulOutcome__value_PR_ResetAcknowledge;
14587 f1ResetAck = &f1apMsg->choice.successfulOutcome->value.choice.ResetAcknowledge;
14591 f1ResetAck->protocolIEs.list.count = elementCnt;
14592 f1ResetAck->protocolIEs.list.size = elementCnt*sizeof(ResetAcknowledgeIEs_t *);
14594 DU_ALLOC(f1ResetAck->protocolIEs.list.array, f1ResetAck->protocolIEs.list.size );
14595 if(f1ResetAck->protocolIEs.list.array == NULLP)
14597 DU_LOG("\nERROR --> F1AP : Memory allocation for F1ResetAckIEs failed");
14601 for(idx=0; idx<elementCnt; idx++)
14603 DU_ALLOC(f1ResetAck->protocolIEs.list.array[idx], sizeof(ResetAcknowledgeIEs_t));
14604 if(f1ResetAck->protocolIEs.list.array[idx] == NULLP)
14611 f1ResetAck->protocolIEs.list.array[idx]->id = ProtocolIE_ID_id_TransactionID;
14612 f1ResetAck->protocolIEs.list.array[idx]->criticality = Criticality_reject;
14613 f1ResetAck->protocolIEs.list.array[idx]->value.present = ResetAcknowledgeIEs__value_PR_TransactionID;
14614 f1ResetAck->protocolIEs.list.array[idx]->value.choice.TransactionID = TRANS_ID;
14616 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
14618 /* Encode the F1SetupRequest type as UPER */
14619 memset(encBuf, 0, ENC_BUF_MAX_LEN);
14621 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
14623 /* Check encode results */
14624 if(encRetVal.encoded == ENCODE_FAIL)
14626 DU_LOG("\nERROR --> F1AP : Could not encode F1ResetAck structure (at %s)\n",\
14627 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
14632 DU_LOG("\nDUBUG --> F1AP : Created APER encoded buffer for F1ResetAck\n");
14633 #ifdef DEBUG_ASN_PRINT
14634 for(int i=0; i< encBufSize; i++)
14636 printf("%x",encBuf[i]);
14641 if(sendF1APMsg() != ROK)
14643 DU_LOG("\nERROR --> F1AP : Sending F1 Reset Acknowledgement failed");
14651 FreeF1ResetAck(f1apMsg);
14654 /******************************************************************
14656 * @brief free F1 reset msg allocated by aper_decoder
14660 * Function : freeAperDecodeF1ResetMsg
14662 * Functionality: free F1 reset msg allocated by aper_decoder
14664 * @params[in] Reset_t *f1ResetMsg
14667 * ****************************************************************/
14669 void freeAperDecodeF1ResetMsg(Reset_t *f1ResetMsg)
14672 if(f1ResetMsg->protocolIEs.list.array)
14674 for(ieIdx=0 ;ieIdx < f1ResetMsg->protocolIEs.list.count ; ieIdx++)
14676 if(f1ResetMsg->protocolIEs.list.array[ieIdx])
14678 free(f1ResetMsg->protocolIEs.list.array[ieIdx]);
14681 free(f1ResetMsg->protocolIEs.list.array);
14685 /******************************************************************
14687 * @brief Processes DL RRC Message Transfer sent by CU
14691 * Function : procF1ResetReq
14693 * Functionality: Processes DL RRC Message Transfer sent by CU
14695 * @params[in] F1AP_PDU_t ASN decoded F1AP message
14696 * @return ROK - success
14697 * RFAILED - failure
14699 * ****************************************************************/
14700 uint8_t procF1ResetReq(F1AP_PDU_t *f1apMsg)
14702 /* we are currently not supporting Ue release. right now we are supporting only init case of fireset */
14705 Reset_t *f1ResetMsg = NULLP;
14707 DU_LOG("\nINFO --> Processing F1 reset request");
14708 f1ResetMsg = &f1apMsg->choice.initiatingMessage->value.choice.Reset;
14710 for(ieIdx=0; ieIdx<f1ResetMsg->protocolIEs.list.count; ieIdx++)
14712 switch(f1ResetMsg->protocolIEs.list.array[ieIdx]->id)
14714 case ProtocolIE_ID_id_TransactionID:
14717 case ProtocolIE_ID_id_Cause:
14720 case ProtocolIE_ID_id_ResetType:
14729 ret = BuildAndSendF1ResetAck();
14730 DU_LOG("\nINFO --> UE release is not supported for now");
14732 freeAperDecodeF1ResetMsg(f1ResetMsg);
14737 /*******************************************************************
14739 * @brief free the RRC delivery report
14743 * Function : freeRrcDeliveryReport
14745 * Functionality: free the RRC delivery report
14748 * @return ROK - success
14749 * RFAILED - failure
14751 * ****************************************************************/
14752 void freeRrcDeliveryReport(F1AP_PDU_t *f1apMsg )
14755 RRCDeliveryReport_t *rrcDeliveryReport= NULLP;
14759 if(f1apMsg->choice.initiatingMessage)
14761 rrcDeliveryReport = &f1apMsg->choice.initiatingMessage->value.choice.RRCDeliveryReport;
14762 if(rrcDeliveryReport->protocolIEs.list.array)
14764 for(idx =0 ;idx <rrcDeliveryReport->protocolIEs.list.count ;
14767 if(rrcDeliveryReport->protocolIEs.list.array[idx])
14769 DU_FREE(rrcDeliveryReport->protocolIEs.list.array[idx],
14770 sizeof(RRCDeliveryReportIEs_t));
14773 DU_FREE(rrcDeliveryReport->protocolIEs.list.array,
14774 rrcDeliveryReport->protocolIEs.list.size);
14776 DU_FREE(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
14779 sizeof(F1AP_PDU_t));
14783 /*******************************************************************
14785 * @brief Builds and sends the RRC delivery report
14789 * Function : BuildAndSendRrcDeliveryReport
14791 * Functionality: Builds and sends the RRC delivery report
14795 * @return ROK - success
14796 * RFAILED - failure
14798 * ****************************************************************/
14799 uint8_t BuildAndSendRrcDeliveryReport(uint32_t gnbCuUeF1apId, \
14800 uint32_t gnbDuUeF1apId, RrcDeliveryReport *rrcDelivery)
14802 uint8_t ret = RFAILED;
14805 uint8_t elementCnt = 0;
14806 F1AP_PDU_t *f1apMsg = NULLP;
14807 asn_enc_rval_t encRetVal;
14808 RRCDeliveryReport_t *rrcDeliveryReport= NULLP;
14812 DU_LOG("\nINFO --> F1AP : Building RRC delivery Message Transfer Message\n");
14813 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
14814 if(f1apMsg == NULLP)
14816 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
14819 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
14820 DU_ALLOC(f1apMsg->choice.initiatingMessage,sizeof(InitiatingMessage_t));
14821 if(f1apMsg->choice.initiatingMessage == NULLP)
14823 DU_LOG(" ERROR --> F1AP : Memory allocation for F1AP-PDU failed");
14826 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_RRCDeliveryReport;
14827 f1apMsg->choice.initiatingMessage->criticality = Criticality_ignore;
14828 f1apMsg->choice.initiatingMessage->value.present = InitiatingMessage__value_PR_RRCDeliveryReport;
14830 rrcDeliveryReport = &f1apMsg->choice.initiatingMessage->value.choice.RRCDeliveryReport;
14832 rrcDeliveryReport->protocolIEs.list.count = elementCnt;
14833 rrcDeliveryReport->protocolIEs.list.size = elementCnt * sizeof(RRCDeliveryReportIEs_t *);
14835 /* Initialize the F1Setup members */
14836 DU_ALLOC(rrcDeliveryReport->protocolIEs.list.array, rrcDeliveryReport->protocolIEs.list.size);
14837 if(rrcDeliveryReport->protocolIEs.list.array == NULLP)
14839 DU_LOG(" ERROR --> F1AP : Memory allocation for RRC Delivery failed");
14842 for(idx =0 ;idx <elementCnt; idx++)
14844 DU_ALLOC(rrcDeliveryReport->protocolIEs.list.array[idx], sizeof(RRCDeliveryReportIEs_t));
14845 if(rrcDeliveryReport->protocolIEs.list.array[idx] == NULLP)
14853 /*GNB CU UE F1AP ID*/
14854 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
14855 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
14856 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_GNB_CU_UE_F1AP_ID;
14857 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.GNB_CU_UE_F1AP_ID = gnbCuUeF1apId;
14859 /*GNB DU UE F1AP ID*/
14861 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
14862 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_reject;
14863 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_GNB_DU_UE_F1AP_ID;
14864 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.GNB_DU_UE_F1AP_ID = gnbDuUeF1apId;
14866 /*RRC delivery status*/
14868 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_RRCDeliveryStatus;
14869 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_ignore;
14870 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_RRCDeliveryStatus;
14871 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.RRCDeliveryStatus.delivery_status =\
14872 rrcDelivery->rrcDeliveryStatus.deliveryStatus;
14873 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.RRCDeliveryStatus.triggering_message =\
14874 rrcDelivery->rrcDeliveryStatus.triggeringMessage;
14878 rrcDeliveryReport->protocolIEs.list.array[idx1]->id = ProtocolIE_ID_id_SRBID;
14879 rrcDeliveryReport->protocolIEs.list.array[idx1]->criticality = Criticality_ignore;
14880 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.present = RRCDeliveryReportIEs__value_PR_SRBID;
14881 rrcDeliveryReport->protocolIEs.list.array[idx1]->value.choice.SRBID = rrcDelivery->srbId;
14883 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
14885 /* Encode the RRC DELIVERY REPORT type as APER */
14886 memset(encBuf, 0, ENC_BUF_MAX_LEN);
14888 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,\
14891 /* Encode results */
14892 if(encRetVal.encoded == ENCODE_FAIL)
14894 DU_LOG("\nERROR --> F1AP : Could not encode RRC Delivery Msg structure (at %s)\n",\
14895 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
14900 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for RRC Delivery Msg \n");
14901 #ifdef DEBUG_ASN_PRINT
14902 for(idx=0; idx< encBufSize; idx++)
14904 printf("%x",encBuf[idx]);
14910 if(sendF1APMsg() != ROK)
14912 DU_LOG("\nERROR --> F1AP : Sending RRC delivery msg request failed");
14920 freeRrcDeliveryReport(f1apMsg);
14924 /*******************************************************************
14926 * @brief Processes cells to be activated
14930 * Function : extractCellsToBeActivated
14933 * - Processes cells to be activated list received in F1SetupRsp
14936 * @return ROK - success
14937 * RFAILED - failure
14939 * ****************************************************************/
14941 uint8_t extractCellsToBeActivated(Cells_to_be_Activated_List_t cellsToActivate)
14944 uint16_t idx, pci = 0;
14946 Cells_to_be_Activated_List_Item_t cell;
14948 for(idx=0; idx<cellsToActivate.list.count; idx++)
14951 cell = cellsToActivate.list.array[idx]->value.choice.Cells_to_be_Activated_List_Item;
14952 bitStringToInt(&cell.nRCGI.nRCellIdentity, &nci);
14958 ret = duProcCellsToBeActivated(cell.nRCGI.pLMN_Identity.buf, nci, pci);
14962 /******************************************************************
14964 * @brief Processes F1 Setup Response allocated by aper_decoder
14968 * Function : freeF1SetupRsp
14970 * Functionality: free F1 Setup Response allocated by aper_decoder
14972 * @params[in] F1SetupResponse_t *f1SetRspMsg
14975 * ****************************************************************/
14977 void freeAperDecodeF1SetupRsp(F1SetupResponse_t *f1SetRspMsg)
14981 Cells_to_be_Activated_List_t *cellToActivate =NULLP;
14982 RRC_Version_t *rrcVer =NULLP;
14984 if(f1SetRspMsg->protocolIEs.list.array)
14986 for(ieIdx=0; ieIdx<f1SetRspMsg->protocolIEs.list.count; ieIdx++)
14988 if(f1SetRspMsg->protocolIEs.list.array[ieIdx])
14990 switch(f1SetRspMsg->protocolIEs.list.array[ieIdx]->id)
14992 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
14995 &f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.Cells_to_be_Activated_List;
14996 if(cellToActivate->list.array)
14998 for(arrIdx=0; arrIdx<cellToActivate->list.count ; arrIdx++)
15000 if(cellToActivate->list.array[arrIdx])
15003 if(cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.nRCGI.\
15006 if(cellToActivate->list.array[0]->value.choice.\
15007 Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf)
15009 free(cellToActivate->list.array[0]->value.choice.\
15010 Cells_to_be_Activated_List_Item.nRCGI.nRCellIdentity.buf);
15013 free(cellToActivate->list.array[0]->value.choice.Cells_to_be_Activated_List_Item.\
15014 nRCGI.pLMN_Identity.buf);
15016 free(cellToActivate->list.array[arrIdx]);
15019 free(cellToActivate->list.array);
15023 case ProtocolIE_ID_id_TransactionID:
15027 case ProtocolIE_ID_id_gNB_CU_Name:
15029 free(f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_Name.buf);
15032 case ProtocolIE_ID_id_GNB_CU_RRC_Version:
15034 rrcVer = &f1SetRspMsg->protocolIEs.list.array[ieIdx]->value.choice.RRC_Version;
15035 if(rrcVer->latest_RRC_Version.buf)
15037 if(rrcVer->iE_Extensions)
15039 if(rrcVer->iE_Extensions->list.array)
15041 if(rrcVer->iE_Extensions->list.array[0])
15043 if(rrcVer->iE_Extensions->list.\
15044 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf)
15046 free(rrcVer->iE_Extensions->list.\
15047 array[0]->extensionValue.choice.Latest_RRC_Version_Enhanced.buf);
15049 free(rrcVer->iE_Extensions->list.array[0]);
15051 free(rrcVer->iE_Extensions->list.array);
15053 free(rrcVer->iE_Extensions);
15055 free(rrcVer->latest_RRC_Version.buf);
15062 DU_LOG("\nERROR --> DU_APP : Invalid IE received in F1SetupRsp:%ld",
15063 f1SetRspMsg->protocolIEs.list.array[ieIdx]->id);
15066 free(f1SetRspMsg->protocolIEs.list.array[ieIdx]);
15069 free(f1SetRspMsg->protocolIEs.list.array);
15072 /******************************************************************
15074 * @brief Processes F1 Setup Response sent by CU
15078 * Function : procF1SetupRsp
15080 * Functionality: Processes F1 Setup Response sent by CU
15082 * @params[in] F1AP_PDU_t ASN decoded F1AP message
15083 * @return ROK - success
15084 * RFAILED - failure
15086 * ****************************************************************/
15087 uint8_t procF1SetupRsp(F1AP_PDU_t *f1apMsg, MsgLen recvBufLen, char *recvBuf)
15091 F1SetupResponse_t *f1SetRspMsg = NULLP;
15092 GNB_CU_Name_t *cuName = NULLP;
15093 F1SetupRsp f1SetRspDb;
15094 RRC_Version_t *rrcVer =NULLP;
15096 memset(&f1SetRspDb, 0, sizeof(F1SetupRsp));
15098 DU_LOG("\nINFO --> F1AP : F1 Setup Response received");
15099 f1SetRspMsg = &f1apMsg->choice.successfulOutcome->value.choice.F1SetupResponse;
15101 for(idx=0; idx<f1SetRspMsg->protocolIEs.list.count; idx++)
15103 switch(f1SetRspMsg->protocolIEs.list.array[idx]->id)
15105 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
15107 extractCellsToBeActivated(f1SetRspMsg->protocolIEs.list.array[idx]->\
15108 value.choice.Cells_to_be_Activated_List);
15111 case ProtocolIE_ID_id_TransactionID:
15113 f1SetRspDb.transId = f1SetRspMsg->protocolIEs.list.array[idx]->\
15114 value.choice.TransactionID;
15117 case ProtocolIE_ID_id_gNB_CU_Name:
15119 cuName = &f1SetRspMsg->protocolIEs.list.array[idx]->\
15120 value.choice.GNB_CU_Name;
15121 strcpy(f1SetRspDb.cuName, (const char*)cuName->buf);
15124 case ProtocolIE_ID_id_GNB_CU_RRC_Version:
15126 rrcVer = &f1SetRspMsg->protocolIEs.list.array[idx]->value.choice.RRC_Version;
15127 strcpy(f1SetRspDb.rrcVersion.rrcVer,
15128 (const char*)rrcVer->latest_RRC_Version.buf);
15132 DU_LOG("\nERROR --> DU_APP : Invalid IE received in F1SetupRsp:%ld",
15133 f1SetRspMsg->protocolIEs.list.array[idx]->id);
15135 duProcF1SetupRsp();
15138 freeAperDecodeF1SetupRsp(f1SetRspMsg);
15140 duCb.f1SetupReqAndRspMsg.f1MsgRspBufSize = recvBufLen;
15141 DU_ALLOC(duCb.f1SetupReqAndRspMsg.f1MsgRspBuf, duCb.f1SetupReqAndRspMsg.f1MsgRspBufSize);
15142 if(duCb.f1SetupReqAndRspMsg.f1MsgReqBuf == NULLP)
15144 DU_LOG("\nERROR --> F1AP : Memory allocation failed to store the buf of F1setup response");
15147 memcpy(duCb.f1SetupReqAndRspMsg.f1MsgRspBuf, recvBuf, recvBufLen);
15149 if(BuildAndSendE2SetupReq() != ROK)
15151 DU_LOG("\nERROR --> F1AP : Failed to build and send E2 setup request ");
15156 /*******************************************************************
15158 * @brief free GNB DU config update ack
15162 * Function : freeAperDecodeGnbDuAck
15164 * Functionality: Processes GNB DU config update ack And
15165 * added free part for the memory allocated by aper_decoder
15167 * @params[in] F1AP_PDU_t ASN decoded F1AP message
15168 * @return ROK - success
15169 * RFAILED - failure
15171 * ****************************************************************/
15173 void freeAperDecodeGnbDuAck(GNBDUConfigurationUpdateAcknowledge_t *gnbDuAck)
15177 if(gnbDuAck->protocolIEs.list.array)
15179 for(ieIdx=0; ieIdx < gnbDuAck->protocolIEs.list.count; ieIdx++)
15181 if(gnbDuAck->protocolIEs.list.array[ieIdx])
15183 free(gnbDuAck->protocolIEs.list.array[ieIdx]);
15186 free(gnbDuAck->protocolIEs.list.array);
15190 /*******************************************************************
15192 * @brief Building result of gnb-du config update ack output
15196 * Function : duProcGnbDuCfgUpdAckMsg
15199 * Building output of gnb-du config update ack
15201 * @params[in] transId
15204 * ****************************************************************/
15206 uint8_t duProcGnbDuCfgUpdAckMsg(uint8_t transId)
15208 uint8_t ieIdx=0, arrIdx=0,ret=ROK;
15209 uint8_t ueId =0 , ueIdx =0, totalActiveUe = 0;
15210 uint16_t cellIdx =0, crnti=0;
15211 uint64_t cellId =0;
15212 CmLList *f1apPduNode = NULLP;
15213 ReservedF1apPduInfo *f1apPduInfo =NULLP;
15214 F1AP_PDU_t *f1apMsgPdu = NULLP;
15215 GNBDUConfigurationUpdate_t *gnbDuConfigUpdate = NULLP;
15216 BIT_STRING_t *cellIdentity=NULLP;
15217 struct Served_Cells_To_Delete_ItemIEs *deleteItemIe=NULLP;
15218 Served_Cells_To_Delete_List_t *cellsToDelete=NULLP;
15219 Served_Cells_To_Delete_Item_t *deleteItem=NULLP;
15221 DU_LOG("\nINFO --> DU APP: GNB-DU config update Ack received ");
15222 f1apPduNode = searchFromReservedF1apPduList(transId);
15223 f1apPduInfo = (ReservedF1apPduInfo *)f1apPduNode->node;
15224 f1apMsgPdu = (F1AP_PDU_t *)f1apPduInfo->f1apMsg;
15228 if(f1apMsgPdu->choice.initiatingMessage)
15230 gnbDuConfigUpdate = &f1apMsgPdu->choice.initiatingMessage->value.choice.GNBDUConfigurationUpdate;
15231 for(ieIdx=0; ieIdx < gnbDuConfigUpdate->protocolIEs.list.count; ieIdx++)
15233 switch(gnbDuConfigUpdate->protocolIEs.list.array[ieIdx]->id)
15235 case ProtocolIE_ID_id_Served_Cells_To_Delete_List:
15237 cellsToDelete = &gnbDuConfigUpdate->protocolIEs.list.array[ieIdx]->value.choice.\
15238 Served_Cells_To_Delete_List;
15239 if(cellsToDelete->list.array)
15241 if(cellsToDelete->list.array[arrIdx])
15243 deleteItemIe = (Served_Cells_To_Delete_ItemIEs_t*)cellsToDelete->list.array[arrIdx];
15244 deleteItem=&deleteItemIe->value.choice.Served_Cells_To_Delete_Item;
15245 if(deleteItem->oldNRCGI.nRCellIdentity.buf)
15247 cellIdentity = &deleteItem->oldNRCGI.nRCellIdentity;
15248 bitStringToInt(cellIdentity, &cellId);
15250 GET_CELL_IDX(cellId, cellIdx);
15251 if(duCb.actvCellLst[cellIdx] != NULLP)
15253 duCb.actvCellLst[cellId-1]->cellStatus = DELETION_IN_PROGRESS;
15259 if(duCb.actvCellLst[cellIdx] != NULLP)
15261 if(duCb.actvCellLst[cellIdx]->numActvUes == 0)
15263 ret = duSendCellDeletReq(cellId);
15266 DU_LOG("\nERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): Failed to send cell delete\
15267 request for cellId[%lu]", cellId);
15272 totalActiveUe = duCb.actvCellLst[cellIdx]->numActvUes;
15273 while(totalActiveUe)
15275 if(duCb.actvCellLst[cellIdx]->ueCb[ueIdx].ueState != UE_ACTIVE)
15281 crnti = duCb.actvCellLst[cellIdx]->ueCb[ueIdx].crnti;
15282 GET_UE_ID(crnti,ueId);
15283 /* Sending Ue Context release request only for maximum supporting UEs */
15284 ret = BuildAndSendUeContextReleaseReq(cellId, ueId);
15287 DU_LOG("\nERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): Failed to build and send UE delete\
15288 request for cellId[%lu]", cellId);
15297 DU_LOG("\nERROR --> DU_APP : duProcGnbDuCfgUpdAckMsg(): CellId [%lu] not found", cellId);
15310 FreeDUConfigUpdate(f1apMsgPdu);
15311 deleteFromReservedF1apPduList(f1apPduNode);
15315 /*******************************************************************
15317 * @brief Processes GNB DU config update ack
15321 * Function : procF1GNBDUCfgUpdAck
15323 * Functionality: added free part for the memory allocated by aper_decoder
15325 * @params[in] F1AP_PDU_t *f1apMsg
15328 * ****************************************************************/
15329 uint8_t procF1GNBDUCfgUpdAck(F1AP_PDU_t *f1apMsg)
15331 uint8_t ieIdx=0,transId=0;
15332 GNBDUConfigurationUpdateAcknowledge_t *gnbDuAck = NULLP;
15334 DU_LOG("\nINFO --> F1AP : GNB-DU config update acknowledgment");
15335 gnbDuAck = &f1apMsg->choice.successfulOutcome->value.choice.GNBDUConfigurationUpdateAcknowledge;
15337 for(ieIdx=0; ieIdx < gnbDuAck->protocolIEs.list.count; ieIdx++)
15339 switch(gnbDuAck->protocolIEs.list.array[ieIdx]->id)
15341 case ProtocolIE_ID_id_TransactionID:
15343 transId = gnbDuAck->protocolIEs.list.array[ieIdx]->value.choice.TransactionID;
15346 case ProtocolIE_ID_id_Cells_to_be_Activated_List:
15352 DU_LOG("\nERROR --> F1AP: procF1GNBDUCfgUpdAck(): Invalid IE Received: %ld", \
15353 gnbDuAck->protocolIEs.list.array[ieIdx]->id);
15359 duProcGnbDuCfgUpdAckMsg(transId);
15362 /* presently we are not supporting F1 Reset from DU to CU , we are only
15363 * supporting F1 Reset from CU to DU */
15365 if(BuildAndSendF1ResetReq() != ROK)
15371 freeAperDecodeGnbDuAck(gnbDuAck);
15374 /******************************************************************
15376 * @brief free DL RRC Message Transfer allocated by aper_decoder
15380 * Function : freeAperDecodef1DlRrcMsg
15382 * Functionality: free DL RRC Message Transfer allocated by aper_decoder
15384 * @params[in] DLRRCMessageTransfer_t *f1DlRrcMsg
15385 * @return ROK - success
15386 * RFAILED - failure
15388 * ****************************************************************/
15390 void freeAperDecodef1DlRrcMsg(DLRRCMessageTransfer_t *f1DlRrcMsg)
15393 RRCContainer_t *rrcContainer = NULLP;
15395 if(f1DlRrcMsg->protocolIEs.list.array)
15397 for(ieIdx=0; ieIdx<f1DlRrcMsg->protocolIEs.list.count; ieIdx++)
15399 if(f1DlRrcMsg->protocolIEs.list.array[ieIdx])
15401 switch(f1DlRrcMsg->protocolIEs.list.array[ieIdx]->id)
15403 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
15405 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
15407 case ProtocolIE_ID_id_SRBID:
15409 case ProtocolIE_ID_id_RRCContainer:
15411 rrcContainer =&f1DlRrcMsg->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer;
15412 free(rrcContainer->buf);
15414 case ProtocolIE_ID_id_ExecuteDuplication:
15416 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
15420 free(f1DlRrcMsg->protocolIEs.list.array[ieIdx]);
15423 free(f1DlRrcMsg->protocolIEs.list.array);
15426 /******************************************************************
15428 * @brief Processes DL RRC Message Transfer sent by CU
15432 * Function : procF1DlRrcMsgTrans
15434 * Functionality: Processes DL RRC Message Transfer sent by CU
15436 * @params[in] F1AP_PDU_t ASN decoded F1AP message
15437 * @return ROK - success
15438 * RFAILED - failure
15440 * ****************************************************************/
15441 uint8_t procF1DlRrcMsgTrans(F1AP_PDU_t *f1apMsg)
15444 DLRRCMessageTransfer_t *f1DlRrcMsg = NULLP;
15446 memset(&dlMsg, 0, sizeof(F1DlRrcMsg));
15448 DU_LOG("\nINFO --> DU_APP : DL RRC message transfer Recevied");
15449 f1DlRrcMsg = &f1apMsg->choice.initiatingMessage->value.choice.DLRRCMessageTransfer;
15453 for(idx=0; idx<f1DlRrcMsg->protocolIEs.list.count; idx++)
15455 switch(f1DlRrcMsg->protocolIEs.list.array[idx]->id)
15457 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
15459 dlMsg.gnbCuUeF1apId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_CU_UE_F1AP_ID;
15462 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
15464 dlMsg.gnbDuUeF1apId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.GNB_DU_UE_F1AP_ID;
15467 case ProtocolIE_ID_id_SRBID:
15469 dlMsg.srbId = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.SRBID;
15472 case ProtocolIE_ID_id_ExecuteDuplication:
15473 dlMsg.execDup = true;
15476 case ProtocolIE_ID_id_RRCContainer:
15478 if(f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size > 0)
15480 dlMsg.rrcMsgSize = f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size;
15481 DU_ALLOC_SHRABL_BUF(dlMsg.rrcMsgPdu, dlMsg.rrcMsgSize);
15482 if(dlMsg.rrcMsgPdu)
15484 memcpy(dlMsg.rrcMsgPdu, f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.buf,\
15489 DU_LOG("\nERROR --> DU APP : Memory alloc Failed at RRC Container at procF1DlRrcMsgTrans()");
15495 DU_LOG("\nERROR --> DU_APP : RRC Container Size is invalid:%ld",\
15496 f1DlRrcMsg->protocolIEs.list.array[idx]->value.choice.RRCContainer.size);
15501 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
15503 dlMsg.deliveryStatRpt = true;
15507 DU_LOG("\nERROR --> DU_APP : Invalid IE received in DL RRC Msg Transfer:%ld",
15508 f1DlRrcMsg->protocolIEs.list.array[idx]->id);
15512 ret = duProcDlRrcMsg(&dlMsg);
15514 freeAperDecodef1DlRrcMsg(f1DlRrcMsg);
15517 /*******************************************************************
15519 * @brief Builds the DRB to be Setup Mod list
15525 * Functionality: Constructs the DRB to be Setup Mod list
15527 * @params[in] DRBs_SetupMod_List_t *drbSet
15529 * @return ROK - success
15530 * RFAILED - failure
15532 * ****************************************************************/
15533 uint8_t BuildSrbSetupModList(SRBs_SetupMod_List_t *srbList, DuUeCfg *ueCfg)
15535 uint8_t srbIdx = 0;
15536 struct SRBs_SetupMod_ItemIEs *srbItemIe;
15538 srbList->list.count = ueCfg->numRlcLcs;
15539 srbList->list.size = srbList->list.count * sizeof(SRBs_SetupMod_ItemIEs_t *);
15541 DU_ALLOC(srbList->list.array, srbList->list.size);
15542 if(srbList->list.array == NULLP)
15544 DU_LOG("\nERROR --> DU APP : Memory allocation failed in BuildSrbSetupModList");
15548 for(srbIdx = 0; srbIdx < srbList->list.count; srbIdx++)
15550 DU_ALLOC(srbList->list.array[srbIdx], sizeof(SRBs_SetupMod_ItemIEs_t));
15551 if(srbList->list.array[srbIdx] == NULLP)
15553 DU_LOG("\nERROR --> DU APP : Memory allocation failed in BuildSrbSetupModList");
15558 for(srbIdx=0; srbIdx < srbList->list.count; srbIdx++)
15560 srbItemIe = (struct SRBs_SetupMod_ItemIEs *)srbList->list.array[srbIdx];
15561 srbItemIe->id = ProtocolIE_ID_id_SRBs_SetupMod_Item;
15562 srbItemIe->criticality = Criticality_reject;
15563 srbItemIe->value.present = SRBs_SetupMod_ItemIEs__value_PR_SRBs_SetupMod_Item;
15564 srbItemIe->value.choice.SRBs_SetupMod_Item.sRBID = ueCfg->rlcLcCfg[srbIdx].rbId;
15565 srbItemIe->value.choice.SRBs_SetupMod_Item.lCID = ueCfg->rlcLcCfg[srbIdx].lcId;
15570 /*******************************************************************
15572 * @brief Builds the DRB to be Setup Mod list
15578 * Functionality: Constructs the DRB to be Setup Mod list
15580 * @params[in] DRBs_SetupMod_List_t *drbSet
15582 * @return ROK - success
15583 * RFAILED - failure
15585 * ****************************************************************/
15587 uint8_t BuildDrbSetupModList(DRBs_SetupMod_List_t *drbSet , DuUeCfg *ueCfg)
15591 struct DRBs_SetupMod_ItemIEs *drbItemIe;
15593 drbCnt = ueCfg->numDrbSetupMod;
15597 DU_LOG("\nINFO --> F1AP : BuildDrbToBeSetupModList(): No DRB information to avaialble to add");
15601 drbSet->list.count = drbCnt;
15602 drbSet->list.size = drbCnt * sizeof(DRBs_SetupMod_ItemIEs_t *);
15603 DU_ALLOC(drbSet->list.array, drbSet->list.size);
15604 if(drbSet->list.array == NULLP)
15606 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDrbToBeSetupModList");
15609 for(arrIdx=0; arrIdx<drbCnt; arrIdx++)
15611 DU_ALLOC(drbSet->list.array[arrIdx], sizeof(DRBs_SetupMod_ItemIEs_t));
15612 if(drbSet->list.array[arrIdx] == NULLP)
15614 DU_LOG("\nERROR --> F1AP : Memory allocation failed in BuildDrbToBeSetupModList");
15618 drbItemIe = (struct DRBs_SetupMod_ItemIEs *)drbSet->list.array[arrIdx];
15619 drbItemIe->id = ProtocolIE_ID_id_DRBs_SetupMod_Item;
15620 drbItemIe->criticality = Criticality_reject;
15621 drbItemIe->value.present = DRBs_SetupMod_ItemIEs__value_PR_DRBs_SetupMod_Item;
15622 drbItemIe->value.choice.DRBs_SetupMod_Item.dRBID = ueCfg->upTnlInfo[arrIdx].drbId;
15623 if(fillDlTnlSetupList(&drbItemIe->value.choice.DRBs_SetupMod_Item.dLUPTNLInformation_ToBeSetup_List,\
15624 &ueCfg->upTnlInfo[arrIdx])!= ROK)
15626 DU_LOG("\nERROR --> F1AP : Failed to fill DlTnl SetupList in BuildDrbToBeSetupModList");
15634 /*******************************************************************
15635 * @brief Free the memory allocated for DRB setup List
15639 * Function : FreeDrbSetupModList
15642 * Free the memory allocated for DRB setup list
15644 * @params[in] DRBs_Setup_List_t *
15647 * ****************************************************************/
15648 void FreeDrbSetupModList(DRBs_SetupMod_List_t *drbSetupList)
15650 uint8_t arrIdx = 0;
15651 DRBs_SetupMod_ItemIEs_t *drbItemIe = NULLP;
15653 for(arrIdx = 0; arrIdx < drbSetupList->list.count; arrIdx++)
15655 drbItemIe = ((DRBs_SetupMod_ItemIEs_t *)drbSetupList->list.array[arrIdx]);
15656 freeDlTnlInfo(&drbItemIe->value.choice.DRBs_SetupMod_Item.dLUPTNLInformation_ToBeSetup_List);
15657 DU_FREE(drbSetupList->list.array[arrIdx], sizeof(DRBs_SetupMod_ItemIEs_t));
15659 DU_FREE(drbSetupList->list.array, drbSetupList->list.size);
15662 /*******************************************************************
15663 * @brief Free the memory allocated for SRB setup List
15667 * Function : FreeSrbSetupModList
15670 * Free the memory allocated for SRB setup list
15672 * @params[in] SRBs_Setup_List_t *
15675 * ****************************************************************/
15676 void FreeSrbSetupModList(SRBs_SetupMod_List_t *srbSetupList)
15678 uint8_t srbIdx = 0;
15680 for(srbIdx = 0; srbIdx < srbSetupList->list.count; srbIdx++)
15681 DU_FREE(srbSetupList->list.array[srbIdx], sizeof(SRBs_SetupMod_ItemIEs_t));
15682 DU_FREE(srbSetupList->list.array, srbSetupList->list.size);
15685 /*******************************************************************
15686 * @brief Free the memory allocated for UE Context Mod Response
15690 * Function : FreeUeContextModResp
15693 * Free the memory allocated for UE Context Mod Response
15695 * @params[in] F1AP_PDU_t *f1apMsg
15698 * ****************************************************************/
15700 void FreeUeContextModResp(F1AP_PDU_t *f1apMsg)
15703 UEContextModificationResponse_t *ueContextModifyRes = NULLP;
15706 if(f1apMsg->choice.successfulOutcome)
15708 ueContextModifyRes =&f1apMsg->choice.successfulOutcome->value.choice.UEContextModificationResponse;
15709 if(ueContextModifyRes->protocolIEs.list.array)
15711 for(ieIdx=0 ; ieIdx<ueContextModifyRes->protocolIEs.list.count; ieIdx++)
15713 if(ueContextModifyRes->protocolIEs.list.array[ieIdx])
15715 switch(ueContextModifyRes->protocolIEs.list.array[ieIdx]->id)
15717 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
15719 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
15721 case ProtocolIE_ID_id_DRBs_SetupMod_List:
15723 FreeDrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
15724 value.choice.DRBs_SetupMod_List));
15727 case ProtocolIE_ID_id_SRBs_SetupMod_List:
15729 FreeSrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.\
15730 SRBs_SetupMod_List));
15734 DU_FREE(ueContextModifyRes->protocolIEs.list.array[ieIdx], sizeof(UEContextModificationResponse_t));
15738 DU_FREE(ueContextModifyRes->protocolIEs.list.array, ueContextModifyRes->protocolIEs.list.size);
15740 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
15742 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
15746 /*****************************************************************i
15748 * @brief Creating the ue context modifcation response and sending
15752 * Function : BuildAndSendUeContextModRsp
15755 * - Creating the ue context modifcation response
15757 * @params[in] uint8_t cellId,uint8_t ueId
15758 * @return ROK - success
15759 * RFAILED - failure
15761 * ****************************************************************/
15762 uint8_t BuildAndSendUeContextModRsp(DuUeCb *ueCb)
15764 uint8_t ieIdx = 0, tnlIdx = 0, rbIdx = 0;
15765 uint8_t elementCnt = 0;
15766 uint8_t ret = RFAILED;
15767 F1AP_PDU_t *f1apMsg = NULLP;
15768 asn_enc_rval_t encRetVal;
15769 UEContextModificationResponse_t *ueContextModifyRes = NULLP;
15771 DU_LOG("\nINFO --> F1AP : Building UE context modification response\n");
15775 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
15776 if(f1apMsg == NULLP)
15778 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed Ue context modification");
15782 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
15784 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
15785 if(f1apMsg->choice.successfulOutcome == NULLP)
15787 DU_LOG("\nERROR --> F1AP : Memory allocation for F1AP-PDU failed Ue context modification");
15790 f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_UEContextModification;
15791 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
15792 f1apMsg->choice.successfulOutcome->value.present = SuccessfulOutcome__value_PR_UEContextModificationResponse;
15794 ueContextModifyRes =&f1apMsg->choice.successfulOutcome->value.choice.UEContextModificationResponse;
15796 if(ueCb->f1UeDb->actionType == UE_CTXT_MOD)
15798 if(ueCb->f1UeDb->duUeCfg.numDrbSetupMod)
15803 if(ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY)
15805 if(ueCb->f1UeDb->actionType == UE_CTXT_RRC_RECFG_COMPLETE)
15807 ueContextModifyRes->protocolIEs.list.count = elementCnt;
15808 ueContextModifyRes->protocolIEs.list.size = elementCnt*sizeof(UEContextModificationResponse_t*);
15810 /* Initialize the UE context modification members */
15811 DU_ALLOC(ueContextModifyRes->protocolIEs.list.array, ueContextModifyRes->protocolIEs.list.size);
15812 if(ueContextModifyRes->protocolIEs.list.array == NULLP)
15814 DU_LOG("\nERROR --> F1AP : Memory allocation for UE context modifcation Request failed");
15818 for(ieIdx=0 ; ieIdx<elementCnt; ieIdx++)
15820 DU_ALLOC(ueContextModifyRes->protocolIEs.list.array[ieIdx], sizeof(UEContextModificationResponse_t));
15821 if(ueContextModifyRes->protocolIEs.list.array[ieIdx] == NULLP)
15823 DU_LOG("\nERROR --> F1AP : Memory allocation for UE context modifcation Request failed");
15829 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
15830 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
15831 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present =\
15832 UEContextModificationResponseIEs__value_PR_GNB_CU_UE_F1AP_ID;
15833 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID = ueCb->gnbCuUeF1apId;
15836 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
15837 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
15838 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present=\
15839 UEContextModificationResponseIEs__value_PR_GNB_DU_UE_F1AP_ID;
15840 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID = ueCb->gnbDuUeF1apId;
15842 if(ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY)
15845 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DUtoCURRCInformation;
15846 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
15847 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present = \
15848 UEContextModificationResponseIEs__value_PR_DUtoCURRCInformation;
15849 BuildCellGroupConfigRrc(ueCb, &ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.DUtoCURRCInformation.cellGroupConfig);
15852 if((ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY) || ((ueCb->f1UeDb->actionType == UE_CTXT_MOD) && (ueCb->f1UeDb->duUeCfg.numDrbSetupMod)))
15855 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_DRBs_SetupMod_List;
15856 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
15857 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present =\
15858 UEContextModificationResponseIEs__value_PR_DRBs_SetupMod_List;
15859 if(ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY)
15861 for(tnlIdx = 0; tnlIdx < duCb.numTeId; tnlIdx++)
15863 if(duCb.upTnlCfg[tnlIdx]->ueId == ueCb->gnbDuUeF1apId)
15865 memcpy(&ueCb->f1UeDb->duUeCfg.upTnlInfo[ueCb->f1UeDb->duUeCfg.numDrbSetupMod++], duCb.upTnlCfg[tnlIdx], sizeof(UpTnlCfg));
15869 ret = BuildDrbSetupModList(&(ueContextModifyRes->protocolIEs.list.array[ieIdx]->\
15870 value.choice.DRBs_SetupMod_List) , &ueCb->f1UeDb->duUeCfg);
15873 DU_LOG( "\nERROR --> F1AP : Failed to build DRB setupmod List ");
15878 if(ueCb->f1UeDb->actionType == UE_CTXT_CFG_QUERY)
15881 ueContextModifyRes->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_SRBs_SetupMod_List;
15882 ueContextModifyRes->protocolIEs.list.array[ieIdx]->criticality = Criticality_reject;
15883 ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.present = \
15884 UEContextModificationResponseIEs__value_PR_SRBs_SetupMod_List;
15885 for(rbIdx = 0; rbIdx < ueCb->rlcUeCfg.numLcs; rbIdx++)
15887 if(ueCb->rlcUeCfg.rlcLcCfg[rbIdx].rbType == RB_TYPE_SRB)
15889 memcpy(&ueCb->f1UeDb->duUeCfg.rlcLcCfg[ueCb->f1UeDb->duUeCfg.numRlcLcs++], &ueCb->rlcUeCfg.rlcLcCfg[rbIdx],\
15890 sizeof(RlcBearerCfg));
15893 ret = BuildSrbSetupModList(&ueContextModifyRes->protocolIEs.list.array[ieIdx]->value.choice.SRBs_SetupMod_List, \
15894 &ueCb->f1UeDb->duUeCfg);
15897 DU_LOG( "\nERROR --> F1AP : Failed to build SRB setupmod List ");
15902 freeF1UeDb(ueCb->f1UeDb);
15903 ueCb->f1UeDb = NULLP;
15905 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
15907 /* Encode the F1SetupRequest type as APER */
15908 memset(encBuf, 0, ENC_BUF_MAX_LEN);
15910 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf,encBuf);
15912 /* Encode results */
15913 if(encRetVal.encoded == ENCODE_FAIL)
15915 DU_LOG( "\nERROR --> F1AP : Could not encode UE Context Setup Request structure (at %s)\n",\
15916 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
15922 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UE Context Modification Response\n");
15923 #ifdef DEBUG_ASN_PRINT
15924 for(int i=0; i< encBufSize; i++)
15926 printf("%x",encBuf[i]);
15932 if(sendF1APMsg() != ROK)
15934 DU_LOG("\nERROR --> F1AP : Sending UE Context Setup Res Failed");
15942 FreeUeContextModResp(f1apMsg);
15945 /*******************************************************************
15947 * @brief Deallocating the memory allocated by the aper decoder
15952 * Function : freeAperDecodeQosInfo
15954 * Functionality: Deallocating the memory allocated for QOSInfo
15956 * @params[in] QoSFlowLevelQoSParameters_t *drbQos
15960 * ****************************************************************/
15962 void freeAperDecodeQosInfo(QoSFlowLevelQoSParameters_t *drbQos)
15964 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI != NULLP)
15966 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow!=NULLP)
15968 if(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume!=NULLP)
15970 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->maxDataBurstVolume);
15972 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI->averagingWindow);
15974 free(drbQos->qoS_Characteristics.choice.non_Dynamic_5QI);
15977 /*******************************************************************
15979 * @brief Deallocating the memory allocated by the aper decoder
15980 * for UlTnlInfoforDrb
15984 * Function : freeAperDecodeUlTnlInfoforDrbSetupMod
15986 * Functionality: Deallocating memory allocated for UlTnlInfoforDrb
15988 * @params[in] ULUPTNLInformation_ToBeSetup_List_t *ulInfo
15992 * ****************************************************************/
15993 void freeAperDecodeUlTnlInfoforDrbSetupMod(ULUPTNLInformation_ToBeSetup_List_t *ulInfo)
15997 if(ulInfo->list.array)
15999 for(arrIdx=0; arrIdx<ulInfo->list.count ; arrIdx++)
16001 if(ulInfo->list.array[arrIdx])
16003 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel )
16005 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->transportLayerAddress.buf)
16007 if(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->gTP_TEID.buf)
16009 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\
16012 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel->\
16013 transportLayerAddress.buf);
16015 free(ulInfo->list.array[arrIdx]->uLUPTNLInformation.choice.gTPTunnel);
16017 free(ulInfo->list.array[arrIdx]);
16020 free(ulInfo->list.array);
16023 /*******************************************************************
16025 * @brief Deallocating the memory allocated by the aper decoder
16026 * for DrbSetupModItem
16030 * Function : freeAperDecodeDrbSetupModItem
16032 * Functionality: Deallocating memory allocated for DrbSetupModItem
16034 * @params[in] DRBs_ToBeSetupMod_Item_t *drbItem
16038 * ****************************************************************/
16040 void freeAperDecodeDrbSetupModItem(DRBs_ToBeSetupMod_Item_t *drbItem)
16043 SNSSAI_t *snssai =NULLP;
16044 Flows_Mapped_To_DRB_List_t *flowMap = NULLP;
16046 drbItem->qoSInformation.present = QoSInformation_PR_choice_extension;
16047 switch(drbItem->qoSInformation.present)
16049 case QoSInformation_PR_NOTHING:
16051 case QoSInformation_PR_eUTRANQoS:
16053 if(drbItem->qoSInformation.choice.eUTRANQoS)
16055 free(drbItem->qoSInformation.choice.eUTRANQoS);
16059 case QoSInformation_PR_choice_extension:
16061 if(drbItem->qoSInformation.choice.choice_extension)
16063 freeAperDecodeQosInfo(&drbItem->qoSInformation.choice.choice_extension->value.choice.\
16064 DRB_Information.dRB_QoS);
16065 snssai = &drbItem->qoSInformation.choice.choice_extension->value.choice.DRB_Information.sNSSAI;
16066 if(snssai->sST.buf)
16068 free(snssai->sST.buf);
16072 if(snssai->sD->buf)
16074 free(snssai->sD->buf);
16079 flowMap = &drbItem->qoSInformation.choice.choice_extension->value.choice.\
16080 DRB_Information.flows_Mapped_To_DRB_List;
16081 if(flowMap->list.array)
16083 for(arrIdx=0; arrIdx<flowMap->list.count; arrIdx++)
16085 if(flowMap->list.array[arrIdx] )
16087 freeAperDecodeQosInfo(&flowMap->list.array[arrIdx]->qoSFlowLevelQoSParameters);
16088 free(flowMap->list.array[arrIdx]);
16091 free(flowMap->list.array);
16094 free(drbItem->qoSInformation.choice.choice_extension);
16100 freeAperDecodeUlTnlInfoforDrbSetupMod(&drbItem->uLUPTNLInformation_ToBeSetup_List);
16101 if(drbItem->uLConfiguration)
16103 free(drbItem->uLConfiguration);
16107 /*******************************************************************
16109 * @brief Deallocating the memory allocated by the aper decoder
16110 * for DrbToBeSetupModList
16114 * Function : freeAperDecodeDrbToBeSetupModList
16116 * Functionality: Deallocating memory allocated for DrbToBeSetupModList
16118 * @params[in] DRBs_ToBeSetupMod_List_t *drbSet
16122 * ****************************************************************/
16124 void freeAperDecodeDrbToBeSetupModList(DRBs_ToBeSetupMod_List_t *drbSet)
16127 struct DRBs_ToBeSetupMod_ItemIEs *drbItemIe;
16129 if(drbSet->list.array)
16131 for(arrIdx=0; arrIdx<drbSet->list.count ; arrIdx++)
16133 if(drbSet->list.array[arrIdx] != NULLP)
16137 drbItemIe = (DRBs_ToBeSetupMod_ItemIEs_t *)drbSet->list.array[arrIdx];
16138 freeAperDecodeDrbSetupModItem(&(drbItemIe->value.choice.DRBs_ToBeSetupMod_Item));
16140 free(drbSet->list.array[arrIdx]);
16143 free(drbSet->list.array);
16147 /*******************************************************************
16149 * @brief Deallocating the memory allocated by the aper decoder
16150 * for UeContextModificationReqMsg
16154 * Function : freeAperDecodeUeContextModificationReqMsg
16156 * Functionality: Deallocating memory allocated for
16157 * UeContextModificationReqMsg
16159 * @params[in] UEContextModificationRequest_t *UeContextModifyReq
16163 * ****************************************************************/
16164 void freeAperDecodeUeContextModificationReqMsg(UEContextModificationRequest_t *ueContextModifyReq )
16166 uint8_t arrIdx, ieId;
16168 if(ueContextModifyReq->protocolIEs.list.array)
16170 for( arrIdx = 0 ; arrIdx<ueContextModifyReq->protocolIEs.list.count ; arrIdx++)
16172 if(ueContextModifyReq->protocolIEs.list.array[arrIdx])
16174 ieId = ueContextModifyReq->protocolIEs.list.array[arrIdx]->id;
16177 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
16179 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
16181 case ProtocolIE_ID_id_DRBs_ToBeSetupMod_List:
16183 freeAperDecodeDrbToBeSetupModList(&ueContextModifyReq->protocolIEs.list.array[arrIdx]->\
16184 value.choice.DRBs_ToBeSetupMod_List);
16187 case ProtocolIE_ID_id_TransmissionActionIndicator:
16189 case ProtocolIE_ID_id_RRCContainer:
16191 free(ueContextModifyReq->protocolIEs.list.array[arrIdx]->value.choice.RRCContainer.buf);
16194 free(ueContextModifyReq->protocolIEs.list.array[arrIdx]);
16197 free(ueContextModifyReq->protocolIEs.list.array);
16200 /*******************************************************************
16202 * @brief processing the F1 UeContextModificationReq
16206 * Function : procF1UeContextModificationReq
16208 * Functionality: processing the F1 UeContextModificationReq
16210 * @params[in] F1AP_PDU_t *f1apMsg
16213 * ****************************************************************/
16214 uint8_t procF1UeContextModificationReq(F1AP_PDU_t *f1apMsg)
16216 UEContextModificationRequest_t *ueContextModifyReq = NULLP;
16217 uint8_t ret = ROK, ieIdx = 0, cellIdx=0;
16218 DuUeCb *duUeCb = NULLP;
16219 DRBs_ToBeSetupMod_List_t *drbSetupModCfg;
16220 DRBs_ToBeModified_List_t *drbModifiedCfg;
16221 uint32_t gnbCuUeF1apId, gnbDuUeF1apId;
16223 ueContextModifyReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextModificationRequest;
16224 for(ieIdx=0; (ieIdx < ueContextModifyReq->protocolIEs.list.count && ret == ROK); ieIdx++)
16226 switch(ueContextModifyReq->protocolIEs.list.array[ieIdx]->id)
16228 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
16230 gnbCuUeF1apId = ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID;
16233 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
16235 gnbDuUeF1apId = ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID;
16236 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
16238 if(duCb.actvCellLst[cellIdx])
16240 if((duCb.actvCellLst[cellIdx]->ueCb[gnbDuUeF1apId-1].gnbDuUeF1apId == gnbDuUeF1apId)&&\
16241 (duCb.actvCellLst[cellIdx]->ueCb[gnbDuUeF1apId-1].gnbCuUeF1apId == gnbCuUeF1apId))
16243 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[gnbDuUeF1apId-1];
16244 if(duUeCb->f1UeDb == NULLP)
16246 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
16247 duUeCb->f1UeDb->cellIdx = cellIdx;
16248 duUeCb->f1UeDb->actionType = UE_CTXT_MOD;
16254 if(duUeCb == NULLP)
16256 DU_LOG("\nERROR --> DU APP : wrong values of gnbCuUeF1apId and gnbDuUeF1apId ");
16262 case ProtocolIE_ID_id_RRCContainer:
16264 /* Filling Dl RRC Msg Info */
16265 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
16266 if(!duUeCb->f1UeDb->dlRrcMsg)
16268 DU_LOG("\nERROR --> DU APP : procF1UeContextReleaseCommand(): \
16269 Memory allocation failed ");
16274 duUeCb->f1UeDb->dlRrcMsgPres = true;
16275 memset(duUeCb->f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
16276 ret = extractDlRrcMsg(gnbDuUeF1apId, gnbCuUeF1apId, duUeCb->f1UeDb->dlRrcMsg,\
16277 &ueContextModifyReq->protocolIEs.list.array[ieIdx]->\
16278 value.choice.RRCContainer);
16284 case ProtocolIE_ID_id_DRBs_ToBeSetupMod_List:
16285 case ProtocolIE_ID_id_DRBs_ToBeModified_List:
16289 if(ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.present ==\
16290 UEContextModificationRequestIEs__value_PR_DRBs_ToBeSetupMod_List)
16292 drbSetupModCfg = &ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.\
16293 choice.DRBs_ToBeSetupMod_List;
16295 if(extractDrbListToSetupMod(NULL, drbSetupModCfg, NULL, drbSetupModCfg->list.count,\
16296 &duUeCb->f1UeDb->duUeCfg, &duUeCb->drbBitMap, NULL))
16298 DU_LOG("\nERROR --> DU APP : Failed at extractDrbListToSetupMod() for DrbSetupModList");
16303 if(ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.present == \
16304 UEContextModificationRequestIEs__value_PR_DRBs_ToBeModified_List)
16307 drbModifiedCfg = &ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.\
16308 choice.DRBs_ToBeModified_List;
16309 if(extractDrbListToSetupMod(NULL, NULL, drbModifiedCfg, drbModifiedCfg->list.count,\
16310 &duUeCb->f1UeDb->duUeCfg, &duUeCb->drbBitMap, &duUeCb->rlcUeCfg))
16312 DU_LOG("\nERROR --> DU APP : Failed at extractDrbListToSetupMod() for DrbModifiedList");
16320 case ProtocolIE_ID_id_GNB_DUConfigurationQuery:
16322 DU_LOG("\nINFO --> DU APP : Received GNB DU Configuration Query in UE Context Modification Request from CU");
16325 duUeCb->f1UeDb->actionType = UE_CTXT_CFG_QUERY;
16330 case ProtocolIE_ID_id_RRCReconfigurationCompleteIndicator:
16332 if(ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.RRCReconfigurationCompleteIndicator == \
16333 RRCReconfigurationCompleteIndicator_true)
16335 duUeCb->f1UeDb->actionType = UE_CTXT_RRC_RECFG_COMPLETE;
16339 case ProtocolIE_ID_id_TransmissionActionIndicator:
16343 if(ueContextModifyReq->protocolIEs.list.array[ieIdx]->value.choice.TransmissionActionIndicator == TransmissionActionIndicator_stop)
16345 duUeCb->f1UeDb->duUeCfg.dataTransmissionAction = STOP_TRANSMISSION;
16349 duUeCb->f1UeDb->duUeCfg.dataTransmissionAction = RESTART_TRANSMISSION;
16355 case ProtocolIE_ID_id_RRCDeliveryStatusRequest:
16357 if(duUeCb->f1UeDb->dlRrcMsg->rrcMsgPdu)
16359 duUeCb->f1UeDb->dlRrcMsg->deliveryStatRpt = true;
16369 ret = duProcUeContextModReq(duUeCb);
16371 freeAperDecodeUeContextModificationReqMsg(ueContextModifyReq);
16375 /*****************************************************************i
16377 * @brief Free memory allocated for UE Context Release Request
16381 * Function : FreeUeContextReleaseReq
16384 * - Free memory allocated for UE Context Release Request
16386 * @params[in] F1AP_PDU_t *f1apMsg
16389 * *************************************************************/
16390 void FreeUeContextReleaseReq(F1AP_PDU_t *f1apMsg)
16393 UEContextReleaseRequest_t *ueReleaseReq = NULLP;
16397 if(f1apMsg->choice.initiatingMessage)
16399 ueReleaseReq =&f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseRequest;
16400 if(ueReleaseReq->protocolIEs.list.array)
16402 for(ieIdx=0 ; ieIdx<ueReleaseReq->protocolIEs.list.count; ieIdx++)
16404 DU_FREE(ueReleaseReq->protocolIEs.list.array[ieIdx], sizeof(UEContextReleaseRequest_t));
16406 DU_FREE(ueReleaseReq->protocolIEs.list.array, ueReleaseReq->protocolIEs.list.size);
16408 DU_FREE(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
16410 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
16414 /*****************************************************************i
16416 * @brief Build and Send UE Context Release Request
16420 * Function : BuildAndSendUeContextReleaseReq
16423 * - Build and Send UE Context Release Request
16426 * @return ROK - success
16427 * RFAILED - failure
16429 * *************************************************************/
16430 uint8_t BuildAndSendUeContextReleaseReq(uint16_t cellId, uint8_t ueId)
16432 bool memAllocFail = false;
16434 uint8_t ret = RFAILED;
16435 uint16_t cellIdx =0;
16436 uint16_t crnti = 0;
16437 uint8_t elementCnt = 0;
16438 uint32_t gnbCuUeF1apId =0; /* gNB-CU UE F1AP Id */
16439 uint32_t gnbDuUeF1apId =0; /* gNB-DU UE F1AP Id */
16440 asn_enc_rval_t encRetVal;
16441 F1AP_PDU_t *f1apMsg = NULLP;
16442 UEContextReleaseRequest_t *ueReleaseReq = NULLP;
16444 DU_LOG("\nINFO --> Building the UE Context Release Request");
16447 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
16448 if(f1apMsg == NULLP)
16450 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for f1apMsg");
16454 f1apMsg->present = F1AP_PDU_PR_initiatingMessage;
16455 DU_ALLOC(f1apMsg->choice.initiatingMessage, sizeof(InitiatingMessage_t));
16456 if(f1apMsg->choice.initiatingMessage == NULLP)
16458 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for\
16459 initiatingMessage");
16462 f1apMsg->choice.initiatingMessage->procedureCode = ProcedureCode_id_UEContextReleaseRequest;
16463 f1apMsg->choice.initiatingMessage->criticality = Criticality_reject;
16464 f1apMsg->choice.initiatingMessage->value.present = \
16465 InitiatingMessage__value_PR_UEContextReleaseRequest;
16467 ueReleaseReq = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseRequest;
16471 ueReleaseReq->protocolIEs.list.count = elementCnt;
16472 ueReleaseReq->protocolIEs.list.size = elementCnt * sizeof(UEContextReleaseRequest_t *);
16474 /* Initialize the F1Setup members */
16475 DU_ALLOC(ueReleaseReq->protocolIEs.list.array,ueReleaseReq->protocolIEs.list.size);
16476 if(ueReleaseReq->protocolIEs.list.array == NULLP)
16478 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for IE array");
16481 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
16483 DU_ALLOC(ueReleaseReq->protocolIEs.list.array[ieIdx],\
16484 sizeof(UEContextReleaseRequest_t));
16485 if(ueReleaseReq->protocolIEs.list.array[ieIdx] == NULLP)
16487 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): Memory allocation failed for IE elements");
16488 memAllocFail = true;
16492 if(memAllocFail == true)
16495 /* Fetching Ue Cb Info*/
16496 GET_CELL_IDX(cellId, cellIdx);
16497 if(duCb.actvCellLst[cellIdx] == NULLP)
16499 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): CellId[%d] does not exist", cellId);
16504 GET_CRNTI(crnti, ueId);
16505 if(duCb.actvCellLst[cellIdx]->ueCb[ueId-1].crnti != crnti)
16507 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseReq(): crnti[%d] does not exist", crnti);
16510 gnbDuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbDuUeF1apId;
16511 gnbCuUeF1apId = duCb.actvCellLst[cellIdx]->ueCb[ueId-1].gnbCuUeF1apId;
16515 ueReleaseReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
16516 ueReleaseReq->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
16517 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.present = \
16518 UEContextReleaseRequestIEs__value_PR_GNB_CU_UE_F1AP_ID;
16519 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID =gnbCuUeF1apId;
16522 ueReleaseReq->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
16523 ueReleaseReq->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
16524 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.present =\
16525 UEContextReleaseRequestIEs__value_PR_GNB_DU_UE_F1AP_ID;
16526 ueReleaseReq->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID =gnbDuUeF1apId;
16528 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
16530 /* Encode the F1SetupRequest type as APER */
16531 memset(encBuf, 0, ENC_BUF_MAX_LEN);
16533 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
16534 /* Encode results */
16535 if(encRetVal.encoded == ENCODE_FAIL)
16537 DU_LOG("\nERROR --> F1AP : Could not encode UEContextReleaseRequest structure (at %s)\n",\
16538 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
16543 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UEContextReleaseRequest\n");
16544 #ifdef DEBUG_ASN_PRINT
16545 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
16547 printf("%x",encBuf[ieIdx]);
16553 if(sendF1APMsg() != ROK)
16555 DU_LOG("\nERROR --> F1AP : Sending UE Context Release Request failed");
16562 FreeUeContextReleaseReq(f1apMsg);
16565 /*****************************************************************i
16567 * @brief Free memory allocated for UE Context Release Complete
16571 * Function : FreeUeContextReleaseComplete
16574 * - Free memory allocated for UE Context Release Complete
16576 * @params[in] F1AP_PDU_t *f1apMsg
16579 * *************************************************************/
16580 void FreeUeContextReleaseComplete(F1AP_PDU_t *f1apMsg)
16583 UEContextReleaseComplete_t *ueReleaseComplete = NULLP;
16587 if(f1apMsg->choice.successfulOutcome)
16589 ueReleaseComplete =&f1apMsg->choice.successfulOutcome->value.choice.UEContextReleaseComplete;
16590 if(ueReleaseComplete->protocolIEs.list.array)
16592 for(ieIdx=0 ; ieIdx<ueReleaseComplete->protocolIEs.list.count; ieIdx++)
16594 DU_FREE(ueReleaseComplete->protocolIEs.list.array[ieIdx], sizeof(UEContextReleaseComplete_t));
16596 DU_FREE(ueReleaseComplete->protocolIEs.list.array, ueReleaseComplete->protocolIEs.list.size);
16598 DU_FREE(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
16600 DU_FREE(f1apMsg, sizeof(F1AP_PDU_t));
16604 /*****************************************************************i
16606 * @brief Build and Send UE Context Release Complete
16610 * Function : BuildAndSendUeContextReleaseComplete
16613 * - Build and Send UE Context Release Complete
16615 * @params[in] cellId, gnbCuUeF1apId, gnbDuUeF1apId
16616 * @return ROK - success
16617 * RFAILED - failure
16619 * *************************************************************/
16620 uint8_t BuildAndSendUeContextReleaseComplete(uint16_t cellId, uint32_t gnbCuUeF1apId, uint32_t gnbDuUeF1apId)
16622 bool memAllocFail = false;
16623 uint8_t ieIdx =0, ret = RFAILED, elementCnt = 0;
16624 asn_enc_rval_t encRetVal;
16625 F1AP_PDU_t *f1apMsg = NULLP;
16626 UEContextReleaseComplete_t *ueReleaseComplete = NULLP;
16628 DU_LOG("\nINFO --> Building the UE Context Release Complete");
16631 DU_ALLOC(f1apMsg, sizeof(F1AP_PDU_t));
16632 if(f1apMsg == NULLP)
16634 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for f1apMsg");
16638 f1apMsg->present = F1AP_PDU_PR_successfulOutcome;
16639 DU_ALLOC(f1apMsg->choice.successfulOutcome, sizeof(SuccessfulOutcome_t));
16640 if(f1apMsg->choice.successfulOutcome == NULLP)
16642 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for\
16643 successfulOutcome");
16646 f1apMsg->choice.successfulOutcome->procedureCode = ProcedureCode_id_UEContextRelease;
16647 f1apMsg->choice.successfulOutcome->criticality = Criticality_reject;
16648 f1apMsg->choice.successfulOutcome->value.present = \
16649 SuccessfulOutcome__value_PR_UEContextReleaseComplete;
16651 ueReleaseComplete = &f1apMsg->choice.successfulOutcome->value.choice.UEContextReleaseComplete;
16654 ueReleaseComplete->protocolIEs.list.count = elementCnt;
16655 ueReleaseComplete->protocolIEs.list.size = elementCnt * sizeof(UEContextReleaseComplete_t *);
16657 /* Initialize the UE Release Complete members */
16658 DU_ALLOC(ueReleaseComplete->protocolIEs.list.array,ueReleaseComplete->protocolIEs.list.size);
16659 if(ueReleaseComplete->protocolIEs.list.array == NULLP)
16661 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for IE array");
16664 for(ieIdx=0; ieIdx<elementCnt; ieIdx++)
16666 DU_ALLOC(ueReleaseComplete->protocolIEs.list.array[ieIdx],\
16667 sizeof(UEContextReleaseComplete_t));
16668 if(ueReleaseComplete->protocolIEs.list.array[ieIdx] == NULLP)
16670 DU_LOG("\nERROR --> F1AP : BuildAndSendUeContextReleaseComplete(): Memory allocation failed for IE\
16672 memAllocFail = true;
16676 if(memAllocFail == true)
16681 ueReleaseComplete->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
16682 ueReleaseComplete->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
16683 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.present = \
16684 UEContextReleaseCompleteIEs__value_PR_GNB_CU_UE_F1AP_ID;
16685 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.choice.GNB_CU_UE_F1AP_ID =gnbCuUeF1apId;
16688 ueReleaseComplete->protocolIEs.list.array[ieIdx]->id = ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
16689 ueReleaseComplete->protocolIEs.list.array[ieIdx]->criticality= Criticality_reject;
16690 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.present =\
16691 UEContextReleaseCompleteIEs__value_PR_GNB_DU_UE_F1AP_ID;
16692 ueReleaseComplete->protocolIEs.list.array[ieIdx]->value.choice.GNB_DU_UE_F1AP_ID =gnbDuUeF1apId;
16694 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
16696 /* Encode the F1SetupComplete type as APER */
16697 memset(encBuf, 0, ENC_BUF_MAX_LEN);
16699 encRetVal = aper_encode(&asn_DEF_F1AP_PDU, 0, f1apMsg, PrepFinalEncBuf, encBuf);
16700 /* Encode results */
16701 if(encRetVal.encoded == ENCODE_FAIL)
16703 DU_LOG("\nERROR --> F1AP : Could not encode UEContextReleaseComplete structure (at %s)\n",\
16704 encRetVal.failed_type ? encRetVal.failed_type->name : "unknown");
16709 DU_LOG("\nDEBUG --> F1AP : Created APER encoded buffer for UEContextReleaseComplete\n");
16710 #ifdef DEBUG_ASN_PRINT
16711 for(ieIdx=0; ieIdx< encBufSize; ieIdx++)
16713 printf("%x",encBuf[ieIdx]);
16719 if(sendF1APMsg() != ROK)
16721 DU_LOG("\nERROR --> F1AP : Sending UE Context Release Complete failed");
16728 if((ret == ROK) && (duCb.actvCellLst[cellId-1]) && (duCb.actvCellLst[cellId-1]->cellStatus == DELETION_IN_PROGRESS)
16729 && (duCb.actvCellLst[cellId-1]->numActvUes == 0))
16731 ret = duSendCellDeletReq(cellId);
16734 DU_LOG("\nERROR --> F1AP: BuildAndSendUeContextReleaseComplete(): Failed to process cell\
16735 Delete req for CellId");
16738 FreeUeContextReleaseComplete(f1apMsg);
16743 /*******************************************************************
16745 * @brief added free part for the memory allocated by aper_decoder
16749 * Function : freeAperDecodeUeContextReleaseCommand
16751 * Functionality: added free part for the memory allocated by aper_decoder
16753 * @params[in] F1AP_PDU_t *f1apMsg
16756 * ****************************************************************/
16757 void freeAperDecodeUeContextReleaseCommand(F1AP_PDU_t *f1apMsg)
16760 UEContextReleaseCommand_t *ueContextReleaseCommand = NULLP;
16762 ueContextReleaseCommand = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseCommand;
16764 if(ueContextReleaseCommand->protocolIEs.list.array)
16766 for(ieIdx=0; ieIdx < ueContextReleaseCommand->protocolIEs.list.count; ieIdx++)
16768 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx])
16770 switch(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id)
16772 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
16774 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
16776 case ProtocolIE_ID_id_Cause:
16778 case ProtocolIE_ID_id_RRCContainer:
16780 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf)
16782 free(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->value.choice.RRCContainer.buf);
16787 DU_LOG("\nERROR --> F1AP: freeAperDecodeUeContextReleaseCommand():Invalid IE Received: %ld"\
16788 ,ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id);
16792 free(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]);
16794 free(ueContextReleaseCommand->protocolIEs.list.array);
16797 /*******************************************************************
16799 * @brief processing of UE Context Release Command
16803 * Function : procF1UeContextReleaseCommand
16805 * Functionality: processing of UE Context Release Command
16807 * @params[in] F1AP_PDU_t *f1apMsg
16810 * ****************************************************************/
16811 uint8_t procF1UeContextReleaseCommand(F1AP_PDU_t *f1apMsg)
16813 uint8_t ieIdx=0, ret=ROK, ueIdx=0;
16814 uint16_t cellIdx =0, cellId = 0;
16815 bool ueIdxFound = false;
16816 uint32_t gnbCuUeF1apId=0, gnbDuUeF1apId=0;
16817 DuUeCb *duUeCb = NULLP;
16818 UEContextReleaseCommand_t *ueContextReleaseCommand = NULLP;
16820 ueContextReleaseCommand = &f1apMsg->choice.initiatingMessage->value.choice.UEContextReleaseCommand;
16822 if(ueContextReleaseCommand->protocolIEs.list.array)
16824 for(ieIdx=0; ieIdx < ueContextReleaseCommand->protocolIEs.list.count; ieIdx++)
16826 if(ueContextReleaseCommand->protocolIEs.list.array[ieIdx])
16828 switch(ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id)
16830 case ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID:
16832 gnbCuUeF1apId= ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
16833 value.choice.GNB_CU_UE_F1AP_ID;
16837 case ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID:
16839 gnbDuUeF1apId = ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
16840 value.choice.GNB_DU_UE_F1AP_ID;
16844 case ProtocolIE_ID_id_Cause:
16846 for(cellIdx = 0; cellIdx < MAX_NUM_CELL; cellIdx++)
16848 for(ueIdx = 0; ueIdx < MAX_NUM_UE; ueIdx++)
16850 if(duCb.actvCellLst[cellIdx] && (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbDuUeF1apId == gnbDuUeF1apId)&&\
16851 (duCb.actvCellLst[cellIdx]->ueCb[ueIdx].gnbCuUeF1apId == gnbCuUeF1apId))
16853 cellId = duCb.actvCellLst[cellIdx]->cellId;
16854 duUeCb = &duCb.actvCellLst[cellIdx]->ueCb[ueIdx];
16859 if(ueIdxFound == true)
16867 DU_LOG("\nERROR --> F1AP: procF1UeContextReleaseCommand(): Ue Information is not available");
16873 case ProtocolIE_ID_id_RRCContainer:
16875 if(ueIdxFound == true)
16877 DU_ALLOC(duUeCb->f1UeDb, sizeof(F1UeContextSetupDb));
16880 memset(duUeCb->f1UeDb, 0, sizeof(F1UeContextSetupDb));
16881 duUeCb->f1UeDb->actionType = UE_CTXT_RELEASE;
16882 duUeCb->f1UeDb->cellIdx = cellIdx;
16883 /* Filling Dl RRC Msg Info */
16884 DU_ALLOC_SHRABL_BUF(duUeCb->f1UeDb->dlRrcMsg, sizeof(F1DlRrcMsg));
16885 if(!duUeCb->f1UeDb->dlRrcMsg)
16887 DU_LOG("\nERROR --> DU APP : procF1UeContextReleaseCommand(): \
16888 Memory allocation failed ");
16893 duUeCb->f1UeDb->dlRrcMsgPres = true;
16894 memset(duUeCb->f1UeDb->dlRrcMsg, 0, sizeof(F1DlRrcMsg));
16895 ret = extractDlRrcMsg(gnbDuUeF1apId, gnbCuUeF1apId, duUeCb->f1UeDb->dlRrcMsg,\
16896 &ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->\
16897 value.choice.RRCContainer);
16903 DU_LOG("\nERROR --> DU APP : procF1UeContextReleaseCommand(): \
16904 Memory allocation failed ");
16912 DU_LOG("\nERROR --> F1AP: freeAperDecodeUeContextReleaseCommand():Invalid IE Received: %ld"\
16913 ,ueContextReleaseCommand->protocolIEs.list.array[ieIdx]->id);
16921 duProcUeContextReleaseCommand(cellId, duUeCb);
16923 freeAperDecodeUeContextReleaseCommand(f1apMsg);
16927 /**************************************************************
16929 * @brief free the memory allocated by aper decoder for paging
16933 * Function : freeAperDecodePagingMsg
16936 * - free the memory allocated by aper decoder for
16937 * the paging f1ap msg
16939 * @params[in] Paging_t *paging
16940 * @return ROK - success
16941 * RFAILED - failure
16943 ****************************************************************/
16944 void freeAperDecodePagingMsg(Paging_t *paging)
16946 uint8_t ieIdx, cellIdx;
16947 PagingCell_ItemIEs_t *pagingCellItemIes;
16948 PagingCell_Item_t *pagingCellItem;
16949 PagingCell_list_t *pagingCelllist;
16953 if(paging->protocolIEs.list.array)
16955 for(ieIdx=0 ; ieIdx<paging->protocolIEs.list.count; ieIdx++)
16957 if(paging->protocolIEs.list.array[ieIdx])
16959 switch(paging->protocolIEs.list.array[ieIdx]->id)
16961 case ProtocolIE_ID_id_UEIdentityIndexValue:
16963 free(paging->protocolIEs.list.array[ieIdx]->value.choice.UEIdentityIndexValue.choice.indexLength10.buf);
16966 case ProtocolIE_ID_id_PagingIdentity:
16968 if(paging->protocolIEs.list.array[ieIdx]->value.choice.PagingIdentity.present == PagingIdentity_PR_cNUEPagingIdentity)
16970 if(paging->protocolIEs.list.array[ieIdx]->value.choice.PagingIdentity.choice.cNUEPagingIdentity)
16972 if(paging->protocolIEs.list.array[ieIdx]->value.choice.PagingIdentity.choice.cNUEPagingIdentity->present == \
16973 CNUEPagingIdentity_PR_fiveG_S_TMSI)
16975 free(paging->protocolIEs.list.array[ieIdx]->value.choice.PagingIdentity.choice.cNUEPagingIdentity->choice.fiveG_S_TMSI.buf);
16977 free(paging->protocolIEs.list.array[ieIdx]->value.choice.PagingIdentity.choice.cNUEPagingIdentity);
16982 case ProtocolIE_ID_id_PagingCell_List:
16984 pagingCelllist = &paging->protocolIEs.list.array[ieIdx]->value.choice.PagingCell_list;
16985 if(pagingCelllist->list.array)
16987 for(cellIdx = 0; cellIdx < pagingCelllist->list.count; cellIdx++)
16989 if(pagingCelllist->list.array[cellIdx])
16991 pagingCellItemIes = (PagingCell_ItemIEs_t *)pagingCelllist->list.array[cellIdx];
16992 if(pagingCellItemIes->id == ProtocolIE_ID_id_PagingCell_Item)
16994 pagingCellItem = &pagingCellItemIes->value.choice.PagingCell_Item;
16995 free(pagingCellItem->nRCGI.pLMN_Identity.buf);
16996 free(pagingCellItem->nRCGI.nRCellIdentity.buf);
16998 free(pagingCelllist->list.array[cellIdx]);
17001 free(pagingCelllist->list.array);
17006 free(paging->protocolIEs.list.array[ieIdx]);
17009 free(paging->protocolIEs.list.array);
17015 /**************************************************************
17017 * @brief processing the paging f1ap msg received from CU
17021 * Function : procPagingMsg
17024 * - processing the paging f1ap msg received from CU
17026 * @params[in] F1AP_PDU_t *f1apMsg
17027 * @return ROK - success
17028 * RFAILED - failure
17031 ****************************************************************/
17032 uint8_t procPagingMsg(F1AP_PDU_t *f1apMsg)
17034 uint8_t ieIdx = 0, cellListIdx = 0;
17035 uint64_t cellId = 0;
17036 Paging_t *paging = NULLP;
17037 PagingCell_list_t *pagingCelllist = NULLP;
17038 PagingCell_ItemIEs_t *pagingCellItemIes = NULLP;
17039 PagingCell_Item_t *pagingCellItem = NULLP;
17040 DuPagingMsg *tmpPagingParam = NULLP;
17042 paging = &f1apMsg->choice.initiatingMessage->value.choice.Paging;
17045 if(paging->protocolIEs.list.array)
17047 DU_ALLOC(tmpPagingParam, sizeof(DuPagingMsg));
17048 if(tmpPagingParam == NULLP)
17050 DU_LOG("\nERROR --> DU APP : Memory Allocation Failure in procPagingMsg");
17051 freeAperDecodePagingMsg(paging);
17054 for(ieIdx=0 ; ieIdx<paging->protocolIEs.list.count; ieIdx++)
17056 if(paging->protocolIEs.list.array[ieIdx])
17058 switch(paging->protocolIEs.list.array[ieIdx]->id)
17060 case ProtocolIE_ID_id_UEIdentityIndexValue:
17062 bitStringToInt(&paging->protocolIEs.list.array[ieIdx]->value.choice.UEIdentityIndexValue.choice.indexLength10,\
17063 &tmpPagingParam->pagUeId);
17067 case ProtocolIE_ID_id_PagingIdentity:
17069 switch(paging->protocolIEs.list.array[ieIdx]->value.choice.PagingIdentity.present)
17071 case PagingIdentity_PR_cNUEPagingIdentity:
17073 if(paging->protocolIEs.list.array[ieIdx]->value.choice.PagingIdentity.choice.cNUEPagingIdentity)
17075 bitStringToInt(&paging->protocolIEs.list.array[ieIdx]->value.choice.PagingIdentity.choice.\
17076 cNUEPagingIdentity->choice.fiveG_S_TMSI, &tmpPagingParam->sTmsi);
17081 case PagingIdentity_PR_rANUEPagingIdentity:
17083 /*TODO: This Identifier is specific to RAN Initiated Paging – Connected Mode Paging*/
17088 DU_LOG("ERROR --> DU APP: Invalid UE Paging Identity, Skipping this Paging Message:");
17094 case ProtocolIE_ID_id_PagingDRX:
17096 tmpPagingParam->pagingDrxPres = TRUE;
17097 tmpPagingParam->pagingDrx = convertPagingCycleEnumToValue(paging->protocolIEs.list.array[ieIdx]->value.choice.PagingDRX);
17101 case ProtocolIE_ID_id_PagingPriority:
17103 tmpPagingParam->pagPriority = paging->protocolIEs.list.array[ieIdx]->value.choice.PagingPriority;
17107 case ProtocolIE_ID_id_PagingCell_List:
17109 pagingCelllist = &paging->protocolIEs.list.array[ieIdx]->value.choice.PagingCell_list;
17110 if(pagingCelllist->list.array)
17112 for(cellListIdx = 0; cellListIdx < pagingCelllist->list.count; cellListIdx++)
17114 if(pagingCelllist->list.array[cellListIdx])
17116 pagingCellItemIes = (PagingCell_ItemIEs_t *)pagingCelllist->list.array[cellListIdx];
17117 pagingCellItem = &pagingCellItemIes->value.choice.PagingCell_Item;
17118 bitStringToInt(&pagingCellItem->nRCGI.nRCellIdentity, &cellId);
17119 if(processPagingMsg(cellId, tmpPagingParam) != ROK)
17121 DU_LOG("\nERROR --> DU APP : Paging Processing Failed at CellId:%lu",cellId);
17131 DU_LOG("\nERROR --> F1AP : Incorrect Paging IE option");
17139 DU_FREE(tmpPagingParam, sizeof(DuPagingMsg));
17140 freeAperDecodePagingMsg(paging);
17145 /**************************************************************
17147 * @brief Handles received F1AP message and sends back response
17151 * Function : F1APMsgHdlr
17154 * - Decodes received F1AP control message
17155 * - Prepares response message, encodes and sends to SCTP
17158 * @return ROK - success
17159 * RFAILED - failure
17161 * ****************************************************************/
17162 void F1APMsgHdlr(Buffer *mBuf)
17165 char *recvBuf =NULLP;
17167 MsgLen recvBufLen =0;
17168 F1AP_PDU_t *f1apMsg =NULLP;
17169 asn_dec_rval_t rval; /* Decoder return value */
17170 F1AP_PDU_t f1apasnmsg ;
17171 DU_LOG("\nINFO --> F1AP : Received F1AP message buffer");
17172 ODU_PRINT_MSG(mBuf, 0,0);
17174 /* Copy mBuf into char array to decode it */
17175 ODU_GET_MSG_LEN(mBuf, &recvBufLen);
17176 DU_ALLOC(recvBuf, (Size)recvBufLen);
17178 if(recvBuf == NULLP)
17180 DU_LOG("\nERROR --> F1AP : Memory allocation failed");
17183 if(ODU_COPY_MSG_TO_FIX_BUF(mBuf, 0, recvBufLen, (Data *)recvBuf, ©Cnt) != ROK)
17185 DU_LOG("\nERROR --> F1AP : Failed while copying %d", copyCnt);
17189 #ifdef DEBUG_ASN_PRINT
17190 printf("\nDEBUG --> F1AP : Received flat buffer to be decoded : ");
17191 for(i=0; i< recvBufLen; i++)
17193 printf("%x",recvBuf[i]);
17197 /* Decoding flat buffer into F1AP messsage */
17198 f1apMsg = &f1apasnmsg;
17199 memset(f1apMsg, 0, sizeof(F1AP_PDU_t));
17201 rval = aper_decode(0, &asn_DEF_F1AP_PDU, (void **)&f1apMsg, recvBuf, recvBufLen, 0, 0);
17203 if(rval.code == RC_FAIL || rval.code == RC_WMORE)
17205 DU_LOG("\nERROR --> F1AP : ASN decode failed");
17209 xer_fprint(stdout, &asn_DEF_F1AP_PDU, f1apMsg);
17211 switch(f1apMsg->present)
17213 case F1AP_PDU_PR_successfulOutcome:
17215 switch(f1apMsg->choice.successfulOutcome->value.present)
17217 case SuccessfulOutcome__value_PR_ResetAcknowledge:
17219 DU_LOG("\nINFO --> F1AP : F1ResetAcknowledge is received successfully ");
17222 case SuccessfulOutcome__value_PR_F1SetupResponse:
17224 #ifndef ODU_TEST_STUB
17225 procF1SetupRsp(f1apMsg, recvBufLen, recvBuf);
17230 case SuccessfulOutcome__value_PR_GNBDUConfigurationUpdateAcknowledge:
17232 procF1GNBDUCfgUpdAck(f1apMsg);
17238 DU_LOG("\nERROR --> F1AP : Invalid type of SuccessfulOutcome__value_PR_ResetAcknowledge [%d]",\
17239 f1apMsg->choice.successfulOutcome->value.present);
17242 }/* End of switch(successfulOutcome) */
17243 free(f1apMsg->choice.successfulOutcome);
17246 case F1AP_PDU_PR_initiatingMessage:
17248 switch(f1apMsg->choice.initiatingMessage->value.present)
17250 case InitiatingMessage__value_PR_Reset:
17252 procF1ResetReq(f1apMsg);
17255 case InitiatingMessage__value_PR_DLRRCMessageTransfer:
17257 procF1DlRrcMsgTrans(f1apMsg);
17260 case InitiatingMessage__value_PR_UEContextSetupRequest:
17262 procF1UeContextSetupReq(f1apMsg);
17265 case InitiatingMessage__value_PR_UEContextModificationRequest:
17267 procF1UeContextModificationReq(f1apMsg);
17270 case InitiatingMessage__value_PR_UEContextReleaseCommand:
17272 procF1UeContextReleaseCommand(f1apMsg);
17275 case InitiatingMessage__value_PR_Paging:
17277 procPagingMsg(f1apMsg);
17282 DU_LOG("\nERROR --> F1AP : Invalid type of F1AP_PDU_PR_initiatingMessage [%d]",
17283 f1apMsg->choice.initiatingMessage->value.present);
17286 }/* End of switch(initiatingMessage) */
17287 free(f1apMsg->choice.initiatingMessage);
17293 DU_LOG("\nERROR --> F1AP : Invalid type of f1apMsg->present [%d]",f1apMsg->present);
17298 }/* End of switch(f1apMsg->present) */
17300 DU_FREE(recvBuf, (Size)recvBufLen);
17301 } /* End of F1APMsgHdlr */
17303 /**********************************************************************
17305 **********************************************************************/