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 TRC3(rlcDlUdxBndReq);
104 #if (ERRCLASS & ERRCLS_INT_PAR)
105 if (pst->dstInst >= MAX_RLC_INSTANCES)
110 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
112 RLCDBGP_BRIEF(tRlcCb, "rlcDlUdxBndReq(spId(%d), suId(%d))\n",
115 udxSap = (tRlcCb->u.dlCb->udxDlSap + spId);
117 /* Verify CKW SAP State */
118 switch(udxSap->state)
120 /* SAP is configured but not bound */
124 /* copy bind configuration parameters in SSAP sap */
126 udxSap->pst.dstProcId = pst->srcProcId;
127 udxSap->pst.dstEnt = pst->srcEnt;
128 udxSap->pst.dstInst = pst->srcInst;
130 /* Update the State */
131 udxSap->state = RLC_SAP_BND;
133 RLOG1(L_INFO, "UDX SAP state [%d]", udxSap->state);
136 /* SAP is already bound */
140 * Sap is already bound check source, destination Entity and
143 if (udxSap->pst.dstProcId != pst->srcProcId
144 || udxSap->pst.dstEnt != pst->srcEnt
145 || udxSap->pst.dstInst != pst->srcInst
146 || udxSap->suId != suId)
148 RLC_SEND_SAPID_ALARM(tRlcCb, spId,
149 LKW_EVENT_UDX_BND_REQ, LCM_CAUSE_INV_PAR_VAL);
151 RLOG0(L_ERROR, "UDX SAP already Bound");
152 rlcDlUdxBndCfm(&(udxSap->pst), udxSap->suId, CM_BND_NOK);
159 #if (ERRCLASS & ERRCLS_INT_PAR)
160 RLC_SEND_SAPID_ALARM(tRlcCb,spId,
161 LKW_EVENT_CKW_BND_REQ, LCM_CAUSE_INV_STATE);
162 #endif /* ERRCLASS & ERRCLS_INT_PAR */
163 RLOG0(L_ERROR, "Invalid UDX SAP State in Bind Req");
164 rlcDlUdxBndCfm(&(udxSap->pst), udxSap->suId, CM_BND_NOK);
168 rlcDlUdxBndCfm(&(udxSap->pst), udxSap->suId, CM_BND_OK);
175 * Handler for unbinding the DL from UL.
177 * @param[in] pst Post structure
178 * @param[in] spId Service provider SAP ID
179 * @param[in] reason Reason for Unbinding
192 S16 rlcDlUdxUbndReq(pst, spId, reason)
198 RlcUdxDlSapCb *udxSap;
201 TRC3(rlcDlUdxUbndReq)
203 #if (ERRCLASS & ERRCLS_INT_PAR)
204 if (pst->dstInst >= MAX_RLC_INSTANCES)
210 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
212 RLOG2(L_DEBUG,"Unbind Req for spId[%d], reason[%d]",
215 /* disable upper sap (CKW) */
216 udxSap = (tRlcCb->u.dlCb->udxDlSap + spId);
218 #if (ERRCLASS & ERRCLS_INT_PAR)
219 RLC_GET_AND_VALIDATE_UDXSAP(tRlcCb,udxSap, EKW208, "KwUiDlUdxndReq");
220 #endif /* ERRCLASS & ERRCLS_INT_PAR */
221 udxSap->state = RLC_SAP_CFG;
228 * Handler for configuring RLC entities.
231 * This function is used by RRC to configure(add/delete/modify)
232 * one or more RLC entities.
233 * - CKW_CFG_ADD => rlcCfgAddRb
234 * - CKW_CFG_MODIFY => rlcCfgReCfgRb
235 * - CKW_CFG_DELETE => rlcCfgDelRb
236 * - CKW_CFG_REESTABLISH => rlcCfgReEstRb
237 * - CKW_CFG_DELETE_UE => rlcCfgDelUe
239 * @param[in] pst - Post structure
240 * @param[in] spId - Serive Provider ID
241 * @param[in] cfg - Configuration information for one or more RLC entities.
255 S16 rlcDlUdxCfgReq(pst, spId, cfg)
261 RlcCfgCfmInfo *cfgCfm;
268 #if (ERRCLASS & ERRCLS_INT_PAR)
269 if (pst->dstInst >= MAX_RLC_INSTANCES)
275 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
277 pstUdxCfm = &(tRlcCb->u.dlCb->udxDlSap[spId].pst);
278 RLCDBGP_BRIEF(tRlcCb,"spId(%d)\n", spId);
279 /* Allocate memory and memset to 0 for cfmInfo */
280 RLC_ALLOC_SHRABL_BUF_WC(pstUdxCfm->region,
283 sizeof(RlcCfgCfmInfo));
285 #if (ERRCLASS & ERRCLS_ADD_RES)
288 RLOG0(L_FATAL,"Memory Allocation Failed.");
289 /* kw002.201 Freeing from proper region */
290 /* RLC_PST_FREE(pst->region, pst->pool, cfg, sizeof(RlcCfgInfo)); */
293 #endif /* ERRCLASS & ERRCLS_ADD_RES */
295 /* For every entity configuration process by cfgType */
296 for (idx = 0; idx < cfg->numEnt; idx++)
298 RlcEntCfgCfmInfo *entCfgCfm;
299 RlcEntCfgInfo *entCfg;
301 entCfg = (RlcEntCfgInfo *)&(cfg->entCfg[idx]);
302 entCfgCfm = (RlcEntCfgCfmInfo *)&(cfgCfm->entCfgCfm[idx]);
304 switch (entCfg->cfgType)
308 if (entCfg->dir & RLC_DIR_DL)
310 /* Add a new RB entity configuration */
311 if (rlcCfgAddDlRb(tRlcCb,cfg->ueId, cfg->cellId,\
312 entCfg, entCfgCfm) != ROK)
314 RLOG_ARG1(L_ERROR,DBG_RBID,cfg->entCfg[idx].rbId,"Addition Failed due to[%d]",
315 entCfgCfm->status.reason);
322 if (entCfg->dir & RLC_DIR_DL)
324 /* Re-configure the existing RB entity configuration */
325 if (rlcCfgReCfgDlRb(tRlcCb,cfg->ueId, cfg->cellId,\
326 entCfg, entCfgCfm) != ROK)
328 RLOG_ARG1(L_ERROR,DBG_RBID,cfg->entCfg[idx].rbId,"ReCfg Failed due to[%d]",
329 entCfgCfm->status.reason);
337 if (entCfg->dir & RLC_DIR_DL)
339 /* Delete the existing RB entity configuration */
340 if (rlcCfgDelDlRb(tRlcCb,cfg->ueId, cfg->cellId,\
341 entCfg, entCfgCfm) != ROK)
343 RLOG_ARG1(L_ERROR,DBG_RBID,cfg->entCfg[idx].rbId,"Deletion Failed due to[%d]",
344 entCfgCfm->status.reason);
350 case CKW_CFG_REESTABLISH:
352 if (entCfg->dir & RLC_DIR_DL)
354 /*if direction is both then, re-establishment end indication
355 * should be sent only from the UL instance, only if DIR is
356 * DL only then DL instance will send indication.*/
357 Bool sndReEst = TRUE;
358 if (entCfg->dir & RLC_DIR_UL)
362 /* Re-establish the existing RB entity configuration */
363 if (rlcCfgReEstDlRb(tRlcCb,cfg->ueId, cfg->cellId,
364 sndReEst,entCfg, entCfgCfm) != ROK)
366 RLOG_ARG1(L_ERROR,DBG_RBID,cfg->entCfg[idx].rbId,"Reest Failed due to[%d]",
367 entCfgCfm->status.reason);
373 case CKW_CFG_DELETE_UE:
375 /* Delete all RB entity configuration under UE */
376 if (rlcCfgDelDlUe(tRlcCb,cfg->ueId, cfg->cellId,
377 entCfg, entCfgCfm) != ROK)
379 RLOG_ARG1(L_ERROR,DBG_UEID,cfg->ueId,"deletion Failed due to[%d]",
380 entCfgCfm->status.reason);
384 case CKW_CFG_DELETE_CELL:
386 if (rlcCfgDelDlCell(tRlcCb,cfg->cellId,entCfg,entCfgCfm)
389 RLOG_ARG1(L_ERROR,DBG_CELLID,cfg->cellId,"deletion Failed due to[%d]",
390 entCfgCfm->status.reason);
397 RLC_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType,\
398 CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_CFG);
399 RLOG0(L_ERROR, "Invalid CfgType");
404 /* Assign number of entity configuraitons and suId */
405 cfgCfm->transId = cfg->transId;
406 cfgCfm->ueId = cfg->ueId;
407 cfgCfm->cellId = cfg->cellId;
408 cfgCfm->numEnt = cfg->numEnt;
410 /* kw002.201 Freeing from proper region */
411 /* RLC_PST_FREE(pst->region, pst->pool, cfg, sizeof(RlcCfgInfo)); */
412 /* Send Configuration confirm primitive */
413 rlcDlUdxCfgCfm(&(tRlcCb->u.dlCb->udxDlSap[spId].pst),
414 tRlcCb->u.dlCb->udxDlSap[spId].suId,
422 * This primitive is used by RRC to change the UeId for the existing UE
425 * @param pst - Pointer to the pst structure
426 * @param spId - The ID of the service provider SAP in the RLC layer
427 * @param transId - Transaction ID. This field uniquily identifies
428 * transaction between RRC and RLC
429 * @param ueInfo - Old UE Id Info for which the change request has come
430 * @param newUeInfo - New UE Id Info for existing UE context
437 S16 rlcDlUdxUeIdChgReq
446 S16 rlcDlUdxUeIdChgReq(pst,spId,transId,ueInfo,newUeInfo)
451 CkwUeInfo *newUeInfo;
457 TRC3(rlcDlUdxUeIdChgReq)
459 #if (ERRCLASS & ERRCLS_INT_PAR)
460 if (pst->dstInst >= MAX_RLC_INSTANCES)
466 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
468 RLCDBGP_BRIEF(tRlcCb, "(spId(%d), transId(%ld))\n",
471 RLCDBGP_BRIEF(tRlcCb, "(spId(%d), transId(%d))\n",
475 status.reason = CKW_CFG_REAS_NONE;
476 status.status = CKW_CFG_CFM_OK;
478 if (rlcCfgDlUeIdChng(tRlcCb, ueInfo, newUeInfo, &status) != ROK)
480 RLOG_ARG1(L_ERROR,DBG_CELLID,newUeInfo->cellId,"Failure due to[%d]",
483 rlcDlUdxUeIdChgCfm(&(tRlcCb->u.dlCb->udxDlSap[spId].pst),
484 tRlcCb->u.dlCb->udxDlSap[spId].suId,
493 * Request for status PDU from ULM to DLM.
495 * @param[in] pst - Post Structure
496 * @param[in] spId - Service Provider Id
497 * @param[in] rlcId - Rlc Information Id
498 * @param[in] pStaPdu - Status PDU
505 S16 rlcDlUdxStaPduReq
510 RlcUdxDlStaPdu *pStaPdu
513 S16 rlcDlUdxStaPduReq(pst, spId, rlcId, pStaPdu)
517 RlcUdxDlStaPdu *pStaPdu;
523 tRlcCb = RLC_GET_RLCCB (pst->dstInst);
525 rlcDbmFetchDlRbCbByRbId(tRlcCb, rlcId, &rbCb); /* Fetch DBM RbCb */
528 RLOG_ARG2(L_ERROR, DBG_UEID,rlcId->ueId, "CellId [%u]:RbId[%d] not found",
529 rlcId->cellId,rlcId->rbId);
530 RLC_FREE_SHRABL_BUF(pst->region,
533 sizeof(RlcUdxDlStaPdu));
537 AMDL.cntrlBo = pStaPdu->controlBo;
538 /* If there already exists a STAUS PDU, free it and take the new one
542 RLC_FREE_SHRABL_BUF(pst->region,
545 sizeof(RlcUdxDlStaPdu));
548 AMDL.pStaPdu = pStaPdu;
549 rlcAmmSendDedLcBoStatus(tRlcCb, rbCb, &AMDL);
556 * It handles the status update recieved from ULM.
558 * @param[in] pst - Post Structure
559 * @param[in] spId - Service Provider Id
560 * @param[in] rlcId - Rlc Information Id
561 * @param[in] pStaPdu - Status PDU
568 S16 rlcDlUdxStaUpdReq
573 RlcUdxStaPdu *pStaPdu
576 S16 rlcDlUdxStaUpdReq(pst, spId, rlcId,pStaPdu)
580 RlcUdxStaPdu *pStaPdu;
586 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
588 rlcDbmFetchDlRbCbByRbId(tRlcCb, rlcId, &rbCb);
591 RLOG_ARG2(L_ERROR, DBG_UEID,rlcId->ueId, "CellId [%u]:RbId[%d] not found",
592 rlcId->cellId,rlcId->rbId);
596 rlcAmmDlHndlStatusPdu(tRlcCb, rbCb, pStaPdu);
598 RLC_FREE_SHRABL_BUF(pst->region,
601 sizeof(RlcUdxStaPdu));
610 S16 rlcDlUdxL2MeasReq
613 RlcL2MeasReqEvt *measReqEvt
616 S16 rlcDlUdxL2MeasReq (pst, measReqEvt)
618 RlcL2MeasReqEvt *measReqEvt;
623 VOLATILE U32 startTime = 0;
626 TRC3(rlcDlUdxL2MeasReq);
629 SStartTask(&startTime, PID_RLC_MEAS_START);
631 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
633 /* Initialize measCfmEvt */
635 /* validate the received measReqEvt */
636 /*LTE_L2_MEAS_PHASE2*/
638 measType = measReqEvt->measReq.measType;
640 if(measType & LKW_L2MEAS_DL_IP)
642 /* if measurement is for DL IP enable for all QCI */
643 for(cntr = 0; cntr < LKW_MAX_QCI; cntr++)
645 tRlcCb->u.dlCb->rlcL2Cb.measOn[cntr] |= LKW_L2MEAS_DL_IP;
650 /* for nonIpThroughput meas, enable only for the sent QCIs */
652 for(i = 0; i < LKW_MAX_QCI; i++)
654 tRlcCb->u.dlCb->rlcL2Cb.measOn[i] |= measType;
658 /* We need to copy the transId for sending back confirms later */
659 for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
661 RlcL2MeasEvtCb* measEvtCb = &(tRlcCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr]);
662 if(measEvtCb->measCb.measType & measType)
664 measEvtCb->transId= measReqEvt->transId;
669 SStopTask(startTime, PID_RLC_MEAS_START);
671 } /* rlcDlUdxMeasReq */
675 This function processes L2 Measurement stop request received from the layer manager.
676 After receving this request, RLC stops L2 Measurement
677 * @param[in] pst post structure
678 * @param[in] measType meas Type
681 * -# Failure : RFAILED
685 S16 rlcDlUdxL2MeasStopReq
691 S16 rlcDlUdxL2MeasStopReq (pst, measType)
697 RlcL2MeasEvtCb *measEvtCb = NULLP;
700 /* RlcL2MeasCfmEvt measCfmEvt; */
701 VOLATILE U32 startTime = 0;
703 TRC3(rlcDlUdxMeasStopReq);
706 SStartTask(&startTime, PID_RLC_MEAS_STOP);
708 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
709 /* cmMemset((U8*)&measCfmEvt, 0, sizeof(RlcL2MeasCfmEvt)); */
710 /* reset the counters for the measurement type passed */
711 for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
713 measEvtCb = &(tRlcCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr]);
714 if(measEvtCb->measCb.measType & measType)
716 rlcUtlResetDlL2MeasInRlcRb(tRlcCb, &measEvtCb->measCb, measType);
721 /* switch off the measurements for the type passed */
722 for(cntr = 0; cntr < LKW_MAX_QCI; cntr++)
724 tRlcCb->u.dlCb->rlcL2Cb.measOn[cntr] &= ~measType;
727 status = LCM_PRIM_OK;
728 /* Stop confirm is removed as UL thread is already sending it */
731 SStopTask(startTime, PID_RLC_MEAS_STOP);
737 This function processes L2 Measurement Send request received from the layer manager.
738 After receving this request, RLC sends L2 Measurement
739 * @param[in] pst post structure
740 * @param[in] measType meas Type
743 * -# Failure : RFAILED
747 S16 rlcDlUdxL2MeasSendReq
753 S16 rlcDlUdxL2MeasSendReq (pst, measType)
758 RlcL2MeasEvtCb *measEvtCb;
761 VOLATILE U32 startTime = 0;
763 TRC3(rlcDlUdxMeasSendReq);
765 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
766 for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
768 measEvtCb = &(tRlcCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr]);
769 if(measEvtCb->measCb.measType & measType)
772 SStartTask(&startTime, PID_RLC_MEAS_REPORT);
774 rlcUtlSndDlL2MeasCfm(tRlcCb, measEvtCb);
777 SStopTask(startTime, PID_RLC_MEAS_REPORT);
783 #endif /* LTE_L2_MEAS */
787 #endif /* __cplusplus */
790 /**********************************************************************
792 **********************************************************************/