[ Jira id - ODUHIGH-593 ] Pack and unpack function nomenclature correction
[o-du/l2.git] / src / du_app / du_e2ap_mgr.h
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
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                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
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
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
24
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
29
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 */
40
41 #define STRING_SIZE_150_BYTES 150
42 #define STRING_SIZE_1000_BYTES 1000
43
44 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.26 */
45 typedef enum
46 {
47    NG,
48    XN,
49    E1,
50    F1,
51    W1,
52    S1,
53    X2
54 }InterfaceType;
55
56 typedef enum
57 {
58    E2_NODE_COMPONENT_ADD,
59    E2_NODE_COMPONENT_UPDATE,
60    E2_NODE_COMPONENT_DEL
61 }ComponentActionType;
62
63
64 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.30 */
65 typedef enum
66 {
67    RIC_SERVICE,
68    SUPPORT_FUNCTIONS,
69    BOTH_FUNCTIONALITY
70 }AssocUsage;
71
72 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.11 */
73 typedef enum
74 {
75    REPORT,
76    INSERT,
77    POLICY
78 }ActionType;
79
80 typedef enum
81 {
82    RIC_INITIATED,
83    E2_NODE_INITIATED
84 }E2ProcedureDirection;
85
86 typedef enum
87 {
88    E2_RAN_FUNCTION_ID_INVALID,
89    E2_ACTION_NOT_SUPPORTED,
90    E2_EXECESSIVE_ACTIONS,
91    E2_DUPLICATE_ACTION,
92    E2_DUPLICATE_EVENT_TRIGGER,
93    E2_FUNCTION_RESOURCE_LIMIT,
94    E2_REQUEST_ID_UNKNOWN,
95    E2_INCONSISTENT_ACTION_SUBSEQUENT_ACTION_SEQUENCE,
96    E2_CONTROL_MESSAGE_INVALID,
97    E2_RIC_CALL_PROCESS_ID_INVALID,
98    E2_CONTROL_TIMER_EXPIRED,
99    E2_CONTROL_FAILED_TO_EXECUTE,
100    E2_SYSTEM_NOT_READY,
101    E2_RIC_REQUEST_CAUSE_UNSPECIFIED,
102    E2_RIC_SUBSCRIPTION_END_TIME_EXPIRED,
103    E2_RIC_SUBSCRIPTION_END_TIME_INVALID,
104    E2_DUPLICATE_RIC_REQUEST_ID,
105    E2_EVENT_TRIGGER_NOT_SUPPORTED,
106    E2_REQUEST_INFORMATION_UNAVAILABLE,
107    E2_INVALID_INFORMATION_REQUEST
108 }E2CauseRicRequest;
109
110 typedef enum
111 {
112    E2_RAN_FUNCTION_NOT_SUPPORTED,
113    E2_EXCESSIVE_FUNCTIONS,
114    E2_RIC_RESOURCE_LIMIT,
115 }E2CauseRicService;
116
117 typedef enum
118 {
119    E2_NODE_COMPONENT_UNKNOWN
120 }E2CauseE2Node;
121
122 typedef enum
123 {
124    E2_TRANSPORT_CAUSE_UNSPECIFIED,
125    E2_TRANSPORT_RESOURCE_UNAVAILABLE
126 }E2CauseTransport;
127
128 typedef enum
129 {
130    E2_TRANSFER_SYNTAX_ERROR,
131    E2_ABSTRACT_SYNTAX_ERROR_REJECT,
132    E2_ABSTRACT_SYNTAX_ERROR_IGNORE_AND_NOTIFY,
133    E2_MESSAGE_NOT_COMPATIBLE_WITH_RECEIVER_STATE,
134    E2_SEMANTIC_ERROR,
135    E2_ABSTRACT_SYNTAX_ERROR_FALSELY_CONSTRUCTED_MESSAGE,
136    E2_PROTOCOL_CAUSE_UNSPECIFIED
137 }E2CauseProtocol;
138
139 typedef enum
140 {
141    E2_CONTROL_PROCESSING_OVERLOAD,
142    E2_HARDWARE_FAILURE,
143    E2_OM_INTERVENTION,
144    E2_MISCELLANEOUS_CAUSE_UNSPECIFIED
145 }E2CauseMisc;
146
147 typedef enum 
148 {
149    E2_NOTHING,
150    E2_RIC_REQUEST,
151    E2_RIC_SERVICE,
152    E2_NODE,
153    E2_TRANSPORT,
154    E2_PROTOCOL,
155    E2_MISCELLANEOUS
156 }E2CauseType;
157
158 typedef uint8_t E2Cause;
159
160 typedef struct e2FailureCause
161 {
162    E2CauseType causeType;
163    uint8_t     cause;
164 }E2FailureCause;
165
166 typedef struct
167 {
168    uint8_t transactionId;
169    uint8_t procedureCode;
170 }E2TransInfo;
171
172 typedef struct e2Transcation
173 {
174    uint8_t     transIdCounter; /* counting the total number of DU initiated transaction */
175    E2TransInfo e2InitTransaction[MAX_NUM_TRANSACTION]; /* Storing DU-initiated transactions information */
176    E2TransInfo ricInitTransaction[MAX_NUM_TRANSACTION]; /* Storing RIC-initiated transactions information */
177 }E2Transaction;
178
179 typedef struct
180 {
181    uint16_t   id;
182    uint16_t   revisionCounter;
183 }RanFuncInfo;
184
185 typedef struct
186 {
187    uint8_t     numOfRanFunToBeAdded;
188    RanFuncInfo ranFunToBeAdded[MAX_RAN_FUNCTION];
189    uint8_t     numOfRanFunToBeModified;
190    RanFuncInfo ranFunToBeModified[MAX_RAN_FUNCTION];
191    uint8_t     numOfRanFunToBeDeleted;
192    RanFuncInfo ranFunToBeDeleted[MAX_RAN_FUNCTION];
193 }E2TmpRanFunList;
194
195 typedef struct ricServiceUpdate
196 {
197    E2ProcedureDirection dir;
198    uint8_t              transId;
199    E2TmpRanFunList      recvRanFuncList;
200 }RicServiceUpdate;
201
202 typedef struct 
203 {
204    RicServiceUpdate ricService;
205    CmTimer          timer;
206 }RicServiceUpdateTimer;
207
208 typedef struct e2NodeCfgItem
209 {
210    InterfaceType interface;
211    uint64_t      componentId; 
212 }E2NodeConfigItem;
213
214 typedef struct e2NodeCfgList
215 {
216    uint16_t addE2NodeCount;
217    E2NodeConfigItem addE2Node[MAX_E2_NODE_COMPONENT];
218    uint16_t updateE2NodeCount;
219    E2NodeConfigItem updateE2Node[MAX_E2_NODE_COMPONENT];
220    uint16_t removeE2NodeCount;
221    E2NodeConfigItem removeE2Node[MAX_E2_NODE_COMPONENT];
222 }E2NodeConfigList;
223
224 typedef struct
225 {
226    E2NodeConfigList configList;
227    CmTimer    timer;
228 }E2NodeConfigUpdateTimer;
229
230 typedef struct e2Timer
231 {
232    CmTimer e2SetupTimer;
233    RicServiceUpdateTimer   ricServiceUpdateTimer;
234    E2NodeConfigUpdateTimer e2NodeConfigUpdate;
235    /* More timers can be added to this structure in future */
236 }E2Timer;
237
238
239 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.4 */
240 typedef struct
241 {
242    Plmn     plmnId; 
243    uint32_t nearRtRicId;
244 }GlobalRicId;
245
246 /* O-RAN.WG3.E2SM-R003-v03.00 : Section 6.2.2.1 */
247 typedef struct
248 {
249    char  shortName[STRING_SIZE_150_BYTES];
250    char  serviceModelOID[STRING_SIZE_1000_BYTES];
251    char  description[STRING_SIZE_150_BYTES];
252 }RanFunctionName;
253
254 /* O-RAN.WG3.E2SM-R003-v03.00 : Section 6.2.2.2-6.2.2.4 */
255 typedef struct
256 {
257    uint8_t styleType;
258    char    name[STRING_SIZE_150_BYTES];
259    uint8_t formatType;
260 }RicStyle;
261
262 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.2.1 */
263 typedef struct
264 {
265    char     measurementTypeName[STRING_SIZE_150_BYTES];
266    uint16_t measurementTypeId;
267 }MeasurementInfoForAction;
268
269 typedef struct
270 {
271    RicStyle       reportStyle;
272    CmLListCp      measurementInfoList;
273 }RicReportStyle;
274
275 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.7 */
276 typedef struct
277 {
278    uint16_t requestorId;
279    uint16_t instanceId;
280 }RicRequestId;
281
282 typedef struct reportStartTime
283 {
284    uint32_t timeInSec;
285    uint32_t timeInMilliSec;
286 }ReportStartTime;
287
288 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.1.1 */
289 typedef struct
290 {
291    uint32_t reportingPeriod; /* In milliseconds */
292    ReportStartTime startTime;
293 }EventTriggerFormat1;
294
295 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.1 */
296 typedef struct
297 {
298    uint8_t  formatType;
299    union
300    {
301       EventTriggerFormat1 format1;
302       /* More formats can be added in future */
303    }choice;
304 }EventTriggerDefinition;
305
306 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.3.11 */
307 typedef struct
308 {
309    /* TODO : To be added in future when subcounters for any
310     * measurment type is required */
311 }LabelInfo;
312
313 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.2.1 */
314 typedef struct
315 {
316    char     measurementTypeName[STRING_SIZE_150_BYTES];
317    uint16_t measurementTypeId;
318
319    /* As of now Labels are not used, hence it is not implemented completely */
320    //uint32_t    numOfLabels;
321    //LabelInfo   LabelInfoList[MAX_LABEL_INFO];
322
323    CmLListCp   measuredValue;  /* To be filled when numOfLabels is 0, else values are calculated per Label */
324 }MeasurementInfo;
325
326 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.2.1 */
327 typedef struct
328 {
329    CmLListCp               measurementInfoList;    /* Each node corresponds to MeasurementInfo */
330    uint32_t                granularityPeriod;      /* In millisecond */
331 }ActionDefFormat1;
332
333 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.2.2 */
334 typedef struct
335 {
336    /* TODO : This format will be defined in future if required */
337 }ActionDefFormat2;
338
339 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.2.3 */
340 typedef struct
341 {
342    /* TODO : This format will be defined in future if required */
343 }ActionDefFormat3;
344
345 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.2.4 */
346 typedef struct
347 {
348    /* TODO : This format will be defined in future if required */
349 }ActionDefFormat4;
350
351 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.2.5 */
352 typedef struct
353 {
354    /* TODO : This format will be defined in future if required */
355 }ActionDefFormat5;
356
357 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.2 */
358 typedef struct
359 {
360    uint8_t     styleType;
361    uint8_t     formatType;
362    union
363    {
364       ActionDefFormat1  format1;
365       ActionDefFormat2  format2;
366       ActionDefFormat3  format3;
367       ActionDefFormat4  format4;
368       ActionDefFormat5  format5;
369    }choice;
370 }ActionDefinition;
371
372 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.1.1.1 : maxofRICActionID */
373 typedef struct
374 {
375    int16_t           actionId;     /* O-RAN.WG3.E2AP-R003-v03.00 Section 9.2.10. Valid action id range = 0..255 */
376    ActionType        type;
377    ActionDefinition  definition;
378    ConfigType        action;
379    E2FailureCause    failureCause; /* Used only when an action is required to be deleted */
380 }ActionInfo;
381
382 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.1.1.1 : maxofRICActionID */
383 typedef struct
384 {
385    RicRequestId           requestId;
386    uint16_t               ranFuncId;
387    EventTriggerDefinition eventTriggerDefinition;
388    CmLListCp              actionSequence; 
389    CmTimer                ricSubsReportTimer;
390    ConfigType             action;
391    E2FailureCause         failureCause; /* Used only when a subscription is required to be deleted */
392 }RicSubscription;
393
394 typedef struct rejectedAction
395 {
396    uint8_t id;
397    E2FailureCause failureCause;
398 }RejectedAction;
399
400 typedef struct pendingSubsRspInfo
401 {
402    RicRequestId    requestId;
403    uint16_t        ranFuncId;
404    uint8_t         numOfAcceptedActions;
405    uint8_t         acceptedActionList[MAX_RIC_ACTION];
406    uint8_t         numOfRejectedActions;
407    RejectedAction  rejectedActionList[MAX_RIC_ACTION];
408 }PendingSubsRspInfo;
409
410 typedef struct actionStatus
411 {
412    uint8_t         numOfAcceptedActions;
413    uint8_t         acceptedActionList[MAX_RIC_ACTION];
414    uint8_t         numOfRejectedActions;
415    RejectedAction  rejectedActionList[MAX_RIC_ACTION];
416 }ActionStatus;
417
418 typedef struct pendingSubsModRspInfo 
419 {
420    RicRequestId requestId;
421    uint16_t     ranFuncId;
422    bool         addActionCompleted;
423    ActionStatus addActionStatus;
424    bool         modActionCompleted;
425    ActionStatus modActionStatus;
426    bool         removeActionCompleted;
427    ActionStatus removeActionStatus;
428 }PendingSubsModRspInfo;
429
430 typedef struct
431 {
432    /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.2.1 */
433    uint16_t         id;
434    RanFunctionName  name;
435    uint16_t         revisionCounter;
436    uint8_t          numOfEventTriggerStyleSupported;
437    RicStyle         eventTriggerStyleList[MAX_RIC_STYLES];
438    uint8_t          numOfReportStyleSupported;
439    RicReportStyle   reportStyleList[MAX_RIC_STYLES];
440    uint8_t          ricIndicationHeaderFormat;
441    uint8_t          ricIndicationMessageFormat;
442    /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.1.1.1 */
443    CmLListCp        subscriptionList;
444    uint8_t          numPendingSubsRsp;
445    PendingSubsRspInfo pendingSubsRspInfo[MAX_PENDING_SUBSCRIPTION_RSP];
446    uint8_t            numPendingSubsModRsp;
447    PendingSubsModRspInfo pendingSubsModRspInfo[MAX_PENDING_SUBSCRIPTION_RSP];
448 }RanFunction;
449
450 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.26-9.2.27 */
451 typedef struct
452 {
453    uint8_t    reqBufSize;
454    uint8_t    *componentRequestPart;
455    uint8_t    rspBufSize;
456    uint8_t    *componentResponsePart;
457 }E2NodeConfig;
458
459 typedef struct
460 {
461    InterfaceType interfaceType;
462    uint64_t      componentId; 
463    E2NodeConfig  *addConfiguration;
464    E2NodeConfig  *updateConfiguration;
465    bool          deleteConfiguration;
466 }E2NodeComponent;
467
468 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.29 */
469
470 typedef struct e2Ipaddr
471 {
472    bool     ipV4Pres;
473    uint32_t ipV4Addr;
474 }E2IpAddr;
475
476 typedef struct
477 {
478    E2IpAddr    localIpAddress;
479    uint16_t    localPort;
480    E2IpAddr    destIpAddress;
481    uint16_t    destPort;
482    AssocUsage  usage;
483 }TNLAssociation;
484
485 typedef struct e2TimersInfo
486 {
487    E2Timer  e2Timers;
488    uint8_t  e2SetupTimerInterval;
489 }E2TimersInfo;
490
491 typedef struct
492 {
493    uint64_t         e2NodeId; 
494    GlobalRicId      ricId;
495    E2Transaction    e2TransInfo;
496    uint16_t         numOfRanFunction;
497    RanFunction      ranFunction[MAX_RAN_FUNCTION];  
498    CmLListCp        e2NodeComponentList; 
499    uint8_t          numOfTNLAssoc;
500    TNLAssociation   tnlAssoc[MAX_TNL_ASSOCIATION];
501    E2TimersInfo     e2TimersInfo;
502 }E2apDb;
503
504 typedef struct e2ConnectionItem
505 {
506    uint32_t    ipV4Addr;
507    AssocUsage  usage;
508 }E2ConnectionItem;
509
510 typedef struct e2ConnectionList
511 {
512    uint8_t numOfE2ConnectionSetup;
513    E2ConnectionItem setupE2Connection[MAX_TNL_ASSOCIATION];
514    uint8_t numOfE2ConnectionFailedToSetup;
515    E2ConnectionItem failedToSetupE2Connection[MAX_TNL_ASSOCIATION];
516 }E2ConnectionList;
517
518 uint8_t assignTransactionId();
519 ActionInfo *fetchActionInfoFromActionId(uint8_t actionId, RicSubscription *ricSubscriptionInfo, CmLList ** actionNode, ConfigType configType);
520 RicSubscription *fetchSubsInfoFromRicReqId(RicRequestId ricReqId, RanFunction *ranFuncDb, CmLList **ricSubscriptionNode);
521 RanFunction *fetchRanFuncFromRanFuncId(uint16_t ranFuncId);
522 uint8_t fetchSubsInfoFromSubsId(uint64_t subscriptionId, RanFunction **ranFuncDb, CmLList **ricSubscriptionNode, \
523    RicSubscription **ricSubscriptionInfo);
524 void fetchRicSubsToBeDeleted(CmLListCp *ricSubsToBeDelList);
525
526 uint8_t fillRicSubsInMacStatsReq(MacStatsReq *macStatsReq, RicSubscription* ricSubscriptionInfo);
527 uint8_t e2ProcStatsRsp(MacStatsRsp *statsRsp);
528 uint8_t e2ProcStatsInd(MacStatsInd *statsInd);
529 void E2apHdlRicSubsReportTmrExp(RicSubscription *ricSubscription);
530
531 uint8_t ResetE2Request(E2ProcedureDirection dir, E2FailureCause resetCause);
532 uint8_t SendE2APMsg(Region region, Pool pool, char *encBuf, int encBufSize);
533 E2NodeComponent *fetchE2NodeComponentInfo(InterfaceType interfaceType, uint64_t componentId, CmLList **e2ComponentNode);
534 uint8_t fillE2NodeComponentReqInfo(InterfaceType interfaceType, uint64_t componentId, uint8_t action, uint8_t bufSize, char *bufString);
535 uint8_t fillE2NodeComponentRspInfo(InterfaceType interfaceType, uint64_t componentId, uint8_t action, uint8_t bufSize, char *bufString);
536 void deleteRicSubscriptionList(CmLListCp *subscriptionList);
537 void deleteRicSubscriptionNode(CmLList *ricSubscriptionInfo);
538 void deleteMeasurementInfoList(CmLListCp *measInfoList);
539 void deleteActionSequence(CmLList *action);
540 void deleteMeasuredValueList(CmLListCp *measuredValueList);
541 void removeE2NodeInformation();
542 void encodeSubscriptionId(uint64_t *subscriptionId, uint16_t ranFuncId, RicRequestId ricReqId);
543 uint8_t e2ProcStatsDeleteRsp(MacStatsDeleteRsp *statsDeleteRsp);
544 uint8_t fillRicSubsInMacStatsModificationReq(MacStatsModificationReq *macStatsModReq, RicSubscription* ricSubscriptionInfo);
545 uint8_t e2ProcActionDeleteRsp(MacStatsDeleteRsp *statsDeleteRsp);
546 uint8_t e2ProcStatsModificationRsp(MacStatsModificationRsp *statsModificationRsp);
547 uint8_t duProcPendingSubsModRsp(RicSubscription *ricSubscriptionInfo, PendingSubsModRspInfo *pendingSubsModRsp);
548
549 /**********************************************************************
550   End of file
551  **********************************************************************/