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 */
244 if ((data == NULLP) || (*data == NULLP) || (size == 0))
249 /* Deallocate buffer */
250 MAC_FREE_SHRABL_BUF(rgCb[inst].rgInit.region, rgCb[inst].rgInit.pool, *data, size);
261 } /* end of rgFreeSharableBuf */
269 * Desc: The argument to rgFreeSBuf() is a pointer to a block
270 * previously allocated by rgAllocSBuf() and size. It
271 * deallocates the memory.
275 * Notes: ccpu00117052 - MOD- changed the Data parameter from
276 * pointer to address of pointer so that
277 * the freed memory could be set to NULLP
284 Data **data, /* address of pointer to data */
291 if ((data == NULLP) || (*data == NULLP) || (size == 0))
297 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
300 /* Deallocate buffer */
301 MAC_FREE(data, size);
305 DU_LOG("\nERROR --> MAC : rgFreeSBuf failed.\n");
313 } /* end of rgFreeSBuf */
316 /***********************************************************
320 * Desc : Utility Function to Allocate message buffer.
326 * Notes: Caller doesnt need to raise the alarm in case of memory
327 * allocation gets failed.
331 **********************************************************/
335 Buffer **mBuf /* Message Buffer pointer be returned */
340 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
341 MS_BUF_ADD_ALLOC_CALLER();
343 ret = ODU_GET_MSG_BUF(RG_GET_MEM_REGION(rgCb[inst]), RG_GET_MEM_POOL(rgCb[inst]), mBuf);
347 /* Moving diagnostics structure to limited scope for optimization */
348 RgUstaDgn dgn; /* Alarm diagnostics structure */
350 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
352 /* Send an alarm to Layer Manager */
353 rgLMMStaInd(inst,LCM_CATEGORY_RESOURCE, LCM_EVENT_DMEM_ALLOC_FAIL,
354 LCM_CAUSE_MEM_ALLOC_FAIL, &dgn);
355 DU_LOG("\nERROR --> MAC : Unable to Allocate Buffer");
361 } /* end of rgGetMsg */
364 /***********************************************************
366 * Func : rgFillDgnParams
368 * Desc : Utility Function to Fill Diagonostic params.
376 **********************************************************/
387 case LRG_USTA_DGNVAL_MEM:
388 dgn->type = (uint8_t) LRG_USTA_DGNVAL_MEM;
389 dgn->u.mem.region = rgCb[inst].rgInit.region;
390 dgn->u.mem.pool = rgCb[inst].rgInit.pool;
398 } /* end of rgFillDgnParams */
401 /***********************************************************
403 * Func : rgUpdtRguDedSts
405 * Desc : Utility Function to update rgu sap statistics for dedicated
416 **********************************************************/
421 uint8_t stsType, /* Statistics type to update */
422 RgRguDedDatReq *datReq /* DatReq pointer */
430 case RG_RGU_SDU_RCVD:
431 for(idx = 0; idx < datReq->nmbOfUeGrantPerTti; idx++)
433 RguDDatReqPerUe *datReqPerUe = &datReq->datReq[idx];
434 for (idx1 = 0; idx1 < datReqPerUe->nmbOfTbs; idx1++)
436 for(idx2 = 0; idx2 < datReqPerUe->datReqTb[idx1].nmbLch; idx2++)
438 rguDlSap->sapSts.numPduRcvd +=
439 datReqPerUe->datReqTb[idx1].lchData[idx2].pdu.numPdu;
445 case RG_RGU_SDU_DROP:
446 for(idx = 0; idx < datReq->nmbOfUeGrantPerTti; idx++)
448 RguDDatReqPerUe *datReqPerUe = &datReq->datReq[idx];
449 for (idx1 = 0; idx1 < datReqPerUe->nmbOfTbs; idx1++)
451 for(idx2 = 0; idx2 < datReqPerUe->datReqTb[idx1].nmbLch; idx2++)
453 rguDlSap->sapSts.numPduRcvd +=
454 datReqPerUe->datReqTb[idx1].lchData[idx2].pdu.numPdu;
455 rguDlSap->sapSts.numPduDrop +=
456 datReqPerUe->datReqTb[idx1].lchData[idx2].pdu.numPdu;
465 } /* rgUpdtRguDedSts */
468 /***********************************************************
470 * Func : rgUpdtRguCmnSts
472 * Desc : Utility Function to update rgu sap statistics for common
483 **********************************************************/
488 uint8_t stsType /* Statistics type to update */
494 case RG_RGU_SDU_RCVD:
495 rguDlSap->sapSts.numPduRcvd ++;
497 case RG_RGU_SDU_DROP:
498 rguDlSap->sapSts.numPduRcvd ++;
499 rguDlSap->sapSts.numPduDrop ++;
504 } /* rgUpdtRguCmnSts */
507 /***********************************************************
509 * Func : rgUpdtCellCnt
511 * Desc : Utility Function to update cell count. It gives number of active
518 * Notes: This function should be called only after cell is added/deleted
519 * from the globlal hashlist
523 **********************************************************/
524 Void rgUpdtCellCnt(Inst inst,uint8_t updtType)
530 rgCb[inst].genSts.numCellCfg++;
533 rgCb[inst].genSts.numCellCfg--;
540 } /* rgUpdtCellCnt */
543 /***********************************************************
547 * Desc : Utility Function to update ue count. It gives number of active
554 * Notes: This function should be called only after ue is added/deleted
555 * from the globlal hashlist
559 **********************************************************/
560 Void rgUpdtUeCnt(Inst inst,uint8_t updtType)
565 rgCb[inst].genSts.numUeCfg++;
568 rgCb[inst].genSts.numUeCfg--;
578 * Fun: rgAllocEventMem
580 * Desc: This function allocates event memory
582 * Ret: ROK - on success
583 * RFAILED - on failure
598 volatile uint32_t startTime=0;
601 sMem.region = rgCb[inst].rgInit.region;
602 sMem.pool = rgCb[inst].rgInit.pool;
604 #if (ERRCLASS & ERRCLS_DEBUG)
607 DU_LOG("\nERROR --> MAC : rgAllocEventMem(): memSize invalid\n");
610 #endif /* ERRCLASS & ERRCLS_DEBUG */
614 SStartTask(&startTime, PID_MACUTL_CMALLCEVT);
616 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
617 MS_BUF_ADD_ALLOC_CALLER();
619 #ifdef TFU_ALLOC_EVENT_NO_INIT
620 if(ROK != cmAllocEvntNoInit(memSize, TFU_MAX_MEMBLK_SIZE, &sMem, memPtr))
622 if(ROK != cmAllocEvnt(memSize, TFU_MAX_MEMBLK_SIZE, &sMem, memPtr))
625 DU_LOG("\nERROR --> MAC : cmAllocEvnt Failed");
630 SStopTask(startTime, PID_MACUTL_CMALLCEVT);
633 } /* end of rgAllocEventMem*/
639 * Desc: This function allocates event memory
641 * Ret: ROK - on success
642 * RFAILED - on failure
659 #ifdef TFU_ALLOC_EVENT_NO_INIT
660 ret = cmGetMemNoInit(memCp, len, (Ptr *)ptr);
662 ret = cmGetMem(memCp, len, (Ptr *)ptr);
665 } /* end of rgGetEventMem*/
667 /***********************************************************
669 * Func : rgGetPstToInst
671 * Desc : Utility Function to get the pst structure to post a message to
678 * Notes: This function should be called while sending a msg from
679 * MAC to a scheduler instance
683 **********************************************************/
692 pst->srcEnt = rgCb[srcInst].rgInit.ent;
693 pst->srcInst = rgCb[srcInst].rgInit.inst;
694 pst->srcProcId = rgCb[srcInst].rgInit.procId;
695 pst->region = rgCb[srcInst].rgInit.region;
696 pst->pool = rgCb[srcInst].rgInit.pool;
698 pst->dstProcId = rgCb[dstInst].rgInit.procId;
699 pst->dstEnt = rgCb[dstInst].rgInit.ent;
700 pst->dstInst = dstInst;
704 pst->route = RTESPEC;
707 } /* end of rgGetPstToInst */
709 /***********************************************************
711 * Func : RgSchMacLcgRegReq
713 * Desc : Utility Function to register the set of GBR LCG.
714 * Invoked at the time of LCG configuration/Reconfiguration at Schedular.
717 * - Fetch the ueCb using the crnti given in lcInfo
718 * - Store the if LCG is GBR or not.
723 * Notes: This function should be called at the time of LCG
724 * configuration/Reconfiguration at Schedular.
729 **********************************************************/
730 S16 RgSchMacLcgRegReq(Pst *pst,RgInfLcgRegReq *lcgRegReq)
733 RgCellCb *cell = NULLP;
736 RG_IS_INST_VALID(pst->dstInst);
737 inst = pst->dstInst - RG_INST_START;
738 cell = rgCb[inst].cell;
739 /* Fetch the cell and then the UE */
740 if((cell == NULLP) ||
741 (cell->cellId != lcgRegReq->cellId))
744 DU_LOG("\nERROR --> MAC : Cell does not exist ");
748 if ((ue = rgDBMGetUeCb(cell, lcgRegReq->crnti)) == NULLP)
750 DU_LOG("\nERROR --> MAC : CRNTI:%d does not exist",
754 ue->ul.lcgArr[lcgRegReq->lcgId].isGbr = lcgRegReq->isGbr;
757 } /* end of RgSchMacLcgRegReq */
761 /***********************************************************
763 * Func : RgSchMacUlSpsResetReq
765 * Desc : Utility Function to reset SPS params for a UE
768 * - Fetch the ueCb using the crnti
769 * - reset implRelCnt and explRelCnt
776 **********************************************************/
777 S16 RgSchMacUlSpsResetReq(Pst *pst,RgInfUlSpsReset *ulSpsResetInfo)
780 RgCellCb *cell = NULLP;
783 RG_IS_INST_VALID(pst->dstInst);
784 inst = pst->dstInst - RG_INST_START;
785 cell = rgCb[inst].cell;
786 /* Fetch the cell and then the UE */
788 (cell->cellId != ulSpsResetInfo->cellId))
791 DU_LOG("\nERROR --> MAC : Cell does not exist ");
795 if ((ue = rgDBMGetUeCb(cell, ulSpsResetInfo->crnti)) == NULLP)
797 DU_LOG("\nERROR --> MAC : CRNTI:%d does not exist",
798 ulSpsResetInfo->crnti);
802 ue->ul.implRelCntr = 0;
803 ue->ul.explRelCntr = 0;
806 } /* end of RgSchMacUlSpsResetReq */
811 /***********************************************************
813 * Func : RgSchMacSpsLcRegReq
815 * Desc : Utility Function to register the set of uplink SPS logical
816 * channels for a SPS UE.
817 * Invoked at the time of activation of a UE for UL-SPS.
818 * Whenever there is data on these LCs MAC shall inform scheduler
821 * - Fetch the ueCb using the crnti given in lcInfo
822 * - Store the sps-rnti and set the bits corresponding to the
823 * logical channel ids in ueUlCb->spsLcMask.
828 * Notes: This function should be called at the time UL SPS is activated
829 * for a UE at scheduler
834 **********************************************************/
835 S16 RgSchMacSpsLcRegReq(Pst *pst,RgInfSpsLcInfo *lcInfo)
838 RgCellCb *cell= NULLP;
842 RG_IS_INST_VALID(pst->dstInst);
843 inst = pst->dstInst - RG_INST_START;
844 cell = rgCb[inst].cell;
845 /* Fetch the cell and then the UE */
846 if((cell == NULLP) ||
847 (cell->cellId != lcInfo->cellId))
850 DU_LOG("\nERROR --> MAC : Cell does not exist ");
854 if ((ue = rgDBMGetUeCb(cell, lcInfo->crnti)) == NULLP)
856 DU_LOG("\nERROR --> MAC : CRNTI:%d does not exist",
861 /* Store the sps-rnti and SPS LC information in the UE */
862 ue->spsRnti = lcInfo->spsRnti;
863 for (idx=0; idx < lcInfo->spsLcCnt; idx++)
865 /* KWORK_FIX: Modified the index from lcId to lcId-1 for handling lcId 10 properly */
866 ue->ul.spsLcId[(lcInfo->spsLcId[idx])-1] = TRUE;
868 ue->ul.implRelCnt = lcInfo->implRelCnt;
869 ue->ul.explRelCnt = ue->ul.implRelCnt + 1; /*(lcInfo->implRelCnt * lcInfo->spsPrd);*/
871 /* Insert the UE into SPS UE List */
872 if (rgDBMInsSpsUeCb(cell, ue) == RFAILED)
874 DU_LOG("\nERROR --> MAC : Ue insertion into SPS list failed SPS CRNTI:%d", ue->spsRnti);
879 } /* end of RgSchMacSpsLcRegReq */
882 /***********************************************************
884 * Func : RgSchMacSpsLcDeregReq
886 * Desc : Utility Function to deregister the set of uplink SPS
887 * logical channels for a UE.
888 * Invoked at the time of release of UL-SPS for an activated UE.
891 * - Fetch the ueCb using the crnti given
892 * - Reset the bits corresponding to the logical channel ids in
898 * Notes: This function should be called at the time UL SPS is released
899 * for a UE at scheduler
904 **********************************************************/
905 S16 RgSchMacSpsLcDeregReq(Pst *pst,CmLteCellId cellId,CmLteRnti crnti)
908 RgCellCb *cell = NULLP;
911 RG_IS_INST_VALID(pst->dstInst);
912 inst = pst->dstInst - RG_INST_START;
913 cell = rgCb[inst].cell;
914 /* Fetch the cell and then the UE */
915 if((cell == NULLP) ||
916 (cell->cellId != cellId))
919 DU_LOG("\nERROR --> MAC : Cell does not exist ");
923 if ((ue = rgDBMGetUeCb(cell, crnti)) == NULLP)
925 DU_LOG("\nERROR --> MAC : CRNTI:%d Ue does not exist", crnti);
929 /* No need to reset the SPS LC Ids as they will not be looked at*/
931 /* Delete UE from the SPS UE List */
932 rgDBMDelSpsUeCb(cell, ue);
935 } /* end of RgSchMacSpsLcDeregReq */
937 #endif /* LTEMAC_SPS */
940 * @brief Function for handling CRNTI change request
941 * received from scheduler to MAC.
945 * Function : rgUtlHndlCrntiChng
947 * - Delete old UE from the list.
948 * - Update the new rnti and re-insert the UE in the list.
951 * @param[in] Inst inst
952 * @param[in] RgCellCb *cell,
953 * @param[in] CmLteRnti rnti,
954 * @param[in] CmLteRnti newRnti
959 static S16 rgUtlHndlCrntiChng
968 RgUeCb *newUe = NULLP;
970 ue = rgDBMGetUeCb(cell, rnti);
971 newUe = rgDBMGetUeCbFromRachLst(cell, newRnti);
972 if ((ue == NULLP) || (newUe == NULLP))
974 DU_LOG("\nERROR --> MAC : RNTI:%d Failed to get UECB[%lu:%lu] or NEW RNTI:%d",
975 rnti, ((PTR)ue), ((PTR)newUe), newRnti);
978 #ifdef XEON_SPECIFIC_CHANGES
979 DU_LOG("\nDEBUG --> MAC : MAC:UE[%d] id changed to %d\n", rnti, newRnti);
981 rgDBMDelUeCb(cell, ue);
985 memcpy(&(ue->contResId), &(newUe->contResId),
986 sizeof(newUe->contResId));
987 /* Fix : syed MSG4 might be RETXing need to store the
989 rgDHMFreeUe(inst,&ue->dl.hqEnt);
990 ue->dl.hqEnt = newUe->dl.hqEnt;
992 rgDBMInsUeCb(cell, ue);
994 rgDBMDelUeCbFromRachLst(cell, newUe);
995 rgFreeSBuf(inst,(Data **)&newUe, sizeof(*newUe));
998 } /* end of rgUtlHndlCrntiChng */
1002 * @brief Function for handling UE release for SCELL
1003 * triggered from SCH to MAC.
1007 * Function : rgDelUeFrmAllSCell
1009 * - This Function should be invoked by PCell of UE
1010 * - Remove the UE context from SCELL corresponding to rnti.
1012 * @param[in] Inst *macInst,
1013 * @param[in] RgUeCb *ue
1014 * @return ROK is SUCCESS
1016 S16 rgDelUeFrmAllSCell(RgCellCb *cell,RgUeCb *ue)
1018 Inst inst = cell->macInst - RG_INST_START;
1022 RgPrgUeSCellDelInfo ueSCellDelInfo;
1024 /* To Delete the SCells if exisits for that UE */
1025 for(idx = 0; idx < RG_MAX_SCELL_PER_UE ; idx++)
1027 if(TRUE == ue->sCelInfo[idx].isSCellAdded)
1029 sCellInstIdx = ue->sCelInfo[idx].macInst - RG_INST_START;
1031 rgGetPstToInst(&dstInstPst, inst, sCellInstIdx);
1032 ueSCellDelInfo.ueId = ue->ueId;
1033 ueSCellDelInfo.sCellId = ue->sCelInfo[idx].sCellId;
1035 /* Filling same ueId in newRnti so that SMAC will check if newRnti
1036 *and old UeId is same that means its a UeSCell delete request*/
1037 ueSCellDelInfo.newRnti = ue->ueId;
1039 RgPrgPMacSMacUeSCellDel(&dstInstPst, &ueSCellDelInfo);
1040 ue->sCelInfo[idx].isSCellAdded = FALSE;
1045 } /* rgDelUeFrmAllSCell */
1048 * @brief Function to validate AddSCellCfg.
1052 * Function : rgUtlVltdAddSCellCfg
1055 * @param[in] ueSCellCb secondary cell CB for validation
1056 * @param[in] cell cell control block
1057 * @param[in] inst instance number to fetch rgCb instance
1061 S16 rgUtlVltdAddSCellCfg(RgPrgUeSCellCfgInfo *ueSCellCb,RgCellCb *cell,Inst inst)
1065 /* To Validate the CellID presence */
1066 if((cell == NULLP) ||
1067 (cell->cellId != ueSCellCb->cellId))
1069 DU_LOG("\nERROR --> MAC : [%d]Sec Cell does not exit %d\n",
1070 ueSCellCb->ueId, ueSCellCb->cellId);
1073 #ifdef TENB_MULT_CELL_SUPPRT
1074 if((ueSCellCb->rguDlSapId > rgCb[inst].numRguSaps) ||
1075 (ueSCellCb->rguUlSapId > rgCb[inst].numRguSaps))
1077 DU_LOG("\nERROR --> MAC : Invald Sap Id: DL %d UL %d for ueId %d failed\n",
1078 ueSCellCb->rguDlSapId,
1079 ueSCellCb->rguUlSapId,
1085 } /* rgUtlVltdAddSCellCfg */
1088 * @brief Function to build CrntiChangeReq and send to all SMACs.
1092 * Function : rgUtlSndCrntiChngReq2AllSMacs
1094 * - This Function should be invoked by PCell of UE
1095 * - It sends RgPrgPMacSMacUeSCellDelReq to all SMACs with newRnti sent
1096 * by SCH. SMAC will check if newRnti is not equal to old UeId then it
1097 * do only UeId change else it will delete the UeScell context
1099 * @param[in] cell Cell CB to get Ue control block
1100 * @param[in] rnti Ue Identifier used to fill in UeId Change req
1101 * @param[in] newRnti UE new identifier, to be used in UeId Change req
1105 static S16 rgUtlSndCrntiChngReq2AllSMacs
1112 Inst inst = cell->macInst - RG_INST_START;
1115 RgPrgUeSCellDelInfo ueIdChngReq;
1119 TfuDelDatReqInfo delDatReq;
1122 /* use newRnti to get UeCb in PMac because rnti is already changed in PMac*/
1123 ue = rgDBMGetUeCb(cell, newRnti);
1126 DU_LOG("\nERROR --> MAC : [%d]RNTI:Failed to get ueCb \
1127 newRnti=%d\n", rnti, newRnti);
1130 /* For all added SCells, prepare and send ueIdChngReq */
1131 for(idx = 0; idx < RG_MAX_SCELL_PER_UE ; idx++)
1133 if(TRUE == ue->sCelInfo[idx].isSCellAdded)
1135 sCellInstIdx = ue->sCelInfo[idx].macInst - RG_INST_START;
1137 rgGetPstToInst(&dstInstPst, inst, sCellInstIdx);
1139 ueIdChngReq.ueId = rnti;
1140 ueIdChngReq.sCellId = ue->sCelInfo[idx].sCellId;
1142 /* Filling newRnti so that SMAC can check if old ueId and new UeId
1143 *(newRnti) is different then its a UeId change request from PMAC.
1144 * RgPrgPMacSMacUeSCellDelReq is being reused for UeId change req
1145 * from PMAC to SMAC*/
1146 ueIdChngReq.newRnti = newRnti;
1148 /* Re-using UeSCellDelReq API for UeId change*/
1149 RgPrgPMacSMacUeSCellDel(&dstInstPst, &ueIdChngReq);
1151 /* Sending delDatReq to CL to clear the Pdus for old UeId present in CL*/
1152 delDatReq.cellId = ueIdChngReq.sCellId;
1153 delDatReq.ueId = ueIdChngReq.ueId;
1154 rgLIMTfuDelDatReq(sCellInstIdx, &delDatReq);
1161 } /* rgUtlSndCrntiChngReq2AllSMacs */
1163 #endif /* LTE_ADV */
1166 * @brief Function for handling CRNTI Context release
1167 * triggered from SCH to MAC.
1171 * Function : rgUtlHndlCrntiRls
1173 * - Remove the UE context from MAC corresponding to rnti.
1176 * @param[in] RgCellCb *cell,
1177 * @param[in] CmLteRnti rnti
1180 static Void rgUtlHndlCrntiRls(RgCellCb *cell,RgInfRlsRnti *rlsRnti)
1182 Inst inst = cell->macInst - RG_INST_START;
1185 RgUeCb *spsUeCb = NULLP;
1188 if ((ue = rgDBMGetUeCb(cell, rlsRnti->rnti)) == NULLP)
1190 /* Check in RachLst */
1191 if((ue=rgDBMGetUeCbFromRachLst (cell, rlsRnti->rnti)) != NULLP)
1193 /* Delete Ue from the UE list */
1194 rgDBMDelUeCbFromRachLst(cell, ue);
1197 rgRAMFreeUeCb(inst,ue);
1201 DU_LOG("\nERROR --> MAC : RNTI:%d No ueCb found in RachLst",rlsRnti->rnti);
1207 if(FALSE == rlsRnti->isUeSCellDel)
1209 rgDelUeFrmAllSCell(cell, ue);
1211 #endif /* LTE_ADV */
1213 /* Delete Ue from the UE list */
1214 rgDBMDelUeCb(cell, ue);
1216 spsUeCb = rgDBMGetSpsUeCb (cell, ue->spsRnti);
1219 rgDBMDelSpsUeCb(cell, spsUeCb);
1224 rgCFGFreeUeCb(cell, ue);
1225 /* MS_REMOVE : syed Check in RachLst */
1227 if((ue=rgDBMGetUeCbFromRachLst (cell, rlsRnti->rnti)) != NULLP)
1229 DU_LOG("\nERROR --> MAC : RNTI:%d STALE UE is still present", rlsRnti->rnti);
1235 } /* end of rgUtlHndlCrntiRls */
1238 * @brief Function for handling RaResp request received from scheduler to MAC.
1242 * Function : RgSchMacRlsRntiReq
1244 * This function shall be invoked whenever scheduler is done with the
1245 * allocations of random access responses for a subframe.
1246 * This shall invoke RAM to create ueCbs for all the rapIds allocated and
1247 * shall invoke MUX to create RAR PDUs for raRntis allocated.
1250 * @param[in] CmLteCellId cellId,
1251 * @param[in] CmLteTimingInfo timingInfo,
1252 * @param[in] RaRespInfo *rarInfo
1256 S16 RgSchMacRlsRntiReq(Pst *pst,RgInfRlsRnti *rlsRnti)
1259 // RgInfUeDelInd ueDelInd;
1263 TfuDelDatReqInfo delDatReq;
1266 RG_IS_INST_VALID(pst->dstInst);
1267 macInst = pst->dstInst - RG_INST_START;
1268 cell = rgCb[macInst].cell;
1270 if(NULLP == rlsRnti)
1275 if((cell == NULLP) ||
1276 (cell->cellId != rlsRnti->cellId))
1279 DU_LOG("\nERROR --> MAC : No cellCb found with cellId for RNTI:%d",
1283 /* Fix : syed Clearing UE context when SCH indicates to do so
1284 * UE DEL from CRG interface is now dummy. */
1285 if (rlsRnti->ueIdChng)
1287 /* Fix : syed ueId change as part of reestablishment.
1288 * Now SCH to trigger this. CRG ueRecfg for ueId change
1290 if (rgUtlHndlCrntiChng(macInst,cell, rlsRnti->rnti, rlsRnti->newRnti) != ROK)
1292 DU_LOG("\nERROR --> MAC : CRNTI change failed for RNTI:%d new RNTI:%d",
1293 rlsRnti->rnti,rlsRnti->newRnti);
1298 /*PMAC_Reest: Prepare CrntiChngReq and then send to all SMACs to change
1301 if(rgUtlSndCrntiChngReq2AllSMacs(cell, rlsRnti->rnti, rlsRnti->newRnti) != ROK)
1303 /* TODO: do we need to send DelInd to SCH in failure case*/
1308 /* Sending delDatReq to CL to clear the Pdus for old UeId present in CL*/
1309 delDatReq.cellId = cell->cellId;
1310 delDatReq.ueId = rlsRnti->rnti;
1311 rgLIMTfuDelDatReq(macInst, &delDatReq);
1316 rgUtlHndlCrntiRls(cell, rlsRnti);
1318 /* Fix : syed Send delete confirmation to SCH */
1319 /* Send RgMacSchUeDelInd to SCH only if it is Rnti release to PMAC.
1320 * Basically dont send DelInd to SCH incase of Ue SCell Del*/
1322 if(FALSE == rlsRnti->isUeSCellDel)
1325 //TODO: commented for compilation without SCH
1327 ueDelInd.cellSapId = cell->schInstMap.cellSapId;
1328 ueDelInd.cellId = rlsRnti->cellId;
1329 ueDelInd.rnti = rlsRnti->rnti;
1330 rgGetPstToInst(&schPst,macInst, cell->schInstMap.schInst);
1331 RgMacSchUeDel(&schPst, &ueDelInd);
1336 } /* end of RgSchMacRlsRntiReq */
1339 Bool RgUtlIsTbMuxed(TfuDatReqTbInfo *tb)
1342 SFndLenMsg(tb->macHdr, &len);
1343 return (len?TRUE : FALSE);
1347 /**********************************************************************
1350 **********************************************************************/