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 : packMacCellStartReq
187 * Packs and Sends Cell Start Request to MAC
189 * @params[in] Post structure pointer
190 * MacCellStartInfo pointer
191 * @return ROK - success
194 * ****************************************************************/
195 uint8_t packMacCellStartReq(Pst *pst, MacCellStartInfo *cellStartInfo)
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)cellStartInfo, mBuf);
217 return ODU_POST_TASK(pst,mBuf);
220 /*******************************************************************
222 * @brief Unpacks MAC Cell Start Request from DU APP
226 * Function : unpackMaCellStartReq
229 * Unpacks MAC Cell Start Request from DU APP
231 * @params[in] Function pointer of cell start request handler
232 * Post structure pointer
233 * Cell Start Request Info Pointer
234 * @return ROK - success
237 * ****************************************************************/
238 uint8_t unpackMacCellStartReq(DuMacCellStartReq func, Pst *pst, Buffer *mBuf)
240 MacCellStartInfo *cellStartInfo;
242 if(pst->selector == ODU_SELECTOR_LWLC)
244 /* unpack the address of the structure */
245 CMCHKUNPK(oduUnpackPointer, (PTR *)&cellStartInfo, mBuf);
246 ODU_PUT_MSG_BUF(mBuf);
247 return (*func)(pst, cellStartInfo);
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 : packMacCellStopReq
266 * Packs and Send cell stop request to MAC
268 * @params[in] Post structure pointer
269 * Cell stop info structure
270 * @return ROK - success
273 * ****************************************************************/
274 uint8_t packMacCellStopReq(Pst *pst, MacCellStopInfo *cellStopInfo)
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)cellStopInfo, mBuf);
294 return ODU_POST_TASK(pst,mBuf);
299 /*******************************************************************
301 * @brief Unpacks cell stop request from DU APP
305 * Function : unpackMaCellStopReq
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 unpackMacCellStopReq(DuMacCellStopReq func, Pst *pst, Buffer *mBuf)
319 MacCellStopInfo *cellStopInfo;
321 if(pst->selector == ODU_SELECTOR_LWLC)
323 /* unpack the address of the structure */
324 CMCHKUNPK(oduUnpackPointer, (PTR *)&cellStopInfo, mBuf);
325 ODU_PUT_MSG_BUF(mBuf);
326 return (*func)(pst, cellStopInfo);
330 /* Nothing to do for loose coupling */
331 ODU_PUT_MSG_BUF(mBuf);
336 /*******************************************************************
338 * @brief Packs and Sends slot ind from MAC to DUAPP
342 * Function : packMacSlotInd
345 * Packs and Sends slot ind from MAC to DUAPP
347 * @params[in] Post structure pointer
349 * @return ROK - success
352 * ****************************************************************/
353 uint8_t packMacSlotInd(Pst *pst, SlotIndInfo *slotInfo )
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 cell start req pack");
363 if(pst->selector == ODU_SELECTOR_LC)
365 CMCHKPK(oduUnpackUInt16, slotInfo->cellId, mBuf);
366 CMCHKPK(oduUnpackUInt16, slotInfo->sfn, mBuf);
367 CMCHKPK(oduUnpackUInt16, slotInfo->slot, mBuf);
369 CM_FREE_SHRABL_BUF(pst->region, pst->pool, slotInfo, sizeof(SlotIndInfo));
372 else if(pst->selector == ODU_SELECTOR_LWLC)
374 /* pack the address of the structure */
375 CMCHKPK(oduPackPointer,(PTR)slotInfo, mBuf);
379 ODU_PUT_MSG_BUF(mBuf);
382 return ODU_POST_TASK(pst,mBuf);
385 /*******************************************************************
387 * @brief Unpacks slot indication from MAC
391 * Function : unpackMacSlotInd
394 * Unpacks slot indication from MAC
396 * @params[in] Pointer to Handler
397 * Post structure pointer
399 * @return ROK - success
402 * ****************************************************************/
403 uint8_t unpackMacSlotInd(DuMacSlotInd func, Pst *pst, Buffer *mBuf)
405 if(pst->selector == ODU_SELECTOR_LWLC)
407 SlotIndInfo *slotInfo;
409 /* unpack the address of the structure */
410 CMCHKUNPK(oduUnpackPointer, (PTR *)&slotInfo, mBuf);
411 ODU_PUT_MSG_BUF(mBuf);
412 return (*func)(pst, slotInfo);
414 else if(pst->selector == ODU_SELECTOR_LC)
416 SlotIndInfo slotInfo;
418 CMCHKUNPK(oduPackUInt16, &(slotInfo.slot), mBuf);
419 CMCHKUNPK(oduPackUInt16, &(slotInfo.sfn), mBuf);
420 CMCHKUNPK(oduPackUInt16, &(slotInfo.cellId), mBuf);
422 ODU_PUT_MSG_BUF(mBuf);
423 return (*func)(pst, &slotInfo);
428 /* Nothing to do for loose coupling */
429 ODU_PUT_MSG_BUF(mBuf);
435 /*******************************************************************
437 * @brief Packs and Sends stop ind from MAC to DUAPP
441 * Function : packMacStopInd
444 * Packs and Sends stop ind from MAC to DUAPP
446 * @params[in] Post structure pointer
447 * @return ROK - success
450 * ****************************************************************/
451 uint8_t packMacStopInd(Pst *pst, MacCellStopInfo *cellStopId)
453 Buffer *mBuf = NULLP;
455 if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
457 DU_LOG("\nDU APP : Memory allocation failed for stop Ind pack");
461 if(pst->selector == ODU_SELECTOR_LC)
463 /*pack the payload here*/
464 DU_LOG("\nDU APP : Packed CellId");
465 CMCHKPK(oduUnpackUInt16, cellStopId->cellId, mBuf);
466 CM_FREE_SHRABL_BUF(pst->region, pst->pool, cellStopId, sizeof(MacCellStopInfo));
469 else if(pst->selector == ODU_SELECTOR_LWLC)
471 /* pack the address of the structure */
472 CMCHKPK(oduPackPointer,(PTR)cellStopId, mBuf);
476 ODU_PUT_MSG_BUF(mBuf);
479 return ODU_POST_TASK(pst,mBuf);
482 /*******************************************************************
484 * @brief Unpacks stop indication from MAC
488 * Function : unpackMacStopInd
491 * Unpacks stop indication from MAC
493 * @params[in] Pointer to Handler
494 * Post structure pointer
496 * @return ROK - success
499 * ****************************************************************/
500 uint8_t unpackMacStopInd(DuMacStopInd func, Pst *pst, Buffer *mBuf)
502 if(pst->selector == ODU_SELECTOR_LWLC)
504 MacCellStopInfo *cellStopId;
505 /* unpack the address of the structure */
506 CMCHKUNPK(oduUnpackPointer, (PTR *)&cellStopId, mBuf);
507 ODU_PUT_MSG_BUF(mBuf);
508 return (*func)(pst, cellStopId);
510 else if(pst->selector == ODU_SELECTOR_LC)
512 MacCellStopInfo cellStopId;
513 CMCHKUNPK(oduPackUInt16, &(cellStopId.cellId), mBuf);
515 ODU_PUT_MSG_BUF(mBuf);
516 return (*func)(pst, &cellStopId);
521 /* Nothing to do for loose coupling */
522 ODU_PUT_MSG_BUF(mBuf);
528 /*******************************************************************
530 * @brief Packs and Sends UL CCCH Ind from MAC to DUAPP
534 * Function : packMacUlCcchInd
537 * Packs and Sends UL CCCH Ind from MAC to DUAPP
539 * @params[in] Post structure pointer
540 * UL CCCH Ind pointer
541 * @return ROK - success
544 * ****************************************************************/
545 uint8_t packMacUlCcchInd(Pst *pst, UlCcchIndInfo *ulCcchIndInfo)
547 Buffer *mBuf = NULLP;
549 if(pst->selector == ODU_SELECTOR_LWLC)
551 if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
553 DU_LOG("\nMAC : Memory allocation failed at packMacUlCcchInd");
556 /* pack the address of the structure */
557 CMCHKPK(oduPackPointer,(PTR)ulCcchIndInfo, mBuf);
561 DU_LOG("\nMAC: Only LWLC supported for UL CCCH Ind ");
565 return ODU_POST_TASK(pst,mBuf);
568 /*******************************************************************
570 * @brief Unpacks UL CCCH indication from MAC
574 * Function : unpackMacUlCcchInd
577 * Unpacks UL CCCH indication from MAC
579 * @params[in] Pointer to Handler
580 * Post structure pointer
582 * @return ROK - success
585 * ****************************************************************/
586 uint8_t unpackMacUlCcchInd(DuMacUlCcchInd func, Pst *pst, Buffer *mBuf)
588 if(pst->selector == ODU_SELECTOR_LWLC)
590 UlCcchIndInfo *ulCcchIndInfo;
592 /* unpack the address of the structure */
593 CMCHKUNPK(oduUnpackPointer, (PTR *)&ulCcchIndInfo, mBuf);
594 ODU_PUT_MSG_BUF(mBuf);
595 return (*func)(pst, ulCcchIndInfo);
599 /* Nothing to do for other selectors */
600 DU_LOG("\n Only LWLC supported for UL CCCH Ind ");
601 ODU_PUT_MSG_BUF(mBuf);
606 /*******************************************************************
608 * @brief Packs and Sends DL CCCH Ind from DUAPP to MAC
612 * Function : packMacDlCcchInd
615 * Packs and Sends DL CCCH Ind from DUAPP to MAC
618 * @params[in] Post structure pointer
619 * DL CCCH Ind pointer
620 * @return ROK - success
623 * ****************************************************************/
624 uint8_t packMacDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo)
626 Buffer *mBuf = NULLP;
628 if(pst->selector == ODU_SELECTOR_LWLC)
630 if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
632 DU_LOG("\nMAC : Memory allocation failed at packMacDlCcchInd");
635 /* pack the address of the structure */
636 CMCHKPK(oduPackPointer,(PTR)dlCcchIndInfo, mBuf);
640 DU_LOG("\nDU APP: Only LWLC supported for DL CCCH Ind ");
644 return ODU_POST_TASK(pst,mBuf);
647 /*******************************************************************
649 * @brief Unpacks DL CCCH indication from DU APP
653 * Function : unpackMacDlCcchInd
656 * Unpacks DL CCCH indication from DU APP
658 * @params[in] Pointer to Handler
659 * Post structure pointer
661 * @return ROK - success
664 * ****************************************************************/
665 uint8_t unpackMacDlCcchInd(DuMacDlCcchInd func, Pst *pst, Buffer *mBuf)
667 if(pst->selector == ODU_SELECTOR_LWLC)
669 DlCcchIndInfo *dlCcchIndInfo;
671 /* unpack the address of the structure */
672 CMCHKUNPK(oduUnpackPointer, (PTR *)&dlCcchIndInfo, mBuf);
673 ODU_PUT_MSG_BUF(mBuf);
674 return (*func)(pst, dlCcchIndInfo);
678 /* Nothing to do for other selectors */
679 DU_LOG("\n Only LWLC supported for DL CCCH Ind ");
680 ODU_PUT_MSG_BUF(mBuf);
686 /*******************************************************************
688 * @brief Packs and Sends UE create Request from DUAPP to MAC
692 * Function : packDuMacUeCreateReq
695 * Packs and Sends UE Create Request from DUAPP to MAC
698 * @params[in] Post structure pointer
700 * @return ROK - success
703 * ****************************************************************/
704 uint8_t packDuMacUeCreateReq(Pst *pst, MacUeCfg *ueCfg)
706 Buffer *mBuf = NULLP;
708 if(pst->selector == ODU_SELECTOR_LWLC)
710 if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
712 DU_LOG("\nMAC : Memory allocation failed at packDuMacUeCreateReq");
715 /* pack the address of the structure */
716 CMCHKPK(oduPackPointer,(PTR)ueCfg, mBuf);
720 DU_LOG("\nMAC: Only LWLC supported for packDuMacUeCreateReq");
724 return ODU_POST_TASK(pst,mBuf);
727 /*******************************************************************
729 * @brief Unpacks UE Create Request received from DU APP
733 * Function : unpackMacUeCreateReq
736 * Unpacks UE Create Request received from DU APP
738 * @params[in] Pointer to Handler
739 * Post structure pointer
741 * @return ROK - success
744 * ****************************************************************/
745 uint8_t unpackMacUeCreateReq(DuMacUeCreateReq func, Pst *pst, Buffer *mBuf)
747 if(pst->selector == ODU_SELECTOR_LWLC)
751 /* unpack the address of the structure */
752 CMCHKUNPK(oduUnpackPointer, (PTR *)&ueCfg, mBuf);
753 ODU_PUT_MSG_BUF(mBuf);
754 return (*func)(pst, ueCfg);
758 /* Nothing to do for other selectors */
759 DU_LOG("\n Only LWLC supported for UE Create Request ");
760 ODU_PUT_MSG_BUF(mBuf);
766 /*******************************************************************
768 * @brief Pack and send UE config response from MAC to DU APP
772 * Function : packDuMacUeCreateRsp
775 * Pack and send UE config response from MAC to DU APP
778 * @return ROK - success
781 * ****************************************************************/
782 uint8_t packDuMacUeCreateRsp(Pst *pst, MacUeCfgRsp *cfgRsp)
784 Buffer *mBuf = NULLP;
786 if(pst->selector == ODU_SELECTOR_LWLC)
788 if (ODU_GET_MSG_BUF(pst->region, pst->pool, &mBuf) != ROK)
790 DU_LOG("\nMAC : Memory allocation failed at packDuMacUeCfgRsp");
793 /* pack the address of the structure */
794 CMCHKPK(oduPackPointer,(PTR)cfgRsp, mBuf);
798 DU_LOG("\nMAC: Only LWLC supported for packDuMacUeCfgRsp");
802 return ODU_POST_TASK(pst,mBuf);
805 /*******************************************************************
807 * @brief Unpack UE Config Response from MAC to DU APP
811 * Function : unpackDuMacUeCreateRsp
813 * Functionality: Unpack UE Config Response from MAC to DU APP
816 * @return ROK - success
819 * ****************************************************************/
820 uint8_t unpackDuMacUeCreateRsp(DuMacUeCreateRspFunc func, Pst *pst, Buffer *mBuf)
822 if(pst->selector == ODU_SELECTOR_LWLC)
826 /* unpack the address of the structure */
827 CMCHKUNPK(oduUnpackPointer, (PTR *)&cfgRsp, mBuf);
828 ODU_PUT_MSG_BUF(mBuf);
829 return (*func)(pst, cfgRsp);
832 ODU_PUT_MSG_BUF(mBuf);
836 /**********************************************************************
838 **********************************************************************/