a2663def67c0a444bb733dae0908a5bac52bbafa
[o-du/l2.git] / src / ric_stub / ric_stub.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 #ifndef __RIC_MGR_MAIN_H__
20 #define __RIC_MGR_MAIN_H__
21
22 #define RIC_ID 1
23 #define RIC_NAME "ORAN_OAM_RIC"
24
25 #define DU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0001"
26 #define RIC_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0011"
27
28 #ifndef O1_ENABLE
29 #define LOCAL_IP_RIC "192.168.130.80"
30
31 #define E2_SCTP_PORT 36421
32 #define NUM_E2_ASSOC 1 
33 #define REMOTE_IP_DU (char*[]){"192.168.130.81", "192.168.130.83"}
34 #endif
35
36 #define RRC_VER 0
37 #define EXT_RRC_VER 5
38 #define PLMN_MCC0 3
39 #define PLMN_MCC1 1
40 #define PLMN_MCC2 1
41 #define PLMN_MNC0 4
42 #define PLMN_MNC1 8
43 #define PLMN_MNC2 0
44
45 #define RIC_DU_NAME_LEN_MAX 30      /* Max length of RIC/DU name string */
46
47 #define RIC_APP_MEM_REG 1
48 #define RIC_POOL 1
49 #define MAX_RAN_FUNCTION 256        /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.1.2.2 : maxofRANfunctionID */
50 #define MAX_NUM_TRANSACTION 256     /* As per, O-RAN WG3 E2AP v3.0, section 9.2.33 */
51 #define MAX_E2_NODE_COMPONENT 1024     /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.1.2.2 : maxofE2nodeComponents */
52 #define MAX_RIC_ACTION  16          /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.1.1.1 : maxofRICActionID */
53 #define MAX_RIC_REQUEST 5           /* As per O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.7, max request is 65535. \
54                                      * But for our internal testing purpose, keeping it to 5 for now */
55
56 /* allocate and zero out a static buffer */
57 #define RIC_ALLOC(_datPtr, _size)                                \
58 {                                                               \
59    S16 _ret;                                                    \
60    _ret = SGetSBuf(RIC_APP_MEM_REG, RIC_POOL,                  \
61                      (Data **)&_datPtr, _size);                  \
62    if(_ret == ROK)                                              \
63       memset(_datPtr, 0, _size);                         \
64    else                                                         \
65       _datPtr = NULLP;                                          \
66 }
67  
68 /* free a static buffer */
69 #define RIC_FREE(_datPtr, _size)                                 \
70    SPutSBuf(RIC_APP_MEM_REG, RIC_POOL,                         \
71          (Data *)_datPtr, _size);
72
73 #define SEARCH_DU_DB(_duIdx, _duId, _duDb){\
74    _duDb = NULLP; \
75    for(_duIdx=0; _duIdx < ricCb.numDu; _duIdx++)\
76    {\
77       if(ricCb.duInfo[_duIdx].duId == _duId)\
78       {\
79          _duDb =  (&ricCb.duInfo[_duIdx]);\
80          break; \
81      }\
82    }\
83 }
84
85 typedef enum
86 {
87    ADD_CONNECTION,
88    MODIFY_CONNECTION,
89    REMOVE_CONNECTION
90 }E2Connection;
91
92 /* O-RAN.WG3.E2AP-R003-v03.00 : Section 9.2.26 */
93 typedef enum
94 {
95    NG,
96    XN,
97    E1,
98    F1,
99    W1,
100    S1,
101    X2
102 }InterfaceType;
103
104 typedef struct
105 {
106    uint16_t requestorId;
107    uint16_t instanceId;
108 }RicRequestId;
109
110 typedef struct
111 {
112    int16_t         actionId;
113 }ActionInfo;
114
115 typedef struct ricSubscription
116 {
117    RicRequestId    requestId;
118    uint16_t        ranFuncId;
119    uint8_t         numOfActions;
120    ActionInfo      actionSequence[MAX_RIC_ACTION];
121 }RicSubscription;
122
123 typedef struct
124 {
125    uint16_t  id;
126    uint16_t  revisionCounter;
127    CmLListCp  subscriptionList;
128 }RanFunction;
129
130 typedef struct
131 {
132    InterfaceType   interfaceType;
133    uint64_t        componentId;
134 }E2NodeComponent;
135
136 typedef struct duDb
137 {
138    uint32_t        duId;
139    uint8_t         ricTransIdCounter;
140    uint16_t        numOfRanFunction;
141    RanFunction     ranFunction[MAX_RAN_FUNCTION];
142    CmLListCp       e2NodeComponent;
143 }DuDb;
144
145 typedef struct ricCfgParams
146 {
147    uint32_t        ricId;
148    char            ricName[RIC_DU_NAME_LEN_MAX];
149    RicSctpParams   sctpParams;
150    Plmn            plmn;
151 }RicCfgParams;
152
153 typedef struct cuGlobalCb
154 {
155    RicCfgParams ricCfgParams;
156    uint8_t      numDu;
157    DuDb         duInfo[MAX_DU_SUPPORTED];
158 }RicGlobalCb;
159
160 RicGlobalCb ricCb;
161
162 typedef struct
163 {
164    uint8_t numOfRanFunAccepted;
165    RanFunction ranFunAcceptedList[MAX_RAN_FUNCTION];
166    uint8_t numOfRanFuneRejected;
167    RanFunction ranFunRejectedList[MAX_RAN_FUNCTION];
168 }RicTmpRanFunList;
169
170 typedef struct actionFailed
171 {
172    uint8_t actionId;
173    uint8_t failureType;
174    uint8_t cause;
175 }ActionFailed;
176
177 typedef struct
178 {
179    uint8_t numActionModified;
180    uint8_t actionModifiedList[MAX_RIC_ACTION];
181    uint8_t numActionModFailed;
182    ActionFailed actionModFailedList[MAX_RIC_ACTION];
183    uint8_t numActionRemoved;
184    uint8_t actionRemovedList[MAX_RIC_ACTION];
185    uint8_t numActionRemovalFailed;
186    ActionFailed actionRemovalFailedList[MAX_RIC_ACTION];
187 }RicTmpActionList;
188
189 typedef struct e2NodeCfgItem
190 {
191    E2NodeComponent componentInfo;
192    bool           isSuccessful;
193 }E2NodeConfigItem;
194
195 typedef struct e2NodeCfgList
196 {
197    uint16_t addedE2NodeCount;
198    E2NodeConfigItem addedE2Node[MAX_E2_NODE_COMPONENT];
199    uint16_t updatedE2NodeCount;
200    E2NodeConfigItem updatedE2Node[MAX_E2_NODE_COMPONENT];
201    uint16_t removedE2NodeCount;
202    E2NodeConfigItem removedE2Node[MAX_E2_NODE_COMPONENT];
203 }E2NodeConfigList;
204
205 typedef struct ricSubsActionInfo
206 {
207    ConfigType  configType; 
208    uint16_t    actionId;
209 }RicSubsActionInfo;
210
211 typedef struct ricSubsModReq
212
213     uint16_t   numOfActionToBeAdded;
214     ActionInfo actionToBeAdded[MAX_RIC_ACTION]; 
215     uint16_t   numOfActionToBeModify;
216     ActionInfo actionToBeModify[MAX_RIC_ACTION]; 
217     uint16_t   numOfActionToBeRemove;
218     ActionInfo actionToBeRemove[MAX_RIC_ACTION]; 
219 }RicSubsModReq;
220
221 void readRicCfg();
222 void cuAppInmsgHdlr(Buffer *mBuf);
223 void sctpNtfyInd(CmInetSctpNotification *ntfy);
224
225 #endif
226
227 /**********************************************************************
228          End of file
229 **********************************************************************/