Merge "Replaced old SSI function with new macros jira id - ODUHIGH-212"
[o-du/l2.git] / src / 5gnrmac / rg_dhm.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
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                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
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 *******************************************************************************/
18
19 /************************************************************************
20  
21      Name:     LTE-MAC layer
22   
23      Type:     C source file
24   
25      Desc:     C source code for Entry point fucntions
26   
27      File:     rg_dhm.c
28   
29 **********************************************************************/
30
31 /** @file rg_dhm.c
32 @brief APIs related to Downlink HARQ.
33 */
34
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 "common_def.h"
40 #ifdef L2_OPTMZ
41 #include "ss_strm.h"
42 #endif
43 #include "lrg.h"
44 #include "crg.h"
45 #include "tfu.h"
46 #include "rgu.h"
47 #include "rg_sch_inf.h"
48 #include "rg_env.h"
49 #include "rg_err.h"
50 #include "rg.h"
51 #include "du_app_mac_inf.h"
52
53 /* header/extern include files (.x) */
54 #ifdef L2_OPTMZ
55 #include "ss_strm.x"
56 #endif
57 #include "lrg.x"
58 #include "crg.x"
59 #include "tfu.x"
60 #include "rgu.x"
61 #include "rg_sch_inf.x"
62 #include "rg_prg.x"        /* PRG interface typedefs */
63 #include "rg.x"
64
65 #ifdef L2_OPTMZ
66 #include "ss_queue.h"
67 #include "ss_queue.x"
68 #include "ss_task.x"
69 #include "ss_msg.x"            /* MAC includes */
70 /* local defines */
71 //EXTERN  S16 ssGetDBufOfSize(Region region,Size size,Buffer **dBuf);
72 //void prc_trace_format_string(UINT32 group_mask, UINT16 level, const char *format, ...);
73 #endif
74
75 /* local typedefs */
76  
77 /* local externs */
78 EXTERN S16 SIncMsgRef(Buffer *srcBuf,Region dstRegion, Pool dstPool,Buffer **dstBuf);
79
80 PRIVATE Void rgDHMBldTfuDatReq ARGS((RgCellCb *cellCb, RgDlSf *dlSf, RgDlHqProcCb *hqP,
81                            RgTfuDatReqPduInfo *datReq));
82
83 #ifdef L2_OPTMZ
84 PUBLIC S16 rgDHMFreeHqProcTB
85 (
86 RgDlHqProcCb         *hqP,
87 U8                   tbIndex
88 );
89
90 #endif
91
92 /* forward references */
93
94 /**
95  * @brief This function initializes the DL HARQ Entity of UE
96  *
97  * @details
98  *
99  *     Function: rgDHMHqEntInit
100  *     Purpose:  This function initializes the DL HARQ entity of 
101  *               UE control block. This is performed at the time
102  *               of creating UE control block.
103  *     
104  *     Invoked by: configuration module
105  *     
106  *  @param[in]  Inst        inst
107  *  @param[in]  RgCellCb*  cell
108  *  @param[in]  RgUeCb*    ue
109  *  @return  S16
110  *           -# ROK
111  *           -# RFAILED
112  *
113  **/
114 #ifdef ANSI
115 PUBLIC S16 rgDHMHqEntInit
116 (
117 Inst               inst,
118 RgDlHqEnt          *hqE,
119 U8                 maxHqProcs
120 )
121 #else
122 PUBLIC S16 rgDHMHqEntInit(inst,hqE, maxHqProcs)
123 Inst               inst,
124 RgDlHqEnt          *hqE;
125 U8                 maxHqProcs;
126 #endif
127 {
128    U8 idx1,idx2;
129 #ifdef L2_OPTMZ
130    Buffer  *hdrDBuf = NULLP;
131    Buffer  *ceDBuf = NULLP;
132 #endif
133
134    TRC2(rgDHMHqEntInit)
135
136    hqE->numHqProcs = maxHqProcs;
137    /* for each harq process */
138    for (idx1 = 0; idx1 < hqE->numHqProcs; idx1++)
139    {
140       if (rgAllocSBuf(inst,(Data **)&(hqE->procs[idx1]),sizeof(RgDlHqProcCb)) != ROK) 
141       {
142          while(idx1--)
143          {
144             rgFreeSBuf(inst,(Data **)&(hqE->procs[idx1]), sizeof(RgDlHqProcCb));
145          }
146          RLOG0(L_ERROR, "Memory Alloc Failure for RgDlHqProcCb");        
147          return RFAILED;
148       }
149
150       hqE->procs[idx1]->procId      = idx1;
151       for(idx2 = 0; idx2 < RG_MAX_TB_PER_UE; idx2++)
152       {
153 #ifndef L2_OPTMZ
154          hqE->procs[idx1]->tbInfo[idx2].tb = NULLP;
155 #else
156          Buffer *tmpMBuf;
157          /* L2 optimization for mUe/Tti: Allocating buffers for macHdr, macCes
158           * and macPadding. These buffers shall not be released by MAC/CL.
159           * However, Only rPtr and wPtr will be reset while release of hq proc
160           */
161          tmpMBuf = hqE->procs[idx1]->tbInfo[idx2].tb.macHdr;
162          rgGetMsg(inst, &tmpMBuf);
163          RG_ADD_DBuf(hdrDBuf, RG_MAC_HDR_SIZE, tmpMBuf);
164          hqE->procs[idx1]->tbInfo[idx2].tb.macHdr = tmpMBuf;
165          macHeader[idx2] = MacPtrAddress;
166
167          tmpMBuf = hqE->procs[idx1]->tbInfo[idx2].tb.macCes;
168          rgGetMsg(inst, &tmpMBuf);
169          RG_ADD_DBuf(ceDBuf, RG_MAC_CE_SIZE, tmpMBuf);
170          hqE->procs[idx1]->tbInfo[idx2].tb.macCes = tmpMBuf;
171
172          hqE->procs[idx1]->tbInfo[idx2].tb.padSize = 0;
173 #endif
174 #ifdef LTE_L2_MEAS
175          hqE->procs[idx1]->tbId[idx2] = RGU_INVALID_TBID;
176 #endif
177       }
178
179       cmLListInit(&hqE->savedProcLst[idx1]);
180    }
181
182
183    return ROK;
184 } /* rgDHMHqEntInit */
185
186 /**
187  * @brief This function releases a HARQ process
188  *
189  * @details
190  *
191  *     Function: rgDHMUeReset
192  *     Purpose:  This function resets TB in each HarqProc.
193  *     
194  *     Invoked by: CFG UE Reset 
195  *     
196  *  @param[in]  RgDlHqProc    *hqP
197  *  @return  Void      
198  *
199  **/
200 #ifdef ANSI
201 PUBLIC Void rgDHMUeReset
202 (
203 RgCellCb *cell,
204 RgDlHqEnt          *hqE
205 )
206 #else
207 PUBLIC Void rgDHMUeReset(cell, hqE)
208 RgCellCb *cell;
209 RgDlHqEnt          *hqE;
210 #endif
211 {
212    U8       i = 0;
213
214    TRC2(rgDHMUeReset)
215
216    if(hqE->procs[0])
217    {
218       /* Free all the TB memory associated with HARQ */
219       for (i=0; i < hqE->numHqProcs; i++)
220       {
221          rgDHMRlsHqProcTB(cell, hqE->procs[i], 1);
222          rgDHMRlsHqProcTB(cell, hqE->procs[i], 2);
223
224 #ifdef LTE_ADV
225          rgDHMFreeSavedHqP((cell->macInst - RG_INST_START), hqE, i);
226 #endif
227       }
228    }
229    RETVOID;
230 } /* rgDHMUeReset*/
231
232 /**
233  * @brief This function defers shared memory buffer
234  *        freeing out of the critical RT path.
235  *
236  * @details
237  *
238  *     Function: rgDHMHdlBufFree
239  *     Purpose: To defer shared memory freeing post 
240  *              critical path. Defer as many if defer queue 
241  *              is full then release instantly.
242  *     
243  *     Invoked by: HARQ TB Release. 
244  *     
245  *  @return  Void      
246  *
247  **/
248 #ifdef ANSI
249 PUBLIC Void rgDHMHdlBufFree
250 (
251 Inst inst,
252 Buffer **mBuf
253 )
254 #else
255 PUBLIC Void rgDHMHdlBufFree(Inst inst, Buffer **mBuf)
256 Inst inst;
257 #endif
258 {
259    RgCb *rgCbP = &rgCb[inst];
260    TRC2(rgDHMHdlBufFree)
261
262    if (rgCbP->bufCnt < RG_MAX_DFRD_FREE_BUFS)
263    {
264       if (*mBuf)
265       {
266          rgCbP->bufToFree[rgCbP->bufCnt] = *mBuf;
267          rgCbP->bufCnt++;
268          *mBuf = NULLP;
269       }
270    }
271    else
272    {
273       RG_FREE_MSG(*mBuf);
274    }
275    RETVOID;
276 }
277 /**
278  * @brief This function is called to release the 
279  *        shared memory of the HARQ TBs outside 
280  *        the critical RT path.
281  *
282  * @details
283  *
284  *     Function: rgDHMFreeTbBufs
285  *     Purpose: This function is called to release the 
286  *        shared memory of the HARQ TBs outside 
287  *        the critical RT path.
288  *     
289  *     1. Job of releasing TBs is shared across TTIs
290  *     Invoked by: MAC every TTI 
291  *     
292  *  @return  Void      
293  *
294  **/
295 #ifdef ANSI
296 PUBLIC Void rgDHMFreeTbBufs
297 (
298 Inst inst
299 )
300 #else
301 PUBLIC Void rgDHMFreeTbBufs(inst)
302 Inst inst;
303 #endif
304 {
305    RgCb *rgCbP = &rgCb[inst];
306    U8 start = rgCbP->bufCnt;
307    U8 end = 0;
308
309    TRC2(rgDHMFreeTbBufs)
310
311    if (rgCbP->bufCnt < RG_MAX_FREE_BUFS_PERTTI)
312    {
313       end = 0;
314    }
315    else
316    {
317       end = rgCbP->bufCnt - RG_MAX_FREE_BUFS_PERTTI;
318    }
319    while (start != end)
320    {
321       start--;
322       SPutMsg(rgCbP->bufToFree[start]);
323    }
324    rgCbP->bufCnt = end;
325    RETVOID;
326 } /* rgDHMFreeTbBufs */
327
328 #ifdef ANSI
329 PUBLIC Void rgDHMFreeAllTbBufs
330 (
331 Inst inst
332 )
333 #else
334 PUBLIC Void rgDHMFreeAllTbBufs(inst)
335 Inst inst;
336 #endif
337 {
338    RgCb *rgCbP = &rgCb[inst];
339    U8 start = rgCbP->bufCnt;
340    U8 end = 0;
341
342    TRC2(rgDHMFreeAllTbBufs)
343
344    while (start != end)
345    {
346       start--;
347       SPutMsg(rgCbP->bufToFree[start]);
348    }
349    rgCbP->bufCnt = end;
350    RETVOID;
351 } /* rgDHMFreeTbBufs */
352
353
354 /**
355  * @brief This function releases a HARQ process
356  *
357  * @details
358  *
359  *     Function: rgDHMRlsHqProcTB
360  *     Purpose:  This function returns a HARQ process to HARQ Entity 
361  *               in the DL direction.
362  *     
363  *               1. Add the HARQ process to the free queue.
364  *     Invoked by: scheduler and HARQ processing
365  *     
366  *  @param[in]  RgDlHqProc    *hqP
367  *  @return  Void      
368  *
369  **/
370 #ifdef ANSI
371 PUBLIC S16 rgDHMRlsHqProcTB
372 (
373 RgCellCb             *cell,
374 RgDlHqProcCb         *hqP,
375 U8                   tbIndex
376 )
377 #else
378 PUBLIC S16 rgDHMRlsHqProcTB(cell, hqP, tbIndex)
379 RgCellCb             *cell;
380 RgDlHqProcCb         *hqP;
381 U8                   tbIndex;
382 #endif
383 {
384     U8                    idx;
385 #ifdef L2_OPTMZ
386     RgTfuDatReqTbInfo     *tb;   /* TB to be sent to CL/PHY*/
387    // U32 lchIdx, pduIdx;
388 #endif
389
390    TRC2(rgDHMRlsHqProcTB)
391
392    if((tbIndex > RG_MAX_TB_PER_UE) ||
393       (tbIndex == 0))
394    {
395       return RFAILED;
396    }
397
398    hqP->tbInfo[tbIndex-1].numSchLch = 0;
399 #ifndef L2_OPTMZ
400    if (hqP->tbInfo[tbIndex-1].tb)
401    {
402       rgDHMHdlBufFree(cell->macInst - RG_INST_START, &hqP->tbInfo[tbIndex-1].tb);
403    }
404 #else
405    /* L2 Optimization for mUe/Tti:  macHdr, macCes and macPad mBuf pointers
406     * shall not be released. However, Inorder to release harq info/TB info,
407     * just Resetting rPtr and wPtr of these mbufs to db_base
408     */
409    tb = &(hqP->tbInfo[tbIndex-1].tb);
410    if (tb->tbPres == TRUE)
411    {
412       RG_FREE_TB(tb);
413    }
414 #endif
415    hqP->tbInfo[tbIndex-1].schdTa.pres = FALSE;
416 #ifdef LTE_ADV
417    hqP->tbInfo[tbIndex -1].sCellActCe.pres = FALSE;
418 #endif
419
420    /* Decrementing might lead to roundoff error in case of say UE reset
421     * where all the HqProcs irrespective whether in use are called for rls.
422     * Hence to avoid the same shift operator is being used. */
423    hqP->numOfTBs = hqP->numOfTBs >> 1;
424    for(idx = 0; idx < 2; idx++)
425    {
426       if (hqP->tbInfo[tbIndex-1].sfLnkInfo[idx].sfLnk.node != NULLP)
427    {
428          cmLListDelFrm(&hqP->tbInfo[tbIndex-1].sfLnkInfo[idx].sf->tbs,
429                &(hqP->tbInfo[tbIndex-1].sfLnkInfo[idx].sfLnk));
430          hqP->tbInfo[tbIndex-1].sfLnkInfo[idx].sfLnk.node  = (PTR)NULLP;
431       printf("\nrgDHMRlsHqProcTB:: hqP %p \n", (Void *)hqP);
432    }
433       hqP->tbInfo[tbIndex-1].sfLnkInfo[idx].sf = NULLP;
434    }
435    /* Fix : syed It is better to reset these feilds
436     * corruption avoidance */
437    hqP->tbInfo[tbIndex-1].tbSz = 0;
438    hqP->tbInfo[tbIndex-1].contResCe = NOTPRSNT;
439    hqP->tbInfo[tbIndex-1].contResId = NULLP;
440
441    return ROK;
442 } /* rgDHMRlsHqProc */
443
444 /**
445  * @brief This function gets HARQ process with the given Id
446  *
447  * @details
448  *
449  *     Function: rgDHMGetHqProcFrmId
450  *     Purpose:  This function returns the HARQ process with the given ID.
451  *     Invoked by: ROM
452  *     
453  *  @param[in]  RgUeCb        *ue
454  *  @param[in]  U8            idx
455  *  @param[in]  RgDlHqProc    **hqP
456  *  @return  S16       
457  *         -#   ROK     if successful
458  *         -#   RFAILED otherwise
459  *
460  **/
461 #ifdef ANSI
462 PUBLIC S16 rgDHMGetHqProcFrmId
463 (
464 RgUeCb               *ue,
465 U8                   idx,
466 RgDlHqProcCb         **hqP
467 )
468 #else
469 PUBLIC S16 rgDHMGetHqProcFrmId(ue, idx, hqP)
470 RgUeCb               *ue;
471 U8                   idx;
472 RgDlHqProcCb         **hqP;
473 #endif
474 {
475    TRC2(rgDHMGetHqProcFrmId)
476
477    /* Pick the proc based on the index provided */
478    *hqP = (ue->dl.hqEnt.procs[idx]);
479
480    return ROK;
481 } /* rgDHMGetHqProcFrmId */
482
483 /*PRIVATE U32 dataAvl; */
484 /**
485  * @brief Handler for sending data to PHY
486  *
487  * @details
488  *
489  *     Function : rgDHMSndDatReq
490  *     
491  *     This function shall send the MAC PDU built for the UE to TOM
492  *     when invoked as part of TTI processing and keep track of the number of
493  *     transmissions for this TB.
494  *     
495  *           
496  *  @param[in]  RgCellCb      *cell
497  *  @param[in]  RgDlHqProcCb  *hqE 
498  *  @param[out] RgErrInfo     *err 
499  *  @return     S16
500  *      -#ROK 
501  *      -#RFAILED 
502  **/
503 #ifdef ANSI
504 PUBLIC S16 rgDHMSndDatReq
505 (
506 RgCellCb        *cellCb,
507 RgDlSf          *dlSf,
508 RgTfuDatReqInfo *datInfo,
509 RgDlHqProcCb   *hqP,
510 RgErrInfo      *err 
511 )
512 #else
513 PUBLIC S16 rgDHMSndDatReq(cellCb, dlSf, datInfo, hqP, err)
514 RgCellCb        *cellCb;
515 RgDlSf          *dlSf;
516 RgTfuDatReqInfo *datInfo;
517 RgDlHqProcCb    *hqP;
518 RgErrInfo       *err;
519 #endif
520 {
521    U8 i;
522    Inst               inst = cellCb->macInst - RG_INST_START;
523    RgTfuDatReqPduInfo   *datReq;
524    RgBldPduInfo      bldPdu;
525    /*Added this variable to figure out that whether this UE data
526      has to be inclueded in the TFU Data request.*/
527    Bool  dataAvlblUe;
528
529    TRC2(rgDHMSndDatReq)
530   
531    dataAvlblUe = TRUE;
532    for(i=0;i< RG_MAX_TB_PER_UE;i++)
533    {
534          /* printf("\nDHMSndDatReq1: Rnti %d dlSfSchdTime(sfn sf) : (%d %d)\n"
535                 "macCell(sfn sf): (%d %d) tbTimingInfo(sfn sf): (%d %d)\n"
536                 "dlSf %p dlSf->tbs.count %d hqp %p tb %p\n",
537                              hqP->tbInfo[i].pdcch.rnti,
538                              dlSf->schdTime.sfn, dlSf->schdTime.slot,
539                              cellCb->crntTime.sfn, cellCb->crntTime.slot,
540                              hqP->tbInfo[i].timingInfo.sfn, 
541                              hqP->tbInfo[i].timingInfo.slot,
542                              (Void *)dlSf, dlSf->tbs.count,
543                              (Void *)hqP,
544                              (Void *)hqP->tbInfo[i].tb);*/
545       /* Mukesh :: in case of rpepetiton this is not rerd*/
546       if (hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sf == dlSf)
547       {
548          /* Check if data from RLC had been received and got muxed. */
549 #ifndef L2_OPTMZ
550          if (hqP->tbInfo[i].tb == NULLP) 
551 #else
552          if (!(hqP->tbInfo[i].tb.tbPres)) 
553 #endif
554          {
555 #ifndef LTE_ADV
556             if (hqP->tbInfo[i].schdTa.pres == TRUE ||
557                   hqP->tbInfo[i].contResCe == PRSNT_NODEF)
558 #else
559             if ((hqP->tbInfo[i].schdTa.pres == TRUE) ||
560                  (hqP->tbInfo[i].contResCe == PRSNT_NODEF) ||
561                  (hqP->tbInfo[i].sCellActCe.pres == TRUE))
562 #endif
563             {
564                /* Data not received but ta needs to be sent. */
565                /* MUX TA and send it */
566                bldPdu.datReq    =  NULLP;
567                //bldPdu.reqType   =  EVENT_SLOT_IND_TO_MAC;
568                bldPdu.schdTbSz  =  hqP->tbInfo[i].tbSz;
569                bldPdu.ta        =  hqP->tbInfo[i].schdTa;
570 #ifdef LTE_ADV
571                bldPdu.sCellActCe= hqP->tbInfo[i].sCellActCe;
572 #endif
573                /* changes for CR timer implementation*/
574                bldPdu.contResId =  hqP->tbInfo[i].contResId;
575                if (ROK != rgMUXBldPdu(inst,&bldPdu, &(hqP->tbInfo[i].tb), err))  
576                {
577                   RLOG1(L_ERROR, "MUXing failed for:  MacInst %d", inst);
578                   RLOG4(L_ERROR, "MUXing failed for:  time: %d/%d\
579                   procId %d ueId %d", hqP->tbInfo[i].timingInfo.sfn,
580                   hqP->tbInfo[i].timingInfo.slot, hqP->procId, 
581                   hqP->tbInfo[i].pdcch.rnti);
582
583                   return RFAILED;
584                }
585             }
586             else   
587             {
588 #ifdef LTEMAC_RGU_PAD
589                /* Data not received from RLC. Padding at MAC */
590                bldPdu.datReq    =  NULLP;
591                //bldPdu.reqType   =  EVENT_SLOT_IND_TO_MAC;
592                bldPdu.schdTbSz  =  hqP->tbInfo[i].tbSz;
593                bldPdu.ta        =  hqP->tbInfo[i].schdTa;
594 #ifdef LTE_ADV
595                bldPdu.sCellActCe= hqP->tbInfo[i].sCellActCe;
596 #endif
597                bldPdu.ta.val    =  0;
598                bldPdu.contResId =  NULLP;
599
600                if (ROK != rgMUXBldPdu(inst,&bldPdu, &(hqP->tbInfo[i].tb), err))  
601                {
602                   RLOG1(L_ERROR, "MUXing failed for:  MacInst %d", inst);
603                   RLOG4(L_ERROR, "MUXing failed for:  time: %d/%d\
604                   procId %d ueId %d", hqP->tbInfo[i].timingInfo.sfn,
605                   hqP->tbInfo[i].timingInfo.slot, hqP->procId, 
606                   hqP->tbInfo[i].pdcch.rnti);
607                   
608                   return RFAILED;
609                }
610 #else
611                /*Padding is not done so data for this UE will not be
612                  included.*/
613                dataAvlblUe = FALSE;
614 #endif
615             }
616          }
617          else
618          {
619          }
620       }
621       //else
622       {
623       }
624    }
625
626    /*If Data/Padding is not available for UE, then we can not include
627      any Data for this UE in TFU Data Request.*/
628    if(!dataAvlblUe)
629    {
630       /*Free up the HARQ process for this allocation.*/
631       /* Release First TB, as this would be anyway there*/
632       rgDHMRlsHqProcTB(cellCb, hqP, 1);
633       if(2 == hqP->numOfTBs)
634       {
635          rgDHMRlsHqProcTB(cellCb, hqP, 2);
636       }
637       
638       return ROK;
639    }
640
641    if (rgGetEventMem(inst,(Ptr *)&datReq, sizeof(TfuDatReqPduInfo),
642             &(datInfo->memCp)) != ROK)
643    {
644       return RFAILED;
645    }
646    /* Fill the TFU Dat Req with information from Harq Proc */
647   
648    rgDHMBldTfuDatReq(cellCb, dlSf, hqP, datReq);
649
650    /* MS_WORKAROUND for ccpu00122894 */
651    for(i=0;i< RG_MAX_TB_PER_UE;i++)
652    {
653       if (hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sf == dlSf)
654       {
655          cmLListDelFrm(&dlSf->tbs, &(hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sfLnk));
656          hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sfLnk.node = NULLP;
657          
658         
659         hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sf = NULLP;
660       }
661    }
662    cmLListAdd2Tail(&datInfo->pdus, &(datReq->lnk));
663    datReq->lnk.node = (PTR)datReq;
664
665    return ROK;
666 }  /* rgDHMSndDatReq */
667
668 /**
669  * @brief Function to handle RGU datReq received from ROM
670  *
671  * @details
672  *
673  *     Function : rgDHMHndlDedDatReq
674  *     
675  *     This function shall act on the datReq received on RGU. It shall 
676  *     store the data IDs for all the logical channels and get the MAC 
677  *     PDU built.
678  *     
679  *           
680  *  @param[in]  Inst        inst
681  *  @param[in]  RgDlHqProcCb   *hqProc 
682  *  @param[in]  RgRguDedDatReq *datReq
683  *  @param[out] RgErrInfo      *err
684  *  @return     S16
685  *      -# ROK 
686  *      -# RFAILED 
687  **/
688 #ifdef ANSI
689 PUBLIC S16 rgDHMHndlDedDatReq
690 (
691 Inst           inst,
692 RgDlHqProcCb   *hqProc,
693 RgRguDDatReqPerUe *datReq,
694 RgDlSf            *dlSf,
695 RgErrInfo      *err
696 )
697 #else
698 PUBLIC S16 rgDHMHndlDedDatReq(inst,hqProc, datReq, dlSf, err)
699 Inst           inst;
700 RgDlHqProcCb   *hqProc;
701 RgRguDDatReqPerUe *datReq;
702 RgDlSf            *dlSf;
703 RgErrInfo      *err;
704 #endif
705 {
706 //   U32            len;
707    U8             i;
708    U8             j;
709    RgBldPduInfo   bldPdu;
710    U8             tbIndex;
711 #ifdef L2_OPTMZ
712    RgTfuDatReqTbInfo     *tb;
713 #endif
714
715    TRC2(rgDHMHndlDedDatReq);
716
717    tbIndex = (U8)(datReq->transId & 0x03);
718    /* Accept all the data requests even if delayed in case nothing
719     * has been sent earlier on the harq proc.
720     */
721    if((datReq->nmbOfTbs > RG_MAX_TB_PER_UE) ||
722          (tbIndex == 0))
723    {
724       /* release corresponding TBs from SF tbs List */
725       for(j=0;j<datReq->nmbOfTbs;j++)
726       {
727          if (!(tbIndex & (j+1)))
728          {
729             j++;
730          } 
731          rgDHMRlsHqProcTB(rgCb[inst].cell, hqProc, (U8)(j+1));
732       }
733       return RFAILED;
734    }
735
736    for(i=0;i<datReq->nmbOfTbs;i++)
737    {
738       /* tbIndex 01 corresponds to presence of 1st TB
739        * 10 corresponds 2nd TB
740        * 11 corresponds two TBs of UE */
741       if (!(tbIndex & (i+1)))
742       {
743           continue;
744       }
745       if (hqProc->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sfLnk.node == NULLP)
746       {
747          /* release corresponding TBs from SF tbs List */
748          for(j=0;j<datReq->nmbOfTbs;j++)
749          {
750             if (!(tbIndex & (j+1)))
751             {
752                j++;
753             }
754             rgDHMRlsHqProcTB(rgCb[inst].cell, hqProc, (U8)(j+1));
755             printf("\nrgDHMHndlDedDatReq:: hqP %p \n", (Void *)hqProc);
756          }
757          return RFAILED;
758
759       }
760 #ifndef L2_OPTMZ
761       RG_FREE_MSG(hqProc->tbInfo[i].tb);
762       /* L2 optimization for mUe/Tti: Pre-allocated mBuf pointers(macHdr, 
763        * macCes and MacPad) of harq TB need to be reset to db_base
764        */
765 #else
766       tb = &hqProc->tbInfo[i].tb;
767       if (tb->tbPres == TRUE)
768       {
769          RG_FREE_TB(tb);
770       }
771 #endif
772       bldPdu.datReq    =  datReq;
773       bldPdu.reqType   =  EVTRGUDDATREQ;
774       bldPdu.schdTbSz  =  hqProc->tbInfo[i].tbSz;
775       bldPdu.tbIndex   =  i+1;
776       bldPdu.ta        =  hqProc->tbInfo[i].schdTa;
777 #ifdef LTE_ADV
778       bldPdu.sCellActCe= hqProc->tbInfo[i].sCellActCe;
779 #endif
780       bldPdu.contResId =  NULLP;
781 #ifdef LTE_L2_MEAS
782       /* Store tbId from RLC in DDatRequest */
783       hqProc->tbId[i] = datReq->datReqTb[i].tbId;
784
785
786       hqProc->status[i] =  FALSE;
787 #endif 
788       if(rgMUXBldPdu(inst,&bldPdu, &(hqProc->tbInfo[i].tb), err) != ROK)
789       {
790          RLOG1(L_ERROR, "MUXing failed for:  MacInst %d", inst);
791          RLOG4(L_ERROR, "MUXing failed for:  time: %d/%d\
792                procId %d ueId %d", hqProc->tbInfo[i].timingInfo.sfn,
793                hqProc->tbInfo[i].timingInfo.slot, hqProc->procId, 
794                hqProc->tbInfo[i].pdcch.rnti);
795
796          /* release corresponding TBs from SF tbs List */
797          for(j=0;j<datReq->nmbOfTbs;j++)
798          {
799             if (!(tbIndex & (j+1)))
800             {
801                j++;
802             }
803             rgDHMRlsHqProcTB(rgCb[inst].cell, hqProc, (U8)(j+1));
804          }
805          return RFAILED;
806       }
807       /*
808       SFndLenMsg(hqProc->tbInfo[i].tb, &len);
809       */
810    }
811    return ROK;
812 }  /* rgDHMHndlDedDatReq */
813
814 /**
815  * @brief Function to handle RGU datReq received from ROM
816  *
817  * @details
818  *
819  *     Function : rgDHMHndlCmnDatReq
820  *     
821  *     This function shall act on the datReq received on RGU. It shall 
822  *     store the data IDs for all the logical channels and get the MAC 
823  *     PDU built.
824  *     
825  *           
826  *  @param[in]  Inst        inst
827  *  @param[in]  RgDlHqProcCb   *hqProc 
828  *  @param[in]  RgRguCmnDatReq *datReq
829  *  @param[out] RgErrInfo      *err
830  *  @return     S16
831  *      -# ROK 
832  *      -# RFAILED 
833  **/
834 #ifdef ANSI
835 PUBLIC S16 rgDHMHndlCmnDatReq
836 (
837 Inst           inst,
838 RgDlHqProcCb   *hqProc,
839 RgRguCmnDatReq *datReq,
840 RgErrInfo      *err
841 )
842 #else
843 PUBLIC S16 rgDHMHndlCmnDatReq(inst,hqProc, datReq, err)
844 Inst           inst;
845 RgDlHqProcCb   *hqProc;
846 RgRguCmnDatReq *datReq;
847 RgErrInfo      *err;
848 #endif
849 {
850    RgUstaDgn      dgn;
851    RgBldPduInfo   bldPdu;
852
853    TRC2(rgDHMHndlCmnDatReq)
854
855 #ifndef L2_OPTMZ
856       if (hqProc->tbInfo[0].tb != NULLP)
857 #else
858       /* If numLch is non zero means HQ Proc is busy*/
859       if (hqProc->tbInfo[0].tb.tbPres)
860 #endif
861       {
862          /* datReq discarded. Generate an alarm */
863          rgFillDgnParams(inst,&dgn, LRG_USTA_DGNVAL_HARQ); 
864          rgLMMStaInd(inst,LCM_CATEGORY_PROTOCOL, LCM_EVENT_UI_INV_EVT,
865                LRG_CAUSE_HQ_PROC_BUSY, &dgn);
866          return RFAILED;
867       }
868
869    bldPdu.datReq    =  datReq;
870    bldPdu.reqType   =  EVTRGUCDATREQ;
871    bldPdu.schdTbSz  =  hqProc->tbInfo[0].tbSz;
872    bldPdu.ta        =  hqProc->tbInfo[0].schdTa;
873 #ifdef LTE_ADV
874    bldPdu.sCellActCe= hqProc->tbInfo[0].sCellActCe;
875 #endif
876
877    bldPdu.contResId  =  hqProc->tbInfo[0].contResId;
878
879    if(rgMUXBldPdu(inst,&bldPdu, &(hqProc->tbInfo[0].tb), err) != ROK)
880    {
881       RLOG1(L_ERROR, "MUXing failed for:  MacInst %d", inst); 
882       RLOG4(L_ERROR, "MUXing failed for: time: %d/%d\
883                procId %d ueId %d", hqProc->tbInfo[0].timingInfo.sfn,
884             hqProc->tbInfo[0].timingInfo.slot, hqProc->procId, 
885             hqProc->tbInfo[0].pdcch.rnti);
886
887       RG_FREE_MSG(datReq->pdu);
888       return RFAILED;
889    }
890
891    return ROK;
892 }  /* rgDHMHndlCmnDatReq */
893
894 /**
895  * @brief Function to get consolidate grants and send consolidated grant to RLC
896  *
897  * @details
898  *
899  *     Function : rgDHMSndConsolidatedStaInd
900  *     
901  *     This function shall be invoked by Scheduler to trigger DHM to send a
902  *     consolidated status indication of all UE scheduled in a TTI as well as
903  *     send consolidated CStaInd for MSG4 and for all common channels(PCCH,
904  *     if RGR_SI_SCH is not defined then it includes BCH and BCCH also)
905  *     
906  *           
907  *  @param[in]  RgCellCb       *cell
908  *  @param[in]  RgInfUeInfo   *ueInfo,
909  *  @param[in]  CmLteTimingInfo timingInfo,
910  *  @param[out] RgErrInfo      err
911  *  @param[in]  RguCStaIndInfo   *cStaInd
912  *  @return     S16
913  *      -# ROK 
914  *      -# RFAILED 
915  **/
916  RgUeCb  *gUe =NULLP;
917 #ifdef ANSI
918 PUBLIC S16 rgDHMSndConsolidatedStaInd
919 (
920 RgCellCb        *cell,
921 RgInfUeInfo     *ueInfo,
922 CmLteTimingInfo timingInfo,
923 RgErrInfo       *err
924 )
925 #else
926 PUBLIC S16 rgDHMSndConsolidatedStaInd(cell, ueInfo, timingInfo, err)
927 RgCellCb        *cell;
928 RgInfUeInfo     *ueInfo;
929 CmLteTimingInfo timingInfo;
930 RgErrInfo       *err;
931 #endif
932 {
933    SuId            rguDlSpId;/*need to use spID instead of suID*/
934    U8              idx;
935    U8              ueIdx;
936    U8              lcIdx;
937    U8              tbIndex=0,idx1;
938    RgDlSf          *dlSf = &cell->subFrms[(timingInfo.slot % RG_NUM_SUB_FRAMES)];
939    Inst            inst = cell->macInst - RG_INST_START;
940 //   Bool            isDStaReqrd = FALSE;
941    RgRguDedStaInd  *dStaInd[rgCb[inst].numRguSaps] ;
942    RgUpSapCb      *rguDlSap[rgCb[inst].numRguSaps];
943
944    int lchBufSize =0;
945    RgUeCb         *ue;
946    RgDlHqProcCb   *hqP;
947    RgInfUeAlloc   *allocInfo;
948    U8             activeSapCnt = 0;
949    U8             staIndCnt    = 0;
950 #ifdef LTE_ADV
951    Bool           hqPAdded     = FALSE;
952 #endif
953 #ifdef L2_OPTMZ
954    RgTfuDatReqTbInfo     *tb;   /* TB to be sent to CL/PHY*/
955 #endif
956
957    TRC2(rgDHMSndConsolidatedStaInd)
958    cmMemset ((U8 *)dStaInd, 0, (sizeof(RgRguDedStaInd *) * rgCb[inst].numRguSaps));
959    cmMemset ((U8 *)rguDlSap, 0, (sizeof(RgUpSapCb  *) * rgCb[inst].numRguSaps));
960
961    /* Send StaInd for the scheduled UEs */
962    for(ueIdx = 0; ueIdx < ueInfo->numUes; ueIdx++)
963    {
964 #ifdef LTE_ADV
965       hqPAdded = FALSE;
966 #endif
967       if((ue=rgDBMGetUeCb (cell, ueInfo->allocInfo[ueIdx].rnti)) == NULLP)
968       {
969          /* Check in RachLst */
970          if((ue=rgDBMGetUeCbFromRachLst (cell, 
971                      ueInfo->allocInfo[ueIdx].rnti)) == NULLP)
972          {
973             RLOG_ARG1(L_ERROR,DBG_CELLID,cell->cellId,"CRNTI:%d No ueCb found", 
974                       ueInfo->allocInfo[ueIdx].rnti);
975             /*Fix: If one UE is not present dont return, look for the next.*/
976             continue;
977          }
978       }
979
980
981       rgDHMGetHqProcFrmId(ue,ueInfo->allocInfo[ueIdx].hqProcId,&hqP);
982       allocInfo = &ueInfo->allocInfo[ueIdx];
983       gUe = ue;
984
985       /* Fix : syed Avoid sending data for a RETX
986        * if initial TX data processing was unsuccessful */
987       if((allocInfo->tbInfo[0].isReTx == TRUE) &&
988             (hqP->tbInfo[0].tbSz == 0)) 
989       {
990          RLOG_ARG2(L_ERROR,DBG_CELLID,cell->cellId,
991                "CRNTI:%d RETX hqP(%d) tb(0) for a failed New Tx", 
992                   allocInfo->rnti, hqP->procId);        
993          continue;
994       }
995       if((allocInfo->tbInfo[1].isReTx == TRUE) &&
996             (hqP->tbInfo[1].tbSz == 0)) 
997       {
998          RLOG_ARG2(L_ERROR,DBG_CELLID,cell->cellId,
999                    "CRNTI:%d RETX hqP(%d) tb(1) for a failed New Tx", 
1000                   allocInfo->rnti, hqP->procId);        
1001          continue;
1002       }
1003
1004       if(ue->rguDlSap != NULLP)
1005       {
1006           rguDlSpId = ue->rguDlSap->sapCfg.spId;
1007       }else
1008       {/* UeCb is from rachList */
1009           rguDlSpId = cell->rguDlSap->sapCfg.spId;
1010       }
1011
1012
1013       for(idx=allocInfo->tbStrtIdx;((idx-allocInfo->tbStrtIdx) <\
1014                allocInfo->nmbOfTBs); idx++)
1015       {
1016          RguCStaIndInfo  *cStaInd;
1017 #ifdef TFU_UPGRADE
1018          /* LTE_ADV_FLAG_REMOVED_START */
1019          hqP->tbInfo[idx].isEnbSFR = allocInfo->isEnbSFR;
1020          /* update pA value */
1021          hqP->tbInfo[idx].pa = allocInfo->pa;
1022          /* LTE_ADV_FLAG_REMOVED_END */
1023 #endif
1024
1025          hqP->numOfTBs =  allocInfo->nmbOfTBs;
1026          hqP->tbInfo[idx].sfLnkInfo[dlSf->schdTime.slot % 2].sfLnk.node = (PTR)hqP;
1027          hqP->tbInfo[idx].sfLnkInfo[dlSf->schdTime.slot % 2].sf = dlSf;
1028          cmLListAdd2Tail(&dlSf->tbs,&(hqP->tbInfo[idx].sfLnkInfo[dlSf->schdTime.slot % 2].sfLnk));
1029          /* Changes as part of performance testing*/
1030          /*   hqP->numOfTBs++;*/
1031          hqP->tbInfo[idx].doa = allocInfo->doa;
1032          hqP->tbInfo[idx].txMode = allocInfo->txMode;
1033          hqP->tbInfo[idx].puschRptUsd = allocInfo->puschRptUsd;
1034          hqP->tbInfo[idx].puschPmiInfo = allocInfo->puschPmiInfo;
1035 #ifdef LTEMAC_SPS
1036          hqP->tbInfo[idx].pdcch.rnti = allocInfo->pdcchRnti;
1037 #else
1038          hqP->tbInfo[idx].pdcch.rnti = allocInfo->rnti;
1039 #endif
1040          if(allocInfo->tbInfo[idx].isReTx == TRUE)
1041          {
1042             hqP->tbInfo[idx].pdcch.dci = allocInfo->dciInfo;
1043             continue;
1044          }
1045
1046          hqP->tbInfo[idx].timingInfo = timingInfo;
1047          hqP->tbInfo[idx].pdcch.dci = allocInfo->dciInfo;
1048 #ifndef L2_OPTMZ
1049          RG_FREE_MSG(hqP->tbInfo[idx].tb);
1050 #else
1051          /* L2 optimization for mUe/Tti: Pre-allocated mBuf pointers(macHdr, 
1052           * macCes and MacPad) of harq TB need to be reset to db_base
1053           */
1054          tb = &(hqP->tbInfo[idx].tb);
1055          if (tb->tbPres == TRUE)
1056          {
1057             RG_FREE_TB(tb);
1058          }
1059 #endif
1060          hqP->tbInfo[idx].tbSz = allocInfo->tbInfo[idx].schdTbSz; 
1061
1062          hqP->tbInfo[idx].schdTa.pres = allocInfo->tbInfo[idx].ta.pres;
1063          hqP->tbInfo[idx].schdTa.val  = allocInfo->tbInfo[idx].ta.val;
1064
1065 #ifdef LTE_ADV
1066          hqP->tbInfo[idx].sCellActCe.pres = allocInfo->tbInfo[idx].sCellActCe.pres;
1067          hqP->tbInfo[idx].sCellActCe.val  = allocInfo->tbInfo[idx].sCellActCe.val;
1068 #endif
1069
1070 #ifdef LTE_ADV 
1071          if(( hqPAdded == TRUE) || (ROK == rgLaaPushHqPToScellLst(allocInfo,cell,timingInfo)))
1072          {
1073             hqPAdded = TRUE;
1074             continue;
1075          }
1076 #endif
1077          if (allocInfo->tbInfo[idx].schdDat[0].lcId == RG_CCCH_LCID)        
1078          {
1079 #ifndef L2_OPTMZ
1080             RG_FREE_MSG(hqP->tbInfo[idx].tb);
1081 #else
1082            /* L2 optimization for mUe/Tti: Pre-allocated mBuf pointers(macHdr, 
1083             * macCes and MacPad) of harq TB need to be reset to db_base
1084             */
1085            tb = &(hqP->tbInfo[idx].tb);
1086
1087            if (tb->tbPres == TRUE)
1088            {
1089               RG_FREE_TB(tb);
1090            }
1091 #endif
1092             hqP->tbInfo[0].contResCe  = allocInfo->tbInfo[0].contResCe;
1093             if(allocInfo->tbInfo[0].contResCe)
1094             {
1095                hqP->tbInfo[0].contResId = &ue->contResId;
1096             }
1097
1098
1099             if(allocInfo->tbInfo[idx].numSchLch == 0)
1100             {
1101                RLOG_ARG2(L_DEBUG,DBG_CELLID,cell->cellId,
1102                         "UEID:%d MSG4 with only contResId hqP(%d)",
1103                                 allocInfo->rnti,
1104                         hqP->procId);
1105                hqP->tbInfo[idx].numSchLch = 0;
1106                continue;
1107             }
1108
1109             /* Increamenting the tbIndex instead of
1110                assigning it to constant */
1111             tbIndex++;
1112
1113
1114             hqP->tbInfo[idx].numSchLch = 1;
1115             hqP->tbInfo[idx].schdData[0].lcId = 
1116                allocInfo->tbInfo[idx].schdDat[0].lcId;
1117             hqP->tbInfo[idx].schdData[0].schdSz = 
1118                allocInfo->tbInfo[idx].schdDat[0].numBytes;
1119
1120            // if(cStaInd == NULLP)
1121             {
1122                if ((rgAllocShrablSBuf(inst,(Data**)&cStaInd, sizeof(RguCStaIndInfo))) != ROK)
1123                {
1124                   err->errType  = RGERR_DHM_SND_STA_IND;
1125                   err->errCause = RG_DHM_MEM_ALLOC_FAIL;
1126                   return RFAILED; 
1127                }
1128             }
1129
1130             idx1 = (hqP->procId << 2) | tbIndex;
1131             
1132             cStaInd->cellId    = cell->cellId;
1133             cStaInd->rnti      = allocInfo->rnti;
1134             cStaInd->lcId      = cell->dlCcchId;
1135             cStaInd->transId   = (timingInfo.sfn << 16) | 
1136                                  (timingInfo.slot << 8) | idx1;
1137                /* ADD Changes for Downlink UE Timing Optimization */
1138 #ifdef LTEMAC_DLUE_TMGOPTMZ
1139             dlSf->remDatReqCnt++;
1140 #endif
1141             RLOG_ARG3(L_DEBUG,DBG_CELLID,cell->cellId,
1142                                "RNTI:%d UE:MSG4 grant for CCCH hqP(%d) LCID:%d",
1143                      allocInfo->rnti, 
1144                      hqP->procId,
1145                                cStaInd->lcId);       
1146             /* Fix : syed Avoid return param for interface prim and
1147              * proceed for other UEs. For the failed UE, MAC shall
1148              * do padding. */
1149             rgUIMSndCmnStaInd(cell->macInst,cell->rguDlSap,cStaInd);
1150             break;
1151          }
1152          else
1153          {
1154             tbIndex+=idx+1;
1155 #ifndef L2_OPTMZ
1156             RG_FREE_MSG(hqP->tbInfo[idx].tb);
1157 #else
1158             /* L2 optimization for mUe/Tti: Pre-allocated mBuf pointers(macHdr, 
1159              * macCes and MacPad) of harq TB need to be reset to db_base
1160              */
1161             tb = &(hqP->tbInfo[idx].tb);
1162             if (tb->tbPres == TRUE)
1163             {  
1164                RG_FREE_TB(tb);
1165             }
1166 #endif
1167
1168             if((NULLP == dStaInd[rguDlSpId]) && (allocInfo->tbInfo[idx].numSchLch))
1169             {
1170                if ((rgAllocShrablSBuf (inst,(Data**)&dStaInd[rguDlSpId], sizeof(RguDStaIndInfo))) != ROK)
1171                {
1172                   err->errType  = RGERR_DHM_SND_STA_IND;
1173                   err->errCause = RG_DHM_MEM_ALLOC_FAIL;
1174                   /* Need to return as memory allocation will fail for other UEs also*/
1175                   return RFAILED;
1176                }
1177                dStaInd[rguDlSpId]->nmbOfUeGrantPerTti = 0;
1178                rguDlSap[rguDlSpId] = ue->rguDlSap;
1179                activeSapCnt++;
1180             }
1181
1182             for (lcIdx = 0; 
1183                   lcIdx < allocInfo->tbInfo[idx].numSchLch; lcIdx++)
1184             {
1185                hqP->tbInfo[idx].schdData[lcIdx].lcId = 
1186                   allocInfo->tbInfo[idx].schdDat[lcIdx].lcId;
1187                if (hqP->tbInfo[idx].schdData[lcIdx].lcId == 0)
1188                {
1189                   RLOG_ARG2(L_ERROR,DBG_CELLID,cell->cellId, 
1190                         "CCCH grant in DStaInd for LCID:%d CRNTI:%d",
1191                         hqP->tbInfo[idx].schdData[lcIdx].lcId,allocInfo->rnti);
1192                }
1193                hqP->tbInfo[idx].schdData[lcIdx].schdSz = 
1194                   allocInfo->tbInfo[idx].schdDat[lcIdx].numBytes;
1195                if(dStaInd[rguDlSpId])
1196                {
1197                   dStaInd[rguDlSpId]->staInd[dStaInd[rguDlSpId]->nmbOfUeGrantPerTti].staIndTb[idx].\
1198                   lchStaInd[lcIdx].lcId = allocInfo->tbInfo[idx].\
1199                   schdDat[lcIdx].lcId;
1200                   dStaInd[rguDlSpId]->staInd[dStaInd[rguDlSpId]->nmbOfUeGrantPerTti].staIndTb[idx].\
1201                   lchStaInd[lcIdx].totBufSize = allocInfo->tbInfo[idx].\
1202                   schdDat[lcIdx].numBytes;
1203                }
1204
1205                lchBufSize+=allocInfo->tbInfo[idx].schdDat[lcIdx].numBytes;
1206             }
1207             hqP->tbInfo[idx].numSchLch = 
1208                allocInfo->tbInfo[idx].numSchLch;
1209             if(dStaInd[rguDlSpId])
1210             {
1211                dStaInd[rguDlSpId]->staInd[dStaInd[rguDlSpId]->nmbOfUeGrantPerTti].staIndTb[idx].nmbLch =
1212                   allocInfo->tbInfo[idx].numSchLch;
1213 #ifdef LTE_L2_MEAS
1214                dStaInd[rguDlSpId]->staInd[dStaInd[rguDlSpId]->nmbOfUeGrantPerTti].staIndTb[idx].tbId =
1215                   hqP->tbId[idx]; 
1216 #endif
1217             }
1218             lchBufSize=0;
1219          }
1220       }
1221       //if((dStaInd) && (tbIndex) && (isDStaReqrd == TRUE))
1222       if((dStaInd[rguDlSpId]) && (tbIndex))
1223       {
1224          idx1 = (hqP->procId << 2) | tbIndex;
1225          /* Create RguDStaInd struct and send to UIM */
1226          dStaInd[rguDlSpId]->staInd[dStaInd[rguDlSpId]->nmbOfUeGrantPerTti].rnti    = allocInfo->rnti;
1227          /*
1228             dStaInd->transId = (hqP->timingInfo.sfn << 16) | 
1229             (hqP->timingInfo.slot << 8) | hqP->procId;
1230           */
1231          dStaInd[rguDlSpId]->staInd[dStaInd[rguDlSpId]->nmbOfUeGrantPerTti].transId = (timingInfo.sfn << 16) | 
1232             (timingInfo.slot << 8) | idx1;
1233          dStaInd[rguDlSpId]->staInd[dStaInd[rguDlSpId]->nmbOfUeGrantPerTti].nmbOfTbs = hqP->numOfTBs;
1234 #ifdef LTE_ADV
1235          dStaInd[rguDlSpId]->staInd[dStaInd[rguDlSpId]->nmbOfUeGrantPerTti].fillCtrlPdu = allocInfo->fillCtrlPdu;
1236 #endif        
1237          /*increment num of UE as staInd is prepared for it */
1238          dStaInd[rguDlSpId]->nmbOfUeGrantPerTti++;
1239          /* ADD Changes for Downlink UE Timing Optimization */
1240 #ifdef LTEMAC_DLUE_TMGOPTMZ
1241          dlSf->remDatReqCnt++;
1242 #endif
1243       }
1244       //isDStaReqrd = FALSE;
1245       tbIndex = 0;
1246    }
1247
1248    for(idx = 0; idx < rgCb[inst].numRguSaps ; idx++)
1249    {
1250       if(dStaInd[idx] != NULLP)
1251       {
1252          dStaInd[idx]->cellId  = cell->cellId;
1253          /* Fix : syed Avoid return param for interface prim and
1254           * proceed for other UEs. For the failed UE, MAC shall
1255           * do padding. */
1256          rgUIMSndDedStaInd(inst,rguDlSap[idx],dStaInd[idx]);
1257    
1258          staIndCnt++;
1259          if(staIndCnt == activeSapCnt)
1260             break;/* all valid staind are considered */
1261       }
1262
1263    }
1264    return ROK;
1265 }  /* rgDHMSndConsolidatedStaInd */
1266
1267
1268 /**
1269  * @brief Function to handle building the TFU Data Request
1270  *
1271  * @details
1272  *
1273  *     Function : rgDHMBldTfuDatReq
1274  *     
1275  *     This function builds the TFU Data Request with the details 
1276  *     present in HARQ Process.
1277  *           
1278  *  @param[in]  RgDlHqProcCb     *hqP 
1279  *  @param[out] TfuDatReqPduInfo  *datReq 
1280  *  @return     Void
1281  *              None 
1282  **/
1283 //U8 crashFlag = 0;
1284 #ifdef ANSI
1285 PRIVATE Void rgDHMBldTfuDatReq
1286 (
1287 RgCellCb           *cellCb,
1288 RgDlSf             *dlSf,
1289 RgDlHqProcCb       *hqP,
1290 RgTfuDatReqPduInfo *datReq
1291 )
1292 #else
1293 PRIVATE Void rgDHMBldTfuDatReq(cellCb, dlSf, hqP, datReq)
1294 RgCellCb           *cellCb;
1295 RgDlSf             *dlSf;
1296 RgDlHqProcCb       *hqP;
1297 RgTfuDatReqPduInfo *datReq;
1298 #endif
1299 {
1300
1301 #ifndef L2_OPTMZ
1302 #if !(!(defined TENB_ACC) && !(defined LTE_PAL_ENB))
1303    Inst inst;
1304 #elif defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD)
1305    Inst inst;
1306 #endif
1307 #endif
1308
1309    U8 i;
1310
1311 #ifdef L2_OPTMZ
1312    U32 lchIdx, pduIdx;
1313 #endif
1314    TRC2(rgDHMBldTfuDatReq)
1315  
1316    datReq->nmbOfTBs = 0;
1317 #ifndef L2_OPTMZ
1318 #if !(!(defined TENB_ACC) && !(defined LTE_PAL_ENB))
1319    inst = cellCb->macInst - RG_INST_START;
1320 #elif defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD)
1321    inst = cellCb->macInst - RG_INST_START;
1322 #endif
1323 #endif
1324    /*MS_WORKAROUND  for ccpu00123904*/
1325    datReq->isTApres = FALSE;
1326 #ifdef TFU_ALLOC_EVENT_NO_INIT
1327 #ifndef L2_OPTMZ   
1328    datReq->mBuf[0] = 0;
1329    datReq->mBuf[1] = 0;
1330 #endif    
1331 #endif
1332  
1333    for(i=0;i<RG_MAX_TB_PER_UE;i++)
1334    {
1335 #ifndef L2_OPTMZ
1336       if ((hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sf == dlSf) &&
1337           (hqP->tbInfo[i].tb != NULLP))
1338 #else
1339       if ((hqP->tbInfo[i].sfLnkInfo[dlSf->schdTime.slot % 2].sf == dlSf) &&
1340            RgUtlIsTbMuxed(&(hqP->tbInfo[i].tb)))
1341 #endif
1342       {
1343
1344          datReq->rnti           =  hqP->tbInfo[i].pdcch.rnti;
1345          datReq->dciInfo        =  hqP->tbInfo[i].pdcch.dci;
1346          datReq->doa            =  hqP->tbInfo[i].doa;
1347          datReq->transMode      =  hqP->tbInfo[i].txMode;
1348          datReq->puschRptUsd    =  hqP->tbInfo[i].puschRptUsd;
1349          datReq->puschPmiInfo   =  hqP->tbInfo[i].puschPmiInfo;
1350          /*MS_WORKAROUND  for ccpu00123904*/
1351          if (hqP->tbInfo[i].schdTa.pres)
1352          {
1353             datReq->isTApres       =  TRUE; 
1354          }
1355 #ifdef   TFU_UPGRADE
1356          /* update pA value */
1357          datReq->pa             =  hqP->tbInfo[i].pa;
1358 #endif
1359          /* LTE_ADV_FLAG_REMOVED_START */
1360          datReq->isEnbSFR       =  hqP->tbInfo[i].isEnbSFR;
1361          /* LTE_ADV_FLAG_REMOVED_END */
1362 #ifndef L2_OPTMZ
1363 #if (!(defined TENB_ACC) && !(defined LTE_PAL_ENB))  /* ABHI */ /* This is only temp fix. It needs to be removed
1364                                 after rebasing to MAC CCB */
1365 #ifdef BRDCM
1366          datReq->mBuf[i] = hqP->tbInfo[i].tb;
1367 #else
1368          /* Intel Tdd- Commenting out the Optimization for direct Access of 
1369           * mBuf Index */
1370          /*Proper clean-up needed as this needs long stability tests
1371           * in all SoCs*/
1372 #if defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD)
1373          SIncMsgRef(hqP->tbInfo[i].tb, RG_GET_MEM_REGION(rgCb[inst]),
1374                RG_GET_MEM_POOL(rgCb[inst]), &datReq->mBuf[i]); 
1375 #else
1376          datReq->mBuf[i] = hqP->tbInfo[i].tb;
1377 #endif
1378 #endif/*BRDCM*/
1379 #else
1380          SIncMsgRef(hqP->tbInfo[i].tb, RG_GET_MEM_REGION(rgCb[inst]),
1381                RG_GET_MEM_POOL(rgCb[inst]), &datReq->mBuf[i]);
1382 #endif
1383          {
1384             MsgLen   dbgBufLen;
1385             if(SFndLenMsg(datReq->mBuf[i], &dbgBufLen))
1386             {
1387                if(dbgBufLen == 0)
1388                {              
1389                   RLOG_ARG4(L_ERROR,DBG_CELLID,cellCb->cellId,
1390                                           "RNTI:%d SFN:%d slot:%d tbIdx:%d Sdu Length 0 ",
1391                               datReq->rnti,
1392                                       hqP->tbInfo[i].timingInfo.sfn,
1393                                           hqP->tbInfo[i].timingInfo.slot,i);
1394                   RLOG_ARG3(L_ERROR,DBG_CELLID,cellCb->cellId,
1395                               "taPres [%d] numOfTbs [%d] format[%d]",
1396                               datReq->isTApres, 
1397                            hqP->numOfTBs, 
1398                            datReq->dciInfo.format);  
1399                }              
1400             }  
1401          }
1402 #else
1403          /* L2 optimization for mUe/Tti: Removing SIncMsgRef to avoid additional
1404           * mBuf allocation. MAC header, MAC Ces, MAC PDU per LCH per TB Per UE
1405           * and MAC padding Mbufs are being sent to CL. Populating these Ptrs
1406           * From TB Info to TfuDatReq
1407           */
1408          datReq->tbInfo[i].tbPres =  TRUE;
1409          datReq->tbInfo[i].tbSize =  hqP->tbInfo[i].tbSz;
1410          datReq->tbInfo[i].macHdr =  hqP->tbInfo[i].tb.macHdr;
1411          datReq->tbInfo[i].macCes =  hqP->tbInfo[i].tb.macCes;
1412          datReq->tbInfo[i].numLch =  hqP->tbInfo[i].tb.numLch;
1413          for(lchIdx = 0; lchIdx < hqP->tbInfo[i].tb.numLch; lchIdx++)
1414          {
1415             datReq->tbInfo[i].lchInfo[lchIdx].numPdu = hqP->tbInfo[i].tb.\
1416                                                        lchInfo[lchIdx].numPdu;
1417             for(pduIdx = 0; pduIdx < hqP->tbInfo[i].tb.lchInfo[lchIdx].numPdu;\
1418                   pduIdx++)
1419             {
1420                datReq->tbInfo[i].lchInfo[lchIdx].mBuf[pduIdx] =
1421                   hqP->tbInfo[i].tb.lchInfo[lchIdx].mBuf[pduIdx];
1422             }
1423          }
1424         // datReq->tbInfo[i].macPad  =  hqP->tbInfo[i].tb.macPad;
1425          datReq->tbInfo[i].padSize =  hqP->tbInfo[i].tb.padSize;
1426         // prc_trace_format_string(0x40,3,"TfuDatReq:RNTI=%d TbIdx=%d TbSize=%d PdSz=(%d) macHdraddr: (%p) macCEAddr: (%p) noLch=(%d)",datReq->rnti, i,
1427           //     hqP->tbInfo[i].tbSz, datReq->tbInfo[i].padSize, datReq->tbInfo[i].macHdr, datReq->tbInfo[i].macCes, datReq->tbInfo[i].numLch);
1428
1429 #endif
1430          datReq->nmbOfTBs++;
1431       }
1432    }
1433    RETVOID;
1434 }  /* rgDHMBldTfuDatReq */
1435
1436
1437 #ifdef L2_OPTMZ
1438 /**
1439  * @brief This function releases a HARQ process
1440  *
1441  * @details
1442  *
1443  *     Function: rgDHMFreeHqProcTB
1444  *     Purpose:  This function returns a HARQ process to HARQ Entity 
1445  *               in the DL direction.
1446  *     
1447  *               1. Add the HARQ process to the free queue.
1448  *     Invoked by: scheduler and HARQ processing
1449  *     
1450  *  @param[in]  RgDlHqProc    *hqP
1451  *  @return  Void      
1452  *
1453  **/
1454 #ifdef ANSI
1455 PUBLIC S16 rgDHMFreeHqProcTB
1456 (
1457 RgDlHqProcCb         *hqP,
1458 U8                   tbIndex
1459 )
1460 #else
1461 PUBLIC S16 rgDHMFreeHqProcTB(hqP, tbIndex)
1462 RgDlHqProcCb         *hqP;
1463 U8                   tbIndex;
1464 #endif
1465 {
1466    RgTfuDatReqTbInfo     *tb;   /* TB to be sent to CL/PHY*/
1467    U8                    idx;
1468
1469    TRC2(rgDHMFreeHqProcTB)
1470
1471    if((tbIndex > RG_MAX_TB_PER_UE) ||
1472       (tbIndex == 0))
1473    {
1474       return RFAILED;
1475    }
1476
1477    tb = &(hqP->tbInfo[tbIndex-1].tb);
1478    RG_FREE_MSG(tb->macHdr);
1479    RG_FREE_MSG(tb->macCes);
1480
1481    for(idx = 0; idx < 2; idx++)
1482    {
1483       if (hqP->tbInfo[tbIndex-1].sfLnkInfo[idx].sfLnk.node != NULLP)
1484    {
1485          cmLListDelFrm(&hqP->tbInfo[tbIndex-1].sfLnkInfo[idx].sf->tbs,
1486                &(hqP->tbInfo[tbIndex-1].sfLnkInfo[idx].sfLnk));
1487          hqP->tbInfo[tbIndex-1].sfLnkInfo[idx].sfLnk.node  = (PTR)NULLP;
1488       printf("\nrgDHMFreeHqProcTB:: hqP %p \n", (Void *)hqP);
1489    }
1490       hqP->tbInfo[tbIndex-1].sfLnkInfo[idx].sf = NULLP;
1491    }
1492    return ROK;
1493 }
1494 #endif
1495
1496
1497
1498 /**
1499  * @brief Handler for freeing up the harq related information from ueCb
1500  *
1501  * @details
1502  *
1503  *     Function : rgDHMFreeUe
1504  *     
1505  *     This function shall free up the HARQ specific information from ueCb.
1506  *           
1507  *  @param[in]  Inst        inst
1508  *  @param[in]  RgDlHqEnt     *hqE 
1509  *
1510  *  @return     None.
1511  *
1512  **/
1513 #ifdef ANSI
1514 PUBLIC Void rgDHMFreeUe
1515 (
1516 Inst               inst,
1517 RgDlHqEnt          *hqE
1518 )
1519 #else
1520 PUBLIC Void rgDHMFreeUe(inst,hqE)
1521 Inst               inst;
1522 RgDlHqEnt          *hqE;
1523 #endif
1524 {
1525    U8             i;
1526    TRC2(rgDHMFreeUe)
1527
1528    if(hqE->procs)
1529    {
1530       /* Free all the memory associated with HARQ */
1531       for (i=0; i < hqE->numHqProcs; i++)
1532       {
1533 #ifndef L2_OPTMZ
1534          rgDHMRlsHqProcTB(rgCb[inst].cell, hqE->procs[i], 1);
1535          rgDHMRlsHqProcTB(rgCb[inst].cell, hqE->procs[i], 2);
1536 #else
1537          rgDHMFreeHqProcTB(hqE->procs[i], 1);
1538          rgDHMFreeHqProcTB(hqE->procs[i], 2);
1539 #endif
1540          
1541          rgFreeSBuf(inst,(Data **)&(hqE->procs[i]), sizeof(RgDlHqProcCb));
1542 #ifdef LTE_ADV
1543          rgDHMFreeSavedHqP(inst,hqE,i);
1544 #endif
1545       }
1546
1547       /*ccpu00117052 - MOD - Passing double pointer for proper NULLP
1548                             assignment */
1549    }
1550
1551    RETVOID;
1552
1553 }  /* rgDHMFreeUe */
1554 /**
1555  * @brief Function for handling RaResp request received from scheduler to MAC
1556  *
1557  * @details
1558  *
1559  *     Function : RgSchMacRstHqEntReq
1560  *     
1561  *     This function shall be invoked whenever a sec cell of an ue
1562  *     is deactivated. MAC needs to reset the harqentity associated 
1563  *     with the deactivated scell of the ue
1564  *     
1565  *           
1566  *  @param[in] Pst             *pst
1567  *  @param[in] RgInfResetHqEnt *hqEntInfo
1568  *  @return  S16
1569  *      -# ROK 
1570  **/
1571 #ifdef ANSI
1572 PUBLIC S16 RgSchMacRstHqEntReq
1573 (
1574 Pst*                 pst,    
1575 RgInfResetHqEnt*     hqEntInfo
1576 )
1577 #else
1578 PUBLIC S16 RgSchMacRstHqEntReq(pst, hqEntInfo)
1579 Pst*                 pst;
1580 RgInfResetHqEnt*     hqEntInfo;
1581 #endif
1582 {
1583    Inst      inst;
1584    RgCellCb  *cell;
1585    RgUeCb    *ue;
1586
1587    inst = pst->dstInst - RG_INST_START;
1588
1589    if (((cell = rgCb[inst].cell) == NULLP) ||
1590        (rgCb[inst].cell->cellId != hqEntInfo->cellId))
1591    {
1592       RGDBGERRNEW(inst,(rgPBuf(inst), "For user [%d]Cell does not exist %d\n",
1593                 hqEntInfo->crnti,hqEntInfo->cellId));
1594       return RFAILED;
1595    }
1596
1597    if ((ue = rgDBMGetUeCb(cell, hqEntInfo->crnti)) == NULLP)
1598    {
1599       RGDBGERRNEW(inst,(rgPBuf(inst), "[%d]UE does not exist for this hqEntInfo\n",
1600                        hqEntInfo->crnti));
1601       return RFAILED;
1602    }
1603
1604    rgDHMUeReset(cell, &ue->dl.hqEnt);
1605
1606    return ROK;
1607 }
1608 U32 gSaveVal;
1609 \f
1610 /**
1611  * @brief Function for handling RaResp request received from scheduler to MAC
1612  *
1613  * @details
1614  *
1615  *     Function : RgSchMacRlsHqReq
1616  *     
1617  *     This function shall be invoked whenever scheduler is done with the
1618  *     allocations of random access responses for a slot.
1619  *     This shall invoke RAM to create ueCbs for all the rapIds allocated and 
1620  *     shall invoke MUX to create RAR PDUs for raRntis allocated.
1621  *     
1622  *           
1623  *  @param[in] CmLteCellId         cellId,
1624  *  @param[in] CmLteTimingInfo     timingInfo,
1625  *  @param[in] RaRespInfo          *rarInfo
1626  *  @return  S16
1627  *      -# ROK 
1628  **/
1629 #ifdef ANSI
1630 PUBLIC S16 RgSchMacRlsHqReq
1631 (
1632 Pst                 *pst,
1633 RgInfRlsHqInfo      *rlshqUeInfo
1634 )
1635 #else
1636 PUBLIC S16 RgSchMacRlsHqReq(pst, rlshqUeInfo)
1637 Pst                 *pst;
1638 RgInfRlsHqInfo      *rlshqUeInfo;
1639 #endif
1640 {
1641    Inst           inst;
1642    RgCellCb       *cell = NULLP;
1643    RgUeCb         *ue;
1644    RgDlHqProcCb   *hqP;
1645    U8             idx1,idx2;
1646 #ifdef LTE_L2_MEAS
1647    U8                tbId;
1648    RguHarqStatusInd  hqStaInd;
1649    Bool              isValidTbId = FALSE;
1650 #endif
1651    U32        startTime=0;
1652    
1653    TRC2(RgSchMacRlsHqReq)
1654
1655    RG_IS_INST_VALID(pst->dstInst);
1656    inst = pst->dstInst - RG_INST_START;
1657    cell  = rgCb[inst].cell;
1658    /*starting Task*/
1659    SStartTask(&startTime, PID_MAC_AM_HARQ_RLS);
1660
1661    if(NULLP == rlshqUeInfo)
1662    {
1663       return RFAILED;
1664    }
1665
1666    if((cell  == NULLP)
1667       ||( cell->cellId != rlshqUeInfo->cellId))
1668    {
1669        
1670       RLOG_ARG0(L_ERROR,DBG_CELLID,rlshqUeInfo->cellId,
1671                 "No cellCb found with cellId");
1672       return RFAILED;
1673    }
1674
1675    if(NULLP == rlshqUeInfo->ueHqInfo)
1676    {
1677       return RFAILED;
1678    }
1679
1680    for(idx1 = 0; idx1 < rlshqUeInfo->numUes; idx1++)
1681    {
1682       if((ue=rgDBMGetUeCb (cell, rlshqUeInfo->ueHqInfo[idx1].rnti)) == NULLP)
1683       {
1684          /* Check in RachLst */
1685          if((ue=rgDBMGetUeCbFromRachLst (cell, 
1686                      rlshqUeInfo->ueHqInfo[idx1].rnti)) == NULLP)
1687          {
1688             RLOG_ARG1(L_ERROR,DBG_CELLID,rlshqUeInfo->cellId, "CRNTI:%d No ueCb found",
1689                      rlshqUeInfo->ueHqInfo[idx1].rnti);
1690             continue;
1691          }
1692       }
1693 #ifdef LTE_ADV
1694 #ifdef LAA_DBG
1695      if ((rlshqUeInfo->ueHqInfo[idx1].rlsOperationType && !gSaveVal) || (rlshqUeInfo->ueHqInfo[idx1].hqProcId > 8))
1696       {
1697          int *p = NULL;
1698          RLOG_ARG1(L_INFO," SPURIOUS CALLL !!!! procId %d \n", rlshqUeInfo->ueHqInfo[idx1].hqProcId);
1699
1700
1701        printf ("RgSchMacRlsHqReq cell %d : numUes %d idx %d rnti %d hqProc %d numTbs %d tbid[0] %d tbid[1] %d rlsopr %d \n",
1702       cell->cellId,
1703        rlshqUeInfo->numUes,
1704        idx1,
1705        rlshqUeInfo->ueHqInfo[idx1].rnti,
1706        rlshqUeInfo->ueHqInfo[idx1].hqProcId,
1707        rlshqUeInfo->ueHqInfo[idx1].numOfTBs,
1708        rlshqUeInfo->ueHqInfo[idx1].tbId[0],
1709        rlshqUeInfo->ueHqInfo[idx1].tbId[1],
1710        rlshqUeInfo->ueHqInfo[idx1].rlsOperationType);
1711       
1712          *p = 10; 
1713       }
1714 #endif
1715       gSaveVal = 0;
1716
1717
1718       RgSchMacHndlRelReq(cell, ue, &rlshqUeInfo->ueHqInfo[idx1]);
1719
1720       if (RGINF_RLS_HQ_DEL_TB == rlshqUeInfo->ueHqInfo[idx1].rlsOperationType)
1721       {
1722          /* If REQ is to DEL the saved TBs no need to free the HqP as it's already
1723             freed up earlier */
1724          continue;
1725       }
1726 #endif /* LTE_ADV */
1727       rgDHMGetHqProcFrmId(ue,rlshqUeInfo->ueHqInfo[idx1].hqProcId,&hqP);
1728       if(rlshqUeInfo->ueHqInfo[idx1].status[0] != TRUE)
1729       {
1730          rgCb[inst].genSts.numHarqFail++;
1731       }
1732      
1733 #ifdef LTE_L2_MEAS
1734       hqStaInd.cellId = cell->cellId;
1735       hqStaInd.ueId = rlshqUeInfo->ueHqInfo[idx1].rnti;
1736       hqStaInd.numTbs = rlshqUeInfo->ueHqInfo[idx1].numOfTBs;
1737 #endif
1738
1739       for(idx2=0; idx2 < rlshqUeInfo->ueHqInfo[idx1].numOfTBs; idx2++)
1740       {
1741 #ifdef LTE_L2_MEAS
1742          /* Fill the hq sta Ind stucture. Need to send the Status Ind for only
1743           those TBID's reported by Scheduler*/
1744             tbId = rlshqUeInfo->ueHqInfo[idx1].tbId[idx2];
1745             if (hqP->tbId[tbId-1] != RGU_INVALID_TBID)
1746             {
1747             /* Fill the correct Sn Map corresponding to the TBID */
1748             hqStaInd.tbId[idx2] = hqP->tbId[tbId-1];
1749             hqStaInd.status[idx2] = rlshqUeInfo->ueHqInfo[idx1].status[idx2];
1750                isValidTbId = TRUE;
1751             }
1752 #endif
1753          if(rgDHMRlsHqProcTB(cell, hqP, 
1754                rlshqUeInfo->ueHqInfo[idx1].tbId[idx2]) != ROK)
1755          {
1756             RLOG_ARG1(L_ERROR,DBG_CELLID,rlshqUeInfo->cellId,
1757                   "CRNTI:%d Failure in releasing hq TB",
1758                   rlshqUeInfo->ueHqInfo[idx1].rnti);
1759             continue;
1760          }
1761       }
1762
1763 #ifdef LTE_L2_MEAS
1764
1765          if (isValidTbId)
1766          {
1767             if(ue->rguDlSap)
1768             {
1769                RgUiRguHqStaInd(&(ue->rguDlSap->sapCfg.sapPst),
1770                      ue->rguDlSap->sapCfg.suId,
1771                      &hqStaInd);
1772             }
1773             else
1774             {/* Ue is from rach list*/
1775                RgUiRguHqStaInd(&(cell->rguDlSap->sapCfg.sapPst),
1776                      cell->rguDlSap->sapCfg.suId,
1777                      &hqStaInd);
1778             }
1779          }
1780 #endif
1781    } /* end of ues loop */
1782
1783    /*starting Task*/
1784    SStopTask(startTime,PID_MAC_AM_HARQ_RLS);
1785
1786    return ROK;
1787 } /* end of RgSchMacRlsHqReq */
1788
1789
1790 /**********************************************************************
1791  
1792          End of file
1793 **********************************************************************/