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 *******************************************************************************/
20 /************************************************************************
26 Desc: C source code for packing/unpacking of RGM interface
31 **********************************************************************/
34 @brief This file contains the packing/unpacking code for the RGM interface
38 /* header include files (.h) */
39 #include "common_def.h"
40 #include "rgm.h" /* RGM Interface defines */
41 /* header/extern include files (.x) */
42 #include "rgm.x" /* RGM Interface includes */
48 * @brief Request from RRM to MAC to bind the interface saps
52 * Function : cmPkLwLcRgmBndReq
55 * @param[in] SuId suId
56 * @param[in] SpId spId
69 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
74 if (SPkS16(spId, mBuf) != ROK)
80 if (SPkS16(suId, mBuf) != ROK)
86 pst->event = (Event) EVTRGMBNDREQ;
87 return (SPstTsk(pst,mBuf));
92 * @brief Request from RRM to MAC to bind the interface saps
96 * Function : cmUnpkLwLcRgmBndReq
99 * @param[in] SuId suId
100 * @param[in] SpId spId
104 S16 cmUnpkLwLcRgmBndReq
116 if (SUnpkS16(&suId, mBuf) != ROK)
122 if (SUnpkS16(&spId, mBuf) != ROK)
128 ret = ((*func)(pst, suId, spId));
136 * @brief Request from RRM to MAC to Unbind the interface saps
140 * Function : cmPkLwLcRgmUbndReq
142 * @param[in] Pst* pst
143 * @param[in] SpId spId
144 * @param[in] Reason reason
148 S16 cmPkLwLcRgmUbndReq
155 Buffer *mBuf = NULLP;
157 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
161 if (SPkS16(reason, mBuf) != ROK)
166 if (SPkS16(spId, mBuf) != ROK)
172 pst->event = (Event) EVTRGMUBNDREQ;
173 return (SPstTsk(pst,mBuf));
177 * @brief Confirmation from MAC to RRM for the bind/Unbind
178 * request for the interface saps
182 * Function : cmPkLwLcRgmBndCfm
184 * @param[in] Pst* pst
185 * @param[in] SuId suId
186 * @param[in] uint8_t status
190 S16 cmPkLwLcRgmBndCfm
197 Buffer *mBuf = NULLP;
199 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
204 if (SPkS16(suId, mBuf) != ROK)
210 if (oduUnpackUInt8(status, mBuf) != ROK)
216 pst->event = (Event) EVTRGMBNDCFM;
217 return (SPstTsk(pst,mBuf));
222 * @brief Confirmation from MAC to RRM for the bind/Unbind
223 * request for the interface saps
227 * Function : cmUnpkLwLcRgmBndCfm
229 * @param[in] Pst* pst
230 * @param[in] SuId suId
231 * @param[in] uint8_t status
235 S16 cmUnpkLwLcRgmBndCfm
246 if (oduPackUInt8(&status, mBuf) != ROK)
252 if (SUnpkS16(&suId, mBuf) != ROK)
258 return ((*func)(pst, suId, status));
263 * @brief Configure the PRB Report Preparation Start/Stop from RRM to MAC
267 * Function : cmPkLwLcRgmCfgPrbRprt
269 * @param[in] Pst* pst
270 * @param[in] SpId spId
271 * @param[in] RgmPrbRprtCfg * prbRprtCfg
275 S16 cmPkLwLcRgmCfgPrbRprt
279 RgmPrbRprtCfg * prbRprtCfg
282 Buffer *mBuf = NULLP;
283 uint32_t len = sizeof(RgmPrbRprtCfg);
285 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
287 SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)prbRprtCfg, sizeof(RgmPrbRprtCfg));
291 if(oduPackPointer((PTR)prbRprtCfg, mBuf) != ROK)
294 SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data*)prbRprtCfg, len);
298 if (SPkS16(spId, mBuf) != ROK)
300 SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)prbRprtCfg, sizeof(RgmPrbRprtCfg));
305 pst->event = (Event) EVTRGMCFGPRBRPRT;
306 return (SPstTsk(pst,mBuf));
311 * @brief Configure the PRB Report Preparation Start/Stop from RRM to MAC
315 * Function : cmUnpkLwLcRgmCfgPrbRprt
317 * @param[in] Pst* pst
318 * @param[in] SpId spId
319 * @param[in] RgmPrbRprtCfg * prbRprtCfg
323 S16 cmUnpkLwLcRgmCfgPrbRprt
325 RgmCfgPrbRprtFptr func,
332 RgmPrbRprtCfg *prbRprtCfg;
335 if (SUnpkS16(&spId, mBuf) != ROK)
341 if (oduUnpackPointer((PTR *)&prbRprtCfg, mBuf) != ROK)
344 SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)prbRprtCfg, sizeof(RgmPrbRprtCfg));
348 ret = ((*func)(pst, spId, prbRprtCfg));
356 * @brief PRB Usage Report Indication from MAC to RRM
360 * Function : cmPkLwLcRgmPrbRprtInd
362 * @param[in] Pst* pst
363 * @param[in] SuId suId
364 * @param[in] RgmPrbRprtInd * prbRprtInd
368 S16 cmPkLwLcRgmPrbRprtInd
372 RgmPrbRprtInd * prbRprtInd
375 Buffer *mBuf = NULLP;
378 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
379 SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)prbRprtInd, sizeof(RgmPrbRprtInd));
383 if(oduPackPointer((PTR)prbRprtInd, mBuf) != ROK)
385 SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)prbRprtInd, sizeof(RgmPrbRprtInd));
390 if (SPkS16(suId, mBuf) != ROK)
392 SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)prbRprtInd, sizeof(RgmPrbRprtInd));
397 pst->event = (Event) EVTRGMCFGPRBRPRT;
398 return (SPstTsk(pst,mBuf));
403 * @brief PRB Usage Report Indication from MAC to RRM
407 * Function : cmUnpkLwLcRgmPrbRprtInd
409 * @param[in] Pst* pst
410 * @param[in] SuId suId
411 * @param[in] RgmPrbRprtInd * prbRprtInd
415 S16 cmUnpkLwLcRgmPrbRprtInd
417 RgmPrbRprtIndFptr func,
423 RgmPrbRprtInd *prbRprtInd;
427 if (SUnpkS16(&suId, mBuf) != ROK)
433 if (oduUnpackPointer((PTR *)&prbRprtInd, mBuf) != ROK)
436 SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)prbRprtInd, sizeof(RgmPrbRprtInd));
441 ret = ((*func)(pst, suId, prbRprtInd));
451 * @brief Request from RRM to MAC to bind the interface saps
455 * Function : cmPkRgmBndReq
457 * @param[in] Pst* pst
458 * @param[in] SuId suId
459 * @param[in] SpId spId
470 Buffer *mBuf = NULLP;
472 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
477 if (SPkS16(spId, mBuf) != ROK)
483 if (SPkS16(suId, mBuf) != ROK)
489 pst->event = (Event) EVTRGMBNDREQ;
490 return (SPstTsk(pst,mBuf));
495 * @brief Request from RRM to MAC to bind the interface saps
499 * Function : cmUnpkRgmBndReq
501 * @param[in] Pst* pst
502 * @param[in] SuId suId
503 * @param[in] SpId spId
519 if (SUnpkS16(&suId, mBuf) != ROK)
525 if (SUnpkS16(&spId, mBuf) != ROK)
531 ret = ((*func)(pst, suId, spId));
539 * @brief Request from RRM to MAC to Unbind the interface saps
543 * Function : cmPkRgmUbndReq
545 * @param[in] Pst* pst
546 * @param[in] SpId spId
547 * @param[in] Reason reason
558 Buffer *mBuf = NULLP;
560 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
564 if (SPkS16(reason, mBuf) != ROK)
569 if (SPkS16(spId, mBuf) != ROK)
575 pst->event = (Event) EVTRGMUBNDREQ;
576 return (SPstTsk(pst,mBuf));
582 * @brief Request from RRM to MAC to Unbind the interface saps
586 * Function : cmUnpkRgmUbndReq
588 * @param[in] Pst* pst
589 * @param[in] SpId spId
590 * @param[in] Reason reason
605 if (SUnpkS16(&spId, mBuf) != ROK)
610 if (SUnpkS16(&reason, mBuf) != ROK)
616 return ((*func)(pst, spId, reason));
621 * @brief Confirmation from MAC to RRM for the bind/Unbind
622 * request for the interface saps
626 * Function : cmPkRgmBndCfm
628 * @param[in] Pst* pst
629 * @param[in] SuId suId
630 * @param[in] uint8_t status
641 Buffer *mBuf = NULLP;
643 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
648 if (SPkS16(suId, mBuf) != ROK)
654 if (oduUnpackUInt8(status, mBuf) != ROK)
660 pst->event = (Event) EVTRGMBNDCFM;
661 return (SPstTsk(pst,mBuf));
666 * @brief Confirmation from MAC to RRM for the bind/Unbind
667 * request for the interface saps
671 * Function : cmUnpkRgmBndCfm
673 * @param[in] Pst* pst
674 * @param[in] SuId suId
675 * @param[in] uint8_t status
690 if (oduPackUInt8(&status, mBuf) != ROK)
696 if (SUnpkS16(&suId, mBuf) != ROK)
702 return ((*func)(pst, suId, status));
709 * @brief Configure the PRB Report Preparation Start/Stop from RRM to MAC
713 * Function : cmPkCfgPrbRprt
715 * @param[in] RgmPrbRprtCfg *prbRprtCfg
716 * @param[in] Buffer *mBuf
722 RgmPrbRprtCfg * prbRprtCfg,
726 CMCHKPK(oduUnpackUInt16, prbRprtCfg->usPrbAvgPeriodicty, mBuf);
727 CMCHKPK(oduUnpackUInt8, prbRprtCfg->bConfigType, mBuf);
728 CMCHKPK(oduUnpackUInt8, prbRprtCfg->bCellId, mBuf);
732 * @brief Configure the PRB Report Preparation Start/Stop from RRM to MAC
736 * Function : cmUnPkCfgPrbRprt
738 * @param[in] RgmPrbRprtCfg *prbRprtCfg
739 * @param[in] Buffer *mBuf
745 RgmPrbRprtCfg * prbRprtCfg,
749 CMCHKUNPK(oduPackUInt8, &prbRprtCfg->bCellId, mBuf);
750 CMCHKUNPK(oduPackUInt8, &prbRprtCfg->bConfigType, mBuf);
751 CMCHKUNPK(oduPackUInt16, &prbRprtCfg->usPrbAvgPeriodicty, mBuf);
759 * @brief Configure the PRB Report Preparation Start/Stop from RRM to MAC
763 * Function : cmPkRgmCfgPrbRprt
765 * @param[in] Pst* pst
766 * @param[in] SpId spId
767 * @param[in] RgmPrbRprtCfg *prbRprtCfg
771 S16 cmPkRgmCfgPrbRprt
775 RgmPrbRprtCfg * prbRprtCfg
778 Buffer *mBuf = NULLP;
779 uint32_t len = sizeof(RgmPrbRprtCfg);
781 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK)
783 SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)prbRprtCfg, sizeof(RgmPrbRprtCfg));
787 if(cmPkCfgPrbRprt(prbRprtCfg, mBuf) != ROK)
790 SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data*)prbRprtCfg, len);
794 if (SPkS16(spId, mBuf) != ROK)
796 SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)prbRprtCfg, sizeof(RgmPrbRprtCfg));
801 SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)prbRprtCfg, sizeof(RgmPrbRprtCfg));
803 pst->event = (Event) EVTRGMCFGPRBRPRT;
804 return (SPstTsk(pst,mBuf));
810 * @brief Configure the PRB Report Preparation Start/Stop from RRM to MAC
814 * Function : cmUnpkRgmCfgPrbRprt
816 * @param[in] Pst* pst
817 * @param[in] SpId spId
818 * @param[in] RgmPrbRprtCfg * prbRprtCfg
822 S16 cmUnpkRgmCfgPrbRprt
824 RgmCfgPrbRprtFptr func,
830 RgmPrbRprtCfg *prbRprtCfg;
832 if ((SGetSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data **)&prbRprtCfg, sizeof(RgmPrbRprtCfg))) != ROK)
838 if (SUnpkS16(&spId, mBuf) != ROK)
844 if (cmUnPkCfgPrbRprt(prbRprtCfg, mBuf) != ROK)
851 return ((*func)(pst, spId, prbRprtCfg));
856 * @brief Packing of PRB Usage Report for qci for sending
861 * Function : cmPkRgmPrbQciRpt
863 * @param[in] RgmPrbRptPerQci * qciPrbRprt
864 * @param[out] Buffer *mBuf
870 RgmPrbRptPerQci *qciPrbRprt,
874 CMCHKPK(oduUnpackUInt8, qciPrbRprt->bQci, mBuf);
875 CMCHKPK(oduUnpackUInt8, qciPrbRprt->bAvgPrbUlUsage, mBuf);
876 CMCHKPK(oduUnpackUInt8, qciPrbRprt->bAvgPrbDlUsage, mBuf);
882 * @brief Unpacking of PRB Usage Report for qci received from MAC
886 * Function : cmUnpkRgmPrbQciRpt
888 * @param[out] RgmPrbRptPerQci * qciPrbRprt
889 * @param[in] Buffer *mBuf
893 S16 cmUnpkRgmPrbQciRpt
895 RgmPrbRptPerQci *qciPrbRprt,
899 CMCHKUNPK(oduPackUInt8, &qciPrbRprt->bAvgPrbDlUsage, mBuf);
900 CMCHKUNPK(oduPackUInt8, &qciPrbRprt->bAvgPrbUlUsage, mBuf);
901 CMCHKUNPK(oduPackUInt8, &qciPrbRprt->bQci, mBuf);
908 * @brief PRB Usage Report Indication from MAC to RRM
912 * Function : cmPkPrbRprtInd
914 * @param[in] RgmPrbRprtInd * prbRprtInd
915 * @param[in] Buffer *mBuf
921 RgmPrbRprtInd * prbRprtInd,
929 for(idx = RGM_MAX_QCI_REPORTS-1; idx >= 0; idx--)
931 CMCHKPK(cmPkRgmPrbQciRpt, &prbRprtInd->stQciPrbRpts[idx], mBuf);
933 CMCHKPK(oduUnpackUInt8, prbRprtInd->bPrbUsageMask, mBuf);
934 CMCHKPK(oduUnpackUInt8, prbRprtInd->bCellId, mBuf);
940 * @brief PRB Usage Report Indication from MAC to RRM
944 * Function : cmUnpkPrbRprtInd
946 * @param[in] RgmPrbRprtInd * prbRprtInd
947 * @param[in] Buffer *mBuf
953 RgmPrbRprtInd * prbRprtInd,
961 CMCHKUNPK(oduPackUInt8, &prbRprtInd->bCellId, mBuf);
962 CMCHKUNPK(oduPackUInt8, &prbRprtInd->bPrbUsageMask, mBuf);
963 for(idx = 0; idx < RGM_MAX_QCI_REPORTS; idx++)
965 CMCHKUNPK(cmUnpkRgmPrbQciRpt, &prbRprtInd->stQciPrbRpts[idx], mBuf);
975 * @brief PRB Usage Report Indication from MAC to RRM
979 * Function : cmPkRgmPrbRprtInd
981 * @param[in] Pst* pst
982 * @param[in] SuId suId
983 * @param[in] RgmPrbRprtInd * prbRprtInd
987 S16 cmPkRgmPrbRprtInd
991 RgmPrbRprtInd * prbRprtInd
994 Buffer *mBuf = NULLP;
997 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
998 SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)prbRprtInd, sizeof(RgmPrbRprtInd));
1002 if(cmPkPrbRprtInd(prbRprtInd, mBuf) != ROK)
1004 SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)prbRprtInd, sizeof(RgmPrbRprtInd));
1009 if (SPkS16(suId, mBuf) != ROK)
1011 SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)prbRprtInd, sizeof(RgmPrbRprtInd));
1016 SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)prbRprtInd, sizeof(RgmPrbRprtInd));
1018 pst->event = (Event) EVTRGMPRBRPRTIND;
1019 return (SPstTsk(pst,mBuf));
1022 * @brief PRB Usage Report Indication from MAC to RRM
1026 * Function : cmUnpkRgmPrbRprtInd
1028 * @param[in] Pst* pst
1029 * @param[in] SuId suId
1030 * @param[in] RgmPrbRprtInd * prbRprtInd
1034 S16 cmUnpkRgmPrbRprtInd
1036 RgmPrbRprtIndFptr func,
1042 RgmPrbRprtInd prbRprtInd;
1045 if (SUnpkS16(&suId, mBuf) != ROK)
1051 if (cmUnpkPrbRprtInd(&prbRprtInd, mBuf) != ROK)
1058 return ((*func)(pst, suId, &prbRprtInd));
1062 * @brief Transmission Mode Change Indication from MAC to RRM
1066 * Function : cmPkTransModeInd
1068 * @param[in] RgmTransModeInd *transModeInd
1069 * @param[in] Buffer *mBuf
1073 S16 cmPkTransModeInd
1075 RgmTransModeInd *transModeInd,
1079 CMCHKPK(oduUnpackUInt32, transModeInd->eMode, mBuf);
1080 CMCHKPK(oduUnpackUInt16, transModeInd->usCrnti, mBuf);
1081 CMCHKPK(oduUnpackUInt8, transModeInd->bCellId, mBuf);
1086 * @brief Transmission Mode Change Indication from MAC to RRM
1090 * Function : cmUnpkTransModeInd
1092 * @param[in] RgmTransModeInd *transModeInd
1093 * @param[in] Buffer *mBuf
1097 S16 cmUnpkTransModeInd
1099 RgmTransModeInd *transModeInd,
1103 uint32_t tmpModeEnum;
1104 CMCHKUNPK(oduPackUInt8, &transModeInd->bCellId, mBuf);
1105 CMCHKUNPK(oduPackUInt16, &transModeInd->usCrnti, mBuf);
1106 CMCHKUNPK(oduPackUInt32, (uint32_t *)&tmpModeEnum, mBuf);
1107 transModeInd->eMode = (RgmTxnMode)tmpModeEnum;
1111 * @brief Transmission Mode Change Indication from MAC to RRM
1115 * Function : cmPkRgmTransModeInd
1117 * @param[in] Pst* pst
1118 * @param[in] SuId suId
1119 * @param[in] RgmTransModeInd *transModeInd
1124 S16 cmPkRgmTransModeInd
1128 RgmTransModeInd *transModeInd
1131 Buffer *mBuf = NULLP;
1134 if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) {
1135 SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)transModeInd, sizeof(RgmTransModeInd));
1139 if(cmPkTransModeInd(transModeInd, mBuf) != ROK)
1141 SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)transModeInd, sizeof(RgmTransModeInd));
1146 if (SPkS16(suId, mBuf) != ROK)
1148 SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)transModeInd, sizeof(RgmTransModeInd));
1153 SPutSBufNewForDebug(__FILE__,__FUNCTION__,__LINE__,pst->region, pst->pool, (Data *)transModeInd, sizeof(RgmTransModeInd));
1155 pst->event = (Event) EVTRGMTRANSMODEIND;
1156 return (SPstTsk(pst,mBuf));
1159 * @brief Transmission Mode Change Indication from MAC to RRM
1163 * Function : cmUnpkRgmTransModeInd
1165 * @param[in] Pst* pst
1166 * @param[in] SuId suId
1167 * @param[in] RgmTransModeInd *transModeInd
1171 S16 cmUnpkRgmTransModeInd
1173 RgmTransModeIndFptr func,
1179 RgmTransModeInd transModeInd;
1182 if (SUnpkS16(&suId, mBuf) != ROK)
1188 if (cmUnpkTransModeInd(&transModeInd, mBuf) != ROK)
1195 return ((*func)(pst, suId, &transModeInd));
1197 /**********************************************************************
1201 **********************************************************************/