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
35 static const char* RLOG_MODULE_NAME="MAC";
36 static int RLOG_MODULE_ID=4096;
37 static int RLOG_FILE_ID=179;
39 /* header include files (.h) */
40 #include "common_def.h"
41 #include "rg_env.h" /* MAC Environment Defines */
42 #include "crg.h" /* CRG Interface defines */
43 #include "rgu.h" /* RGU Interface defines */
44 #include "tfu.h" /* TFU Interface defines */
45 #include "rg_sch_inf.h" /* RGR Interface defines */
46 #include "lrg.h" /* LRG Interface defines */
48 #include "rg_prg.h" /* PRG(MAC-MAC) Interface includes */
49 #include "rg.h" /* MAC defines */
50 #include "rg_err.h" /* MAC error defines */
52 /* header/extern include files (.x) */
53 #include "cm5.x" /* Timer */
55 #include "crg.x" /* CRG Interface includes */
56 #include "rgu.x" /* RGU Interface includes */
57 #include "tfu.x" /* TFU Interface includes */
58 #include "rg_sch_inf.x" /* RGR Interface includes */
59 #include "lrg.x" /* LRG Interface includes */
60 #include "rg_prg.x" /* PRG(MAC-MAC) Interface includes */
62 #include "du_app_mac_inf.h"
63 #include "rg.x" /* MAC includes */
66 #define RG_NON_MIMO_IDX 0
72 /* forward references */
73 static S16 rgUtlHndlCrntiChng ARGS((
79 static Void rgUtlHndlCrntiRls ARGS((
84 S16 rgDelUeFrmAllSCell ARGS((
90 static S16 rgUtlSndCrntiChngReq2AllSMacs ARGS((
96 /***********************************************************
98 * Func : rgAllocShrablSBuf
100 * Desc : Utility Function to Allocate static buffer which is
101 * sharable among different layers if YYYY flag is enabled.
102 * else it allocates from normal static region
103 * Memory allocated is assumed contiguous.
109 * Notes: Caller doesnt need to raise the alarm in case of memory
110 * allocation gets failed.
114 **********************************************************/
115 S16 rgAllocShrablSBuf
118 Data **pData, /* Pointer of the data to be returned */
122 RgUstaDgn dgn; /* Alarm diagnostics structure */
124 /* Initialize the param to NULLP */
132 /* allocate buffer */
133 if (SGetStaticBuffer(rgCb[inst].rgInit.region, rgCb[inst].rgInit.pool, pData, size, 0) != ROK)
135 dgn.type = LRG_USTA_DGNVAL_MEM;
136 dgn.u.mem.region = rgCb[inst].rgInit.region;
137 dgn.u.mem.pool = rgCb[inst].rgInit.pool;
138 /* Send an alarm to Layer Manager */
139 rgLMMStaInd(inst,LCM_CATEGORY_RESOURCE, LCM_EVENT_SMEM_ALLOC_FAIL,
140 LCM_CAUSE_MEM_ALLOC_FAIL, &dgn);
141 RGLOGERROR(inst,ERRCLS_DEBUG, ERG028, 0, "Unable to Allocate Buffer");
146 RGDBGINFO(inst,(rgPBuf(inst), "SGetSBuf(Region (%d), Pool (%d), Size (%ld)), Data (0x%p))\n",
147 rgCb[inst].rgInit.region, rgCb[inst].rgInit.pool, size, *pData));
149 RGDBGINFO(inst,(rgPBuf(inst), "SGetSBuf(Region (%d), Pool (%d), Size (%d)), Data (0x%p))\n",
150 rgCb[inst].rgInit.region, rgCb[inst].rgInit.pool, size, *pData));
153 /* zero out the allocated memory */
154 memset(*pData, 0x00, size);
158 } /* end of rgAllocSBuf */
161 /***********************************************************
165 * Desc : Utility Function to Allocate static buffer.
166 * Memory allocated is assumed contiguous.
172 * Notes: Caller doesnt need to raise the alarm in case of memory
173 * allocation gets failed.
177 **********************************************************/
181 Data **pData, /* Pointer of the data to be returned */
185 RgUstaDgn dgn; /* Alarm diagnostics structure */
187 /* Initialize the param to NULLP */
195 /* allocate buffer */
196 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
197 MS_BUF_ADD_ALLOC_CALLER();
199 if (SGetSBuf(rgCb[inst].rgInit.region, rgCb[inst].rgInit.pool, pData, size) != ROK)
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 RGLOGERROR(inst,ERRCLS_DEBUG, ERG028, 0, "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 ret = SPutStaticBuffer(rgCb[inst].rgInit.region, rgCb[inst].rgInit.pool, *data, size, SS_SHARABLE_MEMORY);
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 ret = SPutSBuf(rgCb[inst].rgInit.region, rgCb[inst].rgInit.pool, *data, size);
305 RGLOGERROR(inst,ERRCLS_DEBUG, ERG029, (ErrVal) 0, "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 = SGetMsg(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 RGLOGERROR(inst,ERRCLS_DEBUG, ERG030, 0, "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 RGLOGERROR(inst,ERRCLS_INT_PAR, ERG031, memSize,
608 "rgAllocEventMem(): memSize invalid\n");
611 #endif /* ERRCLASS & ERRCLS_DEBUG */
615 SStartTask(&startTime, PID_MACUTL_CMALLCEVT);
617 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
618 MS_BUF_ADD_ALLOC_CALLER();
620 #ifdef TFU_ALLOC_EVENT_NO_INIT
621 if(ROK != cmAllocEvntNoInit(memSize, TFU_MAX_MEMBLK_SIZE, &sMem, memPtr))
623 if(ROK != cmAllocEvnt(memSize, TFU_MAX_MEMBLK_SIZE, &sMem, memPtr))
626 RLOG0(L_ERROR,"cmAllocEvnt Failed");
631 SStopTask(startTime, PID_MACUTL_CMALLCEVT);
634 } /* end of rgAllocEventMem*/
640 * Desc: This function allocates event memory
642 * Ret: ROK - on success
643 * RFAILED - on failure
660 #ifdef TFU_ALLOC_EVENT_NO_INIT
661 ret = cmGetMemNoInit(memCp, len, (Ptr *)ptr);
663 ret = cmGetMem(memCp, len, (Ptr *)ptr);
666 } /* end of rgGetEventMem*/
668 /***********************************************************
670 * Func : rgGetPstToInst
672 * Desc : Utility Function to get the pst structure to post a message to
679 * Notes: This function should be called while sending a msg from
680 * MAC to a scheduler instance
684 **********************************************************/
693 pst->srcEnt = rgCb[srcInst].rgInit.ent;
694 pst->srcInst = rgCb[srcInst].rgInit.inst;
695 pst->srcProcId = rgCb[srcInst].rgInit.procId;
696 pst->region = rgCb[srcInst].rgInit.region;
697 pst->pool = rgCb[srcInst].rgInit.pool;
699 pst->dstProcId = rgCb[dstInst].rgInit.procId;
700 pst->dstEnt = rgCb[dstInst].rgInit.ent;
701 pst->dstInst = dstInst;
705 pst->route = RTESPEC;
708 } /* end of rgGetPstToInst */
710 /***********************************************************
712 * Func : RgSchMacLcgRegReq
714 * Desc : Utility Function to register the set of GBR LCG.
715 * Invoked at the time of LCG configuration/Reconfiguration at Schedular.
718 * - Fetch the ueCb using the crnti given in lcInfo
719 * - Store the if LCG is GBR or not.
724 * Notes: This function should be called at the time of LCG
725 * configuration/Reconfiguration at Schedular.
730 **********************************************************/
731 S16 RgSchMacLcgRegReq(Pst *pst,RgInfLcgRegReq *lcgRegReq)
734 RgCellCb *cell = NULLP;
737 RG_IS_INST_VALID(pst->dstInst);
738 inst = pst->dstInst - RG_INST_START;
739 cell = rgCb[inst].cell;
740 /* Fetch the cell and then the UE */
741 if((cell == NULLP) ||
742 (cell->cellId != lcgRegReq->cellId))
745 RLOG_ARG0(L_ERROR,DBG_CELLID,lcgRegReq->cellId,"Cell does not exist ");
749 if ((ue = rgDBMGetUeCb(cell, lcgRegReq->crnti)) == NULLP)
751 RLOG_ARG1(L_ERROR, DBG_CELLID,cell->cellId,"CRNTI:%d does not exist",
755 ue->ul.lcgArr[lcgRegReq->lcgId].isGbr = lcgRegReq->isGbr;
758 } /* end of RgSchMacLcgRegReq */
762 /***********************************************************
764 * Func : RgSchMacUlSpsResetReq
766 * Desc : Utility Function to reset SPS params for a UE
769 * - Fetch the ueCb using the crnti
770 * - reset implRelCnt and explRelCnt
777 **********************************************************/
778 S16 RgSchMacUlSpsResetReq(Pst *pst,RgInfUlSpsReset *ulSpsResetInfo)
781 RgCellCb *cell = NULLP;
784 RG_IS_INST_VALID(pst->dstInst);
785 inst = pst->dstInst - RG_INST_START;
786 cell = rgCb[inst].cell;
787 /* Fetch the cell and then the UE */
789 (cell->cellId != ulSpsResetInfo->cellId))
792 RLOG_ARG0(L_ERROR, DBG_CELLID,ulSpsResetInfo->cellId,"Cell does not exist ");
796 if ((ue = rgDBMGetUeCb(cell, ulSpsResetInfo->crnti)) == NULLP)
798 RLOG_ARG1(L_ERROR, DBG_CELLID,cell->cellId,"CRNTI:%d does not exist",
799 ulSpsResetInfo->crnti);
803 ue->ul.implRelCntr = 0;
804 ue->ul.explRelCntr = 0;
807 } /* end of RgSchMacUlSpsResetReq */
812 /***********************************************************
814 * Func : RgSchMacSpsLcRegReq
816 * Desc : Utility Function to register the set of uplink SPS logical
817 * channels for a SPS UE.
818 * Invoked at the time of activation of a UE for UL-SPS.
819 * Whenever there is data on these LCs MAC shall inform scheduler
822 * - Fetch the ueCb using the crnti given in lcInfo
823 * - Store the sps-rnti and set the bits corresponding to the
824 * logical channel ids in ueUlCb->spsLcMask.
829 * Notes: This function should be called at the time UL SPS is activated
830 * for a UE at scheduler
835 **********************************************************/
836 S16 RgSchMacSpsLcRegReq(Pst *pst,RgInfSpsLcInfo *lcInfo)
839 RgCellCb *cell= NULLP;
843 RG_IS_INST_VALID(pst->dstInst);
844 inst = pst->dstInst - RG_INST_START;
845 cell = rgCb[inst].cell;
846 /* Fetch the cell and then the UE */
847 if((cell == NULLP) ||
848 (cell->cellId != lcInfo->cellId))
851 RLOG_ARG0(L_ERROR,DBG_CELLID,lcInfo->cellId, "Cell does not exist ");
855 if ((ue = rgDBMGetUeCb(cell, lcInfo->crnti)) == NULLP)
857 RLOG_ARG1(L_ERROR, DBG_CELLID,cell->cellId,"CRNTI:%d does not exist",
862 /* Store the sps-rnti and SPS LC information in the UE */
863 ue->spsRnti = lcInfo->spsRnti;
864 for (idx=0; idx < lcInfo->spsLcCnt; idx++)
866 /* KWORK_FIX: Modified the index from lcId to lcId-1 for handling lcId 10 properly */
867 ue->ul.spsLcId[(lcInfo->spsLcId[idx])-1] = TRUE;
869 ue->ul.implRelCnt = lcInfo->implRelCnt;
870 ue->ul.explRelCnt = ue->ul.implRelCnt + 1; /*(lcInfo->implRelCnt * lcInfo->spsPrd);*/
872 /* Insert the UE into SPS UE List */
873 if (rgDBMInsSpsUeCb(cell, ue) == RFAILED)
875 RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId,
876 "Ue insertion into SPS list failed SPS CRNTI:%d", ue->spsRnti);
881 } /* end of RgSchMacSpsLcRegReq */
884 /***********************************************************
886 * Func : RgSchMacSpsLcDeregReq
888 * Desc : Utility Function to deregister the set of uplink SPS
889 * logical channels for a UE.
890 * Invoked at the time of release of UL-SPS for an activated UE.
893 * - Fetch the ueCb using the crnti given
894 * - Reset the bits corresponding to the logical channel ids in
900 * Notes: This function should be called at the time UL SPS is released
901 * for a UE at scheduler
906 **********************************************************/
907 S16 RgSchMacSpsLcDeregReq(Pst *pst,CmLteCellId cellId,CmLteRnti crnti)
910 RgCellCb *cell = NULLP;
913 RG_IS_INST_VALID(pst->dstInst);
914 inst = pst->dstInst - RG_INST_START;
915 cell = rgCb[inst].cell;
916 /* Fetch the cell and then the UE */
917 if((cell == NULLP) ||
918 (cell->cellId != cellId))
921 RLOG_ARG0(L_ERROR,DBG_CELLID,cellId, "Cell does not exist ");
925 if ((ue = rgDBMGetUeCb(cell, crnti)) == NULLP)
927 RLOG_ARG1(L_ERROR, DBG_CELLID,cellId,"CRNTI:%d Ue does not exist", crnti);
931 /* No need to reset the SPS LC Ids as they will not be looked at*/
933 /* Delete UE from the SPS UE List */
934 rgDBMDelSpsUeCb(cell, ue);
937 } /* end of RgSchMacSpsLcDeregReq */
939 #endif /* LTEMAC_SPS */
942 * @brief Function for handling CRNTI change request
943 * received from scheduler to MAC.
947 * Function : rgUtlHndlCrntiChng
949 * - Delete old UE from the list.
950 * - Update the new rnti and re-insert the UE in the list.
953 * @param[in] Inst inst
954 * @param[in] RgCellCb *cell,
955 * @param[in] CmLteRnti rnti,
956 * @param[in] CmLteRnti newRnti
961 static S16 rgUtlHndlCrntiChng
970 RgUeCb *newUe = NULLP;
972 ue = rgDBMGetUeCb(cell, rnti);
973 newUe = rgDBMGetUeCbFromRachLst(cell, newRnti);
974 if ((ue == NULLP) || (newUe == NULLP))
976 RLOG_ARG4(L_ERROR,DBG_CELLID,cell->cellId,
977 "RNTI:%d Failed to get UECB[%lu:%lu] or NEW RNTI:%d",
978 rnti, ((PTR)ue), ((PTR)newUe), newRnti);
981 #ifdef XEON_SPECIFIC_CHANGES
982 CM_LOG_DEBUG(CM_LOG_ID_MAC, "MAC:UE[%d] id changed to %d\n", rnti, newRnti);
984 rgDBMDelUeCb(cell, ue);
988 memcpy(&(ue->contResId), &(newUe->contResId),
989 sizeof(newUe->contResId));
990 /* Fix : syed MSG4 might be RETXing need to store the
992 rgDHMFreeUe(inst,&ue->dl.hqEnt);
993 ue->dl.hqEnt = newUe->dl.hqEnt;
995 rgDBMInsUeCb(cell, ue);
997 rgDBMDelUeCbFromRachLst(cell, newUe);
998 rgFreeSBuf(inst,(Data **)&newUe, sizeof(*newUe));
1001 } /* end of rgUtlHndlCrntiChng */
1005 * @brief Function for handling UE release for SCELL
1006 * triggered from SCH to MAC.
1010 * Function : rgDelUeFrmAllSCell
1012 * - This Function should be invoked by PCell of UE
1013 * - Remove the UE context from SCELL corresponding to rnti.
1015 * @param[in] Inst *macInst,
1016 * @param[in] RgUeCb *ue
1017 * @return ROK is SUCCESS
1019 S16 rgDelUeFrmAllSCell(RgCellCb *cell,RgUeCb *ue)
1021 Inst inst = cell->macInst - RG_INST_START;
1025 RgPrgUeSCellDelInfo ueSCellDelInfo;
1027 /* To Delete the SCells if exisits for that UE */
1028 for(idx = 0; idx < RG_MAX_SCELL_PER_UE ; idx++)
1030 if(TRUE == ue->sCelInfo[idx].isSCellAdded)
1032 sCellInstIdx = ue->sCelInfo[idx].macInst - RG_INST_START;
1034 rgGetPstToInst(&dstInstPst, inst, sCellInstIdx);
1035 ueSCellDelInfo.ueId = ue->ueId;
1036 ueSCellDelInfo.sCellId = ue->sCelInfo[idx].sCellId;
1038 /* Filling same ueId in newRnti so that SMAC will check if newRnti
1039 *and old UeId is same that means its a UeSCell delete request*/
1040 ueSCellDelInfo.newRnti = ue->ueId;
1042 RgPrgPMacSMacUeSCellDel(&dstInstPst, &ueSCellDelInfo);
1043 ue->sCelInfo[idx].isSCellAdded = FALSE;
1048 } /* rgDelUeFrmAllSCell */
1051 * @brief Function to validate AddSCellCfg.
1055 * Function : rgUtlVltdAddSCellCfg
1058 * @param[in] ueSCellCb secondary cell CB for validation
1059 * @param[in] cell cell control block
1060 * @param[in] inst instance number to fetch rgCb instance
1064 S16 rgUtlVltdAddSCellCfg(RgPrgUeSCellCfgInfo *ueSCellCb,RgCellCb *cell,Inst inst)
1068 /* To Validate the CellID presence */
1069 if((cell == NULLP) ||
1070 (cell->cellId != ueSCellCb->cellId))
1072 RGDBGERRNEW(inst, (rgPBuf(inst),
1073 "[%d]Sec Cell does not exit %d\n",
1074 ueSCellCb->ueId, ueSCellCb->cellId));
1077 #ifdef TENB_MULT_CELL_SUPPRT
1078 if((ueSCellCb->rguDlSapId > rgCb[inst].numRguSaps) ||
1079 (ueSCellCb->rguUlSapId > rgCb[inst].numRguSaps))
1081 RGDBGERRNEW(inst,(rgPBuf(inst), "Invald Sap Id: DL %d UL %d for ueId %d failed\n",
1082 ueSCellCb->rguDlSapId,
1083 ueSCellCb->rguUlSapId,
1084 ueSCellCb->cellId));
1089 } /* rgUtlVltdAddSCellCfg */
1092 * @brief Function to build CrntiChangeReq and send to all SMACs.
1096 * Function : rgUtlSndCrntiChngReq2AllSMacs
1098 * - This Function should be invoked by PCell of UE
1099 * - It sends RgPrgPMacSMacUeSCellDelReq to all SMACs with newRnti sent
1100 * by SCH. SMAC will check if newRnti is not equal to old UeId then it
1101 * do only UeId change else it will delete the UeScell context
1103 * @param[in] cell Cell CB to get Ue control block
1104 * @param[in] rnti Ue Identifier used to fill in UeId Change req
1105 * @param[in] newRnti UE new identifier, to be used in UeId Change req
1109 static S16 rgUtlSndCrntiChngReq2AllSMacs
1116 Inst inst = cell->macInst - RG_INST_START;
1119 RgPrgUeSCellDelInfo ueIdChngReq;
1123 TfuDelDatReqInfo delDatReq;
1126 /* use newRnti to get UeCb in PMac because rnti is already changed in PMac*/
1127 ue = rgDBMGetUeCb(cell, newRnti);
1130 RGDBGERRNEW(inst,(rgPBuf(inst),"[%d]RNTI:Failed to get ueCb \
1131 newRnti=%d\n", rnti, newRnti));
1134 /* For all added SCells, prepare and send ueIdChngReq */
1135 for(idx = 0; idx < RG_MAX_SCELL_PER_UE ; idx++)
1137 if(TRUE == ue->sCelInfo[idx].isSCellAdded)
1139 sCellInstIdx = ue->sCelInfo[idx].macInst - RG_INST_START;
1141 rgGetPstToInst(&dstInstPst, inst, sCellInstIdx);
1143 ueIdChngReq.ueId = rnti;
1144 ueIdChngReq.sCellId = ue->sCelInfo[idx].sCellId;
1146 /* Filling newRnti so that SMAC can check if old ueId and new UeId
1147 *(newRnti) is different then its a UeId change request from PMAC.
1148 * RgPrgPMacSMacUeSCellDelReq is being reused for UeId change req
1149 * from PMAC to SMAC*/
1150 ueIdChngReq.newRnti = newRnti;
1152 /* Re-using UeSCellDelReq API for UeId change*/
1153 RgPrgPMacSMacUeSCellDel(&dstInstPst, &ueIdChngReq);
1155 /* Sending delDatReq to CL to clear the Pdus for old UeId present in CL*/
1156 delDatReq.cellId = ueIdChngReq.sCellId;
1157 delDatReq.ueId = ueIdChngReq.ueId;
1158 rgLIMTfuDelDatReq(sCellInstIdx, &delDatReq);
1165 } /* rgUtlSndCrntiChngReq2AllSMacs */
1167 #endif /* LTE_ADV */
1170 * @brief Function for handling CRNTI Context release
1171 * triggered from SCH to MAC.
1175 * Function : rgUtlHndlCrntiRls
1177 * - Remove the UE context from MAC corresponding to rnti.
1180 * @param[in] RgCellCb *cell,
1181 * @param[in] CmLteRnti rnti
1184 static Void rgUtlHndlCrntiRls(RgCellCb *cell,RgInfRlsRnti *rlsRnti)
1186 Inst inst = cell->macInst - RG_INST_START;
1189 RgUeCb *spsUeCb = NULLP;
1192 if ((ue = rgDBMGetUeCb(cell, rlsRnti->rnti)) == NULLP)
1194 /* Check in RachLst */
1195 if((ue=rgDBMGetUeCbFromRachLst (cell, rlsRnti->rnti)) != NULLP)
1197 /* Delete Ue from the UE list */
1198 rgDBMDelUeCbFromRachLst(cell, ue);
1201 rgRAMFreeUeCb(inst,ue);
1205 RLOG_ARG1(L_WARNING,DBG_CELLID,cell->cellId,
1206 "RNTI:%d No ueCb found in RachLst",rlsRnti->rnti);
1212 if(FALSE == rlsRnti->isUeSCellDel)
1214 rgDelUeFrmAllSCell(cell, ue);
1216 #endif /* LTE_ADV */
1218 /* Delete Ue from the UE list */
1219 rgDBMDelUeCb(cell, ue);
1221 spsUeCb = rgDBMGetSpsUeCb (cell, ue->spsRnti);
1224 rgDBMDelSpsUeCb(cell, spsUeCb);
1229 rgCFGFreeUeCb(cell, ue);
1230 /* MS_REMOVE : syed Check in RachLst */
1232 if((ue=rgDBMGetUeCbFromRachLst (cell, rlsRnti->rnti)) != NULLP)
1234 RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId,
1235 "RNTI:%d STALE UE is still present", rlsRnti->rnti);
1241 } /* end of rgUtlHndlCrntiRls */
1244 * @brief Function for handling RaResp request received from scheduler to MAC.
1248 * Function : RgSchMacRlsRntiReq
1250 * This function shall be invoked whenever scheduler is done with the
1251 * allocations of random access responses for a subframe.
1252 * This shall invoke RAM to create ueCbs for all the rapIds allocated and
1253 * shall invoke MUX to create RAR PDUs for raRntis allocated.
1256 * @param[in] CmLteCellId cellId,
1257 * @param[in] CmLteTimingInfo timingInfo,
1258 * @param[in] RaRespInfo *rarInfo
1262 S16 RgSchMacRlsRntiReq(Pst *pst,RgInfRlsRnti *rlsRnti)
1265 // RgInfUeDelInd ueDelInd;
1269 TfuDelDatReqInfo delDatReq;
1272 RG_IS_INST_VALID(pst->dstInst);
1273 macInst = pst->dstInst - RG_INST_START;
1274 cell = rgCb[macInst].cell;
1276 if(NULLP == rlsRnti)
1281 if((cell == NULLP) ||
1282 (cell->cellId != rlsRnti->cellId))
1285 RLOG_ARG1(L_ERROR,DBG_CELLID,rlsRnti->cellId,
1286 "No cellCb found with cellId for RNTI:%d",
1290 /* Fix : syed Clearing UE context when SCH indicates to do so
1291 * UE DEL from CRG interface is now dummy. */
1292 if (rlsRnti->ueIdChng)
1294 /* Fix : syed ueId change as part of reestablishment.
1295 * Now SCH to trigger this. CRG ueRecfg for ueId change
1297 if (rgUtlHndlCrntiChng(macInst,cell, rlsRnti->rnti, rlsRnti->newRnti) != ROK)
1299 RLOG_ARG2(L_ERROR,DBG_CELLID,rlsRnti->cellId,
1300 "CRNTI change failed for RNTI:%d new RNTI:%d",
1301 rlsRnti->rnti,rlsRnti->newRnti);
1306 /*PMAC_Reest: Prepare CrntiChngReq and then send to all SMACs to change
1309 if(rgUtlSndCrntiChngReq2AllSMacs(cell, rlsRnti->rnti, rlsRnti->newRnti) != ROK)
1311 /* TODO: do we need to send DelInd to SCH in failure case*/
1316 /* Sending delDatReq to CL to clear the Pdus for old UeId present in CL*/
1317 delDatReq.cellId = cell->cellId;
1318 delDatReq.ueId = rlsRnti->rnti;
1319 rgLIMTfuDelDatReq(macInst, &delDatReq);
1324 rgUtlHndlCrntiRls(cell, rlsRnti);
1326 /* Fix : syed Send delete confirmation to SCH */
1327 /* Send RgMacSchUeDelInd to SCH only if it is Rnti release to PMAC.
1328 * Basically dont send DelInd to SCH incase of Ue SCell Del*/
1330 if(FALSE == rlsRnti->isUeSCellDel)
1333 //TODO: commented for compilation without SCH
1335 ueDelInd.cellSapId = cell->schInstMap.cellSapId;
1336 ueDelInd.cellId = rlsRnti->cellId;
1337 ueDelInd.rnti = rlsRnti->rnti;
1338 rgGetPstToInst(&schPst,macInst, cell->schInstMap.schInst);
1339 RgMacSchUeDel(&schPst, &ueDelInd);
1344 } /* end of RgSchMacRlsRntiReq */
1347 Bool RgUtlIsTbMuxed(TfuDatReqTbInfo *tb)
1350 SFndLenMsg(tb->macHdr, &len);
1351 return (len?TRUE : FALSE);
1355 /**********************************************************************
1358 **********************************************************************/