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 all E2AP message handler related functionality */
20 #define MAX_E2_SETUP_TMR 1
21 #define MAX_E2_NODE_CONFIG_UPDATE_TMR 1
22 #define MAX_RIC_SERVICE_UPDATE_TMR 1
23 #define MAX_RIC_SUBSCRIPTION_REPORTING_TMR 1
25 #define EVENT_E2_SETUP_TMR 1
26 #define EVENT_RIC_SERVICE_UPDATE_TMR 2
27 #define EVENT_E2_NODE_CONFIG_UPDATE_TMR 3
28 #define EVENT_RIC_SUBSCRIPTION_REPORTING_TMR 4
30 #define MAX_NUM_TRANSACTION 256 /* As per, O-RAN WG3 E2AP v3.0, section 9.2.33 */
31 #define MAX_RAN_FUNCTION 256 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.1.2.2 : maxofRANfunctionID */
32 #define MAX_E2_NODE_COMPONENT 1024 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.1.2.2 : maxofE2nodeComponents */
33 #define MAX_TNL_ASSOCIATION 32 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.1.2.11 : maxofTNLA */
34 #define MAX_RIC_STYLES 64 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.2.1 : maxnoofRICstyle */
35 #define MAX_MEASUREMENT_INFO 65535 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.2.1 : maxnoofMeasurementInfo */
36 #define MAX_LABEL_INFO 2147483648 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.2.1 : maxnoofLabelInfo */
37 #define MAX_RIC_ACTION 16 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.1.1.1 : maxofRICActionID */
38 #define MAX_RIC_REQUEST 65535 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.7 */
39 #define MAX_PENDING_SUBSCRIPTION_RSP 5 /* Number of statistics request in processing */
41 #define STRING_SIZE_150_BYTES 150
42 #define STRING_SIZE_1000_BYTES 1000
44 #define SHORT_NAME "ORAN-E2SM-KPM"
45 #define SERVICE_MODEL_OID "1.3.6.1.4.1.53148.1.2.2.2"
46 #define DESCRIPTION "KPM Monitor"
47 #define NUM_OF_EVENT_TRIGGER_STYLE_SUPPORTED 1
48 #define EVENT_TRIGGER_STYLE_NAME "Periodic Report"
49 #define EVENT_TRIGGER_STYLE_TYPE 1
50 #define EVENT_TRIGGER_STYLE_FORMAT_TYPE 1
51 #define NUM_OF_RIC_REPORT_STYLE_SUPPORTED 1
52 #define REPORT_STYLE_NAME "E2 Node Measurement"
53 #define REPORT_STYLE_TYPE 1
54 #define REPORT_ACTION_FORMAT_TYPE 1
55 #define MEASUREMENT_TYPE_NAME (char*[]) {"RRU.PrbTotDl", "RRU.PrbTotUl"}
56 #define RIC_INDICATION_HEADER_FORMAT 1
57 #define RIC_INDICATION_MESSAGE_FORMAT 1
59 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.26 */
73 E2_NODE_COMPONENT_ADD,
74 E2_NODE_COMPONENT_UPDATE,
79 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.30 */
87 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.11 */
99 }E2ProcedureDirection;
103 E2_RAN_FUNCTION_ID_INVALID,
104 E2_ACTION_NOT_SUPPORTED,
105 E2_EXECESSIVE_ACTIONS,
107 E2_DUPLICATE_EVENT_TRIGGER,
108 E2_FUNCTION_RESOURCE_LIMIT,
109 E2_REQUEST_ID_UNKNOWN,
110 E2_INCONSISTENT_ACTION_SUBSEQUENT_ACTION_SEQUENCE,
111 E2_CONTROL_MESSAGE_INVALID,
112 E2_RIC_CALL_PROCESS_ID_INVALID,
113 E2_CONTROL_TIMER_EXPIRED,
114 E2_CONTROL_FAILED_TO_EXECUTE,
116 E2_RIC_REQUEST_CAUSE_UNSPECIFIED,
117 E2_RIC_SUBSCRIPTION_END_TIME_EXPIRED,
118 E2_RIC_SUBSCRIPTION_END_TIME_INVALID,
119 E2_DUPLICATE_RIC_REQUEST_ID,
120 E2_EVENT_TRIGGER_NOT_SUPPORTED,
121 E2_REQUEST_INFORMATION_UNAVAILABLE,
122 E2_INVALID_INFORMATION_REQUEST
127 E2_RAN_FUNCTION_NOT_SUPPORTED,
128 E2_EXCESSIVE_FUNCTIONS,
129 E2_RIC_RESOURCE_LIMIT,
134 E2_NODE_COMPONENT_UNKNOWN
139 E2_TRANSPORT_CAUSE_UNSPECIFIED,
140 E2_TRANSPORT_RESOURCE_UNAVAILABLE
145 E2_TRANSFER_SYNTAX_ERROR,
146 E2_ABSTRACT_SYNTAX_ERROR_REJECT,
147 E2_ABSTRACT_SYNTAX_ERROR_IGNORE_AND_NOTIFY,
148 E2_MESSAGE_NOT_COMPATIBLE_WITH_RECEIVER_STATE,
150 E2_ABSTRACT_SYNTAX_ERROR_FALSELY_CONSTRUCTED_MESSAGE,
151 E2_PROTOCOL_CAUSE_UNSPECIFIED
156 E2_CONTROL_PROCESSING_OVERLOAD,
159 E2_MISCELLANEOUS_CAUSE_UNSPECIFIED
173 typedef uint8_t E2Cause;
175 typedef struct e2FailureCause
177 E2CauseType causeType;
183 uint8_t transactionId;
184 uint8_t procedureCode;
187 typedef struct e2Transcation
189 uint8_t transIdCounter; /* counting the total number of DU initiated transaction */
190 E2TransInfo e2InitTransaction[MAX_NUM_TRANSACTION]; /* Storing DU-initiated transactions information */
191 E2TransInfo ricInitTransaction[MAX_NUM_TRANSACTION]; /* Storing RIC-initiated transactions information */
197 uint16_t revisionCounter;
202 uint8_t numOfRanFunToBeAdded;
203 RanFuncInfo ranFunToBeAdded[MAX_RAN_FUNCTION];
204 uint8_t numOfRanFunToBeModified;
205 RanFuncInfo ranFunToBeModified[MAX_RAN_FUNCTION];
206 uint8_t numOfRanFunToBeDeleted;
207 RanFuncInfo ranFunToBeDeleted[MAX_RAN_FUNCTION];
210 typedef struct ricServiceUpdate
212 E2ProcedureDirection dir;
214 E2TmpRanFunList recvRanFuncList;
219 RicServiceUpdate ricService;
221 }RicServiceUpdateTimer;
223 typedef struct e2NodeCfgItem
225 InterfaceType interface;
226 uint64_t componentId;
229 typedef struct e2NodeCfgList
231 uint16_t addE2NodeCount;
232 E2NodeConfigItem addE2Node[MAX_E2_NODE_COMPONENT];
233 uint16_t updateE2NodeCount;
234 E2NodeConfigItem updateE2Node[MAX_E2_NODE_COMPONENT];
235 uint16_t removeE2NodeCount;
236 E2NodeConfigItem removeE2Node[MAX_E2_NODE_COMPONENT];
241 E2NodeConfigList configList;
243 }E2NodeConfigUpdateTimer;
245 typedef struct e2Timer
247 CmTimer e2SetupTimer;
248 RicServiceUpdateTimer ricServiceUpdateTimer;
249 E2NodeConfigUpdateTimer e2NodeConfigUpdate;
250 /* More timers can be added to this structure in future */
254 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.4 */
258 uint32_t nearRtRicId;
261 /* O-RAN.WG3.E2SM-R003-v03.00 : Section 6.2.2.1 */
264 char shortName[STRING_SIZE_150_BYTES];
265 char serviceModelOID[STRING_SIZE_1000_BYTES];
266 char description[STRING_SIZE_150_BYTES];
269 /* O-RAN.WG3.E2SM-R003-v03.00 : Section 6.2.2.2-6.2.2.4 */
273 char name[STRING_SIZE_150_BYTES];
277 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.2.1 */
280 char measurementTypeName[STRING_SIZE_150_BYTES];
281 uint16_t measurementTypeId;
282 }MeasurementInfoForAction;
286 RicStyle reportStyle;
287 CmLListCp measurementInfoList;
290 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.7 */
293 uint16_t requestorId;
297 typedef struct reportStartTime
300 uint32_t timeInMilliSec;
303 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.1.1 */
306 uint32_t reportingPeriod; /* In milliseconds */
307 ReportStartTime startTime;
308 }EventTriggerFormat1;
310 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.1 */
316 EventTriggerFormat1 format1;
317 /* More formats can be added in future */
319 }EventTriggerDefinition;
321 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.3.11 */
324 /* TODO : To be added in future when subcounters for any
325 * measurment type is required */
328 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.2.1 */
331 char measurementTypeName[STRING_SIZE_150_BYTES];
332 uint16_t measurementTypeId;
334 /* As of now Labels are not used, hence it is not implemented completely */
335 //uint32_t numOfLabels;
336 //LabelInfo LabelInfoList[MAX_LABEL_INFO];
338 CmLListCp measuredValue; /* To be filled when numOfLabels is 0, else values are calculated per Label */
341 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.2.1 */
344 CmLListCp measurementInfoList; /* Each node corresponds to MeasurementInfo */
345 uint32_t granularityPeriod; /* In millisecond */
348 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.2.2 */
351 /* TODO : This format will be defined in future if required */
354 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.2.3 */
357 /* TODO : This format will be defined in future if required */
360 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.2.4 */
363 /* TODO : This format will be defined in future if required */
366 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.2.5 */
369 /* TODO : This format will be defined in future if required */
372 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.2 */
379 ActionDefFormat1 format1;
380 ActionDefFormat2 format2;
381 ActionDefFormat3 format3;
382 ActionDefFormat4 format4;
383 ActionDefFormat5 format5;
387 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.1.1.1 : maxofRICActionID */
390 int16_t actionId; /* O-RAN.WG3.E2AP-R003-v03.00 Section 9.2.10. Valid action id range = 0..255 */
392 ActionDefinition definition;
394 E2FailureCause failureCause; /* Used only when an action is required to be deleted */
397 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.1.1.1 : maxofRICActionID */
400 RicRequestId requestId;
402 EventTriggerDefinition eventTriggerDefinition;
403 CmLListCp actionSequence;
404 CmTimer ricSubsReportTimer;
406 E2FailureCause failureCause; /* Used only when a subscription is required to be deleted */
409 typedef struct rejectedAction
412 E2FailureCause failureCause;
415 typedef struct pendingSubsRspInfo
417 RicRequestId requestId;
419 uint8_t numOfAcceptedActions;
420 uint8_t acceptedActionList[MAX_RIC_ACTION];
421 uint8_t numOfRejectedActions;
422 RejectedAction rejectedActionList[MAX_RIC_ACTION];
425 typedef struct actionStatus
427 uint8_t numOfAcceptedActions;
428 uint8_t acceptedActionList[MAX_RIC_ACTION];
429 uint8_t numOfRejectedActions;
430 RejectedAction rejectedActionList[MAX_RIC_ACTION];
433 typedef struct pendingSubsModRspInfo
435 RicRequestId requestId;
437 bool addActionCompleted;
438 ActionStatus addActionStatus;
439 bool modActionCompleted;
440 ActionStatus modActionStatus;
441 bool removeActionCompleted;
442 ActionStatus removeActionStatus;
443 }PendingSubsModRspInfo;
447 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.2.1 */
449 RanFunctionName name;
450 uint16_t revisionCounter;
451 uint8_t numOfEventTriggerStyleSupported;
452 RicStyle eventTriggerStyleList[MAX_RIC_STYLES];
453 uint8_t numOfReportStyleSupported;
454 RicReportStyle reportStyleList[MAX_RIC_STYLES];
455 uint8_t ricIndicationHeaderFormat;
456 uint8_t ricIndicationMessageFormat;
457 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.1.1.1 */
458 CmLListCp subscriptionList;
459 uint8_t numPendingSubsRsp;
460 PendingSubsRspInfo pendingSubsRspInfo[MAX_PENDING_SUBSCRIPTION_RSP];
461 uint8_t numPendingSubsModRsp;
462 PendingSubsModRspInfo pendingSubsModRspInfo[MAX_PENDING_SUBSCRIPTION_RSP];
465 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.26-9.2.27 */
469 uint8_t *componentRequestPart;
471 uint8_t *componentResponsePart;
476 InterfaceType interfaceType;
477 uint64_t componentId;
478 E2NodeConfig *addConfiguration;
479 E2NodeConfig *updateConfiguration;
480 bool deleteConfiguration;
483 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.29 */
485 typedef struct e2Ipaddr
493 E2IpAddr localIpAddress;
495 E2IpAddr destIpAddress;
500 typedef struct e2TimersInfo
503 uint8_t e2SetupTimerInterval;
510 E2Transaction e2TransInfo;
511 uint16_t numOfRanFunction;
512 RanFunction ranFunction[MAX_RAN_FUNCTION];
513 CmLListCp e2NodeComponentList;
514 uint8_t numOfTNLAssoc;
515 TNLAssociation tnlAssoc[MAX_TNL_ASSOCIATION];
516 E2TimersInfo e2TimersInfo;
519 typedef struct e2ConnectionItem
525 typedef struct e2ConnectionList
527 uint8_t numOfE2ConnectionSetup;
528 E2ConnectionItem setupE2Connection[MAX_TNL_ASSOCIATION];
529 uint8_t numOfE2ConnectionFailedToSetup;
530 E2ConnectionItem failedToSetupE2Connection[MAX_TNL_ASSOCIATION];
533 uint8_t assignTransactionId();
534 ActionInfo *fetchActionInfoFromActionId(uint8_t actionId, RicSubscription *ricSubscriptionInfo, CmLList ** actionNode, ConfigType configType);
535 RicSubscription *fetchSubsInfoFromRicReqId(RicRequestId ricReqId, RanFunction *ranFuncDb, CmLList **ricSubscriptionNode);
536 RanFunction *fetchRanFuncFromRanFuncId(uint16_t ranFuncId);
537 uint8_t fetchSubsInfoFromSubsId(uint64_t subscriptionId, RanFunction **ranFuncDb, CmLList **ricSubscriptionNode, \
538 RicSubscription **ricSubscriptionInfo);
539 void fetchRicSubsToBeDeleted(CmLListCp *ricSubsToBeDelList);
541 uint8_t fillRicSubsInMacStatsReq(MacStatsReq *macStatsReq, RicSubscription* ricSubscriptionInfo);
542 uint8_t e2ProcStatsRsp(MacStatsRsp *statsRsp);
543 uint8_t e2ProcStatsInd(MacStatsInd *statsInd);
544 void E2apHdlRicSubsReportTmrExp(RicSubscription *ricSubscription);
546 uint8_t ResetE2Request(E2ProcedureDirection dir, E2FailureCause resetCause);
547 uint8_t SendE2APMsg(Region region, Pool pool, char *encBuf, int encBufSize);
548 E2NodeComponent *fetchE2NodeComponentInfo(InterfaceType interfaceType, uint64_t componentId, CmLList **e2ComponentNode);
549 uint8_t fillE2NodeComponentReqInfo(InterfaceType interfaceType, uint64_t componentId, uint8_t action, uint8_t bufSize, char *bufString);
550 uint8_t fillE2NodeComponentRspInfo(InterfaceType interfaceType, uint64_t componentId, uint8_t action, uint8_t bufSize, char *bufString);
551 void deleteRicSubscriptionList(CmLListCp *subscriptionList);
552 void deleteRicSubscriptionNode(CmLList *ricSubscriptionInfo);
553 void deleteMeasurementInfoList(CmLListCp *measInfoList);
554 void deleteActionSequence(CmLList *action);
555 void deleteMeasuredValueList(CmLListCp *measuredValueList);
556 void removeE2NodeInformation();
557 void encodeSubscriptionId(uint64_t *subscriptionId, uint16_t ranFuncId, RicRequestId ricReqId);
558 uint8_t e2ProcStatsDeleteRsp(MacStatsDeleteRsp *statsDeleteRsp);
559 uint8_t fillRicSubsInMacStatsModificationReq(MacStatsModificationReq *macStatsModReq, RicSubscription* ricSubscriptionInfo);
560 uint8_t e2ProcActionDeleteRsp(MacStatsDeleteRsp *statsDeleteRsp);
561 uint8_t e2ProcStatsModificationRsp(MacStatsModificationRsp *statsModificationRsp);
562 uint8_t duProcPendingSubsModRsp(RicSubscription *ricSubscriptionInfo, PendingSubsModRspInfo *pendingSubsModRsp);
564 /**********************************************************************
566 **********************************************************************/