098223dad4be3f24284250b77bebc03a68a6fed4
[o-du/l2.git] / src / du_app / du_e2_conversions.c
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 functions that maps values received in F1AP message with
20  * its corresponding values used in DU and vice-versa */
21
22 #include "common_def.h"
23 #include "TimeToWaitE2.h"
24 #include "du_app_mac_inf.h"
25 #include "du_e2ap_mgr.h"
26 #include "E2nodeComponentInterfaceType.h"
27
28 /************************************************************************
29  *
30  * @brief Converts enum values into actual value of E2 wait timer
31  *
32  * @details
33  *
34  *    Function : convertE2WaitTimerEnumToValue
35  *
36  *    Functionality: Converts enum values into actual value of E2 wait timer 
37  *
38  * @params[in] Enum value of e2 wait timer 
39  * @return Actual value of e2 wait timer
40  *
41  * **********************************************************************/
42
43 uint8_t convertE2WaitTimerEnumToValue(uint8_t timerToWait)
44 {
45    switch(timerToWait)
46    {
47       case TimeToWaitE2_v1s:
48          return 1;
49          
50       case TimeToWaitE2_v2s:
51          return 2;
52          
53       case TimeToWaitE2_v5s:
54          return 5;
55          
56       case TimeToWaitE2_v10s:
57          return 10;
58          
59       case TimeToWaitE2_v20s:
60          return 20;
61          
62       case TimeToWaitE2_v60s:
63          return 60;
64          
65       default:
66          DU_LOG("\nERROR  -->  F1AP: Invalid value of E2 Wait timer");
67    }
68    return RFAILED;
69 }
70
71 /*******************************************************************
72  *
73  * @brief Converts DU specific failure cause to E2 interface
74  *        failure cause
75  *
76  * @details
77  *
78  *    Function : convertDuCauseToE2Cause
79  *
80  *    Functionality: Converts DU specific failure cause to E2 
81  *       interface failure cause
82  *
83  * @params[in] DU specific failure cause
84  *             E2 specific failure cause
85  *
86  * @return void
87  *
88  * ****************************************************************/
89 void convertDuCauseToE2Cause(CauseOfResult l2Cause, E2FailureCause *failureCause)
90 {
91    switch(l2Cause)
92    {
93       case PARAM_INVALID:
94          {
95             failureCause->causeType = E2_RIC_REQUEST;
96             failureCause->cause = E2_ACTION_NOT_SUPPORTED;
97             break;
98          }
99       case RESOURCE_UNAVAILABLE:
100          {
101             failureCause->causeType = E2_RIC_REQUEST;
102             failureCause->cause = E2_FUNCTION_RESOURCE_LIMIT;
103             break;
104          }
105       default:
106          {
107             failureCause->causeType = E2_RIC_REQUEST;
108             failureCause->cause = E2_RIC_REQUEST_CAUSE_UNSPECIFIED;
109             break;
110          }
111    }
112 }
113
114 /************************************************************************
115  *
116  * @brief Converts InterfaceType into E2nodeComponentInterfaceType value 
117  *
118  * @details
119  *
120  *    Function : convertInterfaceToE2ComponentInterfaceType
121  *
122  *    Functionality: Convert InterfaceType into E2nodeComponentInterfaceType
123  *    value
124  *
125  * @params[in] Actual value of interface
126  * @return Enum value of e2 interface
127  *
128  * **********************************************************************/
129
130 uint8_t convertInterfaceToE2ComponentInterfaceType(uint8_t interface)
131 {
132    switch(interface)
133    {
134       case NG:
135          return E2nodeComponentInterfaceType_ng;
136
137       case XN:
138          return E2nodeComponentInterfaceType_xn;
139
140       case E1:
141          return E2nodeComponentInterfaceType_e1;
142
143       case F1:
144          return E2nodeComponentInterfaceType_f1;
145
146       case W1:
147          return E2nodeComponentInterfaceType_w1;
148
149       case S1:
150          return E2nodeComponentInterfaceType_s1;
151
152       case X2:
153          return E2nodeComponentInterfaceType_x2;
154    }
155    return RFAILED;
156 }
157
158 /*******************************************************************
159  *
160  * @brief Converts MAC-specific Measurement type to E2 interface
161  *        specific measurement type
162  *
163  * @details
164  *
165  *    Function : convertMacMeasTypeToE2MeasType
166  *
167  *    Functionality: Converts MAC-specific Measurement type to E2 
168  *       interface specific measurement type
169  *
170  * @params[in] MAC specific measurement type
171  *             E2 interface specific measurement type
172  *
173  * @return uint8_t
174  *
175  * ****************************************************************/
176 uint8_t convertMacMeasTypeToE2MeasType(MacMeasurementType macMeasName, char *e2MeasName)
177 {
178    uint8_t measNameLen = 0;
179
180    switch(macMeasName)
181    {
182       case MAC_DL_TOTAL_PRB_USAGE:
183          {
184             measNameLen = strlen("RRU.PrbTotDl");
185             memcpy(e2MeasName, "RRU.PrbTotDl", measNameLen+1);
186             break;
187          }
188       case MAC_UL_TOTAL_PRB_USAGE:
189          {
190             measNameLen = strlen("RRU.PrbTotUl");
191             memcpy(e2MeasName, "RRU.PrbTotUl", measNameLen+1);
192             break;
193          }
194       default:
195          {
196              DU_LOG("\nERROR  -->  E2AP : MAC mesurement type [%d] not supported", macMeasName);
197              return RFAILED;
198          }
199    }
200    return ROK;
201 }
202
203 /**********************************************************************
204   End of file
205  **********************************************************************/