RLC UeCb Changes
[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_log.h"
21 #include "du_app_rlc_inf.h"
22
23 /*******************************************************************
24  *
25  * @brief Packs and Sends UE create Request from DUAPP to RLC
26  *
27  * @details
28  *
29  *    Function : packDuRlcUlUeCreateReq
30  *
31  *    Functionality:
32  *       Packs and Sends UE Create Request from DUAPP to RLC
33  *
34  *
35  * @params[in] Post structure pointer
36  *             RlcUeCfg pointer              
37  * @return ROK     - success
38  *         RFAILED - failure
39  *
40  * ****************************************************************/
41 uint8_t packDuRlcUlUeCreateReq(Pst *pst, RlcUeCfg *ueCfg)
42 {
43    Buffer *mBuf = NULLP;
44  
45    if(pst->selector == ODU_SELECTOR_LWLC)
46    {
47       if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
48       {
49          DU_LOG("\nRLC : Memory allocation failed at packDuRlcUeCreateReq");
50          return RFAILED;
51       }
52       /* pack the address of the structure */
53       CMCHKPK(cmPkPtr,(PTR)ueCfg, mBuf);
54    }
55    else
56    {
57       DU_LOG("\nRLC: Only LWLC supported for packDuRlcUeCreateReq");
58       return RFAILED;
59    }
60
61     return SPstTsk(pst,mBuf);
62 }
63
64 /*******************************************************************
65  *
66  * @brief Unpacks UE Create Request received from DU APP
67  *
68  * @details
69  *
70  *    Function : unpackRlcUlUeCreateReq
71  *
72  *    Functionality:
73  *         Unpacks UE Create Request received from DU APP
74  *
75  * @params[in] Pointer to Handler
76  *             Post structure pointer
77  *             Message Buffer
78  * @return ROK     - success
79  *         RFAILED - failure
80  *
81  * ****************************************************************/
82 uint8_t unpackRlcUlUeCreateReq(DuRlcUlUeCreateReq func, Pst *pst, Buffer *mBuf)
83 {
84    if(pst->selector == ODU_SELECTOR_LWLC)
85    {
86       RlcUeCfg *ueCfg;
87       /* unpack the address of the structure */
88       CMCHKUNPK(cmUnpkPtr, (PTR *)&ueCfg, mBuf);
89       SPutMsg(mBuf);
90       return (*func)(pst, ueCfg);
91    }
92    else
93    {
94       /* Nothing to do for other selectors */
95       DU_LOG("\nRLC: Only LWLC supported for UE Create Request ");
96       SPutMsg(mBuf);
97    }
98
99    return RFAILED;
100 }
101
102 /*******************************************************************
103  *
104  * @brief Packs and Sends UE create Response from RLC to DUAPP
105  *
106  * @details
107  *
108  *    Function : packRlcUlDuUeCreateRsp
109  *
110  *    Functionality:
111  *       Packs and Sends UE Create Rrsponse from RLC to DUAPP
112  *
113  *
114  * @params[in] Post structure pointer
115  *             RlcUeCfg pointer              
116  * @return ROK     - success
117  *         RFAILED - failure
118  *
119  * ****************************************************************/
120 uint8_t packRlcUlDuUeCreateRsp(Pst *pst, RlcUeCfgRsp *ueCfg)
121 {
122    Buffer *mBuf = NULLP;
123  
124    if(pst->selector == ODU_SELECTOR_LWLC)
125    {
126       if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
127       {
128          DU_LOG("\nRLC : Memory allocation failed at packRlcUlDuUeCreateRsp");
129          return RFAILED;
130       }
131       /* pack the address of the structure */
132       CMCHKPK(cmPkPtr,(PTR)ueCfg, mBuf);
133    }
134    else
135    {
136       DU_LOG("\nRLC: Only LWLC supported for packRlcUlDuUeCreateRsp");
137       return RFAILED;
138    }
139
140     return SPstTsk(pst,mBuf);
141 }
142
143 /*******************************************************************
144  *
145  * @brief Unpacks UE Create Response received from DU APP
146  *
147  * @details
148  *
149  *    Function : unpackRlcUlUeCreateRsp
150  *
151  *    Functionality:
152  *         Unpacks UE Create Response received from DU APP
153  *
154  * @params[in] Pointer to Handler
155  *             Post structure pointer
156  *             Message Buffer
157  * @return ROK     - success
158  *         RFAILED - failure
159  *
160  * ****************************************************************/
161 uint8_t unpackRlcUlUeCreateRsp(RlcUlDuUeCreateRsp func, Pst *pst, Buffer *mBuf)
162 {
163    if(pst->selector == ODU_SELECTOR_LWLC)
164    {
165       RlcUeCfgRsp *cfgRsp;
166       /* unpack the address of the structure */
167       CMCHKUNPK(cmUnpkPtr, (PTR *)&cfgRsp, mBuf);
168       SPutMsg(mBuf);
169       return (*func)(pst, cfgRsp);
170    }
171    else
172    {
173       /* Nothing to do for other selectors */
174       DU_LOG("\nRLC: Only LWLC supported for UE Create Response ");
175       SPutMsg(mBuf);
176    }
177
178    return RFAILED;
179 }
180 /**********************************************************************
181          End of file
182 **********************************************************************/