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 /********************************************************************20**
21 Name: LTE-RLC Layer - Lower Interface Functions
25 Desc: Source code for RLC Lower Interface Module.
26 This file contains following functions
31 --rlcProcCommLcSchedRpt
32 --rlcProcDedLcSchedRpt
37 **********************************************************************/
41 * @brief RLC Lower Interface module
44 #define RLC_MODULE RLC_DBGMASK_INF
47 /* header (.h) include files */
48 #include "common_def.h"
49 #include "lkw.h" /* LKW defines */
50 #include "ckw.h" /* CKW defines */
51 #include "kwu.h" /* KWU defines */
52 #include "rgu.h" /* RGU defines */
54 #include "kw_env.h" /* RLC environment options */
56 #include "kw.h" /* RLC defines */
61 /* extern (.x) include files */
62 #include "lkw.x" /* LKW */
63 #include "ckw.x" /* CKW */
64 #include "kwu.x" /* KWU */
65 #include "rgu.x" /* RGU */
71 #include "rlc_utils.h"
72 #include "rlc_mac_inf.h"
76 #endif /* __cplusplus */
79 /*****************************************************************************
81 ****************************************************************************/
83 * @brief Handler for bind confirmation from MAC.
86 * This function handles the bind confirmation received from MAC. If the
87 * bind was successful changes the state of the SAP to RLC_SAP_BND
88 * else RLC_SAP_CFG. Sends an alarm to LM in any case
90 * @param[in] pst Post structure
91 * @param[in] suId Service User ID
92 * @param[in] status Status whether the bind was successful or not
99 S16 RlcLiRguBndCfm(Pst *pst,SuId suId,uint8_t status)
101 uint16_t event; /* Event */
102 uint16_t cause; /* Cause */
103 RlcRguSapCb *rguSap; /* RGU SAP Control Block */
106 #if (ERRCLASS & ERRCLS_INT_PAR)
107 if (pst->dstInst >= MAX_RLC_INSTANCES)
112 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
114 DU_LOG("\nDEBUG --> RLC UL : RlcLiRguBndCfm(suId(%d), status(%d)", suId, status);
116 #if (ERRCLASS & ERRCLS_INT_PAR)
117 if (tRlcCb->init.cfgDone != TRUE)
119 DU_LOG("\nERROR --> RLC UL : General configuration not done");
121 RLC_SEND_SAPID_ALARM(tRlcCb,suId,LKW_EVENT_LI_BND_CFM, LCM_CAUSE_INV_STATE);
126 if ((suId >= tRlcCb->genCfg.maxRguSaps) || (suId < 0))
128 DU_LOG("\nERROR --> RLC UL : Invalid suId");
130 RLC_SEND_SAPID_ALARM(tRlcCb,suId, LKW_EVENT_LI_BND_CFM, LCM_CAUSE_INV_SUID);
134 #endif /* ERRCLASS & ERRCLS_INT_PAR */
136 rguSap = (tRlcCb->genCfg.rlcMode == LKW_RLC_MODE_DL) ?
137 &(tRlcCb->u.dlCb->rguDlSap[suId]) : &(tRlcCb->u.ulCb->rguUlSap[suId]);
139 DU_LOG("\nDEBUG --> RLC UL : RlcLiRguBndCfm: For RGU SAP state=%d", rguSap->state);
141 switch (rguSap->state)
143 case RLC_SAP_BINDING:
145 rlcStopTmr (tRlcCb,(PTR)rguSap, EVENT_RLC_WAIT_BNDCFM);
147 rguSap->retryCnt = 0;
149 if (status == CM_BND_OK)
151 rguSap->state = RLC_SAP_BND;
152 event = LCM_EVENT_BND_OK;
153 cause = LKW_CAUSE_SAP_BNDENB;
157 rguSap->state = RLC_SAP_CFG;
158 event = LCM_EVENT_BND_FAIL;
159 cause = LKW_CAUSE_UNKNOWN;
165 event = LKW_EVENT_RGU_BND_CFM;
166 cause = LCM_CAUSE_INV_STATE;
170 /* Send an alarm with proper event and cause */
171 RLC_SEND_SAPID_ALARM(tRlcCb, suId, event, cause);
174 } /* RlcLiRguBndCfm */
179 * @brief Handler to process PDU received from MAC for common logical channels.
182 * This function receives the PDU from MAC for common logical channels
183 * does checks before handing over the PDU to the TM module
185 * @param[in] pst Post structure
186 * @param[in] suId Service User ID
187 * @param[in] datInd Data Indication Information
194 uint8_t rlcProcCommLcUlData(Pst *pst, SuId suId, RguCDatIndInfo *datInd)
201 #if (ERRCLASS & ERRCLS_INT_PAR)
202 if (pst->dstInst >= MAX_RLC_INSTANCES)
204 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguCDatIndInfo));
209 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
211 #if (ERRCLASS & ERRCLS_DEBUG)
212 if (tRlcCb->genCfg.rlcMode == LKW_RLC_MODE_DL)
214 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguCDatIndInfo));
219 /* kw006.201 ccpu00120058, Added array boundary condition check */
220 #if (ERRCLASS & ERRCLS_DEBUG)
221 if(RLC_MAX_LCH_PER_CELL <= datInd->lcId)
223 DU_LOG("\nERROR --> RLC UL : rlcProcCommLcUlData : Invalid LcId [%d], Max is [%d]",\
224 datInd->lcId, RLC_MAX_LCH_PER_CELL);
225 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguCDatIndInfo));
228 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
230 /* Fetch RbCb from lcId */
231 rlcDbmFetchUlRbCbFromLchId(tRlcCb, datInd->rnti, datInd->cellId, datInd->lcId, &rbCb);
234 DU_LOG("\nERROR --> RLC UL : rlcProcCommLcUlData : LcId [%d] not found",
236 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguCDatIndInfo));
240 /* Dispatch to TM Module */
242 rlcTmmRcvFrmMac(tRlcCb, rbCb, datInd->rnti, datInd->pdu);
244 rlcTmmRcvFrmMac(tRlcCb, rbCb, datInd->pdu);
245 #endif /* CCPU_OPT */
247 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguCDatIndInfo));
250 } /* rlcProcCommLcUlData */
253 * @brief Handler to process PDU received from MAC for
254 * dedicated logical channels.
257 * This function receives the PDU from MAC for one or more dedicated
258 * logical channels and passes it to the UTL module for further processing
260 * @param[in] pst Post structure
261 * @param[in] suId Service User ID
262 * @param[in] datInd Data Indication Information
270 uint8_t rlcProcDedLcUlData(Pst *pst, SuId suId, RguDDatIndInfo *datInd)
273 #if (ERRCLASS & ERRCLS_INT_PAR)
274 if (pst->dstInst >= MAX_RLC_INSTANCES)
276 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguDDatIndInfo));
281 #if (ERRCLASS & ERRCLS_DEBUG)
282 if (((RlcCb*)RLC_GET_RLCCB(pst->dstInst))->genCfg.rlcMode == LKW_RLC_MODE_DL)
284 DU_LOG("\nDEBUG --> RLC UL : rlcProcDedLcUlData : suId(%d))recieved in DL Inst", suId);
285 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguDDatIndInfo));
289 rlcUtlRcvFrmMac(RLC_GET_RLCCB(pst->dstInst),datInd);
291 #ifdef SS_LOCKLESS_MEMORY
292 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguDDatIndInfo));
294 RLC_PST_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguDDatIndInfo));
299 } /* rlcProcDedLcUlData */
302 * @brief Handler for trigerring the data transfer from RLC to MAC
303 * for common logical channels.
306 * This function receives the size of the PDU to be transmitted
307 * and acts as a trigger for forming PDU and sending it to MAC.
309 * @param[in] pst Post structure
310 * @param[in] suId Service User ID
311 * @param[in] staInd Status Indication Information for Common Logical
319 uint8_t rlcProcCommLcSchedRpt(Pst *pst, SuId suId, RguCStaIndInfo *staInd)
324 #if (ERRCLASS & ERRCLS_INT_PAR)
325 if (pst->dstInst >= MAX_RLC_INSTANCES)
327 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguCStaIndInfo));
332 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
334 #if (ERRCLASS & ERRCLS_INT_PAR)
335 if ((suId >= tRlcCb->genCfg.maxRguSaps) || (suId < 0))
337 DU_LOG("\nERROR --> RLC UL : rlcProcCommLcSchedRpt: Invalid RGU suId %d\n", suId);
340 if (tRlcCb->genCfg.rlcMode == LKW_RLC_MODE_UL)
342 DU_LOG("\nDEBUG --> RLC UL : rlcProcCommLcSchedRpt: Received in RLC UL CELLID:%d",
344 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguCStaIndInfo));
351 /* kw006.201 ccpu00120058, added boundary condition check */
352 #if (ERRCLASS & ERRCLS_DEBUG)
353 if(RLC_MAX_LCH_PER_CELL < staInd->lcId)
355 DU_LOG("\nERROR --> RLC UL : rlcProcCommLcSchedRpt: Invalid LcId, Max is [%d] CELLID:%d",
356 RLC_MAX_LCH_PER_CELL, staInd->cellId);
357 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguCStaIndInfo));
360 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
361 /* Fertch RbCb from lcId */
362 rlcDbmFetchDlRbCbFromLchId(tRlcCb,0, staInd->cellId, staInd->lcId, &rbCb);
365 DU_LOG("\nERROR --> RLC UL : rlcProcCommLcSchedRpt: LcId [%d] not found CELLID:%d",
366 staInd->lcId, staInd->cellId);
367 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguCStaIndInfo));
371 /* Dispatch to TM Module */
372 rbCb->transId = staInd->transId;
373 rlcTmmSendToMac(tRlcCb, suId, rbCb, staInd);
375 #ifdef SS_LOCKLESS_MEMORY
376 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguCStaIndInfo));
378 RLC_PST_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguCStaIndInfo));
381 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguCStaIndInfo));
384 } /* rlcProcCommLcSchedRpt */
387 * @brief Handler for trigerring the data transfer from RLC to MAC
388 * for dedicated logical channels.
391 * This function receives the size of the PDUs to be transmitted to
392 * MAC via one or more dedicated logical channels and acts as a trigger
393 * for forming PDUs and sending them to MAC.
395 * @param[in] pst Post structure
396 * @param[in] suId Service User ID
397 * @param[in] staInd Status Indication Information for Dedicated Logical
405 uint8_t rlcProcDedLcSchedRpt(Pst *pst, SuId suId, RguDStaIndInfo *staInd)
409 #if (ERRCLASS & ERRCLS_INT_PAR)
410 if (pst->dstInst >= MAX_RLC_INSTANCES)
412 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguDStaIndInfo));
417 gCb = RLC_GET_RLCCB(pst->dstInst);
419 #if (ERRCLASS & ERRCLS_INT_PAR)
420 if (((RlcCb*)RLC_GET_RLCCB(pst->dstInst))->genCfg.rlcMode == LKW_RLC_MODE_UL)
422 DU_LOG("\nDEBUG --> RLC UL : rlcProcDedLcSchedRpt: Received in RLC UL ");
423 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguDStaIndInfo));
426 if ((suId >= gCb->genCfg.maxRguSaps) || (suId < 0))
428 DU_LOG("\nERROR --> RLC UL : rlcProcDedLcSchedRpt: Invalid RGU suId %d\n", suId);
432 rlcUtlSendToMac(gCb, suId, staInd);
434 /* kw002.201 :Freeing from proper region */
435 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguDStaIndInfo));
437 } /* rlcProcDedLcSchedRpt */
440 * @brief Handler for handling the flow cntrl Ind from MAC
444 * This function receives the flow control indication from
445 * MAC and calls rlcUtlTrigPdbFlowCntrl
447 * @param[in] pst Post structure
448 * @param[in] suId Service User ID
449 * @param[in] flowCntrlInd flow control Indication Information
457 S16 RlcLiRguFlowCntrlInd(Pst *pst,SuId suId,RguFlowCntrlInd *flowCntrlInd)
460 RlcDlRbCb *rbCb = NULLP;
464 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
465 for (idx = 0; idx < flowCntrlInd->numUes; idx++)
467 for (lcIdx = 0; lcIdx < flowCntrlInd->ueFlowCntrlInfo[idx].numLcs; lcIdx++)
469 RguLcFlowCntrlInfo *lcInfo = &(flowCntrlInd->ueFlowCntrlInfo[idx].lcInfo[lcIdx]);
470 rlcDbmFetchDlRbCbFromLchId(tRlcCb, flowCntrlInd->ueFlowCntrlInfo[idx].ueId, flowCntrlInd->cellId, lcInfo->lcId, &rbCb);
474 if (lcInfo->pktAdmitCnt == 0) /* Special case */
476 rlcUtlTrigPdbFlowCntrl(tRlcCb, rbCb, lcInfo->pktAdmitCnt);
479 if (rbCb->mode == RLC_MODE_AM)
481 if ((rbCb->m.amDl.retxLst.count != 0) ||
482 ((rbCb->m.amDl.bo == 0) ||
483 (rbCb->m.amDl.bo < lcInfo->maxBo4FlowCtrl)))
490 if ((rbCb->m.umDl.bo == 0) ||
491 (rbCb->m.umDl.bo < lcInfo->maxBo4FlowCtrl))
496 rlcUtlTrigPdbFlowCntrl(tRlcCb, rbCb, lcInfo->pktAdmitCnt);
502 /* kw005.201 added support for L2 Measurement */
509 * Handler for indicating the Harq Status of the data sent.
513 * This function receives the harq status of the data sent to MAC.
514 * This information is used for two things.
515 * 1. Computing the UuLoss of UM
516 * 2. Computing the DL Delay for UM and AM.
518 * @param[in] pst - Post structure
519 * @param[in] suId - Service User ID
520 * @param[in] staInd - Harq Status Indication Information.
527 S16 RlcLiRguHqStaInd(Pst *pst, SuId suId,RguHarqStatusInd *staInd)
536 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
537 ueKey.cellId = staInd->cellId;
538 ueKey.ueId = staInd->ueId;
540 ret = rlcDbmFetchDlUeCb(tRlcCb, ueKey.ueId, ueKey.cellId, &ueCb);
546 /*Call rlcUtlProcHarqInd as many times as number of Tbs present*/
547 for ( tbIdx = 0; tbIdx < staInd->numTbs; tbIdx++)
549 rlcUtlProcHarqInd(tRlcCb, staInd, ueCb, tbIdx);
553 } /* RlcLiRguHqStaInd */
554 #endif /* LTE_L2_MEAS */
558 #endif /* __cplusplus */
560 /********************************************************************30**
562 **********************************************************************/