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) */
40 #include "envopt.h" /* environment options */
41 #include "envdep.h" /* environment dependent */
42 #include "envind.h" /* environment independent */
43 #include "gen.h" /* general layer */
44 #include "ssi.h" /* system services */
45 #include "cm5.h" /* common timers defines */
46 #include "cm_hash.h" /* common hash list defines */
47 #include "cm_llist.h" /* common linked list defines */
48 #include "cm_mblk.h" /* memory management */
49 #include "cm_tkns.h" /* common tokens */
50 #include "cm_lte.h" /* common tokens */
51 #include "rgu.h" /* RGU defines */
52 #include "tfu.h" /* RGU defines */
53 #include "lrg.h" /* layer management defines for LTE-MAC */
54 #include "crg.h" /* layer management defines for LTE-MAC */
55 #include "rg_sch_inf.h" /* layer management defines for LTE-MAC */
56 #include "rg.h" /* defines and macros for MAC */
57 #include "rg_env.h" /* defines and macros for MAC */
58 #include "rg_err.h" /* defines and macros for MAC */
61 /* header/extern include files (.x) */
62 #include "gen.x" /* general layer typedefs */
63 #include "ssi.x" /* system services typedefs */
64 #include "cm5.x" /* common timers */
65 #include "cm_hash.x" /* common hash list */
66 #include "cm_lib.x" /* common library */
67 #include "cm_llist.x" /* common linked list */
68 #include "cm_mblk.x" /* memory management */
69 #include "cm_tkns.x" /* common tokens */
70 #include "cm_lte.x" /* common tokens */
71 #include "rgu.x" /* RGU types */
72 #include "tfu.x" /* RGU types */
73 #include "lrg.x" /* layer management typedefs for MAC */
74 #include "crg.x" /* CRG interface typedefs */
75 #include "rg_sch_inf.x" /* SCH interface typedefs */
76 #include "rg_prg.x" /* PRG interface typedefs */
77 #include "rgm.x" /* layer management typedefs for MAC */
78 #include "rgm.h" /* layer management typedefs for MAC */
79 #include "du_app_mac_inf.h"
81 #include "rg.x" /* typedefs for MAC */
82 #include "lwr_mac_fsm.h"
83 #ifdef MAC_RLC_UL_RBUF
88 uint16_t handleDlTtiReq(SlotIndInfo currTimingInfo);
89 uint16_t handleUlTtiReq(SlotIndInfo currTimingInfo);
91 /* ADD Changes for Downlink UE Timing Optimization */
92 #ifndef LTEMAC_DLUE_TMGOPTMZ
93 PRIVATE S16 rgTOMUtlProcDlSf ARGS(( RgDlSf *dlSf, RgCellCb *cellCb,
96 PUBLIC S16 rgTOMUtlProcDlSf ARGS((RgDlSf *dlSf, RgCellCb *cellCb,
99 PRIVATE S16 rgTOMProcCrntiCEInDatInd ARGS((
108 PRIVATE S16 rgTOMProcCCCHSduInDatInd ARGS((
117 PUBLIC S16 rgHndlFlowCntrl
123 EXTERN S16 RgUiRguFlowCntrlInd(Pst* pst, SuId suId, RguFlowCntrlInd *flowCntrlInd);
125 EXTERN S16 rgEmtcHndl(RgCellCb *cell,RgInfSfAlloc *sfInfo);
126 EXTERN S16 rgTOMEmtcUtlFillDatReqPdus(TfuDatReqInfo *datInfo, RgDlSf *dlSf, RgCellCb *cell, RgErrInfo *err);
127 EXTERN Void rgTOMEmtcRlsSf(RgDlSf *dlSf);
130 PRIVATE Void rgTOML2MCompileActiveLCs ARGS
137 PRIVATE S16 rgTOMUtlL2MStoreBufSz ARGS
143 PRIVATE S16 rgTomUtlPrepareL2MUlThrpInfo ARGS
147 RgRguDedDatInd *dDatInd
151 /* The below table takes lower values of BSR Range for a BSR value
152 This is to ensure that outstanding can be decrease to zero upon reception of
153 TB, which is not guaranteed if higher Range values are used */
154 /* Note: taking value 10 for BSR index 1 */
155 #ifndef MAC_5GTF_UPDATE
156 PRIVATE U32 rgLwrBsrTbl[64] = {
157 0, 10, 10, 12, 14, 17, 19, 22, 26,
158 31, 36, 42, 49, 57, 67, 78, 91,
159 107, 125, 146, 171, 200, 234, 274, 321,
160 376, 440, 515, 603, 706, 826, 967, 1132,
161 1326, 1552, 1817, 2127, 2490, 2915, 3413, 3995,
162 4677, 5476, 6411, 7505, 8787, 10287, 12043, 14099,
163 16507, 19325, 22624, 26487, 31009, 36304, 42502, 49759,
164 58255, 68201, 79846, 93479, 109439, 128125, 150000
168 PRIVATE U32 rgLwrBsrTbl[64] = {
169 0,10,13,16,19,23,29,35,43,53,65,80,98,120,147,181,223,274,337,414,
170 509,625,769,945,1162,1429,1757,2161,2657,3267,4017,4940,6074,7469,
171 9185,11294,13888,17077,20999,25822,31752,39045,48012,59039,72598,
172 89272,109774,134986,165989,204111,250990,308634,379519,466683,
173 573866,705666,867737,1067031,1312097,1613447,1984009,2439678,
181 #define RG_TOM_INF_ALLOC(_pdu, _size, _dataPtr, _ret) {\
182 _ret = cmGetMem((Ptr)&_pdu->memCp, _size, (Ptr *)&_dataPtr); \
185 /* global variables */
186 PUBLIC U32 rgUlrate_tfu;
188 EXTERN U32 grgUlrate_tfu;
191 /** @brief This function fills the PDSCH data of a downlink subframe
195 * Function: rgTOMUtlFillDatReqPdus
198 * - Fill BCCH on DLSCH data using datInfo
199 * - Fill PCCH on DLSCH data using datInfo
200 * - Fill Dedicated data on DLSCH data using datInfo
201 * - Fill RA RSP data using datInfo
203 * @param [out] TfuDatReqInfo *datInfo
204 * @param [in] RgDlSf *dlSf
205 * @param [in] RgCellCb *cellCb
206 * @param [out] RgErrInfo *err
212 PRIVATE S16 rgTOMUtlFillDatReqPdus
214 TfuDatReqInfo *datInfo,
220 PRIVATE S16 rgTOMUtlFillDatReqPdus(datInfo, dlSf, cellCb, err)
221 TfuDatReqInfo *datInfo;
228 TfuDatReqPduInfo *datReq=NULLP;
229 /* Moving node declaration to limited scope for optimization */
232 Inst inst = cellCb->macInst - RG_INST_START;
234 TRC2(rgTOMUtlFillDatReqPdus)
236 /* first lets send the BCCH data down to PHY */
237 if (dlSf->bcch.tb != NULLP)
239 if ((ret = rgGetEventMem(inst,(Ptr *)&datReq, sizeof(TfuDatReqPduInfo),
240 &(datInfo->memCp))) != ROK)
242 err->errCause = RGERR_TOM_MEM_EXHAUST;
243 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,"Memory Exhaustion ");
246 #ifdef TFU_ALLOC_EVENT_NO_INIT
250 datReq->tbInfo[0].lchInfo[0].mBuf[0]=NULLP;
253 datReq->rnti = RG_SI_RNTI;
254 datReq->dciInfo = dlSf->bcch.pdcch.dci;
255 /* Note: SCpyMsgMsg is not done since free of unsent buffer
256 * has been taken care through cell delete by invoking rgTomRlsSf
258 datReq->nmbOfTBs = 1;
260 datReq->mBuf[0] = dlSf->bcch.tb;
262 SFndLenMsg((Buffer *)dlSf->bcch.tb, &(datReq->tbInfo[0].tbSize));
263 datReq->tbInfo[0].tbPres = TRUE;
264 datReq->tbInfo[0].lchInfo[0].mBuf[0] = dlSf->bcch.tb;
265 datReq->tbInfo[0].numLch = 1;
266 datReq->tbInfo[0].lchInfo[0].numPdu = 1;
268 #ifdef TFU_ALLOC_EVENT_NO_INIT
269 datReq->tbInfo[1].tbPres = FALSE;
270 datReq->tbInfo[1].lchInfo[0].mBuf[0] = NULLP;
273 cmLListAdd2Tail(&datInfo->pdus, &(datReq->lnk));
274 datReq->lnk.node = (PTR)datReq;
276 /* ccpu00132314-ADD- Adding txPower offset for the PDSCH transmission */
277 datReq->txPwrOffset = dlSf->bcch.txPwrOffset;
279 /* Setting the pointer to NULL post transmission */
280 dlSf->bcch.tb = NULLP;
283 if (dlSf->pcch.tb != NULLP)
285 if ((ret = rgGetEventMem(inst,(Ptr *)&datReq, sizeof(TfuDatReqPduInfo),
286 &(datInfo->memCp))) != ROK)
288 err->errCause = RGERR_TOM_MEM_EXHAUST;
289 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"Memory Exhaustion CRNTI:%d",datReq->rnti);
292 #ifdef TFU_ALLOC_EVENT_NO_INIT
297 datReq->rnti = RG_P_RNTI;
298 datReq->dciInfo = dlSf->pcch.pdcch.dci;
299 datReq->nmbOfTBs = 1;
301 datReq->mBuf[0] = dlSf->pcch.tb;
303 SFndLenMsg((Buffer *)dlSf->pcch.tb, &datReq->tbInfo[0].tbSize);
304 datReq->tbInfo[0].tbPres = TRUE;
305 datReq->tbInfo[0].lchInfo[0].mBuf[0] = dlSf->pcch.tb;
306 #ifdef TFU_ALLOC_EVENT_NO_INIT
307 datReq->tbInfo[1].tbPres = FALSE;
308 datReq->tbInfo[1].lchInfo[0].mBuf[0] = NULLP;
310 datReq->tbInfo[0].numLch = 1;
311 datReq->tbInfo[0].lchInfo[0].numPdu = 1;
313 cmLListAdd2Tail(&datInfo->pdus, &(datReq->lnk));
314 datReq->lnk.node = (PTR)datReq;
316 /* ccpu00132314-ADD- Adding txPower offset for the PDSCH transmission */
317 datReq->txPwrOffset = dlSf->pcch.txPwrOffset;
319 dlSf->pcch.tb = NULLP;
322 for(idx=0; idx < dlSf->numRaRsp; idx++)
324 if ((ret = rgGetEventMem(inst,(Ptr *)&datReq, sizeof(TfuDatReqPduInfo),
325 &(datInfo->memCp))) != ROK)
327 err->errCause = RGERR_TOM_MEM_EXHAUST;
328 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"Memory Exhaustion CRNTI:%d",
332 #ifdef TFU_ALLOC_EVENT_NO_INIT
337 datReq->rnti = dlSf->raRsp[idx].pdcch.rnti;
338 datReq->dciInfo = dlSf->raRsp[idx].pdcch.dci;
339 datReq->nmbOfTBs = 1;
341 datReq->mBuf[0] = dlSf->raRsp[idx].rar;
343 SFndLenMsg((Buffer *)dlSf->raRsp[idx].rar, &datReq->tbInfo[0].tbSize);
344 datReq->tbInfo[0].tbPres = TRUE;
345 datReq->tbInfo[0].lchInfo[0].mBuf[0] = dlSf->raRsp[idx].rar;
346 #ifdef TFU_ALLOC_EVENT_NO_INIT
347 datReq->tbInfo[1].lchInfo[0].mBuf[0] = NULLP;
348 datReq->tbInfo[1].tbPres = FALSE;
350 datReq->tbInfo[0].numLch = 1;
351 datReq->tbInfo[0].lchInfo[0].numPdu = 1;
352 // prc_trace_format_string(0x40,3,"UE Id=(%d) tbSz=(%d)",datReq->rnti, datReq->tbInfo[0].tbSize);
354 cmLListAdd2Tail(&datInfo->pdus, &(datReq->lnk));
355 datReq->lnk.node = (PTR)datReq;
357 /* ccpu00132314-ADD- Adding txPower offset for the PDSCH transmission */
358 datReq->txPwrOffset = dlSf->raRsp[idx].txPwrOffset;
360 dlSf->raRsp[idx].rar = NULLP;
363 /* Fill Dedicated UE data */
364 if (dlSf->tbs.count != 0)
367 while (dlSf->tbs.first)
369 node = dlSf->tbs.first;
370 hqCb = (RgDlHqProcCb*)node->node;
371 if ((ret = rgDHMSndDatReq (cellCb, dlSf, datInfo, hqCb, err)) != ROK)
373 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
374 "DHM unable to fill DATA request");
375 err->errType = RGERR_TOM_TTIIND;
382 } /* end of rgTOMUtlFillDatReqPdus*/
384 /** @brief This function does all the processing related to a single downlink
389 * Function: rgTOMUtlProcDlSf
392 * - collate control data for all UEs and send to PHY
393 * - collate data buffers for all UEs and send to PHY
395 * @param [in] RgDlSf *dlSf
396 * @param [in] RgCellCb *cellCb
397 * @param [out] RgErrInfo *err
400 /* ADD Changes for Downlink UE Timing Optimization */
401 #ifndef LTEMAC_DLUE_TMGOPTMZ
403 PRIVATE S16 rgTOMUtlProcDlSf
410 PRIVATE S16 rgTOMUtlProcDlSf (dlSf, cellCb, err)
417 PUBLIC S16 rgTOMUtlProcDlSf
424 PUBLIC S16 rgTOMUtlProcDlSf (dlSf, cellCb, err)
432 TfuDatReqInfo *datInfo;
433 Inst inst = cellCb->macInst - RG_INST_START;
435 TRC2(rgTOMUtlProcDlSf);
437 /* Fill Data Request Info from scheduler to PHY */
438 if ((ret = rgAllocEventMem(inst,(Ptr *)&datInfo,
439 sizeof(TfuDatReqInfo))) != ROK)
441 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,"Unable to Allocate TfuDatReqInfo");
446 cmLListInit(&datInfo->pdus);
448 RGADDTOCRNTTIME(dlSf->schdTime, datInfo->timingInfo, TFU_DELTA);
450 RGADDTOCRNTTIME(dlSf->schdTime, datInfo->timingInfo, TFU_DLDATA_DLDELTA);
452 datInfo->cellId = cellCb->cellId;
453 if((0 == (datInfo->timingInfo.sfn % 30)) && (0 == datInfo->timingInfo.slot))
455 //printf("5GTF_CHECK rgTOMUtlProcDlSf dat (%d : %d)\n", datInfo->timingInfo.sfn, datInfo->timingInfo.slot);
457 #ifdef TFU_ALLOC_EVENT_NO_INIT
458 datInfo->bchDat.pres = 0;
462 if (dlSf->bch.tb != NULLP)
464 datInfo->bchDat.pres = PRSNT_NODEF;
465 datInfo->bchDat.val = dlSf->bch.tb;
466 dlSf->bch.tb = NULLP;
469 /* Fill the DLSCH PDUs of BCCH, PCCH and Dedicated Channels */
470 if ((ret = rgTOMEmtcUtlFillDatReqPdus(datInfo, dlSf, cellCb, err)) != ROK)
472 RG_FREE_MEM(datInfo);
476 /* Fill the DLSCH PDUs of BCCH, PCCH and Dedicated Channels */
477 if ((ret = rgTOMUtlFillDatReqPdus(datInfo, dlSf, cellCb, err)) != ROK)
479 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,"Unable to send data for cell");
480 RG_FREE_MEM(datInfo);
483 if((datInfo->pdus.count) || (datInfo->bchDat.pres == TRUE))
485 /* sending the data to Phy */
486 if (rgLIMTfuDatReq(inst,datInfo) != ROK)
488 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,"Unable to send data info for cell");
493 /* Nothing to send: free the allocated datInfo */
494 RG_FREE_MEM(datInfo);
503 * @brief Handler for processing TTI indication recieved from
508 * Function: macProcessSlotInd
510 * Handler for processing slot indication recieved from PHY
513 * Invoked by: macProcessSlotInd
516 * - Get cell and update the cell's current time with the timing value given
518 * - Invoke the cmPrcTmr to process the timing queue.
519 * - Append the PHICH information to the downlink subframe that needs to go
520 * out to PHY in this subframe.
521 * - Invoke DHM to release the downlink subframe that occured earlier
522 * rgDHMRlsDlsfHqProc.
523 * - Invoke the TTI handler of scheduler.
524 * - Invoke the TTI handler of RAM module.
525 * - Get the downlink subframe that has to go out to PHY in this subframe
527 * - Invoke rgTOMUtlProcTA to perform and timing advance processing.
528 * - Invoke rgTOMUtlProcDlSf to do further processing on the downlink
530 * - Get the downlink subframe that would occur after RG_DL_DELTA and
531 * invoke rgTOMUtlProcDlSfStaInd to send status indications to the higher
533 * - Invoke GOM's TTI handler rgGOMTtiHndlr
534 * - Invoke COM's TTI handler rgCOMTtiHndlr
536 * @param[in] Inst inst
537 * @param[in] SlotIndInfo slotInd
542 #if (defined (MAC_FREE_RING_BUF) || defined (RLC_FREE_RING_BUF))
543 pthread_t gMacTId = 0;
545 PUBLIC S16 macProcessSlotInd
554 /* ADD Changes for Downlink UE Timing Optimization */
555 #ifdef LTEMAC_DLUE_TMGOPTMZ
557 CmLteTimingInfo prevTmInfo;
559 //SlotIndInfo *slotInd = &ttiInfo->cells[0];
561 TRC2(macProcessSlotInd);
563 #ifdef MAC_FREE_RING_BUF
564 gMacTId = pthread_self();
567 cellCb = rgCb[inst].cell;
570 err.errType = RGERR_TOM_TTIIND;
571 err.errCause = RGERR_TOM_INV_CELL_ID;
575 RGCPYTIMEINFO(slotInd, cellCb->crntTime);
577 rgMacGT = (slotInd.sfn * RG_NUM_SUB_FRAMES_5G) + slotInd.slot;
580 /*Included to track the number of 10240 cycles completed */
582 if((cellCb->crntTime.sfn == 0) && (cellCb->crntTime.slot==0))
584 cellCb->ttiCycle += 1;
589 /*Check if we have transmitted the previous DL SF, it could be the
590 case that we haven't received all the DATA from RLC as yet
591 and thus we would not have transmitted previous DL SF yet.*/
592 /* ADD Changes for Downlink UE Timing Optimization */
593 #ifdef LTEMAC_DLUE_TMGOPTMZ
594 RGSUBFRMCRNTTIME(slotInd, prevTmInfo, 1);
595 prevDlSf = &cellCb->subFrms[(prevTmInfo.slot % RG_NUM_SUB_FRAMES)];
596 if(FALSE == prevDlSf->txDone)
598 if (ROK != rgTOMUtlProcDlSf (prevDlSf, cellCb, &err))
600 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,"Unable to process "
601 "previous downlink subframe for cell");
602 err.errType = RGERR_TOM_TTIIND;
605 /* Mark this frame as sent */
606 prevDlSf->txDone = TRUE;
608 if(prevDlSf->remDatReqCnt)
610 /*We have not received 1 or more data requests from RLC, this is
611 error scenario. MAC & SCH need to discard the allocations for
612 which data request hasn't been received as yet. And MAC
613 needs to inform SCH about the list of UEs for which
614 allocation need to be discarded. */
615 prevDlSf->remDatReqCnt = 0;
621 /* Trigger for DL TTI REQ */
622 handleDlTtiReq(slotInd);
624 /* Trigger for UL TTI REQ */
625 handleUlTtiReq(slotInd);
627 dlSf = &cellCb->subFrms[(slotInd.slot % RG_NUM_SUB_FRAMES)];
629 if((dlSf->txDone == TRUE) ||
630 (!RG_TIMEINFO_SAME(slotInd,dlSf->schdTime)))
633 #ifndef LTEMAC_DLUE_TMGOPTMZ
634 TfuDatReqInfo *datInfo;
635 CmLteTimingInfo timingInfo;
636 #ifdef TFU_DL_DELTA_CHANGE
637 RGADDTOCRNTTIME(cellCb->crntTime, timingInfo, TFU_DLDATA_DLDELTA);
639 RGADDTOCRNTTIME(cellCb->crntTime, timingInfo, TFU_DELTA);
641 /* Fill Data Request from MAC for BCH */
642 if ((timingInfo.sfn % 4 == 0) && (timingInfo.slot == 0))
644 if (ROK != rgAllocEventMem(inst,(Ptr *)&datInfo,
645 sizeof(TfuDatReqInfo)))
647 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
648 "rgTOMUtlProcDlSf() Unable to Allocate TfuDatReqInfo for cell");
653 cmLListInit(&datInfo->pdus);
654 datInfo->cellId = cellCb->cellId;
655 datInfo->bchDat.pres = NOTPRSNT;
656 datInfo->timingInfo = timingInfo;
659 /* sending the dummy data req to Phy */
660 if (rgLIMTfuDatReq(inst,datInfo) != ROK)
662 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
663 "rgTOMUtlProcDlSf() Unable to send data info for cell");
669 /* Freeing as the part of CL Non RT Indication */
670 /* TDOD : Generalize for all SOCs */
671 #if !(defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD))
672 rgDHMFreeTbBufs(inst);
677 /*Return if there is still some data to be received
678 from RLC for this DL SF. */
679 /* ADD Changes for Downlink UE Timing Optimization */
680 #ifdef LTEMAC_DLUE_TMGOPTMZ
681 if(0 != dlSf->remDatReqCnt)
683 /* Freeing as the part of CL Non RT Indication */
684 /* TODO : Generalize for all SOCs and remove this flag */
685 #if !(defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD))
686 rgDHMFreeTbBufs(inst);
692 #ifdef XEON_SPECIFIC_CHANGES
693 CM_MEAS_TIME((slotInd.slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_DL_BR_PRC);
696 if (ROK != rgTOMUtlProcDlSf (dlSf, cellCb, &err))
698 //RLOG_ARG0(L_ERROR,DBG_CELLID,slotInd->cellId,
699 // "Unable to process downlink subframe for cell");
700 err.errType = RGERR_TOM_TTIIND;
702 #ifdef XEON_SPECIFIC_CHANGES
703 CM_MEAS_TIME((slotInd->slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_DL_AFTER_PRC);
706 /* Mark this frame as sent */
709 /* Freeing as the part of CL Non RT Indication */
710 /* TODO : Generalize for all SOCs and remove this flag */
711 #if !(defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD))
712 rgDHMFreeTbBufs(inst);
715 } /* macProcessSlotInd */
717 /** @brief This function allocates the RgMacPdu that will be populated by DEMUX
718 * with the SubHeaders list and the values of the Control elements.
722 * Function: rgTOMUtlAllocPduEvnt
725 * @param[in] Inst inst
726 * @param [out] RgMacPdu **pdu
733 PRIVATE S16 rgTOMUtlAllocPduEvnt
739 PRIVATE S16 rgTOMUtlAllocPduEvnt (inst,pdu)
746 RgUstaDgn dgn; /* Alarm diagnostics structure */
747 VOLATILE U32 startTime=0;
749 TRC2(rgTOMUtlAllocPduEvnt);
751 evntMem.region = rgCb[inst].rgInit.region;
752 evntMem.pool = rgCb[inst].rgInit.pool;
755 SStartTask(&startTime, PID_TOMUTL_CMALLCEVT);
757 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
758 MS_BUF_ADD_ALLOC_CALLER();
761 if (cmAllocEvnt (sizeof (RgMacPdu), RG_BLKSZ, &evntMem, (Ptr*)pdu) != ROK)
763 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
764 rgLMMStaInd(inst,LCM_CATEGORY_RESOURCE, LCM_EVENT_DMEM_ALLOC_FAIL,
765 LCM_CAUSE_MEM_ALLOC_FAIL, &dgn);
766 RLOG0(L_ERROR,"Allocation of DUX event failed");
771 SStopTask(startTime, PID_TOMUTL_CMALLCEVT);
776 /** @brief This function frees up the RgMacPdu structure that has been
777 * populated by demux.
781 * Function: rgTOMUtlFreePduEvnt
782 * - Function frees up the RgMacPdu structure, in case of error it shall
783 * free up the buffer's present in the different sdu.
786 * @param [in] Inst inst
787 * @param [in] RgMacPdu *pdu
788 * @param [in] Bool *error
792 PRIVATE Void rgTOMUtlFreePduEvnt
798 PRIVATE Void rgTOMUtlFreePduEvnt (pdu, error)
807 TRC2(rgTOMUtlFreePduEvnt);
808 /* Steps of freeing up the PDU.
809 * 1. loop through the subHdrLst and free up all the buffers.
810 * 2. free up the whole event
812 if ((error == TRUE) && (pdu->sduLst.count > 0))
814 node = pdu->sduLst.first;
817 sdu = (RgMacSdu*)node->node;
818 RG_FREE_MSG(sdu->mBuf);
824 } /* end of rgTOMUtlFreePduEvnt */
826 /** @brief This function allocates the RgMacPdu that will be populated by DEMUX
827 * with the SubHeaders list and the values of the Control elements.
831 * Function: rgTOMInfAllocPduEvnt
834 * @param [in] Inst inst
835 * @param [out] RgMacPdu **pdu
842 PRIVATE S16 rgTOMInfAllocPduEvnt
845 RgInfSfDatInd **sfInfo
848 PRIVATE S16 rgTOMInfAllocPduEvnt (inst,sfInfo)
850 RgInfSfDatInd **sfInfo;
855 RgUstaDgn dgn; /* Alarm diagnostics structure */
856 VOLATILE U32 startTime=0;
858 TRC2(rgTOMInfAllocPduEvnt);
860 evntMem.region = rgCb[inst].rgInit.region;
861 evntMem.pool = rgCb[inst].rgInit.pool;
864 SStartTask(&startTime, PID_TOMINF_CMALLCEVT);
866 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
867 MS_BUF_ADD_ALLOC_CALLER();
869 if (cmAllocEvnt (sizeof (RgInfSfDatInd), RG_BLKSZ, &evntMem, (Ptr*)sfInfo) != ROK)
871 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
872 rgLMMStaInd(inst,LCM_CATEGORY_RESOURCE, LCM_EVENT_DMEM_ALLOC_FAIL,
873 LCM_CAUSE_MEM_ALLOC_FAIL, &dgn);
874 RLOG0(L_ERROR,"Allocation failed");
879 SStopTask(startTime, PID_TOMINF_CMALLCEVT);
884 /** @brief This function frees up the RgMacPdu structure that has been
885 * populated by demux.
889 * Function: rgTOMInfFreePduEvnt
890 * - Function frees up the RgMacPdu structure, in case of error it shall
891 * free up the buffer's present in the different sdu.
894 * @param [in] RgMacPdu *pdu
895 * @param [in] Bool *error
899 PRIVATE Void rgTOMInfFreePduEvnt
901 RgInfSfDatInd *sfInfo
904 PRIVATE Void rgTOMInfFreePduEvnt (sfInfo)
905 RgInfSfDatInd *sfInfo;
908 TRC2(rgTOMInfFreePduEvnt);
912 } /* end of rgTOMUtlFreePduEvnt */
916 /** @brief This function performs the preparation of information needed to set
917 * L2M Scheduled UL Throughput Information for a particular UE.
921 * Function: rgTomUtlPrepareL2MUlThrpInfo
922 * This function performs the preparation of information needed to set
923 * L2M Scheduled UL Throughput Information for a particular UE.
927 * @param [in] RgCellCb *cellCb
928 * @param [in] RgUeCb *ueCb
929 * @param [out] RgRguDedDatInd *dDatInd
933 PRIVATE S16 rgTomUtlPrepareL2MUlThrpInfo
937 RgRguDedDatInd *dDatInd
940 PRIVATE S16 rgTomUtlPrepareL2MUlThrpInfo(cellCb,ueCb,dDatInd)
943 RgRguDedDatInd *dDatInd;
949 TRC2(rgTomUtlPrepareL2MUlThrpInfo);
951 dDatInd->burstInd = RGU_L2M_UL_BURST_END;
952 for(loop=0;loop<dDatInd->numLch;loop++)
954 lcId=dDatInd->lchData[loop].lcId;
957 lcgId = ueCb->ul.lcCb[lcId - 1].lcgId;
958 if(ueCb->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs > 0)
960 dDatInd->burstInd = RGU_L2M_UL_BURST_START;
971 /** @brief This function is called by rgTOMDatInd. This function invokes the
972 * scheduler with the information of the received Data and any Control Elements
973 * if present. Also it generates Data indications towards the higher layers.
980 * - Retrieves the RaCb with the rnti provided, if it doesnt exist
982 * - If UE exists then update the Schduler with any MAC CEs if present.
983 * - Invoke RAM module to do Msg3 related processing rgRAMProcMsg3
984 * - Loop through the SDU subheaders and invoke either a common data
985 * indication (rgUIMSndCmnDatInd) or dedicated data indication
986 * (rgUIMSndDedDatInd) towards the higher layers.
988 * @param [in] RgCellCb *cellCb
989 * @param [in] RgUeCb *ueCb
990 * @param [in] CmLteRnti rnti
991 * @param [in] RgMacPdu *pdu
992 * @param [out] U32 *lcgBytes
1003 PRIVATE S16 rgTOMUtlProcMsg
1009 Bool *spsToBeActvtd,
1015 PRIVATE S16 rgTOMUtlProcMsg(cellCb, ueCb, pdu, isSpsRnti,spsToBeActvtd,sduSize, slot, lcgBytes)
1020 Bool *spsToBeActvtd;
1025 #else /* LTEMAC_SPS */
1027 PRIVATE S16 rgTOMUtlProcMsg
1036 PRIVATE S16 rgTOMUtlProcMsg(cellCb, ueCb, pdu, slot, lcgBytes)
1045 Inst inst = cellCb->macInst - RG_INST_START;
1047 RgRguCmnDatInd *cDatInd;
1048 RgRguDedDatInd *dDatInd;
1055 // RgInfSpsRelInfo relInfo;
1062 U16 totalBytesRcvd = 0;
1063 U16 sduLen[RGU_MAX_LC] = {0};
1064 U8 qciVal[RGU_MAX_LC] = {0};
1071 /* Moved outside of LTE_L2_MEAS
1072 * scope as this pointer will now be used to
1073 * check for valid Logical Channel ID
1090 TRC2(rgTOMUtlProcMsg)
1096 if(pdu->sduLst.first)
1098 sdu = (RgMacSdu*)(pdu->sduLst.first->node);
1100 if ((sdu->lcId == RG_CCCH_LCID))
1102 /* code for common channel dat indications */
1103 if ((ret = rgAllocShrablSBuf (inst,(Data**)&cDatInd, sizeof(RgRguCmnDatInd))) != ROK)
1107 cDatInd->cellId = cellCb->cellId;
1108 cDatInd->rnti = ueCb->ueId;
1109 /* rg001.101: Corrected lcId value for common data indication */
1110 cDatInd->lcId = cellCb->ulCcchId;
1111 cDatInd->pdu = sdu->mBuf;
1112 SFndLenMsg (sdu->mBuf, &ccchSz);
1113 /* Fix : syed Contention resolution ID copy should consider only
1114 * 6 bytes of information from sdu->mBuf. Incase of CCCH sdu for reest
1115 * message/psuedo reest message, ccchSz can go beyond 6 and can corrupt
1116 * other fields of ueCb. */
1117 if (ccchSz >= RG_CRES_LEN)
1119 SCpyMsgFix (sdu->mBuf, (MsgLen)0, RG_CRES_LEN, ueCb->contResId.resId,
1122 #ifdef XEON_SPECIFIC_CHANGES
1123 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);
1126 rgUIMSndCmnDatInd(inst,cellCb->rguUlSap,cDatInd);
1128 } /* end of common channel processing */
1130 if ((ret = rgAllocShrablSBuf (inst,(Data**)&dDatInd, sizeof(RgRguDedDatInd))) != ROK)
1136 elem = SRngGetWIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
1141 dDatInd = (RgRguDedDatInd *)elem;
1142 cmMemset((U8 *)dDatInd, 0x00, sizeof(RgRguDedDatInd));
1144 dDatInd->cellId = cellCb->cellId;
1145 dDatInd->rnti = ueCb->ueId;
1146 dDatInd->numLch = 0;
1149 ulSf = &cellCb->ulSf[(slot % RG_NUM_SUB_FRAMES)];
1150 if(ulSf->ueUlAllocInfo != NULLP)
1152 for(idx1 = 0; idx1 < ulSf->numUe; idx1++)
1154 if(ulSf->ueUlAllocInfo[idx1].rnti == ueCb->ueId)
1156 numPrb = ulSf->ueUlAllocInfo[idx1].numPrb;
1162 node = pdu->sduLst.first;
1165 sdu = (RgMacSdu*)node->node;
1167 ulLcCb = rgDBMGetUlDedLcCb (ueCb, sdu->lcId);
1171 RLOG_ARG2(L_ERROR,DBG_CELLID,cellCb->cellId,"Unconfigured LCID:%d CRNTI:%d"
1172 ,sdu->lcId,ueCb->ueId);
1173 /* ccpu00128443: Fix for memory leak */
1174 /* Fix : syed Neccessary to set sdu->mBuf = NULLP */
1175 RG_FREE_MSG(sdu->mBuf);
1179 #ifdef RLC_STA_PROC_IN_MAC/* RLC Status PDU Processing */
1181 extern S16 kwProcDlStatusPdu(Pst *udxPst,SuId suId,
1182 CmLteCellId cellId,CmLteRnti rnti,CmLteLcId lcId,Buffer *rlcSdu);
1184 if(ROK == kwProcDlStatusPdu(&(cellCb->rguDlSap->sapCfg.sapPst),
1185 cellCb->rguDlSap->sapCfg.suId,
1186 cellCb->cellId,ueCb->ueId,sdu->lcId,sdu->mBuf))
1188 RG_FREE_MSG(sdu->mBuf);
1195 /* ccpu00116477- Fixed the rgUIMSndDedDatInd condition when we receive 11 sdus in the
1196 * list we are losing 11th sdu and sending the first 10 sdus again which
1197 * is causing the duplicate packets and eNB crashing due to access
1198 * of the freed memory */
1199 if (dDatInd->numLch >= RGU_MAX_LC)
1201 if ((ret = rgUIMSndDedDatInd(inst,ueCb->rguUlSap,dDatInd)) != ROK)
1203 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
1204 "Failed to send datIndication to RGU CRNTI:%d",ueCb->ueId);
1208 if ((ret = rgAllocShrablSBuf (inst,(Data**)&dDatInd, sizeof(RgRguDedDatInd))) != ROK)
1213 elem = SRngGetWIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
1218 dDatInd = (RgRguDedDatInd *)elem;
1219 cmMemset((U8 *)dDatInd, 0x00, sizeof(RgRguDedDatInd));
1221 dDatInd->cellId = cellCb->cellId;
1222 dDatInd->rnti = ueCb->ueId;
1223 dDatInd->numLch = 0;
1225 dDatInd->lchData[dDatInd->numLch].lcId = sdu->lcId;
1226 dDatInd->lchData[dDatInd->numLch].pdu.mBuf[dDatInd->lchData[dDatInd->numLch].pdu.numPdu] = sdu->mBuf;
1227 dDatInd->lchData[dDatInd->numLch].pdu.numPdu++;
1228 lcgId = ulLcCb->lcgId;
1229 SFndLenMsg(sdu->mBuf, &bufSz);
1233 ueCb->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs -= bufSz;
1236 //if ((lcgBytes != NULLP) && (ueCb->ul.lcgArr[lcgId].isGbr == TRUE))
1237 if (lcgBytes != NULLP)
1239 lcgBytes[lcgId] += bufSz;
1244 /* Check if data has come on SPS LC */
1245 /* KWORK_FIX: Modified the index from lcId to lcId-1 for handling lcId 10 properly */
1246 if (ueCb->ul.spsLcId[sdu->lcId-1] == TRUE)
1248 ueCb->ul.spsDatRcvd++;
1253 /* Data rcvd on CRNTI*/
1254 /* Retrieve the LCG ID of the LCID*/
1255 /* SPS LCG has data whose size > SID Size */
1256 /* Activate SPS if data recvd on SPS LCID and size > SID Packet Size */
1257 if((ueCb->ul.spsLcId[sdu->lcId-1] == TRUE) &&
1258 (sdu->len > RG_SPS_SID_PACKET_SIZE))
1260 *spsToBeActvtd = TRUE;
1261 *sduSize = sdu->len;
1268 if(cellCb->qciArray[ulLcCb->qci].mask == TRUE)
1270 sduLen[ulLcCb->qci] = sdu->len;
1271 totalBytesRcvd += sdu->len;
1272 qciVal[ulLcCb->qci] = ulLcCb->qci;
1276 } /* end of while for SubHeaders */
1278 for(idx2 = 0; idx2 < RGU_MAX_LC; idx2++)
1280 if((cellCb->qciArray[qciVal[idx2]].mask == TRUE) &&
1283 cellCb->qciArray[qciVal[idx2]].prbCount +=
1284 ((numPrb * sduLen[idx2]) / totalBytesRcvd);
1288 if(totalBytesRcvd > 0 && qciVal[idx2] > 0)
1290 RG_UPD_GBR_PRB(cellCb, qciVal[idx2], ((numPrb * sduLen[idx2])/totalBytesRcvd));
1295 /*Added for explicit release - start*/
1298 if(isSpsRnti && dDatInd && dDatInd->numLch)
1300 if(ueCb->ul.spsDatRcvd != 0)
1302 ueCb->ul.explRelCntr = 0;
1303 ueCb->ul.spsDatRcvd = 0;
1307 ueCb->ul.explRelCntr++;
1308 if (ueCb->ul.explRelCntr == ueCb->ul.explRelCnt)
1310 ueCb->ul.explRelCntr = 0;
1311 /* Indicate scheduler for explicit release */
1312 cmMemset((U8*)&schPst1, (U8)0, sizeof(Pst));
1313 rgGetPstToInst(&schPst1,inst, cellCb->schInstMap.schInst);
1314 //TODO: commented for compilation without SCH
1316 relInfo.cellSapId = cellCb->schInstMap.cellSapId;
1317 relInfo.cRnti = ueCb->ueId;
1318 relInfo.isExplRel = TRUE;
1319 /* Release indicator is called now through the matrix in the function below */
1320 //TODO: commented for compilation without SCH RgMacSchSpsRel( &schPst1, &relInfo );
1322 ueCb->ul.implRelCntr = 0;
1329 if(ueCb->ul.spsDatRcvd != 0)
1331 //ueCb->ul.implRelCntr = 0;
1332 ueCb->ul.explRelCntr = 0;
1333 ueCb->ul.spsDatRcvd = 0;
1337 /*Added for explicit release - end */
1339 if((dDatInd) && (dDatInd->numLch))
1342 rgTomUtlPrepareL2MUlThrpInfo(cellCb, ueCb,dDatInd);
1344 RG_CALC_TTI_CNT(cellCb, dDatInd->ttiCnt);
1346 if ((ret = rgUIMSndDedDatInd(inst,ueCb->rguUlSap,dDatInd)) != ROK)
1348 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
1349 "Failed to send datIndication to RGU CRNTI:%d",ueCb->ueId);
1354 else if((dDatInd) && (0 == dDatInd->numLch))
1356 /* Free the memory allocated for dDatInd if we
1357 * have no valid LCH PDU to send to RLC.*/
1358 rgFreeSharableSBuf(inst,(Data **)&dDatInd,sizeof(RgRguDedDatInd));
1364 /** @brief This function frees up the RgMacPdu structure that has been
1365 * populated by demux.
1369 * Function: rgTOMUtlInsSchInfo
1370 * - Function frees up the RgMacPdu structure, in case of error it shall
1371 * free up the buffer's present in the different sdu.
1374 * @param [in] RgMacPdu *pdu
1375 * @param [in] Bool *error
1380 PRIVATE S16 rgTOMUtlInsSchInfo
1383 RgInfSfDatInd *sfInfo,
1384 RgInfCeInfo *ceInfo,
1391 PRIVATE S16 rgTOMUtlInsSchInfo (pdu, sfInfo, ceInfo, rnti,spsToBeActvtd,sduSize, lcgBytes)
1393 RgInfSfDatInd *sfInfo;
1394 RgInfCeInfo *ceInfo;
1403 PRIVATE S16 rgTOMUtlInsSchInfo
1406 RgInfSfDatInd *sfInfo,
1407 RgInfCeInfo *ceInfo,
1412 PRIVATE S16 rgTOMUtlInsSchInfo (pdu, sfInfo, ceInfo, rnti, lcgBytes)
1414 RgInfSfDatInd *sfInfo;
1415 RgInfCeInfo *ceInfo;
1422 RgInfUeDatInd *ueInfo;
1426 TRC2(rgTOMUtlInsSchInfo);
1428 RG_TOM_INF_ALLOC(sfInfo, sizeof(RgInfUeDatInd), ueInfo, ret);
1435 ueInfo->rnti = rnti;
1437 ueInfo->ceInfo = *ceInfo;
1438 ueInfo->ueLstEnt.node = (PTR)ueInfo;
1439 for (lcgId = 1, idx = 0; lcgId < RGINF_MAX_LCG_PER_UE; lcgId++)
1441 if (lcgBytes[lcgId] != 0)
1443 /* Only GBR bytes */
1444 ueInfo->lcgInfo[idx].lcgId = lcgId;
1445 ueInfo->lcgInfo[idx++].bytesRcvd = lcgBytes[lcgId];
1446 lcgBytes[lcgId] = 0;
1449 cmLListAdd2Tail(&sfInfo->ueLst, &ueInfo->ueLstEnt);
1451 } /* end of rgTOMUtlInsSchInfo */
1455 * @brief Handler for processing data indication recieved from PHY for UEs.
1459 * Function: rgTOMDatInd
1461 * Handler for processing data indication recieved from PHY for UEs.
1463 * Invoked by: RgLiTfuDatInd of LIM
1466 * For each DataInfo recieved
1467 * - Validate the information received and retrieve cellCb
1468 * Validate cellId, rnti
1469 * - Call De-Mux module to decode the data rgDUXDemuxData
1470 * - If received a CRNTI control element
1471 * - Check if a CCCH SDU is present, if it is return failure
1472 * - Check for the existence of UE, if its isnt present return failure.
1473 * - Delegate the remaining processing to rgTOMUtlProcMsg3 which
1474 * primarily informs the scheduler about the data received and
1475 * generates Data indications towards the higher layer.
1476 * - If only CCCH SDU is present
1477 * - Invoke rgTOMUtlProcMsg3 for further processing.
1478 * - If its a non-Msg3 PDU i.e. received outside of a RA procedure
1479 * - Retrieve the UeCB
1480 * - Validate that the received PDU contains only configured Logical
1482 * - Invoke rgTOMUtlProcDatPdu for further processing. It informs the
1483 * scheduler with the information of the received Data and generates
1484 * DatIndications towards the higher layers.
1486 * @param [in] Inst inst
1487 * @param[in] TfuDatIndInfo *datInd
1493 PUBLIC S16 rgTOMDatInd
1496 TfuDatIndInfo *datInd
1499 PUBLIC S16 rgTOMDatInd(inst,datInd)
1501 TfuDatIndInfo *datInd;
1507 RgUeCb *prevUeCb = NULLP;
1510 RgInfSfDatInd *sfInfo;
1514 TfuDatInfo *datInfo;
1518 Bool isSpsRnti=FALSE;
1520 // RgInfSpsRelInfo relInfo;
1521 Bool spsToBeActvtd = FALSE;
1524 U32 lcgBytes[RGINF_MAX_LCG_PER_UE];
1528 #ifdef STUB_TTI_HANDLING_5GTF
1529 node = datInd->datIndLst.first;
1530 for (;node; node=node->next)
1532 datInfo = (TfuDatInfo*)node->node;
1535 SFndLenMsg(datInfo->mBuf, &len);
1536 rgUlrate_tfu += len;
1537 if (rgUlrate_tfu > 100000)
1539 printf("Sowmya:rgTOMDatInd datInfo->mBuf len =%d rgUlrate_tfu=%d",len,rgUlrate_tfu);
1547 cmMemset((U8 *)&lcgBytes, 0, sizeof(lcgBytes));
1549 tfuSap = &(rgCb[inst].tfuSap);
1551 cellCb = rgCb[inst].cell;
1552 if((cellCb == NULLP) ||
1553 (cellCb->cellId != datInd->cellId))
1556 RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"Unable to get the cellCb for cell");
1559 /* Avoiding memset as all the fields are getting initialized further */
1561 if (rgTOMInfAllocPduEvnt (inst,&sfInfo) != ROK)
1563 err.errType = RGERR_TOM_DATIND;
1564 RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"Unable to Allocate PDU for DUX cell");
1565 node = datInd->datIndLst.first;
1568 cmLListInit(&sfInfo->ueLst);
1569 sfInfo->cellId = datInd->cellId;
1570 sfInfo->timingInfo = datInd->timingInfo;
1571 slot = datInd->timingInfo.slot;
1573 node = datInd->datIndLst.first;
1574 for (;node; node=node->next)
1576 datInfo = (TfuDatInfo*)node->node;
1578 //extern U32 ulrate_tfu;
1580 SFndLenMsg(datInfo->mBuf, &len);
1581 #ifdef STUB_TTI_HANDLING_5GTF
1582 // printf("Sowmya:rgTOMDatInd datInfo->mBuf len =%d",len);
1584 rgUlrate_tfu += len;
1586 grgUlrate_tfu += len;
1589 #ifdef STUB_TTI_HANDLING_5GTF
1590 rgLIMUtlFreeDatIndEvnt(datInd,TRUE);
1592 /* We shall call De-Mux to process the received buffer. We shall try and find
1593 * out the RaCb based on the following -
1594 * 1. If the incoming PDU contained a CCCH SDU i.e. this is message 3.
1595 * 2. If the incoming PDU contained a CRNTI control element, i.e. we should
1596 * have a ueCb also for this
1598 /* Lets allocate the event that needs to be passed to DUX */
1599 if (rgTOMUtlAllocPduEvnt (inst,&pdu) != ROK)
1601 err.errType = RGERR_TOM_DATIND;
1602 RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"Unable to Allocate PDU for DUX cell");
1603 rgTOMInfFreePduEvnt (sfInfo);
1607 if ((ret = rgDUXDemuxData (inst,pdu, &ceInfo,
1608 &datInfo->mBuf, &err)) != ROK)
1611 /* Fix: sriky memory corruption precautions */
1612 rgTOMUtlFreePduEvnt (pdu, TRUE);
1613 err.errType = RGERR_TOM_DATIND;
1614 RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"DUX processing failed");
1615 tfuSap->sapSts.numPduDrop++;
1618 /* It could be that a non-msg3 pdu contains a CRNTI Control element. We
1619 * should check for CRNTI CE and if it exists the UECb must exist, also an
1620 * if the CRNTI in the CE and the one with which the message came in are
1621 * different we shall look for an raCb as well.
1624 if (ceInfo.bitMask & RG_CCCH_SDU_PRSNT)
1626 ret = rgTOMProcCCCHSduInDatInd(pdu, prevUeCb, \
1627 cellCb, datInfo, &ceInfo, slot);
1630 rgTOMUtlFreePduEvnt (pdu, TRUE);
1631 err.errType = RGERR_TOM_DATIND;
1632 tfuSap->sapSts.numPduDrop++;
1635 } /* end of Msg3 processing */
1637 else if (ceInfo.bitMask & RG_CRNTI_CE_PRSNT)
1639 ret = rgTOMProcCrntiCEInDatInd(pdu, prevUeCb, \
1640 cellCb, datInfo, &ceInfo, slot);
1643 rgTOMUtlFreePduEvnt (pdu, TRUE);
1644 err.errType = RGERR_TOM_DATIND;
1645 tfuSap->sapSts.numPduDrop++;
1649 } /* end of CRNTI based message */
1652 ueCb = rgDBMGetUeCb (cellCb, datInfo->rnti);
1656 /* Try getting the UE using SPS-RNTI. */
1657 ueCb = rgDBMGetSpsUeCb (cellCb, datInfo->rnti);
1661 /* Increment implrelCntr for an empty transmission */
1662 if (pdu->sduLst.count == 0)
1664 ueCb->ul.implRelCntr++;
1665 if (ueCb->ul.implRelCntr == ueCb->ul.implRelCnt)
1667 /* Indicate scheduler for implicit release */
1668 cmMemset((U8*)&schPst1, (U8)0, sizeof(Pst));
1669 rgGetPstToInst(&schPst1,inst, cellCb->schInstMap.schInst);
1671 ueCb->ul.implRelCntr = 0;
1672 ueCb->ul.explRelCntr = 0;
1674 relInfo.cellSapId = cellCb->schInstMap.cellSapId;
1675 relInfo.cRnti = ueCb->ueId;
1676 relInfo.isExplRel= FALSE;
1677 //TODO: commented for compilation without SCH RgMacSchSpsRel(&schPst1, &relInfo);
1683 /* Reset the implrelCntr */
1684 ueCb->ul.implRelCntr = 0;
1690 /* Perform failure if ueCb is still NULLP */
1691 rgTOMUtlFreePduEvnt (pdu, TRUE);
1692 err.errType = RGERR_TOM_DATIND;
1693 RLOG_ARG1(L_ERROR,DBG_CELLID,datInd->cellId,"RNTI:%d Unable to get the UE CB",
1695 tfuSap->sapSts.numPduDrop++;
1700 rgTOMUtlL2MStoreBufSz(ueCb, &ceInfo);
1701 rgTOML2MCompileActiveLCs (cellCb, ueCb, pdu, &ceInfo);
1704 if ((ret = rgTOMUtlProcMsg(cellCb, ueCb, pdu, isSpsRnti,&spsToBeActvtd,&sduSize, slot, (U32 *)&lcgBytes)) != ROK)
1706 if ((ret = rgTOMUtlProcMsg (cellCb, ueCb, pdu, slot, (U32 *)&lcgBytes)) != ROK)
1707 #endif /* LTEMAC_SPS */
1709 rgTOMUtlFreePduEvnt (pdu, TRUE);
1710 err.errType = RGERR_TOM_DATIND;
1711 RLOG_ARG1(L_ERROR,DBG_CELLID,datInd->cellId,
1712 "Unable to handle Data Indication CRNTI:%d",ueCb->ueId);
1713 tfuSap->sapSts.numPduDrop++;
1720 if(rgTOMUtlInsSchInfo(pdu, sfInfo, &ceInfo, datInfo->rnti,spsToBeActvtd,sduSize, (U32 *)&lcgBytes) != ROK)
1722 if(rgTOMUtlInsSchInfo(pdu, sfInfo, &ceInfo, datInfo->rnti, (U32 *)&lcgBytes) != ROK)
1726 rgTOMInfFreePduEvnt (sfInfo);
1727 rgTOMUtlFreePduEvnt (pdu, FALSE);
1730 /* free up the PDU memory */
1731 rgTOMUtlFreePduEvnt (pdu, FALSE);
1733 /* Free the allocated memory for ueUlAllocInfo here */
1735 if(cellCb->ulSf[(slot % RG_NUM_SUB_FRAMES)].ueUlAllocInfo != NULLP)
1737 /*ccpu00117052 - MOD - Passing double for proper NULLP
1739 rgFreeSBuf(inst,(Data **)&(cellCb->ulSf[(slot % RG_NUM_SUB_FRAMES)].ueUlAllocInfo),
1740 ((cellCb->ulSf[(slot % RG_NUM_SUB_FRAMES)].numUe) * sizeof(RgUeUlAlloc)));
1744 /* Update PRB used for all GBR QCIs to scheduler */
1745 cmMemcpy((U8*) &sfInfo->qcisUlPrbCnt[0],
1746 (U8*) &cellCb->qcisUlPrbCnt[0],
1747 (RGM_MAX_QCI_REPORTS * sizeof(U32)));
1748 /* clear the cellCb ul prb value */
1749 cmMemset((U8*)&cellCb->qcisUlPrbCnt[0], 0,
1750 (RGM_MAX_QCI_REPORTS * sizeof(U32)));
1754 rgGetPstToInst(&schPst, inst,cellCb->schInstMap.schInst);
1755 sfInfo->cellSapId = cellCb->schInstMap.cellSapId;
1756 //TODO: commented for compilation without SCH RgMacSchSfRecp(&schPst, sfInfo);
1761 * @brief Function handles allocation for common channels i.e. BCCH-BCH,
1762 * BCCH-DLSCH, PCCH-DLSCH.
1766 * Function : rgHndlCmnChnl
1768 * This function is invoked from RgSchMacSfAllocReq. This function handles
1769 * allocations made for common channels like BCCH and PCCH.
1772 * 1. If BCCH on BCH has been scheduled, send StatusIndication on RGU.
1773 * 2. If PCCH is scheduled, send StatusIndication on RGU.
1774 * 3. If BCCH on DLSCH has been scheduled and sndStatInd is TRUE, send
1775 * StatusIndication on RGU, else copy the bcch buffer onto the downlink
1779 * @param[in] RgCellCb *cell,
1780 * @param[in] CmLteTimingInfo timingInfo,
1781 * @param[in] RgInfCmnLcInfo *cmnLcInfo,
1782 * @param[in/out] RgErrInfo *err,
1788 PRIVATE S16 rgHndlCmnChnl
1791 CmLteTimingInfo timingInfo,
1792 RgInfCmnLcInfo *cmnLcInfo,
1796 PRIVATE S16 rgHndlCmnChnl(cell, timingInfo, cmnLcInfo, err)
1798 CmLteTimingInfo timingInfo;
1799 RgInfCmnLcInfo *cmnLcInfo;
1803 #if (ERRCLASS & ERRCLS_DEBUG)
1807 RgBcchDlschLcCb *bcch;
1808 #if (ERRCLASS & ERRCLS_DEBUG)
1811 #endif/*RGR_SI_SCH*/
1812 RguCStaIndInfo *staInd;
1814 Inst inst = cell->macInst - RG_INST_START;
1818 dlSf = &cell->subFrms[(timingInfo.slot % RG_NUM_SUB_FRAMES)];
1820 if(cmnLcInfo->bitMask & RGINF_BCH_INFO)
1823 #if (ERRCLASS & ERRCLS_DEBUG)
1824 if(NULLP == (bch = rgDBMGetBcchOnBch(cell)))
1828 if(cmnLcInfo->bchInfo.lcId != bch->lcId)
1834 if (rgAllocShrablSBuf (inst,(Data**)&staInd, sizeof(RguCStaIndInfo)) != ROK)
1836 err->errCause = RGERR_TOM_MEM_EXHAUST;
1839 staInd->cellId = cell->cellId;
1840 staInd->rnti = RG_INVALID_RNTI;
1841 staInd->lcId = cmnLcInfo->bchInfo.lcId;
1842 staInd->transId = (timingInfo.sfn << 8) | (timingInfo.slot);
1843 /* ADD Changes for Downlink UE Timing Optimization */
1844 #ifdef LTEMAC_DLUE_TMGOPTMZ
1845 dlSf->remDatReqCnt++;
1847 if (rgUIMSndCmnStaInd (inst,cell->rguDlSap,staInd) != ROK)
1852 /*Store the received BCH Data in the scheduled subframe*/
1853 dlSf->bch.tb = cmnLcInfo->bchInfo.pdu;
1854 #endif/*RGR_SI_SCH*/
1857 if(cmnLcInfo->bitMask & RGINF_PCCH_INFO)
1859 #if (ERRCLASS & ERRCLS_DEBUG)
1860 if(NULLP == (pcch = rgDBMGetPcch(cell)))
1864 if(cmnLcInfo->pcchInfo.lcId != pcch->lcId)
1870 dlSf->pcch.pdcch.rnti =
1871 cmnLcInfo->pcchInfo.rnti;
1872 dlSf->pcch.pdcch.dci =
1873 cmnLcInfo->pcchInfo.dciInfo;
1875 /* ccpu00132314-ADD-Fill the tx Pwr offset from scheduler */
1876 dlSf->pcch.txPwrOffset = cmnLcInfo->pcchInfo.txPwrOffset;
1878 if (rgAllocShrablSBuf (inst,(Data**)&staInd, sizeof(RguCStaIndInfo)) != ROK)
1880 err->errCause = RGERR_TOM_MEM_EXHAUST;
1883 staInd->cellId = cell->cellId;
1884 staInd->rnti = RG_INVALID_RNTI;
1885 staInd->lcId = cmnLcInfo->pcchInfo.lcId;
1886 staInd->transId = (timingInfo.sfn << 8) | (timingInfo.slot);
1887 /* ADD Changes for Downlink UE Timing Optimization */
1888 #ifdef LTEMAC_DLUE_TMGOPTMZ
1889 dlSf->remDatReqCnt++;
1891 /* for consolidated CmnStaInd calling below function from function
1892 * rgHndlSchedUe once CmnStaInd prepared for all UEs
1894 if (rgUIMSndCmnStaInd (inst,cell->rguDlSap,staInd) != ROK)
1900 if(cmnLcInfo->bitMask & RGINF_BCCH_INFO)
1902 dlSf->bcch.pdcch.rnti =
1903 cmnLcInfo->bcchInfo.rnti;
1904 dlSf->bcch.pdcch.dci =
1905 cmnLcInfo->bcchInfo.dciInfo;
1907 /* ccpu00132314-ADD-Fill the tx Pwr offset from scheduler */
1908 dlSf->bcch.txPwrOffset = cmnLcInfo->bcchInfo.txPwrOffset;
1912 (bcch=rgDBMGetBcchOnDlsch(cell,cmnLcInfo->bcchInfo.lcId)))
1916 if(TRUE == cmnLcInfo->bcchInfo.sndStatInd)
1918 RG_FREE_MSG(bcch->tb);
1919 if (rgAllocShrablSBuf (inst,(Data**)&staInd,
1920 sizeof(RguCStaIndInfo)) != ROK)
1922 err->errCause = RGERR_TOM_MEM_EXHAUST;
1925 staInd->cellId = cell->cellId;
1926 staInd->rnti = RG_INVALID_RNTI;
1927 staInd->lcId = cmnLcInfo->bcchInfo.lcId;
1928 staInd->transId = (timingInfo.sfn << 8) | (timingInfo.slot);
1929 /* ADD Changes for Downlink UE Timing Optimization */
1930 #ifdef LTEMAC_DLUE_TMGOPTMZ
1931 dlSf->remDatReqCnt++;
1933 if (rgUIMSndCmnStaInd (inst,cell->rguDlSap,staInd) != ROK)
1940 SCpyMsgMsg(bcch->tb, RG_GET_MEM_REGION(rgCb[inst]),
1941 RG_GET_MEM_POOL(rgCb[inst]), &dlSf->bcch.tb);
1944 /*Store the received BCCH Data in the scheduled subframe*/
1945 dlSf->bcch.tb = cmnLcInfo->bcchInfo.pdu;
1946 #endif/*RGR_SI_SCH*/
1950 } /* end of rgHndlCmnChnl */
1953 * @brief Function for handling allocations for dedicated channels for a
1958 * Function : rgHndlSchdUe
1960 * This function shall be invoked whenever scheduler is done with the
1961 * allocations of dedicated channels for a subframe. Invoked by the function
1962 * RgSchMacSfAllocReq.
1964 * Processing steps :
1965 * 1. Loops through the list of UE's scheduled looking for the corresponding
1967 * 2. Finds the corresponding HARQ process.
1968 * 3. Invokes the DHM function to issue StatusIndications on RGU.
1971 * @param[in] RgCellCb *cell,
1972 * @param[in] CmLteTimingInfo timingInfo,
1973 * @param[in] RgInfUeInfo *ueInfo
1974 * @param[in/out] RgErrInfo *err
1980 PRIVATE S16 rgHndlSchdUe
1983 CmLteTimingInfo timingInfo,
1984 RgInfUeInfo *ueInfo,
1988 PRIVATE S16 rgHndlSchdUe(cell, timingInfo, ueInfo, err) /* laa_ut_fix */
1990 CmLteTimingInfo timingInfo;
1991 RgInfUeInfo *ueInfo;
1998 if(NULLP == ueInfo->allocInfo)
2003 rgDHMSndConsolidatedStaInd(cell, ueInfo, timingInfo, err);
2006 } /* end of rgHndlSchdUe */
2010 * @brief Function for handling Uplink allocations for Ue for a
2015 * Function : rgHndlUlUeInfo
2017 * @param[in] RgCellCb *cell,
2018 * @param[in] CmLteTimingInfo timingInfo,
2019 * @param[in] RgInfUlUeInfo *ueInfo
2025 PRIVATE S16 rgHndlUlUeInfo
2028 CmLteTimingInfo timingInfo,
2029 RgInfUlUeInfo *ueInfo
2032 PRIVATE S16 rgHndlUlUeInfo(cell, timingInfo, ueInfo)
2034 CmLteTimingInfo timingInfo;
2035 RgInfUlUeInfo *ueInfo;
2038 Inst inst = cell->macInst - RG_INST_START;
2043 TRC2(rgHndlUlUeInfo)
2045 ulSf = &cell->ulSf[(timingInfo.slot % RGSCH_NUM_SUB_FRAMES)];
2047 /* rg003.301-MOD- Corrected the purifier memory leak */
2048 if (ulSf->numUe != ueInfo->numUes)
2050 if (ulSf->ueUlAllocInfo)
2052 rgFreeSBuf(inst,(Data **)&(ulSf->ueUlAllocInfo),
2053 ulSf->numUe * sizeof(RgUeUlAlloc));
2056 #ifdef XEON_SPECIFIC_CHANGES
2057 CM_MEAS_TIME((cell->crntTime.slot % RGSCH_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MEAS_FREE);
2058 CM_ADD_INFO((cell->crntTime.slot % RGSCH_NUM_SUB_FRAMES), CM_DBG_MEAS_FREE, ulSf->numUe);
2060 ulSf->numUe = ueInfo->numUes;
2061 if((ulSf->ueUlAllocInfo == NULLP) && (ueInfo->numUes > 0))
2063 /* Allocate memory for ulAllocInfo */
2064 if((ret = rgAllocSBuf(inst,(Data**)&(cell->ulSf[(timingInfo.slot % RGSCH_NUM_SUB_FRAMES)].
2065 ueUlAllocInfo), ueInfo->numUes * sizeof(RgUeUlAlloc))) != ROK)
2070 #ifdef XEON_SPECIFIC_CHANGES
2071 CM_MEAS_TIME((cell->crntTime.slot % RGSCH_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MEAS_ALLOC);
2072 CM_ADD_INFO((cell->crntTime.slot % RGSCH_NUM_SUB_FRAMES), CM_DBG_MEAS_ALLOC, ueInfo->numUes);
2074 if (ulSf->ueUlAllocInfo != NULLP)
2076 for(idx = 0; idx < ueInfo->numUes; idx++)
2078 ulSf->ueUlAllocInfo[idx].rnti = ueInfo->ulAllocInfo[idx].rnti;
2079 ulSf->ueUlAllocInfo[idx].numPrb = ueInfo->ulAllocInfo[idx].numPrb;
2082 RGCPYTIMEINFO(timingInfo, ulSf->schdTime);
2084 } /* end of rgHndlUlUeInfo */
2087 * @brief Function for handling RaResp request received from scheduler to MAC
2091 * Function : rgTOMRlsSf
2093 * This function shall be invoked whenever scheduler is done with the
2094 * allocations of random access responses for a subframe.
2095 * This shall invoke RAM to create ueCbs for all the rapIds allocated and
2096 * shall invoke MUX to create RAR PDUs for raRntis allocated.
2099 * @param[in] Inst inst
2100 * @param[in] CmLteCellId cellId,
2101 * @param[in] CmLteTimingInfo timingInfo,
2102 * @param[in] RaRespInfo *rarInfo
2107 PUBLIC Void rgTOMRlsSf
2113 PUBLIC Void rgTOMRlsSf(dlSf)
2122 if(dlSf->txDone == FALSE)
2124 RLOG0(L_ERROR, "SUBFRAME Not pushed to the PHY");
2126 if (dlSf->bch.tb != NULLP)
2128 RG_FREE_MSG(dlSf->bch.tb);
2130 if (dlSf->bcch.tb != NULLP)
2132 RG_FREE_MSG(dlSf->bcch.tb);
2134 if (dlSf->pcch.tb != NULLP)
2136 RG_FREE_MSG(dlSf->pcch.tb);
2139 rgTOMEmtcRlsSf(dlSf);
2141 for(idx=0; idx < dlSf->numRaRsp; idx++)
2143 RG_FREE_MSG(dlSf->raRsp[idx].rar);
2146 /* ADD Changes for Downlink UE Timing Optimization */
2147 #ifdef LTEMAC_DLUE_TMGOPTMZ
2148 dlSf->remDatReqCnt = 0;
2149 /* Fix[ccpu00126310]: Tracks Data Requests from RLC for both loosely and tight coupled
2151 dlSf->statIndDone = FALSE;
2153 if (dlSf->tbs.count)
2158 RGDBGERRNEW(inst, (rgPBuf(inst),
2159 "Error Stale TBs in Subframes TBS list\n"));
2160 node = dlSf->tbs.first;
2163 hqP = (RgDlHqProcCb*)node->node;
2167 for(i=0;i< RG_MAX_TB_PER_UE;i++)
2169 if (hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sf == dlSf)
2171 cmLListDelFrm(&dlSf->tbs, &(hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sfLnk));
2172 hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sfLnk.node = NULLP;
2173 printf("\n rgTOMRlsSf:: hqP %p \n", (Void *)hqP);
2175 hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sf = NULLP;
2180 /*arjun: check if dlSf laaTb list has to be freed???*/
2181 cmLListInit(&dlSf->tbs);
2182 dlSf->txDone = FALSE;
2188 * @brief Function is called by the scheduler once it has completed the
2189 * allocation for the subframe.
2193 * Function : rgHndlFlowCntrl
2194 * This function should fill and send Flow control
2198 * @param[in] Pst *cell
2199 * @param[in] RgInfSfAlloc *sfInfo Carries all the allocation
2205 PUBLIC S16 rgHndlFlowCntrl
2208 RgInfSfAlloc *sfInfo
2211 PUBLIC S16 rgHndlFlowCntrl(cell, sfInfo)
2213 RgInfSfAlloc *sfInfo;
2216 RguFlowCntrlInd *flowCntrlInd;
2220 TRC3(rgHndlFlowCntrl);
2222 pst = &cell->rguDlSap->sapCfg.sapPst;
2223 /* flowCntrlInd is alloced in cell init time and will be re-used throughout */
2224 flowCntrlInd = cell->flowCntrlInd;
2225 flowCntrlInd->cellId = sfInfo->cellId;
2226 flowCntrlInd->numUes = sfInfo->flowCntrlInfo.numUes;
2228 for (ueIdx = 0; ueIdx < sfInfo->flowCntrlInfo.numUes; ueIdx++)
2230 flowCntrlInd->ueFlowCntrlInfo[ueIdx].ueId = sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].ueId;
2231 flowCntrlInd->ueFlowCntrlInfo[ueIdx].numLcs = sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].numLcs;
2233 for (lcIdx = 0; lcIdx < RGINF_MAX_NUM_DED_LC; lcIdx++)
2235 flowCntrlInd->ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].lcId =
2236 sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].lcId;
2237 flowCntrlInd->ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].pktAdmitCnt =
2238 sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].pktAdmitCnt;
2240 flowCntrlInd->ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].maxBo4FlowCtrl =
2241 sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].maxBo4FlowCtrl;
2244 RgUiRguFlowCntrlInd(pst, cell->rguDlSap->sapCfg.spId,flowCntrlInd); /* TODO: Rishi confirm if the suId and pst pointer is correct */
2248 * @brief Function is called by the scheduler once it has completed the
2249 * allocation for the subframe.
2253 * Function : RgSchMacSfAllocReq
2255 * This function shall be invoked whenever scheduler is done with the
2256 * allocations of for a subframe. The sfInfo carries all the allocation
2257 * details for the common channels, RA responses and dedicated channel
2260 * Processing steps :
2261 * 1. Reset the information present in the downlink subframe that is
2263 * 2. Handle common channel allocations
2264 * 3. Handle RA Response allocations
2265 * 4. Handle dedicated channel allocations.
2267 * @param[in] Pst *pst
2268 * @param[in] RgInfSfAlloc *sfInfo Carries all the allocation
2274 PUBLIC S16 RgSchMacSfAllocReq
2277 RgInfSfAlloc *sfInfo
2280 PUBLIC S16 RgSchMacSfAllocReq(pst, sfInfo)
2282 RgInfSfAlloc *sfInfo;
2288 VOLATILE U32 startTime=0;
2291 TRC2(RgSchMacSfAllocReq)
2293 RG_IS_INST_VALID(pst->dstInst);
2294 inst = pst->dstInst - RG_INST_START;
2296 SStartTask(&startTime, PID_MAC_SF_ALLOC_REQ);
2303 if((cell = rgCb[inst].cell) == NULLP)
2305 RLOG_ARG0(L_ERROR,DBG_CELLID,sfInfo->cellId, "No cellCb found with cell");
2309 dlSf = &cell->subFrms[(sfInfo->timingInfo.slot % RG_NUM_SUB_FRAMES)];
2311 rgTOMRlsSf(inst,dlSf);
2312 dlSf->schdTime = sfInfo->timingInfo;
2315 rgLaaInitTbInfoLst(cell);
2318 /* Fix : syed Ignore Failure Returns and continue processing.
2319 * Incomplete processing results in state sync loss between MAC-SCH. */
2321 if(TRUE == cell->emtcEnable)
2323 rgEmtcHndl(cell, sfInfo);
2326 rgHndlCmnChnl(cell, sfInfo->timingInfo, &sfInfo->cmnLcInfo, &err);
2328 rgHndlRaResp(cell, sfInfo->timingInfo, &sfInfo->rarInfo, &err);
2331 #ifdef XEON_SPECIFIC_CHANGES
2332 CM_MEAS_TIME((cell->crntTime.slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_B4_UE_SCHD);
2334 rgHndlSchdUe(cell, sfInfo->timingInfo, &sfInfo->ueInfo, &err);
2335 #ifdef XEON_SPECIFIC_CHANGES
2336 CM_MEAS_TIME((cell->crntTime.slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_UE_SCHD);
2338 rgLaaChkAndReqTbs(dlSf,cell, inst);
2341 rgHndlSchdUe(cell, sfInfo->timingInfo, &sfInfo->ueInfo, &err);
2345 if(rgHndlUlUeInfo(cell, sfInfo->ulUeInfo.timingInfo,
2346 &sfInfo->ulUeInfo) != ROK)
2351 #ifdef XEON_SPECIFIC_CHANGES
2352 CM_MEAS_TIME((cell->crntTime.slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_MEAS);
2354 /* Fix[ccpu00126310]: Tracks Data Requests from RLC for both loosely and tight coupled
2358 /* Added the handling for pushing down
2359 * TFU Data request in the retransmission only scenario.*/
2360 #ifdef LTEMAC_DLUE_TMGOPTMZ
2361 dlSf->statIndDone = TRUE;
2362 /* Fix [ccpu00126310]: Tracks Data Requests from RLC for both loosely and tight coupled
2364 if(!(dlSf->txDone) &&
2366 (TRUE == rgLaaChkAllRxTbs(dlSf)) &&
2368 (0 == dlSf->remDatReqCnt) && (dlSf->statIndDone) &&
2369 (RG_TIMEINFO_SAME(cell->crntTime, dlSf->schdTime)))
2371 /*This is the case of rettransmission, so no need
2372 * to wait for TTI Ind to push TFU Data Request. Send
2374 if (ROK != rgTOMUtlProcDlSf (dlSf, cell, &err))
2376 RLOG_ARG0(L_ERROR,DBG_CELLID,cell->cellId,"Unable to process downlink subframe for cell");
2377 err.errType = RGERR_ROM_DEDDATREQ;
2379 /* Mark this frame as sent */
2380 dlSf->txDone = TRUE;
2383 if (sfInfo->flowCntrlInfo.numUes > 0)
2385 rgHndlFlowCntrl(cell,sfInfo);
2388 SStopTask(startTime, PID_MAC_SF_ALLOC_REQ);
2390 } /* end of RgSchMacSfAllocReq */
2392 * @brief Handler for processing data indication recieved from PHY for UEs.
2396 * Function: rgTOMProcCrntiCEInDatInd
2398 * Handler for processing data indication recieved from PHY for UEs.
2400 * Invoked by: RgLiTfuDatInd of LIM
2403 * For each DataInfo recieved
2404 * - If received a CRNTI control element
2405 * - Check if a CCCH SDU is present, if it is return failure
2406 * - Check for the existence of UE, if its isnt present return failure.
2407 * - Delegate the remaining processing to rgTOMUtlProcMsg3 which
2408 * primarily informs the scheduler about the data received and
2409 * generates Data indications towards the higher layer.
2411 * @param RgMacPdu *pdu,
2412 * @param RgUeCb *prevUeCb,
2413 * @param RgCellCb *cellCb,
2414 * @param TfuDatInfo *datInfo,
2415 * @param RgInfCeInfo *ceInfo
2421 PRIVATE S16 rgTOMProcCrntiCEInDatInd
2426 TfuDatInfo *datInfo,
2427 RgInfCeInfo *ceInfo,
2431 PRIVATE S16 rgTOMProcCrntiCEInDatInd( pdu, prevUeCb, cellCb, datInfo, ceInfo, slot)
2435 TfuDatInfo *datInfo;
2436 RgInfCeInfo *ceInfo;
2440 RgUeCb *ueCb = NULLP;
2441 Inst inst = cellCb->macInst - RG_INST_START;
2449 TRC2(rgTOMProcCrntiCEInDatInd)
2455 ueCb = rgDBMGetUeCbFromRachLst (cellCb, datInfo->rnti);
2459 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2460 "RNTI:%d Received MSG3 with CRNTI,unable to find ueCb", ceInfo->ces.cRnti);
2464 prevUeCb = rgDBMGetUeCb (cellCb, ceInfo->ces.cRnti);
2465 if (prevUeCb == NULLP)
2467 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2468 "RNTI:%d Received MSG3 with CRNTI,unable to find ueCb", ceInfo->ces.cRnti);
2471 RLOG_ARG2(L_DEBUG,DBG_CELLID,cellCb->cellId,
2472 "CRNTI CE(%d) received through tmpCrnti(%d)",
2473 ceInfo->ces.cRnti, datInfo->rnti);
2474 rgDBMDelUeCbFromRachLst(cellCb, ueCb);
2475 rgRAMFreeUeCb(inst,ueCb);
2478 if ((rgTOMUtlProcMsg(cellCb, ueCb, pdu, FALSE,&spsToBeActvtd,&sduSize, slot, NULLP)) != ROK)
2480 if ((rgTOMUtlProcMsg (cellCb, ueCb, pdu, slot, NULLP)) != ROK)
2481 #endif /* LTEMAC_SPS */
2483 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2484 "RNTI:%d Processing for MSG3 failed",datInfo->rnti);
2490 * @brief Handler for processing data indication recieved from PHY for UEs.
2494 * Function: rgTOMProcCCCHSduInDatInd
2496 * Handler for processing data indication recieved from PHY for UEs.
2498 * Invoked by: RgLiTfuDatInd of LIM
2501 * For each DataInfo recieved
2502 * - If only CCCH SDU is present
2503 * - Invoke rgTOMUtlProcMsg3 for further processing.
2504 * - If its a non-Msg3 PDU i.e. received outside of a RA procedure
2505 * - Retrieve the UeCB
2506 * - Validate that the received PDU contains only configured Logical
2508 * - Invoke rgTOMUtlProcDatPdu for further processing. It informs the
2509 * scheduler with the information of the received Data and generates
2510 * DatIndications towards the higher layers.
2512 * @param TfuDatIndInfo *datInd
2513 * @param RgMacPdu *pdu,
2514 * @param RgUeCb *prevUeCb,
2515 * @param RgCellCb *cellCb,
2516 * @param TfuDatInfo *datInfo,
2517 * @param RgInfCeInfo *ceInfo
2523 PRIVATE S16 rgTOMProcCCCHSduInDatInd
2528 TfuDatInfo *datInfo,
2529 RgInfCeInfo *ceInfo,
2533 PRIVATE S16 rgTOMProcCCCHSduInDatInd( pdu, prevUeCb, cellCb, datInfo, ceInfo, slot)
2537 TfuDatInfo *datInfo;
2538 RgInfCeInfo *ceInfo;
2542 RgUeCb *ueCb = NULLP;
2543 Inst inst = cellCb->macInst - RG_INST_START;
2551 TRC2(rgTOMProcCCCHSduInDatInd)
2557 if (ceInfo->bitMask & RG_CRNTI_CE_PRSNT)
2559 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2560 "CRNTI:%d Received MSG3 with CCCH",ceInfo->ces.cRnti);
2564 ueCb = rgDBMGetUeCbFromRachLst (cellCb, datInfo->rnti);
2568 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2569 "RNTI:%d Processing for MSG3 failed", datInfo->rnti);
2572 /* Fix: syed Drop any duplicate Msg3(CCCH Sdu) */
2573 if (ueCb->dl.hqEnt.numHqProcs)
2575 /* HqE is already initialized by a previuos Msg3 */
2576 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"RNTI:%d Processing for MSG3 failed. Duplicate "
2577 "MSG3 received. Dropping", datInfo->rnti);
2581 if(rgDHMHqEntInit(inst,&ueCb->dl.hqEnt,
2582 cellCb->maxDlHqProcPerUe) != ROK)
2584 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"RNTI:%d Harq Initialization failed ",
2588 RLOG_ARG1(L_DEBUG,DBG_CELLID,cellCb->cellId,
2589 "CCCH SDU received through tmpCrnti(%d)",datInfo->rnti);
2591 if ((rgTOMUtlProcMsg(cellCb, ueCb, pdu, FALSE,&spsToBeActvtd,&sduSize, slot, NULLP)) != ROK)
2593 if ((rgTOMUtlProcMsg (cellCb, ueCb, pdu, slot, NULLP)) != ROK)
2594 #endif /* LTEMAC_SPS */
2596 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"RNTI:%d Processing for MSG3 failed",
2605 /** @brief This function captures the BSR value from Control Element
2606 * Info structure and updates the effective Buffer size into the
2607 * corresponding LCG ID.
2611 * Function: rgTOMUtlL2MStoreBufSz
2614 * - update/append the Data structure based on BSR type
2616 * @param [in] RgUeCb *ueCb
2617 * @param [in] RgInfCeInfo *ceInfo
2622 PRIVATE S16 rgTOMUtlL2MStoreBufSz
2628 PRIVATE S16 rgTOMUtlL2MStoreBufSz (ueCb, ceInfo)
2630 RgInfCeInfo *ceInfo;
2635 TRC2(rgTOMUtlL2MStoreBufSz);
2637 if(ceInfo->bitMask & RG_TRUNC_BSR_CE_PRSNT)
2639 lcgId = ((ceInfo->ces.bsr.truncBsr >> 6) & 0x03);
2640 bsr = ceInfo->ces.bsr.truncBsr & 0x3F;
2641 ueCb->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs = rgLwrBsrTbl[bsr];
2643 else if(ceInfo->bitMask & RG_SHORT_BSR_CE_PRSNT)
2645 lcgId = ((ceInfo->ces.bsr.shortBsr >> 6) & 0x03);
2646 bsr = ceInfo->ces.bsr.shortBsr & 0x3F;
2647 ueCb->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs = rgLwrBsrTbl[bsr];
2650 else if(ceInfo->bitMask & RG_LONG_BSR_CE_PRSNT)
2652 ueCb->ul.lcgArr[0].lcgBsInfo.outStndngBs = rgLwrBsrTbl[ceInfo->ces.bsr.longBsr.bs1];
2653 ueCb->ul.lcgArr[1].lcgBsInfo.outStndngBs = rgLwrBsrTbl[ceInfo->ces.bsr.longBsr.bs2];
2654 ueCb->ul.lcgArr[2].lcgBsInfo.outStndngBs = rgLwrBsrTbl[ceInfo->ces.bsr.longBsr.bs3];
2655 ueCb->ul.lcgArr[3].lcgBsInfo.outStndngBs = rgLwrBsrTbl[ceInfo->ces.bsr.longBsr.bs4];
2658 } /* end of rgTOMUtlL2MStoreBufSz*/
2660 /** @brief : Compiles list of LCs received in UL data for DTCH RBs
2664 * @param [in] RgCellCb *cellCb
2665 * @param [in] RgUeCb *ueCb
2666 * @param [in] CmLteRnti rnti
2667 * @param [in] RgMacPdu *pdu
2674 PRIVATE Void rgTOML2MCompileActiveLCs
2682 PRIVATE Void rgTOML2MCompileActiveLCs(cellCb, ueCb, pdu, ceInfo)
2686 RgInfCeInfo *ceInfo;
2693 TRC2(rgTOML2MCompileActiveLCs)
2695 node = pdu->sduLst.first;
2698 sdu = (RgMacSdu*)node->node;
2700 if ((ulLcCb = rgDBMGetUlDedLcCb(ueCb, sdu->lcId)), ulLcCb != NULLP)
2702 if (ulLcCb->lcgId != 0)
2704 ceInfo->bitMask |= RG_ACTIVE_LC_PRSNT;
2705 ceInfo->ulActLCs[ulLcCb->lcId - 1] = TRUE;
2716 /**********************************************************************
2719 **********************************************************************/