JIRA ID - ODUHIGH-241 Implementation of RRC DELIVERY REPORT
[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_BUF(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_BUF(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_BUF(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_BUF(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_BUF(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_BUF(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_BUF(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_BUF(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_BUF(mBuf);
250    }
251
252    return RFAILED;
253 }
254
255 /*******************************************************************
256  *
257  * @brief Pack and post DL RRC Message from DU APP to RLC 
258  *
259  * @details
260  *
261  *    Function : packDlRrcMsgToRlc
262  *
263  *    Functionality: Pack and post DL RRC Message from DU APP to RLC
264  *
265  * @params[in] Post structure
266  *             DL RRC Message info
267  * @return ROK     - success
268  *         RFAILED - failure
269  *
270  * ****************************************************************/
271 uint8_t packDlRrcMsgToRlc(Pst *pst, RlcDlRrcMsgInfo *dlRrcMsgInfo)
272 {
273    Buffer *mBuf = NULLP;
274
275    if(pst->selector == ODU_SELECTOR_LWLC)
276    {
277       if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
278       {
279          DU_LOG("\nRLC : Memory allocation failed at packRlcUlRrcMsgToDu");
280          return RFAILED;
281       }
282       /* pack the address of the structure */
283       CMCHKPK(oduPackPointer,(PTR)dlRrcMsgInfo, mBuf);
284       return ODU_POST_TASK(pst,mBuf);
285    }
286    else
287    {
288       DU_LOG("\nRLC: Only LWLC supported for packDlRrcMsgToRlc");
289    }
290    return RFAILED;
291 }
292
293 /*******************************************************************
294  *
295  * @brief Unpacks DL RRC Message info received at RLC from DU APP
296  *
297  * @details
298  *
299  *    Function : unpackDlRrcMsgToRlc
300  *
301  *    Functionality:
302  *      Unpacks the DL RRC Message info received at RLC from DU APP
303  *
304  * @params[in] Pointer to handler function
305  *             Post structure
306  *             Messae buffer to be unpacked
307  * @return ROK     - success
308  *         RFAILED - failure
309  *
310  * ****************************************************************/
311 uint8_t unpackDlRrcMsgToRlc(DuDlRrcMsgToRlcFunc func, Pst *pst, Buffer *mBuf)
312 {
313    if(pst->selector == ODU_SELECTOR_LWLC)
314    {
315       RlcDlRrcMsgInfo *dlRrcMsgInfo;
316       /* unpack the address of the structure */
317       CMCHKUNPK(oduUnpackPointer, (PTR *)&dlRrcMsgInfo, mBuf);
318       ODU_PUT_MSG_BUF(mBuf);
319       return (*func)(pst, dlRrcMsgInfo);
320    }
321    else
322    {
323       /* Nothing to do for other selectors */
324       DU_LOG("\nRLC: Only LWLC supported for UL RRC Message transfer ");
325       ODU_PUT_MSG_BUF(mBuf);
326    }
327    return RFAILED;
328 }
329
330 /*******************************************************************
331 *
332 * @brief packs RRC delivery report sending from  RLC to DU APP
333 *
334 * @details
335 *
336 *    Function : packRrcDeliveryReportToDu
337 *
338 *    Functionality:
339 *      Unpacks the DL RRC Message info received at RLC from DU APP
340 *
341 * @params[in] Pointer to handler function
342 *             Post structure
343 *             Messae buffer to be unpacked
344 * @return ROK     - success
345 *         RFAILED - failure
346 *
347 * ****************************************************************/
348 uint8_t packRrcDeliveryReportToDu(Pst *pst, RrcDeliveryReport *rrcDeliveryReport)
349 {
350     Buffer *mBuf = NULLP;
351
352     if(pst->selector == ODU_SELECTOR_LWLC)
353     {
354        if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
355        {
356           DU_LOG("\nRLC : Memory allocation failed at packRrcDeliveryReportToDu");
357           return RFAILED;
358        }
359        /* pack the address of the structure */
360        CMCHKPK(oduPackPointer,(PTR)rrcDeliveryReport, mBuf);
361        return ODU_POST_TASK(pst,mBuf);
362     }
363     else
364     {
365        DU_LOG("\nRLC: Only LWLC supported for packRrcDeliveryReportToDu");
366     }
367     return RFAILED;
368  }
369
370 /*******************************************************************
371 *
372 * @brief Unpacks RRC Delivery Report info received at DU APP from RIC
373 *
374 * @details
375 *
376 *    Function : unpackRrcDeliveryReportToDu
377 *
378 *    Functionality:
379 *      Unpacks RRC Delivery Report info received at DU APP from RIC
380 *
381 * @params[in] Pointer to handler function
382 *             Post structure
383 *             Messae buffer to be unpacked
384 * @return ROK     - success
385 *         RFAILED - failure
386 *
387 * ****************************************************************/
388 uint8_t unpackRrcDeliveryReportToDu(RlcRrcDeliveryReportToDuFunc func, Pst *pst, Buffer *mBuf)
389 {
390     if(pst->selector == ODU_SELECTOR_LWLC)
391     {
392        RrcDeliveryReport *rrcDeliveryReport;
393        /* unpack the address of the structure */
394        CMCHKUNPK(oduUnpackPointer, (PTR *)&rrcDeliveryReport, mBuf);
395        ODU_PUT_MSG_BUF(mBuf);
396        return (*func)(pst, rrcDeliveryReport);
397     }
398     else
399     {
400        /* Nothing to do for other selectors */
401        DU_LOG("\nRLC: Only LWLC supported for RRC delivery Message transfer ");
402        ODU_PUT_MSG_BUF(mBuf);
403     }
404
405     return RFAILED;
406 }
407
408 /**********************************************************************
409          End of file
410 ***********************************************************************/