1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /************************************************************************
25 Desc: C source code for Entry point fucntions
29 **********************************************************************/
31 static const char* RLOG_MODULE_NAME="MAC";
32 static int RLOG_FILE_ID=237;
33 static int RLOG_MODULE_ID=4096;
35 @brief This module does processing related to handling of lower interface APIs
36 invoked by PHY towards MAC
38 /* header include files -- defines (.h) */
39 #include "envopt.h" /* environment options */
40 #include "envdep.h" /* environment dependent */
41 #include "envind.h" /* environment independent */
42 #include "gen.h" /* general layer */
43 #include "ssi.h" /* system services */
44 #include "cm5.h" /* common timers defines */
45 #include "cm_hash.h" /* common hash list defines */
46 #include "cm_llist.h" /* common linked list defines */
47 #include "cm_mblk.h" /* memory management */
48 #include "cm_tkns.h" /* common tokens */
49 #include "cm_lte.h" /* common tokens */
50 #include "rgu.h" /* RGU defines */
51 #include "tfu.h" /* RGU defines */
52 #include "lrg.h" /* layer management defines for LTE-MAC */
53 #include "crg.h" /* layer management defines for LTE-MAC */
54 #include "rg_sch_inf.h" /* layer management defines for LTE-MAC */
55 #include "rg.h" /* defines and macros for MAC */
56 #include "rg_env.h" /* defines and macros for MAC */
57 #include "rg_err.h" /* defines and macros for MAC */
60 /* header/extern include files (.x) */
61 #include "gen.x" /* general layer typedefs */
62 #include "ssi.x" /* system services typedefs */
63 #include "cm5.x" /* common timers */
64 #include "cm_hash.x" /* common hash list */
65 #include "cm_lib.x" /* common library */
66 #include "cm_llist.x" /* common linked list */
67 #include "cm_mblk.x" /* memory management */
68 #include "cm_tkns.x" /* common tokens */
69 #include "cm_lte.x" /* common tokens */
70 #include "rgu.x" /* RGU types */
71 #include "tfu.x" /* RGU types */
72 #include "lrg.x" /* layer management typedefs for MAC */
73 #include "crg.x" /* CRG interface typedefs */
74 #include "rg_sch_inf.x" /* SCH interface typedefs */
75 #include "rg_prg.x" /* PRG interface typedefs */
76 #include "rgm.x" /* layer management typedefs for MAC */
77 #include "rgm.h" /* layer management typedefs for MAC */
78 #include "du_app_mac_inf.h"
80 #include "rg.x" /* typedefs for MAC */
81 #include "lwr_mac_fsm.h"
82 #ifdef MAC_RLC_UL_RBUF
87 /* ADD Changes for Downlink UE Timing Optimization */
88 #ifndef LTEMAC_DLUE_TMGOPTMZ
89 PRIVATE S16 rgTOMUtlProcDlSf ARGS(( RgDlSf *dlSf, RgCellCb *cellCb,
92 PUBLIC S16 rgTOMUtlProcDlSf ARGS((RgDlSf *dlSf, RgCellCb *cellCb,
95 PRIVATE S16 rgTOMProcCrntiCEInDatInd ARGS((
104 PRIVATE S16 rgTOMProcCCCHSduInDatInd ARGS((
113 PUBLIC S16 rgHndlFlowCntrl
119 EXTERN S16 RgUiRguFlowCntrlInd(Pst* pst, SuId suId, RguFlowCntrlInd *flowCntrlInd);
121 EXTERN S16 rgEmtcHndl(RgCellCb *cell,RgInfSfAlloc *sfInfo);
122 EXTERN S16 rgTOMEmtcUtlFillDatReqPdus(TfuDatReqInfo *datInfo, RgDlSf *dlSf, RgCellCb *cell, RgErrInfo *err);
123 EXTERN Void rgTOMEmtcRlsSf(RgDlSf *dlSf);
126 PRIVATE Void rgTOML2MCompileActiveLCs ARGS
133 PRIVATE S16 rgTOMUtlL2MStoreBufSz ARGS
139 PRIVATE S16 rgTomUtlPrepareL2MUlThrpInfo ARGS
143 RgRguDedDatInd *dDatInd
147 /* The below table takes lower values of BSR Range for a BSR value
148 This is to ensure that outstanding can be decrease to zero upon reception of
149 TB, which is not guaranteed if higher Range values are used */
150 /* Note: taking value 10 for BSR index 1 */
151 #ifndef MAC_5GTF_UPDATE
152 PRIVATE U32 rgLwrBsrTbl[64] = {
153 0, 10, 10, 12, 14, 17, 19, 22, 26,
154 31, 36, 42, 49, 57, 67, 78, 91,
155 107, 125, 146, 171, 200, 234, 274, 321,
156 376, 440, 515, 603, 706, 826, 967, 1132,
157 1326, 1552, 1817, 2127, 2490, 2915, 3413, 3995,
158 4677, 5476, 6411, 7505, 8787, 10287, 12043, 14099,
159 16507, 19325, 22624, 26487, 31009, 36304, 42502, 49759,
160 58255, 68201, 79846, 93479, 109439, 128125, 150000
164 PRIVATE U32 rgLwrBsrTbl[64] = {
165 0,10,13,16,19,23,29,35,43,53,65,80,98,120,147,181,223,274,337,414,
166 509,625,769,945,1162,1429,1757,2161,2657,3267,4017,4940,6074,7469,
167 9185,11294,13888,17077,20999,25822,31752,39045,48012,59039,72598,
168 89272,109774,134986,165989,204111,250990,308634,379519,466683,
169 573866,705666,867737,1067031,1312097,1613447,1984009,2439678,
177 #define RG_TOM_INF_ALLOC(_pdu, _size, _dataPtr, _ret) {\
178 _ret = cmGetMem((Ptr)&_pdu->memCp, _size, (Ptr *)&_dataPtr); \
181 /* global variables */
182 PUBLIC U32 rgUlrate_tfu;
184 EXTERN U32 grgUlrate_tfu;
187 /** @brief This function fills the PDSCH data of a downlink subframe
191 * Function: rgTOMUtlFillDatReqPdus
194 * - Fill BCCH on DLSCH data using datInfo
195 * - Fill PCCH on DLSCH data using datInfo
196 * - Fill Dedicated data on DLSCH data using datInfo
197 * - Fill RA RSP data using datInfo
199 * @param [out] TfuDatReqInfo *datInfo
200 * @param [in] RgDlSf *dlSf
201 * @param [in] RgCellCb *cellCb
202 * @param [out] RgErrInfo *err
208 PRIVATE S16 rgTOMUtlFillDatReqPdus
210 TfuDatReqInfo *datInfo,
216 PRIVATE S16 rgTOMUtlFillDatReqPdus(datInfo, dlSf, cellCb, err)
217 TfuDatReqInfo *datInfo;
224 TfuDatReqPduInfo *datReq=NULLP;
225 /* Moving node declaration to limited scope for optimization */
228 Inst inst = cellCb->macInst - RG_INST_START;
230 TRC2(rgTOMUtlFillDatReqPdus)
232 /* first lets send the BCCH data down to PHY */
233 if (dlSf->bcch.tb != NULLP)
235 if ((ret = rgGetEventMem(inst,(Ptr *)&datReq, sizeof(TfuDatReqPduInfo),
236 &(datInfo->memCp))) != ROK)
238 err->errCause = RGERR_TOM_MEM_EXHAUST;
239 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,"Memory Exhaustion ");
242 #ifdef TFU_ALLOC_EVENT_NO_INIT
246 datReq->tbInfo[0].lchInfo[0].mBuf[0]=NULLP;
249 datReq->rnti = RG_SI_RNTI;
250 datReq->dciInfo = dlSf->bcch.pdcch.dci;
251 /* Note: SCpyMsgMsg is not done since free of unsent buffer
252 * has been taken care through cell delete by invoking rgTomRlsSf
254 datReq->nmbOfTBs = 1;
256 datReq->mBuf[0] = dlSf->bcch.tb;
258 SFndLenMsg((Buffer *)dlSf->bcch.tb, &(datReq->tbInfo[0].tbSize));
259 datReq->tbInfo[0].tbPres = TRUE;
260 datReq->tbInfo[0].lchInfo[0].mBuf[0] = dlSf->bcch.tb;
261 datReq->tbInfo[0].numLch = 1;
262 datReq->tbInfo[0].lchInfo[0].numPdu = 1;
264 #ifdef TFU_ALLOC_EVENT_NO_INIT
265 datReq->tbInfo[1].tbPres = FALSE;
266 datReq->tbInfo[1].lchInfo[0].mBuf[0] = NULLP;
269 cmLListAdd2Tail(&datInfo->pdus, &(datReq->lnk));
270 datReq->lnk.node = (PTR)datReq;
272 /* ccpu00132314-ADD- Adding txPower offset for the PDSCH transmission */
273 datReq->txPwrOffset = dlSf->bcch.txPwrOffset;
275 /* Setting the pointer to NULL post transmission */
276 dlSf->bcch.tb = NULLP;
279 if (dlSf->pcch.tb != NULLP)
281 if ((ret = rgGetEventMem(inst,(Ptr *)&datReq, sizeof(TfuDatReqPduInfo),
282 &(datInfo->memCp))) != ROK)
284 err->errCause = RGERR_TOM_MEM_EXHAUST;
285 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"Memory Exhaustion CRNTI:%d",datReq->rnti);
288 #ifdef TFU_ALLOC_EVENT_NO_INIT
293 datReq->rnti = RG_P_RNTI;
294 datReq->dciInfo = dlSf->pcch.pdcch.dci;
295 datReq->nmbOfTBs = 1;
297 datReq->mBuf[0] = dlSf->pcch.tb;
299 SFndLenMsg((Buffer *)dlSf->pcch.tb, &datReq->tbInfo[0].tbSize);
300 datReq->tbInfo[0].tbPres = TRUE;
301 datReq->tbInfo[0].lchInfo[0].mBuf[0] = dlSf->pcch.tb;
302 #ifdef TFU_ALLOC_EVENT_NO_INIT
303 datReq->tbInfo[1].tbPres = FALSE;
304 datReq->tbInfo[1].lchInfo[0].mBuf[0] = NULLP;
306 datReq->tbInfo[0].numLch = 1;
307 datReq->tbInfo[0].lchInfo[0].numPdu = 1;
309 cmLListAdd2Tail(&datInfo->pdus, &(datReq->lnk));
310 datReq->lnk.node = (PTR)datReq;
312 /* ccpu00132314-ADD- Adding txPower offset for the PDSCH transmission */
313 datReq->txPwrOffset = dlSf->pcch.txPwrOffset;
315 dlSf->pcch.tb = NULLP;
318 for(idx=0; idx < dlSf->numRaRsp; idx++)
320 if ((ret = rgGetEventMem(inst,(Ptr *)&datReq, sizeof(TfuDatReqPduInfo),
321 &(datInfo->memCp))) != ROK)
323 err->errCause = RGERR_TOM_MEM_EXHAUST;
324 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"Memory Exhaustion CRNTI:%d",
328 #ifdef TFU_ALLOC_EVENT_NO_INIT
333 datReq->rnti = dlSf->raRsp[idx].pdcch.rnti;
334 datReq->dciInfo = dlSf->raRsp[idx].pdcch.dci;
335 datReq->nmbOfTBs = 1;
337 datReq->mBuf[0] = dlSf->raRsp[idx].rar;
339 SFndLenMsg((Buffer *)dlSf->raRsp[idx].rar, &datReq->tbInfo[0].tbSize);
340 datReq->tbInfo[0].tbPres = TRUE;
341 datReq->tbInfo[0].lchInfo[0].mBuf[0] = dlSf->raRsp[idx].rar;
342 #ifdef TFU_ALLOC_EVENT_NO_INIT
343 datReq->tbInfo[1].lchInfo[0].mBuf[0] = NULLP;
344 datReq->tbInfo[1].tbPres = FALSE;
346 datReq->tbInfo[0].numLch = 1;
347 datReq->tbInfo[0].lchInfo[0].numPdu = 1;
348 // prc_trace_format_string(0x40,3,"UE Id=(%d) tbSz=(%d)",datReq->rnti, datReq->tbInfo[0].tbSize);
350 cmLListAdd2Tail(&datInfo->pdus, &(datReq->lnk));
351 datReq->lnk.node = (PTR)datReq;
353 /* ccpu00132314-ADD- Adding txPower offset for the PDSCH transmission */
354 datReq->txPwrOffset = dlSf->raRsp[idx].txPwrOffset;
356 dlSf->raRsp[idx].rar = NULLP;
359 /* Fill Dedicated UE data */
360 if (dlSf->tbs.count != 0)
363 while (dlSf->tbs.first)
365 node = dlSf->tbs.first;
366 hqCb = (RgDlHqProcCb*)node->node;
367 if ((ret = rgDHMSndDatReq (cellCb, dlSf, datInfo, hqCb, err)) != ROK)
369 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
370 "DHM unable to fill DATA request");
371 err->errType = RGERR_TOM_TTIIND;
378 } /* end of rgTOMUtlFillDatReqPdus*/
380 /** @brief This function does all the processing related to a single downlink
385 * Function: rgTOMUtlProcDlSf
388 * - collate control data for all UEs and send to PHY
389 * - collate data buffers for all UEs and send to PHY
391 * @param [in] RgDlSf *dlSf
392 * @param [in] RgCellCb *cellCb
393 * @param [out] RgErrInfo *err
396 /* ADD Changes for Downlink UE Timing Optimization */
397 #ifndef LTEMAC_DLUE_TMGOPTMZ
399 PRIVATE S16 rgTOMUtlProcDlSf
406 PRIVATE S16 rgTOMUtlProcDlSf (dlSf, cellCb, err)
413 PUBLIC S16 rgTOMUtlProcDlSf
420 PUBLIC S16 rgTOMUtlProcDlSf (dlSf, cellCb, err)
428 TfuDatReqInfo *datInfo;
429 Inst inst = cellCb->macInst - RG_INST_START;
431 TRC2(rgTOMUtlProcDlSf);
433 /* Fill Data Request Info from scheduler to PHY */
434 if ((ret = rgAllocEventMem(inst,(Ptr *)&datInfo,
435 sizeof(TfuDatReqInfo))) != ROK)
437 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,"Unable to Allocate TfuDatReqInfo");
442 cmLListInit(&datInfo->pdus);
444 RGADDTOCRNTTIME(dlSf->schdTime, datInfo->timingInfo, TFU_DELTA);
446 RGADDTOCRNTTIME(dlSf->schdTime, datInfo->timingInfo, TFU_DLDATA_DLDELTA);
448 datInfo->cellId = cellCb->cellId;
449 if((0 == (datInfo->timingInfo.sfn % 30)) && (0 == datInfo->timingInfo.slot))
451 //printf("5GTF_CHECK rgTOMUtlProcDlSf dat (%d : %d)\n", datInfo->timingInfo.sfn, datInfo->timingInfo.slot);
453 #ifdef TFU_ALLOC_EVENT_NO_INIT
454 datInfo->bchDat.pres = 0;
458 if (dlSf->bch.tb != NULLP)
460 datInfo->bchDat.pres = PRSNT_NODEF;
461 datInfo->bchDat.val = dlSf->bch.tb;
462 dlSf->bch.tb = NULLP;
465 /* Fill the DLSCH PDUs of BCCH, PCCH and Dedicated Channels */
466 if ((ret = rgTOMEmtcUtlFillDatReqPdus(datInfo, dlSf, cellCb, err)) != ROK)
468 RG_FREE_MEM(datInfo);
472 /* Fill the DLSCH PDUs of BCCH, PCCH and Dedicated Channels */
473 if ((ret = rgTOMUtlFillDatReqPdus(datInfo, dlSf, cellCb, err)) != ROK)
475 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,"Unable to send data for cell");
476 RG_FREE_MEM(datInfo);
479 if((datInfo->pdus.count) || (datInfo->bchDat.pres == TRUE))
481 /* sending the data to Phy */
482 if (rgLIMTfuDatReq(inst,datInfo) != ROK)
484 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,"Unable to send data info for cell");
489 /* Nothing to send: free the allocated datInfo */
490 RG_FREE_MEM(datInfo);
499 * @brief Handler for processing TTI indication recieved from
504 * Function: macProcessSlotInd
506 * Handler for processing slot indication recieved from PHY
509 * Invoked by: macProcessSlotInd
512 * - Get cell and update the cell's current time with the timing value given
514 * - Invoke the cmPrcTmr to process the timing queue.
515 * - Append the PHICH information to the downlink subframe that needs to go
516 * out to PHY in this subframe.
517 * - Invoke DHM to release the downlink subframe that occured earlier
518 * rgDHMRlsDlsfHqProc.
519 * - Invoke the TTI handler of scheduler.
520 * - Invoke the TTI handler of RAM module.
521 * - Get the downlink subframe that has to go out to PHY in this subframe
523 * - Invoke rgTOMUtlProcTA to perform and timing advance processing.
524 * - Invoke rgTOMUtlProcDlSf to do further processing on the downlink
526 * - Get the downlink subframe that would occur after RG_DL_DELTA and
527 * invoke rgTOMUtlProcDlSfStaInd to send status indications to the higher
529 * - Invoke GOM's TTI handler rgGOMTtiHndlr
530 * - Invoke COM's TTI handler rgCOMTtiHndlr
532 * @param[in] Inst inst
533 * @param[in] SlotIndInfo slotInd
538 #if (defined (MAC_FREE_RING_BUF) || defined (RLC_FREE_RING_BUF))
539 pthread_t gMacTId = 0;
541 PUBLIC S16 macProcessSlotInd
550 /* ADD Changes for Downlink UE Timing Optimization */
551 #ifdef LTEMAC_DLUE_TMGOPTMZ
553 CmLteTimingInfo prevTmInfo;
555 //SlotIndInfo *slotInd = &ttiInfo->cells[0];
557 TRC2(macProcessSlotInd);
559 #ifdef MAC_FREE_RING_BUF
560 gMacTId = pthread_self();
563 cellCb = rgCb[inst].cell;
566 err.errType = RGERR_TOM_TTIIND;
567 err.errCause = RGERR_TOM_INV_CELL_ID;
571 RGCPYTIMEINFO(slotInd, cellCb->crntTime);
573 rgMacGT = (slotInd.sfn * RG_NUM_SUB_FRAMES_5G) + slotInd.slot;
576 /*Included to track the number of 10240 cycles completed */
578 if((cellCb->crntTime.sfn == 0) && (cellCb->crntTime.slot==0))
580 cellCb->ttiCycle += 1;
585 /*Check if we have transmitted the previous DL SF, it could be the
586 case that we haven't received all the DATA from RLC as yet
587 and thus we would not have transmitted previous DL SF yet.*/
588 /* ADD Changes for Downlink UE Timing Optimization */
589 #ifdef LTEMAC_DLUE_TMGOPTMZ
590 RGSUBFRMCRNTTIME(slotInd, prevTmInfo, 1);
591 prevDlSf = &cellCb->subFrms[(prevTmInfo.slot % RG_NUM_SUB_FRAMES)];
592 if(FALSE == prevDlSf->txDone)
594 if (ROK != rgTOMUtlProcDlSf (prevDlSf, cellCb, &err))
596 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,"Unable to process "
597 "previous downlink subframe for cell");
598 err.errType = RGERR_TOM_TTIIND;
601 /* Mark this frame as sent */
602 prevDlSf->txDone = TRUE;
604 if(prevDlSf->remDatReqCnt)
606 /*We have not received 1 or more data requests from RLC, this is
607 error scenario. MAC & SCH need to discard the allocations for
608 which data request hasn't been received as yet. And MAC
609 needs to inform SCH about the list of UEs for which
610 allocation need to be discarded. */
611 prevDlSf->remDatReqCnt = 0;
616 CmLteTimingInfo timingInfo;
617 RGADDTOCRNTTIME(cellCb->crntTime, timingInfo, TFU_DELTA);
619 /* Trigger for DL TTI REQ */
620 handleDlTtiReq(&timingInfo);
622 /* Trigger for UL TTI REQ */
623 handleUlTtiReq(&timingInfo);
625 dlSf = &cellCb->subFrms[(slotInd.slot % RG_NUM_SUB_FRAMES)];
627 if((dlSf->txDone == TRUE) ||
628 (!RG_TIMEINFO_SAME(slotInd,dlSf->schdTime)))
631 #ifndef LTEMAC_DLUE_TMGOPTMZ
632 TfuDatReqInfo *datInfo;
633 CmLteTimingInfo timingInfo;
634 #ifdef TFU_DL_DELTA_CHANGE
635 RGADDTOCRNTTIME(cellCb->crntTime, timingInfo, TFU_DLDATA_DLDELTA);
637 RGADDTOCRNTTIME(cellCb->crntTime, timingInfo, TFU_DELTA);
639 /* Fill Data Request from MAC for BCH */
640 if ((timingInfo.sfn % 4 == 0) && (timingInfo.slot == 0))
642 if (ROK != rgAllocEventMem(inst,(Ptr *)&datInfo,
643 sizeof(TfuDatReqInfo)))
645 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
646 "rgTOMUtlProcDlSf() Unable to Allocate TfuDatReqInfo for cell");
651 cmLListInit(&datInfo->pdus);
652 datInfo->cellId = cellCb->cellId;
653 datInfo->bchDat.pres = NOTPRSNT;
654 datInfo->timingInfo = timingInfo;
657 /* sending the dummy data req to Phy */
658 if (rgLIMTfuDatReq(inst,datInfo) != ROK)
660 RLOG_ARG0(L_ERROR,DBG_CELLID,cellCb->cellId,
661 "rgTOMUtlProcDlSf() Unable to send data info for cell");
667 /* Freeing as the part of CL Non RT Indication */
668 /* TDOD : Generalize for all SOCs */
669 #if !(defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD))
670 rgDHMFreeTbBufs(inst);
675 /*Return if there is still some data to be received
676 from RLC for this DL SF. */
677 /* ADD Changes for Downlink UE Timing Optimization */
678 #ifdef LTEMAC_DLUE_TMGOPTMZ
679 if(0 != dlSf->remDatReqCnt)
681 /* Freeing as the part of CL Non RT Indication */
682 /* TODO : Generalize for all SOCs and remove this flag */
683 #if !(defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD))
684 rgDHMFreeTbBufs(inst);
690 #ifdef XEON_SPECIFIC_CHANGES
691 CM_MEAS_TIME((slotInd.slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_DL_BR_PRC);
694 if (ROK != rgTOMUtlProcDlSf (dlSf, cellCb, &err))
696 //RLOG_ARG0(L_ERROR,DBG_CELLID,slotInd->cellId,
697 // "Unable to process downlink subframe for cell");
698 err.errType = RGERR_TOM_TTIIND;
700 #ifdef XEON_SPECIFIC_CHANGES
701 CM_MEAS_TIME((slotInd->slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_DL_AFTER_PRC);
704 /* Mark this frame as sent */
707 /* Freeing as the part of CL Non RT Indication */
708 /* TODO : Generalize for all SOCs and remove this flag */
709 #if !(defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD))
710 rgDHMFreeTbBufs(inst);
713 } /* macProcessSlotInd */
715 /** @brief This function allocates the RgMacPdu that will be populated by DEMUX
716 * with the SubHeaders list and the values of the Control elements.
720 * Function: rgTOMUtlAllocPduEvnt
723 * @param[in] Inst inst
724 * @param [out] RgMacPdu **pdu
731 PRIVATE S16 rgTOMUtlAllocPduEvnt
737 PRIVATE S16 rgTOMUtlAllocPduEvnt (inst,pdu)
744 RgUstaDgn dgn; /* Alarm diagnostics structure */
745 VOLATILE U32 startTime=0;
747 TRC2(rgTOMUtlAllocPduEvnt);
749 evntMem.region = rgCb[inst].rgInit.region;
750 evntMem.pool = rgCb[inst].rgInit.pool;
753 SStartTask(&startTime, PID_TOMUTL_CMALLCEVT);
755 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
756 MS_BUF_ADD_ALLOC_CALLER();
759 if (cmAllocEvnt (sizeof (RgMacPdu), RG_BLKSZ, &evntMem, (Ptr*)pdu) != ROK)
761 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
762 rgLMMStaInd(inst,LCM_CATEGORY_RESOURCE, LCM_EVENT_DMEM_ALLOC_FAIL,
763 LCM_CAUSE_MEM_ALLOC_FAIL, &dgn);
764 RLOG0(L_ERROR,"Allocation of DUX event failed");
769 SStopTask(startTime, PID_TOMUTL_CMALLCEVT);
774 /** @brief This function frees up the RgMacPdu structure that has been
775 * populated by demux.
779 * Function: rgTOMUtlFreePduEvnt
780 * - Function frees up the RgMacPdu structure, in case of error it shall
781 * free up the buffer's present in the different sdu.
784 * @param [in] Inst inst
785 * @param [in] RgMacPdu *pdu
786 * @param [in] Bool *error
790 PRIVATE Void rgTOMUtlFreePduEvnt
796 PRIVATE Void rgTOMUtlFreePduEvnt (pdu, error)
805 TRC2(rgTOMUtlFreePduEvnt);
806 /* Steps of freeing up the PDU.
807 * 1. loop through the subHdrLst and free up all the buffers.
808 * 2. free up the whole event
810 if ((error == TRUE) && (pdu->sduLst.count > 0))
812 node = pdu->sduLst.first;
815 sdu = (RgMacSdu*)node->node;
816 RG_FREE_MSG(sdu->mBuf);
822 } /* end of rgTOMUtlFreePduEvnt */
824 /** @brief This function allocates the RgMacPdu that will be populated by DEMUX
825 * with the SubHeaders list and the values of the Control elements.
829 * Function: rgTOMInfAllocPduEvnt
832 * @param [in] Inst inst
833 * @param [out] RgMacPdu **pdu
840 PRIVATE S16 rgTOMInfAllocPduEvnt
843 RgInfSfDatInd **sfInfo
846 PRIVATE S16 rgTOMInfAllocPduEvnt (inst,sfInfo)
848 RgInfSfDatInd **sfInfo;
853 RgUstaDgn dgn; /* Alarm diagnostics structure */
854 VOLATILE U32 startTime=0;
856 TRC2(rgTOMInfAllocPduEvnt);
858 evntMem.region = rgCb[inst].rgInit.region;
859 evntMem.pool = rgCb[inst].rgInit.pool;
862 SStartTask(&startTime, PID_TOMINF_CMALLCEVT);
864 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
865 MS_BUF_ADD_ALLOC_CALLER();
867 if (cmAllocEvnt (sizeof (RgInfSfDatInd), RG_BLKSZ, &evntMem, (Ptr*)sfInfo) != ROK)
869 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_MEM);
870 rgLMMStaInd(inst,LCM_CATEGORY_RESOURCE, LCM_EVENT_DMEM_ALLOC_FAIL,
871 LCM_CAUSE_MEM_ALLOC_FAIL, &dgn);
872 RLOG0(L_ERROR,"Allocation failed");
877 SStopTask(startTime, PID_TOMINF_CMALLCEVT);
882 /** @brief This function frees up the RgMacPdu structure that has been
883 * populated by demux.
887 * Function: rgTOMInfFreePduEvnt
888 * - Function frees up the RgMacPdu structure, in case of error it shall
889 * free up the buffer's present in the different sdu.
892 * @param [in] RgMacPdu *pdu
893 * @param [in] Bool *error
897 PRIVATE Void rgTOMInfFreePduEvnt
899 RgInfSfDatInd *sfInfo
902 PRIVATE Void rgTOMInfFreePduEvnt (sfInfo)
903 RgInfSfDatInd *sfInfo;
906 TRC2(rgTOMInfFreePduEvnt);
910 } /* end of rgTOMUtlFreePduEvnt */
914 /** @brief This function performs the preparation of information needed to set
915 * L2M Scheduled UL Throughput Information for a particular UE.
919 * Function: rgTomUtlPrepareL2MUlThrpInfo
920 * This function performs the preparation of information needed to set
921 * L2M Scheduled UL Throughput Information for a particular UE.
925 * @param [in] RgCellCb *cellCb
926 * @param [in] RgUeCb *ueCb
927 * @param [out] RgRguDedDatInd *dDatInd
931 PRIVATE S16 rgTomUtlPrepareL2MUlThrpInfo
935 RgRguDedDatInd *dDatInd
938 PRIVATE S16 rgTomUtlPrepareL2MUlThrpInfo(cellCb,ueCb,dDatInd)
941 RgRguDedDatInd *dDatInd;
947 TRC2(rgTomUtlPrepareL2MUlThrpInfo);
949 dDatInd->burstInd = RGU_L2M_UL_BURST_END;
950 for(loop=0;loop<dDatInd->numLch;loop++)
952 lcId=dDatInd->lchData[loop].lcId;
955 lcgId = ueCb->ul.lcCb[lcId - 1].lcgId;
956 if(ueCb->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs > 0)
958 dDatInd->burstInd = RGU_L2M_UL_BURST_START;
969 /** @brief This function is called by rgTOMDatInd. This function invokes the
970 * scheduler with the information of the received Data and any Control Elements
971 * if present. Also it generates Data indications towards the higher layers.
978 * - Retrieves the RaCb with the rnti provided, if it doesnt exist
980 * - If UE exists then update the Schduler with any MAC CEs if present.
981 * - Invoke RAM module to do Msg3 related processing rgRAMProcMsg3
982 * - Loop through the SDU subheaders and invoke either a common data
983 * indication (rgUIMSndCmnDatInd) or dedicated data indication
984 * (rgUIMSndDedDatInd) towards the higher layers.
986 * @param [in] RgCellCb *cellCb
987 * @param [in] RgUeCb *ueCb
988 * @param [in] CmLteRnti rnti
989 * @param [in] RgMacPdu *pdu
990 * @param [out] U32 *lcgBytes
1001 PRIVATE S16 rgTOMUtlProcMsg
1007 Bool *spsToBeActvtd,
1013 PRIVATE S16 rgTOMUtlProcMsg(cellCb, ueCb, pdu, isSpsRnti,spsToBeActvtd,sduSize, slot, lcgBytes)
1018 Bool *spsToBeActvtd;
1023 #else /* LTEMAC_SPS */
1025 PRIVATE S16 rgTOMUtlProcMsg
1034 PRIVATE S16 rgTOMUtlProcMsg(cellCb, ueCb, pdu, slot, lcgBytes)
1043 Inst inst = cellCb->macInst - RG_INST_START;
1045 RgRguCmnDatInd *cDatInd;
1046 RgRguDedDatInd *dDatInd;
1053 // RgInfSpsRelInfo relInfo;
1060 U16 totalBytesRcvd = 0;
1061 U16 sduLen[RGU_MAX_LC] = {0};
1062 U8 qciVal[RGU_MAX_LC] = {0};
1069 /* Moved outside of LTE_L2_MEAS
1070 * scope as this pointer will now be used to
1071 * check for valid Logical Channel ID
1088 TRC2(rgTOMUtlProcMsg)
1094 if(pdu->sduLst.first)
1096 sdu = (RgMacSdu*)(pdu->sduLst.first->node);
1098 if ((sdu->lcId == RG_CCCH_LCID))
1100 /* code for common channel dat indications */
1101 if ((ret = rgAllocShrablSBuf (inst,(Data**)&cDatInd, sizeof(RgRguCmnDatInd))) != ROK)
1105 cDatInd->cellId = cellCb->cellId;
1106 cDatInd->rnti = ueCb->ueId;
1107 /* rg001.101: Corrected lcId value for common data indication */
1108 cDatInd->lcId = cellCb->ulCcchId;
1109 cDatInd->pdu = sdu->mBuf;
1110 SFndLenMsg (sdu->mBuf, &ccchSz);
1111 /* Fix : syed Contention resolution ID copy should consider only
1112 * 6 bytes of information from sdu->mBuf. Incase of CCCH sdu for reest
1113 * message/psuedo reest message, ccchSz can go beyond 6 and can corrupt
1114 * other fields of ueCb. */
1115 if (ccchSz >= RG_CRES_LEN)
1117 SCpyMsgFix (sdu->mBuf, (MsgLen)0, RG_CRES_LEN, ueCb->contResId.resId,
1120 #ifdef XEON_SPECIFIC_CHANGES
1121 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);
1124 rgUIMSndCmnDatInd(inst,cellCb->rguUlSap,cDatInd);
1126 } /* end of common channel processing */
1128 if ((ret = rgAllocShrablSBuf (inst,(Data**)&dDatInd, sizeof(RgRguDedDatInd))) != ROK)
1134 elem = SRngGetWIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
1139 dDatInd = (RgRguDedDatInd *)elem;
1140 cmMemset((U8 *)dDatInd, 0x00, sizeof(RgRguDedDatInd));
1142 dDatInd->cellId = cellCb->cellId;
1143 dDatInd->rnti = ueCb->ueId;
1144 dDatInd->numLch = 0;
1147 ulSf = &cellCb->ulSf[(slot % RG_NUM_SUB_FRAMES)];
1148 if(ulSf->ueUlAllocInfo != NULLP)
1150 for(idx1 = 0; idx1 < ulSf->numUe; idx1++)
1152 if(ulSf->ueUlAllocInfo[idx1].rnti == ueCb->ueId)
1154 numPrb = ulSf->ueUlAllocInfo[idx1].numPrb;
1160 node = pdu->sduLst.first;
1163 sdu = (RgMacSdu*)node->node;
1165 ulLcCb = rgDBMGetUlDedLcCb (ueCb, sdu->lcId);
1169 RLOG_ARG2(L_ERROR,DBG_CELLID,cellCb->cellId,"Unconfigured LCID:%d CRNTI:%d"
1170 ,sdu->lcId,ueCb->ueId);
1171 /* ccpu00128443: Fix for memory leak */
1172 /* Fix : syed Neccessary to set sdu->mBuf = NULLP */
1173 RG_FREE_MSG(sdu->mBuf);
1177 #ifdef RLC_STA_PROC_IN_MAC/* RLC Status PDU Processing */
1179 extern S16 kwProcDlStatusPdu(Pst *udxPst,SuId suId,
1180 CmLteCellId cellId,CmLteRnti rnti,CmLteLcId lcId,Buffer *rlcSdu);
1182 if(ROK == kwProcDlStatusPdu(&(cellCb->rguDlSap->sapCfg.sapPst),
1183 cellCb->rguDlSap->sapCfg.suId,
1184 cellCb->cellId,ueCb->ueId,sdu->lcId,sdu->mBuf))
1186 RG_FREE_MSG(sdu->mBuf);
1193 /* ccpu00116477- Fixed the rgUIMSndDedDatInd condition when we receive 11 sdus in the
1194 * list we are losing 11th sdu and sending the first 10 sdus again which
1195 * is causing the duplicate packets and eNB crashing due to access
1196 * of the freed memory */
1197 if (dDatInd->numLch >= RGU_MAX_LC)
1199 if ((ret = rgUIMSndDedDatInd(inst,ueCb->rguUlSap,dDatInd)) != ROK)
1201 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
1202 "Failed to send datIndication to RGU CRNTI:%d",ueCb->ueId);
1206 if ((ret = rgAllocShrablSBuf (inst,(Data**)&dDatInd, sizeof(RgRguDedDatInd))) != ROK)
1211 elem = SRngGetWIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
1216 dDatInd = (RgRguDedDatInd *)elem;
1217 cmMemset((U8 *)dDatInd, 0x00, sizeof(RgRguDedDatInd));
1219 dDatInd->cellId = cellCb->cellId;
1220 dDatInd->rnti = ueCb->ueId;
1221 dDatInd->numLch = 0;
1223 dDatInd->lchData[dDatInd->numLch].lcId = sdu->lcId;
1224 dDatInd->lchData[dDatInd->numLch].pdu.mBuf[dDatInd->lchData[dDatInd->numLch].pdu.numPdu] = sdu->mBuf;
1225 dDatInd->lchData[dDatInd->numLch].pdu.numPdu++;
1226 lcgId = ulLcCb->lcgId;
1227 SFndLenMsg(sdu->mBuf, &bufSz);
1231 ueCb->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs -= bufSz;
1234 //if ((lcgBytes != NULLP) && (ueCb->ul.lcgArr[lcgId].isGbr == TRUE))
1235 if (lcgBytes != NULLP)
1237 lcgBytes[lcgId] += bufSz;
1242 /* Check if data has come on SPS LC */
1243 /* KWORK_FIX: Modified the index from lcId to lcId-1 for handling lcId 10 properly */
1244 if (ueCb->ul.spsLcId[sdu->lcId-1] == TRUE)
1246 ueCb->ul.spsDatRcvd++;
1251 /* Data rcvd on CRNTI*/
1252 /* Retrieve the LCG ID of the LCID*/
1253 /* SPS LCG has data whose size > SID Size */
1254 /* Activate SPS if data recvd on SPS LCID and size > SID Packet Size */
1255 if((ueCb->ul.spsLcId[sdu->lcId-1] == TRUE) &&
1256 (sdu->len > RG_SPS_SID_PACKET_SIZE))
1258 *spsToBeActvtd = TRUE;
1259 *sduSize = sdu->len;
1266 if(cellCb->qciArray[ulLcCb->qci].mask == TRUE)
1268 sduLen[ulLcCb->qci] = sdu->len;
1269 totalBytesRcvd += sdu->len;
1270 qciVal[ulLcCb->qci] = ulLcCb->qci;
1274 } /* end of while for SubHeaders */
1276 for(idx2 = 0; idx2 < RGU_MAX_LC; idx2++)
1278 if((cellCb->qciArray[qciVal[idx2]].mask == TRUE) &&
1281 cellCb->qciArray[qciVal[idx2]].prbCount +=
1282 ((numPrb * sduLen[idx2]) / totalBytesRcvd);
1286 if(totalBytesRcvd > 0 && qciVal[idx2] > 0)
1288 RG_UPD_GBR_PRB(cellCb, qciVal[idx2], ((numPrb * sduLen[idx2])/totalBytesRcvd));
1293 /*Added for explicit release - start*/
1296 if(isSpsRnti && dDatInd && dDatInd->numLch)
1298 if(ueCb->ul.spsDatRcvd != 0)
1300 ueCb->ul.explRelCntr = 0;
1301 ueCb->ul.spsDatRcvd = 0;
1305 ueCb->ul.explRelCntr++;
1306 if (ueCb->ul.explRelCntr == ueCb->ul.explRelCnt)
1308 ueCb->ul.explRelCntr = 0;
1309 /* Indicate scheduler for explicit release */
1310 cmMemset((U8*)&schPst1, (U8)0, sizeof(Pst));
1311 rgGetPstToInst(&schPst1,inst, cellCb->schInstMap.schInst);
1312 //TODO: commented for compilation without SCH
1314 relInfo.cellSapId = cellCb->schInstMap.cellSapId;
1315 relInfo.cRnti = ueCb->ueId;
1316 relInfo.isExplRel = TRUE;
1317 /* Release indicator is called now through the matrix in the function below */
1318 //TODO: commented for compilation without SCH RgMacSchSpsRel( &schPst1, &relInfo );
1320 ueCb->ul.implRelCntr = 0;
1327 if(ueCb->ul.spsDatRcvd != 0)
1329 //ueCb->ul.implRelCntr = 0;
1330 ueCb->ul.explRelCntr = 0;
1331 ueCb->ul.spsDatRcvd = 0;
1335 /*Added for explicit release - end */
1337 if((dDatInd) && (dDatInd->numLch))
1340 rgTomUtlPrepareL2MUlThrpInfo(cellCb, ueCb,dDatInd);
1342 RG_CALC_TTI_CNT(cellCb, dDatInd->ttiCnt);
1344 if ((ret = rgUIMSndDedDatInd(inst,ueCb->rguUlSap,dDatInd)) != ROK)
1346 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
1347 "Failed to send datIndication to RGU CRNTI:%d",ueCb->ueId);
1352 else if((dDatInd) && (0 == dDatInd->numLch))
1354 /* Free the memory allocated for dDatInd if we
1355 * have no valid LCH PDU to send to RLC.*/
1356 rgFreeSharableSBuf(inst,(Data **)&dDatInd,sizeof(RgRguDedDatInd));
1362 /** @brief This function frees up the RgMacPdu structure that has been
1363 * populated by demux.
1367 * Function: rgTOMUtlInsSchInfo
1368 * - Function frees up the RgMacPdu structure, in case of error it shall
1369 * free up the buffer's present in the different sdu.
1372 * @param [in] RgMacPdu *pdu
1373 * @param [in] Bool *error
1378 PRIVATE S16 rgTOMUtlInsSchInfo
1381 RgInfSfDatInd *sfInfo,
1382 RgInfCeInfo *ceInfo,
1389 PRIVATE S16 rgTOMUtlInsSchInfo (pdu, sfInfo, ceInfo, rnti,spsToBeActvtd,sduSize, lcgBytes)
1391 RgInfSfDatInd *sfInfo;
1392 RgInfCeInfo *ceInfo;
1401 PRIVATE S16 rgTOMUtlInsSchInfo
1404 RgInfSfDatInd *sfInfo,
1405 RgInfCeInfo *ceInfo,
1410 PRIVATE S16 rgTOMUtlInsSchInfo (pdu, sfInfo, ceInfo, rnti, lcgBytes)
1412 RgInfSfDatInd *sfInfo;
1413 RgInfCeInfo *ceInfo;
1420 RgInfUeDatInd *ueInfo;
1424 TRC2(rgTOMUtlInsSchInfo);
1426 RG_TOM_INF_ALLOC(sfInfo, sizeof(RgInfUeDatInd), ueInfo, ret);
1433 ueInfo->rnti = rnti;
1435 ueInfo->ceInfo = *ceInfo;
1436 ueInfo->ueLstEnt.node = (PTR)ueInfo;
1437 for (lcgId = 1, idx = 0; lcgId < RGINF_MAX_LCG_PER_UE; lcgId++)
1439 if (lcgBytes[lcgId] != 0)
1441 /* Only GBR bytes */
1442 ueInfo->lcgInfo[idx].lcgId = lcgId;
1443 ueInfo->lcgInfo[idx++].bytesRcvd = lcgBytes[lcgId];
1444 lcgBytes[lcgId] = 0;
1447 cmLListAdd2Tail(&sfInfo->ueLst, &ueInfo->ueLstEnt);
1449 } /* end of rgTOMUtlInsSchInfo */
1453 * @brief Handler for processing data indication recieved from PHY for UEs.
1457 * Function: rgTOMDatInd
1459 * Handler for processing data indication recieved from PHY for UEs.
1461 * Invoked by: RgLiTfuDatInd of LIM
1464 * For each DataInfo recieved
1465 * - Validate the information received and retrieve cellCb
1466 * Validate cellId, rnti
1467 * - Call De-Mux module to decode the data rgDUXDemuxData
1468 * - If received a CRNTI control element
1469 * - Check if a CCCH SDU is present, if it is return failure
1470 * - Check for the existence of UE, if its isnt present return failure.
1471 * - Delegate the remaining processing to rgTOMUtlProcMsg3 which
1472 * primarily informs the scheduler about the data received and
1473 * generates Data indications towards the higher layer.
1474 * - If only CCCH SDU is present
1475 * - Invoke rgTOMUtlProcMsg3 for further processing.
1476 * - If its a non-Msg3 PDU i.e. received outside of a RA procedure
1477 * - Retrieve the UeCB
1478 * - Validate that the received PDU contains only configured Logical
1480 * - Invoke rgTOMUtlProcDatPdu for further processing. It informs the
1481 * scheduler with the information of the received Data and generates
1482 * DatIndications towards the higher layers.
1484 * @param [in] Inst inst
1485 * @param[in] TfuDatIndInfo *datInd
1491 PUBLIC S16 rgTOMDatInd
1494 TfuDatIndInfo *datInd
1497 PUBLIC S16 rgTOMDatInd(inst,datInd)
1499 TfuDatIndInfo *datInd;
1505 RgUeCb *prevUeCb = NULLP;
1508 RgInfSfDatInd *sfInfo;
1512 TfuDatInfo *datInfo;
1516 Bool isSpsRnti=FALSE;
1518 // RgInfSpsRelInfo relInfo;
1519 Bool spsToBeActvtd = FALSE;
1522 U32 lcgBytes[RGINF_MAX_LCG_PER_UE];
1526 #ifdef STUB_TTI_HANDLING_5GTF
1527 node = datInd->datIndLst.first;
1528 for (;node; node=node->next)
1530 datInfo = (TfuDatInfo*)node->node;
1533 SFndLenMsg(datInfo->mBuf, &len);
1534 rgUlrate_tfu += len;
1535 if (rgUlrate_tfu > 100000)
1537 printf("Sowmya:rgTOMDatInd datInfo->mBuf len =%d rgUlrate_tfu=%d",len,rgUlrate_tfu);
1545 cmMemset((U8 *)&lcgBytes, 0, sizeof(lcgBytes));
1547 tfuSap = &(rgCb[inst].tfuSap);
1549 cellCb = rgCb[inst].cell;
1550 if((cellCb == NULLP) ||
1551 (cellCb->cellId != datInd->cellId))
1554 RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"Unable to get the cellCb for cell");
1557 /* Avoiding memset as all the fields are getting initialized further */
1559 if (rgTOMInfAllocPduEvnt (inst,&sfInfo) != ROK)
1561 err.errType = RGERR_TOM_DATIND;
1562 RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"Unable to Allocate PDU for DUX cell");
1563 node = datInd->datIndLst.first;
1566 cmLListInit(&sfInfo->ueLst);
1567 sfInfo->cellId = datInd->cellId;
1568 sfInfo->timingInfo = datInd->timingInfo;
1569 slot = datInd->timingInfo.slot;
1571 node = datInd->datIndLst.first;
1572 for (;node; node=node->next)
1574 datInfo = (TfuDatInfo*)node->node;
1576 //extern U32 ulrate_tfu;
1578 SFndLenMsg(datInfo->mBuf, &len);
1579 #ifdef STUB_TTI_HANDLING_5GTF
1580 // printf("Sowmya:rgTOMDatInd datInfo->mBuf len =%d",len);
1582 rgUlrate_tfu += len;
1584 grgUlrate_tfu += len;
1587 #ifdef STUB_TTI_HANDLING_5GTF
1588 rgLIMUtlFreeDatIndEvnt(datInd,TRUE);
1590 /* We shall call De-Mux to process the received buffer. We shall try and find
1591 * out the RaCb based on the following -
1592 * 1. If the incoming PDU contained a CCCH SDU i.e. this is message 3.
1593 * 2. If the incoming PDU contained a CRNTI control element, i.e. we should
1594 * have a ueCb also for this
1596 /* Lets allocate the event that needs to be passed to DUX */
1597 if (rgTOMUtlAllocPduEvnt (inst,&pdu) != ROK)
1599 err.errType = RGERR_TOM_DATIND;
1600 RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"Unable to Allocate PDU for DUX cell");
1601 rgTOMInfFreePduEvnt (sfInfo);
1605 if ((ret = rgDUXDemuxData (inst,pdu, &ceInfo,
1606 &datInfo->mBuf, &err)) != ROK)
1609 /* Fix: sriky memory corruption precautions */
1610 rgTOMUtlFreePduEvnt (pdu, TRUE);
1611 err.errType = RGERR_TOM_DATIND;
1612 RLOG_ARG0(L_ERROR,DBG_CELLID,datInd->cellId,"DUX processing failed");
1613 tfuSap->sapSts.numPduDrop++;
1616 /* It could be that a non-msg3 pdu contains a CRNTI Control element. We
1617 * should check for CRNTI CE and if it exists the UECb must exist, also an
1618 * if the CRNTI in the CE and the one with which the message came in are
1619 * different we shall look for an raCb as well.
1622 if (ceInfo.bitMask & RG_CCCH_SDU_PRSNT)
1624 ret = rgTOMProcCCCHSduInDatInd(pdu, prevUeCb, \
1625 cellCb, datInfo, &ceInfo, slot);
1628 rgTOMUtlFreePduEvnt (pdu, TRUE);
1629 err.errType = RGERR_TOM_DATIND;
1630 tfuSap->sapSts.numPduDrop++;
1633 } /* end of Msg3 processing */
1635 else if (ceInfo.bitMask & RG_CRNTI_CE_PRSNT)
1637 ret = rgTOMProcCrntiCEInDatInd(pdu, prevUeCb, \
1638 cellCb, datInfo, &ceInfo, slot);
1641 rgTOMUtlFreePduEvnt (pdu, TRUE);
1642 err.errType = RGERR_TOM_DATIND;
1643 tfuSap->sapSts.numPduDrop++;
1647 } /* end of CRNTI based message */
1650 ueCb = rgDBMGetUeCb (cellCb, datInfo->rnti);
1654 /* Try getting the UE using SPS-RNTI. */
1655 ueCb = rgDBMGetSpsUeCb (cellCb, datInfo->rnti);
1659 /* Increment implrelCntr for an empty transmission */
1660 if (pdu->sduLst.count == 0)
1662 ueCb->ul.implRelCntr++;
1663 if (ueCb->ul.implRelCntr == ueCb->ul.implRelCnt)
1665 /* Indicate scheduler for implicit release */
1666 cmMemset((U8*)&schPst1, (U8)0, sizeof(Pst));
1667 rgGetPstToInst(&schPst1,inst, cellCb->schInstMap.schInst);
1669 ueCb->ul.implRelCntr = 0;
1670 ueCb->ul.explRelCntr = 0;
1672 relInfo.cellSapId = cellCb->schInstMap.cellSapId;
1673 relInfo.cRnti = ueCb->ueId;
1674 relInfo.isExplRel= FALSE;
1675 //TODO: commented for compilation without SCH RgMacSchSpsRel(&schPst1, &relInfo);
1681 /* Reset the implrelCntr */
1682 ueCb->ul.implRelCntr = 0;
1688 /* Perform failure if ueCb is still NULLP */
1689 rgTOMUtlFreePduEvnt (pdu, TRUE);
1690 err.errType = RGERR_TOM_DATIND;
1691 RLOG_ARG1(L_ERROR,DBG_CELLID,datInd->cellId,"RNTI:%d Unable to get the UE CB",
1693 tfuSap->sapSts.numPduDrop++;
1698 rgTOMUtlL2MStoreBufSz(ueCb, &ceInfo);
1699 rgTOML2MCompileActiveLCs (cellCb, ueCb, pdu, &ceInfo);
1702 if ((ret = rgTOMUtlProcMsg(cellCb, ueCb, pdu, isSpsRnti,&spsToBeActvtd,&sduSize, slot, (U32 *)&lcgBytes)) != ROK)
1704 if ((ret = rgTOMUtlProcMsg (cellCb, ueCb, pdu, slot, (U32 *)&lcgBytes)) != ROK)
1705 #endif /* LTEMAC_SPS */
1707 rgTOMUtlFreePduEvnt (pdu, TRUE);
1708 err.errType = RGERR_TOM_DATIND;
1709 RLOG_ARG1(L_ERROR,DBG_CELLID,datInd->cellId,
1710 "Unable to handle Data Indication CRNTI:%d",ueCb->ueId);
1711 tfuSap->sapSts.numPduDrop++;
1718 if(rgTOMUtlInsSchInfo(pdu, sfInfo, &ceInfo, datInfo->rnti,spsToBeActvtd,sduSize, (U32 *)&lcgBytes) != ROK)
1720 if(rgTOMUtlInsSchInfo(pdu, sfInfo, &ceInfo, datInfo->rnti, (U32 *)&lcgBytes) != ROK)
1724 rgTOMInfFreePduEvnt (sfInfo);
1725 rgTOMUtlFreePduEvnt (pdu, FALSE);
1728 /* free up the PDU memory */
1729 rgTOMUtlFreePduEvnt (pdu, FALSE);
1731 /* Free the allocated memory for ueUlAllocInfo here */
1733 if(cellCb->ulSf[(slot % RG_NUM_SUB_FRAMES)].ueUlAllocInfo != NULLP)
1735 /*ccpu00117052 - MOD - Passing double for proper NULLP
1737 rgFreeSBuf(inst,(Data **)&(cellCb->ulSf[(slot % RG_NUM_SUB_FRAMES)].ueUlAllocInfo),
1738 ((cellCb->ulSf[(slot % RG_NUM_SUB_FRAMES)].numUe) * sizeof(RgUeUlAlloc)));
1742 /* Update PRB used for all GBR QCIs to scheduler */
1743 cmMemcpy((U8*) &sfInfo->qcisUlPrbCnt[0],
1744 (U8*) &cellCb->qcisUlPrbCnt[0],
1745 (RGM_MAX_QCI_REPORTS * sizeof(U32)));
1746 /* clear the cellCb ul prb value */
1747 cmMemset((U8*)&cellCb->qcisUlPrbCnt[0], 0,
1748 (RGM_MAX_QCI_REPORTS * sizeof(U32)));
1752 rgGetPstToInst(&schPst, inst,cellCb->schInstMap.schInst);
1753 sfInfo->cellSapId = cellCb->schInstMap.cellSapId;
1754 //TODO: commented for compilation without SCH RgMacSchSfRecp(&schPst, sfInfo);
1759 * @brief Function handles allocation for common channels i.e. BCCH-BCH,
1760 * BCCH-DLSCH, PCCH-DLSCH.
1764 * Function : rgHndlCmnChnl
1766 * This function is invoked from RgSchMacSfAllocReq. This function handles
1767 * allocations made for common channels like BCCH and PCCH.
1770 * 1. If BCCH on BCH has been scheduled, send StatusIndication on RGU.
1771 * 2. If PCCH is scheduled, send StatusIndication on RGU.
1772 * 3. If BCCH on DLSCH has been scheduled and sndStatInd is TRUE, send
1773 * StatusIndication on RGU, else copy the bcch buffer onto the downlink
1777 * @param[in] RgCellCb *cell,
1778 * @param[in] CmLteTimingInfo timingInfo,
1779 * @param[in] RgInfCmnLcInfo *cmnLcInfo,
1780 * @param[in/out] RgErrInfo *err,
1786 PRIVATE S16 rgHndlCmnChnl
1789 CmLteTimingInfo timingInfo,
1790 RgInfCmnLcInfo *cmnLcInfo,
1794 PRIVATE S16 rgHndlCmnChnl(cell, timingInfo, cmnLcInfo, err)
1796 CmLteTimingInfo timingInfo;
1797 RgInfCmnLcInfo *cmnLcInfo;
1801 #if (ERRCLASS & ERRCLS_DEBUG)
1805 RgBcchDlschLcCb *bcch;
1806 #if (ERRCLASS & ERRCLS_DEBUG)
1809 #endif/*RGR_SI_SCH*/
1810 RguCStaIndInfo *staInd;
1812 Inst inst = cell->macInst - RG_INST_START;
1816 dlSf = &cell->subFrms[(timingInfo.slot % RG_NUM_SUB_FRAMES)];
1818 if(cmnLcInfo->bitMask & RGINF_BCH_INFO)
1821 #if (ERRCLASS & ERRCLS_DEBUG)
1822 if(NULLP == (bch = rgDBMGetBcchOnBch(cell)))
1826 if(cmnLcInfo->bchInfo.lcId != bch->lcId)
1832 if (rgAllocShrablSBuf (inst,(Data**)&staInd, sizeof(RguCStaIndInfo)) != ROK)
1834 err->errCause = RGERR_TOM_MEM_EXHAUST;
1837 staInd->cellId = cell->cellId;
1838 staInd->rnti = RG_INVALID_RNTI;
1839 staInd->lcId = cmnLcInfo->bchInfo.lcId;
1840 staInd->transId = (timingInfo.sfn << 8) | (timingInfo.slot);
1841 /* ADD Changes for Downlink UE Timing Optimization */
1842 #ifdef LTEMAC_DLUE_TMGOPTMZ
1843 dlSf->remDatReqCnt++;
1845 if (rgUIMSndCmnStaInd (inst,cell->rguDlSap,staInd) != ROK)
1850 /*Store the received BCH Data in the scheduled subframe*/
1851 dlSf->bch.tb = cmnLcInfo->bchInfo.pdu;
1852 #endif/*RGR_SI_SCH*/
1855 if(cmnLcInfo->bitMask & RGINF_PCCH_INFO)
1857 #if (ERRCLASS & ERRCLS_DEBUG)
1858 if(NULLP == (pcch = rgDBMGetPcch(cell)))
1862 if(cmnLcInfo->pcchInfo.lcId != pcch->lcId)
1868 dlSf->pcch.pdcch.rnti =
1869 cmnLcInfo->pcchInfo.rnti;
1870 dlSf->pcch.pdcch.dci =
1871 cmnLcInfo->pcchInfo.dciInfo;
1873 /* ccpu00132314-ADD-Fill the tx Pwr offset from scheduler */
1874 dlSf->pcch.txPwrOffset = cmnLcInfo->pcchInfo.txPwrOffset;
1876 if (rgAllocShrablSBuf (inst,(Data**)&staInd, sizeof(RguCStaIndInfo)) != ROK)
1878 err->errCause = RGERR_TOM_MEM_EXHAUST;
1881 staInd->cellId = cell->cellId;
1882 staInd->rnti = RG_INVALID_RNTI;
1883 staInd->lcId = cmnLcInfo->pcchInfo.lcId;
1884 staInd->transId = (timingInfo.sfn << 8) | (timingInfo.slot);
1885 /* ADD Changes for Downlink UE Timing Optimization */
1886 #ifdef LTEMAC_DLUE_TMGOPTMZ
1887 dlSf->remDatReqCnt++;
1889 /* for consolidated CmnStaInd calling below function from function
1890 * rgHndlSchedUe once CmnStaInd prepared for all UEs
1892 if (rgUIMSndCmnStaInd (inst,cell->rguDlSap,staInd) != ROK)
1898 if(cmnLcInfo->bitMask & RGINF_BCCH_INFO)
1900 dlSf->bcch.pdcch.rnti =
1901 cmnLcInfo->bcchInfo.rnti;
1902 dlSf->bcch.pdcch.dci =
1903 cmnLcInfo->bcchInfo.dciInfo;
1905 /* ccpu00132314-ADD-Fill the tx Pwr offset from scheduler */
1906 dlSf->bcch.txPwrOffset = cmnLcInfo->bcchInfo.txPwrOffset;
1910 (bcch=rgDBMGetBcchOnDlsch(cell,cmnLcInfo->bcchInfo.lcId)))
1914 if(TRUE == cmnLcInfo->bcchInfo.sndStatInd)
1916 RG_FREE_MSG(bcch->tb);
1917 if (rgAllocShrablSBuf (inst,(Data**)&staInd,
1918 sizeof(RguCStaIndInfo)) != ROK)
1920 err->errCause = RGERR_TOM_MEM_EXHAUST;
1923 staInd->cellId = cell->cellId;
1924 staInd->rnti = RG_INVALID_RNTI;
1925 staInd->lcId = cmnLcInfo->bcchInfo.lcId;
1926 staInd->transId = (timingInfo.sfn << 8) | (timingInfo.slot);
1927 /* ADD Changes for Downlink UE Timing Optimization */
1928 #ifdef LTEMAC_DLUE_TMGOPTMZ
1929 dlSf->remDatReqCnt++;
1931 if (rgUIMSndCmnStaInd (inst,cell->rguDlSap,staInd) != ROK)
1938 SCpyMsgMsg(bcch->tb, RG_GET_MEM_REGION(rgCb[inst]),
1939 RG_GET_MEM_POOL(rgCb[inst]), &dlSf->bcch.tb);
1942 /*Store the received BCCH Data in the scheduled subframe*/
1943 dlSf->bcch.tb = cmnLcInfo->bcchInfo.pdu;
1944 #endif/*RGR_SI_SCH*/
1948 } /* end of rgHndlCmnChnl */
1951 * @brief Function for handling allocations for dedicated channels for a
1956 * Function : rgHndlSchdUe
1958 * This function shall be invoked whenever scheduler is done with the
1959 * allocations of dedicated channels for a subframe. Invoked by the function
1960 * RgSchMacSfAllocReq.
1962 * Processing steps :
1963 * 1. Loops through the list of UE's scheduled looking for the corresponding
1965 * 2. Finds the corresponding HARQ process.
1966 * 3. Invokes the DHM function to issue StatusIndications on RGU.
1969 * @param[in] RgCellCb *cell,
1970 * @param[in] CmLteTimingInfo timingInfo,
1971 * @param[in] RgInfUeInfo *ueInfo
1972 * @param[in/out] RgErrInfo *err
1978 PRIVATE S16 rgHndlSchdUe
1981 CmLteTimingInfo timingInfo,
1982 RgInfUeInfo *ueInfo,
1986 PRIVATE S16 rgHndlSchdUe(cell, timingInfo, ueInfo, err) /* laa_ut_fix */
1988 CmLteTimingInfo timingInfo;
1989 RgInfUeInfo *ueInfo;
1996 if(NULLP == ueInfo->allocInfo)
2001 rgDHMSndConsolidatedStaInd(cell, ueInfo, timingInfo, err);
2004 } /* end of rgHndlSchdUe */
2008 * @brief Function for handling Uplink allocations for Ue for a
2013 * Function : rgHndlUlUeInfo
2015 * @param[in] RgCellCb *cell,
2016 * @param[in] CmLteTimingInfo timingInfo,
2017 * @param[in] RgInfUlUeInfo *ueInfo
2023 PRIVATE S16 rgHndlUlUeInfo
2026 CmLteTimingInfo timingInfo,
2027 RgInfUlUeInfo *ueInfo
2030 PRIVATE S16 rgHndlUlUeInfo(cell, timingInfo, ueInfo)
2032 CmLteTimingInfo timingInfo;
2033 RgInfUlUeInfo *ueInfo;
2036 Inst inst = cell->macInst - RG_INST_START;
2041 TRC2(rgHndlUlUeInfo)
2043 ulSf = &cell->ulSf[(timingInfo.slot % RGSCH_NUM_SUB_FRAMES)];
2045 /* rg003.301-MOD- Corrected the purifier memory leak */
2046 if (ulSf->numUe != ueInfo->numUes)
2048 if (ulSf->ueUlAllocInfo)
2050 rgFreeSBuf(inst,(Data **)&(ulSf->ueUlAllocInfo),
2051 ulSf->numUe * sizeof(RgUeUlAlloc));
2054 #ifdef XEON_SPECIFIC_CHANGES
2055 CM_MEAS_TIME((cell->crntTime.slot % RGSCH_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MEAS_FREE);
2056 CM_ADD_INFO((cell->crntTime.slot % RGSCH_NUM_SUB_FRAMES), CM_DBG_MEAS_FREE, ulSf->numUe);
2058 ulSf->numUe = ueInfo->numUes;
2059 if((ulSf->ueUlAllocInfo == NULLP) && (ueInfo->numUes > 0))
2061 /* Allocate memory for ulAllocInfo */
2062 if((ret = rgAllocSBuf(inst,(Data**)&(cell->ulSf[(timingInfo.slot % RGSCH_NUM_SUB_FRAMES)].
2063 ueUlAllocInfo), ueInfo->numUes * sizeof(RgUeUlAlloc))) != ROK)
2068 #ifdef XEON_SPECIFIC_CHANGES
2069 CM_MEAS_TIME((cell->crntTime.slot % RGSCH_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MEAS_ALLOC);
2070 CM_ADD_INFO((cell->crntTime.slot % RGSCH_NUM_SUB_FRAMES), CM_DBG_MEAS_ALLOC, ueInfo->numUes);
2072 if (ulSf->ueUlAllocInfo != NULLP)
2074 for(idx = 0; idx < ueInfo->numUes; idx++)
2076 ulSf->ueUlAllocInfo[idx].rnti = ueInfo->ulAllocInfo[idx].rnti;
2077 ulSf->ueUlAllocInfo[idx].numPrb = ueInfo->ulAllocInfo[idx].numPrb;
2080 RGCPYTIMEINFO(timingInfo, ulSf->schdTime);
2082 } /* end of rgHndlUlUeInfo */
2085 * @brief Function for handling RaResp request received from scheduler to MAC
2089 * Function : rgTOMRlsSf
2091 * This function shall be invoked whenever scheduler is done with the
2092 * allocations of random access responses for a subframe.
2093 * This shall invoke RAM to create ueCbs for all the rapIds allocated and
2094 * shall invoke MUX to create RAR PDUs for raRntis allocated.
2097 * @param[in] Inst inst
2098 * @param[in] CmLteCellId cellId,
2099 * @param[in] CmLteTimingInfo timingInfo,
2100 * @param[in] RaRespInfo *rarInfo
2105 PUBLIC Void rgTOMRlsSf
2111 PUBLIC Void rgTOMRlsSf(dlSf)
2120 if(dlSf->txDone == FALSE)
2122 RLOG0(L_ERROR, "SUBFRAME Not pushed to the PHY");
2124 if (dlSf->bch.tb != NULLP)
2126 RG_FREE_MSG(dlSf->bch.tb);
2128 if (dlSf->bcch.tb != NULLP)
2130 RG_FREE_MSG(dlSf->bcch.tb);
2132 if (dlSf->pcch.tb != NULLP)
2134 RG_FREE_MSG(dlSf->pcch.tb);
2137 rgTOMEmtcRlsSf(dlSf);
2139 for(idx=0; idx < dlSf->numRaRsp; idx++)
2141 RG_FREE_MSG(dlSf->raRsp[idx].rar);
2144 /* ADD Changes for Downlink UE Timing Optimization */
2145 #ifdef LTEMAC_DLUE_TMGOPTMZ
2146 dlSf->remDatReqCnt = 0;
2147 /* Fix[ccpu00126310]: Tracks Data Requests from RLC for both loosely and tight coupled
2149 dlSf->statIndDone = FALSE;
2151 if (dlSf->tbs.count)
2156 RGDBGERRNEW(inst, (rgPBuf(inst),
2157 "Error Stale TBs in Subframes TBS list\n"));
2158 node = dlSf->tbs.first;
2161 hqP = (RgDlHqProcCb*)node->node;
2165 for(i=0;i< RG_MAX_TB_PER_UE;i++)
2167 if (hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sf == dlSf)
2169 cmLListDelFrm(&dlSf->tbs, &(hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sfLnk));
2170 hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sfLnk.node = NULLP;
2171 printf("\n rgTOMRlsSf:: hqP %p \n", (Void *)hqP);
2173 hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sf = NULLP;
2178 /*arjun: check if dlSf laaTb list has to be freed???*/
2179 cmLListInit(&dlSf->tbs);
2180 dlSf->txDone = FALSE;
2186 * @brief Function is called by the scheduler once it has completed the
2187 * allocation for the subframe.
2191 * Function : rgHndlFlowCntrl
2192 * This function should fill and send Flow control
2196 * @param[in] Pst *cell
2197 * @param[in] RgInfSfAlloc *sfInfo Carries all the allocation
2203 PUBLIC S16 rgHndlFlowCntrl
2206 RgInfSfAlloc *sfInfo
2209 PUBLIC S16 rgHndlFlowCntrl(cell, sfInfo)
2211 RgInfSfAlloc *sfInfo;
2214 RguFlowCntrlInd *flowCntrlInd;
2218 TRC3(rgHndlFlowCntrl);
2220 pst = &cell->rguDlSap->sapCfg.sapPst;
2221 /* flowCntrlInd is alloced in cell init time and will be re-used throughout */
2222 flowCntrlInd = cell->flowCntrlInd;
2223 flowCntrlInd->cellId = sfInfo->cellId;
2224 flowCntrlInd->numUes = sfInfo->flowCntrlInfo.numUes;
2226 for (ueIdx = 0; ueIdx < sfInfo->flowCntrlInfo.numUes; ueIdx++)
2228 flowCntrlInd->ueFlowCntrlInfo[ueIdx].ueId = sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].ueId;
2229 flowCntrlInd->ueFlowCntrlInfo[ueIdx].numLcs = sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].numLcs;
2231 for (lcIdx = 0; lcIdx < RGINF_MAX_NUM_DED_LC; lcIdx++)
2233 flowCntrlInd->ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].lcId =
2234 sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].lcId;
2235 flowCntrlInd->ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].pktAdmitCnt =
2236 sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].pktAdmitCnt;
2238 flowCntrlInd->ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].maxBo4FlowCtrl =
2239 sfInfo->flowCntrlInfo.ueFlowCntrlInfo[ueIdx].lcInfo[lcIdx].maxBo4FlowCtrl;
2242 RgUiRguFlowCntrlInd(pst, cell->rguDlSap->sapCfg.spId,flowCntrlInd); /* TODO: Rishi confirm if the suId and pst pointer is correct */
2246 * @brief Function is called by the scheduler once it has completed the
2247 * allocation for the subframe.
2251 * Function : RgSchMacSfAllocReq
2253 * This function shall be invoked whenever scheduler is done with the
2254 * allocations of for a subframe. The sfInfo carries all the allocation
2255 * details for the common channels, RA responses and dedicated channel
2258 * Processing steps :
2259 * 1. Reset the information present in the downlink subframe that is
2261 * 2. Handle common channel allocations
2262 * 3. Handle RA Response allocations
2263 * 4. Handle dedicated channel allocations.
2265 * @param[in] Pst *pst
2266 * @param[in] RgInfSfAlloc *sfInfo Carries all the allocation
2272 PUBLIC S16 RgSchMacSfAllocReq
2275 RgInfSfAlloc *sfInfo
2278 PUBLIC S16 RgSchMacSfAllocReq(pst, sfInfo)
2280 RgInfSfAlloc *sfInfo;
2286 VOLATILE U32 startTime=0;
2289 TRC2(RgSchMacSfAllocReq)
2291 RG_IS_INST_VALID(pst->dstInst);
2292 inst = pst->dstInst - RG_INST_START;
2294 SStartTask(&startTime, PID_MAC_SF_ALLOC_REQ);
2301 if((cell = rgCb[inst].cell) == NULLP)
2303 RLOG_ARG0(L_ERROR,DBG_CELLID,sfInfo->cellId, "No cellCb found with cell");
2307 dlSf = &cell->subFrms[(sfInfo->timingInfo.slot % RG_NUM_SUB_FRAMES)];
2309 rgTOMRlsSf(inst,dlSf);
2310 dlSf->schdTime = sfInfo->timingInfo;
2313 rgLaaInitTbInfoLst(cell);
2316 /* Fix : syed Ignore Failure Returns and continue processing.
2317 * Incomplete processing results in state sync loss between MAC-SCH. */
2319 if(TRUE == cell->emtcEnable)
2321 rgEmtcHndl(cell, sfInfo);
2324 rgHndlCmnChnl(cell, sfInfo->timingInfo, &sfInfo->cmnLcInfo, &err);
2326 rgHndlRaResp(cell, sfInfo->timingInfo, &sfInfo->rarInfo, &err);
2329 #ifdef XEON_SPECIFIC_CHANGES
2330 CM_MEAS_TIME((cell->crntTime.slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_B4_UE_SCHD);
2332 rgHndlSchdUe(cell, sfInfo->timingInfo, &sfInfo->ueInfo, &err);
2333 #ifdef XEON_SPECIFIC_CHANGES
2334 CM_MEAS_TIME((cell->crntTime.slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_UE_SCHD);
2336 rgLaaChkAndReqTbs(dlSf,cell, inst);
2339 rgHndlSchdUe(cell, sfInfo->timingInfo, &sfInfo->ueInfo, &err);
2343 if(rgHndlUlUeInfo(cell, sfInfo->ulUeInfo.timingInfo,
2344 &sfInfo->ulUeInfo) != ROK)
2349 #ifdef XEON_SPECIFIC_CHANGES
2350 CM_MEAS_TIME((cell->crntTime.slot % RG_NUM_SUB_FRAMES), CM_DBG_MAC_TTI_IND, CM_DBG_MAC_MEAS);
2352 /* Fix[ccpu00126310]: Tracks Data Requests from RLC for both loosely and tight coupled
2356 /* Added the handling for pushing down
2357 * TFU Data request in the retransmission only scenario.*/
2358 #ifdef LTEMAC_DLUE_TMGOPTMZ
2359 dlSf->statIndDone = TRUE;
2360 /* Fix [ccpu00126310]: Tracks Data Requests from RLC for both loosely and tight coupled
2362 if(!(dlSf->txDone) &&
2364 (TRUE == rgLaaChkAllRxTbs(dlSf)) &&
2366 (0 == dlSf->remDatReqCnt) && (dlSf->statIndDone) &&
2367 (RG_TIMEINFO_SAME(cell->crntTime, dlSf->schdTime)))
2369 /*This is the case of rettransmission, so no need
2370 * to wait for TTI Ind to push TFU Data Request. Send
2372 if (ROK != rgTOMUtlProcDlSf (dlSf, cell, &err))
2374 RLOG_ARG0(L_ERROR,DBG_CELLID,cell->cellId,"Unable to process downlink subframe for cell");
2375 err.errType = RGERR_ROM_DEDDATREQ;
2377 /* Mark this frame as sent */
2378 dlSf->txDone = TRUE;
2381 if (sfInfo->flowCntrlInfo.numUes > 0)
2383 rgHndlFlowCntrl(cell,sfInfo);
2386 SStopTask(startTime, PID_MAC_SF_ALLOC_REQ);
2388 } /* end of RgSchMacSfAllocReq */
2390 * @brief Handler for processing data indication recieved from PHY for UEs.
2394 * Function: rgTOMProcCrntiCEInDatInd
2396 * Handler for processing data indication recieved from PHY for UEs.
2398 * Invoked by: RgLiTfuDatInd of LIM
2401 * For each DataInfo recieved
2402 * - If received a CRNTI control element
2403 * - Check if a CCCH SDU is present, if it is return failure
2404 * - Check for the existence of UE, if its isnt present return failure.
2405 * - Delegate the remaining processing to rgTOMUtlProcMsg3 which
2406 * primarily informs the scheduler about the data received and
2407 * generates Data indications towards the higher layer.
2409 * @param RgMacPdu *pdu,
2410 * @param RgUeCb *prevUeCb,
2411 * @param RgCellCb *cellCb,
2412 * @param TfuDatInfo *datInfo,
2413 * @param RgInfCeInfo *ceInfo
2419 PRIVATE S16 rgTOMProcCrntiCEInDatInd
2424 TfuDatInfo *datInfo,
2425 RgInfCeInfo *ceInfo,
2429 PRIVATE S16 rgTOMProcCrntiCEInDatInd( pdu, prevUeCb, cellCb, datInfo, ceInfo, slot)
2433 TfuDatInfo *datInfo;
2434 RgInfCeInfo *ceInfo;
2438 RgUeCb *ueCb = NULLP;
2439 Inst inst = cellCb->macInst - RG_INST_START;
2447 TRC2(rgTOMProcCrntiCEInDatInd)
2453 ueCb = rgDBMGetUeCbFromRachLst (cellCb, datInfo->rnti);
2457 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2458 "RNTI:%d Received MSG3 with CRNTI,unable to find ueCb", ceInfo->ces.cRnti);
2462 prevUeCb = rgDBMGetUeCb (cellCb, ceInfo->ces.cRnti);
2463 if (prevUeCb == NULLP)
2465 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2466 "RNTI:%d Received MSG3 with CRNTI,unable to find ueCb", ceInfo->ces.cRnti);
2469 RLOG_ARG2(L_DEBUG,DBG_CELLID,cellCb->cellId,
2470 "CRNTI CE(%d) received through tmpCrnti(%d)",
2471 ceInfo->ces.cRnti, datInfo->rnti);
2472 rgDBMDelUeCbFromRachLst(cellCb, ueCb);
2473 rgRAMFreeUeCb(inst,ueCb);
2476 if ((rgTOMUtlProcMsg(cellCb, ueCb, pdu, FALSE,&spsToBeActvtd,&sduSize, slot, NULLP)) != ROK)
2478 if ((rgTOMUtlProcMsg (cellCb, ueCb, pdu, slot, NULLP)) != ROK)
2479 #endif /* LTEMAC_SPS */
2481 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2482 "RNTI:%d Processing for MSG3 failed",datInfo->rnti);
2488 * @brief Handler for processing data indication recieved from PHY for UEs.
2492 * Function: rgTOMProcCCCHSduInDatInd
2494 * Handler for processing data indication recieved from PHY for UEs.
2496 * Invoked by: RgLiTfuDatInd of LIM
2499 * For each DataInfo recieved
2500 * - If only CCCH SDU is present
2501 * - Invoke rgTOMUtlProcMsg3 for further processing.
2502 * - If its a non-Msg3 PDU i.e. received outside of a RA procedure
2503 * - Retrieve the UeCB
2504 * - Validate that the received PDU contains only configured Logical
2506 * - Invoke rgTOMUtlProcDatPdu for further processing. It informs the
2507 * scheduler with the information of the received Data and generates
2508 * DatIndications towards the higher layers.
2510 * @param TfuDatIndInfo *datInd
2511 * @param RgMacPdu *pdu,
2512 * @param RgUeCb *prevUeCb,
2513 * @param RgCellCb *cellCb,
2514 * @param TfuDatInfo *datInfo,
2515 * @param RgInfCeInfo *ceInfo
2521 PRIVATE S16 rgTOMProcCCCHSduInDatInd
2526 TfuDatInfo *datInfo,
2527 RgInfCeInfo *ceInfo,
2531 PRIVATE S16 rgTOMProcCCCHSduInDatInd( pdu, prevUeCb, cellCb, datInfo, ceInfo, slot)
2535 TfuDatInfo *datInfo;
2536 RgInfCeInfo *ceInfo;
2540 RgUeCb *ueCb = NULLP;
2541 Inst inst = cellCb->macInst - RG_INST_START;
2549 TRC2(rgTOMProcCCCHSduInDatInd)
2555 if (ceInfo->bitMask & RG_CRNTI_CE_PRSNT)
2557 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2558 "CRNTI:%d Received MSG3 with CCCH",ceInfo->ces.cRnti);
2562 ueCb = rgDBMGetUeCbFromRachLst (cellCb, datInfo->rnti);
2566 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,
2567 "RNTI:%d Processing for MSG3 failed", datInfo->rnti);
2570 /* Fix: syed Drop any duplicate Msg3(CCCH Sdu) */
2571 if (ueCb->dl.hqEnt.numHqProcs)
2573 /* HqE is already initialized by a previuos Msg3 */
2574 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"RNTI:%d Processing for MSG3 failed. Duplicate "
2575 "MSG3 received. Dropping", datInfo->rnti);
2579 if(rgDHMHqEntInit(inst,&ueCb->dl.hqEnt,
2580 cellCb->maxDlHqProcPerUe) != ROK)
2582 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"RNTI:%d Harq Initialization failed ",
2586 RLOG_ARG1(L_DEBUG,DBG_CELLID,cellCb->cellId,
2587 "CCCH SDU received through tmpCrnti(%d)",datInfo->rnti);
2589 if ((rgTOMUtlProcMsg(cellCb, ueCb, pdu, FALSE,&spsToBeActvtd,&sduSize, slot, NULLP)) != ROK)
2591 if ((rgTOMUtlProcMsg (cellCb, ueCb, pdu, slot, NULLP)) != ROK)
2592 #endif /* LTEMAC_SPS */
2594 RLOG_ARG1(L_ERROR,DBG_CELLID,cellCb->cellId,"RNTI:%d Processing for MSG3 failed",
2603 /** @brief This function captures the BSR value from Control Element
2604 * Info structure and updates the effective Buffer size into the
2605 * corresponding LCG ID.
2609 * Function: rgTOMUtlL2MStoreBufSz
2612 * - update/append the Data structure based on BSR type
2614 * @param [in] RgUeCb *ueCb
2615 * @param [in] RgInfCeInfo *ceInfo
2620 PRIVATE S16 rgTOMUtlL2MStoreBufSz
2626 PRIVATE S16 rgTOMUtlL2MStoreBufSz (ueCb, ceInfo)
2628 RgInfCeInfo *ceInfo;
2633 TRC2(rgTOMUtlL2MStoreBufSz);
2635 if(ceInfo->bitMask & RG_TRUNC_BSR_CE_PRSNT)
2637 lcgId = ((ceInfo->ces.bsr.truncBsr >> 6) & 0x03);
2638 bsr = ceInfo->ces.bsr.truncBsr & 0x3F;
2639 ueCb->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs = rgLwrBsrTbl[bsr];
2641 else if(ceInfo->bitMask & RG_SHORT_BSR_CE_PRSNT)
2643 lcgId = ((ceInfo->ces.bsr.shortBsr >> 6) & 0x03);
2644 bsr = ceInfo->ces.bsr.shortBsr & 0x3F;
2645 ueCb->ul.lcgArr[lcgId].lcgBsInfo.outStndngBs = rgLwrBsrTbl[bsr];
2648 else if(ceInfo->bitMask & RG_LONG_BSR_CE_PRSNT)
2650 ueCb->ul.lcgArr[0].lcgBsInfo.outStndngBs = rgLwrBsrTbl[ceInfo->ces.bsr.longBsr.bs1];
2651 ueCb->ul.lcgArr[1].lcgBsInfo.outStndngBs = rgLwrBsrTbl[ceInfo->ces.bsr.longBsr.bs2];
2652 ueCb->ul.lcgArr[2].lcgBsInfo.outStndngBs = rgLwrBsrTbl[ceInfo->ces.bsr.longBsr.bs3];
2653 ueCb->ul.lcgArr[3].lcgBsInfo.outStndngBs = rgLwrBsrTbl[ceInfo->ces.bsr.longBsr.bs4];
2656 } /* end of rgTOMUtlL2MStoreBufSz*/
2658 /** @brief : Compiles list of LCs received in UL data for DTCH RBs
2662 * @param [in] RgCellCb *cellCb
2663 * @param [in] RgUeCb *ueCb
2664 * @param [in] CmLteRnti rnti
2665 * @param [in] RgMacPdu *pdu
2672 PRIVATE Void rgTOML2MCompileActiveLCs
2680 PRIVATE Void rgTOML2MCompileActiveLCs(cellCb, ueCb, pdu, ceInfo)
2684 RgInfCeInfo *ceInfo;
2691 TRC2(rgTOML2MCompileActiveLCs)
2693 node = pdu->sduLst.first;
2696 sdu = (RgMacSdu*)node->node;
2698 if ((ulLcCb = rgDBMGetUlDedLcCb(ueCb, sdu->lcId)), ulLcCb != NULLP)
2700 if (ulLcCb->lcgId != 0)
2702 ceInfo->bitMask |= RG_ACTIVE_LC_PRSNT;
2703 ceInfo->ulActLCs[ulLcCb->lcId - 1] = TRUE;
2714 /**********************************************************************
2717 **********************************************************************/