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"
24 #include "du_app_mac_inf.h"
26 /**************************************************************************
27 * @brief Function to pack Loose Coupled
28 * MAC cell config parameters required by MAC
32 * Function : packMacCellCfg
35 * packs the macCellCfg parameters
37 * @param[in] Pst *pst, Post structure of the primitive.
38 * @param[in] MacCellCfg *macCellCfg, mac cell config parameters.
39 * @return ROK - success
42 ***************************************************************************/
43 int packMacCellCfg(Pst *pst, MacCellCfg *macCellCfg)
45 if(pst->selector == ODU_SELECTOR_LC)
47 /* we are now implemented only light wieght lossely coupled interface */
50 else if(pst->selector == ODU_SELECTOR_LWLC)
54 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
59 /* pack the address of the structure */
60 CMCHKPK(cmPkPtr,(PTR)macCellCfg, mBuf);
62 DU_LOG("\nDU-APP : MAC CELL config sent");
63 return SPstTsk(pst,mBuf);
68 /**************************************************************************
69 * @brief Function to pack Loose Coupled
70 * MAC cell config parameters required by MAC
74 * Function : unpackDuMacCellCfg
77 * packs the macCellCfg parameters
79 * @param[in] DuMacCellCfgReq func; function pointer
80 * @param[in] Pst *pst, Post structure of the primitive.
81 * @param[in] Buffer *mBuf
82 * @return ROK - success
85 ***************************************************************************/
86 int unpackDuMacCellCfg(
92 MacCellCfg *macCellCfg;
94 if(pst->selector == ODU_SELECTOR_LWLC)
96 /* unpack the address of the structure */
97 CMCHKUNPK(cmUnpkPtr, (PTR *)&macCellCfg, mBuf);
98 ret = (*func)(pst, macCellCfg);
102 /* only LWLC is implemented now */
109 /**************************************************************************
110 * @brief Function to pack Loose Coupled
111 * MAC cell config confirm message
115 * Function : packMacCellCfgCfm
118 * packs the transaction ID
120 * @param[in] Pst *pst, Post structure of the primitive.
121 * @param[in] MacCellCfgCfm *macCellCfgCfm, mac cell config confirm.
122 * @return ROK - success
125 ***************************************************************************/
126 int packMacCellCfgCfm(Pst *pst, MacCellCfgCfm *macCellCfgCfm)
128 if(pst->selector == ODU_SELECTOR_LC)
130 Buffer *mBuf = NULLP;
131 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
136 /* pack the transaction ID in CNF structure */
137 CMCHKPK(SPkU8, macCellCfgCfm->rsp, mBuf);
138 CMCHKPK(SPkU16, macCellCfgCfm->transId, mBuf);
140 return SPstTsk(pst,mBuf);
142 else if(pst->selector == ODU_SELECTOR_LWLC)
144 /* only LC is supported */
150 /**************************************************************************
151 * @brief Function to pack MAC cell config confirm message
155 * Function : unpackMacCellCfgCfm
158 * packs the transaction ID
160 * @param[in] DuMacCellCfgCfm func; function pointer
161 * @param[in] Pst *pst, Post structure of the primitive.
162 * @param[in] Buffer *mBuf
163 * @return ROK - success
166 ***************************************************************************/
167 int unpackMacCellCfgCfm(
168 DuMacCellCfgCfm func,
172 MacCellCfgCfm macCellCfgCfm;
174 if(pst->selector == ODU_SELECTOR_LC)
176 /* unpack the transaction ID in CNF structure */
177 CMCHKUNPK(SUnpkU16, &(macCellCfgCfm.transId), mBuf);
178 CMCHKUNPK(SUnpkU8, &(macCellCfgCfm.rsp), mBuf);
180 return (*func)(pst, &macCellCfgCfm);
184 /* only loose coupling is suported */
189 /*******************************************************************
191 * @brief Packs and Send Cell Start Request to MAC
195 * Function : packMacCellStartReq
198 * Packs and Sends Cell Start Request to MAC
200 * @params[in] Post structure pointer
201 * MacCellStartInfo pointer
202 * @return ROK - success
205 * ****************************************************************/
206 uint16_t packMacCellStartReq(Pst *pst, MacCellStartInfo *cellStartInfo)
208 Buffer *mBuf = NULLP;
210 if(pst->selector == ODU_SELECTOR_LC)
212 /* Loose coupling not supported */
215 else if(pst->selector == ODU_SELECTOR_LWLC)
218 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
220 DU_LOG("\nDU APP : Memory allocation failed for cell start req pack");
224 /* pack the address of the structure */
225 CMCHKPK(cmPkPtr,(PTR)cellStartInfo, mBuf);
228 return SPstTsk(pst,mBuf);
231 /*******************************************************************
233 * @brief Unpacks MAC Cell Start Request from DU APP
237 * Function : unpackMaCellStartReq
240 * Unpacks MAC Cell Start Request from DU APP
242 * @params[in] Function pointer of cell start request handler
243 * Post structure pointer
244 * Cell Start Request Info Pointer
245 * @return ROK - success
248 * ****************************************************************/
249 uint16_t unpackMacCellStartReq(DuMacCellStartReq func, Pst *pst, Buffer *mBuf)
251 MacCellStartInfo *cellStartInfo;
253 if(pst->selector == ODU_SELECTOR_LWLC)
255 /* unpack the address of the structure */
256 CMCHKUNPK(cmUnpkPtr, (PTR *)&cellStartInfo, mBuf);
258 return (*func)(pst, cellStartInfo);
262 /* Nothing to do for loose coupling */
268 /*******************************************************************
270 * @brief Packs and Send cell stop request to MAC
274 * Function : packMacCellStopReq
277 * Packs and Send cell stop request to MAC
279 * @params[in] Post structure pointer
280 * Cell stop info structure
281 * @return ROK - success
284 * ****************************************************************/
285 uint16_t packMacCellStopReq(Pst *pst, MacCellStopInfo *cellStopInfo)
287 if(pst->selector == ODU_SELECTOR_LC)
289 /* Loose coupling not supported */
292 else if(pst->selector == ODU_SELECTOR_LWLC)
294 Buffer *mBuf = NULLP;
296 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
298 DU_LOG("\nDU APP : Memory allocation failed for cell stop req pack");
302 /* pack the address of the structure */
303 CMCHKPK(cmPkPtr,(PTR)cellStopInfo, mBuf);
305 return SPstTsk(pst,mBuf);
310 /*******************************************************************
312 * @brief Unpacks cell stop request from DU APP
316 * Function : unpackMaCellStopReq
319 * Unpacks cell stop request from DU APP
321 * @params[in] Handler function pointer
322 * Post structure pointer
324 * @return ROK - success
327 * ****************************************************************/
328 uint16_t unpackMacCellStopReq(DuMacCellStopReq func, Pst *pst, Buffer *mBuf)
330 MacCellStopInfo *cellStopInfo;
332 if(pst->selector == ODU_SELECTOR_LWLC)
334 /* unpack the address of the structure */
335 CMCHKUNPK(cmUnpkPtr, (PTR *)&cellStopInfo, mBuf);
337 return (*func)(pst, cellStopInfo);
341 /* Nothing to do for loose coupling */
347 /*******************************************************************
349 * @brief Packs and Sends slot ind from MAC to DUAPP
353 * Function : packMacSlotInd
356 * Packs and Sends slot ind from MAC to DUAPP
358 * @params[in] Post structure pointer
360 * @return ROK - success
363 * ****************************************************************/
364 uint16_t packMacSlotInd(Pst *pst, SlotInfo *slotInfo )
366 Buffer *mBuf = NULLP;
368 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
370 DU_LOG("\nDU APP : Memory allocation failed for cell start req pack");
374 if(pst->selector == ODU_SELECTOR_LC)
376 CMCHKPK(SPkU16, slotInfo->cellId, mBuf);
377 CMCHKPK(SPkU16, slotInfo->sfn, mBuf);
378 CMCHKPK(SPkU16, slotInfo->slot, mBuf);
380 CM_FREE_SHRABL_BUF(pst->region, pst->pool, slotInfo, sizeof(SlotInfo));
383 else if(pst->selector == ODU_SELECTOR_LWLC)
385 /* pack the address of the structure */
386 CMCHKPK(cmPkPtr,(PTR)slotInfo, mBuf);
393 return SPstTsk(pst,mBuf);
396 /*******************************************************************
398 * @brief Unpacks slot indication from MAC
402 * Function : unpackMacSlotInd
405 * Unpacks slot indication from MAC
407 * @params[in] Pointer to Handler
408 * Post structure pointer
410 * @return ROK - success
413 * ****************************************************************/
414 uint16_t unpackMacSlotInd(DuMacSlotInd func, Pst *pst, Buffer *mBuf)
416 if(pst->selector == ODU_SELECTOR_LWLC)
420 /* unpack the address of the structure */
421 CMCHKUNPK(cmUnpkPtr, (PTR *)&slotInfo, mBuf);
423 return (*func)(pst, slotInfo);
425 else if(pst->selector == ODU_SELECTOR_LC)
429 CMCHKUNPK(SUnpkU16, &(slotInfo.slot), mBuf);
430 CMCHKUNPK(SUnpkU16, &(slotInfo.sfn), mBuf);
431 CMCHKUNPK(SUnpkU16, &(slotInfo.cellId), mBuf);
434 return (*func)(pst, &slotInfo);
439 /* Nothing to do for loose coupling */
446 /*******************************************************************
448 * @brief Packs and Sends stop ind from MAC to DUAPP
452 * Function : packMacStopInd
455 * Packs and Sends stop ind from MAC to DUAPP
457 * @params[in] Post structure pointer
458 * @return ROK - success
461 * ****************************************************************/
462 uint16_t packMacStopInd(Pst *pst, MacCellStopInfo *cellStopId)
464 Buffer *mBuf = NULLP;
466 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
468 DU_LOG("\nDU APP : Memory allocation failed for stop Ind pack");
472 if(pst->selector == ODU_SELECTOR_LC)
474 /*pack the payload here*/
475 DU_LOG("\nDU APP : Packed CellId");
476 CMCHKPK(SPkU16, cellStopId->cellId, mBuf);
477 CM_FREE_SHRABL_BUF(pst->region, pst->pool, cellStopId, sizeof(MacCellStopInfo));
480 else if(pst->selector == ODU_SELECTOR_LWLC)
482 /* pack the address of the structure */
483 CMCHKPK(cmPkPtr,(PTR)cellStopId, mBuf);
490 return SPstTsk(pst,mBuf);
493 /*******************************************************************
495 * @brief Unpacks stop indication from MAC
499 * Function : unpackMacStopInd
502 * Unpacks stop indication from MAC
504 * @params[in] Pointer to Handler
505 * Post structure pointer
507 * @return ROK - success
510 * ****************************************************************/
511 uint16_t unpackMacStopInd(DuMacStopInd func, Pst *pst, Buffer *mBuf)
513 if(pst->selector == ODU_SELECTOR_LWLC)
515 MacCellStopInfo *cellStopId;
516 /* unpack the address of the structure */
517 CMCHKUNPK(cmUnpkPtr, (PTR *)&cellStopId, mBuf);
519 return (*func)(pst, cellStopId);
521 else if(pst->selector == ODU_SELECTOR_LC)
523 MacCellStopInfo cellStopId;
524 CMCHKUNPK(SUnpkU16, &(cellStopId.cellId), mBuf);
527 return (*func)(pst, &cellStopId);
532 /* Nothing to do for loose coupling */
539 /*******************************************************************
541 * @brief Packs and Sends UL CCCH Ind from MAC to DUAPP
545 * Function : packMacUlCcchInd
548 * Packs and Sends UL CCCH Ind from MAC to DUAPP
550 * @params[in] Post structure pointer
551 * UL CCCH Ind pointer
552 * @return ROK - success
555 * ****************************************************************/
556 uint16_t packMacUlCcchInd(Pst *pst, UlCcchIndInfo *ulCcchIndInfo)
558 Buffer *mBuf = NULLP;
560 if(pst->selector == ODU_SELECTOR_LWLC)
562 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
564 DU_LOG("\nMAC : Memory allocation failed at packMacUlCcchInd");
567 /* pack the address of the structure */
568 CMCHKPK(cmPkPtr,(PTR)ulCcchIndInfo, mBuf);
572 DU_LOG("\nMAC: Only LWLC supported for UL CCCH Ind ");
576 return SPstTsk(pst,mBuf);
579 /*******************************************************************
581 * @brief Unpacks UL CCCH indication from MAC
585 * Function : unpackMacUlCcchInd
588 * Unpacks UL CCCH indication from MAC
590 * @params[in] Pointer to Handler
591 * Post structure pointer
593 * @return ROK - success
596 * ****************************************************************/
597 uint16_t unpackMacUlCcchInd(DuMacUlCcchInd func, Pst *pst, Buffer *mBuf)
599 if(pst->selector == ODU_SELECTOR_LWLC)
601 UlCcchIndInfo *ulCcchIndInfo;
603 /* unpack the address of the structure */
604 CMCHKUNPK(cmUnpkPtr, (PTR *)&ulCcchIndInfo, mBuf);
606 return (*func)(pst, ulCcchIndInfo);
610 /* Nothing to do for other selectors */
611 DU_LOG("\n Only LWLC supported for UL CCCH Ind ");
617 /*******************************************************************
619 * @brief Packs and Sends DL CCCH Ind from DUAPP to MAC
623 * Function : packMacDlCcchInd
626 * Packs and Sends DL CCCH Ind from DUAPP to MAC
629 * @params[in] Post structure pointer
630 * DL CCCH Ind pointer
631 * @return ROK - success
634 * ****************************************************************/
635 uint16_t packMacDlCcchInd(Pst *pst, DlCcchIndInfo *dlCcchIndInfo)
637 Buffer *mBuf = NULLP;
639 if(pst->selector == ODU_SELECTOR_LWLC)
641 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
643 DU_LOG("\nMAC : Memory allocation failed at packMacDlCcchInd");
646 /* pack the address of the structure */
647 CMCHKPK(cmPkPtr,(PTR)dlCcchIndInfo, mBuf);
651 DU_LOG("\nDU APP: Only LWLC supported for DL CCCH Ind ");
655 return SPstTsk(pst,mBuf);
658 /*******************************************************************
660 * @brief Unpacks DL CCCH indication from DU APP
664 * Function : unpackMacDlCcchInd
667 * Unpacks DL CCCH indication from DU APP
669 * @params[in] Pointer to Handler
670 * Post structure pointer
672 * @return ROK - success
675 * ****************************************************************/
676 uint16_t unpackMacDlCcchInd(DuMacDlCcchInd func, Pst *pst, Buffer *mBuf)
678 if(pst->selector == ODU_SELECTOR_LWLC)
680 DlCcchIndInfo *dlCcchIndInfo;
682 /* unpack the address of the structure */
683 CMCHKUNPK(cmUnpkPtr, (PTR *)&dlCcchIndInfo, mBuf);
685 return (*func)(pst, dlCcchIndInfo);
689 /* Nothing to do for other selectors */
690 DU_LOG("\n Only LWLC supported for DL CCCH Ind ");
697 /*******************************************************************
699 * @brief Packs and Sends UE create Request from DUAPP to MAC
703 * Function : packDuMacUeCreateReq
706 * Packs and Sends UE Create Request from DUAPP to MAC
709 * @params[in] Post structure pointer
711 * @return ROK - success
714 * ****************************************************************/
715 uint8_t packDuMacUeCreateReq(Pst *pst, MacUeCfg *ueCfg)
717 Buffer *mBuf = NULLP;
719 if(pst->selector == ODU_SELECTOR_LWLC)
721 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
723 DU_LOG("\nMAC : Memory allocation failed at packDuMacUeCreateReq");
726 /* pack the address of the structure */
727 CMCHKPK(cmPkPtr,(PTR)ueCfg, mBuf);
731 DU_LOG("\nMAC: Only LWLC supported for packDuMacUeCreateReq");
735 return SPstTsk(pst,mBuf);
738 /*******************************************************************
740 * @brief Unpacks UE Create Request received from DU APP
744 * Function : unpackMacUeCreateReq
747 * Unpacks UE Create Request received from DU APP
749 * @params[in] Pointer to Handler
750 * Post structure pointer
752 * @return ROK - success
755 * ****************************************************************/
756 uint8_t unpackMacUeCreateReq(DuMacUeCreateReq func, Pst *pst, Buffer *mBuf)
758 if(pst->selector == ODU_SELECTOR_LWLC)
762 /* unpack the address of the structure */
763 CMCHKUNPK(cmUnpkPtr, (PTR *)&ueCfg, mBuf);
765 return (*func)(pst, ueCfg);
769 /* Nothing to do for other selectors */
770 DU_LOG("\n Only LWLC supported for UE Create Request ");
776 /**********************************************************************
778 **********************************************************************/