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