Replaced old SSI function with new macros jira id - ODUHIGH-212
[o-du/l2.git] / src / cm / du_app_rlc_inf.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 #include "common_def.h"
20 #include "du_app_rlc_inf.h"
21
22 /*******************************************************************
23  *
24  * @brief Packs and Sends UE create Request from DUAPP to RLC
25  *
26  * @details
27  *
28  *    Function : packDuRlcUlUeCreateReq
29  *
30  *    Functionality:
31  *       Packs and Sends UE Create Request from DUAPP to RLC
32  *
33  *
34  * @params[in] Post structure pointer
35  *             RlcUeCfg pointer              
36  * @return ROK     - success
37  *         RFAILED - failure
38  *
39  * ****************************************************************/
40 uint8_t packDuRlcUlUeCreateReq(Pst *pst, RlcUeCfg *ueCfg)
41 {
42    Buffer *mBuf = NULLP;
43  
44    if(pst->selector == ODU_SELECTOR_LWLC)
45    {
46       if (ODU_GET_MSG(pst->region, pst->pool, &mBuf) != ROK)
47       {
48          DU_LOG("\nRLC : Memory allocation failed at packDuRlcUeCreateReq");
49          return RFAILED;
50       }
51       /* pack the address of the structure */
52       CMCHKPK(oduPackPointer,(PTR)ueCfg, mBuf);
53    }
54    else
55    {
56       DU_LOG("\nRLC: Only LWLC supported for packDuRlcUeCreateReq");
57       return RFAILED;
58    }
59
60     return ODU_POST_TASK(pst,mBuf);
61 }
62
63 /*******************************************************************
64  *
65  * @brief Unpacks UE Create Request received from DU APP
66  *
67  * @details
68  *
69  *    Function : unpackRlcUlUeCreateReq
70  *
71  *    Functionality:
72  *         Unpacks UE Create Request received from DU APP
73  *
74  * @params[in] Pointer to Handler
75  *             Post structure pointer
76  *             Message Buffer
77  * @return ROK     - success
78  *         RFAILED - failure
79  *
80  * ****************************************************************/
81 uint8_t unpackRlcUlUeCreateReq(DuRlcUlUeCreateReq func, Pst *pst, Buffer *mBuf)
82 {
83    if(pst->selector == ODU_SELECTOR_LWLC)
84    {
85       RlcUeCfg *ueCfg;
86       /* unpack the address of the structure */
87       CMCHKUNPK(oduUnpackPointer, (PTR *)&ueCfg, mBuf);
88       ODU_PUT_MSG(mBuf);
89       return (*func)(pst, ueCfg);
90    }
91    else
92    {
93       /* Nothing to do for other selectors */
94       DU_LOG("\nRLC: Only LWLC supported for UE Create Request ");
95       ODU_PUT_MSG(mBuf);
96    }
97
98    return RFAILED;
99 }
100
101 /*******************************************************************
102  *
103  * @brief Packs and Sends UE create Response from RLC to DUAPP
104  *
105  * @details
106  *
107  *    Function : packRlcUlDuUeCreateRsp
108  *
109  *    Functionality:
110  *       Packs and Sends UE Create Rrsponse from RLC to DUAPP
111  *
112  *
113  * @params[in] Post structure pointer
114  *             RlcUeCfg pointer              
115  * @return ROK     - success
116  *         RFAILED - failure
117  *
118  * ****************************************************************/
119 uint8_t packRlcUlDuUeCreateRsp(Pst *pst, RlcUeCfgRsp *ueCfg)
120 {
121    Buffer *mBuf = NULLP;
122  
123    if(pst->selector == ODU_SELECTOR_LWLC)
124    {
125       if (ODU_GET_MSG(pst->region, pst->pool, &mBuf) != ROK)
126       {
127          DU_LOG("\nRLC : Memory allocation failed at packRlcUlDuUeCreateRsp");
128          return RFAILED;
129       }
130       /* pack the address of the structure */
131       CMCHKPK(oduPackPointer,(PTR)ueCfg, mBuf);
132    }
133    else
134    {
135       DU_LOG("\nRLC: Only LWLC supported for packRlcUlDuUeCreateRsp");
136       return RFAILED;
137    }
138
139     return ODU_POST_TASK(pst,mBuf);
140 }
141
142 /*******************************************************************
143  *
144  * @brief Unpacks UE Create Response received from DU APP
145  *
146  * @details
147  *
148  *    Function : unpackRlcUlUeCreateRsp
149  *
150  *    Functionality:
151  *         Unpacks UE Create Response received from DU APP
152  *
153  * @params[in] Pointer to Handler
154  *             Post structure pointer
155  *             Message Buffer
156  * @return ROK     - success
157  *         RFAILED - failure
158  *
159  * ****************************************************************/
160 uint8_t unpackRlcUlUeCreateRsp(RlcUlDuUeCreateRsp func, Pst *pst, Buffer *mBuf)
161 {
162    if(pst->selector == ODU_SELECTOR_LWLC)
163    {
164       RlcUeCfgRsp *cfgRsp;
165       /* unpack the address of the structure */
166       CMCHKUNPK(oduUnpackPointer, (PTR *)&cfgRsp, mBuf);
167       ODU_PUT_MSG(mBuf);
168       return (*func)(pst, cfgRsp);
169    }
170    else
171    {
172       /* Nothing to do for other selectors */
173       DU_LOG("\nRLC: Only LWLC supported for UE Create Response ");
174       ODU_PUT_MSG(mBuf);
175    }
176
177    return RFAILED;
178 }
179
180 /*******************************************************************
181  *
182  * @brief Pack and send UL RRC message transfer from RLC to DU APP
183  *
184  * @details
185  *
186  *    Function : packRlcUlRrcMsgToDu
187  *
188  *    Functionality:
189  *       Pack and send UL RRC message transfer from RLC to DU APP
190  *
191  * @params[in] Post structure
192  *             UL RRC Msg transfer info
193  * @return ROK     - success
194  *         RFAILED - failure
195  *
196  * ****************************************************************/
197 uint8_t packRlcUlRrcMsgToDu(Pst *pst, RlcUlRrcMsgInfo *ulRrcMsgInfo)
198 {
199    Buffer *mBuf = NULLP;
200
201    if(pst->selector == ODU_SELECTOR_LWLC)
202    {
203       if (ODU_GET_MSG(pst->region, pst->pool, &mBuf) != ROK)
204       {
205          DU_LOG("\nRLC : Memory allocation failed at packRlcUlRrcMsgToDu");
206          return RFAILED;
207       }
208       /* pack the address of the structure */
209       CMCHKPK(oduPackPointer,(PTR)ulRrcMsgInfo, mBuf);
210       return ODU_POST_TASK(pst,mBuf);
211    }
212    else
213    {
214       DU_LOG("\nRLC: Only LWLC supported for packRlcUlRrcMsgToDu");
215    }
216    return RFAILED;
217 }
218
219 /*******************************************************************
220  *
221  * @brief Unpack UL RRC Msg Transfer received at DU APP from RLC
222  *
223  * @details
224  *
225  *    Function : unpackRlcUlRrcMsgToDu
226  *
227  *    Functionality:
228  *      Unpack UL RRC Msg Transfer received at DU APP from RLC
229  *
230  * @params[in]
231  * @return ROK     - success
232  *         RFAILED - failure
233  *
234  * ****************************************************************/
235 uint8_t unpackRlcUlRrcMsgToDu(RlcUlRrcMsgToDuFunc func, Pst *pst, Buffer *mBuf)
236 {
237    if(pst->selector == ODU_SELECTOR_LWLC)
238    {
239       RlcUlRrcMsgInfo *ulRrcMsgInfo;
240       /* unpack the address of the structure */
241       CMCHKUNPK(oduUnpackPointer, (PTR *)&ulRrcMsgInfo, mBuf);
242       ODU_PUT_MSG(mBuf);
243       return (*func)(pst, ulRrcMsgInfo);
244    }
245    else
246    {
247       /* Nothing to do for other selectors */
248       DU_LOG("\nRLC: Only LWLC supported for UL RRC Message transfer ");
249       ODU_PUT_MSG(mBuf);
250    }
251
252    return RFAILED;
253 }
254
255
256 /**********************************************************************
257          End of file
258 ***********************************************************************/