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
27 File: rlc_dl_ul_inf_dl.c
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 "rlc_err.h" /* Err defines */
38 #include "rlc_env.h" /* RLC environment options */
41 /* extern (.x) include files */
42 #include "lkw.x" /* LKW */
43 #include "ckw.x" /* CKW */
44 #include "kwu.x" /* KWU */
45 #include "rgu.x" /* RGU */
47 #include "rlc_utils.h" /* RLC defines */
48 #include "rlc_dl_ul_inf.h"
51 #define RLC_MODULE RLC_DBGMASK_UDX
54 S16 rlcDlmHndlStaRsp ARGS (( RlcCb *gCb,RlcDlRbCb *rbCb,
55 RlcUdxStaPdu *pStaPdu, RlcUdxBufLst *rlsPduLst));
68 * Handler to bind the DL with UL.
70 * @param[in] pst Post structure
71 * @param[in] suId Service user SAP ID
72 * @param[in] spId Service provider ID
85 RlcUdxDlSapCb *udxSap; /* pointer to session SAP */
88 #if (ERRCLASS & ERRCLS_INT_PAR)
89 if (pst->dstInst >= MAX_RLC_INSTANCES)
94 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
96 RLCDBGP_BRIEF(tRlcCb, "rlcDlUdxBndReq(spId(%d), suId(%d))\n",
99 udxSap = (tRlcCb->u.dlCb->udxDlSap + spId);
101 /* Verify CKW SAP State */
102 switch(udxSap->state)
104 /* SAP is configured but not bound */
108 /* copy bind configuration parameters in SSAP sap */
110 udxSap->pst.dstProcId = pst->srcProcId;
111 udxSap->pst.dstEnt = pst->srcEnt;
112 udxSap->pst.dstInst = pst->srcInst;
114 /* Update the State */
115 udxSap->state = RLC_SAP_BND;
117 DU_LOG("\nINFO --> RLC_DL : UDX SAP state [%d]", udxSap->state);
120 /* SAP is already bound */
124 * Sap is already bound check source, destination Entity and
127 if (udxSap->pst.dstProcId != pst->srcProcId
128 || udxSap->pst.dstEnt != pst->srcEnt
129 || udxSap->pst.dstInst != pst->srcInst
130 || udxSap->suId != suId)
132 RLC_SEND_SAPID_ALARM(tRlcCb, spId,
133 LKW_EVENT_UDX_BND_REQ, LCM_CAUSE_INV_PAR_VAL);
135 DU_LOG("\nERROR --> RLC_DL : UDX SAP already Bound");
136 rlcDlUdxBndCfm(&(udxSap->pst), udxSap->suId, CM_BND_NOK);
143 #if (ERRCLASS & ERRCLS_INT_PAR)
144 RLC_SEND_SAPID_ALARM(tRlcCb,spId,
145 LKW_EVENT_CKW_BND_REQ, LCM_CAUSE_INV_STATE);
146 #endif /* ERRCLASS & ERRCLS_INT_PAR */
147 DU_LOG("\nERROR --> RLC_DL : Invalid UDX SAP State in Bind Req");
148 rlcDlUdxBndCfm(&(udxSap->pst), udxSap->suId, CM_BND_NOK);
152 rlcDlUdxBndCfm(&(udxSap->pst), udxSap->suId, CM_BND_OK);
159 * Handler for unbinding the DL from UL.
161 * @param[in] pst Post structure
162 * @param[in] spId Service provider SAP ID
163 * @param[in] reason Reason for Unbinding
175 RlcUdxDlSapCb *udxSap;
178 #if (ERRCLASS & ERRCLS_INT_PAR)
179 if (pst->dstInst >= MAX_RLC_INSTANCES)
185 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
187 DU_LOG("\nDEBUG --> RLC_DL : Unbind Req for spId[%d], reason[%d]",
190 /* disable upper sap (CKW) */
191 udxSap = (tRlcCb->u.dlCb->udxDlSap + spId);
193 #if (ERRCLASS & ERRCLS_INT_PAR)
194 RLC_GET_AND_VALIDATE_UDXSAP(tRlcCb,udxSap, EKW208, "KwUiDlUdxndReq");
195 #endif /* ERRCLASS & ERRCLS_INT_PAR */
196 udxSap->state = RLC_SAP_CFG;
203 * Handler for configuring RLC entities.
206 * This function is used by RRC to configure(add/delete/modify)
207 * one or more RLC entities.
208 * - CKW_CFG_ADD => rlcCfgAddRb
209 * - CKW_CFG_MODIFY => rlcCfgReCfgRb
210 * - CKW_CFG_DELETE => rlcCfgDelRb
211 * - CKW_CFG_REESTABLISH => rlcCfgReEstRb
212 * - CKW_CFG_DELETE_UE => rlcCfgDelUe
214 * @param[in] pst - Post structure
215 * @param[in] spId - Serive Provider ID
216 * @param[in] cfg - Configuration information for one or more RLC entities.
229 RlcCfgCfmInfo *cfgCfm;
234 #if (ERRCLASS & ERRCLS_INT_PAR)
235 if (pst->dstInst >= MAX_RLC_INSTANCES)
241 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
243 pstUdxCfm = &(tRlcCb->u.dlCb->udxDlSap[spId].pst);
244 RLCDBGP_BRIEF(tRlcCb,"spId(%d)\n", spId);
245 /* Allocate memory and memset to 0 for cfmInfo */
246 RLC_ALLOC_SHRABL_BUF_WC(pstUdxCfm->region,
249 sizeof(RlcCfgCfmInfo));
251 #if (ERRCLASS & ERRCLS_ADD_RES)
254 DU_LOG("\nERROR --> RLC_DL : Memory Allocation Failed.");
255 /* kw002.201 Freeing from proper region */
256 /* RLC_PST_FREE(pst->region, pst->pool, cfg, sizeof(RlcCfgInfo)); */
259 #endif /* ERRCLASS & ERRCLS_ADD_RES */
261 /* For every entity configuration process by cfgType */
262 for (idx = 0; idx < cfg->numEnt; idx++)
264 RlcEntCfgCfmInfo *entCfgCfm;
265 RlcEntCfgInfo *entCfg;
267 entCfg = (RlcEntCfgInfo *)&(cfg->entCfg[idx]);
268 entCfgCfm = (RlcEntCfgCfmInfo *)&(cfgCfm->entCfgCfm[idx]);
270 switch (entCfg->cfgType)
274 if (entCfg->dir & RLC_DIR_DL)
276 /* Add a new RB entity configuration */
277 if (rlcCfgAddDlRb(tRlcCb,cfg->ueId, cfg->cellId,\
278 entCfg, entCfgCfm) != ROK)
280 DU_LOG("\nERROR --> RLC_DL : Addition Failed due to[%d]",
281 entCfgCfm->status.reason);
288 if (entCfg->dir & RLC_DIR_DL)
290 /* Re-configure the existing RB entity configuration */
291 if (rlcCfgReCfgDlRb(tRlcCb,cfg->ueId, cfg->cellId,\
292 entCfg, entCfgCfm) != ROK)
294 DU_LOG("\nERROR --> RLC_DL : ReCfg Failed due to[%d]",
295 entCfgCfm->status.reason);
303 if (entCfg->dir & RLC_DIR_DL)
305 /* Delete the existing RB entity configuration */
306 if (rlcCfgDelDlRb(tRlcCb,cfg->ueId, cfg->cellId,\
307 entCfg, entCfgCfm) != ROK)
309 DU_LOG("\nERROR --> RLC_DL : Deletion Failed due to[%d]",
310 entCfgCfm->status.reason);
316 case CKW_CFG_REESTABLISH:
318 if (entCfg->dir & RLC_DIR_DL)
320 /*if direction is both then, re-establishment end indication
321 * should be sent only from the UL instance, only if DIR is
322 * DL only then DL instance will send indication.*/
323 Bool sndReEst = TRUE;
324 if (entCfg->dir & RLC_DIR_UL)
328 /* Re-establish the existing RB entity configuration */
329 if (rlcCfgReEstDlRb(tRlcCb,cfg->ueId, cfg->cellId,
330 sndReEst,entCfg, entCfgCfm) != ROK)
332 DU_LOG("\nERROR --> RLC_DL : Reest Failed due to[%d]",
333 entCfgCfm->status.reason);
339 case CKW_CFG_DELETE_UE:
341 /* Delete all RB entity configuration under UE */
342 if (rlcCfgDelDlUe(tRlcCb,cfg->ueId, cfg->cellId,
343 entCfg, entCfgCfm) != ROK)
345 DU_LOG("\nERROR --> RLC_DL : deletion Failed due to[%d]",
346 entCfgCfm->status.reason);
350 DU_LOG("\nDEBUG --> RLC_DL: UE information is deleted for UEId[%d] and CellId[%d]",\
351 cfg->ueId, cfg->cellId);
355 case CKW_CFG_DELETE_CELL:
357 if (rlcCfgDelDlCell(tRlcCb,cfg->cellId,entCfg,entCfgCfm)
360 DU_LOG("\nERROR --> RLC_DL : deletion Failed due to[%d]",
361 entCfgCfm->status.reason);
368 RLC_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType,\
369 CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_CFG);
370 DU_LOG("\nERROR --> RLC_DL : Invalid CfgType");
375 /* Assign number of entity configuraitons and suId */
376 cfgCfm->transId = cfg->transId;
377 cfgCfm->ueId = cfg->ueId;
378 cfgCfm->cellId = cfg->cellId;
379 cfgCfm->numEnt = cfg->numEnt;
381 /* kw002.201 Freeing from proper region */
382 /* RLC_PST_FREE(pst->region, pst->pool, cfg, sizeof(RlcCfgInfo)); */
383 /* Send Configuration confirm primitive */
384 rlcDlUdxCfgCfm(&(tRlcCb->u.dlCb->udxDlSap[spId].pst),
385 tRlcCb->u.dlCb->udxDlSap[spId].suId,
393 * This primitive is used by RRC to change the UeId for the existing UE
396 * @param pst - Pointer to the pst structure
397 * @param spId - The ID of the service provider SAP in the RLC layer
398 * @param transId - Transaction ID. This field uniquily identifies
399 * transaction between RRC and RLC
400 * @param ueInfo - Old UE Id Info for which the change request has come
401 * @param newUeInfo - New UE Id Info for existing UE context
407 S16 rlcDlUdxUeIdChgReq
419 #if (ERRCLASS & ERRCLS_INT_PAR)
420 if (pst->dstInst >= MAX_RLC_INSTANCES)
426 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
428 RLCDBGP_BRIEF(tRlcCb, "(spId(%d), transId(%ld))\n",
431 RLCDBGP_BRIEF(tRlcCb, "(spId(%d), transId(%d))\n",
435 status.reason = CKW_CFG_REAS_NONE;
436 status.status = CKW_CFG_CFM_OK;
438 if (rlcCfgDlUeIdChng(tRlcCb, ueInfo, newUeInfo, &status) != ROK)
440 DU_LOG("\nERROR --> RLC_DL : Failure due to[%d]",
443 rlcDlUdxUeIdChgCfm(&(tRlcCb->u.dlCb->udxDlSap[spId].pst),
444 tRlcCb->u.dlCb->udxDlSap[spId].suId,
453 * Request for status PDU from ULM to DLM.
455 * @param[in] pst - Post Structure
456 * @param[in] spId - Service Provider Id
457 * @param[in] rlcId - Rlc Information Id
458 * @param[in] pStaPdu - Status PDU
464 S16 rlcDlUdxStaPduReq
469 RlcUdxDlStaPdu *pStaPdu
475 tRlcCb = RLC_GET_RLCCB (pst->dstInst);
477 rlcDbmFetchDlRbCbByRbId(tRlcCb, rlcId, &rbCb); /* Fetch DBM RbCb */
480 DU_LOG("\nERROR --> RLC_DL : CellId [%u]:RbId[%d] not found",
481 rlcId->cellId,rlcId->rbId);
482 RLC_FREE_SHRABL_BUF(pst->region,
485 sizeof(RlcUdxDlStaPdu));
489 RLC_AMDL.cntrlBo = pStaPdu->controlBo;
490 /* If there already exists a STAUS PDU, free it and take the new one
494 RLC_FREE_SHRABL_BUF(pst->region,
497 sizeof(RlcUdxDlStaPdu));
500 RLC_AMDL.pStaPdu = pStaPdu;
501 rlcAmmSendDedLcBoStatus(tRlcCb, rbCb, &RLC_AMDL);
508 * It handles the status update recieved from ULM.
510 * @param[in] pst - Post Structure
511 * @param[in] spId - Service Provider Id
512 * @param[in] rlcId - Rlc Information Id
513 * @param[in] pStaPdu - Status PDU
519 S16 rlcDlUdxStaUpdReq
524 RlcUdxStaPdu *pStaPdu
530 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
532 rlcDbmFetchDlRbCbByRbId(tRlcCb, rlcId, &rbCb);
535 DU_LOG("\nERROR --> RLC_DL : CellId [%u]:RbId[%d] not found",
536 rlcId->cellId,rlcId->rbId);
540 rlcAmmDlHndlStatusPdu(tRlcCb, rbCb, pStaPdu);
542 RLC_FREE_SHRABL_BUF(pst->region,
545 sizeof(RlcUdxStaPdu));
553 S16 rlcDlUdxL2MeasReq
556 RlcL2MeasReqEvt *measReqEvt
561 volatile uint32_t startTime = 0;
565 SStartTask(&startTime, PID_RLC_MEAS_START);
567 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
569 /* Initialize measCfmEvt */
571 /* validate the received measReqEvt */
572 /*LTE_L2_MEAS_PHASE2*/
574 measType = measReqEvt->measReq.measType;
576 if(measType & LKW_L2MEAS_DL_IP)
578 /* if measurement is for DL IP enable for all QCI */
579 for(cntr = 0; cntr < LKW_MAX_QCI; cntr++)
581 tRlcCb->u.dlCb->rlcL2Cb.measOn[cntr] |= LKW_L2MEAS_DL_IP;
586 /* for nonIpThroughput meas, enable only for the sent QCIs */
588 for(i = 0; i < LKW_MAX_QCI; i++)
590 tRlcCb->u.dlCb->rlcL2Cb.measOn[i] |= measType;
594 /* We need to copy the transId for sending back confirms later */
595 for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
597 RlcL2MeasEvtCb* measEvtCb = &(tRlcCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr]);
598 if(measEvtCb->measCb.measType & measType)
600 measEvtCb->transId= measReqEvt->transId;
605 SStopTask(startTime, PID_RLC_MEAS_START);
607 } /* rlcDlUdxMeasReq */
611 This function processes L2 Measurement stop request received from the layer manager.
612 After receving this request, RLC stops L2 Measurement
613 * @param[in] pst post structure
614 * @param[in] measType meas Type
617 * -# Failure : RFAILED
620 S16 rlcDlUdxL2MeasStopReq
627 RlcL2MeasEvtCb *measEvtCb = NULLP;
629 uint8_t status = ROK;
630 /* RlcL2MeasCfmEvt measCfmEvt; */
631 volatile uint32_t startTime = 0;
635 SStartTask(&startTime, PID_RLC_MEAS_STOP);
637 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
638 /* memset(&measCfmEvt, 0, sizeof(RlcL2MeasCfmEvt)); */
639 /* reset the counters for the measurement type passed */
640 for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
642 measEvtCb = &(tRlcCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr]);
643 if(measEvtCb->measCb.measType & measType)
645 rlcUtlResetDlL2MeasInRlcRb(tRlcCb, &measEvtCb->measCb, measType);
650 /* switch off the measurements for the type passed */
651 for(cntr = 0; cntr < LKW_MAX_QCI; cntr++)
653 tRlcCb->u.dlCb->rlcL2Cb.measOn[cntr] &= ~measType;
656 status = LCM_PRIM_OK;
657 /* Stop confirm is removed as UL thread is already sending it */
660 SStopTask(startTime, PID_RLC_MEAS_STOP);
666 This function processes L2 Measurement Send request received from the layer manager.
667 After receving this request, RLC sends L2 Measurement
668 * @param[in] pst post structure
669 * @param[in] measType meas Type
672 * -# Failure : RFAILED
675 S16 rlcDlUdxL2MeasSendReq
681 RlcL2MeasEvtCb *measEvtCb;
683 volatile uint32_t startTime = 0;
686 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
687 for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
689 measEvtCb = &(tRlcCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr]);
690 if(measEvtCb->measCb.measType & measType)
693 SStartTask(&startTime, PID_RLC_MEAS_REPORT);
695 rlcUtlSndDlL2MeasCfm(tRlcCb, measEvtCb);
698 SStopTask(startTime, PID_RLC_MEAS_REPORT);
704 #endif /* LTE_L2_MEAS */
708 #endif /* __cplusplus */
711 /**********************************************************************
713 **********************************************************************/