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;
599 /* Mux Pdu for Msg4 */
600 buildAndSendMuxPdu(slotInd);
602 /* Trigger for DL TTI REQ */
603 handleDlTtiReq(slotInd);
605 /* Trigger for UL TTI REQ */
606 handleUlTtiReq(slotInd);
608 dlSf = &cellCb->subFrms[(slotInd.slot % RG_NUM_SUB_FRAMES)];
610 if((dlSf->txDone == TRUE) ||
611 (!RG_TIMEINFO_SAME(slotInd,dlSf->schdTime)))
614 #ifndef LTEMAC_DLUE_TMGOPTMZ
615 TfuDatReqInfo *datInfo;
616 CmLteTimingInfo timingInfo;
617 #ifdef TFU_DL_DELTA_CHANGE
618 RGADDTOCRNTTIME(cellCb->crntTime, timingInfo, TFU_DLDATA_DLDELTA);
620 RGADDTOCRNTTIME(cellCb->crntTime, timingInfo, TFU_DELTA);
622 /* Fill Data Request from MAC for BCH */
623 if ((timingInfo.sfn % 4 == 0) && (timingInfo.slot == 0))
625 if (ROK != rgAllocEventMem(inst,(Ptr *)&datInfo,
626 sizeof(TfuDatReqInfo)))
628 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
629 "rgTOMUtlProcDlSf() Unable to Allocate TfuDatReqInfo for cell");
634 cmLListInit(&datInfo->pdus);
635 datInfo->cellId = cellCb->cellId;
636 datInfo->bchDat.pres = NOTPRSNT;
637 datInfo->timingInfo = timingInfo;
640 /* sending the dummy data req to Phy */
641 if (rgLIMTfuDatReq(inst,datInfo) != ROK)
643 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
644 "rgTOMUtlProcDlSf() Unable to send data info for cell");
650 /* Freeing as the part of CL Non RT Indication */
651 /* TDOD : Generalize for all SOCs */
652 #if !(defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD))
653 rgDHMFreeTbBufs(inst);
658 /*Return if there is still some data to be received
659 from RLC for this DL SF. */
660 /* ADD Changes for Downlink UE Timing Optimization */
661 #ifdef LTEMAC_DLUE_TMGOPTMZ
662 if(0 != dlSf->remDatReqCnt)
664 /* Freeing as the part of CL Non RT Indication */
665 /* TODO : Generalize for all SOCs and remove this flag */
666 #if !(defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD))
667 rgDHMFreeTbBufs(inst);
673 #ifdef XEON_SPECIFIC_CHANGES
674 CM_MEAS_TIME((slotInd.slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_DL_BR_PRC);
677 if (ROK != rgTOMUtlProcDlSf (dlSf, cellCb, &err))
679 //RLOG_ARG0(L_ERROR,DBG_CELLID,slotInd->cellId,
680 // "Unable to process downlink subframe for cell");
681 err.errType = RGERR_TOM_TTIIND;
683 #ifdef XEON_SPECIFIC_CHANGES
684 CM_MEAS_TIME((slotInd->slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_DL_AFTER_PRC);
687 /* Mark this frame as sent */
690 /* Freeing as the part of CL Non RT Indication */
691 /* TODO : Generalize for all SOCs and remove this flag */
692 #if !(defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD))
693 rgDHMFreeTbBufs(inst);
696 } /* macProcessSlotInd */
698 /** @brief This function allocates the RgMacPdu that will be populated by DEMUX
699 * with the SubHeaders list and the values of the Control elements.
703 * Function: rgTOMUtlAllocPduEvnt
706 * @param[in] Inst inst
707 * @param [out] RgMacPdu **pdu
714 PRIVATE S16 rgTOMUtlAllocPduEvnt
720 PRIVATE S16 rgTOMUtlAllocPduEvnt (inst,pdu)
727 RgUstaDgn dgn; /* Alarm diagnostics structure */
728 VOLATILE U32 startTime=0;
730 TRC2(rgTOMUtlAllocPduEvnt);
732 evntMem.region = rgCb[inst].rgInit.region;
733 evntMem.pool = rgCb[inst].rgInit.pool;
736 SStartTask(&startTime, PID_TOMUTL_CMALLCEVT);
738 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
739 MS_BUF_ADD_ALLOC_CALLER();
742 if (cmAllocEvnt (sizeof (RgMacPdu), RG_BLKSZ, &evntMem, (Ptr*)pdu) != ROK)
744 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
745 rgLMMStaInd(inst,LCM_CATEGORY_RESOURCE, LCM_EVENT_DMEM_ALLOC_FAIL,
746 LCM_CAUSE_MEM_ALLOC_FAIL, &dgn);
747 RLOG0(L_ERROR,"Allocation of DUX event failed");
752 SStopTask(startTime, PID_TOMUTL_CMALLCEVT);
757 /** @brief This function frees up the RgMacPdu structure that has been
758 * populated by demux.
762 * Function: rgTOMUtlFreePduEvnt
763 * - Function frees up the RgMacPdu structure, in case of error it shall
764 * free up the buffer's present in the different sdu.
767 * @param [in] Inst inst
768 * @param [in] RgMacPdu *pdu
769 * @param [in] Bool *error
773 PRIVATE Void rgTOMUtlFreePduEvnt
779 PRIVATE Void rgTOMUtlFreePduEvnt (pdu, error)
788 TRC2(rgTOMUtlFreePduEvnt);
789 /* Steps of freeing up the PDU.
790 * 1. loop through the subHdrLst and free up all the buffers.
791 * 2. free up the whole event
793 if ((error == TRUE) && (pdu->sduLst.count > 0))
795 node = pdu->sduLst.first;
798 sdu = (RgMacSdu*)node->node;
799 RG_FREE_MSG(sdu->mBuf);
805 } /* end of rgTOMUtlFreePduEvnt */
807 /** @brief This function allocates the RgMacPdu that will be populated by DEMUX
808 * with the SubHeaders list and the values of the Control elements.
812 * Function: rgTOMInfAllocPduEvnt
815 * @param [in] Inst inst
816 * @param [out] RgMacPdu **pdu
823 PRIVATE S16 rgTOMInfAllocPduEvnt
826 RgInfSfDatInd **sfInfo
829 PRIVATE S16 rgTOMInfAllocPduEvnt (inst,sfInfo)
831 RgInfSfDatInd **sfInfo;
836 RgUstaDgn dgn; /* Alarm diagnostics structure */
837 VOLATILE U32 startTime=0;
839 TRC2(rgTOMInfAllocPduEvnt);
841 evntMem.region = rgCb[inst].rgInit.region;
842 evntMem.pool = rgCb[inst].rgInit.pool;
845 SStartTask(&startTime, PID_TOMINF_CMALLCEVT);
847 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
848 MS_BUF_ADD_ALLOC_CALLER();
850 if (cmAllocEvnt (sizeof (RgInfSfDatInd), RG_BLKSZ, &evntMem, (Ptr*)sfInfo) != ROK)
852 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
853 rgLMMStaInd(inst,LCM_CATEGORY_RESOURCE, LCM_EVENT_DMEM_ALLOC_FAIL,
854 LCM_CAUSE_MEM_ALLOC_FAIL, &dgn);
855 RLOG0(L_ERROR,"Allocation failed");
860 SStopTask(startTime, PID_TOMINF_CMALLCEVT);
865 /** @brief This function frees up the RgMacPdu structure that has been
866 * populated by demux.
870 * Function: rgTOMInfFreePduEvnt
871 * - Function frees up the RgMacPdu structure, in case of error it shall
872 * free up the buffer's present in the different sdu.
875 * @param [in] RgMacPdu *pdu
876 * @param [in] Bool *error
880 PRIVATE Void rgTOMInfFreePduEvnt
882 RgInfSfDatInd *sfInfo
885 PRIVATE Void rgTOMInfFreePduEvnt (sfInfo)
886 RgInfSfDatInd *sfInfo;
889 TRC2(rgTOMInfFreePduEvnt);
893 } /* end of rgTOMUtlFreePduEvnt */
897 /** @brief This function performs the preparation of information needed to set
898 * L2M Scheduled UL Throughput Information for a particular UE.
902 * Function: rgTomUtlPrepareL2MUlThrpInfo
903 * This function performs the preparation of information needed to set
904 * L2M Scheduled UL Throughput Information for a particular UE.
908 * @param [in] RgCellCb *cellCb
909 * @param [in] RgUeCb *ueCb
910 * @param [out] RgRguDedDatInd *dDatInd
914 PRIVATE S16 rgTomUtlPrepareL2MUlThrpInfo
918 RgRguDedDatInd *dDatInd
921 PRIVATE S16 rgTomUtlPrepareL2MUlThrpInfo(cellCb,ueCb,dDatInd)
924 RgRguDedDatInd *dDatInd;
930 TRC2(rgTomUtlPrepareL2MUlThrpInfo);
932 dDatInd->burstInd = RGU_L2M_UL_BURST_END;
933 for(loop=0;loop<dDatInd->numLch;loop++)
935 lcId=dDatInd->lchData[loop].lcId;
938 lcgId = ueCb->ul.lcCb[lcId - 1].lcgId;
939 if(ueCb->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs > 0)
941 dDatInd->burstInd = RGU_L2M_UL_BURST_START;
952 /** @brief This function is called by rgTOMDatInd. This function invokes the
953 * scheduler with the information of the received Data and any Control Elements
954 * if present. Also it generates Data indications towards the higher layers.
961 * - Retrieves the RaCb with the rnti provided, if it doesnt exist
963 * - If UE exists then update the Schduler with any MAC CEs if present.
964 * - Invoke RAM module to do Msg3 related processing rgRAMProcMsg3
965 * - Loop through the SDU subheaders and invoke either a common data
966 * indication (rgUIMSndCmnDatInd) or dedicated data indication
967 * (rgUIMSndDedDatInd) towards the higher layers.
969 * @param [in] RgCellCb *cellCb
970 * @param [in] RgUeCb *ueCb
971 * @param [in] CmLteRnti rnti
972 * @param [in] RgMacPdu *pdu
973 * @param [out] U32 *lcgBytes
984 PRIVATE S16 rgTOMUtlProcMsg
996 PRIVATE S16 rgTOMUtlProcMsg(cellCb, ueCb, pdu, isSpsRnti,spsToBeActvtd,sduSize, slot, lcgBytes)
1001 Bool *spsToBeActvtd;
1006 #else /* LTEMAC_SPS */
1008 PRIVATE S16 rgTOMUtlProcMsg
1017 PRIVATE S16 rgTOMUtlProcMsg(cellCb, ueCb, pdu, slot, lcgBytes)
1026 Inst inst = cellCb->macInst - RG_INST_START;
1028 RgRguCmnDatInd *cDatInd;
1029 RgRguDedDatInd *dDatInd;
1036 // RgInfSpsRelInfo relInfo;
1043 U16 totalBytesRcvd = 0;
1044 U16 sduLen[RGU_MAX_LC] = {0};
1045 U8 qciVal[RGU_MAX_LC] = {0};
1052 /* Moved outside of LTE_L2_MEAS
1053 * scope as this pointer will now be used to
1054 * check for valid Logical Channel ID
1071 TRC2(rgTOMUtlProcMsg)
1077 if(pdu->sduLst.first)
1079 sdu = (RgMacSdu*)(pdu->sduLst.first->node);
1081 if ((sdu->lcId == RG_CCCH_LCID))
1083 /* code for common channel dat indications */
1084 if ((ret = rgAllocShrablSBuf (inst,(Data**)&cDatInd, sizeof(RgRguCmnDatInd))) != ROK)
1088 cDatInd->cellId = cellCb->cellId;
1089 cDatInd->rnti = ueCb->ueId;
1090 /* rg001.101: Corrected lcId value for common data indication */
1091 cDatInd->lcId = cellCb->ulCcchId;
1092 cDatInd->pdu = sdu->mBuf;
1093 SFndLenMsg (sdu->mBuf, &ccchSz);
1094 /* Fix : syed Contention resolution ID copy should consider only
1095 * 6 bytes of information from sdu->mBuf. Incase of CCCH sdu for reest
1096 * message/psuedo reest message, ccchSz can go beyond 6 and can corrupt
1097 * other fields of ueCb. */
1098 if (ccchSz >= RG_CRES_LEN)
1100 SCpyMsgFix (sdu->mBuf, (MsgLen)0, RG_CRES_LEN, ueCb->contResId.resId,
1103 #ifdef XEON_SPECIFIC_CHANGES
1104 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);
1107 rgUIMSndCmnDatInd(inst,cellCb->rguUlSap,cDatInd);
1109 } /* end of common channel processing */
1111 if ((ret = rgAllocShrablSBuf (inst,(Data**)&dDatInd, sizeof(RgRguDedDatInd))) != ROK)
1117 elem = SRngGetWIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
1122 dDatInd = (RgRguDedDatInd *)elem;
1123 cmMemset((U8 *)dDatInd, 0x00, sizeof(RgRguDedDatInd));
1125 dDatInd->cellId = cellCb->cellId;
1126 dDatInd->rnti = ueCb->ueId;
1127 dDatInd->numLch = 0;
1130 ulSf = &cellCb->ulSf[(slot % RG_NUM_SUB_FRAMES)];
1131 if(ulSf->ueUlAllocInfo != NULLP)
1133 for(idx1 = 0; idx1 < ulSf->numUe; idx1++)
1135 if(ulSf->ueUlAllocInfo[idx1].rnti == ueCb->ueId)
1137 numPrb = ulSf->ueUlAllocInfo[idx1].numPrb;
1143 node = pdu->sduLst.first;
1146 sdu = (RgMacSdu*)node->node;
1148 ulLcCb = rgDBMGetUlDedLcCb (ueCb, sdu->lcId);
1152 RLOG_ARG2(L_ERROR,DBG_CELLID,cellCb->cellId,"Unconfigured LCID:%d CRNTI:%d"
1153 ,sdu->lcId,ueCb->ueId);
1154 /* ccpu00128443: Fix for memory leak */
1155 /* Fix : syed Neccessary to set sdu->mBuf = NULLP */
1156 RG_FREE_MSG(sdu->mBuf);
1160 #ifdef RLC_STA_PROC_IN_MAC/* RLC Status PDU Processing */
1162 extern S16 kwProcDlStatusPdu(Pst *udxPst,SuId suId,
1163 CmLteCellId cellId,CmLteRnti rnti,CmLteLcId lcId,Buffer *rlcSdu);
1165 if(ROK == kwProcDlStatusPdu(&(cellCb->rguDlSap->sapCfg.sapPst),
1166 cellCb->rguDlSap->sapCfg.suId,
1167 cellCb->cellId,ueCb->ueId,sdu->lcId,sdu->mBuf))
1169 RG_FREE_MSG(sdu->mBuf);
1176 /* ccpu00116477- Fixed the rgUIMSndDedDatInd condition when we receive 11 sdus in the
1177 * list we are losing 11th sdu and sending the first 10 sdus again which
1178 * is causing the duplicate packets and eNB crashing due to access
1179 * of the freed memory */
1180 if (dDatInd->numLch >= RGU_MAX_LC)
1182 if ((ret = rgUIMSndDedDatInd(inst,ueCb->rguUlSap,dDatInd)) != ROK)
1184 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
1185 "Failed to send datIndication to RGU CRNTI:%d",ueCb->ueId);
1189 if ((ret = rgAllocShrablSBuf (inst,(Data**)&dDatInd, sizeof(RgRguDedDatInd))) != ROK)
1194 elem = SRngGetWIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
1199 dDatInd = (RgRguDedDatInd *)elem;
1200 cmMemset((U8 *)dDatInd, 0x00, sizeof(RgRguDedDatInd));
1202 dDatInd->cellId = cellCb->cellId;
1203 dDatInd->rnti = ueCb->ueId;
1204 dDatInd->numLch = 0;
1206 dDatInd->lchData[dDatInd->numLch].lcId = sdu->lcId;
1207 dDatInd->lchData[dDatInd->numLch].pdu.mBuf[dDatInd->lchData[dDatInd->numLch].pdu.numPdu] = sdu->mBuf;
1208 dDatInd->lchData[dDatInd->numLch].pdu.numPdu++;
1209 lcgId = ulLcCb->lcgId;
1210 SFndLenMsg(sdu->mBuf, &bufSz);
1214 ueCb->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs -= bufSz;
1217 //if ((lcgBytes != NULLP) && (ueCb->ul.lcgArr[lcgId].isGbr == TRUE))
1218 if (lcgBytes != NULLP)
1220 lcgBytes[lcgId] += bufSz;
1225 /* Check if data has come on SPS LC */
1226 /* KWORK_FIX: Modified the index from lcId to lcId-1 for handling lcId 10 properly */
1227 if (ueCb->ul.spsLcId[sdu->lcId-1] == TRUE)
1229 ueCb->ul.spsDatRcvd++;
1234 /* Data rcvd on CRNTI*/
1235 /* Retrieve the LCG ID of the LCID*/
1236 /* SPS LCG has data whose size > SID Size */
1237 /* Activate SPS if data recvd on SPS LCID and size > SID Packet Size */
1238 if((ueCb->ul.spsLcId[sdu->lcId-1] == TRUE) &&
1239 (sdu->len > RG_SPS_SID_PACKET_SIZE))
1241 *spsToBeActvtd = TRUE;
1242 *sduSize = sdu->len;
1249 if(cellCb->qciArray[ulLcCb->qci].mask == TRUE)
1251 sduLen[ulLcCb->qci] = sdu->len;
1252 totalBytesRcvd += sdu->len;
1253 qciVal[ulLcCb->qci] = ulLcCb->qci;
1257 } /* end of while for SubHeaders */
1259 for(idx2 = 0; idx2 < RGU_MAX_LC; idx2++)
1261 if((cellCb->qciArray[qciVal[idx2]].mask == TRUE) &&
1264 cellCb->qciArray[qciVal[idx2]].prbCount +=
1265 ((numPrb * sduLen[idx2]) / totalBytesRcvd);
1269 if(totalBytesRcvd > 0 && qciVal[idx2] > 0)
1271 RG_UPD_GBR_PRB(cellCb, qciVal[idx2], ((numPrb * sduLen[idx2])/totalBytesRcvd));
1276 /*Added for explicit release - start*/
1279 if(isSpsRnti && dDatInd && dDatInd->numLch)
1281 if(ueCb->ul.spsDatRcvd != 0)
1283 ueCb->ul.explRelCntr = 0;
1284 ueCb->ul.spsDatRcvd = 0;
1288 ueCb->ul.explRelCntr++;
1289 if (ueCb->ul.explRelCntr == ueCb->ul.explRelCnt)
1291 ueCb->ul.explRelCntr = 0;
1292 /* Indicate scheduler for explicit release */
1293 cmMemset((U8*)&schPst1, (U8)0, sizeof(Pst));
1294 rgGetPstToInst(&schPst1,inst, cellCb->schInstMap.schInst);
1295 //TODO: commented for compilation without SCH
1297 relInfo.cellSapId = cellCb->schInstMap.cellSapId;
1298 relInfo.cRnti = ueCb->ueId;
1299 relInfo.isExplRel = TRUE;
1300 /* Release indicator is called now through the matrix in the function below */
1301 //TODO: commented for compilation without SCH RgMacSchSpsRel( &schPst1, &relInfo );
1303 ueCb->ul.implRelCntr = 0;
1310 if(ueCb->ul.spsDatRcvd != 0)
1312 //ueCb->ul.implRelCntr = 0;
1313 ueCb->ul.explRelCntr = 0;
1314 ueCb->ul.spsDatRcvd = 0;
1318 /*Added for explicit release - end */
1320 if((dDatInd) && (dDatInd->numLch))
1323 rgTomUtlPrepareL2MUlThrpInfo(cellCb, ueCb,dDatInd);
1325 RG_CALC_TTI_CNT(cellCb, dDatInd->ttiCnt);
1327 if ((ret = rgUIMSndDedDatInd(inst,ueCb->rguUlSap,dDatInd)) != ROK)
1329 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
1330 "Failed to send datIndication to RGU CRNTI:%d",ueCb->ueId);
1335 else if((dDatInd) && (0 == dDatInd->numLch))
1337 /* Free the memory allocated for dDatInd if we
1338 * have no valid LCH PDU to send to RLC.*/
1339 rgFreeSharableSBuf(inst,(Data **)&dDatInd,sizeof(RgRguDedDatInd));
1345 /** @brief This function frees up the RgMacPdu structure that has been
1346 * populated by demux.
1350 * Function: rgTOMUtlInsSchInfo
1351 * - Function frees up the RgMacPdu structure, in case of error it shall
1352 * free up the buffer's present in the different sdu.
1355 * @param [in] RgMacPdu *pdu
1356 * @param [in] Bool *error
1361 PRIVATE S16 rgTOMUtlInsSchInfo
1364 RgInfSfDatInd *sfInfo,
1365 RgInfCeInfo *ceInfo,
1372 PRIVATE S16 rgTOMUtlInsSchInfo (pdu, sfInfo, ceInfo, rnti,spsToBeActvtd,sduSize, lcgBytes)
1374 RgInfSfDatInd *sfInfo;
1375 RgInfCeInfo *ceInfo;
1384 PRIVATE S16 rgTOMUtlInsSchInfo
1387 RgInfSfDatInd *sfInfo,
1388 RgInfCeInfo *ceInfo,
1393 PRIVATE S16 rgTOMUtlInsSchInfo (pdu, sfInfo, ceInfo, rnti, lcgBytes)
1395 RgInfSfDatInd *sfInfo;
1396 RgInfCeInfo *ceInfo;
1403 RgInfUeDatInd *ueInfo;
1407 TRC2(rgTOMUtlInsSchInfo);
1409 RG_TOM_INF_ALLOC(sfInfo, sizeof(RgInfUeDatInd), ueInfo, ret);
1416 ueInfo->rnti = rnti;
1418 ueInfo->ceInfo = *ceInfo;
1419 ueInfo->ueLstEnt.node = (PTR)ueInfo;
1420 for (lcgId = 1, idx = 0; lcgId < RGINF_MAX_LCG_PER_UE; lcgId++)
1422 if (lcgBytes[lcgId] != 0)
1424 /* Only GBR bytes */
1425 ueInfo->lcgInfo[idx].lcgId = lcgId;
1426 ueInfo->lcgInfo[idx++].bytesRcvd = lcgBytes[lcgId];
1427 lcgBytes[lcgId] = 0;
1430 cmLListAdd2Tail(&sfInfo->ueLst, &ueInfo->ueLstEnt);
1432 } /* end of rgTOMUtlInsSchInfo */
1436 * @brief Handler for processing data indication recieved from PHY for UEs.
1440 * Function: rgTOMDatInd
1442 * Handler for processing data indication recieved from PHY for UEs.
1444 * Invoked by: RgLiTfuDatInd of LIM
1447 * For each DataInfo recieved
1448 * - Validate the information received and retrieve cellCb
1449 * Validate cellId, rnti
1450 * - Call De-Mux module to decode the data rgDUXDemuxData
1451 * - If received a CRNTI control element
1452 * - Check if a CCCH SDU is present, if it is return failure
1453 * - Check for the existence of UE, if its isnt present return failure.
1454 * - Delegate the remaining processing to rgTOMUtlProcMsg3 which
1455 * primarily informs the scheduler about the data received and
1456 * generates Data indications towards the higher layer.
1457 * - If only CCCH SDU is present
1458 * - Invoke rgTOMUtlProcMsg3 for further processing.
1459 * - If its a non-Msg3 PDU i.e. received outside of a RA procedure
1460 * - Retrieve the UeCB
1461 * - Validate that the received PDU contains only configured Logical
1463 * - Invoke rgTOMUtlProcDatPdu for further processing. It informs the
1464 * scheduler with the information of the received Data and generates
1465 * DatIndications towards the higher layers.
1467 * @param [in] Inst inst
1468 * @param[in] TfuDatIndInfo *datInd
1474 PUBLIC S16 rgTOMDatInd
1477 TfuDatIndInfo *datInd
1480 PUBLIC S16 rgTOMDatInd(inst,datInd)
1482 TfuDatIndInfo *datInd;
1488 RgUeCb *prevUeCb = NULLP;
1491 RgInfSfDatInd *sfInfo;
1495 TfuDatInfo *datInfo;
1499 Bool isSpsRnti=FALSE;
1501 // RgInfSpsRelInfo relInfo;
1502 Bool spsToBeActvtd = FALSE;
1505 U32 lcgBytes[RGINF_MAX_LCG_PER_UE];
1509 #ifdef STUB_TTI_HANDLING_5GTF
1510 node = datInd->datIndLst.first;
1511 for (;node; node=node->next)
1513 datInfo = (TfuDatInfo*)node->node;
1516 SFndLenMsg(datInfo->mBuf, &len);
1517 rgUlrate_tfu += len;
1518 if (rgUlrate_tfu > 100000)
1520 printf("Sowmya:rgTOMDatInd datInfo->mBuf len =%d rgUlrate_tfu=%d",len,rgUlrate_tfu);
1528 cmMemset((U8 *)&lcgBytes, 0, sizeof(lcgBytes));
1530 tfuSap = &(rgCb[inst].tfuSap);
1532 cellCb = rgCb[inst].cell;
1533 if((cellCb == NULLP) ||
1534 (cellCb->cellId != datInd->cellId))
1537 RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"Unable to get the cellCb for cell");
1540 /* Avoiding memset as all the fields are getting initialized further */
1542 if (rgTOMInfAllocPduEvnt (inst,&sfInfo) != ROK)
1544 err.errType = RGERR_TOM_DATIND;
1545 RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"Unable to Allocate PDU for DUX cell");
1546 node = datInd->datIndLst.first;
1549 cmLListInit(&sfInfo->ueLst);
1550 sfInfo->cellId = datInd->cellId;
1551 sfInfo->timingInfo = datInd->timingInfo;
1552 slot = datInd->timingInfo.slot;
1554 node = datInd->datIndLst.first;
1555 for (;node; node=node->next)
1557 datInfo = (TfuDatInfo*)node->node;
1559 //extern U32 ulrate_tfu;
1561 SFndLenMsg(datInfo->mBuf, &len);
1562 #ifdef STUB_TTI_HANDLING_5GTF
1563 // printf("Sowmya:rgTOMDatInd datInfo->mBuf len =%d",len);
1565 rgUlrate_tfu += len;
1567 grgUlrate_tfu += len;
1570 #ifdef STUB_TTI_HANDLING_5GTF
1571 rgLIMUtlFreeDatIndEvnt(datInd,TRUE);
1573 /* We shall call De-Mux to process the received buffer. We shall try and find
1574 * out the RaCb based on the following -
1575 * 1. If the incoming PDU contained a CCCH SDU i.e. this is message 3.
1576 * 2. If the incoming PDU contained a CRNTI control element, i.e. we should
1577 * have a ueCb also for this
1579 /* Lets allocate the event that needs to be passed to DUX */
1580 if (rgTOMUtlAllocPduEvnt (inst,&pdu) != ROK)
1582 err.errType = RGERR_TOM_DATIND;
1583 RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"Unable to Allocate PDU for DUX cell");
1584 rgTOMInfFreePduEvnt (sfInfo);
1588 if ((ret = rgDUXDemuxData (inst,pdu, &ceInfo,
1589 &datInfo->mBuf, &err)) != ROK)
1592 /* Fix: sriky memory corruption precautions */
1593 rgTOMUtlFreePduEvnt (pdu, TRUE);
1594 err.errType = RGERR_TOM_DATIND;
1595 RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"DUX processing failed");
1596 tfuSap->sapSts.numPduDrop++;
1599 /* It could be that a non-msg3 pdu contains a CRNTI Control element. We
1600 * should check for CRNTI CE and if it exists the UECb must exist, also an
1601 * if the CRNTI in the CE and the one with which the message came in are
1602 * different we shall look for an raCb as well.
1605 if (ceInfo.bitMask & RG_CCCH_SDU_PRSNT)
1607 ret = rgTOMProcCCCHSduInDatInd(pdu, prevUeCb, \
1608 cellCb, datInfo, &ceInfo, slot);
1611 rgTOMUtlFreePduEvnt (pdu, TRUE);
1612 err.errType = RGERR_TOM_DATIND;
1613 tfuSap->sapSts.numPduDrop++;
1616 } /* end of Msg3 processing */
1618 else if (ceInfo.bitMask & RG_CRNTI_CE_PRSNT)
1620 ret = rgTOMProcCrntiCEInDatInd(pdu, prevUeCb, \
1621 cellCb, datInfo, &ceInfo, slot);
1624 rgTOMUtlFreePduEvnt (pdu, TRUE);
1625 err.errType = RGERR_TOM_DATIND;
1626 tfuSap->sapSts.numPduDrop++;
1630 } /* end of CRNTI based message */
1633 ueCb = rgDBMGetUeCb (cellCb, datInfo->rnti);
1637 /* Try getting the UE using SPS-RNTI. */
1638 ueCb = rgDBMGetSpsUeCb (cellCb, datInfo->rnti);
1642 /* Increment implrelCntr for an empty transmission */
1643 if (pdu->sduLst.count == 0)
1645 ueCb->ul.implRelCntr++;
1646 if (ueCb->ul.implRelCntr == ueCb->ul.implRelCnt)
1648 /* Indicate scheduler for implicit release */
1649 cmMemset((U8*)&schPst1, (U8)0, sizeof(Pst));
1650 rgGetPstToInst(&schPst1,inst, cellCb->schInstMap.schInst);
1652 ueCb->ul.implRelCntr = 0;
1653 ueCb->ul.explRelCntr = 0;
1655 relInfo.cellSapId = cellCb->schInstMap.cellSapId;
1656 relInfo.cRnti = ueCb->ueId;
1657 relInfo.isExplRel= FALSE;
1658 //TODO: commented for compilation without SCH RgMacSchSpsRel(&schPst1, &relInfo);
1664 /* Reset the implrelCntr */
1665 ueCb->ul.implRelCntr = 0;
1671 /* Perform failure if ueCb is still NULLP */
1672 rgTOMUtlFreePduEvnt (pdu, TRUE);
1673 err.errType = RGERR_TOM_DATIND;
1674 RLOG_ARG1(L_ERROR,DBG_CELLID,datInd->cellId,"RNTI:%d Unable to get the UE CB",
1676 tfuSap->sapSts.numPduDrop++;
1681 rgTOMUtlL2MStoreBufSz(ueCb, &ceInfo);
1682 rgTOML2MCompileActiveLCs (cellCb, ueCb, pdu, &ceInfo);
1685 if ((ret = rgTOMUtlProcMsg(cellCb, ueCb, pdu, isSpsRnti,&spsToBeActvtd,&sduSize, slot, (U32 *)&lcgBytes)) != ROK)
1687 if ((ret = rgTOMUtlProcMsg (cellCb, ueCb, pdu, slot, (U32 *)&lcgBytes)) != ROK)
1688 #endif /* LTEMAC_SPS */
1690 rgTOMUtlFreePduEvnt (pdu, TRUE);
1691 err.errType = RGERR_TOM_DATIND;
1692 RLOG_ARG1(L_ERROR,DBG_CELLID,datInd->cellId,
1693 "Unable to handle Data Indication CRNTI:%d",ueCb->ueId);
1694 tfuSap->sapSts.numPduDrop++;
1701 if(rgTOMUtlInsSchInfo(pdu, sfInfo, &ceInfo, datInfo->rnti,spsToBeActvtd,sduSize, (U32 *)&lcgBytes) != ROK)
1703 if(rgTOMUtlInsSchInfo(pdu, sfInfo, &ceInfo, datInfo->rnti, (U32 *)&lcgBytes) != ROK)
1707 rgTOMInfFreePduEvnt (sfInfo);
1708 rgTOMUtlFreePduEvnt (pdu, FALSE);
1711 /* free up the PDU memory */
1712 rgTOMUtlFreePduEvnt (pdu, FALSE);
1714 /* Free the allocated memory for ueUlAllocInfo here */
1716 if(cellCb->ulSf[(slot % RG_NUM_SUB_FRAMES)].ueUlAllocInfo != NULLP)
1718 /*ccpu00117052 - MOD - Passing double for proper NULLP
1720 rgFreeSBuf(inst,(Data **)&(cellCb->ulSf[(slot % RG_NUM_SUB_FRAMES)].ueUlAllocInfo),
1721 ((cellCb->ulSf[(slot % RG_NUM_SUB_FRAMES)].numUe) * sizeof(RgUeUlAlloc)));
1725 /* Update PRB used for all GBR QCIs to scheduler */
1726 cmMemcpy((U8*) &sfInfo->qcisUlPrbCnt[0],
1727 (U8*) &cellCb->qcisUlPrbCnt[0],
1728 (RGM_MAX_QCI_REPORTS * sizeof(U32)));
1729 /* clear the cellCb ul prb value */
1730 cmMemset((U8*)&cellCb->qcisUlPrbCnt[0], 0,
1731 (RGM_MAX_QCI_REPORTS * sizeof(U32)));
1735 rgGetPstToInst(&schPst, inst,cellCb->schInstMap.schInst);
1736 sfInfo->cellSapId = cellCb->schInstMap.cellSapId;
1737 //TODO: commented for compilation without SCH RgMacSchSfRecp(&schPst, sfInfo);
1742 * @brief Function handles allocation for common channels i.e. BCCH-BCH,
1743 * BCCH-DLSCH, PCCH-DLSCH.
1747 * Function : rgHndlCmnChnl
1749 * This function is invoked from RgSchMacSfAllocReq. This function handles
1750 * allocations made for common channels like BCCH and PCCH.
1753 * 1. If BCCH on BCH has been scheduled, send StatusIndication on RGU.
1754 * 2. If PCCH is scheduled, send StatusIndication on RGU.
1755 * 3. If BCCH on DLSCH has been scheduled and sndStatInd is TRUE, send
1756 * StatusIndication on RGU, else copy the bcch buffer onto the downlink
1760 * @param[in] RgCellCb *cell,
1761 * @param[in] CmLteTimingInfo timingInfo,
1762 * @param[in] RgInfCmnLcInfo *cmnLcInfo,
1763 * @param[in/out] RgErrInfo *err,
1769 PRIVATE S16 rgHndlCmnChnl
1772 CmLteTimingInfo timingInfo,
1773 RgInfCmnLcInfo *cmnLcInfo,
1777 PRIVATE S16 rgHndlCmnChnl(cell, timingInfo, cmnLcInfo, err)
1779 CmLteTimingInfo timingInfo;
1780 RgInfCmnLcInfo *cmnLcInfo;
1784 #if (ERRCLASS & ERRCLS_DEBUG)
1788 RgBcchDlschLcCb *bcch;
1789 #if (ERRCLASS & ERRCLS_DEBUG)
1792 #endif/*RGR_SI_SCH*/
1793 RguCStaIndInfo *staInd;
1795 Inst inst = cell->macInst - RG_INST_START;
1799 dlSf = &cell->subFrms[(timingInfo.slot % RG_NUM_SUB_FRAMES)];
1801 if(cmnLcInfo->bitMask & RGINF_BCH_INFO)
1804 #if (ERRCLASS & ERRCLS_DEBUG)
1805 if(NULLP == (bch = rgDBMGetBcchOnBch(cell)))
1809 if(cmnLcInfo->bchInfo.lcId != bch->lcId)
1815 if (rgAllocShrablSBuf (inst,(Data**)&staInd, sizeof(RguCStaIndInfo)) != ROK)
1817 err->errCause = RGERR_TOM_MEM_EXHAUST;
1820 staInd->cellId = cell->cellId;
1821 staInd->rnti = RG_INVALID_RNTI;
1822 staInd->lcId = cmnLcInfo->bchInfo.lcId;
1823 staInd->transId = (timingInfo.sfn << 8) | (timingInfo.slot);
1824 /* ADD Changes for Downlink UE Timing Optimization */
1825 #ifdef LTEMAC_DLUE_TMGOPTMZ
1826 dlSf->remDatReqCnt++;
1828 if (rgUIMSndCmnStaInd (inst,cell->rguDlSap,staInd) != ROK)
1833 /*Store the received BCH Data in the scheduled subframe*/
1834 dlSf->bch.tb = cmnLcInfo->bchInfo.pdu;
1835 #endif/*RGR_SI_SCH*/
1838 if(cmnLcInfo->bitMask & RGINF_PCCH_INFO)
1840 #if (ERRCLASS & ERRCLS_DEBUG)
1841 if(NULLP == (pcch = rgDBMGetPcch(cell)))
1845 if(cmnLcInfo->pcchInfo.lcId != pcch->lcId)
1851 dlSf->pcch.pdcch.rnti =
1852 cmnLcInfo->pcchInfo.rnti;
1853 dlSf->pcch.pdcch.dci =
1854 cmnLcInfo->pcchInfo.dciInfo;
1856 /* ccpu00132314-ADD-Fill the tx Pwr offset from scheduler */
1857 dlSf->pcch.txPwrOffset = cmnLcInfo->pcchInfo.txPwrOffset;
1859 if (rgAllocShrablSBuf (inst,(Data**)&staInd, sizeof(RguCStaIndInfo)) != ROK)
1861 err->errCause = RGERR_TOM_MEM_EXHAUST;
1864 staInd->cellId = cell->cellId;
1865 staInd->rnti = RG_INVALID_RNTI;
1866 staInd->lcId = cmnLcInfo->pcchInfo.lcId;
1867 staInd->transId = (timingInfo.sfn << 8) | (timingInfo.slot);
1868 /* ADD Changes for Downlink UE Timing Optimization */
1869 #ifdef LTEMAC_DLUE_TMGOPTMZ
1870 dlSf->remDatReqCnt++;
1872 /* for consolidated CmnStaInd calling below function from function
1873 * rgHndlSchedUe once CmnStaInd prepared for all UEs
1875 if (rgUIMSndCmnStaInd (inst,cell->rguDlSap,staInd) != ROK)
1881 if(cmnLcInfo->bitMask & RGINF_BCCH_INFO)
1883 dlSf->bcch.pdcch.rnti =
1884 cmnLcInfo->bcchInfo.rnti;
1885 dlSf->bcch.pdcch.dci =
1886 cmnLcInfo->bcchInfo.dciInfo;
1888 /* ccpu00132314-ADD-Fill the tx Pwr offset from scheduler */
1889 dlSf->bcch.txPwrOffset = cmnLcInfo->bcchInfo.txPwrOffset;
1893 (bcch=rgDBMGetBcchOnDlsch(cell,cmnLcInfo->bcchInfo.lcId)))
1897 if(TRUE == cmnLcInfo->bcchInfo.sndStatInd)
1899 RG_FREE_MSG(bcch->tb);
1900 if (rgAllocShrablSBuf (inst,(Data**)&staInd,
1901 sizeof(RguCStaIndInfo)) != ROK)
1903 err->errCause = RGERR_TOM_MEM_EXHAUST;
1906 staInd->cellId = cell->cellId;
1907 staInd->rnti = RG_INVALID_RNTI;
1908 staInd->lcId = cmnLcInfo->bcchInfo.lcId;
1909 staInd->transId = (timingInfo.sfn << 8) | (timingInfo.slot);
1910 /* ADD Changes for Downlink UE Timing Optimization */
1911 #ifdef LTEMAC_DLUE_TMGOPTMZ
1912 dlSf->remDatReqCnt++;
1914 if (rgUIMSndCmnStaInd (inst,cell->rguDlSap,staInd) != ROK)
1921 SCpyMsgMsg(bcch->tb, RG_GET_MEM_REGION(rgCb[inst]),
1922 RG_GET_MEM_POOL(rgCb[inst]), &dlSf->bcch.tb);
1925 /*Store the received BCCH Data in the scheduled subframe*/
1926 dlSf->bcch.tb = cmnLcInfo->bcchInfo.pdu;
1927 #endif/*RGR_SI_SCH*/
1931 } /* end of rgHndlCmnChnl */
1934 * @brief Function for handling allocations for dedicated channels for a
1939 * Function : rgHndlSchdUe
1941 * This function shall be invoked whenever scheduler is done with the
1942 * allocations of dedicated channels for a subframe. Invoked by the function
1943 * RgSchMacSfAllocReq.
1945 * Processing steps :
1946 * 1. Loops through the list of UE's scheduled looking for the corresponding
1948 * 2. Finds the corresponding HARQ process.
1949 * 3. Invokes the DHM function to issue StatusIndications on RGU.
1952 * @param[in] RgCellCb *cell,
1953 * @param[in] CmLteTimingInfo timingInfo,
1954 * @param[in] RgInfUeInfo *ueInfo
1955 * @param[in/out] RgErrInfo *err
1961 PRIVATE S16 rgHndlSchdUe
1964 CmLteTimingInfo timingInfo,
1965 RgInfUeInfo *ueInfo,
1969 PRIVATE S16 rgHndlSchdUe(cell, timingInfo, ueInfo, err) /* laa_ut_fix */
1971 CmLteTimingInfo timingInfo;
1972 RgInfUeInfo *ueInfo;
1979 if(NULLP == ueInfo->allocInfo)
1984 rgDHMSndConsolidatedStaInd(cell, ueInfo, timingInfo, err);
1987 } /* end of rgHndlSchdUe */
1991 * @brief Function for handling Uplink allocations for Ue for a
1996 * Function : rgHndlUlUeInfo
1998 * @param[in] RgCellCb *cell,
1999 * @param[in] CmLteTimingInfo timingInfo,
2000 * @param[in] RgInfUlUeInfo *ueInfo
2006 PRIVATE S16 rgHndlUlUeInfo
2009 CmLteTimingInfo timingInfo,
2010 RgInfUlUeInfo *ueInfo
2013 PRIVATE S16 rgHndlUlUeInfo(cell, timingInfo, ueInfo)
2015 CmLteTimingInfo timingInfo;
2016 RgInfUlUeInfo *ueInfo;
2019 Inst inst = cell->macInst - RG_INST_START;
2024 TRC2(rgHndlUlUeInfo)
2026 ulSf = &cell->ulSf[(timingInfo.slot % RGSCH_NUM_SUB_FRAMES)];
2028 /* rg003.301-MOD- Corrected the purifier memory leak */
2029 if (ulSf->numUe != ueInfo->numUes)
2031 if (ulSf->ueUlAllocInfo)
2033 rgFreeSBuf(inst,(Data **)&(ulSf->ueUlAllocInfo),
2034 ulSf->numUe * sizeof(RgUeUlAlloc));
2037 #ifdef XEON_SPECIFIC_CHANGES
2038 CM_MEAS_TIME((cell->crntTime.slot % RGSCH_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MEAS_FREE);
2039 CM_ADD_INFO((cell->crntTime.slot % RGSCH_NUM_SUB_FRAMES), CM_DBG_MEAS_FREE, ulSf->numUe);
2041 ulSf->numUe = ueInfo->numUes;
2042 if((ulSf->ueUlAllocInfo == NULLP) && (ueInfo->numUes > 0))
2044 /* Allocate memory for ulAllocInfo */
2045 if((ret = rgAllocSBuf(inst,(Data**)&(cell->ulSf[(timingInfo.slot % RGSCH_NUM_SUB_FRAMES)].
2046 ueUlAllocInfo), ueInfo->numUes * sizeof(RgUeUlAlloc))) != ROK)
2051 #ifdef XEON_SPECIFIC_CHANGES
2052 CM_MEAS_TIME((cell->crntTime.slot % RGSCH_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MEAS_ALLOC);
2053 CM_ADD_INFO((cell->crntTime.slot % RGSCH_NUM_SUB_FRAMES), CM_DBG_MEAS_ALLOC, ueInfo->numUes);
2055 if (ulSf->ueUlAllocInfo != NULLP)
2057 for(idx = 0; idx < ueInfo->numUes; idx++)
2059 ulSf->ueUlAllocInfo[idx].rnti = ueInfo->ulAllocInfo[idx].rnti;
2060 ulSf->ueUlAllocInfo[idx].numPrb = ueInfo->ulAllocInfo[idx].numPrb;
2063 RGCPYTIMEINFO(timingInfo, ulSf->schdTime);
2065 } /* end of rgHndlUlUeInfo */
2068 * @brief Function for handling RaResp request received from scheduler to MAC
2072 * Function : rgTOMRlsSf
2074 * This function shall be invoked whenever scheduler is done with the
2075 * allocations of random access responses for a subframe.
2076 * This shall invoke RAM to create ueCbs for all the rapIds allocated and
2077 * shall invoke MUX to create RAR PDUs for raRntis allocated.
2080 * @param[in] Inst inst
2081 * @param[in] CmLteCellId cellId,
2082 * @param[in] CmLteTimingInfo timingInfo,
2083 * @param[in] RaRespInfo *rarInfo
2088 PUBLIC Void rgTOMRlsSf
2094 PUBLIC Void rgTOMRlsSf(dlSf)
2103 if(dlSf->txDone == FALSE)
2105 RLOG0(L_ERROR, "SUBFRAME Not pushed to the PHY");
2107 if (dlSf->bch.tb != NULLP)
2109 RG_FREE_MSG(dlSf->bch.tb);
2111 if (dlSf->bcch.tb != NULLP)
2113 RG_FREE_MSG(dlSf->bcch.tb);
2115 if (dlSf->pcch.tb != NULLP)
2117 RG_FREE_MSG(dlSf->pcch.tb);
2120 rgTOMEmtcRlsSf(dlSf);
2122 for(idx=0; idx < dlSf->numRaRsp; idx++)
2124 RG_FREE_MSG(dlSf->raRsp[idx].rar);
2127 /* ADD Changes for Downlink UE Timing Optimization */
2128 #ifdef LTEMAC_DLUE_TMGOPTMZ
2129 dlSf->remDatReqCnt = 0;
2130 /* Fix[ccpu00126310]: Tracks Data Requests from RLC for both loosely and tight coupled
2132 dlSf->statIndDone = FALSE;
2134 if (dlSf->tbs.count)
2139 RGDBGERRNEW(inst, (rgPBuf(inst),
2140 "Error Stale TBs in Subframes TBS list\n"));
2141 node = dlSf->tbs.first;
2144 hqP = (RgDlHqProcCb*)node->node;
2148 for(i=0;i< RG_MAX_TB_PER_UE;i++)
2150 if (hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sf == dlSf)
2152 cmLListDelFrm(&dlSf->tbs, &(hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sfLnk));
2153 hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sfLnk.node = NULLP;
2154 printf("\n rgTOMRlsSf:: hqP %p \n", (Void *)hqP);
2156 hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sf = NULLP;
2161 /*arjun: check if dlSf laaTb list has to be freed???*/
2162 cmLListInit(&dlSf->tbs);
2163 dlSf->txDone = FALSE;
2169 * @brief Function is called by the scheduler once it has completed the
2170 * allocation for the subframe.
2174 * Function : rgHndlFlowCntrl
2175 * This function should fill and send Flow control
2179 * @param[in] Pst *cell
2180 * @param[in] RgInfSfAlloc *sfInfo Carries all the allocation
2186 PUBLIC S16 rgHndlFlowCntrl
2189 RgInfSfAlloc *sfInfo
2192 PUBLIC S16 rgHndlFlowCntrl(cell, sfInfo)
2194 RgInfSfAlloc *sfInfo;
2197 RguFlowCntrlInd *flowCntrlInd;
2201 TRC3(rgHndlFlowCntrl);
2203 pst = &cell->rguDlSap->sapCfg.sapPst;
2204 /* flowCntrlInd is alloced in cell init time and will be re-used throughout */
2205 flowCntrlInd = cell->flowCntrlInd;
2206 flowCntrlInd->cellId = sfInfo->cellId;
2207 flowCntrlInd->numUes = sfInfo->flowCntrlInfo.numUes;
2209 for (ueIdx = 0; ueIdx < sfInfo->flowCntrlInfo.numUes; ueIdx++)
2211 flowCntrlInd->ueFlowCntrlInfo[ueIdx].ueId = sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].ueId;
2212 flowCntrlInd->ueFlowCntrlInfo[ueIdx].numLcs = sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].numLcs;
2214 for (lcIdx = 0; lcIdx < RGINF_MAX_NUM_DED_LC; lcIdx++)
2216 flowCntrlInd->ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].lcId =
2217 sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].lcId;
2218 flowCntrlInd->ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].pktAdmitCnt =
2219 sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].pktAdmitCnt;
2221 flowCntrlInd->ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].maxBo4FlowCtrl =
2222 sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].maxBo4FlowCtrl;
2225 RgUiRguFlowCntrlInd(pst, cell->rguDlSap->sapCfg.spId,flowCntrlInd); /* TODO: Rishi confirm if the suId and pst pointer is correct */
2229 * @brief Function is called by the scheduler once it has completed the
2230 * allocation for the subframe.
2234 * Function : RgSchMacSfAllocReq
2236 * This function shall be invoked whenever scheduler is done with the
2237 * allocations of for a subframe. The sfInfo carries all the allocation
2238 * details for the common channels, RA responses and dedicated channel
2241 * Processing steps :
2242 * 1. Reset the information present in the downlink subframe that is
2244 * 2. Handle common channel allocations
2245 * 3. Handle RA Response allocations
2246 * 4. Handle dedicated channel allocations.
2248 * @param[in] Pst *pst
2249 * @param[in] RgInfSfAlloc *sfInfo Carries all the allocation
2255 PUBLIC S16 RgSchMacSfAllocReq
2258 RgInfSfAlloc *sfInfo
2261 PUBLIC S16 RgSchMacSfAllocReq(pst, sfInfo)
2263 RgInfSfAlloc *sfInfo;
2269 VOLATILE U32 startTime=0;
2272 TRC2(RgSchMacSfAllocReq)
2274 RG_IS_INST_VALID(pst->dstInst);
2275 inst = pst->dstInst - RG_INST_START;
2277 SStartTask(&startTime, PID_MAC_SF_ALLOC_REQ);
2284 if((cell = rgCb[inst].cell) == NULLP)
2286 RLOG_ARG0(L_ERROR,DBG_CELLID,sfInfo->cellId, "No cellCb found with cell");
2290 dlSf = &cell->subFrms[(sfInfo->timingInfo.slot % RG_NUM_SUB_FRAMES)];
2292 rgTOMRlsSf(inst,dlSf);
2293 dlSf->schdTime = sfInfo->timingInfo;
2296 rgLaaInitTbInfoLst(cell);
2299 /* Fix : syed Ignore Failure Returns and continue processing.
2300 * Incomplete processing results in state sync loss between MAC-SCH. */
2302 if(TRUE == cell->emtcEnable)
2304 rgEmtcHndl(cell, sfInfo);
2307 rgHndlCmnChnl(cell, sfInfo->timingInfo, &sfInfo->cmnLcInfo, &err);
2309 rgHndlRaResp(cell, sfInfo->timingInfo, &sfInfo->rarInfo, &err);
2312 #ifdef XEON_SPECIFIC_CHANGES
2313 CM_MEAS_TIME((cell->crntTime.slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_B4_UE_SCHD);
2315 rgHndlSchdUe(cell, sfInfo->timingInfo, &sfInfo->ueInfo, &err);
2316 #ifdef XEON_SPECIFIC_CHANGES
2317 CM_MEAS_TIME((cell->crntTime.slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_UE_SCHD);
2319 rgLaaChkAndReqTbs(dlSf,cell, inst);
2322 rgHndlSchdUe(cell, sfInfo->timingInfo, &sfInfo->ueInfo, &err);
2326 if(rgHndlUlUeInfo(cell, sfInfo->ulUeInfo.timingInfo,
2327 &sfInfo->ulUeInfo) != ROK)
2332 #ifdef XEON_SPECIFIC_CHANGES
2333 CM_MEAS_TIME((cell->crntTime.slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_MEAS);
2335 /* Fix[ccpu00126310]: Tracks Data Requests from RLC for both loosely and tight coupled
2339 /* Added the handling for pushing down
2340 * TFU Data request in the retransmission only scenario.*/
2341 #ifdef LTEMAC_DLUE_TMGOPTMZ
2342 dlSf->statIndDone = TRUE;
2343 /* Fix [ccpu00126310]: Tracks Data Requests from RLC for both loosely and tight coupled
2345 if(!(dlSf->txDone) &&
2347 (TRUE == rgLaaChkAllRxTbs(dlSf)) &&
2349 (0 == dlSf->remDatReqCnt) && (dlSf->statIndDone) &&
2350 (RG_TIMEINFO_SAME(cell->crntTime, dlSf->schdTime)))
2352 /*This is the case of rettransmission, so no need
2353 * to wait for TTI Ind to push TFU Data Request. Send
2355 if (ROK != rgTOMUtlProcDlSf (dlSf, cell, &err))
2357 RLOG_ARG0(L_ERROR,DBG_CELLID,cell->cellId,"Unable to process downlink subframe for cell");
2358 err.errType = RGERR_ROM_DEDDATREQ;
2360 /* Mark this frame as sent */
2361 dlSf->txDone = TRUE;
2364 if (sfInfo->flowCntrlInfo.numUes > 0)
2366 rgHndlFlowCntrl(cell,sfInfo);
2369 SStopTask(startTime, PID_MAC_SF_ALLOC_REQ);
2371 } /* end of RgSchMacSfAllocReq */
2373 * @brief Handler for processing data indication recieved from PHY for UEs.
2377 * Function: rgTOMProcCrntiCEInDatInd
2379 * Handler for processing data indication recieved from PHY for UEs.
2381 * Invoked by: RgLiTfuDatInd of LIM
2384 * For each DataInfo recieved
2385 * - If received a CRNTI control element
2386 * - Check if a CCCH SDU is present, if it is return failure
2387 * - Check for the existence of UE, if its isnt present return failure.
2388 * - Delegate the remaining processing to rgTOMUtlProcMsg3 which
2389 * primarily informs the scheduler about the data received and
2390 * generates Data indications towards the higher layer.
2392 * @param RgMacPdu *pdu,
2393 * @param RgUeCb *prevUeCb,
2394 * @param RgCellCb *cellCb,
2395 * @param TfuDatInfo *datInfo,
2396 * @param RgInfCeInfo *ceInfo
2402 PRIVATE S16 rgTOMProcCrntiCEInDatInd
2407 TfuDatInfo *datInfo,
2408 RgInfCeInfo *ceInfo,
2412 PRIVATE S16 rgTOMProcCrntiCEInDatInd( pdu, prevUeCb, cellCb, datInfo, ceInfo, slot)
2416 TfuDatInfo *datInfo;
2417 RgInfCeInfo *ceInfo;
2421 RgUeCb *ueCb = NULLP;
2422 Inst inst = cellCb->macInst - RG_INST_START;
2430 TRC2(rgTOMProcCrntiCEInDatInd)
2436 ueCb = rgDBMGetUeCbFromRachLst (cellCb, datInfo->rnti);
2440 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2441 "RNTI:%d Received MSG3 with CRNTI,unable to find ueCb", ceInfo->ces.cRnti);
2445 prevUeCb = rgDBMGetUeCb (cellCb, ceInfo->ces.cRnti);
2446 if (prevUeCb == NULLP)
2448 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2449 "RNTI:%d Received MSG3 with CRNTI,unable to find ueCb", ceInfo->ces.cRnti);
2452 RLOG_ARG2(L_DEBUG,DBG_CELLID,cellCb->cellId,
2453 "CRNTI CE(%d) received through tmpCrnti(%d)",
2454 ceInfo->ces.cRnti, datInfo->rnti);
2455 rgDBMDelUeCbFromRachLst(cellCb, ueCb);
2456 rgRAMFreeUeCb(inst,ueCb);
2459 if ((rgTOMUtlProcMsg(cellCb, ueCb, pdu, FALSE,&spsToBeActvtd,&sduSize, slot, NULLP)) != ROK)
2461 if ((rgTOMUtlProcMsg (cellCb, ueCb, pdu, slot, NULLP)) != ROK)
2462 #endif /* LTEMAC_SPS */
2464 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2465 "RNTI:%d Processing for MSG3 failed",datInfo->rnti);
2471 * @brief Handler for processing data indication recieved from PHY for UEs.
2475 * Function: rgTOMProcCCCHSduInDatInd
2477 * Handler for processing data indication recieved from PHY for UEs.
2479 * Invoked by: RgLiTfuDatInd of LIM
2482 * For each DataInfo recieved
2483 * - If only CCCH SDU is present
2484 * - Invoke rgTOMUtlProcMsg3 for further processing.
2485 * - If its a non-Msg3 PDU i.e. received outside of a RA procedure
2486 * - Retrieve the UeCB
2487 * - Validate that the received PDU contains only configured Logical
2489 * - Invoke rgTOMUtlProcDatPdu for further processing. It informs the
2490 * scheduler with the information of the received Data and generates
2491 * DatIndications towards the higher layers.
2493 * @param TfuDatIndInfo *datInd
2494 * @param RgMacPdu *pdu,
2495 * @param RgUeCb *prevUeCb,
2496 * @param RgCellCb *cellCb,
2497 * @param TfuDatInfo *datInfo,
2498 * @param RgInfCeInfo *ceInfo
2504 PRIVATE S16 rgTOMProcCCCHSduInDatInd
2509 TfuDatInfo *datInfo,
2510 RgInfCeInfo *ceInfo,
2514 PRIVATE S16 rgTOMProcCCCHSduInDatInd( pdu, prevUeCb, cellCb, datInfo, ceInfo, slot)
2518 TfuDatInfo *datInfo;
2519 RgInfCeInfo *ceInfo;
2523 RgUeCb *ueCb = NULLP;
2524 Inst inst = cellCb->macInst - RG_INST_START;
2532 TRC2(rgTOMProcCCCHSduInDatInd)
2538 if (ceInfo->bitMask & RG_CRNTI_CE_PRSNT)
2540 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2541 "CRNTI:%d Received MSG3 with CCCH",ceInfo->ces.cRnti);
2545 ueCb = rgDBMGetUeCbFromRachLst (cellCb, datInfo->rnti);
2549 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2550 "RNTI:%d Processing for MSG3 failed", datInfo->rnti);
2553 /* Fix: syed Drop any duplicate Msg3(CCCH Sdu) */
2554 if (ueCb->dl.hqEnt.numHqProcs)
2556 /* HqE is already initialized by a previuos Msg3 */
2557 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"RNTI:%d Processing for MSG3 failed. Duplicate "
2558 "MSG3 received. Dropping", datInfo->rnti);
2562 if(rgDHMHqEntInit(inst,&ueCb->dl.hqEnt,
2563 cellCb->maxDlHqProcPerUe) != ROK)
2565 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"RNTI:%d Harq Initialization failed ",
2569 RLOG_ARG1(L_DEBUG,DBG_CELLID,cellCb->cellId,
2570 "CCCH SDU received through tmpCrnti(%d)",datInfo->rnti);
2572 if ((rgTOMUtlProcMsg(cellCb, ueCb, pdu, FALSE,&spsToBeActvtd,&sduSize, slot, NULLP)) != ROK)
2574 if ((rgTOMUtlProcMsg (cellCb, ueCb, pdu, slot, NULLP)) != ROK)
2575 #endif /* LTEMAC_SPS */
2577 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"RNTI:%d Processing for MSG3 failed",
2586 /** @brief This function captures the BSR value from Control Element
2587 * Info structure and updates the effective Buffer size into the
2588 * corresponding LCG ID.
2592 * Function: rgTOMUtlL2MStoreBufSz
2595 * - update/append the Data structure based on BSR type
2597 * @param [in] RgUeCb *ueCb
2598 * @param [in] RgInfCeInfo *ceInfo
2603 PRIVATE S16 rgTOMUtlL2MStoreBufSz
2609 PRIVATE S16 rgTOMUtlL2MStoreBufSz (ueCb, ceInfo)
2611 RgInfCeInfo *ceInfo;
2616 TRC2(rgTOMUtlL2MStoreBufSz);
2618 if(ceInfo->bitMask & RG_TRUNC_BSR_CE_PRSNT)
2620 lcgId = ((ceInfo->ces.bsr.truncBsr >> 6) & 0x03);
2621 bsr = ceInfo->ces.bsr.truncBsr & 0x3F;
2622 ueCb->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs = rgLwrBsrTbl[bsr];
2624 else if(ceInfo->bitMask & RG_SHORT_BSR_CE_PRSNT)
2626 lcgId = ((ceInfo->ces.bsr.shortBsr >> 6) & 0x03);
2627 bsr = ceInfo->ces.bsr.shortBsr & 0x3F;
2628 ueCb->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs = rgLwrBsrTbl[bsr];
2631 else if(ceInfo->bitMask & RG_LONG_BSR_CE_PRSNT)
2633 ueCb->ul.lcgArr[0].lcgBsInfo.outStndngBs = rgLwrBsrTbl[ceInfo->ces.bsr.longBsr.bs1];
2634 ueCb->ul.lcgArr[1].lcgBsInfo.outStndngBs = rgLwrBsrTbl[ceInfo->ces.bsr.longBsr.bs2];
2635 ueCb->ul.lcgArr[2].lcgBsInfo.outStndngBs = rgLwrBsrTbl[ceInfo->ces.bsr.longBsr.bs3];
2636 ueCb->ul.lcgArr[3].lcgBsInfo.outStndngBs = rgLwrBsrTbl[ceInfo->ces.bsr.longBsr.bs4];
2639 } /* end of rgTOMUtlL2MStoreBufSz*/
2641 /** @brief : Compiles list of LCs received in UL data for DTCH RBs
2645 * @param [in] RgCellCb *cellCb
2646 * @param [in] RgUeCb *ueCb
2647 * @param [in] CmLteRnti rnti
2648 * @param [in] RgMacPdu *pdu
2655 PRIVATE Void rgTOML2MCompileActiveLCs
2663 PRIVATE Void rgTOML2MCompileActiveLCs(cellCb, ueCb, pdu, ceInfo)
2667 RgInfCeInfo *ceInfo;
2674 TRC2(rgTOML2MCompileActiveLCs)
2676 node = pdu->sduLst.first;
2679 sdu = (RgMacSdu*)node->node;
2681 if ((ulLcCb = rgDBMGetUlDedLcCb(ueCb, sdu->lcId)), ulLcCb != NULLP)
2683 if (ulLcCb->lcgId != 0)
2685 ceInfo->bitMask |= RG_ACTIVE_LC_PRSNT;
2686 ceInfo->ulActLCs[ulLcCb->lcId - 1] = TRUE;
2697 /**********************************************************************
2700 **********************************************************************/