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 **********************************************************************/
32 @brief APIs related to Downlink HARQ.
35 static const char* RLOG_MODULE_NAME="MAC";
36 static int RLOG_FILE_ID=279;
37 static int RLOG_MODULE_ID=4096;
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 service interface */
47 #include "cm5.h" /* common timers */
48 #include "cm_hash.h" /* common hash list */
49 #include "cm_mblk.h" /* common memory link list library */
50 #include "cm_llist.h" /* common linked list library */
51 #include "cm_err.h" /* common error */
52 #include "cm_lte.h" /* common LTE */
57 #include "rg_sch_inf.h"
62 /* header/extern include files (.x) */
63 #include "gen.x" /* general layer */
64 #include "ssi.x" /* system service interface */
68 #include "cm5.x" /* common timers */
69 #include "cm_lib.x" /* common library */
70 #include "cm_hash.x" /* common hash list */
71 #include "cm_llist.x" /* common linked list library */
72 #include "cm_mblk.x" /* memory management */
73 #include "cm_tkns.x" /* common tokens */
74 #include "cm_lte.x" /* common LTE */
79 #include "rg_sch_inf.x"
80 #include "rg_prg.x" /* PRG interface typedefs */
87 #include "ss_msg.x" /* MAC includes */
89 //EXTERN S16 ssGetDBufOfSize(Region region,Size size,Buffer **dBuf);
90 //void prc_trace_format_string(UINT32 group_mask, UINT16 level, const char *format, ...);
96 EXTERN S16 SIncMsgRef(Buffer *srcBuf,Region dstRegion, Pool dstPool,Buffer **dstBuf);
98 PRIVATE Void rgDHMBldTfuDatReq ARGS((RgCellCb *cellCb, RgDlSf *dlSf, RgDlHqProcCb *hqP,
99 RgTfuDatReqPduInfo *datReq));
102 PUBLIC S16 rgDHMFreeHqProcTB
110 /* forward references */
113 * @brief This function initializes the DL HARQ Entity of UE
117 * Function: rgDHMHqEntInit
118 * Purpose: This function initializes the DL HARQ entity of
119 * UE control block. This is performed at the time
120 * of creating UE control block.
122 * Invoked by: configuration module
124 * @param[in] Inst inst
125 * @param[in] RgCellCb* cell
126 * @param[in] RgUeCb* ue
133 PUBLIC S16 rgDHMHqEntInit
140 PUBLIC S16 rgDHMHqEntInit(inst,hqE, maxHqProcs)
148 Buffer *hdrDBuf = NULLP;
149 Buffer *ceDBuf = NULLP;
154 hqE->numHqProcs = maxHqProcs;
155 /* for each harq process */
156 for (idx1 = 0; idx1 < hqE->numHqProcs; idx1++)
158 if (rgAllocSBuf(inst,(Data **)&(hqE->procs[idx1]),sizeof(RgDlHqProcCb)) != ROK)
162 rgFreeSBuf(inst,(Data **)&(hqE->procs[idx1]), sizeof(RgDlHqProcCb));
164 RLOG0(L_ERROR, "Memory Alloc Failure for RgDlHqProcCb");
168 hqE->procs[idx1]->procId = idx1;
169 for(idx2 = 0; idx2 < RG_MAX_TB_PER_UE; idx2++)
172 hqE->procs[idx1]->tbInfo[idx2].tb = NULLP;
175 /* L2 optimization for mUe/Tti: Allocating buffers for macHdr, macCes
176 * and macPadding. These buffers shall not be released by MAC/CL.
177 * However, Only rPtr and wPtr will be reset while release of hq proc
179 tmpMBuf = hqE->procs[idx1]->tbInfo[idx2].tb.macHdr;
180 rgGetMsg(inst, &tmpMBuf);
181 RG_ADD_DBuf(hdrDBuf, RG_MAC_HDR_SIZE, tmpMBuf);
182 hqE->procs[idx1]->tbInfo[idx2].tb.macHdr = tmpMBuf;
183 macHeader[idx2] = MacPtrAddress;
185 tmpMBuf = hqE->procs[idx1]->tbInfo[idx2].tb.macCes;
186 rgGetMsg(inst, &tmpMBuf);
187 RG_ADD_DBuf(ceDBuf, RG_MAC_CE_SIZE, tmpMBuf);
188 hqE->procs[idx1]->tbInfo[idx2].tb.macCes = tmpMBuf;
190 hqE->procs[idx1]->tbInfo[idx2].tb.padSize = 0;
193 hqE->procs[idx1]->tbId[idx2] = RGU_INVALID_TBID;
197 cmLListInit(&hqE->savedProcLst[idx1]);
202 } /* rgDHMHqEntInit */
205 * @brief This function releases a HARQ process
209 * Function: rgDHMUeReset
210 * Purpose: This function resets TB in each HarqProc.
212 * Invoked by: CFG UE Reset
214 * @param[in] RgDlHqProc *hqP
219 PUBLIC Void rgDHMUeReset
225 PUBLIC Void rgDHMUeReset(cell, hqE)
236 /* Free all the TB memory associated with HARQ */
237 for (i=0; i < hqE->numHqProcs; i++)
239 rgDHMRlsHqProcTB(cell, hqE->procs[i], 1);
240 rgDHMRlsHqProcTB(cell, hqE->procs[i], 2);
243 rgDHMFreeSavedHqP((cell->macInst - RG_INST_START), hqE, i);
251 * @brief This function defers shared memory buffer
252 * freeing out of the critical RT path.
256 * Function: rgDHMHdlBufFree
257 * Purpose: To defer shared memory freeing post
258 * critical path. Defer as many if defer queue
259 * is full then release instantly.
261 * Invoked by: HARQ TB Release.
267 PUBLIC Void rgDHMHdlBufFree
273 PUBLIC Void rgDHMHdlBufFree(Inst inst, Buffer **mBuf)
277 RgCb *rgCbP = &rgCb[inst];
278 TRC2(rgDHMHdlBufFree)
280 if (rgCbP->bufCnt < RG_MAX_DFRD_FREE_BUFS)
284 rgCbP->bufToFree[rgCbP->bufCnt] = *mBuf;
296 * @brief This function is called to release the
297 * shared memory of the HARQ TBs outside
298 * the critical RT path.
302 * Function: rgDHMFreeTbBufs
303 * Purpose: This function is called to release the
304 * shared memory of the HARQ TBs outside
305 * the critical RT path.
307 * 1. Job of releasing TBs is shared across TTIs
308 * Invoked by: MAC every TTI
314 PUBLIC Void rgDHMFreeTbBufs
319 PUBLIC Void rgDHMFreeTbBufs(inst)
323 RgCb *rgCbP = &rgCb[inst];
324 U8 start = rgCbP->bufCnt;
327 TRC2(rgDHMFreeTbBufs)
329 if (rgCbP->bufCnt < RG_MAX_FREE_BUFS_PERTTI)
335 end = rgCbP->bufCnt - RG_MAX_FREE_BUFS_PERTTI;
340 SPutMsg(rgCbP->bufToFree[start]);
344 } /* rgDHMFreeTbBufs */
347 PUBLIC Void rgDHMFreeAllTbBufs
352 PUBLIC Void rgDHMFreeAllTbBufs(inst)
356 RgCb *rgCbP = &rgCb[inst];
357 U8 start = rgCbP->bufCnt;
360 TRC2(rgDHMFreeAllTbBufs)
365 SPutMsg(rgCbP->bufToFree[start]);
369 } /* rgDHMFreeTbBufs */
373 * @brief This function releases a HARQ process
377 * Function: rgDHMRlsHqProcTB
378 * Purpose: This function returns a HARQ process to HARQ Entity
379 * in the DL direction.
381 * 1. Add the HARQ process to the free queue.
382 * Invoked by: scheduler and HARQ processing
384 * @param[in] RgDlHqProc *hqP
389 PUBLIC S16 rgDHMRlsHqProcTB
396 PUBLIC S16 rgDHMRlsHqProcTB(cell, hqP, tbIndex)
404 RgTfuDatReqTbInfo *tb; /* TB to be sent to CL/PHY*/
405 // U32 lchIdx, pduIdx;
408 TRC2(rgDHMRlsHqProcTB)
410 if((tbIndex > RG_MAX_TB_PER_UE) ||
416 hqP->tbInfo[tbIndex-1].numSchLch = 0;
418 if (hqP->tbInfo[tbIndex-1].tb)
420 rgDHMHdlBufFree(cell->macInst - RG_INST_START, &hqP->tbInfo[tbIndex-1].tb);
423 /* L2 Optimization for mUe/Tti: macHdr, macCes and macPad mBuf pointers
424 * shall not be released. However, Inorder to release harq info/TB info,
425 * just Resetting rPtr and wPtr of these mbufs to db_base
427 tb = &(hqP->tbInfo[tbIndex-1].tb);
428 if (tb->tbPres == TRUE)
433 hqP->tbInfo[tbIndex-1].schdTa.pres = FALSE;
435 hqP->tbInfo[tbIndex -1].sCellActCe.pres = FALSE;
438 /* Decrementing might lead to roundoff error in case of say UE reset
439 * where all the HqProcs irrespective whether in use are called for rls.
440 * Hence to avoid the same shift operator is being used. */
441 hqP->numOfTBs = hqP->numOfTBs >> 1;
442 for(idx = 0; idx < 2; idx++)
444 if (hqP->tbInfo[tbIndex-1].sfLnkInfo[idx].sfLnk.node != NULLP)
446 cmLListDelFrm(&hqP->tbInfo[tbIndex-1].sfLnkInfo[idx].sf->tbs,
447 &(hqP->tbInfo[tbIndex-1].sfLnkInfo[idx].sfLnk));
448 hqP->tbInfo[tbIndex-1].sfLnkInfo[idx].sfLnk.node = (PTR)NULLP;
449 printf("\nrgDHMRlsHqProcTB:: hqP %p \n", (Void *)hqP);
451 hqP->tbInfo[tbIndex-1].sfLnkInfo[idx].sf = NULLP;
453 /* Fix : syed It is better to reset these feilds
454 * corruption avoidance */
455 hqP->tbInfo[tbIndex-1].tbSz = 0;
456 hqP->tbInfo[tbIndex-1].contResCe = NOTPRSNT;
457 hqP->tbInfo[tbIndex-1].contResId = NULLP;
460 } /* rgDHMRlsHqProc */
463 * @brief This function gets HARQ process with the given Id
467 * Function: rgDHMGetHqProcFrmId
468 * Purpose: This function returns the HARQ process with the given ID.
471 * @param[in] RgUeCb *ue
473 * @param[in] RgDlHqProc **hqP
475 * -# ROK if successful
476 * -# RFAILED otherwise
480 PUBLIC S16 rgDHMGetHqProcFrmId
487 PUBLIC S16 rgDHMGetHqProcFrmId(ue, idx, hqP)
493 TRC2(rgDHMGetHqProcFrmId)
495 /* Pick the proc based on the index provided */
496 *hqP = (ue->dl.hqEnt.procs[idx]);
499 } /* rgDHMGetHqProcFrmId */
501 /*PRIVATE U32 dataAvl; */
503 * @brief Handler for sending data to PHY
507 * Function : rgDHMSndDatReq
509 * This function shall send the MAC PDU built for the UE to TOM
510 * when invoked as part of TTI processing and keep track of the number of
511 * transmissions for this TB.
514 * @param[in] RgCellCb *cell
515 * @param[in] RgDlHqProcCb *hqE
516 * @param[out] RgErrInfo *err
522 PUBLIC S16 rgDHMSndDatReq
526 RgTfuDatReqInfo *datInfo,
531 PUBLIC S16 rgDHMSndDatReq(cellCb, dlSf, datInfo, hqP, err)
534 RgTfuDatReqInfo *datInfo;
540 Inst inst = cellCb->macInst - RG_INST_START;
541 RgTfuDatReqPduInfo *datReq;
543 /*Added this variable to figure out that whether this UE data
544 has to be inclueded in the TFU Data request.*/
550 for(i=0;i< RG_MAX_TB_PER_UE;i++)
552 /* printf("\nDHMSndDatReq1: Rnti %d dlSfSchdTime(sfn sf) : (%d %d)\n"
553 "macCell(sfn sf): (%d %d) tbTimingInfo(sfn sf): (%d %d)\n"
554 "dlSf %p dlSf->tbs.count %d hqp %p tb %p\n",
555 hqP->tbInfo[i].pdcch.rnti,
556 dlSf->schdTime.sfn, dlSf->schdTime.subframe,
557 cellCb->crntTime.sfn, cellCb->crntTime.subframe,
558 hqP->tbInfo[i].timingInfo.sfn,
559 hqP->tbInfo[i].timingInfo.subframe,
560 (Void *)dlSf, dlSf->tbs.count,
562 (Void *)hqP->tbInfo[i].tb);*/
563 /* Mukesh :: in case of rpepetiton this is not rerd*/
564 if (hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.subframe % 2].sf == dlSf)
566 /* Check if data from RLC had been received and got muxed. */
568 if (hqP->tbInfo[i].tb == NULLP)
570 if (!(hqP->tbInfo[i].tb.tbPres))
574 if (hqP->tbInfo[i].schdTa.pres == TRUE ||
575 hqP->tbInfo[i].contResCe == PRSNT_NODEF)
577 if ((hqP->tbInfo[i].schdTa.pres == TRUE) ||
578 (hqP->tbInfo[i].contResCe == PRSNT_NODEF) ||
579 (hqP->tbInfo[i].sCellActCe.pres == TRUE))
582 /* Data not received but ta needs to be sent. */
583 /* MUX TA and send it */
584 bldPdu.datReq = NULLP;
585 bldPdu.reqType = EVTTFUTTIIND;
586 bldPdu.schdTbSz = hqP->tbInfo[i].tbSz;
587 bldPdu.ta = hqP->tbInfo[i].schdTa;
589 bldPdu.sCellActCe= hqP->tbInfo[i].sCellActCe;
591 /* changes for CR timer implementation*/
592 bldPdu.contResId = hqP->tbInfo[i].contResId;
593 if (ROK != rgMUXBldPdu(inst,&bldPdu, &(hqP->tbInfo[i].tb), err))
595 RLOG1(L_ERROR, "MUXing failed for: MacInst %d", inst);
596 RLOG4(L_ERROR, "MUXing failed for: time: %d/%d\
597 procId %d ueId %d", hqP->tbInfo[i].timingInfo.sfn,
598 hqP->tbInfo[i].timingInfo.subframe, hqP->procId,
599 hqP->tbInfo[i].pdcch.rnti);
606 #ifdef LTEMAC_RGU_PAD
607 /* Data not received from RLC. Padding at MAC */
608 bldPdu.datReq = NULLP;
609 bldPdu.reqType = EVTTFUTTIIND;
610 bldPdu.schdTbSz = hqP->tbInfo[i].tbSz;
611 bldPdu.ta = hqP->tbInfo[i].schdTa;
613 bldPdu.sCellActCe= hqP->tbInfo[i].sCellActCe;
616 bldPdu.contResId = NULLP;
618 if (ROK != rgMUXBldPdu(inst,&bldPdu, &(hqP->tbInfo[i].tb), err))
620 RLOG1(L_ERROR, "MUXing failed for: MacInst %d", inst);
621 RLOG4(L_ERROR, "MUXing failed for: time: %d/%d\
622 procId %d ueId %d", hqP->tbInfo[i].timingInfo.sfn,
623 hqP->tbInfo[i].timingInfo.subframe, hqP->procId,
624 hqP->tbInfo[i].pdcch.rnti);
629 /*Padding is not done so data for this UE will not be
644 /*If Data/Padding is not available for UE, then we can not include
645 any Data for this UE in TFU Data Request.*/
648 /*Free up the HARQ process for this allocation.*/
649 /* Release First TB, as this would be anyway there*/
650 rgDHMRlsHqProcTB(cellCb, hqP, 1);
651 if(2 == hqP->numOfTBs)
653 rgDHMRlsHqProcTB(cellCb, hqP, 2);
659 if (rgGetEventMem(inst,(Ptr *)&datReq, sizeof(TfuDatReqPduInfo),
660 &(datInfo->memCp)) != ROK)
664 /* Fill the TFU Dat Req with information from Harq Proc */
666 rgDHMBldTfuDatReq(cellCb, dlSf, hqP, datReq);
668 /* MS_WORKAROUND for ccpu00122894 */
669 for(i=0;i< RG_MAX_TB_PER_UE;i++)
671 if (hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.subframe % 2].sf == dlSf)
673 cmLListDelFrm(&dlSf->tbs, &(hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.subframe % 2].sfLnk));
674 hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.subframe % 2].sfLnk.node = NULLP;
677 hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.subframe % 2].sf = NULLP;
680 cmLListAdd2Tail(&datInfo->pdus, &(datReq->lnk));
681 datReq->lnk.node = (PTR)datReq;
684 } /* rgDHMSndDatReq */
687 * @brief Function to handle RGU datReq received from ROM
691 * Function : rgDHMHndlDedDatReq
693 * This function shall act on the datReq received on RGU. It shall
694 * store the data IDs for all the logical channels and get the MAC
698 * @param[in] Inst inst
699 * @param[in] RgDlHqProcCb *hqProc
700 * @param[in] RgRguDedDatReq *datReq
701 * @param[out] RgErrInfo *err
707 PUBLIC S16 rgDHMHndlDedDatReq
710 RgDlHqProcCb *hqProc,
711 RgRguDDatReqPerUe *datReq,
716 PUBLIC S16 rgDHMHndlDedDatReq(inst,hqProc, datReq, dlSf, err)
718 RgDlHqProcCb *hqProc;
719 RgRguDDatReqPerUe *datReq;
730 RgTfuDatReqTbInfo *tb;
733 TRC2(rgDHMHndlDedDatReq);
735 tbIndex = (U8)(datReq->transId & 0x03);
736 /* Accept all the data requests even if delayed in case nothing
737 * has been sent earlier on the harq proc.
739 if((datReq->nmbOfTbs > RG_MAX_TB_PER_UE) ||
742 /* release corresponding TBs from SF tbs List */
743 for(j=0;j<datReq->nmbOfTbs;j++)
745 if (!(tbIndex & (j+1)))
749 rgDHMRlsHqProcTB(rgCb[inst].cell, hqProc, (U8)(j+1));
754 for(i=0;i<datReq->nmbOfTbs;i++)
756 /* tbIndex 01 corresponds to presence of 1st TB
757 * 10 corresponds 2nd TB
758 * 11 corresponds two TBs of UE */
759 if (!(tbIndex & (i+1)))
763 if (hqProc->tbInfo[i].sfLnkInfo[dlSf->schdTime.subframe % 2].sfLnk.node == NULLP)
765 /* release corresponding TBs from SF tbs List */
766 for(j=0;j<datReq->nmbOfTbs;j++)
768 if (!(tbIndex & (j+1)))
772 rgDHMRlsHqProcTB(rgCb[inst].cell, hqProc, (U8)(j+1));
773 printf("\nrgDHMHndlDedDatReq:: hqP %p \n", (Void *)hqProc);
779 RG_FREE_MSG(hqProc->tbInfo[i].tb);
780 /* L2 optimization for mUe/Tti: Pre-allocated mBuf pointers(macHdr,
781 * macCes and MacPad) of harq TB need to be reset to db_base
784 tb = &hqProc->tbInfo[i].tb;
785 if (tb->tbPres == TRUE)
790 bldPdu.datReq = datReq;
791 bldPdu.reqType = EVTRGUDDATREQ;
792 bldPdu.schdTbSz = hqProc->tbInfo[i].tbSz;
793 bldPdu.tbIndex = i+1;
794 bldPdu.ta = hqProc->tbInfo[i].schdTa;
796 bldPdu.sCellActCe= hqProc->tbInfo[i].sCellActCe;
798 bldPdu.contResId = NULLP;
800 /* Store tbId from RLC in DDatRequest */
801 hqProc->tbId[i] = datReq->datReqTb[i].tbId;
804 hqProc->status[i] = FALSE;
806 if(rgMUXBldPdu(inst,&bldPdu, &(hqProc->tbInfo[i].tb), err) != ROK)
808 RLOG1(L_ERROR, "MUXing failed for: MacInst %d", inst);
809 RLOG4(L_ERROR, "MUXing failed for: time: %d/%d\
810 procId %d ueId %d", hqProc->tbInfo[i].timingInfo.sfn,
811 hqProc->tbInfo[i].timingInfo.subframe, hqProc->procId,
812 hqProc->tbInfo[i].pdcch.rnti);
814 /* release corresponding TBs from SF tbs List */
815 for(j=0;j<datReq->nmbOfTbs;j++)
817 if (!(tbIndex & (j+1)))
821 rgDHMRlsHqProcTB(rgCb[inst].cell, hqProc, (U8)(j+1));
826 SFndLenMsg(hqProc->tbInfo[i].tb, &len);
830 } /* rgDHMHndlDedDatReq */
833 * @brief Function to handle RGU datReq received from ROM
837 * Function : rgDHMHndlCmnDatReq
839 * This function shall act on the datReq received on RGU. It shall
840 * store the data IDs for all the logical channels and get the MAC
844 * @param[in] Inst inst
845 * @param[in] RgDlHqProcCb *hqProc
846 * @param[in] RgRguCmnDatReq *datReq
847 * @param[out] RgErrInfo *err
853 PUBLIC S16 rgDHMHndlCmnDatReq
856 RgDlHqProcCb *hqProc,
857 RgRguCmnDatReq *datReq,
861 PUBLIC S16 rgDHMHndlCmnDatReq(inst,hqProc, datReq, err)
863 RgDlHqProcCb *hqProc;
864 RgRguCmnDatReq *datReq;
871 TRC2(rgDHMHndlCmnDatReq)
874 if (hqProc->tbInfo[0].tb != NULLP)
876 /* If numLch is non zero means HQ Proc is busy*/
877 if (hqProc->tbInfo[0].tb.tbPres)
880 /* datReq discarded. Generate an alarm */
881 rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_HARQ);
882 rgLMMStaInd(inst,LCM_CATEGORY_PROTOCOL, LCM_EVENT_UI_INV_EVT,
883 LRG_CAUSE_HQ_PROC_BUSY, &dgn);
887 bldPdu.datReq = datReq;
888 bldPdu.reqType = EVTRGUCDATREQ;
889 bldPdu.schdTbSz = hqProc->tbInfo[0].tbSz;
890 bldPdu.ta = hqProc->tbInfo[0].schdTa;
892 bldPdu.sCellActCe= hqProc->tbInfo[0].sCellActCe;
895 bldPdu.contResId = hqProc->tbInfo[0].contResId;
897 if(rgMUXBldPdu(inst,&bldPdu, &(hqProc->tbInfo[0].tb), err) != ROK)
899 RLOG1(L_ERROR, "MUXing failed for: MacInst %d", inst);
900 RLOG4(L_ERROR, "MUXing failed for: time: %d/%d\
901 procId %d ueId %d", hqProc->tbInfo[0].timingInfo.sfn,
902 hqProc->tbInfo[0].timingInfo.subframe, hqProc->procId,
903 hqProc->tbInfo[0].pdcch.rnti);
905 RG_FREE_MSG(datReq->pdu);
910 } /* rgDHMHndlCmnDatReq */
913 * @brief Function to get consolidate grants and send consolidated grant to RLC
917 * Function : rgDHMSndConsolidatedStaInd
919 * This function shall be invoked by Scheduler to trigger DHM to send a
920 * consolidated status indication of all UE scheduled in a TTI as well as
921 * send consolidated CStaInd for MSG4 and for all common channels(PCCH,
922 * if RGR_SI_SCH is not defined then it includes BCH and BCCH also)
925 * @param[in] RgCellCb *cell
926 * @param[in] RgInfUeInfo *ueInfo,
927 * @param[in] CmLteTimingInfo timingInfo,
928 * @param[out] RgErrInfo err
929 * @param[in] RguCStaIndInfo *cStaInd
936 PUBLIC S16 rgDHMSndConsolidatedStaInd
940 CmLteTimingInfo timingInfo,
944 PUBLIC S16 rgDHMSndConsolidatedStaInd(cell, ueInfo, timingInfo, err)
947 CmLteTimingInfo timingInfo;
951 SuId rguDlSpId;/*need to use spID instead of suID*/
956 RgDlSf *dlSf = &cell->subFrms[(timingInfo.subframe % RG_NUM_SUB_FRAMES)];
957 Inst inst = cell->macInst - RG_INST_START;
958 // Bool isDStaReqrd = FALSE;
959 RgRguDedStaInd *dStaInd[rgCb[inst].numRguSaps] ;
960 RgUpSapCb *rguDlSap[rgCb[inst].numRguSaps];
965 RgInfUeAlloc *allocInfo;
969 Bool hqPAdded = FALSE;
972 RgTfuDatReqTbInfo *tb; /* TB to be sent to CL/PHY*/
975 TRC2(rgDHMSndConsolidatedStaInd)
976 cmMemset ((U8 *)dStaInd, 0, (sizeof(RgRguDedStaInd *) * rgCb[inst].numRguSaps));
977 cmMemset ((U8 *)rguDlSap, 0, (sizeof(RgUpSapCb *) * rgCb[inst].numRguSaps));
979 /* Send StaInd for the scheduled UEs */
980 for(ueIdx = 0; ueIdx < ueInfo->numUes; ueIdx++)
985 if((ue=rgDBMGetUeCb (cell, ueInfo->allocInfo[ueIdx].rnti)) == NULLP)
987 /* Check in RachLst */
988 if((ue=rgDBMGetUeCbFromRachLst (cell,
989 ueInfo->allocInfo[ueIdx].rnti)) == NULLP)
991 RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId,"CRNTI:%d No ueCb found",
992 ueInfo->allocInfo[ueIdx].rnti);
993 /*Fix: If one UE is not present dont return, look for the next.*/
999 rgDHMGetHqProcFrmId(ue,ueInfo->allocInfo[ueIdx].hqProcId,&hqP);
1000 allocInfo = &ueInfo->allocInfo[ueIdx];
1003 /* Fix : syed Avoid sending data for a RETX
1004 * if initial TX data processing was unsuccessful */
1005 if((allocInfo->tbInfo[0].isReTx == TRUE) &&
1006 (hqP->tbInfo[0].tbSz == 0))
1008 RLOG_ARG2(L_ERROR,DBG_CELLID,cell->cellId,
1009 "CRNTI:%d RETX hqP(%d) tb(0) for a failed New Tx",
1010 allocInfo->rnti, hqP->procId);
1013 if((allocInfo->tbInfo[1].isReTx == TRUE) &&
1014 (hqP->tbInfo[1].tbSz == 0))
1016 RLOG_ARG2(L_ERROR,DBG_CELLID,cell->cellId,
1017 "CRNTI:%d RETX hqP(%d) tb(1) for a failed New Tx",
1018 allocInfo->rnti, hqP->procId);
1022 if(ue->rguDlSap != NULLP)
1024 rguDlSpId = ue->rguDlSap->sapCfg.spId;
1026 {/* UeCb is from rachList */
1027 rguDlSpId = cell->rguDlSap->sapCfg.spId;
1031 for(idx=allocInfo->tbStrtIdx;((idx-allocInfo->tbStrtIdx) <\
1032 allocInfo->nmbOfTBs); idx++)
1034 RguCStaIndInfo *cStaInd;
1036 /* LTE_ADV_FLAG_REMOVED_START */
1037 hqP->tbInfo[idx].isEnbSFR = allocInfo->isEnbSFR;
1038 /* update pA value */
1039 hqP->tbInfo[idx].pa = allocInfo->pa;
1040 /* LTE_ADV_FLAG_REMOVED_END */
1043 hqP->numOfTBs = allocInfo->nmbOfTBs;
1044 hqP->tbInfo[idx].sfLnkInfo[dlSf->schdTime.subframe % 2].sfLnk.node = (PTR)hqP;
1045 hqP->tbInfo[idx].sfLnkInfo[dlSf->schdTime.subframe % 2].sf = dlSf;
1046 cmLListAdd2Tail(&dlSf->tbs,&(hqP->tbInfo[idx].sfLnkInfo[dlSf->schdTime.subframe % 2].sfLnk));
1047 /* Changes as part of performance testing*/
1048 /* hqP->numOfTBs++;*/
1049 hqP->tbInfo[idx].doa = allocInfo->doa;
1050 hqP->tbInfo[idx].txMode = allocInfo->txMode;
1051 hqP->tbInfo[idx].puschRptUsd = allocInfo->puschRptUsd;
1052 hqP->tbInfo[idx].puschPmiInfo = allocInfo->puschPmiInfo;
1054 hqP->tbInfo[idx].pdcch.rnti = allocInfo->pdcchRnti;
1056 hqP->tbInfo[idx].pdcch.rnti = allocInfo->rnti;
1058 if(allocInfo->tbInfo[idx].isReTx == TRUE)
1060 hqP->tbInfo[idx].pdcch.dci = allocInfo->dciInfo;
1064 hqP->tbInfo[idx].timingInfo = timingInfo;
1065 hqP->tbInfo[idx].pdcch.dci = allocInfo->dciInfo;
1067 RG_FREE_MSG(hqP->tbInfo[idx].tb);
1069 /* L2 optimization for mUe/Tti: Pre-allocated mBuf pointers(macHdr,
1070 * macCes and MacPad) of harq TB need to be reset to db_base
1072 tb = &(hqP->tbInfo[idx].tb);
1073 if (tb->tbPres == TRUE)
1078 hqP->tbInfo[idx].tbSz = allocInfo->tbInfo[idx].schdTbSz;
1080 hqP->tbInfo[idx].schdTa.pres = allocInfo->tbInfo[idx].ta.pres;
1081 hqP->tbInfo[idx].schdTa.val = allocInfo->tbInfo[idx].ta.val;
1084 hqP->tbInfo[idx].sCellActCe.pres = allocInfo->tbInfo[idx].sCellActCe.pres;
1085 hqP->tbInfo[idx].sCellActCe.val = allocInfo->tbInfo[idx].sCellActCe.val;
1089 if(( hqPAdded == TRUE) || (ROK == rgLaaPushHqPToScellLst(allocInfo,cell,timingInfo)))
1095 if (allocInfo->tbInfo[idx].schdDat[0].lcId == RG_CCCH_LCID)
1098 RG_FREE_MSG(hqP->tbInfo[idx].tb);
1100 /* L2 optimization for mUe/Tti: Pre-allocated mBuf pointers(macHdr,
1101 * macCes and MacPad) of harq TB need to be reset to db_base
1103 tb = &(hqP->tbInfo[idx].tb);
1105 if (tb->tbPres == TRUE)
1110 hqP->tbInfo[0].contResCe = allocInfo->tbInfo[0].contResCe;
1111 if(allocInfo->tbInfo[0].contResCe)
1113 hqP->tbInfo[0].contResId = &ue->contResId;
1117 if(allocInfo->tbInfo[idx].numSchLch == 0)
1119 RLOG_ARG2(L_DEBUG,DBG_CELLID,cell->cellId,
1120 "UEID:%d MSG4 with only contResId hqP(%d)",
1123 hqP->tbInfo[idx].numSchLch = 0;
1127 /* Increamenting the tbIndex instead of
1128 assigning it to constant */
1132 hqP->tbInfo[idx].numSchLch = 1;
1133 hqP->tbInfo[idx].schdData[0].lcId =
1134 allocInfo->tbInfo[idx].schdDat[0].lcId;
1135 hqP->tbInfo[idx].schdData[0].schdSz =
1136 allocInfo->tbInfo[idx].schdDat[0].numBytes;
1138 // if(cStaInd == NULLP)
1140 if ((rgAllocShrablSBuf(inst,(Data**)&cStaInd, sizeof(RguCStaIndInfo))) != ROK)
1142 err->errType = RGERR_DHM_SND_STA_IND;
1143 err->errCause = RG_DHM_MEM_ALLOC_FAIL;
1148 idx1 = (hqP->procId << 2) | tbIndex;
1150 cStaInd->cellId = cell->cellId;
1151 cStaInd->rnti = allocInfo->rnti;
1152 cStaInd->lcId = cell->dlCcchId;
1153 cStaInd->transId = (timingInfo.sfn << 16) |
1154 (timingInfo.subframe << 8) | idx1;
1155 /* ADD Changes for Downlink UE Timing Optimization */
1156 #ifdef LTEMAC_DLUE_TMGOPTMZ
1157 dlSf->remDatReqCnt++;
1159 RLOG_ARG3(L_DEBUG,DBG_CELLID,cell->cellId,
1160 "RNTI:%d UE:MSG4 grant for CCCH hqP(%d) LCID:%d",
1164 /* Fix : syed Avoid return param for interface prim and
1165 * proceed for other UEs. For the failed UE, MAC shall
1167 rgUIMSndCmnStaInd(cell->macInst,cell->rguDlSap,cStaInd);
1174 RG_FREE_MSG(hqP->tbInfo[idx].tb);
1176 /* L2 optimization for mUe/Tti: Pre-allocated mBuf pointers(macHdr,
1177 * macCes and MacPad) of harq TB need to be reset to db_base
1179 tb = &(hqP->tbInfo[idx].tb);
1180 if (tb->tbPres == TRUE)
1186 if((NULLP == dStaInd[rguDlSpId]) && (allocInfo->tbInfo[idx].numSchLch))
1188 if ((rgAllocShrablSBuf (inst,(Data**)&dStaInd[rguDlSpId], sizeof(RguDStaIndInfo))) != ROK)
1190 err->errType = RGERR_DHM_SND_STA_IND;
1191 err->errCause = RG_DHM_MEM_ALLOC_FAIL;
1192 /* Need to return as memory allocation will fail for other UEs also*/
1195 dStaInd[rguDlSpId]->nmbOfUeGrantPerTti = 0;
1196 rguDlSap[rguDlSpId] = ue->rguDlSap;
1201 lcIdx < allocInfo->tbInfo[idx].numSchLch; lcIdx++)
1203 hqP->tbInfo[idx].schdData[lcIdx].lcId =
1204 allocInfo->tbInfo[idx].schdDat[lcIdx].lcId;
1205 if (hqP->tbInfo[idx].schdData[lcIdx].lcId == 0)
1207 RLOG_ARG2(L_ERROR,DBG_CELLID,cell->cellId,
1208 "CCCH grant in DStaInd for LCID:%d CRNTI:%d",
1209 hqP->tbInfo[idx].schdData[lcIdx].lcId,allocInfo->rnti);
1211 hqP->tbInfo[idx].schdData[lcIdx].schdSz =
1212 allocInfo->tbInfo[idx].schdDat[lcIdx].numBytes;
1213 if(dStaInd[rguDlSpId])
1215 dStaInd[rguDlSpId]->staInd[dStaInd[rguDlSpId]->nmbOfUeGrantPerTti].staIndTb[idx].\
1216 lchStaInd[lcIdx].lcId = allocInfo->tbInfo[idx].\
1217 schdDat[lcIdx].lcId;
1218 dStaInd[rguDlSpId]->staInd[dStaInd[rguDlSpId]->nmbOfUeGrantPerTti].staIndTb[idx].\
1219 lchStaInd[lcIdx].totBufSize = allocInfo->tbInfo[idx].\
1220 schdDat[lcIdx].numBytes;
1223 lchBufSize+=allocInfo->tbInfo[idx].schdDat[lcIdx].numBytes;
1225 hqP->tbInfo[idx].numSchLch =
1226 allocInfo->tbInfo[idx].numSchLch;
1227 if(dStaInd[rguDlSpId])
1229 dStaInd[rguDlSpId]->staInd[dStaInd[rguDlSpId]->nmbOfUeGrantPerTti].staIndTb[idx].nmbLch =
1230 allocInfo->tbInfo[idx].numSchLch;
1232 dStaInd[rguDlSpId]->staInd[dStaInd[rguDlSpId]->nmbOfUeGrantPerTti].staIndTb[idx].tbId =
1239 //if((dStaInd) && (tbIndex) && (isDStaReqrd == TRUE))
1240 if((dStaInd[rguDlSpId]) && (tbIndex))
1242 idx1 = (hqP->procId << 2) | tbIndex;
1243 /* Create RguDStaInd struct and send to UIM */
1244 dStaInd[rguDlSpId]->staInd[dStaInd[rguDlSpId]->nmbOfUeGrantPerTti].rnti = allocInfo->rnti;
1246 dStaInd->transId = (hqP->timingInfo.sfn << 16) |
1247 (hqP->timingInfo.subframe << 8) | hqP->procId;
1249 dStaInd[rguDlSpId]->staInd[dStaInd[rguDlSpId]->nmbOfUeGrantPerTti].transId = (timingInfo.sfn << 16) |
1250 (timingInfo.subframe << 8) | idx1;
1251 dStaInd[rguDlSpId]->staInd[dStaInd[rguDlSpId]->nmbOfUeGrantPerTti].nmbOfTbs = hqP->numOfTBs;
1253 dStaInd[rguDlSpId]->staInd[dStaInd[rguDlSpId]->nmbOfUeGrantPerTti].fillCtrlPdu = allocInfo->fillCtrlPdu;
1255 /*increment num of UE as staInd is prepared for it */
1256 dStaInd[rguDlSpId]->nmbOfUeGrantPerTti++;
1257 /* ADD Changes for Downlink UE Timing Optimization */
1258 #ifdef LTEMAC_DLUE_TMGOPTMZ
1259 dlSf->remDatReqCnt++;
1262 //isDStaReqrd = FALSE;
1266 for(idx = 0; idx < rgCb[inst].numRguSaps ; idx++)
1268 if(dStaInd[idx] != NULLP)
1270 dStaInd[idx]->cellId = cell->cellId;
1271 /* Fix : syed Avoid return param for interface prim and
1272 * proceed for other UEs. For the failed UE, MAC shall
1274 rgUIMSndDedStaInd(inst,rguDlSap[idx],dStaInd[idx]);
1277 if(staIndCnt == activeSapCnt)
1278 break;/* all valid staind are considered */
1283 } /* rgDHMSndConsolidatedStaInd */
1287 * @brief Function to handle building the TFU Data Request
1291 * Function : rgDHMBldTfuDatReq
1293 * This function builds the TFU Data Request with the details
1294 * present in HARQ Process.
1296 * @param[in] RgDlHqProcCb *hqP
1297 * @param[out] TfuDatReqPduInfo *datReq
1303 PRIVATE Void rgDHMBldTfuDatReq
1308 RgTfuDatReqPduInfo *datReq
1311 PRIVATE Void rgDHMBldTfuDatReq(cellCb, dlSf, hqP, datReq)
1315 RgTfuDatReqPduInfo *datReq;
1320 #if !(!(defined TENB_ACC) && !(defined LTE_PAL_ENB))
1322 #elif defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD)
1332 TRC2(rgDHMBldTfuDatReq)
1334 datReq->nmbOfTBs = 0;
1336 #if !(!(defined TENB_ACC) && !(defined LTE_PAL_ENB))
1337 inst = cellCb->macInst - RG_INST_START;
1338 #elif defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD)
1339 inst = cellCb->macInst - RG_INST_START;
1342 /*MS_WORKAROUND for ccpu00123904*/
1343 datReq->isTApres = FALSE;
1344 #ifdef TFU_ALLOC_EVENT_NO_INIT
1346 datReq->mBuf[0] = 0;
1347 datReq->mBuf[1] = 0;
1351 for(i=0;i<RG_MAX_TB_PER_UE;i++)
1354 if ((hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.subframe % 2].sf == dlSf) &&
1355 (hqP->tbInfo[i].tb != NULLP))
1357 if ((hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.subframe % 2].sf == dlSf) &&
1358 RgUtlIsTbMuxed(&(hqP->tbInfo[i].tb)))
1362 datReq->rnti = hqP->tbInfo[i].pdcch.rnti;
1363 datReq->dciInfo = hqP->tbInfo[i].pdcch.dci;
1364 datReq->doa = hqP->tbInfo[i].doa;
1365 datReq->transMode = hqP->tbInfo[i].txMode;
1366 datReq->puschRptUsd = hqP->tbInfo[i].puschRptUsd;
1367 datReq->puschPmiInfo = hqP->tbInfo[i].puschPmiInfo;
1368 /*MS_WORKAROUND for ccpu00123904*/
1369 if (hqP->tbInfo[i].schdTa.pres)
1371 datReq->isTApres = TRUE;
1374 /* update pA value */
1375 datReq->pa = hqP->tbInfo[i].pa;
1377 /* LTE_ADV_FLAG_REMOVED_START */
1378 datReq->isEnbSFR = hqP->tbInfo[i].isEnbSFR;
1379 /* LTE_ADV_FLAG_REMOVED_END */
1381 #if (!(defined TENB_ACC) && !(defined LTE_PAL_ENB)) /* ABHI */ /* This is only temp fix. It needs to be removed
1382 after rebasing to MAC CCB */
1384 datReq->mBuf[i] = hqP->tbInfo[i].tb;
1386 /* Intel Tdd- Commenting out the Optimization for direct Access of
1388 /*Proper clean-up needed as this needs long stability tests
1390 #if defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD)
1391 SIncMsgRef(hqP->tbInfo[i].tb, RG_GET_MEM_REGION(rgCb[inst]),
1392 RG_GET_MEM_POOL(rgCb[inst]), &datReq->mBuf[i]);
1394 datReq->mBuf[i] = hqP->tbInfo[i].tb;
1398 SIncMsgRef(hqP->tbInfo[i].tb, RG_GET_MEM_REGION(rgCb[inst]),
1399 RG_GET_MEM_POOL(rgCb[inst]), &datReq->mBuf[i]);
1403 if(SFndLenMsg(datReq->mBuf[i], &dbgBufLen))
1407 RLOG_ARG4(L_ERROR,DBG_CELLID,cellCb->cellId,
1408 "RNTI:%d SFN:%d subframe:%d tbIdx:%d Sdu Length 0 ",
1410 hqP->tbInfo[i].timingInfo.sfn,
1411 hqP->tbInfo[i].timingInfo.subframe,i);
1412 RLOG_ARG3(L_ERROR,DBG_CELLID,cellCb->cellId,
1413 "taPres [%d] numOfTbs [%d] format[%d]",
1416 datReq->dciInfo.format);
1421 /* L2 optimization for mUe/Tti: Removing SIncMsgRef to avoid additional
1422 * mBuf allocation. MAC header, MAC Ces, MAC PDU per LCH per TB Per UE
1423 * and MAC padding Mbufs are being sent to CL. Populating these Ptrs
1424 * From TB Info to TfuDatReq
1426 datReq->tbInfo[i].tbPres = TRUE;
1427 datReq->tbInfo[i].tbSize = hqP->tbInfo[i].tbSz;
1428 datReq->tbInfo[i].macHdr = hqP->tbInfo[i].tb.macHdr;
1429 datReq->tbInfo[i].macCes = hqP->tbInfo[i].tb.macCes;
1430 datReq->tbInfo[i].numLch = hqP->tbInfo[i].tb.numLch;
1431 for(lchIdx = 0; lchIdx < hqP->tbInfo[i].tb.numLch; lchIdx++)
1433 datReq->tbInfo[i].lchInfo[lchIdx].numPdu = hqP->tbInfo[i].tb.\
1434 lchInfo[lchIdx].numPdu;
1435 for(pduIdx = 0; pduIdx < hqP->tbInfo[i].tb.lchInfo[lchIdx].numPdu;\
1438 datReq->tbInfo[i].lchInfo[lchIdx].mBuf[pduIdx] =
1439 hqP->tbInfo[i].tb.lchInfo[lchIdx].mBuf[pduIdx];
1442 // datReq->tbInfo[i].macPad = hqP->tbInfo[i].tb.macPad;
1443 datReq->tbInfo[i].padSize = hqP->tbInfo[i].tb.padSize;
1444 // prc_trace_format_string(0x40,3,"TfuDatReq:RNTI=%d TbIdx=%d TbSize=%d PdSz=(%d) macHdraddr: (%p) macCEAddr: (%p) noLch=(%d)",datReq->rnti, i,
1445 // hqP->tbInfo[i].tbSz, datReq->tbInfo[i].padSize, datReq->tbInfo[i].macHdr, datReq->tbInfo[i].macCes, datReq->tbInfo[i].numLch);
1452 } /* rgDHMBldTfuDatReq */
1457 * @brief This function releases a HARQ process
1461 * Function: rgDHMFreeHqProcTB
1462 * Purpose: This function returns a HARQ process to HARQ Entity
1463 * in the DL direction.
1465 * 1. Add the HARQ process to the free queue.
1466 * Invoked by: scheduler and HARQ processing
1468 * @param[in] RgDlHqProc *hqP
1473 PUBLIC S16 rgDHMFreeHqProcTB
1479 PUBLIC S16 rgDHMFreeHqProcTB(hqP, tbIndex)
1484 RgTfuDatReqTbInfo *tb; /* TB to be sent to CL/PHY*/
1487 TRC2(rgDHMFreeHqProcTB)
1489 if((tbIndex > RG_MAX_TB_PER_UE) ||
1495 tb = &(hqP->tbInfo[tbIndex-1].tb);
1496 RG_FREE_MSG(tb->macHdr);
1497 RG_FREE_MSG(tb->macCes);
1499 for(idx = 0; idx < 2; idx++)
1501 if (hqP->tbInfo[tbIndex-1].sfLnkInfo[idx].sfLnk.node != NULLP)
1503 cmLListDelFrm(&hqP->tbInfo[tbIndex-1].sfLnkInfo[idx].sf->tbs,
1504 &(hqP->tbInfo[tbIndex-1].sfLnkInfo[idx].sfLnk));
1505 hqP->tbInfo[tbIndex-1].sfLnkInfo[idx].sfLnk.node = (PTR)NULLP;
1506 printf("\nrgDHMFreeHqProcTB:: hqP %p \n", (Void *)hqP);
1508 hqP->tbInfo[tbIndex-1].sfLnkInfo[idx].sf = NULLP;
1517 * @brief Handler for freeing up the harq related information from ueCb
1521 * Function : rgDHMFreeUe
1523 * This function shall free up the HARQ specific information from ueCb.
1525 * @param[in] Inst inst
1526 * @param[in] RgDlHqEnt *hqE
1532 PUBLIC Void rgDHMFreeUe
1538 PUBLIC Void rgDHMFreeUe(inst,hqE)
1548 /* Free all the memory associated with HARQ */
1549 for (i=0; i < hqE->numHqProcs; i++)
1552 rgDHMRlsHqProcTB(rgCb[inst].cell, hqE->procs[i], 1);
1553 rgDHMRlsHqProcTB(rgCb[inst].cell, hqE->procs[i], 2);
1555 rgDHMFreeHqProcTB(hqE->procs[i], 1);
1556 rgDHMFreeHqProcTB(hqE->procs[i], 2);
1559 rgFreeSBuf(inst,(Data **)&(hqE->procs[i]), sizeof(RgDlHqProcCb));
1561 rgDHMFreeSavedHqP(inst,hqE,i);
1565 /*ccpu00117052 - MOD - Passing double pointer for proper NULLP
1573 * @brief Function for handling RaResp request received from scheduler to MAC
1577 * Function : RgSchMacRstHqEntReq
1579 * This function shall be invoked whenever a sec cell of an ue
1580 * is deactivated. MAC needs to reset the harqentity associated
1581 * with the deactivated scell of the ue
1584 * @param[in] Pst *pst
1585 * @param[in] RgInfResetHqEnt *hqEntInfo
1590 PUBLIC S16 RgSchMacRstHqEntReq
1593 RgInfResetHqEnt* hqEntInfo
1596 PUBLIC S16 RgSchMacRstHqEntReq(pst, hqEntInfo)
1598 RgInfResetHqEnt* hqEntInfo;
1605 inst = pst->dstInst - RG_INST_START;
1607 if (((cell = rgCb[inst].cell) == NULLP) ||
1608 (rgCb[inst].cell->cellId != hqEntInfo->cellId))
1610 RGDBGERRNEW(inst,(rgPBuf(inst), "For user [%d]Cell does not exist %d\n",
1611 hqEntInfo->crnti,hqEntInfo->cellId));
1615 if ((ue = rgDBMGetUeCb(cell, hqEntInfo->crnti)) == NULLP)
1617 RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]UE does not exist for this hqEntInfo\n",
1622 rgDHMUeReset(cell, &ue->dl.hqEnt);
1629 * @brief Function for handling RaResp request received from scheduler to MAC
1633 * Function : RgSchMacRlsHqReq
1635 * This function shall be invoked whenever scheduler is done with the
1636 * allocations of random access responses for a subframe.
1637 * This shall invoke RAM to create ueCbs for all the rapIds allocated and
1638 * shall invoke MUX to create RAR PDUs for raRntis allocated.
1641 * @param[in] CmLteCellId cellId,
1642 * @param[in] CmLteTimingInfo timingInfo,
1643 * @param[in] RaRespInfo *rarInfo
1648 PUBLIC S16 RgSchMacRlsHqReq
1651 RgInfRlsHqInfo *rlshqUeInfo
1654 PUBLIC S16 RgSchMacRlsHqReq(pst, rlshqUeInfo)
1656 RgInfRlsHqInfo *rlshqUeInfo;
1660 RgCellCb *cell = NULLP;
1666 RguHarqStatusInd hqStaInd;
1667 Bool isValidTbId = FALSE;
1671 TRC2(RgSchMacRlsHqReq)
1673 RG_IS_INST_VALID(pst->dstInst);
1674 inst = pst->dstInst - RG_INST_START;
1675 cell = rgCb[inst].cell;
1677 SStartTask(&startTime, PID_MAC_AM_HARQ_RLS);
1679 if(NULLP == rlshqUeInfo)
1685 ||( cell->cellId != rlshqUeInfo->cellId))
1688 RLOG_ARG0(L_ERROR,DBG_CELLID,rlshqUeInfo->cellId,
1689 "No cellCb found with cellId");
1693 if(NULLP == rlshqUeInfo->ueHqInfo)
1698 for(idx1 = 0; idx1 < rlshqUeInfo->numUes; idx1++)
1700 if((ue=rgDBMGetUeCb (cell, rlshqUeInfo->ueHqInfo[idx1].rnti)) == NULLP)
1702 /* Check in RachLst */
1703 if((ue=rgDBMGetUeCbFromRachLst (cell,
1704 rlshqUeInfo->ueHqInfo[idx1].rnti)) == NULLP)
1706 RLOG_ARG1(L_ERROR,DBG_CELLID,rlshqUeInfo->cellId, "CRNTI:%d No ueCb found",
1707 rlshqUeInfo->ueHqInfo[idx1].rnti);
1713 if ((rlshqUeInfo->ueHqInfo[idx1].rlsOperationType && !gSaveVal) || (rlshqUeInfo->ueHqInfo[idx1].hqProcId > 8))
1716 RLOG_ARG1(L_INFO," SPURIOUS CALLL !!!! procId %d \n", rlshqUeInfo->ueHqInfo[idx1].hqProcId);
1719 printf ("RgSchMacRlsHqReq cell %d : numUes %d idx %d rnti %d hqProc %d numTbs %d tbid[0] %d tbid[1] %d rlsopr %d \n",
1721 rlshqUeInfo->numUes,
1723 rlshqUeInfo->ueHqInfo[idx1].rnti,
1724 rlshqUeInfo->ueHqInfo[idx1].hqProcId,
1725 rlshqUeInfo->ueHqInfo[idx1].numOfTBs,
1726 rlshqUeInfo->ueHqInfo[idx1].tbId[0],
1727 rlshqUeInfo->ueHqInfo[idx1].tbId[1],
1728 rlshqUeInfo->ueHqInfo[idx1].rlsOperationType);
1736 RgSchMacHndlRelReq(cell, ue, &rlshqUeInfo->ueHqInfo[idx1]);
1738 if (RGINF_RLS_HQ_DEL_TB == rlshqUeInfo->ueHqInfo[idx1].rlsOperationType)
1740 /* If REQ is to DEL the saved TBs no need to free the HqP as it's already
1744 #endif /* LTE_ADV */
1745 rgDHMGetHqProcFrmId(ue,rlshqUeInfo->ueHqInfo[idx1].hqProcId,&hqP);
1746 if(rlshqUeInfo->ueHqInfo[idx1].status[0] != TRUE)
1748 rgCb[inst].genSts.numHarqFail++;
1752 hqStaInd.cellId = cell->cellId;
1753 hqStaInd.ueId = rlshqUeInfo->ueHqInfo[idx1].rnti;
1754 hqStaInd.numTbs = rlshqUeInfo->ueHqInfo[idx1].numOfTBs;
1757 for(idx2=0; idx2 < rlshqUeInfo->ueHqInfo[idx1].numOfTBs; idx2++)
1760 /* Fill the hq sta Ind stucture. Need to send the Status Ind for only
1761 those TBID's reported by Scheduler*/
1762 tbId = rlshqUeInfo->ueHqInfo[idx1].tbId[idx2];
1763 if (hqP->tbId[tbId-1] != RGU_INVALID_TBID)
1765 /* Fill the correct Sn Map corresponding to the TBID */
1766 hqStaInd.tbId[idx2] = hqP->tbId[tbId-1];
1767 hqStaInd.status[idx2] = rlshqUeInfo->ueHqInfo[idx1].status[idx2];
1771 if(rgDHMRlsHqProcTB(cell, hqP,
1772 rlshqUeInfo->ueHqInfo[idx1].tbId[idx2]) != ROK)
1774 RLOG_ARG1(L_ERROR,DBG_CELLID,rlshqUeInfo->cellId,
1775 "CRNTI:%d Failure in releasing hq TB",
1776 rlshqUeInfo->ueHqInfo[idx1].rnti);
1787 RgUiRguHqStaInd(&(ue->rguDlSap->sapCfg.sapPst),
1788 ue->rguDlSap->sapCfg.suId,
1792 {/* Ue is from rach list*/
1793 RgUiRguHqStaInd(&(cell->rguDlSap->sapCfg.sapPst),
1794 cell->rguDlSap->sapCfg.suId,
1799 } /* end of ues loop */
1802 SStopTask(startTime,PID_MAC_AM_HARQ_RLS);
1805 } /* end of RgSchMacRlsHqReq */
1808 /**********************************************************************
1811 **********************************************************************/