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;
143 RgDlHqProcCb *hqProc;
148 CmLteTimingInfo timingInfo;
150 #if (ERRCLASS & ERRCLS_DEBUG)
151 RgUstaDgn dgn; /* Alarm diagnostics structure */
153 /* ADD Changes for Downlink UE Timing Optimization */
154 #ifdef LTEMAC_DLUE_TMGOPTMZ
158 //U8 datReqFailCnt = 0;
163 if (((cell = rgCb[inst].cell) == NULLP)
164 || (cell->cellId != datReq->cellId))
166 #if (ERRCLASS & ERRCLS_INT_PAR)
167 /* Handle Cell fetch failure */
168 RGLOGERROR(inst,ERRCLS_INT_PAR,ERG001,(ErrVal)datReq->cellId,
169 "rgROMDedDatReq(): Invalid cell Id");
171 err.errType = RGERR_ROM_DEDDATREQ;
172 err.errCause = RGERR_ROM_INV_CELL_ID;
176 rgUpdtRguDedSts(inst,cell->rguDlSap,RG_RGU_SDU_DROP, datReq);
181 /* Add loop here to scan for all UEs in the consolidated DDatReq*/
182 for(idx = 0; idx < datReq->nmbOfUeGrantPerTti; idx++)
185 timingInfo.subframe = (U8)((datReq->datReq[idx].transId >> 8) & 0XFF);
186 timingInfo.sfn = (U16)((datReq->datReq[idx].transId >> 16) & 0xFFFF);
187 sf = &cell->subFrms[(timingInfo.subframe % RG_NUM_SUB_FRAMES)];
189 if( (sf->txDone == TRUE) ||
190 (!RG_TIMEINFO_SAME(sf->schdTime,timingInfo)))
192 #if (ERRCLASS & ERRCLS_DEBUG)
193 /* Transmission is already done for this subframe. This is a delayed
194 * datReq. So discard */
195 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
196 rgLMMStaInd(inst,LCM_CATEGORY_PROTOCOL, LCM_EVENT_UI_INV_EVT,
197 LRG_CAUSE_DELAYED_DATREQ, &dgn);
199 err.errType = RGERR_ROM_DEDDATREQ;
200 err.errCause = RGERR_ROM_DELAYED_DATREQ;
202 rgUpdtRguDedSts(inst,cell->rguDlSap,RG_RGU_SDU_DROP, datReq);
205 EXTERN U32 dbgDelayedDatReqInMac;
206 dbgDelayedDatReqInMac++;
210 RG_DROP_RGUDDATREQ_MBUF(datReq->datReq[idx]);
213 // RETVALUE(RFAILED);
216 if ((ue = rgDBMGetUeCb(cell, datReq->datReq[idx].rnti)) == NULLP)
218 #if (ERRCLASS & ERRCLS_INT_PAR)
219 /* Handle Ue fetch failure */
220 RGLOGERROR(inst,ERRCLS_INT_PAR,ERG002,(ErrVal)datReq->datReq[idx].rnti,
221 "rgROMDedDatReq(): Invalid ue Id");
223 err.errType = RGERR_ROM_DEDDATREQ;
224 err.errCause = RGERR_ROM_INV_UE_ID;
226 rgUpdtRguDedSts(inst,cell->rguDlSap,RG_RGU_SDU_DROP, datReq);
227 /* ADD Changes for Downlink UE Timing Optimization */
228 #ifdef LTEMAC_DLUE_TMGOPTMZ
229 /* Trying to send the prev successful PDU's
231 ret = rgROMUpdDlSfRemDataCnt(cell, sf);
234 RLOG0(L_INFO, "Dropping due to no ue \n");
236 RG_DROP_RGUDDATREQ_MBUF(datReq->datReq[idx]);
238 /* Return from here as above functions found more datReq than expected*/
242 /* Conitnue for next UE */
246 hqPId = (U8)(datReq->datReq[idx].transId);
248 /* get harq process and invoke DHM */
249 rgDHMGetHqProcFrmId(ue, hqPId, &hqProc);
251 if (rgDHMHndlDedDatReq(inst,hqProc, &datReq->datReq[idx], sf, &err) == RFAILED)
253 RLOG_ARG1(L_ERROR,DBG_CELLID,datReq->cellId,
254 "Handling of Data request in DHM failedi RNTI:%d",
255 datReq->datReq[idx].rnti);
256 err.errType = RGERR_ROM_DEDDATREQ;
257 /* errcause shall be filled in appropriately by DHM */
259 rgUpdtRguDedSts(inst,ue->rguDlSap,RG_RGU_SDU_DROP, datReq);
260 /* ADD Changes for Downlink UE Timing Optimization */
261 #ifdef LTEMAC_DLUE_TMGOPTMZ
262 /* Trying to send the prev successful PDU's
264 ret = rgROMUpdDlSfRemDataCnt(cell, sf);
267 RLOG0(L_INFO, "Dropping due to no failure of remCnt update");
269 RG_DROP_RGUDDATREQ_MBUF(datReq->datReq[idx]);
271 /* Return from here as above functions found more datReq than expected*/
278 /* Merging the updation of statistics of SDUs with for loop below */
280 rgGetPstToInst(&schPst,inst, cell->schInstMap.schInst);
282 boRpt.cellSapId = cell->schInstMap.cellSapId;
283 boRpt.cellId = datReq->cellId;
285 boRpt.rnti = datReq->datReq[idx].rnti;
288 /* Fill the DStaRsp struct and send it to scheduler */
289 for (idx1 = 0; idx1 < datReq->datReq[idx].nmbOfTbs; idx1++)
291 for(idx2 = 0; idx2 < datReq->datReq[idx].datReqTb[idx1].nmbLch; idx2++)
293 /* Updating dedicated SDUs received statistics without
294 additional function above for optimization */
295 ue->rguDlSap->sapSts.numPduRcvd +=
296 datReq->datReq[idx].datReqTb[idx1].lchData[idx2].pdu.numPdu;
298 boRpt.lcId = datReq->datReq[idx].datReqTb[idx1].lchData[idx2].lcId;
299 boRpt.bo = datReq->datReq[idx].datReqTb[idx1].lchData[idx2].boReport.bo;
300 boRpt.oldestSduArrTime
301 = datReq->datReq[idx].datReqTb[idx1].lchData[idx2].boReport.oldestSduArrTime;
302 boRpt.staPduBo = datReq->datReq[idx].datReqTb[idx1].lchData[idx2].boReport.staPduBo;
304 boRpt.setMaxUlPrio= datReq->datReq[idx].datReqTb[idx1].lchData[idx2].setMaxUlPrio;
306 boRpt.setMaxDlPrio= datReq->datReq[idx].datReqTb[idx1].lchData[idx2].boReport.staPduPrsnt;
308 RgMacSchDedBoUpdt(&schPst, &boRpt);
312 /* ADD Changes for Downlink UE Timing Optimization */
313 #ifdef LTEMAC_DLUE_TMGOPTMZ
314 // sf->remDatReqCnt -= datReqFailCnt;
315 /*Presently this function is not returning RFAILED, thus not checking
316 for failure condition.*/
317 ret = rgROMUpdDlSfRemDataCnt(cell, sf);
320 RLOG0(L_INFO, "\n Dropping due to no failure of remCnt update(1) \n");
322 RG_DROP_RGUDDATREQ_MBUF(datReq->datReq[idx]);
324 /* Return from here as above functions found more datReq than expected*/
328 } /* for loop for num of Ue per TTI*/
331 /* Data send successfully to PHY. lets retuns ROK*/
333 } /* rgROMDedDatReq */
337 * @brief Handler for DatReq received on RGU for a common logical channel.
341 * Function : rgROMCmnDatReq
343 * This function shall invoke rgROMHndlCcchDatReq() if datReq is on CCCH
344 * If not, it shall invoke rgROMHndlBcchPcchDatReq().
347 * @param[in] Inst inst
348 * @param[in] RgRguCmnDatReq *datReq
354 PUBLIC S16 rgROMCmnDatReq
357 RgRguCmnDatReq *datReq
360 PUBLIC S16 rgROMCmnDatReq(inst,datReq)
362 RgRguCmnDatReq *datReq;
368 /* ADD Changes for Downlink UE Timing Optimization */
369 #ifdef LTEMAC_DLUE_TMGOPTMZ
370 CmLteTimingInfo timingInfo;
377 err.errType = RGERR_ROM_CMNDATREQ;
378 if(((cell = rgCb[inst].cell) == NULLP)
379 ||(cell->cellId != datReq->cellId))
381 #if (ERRCLASS & ERRCLS_INT_PAR)
382 /* Handle Cell fetch failure */
383 RGLOGERROR(inst,ERRCLS_INT_PAR,ERG003,(ErrVal)datReq->cellId,
384 "rgROMCmnDatReq(): Invalid cell Id");
386 err.errCause = RGERR_ROM_INV_CELL_ID;
390 rgUpdtRguCmnSts(inst,cell->rguDlSap,RG_RGU_SDU_DROP);
395 if (datReq->lcId == cell->dlCcchId)
397 ret = rgROMHndlCcchDatReq(cell, datReq, &err);
399 /*Get the timing Info*/
400 /* ADD Changes for Downlink UE Timing Optimization */
401 #ifdef LTEMAC_DLUE_TMGOPTMZ
402 timingInfo.subframe = (U8)((datReq->transId >> 8) & 0XFF);
403 timingInfo.sfn = (U16)((datReq->transId >> 16) & 0xFFFF);
408 ret = rgROMHndlBcchPcchDatReq(cell, datReq, &err);
410 /*Get the timing Info*/
411 /* ADD Changes for Downlink UE Timing Optimization */
412 #ifdef LTEMAC_DLUE_TMGOPTMZ
413 timingInfo.subframe = (U8)(datReq->transId & 0XFF);
414 timingInfo.sfn = (U16)((datReq->transId >> 8) & 0xFFFF);
421 rgUpdtRguCmnSts(inst,cell->rguDlSap,RG_RGU_SDU_DROP);
425 /* Update stats with number of SDUs received */
426 rgUpdtRguCmnSts(inst,cell->rguDlSap,RG_RGU_SDU_RCVD);
429 /* ADD Changes for Downlink UE Timing Optimization */
430 #ifdef LTEMAC_DLUE_TMGOPTMZ
431 RG_ARRAY_BOUND_CHECK(0, cell->subFrms, (timingInfo.subframe % RG_NUM_SUB_FRAMES));
432 sf = &cell->subFrms[(timingInfo.subframe % RG_NUM_SUB_FRAMES)];
434 ret = rgROMUpdDlSfRemDataCnt(cell, sf);
435 /*Added check for RFAILED as above function can return RFAILED*/
439 } /* rgROMCmnDatReq */
442 * @brief Handler for DatReq received on RGU for CCCH.
446 * Function : rgROMHndlCcchDatReq
448 * This function shall fetch the raCb with the given rnti and indicate msg4
452 * @param[in] RgCellCb *cell
453 * @param[in] RgRguCmnDatReq *datReq
454 * @param[out] RgErrInfo *err
460 PRIVATE S16 rgROMHndlCcchDatReq
463 RgRguCmnDatReq *datReq,
467 PRIVATE S16 rgROMHndlCcchDatReq(cell, datReq, err)
469 RgRguCmnDatReq *datReq;
473 Inst inst = cell->macInst - RG_INST_START;
476 RgDlHqProcCb *hqProc;
477 CmLteTimingInfo timingInfo;
479 #if (ERRCLASS & ERRCLS_DEBUG)
480 RgUstaDgn dgn; /* Alarm diagnostics structure */
483 TRC2(rgROMHndlCcchDatReq);
486 err->errType = RGERR_ROM_CMNDATREQ;
488 if ((ue = rgDBMGetUeCb(cell, datReq->u.rnti)) == NULLP)
490 if ((ue = rgDBMGetUeCbFromRachLst(cell, datReq->u.rnti)) == NULLP)
492 #if (ERRCLASS & ERRCLS_INT_PAR)
493 /* Handle Ue fetch failure */
494 RGLOGERROR(inst,ERRCLS_INT_PAR,ERG004,(ErrVal)datReq->u.rnti,
495 "rgROMHndlCcchDatReq(): Invalid ue Id");
497 err->errCause = RGERR_ROM_INV_UE_ID;
502 timingInfo.subframe = (U8)((datReq->transId >> 8) & 0XFF);
503 timingInfo.sfn = (U16)((datReq->transId >> 16) & 0xFFFF);
504 sf = &cell->subFrms[(timingInfo.subframe % RG_NUM_SUB_FRAMES)];
506 if( (sf->txDone == TRUE) ||
507 (!RG_TIMEINFO_SAME(sf->schdTime,timingInfo)))
509 #if (ERRCLASS & ERRCLS_DEBUG)
510 /* Transmission is already done for this subframe. This is a delayed
511 * datReq. So discard */
512 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
513 rgLMMStaInd(inst,LCM_CATEGORY_PROTOCOL, LCM_EVENT_UI_INV_EVT,
514 LRG_CAUSE_DELAYED_DATREQ, &dgn);
516 err->errCause = RGERR_ROM_DELAYED_DATREQ;
520 hqPId = (U8)(datReq->transId);
523 /* get harq process and invoke DHM */
524 rgDHMGetHqProcFrmId(ue, hqPId, &hqProc);
526 /* Changed for CR timer implementation*/
527 /* invoke DHM to process CCCH data */
528 if (rgDHMHndlCmnDatReq(inst,hqProc, datReq, err) == RFAILED)
530 RLOG_ARG2(L_ERROR,DBG_CELLID,cell->cellId,
531 "Handling of Data request in DHM failed RNTI:%d LCID:%d",
532 datReq->u.rnti,datReq->lcId);
533 /* Release First TB */
534 rgDHMRlsHqProcTB(cell, hqProc, 1);
535 /* err shall be filled in appropriately by DHM */
540 } /* rgROMHndlCcchDatReq */
544 * @brief Handler for DatReq received on RGU for BCCH or PCCH.
548 * Function : rgROMHndlBcchPcchDatReq
550 * This function shall store the buffer and time to transmit in lcCb.
553 * @param[in] RgCellCb *cell
554 * @param[in] RgRguCmnDatReq *datReq
555 * @param[out] RgErrInfo *err
561 PRIVATE S16 rgROMHndlBcchPcchDatReq
564 RgRguCmnDatReq *datReq,
568 PRIVATE S16 rgROMHndlBcchPcchDatReq(cell, datReq, err)
570 RgRguCmnDatReq *datReq;
574 Inst inst = cell->macInst - RG_INST_START;
576 /* Modified for SI Enhancement*/
579 RgBcchDlschLcCb *bcch;
582 CmLteTimingInfo timingInfo;
583 #if (ERRCLASS & ERRCLS_DEBUG)
584 RgUstaDgn dgn; /* Alarm diagnostics structure */
587 TRC2(rgROMHndlBcchPcchDatReq);
590 timingInfo.subframe = (U8)(datReq->transId & 0XFF);
591 timingInfo.sfn = (U16)((datReq->transId >> 8) & 0xFFFF);
592 sf = &cell->subFrms[(timingInfo.subframe % RG_NUM_SUB_FRAMES)];
594 if( (sf->txDone == TRUE) ||
595 (!RG_TIMEINFO_SAME(sf->schdTime,timingInfo)))
597 #if (ERRCLASS & ERRCLS_DEBUG)
598 /* Transmission is already done for this subframe. This is a delayed
599 * datReq. So discard */
600 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
601 rgLMMStaInd(inst,LCM_CATEGORY_PROTOCOL, LCM_EVENT_UI_INV_EVT,
602 LRG_CAUSE_DELAYED_DATREQ, &dgn);
604 err->errCause = RGERR_ROM_DELAYED_DATREQ;
609 bcch = rgDBMGetBcchOnDlsch(cell,datReq->lcId);
612 /* Store BCCH-DLSCH data received in Scheduled subframe */
613 sf->bcch.tb = datReq->pdu;
615 SCpyMsgMsg(datReq->pdu, RG_GET_MEM_REGION(rgCb[inst]),
616 RG_GET_MEM_POOL(rgCb[inst]), &bcch->tb);
621 bch = rgDBMGetBcchOnBch(cell);
622 if ((bch) && (bch->lcId == datReq->lcId))
624 /* Store BCH data received in Scheduled subframe */
625 sf->bch.tb = datReq->pdu;
630 pcch = rgDBMGetPcch(cell);
631 if ((pcch) && (pcch->lcId == datReq->lcId))
633 /* Store PCCH-DLSCH data received in Scheduled subframe */
634 sf->pcch.tb = datReq->pdu;
638 /* Handle lcCb fetch failure */
639 RGLOGERROR(inst,ERRCLS_INT_PAR,ERG005,(ErrVal)datReq->lcId,
640 "rgROMHndlBcchPcchDatReq(): Invalid Lc Id");
641 err->errCause = RGERR_ROM_INV_LC_ID;
644 } /* rgROMHndlBcchPcchDatReq */
647 * @brief Handler for StaRsp received on RGU for a dedicated logical channel.
651 * Function : rgROMDedStaRsp
653 * This fucntion shall store the BO reported for the given logical
657 * @param[in] Inst inst
658 * @param[in] RgRguDedStaRsp *staRsp
664 PUBLIC S16 rgROMDedStaRsp
667 RgRguDedStaRsp *staRsp
670 PUBLIC S16 rgROMDedStaRsp(inst,staRsp)
672 RgRguDedStaRsp *staRsp;
677 /* Moving the error variables and assignments to available scope */
681 /* Avoiding memset, as the variables of this are getting
685 if(((cell = rgCb[inst].cell) != NULLP)
686 && (cell->cellId == staRsp->cellId))
690 boRpt.cellSapId = cell->schInstMap.cellSapId;
691 boRpt.cellId = staRsp->cellId;
692 boRpt.rnti = staRsp->rnti;
693 boRpt.lcId = staRsp->lcId;
694 boRpt.bo = staRsp->boReport.bo;
695 boRpt.oldestSduArrTime = staRsp->boReport.oldestSduArrTime;
696 boRpt.staPduBo = staRsp->boReport.staPduBo;
697 boRpt.oldestSduArrTime = staRsp->boReport.oldestSduArrTime;
698 rgGetPstToInst(&schPst,inst, cell->schInstMap.schInst);
700 //TODO: commented for compilation without SCH RgMacSchDedBoUpdt(&schPst, &boRpt);
703 RLOG_ARG2(L_ERROR,DBG_CELLID,staRsp->cellId,"Invalid cell for CRNTI:%d LCID:%d ",
704 staRsp->rnti,staRsp->lcId);
707 } /* rgROMDedStaRsp */
709 S16 RgMacSchBrdcmDedBoUpdtReq(
719 //if ((cell = rgDBMGetCellCb(cellId)) != NULLP)
720 if (((cell = rgCb[inst].cell) != NULLP) &&
721 (cell->cellId == cellId))
724 boRpt.cellSapId = cell->schInstMap.cellSapId;
725 boRpt.cellId = cellId;
729 rgGetPstToInst(&schPst,inst, cell->schInstMap.schInst);
731 //TODO: commented for compilation without SCH RgMacSchDedBoUpdtReq (&schPst,&boRpt);
736 * @brief Handler for StaRsp received on RGU for a common logical channel.
740 * Function : rgROMCmnStaRsp
742 * This fucntion shall invoke rgROMHndlCcchStaRsp() for status response on
743 * CCCH and shall invoke rgROMHndlBcchPcchStaRsp() for status response on
747 * @param[in] Inst inst
748 * @param[in] RgRguCmnStaRsp *staRsp
754 PUBLIC S16 rgROMCmnStaRsp
757 RgRguCmnStaRsp *staRsp
760 PUBLIC S16 rgROMCmnStaRsp(inst,staRsp)
762 RgRguCmnStaRsp *staRsp;
771 if(((cell = rgCb[inst].cell) == NULLP)
772 || (cell->cellId != staRsp->cellId))
774 /* Handle Cell fetch failure */
775 RLOG_ARG2(L_ERROR,DBG_CELLID,staRsp->cellId,
776 "Invalid cell for CRNTI:%d LCID:%d",staRsp->u.rnti,staRsp->lcId);
777 err.errType = RGERR_ROM_CMNSTARSP;
778 err.errCause = RGERR_ROM_INV_CELL_ID;
782 /* handle status response on CCCH */
783 if(staRsp->lcId == cell->dlCcchId)
785 rgROMHndlCcchStaRsp(cell, staRsp, &err);
789 rgROMHndlBcchPcchStaRsp(cell, staRsp, &err);
793 } /* rgROMCmnStaRsp */
798 * @brief Handler for Request received on RGU for a UL Throughput measurement
799 * enabled logical channel.
803 * Function :rgROML2MUlThrpMeasReq
805 * This function shall store the L2M UL Throughput Measurement status information
806 * for the given logical channel.
809 * @param[in] Inst inst
810 * @param[in] RgRguL2MUlThrpMeasReq *measReq
816 PUBLIC S16 rgROML2MUlThrpMeasReq
819 RgRguL2MUlThrpMeasReq *measReq
822 PUBLIC S16 rgROML2MUlThrpMeasReq(inst,measReq)
824 RgRguL2MUlThrpMeasReq *measReq;
831 TRC2(rgROML2MUlThrpMeasReq)
835 if(((cell = rgCb[inst].cell) != NULLP)
836 &&(cell->cellId == measReq->cellId))
838 if ((ue = rgDBMGetUeCb(cell, measReq->rnti)) != NULLP)
840 for(loop=0; loop<measReq->numLcId;loop++)
842 if ((rgDBMGetUlDedLcCb(ue, measReq->lcId[loop])) != NULLP)
844 ue->ul.lcCb[measReq->lcId[loop]].measOn = measReq->enbMeas;
845 if(ue->ul.lcCb[measReq->lcId[loop]].measOn == FALSE)
847 lcgId=ue->ul.lcCb[measReq->lcId[loop]].lcgId;
848 ue->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs = 0;
849 ue->ul.lcgArr[lcgId].lcgBsInfo.firstDatSegRcvd = FALSE;
856 RLOG_ARG1(L_ERROR,DBG_CELLID,measReq->cellId,"Invalid cell CRNTI:%d",
859 } /* rgROML2MUlThrpMeasReq */
864 * @brief Handler for StaRsp received on RGU for CCCH.
868 * Function : rgROMHndlCcchStaRsp
870 * This function shall fetch the raCb with the given RNTI and ask RAM to
874 * @param[in] RgCellCb *cell
875 * @param[in] RgRguCmnStaRsp *staRsp
876 * @param[out] RgErrInfo *err
882 PRIVATE S16 rgROMHndlCcchStaRsp
885 RgRguCmnStaRsp *staRsp,
889 PRIVATE S16 rgROMHndlCcchStaRsp(cell, staRsp, err)
891 RgRguCmnStaRsp *staRsp;
896 Inst macInst = cell->macInst - RG_INST_START;
899 TRC2(rgROMHndlCcchStaRsp);
902 boRpt.cellSapId = cell->schInstMap.cellSapId;
903 boRpt.cellId = staRsp->cellId;
904 boRpt.u.rnti = staRsp->u.rnti;
905 boRpt.lcId = staRsp->lcId;
906 boRpt.lcType = staRsp->lcType;
907 boRpt.bo = staRsp->bo;
908 rgGetPstToInst(&schPst,macInst, cell->schInstMap.schInst);
909 //TODO: commented for compilation without SCH RgMacSchCmnBoUpdt(&schPst, &boRpt);
912 } /* rgROMHndlCcchStaRsp */
916 * @brief Handler for StaRsp received on RGU for BCCH or PCCH.
920 * Function : rgROMHndlBcchPcchStaRsp
922 * This function shall store the buffer and time to transmit in lcCb.
925 * @param[in] RgCellCb *cell
926 * @param[in] RgRguCmnStaRsp *staRsp
927 * @param[out] RgErrInfo *err
933 PRIVATE S16 rgROMHndlBcchPcchStaRsp
936 RgRguCmnStaRsp *staRsp,
940 PRIVATE S16 rgROMHndlBcchPcchStaRsp(cell, staRsp, err)
942 RgRguCmnStaRsp *staRsp;
948 Inst macInst = cell->macInst - RG_INST_START;
950 TRC2(rgROMHndlBcchPcchStaRsp);
951 cmMemset((U8*)&schPst, (U8)0, sizeof(Pst));
953 if (rgDBMChkCmnLcCb(cell, staRsp->lcId) != ROK)
955 /* Handle lcCb fetch failure */
956 RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId,"Invalid LCID:%d",staRsp->lcId);
957 err->errCause = RGERR_ROM_INV_LC_ID;
960 /* MS_WORKAROUND : This is to ensure that the queue for BCH is not filled with old BO requests :
961 This assumes that BO is not received more than 4 frames in advance from the enodeb application */
962 if (cell->bcchBchInfo.lcId == staRsp->lcId)
966 nextBchSfn = (cell->crntTime.sfn + 4 - (cell->crntTime.sfn%4)) % RG_MAX_SFN;
967 if ((staRsp->u.timeToTx.sfn != nextBchSfn) ||
968 ((staRsp->u.timeToTx.sfn == cell->crntTime.sfn) && (cell->crntTime.subframe >= 7)))
974 boRpt.cellSapId = cell->schInstMap.cellSapId;
975 boRpt.cellId = staRsp->cellId;
976 boRpt.u.timeToTx = staRsp->u.timeToTx;
977 boRpt.lcId = staRsp->lcId;
978 boRpt.lcType = staRsp->lcType;
979 boRpt.bo = staRsp->bo;
983 if(boRpt.lcType == CM_LTE_LCH_PCCH)
985 boRpt.emtcDIReason = staRsp->emtcDiReason;
986 boRpt.pnb = staRsp->pnb;
990 rgGetPstToInst(&schPst,macInst, cell->schInstMap.schInst);
991 //TODO: commented for compilation without SCH RgMacSchCmnBoUpdt(&schPst, &boRpt);
994 } /* rgROMHndlBcchPcchStaRsp */
996 /* ADD Changes for Downlink UE Timing Optimization */
997 #ifdef LTEMAC_DLUE_TMGOPTMZ
999 * @brief Handler for updating DL SF information on receiving
1000 * DL dedicated data, CCCH, BCCH/PCCH data request.
1004 * Function : rgROMUpdDLSfRemDataCnt
1007 * @param[in] RgCellCb *cell
1008 * @param[in] RgDlSf *dlSf;
1014 PRIVATE S16 rgROMUpdDlSfRemDataCnt
1020 PRIVATE S16 rgROMUpdDlSfRemDataCnt(cellCb, dlSf)
1026 //Inst inst = cellCb->macInst - RG_INST_START;
1028 TRC2(rgROMUpdDlSfRemDataCnt);
1031 if(!dlSf->remDatReqCnt)
1033 /*This is an error scenario of RLC generating more data
1034 * request than the allocation. Do nothing for this. */
1035 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
1036 "RX new data while remDatReqCnt is 0 for cell");
1040 /*Decrement the remaining data request to be received countter
1042 Check if this was the last pending data request for this DL SF.*/
1043 /* Fix[ccpu00126310]: Tracks Data Requests from RLC for both loosely and tight coupled
1045 if((0 == --dlSf->remDatReqCnt) && !(dlSf->txDone) &&
1046 (RG_TIMEINFO_SAME(cellCb->crntTime, dlSf->schdTime)) && (dlSf->statIndDone))
1048 /*Check if we have already received a TTI for this Data,
1049 if that is the case then we need to send TFU Data request
1052 if (ROK != rgTOMUtlProcDlSf (dlSf, cellCb, &err))
1054 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
1055 "Unable to process downlink subframe for cell");
1056 err.errType = RGERR_ROM_DEDDATREQ;
1059 /* Mark this frame as sent */
1060 dlSf->txDone = TRUE;
1064 } /* rgROMUpdDlSfRemDataCnt*/
1067 /**********************************************************************
1070 **********************************************************************/