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 module handles the configuration of MAC by RRC and RRM.
35 static const char* RLOG_MODULE_NAME="MAC";
36 static int RLOG_FILE_ID=180;
37 static int RLOG_MODULE_ID=4096;
39 /* header include files -- defines (.h) */
40 #include "envopt.h" /* environment options */
41 #include "envdep.h" /* environment dependent */
42 #include "envind.h" /* environment independent */
43 #include "gen.h" /* general layer */
44 #include "ssi.h" /* system service interface */
45 #include "cm_hash.h" /* common hash list */
46 #include "cm_mblk.h" /* common memory link list library */
47 #include "cm_llist.h" /* common linked list library */
48 #include "cm_err.h" /* common error */
49 #include "cm_lte.h" /* common LTE */
50 #include "lrg.h" /* Layer manager interface includes*/
51 #include "crg.h" /* CRG interface includes*/
52 #include "rgu.h" /* RGU interface includes*/
53 #include "tfu.h" /* TFU interface includes */
54 #include "rg_sch_inf.h" /* SCH interface includes */
55 #include "rg_prg.h" /* PRG (MAC-MAC) interface includes*/
56 #include "rg_env.h" /* MAC environmental includes*/
57 #include "rg.h" /* MAC includes*/
58 #include "rg_err.h" /* MAC error includes*/
60 /* header/extern include files (.x) */
61 #include "gen.x" /* general layer typedefs */
62 #include "ssi.x" /* system services typedefs */
63 #include "cm5.x" /* common timers */
64 #include "cm_hash.x" /* common hash list */
65 #include "cm_lib.x" /* common library */
66 #include "cm_llist.x" /* common linked list */
67 #include "cm_mblk.x" /* memory management */
68 #include "cm_tkns.x" /* common tokens */
69 #include "cm_lte.x" /* common tokens */
70 #include "rgu.x" /* RGU types */
71 #include "tfu.x" /* RGU types */
72 #include "lrg.x" /* layer management typedefs for MAC */
73 #include "crg.x" /* CRG interface includes */
74 #include "rg_sch_inf.x" /* SCH interface typedefs */
75 #include "rg_prg.x" /* PRG (MAC-MAC) Interface typedefs */
76 #include "du_app_mac_inf.h"
77 #include "rg.x" /* typedefs for MAC */
79 #include "rg_pom_scell.x"
81 /* LTE-MAC Control Block Structure */
82 PUBLIC RgCb rgCb[RG_MAX_INST];
85 PRIVATE S16 rgCFGVldtCrgDedLcCfg ARGS((Inst inst,CrgLchCfg *lcCfg, RgCellCb **cell,
86 RgUeCb **ue, RgErrInfo *errInfo));
87 PRIVATE S16 rgCFGVldtCrgCmnLcCfg ARGS((Inst inst,CrgLchCfg *lcCfg, RgCellCb **cell,
89 PRIVATE S16 rgCFGCrgDedLcCfg ARGS((RgCellCb *cell, RgUeCb *ue,
90 CrgLchCfg *lcCfg, RgErrInfo *errInfo));
91 PRIVATE S16 rgCFGCrgCmnLcCfg ARGS((Inst inst,RgCellCb *cell, CrgLchCfg *lcCfg,
94 PRIVATE Void rgCFGFreeCmnLcLst ARGS((RgCellCb *cell));
95 PRIVATE Void rgCFGFreeUeLst ARGS((RgCellCb *cell));
96 /* Added support for SPS*/
98 PRIVATE Void rgCFGFreeSpsUeLst ARGS((RgCellCb *cell));
99 #endif /* LTEMAC_SPS */
106 /* forward references */
112 * @brief Validates the cell configuration request from RRC to MAC.
116 * Function : rgCFGVldtCrgCellCfg
119 * - Validate the cell configuration request from RRC to MAC at CFG:
120 * validate the value range for the configured values.
121 * - If validated successfully,
126 * @param[in] Inst inst
127 * @param[in] CrgCellCfg *cellCfg
128 * @param[out] RgErrInfo *errInfo
134 PUBLIC S16 rgCFGVldtCrgCellCfg
141 PUBLIC S16 rgCFGVldtCrgCellCfg(inst,cellCfg, errInfo)
147 TRC2(rgCFGVldtCrgCellCfg);
149 errInfo->errCause = RGERR_CFG_INVALID_CRG_CELL_CFG;
150 if ((rgCb[inst].cell != NULLP)
151 || rgCb[inst].inactiveCell != NULLP)
153 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCfg->cellId,"Cell already exists");
156 if ((cellCfg->bwCfg.dlTotalBw < RG_MIN_DL_BW
157 || cellCfg->bwCfg.dlTotalBw > RG_MAX_DL_BW)
158 || (cellCfg->bwCfg.ulTotalBw < RG_MIN_UL_BW
159 || cellCfg->bwCfg.ulTotalBw > RG_MAX_UL_BW))
161 RLOG_ARG2(L_ERROR,DBG_CELLID,cellCfg->cellId,
162 "Invalid Bandwidth configuration: ul %d dl %d",
163 cellCfg->bwCfg.ulTotalBw, cellCfg->bwCfg.dlTotalBw);
166 if (cellCfg->rachCfg.maxMsg3Tx < RG_MIN_HQ_TX)
168 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCfg->cellId,
169 "Invalid RACH configuration: maxMsg3Tx %d",cellCfg->rachCfg.maxMsg3Tx);
172 #ifdef TENB_MULT_CELL_SUPPRT
173 if((cellCfg->rguDlSapId > rgCb[inst].numRguSaps) ||
174 (cellCfg->rguUlSapId > rgCb[inst].numRguSaps))
176 RGDBGERRNEW(inst,(rgPBuf(inst), "Invald Sap Id: DL %d UL %d for CellId %d failed\n",
183 errInfo->errCause = RGERR_NONE;
185 } /* rgCFGVldtCrgCellCfg */
189 * @brief Validates the UE configuration request from RRC to MAC.
193 * Function : rgCFGVldtCrgUeCfg
196 * - Validate the UE configuration request from RRC to MAC at CFG:
197 * validate the value range for the configured values.
198 * - If validated successfully,
199 * - Return ROK and pointer to the cell of UE.
203 * @param[in] Inst inst
204 * @param[in] CrgUeCfg *ueCfg
205 * @param[out] RgCellCb **cell
206 * @param[out] RgErrInfo *errInfo
212 PUBLIC S16 rgCFGVldtCrgUeCfg
220 PUBLIC S16 rgCFGVldtCrgUeCfg(inst,ueCfg, cell, errInfo)
227 TRC2(rgCFGVldtCrgUeCfg);
229 errInfo->errCause = RGERR_CFG_INVALID_CRG_UE_CFG;
230 if ((ueCfg->txMode.pres == PRSNT_NODEF) &&
231 (ueCfg->txMode.tm == CRG_UE_TM_5))
233 RLOG_ARG1(L_ERROR,DBG_CRNTI,ueCfg->crnti,"Transmission Mode=%d not supported",
238 /* Fetch the Active cell */
239 if(((*cell = rgCb[inst].cell) == NULLP) ||
240 ((*cell)->cellId != ueCfg->cellId))
242 RLOG_ARG1(L_ERROR,DBG_CRNTI,ueCfg->crnti,"Active Cell does not exist for cellId%d",
246 /* Check if Ue already configured */
247 if (rgDBMGetUeCb(*cell, ueCfg->crnti) != NULLP)
249 RLOG_ARG0(L_ERROR,DBG_CRNTI,ueCfg->crnti,"Ue already exists");
253 if (ueCfg->ueUlHqCfg.maxUlHqTx < RG_MIN_HQ_TX)
255 RLOG_ARG1(L_ERROR,DBG_CRNTI,ueCfg->crnti, "Invalid Uplink HARQ config %d ",
256 ueCfg->ueUlHqCfg.maxUlHqTx);
259 #ifdef TENB_MULT_CELL_SUPPRT
260 if((ueCfg->rguDlSapId > rgCb[inst].numRguSaps) ||
261 (ueCfg->rguUlSapId > rgCb[inst].numRguSaps))
263 RGDBGERRNEW(inst,(rgPBuf(inst), "Invald Sap Id: DL %d UL %d for ueId %d failed\n",
271 errInfo->errCause = RGERR_NONE;
273 } /* rgCFGVldtCrgUeCfg */
277 * @brief Validates the logical channel configuration request from RRC to MAC.
281 * Function : rgCFGVldtCrgLcCfg
284 * - Validate the logical channel configuration request from RRC to
285 * MAC at CFG: validate if configured values are within the range.
286 * - If validated successfully,
287 * - Return ROK and pointer to the cell for common channels. Return
288 * pointer to cell and UE for dedicated logical channels.
292 * @param[in] CrgLchCfg *lcCfg
293 * @param[in] Inst inst
294 * @param[out] RgCellCb **cell
295 * @param[out] RgUeCb **ue
296 * @param[out] RgErrInfo *errInfo
302 PUBLIC S16 rgCFGVldtCrgLcCfg
311 PUBLIC S16 rgCFGVldtCrgLcCfg(inst,lcCfg, cell, ue, errInfo)
320 TRC2(rgCFGVldtCrgLcCfg);
322 if (lcCfg->lcType == CM_LTE_LCH_DTCH || lcCfg->lcType == CM_LTE_LCH_DCCH)
324 /* Dedicated logical channels */
325 if ((rgCFGVldtCrgDedLcCfg(inst,lcCfg, cell, ue, errInfo)) != ROK)
327 RLOG_ARG0(L_ERROR,DBG_CRNTI,lcCfg->crnti,"Validation for dedicated LC failed");
331 else if (lcCfg->lcType == CM_LTE_LCH_BCCH
332 || lcCfg->lcType == CM_LTE_LCH_PCCH
333 || lcCfg->lcType == CM_LTE_LCH_CCCH)
335 if ((rgCFGVldtCrgCmnLcCfg(inst,lcCfg, cell, errInfo)) != ROK)
337 RLOG_ARG0(L_ERROR,DBG_CRNTI,lcCfg->crnti,"Validation for common logical channels failed");
343 RLOG_ARG1(L_ERROR,DBG_CRNTI,lcCfg->crnti,"Invalid logical channel type %d",
348 if ( lcCfg->qci < RG_QCI_MIN ||
349 lcCfg->qci > RG_QCI_MAX
352 RLOG_ARG1(L_ERROR,DBG_CRNTI,lcCfg->crnti,"Invalid qci %x",lcCfg->qci);
356 #endif /*LTE_L2_MEAS */
358 errInfo->errCause = RGERR_NONE;
360 } /* rgCFGVldtCrgLcCfg */
364 * @brief Validates the cell re-configuration request from RRC to MAC.
368 * Function : rgCFGVldtCrgCellRecfg
371 * - Retrieve the cell control block.
373 * - Validate the range of re-configured values recieved in
374 * re-configuration request.
375 * - If validated successfully,
376 * - Return ROK and pointer to the cell.
379 * - Else return RFAILED.
381 * @param[in] Inst inst
382 * @param[in] CrgCellRecfg *cellRecfg
383 * @param[out] RgCellCb **cell
384 * @param[out] RgErrInfo *errInfo
390 PUBLIC S16 rgCFGVldtCrgCellRecfg
393 CrgCellRecfg *cellRecfg,
398 PUBLIC S16 rgCFGVldtCrgCellRecfg(inst,cellRecfg, cell, errInfo)
400 CrgCellRecfg *cellRecfg;
405 TRC2(rgCFGVldtCrgCellRecfg);
407 errInfo->errCause = RGERR_CFG_INVALID_CRG_CELL_RECFG;
409 if (((*cell = rgCb[inst].cell) == NULLP)
410 && ((*cell = rgCb[inst].inactiveCell) == NULLP))
412 RLOG_ARG0(L_ERROR,DBG_CELLID,cellRecfg->cellId,"Cell does not exist");
416 if((*cell)->cellId != cellRecfg->cellId)
418 RLOG_ARG1(L_ERROR,DBG_CELLID,cellRecfg->cellId, "Cell does not exist %d\n",cellRecfg->cellId);
421 if (cellRecfg->rachRecfg.maxMsg3Tx < RG_MIN_HQ_TX)
423 RLOG_ARG1(L_ERROR,DBG_CELLID,cellRecfg->cellId,
424 "Invalid RACH configuration: maxMsg3Tx %d",cellRecfg->rachRecfg.maxMsg3Tx);
427 errInfo->errCause = RGERR_NONE;
429 } /* rgCFGVldtCrgCellRecfg */
433 * @brief Validates the UE re-configuration request from RRC to MAC.
437 * Function : rgCFGVldtCrgUeRecfg
440 * - Retrieve the UE control block.
442 * - Validate the range of re-configured values recieved in
443 * re-configuration request.
444 * - If validated successfully,
445 * - Return ROK and pointer to the cell and ue.
448 * - Else return RFAILED.
450 * @param[in] Inst inst
451 * @param[in] CrgUeRecfg *ueRecfg
452 * @param[out] RgCellCb **cell
453 * @param[out] RgUeCb **ue
454 * @param[out] RgErrInfo *errInfo
460 PUBLIC S16 rgCFGVldtCrgUeRecfg
469 PUBLIC S16 rgCFGVldtCrgUeRecfg(inst,ueRecfg, cell, ue, errInfo)
477 TRC2(rgCFGVldtCrgUeRecfg);
479 errInfo->errCause = RGERR_CFG_INVALID_CRG_UE_RECFG;
481 if ((ueRecfg->txMode.pres == PRSNT_NODEF) &&
482 (ueRecfg->txMode.tm == CRG_UE_TM_5))
484 RLOG_ARG1(L_ERROR,DBG_CELLID,ueRecfg->cellId,"Transmission Mode=%d not supported",
489 /* Fetch the Active cell */
490 if (((*cell = rgCb[inst].cell) == NULLP)
491 || ((*cell)->cellId != ueRecfg->cellId))
493 RLOG_ARG0(L_ERROR,DBG_CELLID,ueRecfg->cellId, "Active Cell does not exist\n");
497 /* Fix : syed UE ID change at MAC will now be controlled
499 if ((*ue = rgDBMGetUeCb(*cell, ueRecfg->oldCrnti)) == NULLP)
501 RLOG_ARG1(L_ERROR,DBG_CELLID,ueRecfg->cellId,"[%d]Old Ue does not exist", ueRecfg->oldCrnti);
504 if (ueRecfg->ueUlHqRecfg.maxUlHqTx < RG_MIN_HQ_TX)
506 RLOG_ARG1(L_ERROR,DBG_CELLID,ueRecfg->cellId,"Invalid Uplink HARQ config for UE %d",
507 ueRecfg->ueUlHqRecfg.maxUlHqTx);
510 errInfo->errCause = RGERR_NONE;
512 } /* rgCFGVldtCrgUeRecfg */
516 * @brief Validates the logical channel re-configuration request from
521 * Function : rgCFGVldtCrgLcRecfg
524 * - Retrieve the uplink and downlink logical channel control block.
526 * - Validate the range of re-configured values recieved in
527 * re-configuration request.
528 * - If validated successfully,
529 * - Return ROK and pointer to the cell, UE and logical channel.
532 * - Else return RFAILED.
534 * @param[in] Inst inst
535 * @param[in] CrgLchRecfg *lcRecfg
536 * @param[out] RgCellCb **cell
537 * @param[out] RgUeCb **ue
538 * @param[out] RgUlLcCb **ulLc
539 * @param[out] RgDlLcCb **dlLc
540 * @param[out] RgErrInfo *errInfo
546 PUBLIC S16 rgCFGVldtCrgLcRecfg
549 CrgLchRecfg *lcRecfg,
556 PUBLIC S16 rgCFGVldtCrgLcRecfg(inst,lcRecfg, cell, ue, ulLc, errInfo)
558 CrgLchRecfg *lcRecfg;
565 TRC2(rgCFGVldtCrgLcRecfg);
567 errInfo->errCause = RGERR_CFG_INVALID_CRG_LC_RECFG;
570 if ((((*cell = rgCb[inst].cell)) == NULLP)
571 || ((*cell)->cellId != lcRecfg->cellId))
573 RLOG_ARG2(L_ERROR,DBG_CRNTI,lcRecfg->crnti,"Active Cell %u does not exist for UE %u", lcRecfg->cellId, lcRecfg->crnti);
576 /* Fetch the Ue for dedicated channels */
577 if ((*ue = rgDBMGetUeCb(*cell, lcRecfg->crnti)) == NULLP)
579 RLOG_ARG0(L_ERROR,DBG_CRNTI,lcRecfg->crnti,"Ue does not exist for dedicated logical channel");
583 if ((*ulLc = rgDBMGetUlDedLcCb((*ue), lcRecfg->lcId)) == NULLP)
585 RLOG_ARG1(L_ERROR, DBG_CRNTI,lcRecfg->crnti,"Dedicated UL LC does not exist %d",lcRecfg->lcId);
589 if (lcRecfg->ulRecfg.lcgId > (RG_MAX_LCG_PER_UE - 1))
591 RLOG_ARG2(L_ERROR,DBG_CRNTI,lcRecfg->crnti,"Invalid lcgId for uplink logical channel lcg %d lc %d",
592 lcRecfg->ulRecfg.lcgId, lcRecfg->lcId);
596 errInfo->errCause = RGERR_NONE;
598 } /* rgCFGVldtCrgLcRecfg */
600 /* Start: LTEMAC_2.1_DEV_CFG */
602 * @brief Validates the UE Reset request from RRC to MAC.
606 * Function : rgCFGVldtCrgUeReset
609 * - Retrieve the CELL control block.
612 * - Retrieve the UE control block.
616 * @param[in] Inst inst
617 * @param[in] CrgRst *reset,
618 * @param[out] RgCellCb **cell
619 * @param[out] RgUeCb **ue
620 * @param[out] RgErrInfo *errInfo
626 PUBLIC S16 rgCFGVldtCrgUeReset
635 PUBLIC S16 rgCFGVldtCrgUeReset(inst,reset, cell, ue, errInfo)
643 TRC2(rgCFGVldtCrgUeReset);
645 errInfo->errCause = RGERR_CFG_INVALID_CRG_UE_RESET;
647 /* Fetch the Active cell */
648 if (((*cell = rgCb[inst].cell) == NULLP)
649 || ((*cell)->cellId != reset->cellId))
651 RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]Active Cell does not exist %d\n",reset->crnti, reset->cellId));
652 RLOG_ARG1(L_ERROR,DBG_CRNTI,reset->crnti,"Active Cell does not exist %d",reset->cellId);
657 if ((*ue = rgDBMGetUeCb(*cell, reset->crnti)) == NULLP)
659 RLOG_ARG0(L_ERROR,DBG_CRNTI,reset->crnti,"UE does not exist");
663 errInfo->errCause = RGERR_NONE;
665 } /* rgCFGVldtCrgUeReset*/
666 /* End: LTEMAC_2.1_DEV_CFG */
671 * @brief Handler for the cell configuration request from RRC to MAC.
675 * Function : rgCFGCrgCellCfg
678 * - Allocate and create cell control block.
679 * - Update cell control block with the values recieved in the
681 * - Add the control block to hash list of cells.
682 * - Update the statistics.
683 * - If successful, return ROK else return RFAILED.
685 * @param[in] Inst inst
686 * @param[in] CrgCellCfg *cellCfg
687 * @param[out] RgErrInfo *errInfo
693 PUBLIC S16 rgCFGCrgCellCfg
700 PUBLIC S16 rgCFGCrgCellCfg(inst,cellCfg, errInfo)
707 RgCellCb *cell = NULLP;
711 /* RLC SAP to allocate flowCntrlInd buffer*/
714 TRC2(rgCFGCrgCellCfg);
716 errInfo->errCause = RGERR_CFG_CRG_CELL_CFG;
718 /* Allocate the cell control block */
719 if((ret = rgAllocSBuf(inst,(Data**)&cell, sizeof(RgCellCb))) != ROK)
721 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCfg->cellId,"Memory allocation FAILED for cell");
726 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCfg->cellId, "Memory allocation FAILED for cell");
730 /* Initialize the cell */
731 cell->cellId = cellCfg->cellId;
732 cell->rachCfg = cellCfg->rachCfg;
733 cell->bwCfg = cellCfg->bwCfg;
735 if(cellCfg->emtcEnable)
737 cell->emtcEnable = cellCfg->emtcEnable;
740 /* Initialize UL and DL CCCH logical channels */
741 cell->ulCcchId = RG_INVALID_LC_ID;
742 cell->dlCcchId = RG_INVALID_LC_ID;
745 /* Initialize the lists of the cell */
746 ret = rgDBMInitCell(cell);
749 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCfg->cellId,"DBM initialization for cell failed");
750 rgCFGFreeInactvCellCb(cell);
755 if (RFAILED == RgLaaCellCbInit(cell))
757 rgCFGFreeInactvCellCb(cell);
762 for(idx=0;idx < RG_NUM_SUB_FRAMES; idx++)
764 cell->subFrms[idx].txDone = TRUE;
767 cell->macInst = inst + RG_INST_START;
768 /* Insert cell in the incative cell list */
769 rgCb[inst].inactiveCell = cell;
770 rgCb[inst].cell = NULLP;
771 #ifdef TENB_MULT_CELL_SUPPRT
772 rguDlSapId = cellCfg->rguDlSapId;
773 rguUlSapId = cellCfg->rguUlSapId;
775 if(rgCb[inst].numRguSaps > 1)
780 cell->rguDlSap = &(rgCb[inst].rguSap[rguDlSapId]);
781 cell->rguUlSap = &(rgCb[inst].rguSap[rguUlSapId]);
785 cmLListInit(&cell->l2mList);
786 for(idx = 0; idx < RG_NUM_UL_SUB_FRAMES; idx++)
788 cmMemset((U8 *)&cell->ulSf[idx], 0, sizeof(RgUlSf));
791 cell->ttiCycle = (U32)RG_TTI_CYCLE_INVLD;
793 /* Update Statistics */
794 rgUpdtCellCnt(inst,RG_CFG_ADD);
795 errInfo->errCause = RGERR_NONE;
797 pst = &rgCb[inst].rguSap[rguDlSapId].sapCfg.sapPst;
798 /* Allocate a buffer for flowCntrlInd.*/
799 SGetSBuf(pst->region, pst->pool, (Data **)&cell->flowCntrlInd,
800 sizeof(RguFlowCntrlInd));
802 } /* rgCFGCrgCellCfg */
806 * @brief Add SCell Cfg recvd from primary MAC instance.
810 * Function : rgCfgAddUeSCellCfg
813 * - Allocate and create UE control block.
814 * - Update UE control block with the values recieved in the
816 * - If successful, add the control block to hash list of UEs for the cell
817 * else Rollback and FAIL.
819 * @param[in] Inst dstMacInst
820 * @param[in] RgPrgUeSCellCfgInfo *ueSCellCb
821 * @param[in] RgCellCb cell
828 PUBLIC S16 rgCfgAddUeSCellCfg
831 RgPrgUeSCellCfgInfo *ueSCellCb,
835 PUBLIC S16 rgCfgAddUeSCellCfg(dstMacInst, ueSCellCb, cell)
837 RgPrgUeSCellCfgInfo *ueSCellCb;
841 RgUeCb *ueCb = NULLP;
847 TRC2(rgCfgAddUeSCellCfg);
850 rguDlSapId = ueSCellCb->rguDlSapId;
851 rguUlSapId = ueSCellCb->rguUlSapId;
853 #ifndef TENB_MULT_CELL_SUPPRT
854 if(rgCb[dstMacInst].numRguSaps > 1)
860 if ((ueCb = rgDBMGetUeCb(cell, ueSCellCb->ueId)) != NULLP)
862 RGDBGERRNEW(dstMacInst,(rgPBuf(dstMacInst),
863 "[%d]Ue already exist in scell %d during scell addition\n",
870 if((ueCb = rgRAMCreateUeCb(cell, ueSCellCb->ueId,
871 FALSE, &errInfo)) == NULLP)
873 RGDBGERRNEW(dstMacInst, (rgPBuf(dstMacInst),
874 "[%d]UeCb creation failed\n", ueSCellCb->ueId));
878 if(rgDHMHqEntInit(dstMacInst, &ueCb->dl.hqEnt,
879 (rgCb[dstMacInst].cell)->maxDlHqProcPerUe) != ROK)
881 RGDBGERRNEW(dstMacInst,(rgPBuf(dstMacInst),
882 "[%d]UeCb Harq Entity Initialization failed\n", ueSCellCb->ueId));
885 rgDBMInsUeCb(cell, ueCb);
888 ueCb->rguDlSap = &(rgCb[dstMacInst].rguSap[rguDlSapId]);
889 ueCb->rguUlSap = &(rgCb[dstMacInst].rguSap[rguUlSapId]);
891 /* Update satistics */
892 rgUpdtUeCnt(dstMacInst, RG_CFG_ADD);
893 /*Commit Added SCell info to UeCb */
895 ueCb->sCelAddInfo[idx].isSCellAdded = TRUE;
896 ueCb->sCelAddInfo[idx].macInst = dstMacInst;
897 ueCb->sCelAddInfo[idx].sCellId = ueSCellCb->cellId;
900 ueCb->txMode = ueSCellCb->txMode;
901 ueCb->ul.hqEnt.maxHqRetx = ueSCellCb->maxUlHqRetx;
903 for (idx =0; idx <RG_MAX_LC_PER_UE; idx++)
905 ueCb->ul.lcCb[idx] = ueSCellCb->ulLcInfo[idx];
906 ueCb->dl.lcCb[idx] = ueSCellCb->dlLcInfo[idx];
909 for (idx =0; idx < RG_MAX_LCG_PER_UE; idx++)
911 ueCb->ul.lcgArr[idx].lcgId = ueSCellCb->lcgInfo[idx].lcgId;
912 ueCb->ul.lcgArr[idx].lcCount = ueSCellCb->lcgInfo[idx].lcCount;
913 ueCb->ul.lcgArr[idx].isGbr = ueSCellCb->lcgInfo[idx].isGbr;
916 }/* rgCfgAddUeSCellCfg */
919 * @brief SCell Config Filling for added cell from RRC to MAC.
923 * Function : rgFillAndAddSCellCfg
926 * - Update UE control block with the values recieved in the
928 * - Update UE control block with the values present in the
930 * - If successful, add the control block to hash list of UEs for the cell
931 * else Rollback and FAIL.
933 * @param[in] Inst inst
934 * @param[in] RgCellCb *cell
935 * @param[in] CrgUeCfg *ueCfg
936 * @param[in] CrgCfgTransId transId
942 PUBLIC S16 rgFillAndAddSCellCfg
947 CrgCfgTransId transId,
951 PUBLIC S16 rgFillAndAddSCellCfg(inst, cell, ueRecfg, transId, isCfmRqrd)
955 CrgCfgTransId transId;
962 RgPrgUeSCellCfgInfo ueSCellCb;
965 TRC2(rgFillAndAddSCellCfg);
967 /* Fetch the Active cell */
968 if(((cell = rgCb[inst].cell) == NULLP) ||
969 (cell->cellId != ueRecfg->cellId))
971 RGDBGERRNEW(inst,(rgPBuf(inst),
972 "[%d]Active Cell does not exist %d\n",
973 ueRecfg->oldCrnti, ueRecfg->cellId));
977 RGDBGPRM(inst,(rgPBuf(inst),
978 "Filling SCell Config : cellId %d ueId %d\n",
979 cell->cellId, cell->ueId));
981 if ((ue = rgDBMGetUeCb(cell, ueRecfg->oldCrnti)) == NULLP)
983 RGDBGERRNEW(inst,(rgPBuf(inst),
984 "[%d]Ue does not exist\n", ueRecfg->oldCrnti));
988 /* Initialize cfgCfmInfo in the ueCb. This is used while processing SCellAdd
990 ue->cfgCfmInfo.numSCells = ueRecfg->crgSCellCfg.numSCells;
991 ue->cfgCfmInfo.cfgCfgCount = 0;
992 ue->cfgCfmInfo.mask = 0x0;
994 cmMemcpy( (U8*)&(ue->cfgCfmInfo.transId), (U8*)&transId,
995 sizeof(CrgCfgTransId));
996 ueSCellCb.ueId = ueRecfg->oldCrnti;
997 ueSCellCb.txMode = ue->txMode;
998 ueSCellCb.maxUlHqRetx = ue->ul.hqEnt.maxHqRetx;
999 cmMemcpy((U8 *)ueSCellCb.ulLcInfo, (U8 *)ue->ul.lcCb, sizeof(ue->ul.lcCb));
1000 cmMemcpy((U8 *)ueSCellCb.dlLcInfo, (U8 *)ue->dl.lcCb, sizeof(ue->dl.lcCb));
1001 for (idx =0; idx < RG_MAX_LCG_PER_UE; idx++)
1003 ueSCellCb.lcgInfo[idx].lcgId = ue->ul.lcgArr[idx].lcgId;
1004 ueSCellCb.lcgInfo[idx].lcCount = ue->ul.lcgArr[idx].lcCount;
1005 ueSCellCb.lcgInfo[idx].isGbr = ue->ul.lcgArr[idx].isGbr;
1009 idx < ueRecfg->crgSCellCfg.numSCells; idx++)
1011 dstMacInst = ueRecfg->crgSCellCfg.ueSCellCfg[idx].macInst - RG_INST_START;
1012 ueSCellCb.cellId = ueRecfg->crgSCellCfg.ueSCellCfg[idx].sCellId;
1013 ueSCellCb.rguDlSapId = ueRecfg->crgSCellCfg.ueSCellCfg[idx].rguDlSapId;
1014 ueSCellCb.rguUlSapId = ueRecfg->crgSCellCfg.ueSCellCfg[idx].rguUlSapId;
1016 /* Get post structure of the cell to whom ueSCellCb needs to be sent
1017 * And then send the sCell Add based on Mac instances */
1018 rgGetPstToInst(&dstInstPst, inst, dstMacInst);
1019 RgPrgPMacSMacUeSCellCfg(&dstInstPst, &ueSCellCb);
1021 /*Commit Added SCell info to UeCb is moved to config confirm*/
1022 } /*end of for loop */
1026 } /* rgFillAndAddSCellCfg */
1027 #endif /* LTE_ADV */
1030 * @brief Handler for the UE configuration request from RRC to MAC.
1034 * Function : rgCFGCrgUeCfg
1037 * - Allocate and create UE control block.
1038 * - Update UE control block with the values recieved in the
1040 * - Invoke RAM, SCH, UHM and DHM with created UE control block, to
1041 * update random access, scheduler, uplink harq and downlink harq
1042 * specific information respectively.
1043 * - If successful, add the control block to hash list of UEs for the cell
1044 * else Rollback and FAIL.
1046 * @param[in] Inst inst
1047 * @param[in] RgCellCb *cell
1048 * @param[in] CrgUeCfg *ueCfg
1049 * @param[out] RgErrInfo *errInfo
1055 PUBLIC S16 rgCFGCrgUeCfg
1063 PUBLIC S16 rgCFGCrgUeCfg(inst,cell, ueCfg, errInfo)
1071 Bool handover = FALSE;
1072 SuId rguUlSapId = 0;
1073 SuId rguDlSapId = 0;
1075 TRC2(rgCFGCrgUeCfg);
1077 errInfo->errCause = RGERR_CFG_CRG_UE_CFG;
1079 /* Start: LTEMAC_2.1_DEV_CFG */
1080 if ((ue = rgDBMGetUeCbFromRachLst(cell, ueCfg->crnti)) == NULLP)
1082 /* Create UeCb and Insert in Rach List */
1083 if((ue=rgRAMCreateUeCb(cell, ueCfg->crnti, FALSE, errInfo)) == NULLP)
1085 RLOG_ARG0(L_ERROR,DBG_CRNTI,ueCfg->crnti,"UeCb creation failed");
1088 if(rgDHMHqEntInit(inst,&ue->dl.hqEnt, cell->maxDlHqProcPerUe) != ROK)
1090 RLOG_ARG0(L_ERROR,DBG_CRNTI,ueCfg->crnti,"UeCb Harq Entity Initialization failed");
1095 /* End: LTEMAC_2.1_DEV_CFG */
1097 if(handover == FALSE)
1099 /* Remove from the rachLst */
1100 rgDBMDelUeCbFromRachLst(cell, ue);
1104 /* Initialize uplink HARQ related information for UE */
1105 rgUHMCrgUeCfg(cell, ue, ueCfg);
1107 rgDBMInsUeCb(cell, ue);
1109 #ifdef TENB_MULT_CELL_SUPPRT
1110 rguDlSapId = ueCfg->rguDlSapId;
1111 rguUlSapId = ueCfg->rguUlSapId;
1113 if(rgCb[inst].numRguSaps > 1)
1119 ue->rguDlSap = &(rgCb[inst].rguSap[rguDlSapId]);
1120 ue->rguUlSap = &(rgCb[inst].rguSap[rguUlSapId]);
1123 /* Update satistics */
1124 rgUpdtUeCnt(inst,RG_CFG_ADD);
1125 errInfo->errCause = RGERR_NONE;
1127 } /* rgCFGCrgUeCfg */
1131 * @brief Handler for the logical channel configuration request from
1136 * Function : rgCFGCrgLcCfg
1139 * - Check if the configuration is for dedicated or common logical channel.
1140 * - For Dedicated logical channels:
1141 * - Update the dedicated logical channel Cb with the configured values.
1142 * - Invoke SCH will cell, UE and logical channel Cb to update scheduler
1143 * specific information.
1144 * - For Common logical channels:
1145 * - Update the common logical channel Cb with the configured values.
1146 * - Move cell to active list of cells if cell becomes ACTIVE.
1147 * - If successful, return ROK else RFAILED.
1149 * @param[in] Inst inst
1150 * @param[in] RgCellCb *cell
1151 * @param[in] RgUeCb *ue
1152 * @param[in] CrgLchCfg *lcCfg
1153 * @param[out] RgErrInfo *errInfo
1154 * @param[in] Bool *isCfmRqrd
1160 PUBLIC S16 rgCFGCrgLcCfg
1168 CrgCfgTransId transId
1171 PUBLIC S16 rgCFGCrgLcCfg(inst,cell, ue, lcCfg, errInfo, isCfmRqrd,transId)
1178 CrgCfgTransId transId;
1182 TRC2(rgCFGCrgLcCfg);
1184 /* Handle Config for dedicated/common logical channels */
1185 if (lcCfg->lcType == CM_LTE_LCH_DTCH || lcCfg->lcType == CM_LTE_LCH_DCCH)
1188 if ((rgCFGCrgDedLcCfg(cell, ue, lcCfg, errInfo)) != ROK)
1190 RLOG_ARG1(L_ERROR,DBG_CRNTI,lcCfg->crnti,
1191 "Dedicated logical channel configuration failed %d",lcCfg->lcId);
1195 /*ERAB Multl Cell fix*/
1196 cmMemcpy( (U8*)&(ue->cfgCfmInfo.transId), (U8*)&transId,
1197 sizeof(CrgCfgTransId));
1198 rgPomSndUeSCellLchAddToSmac(inst, cell, ue, lcCfg,isCfmRqrd);
1203 if ((rgCFGCrgCmnLcCfg(inst,cell, lcCfg, errInfo)) != ROK)
1205 RLOG_ARG1(L_ERROR, DBG_CRNTI, lcCfg->crnti, "Common logical channel configuration"
1206 "failed %d\n", lcCfg->lcId);
1211 errInfo->errCause = RGERR_NONE;
1212 RLOG_ARG1(L_INFO, DBG_CRNTI,lcCfg->crnti, "CRG LC config done for UE: lcId %d\n", lcCfg->lcId);
1214 } /* rgCFGCrgLcCfg */
1218 * @brief Handler for the cell re-configuration request from RRC to MAC.
1222 * Function : rgCFGCrgCellRecfg
1225 * - Invoke SCH with updated Cell Cb to update scheduler specific
1227 * - Update the cell Cb with the reconfigured values.
1228 * - If successful, return ROK else RFAILED.
1230 * @param[in] Inst inst
1231 * @param[in] RgCellCb *cell
1232 * @param[in] CrgCellRecfg *cellRecfg
1233 * @param[out] RgErrInfo *errInfo
1239 PUBLIC S16 rgCFGCrgCellRecfg
1243 CrgCellRecfg *cellRecfg,
1247 PUBLIC S16 rgCFGCrgCellRecfg(inst,cell, cellRecfg, errInfo)
1250 CrgCellRecfg *cellRecfg;
1254 TRC2(rgCFGCrgCellRecfg);
1256 /* Store the given rachCfg */
1257 cell->rachCfg = cellRecfg->rachRecfg;
1259 errInfo->errCause = RGERR_NONE;
1261 } /* rgCFGCrgCellRecfg */
1265 * @brief Handler for the UE re-configuration request from RRC to MAC.
1269 * Function : rgCFGCrgUeRecfg
1272 * - If rnti changes,
1273 * - Invoke RAM for UE reconfiguration.
1274 * - Delete old UE from the list.
1275 * - Update the new rnti and re-insert the UE in the list.
1276 * - Update the UE control block with the reconfigured values.
1277 * - Invoke SCH, UHM and DHM with updated UE control block to
1278 * update scheduler, uplink HARQ and downlink HARQ specific
1280 * - If successful, return ROK else RFAILED.
1282 * @param[in] Inst inst
1283 * @param[in] RgCellCb *cell
1284 * @param[in] RgUeCb *ue
1285 * @param[in] CrgUeRecfg *ueRecfg
1286 * @param[out] RgErrInfo *errInfo
1292 PUBLIC S16 rgCFGCrgUeRecfg
1297 CrgUeRecfg *ueRecfg,
1301 PUBLIC S16 rgCFGCrgUeRecfg(inst,cell, ue, ueRecfg, errInfo)
1305 CrgUeRecfg *ueRecfg;
1309 TRC2(rgCFGCrgUeRecfg);
1311 errInfo->errCause = RGERR_CFG_CRG_UE_RECFG;
1313 /* Fix : syed UE ID change at MAC will now be controlled
1316 /* Update uplink HARQ related information for UE */
1317 rgUHMCrgUeRecfg(cell, ue, ueRecfg);
1319 errInfo->errCause = RGERR_NONE;
1321 } /* rgCFGCrgUeRecfg */
1325 * @brief Handler for the logical channel re-configuration request from
1330 * Function : rgCFGCrgLcRecfg
1333 * - Invoke scheduler to update scheduler specific information.
1334 * - Update the dedicated logical channel Cb with the re-configured
1336 * - If successful, return ROK else RFAILED.
1338 * @param[in] Inst inst
1339 * @param[in] RgUlCellCb *cell
1340 * @param[in] RgUlUeCb *ue
1341 * @param[in] RgUlLcCb *ulLc
1342 * @param[in] RgDlLcCb *dlLc
1343 * @param[in] CrgLchRecfg *lcRecfg
1344 * @param[out] RgErrInfo *errInfo
1350 PUBLIC S16 rgCFGCrgLcRecfg
1356 CrgLchRecfg *lcRecfg,
1361 PUBLIC S16 rgCFGCrgLcRecfg(inst,cell, ue, ulLc, lcRecfg, errInfo, isCfmRqrd)
1366 CrgLchRecfg *lcRecfg;
1371 TRC2(rgCFGCrgLcRecfg);
1373 if (ulLc->lcgId != lcRecfg->ulRecfg.lcgId)
1375 rgDBMUpdUlDedLcCb(ue, ulLc, lcRecfg->ulRecfg.lcgId);
1377 rgPomSndUeSCellLchModToSmac(inst, cell, ue, lcRecfg,isCfmRqrd);
1381 errInfo->errCause = RGERR_NONE;
1383 } /* rgCFGCrgLcRecfg */
1385 /* Start: LTEMAC_2.1_DEV_CFG */
1387 * @brief Handler for the logical channel re-configuration request from
1392 * Function : rgCFGCrgUeReset
1396 * @param[in] RgUlCellCb *cell
1397 * @param[in] RgUlUeCb *ue
1398 * @param[in] CrgRst *reset
1399 * @param[out] RgErrInfo *errInfo
1405 PUBLIC S16 rgCFGCrgUeReset
1413 PUBLIC S16 rgCFGCrgUeReset(cell, ue, reset, errInfo)
1420 TRC2(rgCFGCrgUeReset);
1422 RLOG_ARG1(L_DEBUG, DBG_CRNTI, ue->ueId, "UE: of cell %d Reset\n", cell->cellId);
1423 rgDHMUeReset(cell, &ue->dl.hqEnt);
1425 errInfo->errCause = RGERR_NONE;
1428 } /* rgCFGCrgUeReset */
1429 /* End: LTEMAC_2.1_DEV_CFG */
1432 * @brief Handler for the cell delete request from RRC to MAC.
1436 * Function : rgCFGCrgCellDel
1439 * - Fetch the cell control block.
1440 * - Remove the cell control block from the hash list of cells.
1441 * - Free the cell control block.
1442 * - If successful, return ROK else return RFAILED.
1444 * @param[in] Inst inst
1445 * @param[in] CrgDel *cellDelInfo
1446 * @param[out] RgErrInfo *errInfo
1452 PUBLIC S16 rgCFGCrgCellDel
1455 CrgDel *cellDelInfo,
1459 PUBLIC S16 rgCFGCrgCellDel(inst,cellDelInfo, errInfo)
1461 CrgDel *cellDelInfo;
1468 TRC2(rgCFGCrgCellDel);
1470 errInfo->errCause = RGERR_CFG_CRG_CELL_DEL;
1471 if (((cell = rgCb[inst].cell) == NULLP)
1472 ||(cell->cellId != cellDelInfo->u.cellDel.cellId))
1474 if(((cell = rgCb[inst].inactiveCell) == NULLP)
1475 ||(cell->cellId != cellDelInfo->u.cellDel.cellId))
1479 RLOG_ARG0(L_ERROR,DBG_CELLID,cellDelInfo->u.cellDel.cellId,"Cell does not exist");
1483 /* Delete cell from inactive list */
1484 rgCb[inst].inactiveCell = NULLP ;
1486 /* Free the inactive cell */
1487 rgCFGFreeInactvCellCb(cell);
1489 errInfo->errCause = RGERR_NONE;
1493 /* Delete from the cell list */
1494 //rgDBMDelCellCb(cell);
1495 for(idx=0;idx < RG_NUM_SUB_FRAMES; idx++)
1497 rgTOMRlsSf(inst,&cell->subFrms[idx]);
1500 /* Free the active cell */
1501 rgCFGFreeCellCb(cell);
1503 rgCb[inst].cell = NULLP;
1505 errInfo->errCause = RGERR_NONE;
1506 RGDBGINFO(inst,(rgPBuf(inst), "Cell %d deleted\n", cellDelInfo->u.cellDel.cellId));
1508 } /* rgCFGCrgCellDel */
1512 * @brief Handler for the UE delete request from RRC to MAC.
1516 * Function : rgCFGCrgUeDel
1519 * - Fetch the UE control block.
1520 * - Remove the UE control block from the hash list of UEs for the cell.
1521 * - Free the UE control block.
1522 * - If successful, return ROK else return RFAILED.
1524 * @param[in] Inst inst
1525 * @param[in] CrgDel *ueDelInfo
1526 * @param[out] RgErrInfo *errInfo
1532 PUBLIC S16 rgCFGCrgUeDel
1539 PUBLIC S16 rgCFGCrgUeDel(inst,ueDelInfo, errInfo)
1545 TRC2(rgCFGCrgUeDel);
1547 errInfo->errCause = RGERR_CFG_CRG_UE_DEL;
1549 RLOG_ARG1(L_DEBUG, DBG_CRNTI, ueDelInfo->u.ueDel.crnti, "UE %d Deletion Req at MAC\n", \
1550 ueDelInfo->u.ueDel.crnti);
1551 if ((rgCb[inst].cell == NULLP)
1552 || (rgCb[inst].cell->cellId != ueDelInfo->u.ueDel.cellId))
1554 RLOG_ARG1(L_ERROR,DBG_CRNTI,ueDelInfo->u.ueDel.crnti,"Cell does not exist %d",
1555 ueDelInfo->u.ueDel.cellId);
1559 errInfo->errCause = RGERR_NONE;
1560 /* Fix: syed Context Deletion is relied upon SCH indication */
1562 } /* rgCFGCrgUeDel */
1566 * @brief Handler for the logical channel delete request from
1571 * Function : rgCFGCrgLcDel
1574 * - Fetch the logical channel control block.
1575 * - Free the logical channel control block.
1576 * - If successful, return ROK else return RFAILED.
1578 * @param[in] Inst inst
1579 * @param[in] CrgDel *lcDelInfo
1580 * @param[out] RgErrInfo *errInfo
1586 PUBLIC S16 rgCFGCrgLcDel
1592 CrgCfgTransId transId
1595 PUBLIC S16 rgCFGCrgLcDel(inst,lcDelInfo, errInfo,isCfmRqrd,transId)
1599 CrgCfgTransId transId;
1602 Bool dirVld = FALSE;
1608 TRC2(rgCFGCrgLcDel);
1610 errInfo->errCause = RGERR_CFG_CRG_LC_DEL;
1612 /* Fetch the Active cell */
1613 if (((cell = rgCb[inst].cell) == NULLP) ||
1614 (rgCb[inst].cell->cellId != lcDelInfo->u.lchDel.cellId))
1616 RLOG_ARG1(L_ERROR,DBG_CRNTI,lcDelInfo->u.lchDel.crnti,"Cell does not exist %d",
1617 lcDelInfo->u.lchDel.cellId);
1622 if ((ue = rgDBMGetUeCb(cell, lcDelInfo->u.lchDel.crnti)) == NULLP)
1624 RLOG_ARG0(L_ERROR,DBG_CRNTI,lcDelInfo->u.lchDel.crnti,
1625 "UE does not exist for dedicated logical channel");
1629 /* Validate downlink info */
1630 if (lcDelInfo->u.lchDel.dir & CRG_DIR_TX)
1632 if ((dlLc = rgDBMGetDlDedLcCb(ue, lcDelInfo->u.lchDel.lcId))
1635 RLOG_ARG1(L_ERROR,DBG_CRNTI,lcDelInfo->u.lchDel.crnti,"DL LC %d does not exist",
1636 lcDelInfo->u.lchDel.lcId);
1639 rgDBMDelDlDedLcCb(ue, dlLc);
1643 /* Validate uplink info */
1644 if (lcDelInfo->u.lchDel.dir & CRG_DIR_RX)
1646 if ((ulLc = rgDBMGetUlDedLcCb(ue, lcDelInfo->u.lchDel.lcId))
1649 RLOG_ARG1(L_ERROR,DBG_CRNTI,lcDelInfo->u.lchDel.crnti,"UL LC %d does not exist",
1650 lcDelInfo->u.lchDel.lcId);
1653 rgDBMDelUlDedLcCb(ue, ulLc);
1659 RLOG_ARG1(L_ERROR,DBG_CRNTI,lcDelInfo->u.lchDel.crnti,"Invalid direction %d for LC Delete",
1660 lcDelInfo->u.lchDel.dir);
1664 /*ERAB - multicell fix*/
1665 cmMemcpy( (U8*)&(ue->cfgCfmInfo.transId), (U8*)&transId,
1666 sizeof(CrgCfgTransId));
1667 rgPomSndUeSCellLchDelToSmac(inst, lcDelInfo, isCfmRqrd);
1669 errInfo->errCause = RGERR_NONE;
1671 } /* rgCFGCrgLcDel */
1673 /***********************************************************
1675 * Func : rgCFGVldtCrgDedLcCfg
1678 * Desc : Validates dedicated logical channel configuration recieved from RRC.
1688 **********************************************************/
1690 PRIVATE S16 rgCFGVldtCrgDedLcCfg
1699 PRIVATE S16 rgCFGVldtCrgDedLcCfg(inst,lcCfg, cell, ue, errInfo)
1708 TRC2(rgCFGVldtCrgDedLcCfg);
1710 errInfo->errCause = RGERR_CFG_INVALID_CRG_DED_LC_CFG;
1712 /* Fetch the Active cell */
1713 if (((*cell = rgCb[inst].cell) == NULLP)
1714 || ((*cell)->cellId != lcCfg->cellId))
1716 RLOG_ARG1(L_ERROR,DBG_CRNTI,lcCfg->crnti,"Active Cell does not exist: Cell %d",
1722 if ((*ue = rgDBMGetUeCb(*cell, lcCfg->crnti)) == NULLP)
1724 RLOG_ARG1(L_ERROR,DBG_CRNTI,lcCfg->crnti,"UE does not exist for dedicated logical channel %d",
1729 /* Validate logical channel Id */
1730 if ((lcCfg->lcId < RG_DEDLC_MIN_LCID)
1731 ||(lcCfg->lcId > RG_DEDLC_MAX_LCID))
1733 RLOG_ARG1(L_ERROR,DBG_CRNTI,lcCfg->crnti,"Invalid logical channel Id %d",
1738 /* Validate downlink info */
1739 if (lcCfg->dir & CRG_DIR_TX)
1741 if (rgDBMGetDlDedLcCb((*ue), lcCfg->lcId) != NULLP)
1743 RLOG_ARG1(L_ERROR,DBG_CRNTI,lcCfg->crnti,"UE: Dedicated DL LC %d already configured",
1750 /* Validate uplink info */
1751 if (lcCfg->dir & CRG_DIR_RX)
1753 if (lcCfg->ulInfo.lcgId > (RG_MAX_LCG_PER_UE - 1))
1755 RLOG_ARG1(L_ERROR,DBG_CRNTI,lcCfg->crnti,"UE: Invalid lcgId for uplink logical channel %d",
1756 lcCfg->ulInfo.lcgId);
1759 if (rgDBMGetUlDedLcCb((*ue), lcCfg->lcId) != NULLP)
1761 RLOG_ARG1(L_ERROR,DBG_CRNTI,lcCfg->crnti,"UE: Dedicated UL LC %d already configured",
1770 RLOG_ARG1(L_ERROR,DBG_CRNTI,lcCfg->crnti,"Invalid Direction %d",
1776 } /* rgCFGVldtCrgDedLcCfg */
1779 /***********************************************************
1781 * Func : rgCFGVldtCrgCmnLcCfg
1784 * Desc : Validates common logical channel configuration recieved from RRC.
1794 **********************************************************/
1796 PRIVATE S16 rgCFGVldtCrgCmnLcCfg
1804 PRIVATE S16 rgCFGVldtCrgCmnLcCfg(inst,lcCfg, cell, errInfo)
1813 TRC2(rgCFGVldtCrgCmnLcCfg);
1815 errInfo->errCause = RGERR_CFG_INVALID_CRG_CMN_LC_CFG;
1817 /* Ensure cell is not in the active list */
1818 if (((*cell = rgCb[inst].cell) != NULLP)
1819 && ((*cell)->cellId != lcCfg->cellId))
1821 RLOG_ARG0(L_ERROR,DBG_CELLID,lcCfg->cellId,"Active Cell exists for common channels");
1825 /* Fetch the inactive cell for common logical channels */
1826 if (((*cell = rgCb[inst].inactiveCell) == NULLP)
1827 || ((*cell)->cellId != lcCfg->cellId))
1830 RLOG_ARG0(L_ERROR,DBG_CELLID,lcCfg->cellId,"Inactive Cell does not exist for common channels");
1833 /* Validate downlink info */
1834 if (lcCfg->dir & CRG_DIR_TX)
1836 if (lcCfg->lcType == CM_LTE_LCH_BCCH)
1838 if (lcCfg->dlInfo.dlTrchType == CM_LTE_TRCH_DL_SCH)
1840 if (rgDBMGetBcchOnDlsch(*cell,lcCfg->lcId) != NULLP)
1842 RLOG_ARG0(L_ERROR,DBG_CELLID,lcCfg->cellId,"BCCH on DLSCH already configured for cell");
1846 else if (lcCfg->dlInfo.dlTrchType == CM_LTE_TRCH_BCH)
1848 if (rgDBMGetBcchOnBch(*cell) != NULLP)
1850 RLOG_ARG0(L_ERROR,DBG_CELLID,lcCfg->cellId,"BCCH on BCH already configured for cell %d");
1856 RLOG_ARG1(L_ERROR,DBG_CELLID,lcCfg->cellId,"Invalid transport channel %d for cell",
1857 lcCfg->dlInfo.dlTrchType);
1861 else if (lcCfg->lcType == CM_LTE_LCH_PCCH)
1863 if (rgDBMGetPcch(*cell) != NULLP)
1865 RLOG_ARG0(L_ERROR,DBG_CELLID,lcCfg->cellId,"PCCH already configured for cell");
1869 else if (RG_DLCCCH_ISCFGD(*cell))
1871 RLOG_ARG0(L_ERROR,DBG_CELLID,lcCfg->cellId,"DL CCCH already configured for cell %d");
1877 /* Validate uplink info */
1878 if (lcCfg->dir & CRG_DIR_RX)
1881 if (lcCfg->lcType != CM_LTE_LCH_CCCH)
1883 RLOG_ARG1(L_ERROR,DBG_CELLID,lcCfg->cellId,"Invalid UL common lcType %d for cell ",
1887 if (RG_ULCCCH_ISCFGD(*cell))
1889 RLOG_ARG0(L_ERROR,DBG_CELLID,lcCfg->cellId,"UL CCCH already configured for cell ");
1895 /* Invalid direction */
1898 RLOG_ARG1(L_ERROR,DBG_CELLID,lcCfg->cellId,"Invalid Direction %d", lcCfg->dir);
1903 } /* rgCFGVldtCrgCmnLcCfg */
1905 /***********************************************************
1907 * Func : rgCFGCrgDedLcCfg
1910 * Desc : Handles dedicated logical channel configuration
1911 * recieved from RRC.
1921 **********************************************************/
1923 PRIVATE S16 rgCFGCrgDedLcCfg
1931 PRIVATE S16 rgCFGCrgDedLcCfg(cell, ue, lcCfg, errInfo)
1938 //Inst inst = cell->macInst - RG_INST_START;
1939 TRC2(rgCFGCrgDedLcCfg);
1941 errInfo->errCause = RGERR_CFG_CRG_DED_LC_CFG;
1943 /* Uplink/Bi-directional logical channel */
1944 if (lcCfg->dir & CRG_DIR_RX)
1947 rgDBMInsUlDedLcCb(ue, lcCfg->lcId, lcCfg->ulInfo.lcgId, lcCfg->qci);
1948 cell->qciArray[lcCfg->qci].qci = lcCfg->qci;
1949 if(lcCfg->lcType == CM_LTE_LCH_DTCH)
1951 rgAddToL2MeasPerQci(cell,lcCfg->qci);/*LTE_L2_MEAS_PHASE2*/
1954 rgDBMInsUlDedLcCb(ue, lcCfg->lcId, lcCfg->ulInfo.lcgId);
1958 /* Downlink/Bi-directional logical channel */
1959 if (lcCfg->dir & CRG_DIR_TX)
1961 rgDBMInsDlDedLcCb(ue, lcCfg->lcId);
1964 } /* rgCFGCrgDedLcCfg */
1967 /***********************************************************
1969 * Func : rgCFGCrgCmnLcCfg
1972 * Desc : Handles dedicated logical channel configuration
1973 * recieved from RRC.
1983 **********************************************************/
1985 PRIVATE S16 rgCFGCrgCmnLcCfg
1993 PRIVATE S16 rgCFGCrgCmnLcCfg(inst,cell, lcCfg, errInfo)
2000 TRC2(rgCFGCrgCmnLcCfg);
2002 errInfo->errCause = RGERR_CFG_CRG_CMN_LC_CFG;
2004 /* Handle configuration for CCCH/BCCH/PCCH */
2005 if (lcCfg->lcType == CM_LTE_LCH_CCCH)
2007 /* UL and DL CCCH configuration */
2008 if (lcCfg->dir & CRG_DIR_TX)
2010 cell->dlCcchId = lcCfg->lcId;
2011 cell->cellActvState |= RG_DL_CCCH_CFG_DONE;
2014 if (lcCfg->dir & CRG_DIR_RX)
2016 cell->ulCcchId = lcCfg->lcId;
2017 cell->cellActvState |= RG_UL_CCCH_CFG_DONE;
2022 if (lcCfg->lcType == CM_LTE_LCH_BCCH)
2024 /* BCCH on BCH and DLSCH configuration */
2025 if (lcCfg->dlInfo.dlTrchType == CM_LTE_TRCH_DL_SCH)
2027 rgDBMInsBcchOnDlsch(cell, lcCfg->lcId);
2029 if(cell->cellActvState & RG_BCCH_DLSCH_CFG1_DONE)
2031 cell->cellActvState |= RG_BCCH_DLSCH_CFG2_DONE;
2035 cell->cellActvState |= RG_BCCH_DLSCH_CFG1_DONE;
2040 rgDBMInsBcchOnBch(cell, lcCfg->lcId);
2041 cell->cellActvState |= RG_BCCH_BCH_CFG_DONE;
2044 else /* PCCH configuration */
2046 rgDBMInsPcch(cell, lcCfg->lcId);
2047 cell->cellActvState |= RG_PCCH_CFG_DONE;
2051 /* Add to active cell list if cell is active */
2052 if (cell->cellActvState == RG_CELL_ACTIVE)
2054 rgCb[inst].cell = cell;
2055 rgCb[inst].inactiveCell = NULLP;
2056 RLOG_ARG1(L_DEBUG, DBG_CELLID, cell->cellId, "Cell %d added to active list after common LC %d\
2057 config\n", lcCfg->lcId);
2061 } /* rgCFGCrgCmnLcCfg */
2063 /***********************************************************
2065 * Func : rgCFGFreeUeUlAlloc
2069 * - Processing Steps:
2070 * - Frees cell control block.
2078 **********************************************************/
2080 PRIVATE Void rgCFGFreeUeUlAlloc
2085 PRIVATE Void rgCFGFreeUeUlAlloc(cell)
2090 Inst inst = cell->macInst - RG_INST_START;
2092 TRC2(rgCFGFreeUeUlAlloc);
2094 for(sfIdx = 0; sfIdx < RG_NUM_UL_SUB_FRAMES; sfIdx++)
2096 if(cell->ulSf[sfIdx].ueUlAllocInfo != NULLP)
2098 /*ccpu00117052 - MOD- Passing double pointer for proper
2099 * NULLP assignment */
2100 rgFreeSBuf(inst,(Data **)&(cell->ulSf[sfIdx].ueUlAllocInfo),
2101 (cell->ulSf[sfIdx].numUe * sizeof(RgUeUlAlloc)));
2104 }/* rgCFGFreeUeUlAlloc */
2106 /***********************************************************
2108 * Func : rgCFGFreeCellCb
2112 * - Processing Steps:
2113 * - Frees cell control block.
2121 **********************************************************/
2123 PUBLIC Void rgCFGFreeCellCb
2128 PUBLIC Void rgCFGFreeCellCb(cell)
2132 Inst inst = cell->macInst - RG_INST_START;
2133 TRC2(rgCFGFreeCellCb);
2136 RgLaaCellCbDeInit(cell);
2138 /* Free lists of the cell */
2140 rgCFGFreeSpsUeLst(cell);
2141 #endif /* LTEMAC_SPS */
2142 rgCFGFreeUeLst(cell);
2143 rgRAMFreeCell(cell);
2144 rgCFGFreeCmnLcLst(cell);
2146 rgCFGFreeUeUlAlloc(cell);
2148 /* ccpu00117052 - MOD - Passing double pointer for proper NULLP
2150 /* Update satistics */
2151 rgUpdtCellCnt(inst,RG_CFG_DEL);
2152 rgDHMFreeAllTbBufs(inst);
2154 rgFreeSBuf(inst,(Data **)&cell->flowCntrlInd, sizeof(RguFlowCntrlInd));
2156 /* De-allocate the Cell */
2157 rgFreeSBuf(inst,(Data **)&cell, sizeof(*cell));
2160 RGDBGINFO(inst,(rgPBuf(inst), "Cell freed\n"));
2162 /* Stack Crash Problem for TRACE5 Changes. Added return below */
2164 } /* rgCFGFreeCellCb */
2167 /***********************************************************
2169 * Func : rgCFGFreeInactvCellCb
2173 * - Processing Steps:
2174 * - Frees inactive cell control block.
2182 **********************************************************/
2184 PUBLIC Void rgCFGFreeInactvCellCb
2189 PUBLIC Void rgCFGFreeInactvCellCb(cell)
2193 Inst inst = cell->macInst - RG_INST_START;
2194 TRC2(rgCFGFreeInactvCellCb);
2196 /* De-initialize the Ue list */
2197 rgDBMDeInitUeCbLst(cell);
2199 rgDBMDeInitSpsUeCbLst(cell);
2202 rgCFGFreeCmnLcLst(cell);
2204 rgFreeSBuf(inst, (Data **)&cell->flowCntrlInd, sizeof(RguFlowCntrlInd));
2205 /*ccpu00117052 - MOD- Passing double pointer for proper
2207 /* De-allocate the Cell */
2208 rgFreeSBuf(inst,(Data **)&cell, sizeof(*cell));
2210 /* Update satistics */
2211 rgUpdtCellCnt(inst,RG_CFG_DEL);
2214 /* Stack Crash Problem for TRACE5 Changes. Added return below */
2216 } /* rgCFGFreeInactvCellCb */
2219 /***********************************************************
2221 * Func : rgCFGFreeUeCb
2225 * - Processing Steps:
2226 * - Frees UE control block.
2234 **********************************************************/
2236 PUBLIC Void rgCFGFreeUeCb
2242 PUBLIC Void rgCFGFreeUeCb(cell, ue)
2247 Inst inst = cell->macInst - RG_INST_START;
2249 TRC2(rgCFGFreeUeCb);
2251 rgDHMFreeUe(inst,&ue->dl.hqEnt);
2253 /* ccpu00117052 - MOD - Passing double pointer for proper NULLP
2255 /* De-allocate the Ue */
2256 rgFreeSBuf(inst,(Data **)&ue, sizeof(*ue));
2258 /* Update Statistics */
2259 rgUpdtUeCnt(inst,RG_CFG_DEL);
2262 /* Stack Crash Problem for TRACE5 Changes. Added return below */
2264 } /* rgCFGFreeUeCb */
2266 /***********************************************************
2268 * Func : rgCFGFreeCmnLcLst
2272 * - Processing Steps:
2273 * - Frees common logical channels in cell control block.
2281 **********************************************************/
2283 PRIVATE Void rgCFGFreeCmnLcLst
2288 PRIVATE Void rgCFGFreeCmnLcLst(cell)
2292 TRC2(rgCFGFreeCmnLcLst);
2294 rgDBMFreeCmnLcLst(cell);
2297 /* Stack Crash Problem for TRACE5 Changes. Added return below */
2299 } /* rgCFGFreeCmnLcLst */
2302 /***********************************************************
2304 * Func : rgCFGFreeUeLst
2308 * - Processing Steps:
2309 * - Frees UE list in cell control block.
2317 **********************************************************/
2319 PRIVATE Void rgCFGFreeUeLst
2324 PRIVATE Void rgCFGFreeUeLst(cell)
2330 TRC2(rgCFGFreeUeLst);
2332 /* Free Ues in the list */
2333 while ((ue = rgDBMGetNextUeCb(cell, NULLP)) != NULLP)
2336 rgDelUeFrmAllSCell(cell,ue);
2338 rgDBMDelUeCb(cell, ue);
2339 rgCFGFreeUeCb(cell, ue);
2342 /* De-initialize the Ue list */
2343 rgDBMDeInitUeCbLst(cell);
2346 /* Stack Crash Problem for TRACE5 Changes. Added return below */
2348 } /* rgCFGFreeUeLst */
2351 /***********************************************************
2353 * Func : rgCFGFreeSpsUeLst
2357 * - Processing Steps:
2358 * - Frees Sps UE list in cell control block.
2366 **********************************************************/
2368 PRIVATE Void rgCFGFreeSpsUeLst
2373 PRIVATE Void rgCFGFreeSpsUeLst(cell)
2379 TRC2(rgCFGFreeSpsUeLst);
2381 /* Free Ues in the list */
2382 while ((ue = rgDBMGetNextSpsUeCb(cell, NULLP)))
2384 rgDBMDelSpsUeCb(cell, ue);
2387 /* De-initialize the Ue list */
2388 rgDBMDeInitSpsUeCbLst(cell);
2390 } /* rgCFGFreeSpsUeLst */
2392 #endif /* LTEMAC_SPS */
2395 * @brief Function for registering cell- scheduler instance mapping
2399 * Function : RgSchMacCellRegReq
2401 * This function shall be invoked whenever scheduler is done with the
2402 * cell configuration successfully.
2403 * This shall create a mapping of the cell, scheduler instance that
2404 * is serving the cell and the unique identifier of the cell on the
2405 * scheduler at MAC. This mapping shall be used for further
2406 * communication to the scheduler instance for this cell.
2409 * @param[in] Pst* pst,
2410 * @param[in] CmLteCellId cellId,
2411 * @param[in] RaRespReqInfo raRespReq
2416 PUBLIC S16 RgSchMacCellRegReq
2419 RgInfCellReg* regReq
2422 PUBLIC S16 RgSchMacCellRegReq(pst, regReq)
2424 RgInfCellReg* regReq;
2428 RgCellCb *cell = NULLP;
2430 TRC3(RgSchMacCellRegReq)
2432 RG_IS_INST_VALID(pst->dstInst);
2433 inst = pst->dstInst - RG_INST_START;
2434 cell = rgCb[inst].cell;
2441 if((cell == NULLP) || (cell->cellId != regReq->cellId))
2445 if(regReq->maxDlHqProcPerUe > RG_MAX_DL_HARQ_NUM)
2450 cell->schInstMap.cellSapId = regReq->cellSapId;
2451 cell->schInstMap.schInst = pst->srcInst;
2452 cell->maxDlHqProcPerUe = regReq->maxDlHqProcPerUe;
2456 } /* end of RgSchMacCellRegReq */
2458 /*Added Ue for Onging L2 Meas*/
2460 /*LTE_L2_MEAS_PHASE2*/
2461 PUBLIC S16 rgAddToL2MeasPerQci(RgCellCb *cell,U8 qci)
2468 lnk = cell->l2mList.first;
2469 while(lnk != NULLP )
2471 measCb = (RgL2MeasCb *)lnk->node;
2472 if(measCb->measReq.measType & LRG_L2MEAS_AVG_PRB_PER_QCI_UL)
2474 for(idx = 0;idx< measCb->measReq.t.prbReq.numQci;idx++)
2476 if(measCb->measReq.t.prbReq.qci[idx] == qci)
2478 break; /*exit from for loop*/
2481 if(idx == measCb->measReq.t.prbReq.numQci)
2483 cell->qciArray[qci].mask = TRUE;
2484 measCb->measReq.t.prbReq.qci[measCb->measReq.t.prbReq.numQci++] = qci;
2498 /**********************************************************************
2501 **********************************************************************/