Renamed SlotIndInfo to SlotTimingInfo [Issue-ID: ODUHIGH-354]
[o-du/l2.git] / src / 5gnrmac / lwr_mac_upr_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 #include "common_def.h"
19 #include "lwr_mac_upr_inf.h"
20
21 /*******************************************************************
22  *
23  * @brief Packs and Sends CRC Ind to MAC
24  *
25  * @details
26  *
27  *    Function : packCrcInd
28  *
29  *    Functionality:
30  *      Packs and Sends CRC Ind to MAC
31  *
32  * @params[in] Post structure pointer
33  *             CRC indication
34  * @return ROK     - success
35  *         RFAILED - failure
36  *
37  * ****************************************************************/
38 uint8_t packCrcInd(Pst *pst, CrcInd *crcInd)
39 {
40    if(pst->selector == ODU_SELECTOR_LWLC)
41    {
42       Buffer *mBuf = NULLP;
43       if(ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
44       {
45          DU_LOG("\nERROR  --> LWR_MAC: Memory allocation failed in packCrcInd");
46          return RFAILED;
47       }
48       CMCHKPK(oduPackPointer,(PTR)crcInd, mBuf);
49       return ODU_POST_TASK(pst, mBuf);
50    }
51    return RFAILED;
52 }
53
54 /**************************************************************************
55  * @brief Function unpack crcInd
56  *
57  * @details
58  *
59  *      Function : unpackCrcInd
60  *
61  *      Functionality:
62  *           unpacks crc indication
63  *
64  * @param[in] function pointer
65  * @param[in] Pst     *pst, Post structure of the primitive.
66  * @param[in] Buffer *mBuf
67  * @return ROK     - success
68  *         RFAILED - failure
69  *
70  ***************************************************************************/
71 uint8_t unpackCrcInd(CrcIndFunc func, Pst *pst, Buffer *mBuf)
72 {
73    if(pst->selector == ODU_SELECTOR_LWLC)
74    {
75       CrcInd *crcInd = NULLP;
76
77       /* unpack the address of the structure */
78       CMCHKUNPK(oduUnpackPointer, (PTR *)&crcInd, mBuf);
79       ODU_PUT_MSG_BUF(mBuf);
80       return (*func)(pst, crcInd);
81    }
82    return RFAILED;
83 }
84
85
86 /*******************************************************************
87  *
88  * @brief Packs and Sends Rx Data Ind to MAC
89  *
90  * @details
91  *
92  *    Function : packRxDataInd
93  *
94  *    Functionality:
95  *      Packs and Sends Rx data Ind to MAC
96  *
97  * @params[in] Post structure pointer
98  *             Rx Data indication
99  * @return ROK     - success
100  *         RFAILED - failure
101  *
102  * ****************************************************************/
103 uint8_t packRxDataInd(Pst *pst, RxDataInd *rxDataInd)
104 {
105    if(pst->selector == ODU_SELECTOR_LWLC)
106    {
107       Buffer *mBuf = NULLP;
108       if(ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
109       {
110          DU_LOG("\nERROR  -->  LWR_MAC: Memory allocation failed in packRxDataInd");
111          return RFAILED;
112       }
113       CMCHKPK(oduPackPointer,(PTR)rxDataInd, mBuf);
114       return ODU_POST_TASK(pst, mBuf);
115    }
116    return RFAILED;
117 }
118
119 /**************************************************************************
120  * @brief Function unpack RxDataInd
121  *
122  * @details
123  *
124  *      Function : unpackRxDataInd
125  *
126  *      Functionality:
127  *           unpacks Rx Data indication
128  *
129  * @param[in] function pointer
130  * @param[in] Pst     *pst, Post structure of the primitive.
131  * @param[in] Buffer *mBuf
132  * @return ROK     - success
133  *         RFAILED - failure
134  *
135  ***************************************************************************/
136 uint8_t unpackRxDataInd(RxDataIndFunc func, Pst *pst, Buffer *mBuf)
137 {
138    if(pst->selector == ODU_SELECTOR_LWLC)
139    {
140       RxDataInd *rxDataInd = NULLP;
141
142       /* unpack the address of the structure */
143       CMCHKUNPK(oduUnpackPointer, (PTR *)&rxDataInd, mBuf);
144       ODU_PUT_MSG_BUF(mBuf);
145       return (*func)(pst, rxDataInd);
146    }
147    return RFAILED;
148 }
149
150
151 /*******************************************************************
152  *
153  * @brief Packs and Sends RACH Ind to MAC
154  *
155  * @details
156  *
157  *    Function : packRachInd
158  *
159  *    Functionality:
160  *         Packs and Sends RACH Ind to MAC
161  *
162  * @params[in] Post structure pointer
163  *             RACH indication
164  * @return ROK     - success
165  *         RFAILED - failure
166  *
167  * ****************************************************************/
168 uint8_t packRachInd(Pst *pst, RachInd *rachInd)
169 {
170    if(pst->selector == ODU_SELECTOR_LWLC)
171    {
172       Buffer *mBuf = NULLP;
173       if(ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
174       {
175          DU_LOG("\nERROR  -->  LWR_MAC: Memory allocation failed in packRachInd");
176          return RFAILED;
177       }
178       CMCHKPK(oduPackPointer,(PTR)rachInd, mBuf);
179       return ODU_POST_TASK(pst, mBuf);
180    }
181    return RFAILED;
182 }
183
184 /**************************************************************************
185  * @brief Function unpacks RachInd
186  *
187  * @details
188  *
189  *      Function : unpackRachInd
190  *
191  *      Functionality:
192  *           unpacks Rach indication
193  *
194  * @param[in] function pointer
195  * @param[in] Pst     *pst, Post structure of the primitive.
196  * @param[in] Buffer *mBuf
197  * @return ROK     - success
198  *         RFAILED - failure
199  *
200  ***************************************************************************/
201 uint8_t unpackRachInd(RachIndFunc func, Pst *pst, Buffer *mBuf)
202 {
203    if(pst->selector == ODU_SELECTOR_LWLC)
204    {
205       RachInd *rachInd = NULLP;
206
207       /* unpack the address of the structure */
208       CMCHKUNPK(oduUnpackPointer, (PTR *)&rachInd, mBuf);
209       ODU_PUT_MSG_BUF(mBuf);
210       return (*func)(pst, rachInd);
211    }
212    return RFAILED;
213 }
214
215 /*******************************************************************
216  *
217  * @brief Pack and send slot indication to MAC
218  *
219  * @details
220  *
221  *    Function : packSlotInd
222  *
223  *    Functionality:
224  *       Pack and send slot indication to MAC
225  *
226  * @params[in] Post structure
227  *             Slot indication info
228  * @return ROK     - success
229  *         RFAILED - failure
230  *
231  * ****************************************************************/
232 uint8_t packSlotInd (Pst *pst, SlotTimingInfo *slotInd)
233 {
234    if(pst->selector == ODU_SELECTOR_LWLC)
235    {
236       Buffer *mBuf = NULLP;
237       if(ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
238       {
239          DU_LOG("\nERROR  -->  LWR_MAC: Memory allocation failed in packSlotInd");
240          return RFAILED;
241       }
242       CMCHKPK(oduPackPointer,(PTR)slotInd, mBuf);
243       return ODU_POST_TASK(pst, mBuf);
244    }
245    return RFAILED;
246 }
247
248 /**************************************************************************
249  * @brief Function unpacks slot indication
250  *
251  * @details
252  *
253  *      Function : unpackSlotInd
254  *
255  *      Functionality:
256  *           unpacks slot indication
257  *
258  * @param[in] function pointer,
259  * @param[in] Pst     *pst,
260  * @param[in] Buffer *mBuf
261  * @return ROK     - success
262  *         RFAILED - failure
263  *
264  ***************************************************************************/
265 uint8_t unpackSlotInd(SlotIndFunc func, Pst *pst, Buffer *mBuf)
266 {
267    if(pst->selector == ODU_SELECTOR_LWLC)
268    {
269       SlotTimingInfo *slotInd = NULLP;
270
271       /* unpack the address of the structure */
272       CMCHKUNPK(oduUnpackPointer, (PTR *)&slotInd, mBuf);
273       ODU_PUT_MSG_BUF(mBuf);
274       return (*func)(pst, slotInd);
275    }
276    return RFAILED;
277 }
278
279
280 /*******************************************************************
281  *
282  * @brief Packs and Sends Stop Ind to MAC
283  *
284  * @details
285  *
286  *    Function : packStopInd
287  *
288  *    Functionality:
289  *         Packs and Sends Stop Ind to MAC
290  *
291  * @params[in] Post structure pointer
292  * @return ROK     - success
293  *         RFAILED - failure
294  *
295  * ****************************************************************/
296 uint8_t packStopInd(Pst *pst, uint16_t *cellId)
297 {
298    if(pst->selector == ODU_SELECTOR_LWLC)
299    {
300       Buffer *mBuf = NULLP;
301       if(ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
302       {
303          DU_LOG("\nERROR  -->  LWR_MAC: Memory allocation failed in packStopInd");
304          return RFAILED;
305       }
306       CMCHKPK(oduPackPointer,(PTR)cellId, mBuf);
307       return ODU_POST_TASK(pst, mBuf);
308    }
309    return RFAILED;
310 }
311
312 /**************************************************************************
313  * @brief Function unpack stop indication
314  *
315  * @details
316  *
317  *      Function : unpackStopInd
318  *
319  *      Functionality:
320  *           unpacks stop indication
321  *
322  * @param[in] function pointer
323  * @param[in] Pst     *pst,
324  * @param[in] Buffer *mBuf
325  * @return ROK     - success
326  *         RFAILED - failure
327  *
328  ***************************************************************************/
329 uint8_t unpackStopInd(StopIndFunc func, Pst *pst, Buffer *mBuf)
330 {
331    if(pst->selector == ODU_SELECTOR_LWLC)
332    {
333       uint16_t *cellId = NULLP;
334
335       /* unpack the address of the structure */
336       CMCHKUNPK(oduUnpackPointer, (PTR *)&cellId, mBuf);
337       ODU_PUT_MSG_BUF(mBuf);
338       return (*func)(pst, cellId);
339    }
340    return RFAILED;
341 }
342
343 /*******************************************************************
344  *
345  * @brief Packs and Sends UCI Ind to MAC
346  *
347  * @details
348  *
349  *    Function : packUciInd
350  *
351  *    Functionality:
352  *         Packs and Sends Uci Ind to MAC
353  *
354  * @params[in] Post structure pointer
355  * @return ROK     - success
356  *         RFAILED - failure
357  *
358  * ****************************************************************/
359 uint8_t packUciInd(Pst *pst, UciInd *uciInd)
360 {
361    if(pst->selector == ODU_SELECTOR_LWLC)
362    {
363       Buffer *mBuf = NULLP;
364       if(ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
365       {
366          DU_LOG("\nERROR  -->  LWR_MAC: Memory allocation failed in packUciInd");
367          return RFAILED;
368       }
369       CMCHKPK(oduPackPointer,(PTR)uciInd, mBuf);
370       return ODU_POST_TASK(pst, mBuf);
371    }
372    return RFAILED;
373 }
374
375 /**************************************************************************
376  * @brief Function unpack UCI indication
377  *
378  * @details
379  *
380  *      Function : unpackUciInd
381  *
382  *      Functionality:
383  *           unpacks UCI indication
384  *
385  * @param[in] function pointer
386  * @param[in] Pst     *pst,
387  * @param[in] Buffer *mBuf
388  * @return ROK     - success
389  *         RFAILED - failure
390  *
391  ***************************************************************************/
392 uint8_t unpackUciInd(UciIndFunc func, Pst *pst, Buffer *mBuf)
393 {
394    if(pst->selector == ODU_SELECTOR_LWLC)
395    {
396       UciInd *uciInd = NULLP;
397
398       /* unpack the address of the structure */
399       CMCHKUNPK(oduUnpackPointer, (PTR *)&uciInd, mBuf);
400       ODU_PUT_MSG_BUF(mBuf);
401       return (*func)(pst, uciInd);
402    }
403    return RFAILED;
404 }
405
406
407 /**********************************************************************
408   End of file
409  **********************************************************************/