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 *******************************************************************************/
18 #include "common_def.h"
25 #include "du_app_mac_inf.h"
26 #include "du_app_rlc_inf.h"
27 #include "du_e2ap_mgr.h"
28 #include "du_e2_conversions.h"
29 #include "du_e2ap_msg_hdl.h"
33 #include "du_mgr_main.h"
36 /*******************************************************************
38 * @brief Assigns new transaction id to DU initiated procedure
42 * Function : assignTransactionId
44 * Functionality: Assigns new transaction id to a DU initiated
47 * @params[in] Region region
49 * @return ROK - success
52 * ****************************************************************/
53 uint8_t assignTransactionId()
55 uint8_t currTransId = duCb.e2apDb.e2TransInfo.transIdCounter;
57 /* Update to next valid value */
58 duCb.e2apDb.e2TransInfo.transIdCounter++;
59 if(duCb.e2apDb.e2TransInfo.transIdCounter == MAX_NUM_TRANSACTION)
60 duCb.e2apDb.e2TransInfo.transIdCounter = 0;
65 /*******************************************************************
67 * @brief Decode subscription ID
71 * Function : decodeSubscriptionId
73 * Functionality: Decode subscription id to get RAN function ID
76 * @params[in] Subscription ID
77 * RAN Function ID to be extracted
78 * RIC Request ID to be extracted
81 * ****************************************************************/
82 void decodeSubscriptionId(uint64_t subscriptionId, uint16_t *ranFuncId, RicRequestId *ricReqId)
84 /* Extract following from 64 bit subscription-ID :
85 * First 16 MSB is unused
86 * Next 16 MSB = RAN-Function-ID
87 * Next 16 MSB = Requestor-ID in RIC-Request-ID
88 * Last 16 LSB = Instance-ID in RIC-Request-ID
90 ricReqId->instanceId = subscriptionId & 0xFFFF;
91 ricReqId->requestorId = (subscriptionId >> 16) & 0xFFFF;
92 *ranFuncId = (subscriptionId >> 32) & 0xFFFF;
95 /*******************************************************************
97 * @brief Encode subscription ID
101 * Function : encodeSubscriptionId
103 * Functionality: Encode subscription id to get RAN function ID
106 * @params[in] Subscription ID to be encoded
111 * ****************************************************************/
112 void encodeSubscriptionId(uint64_t *subscriptionId, uint16_t ranFuncId, RicRequestId ricReqId)
114 /* Calculate 64 bit subscription-ID :
115 * First 16 MSB is unused
116 * Next 16 MSB = RAN-Function-ID
117 * Next 16 MSB = Requestor-ID in RIC-Request-ID
118 * Last 16 LSB = Instance-ID in RIC-Request-ID
120 *subscriptionId = ricReqId.instanceId;
121 *subscriptionId |= ((uint64_t)ricReqId.requestorId << 16);
122 *subscriptionId |= ((uint64_t)ranFuncId << 32);
125 /*******************************************************************
127 * @brief Stores the current time at the start of reporting period
131 * Function : storeReportStartTime
133 * Functionality: Stores the current time at the start of
136 * @params[in] Start Timer to be stored
139 * ****************************************************************/
140 void storeReportStartTime(ReportStartTime *startTime)
144 gettimeofday(&tv, NULL);
145 startTime->timeInSec = tv.tv_sec;
146 startTime->timeInMilliSec = (tv.tv_usec/1000);
150 /*******************************************************************
152 * @brief Fetch Measurement Info using measurement type name
156 * Function : fetchMeasInfoFromMeasTypeName
158 * Functionality: Fetch Measurement Info using measurement type name
160 * @params[in] Measurement type name to search
161 * Measurement Info list to search from
162 * Measurement Info node found from list
163 * @return Measurement Info DB
165 * ****************************************************************/
166 MeasurementInfo *fetchMeasInfoFromMeasTypeName(char *e2MeasTypeName, CmLListCp *measInfoList, CmLList **measInfoNode)
168 MeasurementInfo *measInfo = NULLP;
170 /* Fetch subscription detail in RAN Function DB */
171 CM_LLIST_FIRST_NODE(measInfoList, *measInfoNode);
174 measInfo = (MeasurementInfo *)((*measInfoNode)->node);
175 if(measInfo && !strcmp(e2MeasTypeName, measInfo->measurementTypeName))
179 *measInfoNode = (*measInfoNode)->next;
185 DU_LOG("\nERROR --> E2AP : fetchMeasInfoFromMeasTypeName: Measurement [%s] not found", e2MeasTypeName);
191 /*******************************************************************
193 * @brief Fetch Action details
197 * Function : fetchActionInfoFromActionId
199 * Functionality: Fetch action details from RIC subscription DB
202 * @params[in] Action ID
203 * RIC Subscription DB
206 * @return Action Info DB
207 * NULL, in case of failure
209 * ****************************************************************/
210 ActionInfo *fetchActionInfoFromActionId(uint8_t actionId, RicSubscription *ricSubscriptionInfo, CmLList ** actionNode, ConfigType cfgType)
212 ActionInfo *actionInfoDb = NULLP;
214 CM_LLIST_FIRST_NODE(&ricSubscriptionInfo->actionSequence, *actionNode);
217 actionInfoDb = (ActionInfo*)((*actionNode)->node);
218 if(actionInfoDb && (actionInfoDb->actionId == actionId) && (actionInfoDb->action == cfgType))
222 *actionNode= (*actionNode)->next;
223 actionInfoDb = NULLP;
228 DU_LOG("\nERROR --> E2AP : fetchActionInfoFromActionId: Action Id [%d] not found in \
229 subscription info [Requestor id : %d] [Instance Id : %d]", actionId,\
230 ricSubscriptionInfo->requestId.requestorId, ricSubscriptionInfo->requestId.instanceId);
236 /*******************************************************************
238 * @brief Fetch subscripton DB
242 * Function : fetchSubsInfoFromRicReqId
244 * Functionality: Fetches subscription DB from RAN Function DB
245 * using RIC Request ID
247 * @params[in] RIC Request ID
249 * Pointer to RIC Subscription node to be searched
250 * @return RIC Subscription from RAN Function's subcription list
251 * NULL, in case of failure
253 * ****************************************************************/
254 RicSubscription *fetchSubsInfoFromRicReqId(RicRequestId ricReqId, RanFunction *ranFuncDb, CmLList **ricSubscriptionNode)
256 RicSubscription *ricSubscriptionInfo = NULLP;
258 /* Fetch subscription detail in RAN Function DB */
259 CM_LLIST_FIRST_NODE(&ranFuncDb->subscriptionList, *ricSubscriptionNode);
260 while(*ricSubscriptionNode)
262 ricSubscriptionInfo = (RicSubscription *)((*ricSubscriptionNode)->node);
263 if(ricSubscriptionInfo && (ricSubscriptionInfo->requestId.requestorId == ricReqId.requestorId) &&
264 (ricSubscriptionInfo->requestId.instanceId == ricReqId.instanceId))
268 *ricSubscriptionNode = (*ricSubscriptionNode)->next;
269 ricSubscriptionInfo = NULLP;
272 if(!ricSubscriptionInfo)
274 DU_LOG("\nERROR --> E2AP : fetchSubsInfoFromRicReqId: Subscription not found for Requestor ID [%d] \
275 Instance ID [%d] in RAN Function ID [%d]", ricReqId.requestorId, ricReqId.instanceId, ranFuncDb->id);
278 return ricSubscriptionInfo;
281 /*******************************************************************
283 * @brief Fetches RAN Function DB
287 * Function : fetchRanFuncFromRanFuncId
289 * Functionality: Fetches RAN function DB from E2AP DB using
292 * @params[in] RAN Function ID
293 * @return RAN Function DB
294 * NULL, in case of failure
296 * ****************************************************************/
297 RanFunction *fetchRanFuncFromRanFuncId(uint16_t ranFuncId)
299 RanFunction *ranFuncDb = NULLP;
301 /* Fetch RAN Function DB */
302 if(duCb.e2apDb.ranFunction[ranFuncId-1].id == ranFuncId)
304 ranFuncDb = &duCb.e2apDb.ranFunction[ranFuncId-1];
308 DU_LOG("\nERROR --> E2AP : fetchRanFuncFromRanFuncId: Invalid RAN Function ID[%d]", ranFuncId);
314 /*******************************************************************
316 * @brief Fetches subscription info
320 * Function : fetchSubsInfoFromSubsId
323 * 1. Firstly, RAN Function ID and RIC request ID is extracted
324 * from Subscription ID
325 * 2. Using RAN Function ID, RAN Function DB is searched
326 * 3. Using RIC Request ID, the subscription DB is searched in
329 * @params[in] Subscription ID
331 * RIC Subscription node from RAN Func's Subscription list
335 * ****************************************************************/
336 uint8_t fetchSubsInfoFromSubsId(uint64_t subscriptionId, RanFunction **ranFuncDb, CmLList **ricSubscriptionNode, \
337 RicSubscription **ricSubscriptionInfo)
339 uint16_t ranFuncId = 0;
340 RicRequestId ricReqId;
342 memset(&ricReqId, 0, sizeof(RicRequestId));
344 /* Decode subscription ID o get RIC Request ID and RAN Function ID */
345 decodeSubscriptionId(subscriptionId, &ranFuncId, &ricReqId);
347 /* Fetch RAN Function DB using RAN Function ID */
348 *ranFuncDb = fetchRanFuncFromRanFuncId(ranFuncId);
349 if((*ranFuncDb) == NULLP)
354 /* Fetch Sunscription DB from RAN Function using RIC Request ID */
355 *ricSubscriptionInfo = fetchSubsInfoFromRicReqId(ricReqId, *ranFuncDb, ricSubscriptionNode);
356 if((*ricSubscriptionInfo) == NULLP)
364 /*******************************************************************
366 * @brief Sends E2 msg over SCTP
370 * Function : SendE2APMsg
372 * Functionality: Sends E2 msg over SCTP
374 * @params[in] Region region
376 * @return ROK - success
379 * ****************************************************************/
381 uint8_t SendE2APMsg(Region region, Pool pool, char *encBuf, int encBufSize)
385 if(ODU_GET_MSG_BUF(region, pool, &mBuf) == ROK)
387 if(ODU_ADD_POST_MSG_MULT((Data *)encBuf, encBufSize, mBuf) == ROK)
389 ODU_PRINT_MSG(mBuf, 0,0);
391 if(sctpSend(mBuf, E2_INTERFACE) != ROK)
393 DU_LOG("\nERROR --> E2AP : SCTP Send for E2 failed");
394 ODU_PUT_MSG_BUF(mBuf);
400 DU_LOG("\nERROR --> E2AP : ODU_ADD_POST_MSG_MULT failed");
401 ODU_PUT_MSG_BUF(mBuf);
404 ODU_PUT_MSG_BUF(mBuf);
408 DU_LOG("\nERROR --> E2AP : Failed to allocate memory");
415 /*******************************************************************
421 * Function : ResetE2Request
423 * Functionality: This function resets E2.
424 * As per ORAN WG3 E2GAP v3.0 Spec, section 5.5.3
425 * If E2 node initates reset procedure then:
426 * a. Send reset request to RIC
427 * b. Delete any pre-established RIC subscriptions
428 * c. Gracefully terminates any ongoing RIC services
429 * If RIC initiates reset procedure then :
430 * a. Delete any pre-established RIC subscriptions
431 * b. Gracefully terminates any ongoing RIC services
432 * c. Send reset response to RIC
435 * @return ROK - success
438 * ****************************************************************/
439 uint8_t ResetE2Request(E2ProcedureDirection dir, E2FailureCause resetCause)
441 /* Send Reset Request to RIC if DU detects any abnormal failure */
442 if(dir == E2_NODE_INITIATED)
444 if(BuildAndSendE2ResetRequest(resetCause) != ROK)
446 DU_LOG("\nERROR --> E2AP : BuildAndSendE2ResetRequest failed");
451 /* TODO when RIC subscription service model is implemented
452 Process following steps of resetting E2
453 1. Deletes any pre-established RIC subscriptions
454 2. Gracefully terminates any ongoing RIC services
457 /* Send Reset Response if RIC initiated Reset request is received at DU */
458 if(dir == RIC_INITIATED)
460 //BuildAndSendE2ResetResponse();
465 /*******************************************************************
467 * @brief Fill RIC Subscription datils in MAC Statistics Request
471 * Function : fillRicSubsInMacStatsReq
473 * Functionality: Fill RIC Subscription datils in MAC Statistics
476 * @params[in] MAC Statistics Request to be filled
477 * RIC Subscription Info
479 * @return ROK - success
482 * ****************************************************************/
483 uint8_t fillRicSubsInMacStatsReq(MacStatsReq *macStatsReq, RicSubscription* ricSubscriptionInfo)
485 uint8_t grpIdx = 0, statsIdx = 0;
486 uint64_t subscriptionId = 0;
487 ActionInfo *actionDb = NULLP;
488 CmLList *actionNode = NULLP;
489 ActionDefFormat1 *format1Action = NULLP;
491 /* Generate subscription ID using RIC Request ID and RAN Function ID */
492 encodeSubscriptionId(&subscriptionId, ricSubscriptionInfo->ranFuncId, ricSubscriptionInfo->requestId);
494 macStatsReq->subscriptionId = subscriptionId;
495 CM_LLIST_FIRST_NODE(&ricSubscriptionInfo->actionSequence, actionNode);
498 actionDb = (ActionInfo*)(actionNode->node);
499 if(actionDb->action == CONFIG_ADD)
501 macStatsReq->statsGrpList[grpIdx].groupId = actionDb->actionId;
502 switch(actionDb->definition.formatType)
506 format1Action = &actionDb->definition.choice.format1;
507 macStatsReq->statsGrpList[grpIdx].periodicity = format1Action->granularityPeriod;
509 CmLList *node = NULLP;
510 MeasurementInfo *measInfo = NULLP;
512 /* Update DL PRB Usage for all stats group which requested for DL Total PRB Usage */
513 node = cmLListFirst(&format1Action->measurementInfoList);
516 measInfo = (MeasurementInfo *)(node->node);
517 switch(measInfo->measurementTypeId)
521 macStatsReq->statsGrpList[grpIdx].statsList[statsIdx++] = MAC_DL_TOTAL_PRB_USAGE;
526 macStatsReq->statsGrpList[grpIdx].statsList[statsIdx++] = MAC_UL_TOTAL_PRB_USAGE;
531 DU_LOG("\nERROR --> E2AP : Invalid measurement name");
537 macStatsReq->statsGrpList[grpIdx].numStats = statsIdx;
542 DU_LOG("\nERROR --> E2AP : fillRicSubsInMacStatsReq: Only Action Definition Format 1 supported");
546 if(macStatsReq->statsGrpList[grpIdx].numStats)
549 actionNode = actionNode->next;
552 macStatsReq->numStatsGroup = grpIdx;
553 if(macStatsReq->numStatsGroup)
560 /*******************************************************************
562 * @brief Rejects all actions received in a subscription request
566 * Function : duRejectAllStatsGroup
568 * Functionality: Rejects all actions received in a subscription
570 * a. Removing the subscription entry from RAN function
571 * b. Sending RIC Subscription Failure to RIC with appropriate
574 * @params[in] RAN Function DB
575 * Subscription entry in RAN Function subscription list
576 * Statistics Response from MAC
578 * @return ROK - success
581 * ****************************************************************/
582 uint8_t rejectAllStatsGroup(RanFunction *ranFuncDb, CmLList *ricSubscriptionNode, MacStatsRsp *statsRsp)
585 RicRequestId requestId;
586 E2FailureCause failureCause;
588 /* Delete subcription from RAN Function */
589 memcpy(&requestId, &((RicSubscription *)ricSubscriptionNode->node)->requestId, sizeof(RicRequestId));
590 cmLListDelFrm(&ranFuncDb->subscriptionList, ricSubscriptionNode);
591 deleteRicSubscriptionNode(ricSubscriptionNode);
592 ricSubscriptionNode = NULLP;
593 convertDuCauseToE2Cause(statsRsp->statsGrpRejectedList[0].cause, &failureCause);
595 /* Send RIC subscription failure to RIC */
596 ret = BuildAndSendRicSubscriptionFailure(requestId, ranFuncDb->id, failureCause);
600 /*******************************************************************
602 * @brief Process statistics response received for subscription
603 * modification req and send the ric subscription response msg
607 * Function : procStatsRspForSubsModReq
609 * Functionality: Processes statistics configuration response
610 * received for subscription modification req.
611 * [Step 1] - Fetch pendingSubsModRsp list from ran func db
612 * based on RIC request info.
613 * [Step 2] - Traverse each index of accepted list received in
615 * [Step 2.1] - Added each action related info in pending
616 * rsp's accepted list and mark action status CONFIG_UNKNOWN.
617 * [Step 3] - Traverse each index of rejected list received in
619 * [Step 3.1] - Added each action related info in pending
620 * rsp's rejected list and delete the action info from Db.
621 * [Step 4] - Set addActionCompleted true, and process the Pending
622 * Subscription modification rsp list.
627 * Ric subscription info
629 * @return ROK - success
632 * ****************************************************************/
633 uint8_t procStatsRspForSubsModReq(MacStatsRsp *statsRsp, RanFunction *ranFuncDb, RicSubscription *ricSubscriptionInfo)
636 uint8_t actionId = 0;
637 CmLList *actionNode = NULLP;
638 ActionInfo *actionInfoDb = NULLP;
639 PendingSubsModRspInfo *pendingSubsModRsp = NULLP;
642 for(idx=0; idx<ranFuncDb->numPendingSubsModRsp; idx++)
644 if((ranFuncDb->pendingSubsModRspInfo[idx].requestId.requestorId == ricSubscriptionInfo->requestId.requestorId) &&
645 (ricSubscriptionInfo->requestId.instanceId == ricSubscriptionInfo->requestId.instanceId))
647 pendingSubsModRsp = &ranFuncDb->pendingSubsModRspInfo[idx];
652 if(pendingSubsModRsp == NULLP)
654 DU_LOG("\nERROR --> E2AP : failed in function %s at line %d",__func__,__LINE__);
659 for(idx=0; idx<statsRsp->numGrpAccepted; idx++)
661 actionInfoDb = NULLP;
663 actionId = statsRsp->statsGrpAcceptedList[idx];
664 actionInfoDb = fetchActionInfoFromActionId(actionId, ricSubscriptionInfo, &actionNode, CONFIG_ADD);
668 actionInfoDb->action = CONFIG_UNKNOWN;
669 pendingSubsModRsp->addActionStatus.acceptedActionList[pendingSubsModRsp->addActionStatus.numOfAcceptedActions++] = actionId;
674 for(idx=0; idx<statsRsp->numGrpRejected; idx++)
676 actionInfoDb = NULLP;
677 actionId = statsRsp->statsGrpRejectedList[idx].groupId;
678 actionInfoDb = fetchActionInfoFromActionId(actionId, ricSubscriptionInfo, &actionNode, CONFIG_ADD);
682 cmLListDelFrm(&ricSubscriptionInfo->actionSequence, actionNode);
683 deleteActionSequence(actionNode);
684 pendingSubsModRsp->addActionStatus.rejectedActionList[pendingSubsModRsp->addActionStatus.numOfRejectedActions].id = actionId;
685 convertDuCauseToE2Cause(statsRsp->statsGrpRejectedList[idx].cause, \
686 &pendingSubsModRsp->addActionStatus.rejectedActionList[pendingSubsModRsp->addActionStatus.numOfRejectedActions].failureCause);
687 pendingSubsModRsp->addActionStatus.numOfRejectedActions++;
692 pendingSubsModRsp->addActionCompleted =true;
693 if(duProcPendingSubsModRsp(pendingSubsModRsp) != ROK)
695 DU_LOG("\nERROR --> E2AP : failed in function %s at line %d",__func__,__LINE__);
701 /*******************************************************************
703 * @brief Process statistics response for subscription req and
704 * send the ric subscription response msg
708 * Function : procStatsRspForSubsReq
710 * Functionality: Processes statistics configuration response
711 * received for subscription req.
712 * [Step 1] - Fetch PendingSubsRspInfo list from ran func db
713 * based on RIC request info.
714 * [Step 2] - If all stats group got rejected then send delete
715 * ric subs action info from db and send ric subscription delete
717 * [Step 3] - Store and start RIC Subscription reporting timer.
718 * [Step 4] - Traverse each index of accepted list received in
720 * [Step 4.1] - Added each action related info in pending
721 * rsp's accepted list and mark action status CONFIG_UNKNOWN.
722 * [Step 5] - Traverse each index of rejected list received in
724 * [Step 5.1] - Added each action related info in pending
725 * rsp's rejected list and delete the action info from Db.
726 * [Step 6] - Send subscription response with accepted and rejected
727 * action lists to RIC.
732 * Ric subscription node
733 * Ric subscription info
735 * @return ROK - success
738 * ****************************************************************/
739 uint8_t procStatsRspForSubsReq(MacStatsRsp *statsRsp, RanFunction *ranFuncDb, CmLList *ricSubscriptionNode, RicSubscription *ricSubscriptionInfo)
742 uint8_t actionId = 0;
743 uint32_t reportingPeriod = 0;
744 CmLList *actionNode = NULLP;
745 ActionInfo *actionInfoDb = NULLP;
746 PendingSubsRspInfo *pendingSubsRsp = NULLP;
749 for(idx=0; idx<ranFuncDb->numPendingSubsRsp; idx++)
751 if((ranFuncDb->pendingSubsRspInfo[idx].requestId.requestorId == ricSubscriptionInfo->requestId.requestorId) &&
752 (ricSubscriptionInfo->requestId.instanceId == ricSubscriptionInfo->requestId.instanceId))
754 pendingSubsRsp = &ranFuncDb->pendingSubsRspInfo[idx];
759 if(pendingSubsRsp == NULLP)
761 DU_LOG("\nERROR --> E2AP : failed in function %s at line %d",__func__,__LINE__);
765 if(statsRsp->numGrpAccepted == 0)
768 rejectAllStatsGroup(ranFuncDb, ricSubscriptionNode, statsRsp);
773 switch(ricSubscriptionInfo->eventTriggerDefinition.formatType)
777 reportingPeriod = ricSubscriptionInfo->eventTriggerDefinition.choice.format1.reportingPeriod;
778 storeReportStartTime(&ricSubscriptionInfo->eventTriggerDefinition.choice.format1.startTime);
783 DU_LOG("\nERROR --> E2AP : Invalid event trigger format of RIC subscription");
787 if(duChkTmr((PTR)ricSubscriptionInfo, EVENT_RIC_SUBSCRIPTION_REPORTING_TMR) != true)
789 duStartTmr((PTR)ricSubscriptionInfo, EVENT_RIC_SUBSCRIPTION_REPORTING_TMR, reportingPeriod);
793 DU_LOG("\nERROR --> E2AP : RIC Subscription reporting timer already running for RIC Subscription");
799 for(idx=0; idx<statsRsp->numGrpAccepted; idx++)
801 actionInfoDb = NULLP;
803 actionId = statsRsp->statsGrpAcceptedList[idx];
804 actionInfoDb = fetchActionInfoFromActionId(actionId, ricSubscriptionInfo, &actionNode, CONFIG_ADD);
808 actionInfoDb->action = CONFIG_UNKNOWN;
809 pendingSubsRsp->acceptedActionList[pendingSubsRsp->numOfAcceptedActions++] = actionId;
814 for(idx=0; idx<statsRsp->numGrpRejected; idx++)
816 actionInfoDb = NULLP;
817 actionId = statsRsp->statsGrpRejectedList[idx].groupId;
818 actionInfoDb = fetchActionInfoFromActionId(actionId, ricSubscriptionInfo, &actionNode, CONFIG_ADD);
822 cmLListDelFrm(&ricSubscriptionInfo->actionSequence, actionNode);
823 deleteActionSequence(actionNode);
824 pendingSubsRsp->rejectedActionList[pendingSubsRsp->numOfRejectedActions].id = actionId;
825 convertDuCauseToE2Cause(statsRsp->statsGrpRejectedList[idx].cause, \
826 &pendingSubsRsp->rejectedActionList[pendingSubsRsp->numOfRejectedActions].failureCause);
827 pendingSubsRsp->numOfRejectedActions++;
832 if(BuildAndSendRicSubscriptionRsp(pendingSubsRsp) != ROK)
834 DU_LOG("\nERROR --> E2AP : Failed to build and send RIC Subscription rsp");
838 memset(pendingSubsRsp, 0, sizeof(PendingSubsRspInfo));
839 ricSubscriptionInfo->action = CONFIG_UNKNOWN;
843 /*******************************************************************
845 * @brief Process statistics response from MAC
849 * Function : e2ProcStatsRsp
851 * Functionality: Processes statistics configuration response
853 * [Step -1]Fetch RAN Function and Subscription DB using
854 * subscription Id received in statistics response
855 * [Step -2]check ricSubscriptionInfo's action
856 * [Step 2.1]if action == CONFIG_ADD, if no group
857 * accepted then reject all stats group and send ric
858 * subscription failure. Else process stats rsp for
859 * RIC subscription response.
860 * [Step 2.1]if action == CONFIG_MOD, process stats rsp
861 * for RIC subscription modification response.
863 * @params[in] Statistics response received from MAC
865 * @return ROK - success
868 * ****************************************************************/
869 uint8_t e2ProcStatsRsp(MacStatsRsp *statsRsp)
871 RanFunction *ranFuncDb = NULLP;
872 CmLList *ricSubscriptionNode = NULLP;
873 RicSubscription *ricSubscriptionInfo = NULLP;
876 if(fetchSubsInfoFromSubsId(statsRsp->subscriptionId, &ranFuncDb, &ricSubscriptionNode, &ricSubscriptionInfo) != ROK)
878 DU_LOG("\nERROR --> E2AP : failed in function %s at line %d",__func__,__LINE__);
883 if(ricSubscriptionInfo->action == CONFIG_ADD)
886 if(procStatsRspForSubsReq(statsRsp, ranFuncDb, ricSubscriptionNode, ricSubscriptionInfo) != ROK)
888 rejectAllStatsGroup(ranFuncDb, ricSubscriptionNode, statsRsp);
889 DU_LOG("\nERROR --> E2AP : Failed to build and send RIC Subscription rsp");
893 else if(ricSubscriptionInfo->action == CONFIG_MOD)
896 if(procStatsRspForSubsModReq(statsRsp, ranFuncDb, ricSubscriptionInfo) != ROK)
898 DU_LOG("\nERROR --> E2AP : Failed to build and send RIC Subscription rsp");
905 /*******************************************************************
907 * @brief Extract and store statistics received from DU layers
911 * Function : e2ProcStatsInd
913 * Functionality: Extract statistics received from DU layers
914 * and store in respective RAN function's subscription's
917 * @params[in] Statistics Indication message received from MAC
918 * @return ROK-success
921 * ****************************************************************/
922 uint8_t e2ProcStatsInd(MacStatsInd *statsInd)
924 uint8_t statsIdx = 0;
925 RanFunction *ranFuncDb = NULLP;
926 CmLList *ricSubscriptionNode = NULLP;
927 CmLList *actionNode = NULLP;
928 RicSubscription *ricSubscriptionInfo = NULLP;
929 ActionInfo *actionInfo = NULLP;
930 ActionDefFormat1 *actionFormat = NULLP;
931 char e2MeasTypeName[STRING_SIZE_150_BYTES] = "";
932 MeasurementInfo *measInfo = NULLP;
933 CmLList *measInfoNode = NULLP;
934 double *measValue = NULLP;
935 CmLList *measValueNode = NULLP;
937 /* TODO : When stats indication is received
938 * DU APP searches for the message type in E2AP RIC subscription
939 * database and stores in the value in the list of subscribed measurements
941 * This will be implemented in next gerrit.
944 /* Fetch RAN Function and Subscription DB using subscription Id received
945 * in statistics response */
946 if(fetchSubsInfoFromSubsId(statsInd->subscriptionId, &ranFuncDb, &ricSubscriptionNode, &ricSubscriptionInfo) != ROK)
948 DU_LOG("\nERROR --> E2AP : %s : Failed to fetch subscriprtion details",__func__);
952 /* Fetch RIC subscription's action DB */
953 actionInfo = fetchActionInfoFromActionId(statsInd->groupId, ricSubscriptionInfo, &actionNode, CONFIG_UNKNOWN);
954 if(actionInfo == NULLP)
956 DU_LOG("\nERROR --> E2AP : %s: Failed to fetch action ID [%d]",__func__, statsInd->groupId);
960 /* Check Action format */
961 switch(actionInfo->definition.formatType)
965 actionFormat = &actionInfo->definition.choice.format1;
970 DU_LOG("\nERROR --> E2AP : %s: Action Format [%d] is not supported", __func__,\
971 actionInfo->definition.formatType);
976 /* Fetch each Measurement info from action info and store its reported value in DB */
977 for(statsIdx = 0; statsIdx < statsInd->numStats; statsIdx++)
979 memset(e2MeasTypeName, 0, STRING_SIZE_150_BYTES);
981 measInfoNode = NULLP;
983 /* Convert Measurement type from MAC-supported format to E2-supported format */
984 if(convertMacMeasTypeToE2MeasType(statsInd->measuredStatsList[statsIdx].type, e2MeasTypeName) != ROK)
986 DU_LOG("\nERROR --> E2AP : %s: Failed to convert measurement type from MAC-supported\
987 MAC-supported format to E2-supported format",__func__);
991 /* Fetch Measurement Info using E2-supported measurement type name */
992 measInfo = fetchMeasInfoFromMeasTypeName(e2MeasTypeName, &actionFormat->measurementInfoList, &measInfoNode);
993 if(measInfo == NULLP)
995 DU_LOG("\nERROR --> E2AP : %s: Measurement Type Name [%s] not found", __func__,e2MeasTypeName);
999 /* Store the measurement value in the measurement info DB fetched */
1000 DU_ALLOC(measValue, sizeof(double));
1003 DU_LOG("\nERROR --> E2AP : %s: Memory allocation failed at line [%d]",__func__, __LINE__);
1006 *measValue = statsInd->measuredStatsList[statsIdx].value;
1008 DU_ALLOC(measValueNode, sizeof(CmLList));
1011 DU_LOG("\nERROR --> E2AP : %s : Memory allocation failed at line [%d]",__func__, __LINE__);
1012 DU_FREE(measValue, sizeof(double));
1015 measValueNode->node = (PTR) measValue;
1016 cmLListAdd2Tail(&measInfo->measuredValue, measValueNode);
1021 /*******************************************************************
1023 * @brief Handle RIC Subscription reporting timer expry
1027 * Function : E2apHdlRicSubsReportTmrExp
1029 * Functionality: On expiry of RIC subscription reporting
1030 * timer expiry, RIC indication is sent for all actions
1031 * in RIC subscription
1033 * @params[in] RIC subscription DB
1036 * ****************************************************************/
1037 void E2apHdlRicSubsReportTmrExp(RicSubscription *ricSubscription)
1039 uint32_t reportingPeriod = 0;
1040 ActionInfo *action=NULLP;
1041 CmLList *actionNode=NULLP;
1043 CM_LLIST_FIRST_NODE(&ricSubscription->actionSequence, actionNode);
1046 action = (ActionInfo*)actionNode->node;
1047 BuildAndSendRicIndication(ricSubscription, action);
1048 actionNode = actionNode->next;
1051 /* Start RIC Subscription reporting timer again */
1052 switch(ricSubscription->eventTriggerDefinition.formatType)
1056 reportingPeriod = ricSubscription->eventTriggerDefinition.choice.format1.reportingPeriod;
1057 /* Save the start time of reporting period */
1058 storeReportStartTime(&ricSubscription->eventTriggerDefinition.choice.format1.startTime);
1064 if(duChkTmr((PTR)ricSubscription, EVENT_RIC_SUBSCRIPTION_REPORTING_TMR) != true)
1066 duStartTmr((PTR)ricSubscription, EVENT_RIC_SUBSCRIPTION_REPORTING_TMR, reportingPeriod);
1070 DU_LOG("\nERROR --> E2AP : Failed in %s at line %d", __func__, __LINE__);
1075 /******************************************************************
1077 * @brief Search E2 node component with the help of action type
1081 * Function : fetchE2NodeComponentInfo
1083 * Functionality: Search E2 node component with the help of action type
1088 * Pointer to E2 component node to be searched
1091 * ****************************************************************/
1093 E2NodeComponent *fetchE2NodeComponentInfo(InterfaceType interfaceType, uint64_t componentId, CmLList **e2ComponentNode)
1095 E2NodeComponent *e2NodeComponentInfo=NULLP;
1097 if(duCb.e2apDb.e2NodeComponentList.count)
1099 CM_LLIST_FIRST_NODE(&duCb.e2apDb.e2NodeComponentList, *e2ComponentNode);
1100 while(*e2ComponentNode)
1102 e2NodeComponentInfo = (E2NodeComponent*)((*e2ComponentNode)->node);
1103 if((e2NodeComponentInfo->interfaceType == interfaceType) && (e2NodeComponentInfo->componentId == componentId))
1108 *e2ComponentNode = (*e2ComponentNode)->next;
1109 e2NodeComponentInfo = NULLP;
1112 return e2NodeComponentInfo;
1115 /*******************************************************************
1117 * @brief fill E2 node component rsp info
1121 * Function : fillE2NodeComponentRspInfo
1123 * Functionality: fill E2 Node Component rsp info
1127 * Component action type
1128 * Size of buffer which needs to be store
1129 * buffer string which needs to be store
1130 * @return ROK - success
1133 * ****************************************************************/
1135 uint8_t fillE2NodeComponentRspInfo(InterfaceType interfaceType, uint64_t componentId, uint8_t action, uint8_t bufSize, char *bufString)
1137 E2NodeConfig *configInfo=NULLP;
1138 E2NodeComponent *e2NodeComponentInfo= NULLP;
1139 CmLList *node = NULLP;
1141 e2NodeComponentInfo = fetchE2NodeComponentInfo(interfaceType, componentId, &node);
1142 if(!e2NodeComponentInfo)
1144 DU_LOG("\nERROR --> E2AP : Unable to find the node");
1150 case E2_NODE_COMPONENT_ADD:
1152 configInfo = e2NodeComponentInfo->addConfiguration;
1155 case E2_NODE_COMPONENT_UPDATE:
1157 configInfo = e2NodeComponentInfo->updateConfiguration;
1162 DU_LOG("\nERROR --> E2AP : Invalid action %d received",action);
1167 if(configInfo->componentRequestPart== NULLP)
1169 DU_LOG("\nERROR --> E2AP : E2 node Component request part is not present");
1173 configInfo->rspBufSize = bufSize;
1174 DU_ALLOC(configInfo->componentResponsePart, bufSize);
1175 if(configInfo->componentResponsePart == NULLP)
1177 DU_LOG("\nERROR --> E2AP : Memory allocation failed to store the encoding of rsp");
1180 memcpy(configInfo->componentResponsePart, bufString, configInfo->rspBufSize);
1184 /*******************************************************************
1186 * @brief add E2 node component req info
1190 * Function : addE2NodeComponent
1192 * Functionality: add E2 node component req info
1196 * Component action type
1197 * Size of buffer which needs to be store
1198 * buffer string which needs to be store
1199 * @return ROK - success
1202 ******************************************************************/
1204 uint8_t addE2NodeComponent(InterfaceType interfaceType, uint64_t componentId, uint8_t bufSize, char *bufString)
1206 E2NodeComponent *e2NodeComponentInfo= NULLP;
1207 CmLList *node = NULLP;
1209 DU_ALLOC(e2NodeComponentInfo, sizeof(E2NodeComponent));
1210 if(!e2NodeComponentInfo)
1212 DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at %d",__func__,__LINE__);
1215 e2NodeComponentInfo->interfaceType =interfaceType;
1216 e2NodeComponentInfo->componentId=componentId;
1218 DU_ALLOC(e2NodeComponentInfo->addConfiguration, sizeof(E2NodeConfig));
1219 if(!e2NodeComponentInfo->addConfiguration)
1221 DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at %d",__func__,__LINE__);
1225 e2NodeComponentInfo->addConfiguration->reqBufSize = bufSize;
1227 DU_ALLOC(e2NodeComponentInfo->addConfiguration->componentRequestPart, bufSize);
1228 if(e2NodeComponentInfo->addConfiguration->componentRequestPart == NULLP)
1230 DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at %d",__func__,__LINE__);
1231 DU_FREE(e2NodeComponentInfo, sizeof(E2NodeComponent));
1234 memcpy(e2NodeComponentInfo->addConfiguration->componentRequestPart, bufString,\
1235 e2NodeComponentInfo->addConfiguration->reqBufSize);
1237 DU_ALLOC(node, sizeof(CmLList));
1240 node->node = (PTR) e2NodeComponentInfo;
1241 cmLListAdd2Tail(&duCb.e2apDb.e2NodeComponentList, node);
1245 DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at %d",__func__,__LINE__);
1246 DU_FREE(e2NodeComponentInfo->addConfiguration->componentRequestPart, bufSize);
1247 DU_FREE(e2NodeComponentInfo->addConfiguration, sizeof(E2NodeConfig));
1248 DU_FREE(e2NodeComponentInfo, sizeof(E2NodeComponent));
1254 /*******************************************************************
1256 * @brief update E2 node component req info
1260 * Function : updateE2NodeComponent
1262 * Functionality: update E2 node component req info
1266 * Size of buffer which needs to be store
1267 * buffer string which needs to be store
1268 * @return ROK - success
1271 ******************************************************************/
1273 uint8_t updateE2NodeComponent(InterfaceType interfaceType, uint64_t componentId, uint8_t bufSize, char *bufString)
1275 E2NodeComponent *e2NodeComponentInfo= NULLP;
1276 CmLList *node = NULLP;
1278 e2NodeComponentInfo = fetchE2NodeComponentInfo(interfaceType, componentId, &node);
1279 if(!e2NodeComponentInfo)
1281 DU_LOG("\nERROR --> E2AP : Received null information in %s",__func__);
1285 DU_ALLOC(e2NodeComponentInfo->updateConfiguration, sizeof(E2NodeConfig));
1286 if(!e2NodeComponentInfo->updateConfiguration)
1288 DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at %d",__func__,__LINE__);
1292 e2NodeComponentInfo->updateConfiguration->reqBufSize = bufSize;
1294 DU_ALLOC(e2NodeComponentInfo->updateConfiguration->componentRequestPart, bufSize);
1295 if(e2NodeComponentInfo->updateConfiguration->componentRequestPart == NULLP)
1297 DU_LOG("\nERROR --> E2AP : Memory allocation failed in %s at %d",__func__,__LINE__);
1298 DU_FREE(e2NodeComponentInfo->updateConfiguration, sizeof(E2NodeConfig));
1302 memcpy(e2NodeComponentInfo->updateConfiguration->componentRequestPart, bufString,\
1303 e2NodeComponentInfo->updateConfiguration->reqBufSize);
1308 /*******************************************************************
1310 * @brief delete E2 node component req info
1314 * Function : deleteE2NodeComponent
1316 * Functionality: delete E2 node component req info
1320 * @return ROK - success
1323 ******************************************************************/
1325 uint8_t deleteE2NodeComponent(InterfaceType interfaceType, uint64_t componentId)
1327 E2NodeComponent *e2NodeComponentInfo= NULLP;
1328 CmLList *node = NULLP;
1330 e2NodeComponentInfo = fetchE2NodeComponentInfo(interfaceType, componentId, &node);
1331 if(!e2NodeComponentInfo)
1333 DU_LOG("\nERROR --> E2AP : Received null information in %s",__func__);
1337 e2NodeComponentInfo->deleteConfiguration = true;
1341 /*******************************************************************
1343 * @brief fill E2 node component req info
1347 * Function : fillE2NodeComponentReqInfo
1349 * Functionality: fill E2 node component req info
1353 * Component action type
1354 * Size of buffer which needs to be store
1355 * buffer string which needs to be store
1356 * @return ROK - success
1359 ******************************************************************/
1361 uint8_t fillE2NodeComponentReqInfo(InterfaceType interfaceType, uint64_t componentId, uint8_t action, uint8_t bufSize, char *bufString)
1365 case E2_NODE_COMPONENT_ADD:
1367 if(addE2NodeComponent(interfaceType, componentId, bufSize, bufString) != ROK)
1369 DU_LOG("\nERROR --> E2AP : Failed to add e2 node component");
1374 case E2_NODE_COMPONENT_UPDATE:
1376 if(updateE2NodeComponent(interfaceType, componentId, bufSize, bufString) != ROK)
1378 DU_LOG("\nERROR --> E2AP : Failed to update e2 node component");
1383 case E2_NODE_COMPONENT_DEL:
1385 if(deleteE2NodeComponent(interfaceType, componentId) != ROK)
1387 DU_LOG("\nERROR --> E2AP : Failed to delete e2 node component");
1394 DU_LOG("\nERROR --> E2AP : Invalid action %d received",action);
1402 /******************************************************************
1404 * @brief Delete measured Value list
1408 * Function : deleteMeasuredValueList
1410 * Functionality: Delete measured Value list
1412 * @params[in] List of measured Value
1416 * ****************************************************************/
1417 void deleteMeasuredValueList(CmLListCp *measuredValueList)
1419 CmLList *measValNode = NULLP;
1421 CM_LLIST_FIRST_NODE(measuredValueList, measValNode);
1425 cmLListDelFrm(measuredValueList, measValNode);
1426 DU_FREE(measValNode->node, sizeof(double));
1427 DU_FREE(measValNode, sizeof(CmLList));
1428 CM_LLIST_FIRST_NODE(measuredValueList, measValNode);
1432 /******************************************************************
1434 * @brief Delete Measurement Info List
1438 * Function : deleteMeasurementInfoList
1440 * Functionality: Delete Measurement Info List
1442 * @params[in] List of Measurement Info List
1446 * ****************************************************************/
1447 void deleteMeasurementInfoList(CmLListCp *measInfoList)
1449 CmLList *measInfoNode = NULLP;
1450 MeasurementInfo *measInfo = NULLP;
1452 CM_LLIST_FIRST_NODE(measInfoList, measInfoNode);
1455 measInfo = (MeasurementInfo *)measInfoNode->node;
1456 cmLListDelFrm(measInfoList, measInfoNode);
1457 deleteMeasuredValueList(&measInfo->measuredValue);
1458 DU_FREE(measInfo, sizeof(MeasurementInfo));
1459 DU_FREE(measInfoNode, sizeof(CmLList));
1460 CM_LLIST_FIRST_NODE(measInfoList, measInfoNode);
1464 /******************************************************************
1466 * @brief Delete Ric subscription action
1470 * Function : deleteActionSequence
1472 * Functionality: Delete Ric subscription action
1474 * @params[in] Action info
1478 * ****************************************************************/
1479 void deleteActionSequence(CmLList *actionNode)
1481 ActionInfo *action = NULLP;
1482 ActionDefinition *definition=NULLP;
1486 action = (ActionInfo*)actionNode->node;
1487 definition= &action->definition;
1489 switch(definition->formatType)
1493 deleteMeasurementInfoList(&definition->choice.format1.measurementInfoList);
1503 DU_LOG("\nERROR --> E2AP : Format %d does not supported", definition->formatType);
1507 memset(action, 0, sizeof(ActionInfo));
1508 DU_FREE(actionNode->node, sizeof(ActionInfo));
1509 DU_FREE(actionNode, sizeof(CmLList));
1513 /******************************************************************
1515 * @brief Delete Ric subscription action list
1519 * Function : deleteActionSequenceList
1521 * Functionality: Delete Ric subscription action list
1523 * @params[in] Action info list
1527 * ****************************************************************/
1528 void deleteActionSequenceList(CmLListCp *actionList)
1530 CmLList *actionNode=NULLP;
1532 CM_LLIST_FIRST_NODE(actionList, actionNode);
1535 cmLListDelFrm(actionList, actionNode);
1536 deleteActionSequence(actionNode);
1537 CM_LLIST_FIRST_NODE(actionList, actionNode);
1541 /******************************************************************
1543 * @brief Delete Ric subscription node
1547 * Function : deleteRicSubscriptionNode
1549 * Functionality: Delete Ric subscription node
1551 * @params[in] Ric subscription info
1555 * ****************************************************************/
1556 void deleteRicSubscriptionNode(CmLList *subscriptionNode)
1558 RicSubscription *ricSubscriptionInfo = NULLP;
1560 ricSubscriptionInfo = (RicSubscription*)subscriptionNode->node;
1562 deleteActionSequenceList(&ricSubscriptionInfo->actionSequence);
1563 if(duChkTmr((PTR)ricSubscriptionInfo, EVENT_RIC_SUBSCRIPTION_REPORTING_TMR) == TRUE)
1565 duStopTmr((PTR)ricSubscriptionInfo, EVENT_RIC_SUBSCRIPTION_REPORTING_TMR);
1568 memset(ricSubscriptionInfo, 0, sizeof(RicSubscription));
1569 DU_FREE(subscriptionNode->node, sizeof(RicSubscription));
1570 DU_FREE(subscriptionNode, sizeof(CmLList));
1573 /******************************************************************
1575 * @brief Delete ric subscription list from the database
1579 * Function : deleteRicSubscriptionList
1581 * Functionality: Delete ric subscription list
1584 * Subscription List to be deleted
1588 * ****************************************************************/
1589 void deleteRicSubscriptionList(CmLListCp *subscriptionList)
1591 CmLList *subscriptionNode=NULLP;
1593 CM_LLIST_FIRST_NODE(subscriptionList, subscriptionNode);
1594 while(subscriptionNode)
1596 /* TODO - Remove subscription information from MAC and SCH as well */
1597 cmLListDelFrm(subscriptionList, subscriptionNode);
1598 deleteRicSubscriptionNode(subscriptionNode);
1599 CM_LLIST_FIRST_NODE(subscriptionList, subscriptionNode);
1603 /*******************************************************************
1605 * @brief Find all RIC subscriptions to be deleted in all RAN
1610 * Function : fetchRicSubsToBeDeleted
1612 * Functionality: Find all RIC subscriptions to be deleted in all
1613 * RAN functions and store in a temporary list
1615 * @parameter Temporary list to store subscriptions to be deleted
1618 ******************************************************************/
1619 void fetchRicSubsToBeDeleted(CmLListCp *ricSubsToBeDelList)
1621 uint16_t ranFuncIdx = 0;
1622 CmLList *subsNode = NULLP;
1623 CmLList *subsToDelNode = NULLP;
1625 for(ranFuncIdx = 0; ranFuncIdx < MAX_RAN_FUNCTION; ranFuncIdx++)
1627 if(duCb.e2apDb.ranFunction[ranFuncIdx].id > 0)
1629 CM_LLIST_FIRST_NODE(&duCb.e2apDb.ranFunction[ranFuncIdx].subscriptionList, subsNode);
1632 if(((RicSubscription *)subsNode->node)->action == CONFIG_DEL)
1634 DU_ALLOC(subsToDelNode, sizeof(CmLList));
1637 DU_LOG("\nERROR --> E2AP : %s: Memory allocation failure at %d", __func__, __LINE__);
1640 subsToDelNode->node = subsNode->node;
1641 cmLListAdd2Tail(ricSubsToBeDelList, subsToDelNode);
1643 subsToDelNode = NULLP;
1644 subsNode = subsNode->next;
1650 /******************************************************************
1652 * @brief Delete e2 node information from the database
1656 * Function : removeE2NodeInformation
1658 * Functionality: Delete e2 node information from the database
1664 ******************************************************************/
1665 void removeE2NodeInformation()
1667 uint16_t ranFuncIdx = 0;
1669 DU_LOG("\nINFO --> E2AP : Deleting all the E2 node configuration");
1670 for(ranFuncIdx=0; ranFuncIdx<MAX_RAN_FUNCTION; ranFuncIdx++)
1672 if(duCb.e2apDb.ranFunction[ranFuncIdx].id >0)
1674 deleteRicSubscriptionList(&(duCb.e2apDb.ranFunction[ranFuncIdx].subscriptionList));
1675 memset(&(duCb.e2apDb.ranFunction[ranFuncIdx].pendingSubsRspInfo), 0, MAX_PENDING_SUBSCRIPTION_RSP*sizeof(PendingSubsRspInfo));
1678 memset(&duCb.e2apDb.ricId, 0, sizeof(GlobalRicId));
1679 duCb.e2apDb.numOfTNLAssoc = 0;
1680 memset(&duCb.e2apDb.tnlAssoc, 0, MAX_TNL_ASSOCIATION*sizeof(TNLAssociation));
1681 memset(&ricParams, 0, sizeof(DuSctpDestCb));
1684 /*******************************************************************
1686 * @brief Extract statistics received from DU layers and delete
1687 * Ric subscription info
1691 * Function :e2ProcStatsDeleteRsp
1693 * Functionality: Extract statistics received from DU layers
1694 * and delete ric subscription iformation form db
1696 * @params[in] Statistics delete rsp from MAC
1697 * @return ROK-success
1700 * ****************************************************************/
1701 uint8_t e2ProcStatsDeleteRsp(MacStatsDeleteRsp *statsDeleteRsp)
1703 RicRequestId requestId;
1705 RanFunction *ranFuncDb = NULLP;
1706 CmLList *ricSubscriptionNode = NULLP;
1707 RicSubscription *ricSubscriptionInfo = NULLP;
1708 E2FailureCause failureCause;
1710 /* Fetch RAN Function and Subscription DB using subscription Id received
1711 * in statistics delete response */
1712 if(fetchSubsInfoFromSubsId(statsDeleteRsp->subscriptionId, &ranFuncDb, &ricSubscriptionNode, &ricSubscriptionInfo) != ROK)
1714 DU_LOG("\nERROR --> E2AP : e2ProcStatsDeleteRsp: Failed to fetch subscriprtion details");
1717 ranFuncId = ricSubscriptionInfo->ranFuncId;
1718 memcpy(&requestId, &ricSubscriptionInfo->requestId, sizeof(RicRequestId));
1720 deleteRicSubscriptionNode(ricSubscriptionNode);
1722 if(statsDeleteRsp->subsDelRsp == MAC_DU_APP_RSP_NOK)
1724 if(statsDeleteRsp->subsDelCause == STATS_ID_NOT_FOUND)
1726 failureCause.causeType =E2_RIC_REQUEST;
1727 failureCause.cause = E2_REQUEST_INFORMATION_UNAVAILABLE;
1731 failureCause.causeType = E2_MISCELLANEOUS;
1732 failureCause.cause = E2_MISCELLANEOUS_CAUSE_UNSPECIFIED;
1735 if(BuildAndSendRicSubscriptionDeleteFailure(ranFuncId, requestId, failureCause) != ROK)
1737 DU_LOG("\nERROR --> E2AP : e2ProcStatsDeleteRsp: failed to build and send ric subs delete failure");
1743 if(BuildAndSendRicSubscriptionDeleteResponse(ranFuncId, requestId) != ROK)
1745 DU_LOG("\nERROR --> E2AP : e2ProcStatsDeleteRsp: failed to build and send ric subs delete rsp");
1753 /*******************************************************************
1755 * @brief Extract statistics received from DU layers and delete
1756 * Ric subscription's action info
1760 * Function : e2ProcActionDeleteRsp
1763 * [Step-1] Fetch RAN Function and Subscription DB using
1764 * subscription Id received in statistics delete response.
1765 * [Step-2] Fetch pending ric subs modification rsp info
1766 * from ran func db based on ric request information.
1767 * [Step 3] - Traverse each index of stats group delete list
1768 * received in stats delete response.
1769 * [Step 3.1] - If action deleted successfully, delete the
1770 * node from DB and fill the action info in the pending ric
1771 * subs modification rsp's accepted list.
1772 * [Step 3.1] - Else fill the action info in the pending ric
1773 * subs modification rsp's rejected list.
1774 * [Step 4] - Set removeActionCompleted true and process the
1775 * Pending Subscription modification rsp list.
1778 * @params[in] Statistics delete rsp
1779 * @return ROK-success
1782 * ****************************************************************/
1783 uint8_t e2ProcActionDeleteRsp(MacStatsDeleteRsp *statsDeleteRsp)
1786 uint8_t actionId = 0;
1787 uint8_t tmpIndex = 0;
1788 CmLList *actionNode = NULLP;
1789 ActionInfo *actionInfoDb = NULLP;
1790 PendingSubsModRspInfo *pendingSubsModRsp = NULLP;
1791 RanFunction *ranFuncDb = NULLP;
1792 CmLList *ricSubscriptionNode = NULLP;
1793 RicSubscription *ricSubscriptionInfo = NULLP;
1796 if(fetchSubsInfoFromSubsId(statsDeleteRsp->subscriptionId, &ranFuncDb, &ricSubscriptionNode, &ricSubscriptionInfo) != ROK)
1798 DU_LOG("\nERROR --> E2AP : failed in function %s at line %d",__func__,__LINE__);
1803 for(idx=0; idx<ranFuncDb->numPendingSubsModRsp; idx++)
1805 if((ranFuncDb->pendingSubsModRspInfo[idx].requestId.requestorId == ricSubscriptionInfo->requestId.requestorId) &&
1806 (ricSubscriptionInfo->requestId.instanceId == ricSubscriptionInfo->requestId.instanceId))
1808 pendingSubsModRsp = &ranFuncDb->pendingSubsModRspInfo[idx];
1813 if(pendingSubsModRsp == NULLP)
1815 DU_LOG("\nERROR --> E2AP : failed in function %s at line %d",__func__,__LINE__);
1820 for(idx=0; idx<statsDeleteRsp->numStatsGroupDeleted; idx++)
1822 actionInfoDb = NULLP;
1823 actionId = statsDeleteRsp->statsGrpDelInfo[idx].groupId;
1824 actionInfoDb = fetchActionInfoFromActionId(actionId, ricSubscriptionInfo, &actionNode, CONFIG_DEL);
1827 if(statsDeleteRsp->statsGrpDelInfo[idx].statsGrpDelRsp == MAC_DU_APP_RSP_OK)
1830 tmpIndex = pendingSubsModRsp->removeActionStatus.numOfAcceptedActions;
1831 actionInfoDb->action = CONFIG_UNKNOWN;
1832 cmLListDelFrm(&ricSubscriptionInfo->actionSequence, actionNode);
1833 deleteActionSequence(actionNode);
1834 pendingSubsModRsp->removeActionStatus.acceptedActionList[tmpIndex] = actionId;
1835 pendingSubsModRsp->removeActionStatus.numOfAcceptedActions++;
1840 tmpIndex = pendingSubsModRsp->removeActionStatus.numOfRejectedActions;
1841 pendingSubsModRsp->removeActionStatus.rejectedActionList[tmpIndex].id = actionId;
1842 convertDuCauseToE2Cause(statsDeleteRsp->statsGrpDelInfo[idx].statsGrpDelCause,\
1843 &pendingSubsModRsp->removeActionStatus.rejectedActionList[tmpIndex].failureCause);
1844 pendingSubsModRsp->removeActionStatus.numOfRejectedActions++;
1850 pendingSubsModRsp->removeActionCompleted = true;
1851 if(duProcPendingSubsModRsp(pendingSubsModRsp) != ROK)
1853 DU_LOG("\nERROR --> E2AP : failed to process subscription modification rsp");
1859 /*******************************************************************
1861 * @brief du process pending ric subscription modification rsp
1862 * recieved from the layers
1866 * Function : duProcPendingSubsModRsp
1868 * Functionality: Process pending subscription modification response
1869 * If processing of add, mod and remove action completes
1870 * then send the ric sub modification rsp
1872 * @params[in] Pending Subs modification rsp
1874 * @return ROK - success
1877 * ****************************************************************/
1878 uint8_t duProcPendingSubsModRsp( PendingSubsModRspInfo *pendingSubsModRsp)
1880 if(pendingSubsModRsp->addActionCompleted && pendingSubsModRsp->removeActionCompleted && pendingSubsModRsp->modActionCompleted)
1883 BuildAndSendRicSubsModRsp(pendingSubsModRsp);
1885 memset(pendingSubsModRsp, 0, sizeof(PendingSubsModRspInfo));
1886 DU_LOG("\nProcessing of RIC subscription modification completed");
1890 /*******************************************************************
1892 * @brief Process statistics modification response from MAC
1896 * Function : e2ProcStatsModificationRsp
1898 * Functionality: Processes statistics modification configuration
1899 * response from MAC.
1900 * [Step-1] Fetch RAN Function and Subscription DB using subs Id
1901 * received in statistics modification response.
1902 * [Step-2] Fetch pre-stored statistics mod response info by DUAPP.
1903 * [Step 3] - Traverse each index of accepted list received in
1904 * stats modification response.
1905 * [Step 3.1] - fetch action info from databse which is set
1906 * as CONFIG_UNKNOWN and then delete the node.
1907 * [Step 3.1] - Again fetch action info from databse which is
1908 * set as CONFIG_MOD. Change the action status as CONFIG_UNKNOWN.
1909 * fill the action in pending subscription modification rsp's
1911 * [Step 4] - Traverse each index of rejected list received in
1912 * stats modification response.
1913 * [Step 4.1] - fetch action info from databse and delete
1914 * the action node which is set as CONFIG_MOD. and then
1915 * fill the action in pending subscription modification rsp's
1917 * [Step 5] - Send subscription response with accepted and rejected
1918 * @params[in] Statistics modification response received from MAC
1920 * @return ROK - success
1923 * ****************************************************************/
1924 uint8_t e2ProcStatsModificationRsp(MacStatsModificationRsp *statsModificationRsp)
1927 uint8_t actionId = 0;
1928 uint8_t tempCount = 0;
1929 RanFunction *ranFuncDb = NULLP;
1930 CmLList *actionNode = NULLP;
1931 ActionInfo *actionInfoDb = NULLP;
1932 CmLList *ricSubscriptionNode = NULLP;
1933 RicSubscription *ricSubscriptionInfo = NULLP;
1934 PendingSubsModRspInfo *pendingSubsModRsp = NULLP;
1938 if(fetchSubsInfoFromSubsId(statsModificationRsp->subscriptionId, &ranFuncDb, &ricSubscriptionNode, &ricSubscriptionInfo) != ROK)
1940 DU_LOG("\nERROR --> E2AP : failed in function %s at line %d",__func__,__LINE__);
1945 for(idx=0; idx<ranFuncDb->numPendingSubsModRsp; idx++)
1947 if((ranFuncDb->pendingSubsModRspInfo[idx].requestId.requestorId == ricSubscriptionInfo->requestId.requestorId) &&
1948 (ricSubscriptionInfo->requestId.instanceId == ricSubscriptionInfo->requestId.instanceId))
1950 pendingSubsModRsp = &ranFuncDb->pendingSubsModRspInfo[idx];
1954 if(pendingSubsModRsp == NULLP)
1956 DU_LOG("\nERROR --> E2AP : failed in function %s at line %d",__func__,__LINE__);
1961 for(idx=0; idx<statsModificationRsp->numGrpAccepted; idx++)
1963 actionInfoDb = NULLP;
1964 actionId = statsModificationRsp->statsGrpAcceptedList[idx];
1967 actionInfoDb = fetchActionInfoFromActionId(actionId, ricSubscriptionInfo, &actionNode,CONFIG_UNKNOWN);
1970 cmLListDelFrm(&ricSubscriptionInfo->actionSequence, actionNode);
1971 deleteActionSequence(actionNode);
1976 actionInfoDb = fetchActionInfoFromActionId(actionId, ricSubscriptionInfo, &actionNode,CONFIG_MOD);
1979 actionInfoDb->action = CONFIG_UNKNOWN;
1981 pendingSubsModRsp->modActionStatus.acceptedActionList[pendingSubsModRsp->modActionStatus.numOfAcceptedActions++] = actionId;
1985 for(idx=0; idx<statsModificationRsp->numGrpRejected; idx++)
1987 actionInfoDb = NULLP;
1988 actionId = statsModificationRsp->statsGrpRejectedList[idx].groupId;
1991 actionInfoDb = fetchActionInfoFromActionId(actionId, ricSubscriptionInfo, &actionNode, CONFIG_MOD);
1994 cmLListDelFrm(&ricSubscriptionInfo->actionSequence, actionNode);
1995 deleteActionSequence(actionNode);
1996 tempCount = pendingSubsModRsp->modActionStatus.numOfRejectedActions;
1997 pendingSubsModRsp->modActionStatus.rejectedActionList[tempCount].id = actionId;
1998 convertDuCauseToE2Cause(statsModificationRsp->statsGrpRejectedList[idx].cause, \
1999 &pendingSubsModRsp->modActionStatus.rejectedActionList[tempCount].failureCause);
2000 pendingSubsModRsp->modActionStatus.numOfRejectedActions++;
2005 pendingSubsModRsp->modActionCompleted = true;
2006 if(duProcPendingSubsModRsp(pendingSubsModRsp) != ROK)
2008 DU_LOG("\nERROR --> E2AP : failed to process subscription modification rsp");
2014 /*******************************************************************
2016 * @brief Fill RIC Subscription datils in MAC Statistics
2017 * ModificationRequest
2021 * Function : fillRicSubsInMacStatsModificationReq
2023 * Functionality: Fill RIC Subscription datils in MAC
2024 * Modification Statistics Request
2025 * [Step -1] Generate subscription ID using RIC Request ID and
2027 * [Step -2] Check all the action staus of each action present
2028 * in the ric subscription. If action is CONFIG_MOD then fill
2029 * the information in stats group list.
2030 * [Step -3] Fill group related information in stats modification
2031 * req's in stats group list
2032 * [Step -4] fill measurement information in stats group list
2033 * [Step -5] If the number of stats which needs to modify is
2034 * greater then zero then return ROK else return RFAILED
2036 * @params[in] MAC Statistics Modification Request to be filled
2037 * RIC Subscription Info
2039 * @return ROK - success
2042 * ****************************************************************/
2043 uint8_t fillRicSubsInMacStatsModificationReq(MacStatsModificationReq *macStatsModificationReq, RicSubscription* ricSubscriptionInfo)
2046 uint8_t statsModifyReqIdx = 0;
2047 uint64_t subscriptionId = 0;
2048 CmLList *node = NULLP;
2049 ActionInfo *actionDb = NULLP;
2050 CmLList *actionNode = NULLP;
2051 MeasurementInfo *measInfo = NULLP;
2052 ActionDefFormat1 *format1Action = NULLP;
2055 encodeSubscriptionId(&subscriptionId, ricSubscriptionInfo->ranFuncId, ricSubscriptionInfo->requestId);
2057 macStatsModificationReq->subscriptionId = subscriptionId;
2058 CM_LLIST_FIRST_NODE(&ricSubscriptionInfo->actionSequence, actionNode);
2061 actionDb = (ActionInfo*)(actionNode->node);
2063 if(actionDb->action == CONFIG_MOD)
2066 macStatsModificationReq->statsGrpList[grpIdx].groupId = actionDb->actionId;
2067 switch(actionDb->definition.formatType)
2071 format1Action = &actionDb->definition.choice.format1;
2072 macStatsModificationReq->statsGrpList[grpIdx].periodicity = format1Action->granularityPeriod;
2074 statsModifyReqIdx = 0;
2075 node = cmLListFirst(&format1Action->measurementInfoList);
2079 measInfo = (MeasurementInfo *)(node->node);
2080 switch(measInfo->measurementTypeId)
2084 macStatsModificationReq->statsGrpList[grpIdx].statsList[statsModifyReqIdx++] = MAC_DL_TOTAL_PRB_USAGE;
2089 macStatsModificationReq->statsGrpList[grpIdx].statsList[statsModifyReqIdx++] = MAC_UL_TOTAL_PRB_USAGE;
2094 DU_LOG("\nERROR --> E2AP : Invalid measurement name");
2100 macStatsModificationReq->statsGrpList[grpIdx].numStats = statsModifyReqIdx;
2105 DU_LOG("\nERROR --> E2AP : fillRicSubsInMacStatsModificationReq: Only Action Definition Format 1 supported");
2109 if(macStatsModificationReq->statsGrpList[grpIdx].numStats)
2112 actionNode = actionNode->next;
2116 macStatsModificationReq->numStatsGroup = grpIdx;
2117 if(macStatsModificationReq->numStatsGroup)
2124 /**********************************************************************
2126 **********************************************************************/