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: Defines required by LTE MAC
29 **********************************************************************/
31 /* header include files (.h) */
32 #include "common_def.h"
33 #include "lkw.h" /* LKW defines */
34 #include "ckw.h" /* CKW defines */
35 #include "kwu.h" /* KWU defines */
36 #include "rgu.h" /* RGU defines */
37 #include "kw_err.h" /* Err defines */
38 #include "kw_env.h" /* RLC environment options */
40 #include "kw.h" /* RLC defines */
44 /* extern (.x) include files */
45 #include "lkw.x" /* LKW */
46 #include "ckw.x" /* CKW */
47 #include "kwu.x" /* KWU */
48 #include "rgu.x" /* RGU */
55 #define RLC_MODULE RLC_DBGMASK_UDX
58 S16 rlcDlmHndlStaRsp ARGS (( RlcCb *gCb,RlcDlRbCb *rbCb,
59 RlcUdxStaPdu *pStaPdu, RlcUdxBufLst *rlsPduLst));
72 * Handler to bind the DL with UL.
74 * @param[in] pst Post structure
75 * @param[in] suId Service user SAP ID
76 * @param[in] spId Service provider ID
89 RlcUdxDlSapCb *udxSap; /* pointer to session SAP */
92 #if (ERRCLASS & ERRCLS_INT_PAR)
93 if (pst->dstInst >= MAX_RLC_INSTANCES)
98 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
100 RLCDBGP_BRIEF(tRlcCb, "rlcDlUdxBndReq(spId(%d), suId(%d))\n",
103 udxSap = (tRlcCb->u.dlCb->udxDlSap + spId);
105 /* Verify CKW SAP State */
106 switch(udxSap->state)
108 /* SAP is configured but not bound */
112 /* copy bind configuration parameters in SSAP sap */
114 udxSap->pst.dstProcId = pst->srcProcId;
115 udxSap->pst.dstEnt = pst->srcEnt;
116 udxSap->pst.dstInst = pst->srcInst;
118 /* Update the State */
119 udxSap->state = RLC_SAP_BND;
121 DU_LOG("\nINFO --> RLC_DL : UDX SAP state [%d]", udxSap->state);
124 /* SAP is already bound */
128 * Sap is already bound check source, destination Entity and
131 if (udxSap->pst.dstProcId != pst->srcProcId
132 || udxSap->pst.dstEnt != pst->srcEnt
133 || udxSap->pst.dstInst != pst->srcInst
134 || udxSap->suId != suId)
136 RLC_SEND_SAPID_ALARM(tRlcCb, spId,
137 LKW_EVENT_UDX_BND_REQ, LCM_CAUSE_INV_PAR_VAL);
139 DU_LOG("\nERROR --> RLC_DL : UDX SAP already Bound");
140 rlcDlUdxBndCfm(&(udxSap->pst), udxSap->suId, CM_BND_NOK);
147 #if (ERRCLASS & ERRCLS_INT_PAR)
148 RLC_SEND_SAPID_ALARM(tRlcCb,spId,
149 LKW_EVENT_CKW_BND_REQ, LCM_CAUSE_INV_STATE);
150 #endif /* ERRCLASS & ERRCLS_INT_PAR */
151 DU_LOG("\nERROR --> RLC_DL : Invalid UDX SAP State in Bind Req");
152 rlcDlUdxBndCfm(&(udxSap->pst), udxSap->suId, CM_BND_NOK);
156 rlcDlUdxBndCfm(&(udxSap->pst), udxSap->suId, CM_BND_OK);
163 * Handler for unbinding the DL from UL.
165 * @param[in] pst Post structure
166 * @param[in] spId Service provider SAP ID
167 * @param[in] reason Reason for Unbinding
179 RlcUdxDlSapCb *udxSap;
182 #if (ERRCLASS & ERRCLS_INT_PAR)
183 if (pst->dstInst >= MAX_RLC_INSTANCES)
189 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
191 DU_LOG("\nDEBUG --> RLC_DL : Unbind Req for spId[%d], reason[%d]",
194 /* disable upper sap (CKW) */
195 udxSap = (tRlcCb->u.dlCb->udxDlSap + spId);
197 #if (ERRCLASS & ERRCLS_INT_PAR)
198 RLC_GET_AND_VALIDATE_UDXSAP(tRlcCb,udxSap, EKW208, "KwUiDlUdxndReq");
199 #endif /* ERRCLASS & ERRCLS_INT_PAR */
200 udxSap->state = RLC_SAP_CFG;
207 * Handler for configuring RLC entities.
210 * This function is used by RRC to configure(add/delete/modify)
211 * one or more RLC entities.
212 * - CKW_CFG_ADD => rlcCfgAddRb
213 * - CKW_CFG_MODIFY => rlcCfgReCfgRb
214 * - CKW_CFG_DELETE => rlcCfgDelRb
215 * - CKW_CFG_REESTABLISH => rlcCfgReEstRb
216 * - CKW_CFG_DELETE_UE => rlcCfgDelUe
218 * @param[in] pst - Post structure
219 * @param[in] spId - Serive Provider ID
220 * @param[in] cfg - Configuration information for one or more RLC entities.
233 RlcCfgCfmInfo *cfgCfm;
238 #if (ERRCLASS & ERRCLS_INT_PAR)
239 if (pst->dstInst >= MAX_RLC_INSTANCES)
245 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
247 pstUdxCfm = &(tRlcCb->u.dlCb->udxDlSap[spId].pst);
248 RLCDBGP_BRIEF(tRlcCb,"spId(%d)\n", spId);
249 /* Allocate memory and memset to 0 for cfmInfo */
250 RLC_ALLOC_SHRABL_BUF_WC(pstUdxCfm->region,
253 sizeof(RlcCfgCfmInfo));
255 #if (ERRCLASS & ERRCLS_ADD_RES)
258 DU_LOG("\nERROR --> RLC_DL : Memory Allocation Failed.");
259 /* kw002.201 Freeing from proper region */
260 /* RLC_PST_FREE(pst->region, pst->pool, cfg, sizeof(RlcCfgInfo)); */
263 #endif /* ERRCLASS & ERRCLS_ADD_RES */
265 /* For every entity configuration process by cfgType */
266 for (idx = 0; idx < cfg->numEnt; idx++)
268 RlcEntCfgCfmInfo *entCfgCfm;
269 RlcEntCfgInfo *entCfg;
271 entCfg = (RlcEntCfgInfo *)&(cfg->entCfg[idx]);
272 entCfgCfm = (RlcEntCfgCfmInfo *)&(cfgCfm->entCfgCfm[idx]);
274 switch (entCfg->cfgType)
278 if (entCfg->dir & RLC_DIR_DL)
280 /* Add a new RB entity configuration */
281 if (rlcCfgAddDlRb(tRlcCb,cfg->ueId, cfg->cellId,\
282 entCfg, entCfgCfm) != ROK)
284 DU_LOG("\nERROR --> RLC_DL : Addition Failed due to[%d]",
285 entCfgCfm->status.reason);
292 if (entCfg->dir & RLC_DIR_DL)
294 /* Re-configure the existing RB entity configuration */
295 if (rlcCfgReCfgDlRb(tRlcCb,cfg->ueId, cfg->cellId,\
296 entCfg, entCfgCfm) != ROK)
298 DU_LOG("\nERROR --> RLC_DL : ReCfg Failed due to[%d]",
299 entCfgCfm->status.reason);
307 if (entCfg->dir & RLC_DIR_DL)
309 /* Delete the existing RB entity configuration */
310 if (rlcCfgDelDlRb(tRlcCb,cfg->ueId, cfg->cellId,\
311 entCfg, entCfgCfm) != ROK)
313 DU_LOG("\nERROR --> RLC_DL : Deletion Failed due to[%d]",
314 entCfgCfm->status.reason);
320 case CKW_CFG_REESTABLISH:
322 if (entCfg->dir & RLC_DIR_DL)
324 /*if direction is both then, re-establishment end indication
325 * should be sent only from the UL instance, only if DIR is
326 * DL only then DL instance will send indication.*/
327 Bool sndReEst = TRUE;
328 if (entCfg->dir & RLC_DIR_UL)
332 /* Re-establish the existing RB entity configuration */
333 if (rlcCfgReEstDlRb(tRlcCb,cfg->ueId, cfg->cellId,
334 sndReEst,entCfg, entCfgCfm) != ROK)
336 DU_LOG("\nERROR --> RLC_DL : Reest Failed due to[%d]",
337 entCfgCfm->status.reason);
343 case CKW_CFG_DELETE_UE:
345 /* Delete all RB entity configuration under UE */
346 if (rlcCfgDelDlUe(tRlcCb,cfg->ueId, cfg->cellId,
347 entCfg, entCfgCfm) != ROK)
349 DU_LOG("\nERROR --> RLC_DL : deletion Failed due to[%d]",
350 entCfgCfm->status.reason);
354 DU_LOG("\nDEBUG --> RLC_DL: UE information is deleted for UEIdx[%d] and CellId[%d]",\
355 cfg->ueId, cfg->cellId);
359 case CKW_CFG_DELETE_CELL:
361 if (rlcCfgDelDlCell(tRlcCb,cfg->cellId,entCfg,entCfgCfm)
364 DU_LOG("\nERROR --> RLC_DL : deletion Failed due to[%d]",
365 entCfgCfm->status.reason);
372 RLC_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType,\
373 CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_CFG);
374 DU_LOG("\nERROR --> RLC_DL : Invalid CfgType");
379 /* Assign number of entity configuraitons and suId */
380 cfgCfm->transId = cfg->transId;
381 cfgCfm->ueId = cfg->ueId;
382 cfgCfm->cellId = cfg->cellId;
383 cfgCfm->numEnt = cfg->numEnt;
385 /* kw002.201 Freeing from proper region */
386 /* RLC_PST_FREE(pst->region, pst->pool, cfg, sizeof(RlcCfgInfo)); */
387 /* Send Configuration confirm primitive */
388 rlcDlUdxCfgCfm(&(tRlcCb->u.dlCb->udxDlSap[spId].pst),
389 tRlcCb->u.dlCb->udxDlSap[spId].suId,
397 * This primitive is used by RRC to change the UeId for the existing UE
400 * @param pst - Pointer to the pst structure
401 * @param spId - The ID of the service provider SAP in the RLC layer
402 * @param transId - Transaction ID. This field uniquily identifies
403 * transaction between RRC and RLC
404 * @param ueInfo - Old UE Id Info for which the change request has come
405 * @param newUeInfo - New UE Id Info for existing UE context
411 S16 rlcDlUdxUeIdChgReq
423 #if (ERRCLASS & ERRCLS_INT_PAR)
424 if (pst->dstInst >= MAX_RLC_INSTANCES)
430 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
432 RLCDBGP_BRIEF(tRlcCb, "(spId(%d), transId(%ld))\n",
435 RLCDBGP_BRIEF(tRlcCb, "(spId(%d), transId(%d))\n",
439 status.reason = CKW_CFG_REAS_NONE;
440 status.status = CKW_CFG_CFM_OK;
442 if (rlcCfgDlUeIdChng(tRlcCb, ueInfo, newUeInfo, &status) != ROK)
444 DU_LOG("\nERROR --> RLC_DL : Failure due to[%d]",
447 rlcDlUdxUeIdChgCfm(&(tRlcCb->u.dlCb->udxDlSap[spId].pst),
448 tRlcCb->u.dlCb->udxDlSap[spId].suId,
457 * Request for status PDU from ULM to DLM.
459 * @param[in] pst - Post Structure
460 * @param[in] spId - Service Provider Id
461 * @param[in] rlcId - Rlc Information Id
462 * @param[in] pStaPdu - Status PDU
468 S16 rlcDlUdxStaPduReq
473 RlcUdxDlStaPdu *pStaPdu
479 tRlcCb = RLC_GET_RLCCB (pst->dstInst);
481 rlcDbmFetchDlRbCbByRbId(tRlcCb, rlcId, &rbCb); /* Fetch DBM RbCb */
484 DU_LOG("\nERROR --> RLC_DL : CellId [%u]:RbId[%d] not found",
485 rlcId->cellId,rlcId->rbId);
486 RLC_FREE_SHRABL_BUF(pst->region,
489 sizeof(RlcUdxDlStaPdu));
493 RLC_AMDL.cntrlBo = pStaPdu->controlBo;
494 /* If there already exists a STAUS PDU, free it and take the new one
498 RLC_FREE_SHRABL_BUF(pst->region,
501 sizeof(RlcUdxDlStaPdu));
504 RLC_AMDL.pStaPdu = pStaPdu;
505 rlcAmmSendDedLcBoStatus(tRlcCb, rbCb, &RLC_AMDL);
512 * It handles the status update recieved from ULM.
514 * @param[in] pst - Post Structure
515 * @param[in] spId - Service Provider Id
516 * @param[in] rlcId - Rlc Information Id
517 * @param[in] pStaPdu - Status PDU
523 S16 rlcDlUdxStaUpdReq
528 RlcUdxStaPdu *pStaPdu
534 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
536 rlcDbmFetchDlRbCbByRbId(tRlcCb, rlcId, &rbCb);
539 DU_LOG("\nERROR --> RLC_DL : CellId [%u]:RbId[%d] not found",
540 rlcId->cellId,rlcId->rbId);
544 rlcAmmDlHndlStatusPdu(tRlcCb, rbCb, pStaPdu);
546 RLC_FREE_SHRABL_BUF(pst->region,
549 sizeof(RlcUdxStaPdu));
557 S16 rlcDlUdxL2MeasReq
560 RlcL2MeasReqEvt *measReqEvt
565 volatile uint32_t startTime = 0;
569 SStartTask(&startTime, PID_RLC_MEAS_START);
571 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
573 /* Initialize measCfmEvt */
575 /* validate the received measReqEvt */
576 /*LTE_L2_MEAS_PHASE2*/
578 measType = measReqEvt->measReq.measType;
580 if(measType & LKW_L2MEAS_DL_IP)
582 /* if measurement is for DL IP enable for all QCI */
583 for(cntr = 0; cntr < LKW_MAX_QCI; cntr++)
585 tRlcCb->u.dlCb->rlcL2Cb.measOn[cntr] |= LKW_L2MEAS_DL_IP;
590 /* for nonIpThroughput meas, enable only for the sent QCIs */
592 for(i = 0; i < LKW_MAX_QCI; i++)
594 tRlcCb->u.dlCb->rlcL2Cb.measOn[i] |= measType;
598 /* We need to copy the transId for sending back confirms later */
599 for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
601 RlcL2MeasEvtCb* measEvtCb = &(tRlcCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr]);
602 if(measEvtCb->measCb.measType & measType)
604 measEvtCb->transId= measReqEvt->transId;
609 SStopTask(startTime, PID_RLC_MEAS_START);
611 } /* rlcDlUdxMeasReq */
615 This function processes L2 Measurement stop request received from the layer manager.
616 After receving this request, RLC stops L2 Measurement
617 * @param[in] pst post structure
618 * @param[in] measType meas Type
621 * -# Failure : RFAILED
624 S16 rlcDlUdxL2MeasStopReq
631 RlcL2MeasEvtCb *measEvtCb = NULLP;
633 uint8_t status = ROK;
634 /* RlcL2MeasCfmEvt measCfmEvt; */
635 volatile uint32_t startTime = 0;
639 SStartTask(&startTime, PID_RLC_MEAS_STOP);
641 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
642 /* memset(&measCfmEvt, 0, sizeof(RlcL2MeasCfmEvt)); */
643 /* reset the counters for the measurement type passed */
644 for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
646 measEvtCb = &(tRlcCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr]);
647 if(measEvtCb->measCb.measType & measType)
649 rlcUtlResetDlL2MeasInRlcRb(tRlcCb, &measEvtCb->measCb, measType);
654 /* switch off the measurements for the type passed */
655 for(cntr = 0; cntr < LKW_MAX_QCI; cntr++)
657 tRlcCb->u.dlCb->rlcL2Cb.measOn[cntr] &= ~measType;
660 status = LCM_PRIM_OK;
661 /* Stop confirm is removed as UL thread is already sending it */
664 SStopTask(startTime, PID_RLC_MEAS_STOP);
670 This function processes L2 Measurement Send request received from the layer manager.
671 After receving this request, RLC sends L2 Measurement
672 * @param[in] pst post structure
673 * @param[in] measType meas Type
676 * -# Failure : RFAILED
679 S16 rlcDlUdxL2MeasSendReq
685 RlcL2MeasEvtCb *measEvtCb;
687 volatile uint32_t startTime = 0;
690 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
691 for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
693 measEvtCb = &(tRlcCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr]);
694 if(measEvtCb->measCb.measType & measType)
697 SStartTask(&startTime, PID_RLC_MEAS_REPORT);
699 rlcUtlSndDlL2MeasCfm(tRlcCb, measEvtCb);
702 SStopTask(startTime, PID_RLC_MEAS_REPORT);
708 #endif /* LTE_L2_MEAS */
712 #endif /* __cplusplus */
715 /**********************************************************************
717 **********************************************************************/