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 the schedulers main access to MAC layer code.
36 /* header include files -- defines (.h) */
37 #include "common_def.h"
43 #include "rg_sch_inf.h"
45 #include "rg_sch_err.h"
46 #include "rg_sch_cmn.h"
47 #include "sch_utils.h"
49 /* header/extern include files (.x) */
50 #include "tfu.x" /* TFU types */
51 #include "lrg.x" /* layer management typedefs for MAC */
52 #include "rgr.x" /* layer management typedefs for MAC */
53 #include "rgm.x" /* layer management typedefs for MAC */
54 #include "rg_sch_inf.x" /* typedefs for Scheduler */
55 #include "rg_sch.x" /* typedefs for Scheduler */
56 #include "rg_sch_cmn.x"
57 #include "mac_sch_interface.h"
60 S16 rgEmtcMacSchUeDelInd ARGS((RgSchCellCb *cell,RgInfUeDelInd *ueDelInd));
61 S16 rgSCHGomEmtcHndlSiCfg ARGS((
66 RgrCfgTransId transId,
67 RgrSiCfgReqInfo *cfgReqInfo
69 S16 rgSCHGomEmtcHndlWarningSiCfg ARGS((
74 RgrCfgTransId transId,
75 RgrWarningSiCfgReqInfo *warningSiCfgReqInfo
79 /************** LRG Interface ****************/
82 * @brief Layer Manager Control request handler.
86 * Function : RgMiLrgSchCntrlReq
88 * This function handles the control
89 * request received from the Layer Manager.
90 * -# Based on cntrl->hdr.elmId.elmnt, cntrl->t.cntrl.action
91 * and cntrl->t.cntrl.subAction, it performs the appropriate control action
92 * of SAP (enable/disable) and layer shutdown.
93 * -# Invokes the RgMiLrgSchCntrlCfm to send back the confirmation to LM.
95 * @param[in] Pst *pst, the post structure
96 * @param[in] RgMngmt *cntrl, the control parameter's structure
100 S16 RgMiLrgSchCntrlReq
102 Pst *pst, /* post structure */
103 RgMngmt *cntrl /* control structure */
106 S16 ret = ROK; /* return value */
110 Inst inst = (pst->dstInst - SCH_INST_START); /* Scheduler instance Id */
112 /* Fill the post structure for sending the confirmation */
113 SchFillCfmPst(pst, &cfmPst, cntrl);
115 /* Initialize the cfg cfm structure
116 SCH_ALLOC(cfm, sizeof(RgMngmt));
119 DU_LOG("\nERROR --> SCH : Memory Unavailable for Confirmation");
120 SCH_FREE(pst->region, pst->pool, cntrl, sizeof(RgMngmt));
123 memset(&cfm, 0, sizeof(RgMngmt));
130 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
131 cfm.t.cntrl.action = cntrl->t.cntrl.action;
132 cfm.t.cntrl.subAction = cntrl->t.cntrl.subAction;
134 /* Check if General Config Done*/
135 if(rgSchCb[inst].rgSchInit.cfgDone != TRUE)
137 cfm.cfm.status = LCM_PRIM_NOK;
138 cfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE;
139 cfm.hdr.elmId.elmnt = cntrl->hdr.elmId.elmnt;
140 RgMiLrgSchCntrlCfm(&cfmPst, &cfm);
141 DU_LOG("\nERROR --> SCH : Gen Cfg not done.");
142 /* SCH_FREE(pst->region, pst->pool, cntrl, sizeof(RgMngmt)); */
146 /* General Config done, process the Control request */
147 switch(cntrl->hdr.elmId.elmnt)
150 rgSCHLmmGenCntrl(cntrl, &cfm, &cfmPst);
154 rgSCHLmmSapCntrl(cntrl, &cfm, &cfmPst);
157 cfm.cfm.status = LCM_PRIM_NOK;
158 cfm.cfm.reason = LCM_REASON_INVALID_PAR_VAL;
159 RgMiLrgSchCntrlCfm(&cfmPst, &cfm);
160 DU_LOG("\nERROR --> SCH : invalid elmnt=%d",
161 cntrl->hdr.elmId.elmnt);
164 /* SCH_FREE(pst->region, pst->pool, cntrl, sizeof(RgMngmt)); */
166 }/*-- RgMiLrgSchCntrlReq --*/
170 * @brief Layer Manager L2 Measurement request handler.
174 * Function : RgMiLrgSchL2MeasReq
176 * This function handles the control
177 * measurement request received from the Layer Manager.
179 * @param[in] Pst *pst, the post structure
180 * @param[in] LrgSchMeasReqInfo *measInfo, measurement request info
184 S16 RgMiLrgSchL2MeasReq
186 Pst *pst, /* post structure */
187 LrgSchMeasReqInfo *measInfo /* Meas Req Info */
194 RgSchCb *instCb = &rgSchCb[(pst->dstInst - SCH_INST_START)];
195 #if (ERRCLASS & ERRCLS_ADD_RES)
199 RgSchL2MeasCb *measCb = NULLP;
201 Inst inst = (pst->dstInst - SCH_INST_START); /* Scheduler instance Id */
208 /* Find the cellCb using cellId in measInfo. Iterate through all cells
209 * in rgrsapCb in RgschCb */
211 for (idx = 0; idx < instCb->numSaps; idx++)
213 if ( instCb->rgrSap[idx].cell->cellId == measInfo->cellId)
215 /* got the cell break the loop */
216 cell = instCb->rgrSap[idx].cell;
220 /* If no cellCb return Err with Invalid Cell Id */
223 rgSchL2mFillCfmPst(pst, &cfmPst, measInfo);
224 RGSCHFILLERR(err, RGSCHERR_L2M_MEASREQ, RGSCHERR_SCH_INVALID_CELLID);
225 rgSchL2mSndCfm(&cfmPst, NULLP, measInfo, TRUE);
226 DU_LOG("\nERROR --> SCH : Meas req Failed.Invalid Cell Id errType(%d) errCause(%d)",
227 err.errType, err.errCause);
230 /* Validate for Meas Types */
231 if ( (ret = rgSCHUtlValidateMeasReq(cell, measInfo, &err)) != ROK)
233 rgSchL2mFillCfmPst(pst, &cfmPst, measInfo);
234 RGSCHFILLERR(err, RGSCHERR_L2M_MEASREQ, RGSCHERR_SCH_INVALID_MEASTYPE);
235 rgSchL2mSndCfm(&cfmPst, NULLP, measInfo, TRUE);
236 DU_LOG("\nERROR --> SCH : Meas req Failed.Invalid Measurement Type"
237 "errCasue(%d) errType(%d)", err.errType, err.errCause);
240 /* Iterate through all meas requests in l2mList in cellCb */
241 #if (ERRCLASS & ERRCLS_ADD_RES)
242 lnk = cell->l2mList.first;
245 /* Get the MeasCb : RgSchL2MeasCb */
246 measCb = (RgSchL2MeasCb *)lnk->node;
248 if (measCb->measReq.hdr.transId == measInfo->hdr.transId)
250 rgSchL2mFillCfmPst(pst, &cfmPst, measInfo);
251 RGSCHFILLERR(err, RGSCHERR_L2M_MEASREQ, RGSCHERR_SCH_DUP_TRANSID);
252 rgSchL2mSndCfm(&cfmPst, measCb, measInfo, TRUE);
253 DU_LOG("\nERROR --> SCH : Meas req Failed Duplicate TransId"
254 "errType(%d) errCause(%d)", err.errType, err.errCause);
259 /* Call L2M Function to store Meas req */
260 ret = rgSchL2mMeasReq(cell, measInfo, err);
263 rgSchL2mFillCfmPst(pst, &cfmPst, measInfo);
264 RGSCHFILLERR(err, RGSCHERR_L2M_MEASREQ, RGSCHERR_SCH_L2MEAS_FAILED);
265 rgSchL2mSndCfm(&cfmPst, measCb, measInfo, TRUE);
266 DU_LOG("\nERROR --> SCH : Meas req Failed.errType(%d) errCause(%d)",
267 err.errType, err.errCause);
271 } /* -- RRgMiLrgSchL2MeasReq-- */
274 * @brief Layer Manager L2 Measurement Stop request handler.
278 * Function : RgMiLrgSchL2MeasStopReq
280 * This function handles the control
281 * measurement stop request received from the Layer Manager.
283 * @param[in] Pst *pst, the post structure
284 * @param[in] LrgSchMeasReqInfo *measInfo, measurement stop request info
288 S16 RgMiLrgSchL2MeasStopReq
290 Pst *pst, /* post structure */
291 LrgSchMeasStopReqInfo *measInfo /* Meas Req Info */
295 RgSchCellCb *cell = NULLP;
296 RgSchCb *instCb = &rgSchCb[(pst->dstInst - SCH_INST_START)];
297 CmLList *node = NULLP;
298 RgSchL2MeasCb *measCb = NULLP;
299 LrgSchMeasCfmInfo measCfm;
302 for (idx = 0; idx < instCb->numSaps; idx++)
304 if ( instCb->rgrSap[idx].cell->cellId == measInfo->cellId)
306 /* got the cell break the loop */
307 cell = instCb->rgrSap[idx].cell;
313 DU_LOG("\nERROR --> SCH : Stop req Failed.Invalid Cell Id ");
316 memset(&measCfm, 0, sizeof(LrgSchMeasCfmInfo));
317 node = cell->l2mList.first;
320 measCb = (RgSchL2MeasCb *)(node)->node;
323 cmLListDelFrm(&cell->l2mList, &measCb->measLnk);
324 rgSCHUtlFreeSBuf(cell->instIdx, (Data **)&measCb,
325 sizeof(RgSchL2MeasCb));
328 if(measInfo->measType & LRG_L2MEAS_AVG_PRB_PER_QCI_UL)
330 RgInfL2MeasStopReq measStopReq;
332 memset(&measStopReq, 0, sizeof(RgInfL2MeasStopReq));
333 measStopReq.transId = measInfo->hdr.transId;
334 measStopReq.measType = measInfo->measType;
335 /* measReq.timePrd = measInfo->timePrd; */
336 measStopReq.cellId = measInfo->cellId;
337 rgSCHUtlGetPstToLyr(&pstMac, &rgSchCb[cell->instIdx], cell->macInst);
338 RgSchMacL2MeasStop(&pstMac,&measStopReq);
342 RgMiLrgSchL2MeasStopCfm(&(rgSchCb[cell->instIdx].rgSchInit.lmPst),
346 }/*RgMiLrgSchL2MeasStopReq*/
348 * @brief Layer Manager L2 Measurement request handler.
349 * for Send l2 measurement req
352 * Function : RgMiLrgSchL2MeasSendReq
354 * This function handles the control
355 * measurement send request received from the Layer Manager.
357 * @param[in] Pst *pst, the post structure
358 * @param[in] LrgSchMeasReqInfo *measInfo, measurement stop request info
362 S16 RgMiLrgSchL2MeasSendReq
364 Pst *pst, /* post structure */
365 LrgSchMeasSndReqInfo *measInfo /* Meas Req Info */
370 RgSchCb *instCb = &rgSchCb[(pst->dstInst - SCH_INST_START)];
374 for (idx = 0; idx < instCb->numSaps; idx++)
376 if ( instCb->rgrSap[idx].cell->cellId == measInfo->cellId)
378 /* got the cell break the loop */
379 cell = instCb->rgrSap[idx].cell;
385 DU_LOG("\nERROR --> SCH : Send req Failed.Invalid Cell Id");
389 if(measInfo->measType & LRG_L2MEAS_AVG_PRB_PER_QCI_UL)
391 RgInfL2MeasSndReq measSndReq;
393 memset(&measSndReq, 0, sizeof(RgInfL2MeasSndReq));
394 measSndReq.transId = measInfo->hdr.transId;
395 measSndReq.measType = measInfo->measType;
396 measSndReq.timePrd = measInfo->timePrd;
397 measSndReq.cellId = measInfo->cellId;
398 rgSCHUtlGetPstToLyr(&pstMac, &rgSchCb[cell->instIdx], cell->macInst);
399 RgSchMacL2MeasSend(&pstMac, &measSndReq);
403 cell->sndL2Meas = TRUE;
407 }/*RgMiLrgSchL2MeasSendReq*/
408 #endif /* LTE_L2_MEAS */
413 /************* RGR Interface ****************/
415 * @brief API for bind request from RRM towards MAC.
419 * Function: RgUiRgrBndReq
421 * This API is invoked by RRM towards MAC to bind RGR SAP.
422 * These API validates the Pst, spId, suId and sends the bind confirm to
426 * @param[in] Pst *pst
427 * @param[in] SuId suId
428 * @param[in] SpId spId
433 S16 RgUiRgrBndReq(Pst *pst, SuId suId, SpId spId)
436 Pst tmpPst; /* Temporary Post Structure */
437 Inst instId = pst->dstInst-SCH_INST_START;
438 RgUstaDgn dgn; /* Alarm diagnostics structure */
440 tmpPst.prior = pst->prior;
441 tmpPst.route = pst->route;
442 tmpPst.selector = pst->selector;
443 tmpPst.region = rgSchCb[instId].rgSchInit.region;
444 tmpPst.pool = rgSchCb[instId].rgSchInit.pool;
445 tmpPst.srcProcId = rgSchCb[instId].rgSchInit.procId;
446 tmpPst.srcEnt = rgSchCb[instId].rgSchInit.ent;
447 tmpPst.srcInst = rgSchCb[instId].rgSchInit.inst + SCH_INST_START;
448 tmpPst.event = EVTNONE;
449 tmpPst.dstProcId = pst->srcProcId;
450 tmpPst.dstEnt = pst->srcEnt;
451 tmpPst.dstInst = pst->srcInst;
453 if(spId < rgSchCb[instId].numSaps)
455 /* Check the state of the SAP */
456 switch (rgSchCb[instId].rgrSap[spId].sapSta.sapState)
458 /* This case might not be needed if SAP not configured then it will go
459 * to else of above if condition */
460 case LRG_UNBND: /* SAP is not bound */
461 DU_LOG("\nDEBUG --> SCH : SAP Not yet bound");
462 rgSchCb[instId].rgrSap[spId].sapSta.sapState = LRG_BND;
463 rgSchCb[instId].rgrSap[spId].sapCfg.suId = suId;
464 /* Send Bind Confirm with status as SUCCESS */
465 ret = rgSCHUtlRgrBndCfm(instId, suId, CM_BND_OK);
466 /*Indicate to Layer manager */
467 rgSCHUtlFillDgnParams(instId, &dgn, LRG_USTA_DGNVAL_MEM);
468 ret = rgSCHLmmStaInd(instId, LCM_CATEGORY_INTERFACE,
469 LRG_EVENT_RGRSAP_ENB, LCM_CAUSE_UNKNOWN, &dgn);
471 case LRG_BND: /* SAP is already bound*/
472 DU_LOG("\nDEBUG --> SCH : SAP is already bound");
473 ret = rgSCHUtlRgrBndCfm(instId, suId, CM_BND_OK);
475 default: /* Should Never Enter here */
476 #if (ERRCLASS & ERRCLS_ADD_RES)
477 DU_LOG("\nERROR --> SCH : Invalid SAP State:RgUiRrgBndReq failed\n");
479 ret = rgSCHUtlRgrBndCfm(instId, suId, CM_BND_NOK);
485 #if (ERRCLASS & ERRCLS_ADD_RES)
486 /* ccpu00117035 - MOD - Changed ErrVal argument from accessing sap state
487 to spId to avoid seg fault due to invalid sapID */
488 DU_LOG("\nERROR --> SCH : Invalid SAP Id:RgUiRrgBndReq failed\n");
490 ret = RgUiRgrBndCfm(&tmpPst, suId, CM_BND_NOK);
493 } /* RgUiRgrBndReq */
496 * @brief API for unbind request from RRM towards MAC.
500 * Function: RgUiRgrUbndReq
502 * This API is invoked by RRM towards MAC to unbind RGR SAP.
503 * These API validates the Pst, spId, suId and transfers the unbind request
504 * specific information to corresponding ownership module (GOM) API.
507 * @param[in] Pst *pst
508 * @param[in] SuId suId
509 * @param[in] Reason reason
514 S16 RgUiRgrUbndReq(Pst *pst,SpId spId,Reason reason)
516 Inst instId = pst->dstInst-SCH_INST_START;
518 /* SAP Id validation */
519 if (spId < rgSchCb[instId].numSaps)
521 switch(rgSchCb[instId].rgrSap[spId].sapSta.sapState)
523 case LRG_BND: /* SAP is already bound*/
524 DU_LOG("\nDEBUG --> SCH : SAP is already bound");
525 /* setting SAP state to UN BOUND */
526 rgSchCb[instId].rgrSap[spId].sapSta.sapState = LRG_UNBND;
529 #if (ERRCLASS & ERRCLS_ADD_RES)
530 DU_LOG("\nERROR --> SCH : Invalid SAP State RgUiRgrUbndReq failed\n");
537 #if (ERRCLASS & ERRCLS_ADD_RES)
538 DU_LOG("\nERROR --> SCH : Invalid SAP Id RgUiRgrUbndReq failed\n");
543 } /* RgUiRgrUbndReq */
547 * @brief API for SI configuration request from RRM towards MAC.
551 * Function: RgUiRgrSiCfgReq
553 * This API is invoked by RRM towards MAC to configure SI at MAC.
554 * These API validates the Pst, spId, suId and transfers the
555 * config request specific information to corresponding ownership
559 * @param[in] Pst *pst
560 * @param[in] SpId spId
561 * @param[in] RgrCfgTransId transId
562 * @param[in] RgrSiCfgReqInfo *cfgReqInfo
567 S16 RgUiRgrSiCfgReq(Pst *pst, SpId spId,RgrCfgTransId transId,RgrSiCfgReqInfo *cfgReqInfo)
570 uint8_t cfmStatus = RGR_CFG_CFM_NOK;
571 uint8_t prntTrans[RGR_CFG_TRANSID_SIZE+1];
572 Inst instId = pst->dstInst-SCH_INST_START;
574 memcpy(prntTrans, transId.trans, RGR_CFG_TRANSID_SIZE);
575 prntTrans[RGR_CFG_TRANSID_SIZE] = '\0';
578 if (cfgReqInfo == NULLP)
580 DU_LOG("\nERROR --> SCH : Input Message Buffer is NULL");
581 rgSCHUtlRgrSiCfgCfm(instId, spId, transId, cfmStatus);
585 if (spId < rgSchCb[instId].numSaps)
587 if(LRG_BND != rgSchCb[instId].rgrSap[spId].sapSta.sapState)
589 #if (ERRCLASS & ERRCLS_ADD_RES)
590 DU_LOG("\nERROR --> SCH : Invalid SAP State: RgUiRgrSiCfgReq failed\n");
592 SCH_FREE(cfgReqInfo, (Size)sizeof(*cfgReqInfo));
593 rgSCHUtlRgrSiCfgCfm(instId, spId, transId, cfmStatus);
599 #if (ERRCLASS & ERRCLS_ADD_RES)
600 DU_LOG("\nERROR --> SCH : Invalid SAP Id:RgUiRgrSiCfgReq failed\n");
602 SCH_FREE(cfgReqInfo, (Size)sizeof(*cfgReqInfo));
603 rgSCHUtlRgrSiCfgCfm(instId, spId, transId, cfmStatus);
607 /* Handle configuration */
609 if(rgSchCb[instId].rgrSap[spId].cell->emtcEnable)
611 ret = rgSCHGomEmtcHndlSiCfg(pst->region, pst->pool,
612 &rgSchCb[instId], spId, transId,
617 ret = rgSCHGomHndlSiCfg(pst->region, pst->pool,
618 &rgSchCb[instId], spId, transId,
622 ret = rgSCHGomHndlSiCfg(pst->region, pst->pool,
623 &rgSchCb[instId], spId, transId,
628 DU_LOG("\nERROR --> SCH : RgUiRgrSiCfgReq:"
629 "Configuration Request Handling Failed");
634 } /* RgUiRgrSiCfgReq */
638 * @brief API for Warning SI configuration request from RRM towards MAC.
642 * Function: RgUiRgrWarningSiCfgReq
644 * This API is invoked by RRM towards MAC to configure SI at MAC.
645 * These API validates the Pst, spId, suId and transfers the
646 * config request specific information to corresponding ownership
650 * @param[in] Pst *pst
651 * @param[in] SpId spId
652 * @param[in] RgrCfgTransId transId
653 * @param[in] RgrWarningSiCfgReqInfo *warningSiCfgReqInfo
658 S16 RgUiRgrWarningSiCfgReq(Pst *pst, SpId spId,RgrCfgTransId transId,RgrWarningSiCfgReqInfo *warningSiCfgReqInfo)
660 Inst instId = pst->dstInst-SCH_INST_START;
662 uint8_t cfmStatus = RGR_CFG_CFM_NOK;
663 uint8_t prntTrans[RGR_CFG_TRANSID_SIZE+1];
665 memcpy(prntTrans, transId.trans, RGR_CFG_TRANSID_SIZE);
666 prntTrans[RGR_CFG_TRANSID_SIZE] = '\0';
668 if (warningSiCfgReqInfo == NULLP)
670 DU_LOG("\nERROR --> SCH : Input Message Buffer "
672 rgSCHUtlRgrWarningSiCfgCfm(instId, spId, 0, transId, cfmStatus);
676 if (spId < rgSchCb[instId].numSaps)
678 if(LRG_BND != rgSchCb[instId].rgrSap[spId].sapSta.sapState)
680 #if (ERRCLASS & ERRCLS_ADD_RES)
681 DU_LOG("\nERROR --> SCH : Invalid SAP State: warningSiCfgReqInfo failed\n");
683 rgSCHUtlFreeWarningSiSeg(pst->region, pst->pool,
684 &warningSiCfgReqInfo->siPduLst);
685 SCH_FREE(warningSiCfgReqInfo, sizeof(RgrWarningSiCfgReqInfo));
686 rgSCHUtlRgrWarningSiCfgCfm(instId, spId, warningSiCfgReqInfo->siId,
693 #if (ERRCLASS & ERRCLS_ADD_RES)
694 DU_LOG("\nERROR --> SCH : Invalid SAP Id:warningSiCfgReqInfo failed\n");
696 rgSCHUtlFreeWarningSiSeg(pst->region, pst->pool,
697 &warningSiCfgReqInfo->siPduLst);
698 SCH_FREE(warningSiCfgReqInfo,sizeof(RgrWarningSiCfgReqInfo));
699 rgSCHUtlRgrWarningSiCfgCfm(instId, spId, warningSiCfgReqInfo->siId,
704 /* Handle configuration */
706 if(rgSchCb[instId].rgrSap[spId].cell->emtcEnable)
708 ret = rgSCHGomEmtcHndlWarningSiCfg(pst->region, pst->pool,
709 &rgSchCb[instId], spId, transId, warningSiCfgReqInfo);
713 ret = rgSCHGomHndlWarningSiCfg(pst->region, pst->pool,
714 &rgSchCb[instId], spId, transId, warningSiCfgReqInfo);
717 ret = rgSCHGomHndlWarningSiCfg(pst->region, pst->pool,
718 &rgSchCb[instId], spId, transId, warningSiCfgReqInfo);
722 DU_LOG("\nERROR --> SCH : Configuration Request Handling Failed");
731 * @brief API for Warning SI Stop request from RRM towards MAC.
735 * Function: RgUiRgrWarningSiStopReq
737 * This API is invoked by RRM towards MAC to Stop warning SI at MAC.
738 * These API validates the Pst, spId, suId and transfers the
739 * stop request specific information to corresponding ownership
743 * @param[in] Pst *pst
744 * @param[in] SpId spId
745 * @param[in] RgrWarningSiCfgReqInfo *warningSiCfgReqInfo
750 S16 RgUiRgrWarningSiStopReq(Pst *pst,SpId spId,RgrCfgTransId transId,uint8_t siId)
752 Inst instId = pst->dstInst-SCH_INST_START;
754 if (spId < rgSchCb[instId].numSaps)
756 if(LRG_BND != rgSchCb[instId].rgrSap[spId].sapSta.sapState)
758 #if (ERRCLASS & ERRCLS_ADD_RES)
759 DU_LOG("\nERROR --> SCH : Invalid SAP State: RgUiRgrWarningSiStopReq failed\n");
766 #if (ERRCLASS & ERRCLS_ADD_RES)
767 DU_LOG("\nERROR --> SCH : Invalid SAP Id:RgUiRgrWarningSiStopReq failed\n");
772 rgSCHGomHndlWarningSiStopReq(pst->region, pst->pool,
773 &rgSchCb[instId], siId, transId, spId);
777 #endif /*RGR_SI_SCH */
779 /* LTE_ADV_FLAG_REMOVED_START */
782 * @brief API for LOAD INF request from RRM towards MAC.
786 * Function: RgUiRgrLoadInfReq
788 * This API is invoked by RRM towards MAC to configure LOAD INF Parameters at MAC.
789 * These API validates the Pst, spId, suId and transfers the
790 * LOAD INF request to corresponding ownership
794 * @param[in] Pst *pst
795 * @param[in] SpId spId
796 * @param[in] RgrCfgTransId transId
797 * @param[in] RgrLoadInfReqInfo *loadInfReq
802 S16 RgUiRgrLoadInfReq(Pst *pst, SpId spId, RgrCfgTransId transId,RgrLoadInfReqInfo *loadInfReq)
805 uint8_t prntTrans[RGR_CFG_TRANSID_SIZE+1];
806 Inst instId = pst->dstInst-SCH_INST_START;
808 memcpy(prntTrans, transId.trans, RGR_CFG_TRANSID_SIZE);
809 prntTrans[RGR_CFG_TRANSID_SIZE] = '\0';
812 if (loadInfReq == NULLP)
814 DU_LOG("\nERROR --> SCH : Input Message Buffer "
819 if (spId < rgSchCb[instId].numSaps)
821 if(LRG_BND != rgSchCb[instId].rgrSap[spId].sapSta.sapState)
823 #if (ERRCLASS & ERRCLS_ADD_RES)
824 DU_LOG("\nERROR --> SCH : Invalid SAP State: RgUiRgrLoadInfReq failed\n");
826 SCH_FREE(loadInfReq, (Size)sizeof(*loadInfReq));
832 #if (ERRCLASS & ERRCLS_ADD_RES)
833 DU_LOG("\nERROR --> SCH : Invalid SAP Id:RgUiRgrLoadInfReq failed\n");
835 SCH_FREE(loadInfReq, (Size)sizeof(*loadInfReq));
839 /* Handle configuration */
840 ret = rgSCHGomHndlLoadInf(pst->region, pst->pool,
841 &rgSchCb[(pst->dstInst - SCH_INST_START)], spId, transId,
845 DU_LOG("\nERROR --> SCH : Configuration Request Handling Failed");
850 } /* RgUiRgrLoadInfReq */
851 /* LTE_ADV_FLAG_REMOVED_END */
853 /************** MAC SCH Interface **************/
855 * @brief Function for updating dedicated channel BO at scheduler from MAC.
859 * Function : rgMacSchDedBoUpdtReq
861 * This function shall be invoked whenever MAC gets staRsp from RLC
862 * Scheduler shall update BO in its dedicated logical channel control block.
864 * @param[in] Pst* pst
865 * @param[in] S16 cellSapId
866 * @param[in] RgInfDedBoRpt *boRpt
870 S16 RgMacSchDedBoUpdtReq(Pst* pst,RgInfDedBoRpt *boRpt)
878 Inst inst = (pst->dstInst - SCH_INST_START);
879 S16 cellSapId = boRpt->cellSapId;
881 DU_LOG("\nDEBUG --> SCH : rgMacSchDedBoUpdtReq():"
882 " boRpt->rnti = %u boRpt->lcId = %u",boRpt->rnti, boRpt->lcId);
884 /* No need to chk for cell being NULL as MAC wouldn't have found instance if
886 cell = rgSchCb[inst].rgrSap[cellSapId].cell;
889 if (cell->cellId != boRpt->cellId)
891 /* Handle Cell fetch failure */
892 DU_LOG("\nERROR --> SCH : rgMacSchDedBoUpdtReq(): Invalid cell Id");
897 /* Update Bo in the given logical channel of the UE */
898 if ((ue = rgSCHDbmGetUeCb(cell, boRpt->rnti)) != NULLP)
901 /* Honor BO Reports only from PCELL */
903 if (cell != ue->cell)
908 if ((dlLc = rgSCHDbmGetDlDedLcCb(ue, boRpt->lcId)) != NULLP)
911 if(dlLc->lcType == CM_LTE_LCH_DTCH)
913 if((dlLc->bo == 0) &&(boRpt->bo != 0))
916 if(!(ue->qciActiveLCs[dlLc->qciCb->qci]))
918 dlLc->qciCb->dlUeCount++;
920 ue->qciActiveLCs[dlLc->qciCb->qci]++;
922 else if((dlLc->bo != 0) && (boRpt->bo == 0) && (dlLc->qciCb->dlUeCount))
925 if (ue->qciActiveLCs[dlLc->qciCb->qci])
927 ue->qciActiveLCs[dlLc->qciCb->qci]--;
928 if (!(ue->qciActiveLCs[dlLc->qciCb->qci]))
930 dlLc->qciCb->dlUeCount--;
937 dlUe = RG_SCH_CMN_GET_DL_UE(ue, cell);
938 if (boRpt->bo > dlLc->bo)
940 dlUe->boReported += (boRpt->bo - dlLc->bo);
944 if (boRpt->bo > dlLc->bo)
946 ue->tenbStats->stats.nonPersistent.sch[RG_SCH_CELLINDEX(cell)].dlBo += ((boRpt->bo - dlLc->bo)<<3);
949 /* RLC provides cumulative BO for each LC.
950 * Reduce the left out unscheduled bo from total bo and
951 * update the new BO to the total bo */
952 if(ue->totalBo >= dlLc->bo)
954 ue->totalBo -= dlLc->bo;
958 ue->totalBo = 0; /* this case should not arise
959 * Resetting for safety */
962 ue->totalBo += boRpt->bo;
963 dlLc->bo = boRpt->bo;
964 dlLc->oldestSduArrTime = boRpt->oldestSduArrTime;
965 dlLc->staPduBo = boRpt->staPduBo;
967 dlLc->setMaxUlPrio = boRpt->setMaxUlPrio;
968 dlLc->setMaxDlPrio = boRpt->setMaxDlPrio;
969 /* Update the scheduler */
970 rgSCHUtlDlDedBoUpd(cell, ue, dlLc);
976 } /* end of rgMacSchDedBoUpdtReq */
980 * @brief Function for updating common channel BO at scheduler from MAC.
984 * Function : RgMacSchCmnBoUpdtReq
986 * This function shall be invoked whenever MAC gets staRsp from RLC
987 * Scheduler shall update BO in its common logical channel control block.
989 * @param[in] Pst* pst
990 * @param[in] S16 cellSapId
991 * @param[in] RgInfCmnBoRpt *boRpt
995 S16 RgMacSchCmnBoUpdtReq(Pst* pst,RgInfCmnBoRpt *boRpt)
998 Inst inst = (pst->dstInst - SCH_INST_START);
999 S16 cellSapId = boRpt->cellSapId;
1002 /* No need to chk for cell being NULL as MAC would not have found instance if
1003 * it doesnt exist */
1004 cell = rgSchCb[inst].rgrSap[cellSapId].cell;
1005 if (cell->cellId != boRpt->cellId)
1007 DU_LOG("\nERROR --> SCH : RgMacSchCmnBoUpdtReq():"
1008 "Invalid boRpt cell Id:%d",boRpt->cellId);
1012 /* handle status response on CCCH */
1013 if(boRpt->lcId == cell->dlCcchId)
1015 DU_LOG("\nDEBUG --> SCH : RgMacSchCmnBoUpdtReq():"
1016 " BO update for CCCH");
1017 rgSCHUtlHndlCcchBoUpdt(cell, boRpt);
1021 rgSCHUtlHndlBcchPcchBoUpdt(cell, boRpt);
1025 } /* end of RgMacSchCmnBoUpdtReq */
1026 /*Fix: start: Inform UE delete to scheduler*/
1028 * @brief This API is used to send data indication to Scheduler instance from MAC.
1032 * Function : rgMacSchUeDelInd
1034 * This function shall be invoked whenever MAC gets Ue delete request.
1037 * @param[in] Pst* pst
1038 * @param[in] RgInfUeDelInd *ueDelInd
1042 S16 RgMacSchUeDelInd(Pst* pst,RgInfUeDelInd *ueDelInd)
1045 Inst inst = (pst->dstInst - SCH_INST_START);
1046 S16 cellSapId = ueDelInd->cellSapId;
1048 RgSchRntiLnk *rntiLnk=NULL;
1050 if (rgSchCb[inst].rgrSap == NULLP || rgSchCb[inst].rgrSap[cellSapId].cell == NULLP)
1052 DU_LOG("\nERROR --> SCH : rgrSap or cell is not configured");
1055 cell = rgSchCb[inst].rgrSap[cellSapId].cell;
1057 if (cell->cellId != ueDelInd->cellId)
1059 /* Handle Cell fetch failure */
1060 DU_LOG("\nERROR --> SCH : rgMacSchUeDelInd(): Invalid ueDelInd cell Id:%d",
1066 CM_LLIST_FIRST_NODE(&cell->rntiDb.rntiGuardPool, tmp);
1070 rntiLnk = (RgSchRntiLnk *)(tmp->node);
1071 if(rntiLnk->rnti == ueDelInd->rnti)
1073 cmLListDelFrm(&cell->rntiDb.rntiGuardPool, tmp);
1075 rgSCHDbmRlsRnti(cell, rntiLnk);
1076 DU_LOG("\nDEBUG --> SCH : RNTI:%d Released from the Guard pool(%d)",
1077 ueDelInd->rnti, cell->rntiDb.rntiGuardPool.count);
1081 CM_LLIST_NEXT_NODE(&cell->rntiDb.rntiGuardPool, tmp);
1085 rgEmtcMacSchUeDelInd(cell,ueDelInd);
1090 /* Fix : syed HO UE does not have a valid ue->rntiLnk */
1091 DU_LOG("\nINFO --> SCH : HO CRNTI:%d not present in the"
1092 "Guard Pool:%d", ueDelInd->rnti, cell->rntiDb.rntiGuardPool.count);
1096 } /* rgMacSchUeDelInd */
1097 /*Fix: end: Inform UE delete to scheduler*/
1099 * @brief This API is used to send data indication to Scheduler instance from MAC.
1103 * Function : rgMacSchSfRecpInd
1105 * This function shall be invoked whenever MAC gets datInd on TFU
1106 * Scheduler shall act on the CEs and data that are received as part of
1109 * @param[in] Pst* pst
1110 * @param[in] S16 cellSapId
1111 * @param[in] CmLteRnti rnti
1112 * @param[in] DatIndInfo *datInd
1116 S16 RgMacSchSfRecpInd(Pst* pst,RgInfSfDatInd *subfrmInfo)
1121 RgInfUeDatInd *datInd;
1123 Inst inst = (pst->dstInst - SCH_INST_START);
1127 S16 cellSapId = subfrmInfo->cellSapId;
1128 RgrUeStaIndInfo *ueStaInd;
1131 RgSchCmnUlUeSpsInfo *ulSpsUe ;
1139 uint16_t datIndActQci = 0;
1140 uint16_t combDatIndActQci = 0; /* Prev and Latest Dat Ind combined */
1141 uint16_t tempUeActQci = 0; /* UE specific Active QCIs */
1142 uint16_t diffBits = 0;
1146 /* No need to chk for cell being NULL as MAC wouldn't have found instance if
1147 * it doesnt exist */
1148 cell = rgSchCb[inst].rgrSap[cellSapId].cell;
1150 /* lnkLst assignment */
1151 lnkLst = &(subfrmInfo->ueLst);
1153 CM_LLIST_FIRST_NODE(lnkLst, tmp);
1155 while((NULLP != tmp) && ((RgInfUeDatInd *)tmp->node != NULLP))
1161 datInd = (RgInfUeDatInd *)tmp->node;
1162 rnti = datInd->rnti;
1164 /* We shall try and find
1165 * out the RaCb based on the following -
1166 * 1. If the incoming PDU contained a CCCH SDU i.e. this is message 3.
1167 * 2. If the incoming PDU contained a CRNTI control element, i.e. we should
1168 * have a ueCb also for this
1171 /* It could be that a non-msg3 pdu contains a CRNTI Control element. We
1172 * should check for CRNTI CE and if it exists the UECb must exist, also an
1173 * if the CRNTI in the CE and the one with which the message came in are
1174 * different we shall look for an raCb as well.
1176 if (datInd->ceInfo.bitMask & RGSCH_CRNTI_CE_PRSNT)
1178 /* SR_RACH_STATS : CRNTI CE*/
1181 if (datInd->ceInfo.bitMask & RGSCH_CCCH_SDU_PRSNT)
1183 RGSCH_FREE_MEM(subfrmInfo);
1184 err.errType = RGSCHERR_TOM_DATIND;
1185 DU_LOG("\nDEBUG --> SCH : Received MSG3 with CRNTI:%d and also CCCH ",
1186 datInd->ceInfo.ces.cRnti);
1189 ue = rgSCHDbmGetUeCb (cell, datInd->ceInfo.ces.cRnti);
1192 /* SR_RACH_STATS : CRNTI CE UECB NOT FOUND*/
1193 rgNumCrntiCeCrntiNotFound++;
1194 /* ccpu00141318 - Removed condition for SPS rnti checking*/
1195 RGSCH_FREE_MEM(subfrmInfo);
1196 err.errType = RGSCHERR_TOM_DATIND;
1197 DU_LOG("\nERROR --> SCH : Received MSG3 "
1198 "with CRNTI:%d unable to find ueCb",
1199 datInd->ceInfo.ces.cRnti);
1203 if ((ret = rgSCHUtlProcMsg3 (subfrmInfo, cell, ue,
1204 rnti, datInd, &err)) != ROK)
1206 RGSCH_FREE_MEM(subfrmInfo);
1207 err.errType = RGSCHERR_TOM_DATIND;
1208 DU_LOG("\nERROR --> SCH : Processing for MSG3 failed for CRNTI:%d",
1214 rgSCHUtlHdlCrntiCE (cell, ue);
1216 ret = rgSCHUtlAllocSBuf (cell->instIdx,(Data**)&ueStaInd,
1217 sizeof(RgrUeStaIndInfo));
1220 ueStaInd->status = RGR_UESTA_MAC_CRNTI_CE_RECVD;
1223 ulSpsUe = RG_SCH_CMN_GET_UL_SPS_UE(ue);
1224 if(ulSpsUe->isUlSpsActv)
1226 ueStaInd->status = RGR_UESTA_MAC_CRNTI_CE_RECVD_IN_SPS_ACTIVE;
1227 ue->ul.ulSpsCfg.isLcSRMaskEnab = FALSE;
1230 ret = rgSCHUtlFillSndUeStaInd(cell, ue, ueStaInd);
1233 DU_LOG("\nERROR --> SCH : Could not Send Ue Sta Ind UEID:%d",ue->ueId);
1236 CM_LLIST_NEXT_NODE(lnkLst, tmp);
1238 } /* end of CRNTI based message */
1239 else if (datInd->ceInfo.bitMask & RGSCH_CCCH_SDU_PRSNT)
1241 /* SR_RACH_STATS : CCCH SDU */
1243 /* SR_RACH_STATS : CCCH SDU RACB NOT FOUND*/
1244 if (NULLP == rgSCHDbmGetRaCb (cell, rnti))
1246 rgNumCCCHSduCrntiNotFound++;
1249 if ((ret = rgSCHUtlProcMsg3 (subfrmInfo, cell, ue,
1250 rnti, datInd, &err)) != ROK)
1252 RGSCH_FREE_MEM(subfrmInfo);
1253 err.errType = RGSCHERR_TOM_DATIND;
1254 DU_LOG("\nERROR --> SCH : Processing for MSG3 failed for CRNTI:%d",
1259 CM_LLIST_NEXT_NODE(lnkLst, tmp);
1261 } /* end of Msg3 processing */
1265 ue = rgSCHDbmGetUeCb (cell, datInd->rnti);
1269 if((ue = rgSCHDbmGetSpsUeCb (cell, datInd->rnti)) == NULLP)
1272 RGSCH_FREE_MEM(subfrmInfo);
1273 err.errType = RGSCHERR_TOM_DATIND;
1274 DU_LOG("\nERROR --> SCH : Unable to get the UE CB for CRNTI:%d",
1282 /* The LCs for which data is received at MAC is provided to SCH.
1283 This information is used to estimate the Active LCs at UE
1284 since estimates based on only BSR is not accurate */
1285 if (datInd->ceInfo.bitMask & RGSCH_ACTIVE_LC_PRSNT)
1288 /* Compose a Bitmask with for the QCI's for which Data
1290 for (lcCount = 0; lcCount < RGINF_MAX_NUM_DED_LC; lcCount++)
1292 if ((datInd->ceInfo.ulActLCs[lcCount] == TRUE) && (TRUE == ue->ul.lcCb[lcCount].isValid))
1294 datIndActQci |= (1 << (ue->ul.lcCb[lcCount].qciCb->qci -1));
1297 if (ue->ulActiveLCs && ue->lastDatIndLCs)
1299 /* Combine previous Dat Ind and current Dat Ind to
1300 estimate active LCs at UE */
1301 combDatIndActQci = ue->lastDatIndLCs | datIndActQci;
1302 tempUeActQci = ue->ulActiveLCs;
1303 ue->ulActiveLCs = combDatIndActQci;
1304 diffBits = combDatIndActQci ^ tempUeActQci;
1310 if (0x1 & tempUeActQci)
1312 /* An active QCI has become inactive */
1313 cell->qciArray[qci].ulUeCount--;
1317 /* An Inactive QCI has become active */
1318 cell->qciArray[qci].ulUeCount++;
1325 ue->lastDatIndLCs = datIndActQci;
1329 #endif /* LTE_L2_MEAS */
1330 /* Just copy the timing information from the dat indication into the one
1331 * stored in the UE CB, will be later utilized to handle Timing advance
1334 if ((ret = rgSCHUtlUpdSch (subfrmInfo, cell, ue, datInd, &err)) != ROK)
1336 RGSCH_FREE_MEM(subfrmInfo);
1337 err.errType = RGSCHERR_TOM_DATIND;
1338 DU_LOG("\nERROR --> SCH : Unable to handle Data"
1339 " Indication for UEID:%d",ue->ueId);
1343 CM_LLIST_NEXT_NODE(lnkLst, tmp);
1346 /* update the UL PRB usage for all GBR QCIs*/
1347 for (idx = 0; idx < RGM_MAX_QCI_REPORTS; idx++)
1349 cell->prbUsage.qciPrbRpts[idx].ulTotPrbUsed += subfrmInfo->qcisUlPrbCnt[idx];
1353 /* chk if Sch needs to dealloc datInd after unpk */
1354 RGSCH_FREE_MEM(subfrmInfo);
1356 } /* rgMacSchSfRecpInd */
1360 * @brief Function to handle relInd from MAC for a UE
1364 * Function: RgMacSchSpsRelInd
1366 * Handler for processing relInd for UL SPS of a UE
1373 * @param[in] Pst *pst
1374 * @param[in] RgInfSpsRelInfo *relInfo
1379 S16 RgMacSchSpsRelInd(Pst *pst,RgInfSpsRelInfo *relInfo)
1383 Inst inst = (pst->dstInst - SCH_INST_START);
1386 /* No need to chk for cell being NULL as MAC wouldn't have found instance if
1387 * it doesnt exist */
1388 cell = rgSchCb[inst].rgrSap[relInfo->cellSapId].cell;
1390 if ((ue = rgSCHDbmGetUeCb(cell, relInfo->cRnti)) == NULLP)
1392 DU_LOG("\nERROR --> SCH : No Ue exists with CRNTI:%d",relInfo->cRnti);
1396 if ((rgSCHUtlSpsRelInd(cell, ue, relInfo->isExplRel)) != ROK)
1398 DU_LOG("\nERROR --> SCH : RelInd processing for CRNTI:%d failed",relInfo->cRnti);
1402 } /* end of RgMacSchSpsRelInd */
1403 #endif /* LTEMAC_SPS */
1408 * @brief Function to handle L2MeasCfm from MAC
1412 * Function: RgMacSchL2MeasCfm
1414 * Handler for processing L2 measurement confirm
1421 * @param[in] Pst *pst
1422 * @param[in] RgInfL2MeasCfm *measCfm
1427 S16 RgMacSchL2MeasCfm(Pst *pst, RgInfL2MeasCfm *measCfm)
1429 RgSchCellCb *cell = NULLP;
1430 Inst inst = (pst->dstInst - SCH_INST_START);
1432 RgSchL2MeasCb *measCb = NULLP;
1433 RgSchCb *instCb = &rgSchCb[inst];
1435 LrgSchMeasCfmInfo schMeasCfm;
1437 uint8_t idx1; /*LTE_L2_MEAS_PHASE2*/
1440 /* Find the cellCb using cellId in measInfo. Iterate through all cells
1441 * in rgrsapCb in RgschCb */
1442 for (idx = 0; idx < instCb->numSaps; idx++)
1444 if ( instCb->rgrSap[idx].cell->cellId == measCfm->cellId)
1446 /* got the cell break the loop */
1447 cell = instCb->rgrSap[idx].cell;
1451 /* If no cellCb return Err with Invalid Cell Id */
1454 DU_LOG("\nERROR --> SCH : Meas Cfm Failed.Invalid Cell Id");
1459 /* Iterate through all meas requests in l2mList in cellCb */
1460 lnk = cell->l2mList.first;
1463 /* Get the MeasCb : RgSchL2MeasCb */
1464 measCb = (RgSchL2MeasCb *)lnk->node;
1466 if (measCb->measReq.hdr.transId == measCfm->transId)
1471 if ( measCb == NULLP )
1477 if(measCfm->cfm.status != LCM_PRIM_OK)
1479 for (idx = 0; idx < measCb->measReq.avgPrbQciUl.numQci; idx++)
1481 qciVal = measCb->measReq.avgPrbQciUl.qci[idx];
1482 cell->qciArray[qciVal].qci = 0;
1484 /* Delete this measCb, send the negative confirmation to
1486 cmLListDelFrm(&cell->l2mList, &measCb->measLnk);
1487 /* ccpu00117052 - MOD - Passing double pointer
1488 for proper NULLP assignment*/
1489 rgSCHUtlFreeSBuf(cell->instIdx, (Data **)&measCb, sizeof(RgSchL2MeasCb));
1490 memset(&schMeasCfm, 0, sizeof(LrgSchMeasCfmInfo));
1491 schMeasCfm.measType = measCfm->measType;
1492 schMeasCfm.cfm = measCfm->cfm;
1493 schMeasCfm.hdr.transId = measCfm->transId;
1494 schMeasCfm.cellId = measCfm->cellId;
1495 RgMiLrgSchL2MeasCfm(&(instCb->rgSchInit.lmPst), &schMeasCfm);
1498 for(idx = 0; idx < measCfm->u.prbCfm.numQci; idx++)
1500 measCb->avgPrbQciUl.prbUsage[idx].prbUsage = measCfm->u.prbCfm.prbUsage[idx].prbUsage;
1501 measCb->avgPrbQciUl.prbUsage[idx].qciValue = measCfm->u.prbCfm.prbUsage[idx].qciValue;
1502 /*LTE_L2_MEAS_PHASE2*/
1503 qciVal1 = measCfm->u.prbCfm.prbUsage[idx].qciValue;
1504 for(idx1=0;idx1<measCb->measReq.avgPrbQciUl.numQci;idx1++)
1506 if(measCb->measReq.avgPrbQciUl.qci[idx1] == qciVal1)
1511 if(idx1 == measCb->measReq.avgPrbQciUl.numQci)
1513 measCb->measReq.avgPrbQciUl.qci[measCb->measReq.avgPrbQciUl.numQci++] = qciVal1;
1516 measCb->avgPrbQciUl.numQci = measCfm->u.prbCfm.numQci;
1517 measCb->cfmRcvd = TRUE;
1518 cell->sndL2Meas = TRUE;
1520 } /* end of RgMacSchL2MeasCfm */
1523 * @brief Function to handle L2MeasStopCfm from MAC
1527 * Function: RgMacSchL2MeasStopCfm
1529 * Handler for processing L2 measurement confirm
1536 * @param[in] Pst *pst
1537 * @param[in] RgInfL2MeasCfm *measCfm
1542 S16 RgMacSchL2MeasStopCfm(Pst *pst,RgInfL2MeasCfm *measCfm)
1544 LrgSchMeasCfmInfo schMeasCfm;
1545 Inst inst = (pst->dstInst - SCH_INST_START);
1546 RgSchCb *instCb = &rgSchCb[inst];
1548 memset(&schMeasCfm, 0, sizeof(LrgSchMeasCfmInfo));
1549 schMeasCfm.measType = measCfm->measType;
1550 schMeasCfm.cfm = measCfm->cfm;
1551 schMeasCfm.hdr.transId = measCfm->transId;
1552 schMeasCfm.cellId = measCfm->cellId;
1553 RgMiLrgSchL2MeasStopCfm(&(instCb->rgSchInit.lmPst), &schMeasCfm);
1558 /************** TFU Interface *************/
1561 * @brief Bind confirm API for TFU SAP on scheduler instance.
1565 * Function : RgLiTfuSchBndCfm
1567 * This API is invoked by PHY to confirm TFU SAP bind.
1570 * @param[in] Pst *pst
1571 * @param[in] SuId suId
1572 * @param[in] uint8_t status
1577 S16 RgLiTfuSchBndCfm (Pst *pst,SuId suId, uint8_t status)
1580 RgSchLowSapCb *tfuSap;
1581 Inst instId = pst->dstInst - SCH_INST_START;
1583 if(suId >= rgSchCb[instId].numSaps)
1585 DU_LOG("\nERROR --> SCH : Incorrect SuId");
1588 /* Lets validate suId first */
1589 tfuSap = &(rgSchCb[instId].tfuSap[suId]);
1591 if (suId != tfuSap->sapCfg.suId)
1593 DU_LOG("\nERROR --> SCH : Incorrect SuId. Configured (%d)"
1594 "Recieved (%d)", tfuSap->sapCfg.suId, suId);
1597 ret = rgSCHLmmBndCfm (pst, suId, status);
1599 } /* RgLiTfuSchBndCfm */
1602 * @brief Random Access Request indication from PHY.
1606 * Function : RgLiTfuRaReqInd
1608 * This API is invoked by PHY to send Random Access Request to Scheduler.
1609 * This API contains information for Random Access Request including
1610 * raRnti, list of associated RAPIDs and related information.
1612 * @param[in] Pst *pst
1613 * @param[in] SuId suId
1614 * @param[in] TfuRaReqIndInfo *raReqInd
1619 S16 RgLiTfuRaReqInd(Pst *pst,SuId suId, TfuRaReqIndInfo *raReqInd)
1622 Inst inst = pst->dstInst-SCH_INST_START;
1624 if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
1626 DU_LOG("\nERROR --> SCH : SAP Validation failed SuId(%d)", suId);
1627 /* Free up the memory for the request structure */
1628 RGSCH_FREE_MEM(raReqInd);
1632 if(raReqInd == NULLP)
1634 DU_LOG("\nERROR --> SCH : Invalid input pointer for raReqInd Failed");
1638 if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
1640 DU_LOG("\nERROR --> SCH : No cell exists");
1644 ret = rgSCHTomRaReqInd(rgSchCb[inst].tfuSap[suId].cell, raReqInd);
1645 /* Free up the memory for the request structure */
1646 RGSCH_FREE_MEM(raReqInd);
1647 /*SCH_FREE(pst->region, pst->pool, (Data *)raReqInd,
1648 sizeof(TfuRaReqIndInfo)); */
1650 } /* RgLiTfuRaReqInd */
1653 * @brief Uplink CQI indication from PHY.
1657 * Function : RgLiTfuUlCqiInd
1659 * This API is invoked by PHY to send Uplink CQI to Scheduler.
1660 * This API contains Uplink CQI information reported per UE.
1662 * @param[in] Pst *pst
1663 * @param[in] SuId suId
1664 * @param[in] TfuUlCqiIndInfo *ulCqiInd
1669 S16 RgLiTfuUlCqiInd(Pst *pst, SuId suId, TfuUlCqiIndInfo *ulCqiInd)
1672 Inst inst = pst->dstInst-SCH_INST_START;
1674 if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
1676 DU_LOG("\nERROR --> SCH : SAP Validation failed");
1677 /* Free up the memory for the request structure */
1678 RGSCH_FREE_MEM(ulCqiInd);
1682 if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
1684 DU_LOG("\nERROR --> SCH : No cell exists");
1685 /* Free up the memory for the request structure */
1686 RGSCH_FREE_MEM(ulCqiInd);
1689 ret = rgSCHTomUlCqiInd (rgSchCb[inst].tfuSap[suId].cell, ulCqiInd);
1690 /* Free up the memory for the request structure */
1691 RGSCH_FREE_MEM(ulCqiInd);
1693 } /* RgLiTfuUlCqiInd */
1696 * @brief PUCCH power adjustment indication.
1700 * Function : RgLiTfuPucchDeltaPwrInd
1702 * This API is invoked by PHY to send PUCCH power adjustment
1705 * @param[in] Pst *pst
1706 * @param[in] SuId suId
1707 * @param[in] TfuPucchDeltaPwrIndInfo *pucchDeltaPwr
1712 S16 RgLiTfuPucchDeltaPwrInd(Pst *pst,SuId suId,TfuPucchDeltaPwrIndInfo *pucchDeltaPwr)
1715 Inst inst = pst->dstInst-SCH_INST_START;
1717 if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
1719 DU_LOG("\nERROR --> SCH : SAP Validation failed");
1720 /* Free up the memory for the request structure */
1721 RGSCH_FREE_MEM(pucchDeltaPwr);
1725 if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
1727 DU_LOG("\nERROR --> SCH : No cell exists");
1730 ret = rgSCHTomPucchDeltaPwrInd (rgSchCb[inst].tfuSap[suId].cell, pucchDeltaPwr);
1731 /* Free up the memory for the request structure */
1732 RGSCH_FREE_MEM(pucchDeltaPwr);
1734 } /* RgLiTfuPucchDeltaPwrInd */
1738 * @brief HARQ ACK indication from PHY for Downlink transmissions.
1742 * Function : RgLiTfuHqInd
1744 * This API is invoked by PHY to send HARQ ACK information to Scheduler
1745 * on recieving HARQ ACK/NACK from UEs.
1746 * This API contains HARQ ACK information recieved by PHY for downlink
1749 * @param[in] Pst *pst
1750 * @param[in] SuId suId
1751 * @param[in] TfuHqIndInfo *harqAckInd
1756 S16 RgLiTfuHqInd(Pst *pst, SuId suId, TfuHqIndInfo *harqAckInd)
1759 Inst inst = (pst->dstInst - SCH_INST_START);
1763 if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
1765 DU_LOG("\nERROR --> SCH : SAP Validation failed");
1766 RGSCH_FREE_MEM(harqAckInd);
1770 if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
1772 DU_LOG("\nERROR --> SCH : No cell exists");
1777 /* Now call the TOM (Tfu ownership module) primitive to process further */
1778 ret = rgSCHTomHarqAckInd (rgSchCb[inst].tfuSap[suId].cell, harqAckInd);
1779 /* Free up the memory for the request structure */
1780 RGSCH_FREE_MEM(harqAckInd);
1782 } /* RgLiTfuHqInd */
1786 * @brief Scheduling request(SR) indication from PHY for an UE.
1790 * Function : RgLiTfuSrInd
1792 * This API is invoked by PHY to send Scheduling request information to
1793 * Scheduler on recieving SR from a list of UEs.
1794 * This API contains scheduling request information recieved by PHY for UEs.
1796 * @param[in] Pst *pst
1797 * @param[in] SuId suId
1798 * @param[in] TfuSrIndInfo *srInd
1803 S16 RgLiTfuSrInd(Pst *pst, SuId suId, TfuSrIndInfo *srInd)
1806 Inst inst = pst->dstInst-SCH_INST_START;
1809 if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
1811 DU_LOG("\nERROR --> SCH : SAP Validation failed");
1812 RGSCH_FREE_MEM(srInd);
1816 if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
1818 DU_LOG("\nERROR --> SCH : RgLiTfuSrInd()No cell exists");
1822 /* Now call the TOM (Tfu ownership module) primitive to process further */
1823 ret = rgSCHTomSrInd (rgSchCb[inst].tfuSap[suId].cell, srInd);
1824 /* Free up the memory for the request structure */
1825 RGSCH_FREE_MEM(srInd);
1827 } /* RgLiTfuSrInd */
1831 * @brief Downlink CQI indication from PHY for an UE.
1835 * Function : RgLiTfuDlCqiInd
1837 * This API is invoked by PHY to send Downlink CQI indication to Scheduler
1838 * on recieving downlink CQI from UE.
1839 * This API contains downlink CQI information recieved by PHY for an UE.
1841 * @param[in] Pst *pst
1842 * @param[in] SuId suId
1843 * @param[in] TfuDlCqiIndInfo *dlCqiInd
1848 S16 RgLiTfuDlCqiInd(Pst *pst, SuId suId, TfuDlCqiIndInfo *dlCqiInd)
1851 Inst inst = pst->dstInst-SCH_INST_START;
1853 if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
1855 DU_LOG("\nERROR --> SCH : SAP Validation failed");
1856 /* Free up the memory for the request structure */
1857 RGSCH_FREE_MEM(dlCqiInd);
1861 if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
1863 DU_LOG("\nERROR --> SCH : No cell exists");
1866 ret = rgSCHTomDlCqiInd (rgSchCb[inst].tfuSap[suId].cell, dlCqiInd);
1867 /* Free up the memory for the request structure */
1868 RGSCH_FREE_MEM(dlCqiInd);
1870 } /* RgLiTfuDlCqiInd */
1874 * @brief Raw CQI indication from PHY for an UE.
1878 * Function : RgLiTfuRawCqiInd
1880 * This API is invoked by PHY to send Raw CQI indication to Scheduler
1881 * on receiving Raw CQI from UE.
1882 * This API contains Raw CQI information recieved by PHY for an UE.
1884 * @param[in] Pst *pst
1885 * @param[in] SuId suId
1886 * @param[in] TfuRawCqiIndInfo *rawCqiInd
1891 S16 RgLiTfuRawCqiInd(Pst *pst, SuId suId, TfuRawCqiIndInfo *rawCqiInd)
1894 Inst inst = pst->dstInst-SCH_INST_START;
1897 if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
1899 DU_LOG("\nERROR --> SCH : SAP Validation failed");
1900 /* Free up the memory for the request structure */
1901 RGSCH_FREE_MEM(rawCqiInd);
1905 if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
1907 DU_LOG("\nERROR --> SCH : No cell exists");
1911 ret = rgSCHTomRawCqiInd (rgSchCb[inst].tfuSap[suId].cell, rawCqiInd);
1912 /* Free up the memory for the request structure */
1913 RGSCH_FREE_MEM(rawCqiInd);
1915 } /* RgLiTfuRawCqiInd */
1918 * @brief SRS indication from PHY for an UE.
1922 * Function : RgLiTfuSrsInd
1924 * This API is invoked by PHY to send UL SRS indication to Scheduler
1925 * on receiving a SRS from UE.
1926 * This API contains SRS information recieved by PHY for an UE.
1928 * @param[in] Pst *pst
1929 * @param[in] SuId suId
1930 * @param[in] TfuSrsIndInfo *srsInd
1935 S16 RgLiTfuSrsInd(Pst *pst, SuId suId, TfuSrsIndInfo *srsInd)
1938 Inst inst = pst->dstInst-SCH_INST_START;
1940 if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
1942 DU_LOG("\nERROR --> SCH : SAP Validation failed");
1943 /* Free up the memory for the request structure */
1944 RGSCH_FREE_MEM(srsInd);
1948 if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
1950 DU_LOG("\nERROR --> SCH : No cell exists");
1953 ret = rgSCHTomSrsInd (rgSchCb[inst].tfuSap[suId].cell, srsInd);
1954 /* Free up the memory for the request structure */
1955 RGSCH_FREE_MEM(srsInd);
1957 } /* RgLiTfuSrsInd */
1962 * @brief DOA indication from PHY for an UE.
1966 * Function : RgLiTfuDoaInd
1968 * This API is invoked by PHY to send Direction Of Arrival to Scheduler
1969 * on calculating DOA at PHYSICAL LAYER for an UE.
1970 * This API contains DOA information calculated by PHY for an UE.
1972 * @param[in] Pst *pst
1973 * @param[in] SuId suId
1974 * @param[in] TfuDoaIndInfo *doaInd
1979 S16 RgLiTfuDoaInd(Pst *pst, SuId suId, TfuDoaIndInfo *doaInd)
1982 Inst inst = pst->dstInst-SCH_INST_START;
1984 if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
1986 DU_LOG("\nERROR --> SCH : SAP Validation failed");
1987 /* Free up the memory for the request structure */
1988 RGSCH_FREE_MEM(doaInd);
1992 if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
1994 DU_LOG("\nERROR --> SCH : No cell exists");
1997 ret = rgSCHTomDoaInd (rgSchCb[inst].tfuSap[suId].cell, doaInd);
1998 /* Free up the memory for the request structure */
1999 RGSCH_FREE_MEM(doaInd);
2001 } /* RgLiTfuDlCqiInd */
2004 * @brief CRC indication from PHY.
2008 * Function : RgLiTfuCrcInd
2010 * This API is invoked by PHY to give CRC indication to scheduler.
2012 * @param[in] Pst *pst
2013 * @param[in] SuId suId
2014 * @param[in] TfuCrcIndInfo *crcInd
2019 S16 RgLiTfuCrcInd(Pst *pst, SuId suId, TfuCrcIndInfo *crcInd)
2022 Inst inst = pst->dstInst-SCH_INST_START;
2024 #ifdef XEON_SPECIFIC_CHANGES
2025 struct timeval start6, end6;
2026 gettimeofday(&start6, NULL);
2029 if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
2031 DU_LOG("\nERROR --> SCH : SAP Validation failed");
2032 RGSCH_FREE_MEM(crcInd);
2036 if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
2038 DU_LOG("\nERROR --> SCH : No cell exists");
2043 /* Now call the TOM (Tfu ownership module) primitive to process further */
2044 ret = rgSCHTomCrcInd(rgSchCb[inst].tfuSap[suId].cell, crcInd);
2045 /* Free up the memory for the request structure */
2046 RGSCH_FREE_MEM(crcInd);
2047 #ifdef XEON_SPECIFIC_CHANGES
2048 gettimeofday(&end6, NULL);
2051 } /* RgLiTfuCrcInd */
2054 * @brief Timing Advance indication from PHY.
2058 * Function : RgLiTfuTimingAdvInd
2060 * This API is invoked by PHY to indicate timing advance to Scheduler for
2063 * @param[in] Pst *pst
2064 * @param[in] SuId suId
2065 * @param[in] TfuTimingAdvIndInfo *timingAdvInd
2070 S16 RgLiTfuTimingAdvInd(Pst *pst, SuId suId, TfuTimingAdvIndInfo *timingAdvInd)
2073 Inst inst = pst->dstInst-SCH_INST_START;
2075 if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
2077 DU_LOG("\nERROR --> SCH : SAP Validation failed");
2078 /* Free up the memory for the request structure */
2079 RGSCH_FREE_MEM(timingAdvInd);
2083 if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
2085 DU_LOG("\nERROR --> SCH : No cell exists");
2088 /* Now call the TOM (Tfu ownership module) primitive to process further */
2089 ret = rgSCHTomTimingAdvInd(rgSchCb[inst].tfuSap[suId].cell, timingAdvInd);
2090 /* Free up the memory for the request structure */
2091 RGSCH_FREE_MEM(timingAdvInd);
2093 } /* RgLiTfuTimingAdvInd */
2095 /************* RGM Interface ****************/
2097 * @brief API for bind request from RRM towards MAC.
2101 * Function: RgUiRgmBndReq
2103 * This API is invoked by RRM towards MAC to bind RGM SAP.
2104 * These API validates the Pst, spId, suId and sends the bind confirm to
2108 * @param[in] Pst *pst
2109 * @param[in] SuId suId
2110 * @param[in] SpId spId
2115 S16 RgUiRgmBndReq(Pst *pst,SuId suId,SpId spId)
2118 Pst tmpPst; /* Temporary Post Structure */
2119 Inst instId = pst->dstInst-SCH_INST_START;
2121 tmpPst.prior = pst->prior;
2122 tmpPst.route = pst->route;
2123 tmpPst.selector = pst->selector;
2124 tmpPst.region = rgSchCb[instId].rgSchInit.region;
2125 tmpPst.pool = rgSchCb[instId].rgSchInit.pool;
2127 tmpPst.srcProcId = rgSchCb[instId].rgSchInit.procId;
2128 tmpPst.srcEnt = rgSchCb[instId].rgSchInit.ent;
2129 tmpPst.srcInst = rgSchCb[instId].rgSchInit.inst + SCH_INST_START;
2131 tmpPst.event = EVTNONE;
2133 tmpPst.dstProcId = pst->srcProcId;
2134 tmpPst.dstEnt = pst->srcEnt;
2135 tmpPst.dstInst = pst->srcInst;
2137 /*TODO remove follo statement*/
2138 rgSchCb[instId].rgmSap[spId].sapSta.sapState = LRG_UNBND;
2140 if(spId < rgSchCb[instId].numSaps)
2142 /* Check the state of the SAP */
2143 switch (rgSchCb[instId].rgmSap[spId].sapSta.sapState)
2145 /* This case might not be needed if SAP not configured then it will go
2146 * to else of above if condition */
2147 case LRG_UNBND: /* SAP is not bound */
2148 DU_LOG("\nDEBUG --> SCH : SAP is not yet bound");
2149 rgSchCb[instId].rgmSap[spId].sapSta.sapState = LRG_BND;
2150 rgSchCb[instId].rgmSap[spId].sapCfg.suId = suId;
2151 /* Send Bind Confirm with status as SUCCESS */
2152 ret = rgSCHUtlRgmBndCfm(instId, suId, CM_BND_OK);
2153 /*Indicate to Layer manager */
2155 case LRG_BND: /* SAP is already bound*/
2156 DU_LOG("\nDEBUG --> SCH : SAP is already bound");
2157 ret = rgSCHUtlRgmBndCfm(instId, suId, CM_BND_OK);
2159 default: /* Should Never Enter here */
2160 #if (ERRCLASS & ERRCLS_ADD_RES)
2161 DU_LOG("\nERROR --> SCH : Invalid SAP State:RgUiRgmBndReq failed\n");
2163 ret = rgSCHUtlRgmBndCfm(instId, suId, CM_BND_NOK);
2169 #if (ERRCLASS & ERRCLS_ADD_RES)
2170 /* ccpu00117035 - MOD - Changed ErrVal argument from accessing sap state
2171 to spId to avoid seg fault due to invalid sapID */
2172 DU_LOG("\nERROR --> SCH : Invalid SAP Id:RgUiRrmBndReq failed\n");
2174 ret = RgUiRgmBndCfm(&tmpPst, suId, CM_BND_NOK);
2177 } /* RgUiRgmBndReq */
2180 * @brief API for unbind request from RRM towards MAC.
2184 * Function: RgUiRgmUbndReq
2186 * This API is invoked by RRM towards MAC to unbind RGM SAP.
2187 * These API validates the Pst, spId, suId and transfers the unbind request
2188 * specific information to corresponding ownership module (GOM) API.
2191 * @param[in] Pst *pst
2192 * @param[in] SuId suId
2193 * @param[in] Reason reason
2198 S16 RgUiRgmUbndReq(Pst *pst,SpId spId,Reason reason)
2200 Inst instId = pst->dstInst-SCH_INST_START;
2202 /* SAP Id validation */
2203 if (spId < rgSchCb[instId].numSaps)
2205 switch(rgSchCb[instId].rgmSap[spId].sapSta.sapState)
2207 case LRG_BND: /* SAP is already bound*/
2208 /* setting SAP state to UN BOUND */
2209 DU_LOG("\nDEBUG --> SCH : SAP is already bound");
2210 rgSchCb[instId].rgmSap[spId].sapSta.sapState = LRG_UNBND;
2213 #if (ERRCLASS & ERRCLS_ADD_RES)
2214 DU_LOG("\nERROR --> SCH : Invalid SAP State: RgUiRgmUbndReq failed\n");
2221 #if (ERRCLASS & ERRCLS_ADD_RES)
2222 DU_LOG("\nERROR --> SCH : Invalid SAP Id:RgUiRgmUbndReq failed\n");
2227 } /* RgUiRgmUbndReq */
2231 * @brief API for start or stop PRB reporting from RRM towards MAC.
2235 * Function: RgUiRgmCfgPrbRprt
2237 * This API is invoked by RRM towards MAC to start or stop calculating
2238 * Average PRB usage in downlink and uplink. The average PRB usage will
2239 * be reported to RRM based on confiured periodicity.
2242 * @param[in] Pst *pst
2243 * @param[in] SuId suId
2244 * @param[in] SpId spId
2249 S16 RgUiRgmCfgPrbRprt(Pst *pst, SpId spId,RgmPrbRprtCfg *prbRprtCfg)
2253 RgSchPrbUsage *prbUsage;
2254 Inst inst = (pst->dstInst - SCH_INST_START);
2256 cell = rgSchCb[inst].rgmSap[spId].cell;
2257 prbUsage = &cell->prbUsage;
2258 prbUsage->prbRprtEnabld = prbRprtCfg->bConfigType;
2259 prbUsage->rprtPeriod = prbRprtCfg->usPrbAvgPeriodicty;
2260 RG_SCH_ADD_TO_CRNT_TIME(cell->crntTime, prbUsage->startTime, 1);
2262 /* clear the qciPrbRpts for all GBR QCIs */
2263 memset(&prbUsage->qciPrbRpts[0], 0,
2264 (RGM_MAX_QCI_REPORTS * sizeof(RgSchQciPrbUsage)));
2265 DU_LOG("\nDEBUG --> SCH : RgUiRgmCfgPrbRprt config type %d with the report period %d",
2266 prbUsage->prbRprtEnabld,prbUsage->rprtPeriod);
2268 /* ccpu00134393 : mem leak fix */
2269 SCH_FREE(prbRprtCfg, sizeof(RgmPrbRprtCfg));
2274 * @brief ERROR INDICATION from PHY for the i failed unlicensed Scell transmission.
2278 * Function : RgLiTfuErrInd
2280 * This API is invoked by PHY to send ERROR INDICATION to scheduler
2281 * Currently invoked in the cases when the Unlicensed SCell transmission
2283 * This API contains the Cell and subframe information for which the
2284 * transmission failed.
2286 * @param[in] Pst *pst
2287 * @param[in] SuId suId
2288 * @param[in] TfuErrIndInfo *errIndInfo
2293 S16 RgLiTfuErrInd(Pst *pst, SuId suId, TfuErrIndInfo *errInd)
2297 Inst inst = (pst->dstInst - SCH_INST_START);
2301 if ((ret = rgSCHUtlValidateTfuSap (inst, suId)) != ROK)
2304 DU_LOG("\nERROR --> SCH : SAP Validation failed");
2308 if (rgSchCb[inst].tfuSap[suId].cell == NULLP)
2310 DU_LOG("\nERROR --> SCH : No cell exists");
2316 /* Now call the TOM (Tfu ownership module) primitive to process further */
2317 ret = rgSCHLaaErrInd(rgSchCb[inst].tfuSap[suId].cell, errInd);
2320 } /* RgLiTfuErrInd */
2324 /**********************************************************************
2327 **********************************************************************/