-/**
- * @brief Handler for processing TTI indication recieved from
- * PHY for a cell.
- *
- * @details
- *
- * Function: rgTOMTtiInd
- *
- * Handler for processing TTI indication recieved from PHY
- * for a cell.
- *
- * Invoked by: RgLiTfuTtiInd
- *
- * Processing Steps:
- * - Get cell and update the cell's current time with the timing value given
- * by PHY
- * - Invoke the cmPrcTmr to process the timing queue.
- * - Append the PHICH information to the downlink subframe that needs to go
- * out to PHY in this subframe.
- * - Invoke DHM to release the downlink subframe that occured earlier
- * rgDHMRlsDlsfHqProc.
- * - Invoke the TTI handler of scheduler.
- * - Invoke the TTI handler of RAM module.
- * - Get the downlink subframe that has to go out to PHY in this subframe
- * rgSCHSubFrmGet.
- * - Invoke rgTOMUtlProcTA to perform and timing advance processing.
- * - Invoke rgTOMUtlProcDlSf to do further processing on the downlink
- * subframe.
- * - Get the downlink subframe that would occur after RG_DL_DELTA and
- * invoke rgTOMUtlProcDlSfStaInd to send status indications to the higher
- * layer.
- * - Invoke GOM's TTI handler rgGOMTtiHndlr
- * - Invoke COM's TTI handler rgCOMTtiHndlr
- *
- * @param[in] Inst inst
- * @param[in] TfuTtiIndInfo *ttiInd
- * @return S16
- * -# ROK
- * -# RFAILED
- **/
-#if (defined (MAC_FREE_RING_BUF) || defined (RLC_FREE_RING_BUF))
-pthread_t gMacTId = 0;
-#endif
-#ifdef ANSI
-PUBLIC S16 rgTOMTtiInd
-(
-Inst inst,
-TfuTtiIndInfo *ttiInfo
-)
-#else
-PUBLIC S16 rgTOMTtiInd(inst, ttiInfo)
-Inst inst;
-TfuTtiIndInfo *ttiInfo;
-#endif
-{
- RgCellCb *cellCb;
- RgErrInfo err;
- RgDlSf *dlSf;
-/* ADD Changes for Downlink UE Timing Optimization */
-#ifdef LTEMAC_DLUE_TMGOPTMZ
- RgDlSf *prevDlSf;
- CmLteTimingInfo prevTmInfo;
-#endif
- TfuTtiCellInfo *ttiInd = &ttiInfo->cells[0];
-
- TRC2(rgTOMTtiInd);
-
-#ifdef MAC_FREE_RING_BUF
- gMacTId = pthread_self();
-#endif
- cellCb = rgCb[inst].cell;
- if ((cellCb == NULLP)
- ||(cellCb->cellId != ttiInd->cellId))
- {
-
- RLOG_ARG0(L_ERROR,DBG_CELLID,ttiInd->cellId,
- "Unable to get the cellCb for cell");
- err.errType = RGERR_TOM_TTIIND;
- err.errCause = RGERR_TOM_INV_CELL_ID;
- RETVALUE(RFAILED);
- }
- RGCPYTIMEINFO(ttiInd->timingInfo, cellCb->crntTime);
- if((0 == (ttiInd->timingInfo.sfn % 30)) && (0 == ttiInd->timingInfo.sfn))
- {
- //printf("5GTF_CHECK rgTOMTtiInd (%d : %d)\n", ttiInd->timingInfo.sfn, ttiInd->timingInfo.subframe);
- }
- rgMacGT = (ttiInd->timingInfo.sfn * RG_NUM_SUB_FRAMES_5G) + ttiInd->timingInfo.subframe;
-#ifdef LTE_L2_MEAS
- rgL2Meas(cellCb);
- /*Included to track the number of 10240 cycles completed */
-
- if((cellCb->crntTime.sfn == 0) && (cellCb->crntTime.subframe==0))
- {
- cellCb->ttiCycle += 1;
- }
-
-#endif
-
- /*Check if we have transmitted the previous DL SF, it could be the
- case that we haven't received all the DATA from RLC as yet
- and thus we would not have transmitted previous DL SF yet.*/
-/* ADD Changes for Downlink UE Timing Optimization */
-#ifdef LTEMAC_DLUE_TMGOPTMZ
- RGSUBFRMCRNTTIME(ttiInd->timingInfo, prevTmInfo, 1);
- prevDlSf = &cellCb->subFrms[(prevTmInfo.subframe % RG_NUM_SUB_FRAMES)];
- if(FALSE == prevDlSf->txDone)
- {
- if (ROK != rgTOMUtlProcDlSf (prevDlSf, cellCb, &err))
- {
- RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,"Unable to process "
- "previous downlink subframe for cell");
- err.errType = RGERR_TOM_TTIIND;
- }
-
- /* Mark this frame as sent */
- prevDlSf->txDone = TRUE;
-
- if(prevDlSf->remDatReqCnt)
- {
- /*We have not received 1 or more data requests from RLC, this is
- error scenario. MAC & SCH need to discard the allocations for
- which data request hasn't been received as yet. And MAC
- needs to inform SCH about the list of UEs for which
- allocation need to be discarded. */
- prevDlSf->remDatReqCnt = 0;
- }
- }
-#endif
- dlSf = &cellCb->subFrms[(ttiInd->timingInfo.subframe % RG_NUM_SUB_FRAMES)];
-
- if((dlSf->txDone == TRUE) ||
- (!RG_TIMEINFO_SAME(ttiInd->timingInfo,dlSf->schdTime)))
- {
- /* MS_WORKAROUND */
-#ifndef LTEMAC_DLUE_TMGOPTMZ
- TfuDatReqInfo *datInfo;
- CmLteTimingInfo timingInfo;
-#ifdef TFU_DL_DELTA_CHANGE
- RGADDTOCRNTTIME(cellCb->crntTime, timingInfo, TFU_DLDATA_DLDELTA);
-#else
- RGADDTOCRNTTIME(cellCb->crntTime, timingInfo, TFU_DELTA);
-#endif
- /* Fill Data Request from MAC for BCH */
- if ((timingInfo.sfn % 4 == 0) && (timingInfo.subframe == 0))
- {
- if (ROK != rgAllocEventMem(inst,(Ptr *)&datInfo,
- sizeof(TfuDatReqInfo)))
- {
- RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
- "rgTOMUtlProcDlSf() Unable to Allocate TfuDatReqInfo for cell");
- RETVALUE(RFAILED);
- }
- else
- {
- cmLListInit(&datInfo->pdus);
- datInfo->cellId = cellCb->cellId;
- datInfo->bchDat.pres = NOTPRSNT;
- datInfo->timingInfo = timingInfo;
-
-
- /* sending the dummy data req to Phy */
- if (rgLIMTfuDatReq(inst,datInfo) != ROK)
- {
- RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
- "rgTOMUtlProcDlSf() Unable to send data info for cell");
- }
-
- }
- }
-#endif
- /* Freeing as the part of CL Non RT Indication */
- /* TDOD : Generalize for all SOCs */
-#if !(defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD))
- rgDHMFreeTbBufs(inst);
-#endif
- RETVALUE(ROK);
- }
-
- /*Return if there is still some data to be received
- from RLC for this DL SF. */
-/* ADD Changes for Downlink UE Timing Optimization */
-#ifdef LTEMAC_DLUE_TMGOPTMZ
- if(0 != dlSf->remDatReqCnt)
- {
- /* Freeing as the part of CL Non RT Indication */
- /* TODO : Generalize for all SOCs and remove this flag */
-#if !(defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD))
- rgDHMFreeTbBufs(inst);
-#endif
- RETVALUE(ROK);
- }
-#endif
-
-#ifdef XEON_SPECIFIC_CHANGES
- CM_MEAS_TIME((ttiInd->timingInfo.subframe % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_DL_BR_PRC);
-#endif
-
- if (ROK != rgTOMUtlProcDlSf (dlSf, cellCb, &err))
- {
- RLOG_ARG0(L_ERROR,DBG_CELLID,ttiInd->cellId,
- "Unable to process downlink subframe for cell");
- err.errType = RGERR_TOM_TTIIND;
- }
-#ifdef XEON_SPECIFIC_CHANGES
- CM_MEAS_TIME((ttiInd->timingInfo.subframe % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_DL_AFTER_PRC);
-#endif
-
- /* Mark this frame as sent */
- dlSf->txDone = TRUE;
-
- /* Freeing as the part of CL Non RT Indication */
- /* TODO : Generalize for all SOCs and remove this flag */
-#if !(defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD))
- rgDHMFreeTbBufs(inst);
-#endif
- RETVALUE(ROK);
-} /* rgTOMTtiInd */
-