SLice Mapping to RLC DB [ Jira Id - ODUHIGH-371 ]
[o-du/l2.git] / src / 5gnrrlc / rlc_utl_dl.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:     NR RLC Layer 
22   
23      Type:     C file
24   
25      Desc:     Source code for RLC Utility Module
26                This file contains following functions
27
28                   --rlcUtlSendToMac
29                   --rlcUtlRcvFrmMac
30                   --rlcUtlEmptySduQ
31                   --rlcUtlSendDedLcBoStatus
32                   --rlcUtlSendUlDataToDu 
33                   --kwUtlShutDown
34
35      File:     rlc_utl_dl.c
36
37 **********************************************************************/
38
39 /** @file rlc_utl_dl.c
40 @brief RLC Utility Module 
41 */
42
43 /* header (.h) include files */
44
45 #include "common_def.h"
46 /* kw005.201 added support for L2 Measurement */
47 #ifdef LTE_L2_MEAS
48 #include <sys/time.h>
49 #endif
50 #include "ckw.h"           /* CKW defines */
51 #include "kwu.h"           /* CKW defines */
52 #include "lkw.h"           /* LKW defines */
53 #include "rgu.h"           /* RGU defiens */
54
55 #include "rlc_env.h"        /* RLC environment options */
56 #include "rlc_err.h"        /* Error defines */
57
58
59 /* extern (.x) include files */
60 #include "ckw.x"           /* CKW includes */
61 #include "kwu.x"           /* KWU includes */
62 #include "lkw.x"           /* LKW inlcudes */
63 #include "rgu.x"           /* RGU includes */
64
65 #include "rlc_utils.h"            /* RLC defines */
66 #include "rlc_dl_ul_inf.h"
67 #include "rlc_dl.h"         /* RLC downlink includes */
68 #include "rlc_mac_inf.h"
69 #include "du_app_rlc_inf.h"
70 #include "rlc_lwr_inf_api.h"
71 #include "rlc_upr_inf_api.h"
72
73 #include "ss_rbuf.h"
74 #include "ss_rbuf.x" 
75
76 SsRngBufCnt rngCb;
77
78 #if (defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS))
79 uint32_t isDatReqProcessed;
80 #endif
81 #define RLC_MODULE (RLC_DBGMASK_DUT | RLC_DBGMASK_DL) /* for debugging purpose */
82 #if (defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS)) || defined (SS_RBUF)
83 void rlcUtlDlBatchProcHqStaInd ARGS ((Void));
84 #endif
85 Void ResetRLCStats(Void)
86 {
87    RlcCb* dlInst = rlcCb[1]; 
88    RlcCb* ulInst = rlcCb[0]; 
89    memset(&gRlcStats, 0, sizeof(RLCStats));
90    memset(&dlInst->genSts,0,sizeof(RlcGenSts));
91    memset(&ulInst->genSts,0,sizeof(RlcGenSts));
92 }
93
94 #ifndef ALIGN_64BIT
95 Void PrintRLCStats(Void)
96 {
97    RlcCb* dlInst = rlcCb[1]; 
98    RlcCb* ulInst = rlcCb[0]; 
99
100    DU_LOG("\nINFO  -->  RLC_DL : RLC Stats: PDUs Sent = (%ld), PdusRext = (%ld), TimeOut = (%ld), SduDiscarded = (%ld)",
101                      dlInst->genSts.pdusSent,
102                      dlInst->genSts.pdusRetx,
103                      dlInst->genSts.protTimeOut,
104                      dlInst->genSts.numSduDisc);
105    DU_LOG("\nINFO  -->  RLC_DL : RLC Stats: PDUs Rcvd = (%ld), unexpPdus = (%ld), errorPdus = (%ld)",
106                      ulInst->genSts.pdusRecv,
107                      ulInst->genSts.unexpPdusRecv,
108                      ulInst->genSts.errorPdusRecv);
109    DU_LOG("\nINFO  -->  RLC_DL : RLC Stats: AMDL: "
110                      "StaPduSent:%lu NacksInStaPdu:%lu BytesUnused:%lu PollTimerExpires SRB:%lu ",
111                      gRlcStats.amRlcStats.numDLStaPduSent, gRlcStats.amRlcStats.numDLNacksInStaPdu, 
112                      gRlcStats.amRlcStats.numDLBytesUnused, gRlcStats.amRlcStats.numDLPollTimerExpiresSrb);
113    DU_LOG("\nINFO  -->  RLC_DL : RLC Stats: AMDL: "
114                      "DRB:%lu MaxRetx:%lu RetransPdus:%lu", 
115                      gRlcStats.amRlcStats.numDLPollTimerExpiresDrb, gRlcStats.amRlcStats.numDLMaxRetx, 
116                      gRlcStats.amRlcStats.numDLRetransPdus);
117    DU_LOG("\nINFO  -->  RLC_DL : RLC Stats: AMUL: "
118                      " PdusDiscarded:%lu ReAsmblTimerExpires:%lu StaPduRcvd:%lu NackInStaPduRcvd:%lu ", 
119                      gRlcStats.amRlcStats.numULPdusDiscarded, gRlcStats.amRlcStats.numULReAsmblTimerExpires, 
120                      gRlcStats.amRlcStats.numULStaPduRcvd, gRlcStats.amRlcStats.numULNackInStaPduRcvd);
121
122    RTLIN_DUMP_DEBUG("RLC Stats: PDUs Sent = (%ld), PdusRext = (%ld), TimeOut = (%ld), SduDiscarded = (%ld)\n",
123                      dlInst->genSts.pdusSent,
124                      dlInst->genSts.pdusRetx,
125                      dlInst->genSts.protTimeOut,
126                      dlInst->genSts.numSduDisc);
127    RTLIN_DUMP_DEBUG("RLC Stats: PDUs Rcvd = (%ld), unexpPdus = (%ld), errorPdus = (%ld)\n",
128                      ulInst->genSts.pdusRecv,
129                      ulInst->genSts.unexpPdusRecv,
130                      ulInst->genSts.errorPdusRecv);
131    RTLIN_DUMP_DEBUG("RLC Stats:"
132                     "RLC_AMDL: StaPduSent:%lu NacksInStaPdu:%lu BytesUnused:%lu PollTimerExpires SRB:%lu DRB:%lu MaxRetx:%lu RetransPdus:%lu \n"
133                     "RLC_AMUL: PdusDiscarded:%lu ReAsmblTimerExpires:%lu StaPduRcvd:%lu NackInStaPduRcvd:%lu \n", 
134                      gRlcStats.amRlcStats.numDLStaPduSent, gRlcStats.amRlcStats.numDLNacksInStaPdu, gRlcStats.amRlcStats.numDLBytesUnused, 
135                      gRlcStats.amRlcStats.numDLPollTimerExpiresSrb, gRlcStats.amRlcStats.numDLPollTimerExpiresDrb, gRlcStats.amRlcStats.numDLMaxRetx, 
136                      gRlcStats.amRlcStats.numDLRetransPdus, gRlcStats.amRlcStats.numULPdusDiscarded, gRlcStats.amRlcStats.numULReAsmblTimerExpires, 
137                      gRlcStats.amRlcStats.numULStaPduRcvd, gRlcStats.amRlcStats.numULNackInStaPduRcvd);
138 }
139 #else
140 Void PrintRLCStats(Void)
141 {
142    RlcCb* dlInst = rlcCb[1]; 
143    RlcCb* ulInst = rlcCb[0]; 
144
145    DU_LOG ("\n ================================ RLC STATS ===========================\n");
146    DU_LOG("\nINFO  -->  RLC_DL : RLC Stats: PDUs Sent = (%d), PdusRext = (%d), TimeOut = (%d), SduDiscarded = (%d)",
147                      dlInst->genSts.pdusSent,
148                      dlInst->genSts.pdusRetx,
149                      dlInst->genSts.protTimeOut,
150                      dlInst->genSts.numSduDisc);
151    DU_LOG("\nINFO  -->  RLC_DL : RLC Stats: PDUs Rcvd = (%d), unexpPdus = (%d), errorPdus = (%d)",
152                      ulInst->genSts.pdusRecv,
153                      ulInst->genSts.unexpPdusRecv,
154                      ulInst->genSts.errorPdusRecv);
155    DU_LOG("\nINFO  -->  RLC_DL : RLC Stats: AMDL: "
156                      "StaPduSent:%u NacksInStaPdu:%u BytesUnused:%u PollTimerExpires SRB:%u ",
157                      gRlcStats.amRlcStats.numDLStaPduSent, gRlcStats.amRlcStats.numDLNacksInStaPdu, 
158                      gRlcStats.amRlcStats.numDLBytesUnused, gRlcStats.amRlcStats.numDLPollTimerExpiresSrb);
159    DU_LOG("\nINFO  -->  RLC_DL : RLC Stats: AMDL: "
160                      "DRB:%u MaxRetx:%u RetransPdus:%u", 
161                      gRlcStats.amRlcStats.numDLPollTimerExpiresDrb, gRlcStats.amRlcStats.numDLMaxRetx, 
162                      gRlcStats.amRlcStats.numDLRetransPdus);
163    DU_LOG("\nINFO  -->  RLC_DL : RLC Stats: AMUL: "
164                      " PdusDiscarded:%u ReAsmblTimerExpires:%u StaPduRcvd:%u NackInStaPduRcvd:%u ", 
165                      gRlcStats.amRlcStats.numULPdusDiscarded, gRlcStats.amRlcStats.numULReAsmblTimerExpires, 
166                      gRlcStats.amRlcStats.numULStaPduRcvd, gRlcStats.amRlcStats.numULNackInStaPduRcvd);
167  /*  RTLIN_DUMP_DEBUG("AM RLC Stats:"
168                     "RLC_AMDL: SDUs Tx :(%u) SDU Bytes Tx :(%u) SDUs Retx :(%u) MaxRetx:(%u) WindowStalls: (%u) \n"
169                     "RLC_AMUL: DropOutWinRx :(%u) SDUs Rx :(%u) SDU Bytes Rx :(%u) SDUNack Rx :(%u) Duplicate Pdu Rx :(%u) \n",
170                      gRlcStats.amRlcStats.numRlcAmCellSduTx, gRlcStats.amRlcStats.numRlcAmCellSduBytesTx,
171                      gRlcStats.amRlcStats.numRlcAmCellRetxPdu, gRlcStats.amRlcStats.numRlcAmMaxRetx, gRlcStats.amRlcStats.numRlcAmCellWinStall,
172                      gRlcStats.amRlcStats.numRlcAmCellDropOutWinRx, gRlcStats.amRlcStats.numRlcAmCellSduRx,
173                      gRlcStats.amRlcStats.numRlcAmCellSduBytesRx, gRlcStats.amRlcStats.numRlcAmCellNackRx, gRlcStats.amRlcStats.numRlcAmCellDupPduRx);
174 */
175    RTLIN_DUMP_DEBUG("RLC Stats: PDUs Sent = (%d), PdusRext = (%d), TimeOut = (%d), SduDiscarded = (%d)\n",
176                      dlInst->genSts.pdusSent,
177                      dlInst->genSts.pdusRetx,
178                      dlInst->genSts.protTimeOut,
179                      dlInst->genSts.numSduDisc);
180    RTLIN_DUMP_DEBUG("RLC Stats: PDUs Rcvd = (%d), unexpPdus = (%d), errorPdus = (%d)\n",
181                      ulInst->genSts.pdusRecv,
182                      ulInst->genSts.unexpPdusRecv,
183                      ulInst->genSts.errorPdusRecv);
184    RTLIN_DUMP_DEBUG("RLC_AMDL: StaPduSent:%u NacksInStaPdu:%u BytesUnused:%u PollTimerExpires SRB:%u DRB:%u MaxRetx:%u RetransPdus:%u \n"
185                     "      SDUs Tx :(%u) SDU Bytes Tx :(%u) SDUs Retx :(%u) WindowStalls: (%u) \n"
186
187                     "RLC_AMUL: PdusDiscarded:%u ReAsmblTimerExpires:%u StaPduRcvd:%u NackInStaPduRcvd:%u \n"
188                     "      DropOutWinRx :(%u) SDUs Rx :(%u) SDU Bytes Rx :(%u) SDUNack Rx :(%u) Duplicate Pdu Rx:(%u) \n", 
189                      gRlcStats.amRlcStats.numDLStaPduSent, gRlcStats.amRlcStats.numDLNacksInStaPdu, gRlcStats.amRlcStats.numDLBytesUnused, 
190                      gRlcStats.amRlcStats.numDLPollTimerExpiresSrb, gRlcStats.amRlcStats.numDLPollTimerExpiresDrb,
191                      gRlcStats.amRlcStats.numDLMaxRetx, gRlcStats.amRlcStats.numDLRetransPdus,
192                      gRlcStats.amRlcStats.numRlcAmCellSduTx, gRlcStats.amRlcStats.numRlcAmCellSduBytesTx,
193                      gRlcStats.amRlcStats.numRlcAmCellRetxPdu, gRlcStats.amRlcStats.numRlcAmCellWinStall,
194                      gRlcStats.amRlcStats.numULPdusDiscarded, gRlcStats.amRlcStats.numULReAsmblTimerExpires, 
195                      gRlcStats.amRlcStats.numULStaPduRcvd, gRlcStats.amRlcStats.numULNackInStaPduRcvd,
196                      gRlcStats.amRlcStats.numRlcAmCellDropOutWinRx, gRlcStats.amRlcStats.numRlcAmCellSduRx,
197                      gRlcStats.amRlcStats.numRlcAmCellSduBytesRx, gRlcStats.amRlcStats.numRlcAmCellNackRx, gRlcStats.amRlcStats.numRlcAmCellDupPduRx);
198 }
199 #endif
200
201 /*******************************************************************
202  *
203  * @brief 
204  *    Handler for storing all DL PDU Info into RLC-MAC interface
205  *    struct and sending to lower interface
206  *
207  * @details
208  *    This function stores DL PDU info for all logical channels
209  *    of per UE grant per TTI and sends to MAC
210  *
211  *    Function : rlcSendDedLcDlData 
212  *
213  * @params[in] 
214  * @return ROK     - success
215  *         RFAILED - failure
216  *
217  * ****************************************************************/
218 uint8_t rlcSendDedLcDlData(Pst *post, SpId spId, RguDDatReqInfo *datReqInfo)
219 {
220    uint8_t          ueIdx;                /* UE info list iterator */ 
221    uint8_t          tbIdx;                /* TB info list iterator */
222    uint8_t          lchIdx;               /* Lch info list iterator */
223    uint8_t          pduIdx;               /* RLC PDU list iterator */
224    RguDDatReqPerUe  datPerUe;             /* DL data info per UE */
225    RguDatReqTb      datPerTb;             /* DL data info per TB */
226    RguLchDatReq     datPerLch;            /* DL data info per Lch */
227    RlcData          *dlData = NULLP;      /* DL data to be sent to MAC */
228    RlcDlRrcMsgRsp   *dlRrcMsgRsp = NULLP; /*DL RRC Rsp to be sent to DU*/
229    Pst              pst;                  /* Post structure */
230    uint16_t         pduLen;               /* PDU length */
231    uint16_t         copyLen;              /* Number of bytes copied */
232    uint8_t          lcId = 0;
233
234    RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL,
235                        dlData, sizeof(RlcData));
236    if(dlData == NULLP)
237    {
238       DU_LOG("\nERROR  -->  RLC_DL : rlcSendDedLcDlData: Memory allocation failed for dl data");
239       RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL,
240           datReqInfo, sizeof(RguDDatReqInfo));
241       return RFAILED;
242    }
243    memset(dlData, 0, sizeof(RlcData));
244
245    for(ueIdx = 0; ueIdx < datReqInfo->nmbOfUeGrantPerTti; ueIdx++)
246    {
247       datPerUe = datReqInfo->datReq[ueIdx];
248
249       dlData->cellId = datReqInfo->cellId;
250       dlData->rnti = datPerUe.rnti;
251       /* Retrieving sfn/slot from transId. It was filled in RlcProcSchedResultRpt */
252       dlData->slotInfo.sfn = datPerUe.transId >> 16;
253       dlData->slotInfo.slot = datPerUe.transId & 0xffff;
254       dlData->numPdu = 0;
255       dlData->numLc = 0;
256
257       for(tbIdx = 0; tbIdx < datPerUe.nmbOfTbs; tbIdx++)
258       {
259          datPerTb = datPerUe.datReqTb[tbIdx];
260          for(lchIdx = 0; lchIdx < datPerTb.nmbLch; lchIdx++)
261          {
262             datPerLch = datPerTb.lchData[lchIdx];
263             lcId = datPerLch.lcId;
264             for(pduIdx = 0; pduIdx < datPerLch.pdu.numPdu; pduIdx++)
265             {
266                dlData->pduInfo[dlData->numPdu].commCh = FALSE;
267                dlData->pduInfo[dlData->numPdu].lcId = datPerLch.lcId;
268
269                /* Copy Message to fixed buffer to send */
270                ODU_GET_MSG_LEN(datPerLch.pdu.mBuf[pduIdx], (MsgLen *)&pduLen);
271                RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL,
272                   dlData->pduInfo[dlData->numPdu].pduBuf, pduLen);
273
274                if (dlData->pduInfo[dlData->numPdu].pduBuf == NULLP )
275                {
276                   DU_LOG("\nERROR  -->  RLC_DL : rlcSendDedLcDlData: Memory allocation failed");
277                   for(pduIdx = 0; pduIdx < dlData->numPdu; pduIdx++)
278                   {
279                      RLC_FREE_SHRABL_BUF(pst.region, pst.pool, dlData->pduInfo[pduIdx].pduBuf,\
280                        dlData->pduInfo[pduIdx].pduLen);
281                   }
282                   RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL,
283                      dlData, sizeof(RlcData));
284                   RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL,
285                      datReqInfo, sizeof(RguDDatReqInfo));
286                   return RFAILED;
287                }
288
289                ODU_COPY_MSG_TO_FIX_BUF(datPerLch.pdu.mBuf[pduIdx], 0, pduLen, \
290                   dlData->pduInfo[dlData->numPdu].pduBuf, (MsgLen *)&copyLen);
291                dlData->pduInfo[dlData->numPdu].pduLen = pduLen;
292
293                /* Free message */
294                ODU_PUT_MSG_BUF(datPerLch.pdu.mBuf[pduIdx]);
295
296                dlData->numPdu++;
297             }/* For per PDU */
298             dlData->boStatus[dlData->numLc].cellId = datReqInfo->cellId;
299             GET_UE_IDX(datPerUe.rnti, dlData->boStatus[dlData->numLc].ueIdx);
300             dlData->boStatus[dlData->numLc].commCh = false;
301             dlData->boStatus[dlData->numLc].lcId = datPerLch.lcId;
302             dlData->boStatus[dlData->numLc].bo = datPerLch.boReport.bo + datPerLch.boReport.estRlcHdrSz;
303             dlData->numLc++;
304          }/* For Data per Lch */
305       }/* For Data per Tb */
306
307       RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL, dlRrcMsgRsp, sizeof(RlcDlRrcMsgRsp));
308       if(dlRrcMsgRsp == NULLP)
309       {
310          DU_LOG("\nERROR  -->  RLC_DL : rlcSendDedLcDlData: Memory allocation failed for dlRrcMsgRsp");
311          for(pduIdx = 0; pduIdx < dlData->numPdu; pduIdx++)
312          {
313             RLC_FREE_SHRABL_BUF(pst.region, pst.pool, dlData->pduInfo[pduIdx].pduBuf,\
314                dlData->pduInfo[pduIdx].pduLen);
315          }
316          RLC_FREE_SHRABL_BUF(pst.region, pst.pool, dlData, sizeof(RlcData));
317          RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL,
318              datReqInfo, sizeof(RguDDatReqInfo));
319          return RFAILED;
320       }
321       dlRrcMsgRsp->cellId = dlData->cellId;
322       dlRrcMsgRsp->crnti = dlData->rnti;
323
324       /* Sending DL Data per UE to MAC */
325       FILL_PST_RLC_TO_MAC(pst, RLC_DL_INST, EVENT_DL_DATA_TO_MAC);
326       if(RlcSendDlDataToMac(&pst, dlData) != ROK)
327       {
328          DU_LOG("\nERROR  -->  RLC_DL : rlcSendDedLcDlData: Failed to send Dl RRC Msg To Mac");
329          dlRrcMsgRsp->state = TRANSMISSION_FAILED;
330          for(pduIdx = 0; pduIdx < dlData->numPdu; pduIdx++)
331          {
332             RLC_FREE_SHRABL_BUF(pst.region, pst.pool, dlData->pduInfo[pduIdx].pduBuf,\
333                dlData->pduInfo[pduIdx].pduLen);
334          }
335          RLC_FREE_SHRABL_BUF(pst.region, pst.pool, dlData, sizeof(RlcData));
336          RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RguDDatReqInfo));
337          RLC_FREE_SHRABL_BUF(pst.region, pst.pool, dlRrcMsgRsp, sizeof(RlcDlRrcMsgRsp));
338          return RFAILED;
339       }
340       else
341          dlRrcMsgRsp->state = TRANSMISSION_COMPLETE;
342
343       FILL_PST_RLC_TO_DUAPP(pst, RLC_DL_INST, EVENT_DL_RRC_MSG_RSP_TO_DU);
344       if(lcId >= SRB1_LCID && lcId <= SRB3_LCID) /* Valid for all RRC messages i.e. SRB1, SRB2, SRB3 */
345       {
346          if(rlcSendDlRrcMsgRspToDu(&pst, dlRrcMsgRsp) != ROK)
347          {
348             DU_LOG("\nERROR  -->  RLC_DL : rlcSendDedLcDlData: Failed to send Dl RRC Msg Rsp To Du");
349             RLC_FREE_SHRABL_BUF(pst.region, pst.pool, dlRrcMsgRsp, sizeof(RlcDlRrcMsgRsp));
350             RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RguDDatReqInfo));
351             return RFAILED;
352          }
353       }
354    } /* For Data per UE */
355    RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RguDDatReqInfo));
356    
357    return ROK;
358 }/* End of rlcSendDedLcDlData */
359
360 /**
361  *
362  * @brief 
363  *        Handler for sending the data to multiple logical channels of a UE
364  *
365  * @details:
366  *        This function sends the data for one or more logical channels
367  *        after processing the SDUs and forming the PDUs.It calls
368  *        UMM or AMM functions to form the PDUs for the requested sizes
369  *        by MAC. 
370  *
371  * @param[in] gCb          RLC instance Control block 
372  * @param[in] staIndInfo   Status Indication Information containing the 
373  *                         size of PDU(s) for one or more logical channels  
374  *
375  * @return  S16
376  *      -# ROK 
377  *      -# RFAILED
378  *
379  */
380 uint8_t rlcUtlSendToMac(RlcCb *gCb, SuId suId, KwDStaIndInfo *staIndInfo)
381 {
382    uint8_t           numPdu = 0;
383    uint16_t          ueId;
384    RlcDlUeCb         *ueCb;         /* UE control block */
385    uint32_t          count;         /* Loop Counter */
386    uint32_t          numTb;         /* Number of Tbs */
387    RlcDlRbCb         *rbCb;         /* RB Control Block */
388    RlcDatReq         datReq;        /* PDUs Information */
389    RguDDatReqInfo   *datReqInfo;   /* Data Request Information */
390    RlcRguSapCb      *rguSap;       /* MAC SAP CB */
391    uint32_t         totNumPdu;     /* Total number of PDUS */
392    RguStaIndTb      *staIndTb = NULLP;
393    RguDatReqTb      *datReqTb = NULLP;
394    RguDStaIndPerUe  *staInd = NULLP;
395 #ifdef LTE_L2_MEAS   
396    uint32_t   grantPerLch[RGU_MAX_LC] = {0};
397 #endif
398 /* kw005.201 added support for L2 Measurement */
399 #ifdef LTE_L2_MEAS_LOSS_DELAY
400    uint8_t        snIdx1;
401    uint8_t        snIdx2;
402 #endif /* LTE_L2_MEAS */
403    uint32_t  idx, ueDataIdx = 0;
404
405 //Debug
406    uint32_t staIndSz=0,datIndSz = 0;
407
408    datReqInfo = NULLP;
409    RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL,
410                        datReqInfo,sizeof(RguDDatReqInfo));
411 #if (ERRCLASS & ERRCLS_ADD_RES)
412       if ( datReqInfo == NULLP )
413       {
414          DU_LOG("\nERROR  -->  RLC_DL : rlcUtlSendToMac: Memory allocation failed");
415          return RFAILED;
416       }
417 #endif /* ERRCLASS & ERRCLS_ADD_RES */
418    for(idx = 0; idx < staIndInfo->nmbOfUeGrantPerTti; idx++)
419    {
420       staInd = &staIndInfo->staInd[idx];
421       /* Fetch Ue control block */
422       GET_UE_IDX(staInd->rnti, ueId);
423       if(ROK != rlcDbmFetchDlUeCb(gCb, ueId, staIndInfo->cellId,&ueCb))
424       {
425          /* Fetch UeCb failed */
426          DU_LOG("\nERROR  -->  RLC_DL : rlcUtlSendToMac: UeId[%u]:ueCb not found",
427             staInd->rnti);
428          /* If ueCb is not found for current rnti then continue to look for next rnti*/
429          continue; 
430       }
431       
432       /* kw002.201 Removed the allocation of RlcDatReq */
433       /* kw004.201 Used SSI function to initialize the variable */
434       memset(&datReq, 0, sizeof(RlcDatReq) ); 
435       totNumPdu = 0;
436       for (numTb = 0; numTb < staInd->nmbOfTbs; numTb++)
437       {
438          staIndTb = &(staInd->staIndTb[numTb]);
439          datReqTb = &(datReqInfo->datReq[ueDataIdx].datReqTb[numTb]);
440 #ifdef LTE_L2_MEAS
441          ueCb->tbIdx = (ueCb->tbIdx+1) % RLC_MAX_TB_PER_UE;
442 #endif   
443          for (count = 0;count < staIndTb->nmbLch; count++)
444          {
445 #ifdef LTE_L2_MEAS
446             /*Calculate the total grant size from MAC */
447             if((staIndTb->lchStaInd[count].lcId >= RGU_MAX_LC) 
448                 || (staIndTb->lchStaInd[count].lcId == 0))
449             {
450                /* TODO : Need to figure out why this is happening */
451                break;
452             }
453             else
454             {
455                grantPerLch[staIndTb->lchStaInd[count].lcId] += staIndTb->lchStaInd[count].totBufSize;
456             }
457 #endif   
458             rbCb = ueCb->lCh[staIndTb->lchStaInd[count].lcId - 1].dlRbCb;
459
460             if (rbCb && (!rlcDlUtlIsReestInProgress(rbCb)))
461             { 
462                /* Cosider buffer size for throughput calculation */
463                if(gCb->rlcThpt.thptPerUe[ueId-1].ueId == ueId)
464                   gCb->rlcThpt.thptPerUe[ueId-1].dataVol += staIndTb->lchStaInd[count].totBufSize;
465
466                staIndSz += staIndTb->lchStaInd[count].totBufSize;
467                datReq.pduSz = staIndTb->lchStaInd[count].totBufSize;
468 #ifdef LTE_L2_MEAS            
469                datReq.totMacGrant = grantPerLch[staIndTb->lchStaInd[count].lcId];
470 #endif
471                rlcUtlGetCurrTime(&datReq.boRep.oldestSduArrTime);
472                if ( RLC_MODE_UM == rbCb->mode )
473                {
474                   rlcUmmProcessSdus(gCb,rbCb,&datReq);
475                }
476                else if ( RLC_MODE_AM == rbCb->mode )
477                {
478                   rlcAmmProcessSdus(gCb,rbCb,&datReq,staInd->fillCtrlPdu);
479                }
480 #ifdef LTE_L2_MEAS            
481                grantPerLch[staIndTb->lchStaInd[count].lcId] = datReq.totMacGrant;
482 #endif
483                if ( 0 == datReq.pduInfo.numPdu )
484                {
485                   continue;
486                }
487                totNumPdu += datReq.pduInfo.numPdu;
488                memcpy(&(datReqTb->lchData[count].pdu),
489                   &(datReq.pduInfo),sizeof(KwPduInfo));
490
491                for (;numPdu < datReqTb->lchData[count].pdu.numPdu ; numPdu ++)
492                {
493                   MsgLen len = 0;
494                   ODU_GET_MSG_LEN(datReqTb->lchData[count].pdu.mBuf[numPdu],&len);
495                   datIndSz += len; 
496                }
497                datReqTb->lchData[count].setMaxUlPrio = FALSE;
498                if (RLC_AM_IS_POLL_BIT_SET(RLC_AMDL) && 
499                    (RLC_AMDL.sduQ.count > 1))
500                { 
501                   /* Poll bit is set indicate to MAC*/
502                   datReqTb->lchData[count].setMaxUlPrio = TRUE;
503                }
504                datReqTb->lchData[count].boReport.bo = datReq.boRep.bo;
505
506 #ifdef CCPU_OPT
507                datReqTb->lchData[count].boReport.estRlcHdrSz = 
508                   datReq.boRep.estHdrSz;
509                datReqTb->lchData[count].boReport.staPduPrsnt = 
510                   datReq.boRep.staPduPrsnt;
511 #endif /* CCPU_OPT */
512                datReqTb->lchData[count].boReport.staPduBo = 
513                   datReq.boRep.staPduBo;
514                datReqTb->lchData[count].lcId = staIndTb->lchStaInd[count].lcId;
515
516 #ifdef L2_OPTMZ
517                /* Set if Bearer is UM */
518                if ( RLC_MODE_UM == rbCb->mode )
519                {
520                   datReqTb->lchData[count].freeBuff = TRUE;
521                }
522                else
523                {
524                   datReqTb->lchData[count].freeBuff = FALSE;
525                }
526 #endif
527
528                /* kw005.201 added support for L2 Measurement */
529 #ifdef LTE_L2_MEAS_LOSS_DELAY
530                datReqTb->rguSnInfo->lchMap[count].lChId =
531                   staIndTb->lchStaInd[count].lcId;
532                /* In some cases L2 Measurement for few of the lcId may be off, 
533                 * in this case we are assigning snList to 0xffff 
534                 */
535                for(snIdx1 = 0; snIdx1 < RGU_MAX_PDU; snIdx1++)
536                {
537                   datReqTb->rguSnInfo->lchMap[count].snList[snIdx1] = 0xffff;
538                }
539                if(tbSnMap->numSn != 0)
540                {
541                   snIdx2 = 0;
542                   for(snIdx1=tbSnMap->prevNumSn;snIdx1 < tbSnMap->numSn;snIdx1++)
543                   {
544                      datReqTb->rguSnInfo->lchMap[count].snList[snIdx2++] = 
545                         tbSnMap->snSduMap[snIdx1].sn;
546                   }
547                   tbSnMap->prevNumSn = tbSnMap->numSn;
548                }
549 #endif
550                datReqTb->lchData[count].boReport.oldestSduArrTime = 
551                                              datReq.boRep.oldestSduArrTime;
552                /* kw004.201 Used SSI function to initialize the variable */
553                memset(&datReq, 0, sizeof(RlcDatReq) ); 
554             }
555          }
556 #ifdef LTE_L2_MEAS
557          if(ueCb->l2MeasTbCb[ueCb->tbIdx]!= NULLP)
558          {
559             datReqTb->tbId = ueCb->tbIdx;
560          }
561          else
562          {
563             datReqTb->tbId = RLC_INVALID_TBID; 
564          }
565 #endif
566          datReqTb->nmbLch = staIndTb->nmbLch;
567          /*adding the check to make sure that lcId is not sent as 0
568           * when no data is there in datReq */
569          if ( 0 == totNumPdu )
570          {
571             datReqTb->lchData[0].lcId = staIndTb->lchStaInd[0].lcId;
572          }
573          /* kw005.201 added support for L2 Measurement */
574 #ifdef LTE_L2_MEAS_LOSS_DELAY
575          if(tbSnMap->numSn == 0)
576          {
577             RLC_FREE(tbSnMap,sizeof(RlcTbSnMap));
578             RLC_FREE(datReqTb->rguSnInfo,sizeof(RguSnMapInfo));
579             datReqTb->rguSnInfo = NULLP;
580             rlcCb.rlcL2Cb.curTbSnMap = NULLP;
581             datReqTb->snMapPres = FALSE;
582          }
583          else
584          {
585             cmHashListInsert(&(rlcCb.rlcL2Cb.tbHlCp),(PTR)tbSnMap,
586                   (uint8_t *) &(tbSnMap->tbId), (uint16_t)sizeof(tbSnMap->tbId));
587             rlcCb.rlcL2Cb.curTbSnMap = NULLP;
588          }
589 #endif /* LTE_L2_MEAS */
590       }
591       datReqInfo->datReq[ueDataIdx].nmbOfTbs = staInd->nmbOfTbs;
592       datReqInfo->datReq[ueDataIdx].transId = staInd->transId;
593       datReqInfo->datReq[ueDataIdx].rnti    = staInd->rnti;
594       ueDataIdx++;
595    }
596
597    if(ueDataIdx > 0)
598    {
599       datReqInfo->cellId  = staIndInfo->cellId;
600       datReqInfo->nmbOfUeGrantPerTti = staIndInfo->nmbOfUeGrantPerTti;
601
602       rguSap = &(gCb->u.dlCb->rguDlSap[suId]);
603       rlcSendDedLcDlData(&rguSap->pst,rguSap->spId,datReqInfo); 
604    }
605    else
606    {
607       RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo,sizeof(RguDDatReqInfo));
608    }
609    return ROK;
610 }
611
612 /**
613  *
614  * @brief 
615  *        Handler for sending Status Response to MAC. 
616  *
617  * @detail:
618  *        This function is used by  RLC entity for sending
619  *        status response to MAC after receiving a SDU from
620  *        PDCP.
621  *
622  * @param[in]  gCb           RLC instance Control block
623  * @param[in]  rbCb          Radio Bearer Control Block 
624  * @param[in]  bo            Buffer Occupancy
625  * @param[in]  estHdrSz      Estimated Header Size
626  * @param[in]  staPduPrsnt   Status PDU present or not
627  *
628  * @return  S16
629  *      -# ROK 
630  *      -# RFAILED
631  */
632 uint8_t rlcUtlSendDedLcBoStatus(RlcCb *gCb, RlcDlRbCb *rbCb, int32_t bo, \
633    int32_t estHdrSz, bool staPduPrsnt, uint32_t staPduBo)
634 {
635    Pst           pst;           /* Post info */
636    RlcBoStatus   *boStatus;      /* Buffer occupancy status information */
637
638 #ifndef TENB_ACC
639    if ((rbCb->lastRprtdBoToMac > (uint32_t)8000) && (rbCb->boUnRprtdCnt < (uint32_t)5) 
640        && (!staPduPrsnt) && ((RLC_MODE_AM == rbCb->mode ) && (RLC_AMDL.nxtRetx == NULLP)))
641    {
642       rbCb->boUnRprtdCnt++;
643       return ROK;
644    }
645 #endif
646    rbCb->boUnRprtdCnt = (uint32_t)0;
647    rbCb->lastRprtdBoToMac = (uint32_t)bo;
648
649    RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL, \
650       boStatus, sizeof(RlcBoStatus));
651
652    boStatus->cellId = rbCb->rlcId.cellId;
653    boStatus->ueIdx = rbCb->rlcId.ueId;
654    boStatus->commCh = FALSE; 
655    boStatus->lcId = rbCb->lch.lChId;
656    boStatus->bo = bo + estHdrSz;
657
658    FILL_PST_RLC_TO_MAC(pst, RLC_DL_INST, EVENT_BO_STATUS_TO_MAC);
659    /* Send Status Response to MAC layer */
660    if(RlcSendBoStatusToMac(&pst, boStatus) != ROK)
661    {
662       RLC_FREE_SHRABL_BUF(pst.region, pst.pool, boStatus, sizeof(RlcBoStatus));
663    }
664
665    return ROK;
666 }
667
668 /**
669  *
670  * @brief 
671  *        Handler for emptying the SDU queue. 
672  * 
673  * @detail:
674  *        This function is used to empty the SDU queue when
675  *        a re-establishment request is received from the 
676  *        upper layer.
677  *
678  * @param[in]  gCb    RLC instance control block
679  * @param[in]  rbCb   Radio bearer control block
680  * @param[in]  sduQ   SDU queue to be emptied
681  *
682  * @return Void 
683  */
684 /* kw005.201 added support for L2 Measurement */
685 #ifdef LTE_L2_MEAS_RLC
686 Void rlcUtlEmptySduQ
687 (
688 RlcCb        *gCb, 
689 RlcDlRbCb    *rbCb,
690 CmLListCp   *sduQ 
691 )
692 #else
693 Void rlcUtlEmptySduQ
694 (
695 RlcCb        *gCb,
696 CmLListCp   *sduQ 
697 )
698 #endif
699 {
700 #ifdef LTE_L2_MEAS_RLC
701    CmLListCp   *sduSnMapQ;             /* SDU Sequence number map queue */
702    CmLList     *firstSduSnMap;         /* First Node in SDU SnMap Queue */
703    RlcSduSnMap  *sduSnMap;              /* SDU Sn Map */
704
705    sduSnMapQ = NULLP;
706    firstSduSnMap = NULLP;
707    sduSnMap = NULLP;
708
709
710    sduSnMapQ = &rbCb->sduSnMapQ;
711    CM_LLIST_FIRST_NODE(sduSnMapQ, firstSduSnMap);
712
713    while(firstSduSnMap)
714    {
715       sduSnMap = (RlcSduSnMap *)firstSduSnMap->node;
716       if(sduSnMap != NULLP)
717       {
718          cmLListDelFrm(&(rbCb->sduSnMapQ), &(sduSnMap->lstEnt));
719          RLC_FREE(sduSnMap, sizeof(RlcSduSnMap));
720          CM_LLIST_FIRST_NODE(sduSnMapQ, firstSduSnMap);
721       }
722       else
723       {
724          CM_LLIST_NEXT_NODE(sduSnMapQ, firstSduSnMap);
725       }
726    }
727 #endif
728    return;
729 }
730
731 /**
732  *
733  * @brief 
734  *    Function to set that re-establishment has started for an RB
735  * 
736  * @detail:
737  *    This function is used to set the reestInProgress flag to TRUE.
738  *    This also sets the estimated header size to 0 and sends bo as
739  *    0 to MAC so that RLC does not need to transmit any data.
740  *    If the poll re-transmit timer is running for the RB;
741  *    it is stopped
742  *
743  * @param[in]      gCb      RLC instance control block 
744  * @param[in]      rbCb     RB for which re-establishment has started 
745  *
746  * @return  void 
747  */
748 Void rlcDlUtlSetReestInProgressForRB(RlcCb *gCb,RlcDlRbCb *rbCb)
749 {
750       
751    rbCb->reestInProgress = TRUE;
752    
753    if(rbCb->mode == RLC_MODE_AM )
754    {
755       rbCb->m.amDl.estHdrSz = 0;
756
757       if(rlcChkTmr(gCb, (PTR)rbCb, EVENT_RLC_AMDL_POLL_RETX_TMR))
758       {
759          rlcStopTmr(gCb, (PTR)rbCb, EVENT_RLC_AMDL_POLL_RETX_TMR);
760       }
761    }
762    rlcUtlSendDedLcBoStatus(gCb, rbCb, 0, 0, FALSE,0);
763
764    return;
765 }
766
767 /**
768  *
769  * @brief 
770  *    Function to check if re-establishment is ongoing for an RB
771  * 
772  * @param[in]      rbCb     RB for which re-establishment is to be checked 
773  *
774  * @return  Bool
775  *          TRUE  : Re-establishment is in progress
776  *          FALSE : Re-establishment is not in progress
777  */
778 bool rlcDlUtlIsReestInProgress(RlcDlRbCb *rbCb)
779 {
780    return (rbCb->reestInProgress);
781 }
782
783 /**
784  *
785  * @brief 
786  *    Function to set re-establishment to FALSE
787  * 
788  * @param[in]      rbCb     RB for which re-establishment is to be reset 
789  *
790  * @return  Void
791  */
792 Void rlcDlUtlResetReestInProgress(RlcDlRbCb *rbCb)
793 {
794
795    rbCb->reestInProgress = FALSE;
796 }
797
798 /**
799  *
800  * @brief 
801  *    Function to set that re-establishment has started for all the RBs
802  *    of an UE; except for SRB1
803  *
804  * @detail: For SRB1 only the poll-retransmit timer is stopped
805  * 
806  * @param[in]      gCb      RLC instance control block 
807  * @param[in]      ueCb     UE for which re-establishment has started 
808  *
809  * @return  void 
810  */
811 Void rlcDlUtlSetReestInProgressForAllRBs(RlcCb *gCb,RlcDlUeCb *ueCb)
812 {
813    uint32_t        rbIdx;
814    
815    for(rbIdx = 0;rbIdx < RLC_MAX_SRB_PER_UE;rbIdx++)
816    {
817       if(ueCb->srbCb[rbIdx] != NULLP)
818       {
819          if(ueCb->srbCb[rbIdx]->rlcId.rbId != 1)
820          {
821             rlcDlUtlSetReestInProgressForRB(gCb,ueCb->srbCb[rbIdx]); 
822          }
823          else
824          {
825             /* For SRB we just need to stop the poll re-transmit timer */
826             if(rlcChkTmr(gCb, (PTR)ueCb->srbCb[rbIdx], EVENT_RLC_AMDL_POLL_RETX_TMR))
827             {
828                rlcStopTmr(gCb, (PTR)ueCb->srbCb[rbIdx], EVENT_RLC_AMDL_POLL_RETX_TMR);
829             }
830          }
831       }
832    }
833    
834    for(rbIdx = 0;rbIdx < RLC_MAX_DRB_PER_UE;rbIdx++)
835    {
836       if(ueCb->drbCb[rbIdx] != NULLP)
837       {
838          rlcDlUtlSetReestInProgressForRB(gCb,ueCb->drbCb[rbIdx]);
839       }
840    }
841       
842    return;
843 }
844
845 /**
846  * @brief  Function to increment number of SDUs transmitted 
847  *         in KWU SAP statistics
848  *
849  *
850  * @param[in]  rlckwuSap     KWU SAP in which to increment the counter
851  *
852  * @return  Void
853  */
854 void rlcUtlIncrementKwuStsSduTx(RlcKwuSapCb *rlckwuSap)
855 {
856    rlckwuSap->sts.sduTx++;
857    return;
858 }
859
860 /**
861  * @brief  Function to increment number of bytes and PDUs transmitted 
862  *         in General statistics
863  *
864  *
865  * @param[in]  genSts   KWU SAP in which to increment the counter
866  * @param[in]  pdu      The PDU which is sent
867  *
868  * @return  Void
869  */
870 void rlcUtlIncrementGenStsBytesAndPdusSent(RlcGenSts *genSts, Buffer *pdu)
871 {
872    MsgLen bytesSent;
873    ODU_GET_MSG_LEN(pdu, &bytesSent);
874    genSts->bytesSent += bytesSent;
875    genSts->pdusSent++;
876    return;
877 }
878
879 /**
880  * @brief  Function to initialize the data structures used to free memory
881  *
882  *
883  * @param[in]  gCb        RLC instance control block
884  * @param[out] toBeFreed  Pointer to the freeing structure. This is 
885  *                        initialized here
886  *
887  * @return  Void
888  */
889 Void rlcUtlInitToBeFreed(RlcCb *gCb,RlcDlDataToBeFreed *toBeFreed)
890 {
891    cmLListInit(&(toBeFreed->sduLst));
892    cmLListInit(&(toBeFreed->rbLst));
893    cmLListInit(&(toBeFreed->reTxLst));
894    cmLListInit(&(toBeFreed->txLst));
895    
896    return;
897 }
898
899 /**
900  * @brief  Function to initialize the DL self Pst structure
901  *
902  *
903  * @param[in]  gCb   RLC instance control block
904  *
905  * @return  Void
906  */
907 Void rlcUtlInitializeSelfPst(RlcCb *gCb)
908 {
909    Pst *selfPst = &gCb->u.dlCb->selfPst;
910    
911    RLC_MEM_SET(selfPst, 0, sizeof(Pst));
912    selfPst->srcProcId = SFndProcId();
913    selfPst->dstProcId = SFndProcId();
914    selfPst->dstEnt = gCb->init.ent;
915    selfPst->dstInst = gCb->init.inst; /* this is for the DL instance */
916    selfPst->srcEnt = gCb->init.ent;
917    selfPst->srcInst = gCb->init.inst;  /* DL instance will send to itself */
918    selfPst->prior  = PRIOR3;
919    selfPst->event  = UDX_EVT_DL_CLEANUP_MEM;
920 }
921
922 /**
923  * @brief  Function to send a DL cleanup event
924  *
925  *
926  * @param[in]  gCb   RLC instance control block
927  *
928  * @return  Void
929  */
930 void rlcUtlRaiseDlCleanupEvent(RlcCb *gCb)
931 {
932 #ifdef KWSELFPSTDLCLEAN
933    if(!gCb->u.dlCb->eventInQueue)
934    {
935       ODU_POST_TASK(&gCb->u.dlCb->selfPst, gCb->u.dlCb->selfPstMBuf);
936       gCb->u.dlCb->eventInQueue = TRUE;
937    }
938 #endif
939    return;
940 }
941
942 /**
943  * @brief  Function to add a SDU to the to be freed sdu list
944  *
945  *
946  * @param[in]  gCb   RLC instance control block
947  * @param[in]  sdu   SDU to be added to the list
948  *
949  * @return  Void
950  */
951 void rlcUtlAddSduToBeFreedQueue(RlcCb *gCb, RlcSdu *sdu)
952 {
953    cmLListAdd2Tail(&(gCb->u.dlCb->toBeFreed.sduLst), &(sdu->lstEnt));
954    return;
955 }
956
957 /**
958  * @brief  Function to add a re-transmitted pdu to the to be freed list
959  *
960  *
961  * @param[in]  gCb   RLC instance control block
962  * @param[in]  retx  Re-transmitted pdu to be added to the list
963  *
964  * @return  Void
965  */
966 Void rlcUtlAddReTxPduToBeFreedQueue(RlcCb *gCb,RlcRetx *retx)
967 {
968    cmLListAdd2Tail(&(gCb->u.dlCb->toBeFreed.reTxLst), &(retx->lstEnt));
969    return;
970 }
971
972 /**
973  * @brief  Function to add a transmitted pdu to the to be freed list
974  *
975  *
976  * @param[in]  gCb   RLC instance control block
977  * @param[in]  pdu   PDU to be added to the list
978  *
979  * @return  Void
980  */
981 Void rlcUtlAddTxPduToBeFreedQueue(RlcCb   *gCb,RlcTx   *pdu)
982 {
983    pdu->rlsLnk.node = (PTR)pdu;
984    cmLListAdd2Tail(&(gCb->u.dlCb->toBeFreed.txLst), &(pdu->rlsLnk));
985    return;
986 }
987
988 /*
989  * @brief
990  *    function to free/release the Acknowledged mode RBCB buffers
991  *
992  * @details
993  *    This primitive Frees the Acknowledged Mode RbCb transmission Buffer,
994  *    retransmission Buffer and reciption Buffers
995  *
996  * @param [in]      gCb       - RLC instance control block
997  * @param [in]      rbCb      - Downlink RB Control Block
998  * @param [in,out]  toBeFreed - Number of buffers to be freed
999  *
1000  * @return Bool
1001  *     - TRUE if more data to be freed
1002  *     - FALSE if all the data has been freed
1003  */
1004 static Bool rlcUtlFreeDlAmRbMemory(RlcCb *gCb,RlcDlRbCb *rbCb,uint32_t *toBeFreed)
1005 {
1006    RlcRetx   *retx;   /* retransmission buffer */
1007    RlcSn     mTxNext;    /* send state variable */
1008    RlcTx      *txBuf;
1009
1010    MODAMT(RLC_AMDL.txNext, mTxNext, RLC_AMDL.txNextAck,RLC_AMDL.snModMask);
1011
1012    /* TODO : to be checked changed from <= to < */
1013    while ((0 < mTxNext) && *toBeFreed)
1014    {
1015       txBuf =  rlcUtlGetTxBuf(RLC_AMDL.txBufLst, RLC_AMDL.txNextAck);
1016       if (txBuf && txBuf->pduLst.first)
1017       {
1018          while(txBuf->pduLst.first)
1019          {
1020             RlcDlPduInfo *pduInfo = (RlcDlPduInfo *)(txBuf->pduLst.first->node);
1021             ODU_PUT_MSG_BUF(pduInfo->pdu);
1022             /* Delete node from the txBuf Pdu lst */
1023             cmLListDelFrm(&txBuf->pduLst, txBuf->pduLst.first);
1024             RLC_FREE(gCb, pduInfo, sizeof(RlcDlPduInfo));
1025          }
1026          rlcUtlDelTxBuf(RLC_AMDL.txBufLst, txBuf, gCb);
1027          if(gCb->u.dlCb->shutdownReceived == 0)
1028          {   
1029             (*toBeFreed)--;
1030          }
1031       }
1032       RLC_AMDL.txNextAck = (RLC_AMDL.txNextAck + 1) & RLC_AMDL.snModMask;
1033       MODAMT(RLC_AMDL.txNext, mTxNext, RLC_AMDL.txNextAck,RLC_AMDL.snModMask);
1034    }
1035    RLC_FREE(gCb, rbCb->snssai, sizeof(Snssai));
1036    if(*toBeFreed == 0)
1037    {
1038       return (TRUE);
1039    }
1040    
1041 #ifndef LTE_TDD 
1042       RLC_FREE(gCb,RLC_AMDL.txBufLst, (RLC_TX_BUF_BIN_SIZE * sizeof(CmLListCp)));
1043 #endif
1044
1045    RLC_LLIST_FIRST_RETX(RLC_AMDL.retxLst, retx);
1046    while (retx && (*toBeFreed)) /* Till to be freed becomes 0 */
1047    {
1048
1049       ODU_PUT_MSG_BUF(retx->seg);
1050
1051       cmLListDelFrm(&RLC_AMDL.retxLst, &retx->lstEnt);
1052       RLC_FREE(gCb, retx, sizeof(RlcRetx));
1053
1054       RLC_LLIST_FIRST_RETX(RLC_AMDL.retxLst, retx);
1055       if(gCb->u.dlCb->shutdownReceived == 0)
1056       {
1057       (*toBeFreed)--;
1058    }
1059
1060    }
1061
1062    RLC_AMDL.nxtRetx = NULLP;
1063
1064    /* clean up if there is info about STATUS PDU to be sent */
1065    if(RLC_AMDL.pStaPdu)
1066    {
1067       Pst *udxPst;
1068       udxPst = &gCb->u.dlCb->udxDlSap->pst;
1069       RLC_FREE_SHRABL_BUF_WC(udxPst->region,
1070                             udxPst->pool,
1071                             RLC_AMDL.pStaPdu, 
1072                             sizeof(RlcUdxDlStaPdu));
1073       RLC_AMDL.pStaPdu = NULLP;
1074    }
1075
1076    if(*toBeFreed == 0)
1077    {
1078       return (TRUE);
1079    }  
1080    if(gCb->u.dlCb->shutdownReceived)
1081    {   
1082       (*toBeFreed)--;
1083    }
1084    
1085    return (FALSE);
1086
1087
1088 /**
1089  * @brief  Function to free memory from the DL instance
1090  *
1091  *
1092  * @param[in]  gCb   RLC instance control block
1093  *
1094  * @return  Void
1095  */
1096 Void rlcUtlFreeDlMemory(RlcCb *gCb)
1097 {
1098    uint32_t toBeFreed; 
1099
1100    /* safety check, in case some event was still lying in the queue after
1101       the dlCb was deleted*/
1102    if(!gCb->u.dlCb)
1103    {
1104       return;
1105    }
1106
1107    RlcDlDataToBeFreed* pToBeFreed = &gCb->u.dlCb->toBeFreed;
1108    /* ccpu00136940 */
1109    if(gCb->u.dlCb->shutdownReceived)
1110    {
1111       toBeFreed = pToBeFreed->txLst.count + pToBeFreed->reTxLst.count + pToBeFreed->sduLst.count + pToBeFreed->rbLst.count; 
1112    }
1113    else
1114    {
1115       if ((pToBeFreed->txLst.count + pToBeFreed->reTxLst.count + pToBeFreed->sduLst.count) > (3 * RLC_MAX_TO_BE_FREED))
1116       {
1117 #if !defined(KWSELFPSTDLCLEAN) && defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS)
1118          if (isDatReqProcessed)
1119          {
1120             toBeFreed = (2 *RLC_MAX_TO_BE_FREED);
1121          }
1122          else
1123 #endif
1124          {
1125             toBeFreed = (3 *RLC_MAX_TO_BE_FREED)/2;
1126          }
1127       }
1128       else
1129       {
1130          toBeFreed = RLC_MAX_TO_BE_FREED;
1131       }
1132    }   
1133    CmLListCp        *lst;
1134
1135    gCb->u.dlCb->eventInQueue = FALSE; /* reset as we have received the event
1136                                          and are processing it */
1137
1138    /* Free from the ReTx list */
1139    lst  = &pToBeFreed->reTxLst;
1140    while((lst->first) && toBeFreed)
1141    {
1142       RlcRetx* seg = (RlcRetx *)(lst->first->node);
1143       cmLListDelFrm(lst, lst->first);
1144       ODU_PUT_MSG_BUF(seg->seg);
1145       RLC_FREE(gCb,seg, sizeof(RlcRetx));
1146       toBeFreed--;
1147    }   
1148
1149    /* Free from the Tx list */
1150    lst  = &pToBeFreed->txLst;
1151    while((lst->first) && toBeFreed)
1152    {
1153       RlcTx* pdu = (RlcTx *)(lst->first->node);
1154       cmLListDelFrm(lst, lst->first);
1155       while(pdu->pduLst.first)
1156       {
1157          RlcDlPduInfo *pduInfo = (RlcDlPduInfo *)(pdu->pduLst.first->node);
1158          
1159          cmLListDelFrm(&pdu->pduLst, pdu->pduLst.first);
1160          ODU_PUT_MSG_BUF(pduInfo->pdu);
1161          RLC_FREE(gCb, pduInfo, sizeof(RlcDlPduInfo));
1162       }
1163       RLC_FREE(gCb,pdu, sizeof(RlcTx));
1164       toBeFreed--;
1165    }
1166
1167    /* Free from the SDU queue */
1168    lst  = &pToBeFreed->sduLst;
1169    while((lst->first) && toBeFreed)
1170    {
1171       RlcSdu* sdu = (RlcSdu *)(lst->first->node);
1172       RLC_REMOVE_SDU(gCb, lst, sdu);
1173       toBeFreed--;
1174    }      
1175
1176    /* Free from the RBs */
1177    lst  = &pToBeFreed->rbLst;
1178    while((lst->first) && toBeFreed)
1179    {
1180       RlcDlRbCb* rbCb = (RlcDlRbCb *)(lst->first->node);
1181       Bool moreToBeFreed = rlcUtlFreeDlAmRbMemory(gCb, rbCb,&toBeFreed);
1182       if(!moreToBeFreed)
1183       {
1184          cmLListDelFrm(lst, lst->first);
1185          RLC_FREE(gCb, rbCb, sizeof(RlcDlRbCb));
1186       }
1187    } 
1188
1189    if ((toBeFreed == 0) && !(gCb->u.dlCb->shutdownReceived))
1190    {
1191       rlcUtlRaiseDlCleanupEvent(gCb);
1192    }
1193
1194    return;
1195 }
1196
1197
1198 #ifdef LTE_L2_MEAS
1199 /**
1200  *
1201  * @brief Function to initialise measurement
1202  *
1203  * @b Description
1204  *
1205  * @param[in]  gCb     RLC Instance Control Block
1206  *
1207  *  @return  Void
1208  *
1209  */
1210 S16 rlcUtlL2MeasDlInit(RlcCb *gCb)
1211 {
1212    uint16_t   cntr;
1213
1214    gCb->u.dlCb->rlcL2Cb.rlcNumMeas=0;
1215    for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
1216    {
1217       memset(&(gCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr]), 0, sizeof(RlcL2MeasEvtCb));
1218    }
1219    gCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[RLC_L2MEAS_DL_DISC].measCb.measType = LKW_L2MEAS_DL_DISC;
1220    gCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[RLC_L2MEAS_DL_IP].measCb.measType = LKW_L2MEAS_DL_IP;
1221    gCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[RLC_L2MEAS_DL_DELAY].measCb.measType= LKW_L2MEAS_DL_DELAY;
1222    gCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[RLC_L2MEAS_UU_LOSS].measCb.measType= LKW_L2MEAS_UU_LOSS;
1223    gCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[RLC_L2MEAS_ACT_UE].measCb.measType= LKW_L2MEAS_ACT_UE;
1224
1225    return ROK;
1226 }
1227 /**
1228  *
1229  * @brief Function to detect the data Burst start Condition in a DTCH
1230  *
1231  * @b Description
1232  *
1233  * @param[in]  rbCb     RB control block
1234  * @param[in]  contSduLst  Array of Contained SDUs in the DTCH   
1235  * @param[in]  dataVol  Available data in the DTCH
1236  * @param[in]  schPduSz    Total grant Size given by MAC
1237  *
1238  *  @return  Void
1239  *
1240  */
1241 Void rlcUtlUpdateBurstSdus
1242 (
1243 RlcCb            *gCb,
1244 RlcDlRbCb        *rbCb,
1245 RlcContSduLst    *contSduLst,
1246 S32              dataVol,
1247 uint32_t         schPduSz
1248 )
1249 {
1250
1251    RlcL2MeasDlIpTh   *l2MeasDlIpThruput = NULLP;
1252    RlcL2MeasTb       *l2MeasTb = NULLP;
1253    uint8_t           idx;
1254    uint8_t           currTbIdx;
1255    volatile uint32_t startTime = 0;
1256    RlcContSduLst   *dstContSduLst;
1257
1258
1259    /*starting Task*/
1260    SStartTask(&startTime, PID_RLC_DLIP_TPT_BURSTCALC);
1261
1262    l2MeasDlIpThruput = &rbCb->l2MeasIpThruput.dlIpTh;
1263
1264    if(RLC_MEAS_IS_DL_IP_MEAS_ON_FOR_RB(gCb, rbCb))
1265    {
1266       if(dataVol > schPduSz)
1267       {
1268          if(l2MeasDlIpThruput->isBurstAct == FALSE)
1269          {
1270             l2MeasDlIpThruput->burstStartTime = glblTtiCnt;
1271             l2MeasDlIpThruput->isBurstAct = TRUE;
1272             l2MeasDlIpThruput->burstEndSduId = 0;
1273          }
1274          else
1275          {  /* This is the case when another burst started before RLC gets the 
1276                l2MeasDlIpThruput->burstEndSduId = 0; */
1277          }
1278       }
1279       else
1280       {  /* Store the burstEndSduId here */
1281          if((l2MeasDlIpThruput->isBurstAct == TRUE) &&
1282                (!l2MeasDlIpThruput->burstEndSduId))
1283          {
1284             l2MeasDlIpThruput->burstEndSduId = 
1285                l2MeasDlIpThruput->outStngSduArr[l2MeasDlIpThruput->lastSduIdx].sduId;
1286          }
1287       }
1288       if(l2MeasDlIpThruput->isBurstAct == TRUE)
1289       {
1290          l2MeasTb = rlcUtlGetCurMeasTb(gCb,rbCb);
1291          /* Get the lChId from index 0, because index 0 is always for DL */
1292          if(l2MeasTb->numLcId >= RLC_MAX_ACTV_DRB) 
1293          {
1294             /* ccpu00143043 */
1295             return;
1296          }
1297          l2MeasTb->sduInfo[l2MeasTb->numLcId].lcId = rbCb->lch.lChId;
1298          /* Copy all the sduIdx from sduInfo to tb sduInfo */
1299          currTbIdx = l2MeasTb->sduInfo[l2MeasTb->numLcId].numSdus;
1300          dstContSduLst = &l2MeasTb->sduInfo[l2MeasTb->numLcId];
1301          /* ccpu00143043 */
1302          for(idx = 0; ((idx < contSduLst->numSdus)
1303                   && (currTbIdx < RLC_L2MEAS_MAX_OUTSTNGSDU)) ; idx++)
1304          {
1305             dstContSduLst->sduIdx[currTbIdx++] = contSduLst->sduIdx[idx];
1306          }
1307          l2MeasTb->sduInfo[l2MeasTb->numLcId].numSdus += idx;
1308          l2MeasTb->numLcId++;
1309       }/* End of isBurstAct */
1310    }/* End of if measOn */
1311
1312    /*stopping Task*/
1313    SStopTask(startTime, PID_RLC_DLIP_TPT_BURSTCALC);
1314    return;
1315 }
1316 /**
1317  * @brief
1318  *        This function is used to store locally the sduIdx of the sdu in the 
1319  *        outstanding SDU array
1320  * 
1321  * @b Description:
1322  *        Stores the Sdu Idx in the contained  SDU Array and increments 
1323  *        the num contained  Sdus 
1324  *
1325  *  @param[in]  sduIdx  the Index of the SDU in the outstanding SDU array
1326  *  @param[out] contSduLst This stores the indices of the SDUs 
1327  *
1328  *  @return  Void
1329  */
1330 Void rlcUtlUpdateContainedSduLst(uint8_t sduIdx,RlcContSduLst *contSduLst)
1331 {
1332    if (contSduLst->numSdus < RLC_L2MEAS_MAX_OUTSTNGSDU)
1333    {
1334     contSduLst->sduIdx[contSduLst->numSdus] = sduIdx;
1335     contSduLst->numSdus++;
1336    }
1337     return;
1338 }
1339
1340 /**
1341  * @brief
1342  *        This function is used to store the sduId of the sdu in the 
1343  *        outstanding SDU array
1344  * 
1345  * @b Description:
1346  *        Stores the Sdu Id in the outstanding SDU Array and increments 
1347  *        the num contained  Sdus 
1348  *
1349  *  @param[out] dlIpThPut  The structure in which the outstanding sdus are 
1350  *                         updated
1351  *  @param[in] sduIdx   The Idx at which the sdu ID is stored  
1352  *  @param[in] sduLen   The size if sdu in bytes  
1353  *  @param[in] newIdx   Indicates if the sdu is already present in the 
1354  *                      outstanding array  
1355  *
1356  *  @return  Void
1357  */
1358 Void rlcUtlUpdateOutStandingSduLst
1359 (
1360 RlcL2MeasDlIpTh   *dlIpThPut, 
1361 uint8_t           sduIdx, 
1362 MsgLen            sduLen, 
1363 uint32_t          sduId,
1364 Bool              newIdx
1365 )
1366 {
1367    if (sduIdx < RLC_L2MEAS_MAX_OUTSTNGSDU)
1368    {
1369    if(newIdx == TRUE)
1370    {      
1371      dlIpThPut->outStngSduArr[sduIdx].numTb = 0;
1372    }
1373    dlIpThPut->outStngSduArr[sduIdx].numTb++;
1374    dlIpThPut->outStngSduArr[sduIdx].sduId = sduId;
1375    dlIpThPut->outStngSduArr[sduIdx].sduLen = sduLen;
1376    }
1377    return;
1378 }
1379 RlcL2MeasTb * rlcUtlGetCurMeasTb(RlcCb *gCb,RlcDlRbCb *rbCb)
1380 {
1381    RlcL2MeasTb  *curL2MeasTb;
1382    uint16_t         idx;
1383
1384    if((curL2MeasTb = rbCb->ueCb->l2MeasTbCb[rbCb->ueCb->tbIdx]) == NULLP)
1385       {
1386          /* Intentionally avoiding the RLC_ALLOC macro to avoid  memset */
1387          RLC_ALLOC(gCb, curL2MeasTb, (Size)sizeof(RlcL2MeasTb));
1388          if(curL2MeasTb == NULLP)
1389          {
1390             DU_LOG("ERROR  --> RLC_DL :  rlcUtlGetCurMeasTb(): Memory allocation failed");
1391             return (NULLP);
1392          }
1393          rbCb->ueCb->l2MeasTbCb[rbCb->ueCb->tbIdx] = curL2MeasTb;
1394          /* Initialize the Meas Tb details */
1395          curL2MeasTb->numLcId = 0;
1396          curL2MeasTb->numLchInfo = 0;
1397          curL2MeasTb->txSegSduCnt = 0;
1398          for (idx = 0; idx < RLC_MAX_ACTV_DRB; idx++)
1399          {
1400             curL2MeasTb->sduInfo[idx].numSdus = 0;
1401          }
1402          for (idx = 0; idx < RLC_MAX_ACTV_DRB; idx++)
1403          {
1404             curL2MeasTb->lchInfo[idx].numSdus = 0;
1405          }
1406       }
1407    return (curL2MeasTb);
1408 }
1409
1410
1411 /**
1412  *
1413  * @brief Handler for Processing harq status indication
1414  *
1415  *
1416  * @b Description
1417  *        This function is called when the MAC sends a harq ind Mesage.
1418  *        This is used only for UuLoss and Dl Delay and DL Ipthoughput
1419  *        L2 Measurements.
1420  *
1421  *  @param[in] staInd Harq status indication received from MAC.
1422  *  @param[in] ueCb   UeCb corresponding to the Tb Id.
1423  *  @param[in] tbIdx  TB index, 0 for SISO and 0,1 for MIMO.
1424  *
1425  *
1426  *  @return  S16
1427  *      -# ROK
1428  */
1429
1430 S16 rlcUtlProcHarqInd
1431 (
1432 RlcCb            *gCb,
1433 RguHarqStatusInd *hqStaInd,
1434 RlcDlUeCb        *ueCb,
1435 uint8_t          tbIdx
1436 )
1437 {
1438 #ifdef LTE_L2_MEAS
1439    RlcDlRbCb        *rlcRbCb;           /* KW Control Block */
1440    RlcL2MeasTb       *l2MeasTb = NULLP;         /* Measurement TbCb */
1441    uint8_t           lcIdx;             /* Logical channel id index */
1442    uint8_t           sduIndx;            /* sdu index to out standing sdu list in rbCb */
1443    uint32_t          numSdus;           /* number of sdus in the outstanding sdu list */
1444    RlcOutStngSduInfo *outStngSduArr;  /* Outstanding sdu list */
1445    Ticks             ackTime;
1446    Ticks             delay;
1447    uint32_t          totlSduCnt = 0;
1448 #endif
1449    uint8_t           timeAddedFlag;
1450    S16               ret;
1451    volatile uint32_t     startTime = 0;
1452    /*kw005.201 Code added for DL IP thruput measurement*/
1453
1454    /*starting Task*/
1455    SStartTask(&startTime, PID_RLC_DLIP_TPT_PRCHARQIND);
1456
1457    ret = ROK;
1458    if(hqStaInd->tbId[tbIdx] >= RLC_INVALID_TBID)
1459    {
1460       return ROK;
1461    }
1462
1463    /* Find the L2 measurement tbCb to process DL Ip thruput*/
1464    l2MeasTb = ueCb->l2MeasTbCb[hqStaInd->tbId[tbIdx]];
1465    if(l2MeasTb == NULLP)
1466    {
1467       return ROK;
1468    }
1469    /* For each logical channel in the tbCb, process 
1470     * and get the DL IP thruput */
1471    ackTime = SGetTtiCount();
1472    for(lcIdx = 0; ((lcIdx < l2MeasTb->numLcId) && (lcIdx < RLC_MAX_ACTV_DRB)); lcIdx++)
1473    {
1474       timeAddedFlag = FALSE;
1475       if((rlcRbCb = ueCb->lCh[l2MeasTb->sduInfo[lcIdx].lcId - 1].dlRbCb)
1476             == NULLP)
1477       {
1478          continue;
1479       }
1480       /* fix for DL IP stop*/
1481       if (!gCb->u.dlCb->rlcL2Cb.measOn[rlcRbCb->qci]
1482             || (rlcRbCb->rlcId.rbType == CM_LTE_SRB))
1483       {
1484          continue;
1485       }
1486       
1487       /* Get the outstanding SDUs using sdu index stored in Container sduList
1488        * and check for HARQ ACK/NACK */
1489       numSdus = l2MeasTb->sduInfo[lcIdx].numSdus;
1490       /* ccpu00143043 */
1491       if ((numSdus >= RLC_L2MEAS_MAX_OUTSTNGSDU) || (numSdus == 0))
1492       {
1493          break;
1494       }
1495       totlSduCnt += numSdus;
1496
1497       if (RLC_MEAS_IS_DL_IP_MEAS_ON_FOR_RB(gCb,rlcRbCb))
1498       {
1499          for(sduIndx = 0; sduIndx < numSdus; sduIndx++)
1500          {
1501             outStngSduArr =&(rlcRbCb->l2MeasIpThruput.dlIpTh.outStngSduArr[\
1502                   l2MeasTb->sduInfo[lcIdx].sduIdx[sduIndx]]);
1503             if(hqStaInd->status[tbIdx] == TRUE)
1504             {
1505                /* If ACK is for burst End Sdu Id set burstActive 
1506                 * to FALSE  and accumulate time */
1507                if((rlcRbCb->l2MeasIpThruput.dlIpTh.burstEndSduId == 
1508                         outStngSduArr->sduId) && (outStngSduArr->numTb == 1))
1509                {
1510                   rlcRbCb->l2MeasIpThruput.dlIpTh.isBurstAct = FALSE;
1511                   /*Update the l2Sts structure for calculating throughput*/
1512                   rlcRbCb->rbL2Cb.l2Sts[RLC_L2MEAS_DL_IP]->dlIpThruput.volSummation
1513                      += outStngSduArr->sduLen;
1514
1515                   rlcRbCb->rbL2Cb.l2Sts[RLC_L2MEAS_DL_IP]->dlIpThruput.timeSummation
1516                      += glblTtiCnt - rlcRbCb->l2MeasIpThruput.dlIpTh.burstStartTime;
1517                   outStngSduArr->sduId = 0;
1518                   outStngSduArr->sduLen = 0;
1519                   outStngSduArr->numTb = 0;
1520                   rlcRbCb->l2MeasIpThruput.dlIpTh.burstEndSduId = 0;
1521                }
1522
1523                /* If burst is active and this sdu is only transmitted in single TB then
1524                 * accumulate volume  and clear the outstanding sduList */
1525                if((rlcRbCb->l2MeasIpThruput.dlIpTh.isBurstAct == TRUE) &&
1526                      (--(outStngSduArr->numTb) == 0))
1527                {
1528                   rlcRbCb->rbL2Cb.l2Sts[RLC_L2MEAS_DL_IP]->dlIpThruput.volSummation
1529                      += outStngSduArr->sduLen;
1530
1531                   if(timeAddedFlag == FALSE)
1532                   {
1533                      rlcRbCb->rbL2Cb.l2Sts[RLC_L2MEAS_DL_IP]->dlIpThruput.timeSummation
1534                         += glblTtiCnt - rlcRbCb->l2MeasIpThruput.dlIpTh.burstStartTime;
1535                      rlcRbCb->l2MeasIpThruput.dlIpTh.burstStartTime = glblTtiCnt;
1536                      timeAddedFlag = TRUE;
1537                   }
1538                   outStngSduArr->sduId = 0;
1539                   outStngSduArr->sduLen = 0;
1540                }
1541             }/* End of status == TRUE */
1542             else
1543             {
1544                if(rlcRbCb->l2MeasIpThruput.dlIpTh.isBurstAct == TRUE)
1545                {
1546                   if((rlcRbCb->l2MeasIpThruput.dlIpTh.burstEndSduId == 
1547                            outStngSduArr->sduId))
1548                   {
1549                      rlcRbCb->l2MeasIpThruput.dlIpTh.isBurstAct = FALSE;
1550                      rlcRbCb->l2MeasIpThruput.dlIpTh.burstEndSduId = 0;
1551                   }
1552                   /* Clear the outstanding sdu list */
1553                   outStngSduArr->sduId = 0;
1554                   outStngSduArr->sduLen = 0;
1555                   outStngSduArr->numTb = 0;
1556                }
1557             }
1558          }
1559       } 
1560    }
1561
1562    for(lcIdx = 0; ((lcIdx < l2MeasTb->numLchInfo) && (lcIdx < RLC_MAX_ACTV_DRB)); lcIdx++)
1563    {
1564       if((rlcRbCb = ueCb->lCh[l2MeasTb->lchInfo[lcIdx].lcId - 1].dlRbCb)
1565             == NULLP)
1566       {
1567          continue;
1568       }
1569       numSdus = l2MeasTb->lchInfo[lcIdx].numSdus;
1570       if ( numSdus == 0 )
1571       {
1572          continue;
1573       }
1574       /* ccpu00143043 */
1575       if ((numSdus > RLC_L2MEAS_MAX_OUTSTNGSDU) || (numSdus == 0))
1576       {
1577          break;
1578       }
1579       /* Update stats */
1580       if(hqStaInd->status[tbIdx] == TRUE)
1581       {
1582          for(sduIndx = 0; sduIndx < numSdus; sduIndx++)
1583          {
1584             delay = RLC_TIME_DIFF(ackTime,l2MeasTb->lchInfo[lcIdx].sduInfo[sduIndx].arvlTime);
1585             RLC_UPD_PDCP_L2_DLDELAY_STS(gCb,rlcRbCb, delay); 
1586          }
1587          /* Case of sduInfo not updated */
1588          if (totlSduCnt == 0)
1589          {
1590             totlSduCnt = numSdus;
1591          }
1592          RLC_UPD_L2_UU_LOSS_POS_PKTS(gCb,rlcRbCb, (totlSduCnt + l2MeasTb->txSegSduCnt));
1593       }
1594       else
1595       {
1596          /* Case of sduInfo not updated */
1597          if (totlSduCnt == 0)
1598          {
1599             totlSduCnt = numSdus;
1600          }
1601          RLC_UPD_L2_UU_LOSS_PKTS(gCb,rlcRbCb, (totlSduCnt + l2MeasTb->txSegSduCnt));
1602       }
1603    }
1604    /* Free this tb, deallocate the memory */
1605    RLC_FREE(gCb, l2MeasTb, sizeof(RlcL2MeasTb));
1606    ueCb->l2MeasTbCb[hqStaInd->tbId[tbIdx]] = NULLP;
1607    
1608    /*stopping Task*/
1609    SStopTask(startTime, PID_RLC_DLIP_TPT_PRCHARQIND);
1610
1611    return (ret);
1612 }/* end of  rlcUtlProcHarqInd */ 
1613
1614 /**
1615  *
1616  * @brief Handler for Sending L2 Measurement confirm.
1617  *
1618  *
1619  * @b Description
1620  *        This function sends a consolidates the mesaurements taken during
1621  *        this time and sends the confirm .
1622  *
1623  *  @param[in] measEvtCb    Measurement Event Control Block.
1624  *
1625  *
1626  *  @return  S16
1627  *      -# ROK
1628  */
1629
1630 S16 rlcUtlSndDlL2MeasCfm(RlcCb *gCb,RlcL2MeasEvtCb *measEvtCb)
1631 {
1632    uint32_t         qciIdx;
1633    RlcL2MeasCb      *measCb = NULLP;
1634    RlcL2MeasCfmEvt   measCfmEvt;
1635    uint32_t          posPkts;
1636    uint32_t          dLoss;
1637    uint64_t          dlDataVol;
1638    uint64_t          dlTime;
1639    uint16_t          cntr;
1640    /* Discard new changes starts */
1641    uint8_t           qci = 0;
1642    uint32_t          cfmIdx =0;
1643    /* Discard new changes ends */
1644
1645    /* kw006.201 ccpu00120058 emoved 64 bit compilation warning */
1646 #ifndef ALIGN_64BIT
1647    DU_LOG("\nDEBUG  -->  RLC_DL : rlcUtlSndL2MeasCfm(transId(%ld))", measEvtCb->transId);
1648 #else
1649    DU_LOG("\nDEBUG  -->  RLC_DL : rlcUtlSndL2MeasCfm(transId(%d))", measEvtCb->transId);
1650 #endif
1651
1652    /* Clean up the RB data structures */
1653    measCb = &measEvtCb->measCb;
1654    
1655    memset(&measCfmEvt, 0, sizeof(RlcL2MeasCfmEvt));
1656    measCfmEvt.transId = measEvtCb->transId;
1657
1658    measCfmEvt.measType = measCb->measType;
1659    measCfmEvt.status.status = LCM_PRIM_OK;
1660    measCfmEvt.status.reason = LCM_REASON_NOT_APPL;
1661    
1662    if(measCb->measType & LKW_L2MEAS_DL_IP)
1663    {
1664       RlcL2MeasCbUeMeasInfo *pUeInfoLstCb  = measCb->val.ipThMeas.ueInfoLst;
1665       RlcL2MeasCfmUeInfoLst *pUeInfoLstCfm = measCfmEvt.val.ipThMeas.ueInfoLst;
1666
1667       for(cntr = 0;(cntr < measCb->val.ipThMeas.numUes) && (cntr < gCb->genCfg.maxUe);cntr++)        
1668       {
1669          pUeInfoLstCfm[cfmIdx].numCfm = 0;
1670          if (pUeInfoLstCb[cntr].isValid == TRUE)
1671          {
1672             pUeInfoLstCfm[cfmIdx].ueId = pUeInfoLstCb[cntr].ueId;
1673             pUeInfoLstCfm[cfmIdx].cellId = pUeInfoLstCb[cntr].cellId;
1674             for(qciIdx = 0; qciIdx < pUeInfoLstCb[cntr].numQci; qciIdx++)           
1675             {
1676                qci = pUeInfoLstCb[cntr].qci[qciIdx];
1677                pUeInfoLstCfm[cfmIdx].measCfm[pUeInfoLstCfm[cfmIdx].numCfm].qci = qci;
1678
1679                dlDataVol = pUeInfoLstCb[cntr].measData[qci].dlIpThruput.volSummation;
1680                dlTime = pUeInfoLstCb[cntr].measData[qci].dlIpThruput.timeSummation;
1681
1682                if((0 == dlTime) || !(gCb->u.dlCb->rlcL2Cb.measOn[qci] & LKW_L2MEAS_DL_IP) )
1683                {
1684                   pUeInfoLstCfm[cfmIdx].measCfm[pUeInfoLstCfm[cfmIdx].numCfm].val.ipThrput.dlIpThPut = 0;
1685                }
1686                else
1687                {
1688                   pUeInfoLstCfm[cfmIdx].measCfm[pUeInfoLstCfm[cfmIdx].numCfm].val.ipThrput.dlIpThPut = 
1689                      (dlDataVol / dlTime);
1690                }
1691                pUeInfoLstCfm[cfmIdx].measCfm[pUeInfoLstCfm[cfmIdx].numCfm].val.ipThrput.dlIpThPut *= 8;
1692
1693                /* Reset the values after reporting to Application */
1694                pUeInfoLstCb[cntr].measData[qci].dlIpThruput.volSummation = 0;
1695                pUeInfoLstCb[cntr].measData[qci].dlIpThruput.timeSummation = 0;
1696
1697                measCfmEvt.val.ipThMeas.ueInfoLst[cfmIdx].numCfm++;
1698             }
1699             cfmIdx++;
1700          }
1701       }
1702       measCfmEvt.val.ipThMeas.numUes = cfmIdx; 
1703    }
1704    else
1705    {
1706       RlcL2Cntr *pMeasData = measCb->val.nonIpThMeas.measData;
1707       RlcL2MeasCfmNonIpThMeas *pMeasCfmNonIp = &measCfmEvt.val.nonIpThMeas;
1708
1709       pMeasCfmNonIp->numCfm = 0;
1710
1711       for(qciIdx = 0; qciIdx < LKW_MAX_QCI; qciIdx++)
1712       {
1713          qci = measCb->val.nonIpThMeas.qci[qciIdx];
1714          if (qci > 0)
1715          {
1716             pMeasCfmNonIp->measCfm[pMeasCfmNonIp->numCfm].qci = qci;
1717
1718             if(measCb->measType & LKW_L2MEAS_UU_LOSS)
1719             {
1720                dLoss = pMeasData[qci].uuLoss.dLoss;
1721                posPkts = pMeasData[qci].uuLoss.posPkts;
1722                if(((posPkts + dLoss) != 0))
1723                {
1724                   pMeasCfmNonIp->measCfm[pMeasCfmNonIp->numCfm].val.nonIpThrput.uuLoss  =
1725                      ((dLoss  * 1000000) / (posPkts + dLoss));
1726                }
1727                pMeasData[qci].uuLoss.dLoss = 0;
1728                pMeasData[qci].uuLoss.posPkts = 0;
1729             }
1730             if(measCb->measType & LKW_L2MEAS_DL_DISC)
1731             {
1732
1733                pMeasCfmNonIp->measCfm[pMeasCfmNonIp->numCfm].val.nonIpThrput.dlDiscRate = 0;
1734                if(pMeasData[qci].dlDisc.totSdus != 0)
1735                {
1736                   pMeasCfmNonIp->measCfm[pMeasCfmNonIp->numCfm].val.nonIpThrput.dlDiscRate = 
1737                      (((pMeasData[qci].dlDisc.discSdus)  * 1000000) / (pMeasData[qci].dlDisc.totSdus));
1738                }
1739
1740                pMeasData[qci].dlDisc.totSdus = 0;
1741                pMeasData[qci].dlDisc.discSdus = 0;
1742             }
1743             if(measCb->measType & LKW_L2MEAS_DL_DELAY)
1744             {
1745                if (pMeasData[qci].dlPjSduDelay.numSdus > 0)
1746                {
1747                   pMeasCfmNonIp->measCfm[pMeasCfmNonIp->numCfm].val.nonIpThrput.dlSduDelay = 
1748                     (pMeasData[qci].dlPjSduDelay.sduDelay / pMeasData[qci].dlPjSduDelay.numSdus);
1749                   pMeasData[qci].dlPjSduDelay.sduDelay = 0;
1750                   pMeasData[qci].dlPjSduDelay.numSdus = 0;
1751                }
1752             }
1753             pMeasCfmNonIp->numCfm++;
1754          }
1755       }
1756    }
1757    /* Fix Klock warning */
1758    RlcMiLkwL2MeasCfm(&gCb->genCfg.lmPst, &measCfmEvt);
1759    return ROK;
1760 } /* rlcUtlSndL2MeasCfm */
1761 /**
1762  *
1763  * @brief Handler for Sending Negative confirm .
1764  *
1765  *
1766   @b Description
1767  *        This function is called when the l2 measurement cannot be started
1768  *        This function sends  negative confirm for all the requests
1769  *
1770  *  @param[in] measReqEvt    Measurement Req Structure
1771  *
1772  *
1773  *  @return  S16
1774  *      -# ROK
1775  */
1776
1777 S16 rlcUtlSndDlL2MeasNCfm(RlcCb *gCb,RlcL2MeasReqEvt *measReqEvt,RlcL2MeasCfmEvt *measCfmEvt)
1778 {
1779
1780    RlcMiLkwL2MeasCfm(&gCb->genCfg.lmPst, measCfmEvt);
1781    return ROK;
1782 } /* kwUtlSndL2MeasNCfm */
1783 /**
1784  *
1785  * @brief Handler for resetting the RB data structures
1786  *
1787  *
1788  * @b Description
1789  *        This function resets the RB data structure after the expiry of 
1790  *        measurement timer.
1791  *
1792  *  @param[in] measCb    Measurement Control Block.
1793  *
1794  *
1795  *  @return  Void
1796  */
1797
1798 Void rlcUtlResetDlL2MeasInRlcRb(RlcCb *gCb,RlcL2MeasCb *measCb,uint8_t measType)
1799 {
1800    uint32_t           ueIdx;
1801    uint32_t           qciIdx;
1802    RlcDlUeCb      *ueCb = NULL;
1803
1804
1805
1806    if (measCb->measType & LKW_L2MEAS_DL_IP)
1807    {
1808       for(ueIdx = 0; ueIdx < measCb->val.ipThMeas.numUes; ueIdx++)
1809       {           
1810          if (measCb->val.ipThMeas.ueInfoLst[ueIdx].isValid == TRUE)
1811          {
1812             for (qciIdx =0; qciIdx < measCb->val.ipThMeas.ueInfoLst[ueIdx].numQci; qciIdx++)
1813             {
1814                if (measType & LKW_L2MEAS_DL_IP)
1815                {
1816                   measCb->val.ipThMeas.ueInfoLst[ueIdx].measData[qciIdx].dlIpThruput.volSummation = 0;
1817                   measCb->val.ipThMeas.ueInfoLst[ueIdx].measData[qciIdx].dlIpThruput.timeSummation = 0;
1818                   gCb->u.dlCb->rlcL2Cb.measOn[qciIdx] &= ~measType; 
1819                }
1820             }
1821
1822             if(ROK  != rlcDbmFetchDlUeCb(gCb,measCb->val.ipThMeas.ueInfoLst[ueIdx].ueId,
1823                      measCb->val.ipThMeas.ueInfoLst[ueIdx].cellId, &ueCb))
1824             {
1825                continue;
1826             }
1827
1828          }
1829       }
1830    }
1831    else
1832    {
1833       /* for now the only meas should be DL discard in this case */
1834       if (measCb->measType & LKW_L2MEAS_DL_DISC)
1835       {
1836          uint32_t i;
1837          for(i = 0; i < measCb->val.nonIpThMeas.numQci; i++)
1838          {
1839             uint8_t qciVal = measCb->val.nonIpThMeas.qci[i];
1840
1841             measCb->val.nonIpThMeas.measData[qciVal].dlDisc.discSdus = 0;
1842             measCb->val.nonIpThMeas.measData[qciVal].dlDisc.totSdus  = 0;
1843          }
1844          
1845       }
1846       if (measCb->measType & LKW_L2MEAS_DL_DELAY)
1847       {
1848          uint32_t i;
1849          for(i = 0; i < measCb->val.nonIpThMeas.numQci; i++)
1850          {
1851             uint8_t qciVal = measCb->val.nonIpThMeas.qci[i];
1852
1853             measCb->val.nonIpThMeas.measData[qciVal].dlPjSduDelay.sduDelay = 0;
1854          }
1855       }
1856       measCb->val.nonIpThMeas.numQci = 0;
1857    }
1858 } /* rlcUtlResetDlL2MeasInRlcRb */
1859 #endif
1860
1861 static Void dumpRLCDlRbInformation(RlcDlRbCb* dlRbCb)
1862 {
1863    if(dlRbCb->mode == RLC_MODE_UM)
1864    {
1865       DU_LOG("\nDEBUG  -->  RLC_DL : UM Downlink UEID:%d CELLID:%d Q size = %d",
1866                        dlRbCb->rlcId.ueId,
1867                        dlRbCb->rlcId.cellId,
1868                        (int)dlRbCb->m.umDl.sduQ.count);
1869    }
1870    else if(dlRbCb->mode == RLC_MODE_AM)
1871    {
1872       uint32_t j, numTxPdus=0;
1873       for(j = 0; j <= (RLC_AM_GET_WIN_SZ(dlRbCb->m.amDl.snLen)); j++)
1874       {
1875          RlcTx *txBuf = rlcUtlGetTxBuf(dlRbCb->m.amDl.txBufLst, j);
1876          if(txBuf != NULLP)
1877          {
1878             numTxPdus++;
1879          }
1880       }
1881       DU_LOG("\nDEBUG  -->  RLC_DL : AM Downlink UEID:%d CELLID:%d Sizes SDU Q = %d TX Q = %d ",
1882                        dlRbCb->rlcId.ueId,
1883                        dlRbCb->rlcId.cellId,
1884                        (int)dlRbCb->m.amDl.sduQ.count,
1885                        (int)numTxPdus);
1886       DU_LOG("\nDEBUG  -->  RLC_DL : AM Downlink UEID:%d CELLID:%d RETX Q= %d",
1887                        dlRbCb->rlcId.ueId,
1888                        dlRbCb->rlcId.cellId,
1889                        (int)dlRbCb->m.amDl.retxLst.count);
1890    }
1891 }
1892
1893 Void DumpRLCDlDebugInformation(Void)
1894 {
1895    RlcCb* dlInst = rlcCb[1]; /* TODO : Check whether DL is 0 or 1 */
1896
1897    RlcDlCb *dlCb = dlInst->u.dlCb;
1898
1899    RlcDlUeCb *ueCb = NULLP; 
1900    RTLIN_DUMP_DEBUG("RLC Information\n");
1901    RTLIN_DUMP_DEBUG("===============\n");
1902    /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
1903    while (ROK == cmHashListGetNext(&dlCb->ueLstCp, 
1904                                    (PTR) ueCb, 
1905                                    (PTR *)&ueCb))
1906    {
1907       uint32_t i;
1908       for(i = 0; i< RLC_MAX_SRB_PER_UE; i++)
1909       {
1910          RlcDlRbCb* dlRbCb = ueCb->srbCb[i]; 
1911          if( dlRbCb != NULLP)
1912          {
1913             dumpRLCDlRbInformation(dlRbCb);
1914          }
1915       }
1916       for(i = 0; i< RLC_MAX_DRB_PER_UE; i++)
1917       {
1918          RlcDlRbCb* dlRbCb = ueCb->drbCb[i]; 
1919          if( dlRbCb != NULLP)
1920          {
1921             dumpRLCDlRbInformation(dlRbCb);
1922          }
1923       }
1924    }
1925
1926    RlcDlDataToBeFreed* pToBeFreed = &dlCb->toBeFreed;
1927
1928    RTLIN_DUMP_DEBUG("toBeFreed RETX list size = %d\n",(int)pToBeFreed->reTxLst.count);
1929    RTLIN_DUMP_DEBUG("toBeFreed TX list size   = %d\n",(int)pToBeFreed->txLst.count);
1930    RTLIN_DUMP_DEBUG("toBeFreed SDU list size  = %d\n",(int)pToBeFreed->sduLst.count);
1931    RTLIN_DUMP_DEBUG("toBeFreed RB list size   = %d\n",(int)pToBeFreed->rbLst.count);
1932 }
1933
1934 /**
1935  *
1936  * @b Description
1937  *        This function frees downlink memory 
1938  *
1939  *  @param[in] Void
1940  *
1941  *
1942  *  @return  Void
1943  */
1944
1945 void rlcUtlFreeDlMem( Void)
1946 {
1947   rlcUtlFreeDlMemory(RLC_GET_RLCCB(RLC_DL_INST));
1948 }
1949
1950 /**
1951  *
1952  * @b Description
1953  *        This function returns current time
1954  *
1955  *  @param[in] uint32_t 
1956  *
1957  *
1958  *  @return  Void
1959  */
1960
1961 void rlcUtlGetCurrTime(uint32_t  *currTime)
1962 {
1963    /* Need t define else part for PAL */
1964    *currTime = SGetTtiCount();
1965 }
1966
1967 #if defined(MAC_RLC_HARQ_STA_RBUF) || defined (SS_RBUF)
1968 #ifdef LTE_L2_MEAS
1969 void rlcUtlDlBatchProcHqStaInd( Void)
1970 {
1971    /* Read from Ring Buffer and process PDCP packets */
1972    //Pst pst = {0};
1973
1974    Void *elmIndx = NULLP;
1975    RguHarqStaInd *staInd = NULLP;
1976
1977 #if defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS)
1978    isDatReqProcessed = TRUE;
1979 #endif
1980    elmIndx = (Void *)SRngGetRIndx(SS_RNG_BUF_MAC_HARQ);
1981    while(NULLP != elmIndx)
1982    {
1983       staInd = (RguHarqStaInd *)elmIndx;
1984       RlcLiRguHqStaInd(&(staInd->pst), 0, &(staInd->hqStatusInd));
1985
1986       elmIndx = NULLP;
1987       staInd  = NULLP;
1988       SRngIncrRIndx(SS_RNG_BUF_MAC_HARQ);
1989
1990       if((elmIndx = (Void *)SRngGetRIndx(SS_RNG_BUF_MAC_HARQ)) == NULLP)
1991       {
1992 #if defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS)
1993          isDatReqProcessed = FALSE;
1994 #endif
1995          break;
1996       }
1997    }
1998 }
1999 #endif
2000 #endif
2001
2002 /**
2003  * @brief evaluate and trigger PDB based flow control to PDCP 
2004  *
2005  * @details 
2006  *
2007  * @param[in]   rbCb  RB control block 
2008  *
2009  *
2010  *  @return  Void
2011  *
2012  */
2013 Void rlcUtlTrigPdbFlowCntrl(RlcCb  *gCb,RlcDlRbCb *rbCb,uint32_t pktAdmitCnt)
2014 {
2015    KwuFlowCntrlIndInfo    *flowCntrlInfo;
2016    RlcKwuSapCb*            rlckwuSap;
2017
2018    rlckwuSap = gCb->u.dlCb->rlcKwuDlSap + RLC_UI_PDCP;
2019
2020    RLC_SHRABL_STATIC_BUF_ALLOC(rlckwuSap->pst.region, 
2021                               rlckwuSap->pst.pool, 
2022                               flowCntrlInfo, 
2023                               sizeof(KwuFlowCntrlIndInfo));
2024    flowCntrlInfo->rlcId       = rbCb->rlcId;
2025    flowCntrlInfo->pktAdmitCnt = pktAdmitCnt;
2026    RlcUiKwuFlowCntrlInd(&rlckwuSap->pst, rlckwuSap->suId, flowCntrlInfo);
2027 }
2028
2029 /**
2030  *
2031  * @brief Store the DL buffer in hashList  
2032  *
2033  *
2034  * @b Description
2035  *
2036  *   Use the SN % binSize as key and store the received UL buffer
2037  *  @param[in] txBufLst       List CP array
2038  *  @param[in] txBuf          transmitted buffer
2039  *  @param[in] sn              sn of the received buffer 
2040  *
2041  *
2042  *  @return  Void
2043  */
2044 void rlcUtlStoreTxBuf(CmLListCp *txBufLst, RlcTx *txBuf, RlcSn sn)
2045 {
2046    uint32_t   hashKey; 
2047
2048    hashKey = (sn % RLC_TX_BUF_BIN_SIZE );
2049    txBuf->sn = sn; 
2050    txBuf->lnk.node = (PTR)txBuf;
2051    cmLListAdd2Tail(&(txBufLst[hashKey]), &txBuf->lnk);
2052
2053    return;
2054 } /* rlcUtlStoreRecBuf */
2055
2056 /**
2057  *
2058  * @brief Retrieve the DL buffer from the list
2059  *
2060  *
2061  * @Description
2062  *
2063  *   Use the SN % binSize as key and retrieve the DL buffer
2064  *  @param[in] txBufLst       List CP array
2065  *  @param[in] sn              sn of the transmitted buffer 
2066  *
2067  *
2068  *  @return  Void
2069  */
2070 RlcTx* rlcUtlGetTxBuf(CmLListCp *txBufLst, RlcSn sn)
2071 {
2072    uint32_t            hashKey; 
2073    CmLListCp           *txBufLstCp;
2074    RlcTx               *txBuf;
2075    CmLList             *node = NULLP;
2076
2077    hashKey = (sn % RLC_TX_BUF_BIN_SIZE ); 
2078  
2079    txBufLstCp = &txBufLst[hashKey];
2080    CM_LLIST_FIRST_NODE(txBufLstCp, node);
2081    while(node)
2082    {
2083       txBuf = (RlcTx *) node->node;
2084       if(txBuf->sn == sn)
2085       {
2086          return (txBuf);
2087       }
2088       CM_LLIST_NEXT_NODE(txBufLstCp, node);
2089    }
2090    return NULLP;
2091 } /* rlcUtlStoreTxBuf */
2092 /**
2093  *
2094  * @brief Delete the DL buffer from the list
2095  *
2096  *
2097  * @Description
2098  *
2099  *   Use the SN % binSize as key and retrieve the DL buffer
2100  *  @param[in] txBufLst       List CP array
2101  *  @param[in] sn              sn of the transmitted bffer 
2102  *
2103  *
2104  *  @return  Void
2105  */
2106 Void rlcUtlDelTxBuf (CmLListCp *txBufLst,RlcTx  *txBuf,RlcCb *gCb)
2107 {
2108    uint32_t            hashKey; 
2109    CmLListCp           *txBufLstCp;
2110
2111    hashKey = (txBuf->sn % RLC_TX_BUF_BIN_SIZE ); 
2112  
2113    txBufLstCp = &txBufLst[hashKey];
2114    //DU_LOG("\nINFO  -->  RLC_DL : D-sn(%d)\n", txBuf->hdr.sn);
2115    cmLListDelFrm(txBufLstCp, &txBuf->lnk);
2116    RLC_FREE(gCb, txBuf, sizeof(RlcTx));
2117    return;
2118 } /* rlcUtlDelTxBuf */
2119
2120 /**
2121  *
2122  * @brief Remove the DL buffer from the list
2123  *
2124  *
2125  * @Description
2126  *
2127  *   Use the SN % binSize as key and retrieve the DL buffer
2128  *  @param[in] txBufLst       List CP array
2129  *  @param[in] sn              sn of the transmitted bffer 
2130  *
2131  *
2132  *  @return  Void
2133  */
2134 Void rlcUtlRemovTxBuf(CmLListCp *txBufLst,RlcTx  *txBuf,RlcCb *gCb)
2135 {
2136    uint32_t            hashKey; 
2137    CmLListCp           *txBufLstCp;
2138
2139    hashKey = (txBuf->sn % RLC_TX_BUF_BIN_SIZE ); 
2140  
2141    txBufLstCp = &txBufLst[hashKey];
2142    //DU_LOG("\nINFO  -->  RLC_DL : D-sn(%d)\n", txBuf->hdr.sn);
2143    cmLListDelFrm(txBufLstCp, &txBuf->lnk);
2144    return;
2145 } /* rlcUtlRemovTxBuf */
2146
2147
2148
2149 /********************************************************************30**
2150          End of file
2151 **********************************************************************/