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 **********************************************************************/
31 static const char* RLOG_MODULE_NAME="MAC";
32 static int RLOG_FILE_ID=237;
33 static int RLOG_MODULE_ID=4096;
35 @brief This module does processing related to handling of lower interface APIs
36 invoked by PHY towards MAC
38 /* header include files -- defines (.h) */
39 #include "envopt.h" /* environment options */
40 #include "envdep.h" /* environment dependent */
41 #include "envind.h" /* environment independent */
42 #include "gen.h" /* general layer */
43 #include "ssi.h" /* system services */
44 #include "cm5.h" /* common timers defines */
45 #include "cm_hash.h" /* common hash list defines */
46 #include "cm_llist.h" /* common linked list defines */
47 #include "cm_mblk.h" /* memory management */
48 #include "cm_tkns.h" /* common tokens */
49 #include "cm_lte.h" /* common tokens */
50 #include "rgu.h" /* RGU defines */
51 #include "tfu.h" /* RGU defines */
52 #include "lrg.h" /* layer management defines for LTE-MAC */
53 #include "crg.h" /* layer management defines for LTE-MAC */
54 #include "rg_sch_inf.h" /* layer management defines for LTE-MAC */
55 #include "rg.h" /* defines and macros for MAC */
56 #include "rg_env.h" /* defines and macros for MAC */
57 #include "rg_err.h" /* defines and macros for MAC */
60 /* header/extern include files (.x) */
61 #include "gen.x" /* general layer typedefs */
62 #include "ssi.x" /* system services typedefs */
63 #include "cm5.x" /* common timers */
64 #include "cm_hash.x" /* common hash list */
65 #include "cm_lib.x" /* common library */
66 #include "cm_llist.x" /* common linked list */
67 #include "cm_mblk.x" /* memory management */
68 #include "cm_tkns.x" /* common tokens */
69 #include "cm_lte.x" /* common tokens */
70 #include "rgu.x" /* RGU types */
71 #include "tfu.x" /* RGU types */
72 #include "lrg.x" /* layer management typedefs for MAC */
73 #include "crg.x" /* CRG interface typedefs */
74 #include "rg_sch_inf.x" /* SCH interface typedefs */
75 #include "rg_prg.x" /* PRG interface typedefs */
76 #include "rgm.x" /* layer management typedefs for MAC */
77 #include "rgm.h" /* layer management typedefs for MAC */
78 #include "rg.x" /* typedefs for MAC */
80 #ifdef MAC_RLC_UL_RBUF
85 /* ADD Changes for Downlink UE Timing Optimization */
86 #ifndef LTEMAC_DLUE_TMGOPTMZ
87 PRIVATE S16 rgTOMUtlProcDlSf ARGS(( RgDlSf *dlSf, RgCellCb *cellCb,
90 PUBLIC S16 rgTOMUtlProcDlSf ARGS((RgDlSf *dlSf, RgCellCb *cellCb,
93 PRIVATE S16 rgTOMProcCrntiCEInDatInd ARGS((
102 PRIVATE S16 rgTOMProcCCCHSduInDatInd ARGS((
111 PUBLIC S16 rgHndlFlowCntrl
117 EXTERN S16 RgUiRguFlowCntrlInd(Pst* pst, SuId suId, RguFlowCntrlInd *flowCntrlInd);
119 EXTERN S16 rgEmtcHndl(RgCellCb *cell,RgInfSfAlloc *sfInfo);
120 EXTERN S16 rgTOMEmtcUtlFillDatReqPdus(TfuDatReqInfo *datInfo, RgDlSf *dlSf, RgCellCb *cell, RgErrInfo *err);
121 EXTERN Void rgTOMEmtcRlsSf(RgDlSf *dlSf);
124 PRIVATE Void rgTOML2MCompileActiveLCs ARGS
131 PRIVATE S16 rgTOMUtlL2MStoreBufSz ARGS
137 PRIVATE S16 rgTomUtlPrepareL2MUlThrpInfo ARGS
141 RgRguDedDatInd *dDatInd
145 /* The below table takes lower values of BSR Range for a BSR value
146 This is to ensure that outstanding can be decrease to zero upon reception of
147 TB, which is not guaranteed if higher Range values are used */
148 /* Note: taking value 10 for BSR index 1 */
149 #ifndef MAC_5GTF_UPDATE
150 PRIVATE U32 rgLwrBsrTbl[64] = {
151 0, 10, 10, 12, 14, 17, 19, 22, 26,
152 31, 36, 42, 49, 57, 67, 78, 91,
153 107, 125, 146, 171, 200, 234, 274, 321,
154 376, 440, 515, 603, 706, 826, 967, 1132,
155 1326, 1552, 1817, 2127, 2490, 2915, 3413, 3995,
156 4677, 5476, 6411, 7505, 8787, 10287, 12043, 14099,
157 16507, 19325, 22624, 26487, 31009, 36304, 42502, 49759,
158 58255, 68201, 79846, 93479, 109439, 128125, 150000
162 PRIVATE U32 rgLwrBsrTbl[64] = {
163 0,10,13,16,19,23,29,35,43,53,65,80,98,120,147,181,223,274,337,414,
164 509,625,769,945,1162,1429,1757,2161,2657,3267,4017,4940,6074,7469,
165 9185,11294,13888,17077,20999,25822,31752,39045,48012,59039,72598,
166 89272,109774,134986,165989,204111,250990,308634,379519,466683,
167 573866,705666,867737,1067031,1312097,1613447,1984009,2439678,
175 #define RG_TOM_INF_ALLOC(_pdu, _size, _dataPtr, _ret) {\
176 _ret = cmGetMem((Ptr)&_pdu->memCp, _size, (Ptr *)&_dataPtr); \
179 /* global variables */
180 PUBLIC U32 rgUlrate_tfu;
182 EXTERN U32 grgUlrate_tfu;
185 /** @brief This function fills the PDSCH data of a downlink subframe
189 * Function: rgTOMUtlFillDatReqPdus
192 * - Fill BCCH on DLSCH data using datInfo
193 * - Fill PCCH on DLSCH data using datInfo
194 * - Fill Dedicated data on DLSCH data using datInfo
195 * - Fill RA RSP data using datInfo
197 * @param [out] TfuDatReqInfo *datInfo
198 * @param [in] RgDlSf *dlSf
199 * @param [in] RgCellCb *cellCb
200 * @param [out] RgErrInfo *err
206 PRIVATE S16 rgTOMUtlFillDatReqPdus
208 TfuDatReqInfo *datInfo,
214 PRIVATE S16 rgTOMUtlFillDatReqPdus(datInfo, dlSf, cellCb, err)
215 TfuDatReqInfo *datInfo;
222 TfuDatReqPduInfo *datReq=NULLP;
223 /* Moving node declaration to limited scope for optimization */
226 Inst inst = cellCb->macInst - RG_INST_START;
228 TRC2(rgTOMUtlFillDatReqPdus)
230 /* first lets send the BCCH data down to PHY */
231 if (dlSf->bcch.tb != NULLP)
233 if ((ret = rgGetEventMem(inst,(Ptr *)&datReq, sizeof(TfuDatReqPduInfo),
234 &(datInfo->memCp))) != ROK)
236 err->errCause = RGERR_TOM_MEM_EXHAUST;
237 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,"Memory Exhaustion ");
240 #ifdef TFU_ALLOC_EVENT_NO_INIT
244 datReq->tbInfo[0].lchInfo[0].mBuf[0]=NULLP;
247 datReq->rnti = RG_SI_RNTI;
248 datReq->dciInfo = dlSf->bcch.pdcch.dci;
249 /* Note: SCpyMsgMsg is not done since free of unsent buffer
250 * has been taken care through cell delete by invoking rgTomRlsSf
252 datReq->nmbOfTBs = 1;
254 datReq->mBuf[0] = dlSf->bcch.tb;
256 SFndLenMsg((Buffer *)dlSf->bcch.tb, &(datReq->tbInfo[0].tbSize));
257 datReq->tbInfo[0].tbPres = TRUE;
258 datReq->tbInfo[0].lchInfo[0].mBuf[0] = dlSf->bcch.tb;
259 datReq->tbInfo[0].numLch = 1;
260 datReq->tbInfo[0].lchInfo[0].numPdu = 1;
262 #ifdef TFU_ALLOC_EVENT_NO_INIT
263 datReq->tbInfo[1].tbPres = FALSE;
264 datReq->tbInfo[1].lchInfo[0].mBuf[0] = NULLP;
267 cmLListAdd2Tail(&datInfo->pdus, &(datReq->lnk));
268 datReq->lnk.node = (PTR)datReq;
270 /* ccpu00132314-ADD- Adding txPower offset for the PDSCH transmission */
271 datReq->txPwrOffset = dlSf->bcch.txPwrOffset;
273 /* Setting the pointer to NULL post transmission */
274 dlSf->bcch.tb = NULLP;
277 if (dlSf->pcch.tb != NULLP)
279 if ((ret = rgGetEventMem(inst,(Ptr *)&datReq, sizeof(TfuDatReqPduInfo),
280 &(datInfo->memCp))) != ROK)
282 err->errCause = RGERR_TOM_MEM_EXHAUST;
283 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"Memory Exhaustion CRNTI:%d",datReq->rnti);
286 #ifdef TFU_ALLOC_EVENT_NO_INIT
291 datReq->rnti = RG_P_RNTI;
292 datReq->dciInfo = dlSf->pcch.pdcch.dci;
293 datReq->nmbOfTBs = 1;
295 datReq->mBuf[0] = dlSf->pcch.tb;
297 SFndLenMsg((Buffer *)dlSf->pcch.tb, &datReq->tbInfo[0].tbSize);
298 datReq->tbInfo[0].tbPres = TRUE;
299 datReq->tbInfo[0].lchInfo[0].mBuf[0] = dlSf->pcch.tb;
300 #ifdef TFU_ALLOC_EVENT_NO_INIT
301 datReq->tbInfo[1].tbPres = FALSE;
302 datReq->tbInfo[1].lchInfo[0].mBuf[0] = NULLP;
304 datReq->tbInfo[0].numLch = 1;
305 datReq->tbInfo[0].lchInfo[0].numPdu = 1;
307 cmLListAdd2Tail(&datInfo->pdus, &(datReq->lnk));
308 datReq->lnk.node = (PTR)datReq;
310 /* ccpu00132314-ADD- Adding txPower offset for the PDSCH transmission */
311 datReq->txPwrOffset = dlSf->pcch.txPwrOffset;
313 dlSf->pcch.tb = NULLP;
316 for(idx=0; idx < dlSf->numRaRsp; idx++)
318 if ((ret = rgGetEventMem(inst,(Ptr *)&datReq, sizeof(TfuDatReqPduInfo),
319 &(datInfo->memCp))) != ROK)
321 err->errCause = RGERR_TOM_MEM_EXHAUST;
322 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"Memory Exhaustion CRNTI:%d",
326 #ifdef TFU_ALLOC_EVENT_NO_INIT
331 datReq->rnti = dlSf->raRsp[idx].pdcch.rnti;
332 datReq->dciInfo = dlSf->raRsp[idx].pdcch.dci;
333 datReq->nmbOfTBs = 1;
335 datReq->mBuf[0] = dlSf->raRsp[idx].rar;
337 SFndLenMsg((Buffer *)dlSf->raRsp[idx].rar, &datReq->tbInfo[0].tbSize);
338 datReq->tbInfo[0].tbPres = TRUE;
339 datReq->tbInfo[0].lchInfo[0].mBuf[0] = dlSf->raRsp[idx].rar;
340 #ifdef TFU_ALLOC_EVENT_NO_INIT
341 datReq->tbInfo[1].lchInfo[0].mBuf[0] = NULLP;
342 datReq->tbInfo[1].tbPres = FALSE;
344 datReq->tbInfo[0].numLch = 1;
345 datReq->tbInfo[0].lchInfo[0].numPdu = 1;
346 // prc_trace_format_string(0x40,3,"UE Id=(%d) tbSz=(%d)",datReq->rnti, datReq->tbInfo[0].tbSize);
348 cmLListAdd2Tail(&datInfo->pdus, &(datReq->lnk));
349 datReq->lnk.node = (PTR)datReq;
351 /* ccpu00132314-ADD- Adding txPower offset for the PDSCH transmission */
352 datReq->txPwrOffset = dlSf->raRsp[idx].txPwrOffset;
354 dlSf->raRsp[idx].rar = NULLP;
357 /* Fill Dedicated UE data */
358 if (dlSf->tbs.count != 0)
361 while (dlSf->tbs.first)
363 node = dlSf->tbs.first;
364 hqCb = (RgDlHqProcCb*)node->node;
365 if ((ret = rgDHMSndDatReq (cellCb, dlSf, datInfo, hqCb, err)) != ROK)
367 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
368 "DHM unable to fill DATA request");
369 err->errType = RGERR_TOM_TTIIND;
376 } /* end of rgTOMUtlFillDatReqPdus*/
378 /** @brief This function does all the processing related to a single downlink
383 * Function: rgTOMUtlProcDlSf
386 * - collate control data for all UEs and send to PHY
387 * - collate data buffers for all UEs and send to PHY
389 * @param [in] RgDlSf *dlSf
390 * @param [in] RgCellCb *cellCb
391 * @param [out] RgErrInfo *err
394 /* ADD Changes for Downlink UE Timing Optimization */
395 #ifndef LTEMAC_DLUE_TMGOPTMZ
397 PRIVATE S16 rgTOMUtlProcDlSf
404 PRIVATE S16 rgTOMUtlProcDlSf (dlSf, cellCb, err)
411 PUBLIC S16 rgTOMUtlProcDlSf
418 PUBLIC S16 rgTOMUtlProcDlSf (dlSf, cellCb, err)
426 TfuDatReqInfo *datInfo;
427 Inst inst = cellCb->macInst - RG_INST_START;
429 TRC2(rgTOMUtlProcDlSf);
431 /* Fill Data Request Info from scheduler to PHY */
432 if ((ret = rgAllocEventMem(inst,(Ptr *)&datInfo,
433 sizeof(TfuDatReqInfo))) != ROK)
435 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,"Unable to Allocate TfuDatReqInfo");
440 cmLListInit(&datInfo->pdus);
442 RGADDTOCRNTTIME(dlSf->schdTime, datInfo->timingInfo, TFU_DELTA);
444 RGADDTOCRNTTIME(dlSf->schdTime, datInfo->timingInfo, TFU_DLDATA_DLDELTA);
446 datInfo->cellId = cellCb->cellId;
447 if((0 == (datInfo->timingInfo.sfn % 30)) && (0 == datInfo->timingInfo.subframe))
449 //printf("5GTF_CHECK rgTOMUtlProcDlSf dat (%d : %d)\n", datInfo->timingInfo.sfn, datInfo->timingInfo.subframe);
451 #ifdef TFU_ALLOC_EVENT_NO_INIT
452 datInfo->bchDat.pres = 0;
456 if (dlSf->bch.tb != NULLP)
458 datInfo->bchDat.pres = PRSNT_NODEF;
459 datInfo->bchDat.val = dlSf->bch.tb;
460 dlSf->bch.tb = NULLP;
463 /* Fill the DLSCH PDUs of BCCH, PCCH and Dedicated Channels */
464 if ((ret = rgTOMEmtcUtlFillDatReqPdus(datInfo, dlSf, cellCb, err)) != ROK)
466 RG_FREE_MEM(datInfo);
470 /* Fill the DLSCH PDUs of BCCH, PCCH and Dedicated Channels */
471 if ((ret = rgTOMUtlFillDatReqPdus(datInfo, dlSf, cellCb, err)) != ROK)
473 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,"Unable to send data for cell");
474 RG_FREE_MEM(datInfo);
477 if((datInfo->pdus.count) || (datInfo->bchDat.pres == TRUE))
479 /* sending the data to Phy */
480 if (rgLIMTfuDatReq(inst,datInfo) != ROK)
482 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,"Unable to send data info for cell");
487 /* Nothing to send: free the allocated datInfo */
488 RG_FREE_MEM(datInfo);
497 * @brief Handler for processing TTI indication recieved from
502 * Function: rgTOMTtiInd
504 * Handler for processing TTI indication recieved from PHY
507 * Invoked by: RgLiTfuTtiInd
510 * - Get cell and update the cell's current time with the timing value given
512 * - Invoke the cmPrcTmr to process the timing queue.
513 * - Append the PHICH information to the downlink subframe that needs to go
514 * out to PHY in this subframe.
515 * - Invoke DHM to release the downlink subframe that occured earlier
516 * rgDHMRlsDlsfHqProc.
517 * - Invoke the TTI handler of scheduler.
518 * - Invoke the TTI handler of RAM module.
519 * - Get the downlink subframe that has to go out to PHY in this subframe
521 * - Invoke rgTOMUtlProcTA to perform and timing advance processing.
522 * - Invoke rgTOMUtlProcDlSf to do further processing on the downlink
524 * - Get the downlink subframe that would occur after RG_DL_DELTA and
525 * invoke rgTOMUtlProcDlSfStaInd to send status indications to the higher
527 * - Invoke GOM's TTI handler rgGOMTtiHndlr
528 * - Invoke COM's TTI handler rgCOMTtiHndlr
530 * @param[in] Inst inst
531 * @param[in] TfuTtiIndInfo *ttiInd
536 #if (defined (MAC_FREE_RING_BUF) || defined (RLC_FREE_RING_BUF))
537 pthread_t gMacTId = 0;
540 PUBLIC S16 rgTOMTtiInd
543 TfuTtiIndInfo *ttiInfo
546 PUBLIC S16 rgTOMTtiInd(inst, ttiInfo)
548 TfuTtiIndInfo *ttiInfo;
554 /* ADD Changes for Downlink UE Timing Optimization */
555 #ifdef LTEMAC_DLUE_TMGOPTMZ
557 CmLteTimingInfo prevTmInfo;
559 TfuTtiCellInfo *ttiInd = &ttiInfo->cells[0];
563 #ifdef MAC_FREE_RING_BUF
564 gMacTId = pthread_self();
566 cellCb = rgCb[inst].cell;
567 if ((cellCb == NULLP)
568 ||(cellCb->cellId != ttiInd->cellId))
571 RLOG_ARG0(L_ERROR,DBG_CELLID,ttiInd->cellId,
572 "Unable to get the cellCb for cell");
573 err.errType = RGERR_TOM_TTIIND;
574 err.errCause = RGERR_TOM_INV_CELL_ID;
577 RGCPYTIMEINFO(ttiInd->timingInfo, cellCb->crntTime);
578 if((0 == (ttiInd->timingInfo.sfn % 30)) && (0 == ttiInd->timingInfo.sfn))
580 //printf("5GTF_CHECK rgTOMTtiInd (%d : %d)\n", ttiInd->timingInfo.sfn, ttiInd->timingInfo.subframe);
582 rgMacGT = (ttiInd->timingInfo.sfn * RG_NUM_SUB_FRAMES_5G) + ttiInd->timingInfo.subframe;
585 /*Included to track the number of 10240 cycles completed */
587 if((cellCb->crntTime.sfn == 0) && (cellCb->crntTime.subframe==0))
589 cellCb->ttiCycle += 1;
594 /*Check if we have transmitted the previous DL SF, it could be the
595 case that we haven't received all the DATA from RLC as yet
596 and thus we would not have transmitted previous DL SF yet.*/
597 /* ADD Changes for Downlink UE Timing Optimization */
598 #ifdef LTEMAC_DLUE_TMGOPTMZ
599 RGSUBFRMCRNTTIME(ttiInd->timingInfo, prevTmInfo, 1);
600 prevDlSf = &cellCb->subFrms[(prevTmInfo.subframe % RG_NUM_SUB_FRAMES)];
601 if(FALSE == prevDlSf->txDone)
603 if (ROK != rgTOMUtlProcDlSf (prevDlSf, cellCb, &err))
605 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,"Unable to process "
606 "previous downlink subframe for cell");
607 err.errType = RGERR_TOM_TTIIND;
610 /* Mark this frame as sent */
611 prevDlSf->txDone = TRUE;
613 if(prevDlSf->remDatReqCnt)
615 /*We have not received 1 or more data requests from RLC, this is
616 error scenario. MAC & SCH need to discard the allocations for
617 which data request hasn't been received as yet. And MAC
618 needs to inform SCH about the list of UEs for which
619 allocation need to be discarded. */
620 prevDlSf->remDatReqCnt = 0;
624 dlSf = &cellCb->subFrms[(ttiInd->timingInfo.subframe % RG_NUM_SUB_FRAMES)];
626 if((dlSf->txDone == TRUE) ||
627 (!RG_TIMEINFO_SAME(ttiInd->timingInfo,dlSf->schdTime)))
630 #ifndef LTEMAC_DLUE_TMGOPTMZ
631 TfuDatReqInfo *datInfo;
632 CmLteTimingInfo timingInfo;
633 #ifdef TFU_DL_DELTA_CHANGE
634 RGADDTOCRNTTIME(cellCb->crntTime, timingInfo, TFU_DLDATA_DLDELTA);
636 RGADDTOCRNTTIME(cellCb->crntTime, timingInfo, TFU_DELTA);
638 /* Fill Data Request from MAC for BCH */
639 if ((timingInfo.sfn % 4 == 0) && (timingInfo.subframe == 0))
641 if (ROK != rgAllocEventMem(inst,(Ptr *)&datInfo,
642 sizeof(TfuDatReqInfo)))
644 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
645 "rgTOMUtlProcDlSf() Unable to Allocate TfuDatReqInfo for cell");
650 cmLListInit(&datInfo->pdus);
651 datInfo->cellId = cellCb->cellId;
652 datInfo->bchDat.pres = NOTPRSNT;
653 datInfo->timingInfo = timingInfo;
656 /* sending the dummy data req to Phy */
657 if (rgLIMTfuDatReq(inst,datInfo) != ROK)
659 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
660 "rgTOMUtlProcDlSf() Unable to send data info for cell");
666 /* Freeing as the part of CL Non RT Indication */
667 /* TDOD : Generalize for all SOCs */
668 #if !(defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD))
669 rgDHMFreeTbBufs(inst);
674 /*Return if there is still some data to be received
675 from RLC for this DL SF. */
676 /* ADD Changes for Downlink UE Timing Optimization */
677 #ifdef LTEMAC_DLUE_TMGOPTMZ
678 if(0 != dlSf->remDatReqCnt)
680 /* Freeing as the part of CL Non RT Indication */
681 /* TODO : Generalize for all SOCs and remove this flag */
682 #if !(defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD))
683 rgDHMFreeTbBufs(inst);
689 #ifdef XEON_SPECIFIC_CHANGES
690 CM_MEAS_TIME((ttiInd->timingInfo.subframe % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_DL_BR_PRC);
693 if (ROK != rgTOMUtlProcDlSf (dlSf, cellCb, &err))
695 RLOG_ARG0(L_ERROR,DBG_CELLID,ttiInd->cellId,
696 "Unable to process downlink subframe for cell");
697 err.errType = RGERR_TOM_TTIIND;
699 #ifdef XEON_SPECIFIC_CHANGES
700 CM_MEAS_TIME((ttiInd->timingInfo.subframe % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_DL_AFTER_PRC);
703 /* Mark this frame as sent */
706 /* Freeing as the part of CL Non RT Indication */
707 /* TODO : Generalize for all SOCs and remove this flag */
708 #if !(defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD))
709 rgDHMFreeTbBufs(inst);
714 /** @brief This function allocates the RgMacPdu that will be populated by DEMUX
715 * with the SubHeaders list and the values of the Control elements.
719 * Function: rgTOMUtlAllocPduEvnt
722 * @param[in] Inst inst
723 * @param [out] RgMacPdu **pdu
730 PRIVATE S16 rgTOMUtlAllocPduEvnt
736 PRIVATE S16 rgTOMUtlAllocPduEvnt (inst,pdu)
743 RgUstaDgn dgn; /* Alarm diagnostics structure */
744 VOLATILE U32 startTime=0;
746 TRC2(rgTOMUtlAllocPduEvnt);
748 evntMem.region = rgCb[inst].rgInit.region;
749 evntMem.pool = rgCb[inst].rgInit.pool;
752 SStartTask(&startTime, PID_TOMUTL_CMALLCEVT);
754 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
755 MS_BUF_ADD_ALLOC_CALLER();
758 if (cmAllocEvnt (sizeof (RgMacPdu), RG_BLKSZ, &evntMem, (Ptr*)pdu) != ROK)
760 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
761 rgLMMStaInd(inst,LCM_CATEGORY_RESOURCE, LCM_EVENT_DMEM_ALLOC_FAIL,
762 LCM_CAUSE_MEM_ALLOC_FAIL, &dgn);
763 RLOG0(L_ERROR,"Allocation of DUX event failed");
768 SStopTask(startTime, PID_TOMUTL_CMALLCEVT);
773 /** @brief This function frees up the RgMacPdu structure that has been
774 * populated by demux.
778 * Function: rgTOMUtlFreePduEvnt
779 * - Function frees up the RgMacPdu structure, in case of error it shall
780 * free up the buffer's present in the different sdu.
783 * @param [in] Inst inst
784 * @param [in] RgMacPdu *pdu
785 * @param [in] Bool *error
789 PRIVATE Void rgTOMUtlFreePduEvnt
795 PRIVATE Void rgTOMUtlFreePduEvnt (pdu, error)
804 TRC2(rgTOMUtlFreePduEvnt);
805 /* Steps of freeing up the PDU.
806 * 1. loop through the subHdrLst and free up all the buffers.
807 * 2. free up the whole event
809 if ((error == TRUE) && (pdu->sduLst.count > 0))
811 node = pdu->sduLst.first;
814 sdu = (RgMacSdu*)node->node;
815 RG_FREE_MSG(sdu->mBuf);
821 } /* end of rgTOMUtlFreePduEvnt */
823 /** @brief This function allocates the RgMacPdu that will be populated by DEMUX
824 * with the SubHeaders list and the values of the Control elements.
828 * Function: rgTOMInfAllocPduEvnt
831 * @param [in] Inst inst
832 * @param [out] RgMacPdu **pdu
839 PRIVATE S16 rgTOMInfAllocPduEvnt
842 RgInfSfDatInd **sfInfo
845 PRIVATE S16 rgTOMInfAllocPduEvnt (inst,sfInfo)
847 RgInfSfDatInd **sfInfo;
852 RgUstaDgn dgn; /* Alarm diagnostics structure */
853 VOLATILE U32 startTime=0;
855 TRC2(rgTOMInfAllocPduEvnt);
857 evntMem.region = rgCb[inst].rgInit.region;
858 evntMem.pool = rgCb[inst].rgInit.pool;
861 SStartTask(&startTime, PID_TOMINF_CMALLCEVT);
863 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
864 MS_BUF_ADD_ALLOC_CALLER();
866 if (cmAllocEvnt (sizeof (RgInfSfDatInd), RG_BLKSZ, &evntMem, (Ptr*)sfInfo) != ROK)
868 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
869 rgLMMStaInd(inst,LCM_CATEGORY_RESOURCE, LCM_EVENT_DMEM_ALLOC_FAIL,
870 LCM_CAUSE_MEM_ALLOC_FAIL, &dgn);
871 RLOG0(L_ERROR,"Allocation failed");
876 SStopTask(startTime, PID_TOMINF_CMALLCEVT);
881 /** @brief This function frees up the RgMacPdu structure that has been
882 * populated by demux.
886 * Function: rgTOMInfFreePduEvnt
887 * - Function frees up the RgMacPdu structure, in case of error it shall
888 * free up the buffer's present in the different sdu.
891 * @param [in] RgMacPdu *pdu
892 * @param [in] Bool *error
896 PRIVATE Void rgTOMInfFreePduEvnt
898 RgInfSfDatInd *sfInfo
901 PRIVATE Void rgTOMInfFreePduEvnt (sfInfo)
902 RgInfSfDatInd *sfInfo;
905 TRC2(rgTOMInfFreePduEvnt);
909 } /* end of rgTOMUtlFreePduEvnt */
913 /** @brief This function performs the preparation of information needed to set
914 * L2M Scheduled UL Throughput Information for a particular UE.
918 * Function: rgTomUtlPrepareL2MUlThrpInfo
919 * This function performs the preparation of information needed to set
920 * L2M Scheduled UL Throughput Information for a particular UE.
924 * @param [in] RgCellCb *cellCb
925 * @param [in] RgUeCb *ueCb
926 * @param [out] RgRguDedDatInd *dDatInd
930 PRIVATE S16 rgTomUtlPrepareL2MUlThrpInfo
934 RgRguDedDatInd *dDatInd
937 PRIVATE S16 rgTomUtlPrepareL2MUlThrpInfo(cellCb,ueCb,dDatInd)
940 RgRguDedDatInd *dDatInd;
946 TRC2(rgTomUtlPrepareL2MUlThrpInfo);
948 dDatInd->burstInd = RGU_L2M_UL_BURST_END;
949 for(loop=0;loop<dDatInd->numLch;loop++)
951 lcId=dDatInd->lchData[loop].lcId;
954 lcgId = ueCb->ul.lcCb[lcId - 1].lcgId;
955 if(ueCb->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs > 0)
957 dDatInd->burstInd = RGU_L2M_UL_BURST_START;
968 /** @brief This function is called by rgTOMDatInd. This function invokes the
969 * scheduler with the information of the received Data and any Control Elements
970 * if present. Also it generates Data indications towards the higher layers.
977 * - Retrieves the RaCb with the rnti provided, if it doesnt exist
979 * - If UE exists then update the Schduler with any MAC CEs if present.
980 * - Invoke RAM module to do Msg3 related processing rgRAMProcMsg3
981 * - Loop through the SDU subheaders and invoke either a common data
982 * indication (rgUIMSndCmnDatInd) or dedicated data indication
983 * (rgUIMSndDedDatInd) towards the higher layers.
985 * @param [in] RgCellCb *cellCb
986 * @param [in] RgUeCb *ueCb
987 * @param [in] CmLteRnti rnti
988 * @param [in] RgMacPdu *pdu
989 * @param [out] U32 *lcgBytes
1000 PRIVATE S16 rgTOMUtlProcMsg
1006 Bool *spsToBeActvtd,
1012 PRIVATE S16 rgTOMUtlProcMsg(cellCb, ueCb, pdu, isSpsRnti,spsToBeActvtd,sduSize, subframe, lcgBytes)
1017 Bool *spsToBeActvtd;
1022 #else /* LTEMAC_SPS */
1024 PRIVATE S16 rgTOMUtlProcMsg
1033 PRIVATE S16 rgTOMUtlProcMsg(cellCb, ueCb, pdu, subframe, lcgBytes)
1042 Inst inst = cellCb->macInst - RG_INST_START;
1044 RgRguCmnDatInd *cDatInd;
1045 RgRguDedDatInd *dDatInd;
1052 // RgInfSpsRelInfo relInfo;
1059 U16 totalBytesRcvd = 0;
1060 U16 sduLen[RGU_MAX_LC] = {0};
1061 U8 qciVal[RGU_MAX_LC] = {0};
1068 /* Moved outside of LTE_L2_MEAS
1069 * scope as this pointer will now be used to
1070 * check for valid Logical Channel ID
1087 TRC2(rgTOMUtlProcMsg)
1093 if(pdu->sduLst.first)
1095 sdu = (RgMacSdu*)(pdu->sduLst.first->node);
1097 if ((sdu->lcId == RG_CCCH_LCID))
1099 /* code for common channel dat indications */
1100 if ((ret = rgAllocShrablSBuf (inst,(Data**)&cDatInd, sizeof(RgRguCmnDatInd))) != ROK)
1104 cDatInd->cellId = cellCb->cellId;
1105 cDatInd->rnti = ueCb->ueId;
1106 /* rg001.101: Corrected lcId value for common data indication */
1107 cDatInd->lcId = cellCb->ulCcchId;
1108 cDatInd->pdu = sdu->mBuf;
1109 SFndLenMsg (sdu->mBuf, &ccchSz);
1110 /* Fix : syed Contention resolution ID copy should consider only
1111 * 6 bytes of information from sdu->mBuf. Incase of CCCH sdu for reest
1112 * message/psuedo reest message, ccchSz can go beyond 6 and can corrupt
1113 * other fields of ueCb. */
1114 if (ccchSz >= RG_CRES_LEN)
1116 SCpyMsgFix (sdu->mBuf, (MsgLen)0, RG_CRES_LEN, ueCb->contResId.resId,
1119 #ifdef XEON_SPECIFIC_CHANGES
1120 CM_LOG_DEBUG(CM_LOG_ID_MAC, "CCCH SDU of size(%d) received for UE(%d) CRES[0x%x 0x%x 0x%x 0x%x 0x%x 0x%x] Time[%d %d]\n", ((S16)ccchSz), ueCb->ueId,ueCb->contResId.resId[0], ueCb->contResId.resId[1], ueCb->contResId.resId[2], ueCb->contResId.resId[3], ueCb->contResId.resId[4], ueCb->contResId.resId[5], cellCb->crntTime.sfn, cellCb->crntTime.subframe);
1123 rgUIMSndCmnDatInd(inst,cellCb->rguUlSap,cDatInd);
1125 } /* end of common channel processing */
1127 if ((ret = rgAllocShrablSBuf (inst,(Data**)&dDatInd, sizeof(RgRguDedDatInd))) != ROK)
1133 elem = SRngGetWIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
1138 dDatInd = (RgRguDedDatInd *)elem;
1139 cmMemset((U8 *)dDatInd, 0x00, sizeof(RgRguDedDatInd));
1141 dDatInd->cellId = cellCb->cellId;
1142 dDatInd->rnti = ueCb->ueId;
1143 dDatInd->numLch = 0;
1146 ulSf = &cellCb->ulSf[(subframe % RG_NUM_SUB_FRAMES)];
1147 if(ulSf->ueUlAllocInfo != NULLP)
1149 for(idx1 = 0; idx1 < ulSf->numUe; idx1++)
1151 if(ulSf->ueUlAllocInfo[idx1].rnti == ueCb->ueId)
1153 numPrb = ulSf->ueUlAllocInfo[idx1].numPrb;
1159 node = pdu->sduLst.first;
1162 sdu = (RgMacSdu*)node->node;
1164 ulLcCb = rgDBMGetUlDedLcCb (ueCb, sdu->lcId);
1168 RLOG_ARG2(L_ERROR,DBG_CELLID,cellCb->cellId,"Unconfigured LCID:%d CRNTI:%d"
1169 ,sdu->lcId,ueCb->ueId);
1170 /* ccpu00128443: Fix for memory leak */
1171 /* Fix : syed Neccessary to set sdu->mBuf = NULLP */
1172 RG_FREE_MSG(sdu->mBuf);
1176 #ifdef RLC_STA_PROC_IN_MAC/* RLC Status PDU Processing */
1178 extern S16 kwProcDlStatusPdu(Pst *udxPst,SuId suId,
1179 CmLteCellId cellId,CmLteRnti rnti,CmLteLcId lcId,Buffer *rlcSdu);
1181 if(ROK == kwProcDlStatusPdu(&(cellCb->rguDlSap->sapCfg.sapPst),
1182 cellCb->rguDlSap->sapCfg.suId,
1183 cellCb->cellId,ueCb->ueId,sdu->lcId,sdu->mBuf))
1185 RG_FREE_MSG(sdu->mBuf);
1192 /* ccpu00116477- Fixed the rgUIMSndDedDatInd condition when we receive 11 sdus in the
1193 * list we are losing 11th sdu and sending the first 10 sdus again which
1194 * is causing the duplicate packets and eNB crashing due to access
1195 * of the freed memory */
1196 if (dDatInd->numLch >= RGU_MAX_LC)
1198 if ((ret = rgUIMSndDedDatInd(inst,ueCb->rguUlSap,dDatInd)) != ROK)
1200 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
1201 "Failed to send datIndication to RGU CRNTI:%d",ueCb->ueId);
1205 if ((ret = rgAllocShrablSBuf (inst,(Data**)&dDatInd, sizeof(RgRguDedDatInd))) != ROK)
1210 elem = SRngGetWIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
1215 dDatInd = (RgRguDedDatInd *)elem;
1216 cmMemset((U8 *)dDatInd, 0x00, sizeof(RgRguDedDatInd));
1218 dDatInd->cellId = cellCb->cellId;
1219 dDatInd->rnti = ueCb->ueId;
1220 dDatInd->numLch = 0;
1222 dDatInd->lchData[dDatInd->numLch].lcId = sdu->lcId;
1223 dDatInd->lchData[dDatInd->numLch].pdu.mBuf[dDatInd->lchData[dDatInd->numLch].pdu.numPdu] = sdu->mBuf;
1224 dDatInd->lchData[dDatInd->numLch].pdu.numPdu++;
1225 lcgId = ulLcCb->lcgId;
1226 SFndLenMsg(sdu->mBuf, &bufSz);
1230 ueCb->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs -= bufSz;
1233 //if ((lcgBytes != NULLP) && (ueCb->ul.lcgArr[lcgId].isGbr == TRUE))
1234 if (lcgBytes != NULLP)
1236 lcgBytes[lcgId] += bufSz;
1241 /* Check if data has come on SPS LC */
1242 /* KWORK_FIX: Modified the index from lcId to lcId-1 for handling lcId 10 properly */
1243 if (ueCb->ul.spsLcId[sdu->lcId-1] == TRUE)
1245 ueCb->ul.spsDatRcvd++;
1250 /* Data rcvd on CRNTI*/
1251 /* Retrieve the LCG ID of the LCID*/
1252 /* SPS LCG has data whose size > SID Size */
1253 /* Activate SPS if data recvd on SPS LCID and size > SID Packet Size */
1254 if((ueCb->ul.spsLcId[sdu->lcId-1] == TRUE) &&
1255 (sdu->len > RG_SPS_SID_PACKET_SIZE))
1257 *spsToBeActvtd = TRUE;
1258 *sduSize = sdu->len;
1265 if(cellCb->qciArray[ulLcCb->qci].mask == TRUE)
1267 sduLen[ulLcCb->qci] = sdu->len;
1268 totalBytesRcvd += sdu->len;
1269 qciVal[ulLcCb->qci] = ulLcCb->qci;
1273 } /* end of while for SubHeaders */
1275 for(idx2 = 0; idx2 < RGU_MAX_LC; idx2++)
1277 if((cellCb->qciArray[qciVal[idx2]].mask == TRUE) &&
1280 cellCb->qciArray[qciVal[idx2]].prbCount +=
1281 ((numPrb * sduLen[idx2]) / totalBytesRcvd);
1285 if(totalBytesRcvd > 0 && qciVal[idx2] > 0)
1287 RG_UPD_GBR_PRB(cellCb, qciVal[idx2], ((numPrb * sduLen[idx2])/totalBytesRcvd));
1292 /*Added for explicit release - start*/
1295 if(isSpsRnti && dDatInd && dDatInd->numLch)
1297 if(ueCb->ul.spsDatRcvd != 0)
1299 ueCb->ul.explRelCntr = 0;
1300 ueCb->ul.spsDatRcvd = 0;
1304 ueCb->ul.explRelCntr++;
1305 if (ueCb->ul.explRelCntr == ueCb->ul.explRelCnt)
1307 ueCb->ul.explRelCntr = 0;
1308 /* Indicate scheduler for explicit release */
1309 cmMemset((U8*)&schPst1, (U8)0, sizeof(Pst));
1310 rgGetPstToInst(&schPst1,inst, cellCb->schInstMap.schInst);
1311 //TODO: commented for compilation without SCH
1313 relInfo.cellSapId = cellCb->schInstMap.cellSapId;
1314 relInfo.cRnti = ueCb->ueId;
1315 relInfo.isExplRel = TRUE;
1316 /* Release indicator is called now through the matrix in the function below */
1317 //TODO: commented for compilation without SCH RgMacSchSpsRel( &schPst1, &relInfo );
1319 ueCb->ul.implRelCntr = 0;
1326 if(ueCb->ul.spsDatRcvd != 0)
1328 //ueCb->ul.implRelCntr = 0;
1329 ueCb->ul.explRelCntr = 0;
1330 ueCb->ul.spsDatRcvd = 0;
1334 /*Added for explicit release - end */
1336 if((dDatInd) && (dDatInd->numLch))
1339 rgTomUtlPrepareL2MUlThrpInfo(cellCb, ueCb,dDatInd);
1341 RG_CALC_TTI_CNT(cellCb, dDatInd->ttiCnt);
1343 if ((ret = rgUIMSndDedDatInd(inst,ueCb->rguUlSap,dDatInd)) != ROK)
1345 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
1346 "Failed to send datIndication to RGU CRNTI:%d",ueCb->ueId);
1351 else if((dDatInd) && (0 == dDatInd->numLch))
1353 /* Free the memory allocated for dDatInd if we
1354 * have no valid LCH PDU to send to RLC.*/
1355 rgFreeSharableSBuf(inst,(Data **)&dDatInd,sizeof(RgRguDedDatInd));
1361 /** @brief This function frees up the RgMacPdu structure that has been
1362 * populated by demux.
1366 * Function: rgTOMUtlInsSchInfo
1367 * - Function frees up the RgMacPdu structure, in case of error it shall
1368 * free up the buffer's present in the different sdu.
1371 * @param [in] RgMacPdu *pdu
1372 * @param [in] Bool *error
1377 PRIVATE S16 rgTOMUtlInsSchInfo
1380 RgInfSfDatInd *sfInfo,
1381 RgInfCeInfo *ceInfo,
1388 PRIVATE S16 rgTOMUtlInsSchInfo (pdu, sfInfo, ceInfo, rnti,spsToBeActvtd,sduSize, lcgBytes)
1390 RgInfSfDatInd *sfInfo;
1391 RgInfCeInfo *ceInfo;
1400 PRIVATE S16 rgTOMUtlInsSchInfo
1403 RgInfSfDatInd *sfInfo,
1404 RgInfCeInfo *ceInfo,
1409 PRIVATE S16 rgTOMUtlInsSchInfo (pdu, sfInfo, ceInfo, rnti, lcgBytes)
1411 RgInfSfDatInd *sfInfo;
1412 RgInfCeInfo *ceInfo;
1419 RgInfUeDatInd *ueInfo;
1423 TRC2(rgTOMUtlInsSchInfo);
1425 RG_TOM_INF_ALLOC(sfInfo, sizeof(RgInfUeDatInd), ueInfo, ret);
1432 ueInfo->rnti = rnti;
1434 ueInfo->ceInfo = *ceInfo;
1435 ueInfo->ueLstEnt.node = (PTR)ueInfo;
1436 for (lcgId = 1, idx = 0; lcgId < RGINF_MAX_LCG_PER_UE; lcgId++)
1438 if (lcgBytes[lcgId] != 0)
1440 /* Only GBR bytes */
1441 ueInfo->lcgInfo[idx].lcgId = lcgId;
1442 ueInfo->lcgInfo[idx++].bytesRcvd = lcgBytes[lcgId];
1443 lcgBytes[lcgId] = 0;
1446 cmLListAdd2Tail(&sfInfo->ueLst, &ueInfo->ueLstEnt);
1448 } /* end of rgTOMUtlInsSchInfo */
1452 * @brief Handler for processing data indication recieved from PHY for UEs.
1456 * Function: rgTOMDatInd
1458 * Handler for processing data indication recieved from PHY for UEs.
1460 * Invoked by: RgLiTfuDatInd of LIM
1463 * For each DataInfo recieved
1464 * - Validate the information received and retrieve cellCb
1465 * Validate cellId, rnti
1466 * - Call De-Mux module to decode the data rgDUXDemuxData
1467 * - If received a CRNTI control element
1468 * - Check if a CCCH SDU is present, if it is return failure
1469 * - Check for the existence of UE, if its isnt present return failure.
1470 * - Delegate the remaining processing to rgTOMUtlProcMsg3 which
1471 * primarily informs the scheduler about the data received and
1472 * generates Data indications towards the higher layer.
1473 * - If only CCCH SDU is present
1474 * - Invoke rgTOMUtlProcMsg3 for further processing.
1475 * - If its a non-Msg3 PDU i.e. received outside of a RA procedure
1476 * - Retrieve the UeCB
1477 * - Validate that the received PDU contains only configured Logical
1479 * - Invoke rgTOMUtlProcDatPdu for further processing. It informs the
1480 * scheduler with the information of the received Data and generates
1481 * DatIndications towards the higher layers.
1483 * @param [in] Inst inst
1484 * @param[in] TfuDatIndInfo *datInd
1490 PUBLIC S16 rgTOMDatInd
1493 TfuDatIndInfo *datInd
1496 PUBLIC S16 rgTOMDatInd(inst,datInd)
1498 TfuDatIndInfo *datInd;
1504 RgUeCb *prevUeCb = NULLP;
1507 RgInfSfDatInd *sfInfo;
1511 TfuDatInfo *datInfo;
1515 Bool isSpsRnti=FALSE;
1517 RgInfSpsRelInfo relInfo;
1518 Bool spsToBeActvtd = FALSE;
1521 U32 lcgBytes[RGINF_MAX_LCG_PER_UE];
1525 #ifdef STUB_TTI_HANDLING_5GTF
1526 node = datInd->datIndLst.first;
1527 for (;node; node=node->next)
1529 datInfo = (TfuDatInfo*)node->node;
1532 SFndLenMsg(datInfo->mBuf, &len);
1533 rgUlrate_tfu += len;
1534 if (rgUlrate_tfu > 100000)
1536 printf("Sowmya:rgTOMDatInd datInfo->mBuf len =%d rgUlrate_tfu=%d",len,rgUlrate_tfu);
1544 cmMemset((U8 *)&lcgBytes, 0, sizeof(lcgBytes));
1546 tfuSap = &(rgCb[inst].tfuSap);
1548 cellCb = rgCb[inst].cell;
1549 if((cellCb == NULLP) ||
1550 (cellCb->cellId != datInd->cellId))
1553 RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"Unable to get the cellCb for cell");
1556 /* Avoiding memset as all the fields are getting initialized further */
1558 if (rgTOMInfAllocPduEvnt (inst,&sfInfo) != ROK)
1560 err.errType = RGERR_TOM_DATIND;
1561 RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"Unable to Allocate PDU for DUX cell");
1562 node = datInd->datIndLst.first;
1565 cmLListInit(&sfInfo->ueLst);
1566 sfInfo->cellId = datInd->cellId;
1567 sfInfo->timingInfo = datInd->timingInfo;
1568 subframe = datInd->timingInfo.subframe;
1570 node = datInd->datIndLst.first;
1571 for (;node; node=node->next)
1573 datInfo = (TfuDatInfo*)node->node;
1575 //extern U32 ulrate_tfu;
1577 SFndLenMsg(datInfo->mBuf, &len);
1578 #ifdef STUB_TTI_HANDLING_5GTF
1579 // printf("Sowmya:rgTOMDatInd datInfo->mBuf len =%d",len);
1581 rgUlrate_tfu += len;
1583 grgUlrate_tfu += len;
1586 #ifdef STUB_TTI_HANDLING_5GTF
1587 rgLIMUtlFreeDatIndEvnt(datInd,TRUE);
1589 /* We shall call De-Mux to process the received buffer. We shall try and find
1590 * out the RaCb based on the following -
1591 * 1. If the incoming PDU contained a CCCH SDU i.e. this is message 3.
1592 * 2. If the incoming PDU contained a CRNTI control element, i.e. we should
1593 * have a ueCb also for this
1595 /* Lets allocate the event that needs to be passed to DUX */
1596 if (rgTOMUtlAllocPduEvnt (inst,&pdu) != ROK)
1598 err.errType = RGERR_TOM_DATIND;
1599 RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"Unable to Allocate PDU for DUX cell");
1600 rgTOMInfFreePduEvnt (sfInfo);
1604 if ((ret = rgDUXDemuxData (inst,pdu, &ceInfo,
1605 &datInfo->mBuf, &err)) != ROK)
1608 /* Fix: sriky memory corruption precautions */
1609 rgTOMUtlFreePduEvnt (pdu, TRUE);
1610 err.errType = RGERR_TOM_DATIND;
1611 RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"DUX processing failed");
1612 tfuSap->sapSts.numPduDrop++;
1615 /* It could be that a non-msg3 pdu contains a CRNTI Control element. We
1616 * should check for CRNTI CE and if it exists the UECb must exist, also an
1617 * if the CRNTI in the CE and the one with which the message came in are
1618 * different we shall look for an raCb as well.
1621 if (ceInfo.bitMask & RG_CCCH_SDU_PRSNT)
1623 ret = rgTOMProcCCCHSduInDatInd(pdu, prevUeCb, \
1624 cellCb, datInfo, &ceInfo, subframe);
1627 rgTOMUtlFreePduEvnt (pdu, TRUE);
1628 err.errType = RGERR_TOM_DATIND;
1629 tfuSap->sapSts.numPduDrop++;
1632 } /* end of Msg3 processing */
1634 else if (ceInfo.bitMask & RG_CRNTI_CE_PRSNT)
1636 ret = rgTOMProcCrntiCEInDatInd(pdu, prevUeCb, \
1637 cellCb, datInfo, &ceInfo, subframe);
1640 rgTOMUtlFreePduEvnt (pdu, TRUE);
1641 err.errType = RGERR_TOM_DATIND;
1642 tfuSap->sapSts.numPduDrop++;
1646 } /* end of CRNTI based message */
1649 ueCb = rgDBMGetUeCb (cellCb, datInfo->rnti);
1653 /* Try getting the UE using SPS-RNTI. */
1654 ueCb = rgDBMGetSpsUeCb (cellCb, datInfo->rnti);
1658 /* Increment implrelCntr for an empty transmission */
1659 if (pdu->sduLst.count == 0)
1661 ueCb->ul.implRelCntr++;
1662 if (ueCb->ul.implRelCntr == ueCb->ul.implRelCnt)
1664 /* Indicate scheduler for implicit release */
1665 cmMemset((U8*)&schPst1, (U8)0, sizeof(Pst));
1666 rgGetPstToInst(&schPst1,inst, cellCb->schInstMap.schInst);
1668 ueCb->ul.implRelCntr = 0;
1669 ueCb->ul.explRelCntr = 0;
1670 relInfo.cellSapId = cellCb->schInstMap.cellSapId;
1671 relInfo.cRnti = ueCb->ueId;
1672 relInfo.isExplRel = FALSE;
1673 //TODO: commented for compilation without SCH RgMacSchSpsRel(&schPst1, &relInfo);
1678 /* Reset the implrelCntr */
1679 ueCb->ul.implRelCntr = 0;
1685 /* Perform failure if ueCb is still NULLP */
1686 rgTOMUtlFreePduEvnt (pdu, TRUE);
1687 err.errType = RGERR_TOM_DATIND;
1688 RLOG_ARG1(L_ERROR,DBG_CELLID,datInd->cellId,"RNTI:%d Unable to get the UE CB",
1690 tfuSap->sapSts.numPduDrop++;
1695 rgTOMUtlL2MStoreBufSz(ueCb, &ceInfo);
1696 rgTOML2MCompileActiveLCs (cellCb, ueCb, pdu, &ceInfo);
1699 if ((ret = rgTOMUtlProcMsg(cellCb, ueCb, pdu, isSpsRnti,&spsToBeActvtd,&sduSize, subframe, (U32 *)&lcgBytes)) != ROK)
1701 if ((ret = rgTOMUtlProcMsg (cellCb, ueCb, pdu, subframe, (U32 *)&lcgBytes)) != ROK)
1702 #endif /* LTEMAC_SPS */
1704 rgTOMUtlFreePduEvnt (pdu, TRUE);
1705 err.errType = RGERR_TOM_DATIND;
1706 RLOG_ARG1(L_ERROR,DBG_CELLID,datInd->cellId,
1707 "Unable to handle Data Indication CRNTI:%d",ueCb->ueId);
1708 tfuSap->sapSts.numPduDrop++;
1715 if(rgTOMUtlInsSchInfo(pdu, sfInfo, &ceInfo, datInfo->rnti,spsToBeActvtd,sduSize, (U32 *)&lcgBytes) != ROK)
1717 if(rgTOMUtlInsSchInfo(pdu, sfInfo, &ceInfo, datInfo->rnti, (U32 *)&lcgBytes) != ROK)
1721 rgTOMInfFreePduEvnt (sfInfo);
1722 rgTOMUtlFreePduEvnt (pdu, FALSE);
1725 /* free up the PDU memory */
1726 rgTOMUtlFreePduEvnt (pdu, FALSE);
1728 /* Free the allocated memory for ueUlAllocInfo here */
1730 if(cellCb->ulSf[(subframe % RG_NUM_SUB_FRAMES)].ueUlAllocInfo != NULLP)
1732 /*ccpu00117052 - MOD - Passing double for proper NULLP
1734 rgFreeSBuf(inst,(Data **)&(cellCb->ulSf[(subframe % RG_NUM_SUB_FRAMES)].ueUlAllocInfo),
1735 ((cellCb->ulSf[(subframe % RG_NUM_SUB_FRAMES)].numUe) * sizeof(RgUeUlAlloc)));
1739 /* Update PRB used for all GBR QCIs to scheduler */
1740 cmMemcpy((U8*) &sfInfo->qcisUlPrbCnt[0],
1741 (U8*) &cellCb->qcisUlPrbCnt[0],
1742 (RGM_MAX_QCI_REPORTS * sizeof(U32)));
1743 /* clear the cellCb ul prb value */
1744 cmMemset((U8*)&cellCb->qcisUlPrbCnt[0], 0,
1745 (RGM_MAX_QCI_REPORTS * sizeof(U32)));
1749 rgGetPstToInst(&schPst, inst,cellCb->schInstMap.schInst);
1750 sfInfo->cellSapId = cellCb->schInstMap.cellSapId;
1751 //TODO: commented for compilation without SCH RgMacSchSfRecp(&schPst, sfInfo);
1756 * @brief Function handles allocation for common channels i.e. BCCH-BCH,
1757 * BCCH-DLSCH, PCCH-DLSCH.
1761 * Function : rgHndlCmnChnl
1763 * This function is invoked from RgSchMacSfAllocReq. This function handles
1764 * allocations made for common channels like BCCH and PCCH.
1767 * 1. If BCCH on BCH has been scheduled, send StatusIndication on RGU.
1768 * 2. If PCCH is scheduled, send StatusIndication on RGU.
1769 * 3. If BCCH on DLSCH has been scheduled and sndStatInd is TRUE, send
1770 * StatusIndication on RGU, else copy the bcch buffer onto the downlink
1774 * @param[in] RgCellCb *cell,
1775 * @param[in] CmLteTimingInfo timingInfo,
1776 * @param[in] RgInfCmnLcInfo *cmnLcInfo,
1777 * @param[in/out] RgErrInfo *err,
1783 PRIVATE S16 rgHndlCmnChnl
1786 CmLteTimingInfo timingInfo,
1787 RgInfCmnLcInfo *cmnLcInfo,
1791 PRIVATE S16 rgHndlCmnChnl(cell, timingInfo, cmnLcInfo, err)
1793 CmLteTimingInfo timingInfo;
1794 RgInfCmnLcInfo *cmnLcInfo;
1798 #if (ERRCLASS & ERRCLS_DEBUG)
1802 RgBcchDlschLcCb *bcch;
1803 #if (ERRCLASS & ERRCLS_DEBUG)
1806 #endif/*RGR_SI_SCH*/
1807 RguCStaIndInfo *staInd;
1809 Inst inst = cell->macInst - RG_INST_START;
1813 dlSf = &cell->subFrms[(timingInfo.subframe % RG_NUM_SUB_FRAMES)];
1815 if(cmnLcInfo->bitMask & RGINF_BCH_INFO)
1818 #if (ERRCLASS & ERRCLS_DEBUG)
1819 if(NULLP == (bch = rgDBMGetBcchOnBch(cell)))
1823 if(cmnLcInfo->bchInfo.lcId != bch->lcId)
1829 if (rgAllocShrablSBuf (inst,(Data**)&staInd, sizeof(RguCStaIndInfo)) != ROK)
1831 err->errCause = RGERR_TOM_MEM_EXHAUST;
1834 staInd->cellId = cell->cellId;
1835 staInd->rnti = RG_INVALID_RNTI;
1836 staInd->lcId = cmnLcInfo->bchInfo.lcId;
1837 staInd->transId = (timingInfo.sfn << 8) | (timingInfo.subframe);
1838 /* ADD Changes for Downlink UE Timing Optimization */
1839 #ifdef LTEMAC_DLUE_TMGOPTMZ
1840 dlSf->remDatReqCnt++;
1842 if (rgUIMSndCmnStaInd (inst,cell->rguDlSap,staInd) != ROK)
1847 /*Store the received BCH Data in the scheduled subframe*/
1848 dlSf->bch.tb = cmnLcInfo->bchInfo.pdu;
1849 #endif/*RGR_SI_SCH*/
1852 if(cmnLcInfo->bitMask & RGINF_PCCH_INFO)
1854 #if (ERRCLASS & ERRCLS_DEBUG)
1855 if(NULLP == (pcch = rgDBMGetPcch(cell)))
1859 if(cmnLcInfo->pcchInfo.lcId != pcch->lcId)
1865 dlSf->pcch.pdcch.rnti =
1866 cmnLcInfo->pcchInfo.rnti;
1867 dlSf->pcch.pdcch.dci =
1868 cmnLcInfo->pcchInfo.dciInfo;
1870 /* ccpu00132314-ADD-Fill the tx Pwr offset from scheduler */
1871 dlSf->pcch.txPwrOffset = cmnLcInfo->pcchInfo.txPwrOffset;
1873 if (rgAllocShrablSBuf (inst,(Data**)&staInd, sizeof(RguCStaIndInfo)) != ROK)
1875 err->errCause = RGERR_TOM_MEM_EXHAUST;
1878 staInd->cellId = cell->cellId;
1879 staInd->rnti = RG_INVALID_RNTI;
1880 staInd->lcId = cmnLcInfo->pcchInfo.lcId;
1881 staInd->transId = (timingInfo.sfn << 8) | (timingInfo.subframe);
1882 /* ADD Changes for Downlink UE Timing Optimization */
1883 #ifdef LTEMAC_DLUE_TMGOPTMZ
1884 dlSf->remDatReqCnt++;
1886 /* for consolidated CmnStaInd calling below function from function
1887 * rgHndlSchedUe once CmnStaInd prepared for all UEs
1889 if (rgUIMSndCmnStaInd (inst,cell->rguDlSap,staInd) != ROK)
1895 if(cmnLcInfo->bitMask & RGINF_BCCH_INFO)
1897 dlSf->bcch.pdcch.rnti =
1898 cmnLcInfo->bcchInfo.rnti;
1899 dlSf->bcch.pdcch.dci =
1900 cmnLcInfo->bcchInfo.dciInfo;
1902 /* ccpu00132314-ADD-Fill the tx Pwr offset from scheduler */
1903 dlSf->bcch.txPwrOffset = cmnLcInfo->bcchInfo.txPwrOffset;
1907 (bcch=rgDBMGetBcchOnDlsch(cell,cmnLcInfo->bcchInfo.lcId)))
1911 if(TRUE == cmnLcInfo->bcchInfo.sndStatInd)
1913 RG_FREE_MSG(bcch->tb);
1914 if (rgAllocShrablSBuf (inst,(Data**)&staInd,
1915 sizeof(RguCStaIndInfo)) != ROK)
1917 err->errCause = RGERR_TOM_MEM_EXHAUST;
1920 staInd->cellId = cell->cellId;
1921 staInd->rnti = RG_INVALID_RNTI;
1922 staInd->lcId = cmnLcInfo->bcchInfo.lcId;
1923 staInd->transId = (timingInfo.sfn << 8) | (timingInfo.subframe);
1924 /* ADD Changes for Downlink UE Timing Optimization */
1925 #ifdef LTEMAC_DLUE_TMGOPTMZ
1926 dlSf->remDatReqCnt++;
1928 if (rgUIMSndCmnStaInd (inst,cell->rguDlSap,staInd) != ROK)
1935 SCpyMsgMsg(bcch->tb, RG_GET_MEM_REGION(rgCb[inst]),
1936 RG_GET_MEM_POOL(rgCb[inst]), &dlSf->bcch.tb);
1939 /*Store the received BCCH Data in the scheduled subframe*/
1940 dlSf->bcch.tb = cmnLcInfo->bcchInfo.pdu;
1941 #endif/*RGR_SI_SCH*/
1945 } /* end of rgHndlCmnChnl */
1948 * @brief Function for handling allocations for dedicated channels for a
1953 * Function : rgHndlSchdUe
1955 * This function shall be invoked whenever scheduler is done with the
1956 * allocations of dedicated channels for a subframe. Invoked by the function
1957 * RgSchMacSfAllocReq.
1959 * Processing steps :
1960 * 1. Loops through the list of UE's scheduled looking for the corresponding
1962 * 2. Finds the corresponding HARQ process.
1963 * 3. Invokes the DHM function to issue StatusIndications on RGU.
1966 * @param[in] RgCellCb *cell,
1967 * @param[in] CmLteTimingInfo timingInfo,
1968 * @param[in] RgInfUeInfo *ueInfo
1969 * @param[in/out] RgErrInfo *err
1975 PRIVATE S16 rgHndlSchdUe
1978 CmLteTimingInfo timingInfo,
1979 RgInfUeInfo *ueInfo,
1983 PRIVATE S16 rgHndlSchdUe(cell, timingInfo, ueInfo, err) /* laa_ut_fix */
1985 CmLteTimingInfo timingInfo;
1986 RgInfUeInfo *ueInfo;
1993 if(NULLP == ueInfo->allocInfo)
1998 rgDHMSndConsolidatedStaInd(cell, ueInfo, timingInfo, err);
2001 } /* end of rgHndlSchdUe */
2005 * @brief Function for handling Uplink allocations for Ue for a
2010 * Function : rgHndlUlUeInfo
2012 * @param[in] RgCellCb *cell,
2013 * @param[in] CmLteTimingInfo timingInfo,
2014 * @param[in] RgInfUlUeInfo *ueInfo
2020 PRIVATE S16 rgHndlUlUeInfo
2023 CmLteTimingInfo timingInfo,
2024 RgInfUlUeInfo *ueInfo
2027 PRIVATE S16 rgHndlUlUeInfo(cell, timingInfo, ueInfo)
2029 CmLteTimingInfo timingInfo;
2030 RgInfUlUeInfo *ueInfo;
2033 Inst inst = cell->macInst - RG_INST_START;
2038 TRC2(rgHndlUlUeInfo)
2040 ulSf = &cell->ulSf[(timingInfo.subframe % RGSCH_NUM_SUB_FRAMES)];
2042 /* rg003.301-MOD- Corrected the purifier memory leak */
2043 if (ulSf->numUe != ueInfo->numUes)
2045 if (ulSf->ueUlAllocInfo)
2047 rgFreeSBuf(inst,(Data **)&(ulSf->ueUlAllocInfo),
2048 ulSf->numUe * sizeof(RgUeUlAlloc));
2051 #ifdef XEON_SPECIFIC_CHANGES
2052 CM_MEAS_TIME((cell->crntTime.subframe % RGSCH_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MEAS_FREE);
2053 CM_ADD_INFO((cell->crntTime.subframe % RGSCH_NUM_SUB_FRAMES), CM_DBG_MEAS_FREE, ulSf->numUe);
2055 ulSf->numUe = ueInfo->numUes;
2056 if((ulSf->ueUlAllocInfo == NULLP) && (ueInfo->numUes > 0))
2058 /* Allocate memory for ulAllocInfo */
2059 if((ret = rgAllocSBuf(inst,(Data**)&(cell->ulSf[(timingInfo.subframe % RGSCH_NUM_SUB_FRAMES)].
2060 ueUlAllocInfo), ueInfo->numUes * sizeof(RgUeUlAlloc))) != ROK)
2065 #ifdef XEON_SPECIFIC_CHANGES
2066 CM_MEAS_TIME((cell->crntTime.subframe % RGSCH_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MEAS_ALLOC);
2067 CM_ADD_INFO((cell->crntTime.subframe % RGSCH_NUM_SUB_FRAMES), CM_DBG_MEAS_ALLOC, ueInfo->numUes);
2069 if (ulSf->ueUlAllocInfo != NULLP)
2071 for(idx = 0; idx < ueInfo->numUes; idx++)
2073 ulSf->ueUlAllocInfo[idx].rnti = ueInfo->ulAllocInfo[idx].rnti;
2074 ulSf->ueUlAllocInfo[idx].numPrb = ueInfo->ulAllocInfo[idx].numPrb;
2077 RGCPYTIMEINFO(timingInfo, ulSf->schdTime);
2079 } /* end of rgHndlUlUeInfo */
2082 * @brief Function for handling RaResp request received from scheduler to MAC
2086 * Function : rgTOMRlsSf
2088 * This function shall be invoked whenever scheduler is done with the
2089 * allocations of random access responses for a subframe.
2090 * This shall invoke RAM to create ueCbs for all the rapIds allocated and
2091 * shall invoke MUX to create RAR PDUs for raRntis allocated.
2094 * @param[in] Inst inst
2095 * @param[in] CmLteCellId cellId,
2096 * @param[in] CmLteTimingInfo timingInfo,
2097 * @param[in] RaRespInfo *rarInfo
2102 PUBLIC Void rgTOMRlsSf
2108 PUBLIC Void rgTOMRlsSf(dlSf)
2117 if(dlSf->txDone == FALSE)
2119 RLOG0(L_ERROR, "SUBFRAME Not pushed to the PHY");
2121 if (dlSf->bch.tb != NULLP)
2123 RG_FREE_MSG(dlSf->bch.tb);
2125 if (dlSf->bcch.tb != NULLP)
2127 RG_FREE_MSG(dlSf->bcch.tb);
2129 if (dlSf->pcch.tb != NULLP)
2131 RG_FREE_MSG(dlSf->pcch.tb);
2134 rgTOMEmtcRlsSf(dlSf);
2136 for(idx=0; idx < dlSf->numRaRsp; idx++)
2138 RG_FREE_MSG(dlSf->raRsp[idx].rar);
2141 /* ADD Changes for Downlink UE Timing Optimization */
2142 #ifdef LTEMAC_DLUE_TMGOPTMZ
2143 dlSf->remDatReqCnt = 0;
2144 /* Fix[ccpu00126310]: Tracks Data Requests from RLC for both loosely and tight coupled
2146 dlSf->statIndDone = FALSE;
2148 if (dlSf->tbs.count)
2153 RGDBGERRNEW(inst, (rgPBuf(inst),
2154 "Error Stale TBs in Subframes TBS list\n"));
2155 node = dlSf->tbs.first;
2158 hqP = (RgDlHqProcCb*)node->node;
2162 for(i=0;i< RG_MAX_TB_PER_UE;i++)
2164 if (hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.subframe % 2].sf == dlSf)
2166 cmLListDelFrm(&dlSf->tbs, &(hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.subframe % 2].sfLnk));
2167 hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.subframe % 2].sfLnk.node = NULLP;
2168 printf("\n rgTOMRlsSf:: hqP %p \n", (Void *)hqP);
2170 hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.subframe % 2].sf = NULLP;
2175 /*arjun: check if dlSf laaTb list has to be freed???*/
2176 cmLListInit(&dlSf->tbs);
2177 dlSf->txDone = FALSE;
2183 * @brief Function is called by the scheduler once it has completed the
2184 * allocation for the subframe.
2188 * Function : rgHndlFlowCntrl
2189 * This function should fill and send Flow control
2193 * @param[in] Pst *cell
2194 * @param[in] RgInfSfAlloc *sfInfo Carries all the allocation
2200 PUBLIC S16 rgHndlFlowCntrl
2203 RgInfSfAlloc *sfInfo
2206 PUBLIC S16 rgHndlFlowCntrl(cell, sfInfo)
2208 RgInfSfAlloc *sfInfo;
2211 RguFlowCntrlInd *flowCntrlInd;
2215 TRC3(rgHndlFlowCntrl);
2217 pst = &cell->rguDlSap->sapCfg.sapPst;
2218 /* flowCntrlInd is alloced in cell init time and will be re-used throughout */
2219 flowCntrlInd = cell->flowCntrlInd;
2220 flowCntrlInd->cellId = sfInfo->cellId;
2221 flowCntrlInd->numUes = sfInfo->flowCntrlInfo.numUes;
2223 for (ueIdx = 0; ueIdx < sfInfo->flowCntrlInfo.numUes; ueIdx++)
2225 flowCntrlInd->ueFlowCntrlInfo[ueIdx].ueId = sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].ueId;
2226 flowCntrlInd->ueFlowCntrlInfo[ueIdx].numLcs = sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].numLcs;
2228 for (lcIdx = 0; lcIdx < RGINF_MAX_NUM_DED_LC; lcIdx++)
2230 flowCntrlInd->ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].lcId =
2231 sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].lcId;
2232 flowCntrlInd->ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].pktAdmitCnt =
2233 sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].pktAdmitCnt;
2235 flowCntrlInd->ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].maxBo4FlowCtrl =
2236 sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].maxBo4FlowCtrl;
2239 RgUiRguFlowCntrlInd(pst, cell->rguDlSap->sapCfg.spId,flowCntrlInd); /* TODO: Rishi confirm if the suId and pst pointer is correct */
2243 * @brief Function is called by the scheduler once it has completed the
2244 * allocation for the subframe.
2248 * Function : RgSchMacSfAllocReq
2250 * This function shall be invoked whenever scheduler is done with the
2251 * allocations of for a subframe. The sfInfo carries all the allocation
2252 * details for the common channels, RA responses and dedicated channel
2255 * Processing steps :
2256 * 1. Reset the information present in the downlink subframe that is
2258 * 2. Handle common channel allocations
2259 * 3. Handle RA Response allocations
2260 * 4. Handle dedicated channel allocations.
2262 * @param[in] Pst *pst
2263 * @param[in] RgInfSfAlloc *sfInfo Carries all the allocation
2269 PUBLIC S16 RgSchMacSfAllocReq
2272 RgInfSfAlloc *sfInfo
2275 PUBLIC S16 RgSchMacSfAllocReq(pst, sfInfo)
2277 RgInfSfAlloc *sfInfo;
2283 VOLATILE U32 startTime=0;
2286 TRC2(RgSchMacSfAllocReq)
2288 RG_IS_INST_VALID(pst->dstInst);
2289 inst = pst->dstInst - RG_INST_START;
2291 SStartTask(&startTime, PID_MAC_SF_ALLOC_REQ);
2298 if((cell = rgCb[inst].cell) == NULLP)
2300 RLOG_ARG0(L_ERROR,DBG_CELLID,sfInfo->cellId, "No cellCb found with cell");
2304 dlSf = &cell->subFrms[(sfInfo->timingInfo.subframe % RG_NUM_SUB_FRAMES)];
2306 rgTOMRlsSf(inst,dlSf);
2307 dlSf->schdTime = sfInfo->timingInfo;
2310 rgLaaInitTbInfoLst(cell);
2313 /* Fix : syed Ignore Failure Returns and continue processing.
2314 * Incomplete processing results in state sync loss between MAC-SCH. */
2316 if(TRUE == cell->emtcEnable)
2318 rgEmtcHndl(cell, sfInfo);
2321 rgHndlCmnChnl(cell, sfInfo->timingInfo, &sfInfo->cmnLcInfo, &err);
2323 rgHndlRaResp(cell, sfInfo->timingInfo, &sfInfo->rarInfo, &err);
2326 #ifdef XEON_SPECIFIC_CHANGES
2327 CM_MEAS_TIME((cell->crntTime.subframe % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_B4_UE_SCHD);
2329 rgHndlSchdUe(cell, sfInfo->timingInfo, &sfInfo->ueInfo, &err);
2330 #ifdef XEON_SPECIFIC_CHANGES
2331 CM_MEAS_TIME((cell->crntTime.subframe % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_UE_SCHD);
2333 rgLaaChkAndReqTbs(dlSf,cell, inst);
2336 rgHndlSchdUe(cell, sfInfo->timingInfo, &sfInfo->ueInfo, &err);
2340 if(rgHndlUlUeInfo(cell, sfInfo->ulUeInfo.timingInfo,
2341 &sfInfo->ulUeInfo) != ROK)
2346 #ifdef XEON_SPECIFIC_CHANGES
2347 CM_MEAS_TIME((cell->crntTime.subframe % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_MEAS);
2349 /* Fix[ccpu00126310]: Tracks Data Requests from RLC for both loosely and tight coupled
2353 /* Added the handling for pushing down
2354 * TFU Data request in the retransmission only scenario.*/
2355 #ifdef LTEMAC_DLUE_TMGOPTMZ
2356 dlSf->statIndDone = TRUE;
2357 /* Fix [ccpu00126310]: Tracks Data Requests from RLC for both loosely and tight coupled
2359 if(!(dlSf->txDone) &&
2361 (TRUE == rgLaaChkAllRxTbs(dlSf)) &&
2363 (0 == dlSf->remDatReqCnt) && (dlSf->statIndDone) &&
2364 (RG_TIMEINFO_SAME(cell->crntTime, dlSf->schdTime)))
2366 /*This is the case of rettransmission, so no need
2367 * to wait for TTI Ind to push TFU Data Request. Send
2369 if (ROK != rgTOMUtlProcDlSf (dlSf, cell, &err))
2371 RLOG_ARG0(L_ERROR,DBG_CELLID,cell->cellId,"Unable to process downlink subframe for cell");
2372 err.errType = RGERR_ROM_DEDDATREQ;
2374 /* Mark this frame as sent */
2375 dlSf->txDone = TRUE;
2378 if (sfInfo->flowCntrlInfo.numUes > 0)
2380 rgHndlFlowCntrl(cell,sfInfo);
2383 SStopTask(startTime, PID_MAC_SF_ALLOC_REQ);
2385 } /* end of RgSchMacSfAllocReq */
2387 * @brief Handler for processing data indication recieved from PHY for UEs.
2391 * Function: rgTOMProcCrntiCEInDatInd
2393 * Handler for processing data indication recieved from PHY for UEs.
2395 * Invoked by: RgLiTfuDatInd of LIM
2398 * For each DataInfo recieved
2399 * - If received a CRNTI control element
2400 * - Check if a CCCH SDU is present, if it is return failure
2401 * - Check for the existence of UE, if its isnt present return failure.
2402 * - Delegate the remaining processing to rgTOMUtlProcMsg3 which
2403 * primarily informs the scheduler about the data received and
2404 * generates Data indications towards the higher layer.
2406 * @param RgMacPdu *pdu,
2407 * @param RgUeCb *prevUeCb,
2408 * @param RgCellCb *cellCb,
2409 * @param TfuDatInfo *datInfo,
2410 * @param RgInfCeInfo *ceInfo
2416 PRIVATE S16 rgTOMProcCrntiCEInDatInd
2421 TfuDatInfo *datInfo,
2422 RgInfCeInfo *ceInfo,
2426 PRIVATE S16 rgTOMProcCrntiCEInDatInd( pdu, prevUeCb, cellCb, datInfo, ceInfo, subframe)
2430 TfuDatInfo *datInfo;
2431 RgInfCeInfo *ceInfo;
2435 RgUeCb *ueCb = NULLP;
2436 Inst inst = cellCb->macInst - RG_INST_START;
2444 TRC2(rgTOMProcCrntiCEInDatInd)
2450 ueCb = rgDBMGetUeCbFromRachLst (cellCb, datInfo->rnti);
2454 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2455 "RNTI:%d Received MSG3 with CRNTI,unable to find ueCb", ceInfo->ces.cRnti);
2459 prevUeCb = rgDBMGetUeCb (cellCb, ceInfo->ces.cRnti);
2460 if (prevUeCb == NULLP)
2462 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2463 "RNTI:%d Received MSG3 with CRNTI,unable to find ueCb", ceInfo->ces.cRnti);
2466 RLOG_ARG2(L_DEBUG,DBG_CELLID,cellCb->cellId,
2467 "CRNTI CE(%d) received through tmpCrnti(%d)",
2468 ceInfo->ces.cRnti, datInfo->rnti);
2469 rgDBMDelUeCbFromRachLst(cellCb, ueCb);
2470 rgRAMFreeUeCb(inst,ueCb);
2473 if ((rgTOMUtlProcMsg(cellCb, ueCb, pdu, FALSE,&spsToBeActvtd,&sduSize, subframe, NULLP)) != ROK)
2475 if ((rgTOMUtlProcMsg (cellCb, ueCb, pdu, subframe, NULLP)) != ROK)
2476 #endif /* LTEMAC_SPS */
2478 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2479 "RNTI:%d Processing for MSG3 failed",datInfo->rnti);
2485 * @brief Handler for processing data indication recieved from PHY for UEs.
2489 * Function: rgTOMProcCCCHSduInDatInd
2491 * Handler for processing data indication recieved from PHY for UEs.
2493 * Invoked by: RgLiTfuDatInd of LIM
2496 * For each DataInfo recieved
2497 * - If only CCCH SDU is present
2498 * - Invoke rgTOMUtlProcMsg3 for further processing.
2499 * - If its a non-Msg3 PDU i.e. received outside of a RA procedure
2500 * - Retrieve the UeCB
2501 * - Validate that the received PDU contains only configured Logical
2503 * - Invoke rgTOMUtlProcDatPdu for further processing. It informs the
2504 * scheduler with the information of the received Data and generates
2505 * DatIndications towards the higher layers.
2507 * @param TfuDatIndInfo *datInd
2508 * @param RgMacPdu *pdu,
2509 * @param RgUeCb *prevUeCb,
2510 * @param RgCellCb *cellCb,
2511 * @param TfuDatInfo *datInfo,
2512 * @param RgInfCeInfo *ceInfo
2518 PRIVATE S16 rgTOMProcCCCHSduInDatInd
2523 TfuDatInfo *datInfo,
2524 RgInfCeInfo *ceInfo,
2528 PRIVATE S16 rgTOMProcCCCHSduInDatInd( pdu, prevUeCb, cellCb, datInfo, ceInfo, subframe)
2532 TfuDatInfo *datInfo;
2533 RgInfCeInfo *ceInfo;
2537 RgUeCb *ueCb = NULLP;
2538 Inst inst = cellCb->macInst - RG_INST_START;
2546 TRC2(rgTOMProcCCCHSduInDatInd)
2552 if (ceInfo->bitMask & RG_CRNTI_CE_PRSNT)
2554 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2555 "CRNTI:%d Received MSG3 with CCCH",ceInfo->ces.cRnti);
2559 ueCb = rgDBMGetUeCbFromRachLst (cellCb, datInfo->rnti);
2563 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2564 "RNTI:%d Processing for MSG3 failed", datInfo->rnti);
2567 /* Fix: syed Drop any duplicate Msg3(CCCH Sdu) */
2568 if (ueCb->dl.hqEnt.numHqProcs)
2570 /* HqE is already initialized by a previuos Msg3 */
2571 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"RNTI:%d Processing for MSG3 failed. Duplicate "
2572 "MSG3 received. Dropping", datInfo->rnti);
2576 if(rgDHMHqEntInit(inst,&ueCb->dl.hqEnt,
2577 cellCb->maxDlHqProcPerUe) != ROK)
2579 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"RNTI:%d Harq Initialization failed ",
2583 RLOG_ARG1(L_DEBUG,DBG_CELLID,cellCb->cellId,
2584 "CCCH SDU received through tmpCrnti(%d)",datInfo->rnti);
2586 if ((rgTOMUtlProcMsg(cellCb, ueCb, pdu, FALSE,&spsToBeActvtd,&sduSize, subframe, NULLP)) != ROK)
2588 if ((rgTOMUtlProcMsg (cellCb, ueCb, pdu, subframe, NULLP)) != ROK)
2589 #endif /* LTEMAC_SPS */
2591 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"RNTI:%d Processing for MSG3 failed",
2600 /** @brief This function captures the BSR value from Control Element
2601 * Info structure and updates the effective Buffer size into the
2602 * corresponding LCG ID.
2606 * Function: rgTOMUtlL2MStoreBufSz
2609 * - update/append the Data structure based on BSR type
2611 * @param [in] RgUeCb *ueCb
2612 * @param [in] RgInfCeInfo *ceInfo
2617 PRIVATE S16 rgTOMUtlL2MStoreBufSz
2623 PRIVATE S16 rgTOMUtlL2MStoreBufSz (ueCb, ceInfo)
2625 RgInfCeInfo *ceInfo;
2630 TRC2(rgTOMUtlL2MStoreBufSz);
2632 if(ceInfo->bitMask & RG_TRUNC_BSR_CE_PRSNT)
2634 lcgId = ((ceInfo->ces.bsr.truncBsr >> 6) & 0x03);
2635 bsr = ceInfo->ces.bsr.truncBsr & 0x3F;
2636 ueCb->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs = rgLwrBsrTbl[bsr];
2638 else if(ceInfo->bitMask & RG_SHORT_BSR_CE_PRSNT)
2640 lcgId = ((ceInfo->ces.bsr.shortBsr >> 6) & 0x03);
2641 bsr = ceInfo->ces.bsr.shortBsr & 0x3F;
2642 ueCb->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs = rgLwrBsrTbl[bsr];
2645 else if(ceInfo->bitMask & RG_LONG_BSR_CE_PRSNT)
2647 ueCb->ul.lcgArr[0].lcgBsInfo.outStndngBs = rgLwrBsrTbl[ceInfo->ces.bsr.longBsr.bs1];
2648 ueCb->ul.lcgArr[1].lcgBsInfo.outStndngBs = rgLwrBsrTbl[ceInfo->ces.bsr.longBsr.bs2];
2649 ueCb->ul.lcgArr[2].lcgBsInfo.outStndngBs = rgLwrBsrTbl[ceInfo->ces.bsr.longBsr.bs3];
2650 ueCb->ul.lcgArr[3].lcgBsInfo.outStndngBs = rgLwrBsrTbl[ceInfo->ces.bsr.longBsr.bs4];
2653 } /* end of rgTOMUtlL2MStoreBufSz*/
2655 /** @brief : Compiles list of LCs received in UL data for DTCH RBs
2659 * @param [in] RgCellCb *cellCb
2660 * @param [in] RgUeCb *ueCb
2661 * @param [in] CmLteRnti rnti
2662 * @param [in] RgMacPdu *pdu
2669 PRIVATE Void rgTOML2MCompileActiveLCs
2677 PRIVATE Void rgTOML2MCompileActiveLCs(cellCb, ueCb, pdu, ceInfo)
2681 RgInfCeInfo *ceInfo;
2688 TRC2(rgTOML2MCompileActiveLCs)
2690 node = pdu->sduLst.first;
2693 sdu = (RgMacSdu*)node->node;
2695 if ((ulLcCb = rgDBMGetUlDedLcCb(ueCb, sdu->lcId)), ulLcCb != NULLP)
2697 if (ulLcCb->lcgId != 0)
2699 ceInfo->bitMask |= RG_ACTIVE_LC_PRSNT;
2700 ceInfo->ulActLCs[ulLcCb->lcId - 1] = TRUE;
2711 /**********************************************************************
2714 **********************************************************************/