1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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"
21 /*******************************************************************
23 * @brief Packs and Sends CRC Ind to MAC
27 * Function : packCrcInd
30 * Packs and Sends CRC Ind to MAC
32 * @params[in] Post structure pointer
34 * @return ROK - success
37 * ****************************************************************/
38 uint8_t packCrcInd(Pst *pst, CrcInd *crcInd)
40 if(pst->selector == ODU_SELECTOR_LWLC)
43 if(ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
45 printf("\nLWR_MAC: Memory allocation failed in packCrcInd");
48 CMCHKPK(oduPackPointer,(PTR)crcInd, mBuf);
49 return ODU_POST_TASK(pst, mBuf);
54 /**************************************************************************
55 * @brief Function unpack crcInd
59 * Function : unpackCrcInd
62 * unpacks crc indication
64 * @param[in] function pointer
65 * @param[in] Pst *pst, Post structure of the primitive.
66 * @param[in] Buffer *mBuf
67 * @return ROK - success
70 ***************************************************************************/
71 uint8_t unpackCrcInd(CrcIndFunc func, Pst *pst, Buffer *mBuf)
73 if(pst->selector == ODU_SELECTOR_LWLC)
75 CrcInd *crcInd = NULLP;
77 /* unpack the address of the structure */
78 CMCHKUNPK(oduUnpackPointer, (PTR *)&crcInd, mBuf);
79 ODU_PUT_MSG_BUF(mBuf);
80 return (*func)(pst, crcInd);
86 /*******************************************************************
88 * @brief Packs and Sends Rx Data Ind to MAC
92 * Function : packRxDataInd
95 * Packs and Sends Rx data Ind to MAC
97 * @params[in] Post structure pointer
99 * @return ROK - success
102 * ****************************************************************/
103 uint8_t packRxDataInd(Pst *pst, RxDataInd *rxDataInd)
105 if(pst->selector == ODU_SELECTOR_LWLC)
107 Buffer *mBuf = NULLP;
108 if(ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
110 printf("\nLWR_MAC: Memory allocation failed in packRxDataInd");
113 CMCHKPK(oduPackPointer,(PTR)rxDataInd, mBuf);
114 return ODU_POST_TASK(pst, mBuf);
119 /**************************************************************************
120 * @brief Function unpack RxDataInd
124 * Function : unpackRxDataInd
127 * unpacks Rx Data indication
129 * @param[in] function pointer
130 * @param[in] Pst *pst, Post structure of the primitive.
131 * @param[in] Buffer *mBuf
132 * @return ROK - success
135 ***************************************************************************/
136 uint8_t unpackRxDataInd(RxDataIndFunc func, Pst *pst, Buffer *mBuf)
138 if(pst->selector == ODU_SELECTOR_LWLC)
140 RxDataInd *rxDataInd = NULLP;
142 /* unpack the address of the structure */
143 CMCHKUNPK(oduUnpackPointer, (PTR *)&rxDataInd, mBuf);
144 ODU_PUT_MSG_BUF(mBuf);
145 return (*func)(pst, rxDataInd);
151 /*******************************************************************
153 * @brief Packs and Sends RACH Ind to MAC
157 * Function : packRachInd
160 * Packs and Sends RACH Ind to MAC
162 * @params[in] Post structure pointer
164 * @return ROK - success
167 * ****************************************************************/
168 uint8_t packRachInd(Pst *pst, RachInd *rachInd)
170 if(pst->selector == ODU_SELECTOR_LWLC)
172 Buffer *mBuf = NULLP;
173 if(ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
175 printf("\nLWR_MAC: Memory allocation failed in packRachInd");
178 CMCHKPK(oduPackPointer,(PTR)rachInd, mBuf);
179 return ODU_POST_TASK(pst, mBuf);
184 /**************************************************************************
185 * @brief Function unpacks RachInd
189 * Function : unpackRachInd
192 * unpacks Rach indication
194 * @param[in] function pointer
195 * @param[in] Pst *pst, Post structure of the primitive.
196 * @param[in] Buffer *mBuf
197 * @return ROK - success
200 ***************************************************************************/
201 uint8_t unpackRachInd(RachIndFunc func, Pst *pst, Buffer *mBuf)
203 if(pst->selector == ODU_SELECTOR_LWLC)
205 RachInd *rachInd = NULLP;
207 /* unpack the address of the structure */
208 CMCHKUNPK(oduUnpackPointer, (PTR *)&rachInd, mBuf);
209 ODU_PUT_MSG_BUF(mBuf);
210 return (*func)(pst, rachInd);
215 /*******************************************************************
217 * @brief Pack and send slot indication to MAC
221 * Function : packSlotInd
224 * Pack and send slot indication to MAC
226 * @params[in] Post structure
227 * Slot indication info
228 * @return ROK - success
231 * ****************************************************************/
232 uint8_t packSlotInd (Pst *pst, SlotIndInfo *slotInd)
234 if(pst->selector == ODU_SELECTOR_LWLC)
236 Buffer *mBuf = NULLP;
237 if(ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
239 printf("\nLWR_MAC: Memory allocation failed in packSlotInd");
242 CMCHKPK(oduPackPointer,(PTR)slotInd, mBuf);
243 return ODU_POST_TASK(pst, mBuf);
248 /**************************************************************************
249 * @brief Function unpacks slot indication
253 * Function : unpackSlotInd
256 * unpacks slot indication
258 * @param[in] function pointer,
259 * @param[in] Pst *pst,
260 * @param[in] Buffer *mBuf
261 * @return ROK - success
264 ***************************************************************************/
265 uint8_t unpackSlotInd(SlotIndFunc func, Pst *pst, Buffer *mBuf)
267 if(pst->selector == ODU_SELECTOR_LWLC)
269 SlotIndInfo *slotInd = NULLP;
271 /* unpack the address of the structure */
272 CMCHKUNPK(oduUnpackPointer, (PTR *)&slotInd, mBuf);
273 ODU_PUT_MSG_BUF(mBuf);
274 return (*func)(pst, slotInd);
280 /*******************************************************************
282 * @brief Packs and Sends Stop Ind to MAC
286 * Function : packStopInd
289 * Packs and Sends Stop Ind to MAC
291 * @params[in] Post structure pointer
292 * @return ROK - success
295 * ****************************************************************/
296 uint8_t packStopInd(Pst *pst, uint16_t *cellId)
298 if(pst->selector == ODU_SELECTOR_LWLC)
300 Buffer *mBuf = NULLP;
301 if(ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
303 printf("\nLWR_MAC: Memory allocation failed in packStopInd");
306 CMCHKPK(oduPackPointer,(PTR)cellId, mBuf);
307 return ODU_POST_TASK(pst, mBuf);
312 /**************************************************************************
313 * @brief Function unpack stop indication
317 * Function : unpackStopInd
320 * unpacks stop indication
322 * @param[in] function pointer
323 * @param[in] Pst *pst,
324 * @param[in] Buffer *mBuf
325 * @return ROK - success
328 ***************************************************************************/
329 uint8_t unpackStopInd(StopIndFunc func, Pst *pst, Buffer *mBuf)
331 if(pst->selector == ODU_SELECTOR_LWLC)
333 uint16_t *cellId = NULLP;
335 /* unpack the address of the structure */
336 CMCHKUNPK(oduUnpackPointer, (PTR *)&cellId, mBuf);
337 ODU_PUT_MSG_BUF(mBuf);
338 return (*func)(pst, cellId);
343 /*******************************************************************
345 * @brief Packs and Sends UCI Ind to MAC
349 * Function : packUciInd
352 * Packs and Sends Uci Ind to MAC
354 * @params[in] Post structure pointer
355 * @return ROK - success
358 * ****************************************************************/
359 uint8_t packUciInd(Pst *pst, UciInd *uciInd)
361 if(pst->selector == ODU_SELECTOR_LWLC)
363 Buffer *mBuf = NULLP;
364 if(ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
366 printf("\nLWR_MAC: Memory allocation failed in packUciInd");
369 CMCHKPK(oduPackPointer,(PTR)uciInd, mBuf);
370 return ODU_POST_TASK(pst, mBuf);
375 /**************************************************************************
376 * @brief Function unpack UCI indication
380 * Function : unpackUciInd
383 * unpacks UCI indication
385 * @param[in] function pointer
386 * @param[in] Pst *pst,
387 * @param[in] Buffer *mBuf
388 * @return ROK - success
391 ***************************************************************************/
392 uint8_t unpackUciInd(UciIndFunc func, Pst *pst, Buffer *mBuf)
394 if(pst->selector == ODU_SELECTOR_LWLC)
396 UciInd *uciInd = NULLP;
398 /* unpack the address of the structure */
399 CMCHKUNPK(oduUnpackPointer, (PTR *)&uciInd, mBuf);
400 ODU_PUT_MSG_BUF(mBuf);
401 return (*func)(pst, uciInd);
407 /**********************************************************************
409 **********************************************************************/