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 APIs to handle all the primitives invoked on RGU interface.
35 static const char* RLOG_MODULE_NAME="MAC";
36 static int RLOG_FILE_ID=184;
37 static int RLOG_MODULE_ID=4096;
39 /* header include files (.h) */
40 #include "envopt.h" /* environment options */
41 #include "envdep.h" /* environment dependent */
42 #include "envind.h" /* environment independent */
44 #include "gen.h" /* general */
45 #include "ssi.h" /* system services */
47 #include "cm_tkns.h" /* Common Token Defines */
48 #include "cm_llist.h" /* Common Link List Defines */
49 #include "cm_hash.h" /* Common Hash List Defines */
50 #include "cm_mblk.h" /* common memory link list library */
51 #include "cm_lte.h" /* Common LTE */
53 #include "rg_env.h" /* MAC Environment Defines */
54 #include "crg.h" /* CRG Interface defines */
55 #include "rgu.h" /* RGU Interface defines */
56 #include "tfu.h" /* TFU Interface defines */
57 #include "rg_sch_inf.h" /* RGR Interface defines */
58 #include "lrg.h" /* LRG Interface defines */
60 #include "rg.h" /* MAC defines */
61 #include "rg_err.h" /* MAC error defines */
63 /* header/extern include files (.x) */
64 #include "gen.x" /* general */
65 #include "ssi.x" /* system services */
66 #include "cm5.x" /* Timer */
67 #include "cm_tkns.x" /* Common Token Definitions */
68 #include "cm_llist.x" /* Common Link List Definitions */
69 #include "cm_lib.x" /* Common Library Definitions */
70 #include "cm_hash.x" /* Common Hash List Definitions */
71 #include "cm_mblk.x" /* common memory link list library */
72 #include "cm_lte.x" /* Common LTE */
74 #include "crg.x" /* CRG Interface includes */
75 #include "rgu.x" /* RGU Interface includes */
76 #include "tfu.x" /* TFU Interface includes */
77 #include "rg_sch_inf.x" /* SCH Interface includes */
78 #include "rg_prg.x" /* PRG Interface includes */
79 #include "lrg.x" /* LRG Interface includes */
81 #include "du_app_mac_inf.h"
82 #include "rg.x" /* MAC includes */
85 #define RG_NON_MIMO_IDX 0
89 S16 RgMacSchBrdcmDedBoUpdtReq ARGS((Inst inst, CmLteCellId cellId, CmLteRnti rnti, CmLteLcId lcId, S32 bo ));
90 PRIVATE S16 rgROMHndlCcchDatReq ARGS((RgCellCb *cell,
91 RgRguCmnDatReq *datReq, RgErrInfo *err));
92 PRIVATE S16 rgROMHndlBcchPcchDatReq ARGS((RgCellCb *cell,
93 RgRguCmnDatReq *datReq, RgErrInfo *err));
94 PRIVATE S16 rgROMHndlCcchStaRsp ARGS((RgCellCb *cell,
95 RgRguCmnStaRsp *staRsp, RgErrInfo *err));
96 PRIVATE S16 rgROMHndlBcchPcchStaRsp ARGS((RgCellCb *cell,
97 RgRguCmnStaRsp *staRsp, RgErrInfo *err));
99 /* ADD Changes for Downlink UE Timing Optimization */
100 #ifdef LTEMAC_DLUE_TMGOPTMZ
101 PRIVATE S16 rgROMUpdDlSfRemDataCnt ARGS((RgCellCb *cellCb,
103 PUBLIC S16 rgTOMUtlProcDlSf ARGS(( RgDlSf *dlSf,
108 /* forward references */
111 * @brief Handler for dedicated DatReq received on RGU for an UE.
115 * Function : rgROMDedDatReq
117 * This function shall
118 * -# store the BO reported for the given logical channels.
119 * -# invoke DL HARQ for further processing.
122 * @param[in] Inst inst
123 * @param[in] RgRguDedDatReq *datReq
129 PUBLIC S16 rgROMDedDatReq
132 RgRguDedDatReq *datReq
135 PUBLIC S16 rgROMDedDatReq(inst,datReq)
137 RgRguDedDatReq *datReq;
144 RgDlHqProcCb *hqProc;
149 CmLteTimingInfo timingInfo;
151 #if (ERRCLASS & ERRCLS_DEBUG)
152 RgUstaDgn dgn; /* Alarm diagnostics structure */
154 /* ADD Changes for Downlink UE Timing Optimization */
155 #ifdef LTEMAC_DLUE_TMGOPTMZ
159 //U8 datReqFailCnt = 0;
164 if (((cell = rgCb[inst].cell) == NULLP)
165 || (cell->cellId != datReq->cellId))
167 #if (ERRCLASS & ERRCLS_INT_PAR)
168 /* Handle Cell fetch failure */
169 RGLOGERROR(inst,ERRCLS_INT_PAR,ERG001,(ErrVal)datReq->cellId,
170 "rgROMDedDatReq(): Invalid cell Id");
172 err.errType = RGERR_ROM_DEDDATREQ;
173 err.errCause = RGERR_ROM_INV_CELL_ID;
177 rgUpdtRguDedSts(inst,cell->rguDlSap,RG_RGU_SDU_DROP, datReq);
182 /* Add loop here to scan for all UEs in the consolidated DDatReq*/
183 for(idx = 0; idx < datReq->nmbOfUeGrantPerTti; idx++)
186 timingInfo.slot = (U8)((datReq->datReq[idx].transId >> 8) & 0XFF);
187 timingInfo.sfn = (U16)((datReq->datReq[idx].transId >> 16) & 0xFFFF);
188 sf = &cell->subFrms[(timingInfo.slot % RG_NUM_SUB_FRAMES)];
190 if( (sf->txDone == TRUE) ||
191 (!RG_TIMEINFO_SAME(sf->schdTime,timingInfo)))
193 #if (ERRCLASS & ERRCLS_DEBUG)
194 /* Transmission is already done for this slot. This is a delayed
195 * datReq. So discard */
196 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
197 rgLMMStaInd(inst,LCM_CATEGORY_PROTOCOL, LCM_EVENT_UI_INV_EVT,
198 LRG_CAUSE_DELAYED_DATREQ, &dgn);
200 err.errType = RGERR_ROM_DEDDATREQ;
201 err.errCause = RGERR_ROM_DELAYED_DATREQ;
203 rgUpdtRguDedSts(inst,cell->rguDlSap,RG_RGU_SDU_DROP, datReq);
206 EXTERN U32 dbgDelayedDatReqInMac;
207 dbgDelayedDatReqInMac++;
211 RG_DROP_RGUDDATREQ_MBUF(datReq->datReq[idx]);
214 // RETVALUE(RFAILED);
217 if ((ue = rgDBMGetUeCb(cell, datReq->datReq[idx].rnti)) == NULLP)
219 #if (ERRCLASS & ERRCLS_INT_PAR)
220 /* Handle Ue fetch failure */
221 RGLOGERROR(inst,ERRCLS_INT_PAR,ERG002,(ErrVal)datReq->datReq[idx].rnti,
222 "rgROMDedDatReq(): Invalid ue Id");
224 err.errType = RGERR_ROM_DEDDATREQ;
225 err.errCause = RGERR_ROM_INV_UE_ID;
227 rgUpdtRguDedSts(inst,cell->rguDlSap,RG_RGU_SDU_DROP, datReq);
228 /* ADD Changes for Downlink UE Timing Optimization */
229 #ifdef LTEMAC_DLUE_TMGOPTMZ
230 /* Trying to send the prev successful PDU's
232 ret = rgROMUpdDlSfRemDataCnt(cell, sf);
235 RLOG0(L_INFO, "Dropping due to no ue \n");
237 RG_DROP_RGUDDATREQ_MBUF(datReq->datReq[idx]);
239 /* Return from here as above functions found more datReq than expected*/
243 /* Conitnue for next UE */
247 hqPId = (U8)(datReq->datReq[idx].transId);
249 /* get harq process and invoke DHM */
250 rgDHMGetHqProcFrmId(ue, hqPId, &hqProc);
252 if (rgDHMHndlDedDatReq(inst,hqProc, &datReq->datReq[idx], sf, &err) == RFAILED)
254 RLOG_ARG1(L_ERROR,DBG_CELLID,datReq->cellId,
255 "Handling of Data request in DHM failedi RNTI:%d",
256 datReq->datReq[idx].rnti);
257 err.errType = RGERR_ROM_DEDDATREQ;
258 /* errcause shall be filled in appropriately by DHM */
260 rgUpdtRguDedSts(inst,ue->rguDlSap,RG_RGU_SDU_DROP, datReq);
261 /* ADD Changes for Downlink UE Timing Optimization */
262 #ifdef LTEMAC_DLUE_TMGOPTMZ
263 /* Trying to send the prev successful PDU's
265 ret = rgROMUpdDlSfRemDataCnt(cell, sf);
268 RLOG0(L_INFO, "Dropping due to no failure of remCnt update");
270 RG_DROP_RGUDDATREQ_MBUF(datReq->datReq[idx]);
272 /* Return from here as above functions found more datReq than expected*/
279 /* Merging the updation of statistics of SDUs with for loop below */
281 rgGetPstToInst(&schPst,inst, cell->schInstMap.schInst);
283 boRpt.cellSapId = cell->schInstMap.cellSapId;
284 boRpt.cellId = datReq->cellId;
286 boRpt.rnti = datReq->datReq[idx].rnti;
289 /* Fill the DStaRsp struct and send it to scheduler */
290 for (idx1 = 0; idx1 < datReq->datReq[idx].nmbOfTbs; idx1++)
292 for(idx2 = 0; idx2 < datReq->datReq[idx].datReqTb[idx1].nmbLch; idx2++)
294 /* Updating dedicated SDUs received statistics without
295 additional function above for optimization */
296 ue->rguDlSap->sapSts.numPduRcvd +=
297 datReq->datReq[idx].datReqTb[idx1].lchData[idx2].pdu.numPdu;
299 boRpt.lcId = datReq->datReq[idx].datReqTb[idx1].lchData[idx2].lcId;
300 boRpt.bo = datReq->datReq[idx].datReqTb[idx1].lchData[idx2].boReport.bo;
301 boRpt.oldestSduArrTime
302 = datReq->datReq[idx].datReqTb[idx1].lchData[idx2].boReport.oldestSduArrTime;
303 boRpt.staPduBo = datReq->datReq[idx].datReqTb[idx1].lchData[idx2].boReport.staPduBo;
305 boRpt.setMaxUlPrio= datReq->datReq[idx].datReqTb[idx1].lchData[idx2].setMaxUlPrio;
307 boRpt.setMaxDlPrio= datReq->datReq[idx].datReqTb[idx1].lchData[idx2].boReport.staPduPrsnt;
309 RgMacSchDedBoUpdt(&schPst, &boRpt);
313 /* ADD Changes for Downlink UE Timing Optimization */
314 #ifdef LTEMAC_DLUE_TMGOPTMZ
315 // sf->remDatReqCnt -= datReqFailCnt;
316 /*Presently this function is not returning RFAILED, thus not checking
317 for failure condition.*/
318 ret = rgROMUpdDlSfRemDataCnt(cell, sf);
321 RLOG0(L_INFO, "\n Dropping due to no failure of remCnt update(1) \n");
323 RG_DROP_RGUDDATREQ_MBUF(datReq->datReq[idx]);
325 /* Return from here as above functions found more datReq than expected*/
329 } /* for loop for num of Ue per TTI*/
332 /* Data send successfully to PHY. lets retuns ROK*/
334 } /* rgROMDedDatReq */
338 * @brief Handler for DatReq received on RGU for a common logical channel.
342 * Function : rgROMCmnDatReq
344 * This function shall invoke rgROMHndlCcchDatReq() if datReq is on CCCH
345 * If not, it shall invoke rgROMHndlBcchPcchDatReq().
348 * @param[in] Inst inst
349 * @param[in] RgRguCmnDatReq *datReq
355 PUBLIC S16 rgROMCmnDatReq
358 RgRguCmnDatReq *datReq
361 PUBLIC S16 rgROMCmnDatReq(inst,datReq)
363 RgRguCmnDatReq *datReq;
369 /* ADD Changes for Downlink UE Timing Optimization */
370 #ifdef LTEMAC_DLUE_TMGOPTMZ
371 CmLteTimingInfo timingInfo;
378 err.errType = RGERR_ROM_CMNDATREQ;
379 if(((cell = rgCb[inst].cell) == NULLP)
380 ||(cell->cellId != datReq->cellId))
382 #if (ERRCLASS & ERRCLS_INT_PAR)
383 /* Handle Cell fetch failure */
384 RGLOGERROR(inst,ERRCLS_INT_PAR,ERG003,(ErrVal)datReq->cellId,
385 "rgROMCmnDatReq(): Invalid cell Id");
387 err.errCause = RGERR_ROM_INV_CELL_ID;
391 rgUpdtRguCmnSts(inst,cell->rguDlSap,RG_RGU_SDU_DROP);
396 if (datReq->lcId == cell->dlCcchId)
398 ret = rgROMHndlCcchDatReq(cell, datReq, &err);
400 /*Get the timing Info*/
401 /* ADD Changes for Downlink UE Timing Optimization */
402 #ifdef LTEMAC_DLUE_TMGOPTMZ
403 timingInfo.slot = (U8)((datReq->transId >> 8) & 0XFF);
404 timingInfo.sfn = (U16)((datReq->transId >> 16) & 0xFFFF);
409 ret = rgROMHndlBcchPcchDatReq(cell, datReq, &err);
411 /*Get the timing Info*/
412 /* ADD Changes for Downlink UE Timing Optimization */
413 #ifdef LTEMAC_DLUE_TMGOPTMZ
414 timingInfo.slot = (U8)(datReq->transId & 0XFF);
415 timingInfo.sfn = (U16)((datReq->transId >> 8) & 0xFFFF);
422 rgUpdtRguCmnSts(inst,cell->rguDlSap,RG_RGU_SDU_DROP);
426 /* Update stats with number of SDUs received */
427 rgUpdtRguCmnSts(inst,cell->rguDlSap,RG_RGU_SDU_RCVD);
430 /* ADD Changes for Downlink UE Timing Optimization */
431 #ifdef LTEMAC_DLUE_TMGOPTMZ
432 RG_ARRAY_BOUND_CHECK(0, cell->subFrms, (timingInfo.slot % RG_NUM_SUB_FRAMES));
433 sf = &cell->subFrms[(timingInfo.slot % RG_NUM_SUB_FRAMES)];
435 ret = rgROMUpdDlSfRemDataCnt(cell, sf);
436 /*Added check for RFAILED as above function can return RFAILED*/
440 } /* rgROMCmnDatReq */
443 * @brief Handler for DatReq received on RGU for CCCH.
447 * Function : rgROMHndlCcchDatReq
449 * This function shall fetch the raCb with the given rnti and indicate msg4
453 * @param[in] RgCellCb *cell
454 * @param[in] RgRguCmnDatReq *datReq
455 * @param[out] RgErrInfo *err
461 PRIVATE S16 rgROMHndlCcchDatReq
464 RgRguCmnDatReq *datReq,
468 PRIVATE S16 rgROMHndlCcchDatReq(cell, datReq, err)
470 RgRguCmnDatReq *datReq;
474 Inst inst = cell->macInst - RG_INST_START;
477 RgDlHqProcCb *hqProc;
478 CmLteTimingInfo timingInfo;
480 #if (ERRCLASS & ERRCLS_DEBUG)
481 RgUstaDgn dgn; /* Alarm diagnostics structure */
484 TRC2(rgROMHndlCcchDatReq);
487 err->errType = RGERR_ROM_CMNDATREQ;
489 if ((ue = rgDBMGetUeCb(cell, datReq->u.rnti)) == NULLP)
491 if ((ue = rgDBMGetUeCbFromRachLst(cell, datReq->u.rnti)) == NULLP)
493 #if (ERRCLASS & ERRCLS_INT_PAR)
494 /* Handle Ue fetch failure */
495 RGLOGERROR(inst,ERRCLS_INT_PAR,ERG004,(ErrVal)datReq->u.rnti,
496 "rgROMHndlCcchDatReq(): Invalid ue Id");
498 err->errCause = RGERR_ROM_INV_UE_ID;
503 timingInfo.slot = (U8)((datReq->transId >> 8) & 0XFF);
504 timingInfo.sfn = (U16)((datReq->transId >> 16) & 0xFFFF);
505 sf = &cell->subFrms[(timingInfo.slot % RG_NUM_SUB_FRAMES)];
507 if( (sf->txDone == TRUE) ||
508 (!RG_TIMEINFO_SAME(sf->schdTime,timingInfo)))
510 #if (ERRCLASS & ERRCLS_DEBUG)
511 /* Transmission is already done for this slot. This is a delayed
512 * datReq. So discard */
513 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
514 rgLMMStaInd(inst,LCM_CATEGORY_PROTOCOL, LCM_EVENT_UI_INV_EVT,
515 LRG_CAUSE_DELAYED_DATREQ, &dgn);
517 err->errCause = RGERR_ROM_DELAYED_DATREQ;
521 hqPId = (U8)(datReq->transId);
524 /* get harq process and invoke DHM */
525 rgDHMGetHqProcFrmId(ue, hqPId, &hqProc);
527 /* Changed for CR timer implementation*/
528 /* invoke DHM to process CCCH data */
529 if (rgDHMHndlCmnDatReq(inst,hqProc, datReq, err) == RFAILED)
531 RLOG_ARG2(L_ERROR,DBG_CELLID,cell->cellId,
532 "Handling of Data request in DHM failed RNTI:%d LCID:%d",
533 datReq->u.rnti,datReq->lcId);
534 /* Release First TB */
535 rgDHMRlsHqProcTB(cell, hqProc, 1);
536 /* err shall be filled in appropriately by DHM */
541 } /* rgROMHndlCcchDatReq */
545 * @brief Handler for DatReq received on RGU for BCCH or PCCH.
549 * Function : rgROMHndlBcchPcchDatReq
551 * This function shall store the buffer and time to transmit in lcCb.
554 * @param[in] RgCellCb *cell
555 * @param[in] RgRguCmnDatReq *datReq
556 * @param[out] RgErrInfo *err
562 PRIVATE S16 rgROMHndlBcchPcchDatReq
565 RgRguCmnDatReq *datReq,
569 PRIVATE S16 rgROMHndlBcchPcchDatReq(cell, datReq, err)
571 RgRguCmnDatReq *datReq;
575 Inst inst = cell->macInst - RG_INST_START;
577 /* Modified for SI Enhancement*/
580 RgBcchDlschLcCb *bcch;
583 CmLteTimingInfo timingInfo;
584 #if (ERRCLASS & ERRCLS_DEBUG)
585 RgUstaDgn dgn; /* Alarm diagnostics structure */
588 TRC2(rgROMHndlBcchPcchDatReq);
591 timingInfo.slot = (U8)(datReq->transId & 0XFF);
592 timingInfo.sfn = (U16)((datReq->transId >> 8) & 0xFFFF);
593 sf = &cell->subFrms[(timingInfo.slot % RG_NUM_SUB_FRAMES)];
595 if( (sf->txDone == TRUE) ||
596 (!RG_TIMEINFO_SAME(sf->schdTime,timingInfo)))
598 #if (ERRCLASS & ERRCLS_DEBUG)
599 /* Transmission is already done for this slot. This is a delayed
600 * datReq. So discard */
601 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
602 rgLMMStaInd(inst,LCM_CATEGORY_PROTOCOL, LCM_EVENT_UI_INV_EVT,
603 LRG_CAUSE_DELAYED_DATREQ, &dgn);
605 err->errCause = RGERR_ROM_DELAYED_DATREQ;
610 bcch = rgDBMGetBcchOnDlsch(cell,datReq->lcId);
613 /* Store BCCH-DLSCH data received in Scheduled slot */
614 sf->bcch.tb = datReq->pdu;
616 SCpyMsgMsg(datReq->pdu, RG_GET_MEM_REGION(rgCb[inst]),
617 RG_GET_MEM_POOL(rgCb[inst]), &bcch->tb);
622 bch = rgDBMGetBcchOnBch(cell);
623 if ((bch) && (bch->lcId == datReq->lcId))
625 /* Store BCH data received in Scheduled slot */
626 sf->bch.tb = datReq->pdu;
631 pcch = rgDBMGetPcch(cell);
632 if ((pcch) && (pcch->lcId == datReq->lcId))
634 /* Store PCCH-DLSCH data received in Scheduled slot */
635 sf->pcch.tb = datReq->pdu;
639 /* Handle lcCb fetch failure */
640 RGLOGERROR(inst,ERRCLS_INT_PAR,ERG005,(ErrVal)datReq->lcId,
641 "rgROMHndlBcchPcchDatReq(): Invalid Lc Id");
642 err->errCause = RGERR_ROM_INV_LC_ID;
645 } /* rgROMHndlBcchPcchDatReq */
648 * @brief Handler for StaRsp received on RGU for a dedicated logical channel.
652 * Function : rgROMDedStaRsp
654 * This fucntion shall store the BO reported for the given logical
658 * @param[in] Inst inst
659 * @param[in] RgRguDedStaRsp *staRsp
665 PUBLIC S16 rgROMDedStaRsp
668 RgRguDedStaRsp *staRsp
671 PUBLIC S16 rgROMDedStaRsp(inst,staRsp)
673 RgRguDedStaRsp *staRsp;
678 /* Moving the error variables and assignments to available scope */
682 /* Avoiding memset, as the variables of this are getting
686 if(((cell = rgCb[inst].cell) != NULLP)
687 && (cell->cellId == staRsp->cellId))
692 boRpt.cellSapId = cell->schInstMap.cellSapId;
693 boRpt.cellId = staRsp->cellId;
694 boRpt.rnti = staRsp->rnti;
695 boRpt.lcId = staRsp->lcId;
696 boRpt.bo = staRsp->boReport.bo;
697 boRpt.oldestSduArrTime = staRsp->boReport.oldestSduArrTime;
698 boRpt.staPduBo = staRsp->boReport.staPduBo;
699 boRpt.oldestSduArrTime = staRsp->boReport.oldestSduArrTime;
701 rgGetPstToInst(&schPst,inst, cell->schInstMap.schInst);
703 //TODO: commented for compilation without SCH RgMacSchDedBoUpdt(&schPst, &boRpt);
706 RLOG_ARG2(L_ERROR,DBG_CELLID,staRsp->cellId,"Invalid cell for CRNTI:%d LCID:%d ",
707 staRsp->rnti,staRsp->lcId);
710 } /* rgROMDedStaRsp */
712 S16 RgMacSchBrdcmDedBoUpdtReq(
722 //if ((cell = rgDBMGetCellCb(cellId)) != NULLP)
723 if (((cell = rgCb[inst].cell) != NULLP) &&
724 (cell->cellId == cellId))
729 boRpt.cellSapId = cell->schInstMap.cellSapId;
730 boRpt.cellId = cellId;
735 rgGetPstToInst(&schPst,inst, cell->schInstMap.schInst);
737 //TODO: commented for compilation without SCH RgMacSchDedBoUpdtReq (&schPst,&boRpt);
742 * @brief Handler for StaRsp received on RGU for a common logical channel.
746 * Function : rgROMCmnStaRsp
748 * This fucntion shall invoke rgROMHndlCcchStaRsp() for status response on
749 * CCCH and shall invoke rgROMHndlBcchPcchStaRsp() for status response on
753 * @param[in] Inst inst
754 * @param[in] RgRguCmnStaRsp *staRsp
760 PUBLIC S16 rgROMCmnStaRsp
763 RgRguCmnStaRsp *staRsp
766 PUBLIC S16 rgROMCmnStaRsp(inst,staRsp)
768 RgRguCmnStaRsp *staRsp;
777 if(((cell = rgCb[inst].cell) == NULLP)
778 || (cell->cellId != staRsp->cellId))
780 /* Handle Cell fetch failure */
781 RLOG_ARG2(L_ERROR,DBG_CELLID,staRsp->cellId,
782 "Invalid cell for CRNTI:%d LCID:%d",staRsp->u.rnti,staRsp->lcId);
783 err.errType = RGERR_ROM_CMNSTARSP;
784 err.errCause = RGERR_ROM_INV_CELL_ID;
788 /* handle status response on CCCH */
789 if(staRsp->lcId == cell->dlCcchId)
791 rgROMHndlCcchStaRsp(cell, staRsp, &err);
795 rgROMHndlBcchPcchStaRsp(cell, staRsp, &err);
799 } /* rgROMCmnStaRsp */
804 * @brief Handler for Request received on RGU for a UL Throughput measurement
805 * enabled logical channel.
809 * Function :rgROML2MUlThrpMeasReq
811 * This function shall store the L2M UL Throughput Measurement status information
812 * for the given logical channel.
815 * @param[in] Inst inst
816 * @param[in] RgRguL2MUlThrpMeasReq *measReq
822 PUBLIC S16 rgROML2MUlThrpMeasReq
825 RgRguL2MUlThrpMeasReq *measReq
828 PUBLIC S16 rgROML2MUlThrpMeasReq(inst,measReq)
830 RgRguL2MUlThrpMeasReq *measReq;
837 TRC2(rgROML2MUlThrpMeasReq)
841 if(((cell = rgCb[inst].cell) != NULLP)
842 &&(cell->cellId == measReq->cellId))
844 if ((ue = rgDBMGetUeCb(cell, measReq->rnti)) != NULLP)
846 for(loop=0; loop<measReq->numLcId;loop++)
848 if ((rgDBMGetUlDedLcCb(ue, measReq->lcId[loop])) != NULLP)
850 ue->ul.lcCb[measReq->lcId[loop]].measOn = measReq->enbMeas;
851 if(ue->ul.lcCb[measReq->lcId[loop]].measOn == FALSE)
853 lcgId=ue->ul.lcCb[measReq->lcId[loop]].lcgId;
854 ue->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs = 0;
855 ue->ul.lcgArr[lcgId].lcgBsInfo.firstDatSegRcvd = FALSE;
862 RLOG_ARG1(L_ERROR,DBG_CELLID,measReq->cellId,"Invalid cell CRNTI:%d",
865 } /* rgROML2MUlThrpMeasReq */
870 * @brief Handler for StaRsp received on RGU for CCCH.
874 * Function : rgROMHndlCcchStaRsp
876 * This function shall fetch the raCb with the given RNTI and ask RAM to
880 * @param[in] RgCellCb *cell
881 * @param[in] RgRguCmnStaRsp *staRsp
882 * @param[out] RgErrInfo *err
888 PRIVATE S16 rgROMHndlCcchStaRsp
891 RgRguCmnStaRsp *staRsp,
895 PRIVATE S16 rgROMHndlCcchStaRsp(cell, staRsp, err)
897 RgRguCmnStaRsp *staRsp;
902 Inst macInst = cell->macInst - RG_INST_START;
903 //RgInfCmnBoRpt boRpt;
905 TRC2(rgROMHndlCcchStaRsp);
908 boRpt.cellSapId = cell->schInstMap.cellSapId;
909 boRpt.cellId = staRsp->cellId;
910 boRpt.u.rnti = staRsp->u.rnti;
911 boRpt.lcId = staRsp->lcId;
912 boRpt.lcType = staRsp->lcType;
913 boRpt.bo = staRsp->bo;
915 rgGetPstToInst(&schPst,macInst, cell->schInstMap.schInst);
916 //TODO: commented for compilation without SCH RgMacSchCmnBoUpdt(&schPst, &boRpt);
919 } /* rgROMHndlCcchStaRsp */
923 * @brief Handler for StaRsp received on RGU for BCCH or PCCH.
927 * Function : rgROMHndlBcchPcchStaRsp
929 * This function shall store the buffer and time to transmit in lcCb.
932 * @param[in] RgCellCb *cell
933 * @param[in] RgRguCmnStaRsp *staRsp
934 * @param[out] RgErrInfo *err
940 PRIVATE S16 rgROMHndlBcchPcchStaRsp
943 RgRguCmnStaRsp *staRsp,
947 PRIVATE S16 rgROMHndlBcchPcchStaRsp(cell, staRsp, err)
949 RgRguCmnStaRsp *staRsp;
954 //RgInfCmnBoRpt boRpt;
955 Inst macInst = cell->macInst - RG_INST_START;
957 TRC2(rgROMHndlBcchPcchStaRsp);
958 cmMemset((U8*)&schPst, (U8)0, sizeof(Pst));
960 if (rgDBMChkCmnLcCb(cell, staRsp->lcId) != ROK)
962 /* Handle lcCb fetch failure */
963 RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId,"Invalid LCID:%d",staRsp->lcId);
964 err->errCause = RGERR_ROM_INV_LC_ID;
967 /* MS_WORKAROUND : This is to ensure that the queue for BCH is not filled with old BO requests :
968 This assumes that BO is not received more than 4 frames in advance from the enodeb application */
969 if (cell->bcchBchInfo.lcId == staRsp->lcId)
973 nextBchSfn = (cell->crntTime.sfn + 4 - (cell->crntTime.sfn%4)) % RG_MAX_SFN;
974 if ((staRsp->u.timeToTx.sfn != nextBchSfn) ||
975 ((staRsp->u.timeToTx.sfn == cell->crntTime.sfn) && (cell->crntTime.slot >= 7)))
981 boRpt.cellSapId = cell->schInstMap.cellSapId;
982 boRpt.cellId = staRsp->cellId;
983 boRpt.u.timeToTx = staRsp->u.timeToTx;
984 boRpt.lcId = staRsp->lcId;
985 boRpt.lcType = staRsp->lcType;
986 boRpt.bo = staRsp->bo;*/
990 if(boRpt.lcType == CM_LTE_LCH_PCCH)
992 boRpt.emtcDIReason = staRsp->emtcDiReason;
993 boRpt.pnb = staRsp->pnb;
997 rgGetPstToInst(&schPst,macInst, cell->schInstMap.schInst);
998 //TODO: commented for compilation without SCH RgMacSchCmnBoUpdt(&schPst, &boRpt);
1001 } /* rgROMHndlBcchPcchStaRsp */
1003 /* ADD Changes for Downlink UE Timing Optimization */
1004 #ifdef LTEMAC_DLUE_TMGOPTMZ
1006 * @brief Handler for updating DL SF information on receiving
1007 * DL dedicated data, CCCH, BCCH/PCCH data request.
1011 * Function : rgROMUpdDLSfRemDataCnt
1014 * @param[in] RgCellCb *cell
1015 * @param[in] RgDlSf *dlSf;
1021 PRIVATE S16 rgROMUpdDlSfRemDataCnt
1027 PRIVATE S16 rgROMUpdDlSfRemDataCnt(cellCb, dlSf)
1033 //Inst inst = cellCb->macInst - RG_INST_START;
1035 TRC2(rgROMUpdDlSfRemDataCnt);
1038 if(!dlSf->remDatReqCnt)
1040 /*This is an error scenario of RLC generating more data
1041 * request than the allocation. Do nothing for this. */
1042 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
1043 "RX new data while remDatReqCnt is 0 for cell");
1047 /*Decrement the remaining data request to be received countter
1049 Check if this was the last pending data request for this DL SF.*/
1050 /* Fix[ccpu00126310]: Tracks Data Requests from RLC for both loosely and tight coupled
1052 if((0 == --dlSf->remDatReqCnt) && !(dlSf->txDone) &&
1053 (RG_TIMEINFO_SAME(cellCb->crntTime, dlSf->schdTime)) && (dlSf->statIndDone))
1055 /*Check if we have already received a TTI for this Data,
1056 if that is the case then we need to send TFU Data request
1059 if (ROK != rgTOMUtlProcDlSf (dlSf, cellCb, &err))
1061 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
1062 "Unable to process downlink slot for cell");
1063 err.errType = RGERR_ROM_DEDDATREQ;
1066 /* Mark this frame as sent */
1067 dlSf->txDone = TRUE;
1071 } /* rgROMUpdDlSfRemDataCnt*/
1074 /**********************************************************************
1077 **********************************************************************/