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 /************************************************************************
25 Desc: C source code for Entry point fucntions
29 **********************************************************************/
32 @brief This file implements utility functions for LTE MAC
36 /* header include files (.h) */
37 #include "common_def.h"
38 #include "rg_env.h" /* MAC Environment Defines */
39 #include "crg.h" /* CRG Interface defines */
40 #include "rgu.h" /* RGU Interface defines */
41 #include "tfu.h" /* TFU Interface defines */
42 #include "rg_sch_inf.h" /* RGR Interface defines */
43 #include "lrg.h" /* LRG Interface defines */
44 #include "mac_utils.h"
46 #include "rg_prg.h" /* PRG(MAC-MAC) Interface includes */
47 #include "rg.h" /* MAC defines */
48 #include "rg_err.h" /* MAC error defines */
50 /* header/extern include files (.x) */
51 #include "cm5.x" /* Timer */
53 #include "crg.x" /* CRG Interface includes */
54 #include "rgu.x" /* RGU Interface includes */
55 #include "tfu.x" /* TFU Interface includes */
56 #include "rg_sch_inf.x" /* RGR Interface includes */
57 #include "lrg.x" /* LRG Interface includes */
58 #include "rg_prg.x" /* PRG(MAC-MAC) Interface includes */
60 #include "du_app_mac_inf.h"
61 #include "rg.x" /* MAC includes */
64 #define RG_NON_MIMO_IDX 0
70 /* forward references */
71 static S16 rgUtlHndlCrntiChng ARGS((
77 static Void rgUtlHndlCrntiRls ARGS((
82 S16 rgDelUeFrmAllSCell ARGS((
88 static S16 rgUtlSndCrntiChngReq2AllSMacs ARGS((
94 /***********************************************************
96 * Func : rgAllocShrablSBuf
98 * Desc : Utility Function to Allocate static buffer which is
99 * sharable among different layers if YYYY flag is enabled.
100 * else it allocates from normal static region
101 * Memory allocated is assumed contiguous.
107 * Notes: Caller doesnt need to raise the alarm in case of memory
108 * allocation gets failed.
112 **********************************************************/
113 S16 rgAllocShrablSBuf
116 Data **pData, /* Pointer of the data to be returned */
120 RgUstaDgn dgn; /* Alarm diagnostics structure */
122 /* Initialize the param to NULLP */
130 /* allocate buffer */
131 MAC_ALLOC_SHRABL_BUF(pData, size);
134 dgn.type = LRG_USTA_DGNVAL_MEM;
135 dgn.u.mem.region = rgCb[inst].rgInit.region;
136 dgn.u.mem.pool = rgCb[inst].rgInit.pool;
137 /* Send an alarm to Layer Manager */
138 rgLMMStaInd(inst,LCM_CATEGORY_RESOURCE, LCM_EVENT_SMEM_ALLOC_FAIL,
139 LCM_CAUSE_MEM_ALLOC_FAIL, &dgn);
140 DU_LOG("\nERROR --> MAC : Unable to Allocate Buffer");
145 DU_LOG("\nDEBUG --> MAC : MAC_ALLOC(Region (%d), Pool (%d), Size (%ld)), Data (0x%p))\n",
146 rgCb[inst].rgInit.region, rgCb[inst].rgInit.pool, size, *pData);
148 DU_LOG("\nDEBUG --> MAC : MAC_ALLOC(Region (%d), Pool (%d), Size (%d)), Data (0x%p))\n",
149 rgCb[inst].rgInit.region, rgCb[inst].rgInit.pool, size, *pData);
152 /* zero out the allocated memory */
153 memset(*pData, 0x00, size);
157 } /* end of rgAllocSBuf */
160 /***********************************************************
164 * Desc : Utility Function to Allocate static buffer.
165 * Memory allocated is assumed contiguous.
171 * Notes: Caller doesnt need to raise the alarm in case of memory
172 * allocation gets failed.
176 **********************************************************/
180 Data **pData, /* Pointer of the data to be returned */
184 RgUstaDgn dgn; /* Alarm diagnostics structure */
186 /* Initialize the param to NULLP */
194 /* allocate buffer */
195 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
196 MS_BUF_ADD_ALLOC_CALLER();
198 MAC_ALLOC(pData, size);
201 dgn.type = LRG_USTA_DGNVAL_MEM;
202 dgn.u.mem.region = rgCb[inst].rgInit.region;
203 dgn.u.mem.pool = rgCb[inst].rgInit.pool;
204 /* Send an alarm to Layer Manager */
205 rgLMMStaInd(inst,LCM_CATEGORY_RESOURCE, LCM_EVENT_SMEM_ALLOC_FAIL,
206 LCM_CAUSE_MEM_ALLOC_FAIL, &dgn);
207 DU_LOG("\nERROR --> MAC : Unable to Allocate Buffer");
211 /* zero out the allocated memory */
212 memset(*pData, 0x00, size);
216 } /* end of rgAllocSBuf */
220 * Fun: rgFreeSharableSBuf
222 * Desc: The argument to rgFreeSBuf() is a pointer to a block
223 * previously allocated by rgAllocSBuf() and size. It
224 * deallocates the memory.
228 * Notes: ccpu00117052 - MOD- changed the Data parameter from
229 * pointer to address of pointer so that
230 * the freed memory could be set to NULLP
234 Void rgFreeSharableSBuf
237 Data **data, /* address of pointer to data */
242 if ((data == NULLP) || (*data == NULLP) || (size == 0))
247 /* Deallocate buffer */
248 MAC_FREE_SHRABL_BUF(rgCb[inst].rgInit.region, rgCb[inst].rgInit.pool, *data, size);
259 } /* end of rgFreeSharableBuf */
267 * Desc: The argument to rgFreeSBuf() is a pointer to a block
268 * previously allocated by rgAllocSBuf() and size. It
269 * deallocates the memory.
273 * Notes: ccpu00117052 - MOD- changed the Data parameter from
274 * pointer to address of pointer so that
275 * the freed memory could be set to NULLP
282 Data **data, /* address of pointer to data */
287 if ((data == NULLP) || (*data == NULLP) || (size == 0))
293 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
296 /* Deallocate buffer */
297 MAC_FREE(data, size);
301 DU_LOG("\nERROR --> MAC : rgFreeSBuf failed.\n");
309 } /* end of rgFreeSBuf */
312 /***********************************************************
316 * Desc : Utility Function to Allocate message buffer.
322 * Notes: Caller doesnt need to raise the alarm in case of memory
323 * allocation gets failed.
327 **********************************************************/
331 Buffer **mBuf /* Message Buffer pointer be returned */
336 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
337 MS_BUF_ADD_ALLOC_CALLER();
339 ret = ODU_GET_MSG_BUF(RG_GET_MEM_REGION(rgCb[inst]), RG_GET_MEM_POOL(rgCb[inst]), mBuf);
343 /* Moving diagnostics structure to limited scope for optimization */
344 RgUstaDgn dgn; /* Alarm diagnostics structure */
346 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
348 /* Send an alarm to Layer Manager */
349 rgLMMStaInd(inst,LCM_CATEGORY_RESOURCE, LCM_EVENT_DMEM_ALLOC_FAIL,
350 LCM_CAUSE_MEM_ALLOC_FAIL, &dgn);
351 DU_LOG("\nERROR --> MAC : Unable to Allocate Buffer");
357 } /* end of rgGetMsg */
360 /***********************************************************
362 * Func : rgFillDgnParams
364 * Desc : Utility Function to Fill Diagonostic params.
372 **********************************************************/
383 case LRG_USTA_DGNVAL_MEM:
384 dgn->type = (uint8_t) LRG_USTA_DGNVAL_MEM;
385 dgn->u.mem.region = rgCb[inst].rgInit.region;
386 dgn->u.mem.pool = rgCb[inst].rgInit.pool;
394 } /* end of rgFillDgnParams */
397 /***********************************************************
399 * Func : rgUpdtRguDedSts
401 * Desc : Utility Function to update rgu sap statistics for dedicated
412 **********************************************************/
417 uint8_t stsType, /* Statistics type to update */
418 RgRguDedDatReq *datReq /* DatReq pointer */
426 case RG_RGU_SDU_RCVD:
427 for(idx = 0; idx < datReq->nmbOfUeGrantPerTti; idx++)
429 RguDDatReqPerUe *datReqPerUe = &datReq->datReq[idx];
430 for (idx1 = 0; idx1 < datReqPerUe->nmbOfTbs; idx1++)
432 for(idx2 = 0; idx2 < datReqPerUe->datReqTb[idx1].nmbLch; idx2++)
434 rguDlSap->sapSts.numPduRcvd +=
435 datReqPerUe->datReqTb[idx1].lchData[idx2].pdu.numPdu;
441 case RG_RGU_SDU_DROP:
442 for(idx = 0; idx < datReq->nmbOfUeGrantPerTti; idx++)
444 RguDDatReqPerUe *datReqPerUe = &datReq->datReq[idx];
445 for (idx1 = 0; idx1 < datReqPerUe->nmbOfTbs; idx1++)
447 for(idx2 = 0; idx2 < datReqPerUe->datReqTb[idx1].nmbLch; idx2++)
449 rguDlSap->sapSts.numPduRcvd +=
450 datReqPerUe->datReqTb[idx1].lchData[idx2].pdu.numPdu;
451 rguDlSap->sapSts.numPduDrop +=
452 datReqPerUe->datReqTb[idx1].lchData[idx2].pdu.numPdu;
461 } /* rgUpdtRguDedSts */
464 /***********************************************************
466 * Func : rgUpdtRguCmnSts
468 * Desc : Utility Function to update rgu sap statistics for common
479 **********************************************************/
484 uint8_t stsType /* Statistics type to update */
490 case RG_RGU_SDU_RCVD:
491 rguDlSap->sapSts.numPduRcvd ++;
493 case RG_RGU_SDU_DROP:
494 rguDlSap->sapSts.numPduRcvd ++;
495 rguDlSap->sapSts.numPduDrop ++;
500 } /* rgUpdtRguCmnSts */
503 /***********************************************************
505 * Func : rgUpdtCellCnt
507 * Desc : Utility Function to update cell count. It gives number of active
514 * Notes: This function should be called only after cell is added/deleted
515 * from the globlal hashlist
519 **********************************************************/
520 Void rgUpdtCellCnt(Inst inst,uint8_t updtType)
526 rgCb[inst].genSts.numCellCfg++;
529 rgCb[inst].genSts.numCellCfg--;
536 } /* rgUpdtCellCnt */
539 /***********************************************************
543 * Desc : Utility Function to update ue count. It gives number of active
550 * Notes: This function should be called only after ue is added/deleted
551 * from the globlal hashlist
555 **********************************************************/
556 Void rgUpdtUeCnt(Inst inst,uint8_t updtType)
561 rgCb[inst].genSts.numUeCfg++;
564 rgCb[inst].genSts.numUeCfg--;
574 * Fun: rgAllocEventMem
576 * Desc: This function allocates event memory
578 * Ret: ROK - on success
579 * RFAILED - on failure
594 volatile uint32_t startTime=0;
597 sMem.region = rgCb[inst].rgInit.region;
598 sMem.pool = rgCb[inst].rgInit.pool;
600 #if (ERRCLASS & ERRCLS_DEBUG)
603 DU_LOG("\nERROR --> MAC : rgAllocEventMem(): memSize invalid\n");
606 #endif /* ERRCLASS & ERRCLS_DEBUG */
610 SStartTask(&startTime, PID_MACUTL_CMALLCEVT);
612 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
613 MS_BUF_ADD_ALLOC_CALLER();
615 #ifdef TFU_ALLOC_EVENT_NO_INIT
616 if(ROK != cmAllocEvntNoInit(memSize, TFU_MAX_MEMBLK_SIZE, &sMem, memPtr))
618 if(ROK != cmAllocEvnt(memSize, TFU_MAX_MEMBLK_SIZE, &sMem, memPtr))
621 DU_LOG("\nERROR --> MAC : cmAllocEvnt Failed");
626 SStopTask(startTime, PID_MACUTL_CMALLCEVT);
629 } /* end of rgAllocEventMem*/
635 * Desc: This function allocates event memory
637 * Ret: ROK - on success
638 * RFAILED - on failure
655 #ifdef TFU_ALLOC_EVENT_NO_INIT
656 ret = cmGetMemNoInit(memCp, len, (Ptr *)ptr);
658 ret = cmGetMem(memCp, len, (Ptr *)ptr);
661 } /* end of rgGetEventMem*/
663 /***********************************************************
665 * Func : rgGetPstToInst
667 * Desc : Utility Function to get the pst structure to post a message to
674 * Notes: This function should be called while sending a msg from
675 * MAC to a scheduler instance
679 **********************************************************/
688 pst->srcEnt = rgCb[srcInst].rgInit.ent;
689 pst->srcInst = rgCb[srcInst].rgInit.inst;
690 pst->srcProcId = rgCb[srcInst].rgInit.procId;
691 pst->region = rgCb[srcInst].rgInit.region;
692 pst->pool = rgCb[srcInst].rgInit.pool;
694 pst->dstProcId = rgCb[dstInst].rgInit.procId;
695 pst->dstEnt = rgCb[dstInst].rgInit.ent;
696 pst->dstInst = dstInst;
700 pst->route = RTESPEC;
703 } /* end of rgGetPstToInst */
705 /***********************************************************
707 * Func : RgSchMacLcgRegReq
709 * Desc : Utility Function to register the set of GBR LCG.
710 * Invoked at the time of LCG configuration/Reconfiguration at Schedular.
713 * - Fetch the ueCb using the crnti given in lcInfo
714 * - Store the if LCG is GBR or not.
719 * Notes: This function should be called at the time of LCG
720 * configuration/Reconfiguration at Schedular.
725 **********************************************************/
726 S16 RgSchMacLcgRegReq(Pst *pst,RgInfLcgRegReq *lcgRegReq)
729 RgCellCb *cell = NULLP;
732 RG_IS_INST_VALID(pst->dstInst);
733 inst = pst->dstInst - RG_INST_START;
734 cell = rgCb[inst].cell;
735 /* Fetch the cell and then the UE */
736 if((cell == NULLP) ||
737 (cell->cellId != lcgRegReq->cellId))
740 DU_LOG("\nERROR --> MAC : Cell does not exist ");
744 if ((ue = rgDBMGetUeCb(cell, lcgRegReq->crnti)) == NULLP)
746 DU_LOG("\nERROR --> MAC : CRNTI:%d does not exist",
750 ue->ul.lcgArr[lcgRegReq->lcgId].isGbr = lcgRegReq->isGbr;
753 } /* end of RgSchMacLcgRegReq */
757 /***********************************************************
759 * Func : RgSchMacUlSpsResetReq
761 * Desc : Utility Function to reset SPS params for a UE
764 * - Fetch the ueCb using the crnti
765 * - reset implRelCnt and explRelCnt
772 **********************************************************/
773 S16 RgSchMacUlSpsResetReq(Pst *pst,RgInfUlSpsReset *ulSpsResetInfo)
776 RgCellCb *cell = NULLP;
779 RG_IS_INST_VALID(pst->dstInst);
780 inst = pst->dstInst - RG_INST_START;
781 cell = rgCb[inst].cell;
782 /* Fetch the cell and then the UE */
784 (cell->cellId != ulSpsResetInfo->cellId))
787 DU_LOG("\nERROR --> MAC : Cell does not exist ");
791 if ((ue = rgDBMGetUeCb(cell, ulSpsResetInfo->crnti)) == NULLP)
793 DU_LOG("\nERROR --> MAC : CRNTI:%d does not exist",
794 ulSpsResetInfo->crnti);
798 ue->ul.implRelCntr = 0;
799 ue->ul.explRelCntr = 0;
802 } /* end of RgSchMacUlSpsResetReq */
807 /***********************************************************
809 * Func : RgSchMacSpsLcRegReq
811 * Desc : Utility Function to register the set of uplink SPS logical
812 * channels for a SPS UE.
813 * Invoked at the time of activation of a UE for UL-SPS.
814 * Whenever there is data on these LCs MAC shall inform scheduler
817 * - Fetch the ueCb using the crnti given in lcInfo
818 * - Store the sps-rnti and set the bits corresponding to the
819 * logical channel ids in ueUlCb->spsLcMask.
824 * Notes: This function should be called at the time UL SPS is activated
825 * for a UE at scheduler
830 **********************************************************/
831 S16 RgSchMacSpsLcRegReq(Pst *pst,RgInfSpsLcInfo *lcInfo)
834 RgCellCb *cell= NULLP;
838 RG_IS_INST_VALID(pst->dstInst);
839 inst = pst->dstInst - RG_INST_START;
840 cell = rgCb[inst].cell;
841 /* Fetch the cell and then the UE */
842 if((cell == NULLP) ||
843 (cell->cellId != lcInfo->cellId))
846 DU_LOG("\nERROR --> MAC : Cell does not exist ");
850 if ((ue = rgDBMGetUeCb(cell, lcInfo->crnti)) == NULLP)
852 DU_LOG("\nERROR --> MAC : CRNTI:%d does not exist",
857 /* Store the sps-rnti and SPS LC information in the UE */
858 ue->spsRnti = lcInfo->spsRnti;
859 for (idx=0; idx < lcInfo->spsLcCnt; idx++)
861 /* KWORK_FIX: Modified the index from lcId to lcId-1 for handling lcId 10 properly */
862 ue->ul.spsLcId[(lcInfo->spsLcId[idx])-1] = TRUE;
864 ue->ul.implRelCnt = lcInfo->implRelCnt;
865 ue->ul.explRelCnt = ue->ul.implRelCnt + 1; /*(lcInfo->implRelCnt * lcInfo->spsPrd);*/
867 /* Insert the UE into SPS UE List */
868 if (rgDBMInsSpsUeCb(cell, ue) == RFAILED)
870 DU_LOG("\nERROR --> MAC : Ue insertion into SPS list failed SPS CRNTI:%d", ue->spsRnti);
875 } /* end of RgSchMacSpsLcRegReq */
878 /***********************************************************
880 * Func : RgSchMacSpsLcDeregReq
882 * Desc : Utility Function to deregister the set of uplink SPS
883 * logical channels for a UE.
884 * Invoked at the time of release of UL-SPS for an activated UE.
887 * - Fetch the ueCb using the crnti given
888 * - Reset the bits corresponding to the logical channel ids in
894 * Notes: This function should be called at the time UL SPS is released
895 * for a UE at scheduler
900 **********************************************************/
901 S16 RgSchMacSpsLcDeregReq(Pst *pst,CmLteCellId cellId,CmLteRnti crnti)
904 RgCellCb *cell = NULLP;
907 RG_IS_INST_VALID(pst->dstInst);
908 inst = pst->dstInst - RG_INST_START;
909 cell = rgCb[inst].cell;
910 /* Fetch the cell and then the UE */
911 if((cell == NULLP) ||
912 (cell->cellId != cellId))
915 DU_LOG("\nERROR --> MAC : Cell does not exist ");
919 if ((ue = rgDBMGetUeCb(cell, crnti)) == NULLP)
921 DU_LOG("\nERROR --> MAC : CRNTI:%d Ue does not exist", crnti);
925 /* No need to reset the SPS LC Ids as they will not be looked at*/
927 /* Delete UE from the SPS UE List */
928 rgDBMDelSpsUeCb(cell, ue);
931 } /* end of RgSchMacSpsLcDeregReq */
933 #endif /* LTEMAC_SPS */
936 * @brief Function for handling CRNTI change request
937 * received from scheduler to MAC.
941 * Function : rgUtlHndlCrntiChng
943 * - Delete old UE from the list.
944 * - Update the new rnti and re-insert the UE in the list.
947 * @param[in] Inst inst
948 * @param[in] RgCellCb *cell,
949 * @param[in] CmLteRnti rnti,
950 * @param[in] CmLteRnti newRnti
955 static S16 rgUtlHndlCrntiChng
964 RgUeCb *newUe = NULLP;
966 ue = rgDBMGetUeCb(cell, rnti);
967 newUe = rgDBMGetUeCbFromRachLst(cell, newRnti);
968 if ((ue == NULLP) || (newUe == NULLP))
970 DU_LOG("\nERROR --> MAC : RNTI:%d Failed to get UECB[%lu:%lu] or NEW RNTI:%d",
971 rnti, ((PTR)ue), ((PTR)newUe), newRnti);
974 #ifdef XEON_SPECIFIC_CHANGES
975 DU_LOG("\nDEBUG --> MAC : MAC:UE[%d] id changed to %d\n", rnti, newRnti);
977 rgDBMDelUeCb(cell, ue);
981 memcpy(&(ue->contResId), &(newUe->contResId),
982 sizeof(newUe->contResId));
983 /* Fix : syed MSG4 might be RETXing need to store the
985 rgDHMFreeUe(inst,&ue->dl.hqEnt);
986 ue->dl.hqEnt = newUe->dl.hqEnt;
988 rgDBMInsUeCb(cell, ue);
990 rgDBMDelUeCbFromRachLst(cell, newUe);
991 rgFreeSBuf(inst,(Data **)&newUe, sizeof(*newUe));
994 } /* end of rgUtlHndlCrntiChng */
998 * @brief Function for handling UE release for SCELL
999 * triggered from SCH to MAC.
1003 * Function : rgDelUeFrmAllSCell
1005 * - This Function should be invoked by PCell of UE
1006 * - Remove the UE context from SCELL corresponding to rnti.
1008 * @param[in] Inst *macInst,
1009 * @param[in] RgUeCb *ue
1010 * @return ROK is SUCCESS
1012 S16 rgDelUeFrmAllSCell(RgCellCb *cell,RgUeCb *ue)
1014 Inst inst = cell->macInst - RG_INST_START;
1018 RgPrgUeSCellDelInfo ueSCellDelInfo;
1020 /* To Delete the SCells if exisits for that UE */
1021 for(idx = 0; idx < RG_MAX_SCELL_PER_UE ; idx++)
1023 if(TRUE == ue->sCelInfo[idx].isSCellAdded)
1025 sCellInstIdx = ue->sCelInfo[idx].macInst - RG_INST_START;
1027 rgGetPstToInst(&dstInstPst, inst, sCellInstIdx);
1028 ueSCellDelInfo.ueId = ue->ueId;
1029 ueSCellDelInfo.sCellId = ue->sCelInfo[idx].sCellId;
1031 /* Filling same ueId in newRnti so that SMAC will check if newRnti
1032 *and old UeId is same that means its a UeSCell delete request*/
1033 ueSCellDelInfo.newRnti = ue->ueId;
1035 RgPrgPMacSMacUeSCellDel(&dstInstPst, &ueSCellDelInfo);
1036 ue->sCelInfo[idx].isSCellAdded = FALSE;
1041 } /* rgDelUeFrmAllSCell */
1044 * @brief Function to validate AddSCellCfg.
1048 * Function : rgUtlVltdAddSCellCfg
1051 * @param[in] ueSCellCb secondary cell CB for validation
1052 * @param[in] cell cell control block
1053 * @param[in] inst instance number to fetch rgCb instance
1057 S16 rgUtlVltdAddSCellCfg(RgPrgUeSCellCfgInfo *ueSCellCb,RgCellCb *cell,Inst inst)
1061 /* To Validate the CellID presence */
1062 if((cell == NULLP) ||
1063 (cell->cellId != ueSCellCb->cellId))
1065 DU_LOG("\nERROR --> MAC : [%d]Sec Cell does not exit %d\n",
1066 ueSCellCb->ueId, ueSCellCb->cellId);
1069 #ifdef TENB_MULT_CELL_SUPPRT
1070 if((ueSCellCb->rguDlSapId > rgCb[inst].numRguSaps) ||
1071 (ueSCellCb->rguUlSapId > rgCb[inst].numRguSaps))
1073 DU_LOG("\nERROR --> MAC : Invald Sap Id: DL %d UL %d for ueId %d failed\n",
1074 ueSCellCb->rguDlSapId,
1075 ueSCellCb->rguUlSapId,
1081 } /* rgUtlVltdAddSCellCfg */
1084 * @brief Function to build CrntiChangeReq and send to all SMACs.
1088 * Function : rgUtlSndCrntiChngReq2AllSMacs
1090 * - This Function should be invoked by PCell of UE
1091 * - It sends RgPrgPMacSMacUeSCellDelReq to all SMACs with newRnti sent
1092 * by SCH. SMAC will check if newRnti is not equal to old UeId then it
1093 * do only UeId change else it will delete the UeScell context
1095 * @param[in] cell Cell CB to get Ue control block
1096 * @param[in] rnti Ue Identifier used to fill in UeId Change req
1097 * @param[in] newRnti UE new identifier, to be used in UeId Change req
1101 static S16 rgUtlSndCrntiChngReq2AllSMacs
1108 Inst inst = cell->macInst - RG_INST_START;
1111 RgPrgUeSCellDelInfo ueIdChngReq;
1115 TfuDelDatReqInfo delDatReq;
1118 /* use newRnti to get UeCb in PMac because rnti is already changed in PMac*/
1119 ue = rgDBMGetUeCb(cell, newRnti);
1122 DU_LOG("\nERROR --> MAC : [%d]RNTI:Failed to get ueCb \
1123 newRnti=%d\n", rnti, newRnti);
1126 /* For all added SCells, prepare and send ueIdChngReq */
1127 for(idx = 0; idx < RG_MAX_SCELL_PER_UE ; idx++)
1129 if(TRUE == ue->sCelInfo[idx].isSCellAdded)
1131 sCellInstIdx = ue->sCelInfo[idx].macInst - RG_INST_START;
1133 rgGetPstToInst(&dstInstPst, inst, sCellInstIdx);
1135 ueIdChngReq.ueId = rnti;
1136 ueIdChngReq.sCellId = ue->sCelInfo[idx].sCellId;
1138 /* Filling newRnti so that SMAC can check if old ueId and new UeId
1139 *(newRnti) is different then its a UeId change request from PMAC.
1140 * RgPrgPMacSMacUeSCellDelReq is being reused for UeId change req
1141 * from PMAC to SMAC*/
1142 ueIdChngReq.newRnti = newRnti;
1144 /* Re-using UeSCellDelReq API for UeId change*/
1145 RgPrgPMacSMacUeSCellDel(&dstInstPst, &ueIdChngReq);
1147 /* Sending delDatReq to CL to clear the Pdus for old UeId present in CL*/
1148 delDatReq.cellId = ueIdChngReq.sCellId;
1149 delDatReq.ueId = ueIdChngReq.ueId;
1150 rgLIMTfuDelDatReq(sCellInstIdx, &delDatReq);
1157 } /* rgUtlSndCrntiChngReq2AllSMacs */
1159 #endif /* LTE_ADV */
1162 * @brief Function for handling CRNTI Context release
1163 * triggered from SCH to MAC.
1167 * Function : rgUtlHndlCrntiRls
1169 * - Remove the UE context from MAC corresponding to rnti.
1172 * @param[in] RgCellCb *cell,
1173 * @param[in] CmLteRnti rnti
1176 static Void rgUtlHndlCrntiRls(RgCellCb *cell,RgInfRlsRnti *rlsRnti)
1178 Inst inst = cell->macInst - RG_INST_START;
1181 RgUeCb *spsUeCb = NULLP;
1184 if ((ue = rgDBMGetUeCb(cell, rlsRnti->rnti)) == NULLP)
1186 /* Check in RachLst */
1187 if((ue=rgDBMGetUeCbFromRachLst (cell, rlsRnti->rnti)) != NULLP)
1189 /* Delete Ue from the UE list */
1190 rgDBMDelUeCbFromRachLst(cell, ue);
1193 rgRAMFreeUeCb(inst,ue);
1197 DU_LOG("\nERROR --> MAC : RNTI:%d No ueCb found in RachLst",rlsRnti->rnti);
1203 if(FALSE == rlsRnti->isUeSCellDel)
1205 rgDelUeFrmAllSCell(cell, ue);
1207 #endif /* LTE_ADV */
1209 /* Delete Ue from the UE list */
1210 rgDBMDelUeCb(cell, ue);
1212 spsUeCb = rgDBMGetSpsUeCb (cell, ue->spsRnti);
1215 rgDBMDelSpsUeCb(cell, spsUeCb);
1220 rgCFGFreeUeCb(cell, ue);
1221 /* MS_REMOVE : syed Check in RachLst */
1223 if((ue=rgDBMGetUeCbFromRachLst (cell, rlsRnti->rnti)) != NULLP)
1225 DU_LOG("\nERROR --> MAC : RNTI:%d STALE UE is still present", rlsRnti->rnti);
1231 } /* end of rgUtlHndlCrntiRls */
1234 * @brief Function for handling RaResp request received from scheduler to MAC.
1238 * Function : RgSchMacRlsRntiReq
1240 * This function shall be invoked whenever scheduler is done with the
1241 * allocations of random access responses for a subframe.
1242 * This shall invoke RAM to create ueCbs for all the rapIds allocated and
1243 * shall invoke MUX to create RAR PDUs for raRntis allocated.
1246 * @param[in] CmLteCellId cellId,
1247 * @param[in] CmLteTimingInfo timingInfo,
1248 * @param[in] RaRespInfo *rarInfo
1252 S16 RgSchMacRlsRntiReq(Pst *pst,RgInfRlsRnti *rlsRnti)
1255 // RgInfUeDelInd ueDelInd;
1259 TfuDelDatReqInfo delDatReq;
1262 RG_IS_INST_VALID(pst->dstInst);
1263 macInst = pst->dstInst - RG_INST_START;
1264 cell = rgCb[macInst].cell;
1266 if(NULLP == rlsRnti)
1271 if((cell == NULLP) ||
1272 (cell->cellId != rlsRnti->cellId))
1275 DU_LOG("\nERROR --> MAC : No cellCb found with cellId for RNTI:%d",
1279 /* Fix : syed Clearing UE context when SCH indicates to do so
1280 * UE DEL from CRG interface is now dummy. */
1281 if (rlsRnti->ueIdChng)
1283 /* Fix : syed ueId change as part of reestablishment.
1284 * Now SCH to trigger this. CRG ueRecfg for ueId change
1286 if (rgUtlHndlCrntiChng(macInst,cell, rlsRnti->rnti, rlsRnti->newRnti) != ROK)
1288 DU_LOG("\nERROR --> MAC : CRNTI change failed for RNTI:%d new RNTI:%d",
1289 rlsRnti->rnti,rlsRnti->newRnti);
1294 /*PMAC_Reest: Prepare CrntiChngReq and then send to all SMACs to change
1297 if(rgUtlSndCrntiChngReq2AllSMacs(cell, rlsRnti->rnti, rlsRnti->newRnti) != ROK)
1299 /* TODO: do we need to send DelInd to SCH in failure case*/
1304 /* Sending delDatReq to CL to clear the Pdus for old UeId present in CL*/
1305 delDatReq.cellId = cell->cellId;
1306 delDatReq.ueId = rlsRnti->rnti;
1307 rgLIMTfuDelDatReq(macInst, &delDatReq);
1312 rgUtlHndlCrntiRls(cell, rlsRnti);
1314 /* Fix : syed Send delete confirmation to SCH */
1315 /* Send RgMacSchUeDelInd to SCH only if it is Rnti release to PMAC.
1316 * Basically dont send DelInd to SCH incase of Ue SCell Del*/
1318 if(FALSE == rlsRnti->isUeSCellDel)
1321 //TODO: commented for compilation without SCH
1323 ueDelInd.cellSapId = cell->schInstMap.cellSapId;
1324 ueDelInd.cellId = rlsRnti->cellId;
1325 ueDelInd.rnti = rlsRnti->rnti;
1326 rgGetPstToInst(&schPst,macInst, cell->schInstMap.schInst);
1327 RgMacSchUeDel(&schPst, &ueDelInd);
1332 } /* end of RgSchMacRlsRntiReq */
1335 Bool RgUtlIsTbMuxed(TfuDatReqTbInfo *tb)
1338 SFndLenMsg(tb->macHdr, &len);
1339 return (len?TRUE : FALSE);
1343 /**********************************************************************
1346 **********************************************************************/