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 **********************************************************************/
30 static const char* RLOG_MODULE_NAME="UDX";
31 static int RLOG_MODULE_ID=262144;
32 static int RLOG_FILE_ID=203;
34 /* header include files (.h) */
35 #include "common_def.h"
36 #include "lkw.h" /* LKW defines */
37 #include "ckw.h" /* CKW defines */
38 #include "kwu.h" /* KWU defines */
39 #include "rgu.h" /* RGU defines */
40 #include "kw_err.h" /* Err defines */
41 #include "kw_env.h" /* RLC environment options */
43 #include "kw.h" /* RLC defines */
47 /* extern (.x) include files */
48 #include "lkw.x" /* LKW */
49 #include "ckw.x" /* CKW */
50 #include "kwu.x" /* KWU */
51 #include "rgu.x" /* RGU */
58 #define RLC_MODULE RLC_DBGMASK_UDX
61 EXTERN S16 rlcDlmHndlStaRsp ARGS (( RlcCb *gCb,RlcDlRbCb *rbCb,
62 RlcUdxStaPdu *pStaPdu, RlcUdxBufLst *rlsPduLst));
75 * Handler to bind the DL with UL.
77 * @param[in] pst Post structure
78 * @param[in] suId Service user SAP ID
79 * @param[in] spId Service provider ID
93 S16 rlcDlUdxBndReq (pst, suId, spId)
99 RlcUdxDlSapCb *udxSap; /* pointer to session SAP */
102 #if (ERRCLASS & ERRCLS_INT_PAR)
103 if (pst->dstInst >= MAX_RLC_INSTANCES)
108 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
110 RLCDBGP_BRIEF(tRlcCb, "rlcDlUdxBndReq(spId(%d), suId(%d))\n",
113 udxSap = (tRlcCb->u.dlCb->udxDlSap + spId);
115 /* Verify CKW SAP State */
116 switch(udxSap->state)
118 /* SAP is configured but not bound */
122 /* copy bind configuration parameters in SSAP sap */
124 udxSap->pst.dstProcId = pst->srcProcId;
125 udxSap->pst.dstEnt = pst->srcEnt;
126 udxSap->pst.dstInst = pst->srcInst;
128 /* Update the State */
129 udxSap->state = RLC_SAP_BND;
131 RLOG1(L_INFO, "UDX SAP state [%d]", udxSap->state);
134 /* SAP is already bound */
138 * Sap is already bound check source, destination Entity and
141 if (udxSap->pst.dstProcId != pst->srcProcId
142 || udxSap->pst.dstEnt != pst->srcEnt
143 || udxSap->pst.dstInst != pst->srcInst
144 || udxSap->suId != suId)
146 RLC_SEND_SAPID_ALARM(tRlcCb, spId,
147 LKW_EVENT_UDX_BND_REQ, LCM_CAUSE_INV_PAR_VAL);
149 RLOG0(L_ERROR, "UDX SAP already Bound");
150 rlcDlUdxBndCfm(&(udxSap->pst), udxSap->suId, CM_BND_NOK);
157 #if (ERRCLASS & ERRCLS_INT_PAR)
158 RLC_SEND_SAPID_ALARM(tRlcCb,spId,
159 LKW_EVENT_CKW_BND_REQ, LCM_CAUSE_INV_STATE);
160 #endif /* ERRCLASS & ERRCLS_INT_PAR */
161 RLOG0(L_ERROR, "Invalid UDX SAP State in Bind Req");
162 rlcDlUdxBndCfm(&(udxSap->pst), udxSap->suId, CM_BND_NOK);
166 rlcDlUdxBndCfm(&(udxSap->pst), udxSap->suId, CM_BND_OK);
173 * Handler for unbinding the DL from UL.
175 * @param[in] pst Post structure
176 * @param[in] spId Service provider SAP ID
177 * @param[in] reason Reason for Unbinding
190 S16 rlcDlUdxUbndReq(pst, spId, reason)
196 RlcUdxDlSapCb *udxSap;
199 #if (ERRCLASS & ERRCLS_INT_PAR)
200 if (pst->dstInst >= MAX_RLC_INSTANCES)
206 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
208 RLOG2(L_DEBUG,"Unbind Req for spId[%d], reason[%d]",
211 /* disable upper sap (CKW) */
212 udxSap = (tRlcCb->u.dlCb->udxDlSap + spId);
214 #if (ERRCLASS & ERRCLS_INT_PAR)
215 RLC_GET_AND_VALIDATE_UDXSAP(tRlcCb,udxSap, EKW208, "KwUiDlUdxndReq");
216 #endif /* ERRCLASS & ERRCLS_INT_PAR */
217 udxSap->state = RLC_SAP_CFG;
224 * Handler for configuring RLC entities.
227 * This function is used by RRC to configure(add/delete/modify)
228 * one or more RLC entities.
229 * - CKW_CFG_ADD => rlcCfgAddRb
230 * - CKW_CFG_MODIFY => rlcCfgReCfgRb
231 * - CKW_CFG_DELETE => rlcCfgDelRb
232 * - CKW_CFG_REESTABLISH => rlcCfgReEstRb
233 * - CKW_CFG_DELETE_UE => rlcCfgDelUe
235 * @param[in] pst - Post structure
236 * @param[in] spId - Serive Provider ID
237 * @param[in] cfg - Configuration information for one or more RLC entities.
251 S16 rlcDlUdxCfgReq(pst, spId, cfg)
257 RlcCfgCfmInfo *cfgCfm;
262 #if (ERRCLASS & ERRCLS_INT_PAR)
263 if (pst->dstInst >= MAX_RLC_INSTANCES)
269 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
271 pstUdxCfm = &(tRlcCb->u.dlCb->udxDlSap[spId].pst);
272 RLCDBGP_BRIEF(tRlcCb,"spId(%d)\n", spId);
273 /* Allocate memory and memset to 0 for cfmInfo */
274 RLC_ALLOC_SHRABL_BUF_WC(pstUdxCfm->region,
277 sizeof(RlcCfgCfmInfo));
279 #if (ERRCLASS & ERRCLS_ADD_RES)
282 RLOG0(L_FATAL,"Memory Allocation Failed.");
283 /* kw002.201 Freeing from proper region */
284 /* RLC_PST_FREE(pst->region, pst->pool, cfg, sizeof(RlcCfgInfo)); */
287 #endif /* ERRCLASS & ERRCLS_ADD_RES */
289 /* For every entity configuration process by cfgType */
290 for (idx = 0; idx < cfg->numEnt; idx++)
292 RlcEntCfgCfmInfo *entCfgCfm;
293 RlcEntCfgInfo *entCfg;
295 entCfg = (RlcEntCfgInfo *)&(cfg->entCfg[idx]);
296 entCfgCfm = (RlcEntCfgCfmInfo *)&(cfgCfm->entCfgCfm[idx]);
298 switch (entCfg->cfgType)
302 if (entCfg->dir & RLC_DIR_DL)
304 /* Add a new RB entity configuration */
305 if (rlcCfgAddDlRb(tRlcCb,cfg->ueId, cfg->cellId,\
306 entCfg, entCfgCfm) != ROK)
308 RLOG_ARG1(L_ERROR,DBG_RBID,cfg->entCfg[idx].rbId,"Addition Failed due to[%d]",
309 entCfgCfm->status.reason);
316 if (entCfg->dir & RLC_DIR_DL)
318 /* Re-configure the existing RB entity configuration */
319 if (rlcCfgReCfgDlRb(tRlcCb,cfg->ueId, cfg->cellId,\
320 entCfg, entCfgCfm) != ROK)
322 RLOG_ARG1(L_ERROR,DBG_RBID,cfg->entCfg[idx].rbId,"ReCfg Failed due to[%d]",
323 entCfgCfm->status.reason);
331 if (entCfg->dir & RLC_DIR_DL)
333 /* Delete the existing RB entity configuration */
334 if (rlcCfgDelDlRb(tRlcCb,cfg->ueId, cfg->cellId,\
335 entCfg, entCfgCfm) != ROK)
337 RLOG_ARG1(L_ERROR,DBG_RBID,cfg->entCfg[idx].rbId,"Deletion Failed due to[%d]",
338 entCfgCfm->status.reason);
344 case CKW_CFG_REESTABLISH:
346 if (entCfg->dir & RLC_DIR_DL)
348 /*if direction is both then, re-establishment end indication
349 * should be sent only from the UL instance, only if DIR is
350 * DL only then DL instance will send indication.*/
351 Bool sndReEst = TRUE;
352 if (entCfg->dir & RLC_DIR_UL)
356 /* Re-establish the existing RB entity configuration */
357 if (rlcCfgReEstDlRb(tRlcCb,cfg->ueId, cfg->cellId,
358 sndReEst,entCfg, entCfgCfm) != ROK)
360 RLOG_ARG1(L_ERROR,DBG_RBID,cfg->entCfg[idx].rbId,"Reest Failed due to[%d]",
361 entCfgCfm->status.reason);
367 case CKW_CFG_DELETE_UE:
369 /* Delete all RB entity configuration under UE */
370 if (rlcCfgDelDlUe(tRlcCb,cfg->ueId, cfg->cellId,
371 entCfg, entCfgCfm) != ROK)
373 RLOG_ARG1(L_ERROR,DBG_UEID,cfg->ueId,"deletion Failed due to[%d]",
374 entCfgCfm->status.reason);
378 case CKW_CFG_DELETE_CELL:
380 if (rlcCfgDelDlCell(tRlcCb,cfg->cellId,entCfg,entCfgCfm)
383 RLOG_ARG1(L_ERROR,DBG_CELLID,cfg->cellId,"deletion Failed due to[%d]",
384 entCfgCfm->status.reason);
391 RLC_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType,\
392 CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_CFG);
393 RLOG0(L_ERROR, "Invalid CfgType");
398 /* Assign number of entity configuraitons and suId */
399 cfgCfm->transId = cfg->transId;
400 cfgCfm->ueId = cfg->ueId;
401 cfgCfm->cellId = cfg->cellId;
402 cfgCfm->numEnt = cfg->numEnt;
404 /* kw002.201 Freeing from proper region */
405 /* RLC_PST_FREE(pst->region, pst->pool, cfg, sizeof(RlcCfgInfo)); */
406 /* Send Configuration confirm primitive */
407 rlcDlUdxCfgCfm(&(tRlcCb->u.dlCb->udxDlSap[spId].pst),
408 tRlcCb->u.dlCb->udxDlSap[spId].suId,
416 * This primitive is used by RRC to change the UeId for the existing UE
419 * @param pst - Pointer to the pst structure
420 * @param spId - The ID of the service provider SAP in the RLC layer
421 * @param transId - Transaction ID. This field uniquily identifies
422 * transaction between RRC and RLC
423 * @param ueInfo - Old UE Id Info for which the change request has come
424 * @param newUeInfo - New UE Id Info for existing UE context
431 S16 rlcDlUdxUeIdChgReq
440 S16 rlcDlUdxUeIdChgReq(pst,spId,transId,ueInfo,newUeInfo)
445 CkwUeInfo *newUeInfo;
451 #if (ERRCLASS & ERRCLS_INT_PAR)
452 if (pst->dstInst >= MAX_RLC_INSTANCES)
458 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
460 RLCDBGP_BRIEF(tRlcCb, "(spId(%d), transId(%ld))\n",
463 RLCDBGP_BRIEF(tRlcCb, "(spId(%d), transId(%d))\n",
467 status.reason = CKW_CFG_REAS_NONE;
468 status.status = CKW_CFG_CFM_OK;
470 if (rlcCfgDlUeIdChng(tRlcCb, ueInfo, newUeInfo, &status) != ROK)
472 RLOG_ARG1(L_ERROR,DBG_CELLID,newUeInfo->cellId,"Failure due to[%d]",
475 rlcDlUdxUeIdChgCfm(&(tRlcCb->u.dlCb->udxDlSap[spId].pst),
476 tRlcCb->u.dlCb->udxDlSap[spId].suId,
485 * Request for status PDU from ULM to DLM.
487 * @param[in] pst - Post Structure
488 * @param[in] spId - Service Provider Id
489 * @param[in] rlcId - Rlc Information Id
490 * @param[in] pStaPdu - Status PDU
497 S16 rlcDlUdxStaPduReq
502 RlcUdxDlStaPdu *pStaPdu
505 S16 rlcDlUdxStaPduReq(pst, spId, rlcId, pStaPdu)
509 RlcUdxDlStaPdu *pStaPdu;
515 tRlcCb = RLC_GET_RLCCB (pst->dstInst);
517 rlcDbmFetchDlRbCbByRbId(tRlcCb, rlcId, &rbCb); /* Fetch DBM RbCb */
520 RLOG_ARG2(L_ERROR, DBG_UEID,rlcId->ueId, "CellId [%u]:RbId[%d] not found",
521 rlcId->cellId,rlcId->rbId);
522 RLC_FREE_SHRABL_BUF(pst->region,
525 sizeof(RlcUdxDlStaPdu));
529 AMDL.cntrlBo = pStaPdu->controlBo;
530 /* If there already exists a STAUS PDU, free it and take the new one
534 RLC_FREE_SHRABL_BUF(pst->region,
537 sizeof(RlcUdxDlStaPdu));
540 AMDL.pStaPdu = pStaPdu;
541 rlcAmmSendDedLcBoStatus(tRlcCb, rbCb, &AMDL);
548 * It handles the status update recieved from ULM.
550 * @param[in] pst - Post Structure
551 * @param[in] spId - Service Provider Id
552 * @param[in] rlcId - Rlc Information Id
553 * @param[in] pStaPdu - Status PDU
560 S16 rlcDlUdxStaUpdReq
565 RlcUdxStaPdu *pStaPdu
568 S16 rlcDlUdxStaUpdReq(pst, spId, rlcId,pStaPdu)
572 RlcUdxStaPdu *pStaPdu;
578 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
580 rlcDbmFetchDlRbCbByRbId(tRlcCb, rlcId, &rbCb);
583 RLOG_ARG2(L_ERROR, DBG_UEID,rlcId->ueId, "CellId [%u]:RbId[%d] not found",
584 rlcId->cellId,rlcId->rbId);
588 rlcAmmDlHndlStatusPdu(tRlcCb, rbCb, pStaPdu);
590 RLC_FREE_SHRABL_BUF(pst->region,
593 sizeof(RlcUdxStaPdu));
602 S16 rlcDlUdxL2MeasReq
605 RlcL2MeasReqEvt *measReqEvt
608 S16 rlcDlUdxL2MeasReq (pst, measReqEvt)
610 RlcL2MeasReqEvt *measReqEvt;
615 VOLATILE U32 startTime = 0;
619 SStartTask(&startTime, PID_RLC_MEAS_START);
621 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
623 /* Initialize measCfmEvt */
625 /* validate the received measReqEvt */
626 /*LTE_L2_MEAS_PHASE2*/
628 measType = measReqEvt->measReq.measType;
630 if(measType & LKW_L2MEAS_DL_IP)
632 /* if measurement is for DL IP enable for all QCI */
633 for(cntr = 0; cntr < LKW_MAX_QCI; cntr++)
635 tRlcCb->u.dlCb->rlcL2Cb.measOn[cntr] |= LKW_L2MEAS_DL_IP;
640 /* for nonIpThroughput meas, enable only for the sent QCIs */
642 for(i = 0; i < LKW_MAX_QCI; i++)
644 tRlcCb->u.dlCb->rlcL2Cb.measOn[i] |= measType;
648 /* We need to copy the transId for sending back confirms later */
649 for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
651 RlcL2MeasEvtCb* measEvtCb = &(tRlcCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr]);
652 if(measEvtCb->measCb.measType & measType)
654 measEvtCb->transId= measReqEvt->transId;
659 SStopTask(startTime, PID_RLC_MEAS_START);
661 } /* rlcDlUdxMeasReq */
665 This function processes L2 Measurement stop request received from the layer manager.
666 After receving this request, RLC stops L2 Measurement
667 * @param[in] pst post structure
668 * @param[in] measType meas Type
671 * -# Failure : RFAILED
675 S16 rlcDlUdxL2MeasStopReq
681 S16 rlcDlUdxL2MeasStopReq (pst, measType)
687 RlcL2MeasEvtCb *measEvtCb = NULLP;
690 /* RlcL2MeasCfmEvt measCfmEvt; */
691 VOLATILE U32 startTime = 0;
695 SStartTask(&startTime, PID_RLC_MEAS_STOP);
697 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
698 /* memset(&measCfmEvt, 0, sizeof(RlcL2MeasCfmEvt)); */
699 /* reset the counters for the measurement type passed */
700 for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
702 measEvtCb = &(tRlcCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr]);
703 if(measEvtCb->measCb.measType & measType)
705 rlcUtlResetDlL2MeasInRlcRb(tRlcCb, &measEvtCb->measCb, measType);
710 /* switch off the measurements for the type passed */
711 for(cntr = 0; cntr < LKW_MAX_QCI; cntr++)
713 tRlcCb->u.dlCb->rlcL2Cb.measOn[cntr] &= ~measType;
716 status = LCM_PRIM_OK;
717 /* Stop confirm is removed as UL thread is already sending it */
720 SStopTask(startTime, PID_RLC_MEAS_STOP);
726 This function processes L2 Measurement Send request received from the layer manager.
727 After receving this request, RLC sends L2 Measurement
728 * @param[in] pst post structure
729 * @param[in] measType meas Type
732 * -# Failure : RFAILED
736 S16 rlcDlUdxL2MeasSendReq
742 S16 rlcDlUdxL2MeasSendReq (pst, measType)
747 RlcL2MeasEvtCb *measEvtCb;
750 VOLATILE U32 startTime = 0;
753 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
754 for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
756 measEvtCb = &(tRlcCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr]);
757 if(measEvtCb->measCb.measType & measType)
760 SStartTask(&startTime, PID_RLC_MEAS_REPORT);
762 rlcUtlSndDlL2MeasCfm(tRlcCb, measEvtCb);
765 SStopTask(startTime, PID_RLC_MEAS_REPORT);
771 #endif /* LTE_L2_MEAS */
775 #endif /* __cplusplus */
778 /**********************************************************************
780 **********************************************************************/