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