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