1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /**********************************************************************
25 Desc: Source code for RLC Utility Module
26 This file contains following functions
31 --rlcUtlSendDedLcBoStatus
32 --rlcUtlSendUlDataToDu
37 **********************************************************************/
39 /** @file rlc_utl_dl.c
40 @brief RLC Utility Module
43 /* header (.h) include files */
45 #include "common_def.h"
46 /* kw005.201 added support for L2 Measurement */
50 #include "ckw.h" /* CKW defines */
51 #include "kwu.h" /* CKW defines */
52 #include "lkw.h" /* LKW defines */
53 #include "rgu.h" /* RGU defiens */
55 #include "rlc_env.h" /* RLC environment options */
56 #include "rlc_err.h" /* Error defines */
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 */
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"
78 #if (defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS))
79 uint32_t isDatReqProcessed;
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));
85 Void ResetRLCStats(Void)
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));
95 Void PrintRLCStats(Void)
97 RlcCb* dlInst = rlcCb[1];
98 RlcCb* ulInst = rlcCb[0];
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);
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);
140 Void PrintRLCStats(Void)
142 RlcCb* dlInst = rlcCb[1];
143 RlcCb* ulInst = rlcCb[0];
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);
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"
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);
201 /*******************************************************************
204 * Handler for storing all DL PDU Info into RLC-MAC interface
205 * struct and sending to lower interface
208 * This function stores DL PDU info for all logical channels
209 * of per UE grant per TTI and sends to MAC
211 * Function : rlcSendDedLcDlData
214 * @return ROK - success
217 * ****************************************************************/
218 uint8_t rlcSendDedLcDlData(Pst *post, SpId spId, RguDDatReqInfo *datReqInfo)
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 */
234 RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL,
235 dlData, sizeof(RlcData));
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));
243 memset(dlData, 0, sizeof(RlcData));
245 for(ueIdx = 0; ueIdx < datReqInfo->nmbOfUeGrantPerTti; ueIdx++)
247 datPerUe = datReqInfo->datReq[ueIdx];
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;
257 for(tbIdx = 0; tbIdx < datPerUe.nmbOfTbs; tbIdx++)
259 datPerTb = datPerUe.datReqTb[tbIdx];
260 for(lchIdx = 0; lchIdx < datPerTb.nmbLch; lchIdx++)
262 datPerLch = datPerTb.lchData[lchIdx];
263 lcId = datPerLch.lcId;
264 for(pduIdx = 0; pduIdx < datPerLch.pdu.numPdu; pduIdx++)
266 dlData->pduInfo[dlData->numPdu].commCh = FALSE;
267 dlData->pduInfo[dlData->numPdu].lcId = datPerLch.lcId;
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);
274 if (dlData->pduInfo[dlData->numPdu].pduBuf == NULLP )
276 DU_LOG("\nERROR --> RLC_DL : rlcSendDedLcDlData: Memory allocation failed");
277 for(pduIdx = 0; pduIdx < dlData->numPdu; pduIdx++)
279 RLC_FREE_SHRABL_BUF(pst.region, pst.pool, dlData->pduInfo[pduIdx].pduBuf,\
280 dlData->pduInfo[pduIdx].pduLen);
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));
289 ODU_COPY_MSG_TO_FIX_BUF(datPerLch.pdu.mBuf[pduIdx], 0, pduLen, \
290 dlData->pduInfo[dlData->numPdu].pduBuf, (MsgLen *)©Len);
291 dlData->pduInfo[dlData->numPdu].pduLen = pduLen;
294 ODU_PUT_MSG_BUF(datPerLch.pdu.mBuf[pduIdx]);
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;
304 }/* For Data per Lch */
305 }/* For Data per Tb */
307 RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL, dlRrcMsgRsp, sizeof(RlcDlRrcMsgRsp));
308 if(dlRrcMsgRsp == NULLP)
310 DU_LOG("\nERROR --> RLC_DL : rlcSendDedLcDlData: Memory allocation failed for dlRrcMsgRsp");
311 for(pduIdx = 0; pduIdx < dlData->numPdu; pduIdx++)
313 RLC_FREE_SHRABL_BUF(pst.region, pst.pool, dlData->pduInfo[pduIdx].pduBuf,\
314 dlData->pduInfo[pduIdx].pduLen);
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));
321 dlRrcMsgRsp->cellId = dlData->cellId;
322 dlRrcMsgRsp->crnti = dlData->rnti;
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)
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++)
332 RLC_FREE_SHRABL_BUF(pst.region, pst.pool, dlData->pduInfo[pduIdx].pduBuf,\
333 dlData->pduInfo[pduIdx].pduLen);
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));
341 dlRrcMsgRsp->state = TRANSMISSION_COMPLETE;
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 */
346 if(rlcSendDlRrcMsgRspToDu(&pst, dlRrcMsgRsp) != ROK)
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));
354 } /* For Data per UE */
355 RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(RguDDatReqInfo));
358 }/* End of rlcSendDedLcDlData */
363 * Handler for sending the data to multiple logical channels of a UE
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
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
380 uint8_t rlcUtlSendToMac(RlcCb *gCb, SuId suId, KwDStaIndInfo *staIndInfo)
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;
396 uint32_t grantPerLch[RGU_MAX_LC] = {0};
398 /* kw005.201 added support for L2 Measurement */
399 #ifdef LTE_L2_MEAS_LOSS_DELAY
402 #endif /* LTE_L2_MEAS */
403 uint32_t idx, ueDataIdx = 0;
406 uint32_t staIndSz=0,datIndSz = 0;
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 )
414 DU_LOG("\nERROR --> RLC_DL : rlcUtlSendToMac: Memory allocation failed");
417 #endif /* ERRCLASS & ERRCLS_ADD_RES */
418 for(idx = 0; idx < staIndInfo->nmbOfUeGrantPerTti; idx++)
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))
425 /* Fetch UeCb failed */
426 DU_LOG("\nERROR --> RLC_DL : rlcUtlSendToMac: UeId[%u]:ueCb not found",
428 /* If ueCb is not found for current rnti then continue to look for next rnti*/
432 /* kw002.201 Removed the allocation of RlcDatReq */
433 /* kw004.201 Used SSI function to initialize the variable */
434 memset(&datReq, 0, sizeof(RlcDatReq) );
436 for (numTb = 0; numTb < staInd->nmbOfTbs; numTb++)
438 staIndTb = &(staInd->staIndTb[numTb]);
439 datReqTb = &(datReqInfo->datReq[ueDataIdx].datReqTb[numTb]);
441 ueCb->tbIdx = (ueCb->tbIdx+1) % RLC_MAX_TB_PER_UE;
443 for (count = 0;count < staIndTb->nmbLch; count++)
446 /*Calculate the total grant size from MAC */
447 if((staIndTb->lchStaInd[count].lcId >= RGU_MAX_LC)
448 || (staIndTb->lchStaInd[count].lcId == 0))
450 /* TODO : Need to figure out why this is happening */
455 grantPerLch[staIndTb->lchStaInd[count].lcId] += staIndTb->lchStaInd[count].totBufSize;
458 rbCb = ueCb->lCh[staIndTb->lchStaInd[count].lcId - 1].dlRbCb;
460 if (rbCb && (!rlcDlUtlIsReestInProgress(rbCb)))
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;
466 staIndSz += staIndTb->lchStaInd[count].totBufSize;
467 datReq.pduSz = staIndTb->lchStaInd[count].totBufSize;
469 datReq.totMacGrant = grantPerLch[staIndTb->lchStaInd[count].lcId];
471 rlcUtlGetCurrTime(&datReq.boRep.oldestSduArrTime);
472 if ( RLC_MODE_UM == rbCb->mode )
474 rlcUmmProcessSdus(gCb,rbCb,&datReq);
476 else if ( RLC_MODE_AM == rbCb->mode )
478 rlcAmmProcessSdus(gCb,rbCb,&datReq,staInd->fillCtrlPdu);
481 grantPerLch[staIndTb->lchStaInd[count].lcId] = datReq.totMacGrant;
483 if ( 0 == datReq.pduInfo.numPdu )
487 totNumPdu += datReq.pduInfo.numPdu;
488 memcpy(&(datReqTb->lchData[count].pdu),
489 &(datReq.pduInfo),sizeof(KwPduInfo));
491 for (;numPdu < datReqTb->lchData[count].pdu.numPdu ; numPdu ++)
494 ODU_GET_MSG_LEN(datReqTb->lchData[count].pdu.mBuf[numPdu],&len);
497 datReqTb->lchData[count].setMaxUlPrio = FALSE;
498 if (RLC_AM_IS_POLL_BIT_SET(RLC_AMDL) &&
499 (RLC_AMDL.sduQ.count > 1))
501 /* Poll bit is set indicate to MAC*/
502 datReqTb->lchData[count].setMaxUlPrio = TRUE;
504 datReqTb->lchData[count].boReport.bo = datReq.boRep.bo;
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;
517 /* Set if Bearer is UM */
518 if ( RLC_MODE_UM == rbCb->mode )
520 datReqTb->lchData[count].freeBuff = TRUE;
524 datReqTb->lchData[count].freeBuff = FALSE;
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
535 for(snIdx1 = 0; snIdx1 < RGU_MAX_PDU; snIdx1++)
537 datReqTb->rguSnInfo->lchMap[count].snList[snIdx1] = 0xffff;
539 if(tbSnMap->numSn != 0)
542 for(snIdx1=tbSnMap->prevNumSn;snIdx1 < tbSnMap->numSn;snIdx1++)
544 datReqTb->rguSnInfo->lchMap[count].snList[snIdx2++] =
545 tbSnMap->snSduMap[snIdx1].sn;
547 tbSnMap->prevNumSn = tbSnMap->numSn;
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) );
557 if(ueCb->l2MeasTbCb[ueCb->tbIdx]!= NULLP)
559 datReqTb->tbId = ueCb->tbIdx;
563 datReqTb->tbId = RLC_INVALID_TBID;
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 )
571 datReqTb->lchData[0].lcId = staIndTb->lchStaInd[0].lcId;
573 /* kw005.201 added support for L2 Measurement */
574 #ifdef LTE_L2_MEAS_LOSS_DELAY
575 if(tbSnMap->numSn == 0)
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;
585 cmHashListInsert(&(rlcCb.rlcL2Cb.tbHlCp),(PTR)tbSnMap,
586 (uint8_t *) &(tbSnMap->tbId), (uint16_t)sizeof(tbSnMap->tbId));
587 rlcCb.rlcL2Cb.curTbSnMap = NULLP;
589 #endif /* LTE_L2_MEAS */
591 datReqInfo->datReq[ueDataIdx].nmbOfTbs = staInd->nmbOfTbs;
592 datReqInfo->datReq[ueDataIdx].transId = staInd->transId;
593 datReqInfo->datReq[ueDataIdx].rnti = staInd->rnti;
599 datReqInfo->cellId = staIndInfo->cellId;
600 datReqInfo->nmbOfUeGrantPerTti = staIndInfo->nmbOfUeGrantPerTti;
602 rguSap = &(gCb->u.dlCb->rguDlSap[suId]);
603 rlcSendDedLcDlData(&rguSap->pst,rguSap->spId,datReqInfo);
607 RLC_FREE_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo,sizeof(RguDDatReqInfo));
615 * Handler for sending Status Response to MAC.
618 * This function is used by RLC entity for sending
619 * status response to MAC after receiving a SDU from
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
632 uint8_t rlcUtlSendDedLcBoStatus(RlcCb *gCb, RlcDlRbCb *rbCb, int32_t bo, \
633 int32_t estHdrSz, bool staPduPrsnt, uint32_t staPduBo)
635 Pst pst; /* Post info */
636 RlcBoStatus *boStatus; /* Buffer occupancy status information */
639 if ((rbCb->lastRprtdBoToMac > (uint32_t)8000) && (rbCb->boUnRprtdCnt < (uint32_t)5)
640 && (!staPduPrsnt) && ((RLC_MODE_AM == rbCb->mode ) && (RLC_AMDL.nxtRetx == NULLP)))
642 rbCb->boUnRprtdCnt++;
646 rbCb->boUnRprtdCnt = (uint32_t)0;
647 rbCb->lastRprtdBoToMac = (uint32_t)bo;
649 RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_DL, RLC_POOL, \
650 boStatus, sizeof(RlcBoStatus));
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;
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)
662 RLC_FREE_SHRABL_BUF(pst.region, pst.pool, boStatus, sizeof(RlcBoStatus));
671 * Handler for emptying the SDU queue.
674 * This function is used to empty the SDU queue when
675 * a re-establishment request is received from the
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
684 /* kw005.201 added support for L2 Measurement */
685 #ifdef LTE_L2_MEAS_RLC
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 */
706 firstSduSnMap = NULLP;
710 sduSnMapQ = &rbCb->sduSnMapQ;
711 CM_LLIST_FIRST_NODE(sduSnMapQ, firstSduSnMap);
715 sduSnMap = (RlcSduSnMap *)firstSduSnMap->node;
716 if(sduSnMap != NULLP)
718 cmLListDelFrm(&(rbCb->sduSnMapQ), &(sduSnMap->lstEnt));
719 RLC_FREE(sduSnMap, sizeof(RlcSduSnMap));
720 CM_LLIST_FIRST_NODE(sduSnMapQ, firstSduSnMap);
724 CM_LLIST_NEXT_NODE(sduSnMapQ, firstSduSnMap);
734 * Function to set that re-establishment has started for an RB
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;
743 * @param[in] gCb RLC instance control block
744 * @param[in] rbCb RB for which re-establishment has started
748 Void rlcDlUtlSetReestInProgressForRB(RlcCb *gCb,RlcDlRbCb *rbCb)
751 rbCb->reestInProgress = TRUE;
753 if(rbCb->mode == RLC_MODE_AM )
755 rbCb->m.amDl.estHdrSz = 0;
757 if(rlcChkTmr(gCb, (PTR)rbCb, EVENT_RLC_AMDL_POLL_RETX_TMR))
759 rlcStopTmr(gCb, (PTR)rbCb, EVENT_RLC_AMDL_POLL_RETX_TMR);
762 rlcUtlSendDedLcBoStatus(gCb, rbCb, 0, 0, FALSE,0);
770 * Function to check if re-establishment is ongoing for an RB
772 * @param[in] rbCb RB for which re-establishment is to be checked
775 * TRUE : Re-establishment is in progress
776 * FALSE : Re-establishment is not in progress
778 bool rlcDlUtlIsReestInProgress(RlcDlRbCb *rbCb)
780 return (rbCb->reestInProgress);
786 * Function to set re-establishment to FALSE
788 * @param[in] rbCb RB for which re-establishment is to be reset
792 Void rlcDlUtlResetReestInProgress(RlcDlRbCb *rbCb)
795 rbCb->reestInProgress = FALSE;
801 * Function to set that re-establishment has started for all the RBs
802 * of an UE; except for SRB1
804 * @detail: For SRB1 only the poll-retransmit timer is stopped
806 * @param[in] gCb RLC instance control block
807 * @param[in] ueCb UE for which re-establishment has started
811 Void rlcDlUtlSetReestInProgressForAllRBs(RlcCb *gCb,RlcDlUeCb *ueCb)
815 for(rbIdx = 0;rbIdx < RLC_MAX_SRB_PER_UE;rbIdx++)
817 if(ueCb->srbCb[rbIdx] != NULLP)
819 if(ueCb->srbCb[rbIdx]->rlcId.rbId != 1)
821 rlcDlUtlSetReestInProgressForRB(gCb,ueCb->srbCb[rbIdx]);
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))
828 rlcStopTmr(gCb, (PTR)ueCb->srbCb[rbIdx], EVENT_RLC_AMDL_POLL_RETX_TMR);
834 for(rbIdx = 0;rbIdx < RLC_MAX_DRB_PER_UE;rbIdx++)
836 if(ueCb->drbCb[rbIdx] != NULLP)
838 rlcDlUtlSetReestInProgressForRB(gCb,ueCb->drbCb[rbIdx]);
846 * @brief Function to increment number of SDUs transmitted
847 * in KWU SAP statistics
850 * @param[in] rlckwuSap KWU SAP in which to increment the counter
854 void rlcUtlIncrementKwuStsSduTx(RlcKwuSapCb *rlckwuSap)
856 rlckwuSap->sts.sduTx++;
861 * @brief Function to increment number of bytes and PDUs transmitted
862 * in General statistics
865 * @param[in] genSts KWU SAP in which to increment the counter
866 * @param[in] pdu The PDU which is sent
870 void rlcUtlIncrementGenStsBytesAndPdusSent(RlcGenSts *genSts, Buffer *pdu)
873 ODU_GET_MSG_LEN(pdu, &bytesSent);
874 genSts->bytesSent += bytesSent;
880 * @brief Function to initialize the data structures used to free memory
883 * @param[in] gCb RLC instance control block
884 * @param[out] toBeFreed Pointer to the freeing structure. This is
889 Void rlcUtlInitToBeFreed(RlcCb *gCb,RlcDlDataToBeFreed *toBeFreed)
891 cmLListInit(&(toBeFreed->sduLst));
892 cmLListInit(&(toBeFreed->rbLst));
893 cmLListInit(&(toBeFreed->reTxLst));
894 cmLListInit(&(toBeFreed->txLst));
900 * @brief Function to initialize the DL self Pst structure
903 * @param[in] gCb RLC instance control block
907 Void rlcUtlInitializeSelfPst(RlcCb *gCb)
909 Pst *selfPst = &gCb->u.dlCb->selfPst;
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;
923 * @brief Function to send a DL cleanup event
926 * @param[in] gCb RLC instance control block
930 void rlcUtlRaiseDlCleanupEvent(RlcCb *gCb)
932 #ifdef KWSELFPSTDLCLEAN
933 if(!gCb->u.dlCb->eventInQueue)
935 ODU_POST_TASK(&gCb->u.dlCb->selfPst, gCb->u.dlCb->selfPstMBuf);
936 gCb->u.dlCb->eventInQueue = TRUE;
943 * @brief Function to add a SDU to the to be freed sdu list
946 * @param[in] gCb RLC instance control block
947 * @param[in] sdu SDU to be added to the list
951 void rlcUtlAddSduToBeFreedQueue(RlcCb *gCb, RlcSdu *sdu)
953 cmLListAdd2Tail(&(gCb->u.dlCb->toBeFreed.sduLst), &(sdu->lstEnt));
958 * @brief Function to add a re-transmitted pdu to the to be freed list
961 * @param[in] gCb RLC instance control block
962 * @param[in] retx Re-transmitted pdu to be added to the list
966 Void rlcUtlAddReTxPduToBeFreedQueue(RlcCb *gCb,RlcRetx *retx)
968 cmLListAdd2Tail(&(gCb->u.dlCb->toBeFreed.reTxLst), &(retx->lstEnt));
973 * @brief Function to add a transmitted pdu to the to be freed list
976 * @param[in] gCb RLC instance control block
977 * @param[in] pdu PDU to be added to the list
981 Void rlcUtlAddTxPduToBeFreedQueue(RlcCb *gCb,RlcTx *pdu)
983 pdu->rlsLnk.node = (PTR)pdu;
984 cmLListAdd2Tail(&(gCb->u.dlCb->toBeFreed.txLst), &(pdu->rlsLnk));
990 * function to free/release the Acknowledged mode RBCB buffers
993 * This primitive Frees the Acknowledged Mode RbCb transmission Buffer,
994 * retransmission Buffer and reciption Buffers
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
1001 * - TRUE if more data to be freed
1002 * - FALSE if all the data has been freed
1004 static Bool rlcUtlFreeDlAmRbMemory(RlcCb *gCb,RlcDlRbCb *rbCb,uint32_t *toBeFreed)
1006 RlcRetx *retx; /* retransmission buffer */
1007 RlcSn mTxNext; /* send state variable */
1010 MODAMT(RLC_AMDL.txNext, mTxNext, RLC_AMDL.txNextAck,RLC_AMDL.snModMask);
1012 /* TODO : to be checked changed from <= to < */
1013 while ((0 < mTxNext) && *toBeFreed)
1015 txBuf = rlcUtlGetTxBuf(RLC_AMDL.txBufLst, RLC_AMDL.txNextAck);
1016 if (txBuf && txBuf->pduLst.first)
1018 while(txBuf->pduLst.first)
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));
1026 rlcUtlDelTxBuf(RLC_AMDL.txBufLst, txBuf, gCb);
1027 if(gCb->u.dlCb->shutdownReceived == 0)
1032 RLC_AMDL.txNextAck = (RLC_AMDL.txNextAck + 1) & RLC_AMDL.snModMask;
1033 MODAMT(RLC_AMDL.txNext, mTxNext, RLC_AMDL.txNextAck,RLC_AMDL.snModMask);
1035 RLC_FREE(gCb, rbCb->snssai, sizeof(Snssai));
1042 RLC_FREE(gCb,RLC_AMDL.txBufLst, (RLC_TX_BUF_BIN_SIZE * sizeof(CmLListCp)));
1045 RLC_LLIST_FIRST_RETX(RLC_AMDL.retxLst, retx);
1046 while (retx && (*toBeFreed)) /* Till to be freed becomes 0 */
1049 ODU_PUT_MSG_BUF(retx->seg);
1051 cmLListDelFrm(&RLC_AMDL.retxLst, &retx->lstEnt);
1052 RLC_FREE(gCb, retx, sizeof(RlcRetx));
1054 RLC_LLIST_FIRST_RETX(RLC_AMDL.retxLst, retx);
1055 if(gCb->u.dlCb->shutdownReceived == 0)
1062 RLC_AMDL.nxtRetx = NULLP;
1064 /* clean up if there is info about STATUS PDU to be sent */
1065 if(RLC_AMDL.pStaPdu)
1068 udxPst = &gCb->u.dlCb->udxDlSap->pst;
1069 RLC_FREE_SHRABL_BUF_WC(udxPst->region,
1072 sizeof(RlcUdxDlStaPdu));
1073 RLC_AMDL.pStaPdu = NULLP;
1080 if(gCb->u.dlCb->shutdownReceived)
1089 * @brief Function to free memory from the DL instance
1092 * @param[in] gCb RLC instance control block
1096 Void rlcUtlFreeDlMemory(RlcCb *gCb)
1100 /* safety check, in case some event was still lying in the queue after
1101 the dlCb was deleted*/
1107 RlcDlDataToBeFreed* pToBeFreed = &gCb->u.dlCb->toBeFreed;
1109 if(gCb->u.dlCb->shutdownReceived)
1111 toBeFreed = pToBeFreed->txLst.count + pToBeFreed->reTxLst.count + pToBeFreed->sduLst.count + pToBeFreed->rbLst.count;
1115 if ((pToBeFreed->txLst.count + pToBeFreed->reTxLst.count + pToBeFreed->sduLst.count) > (3 * RLC_MAX_TO_BE_FREED))
1117 #if !defined(KWSELFPSTDLCLEAN) && defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS)
1118 if (isDatReqProcessed)
1120 toBeFreed = (2 *RLC_MAX_TO_BE_FREED);
1125 toBeFreed = (3 *RLC_MAX_TO_BE_FREED)/2;
1130 toBeFreed = RLC_MAX_TO_BE_FREED;
1135 gCb->u.dlCb->eventInQueue = FALSE; /* reset as we have received the event
1136 and are processing it */
1138 /* Free from the ReTx list */
1139 lst = &pToBeFreed->reTxLst;
1140 while((lst->first) && toBeFreed)
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));
1149 /* Free from the Tx list */
1150 lst = &pToBeFreed->txLst;
1151 while((lst->first) && toBeFreed)
1153 RlcTx* pdu = (RlcTx *)(lst->first->node);
1154 cmLListDelFrm(lst, lst->first);
1155 while(pdu->pduLst.first)
1157 RlcDlPduInfo *pduInfo = (RlcDlPduInfo *)(pdu->pduLst.first->node);
1159 cmLListDelFrm(&pdu->pduLst, pdu->pduLst.first);
1160 ODU_PUT_MSG_BUF(pduInfo->pdu);
1161 RLC_FREE(gCb, pduInfo, sizeof(RlcDlPduInfo));
1163 RLC_FREE(gCb,pdu, sizeof(RlcTx));
1167 /* Free from the SDU queue */
1168 lst = &pToBeFreed->sduLst;
1169 while((lst->first) && toBeFreed)
1171 RlcSdu* sdu = (RlcSdu *)(lst->first->node);
1172 RLC_REMOVE_SDU(gCb, lst, sdu);
1176 /* Free from the RBs */
1177 lst = &pToBeFreed->rbLst;
1178 while((lst->first) && toBeFreed)
1180 RlcDlRbCb* rbCb = (RlcDlRbCb *)(lst->first->node);
1181 Bool moreToBeFreed = rlcUtlFreeDlAmRbMemory(gCb, rbCb,&toBeFreed);
1184 cmLListDelFrm(lst, lst->first);
1185 RLC_FREE(gCb, rbCb, sizeof(RlcDlRbCb));
1189 if ((toBeFreed == 0) && !(gCb->u.dlCb->shutdownReceived))
1191 rlcUtlRaiseDlCleanupEvent(gCb);
1201 * @brief Function to initialise measurement
1205 * @param[in] gCb RLC Instance Control Block
1210 S16 rlcUtlL2MeasDlInit(RlcCb *gCb)
1214 gCb->u.dlCb->rlcL2Cb.rlcNumMeas=0;
1215 for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
1217 memset(&(gCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr]), 0, sizeof(RlcL2MeasEvtCb));
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;
1229 * @brief Function to detect the data Burst start Condition in a DTCH
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
1241 Void rlcUtlUpdateBurstSdus
1245 RlcContSduLst *contSduLst,
1251 RlcL2MeasDlIpTh *l2MeasDlIpThruput = NULLP;
1252 RlcL2MeasTb *l2MeasTb = NULLP;
1255 volatile uint32_t startTime = 0;
1256 RlcContSduLst *dstContSduLst;
1260 SStartTask(&startTime, PID_RLC_DLIP_TPT_BURSTCALC);
1262 l2MeasDlIpThruput = &rbCb->l2MeasIpThruput.dlIpTh;
1264 if(RLC_MEAS_IS_DL_IP_MEAS_ON_FOR_RB(gCb, rbCb))
1266 if(dataVol > schPduSz)
1268 if(l2MeasDlIpThruput->isBurstAct == FALSE)
1270 l2MeasDlIpThruput->burstStartTime = glblTtiCnt;
1271 l2MeasDlIpThruput->isBurstAct = TRUE;
1272 l2MeasDlIpThruput->burstEndSduId = 0;
1275 { /* This is the case when another burst started before RLC gets the
1276 l2MeasDlIpThruput->burstEndSduId = 0; */
1280 { /* Store the burstEndSduId here */
1281 if((l2MeasDlIpThruput->isBurstAct == TRUE) &&
1282 (!l2MeasDlIpThruput->burstEndSduId))
1284 l2MeasDlIpThruput->burstEndSduId =
1285 l2MeasDlIpThruput->outStngSduArr[l2MeasDlIpThruput->lastSduIdx].sduId;
1288 if(l2MeasDlIpThruput->isBurstAct == TRUE)
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)
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];
1302 for(idx = 0; ((idx < contSduLst->numSdus)
1303 && (currTbIdx < RLC_L2MEAS_MAX_OUTSTNGSDU)) ; idx++)
1305 dstContSduLst->sduIdx[currTbIdx++] = contSduLst->sduIdx[idx];
1307 l2MeasTb->sduInfo[l2MeasTb->numLcId].numSdus += idx;
1308 l2MeasTb->numLcId++;
1309 }/* End of isBurstAct */
1310 }/* End of if measOn */
1313 SStopTask(startTime, PID_RLC_DLIP_TPT_BURSTCALC);
1318 * This function is used to store locally the sduIdx of the sdu in the
1319 * outstanding SDU array
1322 * Stores the Sdu Idx in the contained SDU Array and increments
1323 * the num contained Sdus
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
1330 Void rlcUtlUpdateContainedSduLst(uint8_t sduIdx,RlcContSduLst *contSduLst)
1332 if (contSduLst->numSdus < RLC_L2MEAS_MAX_OUTSTNGSDU)
1334 contSduLst->sduIdx[contSduLst->numSdus] = sduIdx;
1335 contSduLst->numSdus++;
1342 * This function is used to store the sduId of the sdu in the
1343 * outstanding SDU array
1346 * Stores the Sdu Id in the outstanding SDU Array and increments
1347 * the num contained Sdus
1349 * @param[out] dlIpThPut The structure in which the outstanding sdus are
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
1358 Void rlcUtlUpdateOutStandingSduLst
1360 RlcL2MeasDlIpTh *dlIpThPut,
1367 if (sduIdx < RLC_L2MEAS_MAX_OUTSTNGSDU)
1371 dlIpThPut->outStngSduArr[sduIdx].numTb = 0;
1373 dlIpThPut->outStngSduArr[sduIdx].numTb++;
1374 dlIpThPut->outStngSduArr[sduIdx].sduId = sduId;
1375 dlIpThPut->outStngSduArr[sduIdx].sduLen = sduLen;
1379 RlcL2MeasTb * rlcUtlGetCurMeasTb(RlcCb *gCb,RlcDlRbCb *rbCb)
1381 RlcL2MeasTb *curL2MeasTb;
1384 if((curL2MeasTb = rbCb->ueCb->l2MeasTbCb[rbCb->ueCb->tbIdx]) == NULLP)
1386 /* Intentionally avoiding the RLC_ALLOC macro to avoid memset */
1387 RLC_ALLOC(gCb, curL2MeasTb, (Size)sizeof(RlcL2MeasTb));
1388 if(curL2MeasTb == NULLP)
1390 DU_LOG("ERROR --> RLC_DL : rlcUtlGetCurMeasTb(): Memory allocation failed");
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++)
1400 curL2MeasTb->sduInfo[idx].numSdus = 0;
1402 for (idx = 0; idx < RLC_MAX_ACTV_DRB; idx++)
1404 curL2MeasTb->lchInfo[idx].numSdus = 0;
1407 return (curL2MeasTb);
1413 * @brief Handler for Processing harq status indication
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
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.
1430 S16 rlcUtlProcHarqInd
1433 RguHarqStatusInd *hqStaInd,
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 */
1447 uint32_t totlSduCnt = 0;
1449 uint8_t timeAddedFlag;
1451 volatile uint32_t startTime = 0;
1452 /*kw005.201 Code added for DL IP thruput measurement*/
1455 SStartTask(&startTime, PID_RLC_DLIP_TPT_PRCHARQIND);
1458 if(hqStaInd->tbId[tbIdx] >= RLC_INVALID_TBID)
1463 /* Find the L2 measurement tbCb to process DL Ip thruput*/
1464 l2MeasTb = ueCb->l2MeasTbCb[hqStaInd->tbId[tbIdx]];
1465 if(l2MeasTb == NULLP)
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++)
1474 timeAddedFlag = FALSE;
1475 if((rlcRbCb = ueCb->lCh[l2MeasTb->sduInfo[lcIdx].lcId - 1].dlRbCb)
1480 /* fix for DL IP stop*/
1481 if (!gCb->u.dlCb->rlcL2Cb.measOn[rlcRbCb->qci]
1482 || (rlcRbCb->rlcId.rbType == CM_LTE_SRB))
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;
1491 if ((numSdus >= RLC_L2MEAS_MAX_OUTSTNGSDU) || (numSdus == 0))
1495 totlSduCnt += numSdus;
1497 if (RLC_MEAS_IS_DL_IP_MEAS_ON_FOR_RB(gCb,rlcRbCb))
1499 for(sduIndx = 0; sduIndx < numSdus; sduIndx++)
1501 outStngSduArr =&(rlcRbCb->l2MeasIpThruput.dlIpTh.outStngSduArr[\
1502 l2MeasTb->sduInfo[lcIdx].sduIdx[sduIndx]]);
1503 if(hqStaInd->status[tbIdx] == TRUE)
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))
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;
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;
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))
1528 rlcRbCb->rbL2Cb.l2Sts[RLC_L2MEAS_DL_IP]->dlIpThruput.volSummation
1529 += outStngSduArr->sduLen;
1531 if(timeAddedFlag == FALSE)
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;
1538 outStngSduArr->sduId = 0;
1539 outStngSduArr->sduLen = 0;
1541 }/* End of status == TRUE */
1544 if(rlcRbCb->l2MeasIpThruput.dlIpTh.isBurstAct == TRUE)
1546 if((rlcRbCb->l2MeasIpThruput.dlIpTh.burstEndSduId ==
1547 outStngSduArr->sduId))
1549 rlcRbCb->l2MeasIpThruput.dlIpTh.isBurstAct = FALSE;
1550 rlcRbCb->l2MeasIpThruput.dlIpTh.burstEndSduId = 0;
1552 /* Clear the outstanding sdu list */
1553 outStngSduArr->sduId = 0;
1554 outStngSduArr->sduLen = 0;
1555 outStngSduArr->numTb = 0;
1562 for(lcIdx = 0; ((lcIdx < l2MeasTb->numLchInfo) && (lcIdx < RLC_MAX_ACTV_DRB)); lcIdx++)
1564 if((rlcRbCb = ueCb->lCh[l2MeasTb->lchInfo[lcIdx].lcId - 1].dlRbCb)
1569 numSdus = l2MeasTb->lchInfo[lcIdx].numSdus;
1575 if ((numSdus > RLC_L2MEAS_MAX_OUTSTNGSDU) || (numSdus == 0))
1580 if(hqStaInd->status[tbIdx] == TRUE)
1582 for(sduIndx = 0; sduIndx < numSdus; sduIndx++)
1584 delay = RLC_TIME_DIFF(ackTime,l2MeasTb->lchInfo[lcIdx].sduInfo[sduIndx].arvlTime);
1585 RLC_UPD_PDCP_L2_DLDELAY_STS(gCb,rlcRbCb, delay);
1587 /* Case of sduInfo not updated */
1588 if (totlSduCnt == 0)
1590 totlSduCnt = numSdus;
1592 RLC_UPD_L2_UU_LOSS_POS_PKTS(gCb,rlcRbCb, (totlSduCnt + l2MeasTb->txSegSduCnt));
1596 /* Case of sduInfo not updated */
1597 if (totlSduCnt == 0)
1599 totlSduCnt = numSdus;
1601 RLC_UPD_L2_UU_LOSS_PKTS(gCb,rlcRbCb, (totlSduCnt + l2MeasTb->txSegSduCnt));
1604 /* Free this tb, deallocate the memory */
1605 RLC_FREE(gCb, l2MeasTb, sizeof(RlcL2MeasTb));
1606 ueCb->l2MeasTbCb[hqStaInd->tbId[tbIdx]] = NULLP;
1609 SStopTask(startTime, PID_RLC_DLIP_TPT_PRCHARQIND);
1612 }/* end of rlcUtlProcHarqInd */
1616 * @brief Handler for Sending L2 Measurement confirm.
1620 * This function sends a consolidates the mesaurements taken during
1621 * this time and sends the confirm .
1623 * @param[in] measEvtCb Measurement Event Control Block.
1630 S16 rlcUtlSndDlL2MeasCfm(RlcCb *gCb,RlcL2MeasEvtCb *measEvtCb)
1633 RlcL2MeasCb *measCb = NULLP;
1634 RlcL2MeasCfmEvt measCfmEvt;
1640 /* Discard new changes starts */
1643 /* Discard new changes ends */
1645 /* kw006.201 ccpu00120058 emoved 64 bit compilation warning */
1647 DU_LOG("\nDEBUG --> RLC_DL : rlcUtlSndL2MeasCfm(transId(%ld))", measEvtCb->transId);
1649 DU_LOG("\nDEBUG --> RLC_DL : rlcUtlSndL2MeasCfm(transId(%d))", measEvtCb->transId);
1652 /* Clean up the RB data structures */
1653 measCb = &measEvtCb->measCb;
1655 memset(&measCfmEvt, 0, sizeof(RlcL2MeasCfmEvt));
1656 measCfmEvt.transId = measEvtCb->transId;
1658 measCfmEvt.measType = measCb->measType;
1659 measCfmEvt.status.status = LCM_PRIM_OK;
1660 measCfmEvt.status.reason = LCM_REASON_NOT_APPL;
1662 if(measCb->measType & LKW_L2MEAS_DL_IP)
1664 RlcL2MeasCbUeMeasInfo *pUeInfoLstCb = measCb->val.ipThMeas.ueInfoLst;
1665 RlcL2MeasCfmUeInfoLst *pUeInfoLstCfm = measCfmEvt.val.ipThMeas.ueInfoLst;
1667 for(cntr = 0;(cntr < measCb->val.ipThMeas.numUes) && (cntr < gCb->genCfg.maxUe);cntr++)
1669 pUeInfoLstCfm[cfmIdx].numCfm = 0;
1670 if (pUeInfoLstCb[cntr].isValid == TRUE)
1672 pUeInfoLstCfm[cfmIdx].ueId = pUeInfoLstCb[cntr].ueId;
1673 pUeInfoLstCfm[cfmIdx].cellId = pUeInfoLstCb[cntr].cellId;
1674 for(qciIdx = 0; qciIdx < pUeInfoLstCb[cntr].numQci; qciIdx++)
1676 qci = pUeInfoLstCb[cntr].qci[qciIdx];
1677 pUeInfoLstCfm[cfmIdx].measCfm[pUeInfoLstCfm[cfmIdx].numCfm].qci = qci;
1679 dlDataVol = pUeInfoLstCb[cntr].measData[qci].dlIpThruput.volSummation;
1680 dlTime = pUeInfoLstCb[cntr].measData[qci].dlIpThruput.timeSummation;
1682 if((0 == dlTime) || !(gCb->u.dlCb->rlcL2Cb.measOn[qci] & LKW_L2MEAS_DL_IP) )
1684 pUeInfoLstCfm[cfmIdx].measCfm[pUeInfoLstCfm[cfmIdx].numCfm].val.ipThrput.dlIpThPut = 0;
1688 pUeInfoLstCfm[cfmIdx].measCfm[pUeInfoLstCfm[cfmIdx].numCfm].val.ipThrput.dlIpThPut =
1689 (dlDataVol / dlTime);
1691 pUeInfoLstCfm[cfmIdx].measCfm[pUeInfoLstCfm[cfmIdx].numCfm].val.ipThrput.dlIpThPut *= 8;
1693 /* Reset the values after reporting to Application */
1694 pUeInfoLstCb[cntr].measData[qci].dlIpThruput.volSummation = 0;
1695 pUeInfoLstCb[cntr].measData[qci].dlIpThruput.timeSummation = 0;
1697 measCfmEvt.val.ipThMeas.ueInfoLst[cfmIdx].numCfm++;
1702 measCfmEvt.val.ipThMeas.numUes = cfmIdx;
1706 RlcL2Cntr *pMeasData = measCb->val.nonIpThMeas.measData;
1707 RlcL2MeasCfmNonIpThMeas *pMeasCfmNonIp = &measCfmEvt.val.nonIpThMeas;
1709 pMeasCfmNonIp->numCfm = 0;
1711 for(qciIdx = 0; qciIdx < LKW_MAX_QCI; qciIdx++)
1713 qci = measCb->val.nonIpThMeas.qci[qciIdx];
1716 pMeasCfmNonIp->measCfm[pMeasCfmNonIp->numCfm].qci = qci;
1718 if(measCb->measType & LKW_L2MEAS_UU_LOSS)
1720 dLoss = pMeasData[qci].uuLoss.dLoss;
1721 posPkts = pMeasData[qci].uuLoss.posPkts;
1722 if(((posPkts + dLoss) != 0))
1724 pMeasCfmNonIp->measCfm[pMeasCfmNonIp->numCfm].val.nonIpThrput.uuLoss =
1725 ((dLoss * 1000000) / (posPkts + dLoss));
1727 pMeasData[qci].uuLoss.dLoss = 0;
1728 pMeasData[qci].uuLoss.posPkts = 0;
1730 if(measCb->measType & LKW_L2MEAS_DL_DISC)
1733 pMeasCfmNonIp->measCfm[pMeasCfmNonIp->numCfm].val.nonIpThrput.dlDiscRate = 0;
1734 if(pMeasData[qci].dlDisc.totSdus != 0)
1736 pMeasCfmNonIp->measCfm[pMeasCfmNonIp->numCfm].val.nonIpThrput.dlDiscRate =
1737 (((pMeasData[qci].dlDisc.discSdus) * 1000000) / (pMeasData[qci].dlDisc.totSdus));
1740 pMeasData[qci].dlDisc.totSdus = 0;
1741 pMeasData[qci].dlDisc.discSdus = 0;
1743 if(measCb->measType & LKW_L2MEAS_DL_DELAY)
1745 if (pMeasData[qci].dlPjSduDelay.numSdus > 0)
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;
1753 pMeasCfmNonIp->numCfm++;
1757 /* Fix Klock warning */
1758 RlcMiLkwL2MeasCfm(&gCb->genCfg.lmPst, &measCfmEvt);
1760 } /* rlcUtlSndL2MeasCfm */
1763 * @brief Handler for Sending Negative confirm .
1767 * This function is called when the l2 measurement cannot be started
1768 * This function sends negative confirm for all the requests
1770 * @param[in] measReqEvt Measurement Req Structure
1777 S16 rlcUtlSndDlL2MeasNCfm(RlcCb *gCb,RlcL2MeasReqEvt *measReqEvt,RlcL2MeasCfmEvt *measCfmEvt)
1780 RlcMiLkwL2MeasCfm(&gCb->genCfg.lmPst, measCfmEvt);
1782 } /* kwUtlSndL2MeasNCfm */
1785 * @brief Handler for resetting the RB data structures
1789 * This function resets the RB data structure after the expiry of
1790 * measurement timer.
1792 * @param[in] measCb Measurement Control Block.
1798 Void rlcUtlResetDlL2MeasInRlcRb(RlcCb *gCb,RlcL2MeasCb *measCb,uint8_t measType)
1802 RlcDlUeCb *ueCb = NULL;
1806 if (measCb->measType & LKW_L2MEAS_DL_IP)
1808 for(ueIdx = 0; ueIdx < measCb->val.ipThMeas.numUes; ueIdx++)
1810 if (measCb->val.ipThMeas.ueInfoLst[ueIdx].isValid == TRUE)
1812 for (qciIdx =0; qciIdx < measCb->val.ipThMeas.ueInfoLst[ueIdx].numQci; qciIdx++)
1814 if (measType & LKW_L2MEAS_DL_IP)
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;
1822 if(ROK != rlcDbmFetchDlUeCb(gCb,measCb->val.ipThMeas.ueInfoLst[ueIdx].ueId,
1823 measCb->val.ipThMeas.ueInfoLst[ueIdx].cellId, &ueCb))
1833 /* for now the only meas should be DL discard in this case */
1834 if (measCb->measType & LKW_L2MEAS_DL_DISC)
1837 for(i = 0; i < measCb->val.nonIpThMeas.numQci; i++)
1839 uint8_t qciVal = measCb->val.nonIpThMeas.qci[i];
1841 measCb->val.nonIpThMeas.measData[qciVal].dlDisc.discSdus = 0;
1842 measCb->val.nonIpThMeas.measData[qciVal].dlDisc.totSdus = 0;
1846 if (measCb->measType & LKW_L2MEAS_DL_DELAY)
1849 for(i = 0; i < measCb->val.nonIpThMeas.numQci; i++)
1851 uint8_t qciVal = measCb->val.nonIpThMeas.qci[i];
1853 measCb->val.nonIpThMeas.measData[qciVal].dlPjSduDelay.sduDelay = 0;
1856 measCb->val.nonIpThMeas.numQci = 0;
1858 } /* rlcUtlResetDlL2MeasInRlcRb */
1861 static Void dumpRLCDlRbInformation(RlcDlRbCb* dlRbCb)
1863 if(dlRbCb->mode == RLC_MODE_UM)
1865 DU_LOG("\nDEBUG --> RLC_DL : UM Downlink UEID:%d CELLID:%d Q size = %d",
1867 dlRbCb->rlcId.cellId,
1868 (int)dlRbCb->m.umDl.sduQ.count);
1870 else if(dlRbCb->mode == RLC_MODE_AM)
1872 uint32_t j, numTxPdus=0;
1873 for(j = 0; j <= (RLC_AM_GET_WIN_SZ(dlRbCb->m.amDl.snLen)); j++)
1875 RlcTx *txBuf = rlcUtlGetTxBuf(dlRbCb->m.amDl.txBufLst, j);
1881 DU_LOG("\nDEBUG --> RLC_DL : AM Downlink UEID:%d CELLID:%d Sizes SDU Q = %d TX Q = %d ",
1883 dlRbCb->rlcId.cellId,
1884 (int)dlRbCb->m.amDl.sduQ.count,
1886 DU_LOG("\nDEBUG --> RLC_DL : AM Downlink UEID:%d CELLID:%d RETX Q= %d",
1888 dlRbCb->rlcId.cellId,
1889 (int)dlRbCb->m.amDl.retxLst.count);
1893 Void DumpRLCDlDebugInformation(Void)
1895 RlcCb* dlInst = rlcCb[1]; /* TODO : Check whether DL is 0 or 1 */
1897 RlcDlCb *dlCb = dlInst->u.dlCb;
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,
1908 for(i = 0; i< RLC_MAX_SRB_PER_UE; i++)
1910 RlcDlRbCb* dlRbCb = ueCb->srbCb[i];
1911 if( dlRbCb != NULLP)
1913 dumpRLCDlRbInformation(dlRbCb);
1916 for(i = 0; i< RLC_MAX_DRB_PER_UE; i++)
1918 RlcDlRbCb* dlRbCb = ueCb->drbCb[i];
1919 if( dlRbCb != NULLP)
1921 dumpRLCDlRbInformation(dlRbCb);
1926 RlcDlDataToBeFreed* pToBeFreed = &dlCb->toBeFreed;
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);
1937 * This function frees downlink memory
1945 void rlcUtlFreeDlMem( Void)
1947 rlcUtlFreeDlMemory(RLC_GET_RLCCB(RLC_DL_INST));
1953 * This function returns current time
1955 * @param[in] uint32_t
1961 void rlcUtlGetCurrTime(uint32_t *currTime)
1963 /* Need t define else part for PAL */
1964 *currTime = SGetTtiCount();
1967 #if defined(MAC_RLC_HARQ_STA_RBUF) || defined (SS_RBUF)
1969 void rlcUtlDlBatchProcHqStaInd( Void)
1971 /* Read from Ring Buffer and process PDCP packets */
1974 Void *elmIndx = NULLP;
1975 RguHarqStaInd *staInd = NULLP;
1977 #if defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS)
1978 isDatReqProcessed = TRUE;
1980 elmIndx = (Void *)SRngGetRIndx(SS_RNG_BUF_MAC_HARQ);
1981 while(NULLP != elmIndx)
1983 staInd = (RguHarqStaInd *)elmIndx;
1984 RlcLiRguHqStaInd(&(staInd->pst), 0, &(staInd->hqStatusInd));
1988 SRngIncrRIndx(SS_RNG_BUF_MAC_HARQ);
1990 if((elmIndx = (Void *)SRngGetRIndx(SS_RNG_BUF_MAC_HARQ)) == NULLP)
1992 #if defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS)
1993 isDatReqProcessed = FALSE;
2003 * @brief evaluate and trigger PDB based flow control to PDCP
2007 * @param[in] rbCb RB control block
2013 Void rlcUtlTrigPdbFlowCntrl(RlcCb *gCb,RlcDlRbCb *rbCb,uint32_t pktAdmitCnt)
2015 KwuFlowCntrlIndInfo *flowCntrlInfo;
2016 RlcKwuSapCb* rlckwuSap;
2018 rlckwuSap = gCb->u.dlCb->rlcKwuDlSap + RLC_UI_PDCP;
2020 RLC_SHRABL_STATIC_BUF_ALLOC(rlckwuSap->pst.region,
2021 rlckwuSap->pst.pool,
2023 sizeof(KwuFlowCntrlIndInfo));
2024 flowCntrlInfo->rlcId = rbCb->rlcId;
2025 flowCntrlInfo->pktAdmitCnt = pktAdmitCnt;
2026 RlcUiKwuFlowCntrlInd(&rlckwuSap->pst, rlckwuSap->suId, flowCntrlInfo);
2031 * @brief Store the DL buffer in hashList
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
2044 void rlcUtlStoreTxBuf(CmLListCp *txBufLst, RlcTx *txBuf, RlcSn sn)
2048 hashKey = (sn % RLC_TX_BUF_BIN_SIZE );
2050 txBuf->lnk.node = (PTR)txBuf;
2051 cmLListAdd2Tail(&(txBufLst[hashKey]), &txBuf->lnk);
2054 } /* rlcUtlStoreRecBuf */
2058 * @brief Retrieve the DL buffer from the list
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
2070 RlcTx* rlcUtlGetTxBuf(CmLListCp *txBufLst, RlcSn sn)
2073 CmLListCp *txBufLstCp;
2075 CmLList *node = NULLP;
2077 hashKey = (sn % RLC_TX_BUF_BIN_SIZE );
2079 txBufLstCp = &txBufLst[hashKey];
2080 CM_LLIST_FIRST_NODE(txBufLstCp, node);
2083 txBuf = (RlcTx *) node->node;
2088 CM_LLIST_NEXT_NODE(txBufLstCp, node);
2091 } /* rlcUtlStoreTxBuf */
2094 * @brief Delete the DL buffer from the list
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
2106 Void rlcUtlDelTxBuf (CmLListCp *txBufLst,RlcTx *txBuf,RlcCb *gCb)
2109 CmLListCp *txBufLstCp;
2111 hashKey = (txBuf->sn % RLC_TX_BUF_BIN_SIZE );
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));
2118 } /* rlcUtlDelTxBuf */
2122 * @brief Remove the DL buffer from the list
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
2134 Void rlcUtlRemovTxBuf(CmLListCp *txBufLst,RlcTx *txBuf,RlcCb *gCb)
2137 CmLListCp *txBufLstCp;
2139 hashKey = (txBuf->sn % RLC_TX_BUF_BIN_SIZE );
2141 txBufLstCp = &txBufLst[hashKey];
2142 //DU_LOG("\nINFO --> RLC_DL : D-sn(%d)\n", txBuf->hdr.sn);
2143 cmLListDelFrm(txBufLstCp, &txBuf->lnk);
2145 } /* rlcUtlRemovTxBuf */
2149 /********************************************************************30**
2151 **********************************************************************/