e1195d5ef98fe7698b7eee1349e53add37412b5d
[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
24 #define EVENT_E2_SETUP_TMR 1
25 #define EVENT_RIC_SERVICE_UPDATE_TMR 2
26 #define EVENT_E2_NODE_CONFIG_UPDATE_TMR 3
27
28 #define MAX_NUM_TRANSACTION 256 /* As per, O-RAN WG3 E2AP v3.0, section 9.2.33 */
29 #define MAX_RAN_FUNCTION 256        /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.1.2.2 : maxofRANfunctionID */
30 #define MAX_E2_NODE_COMPONENT 1024     /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.1.2.2 : maxofE2nodeComponents */
31 #define MAX_TNL_ASSOCIATION 32         /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.1.2.11 : maxofTNLA */
32 #define MAX_RIC_STYLES 64           /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.2.1 : maxnoofRICstyle */
33 #define MAX_MEASUREMENT_INFO 65535     /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.2.1 : maxnoofMeasurementInfo */
34 #define MAX_LABEL_INFO  2147483648     /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.2.1 : maxnoofLabelInfo */
35 #define MAX_RIC_ACTION  16          /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.1.1.1 : maxofRICActionID */
36 #define MAX_RIC_REQUEST 65535       /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.7 */
37 #define MAX_PENDING_SUBSCRIPTION_RSP 5  /* Number of statistics request in processing */
38
39 #define STRING_SIZE_150_BYTES 150
40 #define STRING_SIZE_1000_BYTES 1000
41
42 #define SHORT_NAME "ORAN-E2SM-KPM"
43 #define SERVICE_MODEL_OID  "1.3.6.1.4.1.53148.1.2.2.2"
44 #define DESCRIPTION "KPM Monitor"
45 #define NUM_OF_EVENT_TRIGGER_STYLE_SUPPORTED 1
46 #define EVENT_TRIGGER_STYLE_NAME "Periodic Report"
47 #define EVENT_TRIGGER_STYLE_TYPE 1
48 #define EVENT_TRIGGER_STYLE_FORMAT_TYPE 1
49 #define NUM_OF_RIC_REPORT_STYLE_SUPPORTED 1
50 #define REPORT_STYLE_NAME "E2 Node Measurement"
51 #define REPORT_STYLE_TYPE 1
52 #define REPORT_ACTION_FORMAT_TYPE 1
53 #define MEASUREMENT_TYPE_NAME (char*[]) {"RRU.PrbTotDl", "RRU.PrbTotUl"}
54 #define RIC_INDICATION_HEADER_FORMAT 1
55 #define RIC_INDICATION_MESSAGE_FORMAT 1
56
57 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.26 */
58 typedef enum
59 {
60    NG,
61    XN,
62    E1,
63    F1,
64    W1,
65    S1,
66    X2
67 }InterfaceType;
68
69 typedef enum
70 {
71    E2_NODE_COMPONENT_ADD,
72    E2_NODE_COMPONENT_UPDATE,
73    E2_NODE_COMPONENT_DEL
74 }ComponentActionType;
75
76
77 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.30 */
78 typedef enum
79 {
80    RIC_SERVICE,
81    SUPPORT_FUNCTIONS,
82    BOTH_FUNCTIONALITY
83 }AssocUsage;
84
85 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.11 */
86 typedef enum
87 {
88    REPORT,
89    INSERT,
90    POLICY
91 }ActionType;
92
93 typedef enum
94 {
95    RIC_INITIATED,
96    E2_NODE_INITIATED
97 }E2ProcedureDirection;
98
99 typedef enum
100 {
101    E2_RAN_FUNCTION_ID_INVALID,
102    E2_ACTION_NOT_SUPPORTED,
103    E2_EXECESSIVE_ACTIONS,
104    E2_DUPLICATE_ACTION,
105    E2_DUPLICATE_EVENT_TRIGGER,
106    E2_FUNCTION_RESOURCE_LIMIT,
107    E2_REQUEST_ID_UNKNOWN,
108    E2_INCONSISTENT_ACTION_SUBSEQUENT_ACTION_SEQUENCE,
109    E2_CONTROL_MESSAGE_INVALID,
110    E2_RIC_CALL_PROCESS_ID_INVALID,
111    E2_CONTROL_TIMER_EXPIRED,
112    E2_CONTROL_FAILED_TO_EXECUTE,
113    E2_SYSTEM_NOT_READY,
114    E2_RIC_REQUEST_CAUSE_UNSPECIFIED,
115    E2_RIC_SUBSCRIPTION_END_TIME_EXPIRED,
116    E2_RIC_SUBSCRIPTION_END_TIME_INVALID,
117    E2_DUPLICATE_RIC_REQUEST_ID,
118    E2_EVENT_TRIGGER_NOT_SUPPORTED,
119    E2_REQUEST_INFORMATION_UNAVAILABLE,
120    E2_INVALID_INFORMATION_REQUEST
121 }E2CauseRicRequest;
122
123 typedef enum
124 {
125    E2_RAN_FUNCTION_NOT_SUPPORTED,
126    E2_EXCESSIVE_FUNCTIONS,
127    E2_RIC_RESOURCE_LIMIT,
128 }E2CauseRicService;
129
130 typedef enum
131 {
132    E2_NODE_COMPONENT_UNKNOWN
133 }E2CauseE2Node;
134
135 typedef enum
136 {
137    E2_TRANSPORT_CAUSE_UNSPECIFIED,
138    E2_TRANSPORT_RESOURCE_UNAVAILABLE
139 }E2CauseTransport;
140
141 typedef enum
142 {
143    E2_TRANSFER_SYNTAX_ERROR,
144    E2_ABSTRACT_SYNTAX_ERROR_REJECT,
145    E2_ABSTRACT_SYNTAX_ERROR_IGNORE_AND_NOTIFY,
146    E2_MESSAGE_NOT_COMPATIBLE_WITH_RECEIVER_STATE,
147    E2_SEMANTIC_ERROR,
148    E2_ABSTRACT_SYNTAX_ERROR_FALSELY_CONSTRUCTED_MESSAGE,
149    E2_PROTOCOL_CAUSE_UNSPECIFIED
150 }E2CauseProtocol;
151
152 typedef enum
153 {
154    E2_CONTROL_PROCESSING_OVERLOAD,
155    E2_HARDWARE_FAILURE,
156    E2_OM_INTERVENTION,
157    E2_MISCELLANEOUS_CAUSE_UNSPECIFIED
158 }E2CauseMisc;
159
160 typedef enum 
161 {
162    E2_NOTHING,
163    E2_RIC_REQUEST,
164    E2_RIC_SERVICE,
165    E2_NODE,
166    E2_TRANSPORT,
167    E2_PROTOCOL,
168    E2_MISCELLANEOUS
169 }E2CauseType;
170
171 typedef uint8_t E2Cause;
172
173 typedef struct e2FailureCause
174 {
175    E2CauseType causeType;
176    uint8_t     cause;
177 }E2FailureCause;
178
179 typedef struct
180 {
181    uint8_t transactionId;
182    uint8_t procedureCode;
183 }E2TransInfo;
184
185 typedef struct e2Transcation
186 {
187    uint8_t     transIdCounter; /* counting the total number of DU initiated transaction */
188    E2TransInfo e2InitTransaction[MAX_NUM_TRANSACTION]; /* Storing DU-initiated transactions information */
189    E2TransInfo ricInitTransaction[MAX_NUM_TRANSACTION]; /* Storing RIC-initiated transactions information */
190 }E2Transaction;
191
192 typedef struct
193 {
194    uint16_t   id;
195    uint16_t   revisionCounter;
196 }RanFuncInfo;
197
198 typedef struct
199 {
200    uint8_t     numOfRanFunToBeAdded;
201    RanFuncInfo ranFunToBeAdded[MAX_RAN_FUNCTION];
202    uint8_t     numOfRanFunToBeModified;
203    RanFuncInfo ranFunToBeModified[MAX_RAN_FUNCTION];
204    uint8_t     numOfRanFunToBeDeleted;
205    RanFuncInfo ranFunToBeDeleted[MAX_RAN_FUNCTION];
206 }E2TmpRanFunList;
207
208 typedef struct ricServiceUpdate
209 {
210    E2ProcedureDirection dir;
211    uint8_t              transId;
212    E2TmpRanFunList      recvRanFuncList;
213 }RicServiceUpdate;
214
215 typedef struct 
216 {
217    RicServiceUpdate ricService;
218    CmTimer          timer;
219 }RicServiceUpdateTimer;
220
221 typedef struct e2NodeCfgItem
222 {
223    InterfaceType interface;
224    ComponentActionType actionType;
225 }E2NodeConfigItem;
226
227 typedef struct e2NodeCfgList
228 {
229    uint16_t addE2NodeCount;
230    E2NodeConfigItem addE2Node[MAX_E2_NODE_COMPONENT];
231    uint16_t updateE2NodeCount;
232    E2NodeConfigItem updateE2Node[MAX_E2_NODE_COMPONENT];
233    uint16_t removeE2NodeCount;
234    E2NodeConfigItem removeE2Node[MAX_E2_NODE_COMPONENT];
235 }E2NodeConfigList;
236
237 typedef struct
238 {
239    E2NodeConfigList configList;
240    CmTimer    timer;
241 }E2NodeConfigUpdateTimer;
242
243 typedef struct e2Timer
244 {
245    CmTimer e2SetupTimer;
246    RicServiceUpdateTimer   ricServiceUpdateTimer;
247    E2NodeConfigUpdateTimer e2NodeConfigUpdate;
248    /* More timers can be added to this structure in future */
249 }E2Timer;
250
251
252 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.4 */
253 typedef struct
254 {
255    Plmn     plmnId; 
256    uint32_t nearRtRicId;
257 }GlobalRicId;
258
259 /* O-RAN.WG3.E2SM-R003-v03.00 : Section 6.2.2.1 */
260 typedef struct
261 {
262    char  shortName[STRING_SIZE_150_BYTES];
263    char  serviceModelOID[STRING_SIZE_1000_BYTES];
264    char  description[STRING_SIZE_150_BYTES];
265 }RanFunctionName;
266
267 /* O-RAN.WG3.E2SM-R003-v03.00 : Section 6.2.2.2-6.2.2.4 */
268 typedef struct
269 {
270    uint8_t styleType;
271    char    name[STRING_SIZE_150_BYTES];
272    uint8_t formatType;
273 }RicStyle;
274
275 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.2.1 */
276 typedef struct
277 {
278    char     measurementTypeName[STRING_SIZE_150_BYTES];
279    uint16_t measurementTypeId;
280 }MeasurementInfoForAction;
281
282 typedef struct
283 {
284    RicStyle       reportStyle;
285    CmLListCp      measurementInfoList;
286 }RicReportStyle;
287
288 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.7 */
289 typedef struct
290 {
291    uint16_t requestorId;
292    uint16_t instanceId;
293 }RicRequestId;
294
295 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.1.1 */
296 typedef struct
297 {
298    uint32_t reportingPeriod; /* In milliseconds */
299 }EventTriggerFormat1;
300
301 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.1 */
302 typedef struct
303 {
304    uint8_t  formatType;
305    union
306    {
307       EventTriggerFormat1 format1;
308       /* More formats can be added in future */
309    }choice;
310 }EventTriggerDefinition;
311
312 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.3.11 */
313 typedef struct
314 {
315    /* TODO : To be added in future when subcounters for any
316     * measurment type is required */
317 }LabelInfo;
318
319 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.2.1 */
320 typedef struct
321 {
322    char     measurementTypeName[STRING_SIZE_150_BYTES];
323    uint16_t measurementTypeId;
324
325    /* As of now Labels are not used, hence it is not implemented completely */
326    //uint32_t    numOfLabels;
327    //LabelInfo   LabelInfoList[MAX_LABEL_INFO];
328
329    CmLListCp   measuredValue;  /* To be filled when numOfLabels is 0, else values are calculated per Label */
330 }MeasurementInfo;
331
332 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.2.1 */
333 typedef struct
334 {
335    CmLListCp               measurementInfoList;    /* Each node corresponds to MeasurementInfo */
336    uint32_t                granularityPeriod;      /* In millisecond */
337 }ActionDefFormat1;
338
339 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.2.2 */
340 typedef struct
341 {
342    /* TODO : This format will be defined in future if required */
343 }ActionDefFormat2;
344
345 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.2.3 */
346 typedef struct
347 {
348    /* TODO : This format will be defined in future if required */
349 }ActionDefFormat3;
350
351 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.2.4 */
352 typedef struct
353 {
354    /* TODO : This format will be defined in future if required */
355 }ActionDefFormat4;
356
357 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.2.5 */
358 typedef struct
359 {
360    /* TODO : This format will be defined in future if required */
361 }ActionDefFormat5;
362
363 /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.1.2 */
364 typedef struct
365 {
366    uint8_t     styleType;
367    uint8_t     formatType;
368    union
369    {
370       ActionDefFormat1  format1;
371       ActionDefFormat2  format2;
372       ActionDefFormat3  format3;
373       ActionDefFormat4  format4;
374       ActionDefFormat5  format5;
375    }choice;
376 }ActionDefinition;
377
378 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.1.1.1 : maxofRICActionID */
379 typedef struct
380 {
381    uint8_t           id;
382    ActionType        type;
383    ActionDefinition  definition;
384    ConfigType        action;
385 }ActionInfo;
386
387 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.1.1.1 : maxofRICActionID */
388 typedef struct
389 {
390    RicRequestId           requestId;
391    EventTriggerDefinition eventTriggerDefinition;
392    uint8_t                numOfActions;
393    ActionInfo             actionSequence[MAX_RIC_ACTION];  
394 }RicSubscription;
395
396 typedef struct rejectedAction
397 {
398    uint8_t id;
399    E2FailureCause failureCause;
400 }RejectedAction;
401
402 typedef struct pendingSubsRspInfo
403 {
404    RicRequestId    requestId;
405    uint16_t        ranFuncId;
406    uint8_t         numOfAcceptedActions;
407    uint8_t         acceptedActionList[MAX_RIC_ACTION];
408    uint8_t         numOfRejectedActions;
409    RejectedAction  rejectedActionList[MAX_RIC_ACTION];
410 }PendingSubsRspInfo;
411
412 typedef struct
413 {
414    /* O-RAN.WG3.E2SM-KPM-R003-v03.00 : Section 8.2.2.1 */
415    uint16_t         id;
416    RanFunctionName  name;
417    uint16_t         revisionCounter;
418    uint8_t          numOfEventTriggerStyleSupported;
419    RicStyle         eventTriggerStyleList[MAX_RIC_STYLES];
420    uint8_t          numOfReportStyleSupported;
421    RicReportStyle   reportStyleList[MAX_RIC_STYLES];
422    uint8_t          ricIndicationHeaderFormat;
423    uint8_t          ricIndicationMessageFormat;
424    /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.1.1.1 */
425    CmLListCp        subscriptionList;
426    uint8_t          numPendingSubsRsp;
427    PendingSubsRspInfo pendingSubsRspInfo[MAX_PENDING_SUBSCRIPTION_RSP];
428 }RanFunction;
429
430 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.26-9.2.27 */
431 typedef struct
432 {
433    InterfaceType        interfaceType;
434    uint64_t             componentId; 
435    ComponentActionType  componentActionType;
436    uint8_t              reqBufSize;
437    uint8_t              *componentRequestPart;
438    uint8_t              rspBufSize;
439    uint8_t              *componentResponsePart;
440 }E2NodeComponent;
441
442 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.29 */
443
444 typedef struct e2Ipaddr
445 {
446    bool     ipV4Pres;
447    uint32_t ipV4Addr;
448 }E2IpAddr;
449
450 typedef struct
451 {
452    E2IpAddr    localIpAddress;
453    uint16_t    localPort;
454    E2IpAddr    destIpAddress;
455    uint16_t    destPort;
456    AssocUsage  usage;
457 }TNLAssociation;
458
459 typedef struct e2TimersInfo
460 {
461    E2Timer  e2Timers;
462    uint8_t  e2SetupTimerInterval;
463 }E2TimersInfo;
464
465 typedef struct
466 {
467    uint64_t         e2NodeId; 
468    GlobalRicId      ricId;
469    E2Transaction    e2TransInfo;
470    uint16_t         numOfRanFunction;
471    RanFunction      ranFunction[MAX_RAN_FUNCTION];  
472    CmLListCp        e2NodeComponentList; 
473    uint8_t          numOfTNLAssoc;
474    TNLAssociation   tnlAssoc[MAX_TNL_ASSOCIATION];
475    E2TimersInfo     e2TimersInfo;
476 }E2apDb;
477
478 uint8_t assignTransactionId();
479 ActionInfo *fetchActionInfoFromActionId(uint8_t actionId, RicSubscription *ricSubscriptionInfo);
480 RicSubscription *fetchSubsInfoFromRicReqId(RicRequestId ricReqId, RanFunction *ranFuncDb, CmLList **ricSubscriptionNode);
481 RanFunction *fetchRanFuncFromRanFuncId(uint16_t ranFuncId);
482 uint8_t fetchSubsInfoFromSubsId(uint64_t subscriptionId, RanFunction **ranFuncDb, CmLList **ricSubscriptionNode, \
483    RicSubscription **ricSubscriptionInfo);
484
485 uint8_t fillRicSubsInMacStatsReq(MacStatsReq *macStatsReq, uint16_t ranFuncId, RicSubscription* ricSubscriptionInfo);
486 void e2ProcStatsRsp(MacStatsRsp *statsRsp);
487 void e2ProcStatsInd(MacStatsInd *statsInd);
488
489 uint8_t ResetE2Request(E2ProcedureDirection dir, E2FailureCause resetCause);
490 uint8_t SendE2APMsg(Region region, Pool pool, char *encBuf, int encBufSize);
491 E2NodeComponent *fetchE2NodeComponentInfo(InterfaceType interfaceType, uint8_t componentActionType, CmLList **e2ComponentNode);
492 uint8_t addOrModifyE2NodeComponent(InterfaceType interfaceType, uint8_t action, bool reqPart, uint8_t bufSize, char *bufString);
493
494 /**********************************************************************
495   End of file
496  **********************************************************************/