[Epic-ID: ODUHIGH-464][Task-ID: ODUHIGH-480] WG8 Alignment | Third Phase | RLC-MAC...
[o-du/l2.git] / src / cm / rlc_mac_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 /* This file define APIs at RLC-MAC interface */
19 #include "common_def.h"
20 #include "rlc_mac_inf.h"
21
22 /**
23  * @brief Primitive invoked from RLC to MAC to 
24  * inform the BO report for dedicated channels
25  *
26  * @details
27  *
28  *     Function : packBOStatus,
29  *
30  *  @param[in]   Pst*  pst
31  *  @param[in]   RlcMacBOStatus  *  staRsp
32  *  @return   S16
33  *      -# ROK
34  **/
35 uint8_t packRlcBoStatus(Pst* pst, RlcBoStatus  *boStatus)
36 {
37    Buffer *mBuf = NULLP;
38  
39    if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) 
40    {
41       DU_LOG("\nERROR  -->  RLC: Memory allocation failed at packBOStatus");
42       return RFAILED;
43    }
44
45    if (pst->selector == ODU_SELECTOR_LWLC)
46    {
47       /* light weight loose coupling */
48       CMCHKPK(oduPackPointer,(PTR) boStatus, mBuf);
49    }
50    else
51    {
52       /* light coupling */
53       return RFAILED;
54    }
55  
56    return ODU_POST_TASK(pst,mBuf);
57 }
58
59 /**
60  * @brief Primitive invoked from RLC to MAC to 
61  * inform the BO report for dedicated channels
62  *
63  * @details
64  *
65  *     Function : unpackBOStatus
66  *
67  *  @param[in]   Pst*  pst
68  *  @param[in]   RlcMacBOStatus *  staRsp
69  *  @return   S16
70  *      -# ROK
71  **/
72 uint8_t unpackRlcBoStatus(RlcMacBoStatusFunc func, Pst *pst, Buffer *mBuf)
73 {
74    RlcBoStatus *boSta;
75  
76    if (pst->selector == ODU_SELECTOR_LWLC)
77    {
78        /* Light weight loose coupling */
79        CMCHKUNPK(oduUnpackPointer,(PTR *) &boSta, mBuf);
80    }
81    else
82    {
83       /* Light Coupling */
84       return RFAILED;
85    }
86    ODU_PUT_MSG_BUF(mBuf);
87    return (*func)(pst, boSta);
88 }
89
90 /**
91  * @brief Status Indication from MAC to RLC  
92  * as a response to the staRsp primitive from RLC.
93  * Informs RLC of the totalBufferSize and Timing Info 
94  * for the transmission on dedicated channels.
95  *
96  * @details
97  *
98  *     Function : packSchedRep
99  *
100  *  @param[in]   Pst*  pst
101  *  @param[in]   SuId  suId
102  *  @param[in]   RlcMacSchedRep*  schRep
103  *  @return   S16
104  *      -# ROK
105  **/
106 uint8_t packRlcSchedResultRpt(Pst* pst, RlcSchedResultRpt *schRep)
107 {
108    Buffer *mBuf = NULLP;
109  
110    if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) 
111    {
112       DU_LOG("\nERROR  -->  MAC : Memory allocation failed at packSchResultRep");
113       return RFAILED;
114    }
115    if (pst->selector == ODU_SELECTOR_LWLC)
116    {
117       CMCHKPK(oduPackPointer,(PTR) schRep, mBuf);
118    }
119    else
120    {
121       return RFAILED;
122    }
123  
124    return ODU_POST_TASK(pst,mBuf);
125 }
126
127 /**
128  * @brief Status Indication from MAC to RLC  
129  * as a response to the staRsp primitive from RLC.
130  * Informs RLC of the totalBufferSize and Timing Info 
131  * for the transmission on dedicated channels.
132  *
133  * @details
134  *
135  *     Function : unpackSchResultRpt
136  *
137  *  @param[in]   Pst*  pst
138  *  @param[in]   SuId  suId
139  *  @param[in]   RguDStaIndInfo  *  staInd
140  *  @return   S16
141  *      -# ROK
142  **/
143 uint8_t unpackSchedResultRpt(RlcMacSchedResultRptFunc func, Pst *pst, Buffer *mBuf)
144 {
145    RlcSchedResultRpt *schRep;
146  
147    if (pst->selector == ODU_SELECTOR_LWLC)
148    {
149       CMCHKUNPK(oduUnpackPointer,(PTR *) &schRep, mBuf);
150    }
151    else
152    {
153       return RFAILED;
154    }
155    ODU_PUT_MSG_BUF(mBuf);
156    return (*func)(pst, schRep);
157 }
158
159 /*******************************************************************
160  *
161  * @brief Pack and send DL Data from RLC to MAC
162  *
163  * @details
164  *
165  *    Function : packRlcDlData
166  *
167  *    Functionality: Pack and send DL Data from RLC to MAC
168  *
169  * @params[in] 
170  * @return ROK     - success
171  *         RFAILED - failure
172  *
173  * ****************************************************************/
174 uint8_t packRlcDlData(Pst* pst, RlcDlData *dlData)
175 {
176    Buffer *mBuf = NULLP;
177
178    if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) 
179    {
180       DU_LOG("\nERROR  -->  RLC : Memory allocation failed at packRlcDlData");
181       return RFAILED;
182    }
183  
184    if (pst->selector == ODU_SELECTOR_LWLC)
185    {
186        CMCHKPK(oduPackPointer,(PTR) dlData, mBuf);
187    }
188    else
189    {
190       return RFAILED;
191    }
192    return ODU_POST_TASK(pst,mBuf);
193
194 }
195
196 /*******************************************************************
197  *
198  * @brief unpack RLC DL data
199  *
200  * @details
201  *
202  *    Function : unpackRlcDlData
203  *
204  *    Functionality: unpack RLC DL data
205  *
206  * @params[in] 
207  * @return ROK     - success
208  *         RFAILED - failure
209  *
210  * ****************************************************************/
211 uint8_t unpackRlcDlData(RlcMacDlDataFunc func, Pst *pst, Buffer *mBuf)
212 {
213    RlcDlData *dlData;
214
215    if (pst->selector == ODU_SELECTOR_LWLC)
216    {
217       CMCHKUNPK(oduUnpackPointer, (PTR *) &dlData, mBuf);
218    }
219    else
220    {
221       return RFAILED;
222    }
223    ODU_PUT_MSG_BUF(mBuf);
224    return((*func)(pst, dlData));
225 }
226
227 /*******************************************************************
228  *
229  * @brief Pack and send UL data from MAC to RLC
230  *
231  * @details
232  *
233  *    Function : packRlcUlData
234  *
235  *    Functionality: Pack and send UL data from MAC to RLC
236  *
237  * @params[in] 
238  * @return ROK     - success
239  *         RFAILED - failure
240  *
241  * ****************************************************************/
242 uint8_t packRlcUlData(Pst* pst, RlcUlData *ulData)
243 {
244    Buffer *mBuf = NULLP;
245  
246    if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK) 
247    {
248       DU_LOG("\nERROR  -->  MAC : Memory allocation failed at packRlcUlData");
249       return RFAILED;
250    }
251
252    if (pst->selector == ODU_SELECTOR_LWLC)
253    {
254       CMCHKPK(oduPackPointer,(PTR)ulData, mBuf);
255    }
256    else
257    {
258       return RFAILED;
259    }
260  
261    pst->event = (Event)EVENT_UL_DATA_TO_RLC;
262    return ODU_POST_TASK(pst,mBuf);
263 }
264
265 /*******************************************************************
266  *
267  * @brief Unpack RLC UL data
268  *
269  * @details
270  *
271  *    Function : unpackRlcUlData
272  *
273  *    Functionality: Unpack RLC UL data
274  *
275  * @params[in] 
276  * @return ROK     - success
277  *         RFAILED - failure
278  *
279  * ****************************************************************/
280 uint8_t unpackRlcUlData(RlcMacUlDataFunc func, Pst *pst, Buffer *mBuf)
281 {
282    RlcUlData *ulData;
283  
284    if (pst->selector == ODU_SELECTOR_LWLC)
285    {
286       CMCHKUNPK(oduUnpackPointer,(PTR *) &ulData, mBuf);
287    }
288    else 
289    {
290       return RFAILED;
291    }
292    ODU_PUT_MSG_BUF(mBuf);
293    return (*func)(pst, ulData);
294 }
295
296 /**********************************************************************
297          End of file
298 **********************************************************************/