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 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
92 RlcUdxDlSapCb *udxSap; /* pointer to session SAP */
95 #if (ERRCLASS & ERRCLS_INT_PAR)
96 if (pst->dstInst >= MAX_RLC_INSTANCES)
101 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
103 RLCDBGP_BRIEF(tRlcCb, "rlcDlUdxBndReq(spId(%d), suId(%d))\n",
106 udxSap = (tRlcCb->u.dlCb->udxDlSap + spId);
108 /* Verify CKW SAP State */
109 switch(udxSap->state)
111 /* SAP is configured but not bound */
115 /* copy bind configuration parameters in SSAP sap */
117 udxSap->pst.dstProcId = pst->srcProcId;
118 udxSap->pst.dstEnt = pst->srcEnt;
119 udxSap->pst.dstInst = pst->srcInst;
121 /* Update the State */
122 udxSap->state = RLC_SAP_BND;
124 RLOG1(L_INFO, "UDX SAP state [%d]", udxSap->state);
127 /* SAP is already bound */
131 * Sap is already bound check source, destination Entity and
134 if (udxSap->pst.dstProcId != pst->srcProcId
135 || udxSap->pst.dstEnt != pst->srcEnt
136 || udxSap->pst.dstInst != pst->srcInst
137 || udxSap->suId != suId)
139 RLC_SEND_SAPID_ALARM(tRlcCb, spId,
140 LKW_EVENT_UDX_BND_REQ, LCM_CAUSE_INV_PAR_VAL);
142 RLOG0(L_ERROR, "UDX SAP already Bound");
143 rlcDlUdxBndCfm(&(udxSap->pst), udxSap->suId, CM_BND_NOK);
150 #if (ERRCLASS & ERRCLS_INT_PAR)
151 RLC_SEND_SAPID_ALARM(tRlcCb,spId,
152 LKW_EVENT_CKW_BND_REQ, LCM_CAUSE_INV_STATE);
153 #endif /* ERRCLASS & ERRCLS_INT_PAR */
154 RLOG0(L_ERROR, "Invalid UDX SAP State in Bind Req");
155 rlcDlUdxBndCfm(&(udxSap->pst), udxSap->suId, CM_BND_NOK);
159 rlcDlUdxBndCfm(&(udxSap->pst), udxSap->suId, CM_BND_OK);
166 * Handler for unbinding the DL from UL.
168 * @param[in] pst Post structure
169 * @param[in] spId Service provider SAP ID
170 * @param[in] reason Reason for Unbinding
182 RlcUdxDlSapCb *udxSap;
185 #if (ERRCLASS & ERRCLS_INT_PAR)
186 if (pst->dstInst >= MAX_RLC_INSTANCES)
192 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
194 RLOG2(L_DEBUG,"Unbind Req for spId[%d], reason[%d]",
197 /* disable upper sap (CKW) */
198 udxSap = (tRlcCb->u.dlCb->udxDlSap + spId);
200 #if (ERRCLASS & ERRCLS_INT_PAR)
201 RLC_GET_AND_VALIDATE_UDXSAP(tRlcCb,udxSap, EKW208, "KwUiDlUdxndReq");
202 #endif /* ERRCLASS & ERRCLS_INT_PAR */
203 udxSap->state = RLC_SAP_CFG;
210 * Handler for configuring RLC entities.
213 * This function is used by RRC to configure(add/delete/modify)
214 * one or more RLC entities.
215 * - CKW_CFG_ADD => rlcCfgAddRb
216 * - CKW_CFG_MODIFY => rlcCfgReCfgRb
217 * - CKW_CFG_DELETE => rlcCfgDelRb
218 * - CKW_CFG_REESTABLISH => rlcCfgReEstRb
219 * - CKW_CFG_DELETE_UE => rlcCfgDelUe
221 * @param[in] pst - Post structure
222 * @param[in] spId - Serive Provider ID
223 * @param[in] cfg - Configuration information for one or more RLC entities.
236 RlcCfgCfmInfo *cfgCfm;
241 #if (ERRCLASS & ERRCLS_INT_PAR)
242 if (pst->dstInst >= MAX_RLC_INSTANCES)
248 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
250 pstUdxCfm = &(tRlcCb->u.dlCb->udxDlSap[spId].pst);
251 RLCDBGP_BRIEF(tRlcCb,"spId(%d)\n", spId);
252 /* Allocate memory and memset to 0 for cfmInfo */
253 RLC_ALLOC_SHRABL_BUF_WC(pstUdxCfm->region,
256 sizeof(RlcCfgCfmInfo));
258 #if (ERRCLASS & ERRCLS_ADD_RES)
261 RLOG0(L_FATAL,"Memory Allocation Failed.");
262 /* kw002.201 Freeing from proper region */
263 /* RLC_PST_FREE(pst->region, pst->pool, cfg, sizeof(RlcCfgInfo)); */
266 #endif /* ERRCLASS & ERRCLS_ADD_RES */
268 /* For every entity configuration process by cfgType */
269 for (idx = 0; idx < cfg->numEnt; idx++)
271 RlcEntCfgCfmInfo *entCfgCfm;
272 RlcEntCfgInfo *entCfg;
274 entCfg = (RlcEntCfgInfo *)&(cfg->entCfg[idx]);
275 entCfgCfm = (RlcEntCfgCfmInfo *)&(cfgCfm->entCfgCfm[idx]);
277 switch (entCfg->cfgType)
281 if (entCfg->dir & RLC_DIR_DL)
283 /* Add a new RB entity configuration */
284 if (rlcCfgAddDlRb(tRlcCb,cfg->ueId, cfg->cellId,\
285 entCfg, entCfgCfm) != ROK)
287 RLOG_ARG1(L_ERROR,DBG_RBID,cfg->entCfg[idx].rbId,"Addition Failed due to[%d]",
288 entCfgCfm->status.reason);
295 if (entCfg->dir & RLC_DIR_DL)
297 /* Re-configure the existing RB entity configuration */
298 if (rlcCfgReCfgDlRb(tRlcCb,cfg->ueId, cfg->cellId,\
299 entCfg, entCfgCfm) != ROK)
301 RLOG_ARG1(L_ERROR,DBG_RBID,cfg->entCfg[idx].rbId,"ReCfg Failed due to[%d]",
302 entCfgCfm->status.reason);
310 if (entCfg->dir & RLC_DIR_DL)
312 /* Delete the existing RB entity configuration */
313 if (rlcCfgDelDlRb(tRlcCb,cfg->ueId, cfg->cellId,\
314 entCfg, entCfgCfm) != ROK)
316 RLOG_ARG1(L_ERROR,DBG_RBID,cfg->entCfg[idx].rbId,"Deletion Failed due to[%d]",
317 entCfgCfm->status.reason);
323 case CKW_CFG_REESTABLISH:
325 if (entCfg->dir & RLC_DIR_DL)
327 /*if direction is both then, re-establishment end indication
328 * should be sent only from the UL instance, only if DIR is
329 * DL only then DL instance will send indication.*/
330 Bool sndReEst = TRUE;
331 if (entCfg->dir & RLC_DIR_UL)
335 /* Re-establish the existing RB entity configuration */
336 if (rlcCfgReEstDlRb(tRlcCb,cfg->ueId, cfg->cellId,
337 sndReEst,entCfg, entCfgCfm) != ROK)
339 RLOG_ARG1(L_ERROR,DBG_RBID,cfg->entCfg[idx].rbId,"Reest Failed due to[%d]",
340 entCfgCfm->status.reason);
346 case CKW_CFG_DELETE_UE:
348 /* Delete all RB entity configuration under UE */
349 if (rlcCfgDelDlUe(tRlcCb,cfg->ueId, cfg->cellId,
350 entCfg, entCfgCfm) != ROK)
352 RLOG_ARG1(L_ERROR,DBG_UEID,cfg->ueId,"deletion Failed due to[%d]",
353 entCfgCfm->status.reason);
357 case CKW_CFG_DELETE_CELL:
359 if (rlcCfgDelDlCell(tRlcCb,cfg->cellId,entCfg,entCfgCfm)
362 RLOG_ARG1(L_ERROR,DBG_CELLID,cfg->cellId,"deletion Failed due to[%d]",
363 entCfgCfm->status.reason);
370 RLC_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType,\
371 CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_CFG);
372 RLOG0(L_ERROR, "Invalid CfgType");
377 /* Assign number of entity configuraitons and suId */
378 cfgCfm->transId = cfg->transId;
379 cfgCfm->ueId = cfg->ueId;
380 cfgCfm->cellId = cfg->cellId;
381 cfgCfm->numEnt = cfg->numEnt;
383 /* kw002.201 Freeing from proper region */
384 /* RLC_PST_FREE(pst->region, pst->pool, cfg, sizeof(RlcCfgInfo)); */
385 /* Send Configuration confirm primitive */
386 rlcDlUdxCfgCfm(&(tRlcCb->u.dlCb->udxDlSap[spId].pst),
387 tRlcCb->u.dlCb->udxDlSap[spId].suId,
395 * This primitive is used by RRC to change the UeId for the existing UE
398 * @param pst - Pointer to the pst structure
399 * @param spId - The ID of the service provider SAP in the RLC layer
400 * @param transId - Transaction ID. This field uniquily identifies
401 * transaction between RRC and RLC
402 * @param ueInfo - Old UE Id Info for which the change request has come
403 * @param newUeInfo - New UE Id Info for existing UE context
409 S16 rlcDlUdxUeIdChgReq
421 #if (ERRCLASS & ERRCLS_INT_PAR)
422 if (pst->dstInst >= MAX_RLC_INSTANCES)
428 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
430 RLCDBGP_BRIEF(tRlcCb, "(spId(%d), transId(%ld))\n",
433 RLCDBGP_BRIEF(tRlcCb, "(spId(%d), transId(%d))\n",
437 status.reason = CKW_CFG_REAS_NONE;
438 status.status = CKW_CFG_CFM_OK;
440 if (rlcCfgDlUeIdChng(tRlcCb, ueInfo, newUeInfo, &status) != ROK)
442 RLOG_ARG1(L_ERROR,DBG_CELLID,newUeInfo->cellId,"Failure due to[%d]",
445 rlcDlUdxUeIdChgCfm(&(tRlcCb->u.dlCb->udxDlSap[spId].pst),
446 tRlcCb->u.dlCb->udxDlSap[spId].suId,
455 * Request for status PDU from ULM to DLM.
457 * @param[in] pst - Post Structure
458 * @param[in] spId - Service Provider Id
459 * @param[in] rlcId - Rlc Information Id
460 * @param[in] pStaPdu - Status PDU
466 S16 rlcDlUdxStaPduReq
471 RlcUdxDlStaPdu *pStaPdu
477 tRlcCb = RLC_GET_RLCCB (pst->dstInst);
479 rlcDbmFetchDlRbCbByRbId(tRlcCb, rlcId, &rbCb); /* Fetch DBM RbCb */
482 RLOG_ARG2(L_ERROR, DBG_UEID,rlcId->ueId, "CellId [%u]:RbId[%d] not found",
483 rlcId->cellId,rlcId->rbId);
484 RLC_FREE_SHRABL_BUF(pst->region,
487 sizeof(RlcUdxDlStaPdu));
491 AMDL.cntrlBo = pStaPdu->controlBo;
492 /* If there already exists a STAUS PDU, free it and take the new one
496 RLC_FREE_SHRABL_BUF(pst->region,
499 sizeof(RlcUdxDlStaPdu));
502 AMDL.pStaPdu = pStaPdu;
503 rlcAmmSendDedLcBoStatus(tRlcCb, rbCb, &AMDL);
510 * It handles the status update recieved from ULM.
512 * @param[in] pst - Post Structure
513 * @param[in] spId - Service Provider Id
514 * @param[in] rlcId - Rlc Information Id
515 * @param[in] pStaPdu - Status PDU
521 S16 rlcDlUdxStaUpdReq
526 RlcUdxStaPdu *pStaPdu
532 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
534 rlcDbmFetchDlRbCbByRbId(tRlcCb, rlcId, &rbCb);
537 RLOG_ARG2(L_ERROR, DBG_UEID,rlcId->ueId, "CellId [%u]:RbId[%d] not found",
538 rlcId->cellId,rlcId->rbId);
542 rlcAmmDlHndlStatusPdu(tRlcCb, rbCb, pStaPdu);
544 RLC_FREE_SHRABL_BUF(pst->region,
547 sizeof(RlcUdxStaPdu));
555 S16 rlcDlUdxL2MeasReq
558 RlcL2MeasReqEvt *measReqEvt
563 volatile uint32_t startTime = 0;
567 SStartTask(&startTime, PID_RLC_MEAS_START);
569 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
571 /* Initialize measCfmEvt */
573 /* validate the received measReqEvt */
574 /*LTE_L2_MEAS_PHASE2*/
576 measType = measReqEvt->measReq.measType;
578 if(measType & LKW_L2MEAS_DL_IP)
580 /* if measurement is for DL IP enable for all QCI */
581 for(cntr = 0; cntr < LKW_MAX_QCI; cntr++)
583 tRlcCb->u.dlCb->rlcL2Cb.measOn[cntr] |= LKW_L2MEAS_DL_IP;
588 /* for nonIpThroughput meas, enable only for the sent QCIs */
590 for(i = 0; i < LKW_MAX_QCI; i++)
592 tRlcCb->u.dlCb->rlcL2Cb.measOn[i] |= measType;
596 /* We need to copy the transId for sending back confirms later */
597 for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
599 RlcL2MeasEvtCb* measEvtCb = &(tRlcCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr]);
600 if(measEvtCb->measCb.measType & measType)
602 measEvtCb->transId= measReqEvt->transId;
607 SStopTask(startTime, PID_RLC_MEAS_START);
609 } /* rlcDlUdxMeasReq */
613 This function processes L2 Measurement stop request received from the layer manager.
614 After receving this request, RLC stops L2 Measurement
615 * @param[in] pst post structure
616 * @param[in] measType meas Type
619 * -# Failure : RFAILED
622 S16 rlcDlUdxL2MeasStopReq
629 RlcL2MeasEvtCb *measEvtCb = NULLP;
631 uint8_t status = ROK;
632 /* RlcL2MeasCfmEvt measCfmEvt; */
633 volatile uint32_t startTime = 0;
637 SStartTask(&startTime, PID_RLC_MEAS_STOP);
639 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
640 /* memset(&measCfmEvt, 0, sizeof(RlcL2MeasCfmEvt)); */
641 /* reset the counters for the measurement type passed */
642 for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
644 measEvtCb = &(tRlcCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr]);
645 if(measEvtCb->measCb.measType & measType)
647 rlcUtlResetDlL2MeasInRlcRb(tRlcCb, &measEvtCb->measCb, measType);
652 /* switch off the measurements for the type passed */
653 for(cntr = 0; cntr < LKW_MAX_QCI; cntr++)
655 tRlcCb->u.dlCb->rlcL2Cb.measOn[cntr] &= ~measType;
658 status = LCM_PRIM_OK;
659 /* Stop confirm is removed as UL thread is already sending it */
662 SStopTask(startTime, PID_RLC_MEAS_STOP);
668 This function processes L2 Measurement Send request received from the layer manager.
669 After receving this request, RLC sends L2 Measurement
670 * @param[in] pst post structure
671 * @param[in] measType meas Type
674 * -# Failure : RFAILED
677 S16 rlcDlUdxL2MeasSendReq
683 RlcL2MeasEvtCb *measEvtCb;
685 volatile uint32_t startTime = 0;
688 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
689 for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
691 measEvtCb = &(tRlcCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr]);
692 if(measEvtCb->measCb.measType & measType)
695 SStartTask(&startTime, PID_RLC_MEAS_REPORT);
697 rlcUtlSndDlL2MeasCfm(tRlcCb, measEvtCb);
700 SStopTask(startTime, PID_RLC_MEAS_REPORT);
706 #endif /* LTE_L2_MEAS */
710 #endif /* __cplusplus */
713 /**********************************************************************
715 **********************************************************************/