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