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 "common_def.h"
41 #include "rg_env.h" /* MAC Environment Defines */
42 #include "crg.h" /* CRG Interface defines */
43 #include "rgu.h" /* RGU Interface defines */
44 #include "tfu.h" /* TFU Interface defines */
45 #include "rg_sch_inf.h" /* RGR Interface defines */
46 #include "lrg.h" /* LRG Interface defines */
48 #include "rg.h" /* MAC defines */
49 #include "rg_err.h" /* MAC error defines */
51 /* header/extern include files (.x) */
53 #include "crg.x" /* CRG Interface includes */
54 #include "rgu.x" /* RGU Interface includes */
55 #include "tfu.x" /* TFU Interface includes */
56 #include "rg_sch_inf.x" /* SCH Interface includes */
57 #include "rg_prg.x" /* PRG Interface includes */
58 #include "lrg.x" /* LRG Interface includes */
60 #include "du_app_mac_inf.h"
61 #include "rg.x" /* MAC includes */
64 #define RG_NON_MIMO_IDX 0
68 S16 RgMacSchBrdcmDedBoUpdtReq ARGS((Inst inst, CmLteCellId cellId, CmLteRnti rnti, CmLteLcId lcId, S32 bo ));
69 static S16 rgROMHndlCcchDatReq ARGS((RgCellCb *cell,
70 RgRguCmnDatReq *datReq, RgErrInfo *err));
71 static S16 rgROMHndlBcchPcchDatReq ARGS((RgCellCb *cell,
72 RgRguCmnDatReq *datReq, RgErrInfo *err));
73 static S16 rgROMHndlCcchStaRsp ARGS((RgCellCb *cell,
74 RgRguCmnStaRsp *staRsp, RgErrInfo *err));
75 static S16 rgROMHndlBcchPcchStaRsp ARGS((RgCellCb *cell,
76 RgRguCmnStaRsp *staRsp, RgErrInfo *err));
78 /* ADD Changes for Downlink UE Timing Optimization */
79 #ifdef LTEMAC_DLUE_TMGOPTMZ
80 static S16 rgROMUpdDlSfRemDataCnt ARGS((RgCellCb *cellCb,
82 S16 rgTOMUtlProcDlSf ARGS(( RgDlSf *dlSf,
87 /* forward references */
90 * @brief Handler for dedicated DatReq received on RGU for an UE.
94 * Function : rgROMDedDatReq
97 * -# store the BO reported for the given logical channels.
98 * -# invoke DL HARQ for further processing.
101 * @param[in] Inst inst
102 * @param[in] RgRguDedDatReq *datReq
107 S16 rgROMDedDatReq(Inst inst,RgRguDedDatReq *datReq)
113 RgDlHqProcCb *hqProc;
118 CmLteTimingInfo timingInfo;
120 #if (ERRCLASS & ERRCLS_DEBUG)
121 RgUstaDgn dgn; /* Alarm diagnostics structure */
123 /* ADD Changes for Downlink UE Timing Optimization */
124 #ifdef LTEMAC_DLUE_TMGOPTMZ
128 //uint8_t datReqFailCnt = 0;
131 if (((cell = rgCb[inst].cell) == NULLP)
132 || (cell->cellId != datReq->cellId))
134 #if (ERRCLASS & ERRCLS_INT_PAR)
135 /* Handle Cell fetch failure */
136 RGLOGERROR(inst,ERRCLS_INT_PAR,ERG001,(ErrVal)datReq->cellId,
137 "rgROMDedDatReq(): Invalid cell Id");
139 err.errType = RGERR_ROM_DEDDATREQ;
140 err.errCause = RGERR_ROM_INV_CELL_ID;
144 rgUpdtRguDedSts(inst,cell->rguDlSap,RG_RGU_SDU_DROP, datReq);
149 /* Add loop here to scan for all UEs in the consolidated DDatReq*/
150 for(idx = 0; idx < datReq->nmbOfUeGrantPerTti; idx++)
153 timingInfo.slot = (uint8_t)((datReq->datReq[idx].transId >> 8) & 0XFF);
154 timingInfo.sfn = (uint16_t)((datReq->datReq[idx].transId >> 16) & 0xFFFF);
155 sf = &cell->subFrms[(timingInfo.slot % RG_NUM_SUB_FRAMES)];
157 if( (sf->txDone == TRUE) ||
158 (!RG_TIMEINFO_SAME(sf->schdTime,timingInfo)))
160 #if (ERRCLASS & ERRCLS_DEBUG)
161 /* Transmission is already done for this slot. This is a delayed
162 * datReq. So discard */
163 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
164 rgLMMStaInd(inst,LCM_CATEGORY_PROTOCOL, LCM_EVENT_UI_INV_EVT,
165 LRG_CAUSE_DELAYED_DATREQ, &dgn);
167 err.errType = RGERR_ROM_DEDDATREQ;
168 err.errCause = RGERR_ROM_DELAYED_DATREQ;
170 rgUpdtRguDedSts(inst,cell->rguDlSap,RG_RGU_SDU_DROP, datReq);
173 uint32_t dbgDelayedDatReqInMac;
174 dbgDelayedDatReqInMac++;
178 RG_DROP_RGUDDATREQ_MBUF(datReq->datReq[idx]);
184 if ((ue = rgDBMGetUeCb(cell, datReq->datReq[idx].rnti)) == NULLP)
186 #if (ERRCLASS & ERRCLS_INT_PAR)
187 /* Handle Ue fetch failure */
188 RGLOGERROR(inst,ERRCLS_INT_PAR,ERG002,(ErrVal)datReq->datReq[idx].rnti,
189 "rgROMDedDatReq(): Invalid ue Id");
191 err.errType = RGERR_ROM_DEDDATREQ;
192 err.errCause = RGERR_ROM_INV_UE_ID;
194 rgUpdtRguDedSts(inst,cell->rguDlSap,RG_RGU_SDU_DROP, datReq);
195 /* ADD Changes for Downlink UE Timing Optimization */
196 #ifdef LTEMAC_DLUE_TMGOPTMZ
197 /* Trying to send the prev successful PDU's
199 ret = rgROMUpdDlSfRemDataCnt(cell, sf);
202 RLOG0(L_INFO, "Dropping due to no ue \n");
204 RG_DROP_RGUDDATREQ_MBUF(datReq->datReq[idx]);
206 /* Return from here as above functions found more datReq than expected*/
210 /* Conitnue for next UE */
214 hqPId = (uint8_t)(datReq->datReq[idx].transId);
216 /* get harq process and invoke DHM */
217 rgDHMGetHqProcFrmId(ue, hqPId, &hqProc);
219 if (rgDHMHndlDedDatReq(inst,hqProc, &datReq->datReq[idx], sf, &err) == RFAILED)
221 RLOG_ARG1(L_ERROR,DBG_CELLID,datReq->cellId,
222 "Handling of Data request in DHM failedi RNTI:%d",
223 datReq->datReq[idx].rnti);
224 err.errType = RGERR_ROM_DEDDATREQ;
225 /* errcause shall be filled in appropriately by DHM */
227 rgUpdtRguDedSts(inst,ue->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 failure of remCnt update");
237 RG_DROP_RGUDDATREQ_MBUF(datReq->datReq[idx]);
239 /* Return from here as above functions found more datReq than expected*/
246 /* Merging the updation of statistics of SDUs with for loop below */
248 rgGetPstToInst(&schPst,inst, cell->schInstMap.schInst);
250 boRpt.cellSapId = cell->schInstMap.cellSapId;
251 boRpt.cellId = datReq->cellId;
253 boRpt.rnti = datReq->datReq[idx].rnti;
256 /* Fill the DStaRsp struct and send it to scheduler */
257 for (idx1 = 0; idx1 < datReq->datReq[idx].nmbOfTbs; idx1++)
259 for(idx2 = 0; idx2 < datReq->datReq[idx].datReqTb[idx1].nmbLch; idx2++)
261 /* Updating dedicated SDUs received statistics without
262 additional function above for optimization */
263 ue->rguDlSap->sapSts.numPduRcvd +=
264 datReq->datReq[idx].datReqTb[idx1].lchData[idx2].pdu.numPdu;
266 boRpt.lcId = datReq->datReq[idx].datReqTb[idx1].lchData[idx2].lcId;
267 boRpt.bo = datReq->datReq[idx].datReqTb[idx1].lchData[idx2].boReport.bo;
268 boRpt.oldestSduArrTime
269 = datReq->datReq[idx].datReqTb[idx1].lchData[idx2].boReport.oldestSduArrTime;
270 boRpt.staPduBo = datReq->datReq[idx].datReqTb[idx1].lchData[idx2].boReport.staPduBo;
272 boRpt.setMaxUlPrio= datReq->datReq[idx].datReqTb[idx1].lchData[idx2].setMaxUlPrio;
274 boRpt.setMaxDlPrio= datReq->datReq[idx].datReqTb[idx1].lchData[idx2].boReport.staPduPrsnt;
276 RgMacSchDedBoUpdt(&schPst, &boRpt);
280 /* ADD Changes for Downlink UE Timing Optimization */
281 #ifdef LTEMAC_DLUE_TMGOPTMZ
282 // sf->remDatReqCnt -= datReqFailCnt;
283 /*Presently this function is not returning RFAILED, thus not checking
284 for failure condition.*/
285 ret = rgROMUpdDlSfRemDataCnt(cell, sf);
288 RLOG0(L_INFO, "\n Dropping due to no failure of remCnt update(1) \n");
290 RG_DROP_RGUDDATREQ_MBUF(datReq->datReq[idx]);
292 /* Return from here as above functions found more datReq than expected*/
296 } /* for loop for num of Ue per TTI*/
299 /* Data send successfully to PHY. lets retuns ROK*/
301 } /* rgROMDedDatReq */
305 * @brief Handler for DatReq received on RGU for a common logical channel.
309 * Function : rgROMCmnDatReq
311 * This function shall invoke rgROMHndlCcchDatReq() if datReq is on CCCH
312 * If not, it shall invoke rgROMHndlBcchPcchDatReq().
315 * @param[in] Inst inst
316 * @param[in] RgRguCmnDatReq *datReq
321 S16 rgROMCmnDatReq(Inst inst, RgRguCmnDatReq *datReq)
326 /* ADD Changes for Downlink UE Timing Optimization */
327 #ifdef LTEMAC_DLUE_TMGOPTMZ
328 CmLteTimingInfo timingInfo;
333 err.errType = RGERR_ROM_CMNDATREQ;
334 if(((cell = rgCb[inst].cell) == NULLP)
335 ||(cell->cellId != datReq->cellId))
337 #if (ERRCLASS & ERRCLS_INT_PAR)
338 /* Handle Cell fetch failure */
339 RGLOGERROR(inst,ERRCLS_INT_PAR,ERG003,(ErrVal)datReq->cellId,
340 "rgROMCmnDatReq(): Invalid cell Id");
342 err.errCause = RGERR_ROM_INV_CELL_ID;
346 rgUpdtRguCmnSts(inst,cell->rguDlSap,RG_RGU_SDU_DROP);
351 if (datReq->lcId == cell->dlCcchId)
353 ret = rgROMHndlCcchDatReq(cell, datReq, &err);
355 /*Get the timing Info*/
356 /* ADD Changes for Downlink UE Timing Optimization */
357 #ifdef LTEMAC_DLUE_TMGOPTMZ
358 timingInfo.slot = (uint8_t)((datReq->transId >> 8) & 0XFF);
359 timingInfo.sfn = (uint16_t)((datReq->transId >> 16) & 0xFFFF);
364 ret = rgROMHndlBcchPcchDatReq(cell, datReq, &err);
366 /*Get the timing Info*/
367 /* ADD Changes for Downlink UE Timing Optimization */
368 #ifdef LTEMAC_DLUE_TMGOPTMZ
369 timingInfo.slot = (uint8_t)(datReq->transId & 0XFF);
370 timingInfo.sfn = (uint16_t)((datReq->transId >> 8) & 0xFFFF);
377 rgUpdtRguCmnSts(inst,cell->rguDlSap,RG_RGU_SDU_DROP);
381 /* Update stats with number of SDUs received */
382 rgUpdtRguCmnSts(inst,cell->rguDlSap,RG_RGU_SDU_RCVD);
385 /* ADD Changes for Downlink UE Timing Optimization */
386 #ifdef LTEMAC_DLUE_TMGOPTMZ
387 RG_ARRAY_BOUND_CHECK(0, cell->subFrms, (timingInfo.slot % RG_NUM_SUB_FRAMES));
388 sf = &cell->subFrms[(timingInfo.slot % RG_NUM_SUB_FRAMES)];
390 ret = rgROMUpdDlSfRemDataCnt(cell, sf);
391 /*Added check for RFAILED as above function can return RFAILED*/
395 } /* rgROMCmnDatReq */
398 * @brief Handler for DatReq received on RGU for CCCH.
402 * Function : rgROMHndlCcchDatReq
404 * This function shall fetch the raCb with the given rnti and indicate msg4
408 * @param[in] RgCellCb *cell
409 * @param[in] RgRguCmnDatReq *datReq
410 * @param[out] RgErrInfo *err
415 static S16 rgROMHndlCcchDatReq(RgCellCb *cell, RgRguCmnDatReq *datReq, RgErrInfo *err)
417 Inst inst = cell->macInst - RG_INST_START;
420 RgDlHqProcCb *hqProc;
421 CmLteTimingInfo timingInfo;
423 #if (ERRCLASS & ERRCLS_DEBUG)
424 RgUstaDgn dgn; /* Alarm diagnostics structure */
427 err->errType = RGERR_ROM_CMNDATREQ;
429 if ((ue = rgDBMGetUeCb(cell, datReq->u.rnti)) == NULLP)
431 if ((ue = rgDBMGetUeCbFromRachLst(cell, datReq->u.rnti)) == NULLP)
433 #if (ERRCLASS & ERRCLS_INT_PAR)
434 /* Handle Ue fetch failure */
435 RGLOGERROR(inst,ERRCLS_INT_PAR,ERG004,(ErrVal)datReq->u.rnti,
436 "rgROMHndlCcchDatReq(): Invalid ue Id");
438 err->errCause = RGERR_ROM_INV_UE_ID;
443 timingInfo.slot = (uint8_t)((datReq->transId >> 8) & 0XFF);
444 timingInfo.sfn = (uint16_t)((datReq->transId >> 16) & 0xFFFF);
445 sf = &cell->subFrms[(timingInfo.slot % RG_NUM_SUB_FRAMES)];
447 if( (sf->txDone == TRUE) ||
448 (!RG_TIMEINFO_SAME(sf->schdTime,timingInfo)))
450 #if (ERRCLASS & ERRCLS_DEBUG)
451 /* Transmission is already done for this slot. This is a delayed
452 * datReq. So discard */
453 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
454 rgLMMStaInd(inst,LCM_CATEGORY_PROTOCOL, LCM_EVENT_UI_INV_EVT,
455 LRG_CAUSE_DELAYED_DATREQ, &dgn);
457 err->errCause = RGERR_ROM_DELAYED_DATREQ;
461 hqPId = (uint8_t)(datReq->transId);
464 /* get harq process and invoke DHM */
465 rgDHMGetHqProcFrmId(ue, hqPId, &hqProc);
467 /* Changed for CR timer implementation*/
468 /* invoke DHM to process CCCH data */
469 if (rgDHMHndlCmnDatReq(inst,hqProc, datReq, err) == RFAILED)
471 RLOG_ARG2(L_ERROR,DBG_CELLID,cell->cellId,
472 "Handling of Data request in DHM failed RNTI:%d LCID:%d",
473 datReq->u.rnti,datReq->lcId);
474 /* Release First TB */
475 rgDHMRlsHqProcTB(cell, hqProc, 1);
476 /* err shall be filled in appropriately by DHM */
481 } /* rgROMHndlCcchDatReq */
485 * @brief Handler for DatReq received on RGU for BCCH or PCCH.
489 * Function : rgROMHndlBcchPcchDatReq
491 * This function shall store the buffer and time to transmit in lcCb.
494 * @param[in] RgCellCb *cell
495 * @param[in] RgRguCmnDatReq *datReq
496 * @param[out] RgErrInfo *err
501 static S16 rgROMHndlBcchPcchDatReq(RgCellCb *cell, RgRguCmnDatReq *datReq, RgErrInfo *err)
503 Inst inst = cell->macInst - RG_INST_START;
505 /* Modified for SI Enhancement*/
508 RgBcchDlschLcCb *bcch;
511 CmLteTimingInfo timingInfo;
512 #if (ERRCLASS & ERRCLS_DEBUG)
513 RgUstaDgn dgn; /* Alarm diagnostics structure */
517 timingInfo.slot = (uint8_t)(datReq->transId & 0XFF);
518 timingInfo.sfn = (uint16_t)((datReq->transId >> 8) & 0xFFFF);
519 sf = &cell->subFrms[(timingInfo.slot % RG_NUM_SUB_FRAMES)];
521 if( (sf->txDone == TRUE) ||
522 (!RG_TIMEINFO_SAME(sf->schdTime,timingInfo)))
524 #if (ERRCLASS & ERRCLS_DEBUG)
525 /* Transmission is already done for this slot. This is a delayed
526 * datReq. So discard */
527 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
528 rgLMMStaInd(inst,LCM_CATEGORY_PROTOCOL, LCM_EVENT_UI_INV_EVT,
529 LRG_CAUSE_DELAYED_DATREQ, &dgn);
531 err->errCause = RGERR_ROM_DELAYED_DATREQ;
536 bcch = rgDBMGetBcchOnDlsch(cell,datReq->lcId);
539 /* Store BCCH-DLSCH data received in Scheduled slot */
540 sf->bcch.tb = datReq->pdu;
542 SCpyMsgMsg(datReq->pdu, RG_GET_MEM_REGION(rgCb[inst]),
543 RG_GET_MEM_POOL(rgCb[inst]), &bcch->tb);
548 bch = rgDBMGetBcchOnBch(cell);
549 if ((bch) && (bch->lcId == datReq->lcId))
551 /* Store BCH data received in Scheduled slot */
552 sf->bch.tb = datReq->pdu;
557 pcch = rgDBMGetPcch(cell);
558 if ((pcch) && (pcch->lcId == datReq->lcId))
560 /* Store PCCH-DLSCH data received in Scheduled slot */
561 sf->pcch.tb = datReq->pdu;
565 /* Handle lcCb fetch failure */
566 RGLOGERROR(inst,ERRCLS_INT_PAR,ERG005,(ErrVal)datReq->lcId,
567 "rgROMHndlBcchPcchDatReq(): Invalid Lc Id");
568 err->errCause = RGERR_ROM_INV_LC_ID;
571 } /* rgROMHndlBcchPcchDatReq */
574 * @brief Handler for StaRsp received on RGU for a dedicated logical channel.
578 * Function : rgROMDedStaRsp
580 * This fucntion shall store the BO reported for the given logical
584 * @param[in] Inst inst
585 * @param[in] RgRguDedStaRsp *staRsp
590 S16 rgROMDedStaRsp(Inst inst, RgRguDedStaRsp *staRsp)
594 /* Moving the error variables and assignments to available scope */
596 /* Avoiding memset, as the variables of this are getting
600 if(((cell = rgCb[inst].cell) != NULLP)
601 && (cell->cellId == staRsp->cellId))
606 boRpt.cellSapId = cell->schInstMap.cellSapId;
607 boRpt.cellId = staRsp->cellId;
608 boRpt.rnti = staRsp->rnti;
609 boRpt.lcId = staRsp->lcId;
610 boRpt.bo = staRsp->boReport.bo;
611 boRpt.oldestSduArrTime = staRsp->boReport.oldestSduArrTime;
612 boRpt.staPduBo = staRsp->boReport.staPduBo;
613 boRpt.oldestSduArrTime = staRsp->boReport.oldestSduArrTime;
615 rgGetPstToInst(&schPst,inst, cell->schInstMap.schInst);
617 //TODO: commented for compilation without SCH RgMacSchDedBoUpdt(&schPst, &boRpt);
620 RLOG_ARG2(L_ERROR,DBG_CELLID,staRsp->cellId,"Invalid cell for CRNTI:%d LCID:%d ",
621 staRsp->rnti,staRsp->lcId);
624 } /* rgROMDedStaRsp */
626 S16 RgMacSchBrdcmDedBoUpdtReq(
636 //if ((cell = rgDBMGetCellCb(cellId)) != NULLP)
637 if (((cell = rgCb[inst].cell) != NULLP) &&
638 (cell->cellId == cellId))
643 boRpt.cellSapId = cell->schInstMap.cellSapId;
644 boRpt.cellId = cellId;
649 rgGetPstToInst(&schPst,inst, cell->schInstMap.schInst);
651 //TODO: commented for compilation without SCH RgMacSchDedBoUpdtReq (&schPst,&boRpt);
656 * @brief Handler for StaRsp received on RGU for a common logical channel.
660 * Function : rgROMCmnStaRsp
662 * This fucntion shall invoke rgROMHndlCcchStaRsp() for status response on
663 * CCCH and shall invoke rgROMHndlBcchPcchStaRsp() for status response on
667 * @param[in] Inst inst
668 * @param[in] RgRguCmnStaRsp *staRsp
673 S16 rgROMCmnStaRsp(Inst inst, RgRguCmnStaRsp *staRsp)
678 if(((cell = rgCb[inst].cell) == NULLP)
679 || (cell->cellId != staRsp->cellId))
681 /* Handle Cell fetch failure */
682 RLOG_ARG2(L_ERROR,DBG_CELLID,staRsp->cellId,
683 "Invalid cell for CRNTI:%d LCID:%d",staRsp->u.rnti,staRsp->lcId);
684 err.errType = RGERR_ROM_CMNSTARSP;
685 err.errCause = RGERR_ROM_INV_CELL_ID;
689 /* handle status response on CCCH */
690 if(staRsp->lcId == cell->dlCcchId)
692 rgROMHndlCcchStaRsp(cell, staRsp, &err);
696 rgROMHndlBcchPcchStaRsp(cell, staRsp, &err);
700 } /* rgROMCmnStaRsp */
705 * @brief Handler for Request received on RGU for a UL Throughput measurement
706 * enabled logical channel.
710 * Function :rgROML2MUlThrpMeasReq
712 * This function shall store the L2M UL Throughput Measurement status information
713 * for the given logical channel.
716 * @param[in] Inst inst
717 * @param[in] RgRguL2MUlThrpMeasReq *measReq
722 S16 rgROML2MUlThrpMeasReq(Inst inst, RgRguL2MUlThrpMeasReq *measReq)
729 if(((cell = rgCb[inst].cell) != NULLP)
730 &&(cell->cellId == measReq->cellId))
732 if ((ue = rgDBMGetUeCb(cell, measReq->rnti)) != NULLP)
734 for(loop=0; loop<measReq->numLcId;loop++)
736 if ((rgDBMGetUlDedLcCb(ue, measReq->lcId[loop])) != NULLP)
738 ue->ul.lcCb[measReq->lcId[loop]].measOn = measReq->enbMeas;
739 if(ue->ul.lcCb[measReq->lcId[loop]].measOn == FALSE)
741 lcgId=ue->ul.lcCb[measReq->lcId[loop]].lcgId;
742 ue->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs = 0;
743 ue->ul.lcgArr[lcgId].lcgBsInfo.firstDatSegRcvd = FALSE;
750 RLOG_ARG1(L_ERROR,DBG_CELLID,measReq->cellId,"Invalid cell CRNTI:%d",
753 } /* rgROML2MUlThrpMeasReq */
758 * @brief Handler for StaRsp received on RGU for CCCH.
762 * Function : rgROMHndlCcchStaRsp
764 * This function shall fetch the raCb with the given RNTI and ask RAM to
768 * @param[in] RgCellCb *cell
769 * @param[in] RgRguCmnStaRsp *staRsp
770 * @param[out] RgErrInfo *err
775 static S16 rgROMHndlCcchStaRsp(RgCellCb *cell,RgRguCmnStaRsp *staRsp, RgErrInfo *err)
778 Inst macInst = cell->macInst - RG_INST_START;
779 //RgInfCmnBoRpt boRpt;
783 boRpt.cellSapId = cell->schInstMap.cellSapId;
784 boRpt.cellId = staRsp->cellId;
785 boRpt.u.rnti = staRsp->u.rnti;
786 boRpt.lcId = staRsp->lcId;
787 boRpt.lcType = staRsp->lcType;
788 boRpt.bo = staRsp->bo;
790 rgGetPstToInst(&schPst,macInst, cell->schInstMap.schInst);
791 //TODO: commented for compilation without SCH RgMacSchCmnBoUpdt(&schPst, &boRpt);
794 } /* rgROMHndlCcchStaRsp */
798 * @brief Handler for StaRsp received on RGU for BCCH or PCCH.
802 * Function : rgROMHndlBcchPcchStaRsp
804 * This function shall store the buffer and time to transmit in lcCb.
807 * @param[in] RgCellCb *cell
808 * @param[in] RgRguCmnStaRsp *staRsp
809 * @param[out] RgErrInfo *err
814 static S16 rgROMHndlBcchPcchStaRsp(RgCellCb *cell,RgRguCmnStaRsp *staRsp,RgErrInfo *err)
817 //RgInfCmnBoRpt boRpt;
818 Inst macInst = cell->macInst - RG_INST_START;
820 memset(&schPst, 0, sizeof(Pst));
822 if (rgDBMChkCmnLcCb(cell, staRsp->lcId) != ROK)
824 /* Handle lcCb fetch failure */
825 RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId,"Invalid LCID:%d",staRsp->lcId);
826 err->errCause = RGERR_ROM_INV_LC_ID;
829 /* MS_WORKAROUND : This is to ensure that the queue for BCH is not filled with old BO requests :
830 This assumes that BO is not received more than 4 frames in advance from the enodeb application */
831 if (cell->bcchBchInfo.lcId == staRsp->lcId)
835 nextBchSfn = (cell->crntTime.sfn + 4 - (cell->crntTime.sfn%4)) % RG_MAX_SFN;
836 if ((staRsp->u.timeToTx.sfn != nextBchSfn) ||
837 ((staRsp->u.timeToTx.sfn == cell->crntTime.sfn) && (cell->crntTime.slot >= 7)))
843 boRpt.cellSapId = cell->schInstMap.cellSapId;
844 boRpt.cellId = staRsp->cellId;
845 boRpt.u.timeToTx = staRsp->u.timeToTx;
846 boRpt.lcId = staRsp->lcId;
847 boRpt.lcType = staRsp->lcType;
848 boRpt.bo = staRsp->bo;*/
852 if(boRpt.lcType == CM_LTE_LCH_PCCH)
854 boRpt.emtcDIReason = staRsp->emtcDiReason;
855 boRpt.pnb = staRsp->pnb;
859 rgGetPstToInst(&schPst,macInst, cell->schInstMap.schInst);
860 //TODO: commented for compilation without SCH RgMacSchCmnBoUpdt(&schPst, &boRpt);
863 } /* rgROMHndlBcchPcchStaRsp */
865 /* ADD Changes for Downlink UE Timing Optimization */
866 #ifdef LTEMAC_DLUE_TMGOPTMZ
868 * @brief Handler for updating DL SF information on receiving
869 * DL dedicated data, CCCH, BCCH/PCCH data request.
873 * Function : rgROMUpdDLSfRemDataCnt
876 * @param[in] RgCellCb *cell
877 * @param[in] RgDlSf *dlSf;
882 static S16 rgROMUpdDlSfRemDataCnt(RgCellCb *cellCb, RgDlSf *dlSf)
885 //Inst inst = cellCb->macInst - RG_INST_START;
887 if(!dlSf->remDatReqCnt)
889 /*This is an error scenario of RLC generating more data
890 * request than the allocation. Do nothing for this. */
891 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
892 "RX new data while remDatReqCnt is 0 for cell");
896 /*Decrement the remaining data request to be received countter
898 Check if this was the last pending data request for this DL SF.*/
899 /* Fix[ccpu00126310]: Tracks Data Requests from RLC for both loosely and tight coupled
901 if((0 == --dlSf->remDatReqCnt) && !(dlSf->txDone) &&
902 (RG_TIMEINFO_SAME(cellCb->crntTime, dlSf->schdTime)) && (dlSf->statIndDone))
904 /*Check if we have already received a TTI for this Data,
905 if that is the case then we need to send TFU Data request
908 if (ROK != rgTOMUtlProcDlSf (dlSf, cellCb, &err))
910 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
911 "Unable to process downlink slot for cell");
912 err.errType = RGERR_ROM_DEDDATREQ;
915 /* Mark this frame as sent */
920 } /* rgROMUpdDlSfRemDataCnt*/
923 /**********************************************************************
926 **********************************************************************/