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 SlotIndInfo muxTimingInfo;
601 memset(&muxTimingInfo, 0, sizeof(SlotIndInfo));
602 MacDlSlot *currDlSlot = NULLP;
603 ADD_DELTA_TO_TIME(slotInd, muxTimingInfo, PHY_DELTA);
604 currDlSlot = &macCb.macCell->dlSlot[muxTimingInfo.slot];
605 if(currDlSlot->dlInfo.msg4Alloc)
607 BuildAndSendMsg4MuxPdu(currDlSlot->dlInfo.msg4Alloc);
611 /* Trigger for DL TTI REQ */
612 handleDlTtiReq(slotInd);
614 /* Trigger for UL TTI REQ */
615 handleUlTtiReq(slotInd);
617 dlSf = &cellCb->subFrms[(slotInd.slot % RG_NUM_SUB_FRAMES)];
619 if((dlSf->txDone == TRUE) ||
620 (!RG_TIMEINFO_SAME(slotInd,dlSf->schdTime)))
623 #ifndef LTEMAC_DLUE_TMGOPTMZ
624 TfuDatReqInfo *datInfo;
625 CmLteTimingInfo timingInfo;
626 #ifdef TFU_DL_DELTA_CHANGE
627 RGADDTOCRNTTIME(cellCb->crntTime, timingInfo, TFU_DLDATA_DLDELTA);
629 RGADDTOCRNTTIME(cellCb->crntTime, timingInfo, TFU_DELTA);
631 /* Fill Data Request from MAC for BCH */
632 if ((timingInfo.sfn % 4 == 0) && (timingInfo.slot == 0))
634 if (ROK != rgAllocEventMem(inst,(Ptr *)&datInfo,
635 sizeof(TfuDatReqInfo)))
637 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
638 "rgTOMUtlProcDlSf() Unable to Allocate TfuDatReqInfo for cell");
643 cmLListInit(&datInfo->pdus);
644 datInfo->cellId = cellCb->cellId;
645 datInfo->bchDat.pres = NOTPRSNT;
646 datInfo->timingInfo = timingInfo;
649 /* sending the dummy data req to Phy */
650 if (rgLIMTfuDatReq(inst,datInfo) != ROK)
652 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
653 "rgTOMUtlProcDlSf() Unable to send data info for cell");
659 /* Freeing as the part of CL Non RT Indication */
660 /* TDOD : Generalize for all SOCs */
661 #if !(defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD))
662 rgDHMFreeTbBufs(inst);
667 /*Return if there is still some data to be received
668 from RLC for this DL SF. */
669 /* ADD Changes for Downlink UE Timing Optimization */
670 #ifdef LTEMAC_DLUE_TMGOPTMZ
671 if(0 != dlSf->remDatReqCnt)
673 /* Freeing as the part of CL Non RT Indication */
674 /* TODO : Generalize for all SOCs and remove this flag */
675 #if !(defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD))
676 rgDHMFreeTbBufs(inst);
682 #ifdef XEON_SPECIFIC_CHANGES
683 CM_MEAS_TIME((slotInd.slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_DL_BR_PRC);
686 if (ROK != rgTOMUtlProcDlSf (dlSf, cellCb, &err))
688 //RLOG_ARG0(L_ERROR,DBG_CELLID,slotInd->cellId,
689 // "Unable to process downlink subframe for cell");
690 err.errType = RGERR_TOM_TTIIND;
692 #ifdef XEON_SPECIFIC_CHANGES
693 CM_MEAS_TIME((slotInd->slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_DL_AFTER_PRC);
696 /* Mark this frame as sent */
699 /* Freeing as the part of CL Non RT Indication */
700 /* TODO : Generalize for all SOCs and remove this flag */
701 #if !(defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD))
702 rgDHMFreeTbBufs(inst);
705 } /* macProcessSlotInd */
707 /** @brief This function allocates the RgMacPdu that will be populated by DEMUX
708 * with the SubHeaders list and the values of the Control elements.
712 * Function: rgTOMUtlAllocPduEvnt
715 * @param[in] Inst inst
716 * @param [out] RgMacPdu **pdu
723 PRIVATE S16 rgTOMUtlAllocPduEvnt
729 PRIVATE S16 rgTOMUtlAllocPduEvnt (inst,pdu)
736 RgUstaDgn dgn; /* Alarm diagnostics structure */
737 VOLATILE U32 startTime=0;
739 TRC2(rgTOMUtlAllocPduEvnt);
741 evntMem.region = rgCb[inst].rgInit.region;
742 evntMem.pool = rgCb[inst].rgInit.pool;
745 SStartTask(&startTime, PID_TOMUTL_CMALLCEVT);
747 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
748 MS_BUF_ADD_ALLOC_CALLER();
751 if (cmAllocEvnt (sizeof (RgMacPdu), RG_BLKSZ, &evntMem, (Ptr*)pdu) != ROK)
753 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
754 rgLMMStaInd(inst,LCM_CATEGORY_RESOURCE, LCM_EVENT_DMEM_ALLOC_FAIL,
755 LCM_CAUSE_MEM_ALLOC_FAIL, &dgn);
756 RLOG0(L_ERROR,"Allocation of DUX event failed");
761 SStopTask(startTime, PID_TOMUTL_CMALLCEVT);
766 /** @brief This function frees up the RgMacPdu structure that has been
767 * populated by demux.
771 * Function: rgTOMUtlFreePduEvnt
772 * - Function frees up the RgMacPdu structure, in case of error it shall
773 * free up the buffer's present in the different sdu.
776 * @param [in] Inst inst
777 * @param [in] RgMacPdu *pdu
778 * @param [in] Bool *error
782 PRIVATE Void rgTOMUtlFreePduEvnt
788 PRIVATE Void rgTOMUtlFreePduEvnt (pdu, error)
797 TRC2(rgTOMUtlFreePduEvnt);
798 /* Steps of freeing up the PDU.
799 * 1. loop through the subHdrLst and free up all the buffers.
800 * 2. free up the whole event
802 if ((error == TRUE) && (pdu->sduLst.count > 0))
804 node = pdu->sduLst.first;
807 sdu = (RgMacSdu*)node->node;
808 RG_FREE_MSG(sdu->mBuf);
814 } /* end of rgTOMUtlFreePduEvnt */
816 /** @brief This function allocates the RgMacPdu that will be populated by DEMUX
817 * with the SubHeaders list and the values of the Control elements.
821 * Function: rgTOMInfAllocPduEvnt
824 * @param [in] Inst inst
825 * @param [out] RgMacPdu **pdu
832 PRIVATE S16 rgTOMInfAllocPduEvnt
835 RgInfSfDatInd **sfInfo
838 PRIVATE S16 rgTOMInfAllocPduEvnt (inst,sfInfo)
840 RgInfSfDatInd **sfInfo;
845 RgUstaDgn dgn; /* Alarm diagnostics structure */
846 VOLATILE U32 startTime=0;
848 TRC2(rgTOMInfAllocPduEvnt);
850 evntMem.region = rgCb[inst].rgInit.region;
851 evntMem.pool = rgCb[inst].rgInit.pool;
854 SStartTask(&startTime, PID_TOMINF_CMALLCEVT);
856 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
857 MS_BUF_ADD_ALLOC_CALLER();
859 if (cmAllocEvnt (sizeof (RgInfSfDatInd), RG_BLKSZ, &evntMem, (Ptr*)sfInfo) != ROK)
861 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
862 rgLMMStaInd(inst,LCM_CATEGORY_RESOURCE, LCM_EVENT_DMEM_ALLOC_FAIL,
863 LCM_CAUSE_MEM_ALLOC_FAIL, &dgn);
864 RLOG0(L_ERROR,"Allocation failed");
869 SStopTask(startTime, PID_TOMINF_CMALLCEVT);
874 /** @brief This function frees up the RgMacPdu structure that has been
875 * populated by demux.
879 * Function: rgTOMInfFreePduEvnt
880 * - Function frees up the RgMacPdu structure, in case of error it shall
881 * free up the buffer's present in the different sdu.
884 * @param [in] RgMacPdu *pdu
885 * @param [in] Bool *error
889 PRIVATE Void rgTOMInfFreePduEvnt
891 RgInfSfDatInd *sfInfo
894 PRIVATE Void rgTOMInfFreePduEvnt (sfInfo)
895 RgInfSfDatInd *sfInfo;
898 TRC2(rgTOMInfFreePduEvnt);
902 } /* end of rgTOMUtlFreePduEvnt */
906 /** @brief This function performs the preparation of information needed to set
907 * L2M Scheduled UL Throughput Information for a particular UE.
911 * Function: rgTomUtlPrepareL2MUlThrpInfo
912 * This function performs the preparation of information needed to set
913 * L2M Scheduled UL Throughput Information for a particular UE.
917 * @param [in] RgCellCb *cellCb
918 * @param [in] RgUeCb *ueCb
919 * @param [out] RgRguDedDatInd *dDatInd
923 PRIVATE S16 rgTomUtlPrepareL2MUlThrpInfo
927 RgRguDedDatInd *dDatInd
930 PRIVATE S16 rgTomUtlPrepareL2MUlThrpInfo(cellCb,ueCb,dDatInd)
933 RgRguDedDatInd *dDatInd;
939 TRC2(rgTomUtlPrepareL2MUlThrpInfo);
941 dDatInd->burstInd = RGU_L2M_UL_BURST_END;
942 for(loop=0;loop<dDatInd->numLch;loop++)
944 lcId=dDatInd->lchData[loop].lcId;
947 lcgId = ueCb->ul.lcCb[lcId - 1].lcgId;
948 if(ueCb->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs > 0)
950 dDatInd->burstInd = RGU_L2M_UL_BURST_START;
961 /** @brief This function is called by rgTOMDatInd. This function invokes the
962 * scheduler with the information of the received Data and any Control Elements
963 * if present. Also it generates Data indications towards the higher layers.
970 * - Retrieves the RaCb with the rnti provided, if it doesnt exist
972 * - If UE exists then update the Schduler with any MAC CEs if present.
973 * - Invoke RAM module to do Msg3 related processing rgRAMProcMsg3
974 * - Loop through the SDU subheaders and invoke either a common data
975 * indication (rgUIMSndCmnDatInd) or dedicated data indication
976 * (rgUIMSndDedDatInd) towards the higher layers.
978 * @param [in] RgCellCb *cellCb
979 * @param [in] RgUeCb *ueCb
980 * @param [in] CmLteRnti rnti
981 * @param [in] RgMacPdu *pdu
982 * @param [out] U32 *lcgBytes
993 PRIVATE S16 rgTOMUtlProcMsg
1005 PRIVATE S16 rgTOMUtlProcMsg(cellCb, ueCb, pdu, isSpsRnti,spsToBeActvtd,sduSize, slot, lcgBytes)
1010 Bool *spsToBeActvtd;
1015 #else /* LTEMAC_SPS */
1017 PRIVATE S16 rgTOMUtlProcMsg
1026 PRIVATE S16 rgTOMUtlProcMsg(cellCb, ueCb, pdu, slot, lcgBytes)
1035 Inst inst = cellCb->macInst - RG_INST_START;
1037 RgRguCmnDatInd *cDatInd;
1038 RgRguDedDatInd *dDatInd;
1045 // RgInfSpsRelInfo relInfo;
1052 U16 totalBytesRcvd = 0;
1053 U16 sduLen[RGU_MAX_LC] = {0};
1054 U8 qciVal[RGU_MAX_LC] = {0};
1061 /* Moved outside of LTE_L2_MEAS
1062 * scope as this pointer will now be used to
1063 * check for valid Logical Channel ID
1080 TRC2(rgTOMUtlProcMsg)
1086 if(pdu->sduLst.first)
1088 sdu = (RgMacSdu*)(pdu->sduLst.first->node);
1090 if ((sdu->lcId == RG_CCCH_LCID))
1092 /* code for common channel dat indications */
1093 if ((ret = rgAllocShrablSBuf (inst,(Data**)&cDatInd, sizeof(RgRguCmnDatInd))) != ROK)
1097 cDatInd->cellId = cellCb->cellId;
1098 cDatInd->rnti = ueCb->ueId;
1099 /* rg001.101: Corrected lcId value for common data indication */
1100 cDatInd->lcId = cellCb->ulCcchId;
1101 cDatInd->pdu = sdu->mBuf;
1102 SFndLenMsg (sdu->mBuf, &ccchSz);
1103 /* Fix : syed Contention resolution ID copy should consider only
1104 * 6 bytes of information from sdu->mBuf. Incase of CCCH sdu for reest
1105 * message/psuedo reest message, ccchSz can go beyond 6 and can corrupt
1106 * other fields of ueCb. */
1107 if (ccchSz >= RG_CRES_LEN)
1109 SCpyMsgFix (sdu->mBuf, (MsgLen)0, RG_CRES_LEN, ueCb->contResId.resId,
1112 #ifdef XEON_SPECIFIC_CHANGES
1113 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);
1116 rgUIMSndCmnDatInd(inst,cellCb->rguUlSap,cDatInd);
1118 } /* end of common channel processing */
1120 if ((ret = rgAllocShrablSBuf (inst,(Data**)&dDatInd, sizeof(RgRguDedDatInd))) != ROK)
1126 elem = SRngGetWIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
1131 dDatInd = (RgRguDedDatInd *)elem;
1132 cmMemset((U8 *)dDatInd, 0x00, sizeof(RgRguDedDatInd));
1134 dDatInd->cellId = cellCb->cellId;
1135 dDatInd->rnti = ueCb->ueId;
1136 dDatInd->numLch = 0;
1139 ulSf = &cellCb->ulSf[(slot % RG_NUM_SUB_FRAMES)];
1140 if(ulSf->ueUlAllocInfo != NULLP)
1142 for(idx1 = 0; idx1 < ulSf->numUe; idx1++)
1144 if(ulSf->ueUlAllocInfo[idx1].rnti == ueCb->ueId)
1146 numPrb = ulSf->ueUlAllocInfo[idx1].numPrb;
1152 node = pdu->sduLst.first;
1155 sdu = (RgMacSdu*)node->node;
1157 ulLcCb = rgDBMGetUlDedLcCb (ueCb, sdu->lcId);
1161 RLOG_ARG2(L_ERROR,DBG_CELLID,cellCb->cellId,"Unconfigured LCID:%d CRNTI:%d"
1162 ,sdu->lcId,ueCb->ueId);
1163 /* ccpu00128443: Fix for memory leak */
1164 /* Fix : syed Neccessary to set sdu->mBuf = NULLP */
1165 RG_FREE_MSG(sdu->mBuf);
1169 #ifdef RLC_STA_PROC_IN_MAC/* RLC Status PDU Processing */
1171 extern S16 kwProcDlStatusPdu(Pst *udxPst,SuId suId,
1172 CmLteCellId cellId,CmLteRnti rnti,CmLteLcId lcId,Buffer *rlcSdu);
1174 if(ROK == kwProcDlStatusPdu(&(cellCb->rguDlSap->sapCfg.sapPst),
1175 cellCb->rguDlSap->sapCfg.suId,
1176 cellCb->cellId,ueCb->ueId,sdu->lcId,sdu->mBuf))
1178 RG_FREE_MSG(sdu->mBuf);
1185 /* ccpu00116477- Fixed the rgUIMSndDedDatInd condition when we receive 11 sdus in the
1186 * list we are losing 11th sdu and sending the first 10 sdus again which
1187 * is causing the duplicate packets and eNB crashing due to access
1188 * of the freed memory */
1189 if (dDatInd->numLch >= RGU_MAX_LC)
1191 if ((ret = rgUIMSndDedDatInd(inst,ueCb->rguUlSap,dDatInd)) != ROK)
1193 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
1194 "Failed to send datIndication to RGU CRNTI:%d",ueCb->ueId);
1198 if ((ret = rgAllocShrablSBuf (inst,(Data**)&dDatInd, sizeof(RgRguDedDatInd))) != ROK)
1203 elem = SRngGetWIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
1208 dDatInd = (RgRguDedDatInd *)elem;
1209 cmMemset((U8 *)dDatInd, 0x00, sizeof(RgRguDedDatInd));
1211 dDatInd->cellId = cellCb->cellId;
1212 dDatInd->rnti = ueCb->ueId;
1213 dDatInd->numLch = 0;
1215 dDatInd->lchData[dDatInd->numLch].lcId = sdu->lcId;
1216 dDatInd->lchData[dDatInd->numLch].pdu.mBuf[dDatInd->lchData[dDatInd->numLch].pdu.numPdu] = sdu->mBuf;
1217 dDatInd->lchData[dDatInd->numLch].pdu.numPdu++;
1218 lcgId = ulLcCb->lcgId;
1219 SFndLenMsg(sdu->mBuf, &bufSz);
1223 ueCb->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs -= bufSz;
1226 //if ((lcgBytes != NULLP) && (ueCb->ul.lcgArr[lcgId].isGbr == TRUE))
1227 if (lcgBytes != NULLP)
1229 lcgBytes[lcgId] += bufSz;
1234 /* Check if data has come on SPS LC */
1235 /* KWORK_FIX: Modified the index from lcId to lcId-1 for handling lcId 10 properly */
1236 if (ueCb->ul.spsLcId[sdu->lcId-1] == TRUE)
1238 ueCb->ul.spsDatRcvd++;
1243 /* Data rcvd on CRNTI*/
1244 /* Retrieve the LCG ID of the LCID*/
1245 /* SPS LCG has data whose size > SID Size */
1246 /* Activate SPS if data recvd on SPS LCID and size > SID Packet Size */
1247 if((ueCb->ul.spsLcId[sdu->lcId-1] == TRUE) &&
1248 (sdu->len > RG_SPS_SID_PACKET_SIZE))
1250 *spsToBeActvtd = TRUE;
1251 *sduSize = sdu->len;
1258 if(cellCb->qciArray[ulLcCb->qci].mask == TRUE)
1260 sduLen[ulLcCb->qci] = sdu->len;
1261 totalBytesRcvd += sdu->len;
1262 qciVal[ulLcCb->qci] = ulLcCb->qci;
1266 } /* end of while for SubHeaders */
1268 for(idx2 = 0; idx2 < RGU_MAX_LC; idx2++)
1270 if((cellCb->qciArray[qciVal[idx2]].mask == TRUE) &&
1273 cellCb->qciArray[qciVal[idx2]].prbCount +=
1274 ((numPrb * sduLen[idx2]) / totalBytesRcvd);
1278 if(totalBytesRcvd > 0 && qciVal[idx2] > 0)
1280 RG_UPD_GBR_PRB(cellCb, qciVal[idx2], ((numPrb * sduLen[idx2])/totalBytesRcvd));
1285 /*Added for explicit release - start*/
1288 if(isSpsRnti && dDatInd && dDatInd->numLch)
1290 if(ueCb->ul.spsDatRcvd != 0)
1292 ueCb->ul.explRelCntr = 0;
1293 ueCb->ul.spsDatRcvd = 0;
1297 ueCb->ul.explRelCntr++;
1298 if (ueCb->ul.explRelCntr == ueCb->ul.explRelCnt)
1300 ueCb->ul.explRelCntr = 0;
1301 /* Indicate scheduler for explicit release */
1302 cmMemset((U8*)&schPst1, (U8)0, sizeof(Pst));
1303 rgGetPstToInst(&schPst1,inst, cellCb->schInstMap.schInst);
1304 //TODO: commented for compilation without SCH
1306 relInfo.cellSapId = cellCb->schInstMap.cellSapId;
1307 relInfo.cRnti = ueCb->ueId;
1308 relInfo.isExplRel = TRUE;
1309 /* Release indicator is called now through the matrix in the function below */
1310 //TODO: commented for compilation without SCH RgMacSchSpsRel( &schPst1, &relInfo );
1312 ueCb->ul.implRelCntr = 0;
1319 if(ueCb->ul.spsDatRcvd != 0)
1321 //ueCb->ul.implRelCntr = 0;
1322 ueCb->ul.explRelCntr = 0;
1323 ueCb->ul.spsDatRcvd = 0;
1327 /*Added for explicit release - end */
1329 if((dDatInd) && (dDatInd->numLch))
1332 rgTomUtlPrepareL2MUlThrpInfo(cellCb, ueCb,dDatInd);
1334 RG_CALC_TTI_CNT(cellCb, dDatInd->ttiCnt);
1336 if ((ret = rgUIMSndDedDatInd(inst,ueCb->rguUlSap,dDatInd)) != ROK)
1338 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
1339 "Failed to send datIndication to RGU CRNTI:%d",ueCb->ueId);
1344 else if((dDatInd) && (0 == dDatInd->numLch))
1346 /* Free the memory allocated for dDatInd if we
1347 * have no valid LCH PDU to send to RLC.*/
1348 rgFreeSharableSBuf(inst,(Data **)&dDatInd,sizeof(RgRguDedDatInd));
1354 /** @brief This function frees up the RgMacPdu structure that has been
1355 * populated by demux.
1359 * Function: rgTOMUtlInsSchInfo
1360 * - Function frees up the RgMacPdu structure, in case of error it shall
1361 * free up the buffer's present in the different sdu.
1364 * @param [in] RgMacPdu *pdu
1365 * @param [in] Bool *error
1370 PRIVATE S16 rgTOMUtlInsSchInfo
1373 RgInfSfDatInd *sfInfo,
1374 RgInfCeInfo *ceInfo,
1381 PRIVATE S16 rgTOMUtlInsSchInfo (pdu, sfInfo, ceInfo, rnti,spsToBeActvtd,sduSize, lcgBytes)
1383 RgInfSfDatInd *sfInfo;
1384 RgInfCeInfo *ceInfo;
1393 PRIVATE S16 rgTOMUtlInsSchInfo
1396 RgInfSfDatInd *sfInfo,
1397 RgInfCeInfo *ceInfo,
1402 PRIVATE S16 rgTOMUtlInsSchInfo (pdu, sfInfo, ceInfo, rnti, lcgBytes)
1404 RgInfSfDatInd *sfInfo;
1405 RgInfCeInfo *ceInfo;
1412 RgInfUeDatInd *ueInfo;
1416 TRC2(rgTOMUtlInsSchInfo);
1418 RG_TOM_INF_ALLOC(sfInfo, sizeof(RgInfUeDatInd), ueInfo, ret);
1425 ueInfo->rnti = rnti;
1427 ueInfo->ceInfo = *ceInfo;
1428 ueInfo->ueLstEnt.node = (PTR)ueInfo;
1429 for (lcgId = 1, idx = 0; lcgId < RGINF_MAX_LCG_PER_UE; lcgId++)
1431 if (lcgBytes[lcgId] != 0)
1433 /* Only GBR bytes */
1434 ueInfo->lcgInfo[idx].lcgId = lcgId;
1435 ueInfo->lcgInfo[idx++].bytesRcvd = lcgBytes[lcgId];
1436 lcgBytes[lcgId] = 0;
1439 cmLListAdd2Tail(&sfInfo->ueLst, &ueInfo->ueLstEnt);
1441 } /* end of rgTOMUtlInsSchInfo */
1445 * @brief Handler for processing data indication recieved from PHY for UEs.
1449 * Function: rgTOMDatInd
1451 * Handler for processing data indication recieved from PHY for UEs.
1453 * Invoked by: RgLiTfuDatInd of LIM
1456 * For each DataInfo recieved
1457 * - Validate the information received and retrieve cellCb
1458 * Validate cellId, rnti
1459 * - Call De-Mux module to decode the data rgDUXDemuxData
1460 * - If received a CRNTI control element
1461 * - Check if a CCCH SDU is present, if it is return failure
1462 * - Check for the existence of UE, if its isnt present return failure.
1463 * - Delegate the remaining processing to rgTOMUtlProcMsg3 which
1464 * primarily informs the scheduler about the data received and
1465 * generates Data indications towards the higher layer.
1466 * - If only CCCH SDU is present
1467 * - Invoke rgTOMUtlProcMsg3 for further processing.
1468 * - If its a non-Msg3 PDU i.e. received outside of a RA procedure
1469 * - Retrieve the UeCB
1470 * - Validate that the received PDU contains only configured Logical
1472 * - Invoke rgTOMUtlProcDatPdu for further processing. It informs the
1473 * scheduler with the information of the received Data and generates
1474 * DatIndications towards the higher layers.
1476 * @param [in] Inst inst
1477 * @param[in] TfuDatIndInfo *datInd
1483 PUBLIC S16 rgTOMDatInd
1486 TfuDatIndInfo *datInd
1489 PUBLIC S16 rgTOMDatInd(inst,datInd)
1491 TfuDatIndInfo *datInd;
1497 RgUeCb *prevUeCb = NULLP;
1500 RgInfSfDatInd *sfInfo;
1504 TfuDatInfo *datInfo;
1508 Bool isSpsRnti=FALSE;
1510 // RgInfSpsRelInfo relInfo;
1511 Bool spsToBeActvtd = FALSE;
1514 U32 lcgBytes[RGINF_MAX_LCG_PER_UE];
1518 #ifdef STUB_TTI_HANDLING_5GTF
1519 node = datInd->datIndLst.first;
1520 for (;node; node=node->next)
1522 datInfo = (TfuDatInfo*)node->node;
1525 SFndLenMsg(datInfo->mBuf, &len);
1526 rgUlrate_tfu += len;
1527 if (rgUlrate_tfu > 100000)
1529 printf("Sowmya:rgTOMDatInd datInfo->mBuf len =%d rgUlrate_tfu=%d",len,rgUlrate_tfu);
1537 cmMemset((U8 *)&lcgBytes, 0, sizeof(lcgBytes));
1539 tfuSap = &(rgCb[inst].tfuSap);
1541 cellCb = rgCb[inst].cell;
1542 if((cellCb == NULLP) ||
1543 (cellCb->cellId != datInd->cellId))
1546 RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"Unable to get the cellCb for cell");
1549 /* Avoiding memset as all the fields are getting initialized further */
1551 if (rgTOMInfAllocPduEvnt (inst,&sfInfo) != ROK)
1553 err.errType = RGERR_TOM_DATIND;
1554 RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"Unable to Allocate PDU for DUX cell");
1555 node = datInd->datIndLst.first;
1558 cmLListInit(&sfInfo->ueLst);
1559 sfInfo->cellId = datInd->cellId;
1560 sfInfo->timingInfo = datInd->timingInfo;
1561 slot = datInd->timingInfo.slot;
1563 node = datInd->datIndLst.first;
1564 for (;node; node=node->next)
1566 datInfo = (TfuDatInfo*)node->node;
1568 //extern U32 ulrate_tfu;
1570 SFndLenMsg(datInfo->mBuf, &len);
1571 #ifdef STUB_TTI_HANDLING_5GTF
1572 // printf("Sowmya:rgTOMDatInd datInfo->mBuf len =%d",len);
1574 rgUlrate_tfu += len;
1576 grgUlrate_tfu += len;
1579 #ifdef STUB_TTI_HANDLING_5GTF
1580 rgLIMUtlFreeDatIndEvnt(datInd,TRUE);
1582 /* We shall call De-Mux to process the received buffer. We shall try and find
1583 * out the RaCb based on the following -
1584 * 1. If the incoming PDU contained a CCCH SDU i.e. this is message 3.
1585 * 2. If the incoming PDU contained a CRNTI control element, i.e. we should
1586 * have a ueCb also for this
1588 /* Lets allocate the event that needs to be passed to DUX */
1589 if (rgTOMUtlAllocPduEvnt (inst,&pdu) != ROK)
1591 err.errType = RGERR_TOM_DATIND;
1592 RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"Unable to Allocate PDU for DUX cell");
1593 rgTOMInfFreePduEvnt (sfInfo);
1597 if ((ret = rgDUXDemuxData (inst,pdu, &ceInfo,
1598 &datInfo->mBuf, &err)) != ROK)
1601 /* Fix: sriky memory corruption precautions */
1602 rgTOMUtlFreePduEvnt (pdu, TRUE);
1603 err.errType = RGERR_TOM_DATIND;
1604 RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"DUX processing failed");
1605 tfuSap->sapSts.numPduDrop++;
1608 /* It could be that a non-msg3 pdu contains a CRNTI Control element. We
1609 * should check for CRNTI CE and if it exists the UECb must exist, also an
1610 * if the CRNTI in the CE and the one with which the message came in are
1611 * different we shall look for an raCb as well.
1614 if (ceInfo.bitMask & RG_CCCH_SDU_PRSNT)
1616 ret = rgTOMProcCCCHSduInDatInd(pdu, prevUeCb, \
1617 cellCb, datInfo, &ceInfo, slot);
1620 rgTOMUtlFreePduEvnt (pdu, TRUE);
1621 err.errType = RGERR_TOM_DATIND;
1622 tfuSap->sapSts.numPduDrop++;
1625 } /* end of Msg3 processing */
1627 else if (ceInfo.bitMask & RG_CRNTI_CE_PRSNT)
1629 ret = rgTOMProcCrntiCEInDatInd(pdu, prevUeCb, \
1630 cellCb, datInfo, &ceInfo, slot);
1633 rgTOMUtlFreePduEvnt (pdu, TRUE);
1634 err.errType = RGERR_TOM_DATIND;
1635 tfuSap->sapSts.numPduDrop++;
1639 } /* end of CRNTI based message */
1642 ueCb = rgDBMGetUeCb (cellCb, datInfo->rnti);
1646 /* Try getting the UE using SPS-RNTI. */
1647 ueCb = rgDBMGetSpsUeCb (cellCb, datInfo->rnti);
1651 /* Increment implrelCntr for an empty transmission */
1652 if (pdu->sduLst.count == 0)
1654 ueCb->ul.implRelCntr++;
1655 if (ueCb->ul.implRelCntr == ueCb->ul.implRelCnt)
1657 /* Indicate scheduler for implicit release */
1658 cmMemset((U8*)&schPst1, (U8)0, sizeof(Pst));
1659 rgGetPstToInst(&schPst1,inst, cellCb->schInstMap.schInst);
1661 ueCb->ul.implRelCntr = 0;
1662 ueCb->ul.explRelCntr = 0;
1664 relInfo.cellSapId = cellCb->schInstMap.cellSapId;
1665 relInfo.cRnti = ueCb->ueId;
1666 relInfo.isExplRel= FALSE;
1667 //TODO: commented for compilation without SCH RgMacSchSpsRel(&schPst1, &relInfo);
1673 /* Reset the implrelCntr */
1674 ueCb->ul.implRelCntr = 0;
1680 /* Perform failure if ueCb is still NULLP */
1681 rgTOMUtlFreePduEvnt (pdu, TRUE);
1682 err.errType = RGERR_TOM_DATIND;
1683 RLOG_ARG1(L_ERROR,DBG_CELLID,datInd->cellId,"RNTI:%d Unable to get the UE CB",
1685 tfuSap->sapSts.numPduDrop++;
1690 rgTOMUtlL2MStoreBufSz(ueCb, &ceInfo);
1691 rgTOML2MCompileActiveLCs (cellCb, ueCb, pdu, &ceInfo);
1694 if ((ret = rgTOMUtlProcMsg(cellCb, ueCb, pdu, isSpsRnti,&spsToBeActvtd,&sduSize, slot, (U32 *)&lcgBytes)) != ROK)
1696 if ((ret = rgTOMUtlProcMsg (cellCb, ueCb, pdu, slot, (U32 *)&lcgBytes)) != ROK)
1697 #endif /* LTEMAC_SPS */
1699 rgTOMUtlFreePduEvnt (pdu, TRUE);
1700 err.errType = RGERR_TOM_DATIND;
1701 RLOG_ARG1(L_ERROR,DBG_CELLID,datInd->cellId,
1702 "Unable to handle Data Indication CRNTI:%d",ueCb->ueId);
1703 tfuSap->sapSts.numPduDrop++;
1710 if(rgTOMUtlInsSchInfo(pdu, sfInfo, &ceInfo, datInfo->rnti,spsToBeActvtd,sduSize, (U32 *)&lcgBytes) != ROK)
1712 if(rgTOMUtlInsSchInfo(pdu, sfInfo, &ceInfo, datInfo->rnti, (U32 *)&lcgBytes) != ROK)
1716 rgTOMInfFreePduEvnt (sfInfo);
1717 rgTOMUtlFreePduEvnt (pdu, FALSE);
1720 /* free up the PDU memory */
1721 rgTOMUtlFreePduEvnt (pdu, FALSE);
1723 /* Free the allocated memory for ueUlAllocInfo here */
1725 if(cellCb->ulSf[(slot % RG_NUM_SUB_FRAMES)].ueUlAllocInfo != NULLP)
1727 /*ccpu00117052 - MOD - Passing double for proper NULLP
1729 rgFreeSBuf(inst,(Data **)&(cellCb->ulSf[(slot % RG_NUM_SUB_FRAMES)].ueUlAllocInfo),
1730 ((cellCb->ulSf[(slot % RG_NUM_SUB_FRAMES)].numUe) * sizeof(RgUeUlAlloc)));
1734 /* Update PRB used for all GBR QCIs to scheduler */
1735 cmMemcpy((U8*) &sfInfo->qcisUlPrbCnt[0],
1736 (U8*) &cellCb->qcisUlPrbCnt[0],
1737 (RGM_MAX_QCI_REPORTS * sizeof(U32)));
1738 /* clear the cellCb ul prb value */
1739 cmMemset((U8*)&cellCb->qcisUlPrbCnt[0], 0,
1740 (RGM_MAX_QCI_REPORTS * sizeof(U32)));
1744 rgGetPstToInst(&schPst, inst,cellCb->schInstMap.schInst);
1745 sfInfo->cellSapId = cellCb->schInstMap.cellSapId;
1746 //TODO: commented for compilation without SCH RgMacSchSfRecp(&schPst, sfInfo);
1751 * @brief Function handles allocation for common channels i.e. BCCH-BCH,
1752 * BCCH-DLSCH, PCCH-DLSCH.
1756 * Function : rgHndlCmnChnl
1758 * This function is invoked from RgSchMacSfAllocReq. This function handles
1759 * allocations made for common channels like BCCH and PCCH.
1762 * 1. If BCCH on BCH has been scheduled, send StatusIndication on RGU.
1763 * 2. If PCCH is scheduled, send StatusIndication on RGU.
1764 * 3. If BCCH on DLSCH has been scheduled and sndStatInd is TRUE, send
1765 * StatusIndication on RGU, else copy the bcch buffer onto the downlink
1769 * @param[in] RgCellCb *cell,
1770 * @param[in] CmLteTimingInfo timingInfo,
1771 * @param[in] RgInfCmnLcInfo *cmnLcInfo,
1772 * @param[in/out] RgErrInfo *err,
1778 PRIVATE S16 rgHndlCmnChnl
1781 CmLteTimingInfo timingInfo,
1782 RgInfCmnLcInfo *cmnLcInfo,
1786 PRIVATE S16 rgHndlCmnChnl(cell, timingInfo, cmnLcInfo, err)
1788 CmLteTimingInfo timingInfo;
1789 RgInfCmnLcInfo *cmnLcInfo;
1793 #if (ERRCLASS & ERRCLS_DEBUG)
1797 RgBcchDlschLcCb *bcch;
1798 #if (ERRCLASS & ERRCLS_DEBUG)
1801 #endif/*RGR_SI_SCH*/
1802 RguCStaIndInfo *staInd;
1804 Inst inst = cell->macInst - RG_INST_START;
1808 dlSf = &cell->subFrms[(timingInfo.slot % RG_NUM_SUB_FRAMES)];
1810 if(cmnLcInfo->bitMask & RGINF_BCH_INFO)
1813 #if (ERRCLASS & ERRCLS_DEBUG)
1814 if(NULLP == (bch = rgDBMGetBcchOnBch(cell)))
1818 if(cmnLcInfo->bchInfo.lcId != bch->lcId)
1824 if (rgAllocShrablSBuf (inst,(Data**)&staInd, sizeof(RguCStaIndInfo)) != ROK)
1826 err->errCause = RGERR_TOM_MEM_EXHAUST;
1829 staInd->cellId = cell->cellId;
1830 staInd->rnti = RG_INVALID_RNTI;
1831 staInd->lcId = cmnLcInfo->bchInfo.lcId;
1832 staInd->transId = (timingInfo.sfn << 8) | (timingInfo.slot);
1833 /* ADD Changes for Downlink UE Timing Optimization */
1834 #ifdef LTEMAC_DLUE_TMGOPTMZ
1835 dlSf->remDatReqCnt++;
1837 if (rgUIMSndCmnStaInd (inst,cell->rguDlSap,staInd) != ROK)
1842 /*Store the received BCH Data in the scheduled subframe*/
1843 dlSf->bch.tb = cmnLcInfo->bchInfo.pdu;
1844 #endif/*RGR_SI_SCH*/
1847 if(cmnLcInfo->bitMask & RGINF_PCCH_INFO)
1849 #if (ERRCLASS & ERRCLS_DEBUG)
1850 if(NULLP == (pcch = rgDBMGetPcch(cell)))
1854 if(cmnLcInfo->pcchInfo.lcId != pcch->lcId)
1860 dlSf->pcch.pdcch.rnti =
1861 cmnLcInfo->pcchInfo.rnti;
1862 dlSf->pcch.pdcch.dci =
1863 cmnLcInfo->pcchInfo.dciInfo;
1865 /* ccpu00132314-ADD-Fill the tx Pwr offset from scheduler */
1866 dlSf->pcch.txPwrOffset = cmnLcInfo->pcchInfo.txPwrOffset;
1868 if (rgAllocShrablSBuf (inst,(Data**)&staInd, sizeof(RguCStaIndInfo)) != ROK)
1870 err->errCause = RGERR_TOM_MEM_EXHAUST;
1873 staInd->cellId = cell->cellId;
1874 staInd->rnti = RG_INVALID_RNTI;
1875 staInd->lcId = cmnLcInfo->pcchInfo.lcId;
1876 staInd->transId = (timingInfo.sfn << 8) | (timingInfo.slot);
1877 /* ADD Changes for Downlink UE Timing Optimization */
1878 #ifdef LTEMAC_DLUE_TMGOPTMZ
1879 dlSf->remDatReqCnt++;
1881 /* for consolidated CmnStaInd calling below function from function
1882 * rgHndlSchedUe once CmnStaInd prepared for all UEs
1884 if (rgUIMSndCmnStaInd (inst,cell->rguDlSap,staInd) != ROK)
1890 if(cmnLcInfo->bitMask & RGINF_BCCH_INFO)
1892 dlSf->bcch.pdcch.rnti =
1893 cmnLcInfo->bcchInfo.rnti;
1894 dlSf->bcch.pdcch.dci =
1895 cmnLcInfo->bcchInfo.dciInfo;
1897 /* ccpu00132314-ADD-Fill the tx Pwr offset from scheduler */
1898 dlSf->bcch.txPwrOffset = cmnLcInfo->bcchInfo.txPwrOffset;
1902 (bcch=rgDBMGetBcchOnDlsch(cell,cmnLcInfo->bcchInfo.lcId)))
1906 if(TRUE == cmnLcInfo->bcchInfo.sndStatInd)
1908 RG_FREE_MSG(bcch->tb);
1909 if (rgAllocShrablSBuf (inst,(Data**)&staInd,
1910 sizeof(RguCStaIndInfo)) != ROK)
1912 err->errCause = RGERR_TOM_MEM_EXHAUST;
1915 staInd->cellId = cell->cellId;
1916 staInd->rnti = RG_INVALID_RNTI;
1917 staInd->lcId = cmnLcInfo->bcchInfo.lcId;
1918 staInd->transId = (timingInfo.sfn << 8) | (timingInfo.slot);
1919 /* ADD Changes for Downlink UE Timing Optimization */
1920 #ifdef LTEMAC_DLUE_TMGOPTMZ
1921 dlSf->remDatReqCnt++;
1923 if (rgUIMSndCmnStaInd (inst,cell->rguDlSap,staInd) != ROK)
1930 SCpyMsgMsg(bcch->tb, RG_GET_MEM_REGION(rgCb[inst]),
1931 RG_GET_MEM_POOL(rgCb[inst]), &dlSf->bcch.tb);
1934 /*Store the received BCCH Data in the scheduled subframe*/
1935 dlSf->bcch.tb = cmnLcInfo->bcchInfo.pdu;
1936 #endif/*RGR_SI_SCH*/
1940 } /* end of rgHndlCmnChnl */
1943 * @brief Function for handling allocations for dedicated channels for a
1948 * Function : rgHndlSchdUe
1950 * This function shall be invoked whenever scheduler is done with the
1951 * allocations of dedicated channels for a subframe. Invoked by the function
1952 * RgSchMacSfAllocReq.
1954 * Processing steps :
1955 * 1. Loops through the list of UE's scheduled looking for the corresponding
1957 * 2. Finds the corresponding HARQ process.
1958 * 3. Invokes the DHM function to issue StatusIndications on RGU.
1961 * @param[in] RgCellCb *cell,
1962 * @param[in] CmLteTimingInfo timingInfo,
1963 * @param[in] RgInfUeInfo *ueInfo
1964 * @param[in/out] RgErrInfo *err
1970 PRIVATE S16 rgHndlSchdUe
1973 CmLteTimingInfo timingInfo,
1974 RgInfUeInfo *ueInfo,
1978 PRIVATE S16 rgHndlSchdUe(cell, timingInfo, ueInfo, err) /* laa_ut_fix */
1980 CmLteTimingInfo timingInfo;
1981 RgInfUeInfo *ueInfo;
1988 if(NULLP == ueInfo->allocInfo)
1993 rgDHMSndConsolidatedStaInd(cell, ueInfo, timingInfo, err);
1996 } /* end of rgHndlSchdUe */
2000 * @brief Function for handling Uplink allocations for Ue for a
2005 * Function : rgHndlUlUeInfo
2007 * @param[in] RgCellCb *cell,
2008 * @param[in] CmLteTimingInfo timingInfo,
2009 * @param[in] RgInfUlUeInfo *ueInfo
2015 PRIVATE S16 rgHndlUlUeInfo
2018 CmLteTimingInfo timingInfo,
2019 RgInfUlUeInfo *ueInfo
2022 PRIVATE S16 rgHndlUlUeInfo(cell, timingInfo, ueInfo)
2024 CmLteTimingInfo timingInfo;
2025 RgInfUlUeInfo *ueInfo;
2028 Inst inst = cell->macInst - RG_INST_START;
2033 TRC2(rgHndlUlUeInfo)
2035 ulSf = &cell->ulSf[(timingInfo.slot % RGSCH_NUM_SUB_FRAMES)];
2037 /* rg003.301-MOD- Corrected the purifier memory leak */
2038 if (ulSf->numUe != ueInfo->numUes)
2040 if (ulSf->ueUlAllocInfo)
2042 rgFreeSBuf(inst,(Data **)&(ulSf->ueUlAllocInfo),
2043 ulSf->numUe * sizeof(RgUeUlAlloc));
2046 #ifdef XEON_SPECIFIC_CHANGES
2047 CM_MEAS_TIME((cell->crntTime.slot % RGSCH_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MEAS_FREE);
2048 CM_ADD_INFO((cell->crntTime.slot % RGSCH_NUM_SUB_FRAMES), CM_DBG_MEAS_FREE, ulSf->numUe);
2050 ulSf->numUe = ueInfo->numUes;
2051 if((ulSf->ueUlAllocInfo == NULLP) && (ueInfo->numUes > 0))
2053 /* Allocate memory for ulAllocInfo */
2054 if((ret = rgAllocSBuf(inst,(Data**)&(cell->ulSf[(timingInfo.slot % RGSCH_NUM_SUB_FRAMES)].
2055 ueUlAllocInfo), ueInfo->numUes * sizeof(RgUeUlAlloc))) != ROK)
2060 #ifdef XEON_SPECIFIC_CHANGES
2061 CM_MEAS_TIME((cell->crntTime.slot % RGSCH_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MEAS_ALLOC);
2062 CM_ADD_INFO((cell->crntTime.slot % RGSCH_NUM_SUB_FRAMES), CM_DBG_MEAS_ALLOC, ueInfo->numUes);
2064 if (ulSf->ueUlAllocInfo != NULLP)
2066 for(idx = 0; idx < ueInfo->numUes; idx++)
2068 ulSf->ueUlAllocInfo[idx].rnti = ueInfo->ulAllocInfo[idx].rnti;
2069 ulSf->ueUlAllocInfo[idx].numPrb = ueInfo->ulAllocInfo[idx].numPrb;
2072 RGCPYTIMEINFO(timingInfo, ulSf->schdTime);
2074 } /* end of rgHndlUlUeInfo */
2077 * @brief Function for handling RaResp request received from scheduler to MAC
2081 * Function : rgTOMRlsSf
2083 * This function shall be invoked whenever scheduler is done with the
2084 * allocations of random access responses for a subframe.
2085 * This shall invoke RAM to create ueCbs for all the rapIds allocated and
2086 * shall invoke MUX to create RAR PDUs for raRntis allocated.
2089 * @param[in] Inst inst
2090 * @param[in] CmLteCellId cellId,
2091 * @param[in] CmLteTimingInfo timingInfo,
2092 * @param[in] RaRespInfo *rarInfo
2097 PUBLIC Void rgTOMRlsSf
2103 PUBLIC Void rgTOMRlsSf(dlSf)
2112 if(dlSf->txDone == FALSE)
2114 RLOG0(L_ERROR, "SUBFRAME Not pushed to the PHY");
2116 if (dlSf->bch.tb != NULLP)
2118 RG_FREE_MSG(dlSf->bch.tb);
2120 if (dlSf->bcch.tb != NULLP)
2122 RG_FREE_MSG(dlSf->bcch.tb);
2124 if (dlSf->pcch.tb != NULLP)
2126 RG_FREE_MSG(dlSf->pcch.tb);
2129 rgTOMEmtcRlsSf(dlSf);
2131 for(idx=0; idx < dlSf->numRaRsp; idx++)
2133 RG_FREE_MSG(dlSf->raRsp[idx].rar);
2136 /* ADD Changes for Downlink UE Timing Optimization */
2137 #ifdef LTEMAC_DLUE_TMGOPTMZ
2138 dlSf->remDatReqCnt = 0;
2139 /* Fix[ccpu00126310]: Tracks Data Requests from RLC for both loosely and tight coupled
2141 dlSf->statIndDone = FALSE;
2143 if (dlSf->tbs.count)
2148 RGDBGERRNEW(inst, (rgPBuf(inst),
2149 "Error Stale TBs in Subframes TBS list\n"));
2150 node = dlSf->tbs.first;
2153 hqP = (RgDlHqProcCb*)node->node;
2157 for(i=0;i< RG_MAX_TB_PER_UE;i++)
2159 if (hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sf == dlSf)
2161 cmLListDelFrm(&dlSf->tbs, &(hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sfLnk));
2162 hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sfLnk.node = NULLP;
2163 printf("\n rgTOMRlsSf:: hqP %p \n", (Void *)hqP);
2165 hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sf = NULLP;
2170 /*arjun: check if dlSf laaTb list has to be freed???*/
2171 cmLListInit(&dlSf->tbs);
2172 dlSf->txDone = FALSE;
2178 * @brief Function is called by the scheduler once it has completed the
2179 * allocation for the subframe.
2183 * Function : rgHndlFlowCntrl
2184 * This function should fill and send Flow control
2188 * @param[in] Pst *cell
2189 * @param[in] RgInfSfAlloc *sfInfo Carries all the allocation
2195 PUBLIC S16 rgHndlFlowCntrl
2198 RgInfSfAlloc *sfInfo
2201 PUBLIC S16 rgHndlFlowCntrl(cell, sfInfo)
2203 RgInfSfAlloc *sfInfo;
2206 RguFlowCntrlInd *flowCntrlInd;
2210 TRC3(rgHndlFlowCntrl);
2212 pst = &cell->rguDlSap->sapCfg.sapPst;
2213 /* flowCntrlInd is alloced in cell init time and will be re-used throughout */
2214 flowCntrlInd = cell->flowCntrlInd;
2215 flowCntrlInd->cellId = sfInfo->cellId;
2216 flowCntrlInd->numUes = sfInfo->flowCntrlInfo.numUes;
2218 for (ueIdx = 0; ueIdx < sfInfo->flowCntrlInfo.numUes; ueIdx++)
2220 flowCntrlInd->ueFlowCntrlInfo[ueIdx].ueId = sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].ueId;
2221 flowCntrlInd->ueFlowCntrlInfo[ueIdx].numLcs = sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].numLcs;
2223 for (lcIdx = 0; lcIdx < RGINF_MAX_NUM_DED_LC; lcIdx++)
2225 flowCntrlInd->ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].lcId =
2226 sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].lcId;
2227 flowCntrlInd->ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].pktAdmitCnt =
2228 sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].pktAdmitCnt;
2230 flowCntrlInd->ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].maxBo4FlowCtrl =
2231 sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].maxBo4FlowCtrl;
2234 RgUiRguFlowCntrlInd(pst, cell->rguDlSap->sapCfg.spId,flowCntrlInd); /* TODO: Rishi confirm if the suId and pst pointer is correct */
2238 * @brief Function is called by the scheduler once it has completed the
2239 * allocation for the subframe.
2243 * Function : RgSchMacSfAllocReq
2245 * This function shall be invoked whenever scheduler is done with the
2246 * allocations of for a subframe. The sfInfo carries all the allocation
2247 * details for the common channels, RA responses and dedicated channel
2250 * Processing steps :
2251 * 1. Reset the information present in the downlink subframe that is
2253 * 2. Handle common channel allocations
2254 * 3. Handle RA Response allocations
2255 * 4. Handle dedicated channel allocations.
2257 * @param[in] Pst *pst
2258 * @param[in] RgInfSfAlloc *sfInfo Carries all the allocation
2264 PUBLIC S16 RgSchMacSfAllocReq
2267 RgInfSfAlloc *sfInfo
2270 PUBLIC S16 RgSchMacSfAllocReq(pst, sfInfo)
2272 RgInfSfAlloc *sfInfo;
2278 VOLATILE U32 startTime=0;
2281 TRC2(RgSchMacSfAllocReq)
2283 RG_IS_INST_VALID(pst->dstInst);
2284 inst = pst->dstInst - RG_INST_START;
2286 SStartTask(&startTime, PID_MAC_SF_ALLOC_REQ);
2293 if((cell = rgCb[inst].cell) == NULLP)
2295 RLOG_ARG0(L_ERROR,DBG_CELLID,sfInfo->cellId, "No cellCb found with cell");
2299 dlSf = &cell->subFrms[(sfInfo->timingInfo.slot % RG_NUM_SUB_FRAMES)];
2301 rgTOMRlsSf(inst,dlSf);
2302 dlSf->schdTime = sfInfo->timingInfo;
2305 rgLaaInitTbInfoLst(cell);
2308 /* Fix : syed Ignore Failure Returns and continue processing.
2309 * Incomplete processing results in state sync loss between MAC-SCH. */
2311 if(TRUE == cell->emtcEnable)
2313 rgEmtcHndl(cell, sfInfo);
2316 rgHndlCmnChnl(cell, sfInfo->timingInfo, &sfInfo->cmnLcInfo, &err);
2318 rgHndlRaResp(cell, sfInfo->timingInfo, &sfInfo->rarInfo, &err);
2321 #ifdef XEON_SPECIFIC_CHANGES
2322 CM_MEAS_TIME((cell->crntTime.slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_B4_UE_SCHD);
2324 rgHndlSchdUe(cell, sfInfo->timingInfo, &sfInfo->ueInfo, &err);
2325 #ifdef XEON_SPECIFIC_CHANGES
2326 CM_MEAS_TIME((cell->crntTime.slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_UE_SCHD);
2328 rgLaaChkAndReqTbs(dlSf,cell, inst);
2331 rgHndlSchdUe(cell, sfInfo->timingInfo, &sfInfo->ueInfo, &err);
2335 if(rgHndlUlUeInfo(cell, sfInfo->ulUeInfo.timingInfo,
2336 &sfInfo->ulUeInfo) != ROK)
2341 #ifdef XEON_SPECIFIC_CHANGES
2342 CM_MEAS_TIME((cell->crntTime.slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_MEAS);
2344 /* Fix[ccpu00126310]: Tracks Data Requests from RLC for both loosely and tight coupled
2348 /* Added the handling for pushing down
2349 * TFU Data request in the retransmission only scenario.*/
2350 #ifdef LTEMAC_DLUE_TMGOPTMZ
2351 dlSf->statIndDone = TRUE;
2352 /* Fix [ccpu00126310]: Tracks Data Requests from RLC for both loosely and tight coupled
2354 if(!(dlSf->txDone) &&
2356 (TRUE == rgLaaChkAllRxTbs(dlSf)) &&
2358 (0 == dlSf->remDatReqCnt) && (dlSf->statIndDone) &&
2359 (RG_TIMEINFO_SAME(cell->crntTime, dlSf->schdTime)))
2361 /*This is the case of rettransmission, so no need
2362 * to wait for TTI Ind to push TFU Data Request. Send
2364 if (ROK != rgTOMUtlProcDlSf (dlSf, cell, &err))
2366 RLOG_ARG0(L_ERROR,DBG_CELLID,cell->cellId,"Unable to process downlink subframe for cell");
2367 err.errType = RGERR_ROM_DEDDATREQ;
2369 /* Mark this frame as sent */
2370 dlSf->txDone = TRUE;
2373 if (sfInfo->flowCntrlInfo.numUes > 0)
2375 rgHndlFlowCntrl(cell,sfInfo);
2378 SStopTask(startTime, PID_MAC_SF_ALLOC_REQ);
2380 } /* end of RgSchMacSfAllocReq */
2382 * @brief Handler for processing data indication recieved from PHY for UEs.
2386 * Function: rgTOMProcCrntiCEInDatInd
2388 * Handler for processing data indication recieved from PHY for UEs.
2390 * Invoked by: RgLiTfuDatInd of LIM
2393 * For each DataInfo recieved
2394 * - If received a CRNTI control element
2395 * - Check if a CCCH SDU is present, if it is return failure
2396 * - Check for the existence of UE, if its isnt present return failure.
2397 * - Delegate the remaining processing to rgTOMUtlProcMsg3 which
2398 * primarily informs the scheduler about the data received and
2399 * generates Data indications towards the higher layer.
2401 * @param RgMacPdu *pdu,
2402 * @param RgUeCb *prevUeCb,
2403 * @param RgCellCb *cellCb,
2404 * @param TfuDatInfo *datInfo,
2405 * @param RgInfCeInfo *ceInfo
2411 PRIVATE S16 rgTOMProcCrntiCEInDatInd
2416 TfuDatInfo *datInfo,
2417 RgInfCeInfo *ceInfo,
2421 PRIVATE S16 rgTOMProcCrntiCEInDatInd( pdu, prevUeCb, cellCb, datInfo, ceInfo, slot)
2425 TfuDatInfo *datInfo;
2426 RgInfCeInfo *ceInfo;
2430 RgUeCb *ueCb = NULLP;
2431 Inst inst = cellCb->macInst - RG_INST_START;
2439 TRC2(rgTOMProcCrntiCEInDatInd)
2445 ueCb = rgDBMGetUeCbFromRachLst (cellCb, datInfo->rnti);
2449 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2450 "RNTI:%d Received MSG3 with CRNTI,unable to find ueCb", ceInfo->ces.cRnti);
2454 prevUeCb = rgDBMGetUeCb (cellCb, ceInfo->ces.cRnti);
2455 if (prevUeCb == NULLP)
2457 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2458 "RNTI:%d Received MSG3 with CRNTI,unable to find ueCb", ceInfo->ces.cRnti);
2461 RLOG_ARG2(L_DEBUG,DBG_CELLID,cellCb->cellId,
2462 "CRNTI CE(%d) received through tmpCrnti(%d)",
2463 ceInfo->ces.cRnti, datInfo->rnti);
2464 rgDBMDelUeCbFromRachLst(cellCb, ueCb);
2465 rgRAMFreeUeCb(inst,ueCb);
2468 if ((rgTOMUtlProcMsg(cellCb, ueCb, pdu, FALSE,&spsToBeActvtd,&sduSize, slot, NULLP)) != ROK)
2470 if ((rgTOMUtlProcMsg (cellCb, ueCb, pdu, slot, NULLP)) != ROK)
2471 #endif /* LTEMAC_SPS */
2473 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2474 "RNTI:%d Processing for MSG3 failed",datInfo->rnti);
2480 * @brief Handler for processing data indication recieved from PHY for UEs.
2484 * Function: rgTOMProcCCCHSduInDatInd
2486 * Handler for processing data indication recieved from PHY for UEs.
2488 * Invoked by: RgLiTfuDatInd of LIM
2491 * For each DataInfo recieved
2492 * - If only CCCH SDU is present
2493 * - Invoke rgTOMUtlProcMsg3 for further processing.
2494 * - If its a non-Msg3 PDU i.e. received outside of a RA procedure
2495 * - Retrieve the UeCB
2496 * - Validate that the received PDU contains only configured Logical
2498 * - Invoke rgTOMUtlProcDatPdu for further processing. It informs the
2499 * scheduler with the information of the received Data and generates
2500 * DatIndications towards the higher layers.
2502 * @param TfuDatIndInfo *datInd
2503 * @param RgMacPdu *pdu,
2504 * @param RgUeCb *prevUeCb,
2505 * @param RgCellCb *cellCb,
2506 * @param TfuDatInfo *datInfo,
2507 * @param RgInfCeInfo *ceInfo
2513 PRIVATE S16 rgTOMProcCCCHSduInDatInd
2518 TfuDatInfo *datInfo,
2519 RgInfCeInfo *ceInfo,
2523 PRIVATE S16 rgTOMProcCCCHSduInDatInd( pdu, prevUeCb, cellCb, datInfo, ceInfo, slot)
2527 TfuDatInfo *datInfo;
2528 RgInfCeInfo *ceInfo;
2532 RgUeCb *ueCb = NULLP;
2533 Inst inst = cellCb->macInst - RG_INST_START;
2541 TRC2(rgTOMProcCCCHSduInDatInd)
2547 if (ceInfo->bitMask & RG_CRNTI_CE_PRSNT)
2549 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2550 "CRNTI:%d Received MSG3 with CCCH",ceInfo->ces.cRnti);
2554 ueCb = rgDBMGetUeCbFromRachLst (cellCb, datInfo->rnti);
2558 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2559 "RNTI:%d Processing for MSG3 failed", datInfo->rnti);
2562 /* Fix: syed Drop any duplicate Msg3(CCCH Sdu) */
2563 if (ueCb->dl.hqEnt.numHqProcs)
2565 /* HqE is already initialized by a previuos Msg3 */
2566 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"RNTI:%d Processing for MSG3 failed. Duplicate "
2567 "MSG3 received. Dropping", datInfo->rnti);
2571 if(rgDHMHqEntInit(inst,&ueCb->dl.hqEnt,
2572 cellCb->maxDlHqProcPerUe) != ROK)
2574 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"RNTI:%d Harq Initialization failed ",
2578 RLOG_ARG1(L_DEBUG,DBG_CELLID,cellCb->cellId,
2579 "CCCH SDU received through tmpCrnti(%d)",datInfo->rnti);
2581 if ((rgTOMUtlProcMsg(cellCb, ueCb, pdu, FALSE,&spsToBeActvtd,&sduSize, slot, NULLP)) != ROK)
2583 if ((rgTOMUtlProcMsg (cellCb, ueCb, pdu, slot, NULLP)) != ROK)
2584 #endif /* LTEMAC_SPS */
2586 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"RNTI:%d Processing for MSG3 failed",
2595 /** @brief This function captures the BSR value from Control Element
2596 * Info structure and updates the effective Buffer size into the
2597 * corresponding LCG ID.
2601 * Function: rgTOMUtlL2MStoreBufSz
2604 * - update/append the Data structure based on BSR type
2606 * @param [in] RgUeCb *ueCb
2607 * @param [in] RgInfCeInfo *ceInfo
2612 PRIVATE S16 rgTOMUtlL2MStoreBufSz
2618 PRIVATE S16 rgTOMUtlL2MStoreBufSz (ueCb, ceInfo)
2620 RgInfCeInfo *ceInfo;
2625 TRC2(rgTOMUtlL2MStoreBufSz);
2627 if(ceInfo->bitMask & RG_TRUNC_BSR_CE_PRSNT)
2629 lcgId = ((ceInfo->ces.bsr.truncBsr >> 6) & 0x03);
2630 bsr = ceInfo->ces.bsr.truncBsr & 0x3F;
2631 ueCb->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs = rgLwrBsrTbl[bsr];
2633 else if(ceInfo->bitMask & RG_SHORT_BSR_CE_PRSNT)
2635 lcgId = ((ceInfo->ces.bsr.shortBsr >> 6) & 0x03);
2636 bsr = ceInfo->ces.bsr.shortBsr & 0x3F;
2637 ueCb->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs = rgLwrBsrTbl[bsr];
2640 else if(ceInfo->bitMask & RG_LONG_BSR_CE_PRSNT)
2642 ueCb->ul.lcgArr[0].lcgBsInfo.outStndngBs = rgLwrBsrTbl[ceInfo->ces.bsr.longBsr.bs1];
2643 ueCb->ul.lcgArr[1].lcgBsInfo.outStndngBs = rgLwrBsrTbl[ceInfo->ces.bsr.longBsr.bs2];
2644 ueCb->ul.lcgArr[2].lcgBsInfo.outStndngBs = rgLwrBsrTbl[ceInfo->ces.bsr.longBsr.bs3];
2645 ueCb->ul.lcgArr[3].lcgBsInfo.outStndngBs = rgLwrBsrTbl[ceInfo->ces.bsr.longBsr.bs4];
2648 } /* end of rgTOMUtlL2MStoreBufSz*/
2650 /** @brief : Compiles list of LCs received in UL data for DTCH RBs
2654 * @param [in] RgCellCb *cellCb
2655 * @param [in] RgUeCb *ueCb
2656 * @param [in] CmLteRnti rnti
2657 * @param [in] RgMacPdu *pdu
2664 PRIVATE Void rgTOML2MCompileActiveLCs
2672 PRIVATE Void rgTOML2MCompileActiveLCs(cellCb, ueCb, pdu, ceInfo)
2676 RgInfCeInfo *ceInfo;
2683 TRC2(rgTOML2MCompileActiveLCs)
2685 node = pdu->sduLst.first;
2688 sdu = (RgMacSdu*)node->node;
2690 if ((ulLcCb = rgDBMGetUlDedLcCb(ueCb, sdu->lcId)), ulLcCb != NULLP)
2692 if (ulLcCb->lcgId != 0)
2694 ceInfo->bitMask |= RG_ACTIVE_LC_PRSNT;
2695 ceInfo->ulActLCs[ulLcCb->lcId - 1] = TRUE;
2706 /**********************************************************************
2709 **********************************************************************/