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
102 S16 RlcLiRguBndCfm(Pst *pst,SuId suId,uint8_t status)
104 uint16_t event; /* Event */
105 uint16_t cause; /* Cause */
106 RlcRguSapCb *rguSap; /* RGU SAP Control Block */
109 #if (ERRCLASS & ERRCLS_INT_PAR)
110 if (pst->dstInst >= MAX_RLC_INSTANCES)
115 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
117 RLOG2(L_DEBUG,"RlcLiRguBndCfm(suId(%d), status(%d)", suId, status);
119 #if (ERRCLASS & ERRCLS_INT_PAR)
120 if (tRlcCb->init.cfgDone != TRUE)
122 RLOG0(L_FATAL,"General configuration not done");
124 RLC_SEND_SAPID_ALARM(tRlcCb,suId,LKW_EVENT_LI_BND_CFM, LCM_CAUSE_INV_STATE);
129 if ((suId >= tRlcCb->genCfg.maxRguSaps) || (suId < 0))
131 RLOG0(L_ERROR, "Invalid suId");
133 RLC_SEND_SAPID_ALARM(tRlcCb,suId, LKW_EVENT_LI_BND_CFM, LCM_CAUSE_INV_SUID);
137 #endif /* ERRCLASS & ERRCLS_INT_PAR */
139 rguSap = (tRlcCb->genCfg.rlcMode == LKW_RLC_MODE_DL) ?
140 &(tRlcCb->u.dlCb->rguDlSap[suId]) : &(tRlcCb->u.ulCb->rguUlSap[suId]);
142 RLOG1(L_DEBUG, "RlcLiRguBndCfm: For RGU SAP state=%d", rguSap->state)
144 switch (rguSap->state)
146 case RLC_SAP_BINDING:
148 rlcStopTmr (tRlcCb,(PTR)rguSap, RLC_EVT_WAIT_BNDCFM);
150 rguSap->retryCnt = 0;
152 if (status == CM_BND_OK)
154 rguSap->state = RLC_SAP_BND;
155 event = LCM_EVENT_BND_OK;
156 cause = LKW_CAUSE_SAP_BNDENB;
160 rguSap->state = RLC_SAP_CFG;
161 event = LCM_EVENT_BND_FAIL;
162 cause = LKW_CAUSE_UNKNOWN;
168 event = LKW_EVENT_RGU_BND_CFM;
169 cause = LCM_CAUSE_INV_STATE;
173 /* Send an alarm with proper event and cause */
174 RLC_SEND_SAPID_ALARM(tRlcCb, suId, event, cause);
177 } /* RlcLiRguBndCfm */
182 * @brief Handler to process PDU received from MAC for common logical channels.
185 * This function receives the PDU from MAC for common logical channels
186 * does checks before handing over the PDU to the TM module
188 * @param[in] pst Post structure
189 * @param[in] suId Service User ID
190 * @param[in] datInd Data Indication Information
197 uint8_t rlcProcCommLcUlData(Pst *pst, SuId suId, RguCDatIndInfo *datInd)
204 #if (ERRCLASS & ERRCLS_INT_PAR)
205 if (pst->dstInst >= MAX_RLC_INSTANCES)
207 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguCDatIndInfo));
212 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
214 #if (ERRCLASS & ERRCLS_DEBUG)
215 if (tRlcCb->genCfg.rlcMode == LKW_RLC_MODE_DL)
217 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguCDatIndInfo));
222 /* kw006.201 ccpu00120058, Added array boundary condition check */
223 #if (ERRCLASS & ERRCLS_DEBUG)
224 if(RLC_MAX_LCH_PER_CELL <= datInd->lcId)
226 DU_LOG("\nRLC : rlcProcCommLcUlData : Invalid LcId [%d], Max is [%d]",\
227 datInd->lcId, RLC_MAX_LCH_PER_CELL);
228 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguCDatIndInfo));
231 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
233 /* Fetch RbCb from lcId */
234 rlcDbmFetchUlRbCbFromLchId(tRlcCb, datInd->rnti, datInd->cellId, datInd->lcId, &rbCb);
237 DU_LOG("\nRLC : rlcProcCommLcUlData : LcId [%d] not found",
239 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguCDatIndInfo));
243 /* Dispatch to TM Module */
245 rlcTmmRcvFrmMac(tRlcCb, rbCb, datInd->rnti, datInd->pdu);
247 rlcTmmRcvFrmMac(tRlcCb, rbCb, datInd->pdu);
248 #endif /* CCPU_OPT */
250 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguCDatIndInfo));
253 } /* rlcProcCommLcUlData */
256 * @brief Handler to process PDU received from MAC for
257 * dedicated logical channels.
260 * This function receives the PDU from MAC for one or more dedicated
261 * logical channels and passes it to the UTL module for further processing
263 * @param[in] pst Post structure
264 * @param[in] suId Service User ID
265 * @param[in] datInd Data Indication Information
273 uint8_t rlcProcDedLcUlData(Pst *pst, SuId suId, RguDDatIndInfo *datInd)
276 #if (ERRCLASS & ERRCLS_INT_PAR)
277 if (pst->dstInst >= MAX_RLC_INSTANCES)
279 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguDDatIndInfo));
284 #if (ERRCLASS & ERRCLS_DEBUG)
285 if (((RlcCb*)RLC_GET_RLCCB(pst->dstInst))->genCfg.rlcMode == LKW_RLC_MODE_DL)
287 DU_LOG("\nRLC : rlcProcDedLcUlData : suId(%d))recieved in DL Inst", suId);
288 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguDDatIndInfo));
292 rlcUtlRcvFrmMac(RLC_GET_RLCCB(pst->dstInst),datInd);
294 #ifdef SS_LOCKLESS_MEMORY
295 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguDDatIndInfo));
297 RLC_PST_FREE(RLC_MEM_REGION_UL, RLC_POOL, datInd, sizeof(RguDDatIndInfo));
302 } /* rlcProcDedLcUlData */
305 * @brief Handler for trigerring the data transfer from RLC to MAC
306 * for common logical channels.
309 * This function receives the size of the PDU to be transmitted
310 * and acts as a trigger for forming PDU and sending it to MAC.
312 * @param[in] pst Post structure
313 * @param[in] suId Service User ID
314 * @param[in] staInd Status Indication Information for Common Logical
322 uint8_t rlcProcCommLcSchedRpt(Pst *pst, SuId suId, RguCStaIndInfo *staInd)
327 #if (ERRCLASS & ERRCLS_INT_PAR)
328 if (pst->dstInst >= MAX_RLC_INSTANCES)
330 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguCStaIndInfo));
335 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
337 #if (ERRCLASS & ERRCLS_INT_PAR)
338 if ((suId >= tRlcCb->genCfg.maxRguSaps) || (suId < 0))
340 DU_LOG("\nRLC: rlcProcCommLcSchedRpt: Invalid RGU suId %d\n", suId);
343 if (tRlcCb->genCfg.rlcMode == LKW_RLC_MODE_UL)
345 DU_LOG("\nRLC: rlcProcCommLcSchedRpt: Received in RLC UL CELLID:%d",
347 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguCStaIndInfo));
354 /* kw006.201 ccpu00120058, added boundary condition check */
355 #if (ERRCLASS & ERRCLS_DEBUG)
356 if(RLC_MAX_LCH_PER_CELL < staInd->lcId)
358 DU_LOG("\nRLC: rlcProcCommLcSchedRpt: Invalid LcId, Max is [%d] CELLID:%d",
359 RLC_MAX_LCH_PER_CELL, staInd->cellId);
360 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguCStaIndInfo));
363 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
364 /* Fertch RbCb from lcId */
365 rlcDbmFetchDlRbCbFromLchId(tRlcCb,0, staInd->cellId, staInd->lcId, &rbCb);
368 DU_LOG("\nRLC: rlcProcCommLcSchedRpt: LcId [%d] not found CELLID:%d",
369 staInd->lcId, staInd->cellId);
370 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguCStaIndInfo));
374 /* Dispatch to TM Module */
375 rbCb->transId = staInd->transId;
376 rlcTmmSendToMac(tRlcCb, suId, rbCb, staInd);
378 #ifdef SS_LOCKLESS_MEMORY
379 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguCStaIndInfo));
381 RLC_PST_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguCStaIndInfo));
384 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguCStaIndInfo));
387 } /* rlcProcCommLcSchedRpt */
390 * @brief Handler for trigerring the data transfer from RLC to MAC
391 * for dedicated logical channels.
394 * This function receives the size of the PDUs to be transmitted to
395 * MAC via one or more dedicated logical channels and acts as a trigger
396 * for forming PDUs and sending them to MAC.
398 * @param[in] pst Post structure
399 * @param[in] suId Service User ID
400 * @param[in] staInd Status Indication Information for Dedicated Logical
408 uint8_t rlcProcDedLcSchedRpt(Pst *pst, SuId suId, RguDStaIndInfo *staInd)
412 #if (ERRCLASS & ERRCLS_INT_PAR)
413 if (pst->dstInst >= MAX_RLC_INSTANCES)
415 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguDStaIndInfo));
420 gCb = RLC_GET_RLCCB(pst->dstInst);
422 #if (ERRCLASS & ERRCLS_INT_PAR)
423 if (((RlcCb*)RLC_GET_RLCCB(pst->dstInst))->genCfg.rlcMode == LKW_RLC_MODE_UL)
425 DU_LOG("\nRLC: rlcProcDedLcSchedRpt: Received in RLC UL ");
426 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguDStaIndInfo));
429 if ((suId >= gCb->genCfg.maxRguSaps) || (suId < 0))
431 DU_LOG("\nRLC: rlcProcDedLcSchedRpt: Invalid RGU suId %d\n", suId);
435 rlcUtlSendToMac(gCb, suId, staInd);
437 /* kw002.201 :Freeing from proper region */
438 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, staInd, sizeof(RguDStaIndInfo));
440 } /* rlcProcDedLcSchedRpt */
443 * @brief Handler for handling the flow cntrl Ind from MAC
447 * This function receives the flow control indication from
448 * MAC and calls rlcUtlTrigPdbFlowCntrl
450 * @param[in] pst Post structure
451 * @param[in] suId Service User ID
452 * @param[in] flowCntrlInd flow control Indication Information
460 S16 RlcLiRguFlowCntrlInd(Pst *pst,SuId suId,RguFlowCntrlInd *flowCntrlInd)
463 RlcDlRbCb *rbCb = NULLP;
467 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
468 for (idx = 0; idx < flowCntrlInd->numUes; idx++)
470 for (lcIdx = 0; lcIdx < flowCntrlInd->ueFlowCntrlInfo[idx].numLcs; lcIdx++)
472 RguLcFlowCntrlInfo *lcInfo = &(flowCntrlInd->ueFlowCntrlInfo[idx].lcInfo[lcIdx]);
473 rlcDbmFetchDlRbCbFromLchId(tRlcCb, flowCntrlInd->ueFlowCntrlInfo[idx].ueId, flowCntrlInd->cellId, lcInfo->lcId, &rbCb);
477 if (lcInfo->pktAdmitCnt == 0) /* Special case */
479 rlcUtlTrigPdbFlowCntrl(tRlcCb, rbCb, lcInfo->pktAdmitCnt);
482 if (rbCb->mode == CM_LTE_MODE_AM)
484 if ((rbCb->m.amDl.retxLst.count != 0) ||
485 ((rbCb->m.amDl.bo == 0) ||
486 (rbCb->m.amDl.bo < lcInfo->maxBo4FlowCtrl)))
493 if ((rbCb->m.umDl.bo == 0) ||
494 (rbCb->m.umDl.bo < lcInfo->maxBo4FlowCtrl))
499 rlcUtlTrigPdbFlowCntrl(tRlcCb, rbCb, lcInfo->pktAdmitCnt);
505 /* kw005.201 added support for L2 Measurement */
512 * Handler for indicating the Harq Status of the data sent.
516 * This function receives the harq status of the data sent to MAC.
517 * This information is used for two things.
518 * 1. Computing the UuLoss of UM
519 * 2. Computing the DL Delay for UM and AM.
521 * @param[in] pst - Post structure
522 * @param[in] suId - Service User ID
523 * @param[in] staInd - Harq Status Indication Information.
530 S16 RlcLiRguHqStaInd(Pst *pst, SuId suId,RguHarqStatusInd *staInd)
539 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
540 ueKey.cellId = staInd->cellId;
541 ueKey.ueId = staInd->ueId;
543 ret = rlcDbmFetchDlUeCb(tRlcCb, ueKey.ueId, ueKey.cellId, &ueCb);
549 /*Call rlcUtlProcHarqInd as many times as number of Tbs present*/
550 for ( tbIdx = 0; tbIdx < staInd->numTbs; tbIdx++)
552 rlcUtlProcHarqInd(tRlcCb, staInd, ueCb, tbIdx);
556 } /* RlcLiRguHqStaInd */
557 #endif /* LTE_L2_MEAS */
561 #endif /* __cplusplus */
563 /********************************************************************30**
565 **********************************************************************/