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 "rg.x" /* MAC includes */
84 #define RG_NON_MIMO_IDX 0
88 S16 RgMacSchBrdcmDedBoUpdtReq ARGS((Inst inst, CmLteCellId cellId, CmLteRnti rnti, CmLteLcId lcId, S32 bo ));
89 PRIVATE S16 rgROMHndlCcchDatReq ARGS((RgCellCb *cell,
90 RgRguCmnDatReq *datReq, RgErrInfo *err));
91 PRIVATE S16 rgROMHndlBcchPcchDatReq ARGS((RgCellCb *cell,
92 RgRguCmnDatReq *datReq, RgErrInfo *err));
93 PRIVATE S16 rgROMHndlCcchStaRsp ARGS((RgCellCb *cell,
94 RgRguCmnStaRsp *staRsp, RgErrInfo *err));
95 PRIVATE S16 rgROMHndlBcchPcchStaRsp ARGS((RgCellCb *cell,
96 RgRguCmnStaRsp *staRsp, RgErrInfo *err));
98 /* ADD Changes for Downlink UE Timing Optimization */
99 #ifdef LTEMAC_DLUE_TMGOPTMZ
100 PRIVATE S16 rgROMUpdDlSfRemDataCnt ARGS((RgCellCb *cellCb,
102 PUBLIC S16 rgTOMUtlProcDlSf ARGS(( RgDlSf *dlSf,
107 /* forward references */
110 * @brief Handler for dedicated DatReq received on RGU for an UE.
114 * Function : rgROMDedDatReq
116 * This function shall
117 * -# store the BO reported for the given logical channels.
118 * -# invoke DL HARQ for further processing.
121 * @param[in] Inst inst
122 * @param[in] RgRguDedDatReq *datReq
128 PUBLIC S16 rgROMDedDatReq
131 RgRguDedDatReq *datReq
134 PUBLIC S16 rgROMDedDatReq(inst,datReq)
136 RgRguDedDatReq *datReq;
142 RgDlHqProcCb *hqProc;
147 CmLteTimingInfo timingInfo;
149 #if (ERRCLASS & ERRCLS_DEBUG)
150 RgUstaDgn dgn; /* Alarm diagnostics structure */
152 /* ADD Changes for Downlink UE Timing Optimization */
153 #ifdef LTEMAC_DLUE_TMGOPTMZ
157 //U8 datReqFailCnt = 0;
162 if (((cell = rgCb[inst].cell) == NULLP)
163 || (cell->cellId != datReq->cellId))
165 #if (ERRCLASS & ERRCLS_INT_PAR)
166 /* Handle Cell fetch failure */
167 RGLOGERROR(inst,ERRCLS_INT_PAR,ERG001,(ErrVal)datReq->cellId,
168 "rgROMDedDatReq(): Invalid cell Id");
170 err.errType = RGERR_ROM_DEDDATREQ;
171 err.errCause = RGERR_ROM_INV_CELL_ID;
175 rgUpdtRguDedSts(inst,cell->rguDlSap,RG_RGU_SDU_DROP, datReq);
180 /* Add loop here to scan for all UEs in the consolidated DDatReq*/
181 for(idx = 0; idx < datReq->nmbOfUeGrantPerTti; idx++)
184 timingInfo.subframe = (U8)((datReq->datReq[idx].transId >> 8) & 0XFF);
185 timingInfo.sfn = (U16)((datReq->datReq[idx].transId >> 16) & 0xFFFF);
186 sf = &cell->subFrms[(timingInfo.subframe % RG_NUM_SUB_FRAMES)];
188 if( (sf->txDone == TRUE) ||
189 (!RG_TIMEINFO_SAME(sf->schdTime,timingInfo)))
191 #if (ERRCLASS & ERRCLS_DEBUG)
192 /* Transmission is already done for this subframe. This is a delayed
193 * datReq. So discard */
194 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
195 rgLMMStaInd(inst,LCM_CATEGORY_PROTOCOL, LCM_EVENT_UI_INV_EVT,
196 LRG_CAUSE_DELAYED_DATREQ, &dgn);
198 err.errType = RGERR_ROM_DEDDATREQ;
199 err.errCause = RGERR_ROM_DELAYED_DATREQ;
201 rgUpdtRguDedSts(inst,cell->rguDlSap,RG_RGU_SDU_DROP, datReq);
204 EXTERN U32 dbgDelayedDatReqInMac;
205 dbgDelayedDatReqInMac++;
209 RG_DROP_RGUDDATREQ_MBUF(datReq->datReq[idx]);
212 // RETVALUE(RFAILED);
215 if ((ue = rgDBMGetUeCb(cell, datReq->datReq[idx].rnti)) == NULLP)
217 #if (ERRCLASS & ERRCLS_INT_PAR)
218 /* Handle Ue fetch failure */
219 RGLOGERROR(inst,ERRCLS_INT_PAR,ERG002,(ErrVal)datReq->datReq[idx].rnti,
220 "rgROMDedDatReq(): Invalid ue Id");
222 err.errType = RGERR_ROM_DEDDATREQ;
223 err.errCause = RGERR_ROM_INV_UE_ID;
225 rgUpdtRguDedSts(inst,cell->rguDlSap,RG_RGU_SDU_DROP, datReq);
226 /* ADD Changes for Downlink UE Timing Optimization */
227 #ifdef LTEMAC_DLUE_TMGOPTMZ
228 /* Trying to send the prev successful PDU's
230 ret = rgROMUpdDlSfRemDataCnt(cell, sf);
233 RLOG0(L_INFO, "Dropping due to no ue \n");
235 RG_DROP_RGUDDATREQ_MBUF(datReq->datReq[idx]);
237 /* Return from here as above functions found more datReq than expected*/
241 /* Conitnue for next UE */
245 hqPId = (U8)(datReq->datReq[idx].transId);
247 /* get harq process and invoke DHM */
248 rgDHMGetHqProcFrmId(ue, hqPId, &hqProc);
250 if (rgDHMHndlDedDatReq(inst,hqProc, &datReq->datReq[idx], sf, &err) == RFAILED)
252 RLOG_ARG1(L_ERROR,DBG_CELLID,datReq->cellId,
253 "Handling of Data request in DHM failedi RNTI:%d",
254 datReq->datReq[idx].rnti);
255 err.errType = RGERR_ROM_DEDDATREQ;
256 /* errcause shall be filled in appropriately by DHM */
258 rgUpdtRguDedSts(inst,ue->rguDlSap,RG_RGU_SDU_DROP, datReq);
259 /* ADD Changes for Downlink UE Timing Optimization */
260 #ifdef LTEMAC_DLUE_TMGOPTMZ
261 /* Trying to send the prev successful PDU's
263 ret = rgROMUpdDlSfRemDataCnt(cell, sf);
266 RLOG0(L_INFO, "Dropping due to no failure of remCnt update");
268 RG_DROP_RGUDDATREQ_MBUF(datReq->datReq[idx]);
270 /* Return from here as above functions found more datReq than expected*/
277 /* Merging the updation of statistics of SDUs with for loop below */
279 rgGetPstToInst(&schPst,inst, cell->schInstMap.schInst);
281 boRpt.cellSapId = cell->schInstMap.cellSapId;
282 boRpt.cellId = datReq->cellId;
284 boRpt.rnti = datReq->datReq[idx].rnti;
287 /* Fill the DStaRsp struct and send it to scheduler */
288 for (idx1 = 0; idx1 < datReq->datReq[idx].nmbOfTbs; idx1++)
290 for(idx2 = 0; idx2 < datReq->datReq[idx].datReqTb[idx1].nmbLch; idx2++)
292 /* Updating dedicated SDUs received statistics without
293 additional function above for optimization */
294 ue->rguDlSap->sapSts.numPduRcvd +=
295 datReq->datReq[idx].datReqTb[idx1].lchData[idx2].pdu.numPdu;
297 boRpt.lcId = datReq->datReq[idx].datReqTb[idx1].lchData[idx2].lcId;
298 boRpt.bo = datReq->datReq[idx].datReqTb[idx1].lchData[idx2].boReport.bo;
299 boRpt.oldestSduArrTime
300 = datReq->datReq[idx].datReqTb[idx1].lchData[idx2].boReport.oldestSduArrTime;
301 boRpt.staPduBo = datReq->datReq[idx].datReqTb[idx1].lchData[idx2].boReport.staPduBo;
303 boRpt.setMaxUlPrio= datReq->datReq[idx].datReqTb[idx1].lchData[idx2].setMaxUlPrio;
305 boRpt.setMaxDlPrio= datReq->datReq[idx].datReqTb[idx1].lchData[idx2].boReport.staPduPrsnt;
307 //TODO: commented for compilation without SCH RgMacSchDedBoUpdt(&schPst, &boRpt);
311 /* ADD Changes for Downlink UE Timing Optimization */
312 #ifdef LTEMAC_DLUE_TMGOPTMZ
313 // sf->remDatReqCnt -= datReqFailCnt;
314 /*Presently this function is not returning RFAILED, thus not checking
315 for failure condition.*/
316 ret = rgROMUpdDlSfRemDataCnt(cell, sf);
319 RLOG0(L_INFO, "\n Dropping due to no failure of remCnt update(1) \n");
321 RG_DROP_RGUDDATREQ_MBUF(datReq->datReq[idx]);
323 /* Return from here as above functions found more datReq than expected*/
327 } /* for loop for num of Ue per TTI*/
329 /* Data send successfully to PHY. lets retuns ROK*/
331 } /* rgROMDedDatReq */
335 * @brief Handler for DatReq received on RGU for a common logical channel.
339 * Function : rgROMCmnDatReq
341 * This function shall invoke rgROMHndlCcchDatReq() if datReq is on CCCH
342 * If not, it shall invoke rgROMHndlBcchPcchDatReq().
345 * @param[in] Inst inst
346 * @param[in] RgRguCmnDatReq *datReq
352 PUBLIC S16 rgROMCmnDatReq
355 RgRguCmnDatReq *datReq
358 PUBLIC S16 rgROMCmnDatReq(inst,datReq)
360 RgRguCmnDatReq *datReq;
366 /* ADD Changes for Downlink UE Timing Optimization */
367 #ifdef LTEMAC_DLUE_TMGOPTMZ
368 CmLteTimingInfo timingInfo;
375 err.errType = RGERR_ROM_CMNDATREQ;
376 if(((cell = rgCb[inst].cell) == NULLP)
377 ||(cell->cellId != datReq->cellId))
379 #if (ERRCLASS & ERRCLS_INT_PAR)
380 /* Handle Cell fetch failure */
381 RGLOGERROR(inst,ERRCLS_INT_PAR,ERG003,(ErrVal)datReq->cellId,
382 "rgROMCmnDatReq(): Invalid cell Id");
384 err.errCause = RGERR_ROM_INV_CELL_ID;
388 rgUpdtRguCmnSts(inst,cell->rguDlSap,RG_RGU_SDU_DROP);
393 if (datReq->lcId == cell->dlCcchId)
395 ret = rgROMHndlCcchDatReq(cell, datReq, &err);
397 /*Get the timing Info*/
398 /* ADD Changes for Downlink UE Timing Optimization */
399 #ifdef LTEMAC_DLUE_TMGOPTMZ
400 timingInfo.subframe = (U8)((datReq->transId >> 8) & 0XFF);
401 timingInfo.sfn = (U16)((datReq->transId >> 16) & 0xFFFF);
406 ret = rgROMHndlBcchPcchDatReq(cell, datReq, &err);
408 /*Get the timing Info*/
409 /* ADD Changes for Downlink UE Timing Optimization */
410 #ifdef LTEMAC_DLUE_TMGOPTMZ
411 timingInfo.subframe = (U8)(datReq->transId & 0XFF);
412 timingInfo.sfn = (U16)((datReq->transId >> 8) & 0xFFFF);
419 rgUpdtRguCmnSts(inst,cell->rguDlSap,RG_RGU_SDU_DROP);
423 /* Update stats with number of SDUs received */
424 rgUpdtRguCmnSts(inst,cell->rguDlSap,RG_RGU_SDU_RCVD);
427 /* ADD Changes for Downlink UE Timing Optimization */
428 #ifdef LTEMAC_DLUE_TMGOPTMZ
429 RG_ARRAY_BOUND_CHECK(0, cell->subFrms, (timingInfo.subframe % RG_NUM_SUB_FRAMES));
430 sf = &cell->subFrms[(timingInfo.subframe % RG_NUM_SUB_FRAMES)];
432 ret = rgROMUpdDlSfRemDataCnt(cell, sf);
433 /*Added check for RFAILED as above function can return RFAILED*/
437 } /* rgROMCmnDatReq */
440 * @brief Handler for DatReq received on RGU for CCCH.
444 * Function : rgROMHndlCcchDatReq
446 * This function shall fetch the raCb with the given rnti and indicate msg4
450 * @param[in] RgCellCb *cell
451 * @param[in] RgRguCmnDatReq *datReq
452 * @param[out] RgErrInfo *err
458 PRIVATE S16 rgROMHndlCcchDatReq
461 RgRguCmnDatReq *datReq,
465 PRIVATE S16 rgROMHndlCcchDatReq(cell, datReq, err)
467 RgRguCmnDatReq *datReq;
471 Inst inst = cell->macInst - RG_INST_START;
474 RgDlHqProcCb *hqProc;
475 CmLteTimingInfo timingInfo;
477 #if (ERRCLASS & ERRCLS_DEBUG)
478 RgUstaDgn dgn; /* Alarm diagnostics structure */
481 TRC2(rgROMHndlCcchDatReq);
484 err->errType = RGERR_ROM_CMNDATREQ;
486 if ((ue = rgDBMGetUeCb(cell, datReq->u.rnti)) == NULLP)
488 if ((ue = rgDBMGetUeCbFromRachLst(cell, datReq->u.rnti)) == NULLP)
490 #if (ERRCLASS & ERRCLS_INT_PAR)
491 /* Handle Ue fetch failure */
492 RGLOGERROR(inst,ERRCLS_INT_PAR,ERG004,(ErrVal)datReq->u.rnti,
493 "rgROMHndlCcchDatReq(): Invalid ue Id");
495 err->errCause = RGERR_ROM_INV_UE_ID;
500 timingInfo.subframe = (U8)((datReq->transId >> 8) & 0XFF);
501 timingInfo.sfn = (U16)((datReq->transId >> 16) & 0xFFFF);
502 sf = &cell->subFrms[(timingInfo.subframe % RG_NUM_SUB_FRAMES)];
504 if( (sf->txDone == TRUE) ||
505 (!RG_TIMEINFO_SAME(sf->schdTime,timingInfo)))
507 #if (ERRCLASS & ERRCLS_DEBUG)
508 /* Transmission is already done for this subframe. This is a delayed
509 * datReq. So discard */
510 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
511 rgLMMStaInd(inst,LCM_CATEGORY_PROTOCOL, LCM_EVENT_UI_INV_EVT,
512 LRG_CAUSE_DELAYED_DATREQ, &dgn);
514 err->errCause = RGERR_ROM_DELAYED_DATREQ;
518 hqPId = (U8)(datReq->transId);
521 /* get harq process and invoke DHM */
522 rgDHMGetHqProcFrmId(ue, hqPId, &hqProc);
524 /* Changed for CR timer implementation*/
525 /* invoke DHM to process CCCH data */
526 if (rgDHMHndlCmnDatReq(inst,hqProc, datReq, err) == RFAILED)
528 RLOG_ARG2(L_ERROR,DBG_CELLID,cell->cellId,
529 "Handling of Data request in DHM failed RNTI:%d LCID:%d",
530 datReq->u.rnti,datReq->lcId);
531 /* Release First TB */
532 rgDHMRlsHqProcTB(cell, hqProc, 1);
533 /* err shall be filled in appropriately by DHM */
538 } /* rgROMHndlCcchDatReq */
542 * @brief Handler for DatReq received on RGU for BCCH or PCCH.
546 * Function : rgROMHndlBcchPcchDatReq
548 * This function shall store the buffer and time to transmit in lcCb.
551 * @param[in] RgCellCb *cell
552 * @param[in] RgRguCmnDatReq *datReq
553 * @param[out] RgErrInfo *err
559 PRIVATE S16 rgROMHndlBcchPcchDatReq
562 RgRguCmnDatReq *datReq,
566 PRIVATE S16 rgROMHndlBcchPcchDatReq(cell, datReq, err)
568 RgRguCmnDatReq *datReq;
572 Inst inst = cell->macInst - RG_INST_START;
574 /* Modified for SI Enhancement*/
577 RgBcchDlschLcCb *bcch;
580 CmLteTimingInfo timingInfo;
581 #if (ERRCLASS & ERRCLS_DEBUG)
582 RgUstaDgn dgn; /* Alarm diagnostics structure */
585 TRC2(rgROMHndlBcchPcchDatReq);
588 timingInfo.subframe = (U8)(datReq->transId & 0XFF);
589 timingInfo.sfn = (U16)((datReq->transId >> 8) & 0xFFFF);
590 sf = &cell->subFrms[(timingInfo.subframe % RG_NUM_SUB_FRAMES)];
592 if( (sf->txDone == TRUE) ||
593 (!RG_TIMEINFO_SAME(sf->schdTime,timingInfo)))
595 #if (ERRCLASS & ERRCLS_DEBUG)
596 /* Transmission is already done for this subframe. This is a delayed
597 * datReq. So discard */
598 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
599 rgLMMStaInd(inst,LCM_CATEGORY_PROTOCOL, LCM_EVENT_UI_INV_EVT,
600 LRG_CAUSE_DELAYED_DATREQ, &dgn);
602 err->errCause = RGERR_ROM_DELAYED_DATREQ;
607 bcch = rgDBMGetBcchOnDlsch(cell,datReq->lcId);
610 /* Store BCCH-DLSCH data received in Scheduled subframe */
611 sf->bcch.tb = datReq->pdu;
613 SCpyMsgMsg(datReq->pdu, RG_GET_MEM_REGION(rgCb[inst]),
614 RG_GET_MEM_POOL(rgCb[inst]), &bcch->tb);
619 bch = rgDBMGetBcchOnBch(cell);
620 if ((bch) && (bch->lcId == datReq->lcId))
622 /* Store BCH data received in Scheduled subframe */
623 sf->bch.tb = datReq->pdu;
628 pcch = rgDBMGetPcch(cell);
629 if ((pcch) && (pcch->lcId == datReq->lcId))
631 /* Store PCCH-DLSCH data received in Scheduled subframe */
632 sf->pcch.tb = datReq->pdu;
636 /* Handle lcCb fetch failure */
637 RGLOGERROR(inst,ERRCLS_INT_PAR,ERG005,(ErrVal)datReq->lcId,
638 "rgROMHndlBcchPcchDatReq(): Invalid Lc Id");
639 err->errCause = RGERR_ROM_INV_LC_ID;
642 } /* rgROMHndlBcchPcchDatReq */
645 * @brief Handler for StaRsp received on RGU for a dedicated logical channel.
649 * Function : rgROMDedStaRsp
651 * This fucntion shall store the BO reported for the given logical
655 * @param[in] Inst inst
656 * @param[in] RgRguDedStaRsp *staRsp
662 PUBLIC S16 rgROMDedStaRsp
665 RgRguDedStaRsp *staRsp
668 PUBLIC S16 rgROMDedStaRsp(inst,staRsp)
670 RgRguDedStaRsp *staRsp;
675 /* Moving the error variables and assignments to available scope */
679 /* Avoiding memset, as the variables of this are getting
683 if(((cell = rgCb[inst].cell) != NULLP)
684 && (cell->cellId == staRsp->cellId))
688 boRpt.cellSapId = cell->schInstMap.cellSapId;
689 boRpt.cellId = staRsp->cellId;
690 boRpt.rnti = staRsp->rnti;
691 boRpt.lcId = staRsp->lcId;
692 boRpt.bo = staRsp->boReport.bo;
693 boRpt.oldestSduArrTime = staRsp->boReport.oldestSduArrTime;
694 boRpt.staPduBo = staRsp->boReport.staPduBo;
695 boRpt.oldestSduArrTime = staRsp->boReport.oldestSduArrTime;
696 rgGetPstToInst(&schPst,inst, cell->schInstMap.schInst);
698 //TODO: commented for compilation without SCH RgMacSchDedBoUpdt(&schPst, &boRpt);
701 RLOG_ARG2(L_ERROR,DBG_CELLID,staRsp->cellId,"Invalid cell for CRNTI:%d LCID:%d ",
702 staRsp->rnti,staRsp->lcId);
705 } /* rgROMDedStaRsp */
707 S16 RgMacSchBrdcmDedBoUpdtReq(
717 //if ((cell = rgDBMGetCellCb(cellId)) != NULLP)
718 if (((cell = rgCb[inst].cell) != NULLP) &&
719 (cell->cellId == cellId))
722 boRpt.cellSapId = cell->schInstMap.cellSapId;
723 boRpt.cellId = cellId;
727 rgGetPstToInst(&schPst,inst, cell->schInstMap.schInst);
729 //TODO: commented for compilation without SCH RgMacSchDedBoUpdtReq (&schPst,&boRpt);
734 * @brief Handler for StaRsp received on RGU for a common logical channel.
738 * Function : rgROMCmnStaRsp
740 * This fucntion shall invoke rgROMHndlCcchStaRsp() for status response on
741 * CCCH and shall invoke rgROMHndlBcchPcchStaRsp() for status response on
745 * @param[in] Inst inst
746 * @param[in] RgRguCmnStaRsp *staRsp
752 PUBLIC S16 rgROMCmnStaRsp
755 RgRguCmnStaRsp *staRsp
758 PUBLIC S16 rgROMCmnStaRsp(inst,staRsp)
760 RgRguCmnStaRsp *staRsp;
769 if(((cell = rgCb[inst].cell) == NULLP)
770 || (cell->cellId != staRsp->cellId))
772 /* Handle Cell fetch failure */
773 RLOG_ARG2(L_ERROR,DBG_CELLID,staRsp->cellId,
774 "Invalid cell for CRNTI:%d LCID:%d",staRsp->u.rnti,staRsp->lcId);
775 err.errType = RGERR_ROM_CMNSTARSP;
776 err.errCause = RGERR_ROM_INV_CELL_ID;
780 /* handle status response on CCCH */
781 if(staRsp->lcId == cell->dlCcchId)
783 rgROMHndlCcchStaRsp(cell, staRsp, &err);
787 rgROMHndlBcchPcchStaRsp(cell, staRsp, &err);
791 } /* rgROMCmnStaRsp */
796 * @brief Handler for Request received on RGU for a UL Throughput measurement
797 * enabled logical channel.
801 * Function :rgROML2MUlThrpMeasReq
803 * This function shall store the L2M UL Throughput Measurement status information
804 * for the given logical channel.
807 * @param[in] Inst inst
808 * @param[in] RgRguL2MUlThrpMeasReq *measReq
814 PUBLIC S16 rgROML2MUlThrpMeasReq
817 RgRguL2MUlThrpMeasReq *measReq
820 PUBLIC S16 rgROML2MUlThrpMeasReq(inst,measReq)
822 RgRguL2MUlThrpMeasReq *measReq;
829 TRC2(rgROML2MUlThrpMeasReq)
833 if(((cell = rgCb[inst].cell) != NULLP)
834 &&(cell->cellId == measReq->cellId))
836 if ((ue = rgDBMGetUeCb(cell, measReq->rnti)) != NULLP)
838 for(loop=0; loop<measReq->numLcId;loop++)
840 if ((rgDBMGetUlDedLcCb(ue, measReq->lcId[loop])) != NULLP)
842 ue->ul.lcCb[measReq->lcId[loop]].measOn = measReq->enbMeas;
843 if(ue->ul.lcCb[measReq->lcId[loop]].measOn == FALSE)
845 lcgId=ue->ul.lcCb[measReq->lcId[loop]].lcgId;
846 ue->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs = 0;
847 ue->ul.lcgArr[lcgId].lcgBsInfo.firstDatSegRcvd = FALSE;
854 RLOG_ARG1(L_ERROR,DBG_CELLID,measReq->cellId,"Invalid cell CRNTI:%d",
857 } /* rgROML2MUlThrpMeasReq */
862 * @brief Handler for StaRsp received on RGU for CCCH.
866 * Function : rgROMHndlCcchStaRsp
868 * This function shall fetch the raCb with the given RNTI and ask RAM to
872 * @param[in] RgCellCb *cell
873 * @param[in] RgRguCmnStaRsp *staRsp
874 * @param[out] RgErrInfo *err
880 PRIVATE S16 rgROMHndlCcchStaRsp
883 RgRguCmnStaRsp *staRsp,
887 PRIVATE S16 rgROMHndlCcchStaRsp(cell, staRsp, err)
889 RgRguCmnStaRsp *staRsp;
894 Inst macInst = cell->macInst - RG_INST_START;
897 TRC2(rgROMHndlCcchStaRsp);
900 boRpt.cellSapId = cell->schInstMap.cellSapId;
901 boRpt.cellId = staRsp->cellId;
902 boRpt.u.rnti = staRsp->u.rnti;
903 boRpt.lcId = staRsp->lcId;
904 boRpt.lcType = staRsp->lcType;
905 boRpt.bo = staRsp->bo;
906 rgGetPstToInst(&schPst,macInst, cell->schInstMap.schInst);
907 //TODO: commented for compilation without SCH RgMacSchCmnBoUpdt(&schPst, &boRpt);
910 } /* rgROMHndlCcchStaRsp */
914 * @brief Handler for StaRsp received on RGU for BCCH or PCCH.
918 * Function : rgROMHndlBcchPcchStaRsp
920 * This function shall store the buffer and time to transmit in lcCb.
923 * @param[in] RgCellCb *cell
924 * @param[in] RgRguCmnStaRsp *staRsp
925 * @param[out] RgErrInfo *err
931 PRIVATE S16 rgROMHndlBcchPcchStaRsp
934 RgRguCmnStaRsp *staRsp,
938 PRIVATE S16 rgROMHndlBcchPcchStaRsp(cell, staRsp, err)
940 RgRguCmnStaRsp *staRsp;
946 Inst macInst = cell->macInst - RG_INST_START;
948 TRC2(rgROMHndlBcchPcchStaRsp);
949 cmMemset((U8*)&schPst, (U8)0, sizeof(Pst));
951 if (rgDBMChkCmnLcCb(cell, staRsp->lcId) != ROK)
953 /* Handle lcCb fetch failure */
954 RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId,"Invalid LCID:%d",staRsp->lcId);
955 err->errCause = RGERR_ROM_INV_LC_ID;
958 /* MS_WORKAROUND : This is to ensure that the queue for BCH is not filled with old BO requests :
959 This assumes that BO is not received more than 4 frames in advance from the enodeb application */
960 if (cell->bcchBchInfo.lcId == staRsp->lcId)
964 nextBchSfn = (cell->crntTime.sfn + 4 - (cell->crntTime.sfn%4)) % RG_MAX_SFN;
965 if ((staRsp->u.timeToTx.sfn != nextBchSfn) ||
966 ((staRsp->u.timeToTx.sfn == cell->crntTime.sfn) && (cell->crntTime.subframe >= 7)))
972 boRpt.cellSapId = cell->schInstMap.cellSapId;
973 boRpt.cellId = staRsp->cellId;
974 boRpt.u.timeToTx = staRsp->u.timeToTx;
975 boRpt.lcId = staRsp->lcId;
976 boRpt.lcType = staRsp->lcType;
977 boRpt.bo = staRsp->bo;
981 if(boRpt.lcType == CM_LTE_LCH_PCCH)
983 boRpt.emtcDIReason = staRsp->emtcDiReason;
984 boRpt.pnb = staRsp->pnb;
988 rgGetPstToInst(&schPst,macInst, cell->schInstMap.schInst);
989 //TODO: commented for compilation without SCH RgMacSchCmnBoUpdt(&schPst, &boRpt);
992 } /* rgROMHndlBcchPcchStaRsp */
994 /* ADD Changes for Downlink UE Timing Optimization */
995 #ifdef LTEMAC_DLUE_TMGOPTMZ
997 * @brief Handler for updating DL SF information on receiving
998 * DL dedicated data, CCCH, BCCH/PCCH data request.
1002 * Function : rgROMUpdDLSfRemDataCnt
1005 * @param[in] RgCellCb *cell
1006 * @param[in] RgDlSf *dlSf;
1012 PRIVATE S16 rgROMUpdDlSfRemDataCnt
1018 PRIVATE S16 rgROMUpdDlSfRemDataCnt(cellCb, dlSf)
1024 //Inst inst = cellCb->macInst - RG_INST_START;
1026 TRC2(rgROMUpdDlSfRemDataCnt);
1029 if(!dlSf->remDatReqCnt)
1031 /*This is an error scenario of RLC generating more data
1032 * request than the allocation. Do nothing for this. */
1033 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
1034 "RX new data while remDatReqCnt is 0 for cell");
1038 /*Decrement the remaining data request to be received countter
1040 Check if this was the last pending data request for this DL SF.*/
1041 /* Fix[ccpu00126310]: Tracks Data Requests from RLC for both loosely and tight coupled
1043 if((0 == --dlSf->remDatReqCnt) && !(dlSf->txDone) &&
1044 (RG_TIMEINFO_SAME(cellCb->crntTime, dlSf->schdTime)) && (dlSf->statIndDone))
1046 /*Check if we have already received a TTI for this Data,
1047 if that is the case then we need to send TFU Data request
1050 if (ROK != rgTOMUtlProcDlSf (dlSf, cellCb, &err))
1052 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
1053 "Unable to process downlink subframe for cell");
1054 err.errType = RGERR_ROM_DEDDATREQ;
1057 /* Mark this frame as sent */
1058 dlSf->txDone = TRUE;
1062 } /* rgROMUpdDlSfRemDataCnt*/
1065 /**********************************************************************
1068 **********************************************************************/