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 *******************************************************************************/
19 #include "common_def.h"
20 #include "du_app_mac_inf.h"
22 /**************************************************************************
23 * @brief Function to pack Loose Coupled
24 * MAC cell config parameters required by MAC
28 * Function : packMacCellCfg
31 * packs the macCellCfg parameters
33 * @param[in] Pst *pst, Post structure of the primitive.
34 * @param[in] MacCellCfg *macCellCfg, mac cell config parameters.
35 * @return ROK - success
38 ***************************************************************************/
39 uint8_t packMacCellCfg(Pst *pst, MacCellCfg *macCellCfg)
41 if(pst->selector == ODU_SELECTOR_LC)
43 /* we are now implemented only light wieght lossely coupled interface */
46 else if(pst->selector == ODU_SELECTOR_LWLC)
50 if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
55 /* pack the address of the structure */
56 CMCHKPK(oduPackPointer,(PTR)macCellCfg, mBuf);
58 DU_LOG("\nDU-APP : MAC CELL config sent");
59 return ODU_POST_TASK(pst,mBuf);
64 /**************************************************************************
65 * @brief Function to pack Loose Coupled
66 * MAC cell config parameters required by MAC
70 * Function : unpackDuMacCellCfg
73 * packs the macCellCfg parameters
75 * @param[in] DuMacCellCfgReq func; function pointer
76 * @param[in] Pst *pst, Post structure of the primitive.
77 * @param[in] Buffer *mBuf
78 * @return ROK - success
81 ***************************************************************************/
82 uint8_t unpackDuMacCellCfg(DuMacCellCfgReq func, Pst *pst, Buffer *mBuf)
85 MacCellCfg *macCellCfg;
87 if(pst->selector == ODU_SELECTOR_LWLC)
89 /* unpack the address of the structure */
90 CMCHKUNPK(oduUnpackPointer, (PTR *)&macCellCfg, mBuf);
91 ret = (*func)(pst, macCellCfg);
95 /* only LWLC is implemented now */
102 /**************************************************************************
103 * @brief Function to pack Loose Coupled
104 * MAC cell config confirm message
108 * Function : packMacCellCfgCfm
111 * packs the transaction ID
113 * @param[in] Pst *pst, Post structure of the primitive.
114 * @param[in] MacCellCfgCfm *macCellCfgCfm, mac cell config confirm.
115 * @return ROK - success
118 ***************************************************************************/
119 uint8_t packMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm)
121 if(pst->selector == ODU_SELECTOR_LC)
123 Buffer *mBuf = NULLP;
124 if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
129 /* pack the transaction ID in CNF structure */
130 CMCHKPK(oduUnpackUInt16, macCellCfgCfm->cellId, mBuf);
131 CMCHKPK(oduUnpackUInt8, macCellCfgCfm->rsp, mBuf);
133 return ODU_POST_TASK(pst,mBuf);
135 else if(pst->selector == ODU_SELECTOR_LWLC)
137 /* only LC is supported */
143 /**************************************************************************
144 * @brief Function to pack MAC cell config confirm message
148 * Function : unpackMacCellCfgCfm
151 * packs the transaction ID
153 * @param[in] DuMacCellCfgCfm func; function pointer
154 * @param[in] Pst *pst, Post structure of the primitive.
155 * @param[in] Buffer *mBuf
156 * @return ROK - success
159 ***************************************************************************/
160 uint8_t unpackMacCellCfgCfm(DuMacCellCfgCfm func, Pst *pst, Buffer *mBuf)
162 MacCellCfgCfm macCellCfgCfm;
164 if(pst->selector == ODU_SELECTOR_LC)
166 /* unpack the transaction ID in CNF structure */
167 CMCHKUNPK(oduPackUInt8, &(macCellCfgCfm.rsp), mBuf);
168 CMCHKUNPK(oduPackUInt16, &(macCellCfgCfm.cellId), mBuf);
169 return (*func)(pst, &macCellCfgCfm);
173 /* only loose coupling is suported */
178 /*******************************************************************
180 * @brief Packs and Send Cell Start Request to MAC
184 * Function : packMacCellStart
187 * Packs and Sends Cell Start Request to MAC
189 * @params[in] Post structure pointer
191 * @return ROK - success
194 * ****************************************************************/
195 uint8_t packMacCellStart(Pst *pst, OduCellId *cellId)
197 Buffer *mBuf = NULLP;
199 if(pst->selector == ODU_SELECTOR_LC)
201 /* Loose coupling not supported */
204 else if(pst->selector == ODU_SELECTOR_LWLC)
207 if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
209 DU_LOG("\nDU APP : Memory allocation failed for cell start req pack");
213 /* pack the address of the structure */
214 CMCHKPK(oduPackPointer,(PTR)cellId, mBuf);
217 return ODU_POST_TASK(pst,mBuf);
220 /*******************************************************************
222 * @brief Unpacks MAC Cell Start Request from DU APP
226 * Function : unpackMaCellStart
229 * Unpacks MAC Cell Start Request from DU APP
231 * @params[in] Function pointer of cell start request handler
232 * Post structure pointer
234 * @return ROK - success
237 * ****************************************************************/
238 uint8_t unpackMacCellStart(DuMacCellStart func, Pst *pst, Buffer *mBuf)
242 if(pst->selector == ODU_SELECTOR_LWLC)
244 /* unpack the address of the structure */
245 CMCHKUNPK(oduUnpackPointer, (PTR *)&cellId, mBuf);
246 ODU_PUT_MSG_BUF(mBuf);
247 return (*func)(pst, cellId);
251 /* Nothing to do for loose coupling */
252 ODU_PUT_MSG_BUF(mBuf);
257 /*******************************************************************
259 * @brief Packs and Send cell stop request to MAC
263 * Function : packMacCellStop
266 * Packs and Send cell stop request to MAC
268 * @params[in] Post structure pointer
270 * @return ROK - success
273 * ****************************************************************/
274 uint8_t packMacCellStop(Pst *pst, OduCellId *cellId)
276 if(pst->selector == ODU_SELECTOR_LC)
278 /* Loose coupling not supported */
281 else if(pst->selector == ODU_SELECTOR_LWLC)
283 Buffer *mBuf = NULLP;
285 if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
287 DU_LOG("\nDU APP : Memory allocation failed for cell stop req pack");
291 /* pack the address of the structure */
292 CMCHKPK(oduPackPointer,(PTR)cellId, mBuf);
294 return ODU_POST_TASK(pst,mBuf);
299 /*******************************************************************
301 * @brief Unpacks cell stop request from DU APP
305 * Function : unpackMaCellStop
308 * Unpacks cell stop request from DU APP
310 * @params[in] Handler function pointer
311 * Post structure pointer
313 * @return ROK - success
316 * ****************************************************************/
317 uint8_t unpackMacCellStop(DuMacCellStop func, Pst *pst, Buffer *mBuf)
321 if(pst->selector == ODU_SELECTOR_LWLC)
323 /* unpack the address of the structure */
324 CMCHKUNPK(oduUnpackPointer, (PTR *)&cellId, mBuf);
325 ODU_PUT_MSG_BUF(mBuf);
326 return (*func)(pst, cellId);
330 /* Nothing to do for loose coupling */
331 ODU_PUT_MSG_BUF(mBuf);
336 /*******************************************************************
338 * @brief Packs and Sends cell up ind from MAC to DUAPP
342 * Function : packMacCellUpInd
345 * Packs and Sends cell up ind from MAC to DUAPP
347 * @params[in] Post structure pointer
349 * @return ROK - success
352 * ****************************************************************/
353 uint8_t packMacCellUpInd(Pst *pst, OduCellId *cellId)
355 Buffer *mBuf = NULLP;
357 if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
359 DU_LOG("\nDU APP : Memory allocation failed for packMacCellUpInd");
363 if(pst->selector == ODU_SELECTOR_LC)
365 CMCHKPK(oduUnpackUInt16, cellId->cellId, mBuf);
366 CM_FREE_SHRABL_BUF(pst->region, pst->pool, cellId, sizeof(OduCellId));
369 else if(pst->selector == ODU_SELECTOR_LWLC)
371 /* pack the address of the structure */
372 CMCHKPK(oduPackPointer,(PTR)cellId, mBuf);
376 ODU_PUT_MSG_BUF(mBuf);
379 return ODU_POST_TASK(pst, mBuf);
382 /*******************************************************************
384 * @brief Unpacks cell up indication from MAC
388 * Function : unpackMacCellUpInd
391 * Unpacks cell up indication from MAC
393 * @params[in] Pointer to Handler
394 * Post structure pointer
396 * @return ROK - success
399 * ****************************************************************/
400 uint8_t unpackMacCellUpInd(DuMacCellUpInd func, Pst *pst, Buffer *mBuf)
402 if(pst->selector == ODU_SELECTOR_LWLC)
406 /* unpack the address of the structure */
407 CMCHKUNPK(oduUnpackPointer, (PTR *)&cellId, mBuf);
408 ODU_PUT_MSG_BUF(mBuf);
409 return (*func)(pst, cellId);
411 else if(pst->selector == ODU_SELECTOR_LC)
414 CMCHKUNPK(oduPackUInt16, &cellId.cellId, mBuf);
415 ODU_PUT_MSG_BUF(mBuf);
416 return (*func)(pst, &cellId);
420 /* Nothing to do for loose coupling */
421 ODU_PUT_MSG_BUF(mBuf);
427 /*******************************************************************
429 * @brief Packs and Sends stop ind from MAC to DUAPP
433 * Function : packMacStopInd
436 * Packs and Sends stop ind from MAC to DUAPP
438 * @params[in] Post structure pointer
439 * @return ROK - success
442 * ****************************************************************/
443 uint8_t packMacStopInd(Pst *pst, OduCellId *cellId)
445 Buffer *mBuf = NULLP;
447 if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
449 DU_LOG("\nDU APP : Memory allocation failed for stop Ind pack");
453 if(pst->selector == ODU_SELECTOR_LC)
455 /*pack the payload here*/
456 DU_LOG("\nDU APP : Packed CellId");
457 CMCHKPK(oduUnpackUInt16, cellId->cellId, mBuf);
458 CM_FREE_SHRABL_BUF(pst->region, pst->pool, cellId, sizeof(OduCellId));
461 else if(pst->selector == ODU_SELECTOR_LWLC)
463 /* pack the address of the structure */
464 CMCHKPK(oduPackPointer,(PTR)cellId, mBuf);
468 ODU_PUT_MSG_BUF(mBuf);
471 return ODU_POST_TASK(pst,mBuf);
474 /*******************************************************************
476 * @brief Unpacks stop indication from MAC
480 * Function : unpackMacStopInd
483 * Unpacks stop indication from MAC
485 * @params[in] Pointer to Handler
486 * Post structure pointer
488 * @return ROK - success
491 * ****************************************************************/
492 uint8_t unpackMacStopInd(DuMacStopInd func, Pst *pst, Buffer *mBuf)
494 if(pst->selector == ODU_SELECTOR_LWLC)
497 /* unpack the address of the structure */
498 CMCHKUNPK(oduUnpackPointer, (PTR *)&cellId, mBuf);
499 ODU_PUT_MSG_BUF(mBuf);
500 return (*func)(pst, cellId);
502 else if(pst->selector == ODU_SELECTOR_LC)
505 CMCHKUNPK(oduPackUInt16, &(cellId.cellId), mBuf);
507 ODU_PUT_MSG_BUF(mBuf);
508 return (*func)(pst, &cellId);
513 /* Nothing to do for loose coupling */
514 ODU_PUT_MSG_BUF(mBuf);
520 /*******************************************************************
522 * @brief Packs and Sends UL CCCH Ind from MAC to DUAPP
526 * Function : packMacUlCcchInd
529 * Packs and Sends UL CCCH Ind from MAC to DUAPP
531 * @params[in] Post structure pointer
532 * UL CCCH Ind pointer
533 * @return ROK - success
536 * ****************************************************************/
537 uint8_t packMacUlCcchInd(Pst *pst, UlCcchIndInfo *ulCcchIndInfo)
539 Buffer *mBuf = NULLP;
541 if(pst->selector == ODU_SELECTOR_LWLC)
543 if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
545 DU_LOG("\nMAC : Memory allocation failed at packMacUlCcchInd");
548 /* pack the address of the structure */
549 CMCHKPK(oduPackPointer,(PTR)ulCcchIndInfo, mBuf);
553 DU_LOG("\nMAC: Only LWLC supported for UL CCCH Ind ");
557 return ODU_POST_TASK(pst,mBuf);
560 /*******************************************************************
562 * @brief Unpacks UL CCCH indication from MAC
566 * Function : unpackMacUlCcchInd
569 * Unpacks UL CCCH indication from MAC
571 * @params[in] Pointer to Handler
572 * Post structure pointer
574 * @return ROK - success
577 * ****************************************************************/
578 uint8_t unpackMacUlCcchInd(DuMacUlCcchInd func, Pst *pst, Buffer *mBuf)
580 if(pst->selector == ODU_SELECTOR_LWLC)
582 UlCcchIndInfo *ulCcchIndInfo;
584 /* unpack the address of the structure */
585 CMCHKUNPK(oduUnpackPointer, (PTR *)&ulCcchIndInfo, mBuf);
586 ODU_PUT_MSG_BUF(mBuf);
587 return (*func)(pst, ulCcchIndInfo);
591 /* Nothing to do for other selectors */
592 DU_LOG("\n Only LWLC supported for UL CCCH Ind ");
593 ODU_PUT_MSG_BUF(mBuf);
598 /*******************************************************************
600 * @brief Packs and Sends DL CCCH Ind from DUAPP to MAC
604 * Function : packMacDlCcchInd
607 * Packs and Sends DL CCCH Ind from DUAPP to MAC
610 * @params[in] Post structure pointer
611 * DL CCCH Ind pointer
612 * @return ROK - success
615 * ****************************************************************/
616 uint8_t packMacDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo)
618 Buffer *mBuf = NULLP;
620 if(pst->selector == ODU_SELECTOR_LWLC)
622 if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
624 DU_LOG("\nMAC : Memory allocation failed at packMacDlCcchInd");
627 /* pack the address of the structure */
628 CMCHKPK(oduPackPointer,(PTR)dlCcchIndInfo, mBuf);
632 DU_LOG("\nDU APP: Only LWLC supported for DL CCCH Ind ");
636 return ODU_POST_TASK(pst,mBuf);
639 /*******************************************************************
641 * @brief Unpacks DL CCCH indication from DU APP
645 * Function : unpackMacDlCcchInd
648 * Unpacks DL CCCH indication from DU APP
650 * @params[in] Pointer to Handler
651 * Post structure pointer
653 * @return ROK - success
656 * ****************************************************************/
657 uint8_t unpackMacDlCcchInd(DuMacDlCcchInd func, Pst *pst, Buffer *mBuf)
659 if(pst->selector == ODU_SELECTOR_LWLC)
661 DlCcchIndInfo *dlCcchIndInfo;
663 /* unpack the address of the structure */
664 CMCHKUNPK(oduUnpackPointer, (PTR *)&dlCcchIndInfo, mBuf);
665 ODU_PUT_MSG_BUF(mBuf);
666 return (*func)(pst, dlCcchIndInfo);
670 /* Nothing to do for other selectors */
671 DU_LOG("\n Only LWLC supported for DL CCCH Ind ");
672 ODU_PUT_MSG_BUF(mBuf);
678 /*******************************************************************
680 * @brief Packs and Sends UE create Request from DUAPP to MAC
684 * Function : packDuMacUeCreateReq
687 * Packs and Sends UE Create Request from DUAPP to MAC
690 * @params[in] Post structure pointer
692 * @return ROK - success
695 * ****************************************************************/
696 uint8_t packDuMacUeCreateReq(Pst *pst, MacUeCfg *ueCfg)
698 Buffer *mBuf = NULLP;
700 if(pst->selector == ODU_SELECTOR_LWLC)
702 if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
704 DU_LOG("\nMAC : Memory allocation failed at packDuMacUeCreateReq");
707 /* pack the address of the structure */
708 CMCHKPK(oduPackPointer,(PTR)ueCfg, mBuf);
712 DU_LOG("\nMAC: Only LWLC supported for packDuMacUeCreateReq");
716 return ODU_POST_TASK(pst,mBuf);
719 /*******************************************************************
721 * @brief Unpacks UE Create Request received from DU APP
725 * Function : unpackMacUeCreateReq
728 * Unpacks UE Create Request received from DU APP
730 * @params[in] Pointer to Handler
731 * Post structure pointer
733 * @return ROK - success
736 * ****************************************************************/
737 uint8_t unpackMacUeCreateReq(DuMacUeCreateReq func, Pst *pst, Buffer *mBuf)
739 if(pst->selector == ODU_SELECTOR_LWLC)
743 /* unpack the address of the structure */
744 CMCHKUNPK(oduUnpackPointer, (PTR *)&ueCfg, mBuf);
745 ODU_PUT_MSG_BUF(mBuf);
746 return (*func)(pst, ueCfg);
750 /* Nothing to do for other selectors */
751 DU_LOG("\n Only LWLC supported for UE Create Request ");
752 ODU_PUT_MSG_BUF(mBuf);
758 /*******************************************************************
760 * @brief Pack and send UE config response from MAC to DU APP
764 * Function : packDuMacUeCfgRsp
767 * Pack and send UE config response from MAC to DU APP
770 * @return ROK - success
773 * ****************************************************************/
774 uint8_t packDuMacUeCfgRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
776 Buffer *mBuf = NULLP;
778 if(pst->selector == ODU_SELECTOR_LWLC)
780 if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
782 DU_LOG("\nMAC : Memory allocation failed at packDuMacUeCfgRsp");
785 /* pack the address of the structure */
786 CMCHKPK(oduPackPointer,(PTR)cfgRsp, mBuf);
790 DU_LOG("\nMAC: Only LWLC supported for packDuMacUeCfgRsp");
794 return ODU_POST_TASK(pst,mBuf);
797 /*******************************************************************
799 * @brief Unpack UE Config Response from MAC to DU APP
803 * Function : unpackDuMacUeCfgRsp
805 * Functionality: Unpack UE Config Response from MAC to DU APP
808 * @return ROK - success
811 * ****************************************************************/
812 uint8_t unpackDuMacUeCfgRsp(MacDuUeCfgRspFunc func, Pst *pst, Buffer *mBuf)
814 if(pst->selector == ODU_SELECTOR_LWLC)
816 MacUeCfgRsp *cfgRsp = NULLP;
818 /* unpack the address of the structure */
819 CMCHKUNPK(oduUnpackPointer, (PTR *)&cfgRsp, mBuf);
820 ODU_PUT_MSG_BUF(mBuf);
821 return (*func)(pst, cfgRsp);
824 ODU_PUT_MSG_BUF(mBuf);
828 /*******************************************************************
830 * @brief Packs and Sends UE Reconig Request from DUAPP to MAC
834 * Function : packDuMacUeReconfigReq
837 * Packs and Sends UE Reconfig Request from DUAPP to MAC
840 * @params[in] Post structure pointer
842 * @return ROK - success
845 * ****************************************************************/
846 uint8_t packDuMacUeReconfigReq(Pst *pst, MacUeCfg *ueCfg)
848 Buffer *mBuf = NULLP;
850 if(pst->selector == ODU_SELECTOR_LWLC)
852 if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
854 DU_LOG("\nMAC : Memory allocation failed at packDuMacUeReconfigReq");
857 /* pack the address of the structure */
858 CMCHKPK(oduPackPointer,(PTR)ueCfg, mBuf);
862 DU_LOG("\nMAC: Only LWLC supported for packDuMacUeReconfigReq");
866 return ODU_POST_TASK(pst,mBuf);
868 /*******************************************************************
870 * @brief Unpacks UE Reconfig Request received from DU APP
874 * Function : unpackMacUeReconfigReq
877 * Unpacks UE Reconfig Request received from DU APP
879 * @params[in] Pointer to Handler
880 * Post structure pointer
882 * @return ROK - success
885 * ****************************************************************/
886 uint8_t unpackMacUeReconfigReq(DuMacUeReconfigReq func, Pst *pst, Buffer *mBuf)
888 if(pst->selector == ODU_SELECTOR_LWLC)
892 /* unpack the address of the structure */
893 CMCHKUNPK(oduUnpackPointer, (PTR *)&ueCfg, mBuf);
894 ODU_PUT_MSG_BUF(mBuf);
895 return (*func)(pst, ueCfg);
899 /* Nothing to do for other selectors */
900 DU_LOG("\n Only LWLC supported for UE Create Request ");
901 ODU_PUT_MSG_BUF(mBuf);
907 /**********************************************************************
909 **********************************************************************/