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 **********************************************************************/
38 static const char* RLOG_MODULE_NAME="LIM";
39 static int RLOG_MODULE_ID=2048;
40 static int RLOG_FILE_ID=196;
44 * @brief RLC Lower Interface module
47 #define RLC_MODULE RLC_DBGMASK_INF
50 /* header (.h) include files */
51 #include "common_def.h"
52 #include "lkw.h" /* LKW defines */
53 #include "ckw.h" /* CKW defines */
54 #include "kwu.h" /* KWU defines */
55 #include "rgu.h" /* RGU defines */
57 #include "kw_env.h" /* RLC environment options */
59 #include "kw.h" /* RLC defines */
64 /* extern (.x) include files */
65 #include "lkw.x" /* LKW */
66 #include "ckw.x" /* CKW */
67 #include "kwu.x" /* KWU */
68 #include "rgu.x" /* RGU */
74 #include "rlc_utils.h"
75 #include "rlc_mac_inf.h"
79 #endif /* __cplusplus */
82 /*****************************************************************************
84 ****************************************************************************/
86 * @brief Handler for bind confirmation from MAC.
89 * This function handles the bind confirmation received from MAC. If the
90 * bind was successful changes the state of the SAP to RLC_SAP_BND
91 * else RLC_SAP_CFG. Sends an alarm to LM in any case
93 * @param[in] pst Post structure
94 * @param[in] suId Service User ID
95 * @param[in] status Status whether the bind was successful or not
110 S16 RlcLiRguBndCfm (pst, suId, status)
116 uint16_t event; /* Event */
117 uint16_t cause; /* Cause */
118 RlcRguSapCb *rguSap; /* RGU SAP Control Block */
121 #if (ERRCLASS & ERRCLS_INT_PAR)
122 if (pst->dstInst >= MAX_RLC_INSTANCES)
127 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
129 RLOG2(L_DEBUG,"RlcLiRguBndCfm(suId(%d), status(%d)", suId, status);
131 #if (ERRCLASS & ERRCLS_INT_PAR)
132 if (tRlcCb->init.cfgDone != TRUE)
134 RLOG0(L_FATAL,"General configuration not done");
136 RLC_SEND_SAPID_ALARM(tRlcCb,suId,LKW_EVENT_LI_BND_CFM, LCM_CAUSE_INV_STATE);
141 if ((suId >= tRlcCb->genCfg.maxRguSaps) || (suId < 0))
143 RLOG0(L_ERROR, "Invalid suId");
145 RLC_SEND_SAPID_ALARM(tRlcCb,suId, LKW_EVENT_LI_BND_CFM, LCM_CAUSE_INV_SUID);
149 #endif /* ERRCLASS & ERRCLS_INT_PAR */
151 rguSap = (tRlcCb->genCfg.rlcMode == LKW_RLC_MODE_DL) ?
152 &(tRlcCb->u.dlCb->rguDlSap[suId]) : &(tRlcCb->u.ulCb->rguUlSap[suId]);
154 RLOG1(L_DEBUG, "RlcLiRguBndCfm: For RGU SAP state=%d", rguSap->state)
156 switch (rguSap->state)
158 case RLC_SAP_BINDING:
160 rlcStopTmr (tRlcCb,(PTR)rguSap, RLC_EVT_WAIT_BNDCFM);
162 rguSap->retryCnt = 0;
164 if (status == CM_BND_OK)
166 rguSap->state = RLC_SAP_BND;
167 event = LCM_EVENT_BND_OK;
168 cause = LKW_CAUSE_SAP_BNDENB;
172 rguSap->state = RLC_SAP_CFG;
173 event = LCM_EVENT_BND_FAIL;
174 cause = LKW_CAUSE_UNKNOWN;
180 event = LKW_EVENT_RGU_BND_CFM;
181 cause = LCM_CAUSE_INV_STATE;
185 /* Send an alarm with proper event and cause */
186 RLC_SEND_SAPID_ALARM(tRlcCb, suId, event, cause);
189 } /* RlcLiRguBndCfm */
194 * @brief Handler to process PDU received from MAC for common logical channels.
197 * This function receives the PDU from MAC for common logical channels
198 * does checks before handing over the PDU to the TM module
200 * @param[in] pst Post structure
201 * @param[in] suId Service User ID
202 * @param[in] datInd Data Indication Information
209 uint8_t rlcProcCommLcUlData(Pst *pst, SuId suId, RguCDatIndInfo *datInd)
216 #if (ERRCLASS & ERRCLS_INT_PAR)
217 if (pst->dstInst >= MAX_RLC_INSTANCES)
219 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguCDatIndInfo));
224 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
226 #if (ERRCLASS & ERRCLS_DEBUG)
227 if (tRlcCb->genCfg.rlcMode == LKW_RLC_MODE_DL)
229 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguCDatIndInfo));
234 /* kw006.201 ccpu00120058, Added array boundary condition check */
235 #if (ERRCLASS & ERRCLS_DEBUG)
236 if(RLC_MAX_LCH_PER_CELL <= datInd->lcId)
238 DU_LOG("\nRLC : rlcProcCommLcUlData : Invalid LcId [%d], Max is [%d]",\
239 datInd->lcId, RLC_MAX_LCH_PER_CELL);
240 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguCDatIndInfo));
243 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
245 /* Fetch RbCb from lcId */
246 rlcDbmFetchUlRbCbFromLchId(tRlcCb, datInd->rnti, datInd->cellId, datInd->lcId, &rbCb);
249 DU_LOG("\nRLC : rlcProcCommLcUlData : LcId [%d] not found",
251 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguCDatIndInfo));
255 /* Dispatch to TM Module */
257 rlcTmmRcvFrmMac(tRlcCb, rbCb, datInd->rnti, datInd->pdu);
259 rlcTmmRcvFrmMac(tRlcCb, rbCb, datInd->pdu);
260 #endif /* CCPU_OPT */
262 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguCDatIndInfo));
265 } /* rlcProcCommLcUlData */
268 * @brief Handler to process PDU received from MAC for
269 * dedicated logical channels.
272 * This function receives the PDU from MAC for one or more dedicated
273 * logical channels and passes it to the UTL module for further processing
275 * @param[in] pst Post structure
276 * @param[in] suId Service User ID
277 * @param[in] datInd Data Indication Information
285 uint8_t rlcProcDedLcUlData(Pst *pst, SuId suId, RguDDatIndInfo *datInd)
288 #if (ERRCLASS & ERRCLS_INT_PAR)
289 if (pst->dstInst >= MAX_RLC_INSTANCES)
291 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguDDatIndInfo));
296 #if (ERRCLASS & ERRCLS_DEBUG)
297 if (((RlcCb*)RLC_GET_RLCCB(pst->dstInst))->genCfg.rlcMode == LKW_RLC_MODE_DL)
299 DU_LOG("\nRLC : rlcProcDedLcUlData : suId(%d))recieved in DL Inst", suId);
300 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguDDatIndInfo));
304 rlcUtlRcvFrmMac(RLC_GET_RLCCB(pst->dstInst),datInd);
306 #ifdef SS_LOCKLESS_MEMORY
307 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguDDatIndInfo));
309 RLC_PST_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguDDatIndInfo));
314 } /* rlcProcDedLcUlData */
317 * @brief Handler for trigerring the data transfer from RLC to MAC
318 * for common logical channels.
321 * This function receives the size of the PDU to be transmitted
322 * and acts as a trigger for forming PDU and sending it to MAC.
324 * @param[in] pst Post structure
325 * @param[in] suId Service User ID
326 * @param[in] staInd Status Indication Information for Common Logical
334 uint8_t rlcProcCommLcSchedRpt(Pst *pst, SuId suId, RguCStaIndInfo *staInd)
339 #if (ERRCLASS & ERRCLS_INT_PAR)
340 if (pst->dstInst >= MAX_RLC_INSTANCES)
342 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguCStaIndInfo));
347 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
349 #if (ERRCLASS & ERRCLS_INT_PAR)
350 if ((suId >= tRlcCb->genCfg.maxRguSaps) || (suId < 0))
352 DU_LOG("\nRLC: rlcProcCommLcSchedRpt: Invalid RGU suId %d\n", suId);
355 if (tRlcCb->genCfg.rlcMode == LKW_RLC_MODE_UL)
357 DU_LOG("\nRLC: rlcProcCommLcSchedRpt: Received in RLC UL CELLID:%d",
359 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguCStaIndInfo));
366 /* kw006.201 ccpu00120058, added boundary condition check */
367 #if (ERRCLASS & ERRCLS_DEBUG)
368 if(RLC_MAX_LCH_PER_CELL < staInd->lcId)
370 DU_LOG("\nRLC: rlcProcCommLcSchedRpt: Invalid LcId, Max is [%d] CELLID:%d",
371 RLC_MAX_LCH_PER_CELL, staInd->cellId);
372 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguCStaIndInfo));
375 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
376 /* Fertch RbCb from lcId */
377 rlcDbmFetchDlRbCbFromLchId(tRlcCb,0, staInd->cellId, staInd->lcId, &rbCb);
380 DU_LOG("\nRLC: rlcProcCommLcSchedRpt: LcId [%d] not found CELLID:%d",
381 staInd->lcId, staInd->cellId);
382 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguCStaIndInfo));
386 /* Dispatch to TM Module */
387 rbCb->transId = staInd->transId;
388 rlcTmmSendToMac(tRlcCb, suId, rbCb, staInd);
390 #ifdef SS_LOCKLESS_MEMORY
391 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguCStaIndInfo));
393 RLC_PST_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguCStaIndInfo));
396 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguCStaIndInfo));
399 } /* rlcProcCommLcSchedRpt */
402 * @brief Handler for trigerring the data transfer from RLC to MAC
403 * for dedicated logical channels.
406 * This function receives the size of the PDUs to be transmitted to
407 * MAC via one or more dedicated logical channels and acts as a trigger
408 * for forming PDUs and sending them to MAC.
410 * @param[in] pst Post structure
411 * @param[in] suId Service User ID
412 * @param[in] staInd Status Indication Information for Dedicated Logical
420 uint8_t rlcProcDedLcSchedRpt(Pst *pst, SuId suId, RguDStaIndInfo *staInd)
424 #if (ERRCLASS & ERRCLS_INT_PAR)
425 if (pst->dstInst >= MAX_RLC_INSTANCES)
427 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguDStaIndInfo));
432 gCb = RLC_GET_RLCCB(pst->dstInst);
434 #if (ERRCLASS & ERRCLS_INT_PAR)
435 if (((RlcCb*)RLC_GET_RLCCB(pst->dstInst))->genCfg.rlcMode == LKW_RLC_MODE_UL)
437 DU_LOG("\nRLC: rlcProcDedLcSchedRpt: Received in RLC UL ");
438 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguDStaIndInfo));
441 if ((suId >= gCb->genCfg.maxRguSaps) || (suId < 0))
443 DU_LOG("\nRLC: rlcProcDedLcSchedRpt: Invalid RGU suId %d\n", suId);
447 rlcUtlSendToMac(gCb, suId, staInd);
449 /* kw002.201 :Freeing from proper region */
450 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguDStaIndInfo));
452 } /* rlcProcDedLcSchedRpt */
455 * @brief Handler for handling the flow cntrl Ind from MAC
459 * This function receives the flow control indication from
460 * MAC and calls rlcUtlTrigPdbFlowCntrl
462 * @param[in] pst Post structure
463 * @param[in] suId Service User ID
464 * @param[in] flowCntrlInd flow control Indication Information
473 S16 RlcLiRguFlowCntrlInd
477 RguFlowCntrlInd *flowCntrlInd
480 S16 RlcLiRguFlowCntrlInd(pst, suId, flowCntrlInd)
483 RguFlowCntrlInd *flowCntrlInd;
487 RlcDlRbCb *rbCb = NULLP;
491 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
492 for (idx = 0; idx < flowCntrlInd->numUes; idx++)
494 for (lcIdx = 0; lcIdx < flowCntrlInd->ueFlowCntrlInfo[idx].numLcs; lcIdx++)
496 RguLcFlowCntrlInfo *lcInfo = &(flowCntrlInd->ueFlowCntrlInfo[idx].lcInfo[lcIdx]);
497 rlcDbmFetchDlRbCbFromLchId(tRlcCb, flowCntrlInd->ueFlowCntrlInfo[idx].ueId, flowCntrlInd->cellId, lcInfo->lcId, &rbCb);
501 if (lcInfo->pktAdmitCnt == 0) /* Special case */
503 rlcUtlTrigPdbFlowCntrl(tRlcCb, rbCb, lcInfo->pktAdmitCnt);
506 if (rbCb->mode == CM_LTE_MODE_AM)
508 if ((rbCb->m.amDl.retxLst.count != 0) ||
509 ((rbCb->m.amDl.bo == 0) ||
510 (rbCb->m.amDl.bo < lcInfo->maxBo4FlowCtrl)))
517 if ((rbCb->m.umDl.bo == 0) ||
518 (rbCb->m.umDl.bo < lcInfo->maxBo4FlowCtrl))
523 rlcUtlTrigPdbFlowCntrl(tRlcCb, rbCb, lcInfo->pktAdmitCnt);
529 /* kw005.201 added support for L2 Measurement */
536 * Handler for indicating the Harq Status of the data sent.
540 * This function receives the harq status of the data sent to MAC.
541 * This information is used for two things.
542 * 1. Computing the UuLoss of UM
543 * 2. Computing the DL Delay for UM and AM.
545 * @param[in] pst - Post structure
546 * @param[in] suId - Service User ID
547 * @param[in] staInd - Harq Status Indication Information.
559 RguHarqStatusInd *staInd
562 S16 RlcLiRguHqStaInd(pst,suId,staInd)
565 RguHarqStatusInd *staInd;
575 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
576 ueKey.cellId = staInd->cellId;
577 ueKey.ueId = staInd->ueId;
579 ret = rlcDbmFetchDlUeCb(tRlcCb, ueKey.ueId, ueKey.cellId, &ueCb);
585 /*Call rlcUtlProcHarqInd as many times as number of Tbs present*/
586 for ( tbIdx = 0; tbIdx < staInd->numTbs; tbIdx++)
588 rlcUtlProcHarqInd(tRlcCb, staInd, ueCb, tbIdx);
592 } /* RlcLiRguHqStaInd */
593 #endif /* LTE_L2_MEAS */
597 #endif /* __cplusplus */
599 /********************************************************************30**
601 **********************************************************************/