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 "common_def.h"
40 #include "du_app_mac_inf.h"
41 #include "rgu.h" /* RGU defines */
42 #include "tfu.h" /* RGU defines */
43 #include "lrg.h" /* layer management defines for LTE-MAC */
44 #include "crg.h" /* layer management defines for LTE-MAC */
45 #include "rg_sch_inf.h" /* layer management defines for LTE-MAC */
46 #include "rg.h" /* defines and macros for MAC */
47 #include "rg_env.h" /* defines and macros for MAC */
48 #include "rg_err.h" /* defines and macros for MAC */
49 #include "rgm.h" /* layer management typedefs for MAC */
51 /* header/extern include files (.x) */
52 #include "crg.x" /* CRG interface typedefs */
53 #include "rgu.x" /* RGU types */
54 #include "tfu.x" /* RGU types */
55 #include "lrg.x" /* layer management typedefs for MAC */
56 #include "rg_sch_inf.x" /* SCH interface typedefs */
57 #include "rg_prg.x" /* PRG interface typedefs */
58 #include "rgm.x" /* layer management typedefs for MAC */
59 #include "rg.x" /* typedefs for MAC */
61 #include "lwr_mac_fsm.h"
62 #ifdef MAC_RLC_UL_RBUF
67 uint16_t handleDlTtiReq(SlotIndInfo currTimingInfo);
68 uint16_t handleUlTtiReq(SlotIndInfo currTimingInfo);
70 /* ADD Changes for Downlink UE Timing Optimization */
71 #ifndef LTEMAC_DLUE_TMGOPTMZ
72 PRIVATE S16 rgTOMUtlProcDlSf ARGS(( RgDlSf *dlSf, RgCellCb *cellCb,
75 PUBLIC S16 rgTOMUtlProcDlSf ARGS((RgDlSf *dlSf, RgCellCb *cellCb,
78 PRIVATE S16 rgTOMProcCrntiCEInDatInd ARGS((
87 PRIVATE S16 rgTOMProcCCCHSduInDatInd ARGS((
96 PUBLIC S16 rgHndlFlowCntrl
102 EXTERN S16 RgUiRguFlowCntrlInd(Pst* pst, SuId suId, RguFlowCntrlInd *flowCntrlInd);
104 EXTERN S16 rgEmtcHndl(RgCellCb *cell,RgInfSfAlloc *sfInfo);
105 EXTERN S16 rgTOMEmtcUtlFillDatReqPdus(TfuDatReqInfo *datInfo, RgDlSf *dlSf, RgCellCb *cell, RgErrInfo *err);
106 EXTERN Void rgTOMEmtcRlsSf(RgDlSf *dlSf);
109 PRIVATE Void rgTOML2MCompileActiveLCs ARGS
116 PRIVATE S16 rgTOMUtlL2MStoreBufSz ARGS
122 PRIVATE S16 rgTomUtlPrepareL2MUlThrpInfo ARGS
126 RgRguDedDatInd *dDatInd
130 /* The below table takes lower values of BSR Range for a BSR value
131 This is to ensure that outstanding can be decrease to zero upon reception of
132 TB, which is not guaranteed if higher Range values are used */
133 /* Note: taking value 10 for BSR index 1 */
134 #ifndef MAC_5GTF_UPDATE
135 PRIVATE U32 rgLwrBsrTbl[64] = {
136 0, 10, 10, 12, 14, 17, 19, 22, 26,
137 31, 36, 42, 49, 57, 67, 78, 91,
138 107, 125, 146, 171, 200, 234, 274, 321,
139 376, 440, 515, 603, 706, 826, 967, 1132,
140 1326, 1552, 1817, 2127, 2490, 2915, 3413, 3995,
141 4677, 5476, 6411, 7505, 8787, 10287, 12043, 14099,
142 16507, 19325, 22624, 26487, 31009, 36304, 42502, 49759,
143 58255, 68201, 79846, 93479, 109439, 128125, 150000
147 PRIVATE U32 rgLwrBsrTbl[64] = {
148 0,10,13,16,19,23,29,35,43,53,65,80,98,120,147,181,223,274,337,414,
149 509,625,769,945,1162,1429,1757,2161,2657,3267,4017,4940,6074,7469,
150 9185,11294,13888,17077,20999,25822,31752,39045,48012,59039,72598,
151 89272,109774,134986,165989,204111,250990,308634,379519,466683,
152 573866,705666,867737,1067031,1312097,1613447,1984009,2439678,
160 #define RG_TOM_INF_ALLOC(_pdu, _size, _dataPtr, _ret) {\
161 _ret = cmGetMem((Ptr)&_pdu->memCp, _size, (Ptr *)&_dataPtr); \
164 /* global variables */
165 PUBLIC U32 rgUlrate_tfu;
167 EXTERN U32 grgUlrate_tfu;
170 /** @brief This function fills the PDSCH data of a downlink subframe
174 * Function: rgTOMUtlFillDatReqPdus
177 * - Fill BCCH on DLSCH data using datInfo
178 * - Fill PCCH on DLSCH data using datInfo
179 * - Fill Dedicated data on DLSCH data using datInfo
180 * - Fill RA RSP data using datInfo
182 * @param [out] TfuDatReqInfo *datInfo
183 * @param [in] RgDlSf *dlSf
184 * @param [in] RgCellCb *cellCb
185 * @param [out] RgErrInfo *err
191 PRIVATE S16 rgTOMUtlFillDatReqPdus
193 TfuDatReqInfo *datInfo,
199 PRIVATE S16 rgTOMUtlFillDatReqPdus(datInfo, dlSf, cellCb, err)
200 TfuDatReqInfo *datInfo;
207 TfuDatReqPduInfo *datReq=NULLP;
208 /* Moving node declaration to limited scope for optimization */
211 Inst inst = cellCb->macInst - RG_INST_START;
213 TRC2(rgTOMUtlFillDatReqPdus)
215 /* first lets send the BCCH data down to PHY */
216 if (dlSf->bcch.tb != NULLP)
218 if ((ret = rgGetEventMem(inst,(Ptr *)&datReq, sizeof(TfuDatReqPduInfo),
219 &(datInfo->memCp))) != ROK)
221 err->errCause = RGERR_TOM_MEM_EXHAUST;
222 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,"Memory Exhaustion ");
225 #ifdef TFU_ALLOC_EVENT_NO_INIT
229 datReq->tbInfo[0].lchInfo[0].mBuf[0]=NULLP;
232 datReq->rnti = RG_SI_RNTI;
233 datReq->dciInfo = dlSf->bcch.pdcch.dci;
234 /* Note: SCpyMsgMsg is not done since free of unsent buffer
235 * has been taken care through cell delete by invoking rgTomRlsSf
237 datReq->nmbOfTBs = 1;
239 datReq->mBuf[0] = dlSf->bcch.tb;
241 SFndLenMsg((Buffer *)dlSf->bcch.tb, &(datReq->tbInfo[0].tbSize));
242 datReq->tbInfo[0].tbPres = TRUE;
243 datReq->tbInfo[0].lchInfo[0].mBuf[0] = dlSf->bcch.tb;
244 datReq->tbInfo[0].numLch = 1;
245 datReq->tbInfo[0].lchInfo[0].numPdu = 1;
247 #ifdef TFU_ALLOC_EVENT_NO_INIT
248 datReq->tbInfo[1].tbPres = FALSE;
249 datReq->tbInfo[1].lchInfo[0].mBuf[0] = NULLP;
252 cmLListAdd2Tail(&datInfo->pdus, &(datReq->lnk));
253 datReq->lnk.node = (PTR)datReq;
255 /* ccpu00132314-ADD- Adding txPower offset for the PDSCH transmission */
256 datReq->txPwrOffset = dlSf->bcch.txPwrOffset;
258 /* Setting the pointer to NULL post transmission */
259 dlSf->bcch.tb = NULLP;
262 if (dlSf->pcch.tb != NULLP)
264 if ((ret = rgGetEventMem(inst,(Ptr *)&datReq, sizeof(TfuDatReqPduInfo),
265 &(datInfo->memCp))) != ROK)
267 err->errCause = RGERR_TOM_MEM_EXHAUST;
268 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"Memory Exhaustion CRNTI:%d",datReq->rnti);
271 #ifdef TFU_ALLOC_EVENT_NO_INIT
276 datReq->rnti = RG_P_RNTI;
277 datReq->dciInfo = dlSf->pcch.pdcch.dci;
278 datReq->nmbOfTBs = 1;
280 datReq->mBuf[0] = dlSf->pcch.tb;
282 SFndLenMsg((Buffer *)dlSf->pcch.tb, &datReq->tbInfo[0].tbSize);
283 datReq->tbInfo[0].tbPres = TRUE;
284 datReq->tbInfo[0].lchInfo[0].mBuf[0] = dlSf->pcch.tb;
285 #ifdef TFU_ALLOC_EVENT_NO_INIT
286 datReq->tbInfo[1].tbPres = FALSE;
287 datReq->tbInfo[1].lchInfo[0].mBuf[0] = NULLP;
289 datReq->tbInfo[0].numLch = 1;
290 datReq->tbInfo[0].lchInfo[0].numPdu = 1;
292 cmLListAdd2Tail(&datInfo->pdus, &(datReq->lnk));
293 datReq->lnk.node = (PTR)datReq;
295 /* ccpu00132314-ADD- Adding txPower offset for the PDSCH transmission */
296 datReq->txPwrOffset = dlSf->pcch.txPwrOffset;
298 dlSf->pcch.tb = NULLP;
301 for(idx=0; idx < dlSf->numRaRsp; idx++)
303 if ((ret = rgGetEventMem(inst,(Ptr *)&datReq, sizeof(TfuDatReqPduInfo),
304 &(datInfo->memCp))) != ROK)
306 err->errCause = RGERR_TOM_MEM_EXHAUST;
307 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"Memory Exhaustion CRNTI:%d",
311 #ifdef TFU_ALLOC_EVENT_NO_INIT
316 datReq->rnti = dlSf->raRsp[idx].pdcch.rnti;
317 datReq->dciInfo = dlSf->raRsp[idx].pdcch.dci;
318 datReq->nmbOfTBs = 1;
320 datReq->mBuf[0] = dlSf->raRsp[idx].rar;
322 SFndLenMsg((Buffer *)dlSf->raRsp[idx].rar, &datReq->tbInfo[0].tbSize);
323 datReq->tbInfo[0].tbPres = TRUE;
324 datReq->tbInfo[0].lchInfo[0].mBuf[0] = dlSf->raRsp[idx].rar;
325 #ifdef TFU_ALLOC_EVENT_NO_INIT
326 datReq->tbInfo[1].lchInfo[0].mBuf[0] = NULLP;
327 datReq->tbInfo[1].tbPres = FALSE;
329 datReq->tbInfo[0].numLch = 1;
330 datReq->tbInfo[0].lchInfo[0].numPdu = 1;
331 // prc_trace_format_string(0x40,3,"UE Id=(%d) tbSz=(%d)",datReq->rnti, datReq->tbInfo[0].tbSize);
333 cmLListAdd2Tail(&datInfo->pdus, &(datReq->lnk));
334 datReq->lnk.node = (PTR)datReq;
336 /* ccpu00132314-ADD- Adding txPower offset for the PDSCH transmission */
337 datReq->txPwrOffset = dlSf->raRsp[idx].txPwrOffset;
339 dlSf->raRsp[idx].rar = NULLP;
342 /* Fill Dedicated UE data */
343 if (dlSf->tbs.count != 0)
346 while (dlSf->tbs.first)
348 node = dlSf->tbs.first;
349 hqCb = (RgDlHqProcCb*)node->node;
350 if ((ret = rgDHMSndDatReq (cellCb, dlSf, datInfo, hqCb, err)) != ROK)
352 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
353 "DHM unable to fill DATA request");
354 err->errType = RGERR_TOM_TTIIND;
361 } /* end of rgTOMUtlFillDatReqPdus*/
363 /** @brief This function does all the processing related to a single downlink
368 * Function: rgTOMUtlProcDlSf
371 * - collate control data for all UEs and send to PHY
372 * - collate data buffers for all UEs and send to PHY
374 * @param [in] RgDlSf *dlSf
375 * @param [in] RgCellCb *cellCb
376 * @param [out] RgErrInfo *err
379 /* ADD Changes for Downlink UE Timing Optimization */
380 #ifndef LTEMAC_DLUE_TMGOPTMZ
382 PRIVATE S16 rgTOMUtlProcDlSf
389 PRIVATE S16 rgTOMUtlProcDlSf (dlSf, cellCb, err)
396 PUBLIC S16 rgTOMUtlProcDlSf
403 PUBLIC S16 rgTOMUtlProcDlSf (dlSf, cellCb, err)
411 TfuDatReqInfo *datInfo;
412 Inst inst = cellCb->macInst - RG_INST_START;
414 TRC2(rgTOMUtlProcDlSf);
416 /* Fill Data Request Info from scheduler to PHY */
417 if ((ret = rgAllocEventMem(inst,(Ptr *)&datInfo,
418 sizeof(TfuDatReqInfo))) != ROK)
420 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,"Unable to Allocate TfuDatReqInfo");
425 cmLListInit(&datInfo->pdus);
427 RGADDTOCRNTTIME(dlSf->schdTime, datInfo->timingInfo, TFU_DELTA);
429 RGADDTOCRNTTIME(dlSf->schdTime, datInfo->timingInfo, TFU_DLDATA_DLDELTA);
431 datInfo->cellId = cellCb->cellId;
432 if((0 == (datInfo->timingInfo.sfn % 30)) && (0 == datInfo->timingInfo.slot))
434 //printf("5GTF_CHECK rgTOMUtlProcDlSf dat (%d : %d)\n", datInfo->timingInfo.sfn, datInfo->timingInfo.slot);
436 #ifdef TFU_ALLOC_EVENT_NO_INIT
437 datInfo->bchDat.pres = 0;
441 if (dlSf->bch.tb != NULLP)
443 datInfo->bchDat.pres = PRSNT_NODEF;
444 datInfo->bchDat.val = dlSf->bch.tb;
445 dlSf->bch.tb = NULLP;
448 /* Fill the DLSCH PDUs of BCCH, PCCH and Dedicated Channels */
449 if ((ret = rgTOMEmtcUtlFillDatReqPdus(datInfo, dlSf, cellCb, err)) != ROK)
451 RG_FREE_MEM(datInfo);
455 /* Fill the DLSCH PDUs of BCCH, PCCH and Dedicated Channels */
456 if ((ret = rgTOMUtlFillDatReqPdus(datInfo, dlSf, cellCb, err)) != ROK)
458 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,"Unable to send data for cell");
459 RG_FREE_MEM(datInfo);
462 if((datInfo->pdus.count) || (datInfo->bchDat.pres == TRUE))
464 /* sending the data to Phy */
465 if (rgLIMTfuDatReq(inst,datInfo) != ROK)
467 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,"Unable to send data info for cell");
472 /* Nothing to send: free the allocated datInfo */
473 RG_FREE_MEM(datInfo);
482 * @brief Handler for processing TTI indication recieved from
487 * Function: macProcessSlotInd
489 * Handler for processing slot indication recieved from PHY
492 * Invoked by: macProcessSlotInd
495 * - Get cell and update the cell's current time with the timing value given
497 * - Invoke the cmPrcTmr to process the timing queue.
498 * - Append the PHICH information to the downlink subframe that needs to go
499 * out to PHY in this subframe.
500 * - Invoke DHM to release the downlink subframe that occured earlier
501 * rgDHMRlsDlsfHqProc.
502 * - Invoke the TTI handler of scheduler.
503 * - Invoke the TTI handler of RAM module.
504 * - Get the downlink subframe that has to go out to PHY in this subframe
506 * - Invoke rgTOMUtlProcTA to perform and timing advance processing.
507 * - Invoke rgTOMUtlProcDlSf to do further processing on the downlink
509 * - Get the downlink subframe that would occur after RG_DL_DELTA and
510 * invoke rgTOMUtlProcDlSfStaInd to send status indications to the higher
512 * - Invoke GOM's TTI handler rgGOMTtiHndlr
513 * - Invoke COM's TTI handler rgCOMTtiHndlr
515 * @param[in] Inst inst
516 * @param[in] SlotIndInfo slotInd
521 #if (defined (MAC_FREE_RING_BUF) || defined (RLC_FREE_RING_BUF))
522 pthread_t gMacTId = 0;
524 PUBLIC S16 macProcessSlotInd
533 /* ADD Changes for Downlink UE Timing Optimization */
534 #ifdef LTEMAC_DLUE_TMGOPTMZ
536 CmLteTimingInfo prevTmInfo;
538 //SlotIndInfo *slotInd = &ttiInfo->cells[0];
540 TRC2(macProcessSlotInd);
542 #ifdef MAC_FREE_RING_BUF
543 gMacTId = pthread_self();
546 cellCb = rgCb[inst].cell;
549 err.errType = RGERR_TOM_TTIIND;
550 err.errCause = RGERR_TOM_INV_CELL_ID;
554 RGCPYTIMEINFO(slotInd, cellCb->crntTime);
556 rgMacGT = (slotInd.sfn * RG_NUM_SUB_FRAMES_5G) + slotInd.slot;
559 /*Included to track the number of 10240 cycles completed */
561 if((cellCb->crntTime.sfn == 0) && (cellCb->crntTime.slot==0))
563 cellCb->ttiCycle += 1;
568 /*Check if we have transmitted the previous DL SF, it could be the
569 case that we haven't received all the DATA from RLC as yet
570 and thus we would not have transmitted previous DL SF yet.*/
571 /* ADD Changes for Downlink UE Timing Optimization */
572 #ifdef LTEMAC_DLUE_TMGOPTMZ
573 RGSUBFRMCRNTTIME(slotInd, prevTmInfo, 1);
574 prevDlSf = &cellCb->subFrms[(prevTmInfo.slot % RG_NUM_SUB_FRAMES)];
575 if(FALSE == prevDlSf->txDone)
577 if (ROK != rgTOMUtlProcDlSf (prevDlSf, cellCb, &err))
579 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,"Unable to process "
580 "previous downlink subframe for cell");
581 err.errType = RGERR_TOM_TTIIND;
584 /* Mark this frame as sent */
585 prevDlSf->txDone = TRUE;
587 if(prevDlSf->remDatReqCnt)
589 /*We have not received 1 or more data requests from RLC, this is
590 error scenario. MAC & SCH need to discard the allocations for
591 which data request hasn't been received as yet. And MAC
592 needs to inform SCH about the list of UEs for which
593 allocation need to be discarded. */
594 prevDlSf->remDatReqCnt = 0;
600 /* Trigger for DL TTI REQ */
601 handleDlTtiReq(slotInd);
603 /* Trigger for UL TTI REQ */
604 handleUlTtiReq(slotInd);
606 dlSf = &cellCb->subFrms[(slotInd.slot % RG_NUM_SUB_FRAMES)];
608 if((dlSf->txDone == TRUE) ||
609 (!RG_TIMEINFO_SAME(slotInd,dlSf->schdTime)))
612 #ifndef LTEMAC_DLUE_TMGOPTMZ
613 TfuDatReqInfo *datInfo;
614 CmLteTimingInfo timingInfo;
615 #ifdef TFU_DL_DELTA_CHANGE
616 RGADDTOCRNTTIME(cellCb->crntTime, timingInfo, TFU_DLDATA_DLDELTA);
618 RGADDTOCRNTTIME(cellCb->crntTime, timingInfo, TFU_DELTA);
620 /* Fill Data Request from MAC for BCH */
621 if ((timingInfo.sfn % 4 == 0) && (timingInfo.slot == 0))
623 if (ROK != rgAllocEventMem(inst,(Ptr *)&datInfo,
624 sizeof(TfuDatReqInfo)))
626 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
627 "rgTOMUtlProcDlSf() Unable to Allocate TfuDatReqInfo for cell");
632 cmLListInit(&datInfo->pdus);
633 datInfo->cellId = cellCb->cellId;
634 datInfo->bchDat.pres = NOTPRSNT;
635 datInfo->timingInfo = timingInfo;
638 /* sending the dummy data req to Phy */
639 if (rgLIMTfuDatReq(inst,datInfo) != ROK)
641 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
642 "rgTOMUtlProcDlSf() Unable to send data info for cell");
648 /* Freeing as the part of CL Non RT Indication */
649 /* TDOD : Generalize for all SOCs */
650 #if !(defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD))
651 rgDHMFreeTbBufs(inst);
656 /*Return if there is still some data to be received
657 from RLC for this DL SF. */
658 /* ADD Changes for Downlink UE Timing Optimization */
659 #ifdef LTEMAC_DLUE_TMGOPTMZ
660 if(0 != dlSf->remDatReqCnt)
662 /* Freeing as the part of CL Non RT Indication */
663 /* TODO : Generalize for all SOCs and remove this flag */
664 #if !(defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD))
665 rgDHMFreeTbBufs(inst);
671 #ifdef XEON_SPECIFIC_CHANGES
672 CM_MEAS_TIME((slotInd.slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_DL_BR_PRC);
675 if (ROK != rgTOMUtlProcDlSf (dlSf, cellCb, &err))
677 //RLOG_ARG0(L_ERROR,DBG_CELLID,slotInd->cellId,
678 // "Unable to process downlink subframe for cell");
679 err.errType = RGERR_TOM_TTIIND;
681 #ifdef XEON_SPECIFIC_CHANGES
682 CM_MEAS_TIME((slotInd->slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_DL_AFTER_PRC);
685 /* Mark this frame as sent */
688 /* Freeing as the part of CL Non RT Indication */
689 /* TODO : Generalize for all SOCs and remove this flag */
690 #if !(defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD))
691 rgDHMFreeTbBufs(inst);
694 } /* macProcessSlotInd */
696 /** @brief This function allocates the RgMacPdu that will be populated by DEMUX
697 * with the SubHeaders list and the values of the Control elements.
701 * Function: rgTOMUtlAllocPduEvnt
704 * @param[in] Inst inst
705 * @param [out] RgMacPdu **pdu
712 PRIVATE S16 rgTOMUtlAllocPduEvnt
718 PRIVATE S16 rgTOMUtlAllocPduEvnt (inst,pdu)
725 RgUstaDgn dgn; /* Alarm diagnostics structure */
726 VOLATILE U32 startTime=0;
728 TRC2(rgTOMUtlAllocPduEvnt);
730 evntMem.region = rgCb[inst].rgInit.region;
731 evntMem.pool = rgCb[inst].rgInit.pool;
734 SStartTask(&startTime, PID_TOMUTL_CMALLCEVT);
736 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
737 MS_BUF_ADD_ALLOC_CALLER();
740 if (cmAllocEvnt (sizeof (RgMacPdu), RG_BLKSZ, &evntMem, (Ptr*)pdu) != ROK)
742 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
743 rgLMMStaInd(inst,LCM_CATEGORY_RESOURCE, LCM_EVENT_DMEM_ALLOC_FAIL,
744 LCM_CAUSE_MEM_ALLOC_FAIL, &dgn);
745 RLOG0(L_ERROR,"Allocation of DUX event failed");
750 SStopTask(startTime, PID_TOMUTL_CMALLCEVT);
755 /** @brief This function frees up the RgMacPdu structure that has been
756 * populated by demux.
760 * Function: rgTOMUtlFreePduEvnt
761 * - Function frees up the RgMacPdu structure, in case of error it shall
762 * free up the buffer's present in the different sdu.
765 * @param [in] Inst inst
766 * @param [in] RgMacPdu *pdu
767 * @param [in] Bool *error
771 PRIVATE Void rgTOMUtlFreePduEvnt
777 PRIVATE Void rgTOMUtlFreePduEvnt (pdu, error)
786 TRC2(rgTOMUtlFreePduEvnt);
787 /* Steps of freeing up the PDU.
788 * 1. loop through the subHdrLst and free up all the buffers.
789 * 2. free up the whole event
791 if ((error == TRUE) && (pdu->sduLst.count > 0))
793 node = pdu->sduLst.first;
796 sdu = (RgMacSdu*)node->node;
797 RG_FREE_MSG(sdu->mBuf);
803 } /* end of rgTOMUtlFreePduEvnt */
805 /** @brief This function allocates the RgMacPdu that will be populated by DEMUX
806 * with the SubHeaders list and the values of the Control elements.
810 * Function: rgTOMInfAllocPduEvnt
813 * @param [in] Inst inst
814 * @param [out] RgMacPdu **pdu
821 PRIVATE S16 rgTOMInfAllocPduEvnt
824 RgInfSfDatInd **sfInfo
827 PRIVATE S16 rgTOMInfAllocPduEvnt (inst,sfInfo)
829 RgInfSfDatInd **sfInfo;
834 RgUstaDgn dgn; /* Alarm diagnostics structure */
835 VOLATILE U32 startTime=0;
837 TRC2(rgTOMInfAllocPduEvnt);
839 evntMem.region = rgCb[inst].rgInit.region;
840 evntMem.pool = rgCb[inst].rgInit.pool;
843 SStartTask(&startTime, PID_TOMINF_CMALLCEVT);
845 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
846 MS_BUF_ADD_ALLOC_CALLER();
848 if (cmAllocEvnt (sizeof (RgInfSfDatInd), RG_BLKSZ, &evntMem, (Ptr*)sfInfo) != ROK)
850 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
851 rgLMMStaInd(inst,LCM_CATEGORY_RESOURCE, LCM_EVENT_DMEM_ALLOC_FAIL,
852 LCM_CAUSE_MEM_ALLOC_FAIL, &dgn);
853 RLOG0(L_ERROR,"Allocation failed");
858 SStopTask(startTime, PID_TOMINF_CMALLCEVT);
863 /** @brief This function frees up the RgMacPdu structure that has been
864 * populated by demux.
868 * Function: rgTOMInfFreePduEvnt
869 * - Function frees up the RgMacPdu structure, in case of error it shall
870 * free up the buffer's present in the different sdu.
873 * @param [in] RgMacPdu *pdu
874 * @param [in] Bool *error
878 PRIVATE Void rgTOMInfFreePduEvnt
880 RgInfSfDatInd *sfInfo
883 PRIVATE Void rgTOMInfFreePduEvnt (sfInfo)
884 RgInfSfDatInd *sfInfo;
887 TRC2(rgTOMInfFreePduEvnt);
891 } /* end of rgTOMUtlFreePduEvnt */
895 /** @brief This function performs the preparation of information needed to set
896 * L2M Scheduled UL Throughput Information for a particular UE.
900 * Function: rgTomUtlPrepareL2MUlThrpInfo
901 * This function performs the preparation of information needed to set
902 * L2M Scheduled UL Throughput Information for a particular UE.
906 * @param [in] RgCellCb *cellCb
907 * @param [in] RgUeCb *ueCb
908 * @param [out] RgRguDedDatInd *dDatInd
912 PRIVATE S16 rgTomUtlPrepareL2MUlThrpInfo
916 RgRguDedDatInd *dDatInd
919 PRIVATE S16 rgTomUtlPrepareL2MUlThrpInfo(cellCb,ueCb,dDatInd)
922 RgRguDedDatInd *dDatInd;
928 TRC2(rgTomUtlPrepareL2MUlThrpInfo);
930 dDatInd->burstInd = RGU_L2M_UL_BURST_END;
931 for(loop=0;loop<dDatInd->numLch;loop++)
933 lcId=dDatInd->lchData[loop].lcId;
936 lcgId = ueCb->ul.lcCb[lcId - 1].lcgId;
937 if(ueCb->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs > 0)
939 dDatInd->burstInd = RGU_L2M_UL_BURST_START;
950 /** @brief This function is called by rgTOMDatInd. This function invokes the
951 * scheduler with the information of the received Data and any Control Elements
952 * if present. Also it generates Data indications towards the higher layers.
959 * - Retrieves the RaCb with the rnti provided, if it doesnt exist
961 * - If UE exists then update the Schduler with any MAC CEs if present.
962 * - Invoke RAM module to do Msg3 related processing rgRAMProcMsg3
963 * - Loop through the SDU subheaders and invoke either a common data
964 * indication (rgUIMSndCmnDatInd) or dedicated data indication
965 * (rgUIMSndDedDatInd) towards the higher layers.
967 * @param [in] RgCellCb *cellCb
968 * @param [in] RgUeCb *ueCb
969 * @param [in] CmLteRnti rnti
970 * @param [in] RgMacPdu *pdu
971 * @param [out] U32 *lcgBytes
982 PRIVATE S16 rgTOMUtlProcMsg
994 PRIVATE S16 rgTOMUtlProcMsg(cellCb, ueCb, pdu, isSpsRnti,spsToBeActvtd,sduSize, slot, lcgBytes)
1004 #else /* LTEMAC_SPS */
1006 PRIVATE S16 rgTOMUtlProcMsg
1015 PRIVATE S16 rgTOMUtlProcMsg(cellCb, ueCb, pdu, slot, lcgBytes)
1024 Inst inst = cellCb->macInst - RG_INST_START;
1026 RgRguCmnDatInd *cDatInd;
1027 RgRguDedDatInd *dDatInd;
1034 // RgInfSpsRelInfo relInfo;
1041 U16 totalBytesRcvd = 0;
1042 U16 sduLen[RGU_MAX_LC] = {0};
1043 U8 qciVal[RGU_MAX_LC] = {0};
1050 /* Moved outside of LTE_L2_MEAS
1051 * scope as this pointer will now be used to
1052 * check for valid Logical Channel ID
1069 TRC2(rgTOMUtlProcMsg)
1075 if(pdu->sduLst.first)
1077 sdu = (RgMacSdu*)(pdu->sduLst.first->node);
1079 if ((sdu->lcId == RG_CCCH_LCID))
1081 /* code for common channel dat indications */
1082 if ((ret = rgAllocShrablSBuf (inst,(Data**)&cDatInd, sizeof(RgRguCmnDatInd))) != ROK)
1086 cDatInd->cellId = cellCb->cellId;
1087 cDatInd->rnti = ueCb->ueId;
1088 /* rg001.101: Corrected lcId value for common data indication */
1089 cDatInd->lcId = cellCb->ulCcchId;
1090 cDatInd->pdu = sdu->mBuf;
1091 SFndLenMsg (sdu->mBuf, &ccchSz);
1092 /* Fix : syed Contention resolution ID copy should consider only
1093 * 6 bytes of information from sdu->mBuf. Incase of CCCH sdu for reest
1094 * message/psuedo reest message, ccchSz can go beyond 6 and can corrupt
1095 * other fields of ueCb. */
1096 if (ccchSz >= RG_CRES_LEN)
1098 SCpyMsgFix (sdu->mBuf, (MsgLen)0, RG_CRES_LEN, ueCb->contResId.resId,
1101 #ifdef XEON_SPECIFIC_CHANGES
1102 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.slot);
1105 rgUIMSndCmnDatInd(inst,cellCb->rguUlSap,cDatInd);
1107 } /* end of common channel processing */
1109 if ((ret = rgAllocShrablSBuf (inst,(Data**)&dDatInd, sizeof(RgRguDedDatInd))) != ROK)
1115 elem = SRngGetWIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
1120 dDatInd = (RgRguDedDatInd *)elem;
1121 cmMemset((U8 *)dDatInd, 0x00, sizeof(RgRguDedDatInd));
1123 dDatInd->cellId = cellCb->cellId;
1124 dDatInd->rnti = ueCb->ueId;
1125 dDatInd->numLch = 0;
1128 ulSf = &cellCb->ulSf[(slot % RG_NUM_SUB_FRAMES)];
1129 if(ulSf->ueUlAllocInfo != NULLP)
1131 for(idx1 = 0; idx1 < ulSf->numUe; idx1++)
1133 if(ulSf->ueUlAllocInfo[idx1].rnti == ueCb->ueId)
1135 numPrb = ulSf->ueUlAllocInfo[idx1].numPrb;
1141 node = pdu->sduLst.first;
1144 sdu = (RgMacSdu*)node->node;
1146 ulLcCb = rgDBMGetUlDedLcCb (ueCb, sdu->lcId);
1150 RLOG_ARG2(L_ERROR,DBG_CELLID,cellCb->cellId,"Unconfigured LCID:%d CRNTI:%d"
1151 ,sdu->lcId,ueCb->ueId);
1152 /* ccpu00128443: Fix for memory leak */
1153 /* Fix : syed Neccessary to set sdu->mBuf = NULLP */
1154 RG_FREE_MSG(sdu->mBuf);
1158 #ifdef RLC_STA_PROC_IN_MAC/* RLC Status PDU Processing */
1160 extern S16 kwProcDlStatusPdu(Pst *udxPst,SuId suId,
1161 CmLteCellId cellId,CmLteRnti rnti,CmLteLcId lcId,Buffer *rlcSdu);
1163 if(ROK == kwProcDlStatusPdu(&(cellCb->rguDlSap->sapCfg.sapPst),
1164 cellCb->rguDlSap->sapCfg.suId,
1165 cellCb->cellId,ueCb->ueId,sdu->lcId,sdu->mBuf))
1167 RG_FREE_MSG(sdu->mBuf);
1174 /* ccpu00116477- Fixed the rgUIMSndDedDatInd condition when we receive 11 sdus in the
1175 * list we are losing 11th sdu and sending the first 10 sdus again which
1176 * is causing the duplicate packets and eNB crashing due to access
1177 * of the freed memory */
1178 if (dDatInd->numLch >= RGU_MAX_LC)
1180 if ((ret = rgUIMSndDedDatInd(inst,ueCb->rguUlSap,dDatInd)) != ROK)
1182 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
1183 "Failed to send datIndication to RGU CRNTI:%d",ueCb->ueId);
1187 if ((ret = rgAllocShrablSBuf (inst,(Data**)&dDatInd, sizeof(RgRguDedDatInd))) != ROK)
1192 elem = SRngGetWIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
1197 dDatInd = (RgRguDedDatInd *)elem;
1198 cmMemset((U8 *)dDatInd, 0x00, sizeof(RgRguDedDatInd));
1200 dDatInd->cellId = cellCb->cellId;
1201 dDatInd->rnti = ueCb->ueId;
1202 dDatInd->numLch = 0;
1204 dDatInd->lchData[dDatInd->numLch].lcId = sdu->lcId;
1205 dDatInd->lchData[dDatInd->numLch].pdu.mBuf[dDatInd->lchData[dDatInd->numLch].pdu.numPdu] = sdu->mBuf;
1206 dDatInd->lchData[dDatInd->numLch].pdu.numPdu++;
1207 lcgId = ulLcCb->lcgId;
1208 SFndLenMsg(sdu->mBuf, &bufSz);
1212 ueCb->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs -= bufSz;
1215 //if ((lcgBytes != NULLP) && (ueCb->ul.lcgArr[lcgId].isGbr == TRUE))
1216 if (lcgBytes != NULLP)
1218 lcgBytes[lcgId] += bufSz;
1223 /* Check if data has come on SPS LC */
1224 /* KWORK_FIX: Modified the index from lcId to lcId-1 for handling lcId 10 properly */
1225 if (ueCb->ul.spsLcId[sdu->lcId-1] == TRUE)
1227 ueCb->ul.spsDatRcvd++;
1232 /* Data rcvd on CRNTI*/
1233 /* Retrieve the LCG ID of the LCID*/
1234 /* SPS LCG has data whose size > SID Size */
1235 /* Activate SPS if data recvd on SPS LCID and size > SID Packet Size */
1236 if((ueCb->ul.spsLcId[sdu->lcId-1] == TRUE) &&
1237 (sdu->len > RG_SPS_SID_PACKET_SIZE))
1239 *spsToBeActvtd = TRUE;
1240 *sduSize = sdu->len;
1247 if(cellCb->qciArray[ulLcCb->qci].mask == TRUE)
1249 sduLen[ulLcCb->qci] = sdu->len;
1250 totalBytesRcvd += sdu->len;
1251 qciVal[ulLcCb->qci] = ulLcCb->qci;
1255 } /* end of while for SubHeaders */
1257 for(idx2 = 0; idx2 < RGU_MAX_LC; idx2++)
1259 if((cellCb->qciArray[qciVal[idx2]].mask == TRUE) &&
1262 cellCb->qciArray[qciVal[idx2]].prbCount +=
1263 ((numPrb * sduLen[idx2]) / totalBytesRcvd);
1267 if(totalBytesRcvd > 0 && qciVal[idx2] > 0)
1269 RG_UPD_GBR_PRB(cellCb, qciVal[idx2], ((numPrb * sduLen[idx2])/totalBytesRcvd));
1274 /*Added for explicit release - start*/
1277 if(isSpsRnti && dDatInd && dDatInd->numLch)
1279 if(ueCb->ul.spsDatRcvd != 0)
1281 ueCb->ul.explRelCntr = 0;
1282 ueCb->ul.spsDatRcvd = 0;
1286 ueCb->ul.explRelCntr++;
1287 if (ueCb->ul.explRelCntr == ueCb->ul.explRelCnt)
1289 ueCb->ul.explRelCntr = 0;
1290 /* Indicate scheduler for explicit release */
1291 cmMemset((U8*)&schPst1, (U8)0, sizeof(Pst));
1292 rgGetPstToInst(&schPst1,inst, cellCb->schInstMap.schInst);
1293 //TODO: commented for compilation without SCH
1295 relInfo.cellSapId = cellCb->schInstMap.cellSapId;
1296 relInfo.cRnti = ueCb->ueId;
1297 relInfo.isExplRel = TRUE;
1298 /* Release indicator is called now through the matrix in the function below */
1299 //TODO: commented for compilation without SCH RgMacSchSpsRel( &schPst1, &relInfo );
1301 ueCb->ul.implRelCntr = 0;
1308 if(ueCb->ul.spsDatRcvd != 0)
1310 //ueCb->ul.implRelCntr = 0;
1311 ueCb->ul.explRelCntr = 0;
1312 ueCb->ul.spsDatRcvd = 0;
1316 /*Added for explicit release - end */
1318 if((dDatInd) && (dDatInd->numLch))
1321 rgTomUtlPrepareL2MUlThrpInfo(cellCb, ueCb,dDatInd);
1323 RG_CALC_TTI_CNT(cellCb, dDatInd->ttiCnt);
1325 if ((ret = rgUIMSndDedDatInd(inst,ueCb->rguUlSap,dDatInd)) != ROK)
1327 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
1328 "Failed to send datIndication to RGU CRNTI:%d",ueCb->ueId);
1333 else if((dDatInd) && (0 == dDatInd->numLch))
1335 /* Free the memory allocated for dDatInd if we
1336 * have no valid LCH PDU to send to RLC.*/
1337 rgFreeSharableSBuf(inst,(Data **)&dDatInd,sizeof(RgRguDedDatInd));
1343 /** @brief This function frees up the RgMacPdu structure that has been
1344 * populated by demux.
1348 * Function: rgTOMUtlInsSchInfo
1349 * - Function frees up the RgMacPdu structure, in case of error it shall
1350 * free up the buffer's present in the different sdu.
1353 * @param [in] RgMacPdu *pdu
1354 * @param [in] Bool *error
1359 PRIVATE S16 rgTOMUtlInsSchInfo
1362 RgInfSfDatInd *sfInfo,
1363 RgInfCeInfo *ceInfo,
1370 PRIVATE S16 rgTOMUtlInsSchInfo (pdu, sfInfo, ceInfo, rnti,spsToBeActvtd,sduSize, lcgBytes)
1372 RgInfSfDatInd *sfInfo;
1373 RgInfCeInfo *ceInfo;
1382 PRIVATE S16 rgTOMUtlInsSchInfo
1385 RgInfSfDatInd *sfInfo,
1386 RgInfCeInfo *ceInfo,
1391 PRIVATE S16 rgTOMUtlInsSchInfo (pdu, sfInfo, ceInfo, rnti, lcgBytes)
1393 RgInfSfDatInd *sfInfo;
1394 RgInfCeInfo *ceInfo;
1401 RgInfUeDatInd *ueInfo;
1405 TRC2(rgTOMUtlInsSchInfo);
1407 RG_TOM_INF_ALLOC(sfInfo, sizeof(RgInfUeDatInd), ueInfo, ret);
1414 ueInfo->rnti = rnti;
1416 ueInfo->ceInfo = *ceInfo;
1417 ueInfo->ueLstEnt.node = (PTR)ueInfo;
1418 for (lcgId = 1, idx = 0; lcgId < RGINF_MAX_LCG_PER_UE; lcgId++)
1420 if (lcgBytes[lcgId] != 0)
1422 /* Only GBR bytes */
1423 ueInfo->lcgInfo[idx].lcgId = lcgId;
1424 ueInfo->lcgInfo[idx++].bytesRcvd = lcgBytes[lcgId];
1425 lcgBytes[lcgId] = 0;
1428 cmLListAdd2Tail(&sfInfo->ueLst, &ueInfo->ueLstEnt);
1430 } /* end of rgTOMUtlInsSchInfo */
1434 * @brief Handler for processing data indication recieved from PHY for UEs.
1438 * Function: rgTOMDatInd
1440 * Handler for processing data indication recieved from PHY for UEs.
1442 * Invoked by: RgLiTfuDatInd of LIM
1445 * For each DataInfo recieved
1446 * - Validate the information received and retrieve cellCb
1447 * Validate cellId, rnti
1448 * - Call De-Mux module to decode the data rgDUXDemuxData
1449 * - If received a CRNTI control element
1450 * - Check if a CCCH SDU is present, if it is return failure
1451 * - Check for the existence of UE, if its isnt present return failure.
1452 * - Delegate the remaining processing to rgTOMUtlProcMsg3 which
1453 * primarily informs the scheduler about the data received and
1454 * generates Data indications towards the higher layer.
1455 * - If only CCCH SDU is present
1456 * - Invoke rgTOMUtlProcMsg3 for further processing.
1457 * - If its a non-Msg3 PDU i.e. received outside of a RA procedure
1458 * - Retrieve the UeCB
1459 * - Validate that the received PDU contains only configured Logical
1461 * - Invoke rgTOMUtlProcDatPdu for further processing. It informs the
1462 * scheduler with the information of the received Data and generates
1463 * DatIndications towards the higher layers.
1465 * @param [in] Inst inst
1466 * @param[in] TfuDatIndInfo *datInd
1472 PUBLIC S16 rgTOMDatInd
1475 TfuDatIndInfo *datInd
1478 PUBLIC S16 rgTOMDatInd(inst,datInd)
1480 TfuDatIndInfo *datInd;
1486 RgUeCb *prevUeCb = NULLP;
1489 RgInfSfDatInd *sfInfo;
1493 TfuDatInfo *datInfo;
1497 Bool isSpsRnti=FALSE;
1499 // RgInfSpsRelInfo relInfo;
1500 Bool spsToBeActvtd = FALSE;
1503 U32 lcgBytes[RGINF_MAX_LCG_PER_UE];
1507 #ifdef STUB_TTI_HANDLING_5GTF
1508 node = datInd->datIndLst.first;
1509 for (;node; node=node->next)
1511 datInfo = (TfuDatInfo*)node->node;
1514 SFndLenMsg(datInfo->mBuf, &len);
1515 rgUlrate_tfu += len;
1516 if (rgUlrate_tfu > 100000)
1518 printf("Sowmya:rgTOMDatInd datInfo->mBuf len =%d rgUlrate_tfu=%d",len,rgUlrate_tfu);
1526 cmMemset((U8 *)&lcgBytes, 0, sizeof(lcgBytes));
1528 tfuSap = &(rgCb[inst].tfuSap);
1530 cellCb = rgCb[inst].cell;
1531 if((cellCb == NULLP) ||
1532 (cellCb->cellId != datInd->cellId))
1535 RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"Unable to get the cellCb for cell");
1538 /* Avoiding memset as all the fields are getting initialized further */
1540 if (rgTOMInfAllocPduEvnt (inst,&sfInfo) != ROK)
1542 err.errType = RGERR_TOM_DATIND;
1543 RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"Unable to Allocate PDU for DUX cell");
1544 node = datInd->datIndLst.first;
1547 cmLListInit(&sfInfo->ueLst);
1548 sfInfo->cellId = datInd->cellId;
1549 sfInfo->timingInfo = datInd->timingInfo;
1550 slot = datInd->timingInfo.slot;
1552 node = datInd->datIndLst.first;
1553 for (;node; node=node->next)
1555 datInfo = (TfuDatInfo*)node->node;
1557 //extern U32 ulrate_tfu;
1559 SFndLenMsg(datInfo->mBuf, &len);
1560 #ifdef STUB_TTI_HANDLING_5GTF
1561 // printf("Sowmya:rgTOMDatInd datInfo->mBuf len =%d",len);
1563 rgUlrate_tfu += len;
1565 grgUlrate_tfu += len;
1568 #ifdef STUB_TTI_HANDLING_5GTF
1569 rgLIMUtlFreeDatIndEvnt(datInd,TRUE);
1571 /* We shall call De-Mux to process the received buffer. We shall try and find
1572 * out the RaCb based on the following -
1573 * 1. If the incoming PDU contained a CCCH SDU i.e. this is message 3.
1574 * 2. If the incoming PDU contained a CRNTI control element, i.e. we should
1575 * have a ueCb also for this
1577 /* Lets allocate the event that needs to be passed to DUX */
1578 if (rgTOMUtlAllocPduEvnt (inst,&pdu) != ROK)
1580 err.errType = RGERR_TOM_DATIND;
1581 RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"Unable to Allocate PDU for DUX cell");
1582 rgTOMInfFreePduEvnt (sfInfo);
1586 if ((ret = rgDUXDemuxData (inst,pdu, &ceInfo,
1587 &datInfo->mBuf, &err)) != ROK)
1590 /* Fix: sriky memory corruption precautions */
1591 rgTOMUtlFreePduEvnt (pdu, TRUE);
1592 err.errType = RGERR_TOM_DATIND;
1593 RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"DUX processing failed");
1594 tfuSap->sapSts.numPduDrop++;
1597 /* It could be that a non-msg3 pdu contains a CRNTI Control element. We
1598 * should check for CRNTI CE and if it exists the UECb must exist, also an
1599 * if the CRNTI in the CE and the one with which the message came in are
1600 * different we shall look for an raCb as well.
1603 if (ceInfo.bitMask & RG_CCCH_SDU_PRSNT)
1605 ret = rgTOMProcCCCHSduInDatInd(pdu, prevUeCb, \
1606 cellCb, datInfo, &ceInfo, slot);
1609 rgTOMUtlFreePduEvnt (pdu, TRUE);
1610 err.errType = RGERR_TOM_DATIND;
1611 tfuSap->sapSts.numPduDrop++;
1614 } /* end of Msg3 processing */
1616 else if (ceInfo.bitMask & RG_CRNTI_CE_PRSNT)
1618 ret = rgTOMProcCrntiCEInDatInd(pdu, prevUeCb, \
1619 cellCb, datInfo, &ceInfo, slot);
1622 rgTOMUtlFreePduEvnt (pdu, TRUE);
1623 err.errType = RGERR_TOM_DATIND;
1624 tfuSap->sapSts.numPduDrop++;
1628 } /* end of CRNTI based message */
1631 ueCb = rgDBMGetUeCb (cellCb, datInfo->rnti);
1635 /* Try getting the UE using SPS-RNTI. */
1636 ueCb = rgDBMGetSpsUeCb (cellCb, datInfo->rnti);
1640 /* Increment implrelCntr for an empty transmission */
1641 if (pdu->sduLst.count == 0)
1643 ueCb->ul.implRelCntr++;
1644 if (ueCb->ul.implRelCntr == ueCb->ul.implRelCnt)
1646 /* Indicate scheduler for implicit release */
1647 cmMemset((U8*)&schPst1, (U8)0, sizeof(Pst));
1648 rgGetPstToInst(&schPst1,inst, cellCb->schInstMap.schInst);
1650 ueCb->ul.implRelCntr = 0;
1651 ueCb->ul.explRelCntr = 0;
1653 relInfo.cellSapId = cellCb->schInstMap.cellSapId;
1654 relInfo.cRnti = ueCb->ueId;
1655 relInfo.isExplRel= FALSE;
1656 //TODO: commented for compilation without SCH RgMacSchSpsRel(&schPst1, &relInfo);
1662 /* Reset the implrelCntr */
1663 ueCb->ul.implRelCntr = 0;
1669 /* Perform failure if ueCb is still NULLP */
1670 rgTOMUtlFreePduEvnt (pdu, TRUE);
1671 err.errType = RGERR_TOM_DATIND;
1672 RLOG_ARG1(L_ERROR,DBG_CELLID,datInd->cellId,"RNTI:%d Unable to get the UE CB",
1674 tfuSap->sapSts.numPduDrop++;
1679 rgTOMUtlL2MStoreBufSz(ueCb, &ceInfo);
1680 rgTOML2MCompileActiveLCs (cellCb, ueCb, pdu, &ceInfo);
1683 if ((ret = rgTOMUtlProcMsg(cellCb, ueCb, pdu, isSpsRnti,&spsToBeActvtd,&sduSize, slot, (U32 *)&lcgBytes)) != ROK)
1685 if ((ret = rgTOMUtlProcMsg (cellCb, ueCb, pdu, slot, (U32 *)&lcgBytes)) != ROK)
1686 #endif /* LTEMAC_SPS */
1688 rgTOMUtlFreePduEvnt (pdu, TRUE);
1689 err.errType = RGERR_TOM_DATIND;
1690 RLOG_ARG1(L_ERROR,DBG_CELLID,datInd->cellId,
1691 "Unable to handle Data Indication CRNTI:%d",ueCb->ueId);
1692 tfuSap->sapSts.numPduDrop++;
1699 if(rgTOMUtlInsSchInfo(pdu, sfInfo, &ceInfo, datInfo->rnti,spsToBeActvtd,sduSize, (U32 *)&lcgBytes) != ROK)
1701 if(rgTOMUtlInsSchInfo(pdu, sfInfo, &ceInfo, datInfo->rnti, (U32 *)&lcgBytes) != ROK)
1705 rgTOMInfFreePduEvnt (sfInfo);
1706 rgTOMUtlFreePduEvnt (pdu, FALSE);
1709 /* free up the PDU memory */
1710 rgTOMUtlFreePduEvnt (pdu, FALSE);
1712 /* Free the allocated memory for ueUlAllocInfo here */
1714 if(cellCb->ulSf[(slot % RG_NUM_SUB_FRAMES)].ueUlAllocInfo != NULLP)
1716 /*ccpu00117052 - MOD - Passing double for proper NULLP
1718 rgFreeSBuf(inst,(Data **)&(cellCb->ulSf[(slot % RG_NUM_SUB_FRAMES)].ueUlAllocInfo),
1719 ((cellCb->ulSf[(slot % RG_NUM_SUB_FRAMES)].numUe) * sizeof(RgUeUlAlloc)));
1723 /* Update PRB used for all GBR QCIs to scheduler */
1724 cmMemcpy((U8*) &sfInfo->qcisUlPrbCnt[0],
1725 (U8*) &cellCb->qcisUlPrbCnt[0],
1726 (RGM_MAX_QCI_REPORTS * sizeof(U32)));
1727 /* clear the cellCb ul prb value */
1728 cmMemset((U8*)&cellCb->qcisUlPrbCnt[0], 0,
1729 (RGM_MAX_QCI_REPORTS * sizeof(U32)));
1733 rgGetPstToInst(&schPst, inst,cellCb->schInstMap.schInst);
1734 sfInfo->cellSapId = cellCb->schInstMap.cellSapId;
1735 //TODO: commented for compilation without SCH RgMacSchSfRecp(&schPst, sfInfo);
1740 * @brief Function handles allocation for common channels i.e. BCCH-BCH,
1741 * BCCH-DLSCH, PCCH-DLSCH.
1745 * Function : rgHndlCmnChnl
1747 * This function is invoked from RgSchMacSfAllocReq. This function handles
1748 * allocations made for common channels like BCCH and PCCH.
1751 * 1. If BCCH on BCH has been scheduled, send StatusIndication on RGU.
1752 * 2. If PCCH is scheduled, send StatusIndication on RGU.
1753 * 3. If BCCH on DLSCH has been scheduled and sndStatInd is TRUE, send
1754 * StatusIndication on RGU, else copy the bcch buffer onto the downlink
1758 * @param[in] RgCellCb *cell,
1759 * @param[in] CmLteTimingInfo timingInfo,
1760 * @param[in] RgInfCmnLcInfo *cmnLcInfo,
1761 * @param[in/out] RgErrInfo *err,
1767 PRIVATE S16 rgHndlCmnChnl
1770 CmLteTimingInfo timingInfo,
1771 RgInfCmnLcInfo *cmnLcInfo,
1775 PRIVATE S16 rgHndlCmnChnl(cell, timingInfo, cmnLcInfo, err)
1777 CmLteTimingInfo timingInfo;
1778 RgInfCmnLcInfo *cmnLcInfo;
1782 #if (ERRCLASS & ERRCLS_DEBUG)
1786 RgBcchDlschLcCb *bcch;
1787 #if (ERRCLASS & ERRCLS_DEBUG)
1790 #endif/*RGR_SI_SCH*/
1791 RguCStaIndInfo *staInd;
1793 Inst inst = cell->macInst - RG_INST_START;
1797 dlSf = &cell->subFrms[(timingInfo.slot % RG_NUM_SUB_FRAMES)];
1799 if(cmnLcInfo->bitMask & RGINF_BCH_INFO)
1802 #if (ERRCLASS & ERRCLS_DEBUG)
1803 if(NULLP == (bch = rgDBMGetBcchOnBch(cell)))
1807 if(cmnLcInfo->bchInfo.lcId != bch->lcId)
1813 if (rgAllocShrablSBuf (inst,(Data**)&staInd, sizeof(RguCStaIndInfo)) != ROK)
1815 err->errCause = RGERR_TOM_MEM_EXHAUST;
1818 staInd->cellId = cell->cellId;
1819 staInd->rnti = RG_INVALID_RNTI;
1820 staInd->lcId = cmnLcInfo->bchInfo.lcId;
1821 staInd->transId = (timingInfo.sfn << 8) | (timingInfo.slot);
1822 /* ADD Changes for Downlink UE Timing Optimization */
1823 #ifdef LTEMAC_DLUE_TMGOPTMZ
1824 dlSf->remDatReqCnt++;
1826 if (rgUIMSndCmnStaInd (inst,cell->rguDlSap,staInd) != ROK)
1831 /*Store the received BCH Data in the scheduled subframe*/
1832 dlSf->bch.tb = cmnLcInfo->bchInfo.pdu;
1833 #endif/*RGR_SI_SCH*/
1836 if(cmnLcInfo->bitMask & RGINF_PCCH_INFO)
1838 #if (ERRCLASS & ERRCLS_DEBUG)
1839 if(NULLP == (pcch = rgDBMGetPcch(cell)))
1843 if(cmnLcInfo->pcchInfo.lcId != pcch->lcId)
1849 dlSf->pcch.pdcch.rnti =
1850 cmnLcInfo->pcchInfo.rnti;
1851 dlSf->pcch.pdcch.dci =
1852 cmnLcInfo->pcchInfo.dciInfo;
1854 /* ccpu00132314-ADD-Fill the tx Pwr offset from scheduler */
1855 dlSf->pcch.txPwrOffset = cmnLcInfo->pcchInfo.txPwrOffset;
1857 if (rgAllocShrablSBuf (inst,(Data**)&staInd, sizeof(RguCStaIndInfo)) != ROK)
1859 err->errCause = RGERR_TOM_MEM_EXHAUST;
1862 staInd->cellId = cell->cellId;
1863 staInd->rnti = RG_INVALID_RNTI;
1864 staInd->lcId = cmnLcInfo->pcchInfo.lcId;
1865 staInd->transId = (timingInfo.sfn << 8) | (timingInfo.slot);
1866 /* ADD Changes for Downlink UE Timing Optimization */
1867 #ifdef LTEMAC_DLUE_TMGOPTMZ
1868 dlSf->remDatReqCnt++;
1870 /* for consolidated CmnStaInd calling below function from function
1871 * rgHndlSchedUe once CmnStaInd prepared for all UEs
1873 if (rgUIMSndCmnStaInd (inst,cell->rguDlSap,staInd) != ROK)
1879 if(cmnLcInfo->bitMask & RGINF_BCCH_INFO)
1881 dlSf->bcch.pdcch.rnti =
1882 cmnLcInfo->bcchInfo.rnti;
1883 dlSf->bcch.pdcch.dci =
1884 cmnLcInfo->bcchInfo.dciInfo;
1886 /* ccpu00132314-ADD-Fill the tx Pwr offset from scheduler */
1887 dlSf->bcch.txPwrOffset = cmnLcInfo->bcchInfo.txPwrOffset;
1891 (bcch=rgDBMGetBcchOnDlsch(cell,cmnLcInfo->bcchInfo.lcId)))
1895 if(TRUE == cmnLcInfo->bcchInfo.sndStatInd)
1897 RG_FREE_MSG(bcch->tb);
1898 if (rgAllocShrablSBuf (inst,(Data**)&staInd,
1899 sizeof(RguCStaIndInfo)) != ROK)
1901 err->errCause = RGERR_TOM_MEM_EXHAUST;
1904 staInd->cellId = cell->cellId;
1905 staInd->rnti = RG_INVALID_RNTI;
1906 staInd->lcId = cmnLcInfo->bcchInfo.lcId;
1907 staInd->transId = (timingInfo.sfn << 8) | (timingInfo.slot);
1908 /* ADD Changes for Downlink UE Timing Optimization */
1909 #ifdef LTEMAC_DLUE_TMGOPTMZ
1910 dlSf->remDatReqCnt++;
1912 if (rgUIMSndCmnStaInd (inst,cell->rguDlSap,staInd) != ROK)
1919 SCpyMsgMsg(bcch->tb, RG_GET_MEM_REGION(rgCb[inst]),
1920 RG_GET_MEM_POOL(rgCb[inst]), &dlSf->bcch.tb);
1923 /*Store the received BCCH Data in the scheduled subframe*/
1924 dlSf->bcch.tb = cmnLcInfo->bcchInfo.pdu;
1925 #endif/*RGR_SI_SCH*/
1929 } /* end of rgHndlCmnChnl */
1932 * @brief Function for handling allocations for dedicated channels for a
1937 * Function : rgHndlSchdUe
1939 * This function shall be invoked whenever scheduler is done with the
1940 * allocations of dedicated channels for a subframe. Invoked by the function
1941 * RgSchMacSfAllocReq.
1943 * Processing steps :
1944 * 1. Loops through the list of UE's scheduled looking for the corresponding
1946 * 2. Finds the corresponding HARQ process.
1947 * 3. Invokes the DHM function to issue StatusIndications on RGU.
1950 * @param[in] RgCellCb *cell,
1951 * @param[in] CmLteTimingInfo timingInfo,
1952 * @param[in] RgInfUeInfo *ueInfo
1953 * @param[in/out] RgErrInfo *err
1959 PRIVATE S16 rgHndlSchdUe
1962 CmLteTimingInfo timingInfo,
1963 RgInfUeInfo *ueInfo,
1967 PRIVATE S16 rgHndlSchdUe(cell, timingInfo, ueInfo, err) /* laa_ut_fix */
1969 CmLteTimingInfo timingInfo;
1970 RgInfUeInfo *ueInfo;
1977 if(NULLP == ueInfo->allocInfo)
1982 rgDHMSndConsolidatedStaInd(cell, ueInfo, timingInfo, err);
1985 } /* end of rgHndlSchdUe */
1989 * @brief Function for handling Uplink allocations for Ue for a
1994 * Function : rgHndlUlUeInfo
1996 * @param[in] RgCellCb *cell,
1997 * @param[in] CmLteTimingInfo timingInfo,
1998 * @param[in] RgInfUlUeInfo *ueInfo
2004 PRIVATE S16 rgHndlUlUeInfo
2007 CmLteTimingInfo timingInfo,
2008 RgInfUlUeInfo *ueInfo
2011 PRIVATE S16 rgHndlUlUeInfo(cell, timingInfo, ueInfo)
2013 CmLteTimingInfo timingInfo;
2014 RgInfUlUeInfo *ueInfo;
2017 Inst inst = cell->macInst - RG_INST_START;
2022 TRC2(rgHndlUlUeInfo)
2024 ulSf = &cell->ulSf[(timingInfo.slot % RGSCH_NUM_SUB_FRAMES)];
2026 /* rg003.301-MOD- Corrected the purifier memory leak */
2027 if (ulSf->numUe != ueInfo->numUes)
2029 if (ulSf->ueUlAllocInfo)
2031 rgFreeSBuf(inst,(Data **)&(ulSf->ueUlAllocInfo),
2032 ulSf->numUe * sizeof(RgUeUlAlloc));
2035 #ifdef XEON_SPECIFIC_CHANGES
2036 CM_MEAS_TIME((cell->crntTime.slot % RGSCH_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MEAS_FREE);
2037 CM_ADD_INFO((cell->crntTime.slot % RGSCH_NUM_SUB_FRAMES), CM_DBG_MEAS_FREE, ulSf->numUe);
2039 ulSf->numUe = ueInfo->numUes;
2040 if((ulSf->ueUlAllocInfo == NULLP) && (ueInfo->numUes > 0))
2042 /* Allocate memory for ulAllocInfo */
2043 if((ret = rgAllocSBuf(inst,(Data**)&(cell->ulSf[(timingInfo.slot % RGSCH_NUM_SUB_FRAMES)].
2044 ueUlAllocInfo), ueInfo->numUes * sizeof(RgUeUlAlloc))) != ROK)
2049 #ifdef XEON_SPECIFIC_CHANGES
2050 CM_MEAS_TIME((cell->crntTime.slot % RGSCH_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MEAS_ALLOC);
2051 CM_ADD_INFO((cell->crntTime.slot % RGSCH_NUM_SUB_FRAMES), CM_DBG_MEAS_ALLOC, ueInfo->numUes);
2053 if (ulSf->ueUlAllocInfo != NULLP)
2055 for(idx = 0; idx < ueInfo->numUes; idx++)
2057 ulSf->ueUlAllocInfo[idx].rnti = ueInfo->ulAllocInfo[idx].rnti;
2058 ulSf->ueUlAllocInfo[idx].numPrb = ueInfo->ulAllocInfo[idx].numPrb;
2061 RGCPYTIMEINFO(timingInfo, ulSf->schdTime);
2063 } /* end of rgHndlUlUeInfo */
2066 * @brief Function for handling RaResp request received from scheduler to MAC
2070 * Function : rgTOMRlsSf
2072 * This function shall be invoked whenever scheduler is done with the
2073 * allocations of random access responses for a subframe.
2074 * This shall invoke RAM to create ueCbs for all the rapIds allocated and
2075 * shall invoke MUX to create RAR PDUs for raRntis allocated.
2078 * @param[in] Inst inst
2079 * @param[in] CmLteCellId cellId,
2080 * @param[in] CmLteTimingInfo timingInfo,
2081 * @param[in] RaRespInfo *rarInfo
2086 PUBLIC Void rgTOMRlsSf
2092 PUBLIC Void rgTOMRlsSf(dlSf)
2101 if(dlSf->txDone == FALSE)
2103 RLOG0(L_ERROR, "SUBFRAME Not pushed to the PHY");
2105 if (dlSf->bch.tb != NULLP)
2107 RG_FREE_MSG(dlSf->bch.tb);
2109 if (dlSf->bcch.tb != NULLP)
2111 RG_FREE_MSG(dlSf->bcch.tb);
2113 if (dlSf->pcch.tb != NULLP)
2115 RG_FREE_MSG(dlSf->pcch.tb);
2118 rgTOMEmtcRlsSf(dlSf);
2120 for(idx=0; idx < dlSf->numRaRsp; idx++)
2122 RG_FREE_MSG(dlSf->raRsp[idx].rar);
2125 /* ADD Changes for Downlink UE Timing Optimization */
2126 #ifdef LTEMAC_DLUE_TMGOPTMZ
2127 dlSf->remDatReqCnt = 0;
2128 /* Fix[ccpu00126310]: Tracks Data Requests from RLC for both loosely and tight coupled
2130 dlSf->statIndDone = FALSE;
2132 if (dlSf->tbs.count)
2137 RGDBGERRNEW(inst, (rgPBuf(inst),
2138 "Error Stale TBs in Subframes TBS list\n"));
2139 node = dlSf->tbs.first;
2142 hqP = (RgDlHqProcCb*)node->node;
2146 for(i=0;i< RG_MAX_TB_PER_UE;i++)
2148 if (hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sf == dlSf)
2150 cmLListDelFrm(&dlSf->tbs, &(hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sfLnk));
2151 hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sfLnk.node = NULLP;
2152 printf("\n rgTOMRlsSf:: hqP %p \n", (Void *)hqP);
2154 hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sf = NULLP;
2159 /*arjun: check if dlSf laaTb list has to be freed???*/
2160 cmLListInit(&dlSf->tbs);
2161 dlSf->txDone = FALSE;
2167 * @brief Function is called by the scheduler once it has completed the
2168 * allocation for the subframe.
2172 * Function : rgHndlFlowCntrl
2173 * This function should fill and send Flow control
2177 * @param[in] Pst *cell
2178 * @param[in] RgInfSfAlloc *sfInfo Carries all the allocation
2184 PUBLIC S16 rgHndlFlowCntrl
2187 RgInfSfAlloc *sfInfo
2190 PUBLIC S16 rgHndlFlowCntrl(cell, sfInfo)
2192 RgInfSfAlloc *sfInfo;
2195 RguFlowCntrlInd *flowCntrlInd;
2199 TRC3(rgHndlFlowCntrl);
2201 pst = &cell->rguDlSap->sapCfg.sapPst;
2202 /* flowCntrlInd is alloced in cell init time and will be re-used throughout */
2203 flowCntrlInd = cell->flowCntrlInd;
2204 flowCntrlInd->cellId = sfInfo->cellId;
2205 flowCntrlInd->numUes = sfInfo->flowCntrlInfo.numUes;
2207 for (ueIdx = 0; ueIdx < sfInfo->flowCntrlInfo.numUes; ueIdx++)
2209 flowCntrlInd->ueFlowCntrlInfo[ueIdx].ueId = sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].ueId;
2210 flowCntrlInd->ueFlowCntrlInfo[ueIdx].numLcs = sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].numLcs;
2212 for (lcIdx = 0; lcIdx < RGINF_MAX_NUM_DED_LC; lcIdx++)
2214 flowCntrlInd->ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].lcId =
2215 sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].lcId;
2216 flowCntrlInd->ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].pktAdmitCnt =
2217 sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].pktAdmitCnt;
2219 flowCntrlInd->ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].maxBo4FlowCtrl =
2220 sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].maxBo4FlowCtrl;
2223 RgUiRguFlowCntrlInd(pst, cell->rguDlSap->sapCfg.spId,flowCntrlInd); /* TODO: Rishi confirm if the suId and pst pointer is correct */
2227 * @brief Function is called by the scheduler once it has completed the
2228 * allocation for the subframe.
2232 * Function : RgSchMacSfAllocReq
2234 * This function shall be invoked whenever scheduler is done with the
2235 * allocations of for a subframe. The sfInfo carries all the allocation
2236 * details for the common channels, RA responses and dedicated channel
2239 * Processing steps :
2240 * 1. Reset the information present in the downlink subframe that is
2242 * 2. Handle common channel allocations
2243 * 3. Handle RA Response allocations
2244 * 4. Handle dedicated channel allocations.
2246 * @param[in] Pst *pst
2247 * @param[in] RgInfSfAlloc *sfInfo Carries all the allocation
2253 PUBLIC S16 RgSchMacSfAllocReq
2256 RgInfSfAlloc *sfInfo
2259 PUBLIC S16 RgSchMacSfAllocReq(pst, sfInfo)
2261 RgInfSfAlloc *sfInfo;
2267 VOLATILE U32 startTime=0;
2270 TRC2(RgSchMacSfAllocReq)
2272 RG_IS_INST_VALID(pst->dstInst);
2273 inst = pst->dstInst - RG_INST_START;
2275 SStartTask(&startTime, PID_MAC_SF_ALLOC_REQ);
2282 if((cell = rgCb[inst].cell) == NULLP)
2284 RLOG_ARG0(L_ERROR,DBG_CELLID,sfInfo->cellId, "No cellCb found with cell");
2288 dlSf = &cell->subFrms[(sfInfo->timingInfo.slot % RG_NUM_SUB_FRAMES)];
2290 rgTOMRlsSf(inst,dlSf);
2291 dlSf->schdTime = sfInfo->timingInfo;
2294 rgLaaInitTbInfoLst(cell);
2297 /* Fix : syed Ignore Failure Returns and continue processing.
2298 * Incomplete processing results in state sync loss between MAC-SCH. */
2300 if(TRUE == cell->emtcEnable)
2302 rgEmtcHndl(cell, sfInfo);
2305 rgHndlCmnChnl(cell, sfInfo->timingInfo, &sfInfo->cmnLcInfo, &err);
2307 rgHndlRaResp(cell, sfInfo->timingInfo, &sfInfo->rarInfo, &err);
2310 #ifdef XEON_SPECIFIC_CHANGES
2311 CM_MEAS_TIME((cell->crntTime.slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_B4_UE_SCHD);
2313 rgHndlSchdUe(cell, sfInfo->timingInfo, &sfInfo->ueInfo, &err);
2314 #ifdef XEON_SPECIFIC_CHANGES
2315 CM_MEAS_TIME((cell->crntTime.slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_UE_SCHD);
2317 rgLaaChkAndReqTbs(dlSf,cell, inst);
2320 rgHndlSchdUe(cell, sfInfo->timingInfo, &sfInfo->ueInfo, &err);
2324 if(rgHndlUlUeInfo(cell, sfInfo->ulUeInfo.timingInfo,
2325 &sfInfo->ulUeInfo) != ROK)
2330 #ifdef XEON_SPECIFIC_CHANGES
2331 CM_MEAS_TIME((cell->crntTime.slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_MEAS);
2333 /* Fix[ccpu00126310]: Tracks Data Requests from RLC for both loosely and tight coupled
2337 /* Added the handling for pushing down
2338 * TFU Data request in the retransmission only scenario.*/
2339 #ifdef LTEMAC_DLUE_TMGOPTMZ
2340 dlSf->statIndDone = TRUE;
2341 /* Fix [ccpu00126310]: Tracks Data Requests from RLC for both loosely and tight coupled
2343 if(!(dlSf->txDone) &&
2345 (TRUE == rgLaaChkAllRxTbs(dlSf)) &&
2347 (0 == dlSf->remDatReqCnt) && (dlSf->statIndDone) &&
2348 (RG_TIMEINFO_SAME(cell->crntTime, dlSf->schdTime)))
2350 /*This is the case of rettransmission, so no need
2351 * to wait for TTI Ind to push TFU Data Request. Send
2353 if (ROK != rgTOMUtlProcDlSf (dlSf, cell, &err))
2355 RLOG_ARG0(L_ERROR,DBG_CELLID,cell->cellId,"Unable to process downlink subframe for cell");
2356 err.errType = RGERR_ROM_DEDDATREQ;
2358 /* Mark this frame as sent */
2359 dlSf->txDone = TRUE;
2362 if (sfInfo->flowCntrlInfo.numUes > 0)
2364 rgHndlFlowCntrl(cell,sfInfo);
2367 SStopTask(startTime, PID_MAC_SF_ALLOC_REQ);
2369 } /* end of RgSchMacSfAllocReq */
2371 * @brief Handler for processing data indication recieved from PHY for UEs.
2375 * Function: rgTOMProcCrntiCEInDatInd
2377 * Handler for processing data indication recieved from PHY for UEs.
2379 * Invoked by: RgLiTfuDatInd of LIM
2382 * For each DataInfo recieved
2383 * - If received a CRNTI control element
2384 * - Check if a CCCH SDU is present, if it is return failure
2385 * - Check for the existence of UE, if its isnt present return failure.
2386 * - Delegate the remaining processing to rgTOMUtlProcMsg3 which
2387 * primarily informs the scheduler about the data received and
2388 * generates Data indications towards the higher layer.
2390 * @param RgMacPdu *pdu,
2391 * @param RgUeCb *prevUeCb,
2392 * @param RgCellCb *cellCb,
2393 * @param TfuDatInfo *datInfo,
2394 * @param RgInfCeInfo *ceInfo
2400 PRIVATE S16 rgTOMProcCrntiCEInDatInd
2405 TfuDatInfo *datInfo,
2406 RgInfCeInfo *ceInfo,
2410 PRIVATE S16 rgTOMProcCrntiCEInDatInd( pdu, prevUeCb, cellCb, datInfo, ceInfo, slot)
2414 TfuDatInfo *datInfo;
2415 RgInfCeInfo *ceInfo;
2419 RgUeCb *ueCb = NULLP;
2420 Inst inst = cellCb->macInst - RG_INST_START;
2428 TRC2(rgTOMProcCrntiCEInDatInd)
2434 ueCb = rgDBMGetUeCbFromRachLst (cellCb, datInfo->rnti);
2438 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2439 "RNTI:%d Received MSG3 with CRNTI,unable to find ueCb", ceInfo->ces.cRnti);
2443 prevUeCb = rgDBMGetUeCb (cellCb, ceInfo->ces.cRnti);
2444 if (prevUeCb == NULLP)
2446 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2447 "RNTI:%d Received MSG3 with CRNTI,unable to find ueCb", ceInfo->ces.cRnti);
2450 RLOG_ARG2(L_DEBUG,DBG_CELLID,cellCb->cellId,
2451 "CRNTI CE(%d) received through tmpCrnti(%d)",
2452 ceInfo->ces.cRnti, datInfo->rnti);
2453 rgDBMDelUeCbFromRachLst(cellCb, ueCb);
2454 rgRAMFreeUeCb(inst,ueCb);
2457 if ((rgTOMUtlProcMsg(cellCb, ueCb, pdu, FALSE,&spsToBeActvtd,&sduSize, slot, NULLP)) != ROK)
2459 if ((rgTOMUtlProcMsg (cellCb, ueCb, pdu, slot, NULLP)) != ROK)
2460 #endif /* LTEMAC_SPS */
2462 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2463 "RNTI:%d Processing for MSG3 failed",datInfo->rnti);
2469 * @brief Handler for processing data indication recieved from PHY for UEs.
2473 * Function: rgTOMProcCCCHSduInDatInd
2475 * Handler for processing data indication recieved from PHY for UEs.
2477 * Invoked by: RgLiTfuDatInd of LIM
2480 * For each DataInfo recieved
2481 * - If only CCCH SDU is present
2482 * - Invoke rgTOMUtlProcMsg3 for further processing.
2483 * - If its a non-Msg3 PDU i.e. received outside of a RA procedure
2484 * - Retrieve the UeCB
2485 * - Validate that the received PDU contains only configured Logical
2487 * - Invoke rgTOMUtlProcDatPdu for further processing. It informs the
2488 * scheduler with the information of the received Data and generates
2489 * DatIndications towards the higher layers.
2491 * @param TfuDatIndInfo *datInd
2492 * @param RgMacPdu *pdu,
2493 * @param RgUeCb *prevUeCb,
2494 * @param RgCellCb *cellCb,
2495 * @param TfuDatInfo *datInfo,
2496 * @param RgInfCeInfo *ceInfo
2502 PRIVATE S16 rgTOMProcCCCHSduInDatInd
2507 TfuDatInfo *datInfo,
2508 RgInfCeInfo *ceInfo,
2512 PRIVATE S16 rgTOMProcCCCHSduInDatInd( pdu, prevUeCb, cellCb, datInfo, ceInfo, slot)
2516 TfuDatInfo *datInfo;
2517 RgInfCeInfo *ceInfo;
2521 RgUeCb *ueCb = NULLP;
2522 Inst inst = cellCb->macInst - RG_INST_START;
2530 TRC2(rgTOMProcCCCHSduInDatInd)
2536 if (ceInfo->bitMask & RG_CRNTI_CE_PRSNT)
2538 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2539 "CRNTI:%d Received MSG3 with CCCH",ceInfo->ces.cRnti);
2543 ueCb = rgDBMGetUeCbFromRachLst (cellCb, datInfo->rnti);
2547 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2548 "RNTI:%d Processing for MSG3 failed", datInfo->rnti);
2551 /* Fix: syed Drop any duplicate Msg3(CCCH Sdu) */
2552 if (ueCb->dl.hqEnt.numHqProcs)
2554 /* HqE is already initialized by a previuos Msg3 */
2555 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"RNTI:%d Processing for MSG3 failed. Duplicate "
2556 "MSG3 received. Dropping", datInfo->rnti);
2560 if(rgDHMHqEntInit(inst,&ueCb->dl.hqEnt,
2561 cellCb->maxDlHqProcPerUe) != ROK)
2563 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"RNTI:%d Harq Initialization failed ",
2567 RLOG_ARG1(L_DEBUG,DBG_CELLID,cellCb->cellId,
2568 "CCCH SDU received through tmpCrnti(%d)",datInfo->rnti);
2570 if ((rgTOMUtlProcMsg(cellCb, ueCb, pdu, FALSE,&spsToBeActvtd,&sduSize, slot, NULLP)) != ROK)
2572 if ((rgTOMUtlProcMsg (cellCb, ueCb, pdu, slot, NULLP)) != ROK)
2573 #endif /* LTEMAC_SPS */
2575 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"RNTI:%d Processing for MSG3 failed",
2584 /** @brief This function captures the BSR value from Control Element
2585 * Info structure and updates the effective Buffer size into the
2586 * corresponding LCG ID.
2590 * Function: rgTOMUtlL2MStoreBufSz
2593 * - update/append the Data structure based on BSR type
2595 * @param [in] RgUeCb *ueCb
2596 * @param [in] RgInfCeInfo *ceInfo
2601 PRIVATE S16 rgTOMUtlL2MStoreBufSz
2607 PRIVATE S16 rgTOMUtlL2MStoreBufSz (ueCb, ceInfo)
2609 RgInfCeInfo *ceInfo;
2614 TRC2(rgTOMUtlL2MStoreBufSz);
2616 if(ceInfo->bitMask & RG_TRUNC_BSR_CE_PRSNT)
2618 lcgId = ((ceInfo->ces.bsr.truncBsr >> 6) & 0x03);
2619 bsr = ceInfo->ces.bsr.truncBsr & 0x3F;
2620 ueCb->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs = rgLwrBsrTbl[bsr];
2622 else if(ceInfo->bitMask & RG_SHORT_BSR_CE_PRSNT)
2624 lcgId = ((ceInfo->ces.bsr.shortBsr >> 6) & 0x03);
2625 bsr = ceInfo->ces.bsr.shortBsr & 0x3F;
2626 ueCb->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs = rgLwrBsrTbl[bsr];
2629 else if(ceInfo->bitMask & RG_LONG_BSR_CE_PRSNT)
2631 ueCb->ul.lcgArr[0].lcgBsInfo.outStndngBs = rgLwrBsrTbl[ceInfo->ces.bsr.longBsr.bs1];
2632 ueCb->ul.lcgArr[1].lcgBsInfo.outStndngBs = rgLwrBsrTbl[ceInfo->ces.bsr.longBsr.bs2];
2633 ueCb->ul.lcgArr[2].lcgBsInfo.outStndngBs = rgLwrBsrTbl[ceInfo->ces.bsr.longBsr.bs3];
2634 ueCb->ul.lcgArr[3].lcgBsInfo.outStndngBs = rgLwrBsrTbl[ceInfo->ces.bsr.longBsr.bs4];
2637 } /* end of rgTOMUtlL2MStoreBufSz*/
2639 /** @brief : Compiles list of LCs received in UL data for DTCH RBs
2643 * @param [in] RgCellCb *cellCb
2644 * @param [in] RgUeCb *ueCb
2645 * @param [in] CmLteRnti rnti
2646 * @param [in] RgMacPdu *pdu
2653 PRIVATE Void rgTOML2MCompileActiveLCs
2661 PRIVATE Void rgTOML2MCompileActiveLCs(cellCb, ueCb, pdu, ceInfo)
2665 RgInfCeInfo *ceInfo;
2672 TRC2(rgTOML2MCompileActiveLCs)
2674 node = pdu->sduLst.first;
2677 sdu = (RgMacSdu*)node->node;
2679 if ((ulLcCb = rgDBMGetUlDedLcCb(ueCb, sdu->lcId)), ulLcCb != NULLP)
2681 if (ulLcCb->lcgId != 0)
2683 ceInfo->bitMask |= RG_ACTIVE_LC_PRSNT;
2684 ceInfo->ulActLCs[ulLcCb->lcId - 1] = TRUE;
2695 /**********************************************************************
2698 **********************************************************************/