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 case CKW_CFG_DELETE_CELL:
356 if (rlcCfgDelDlCell(tRlcCb,cfg->cellId,entCfg,entCfgCfm)
359 DU_LOG("\nERROR --> RLC_DL : deletion Failed due to[%d]",
360 entCfgCfm->status.reason);
367 RLC_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType,\
368 CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_CFG);
369 DU_LOG("\nERROR --> RLC_DL : Invalid CfgType");
374 /* Assign number of entity configuraitons and suId */
375 cfgCfm->transId = cfg->transId;
376 cfgCfm->ueId = cfg->ueId;
377 cfgCfm->cellId = cfg->cellId;
378 cfgCfm->numEnt = cfg->numEnt;
380 /* kw002.201 Freeing from proper region */
381 /* RLC_PST_FREE(pst->region, pst->pool, cfg, sizeof(RlcCfgInfo)); */
382 /* Send Configuration confirm primitive */
383 rlcDlUdxCfgCfm(&(tRlcCb->u.dlCb->udxDlSap[spId].pst),
384 tRlcCb->u.dlCb->udxDlSap[spId].suId,
392 * This primitive is used by RRC to change the UeId for the existing UE
395 * @param pst - Pointer to the pst structure
396 * @param spId - The ID of the service provider SAP in the RLC layer
397 * @param transId - Transaction ID. This field uniquily identifies
398 * transaction between RRC and RLC
399 * @param ueInfo - Old UE Id Info for which the change request has come
400 * @param newUeInfo - New UE Id Info for existing UE context
406 S16 rlcDlUdxUeIdChgReq
418 #if (ERRCLASS & ERRCLS_INT_PAR)
419 if (pst->dstInst >= MAX_RLC_INSTANCES)
425 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
427 RLCDBGP_BRIEF(tRlcCb, "(spId(%d), transId(%ld))\n",
430 RLCDBGP_BRIEF(tRlcCb, "(spId(%d), transId(%d))\n",
434 status.reason = CKW_CFG_REAS_NONE;
435 status.status = CKW_CFG_CFM_OK;
437 if (rlcCfgDlUeIdChng(tRlcCb, ueInfo, newUeInfo, &status) != ROK)
439 DU_LOG("\nERROR --> RLC_DL : Failure due to[%d]",
442 rlcDlUdxUeIdChgCfm(&(tRlcCb->u.dlCb->udxDlSap[spId].pst),
443 tRlcCb->u.dlCb->udxDlSap[spId].suId,
452 * Request for status PDU from ULM to DLM.
454 * @param[in] pst - Post Structure
455 * @param[in] spId - Service Provider Id
456 * @param[in] rlcId - Rlc Information Id
457 * @param[in] pStaPdu - Status PDU
463 S16 rlcDlUdxStaPduReq
468 RlcUdxDlStaPdu *pStaPdu
474 tRlcCb = RLC_GET_RLCCB (pst->dstInst);
476 rlcDbmFetchDlRbCbByRbId(tRlcCb, rlcId, &rbCb); /* Fetch DBM RbCb */
479 DU_LOG("\nERROR --> RLC_DL : CellId [%u]:RbId[%d] not found",
480 rlcId->cellId,rlcId->rbId);
481 RLC_FREE_SHRABL_BUF(pst->region,
484 sizeof(RlcUdxDlStaPdu));
488 RLC_AMDL.cntrlBo = pStaPdu->controlBo;
489 /* If there already exists a STAUS PDU, free it and take the new one
493 RLC_FREE_SHRABL_BUF(pst->region,
496 sizeof(RlcUdxDlStaPdu));
499 RLC_AMDL.pStaPdu = pStaPdu;
500 rlcAmmSendDedLcBoStatus(tRlcCb, rbCb, &RLC_AMDL);
507 * It handles the status update recieved from ULM.
509 * @param[in] pst - Post Structure
510 * @param[in] spId - Service Provider Id
511 * @param[in] rlcId - Rlc Information Id
512 * @param[in] pStaPdu - Status PDU
518 S16 rlcDlUdxStaUpdReq
523 RlcUdxStaPdu *pStaPdu
529 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
531 rlcDbmFetchDlRbCbByRbId(tRlcCb, rlcId, &rbCb);
534 DU_LOG("\nERROR --> RLC_DL : CellId [%u]:RbId[%d] not found",
535 rlcId->cellId,rlcId->rbId);
539 rlcAmmDlHndlStatusPdu(tRlcCb, rbCb, pStaPdu);
541 RLC_FREE_SHRABL_BUF(pst->region,
544 sizeof(RlcUdxStaPdu));
552 S16 rlcDlUdxL2MeasReq
555 RlcL2MeasReqEvt *measReqEvt
560 volatile uint32_t startTime = 0;
564 SStartTask(&startTime, PID_RLC_MEAS_START);
566 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
568 /* Initialize measCfmEvt */
570 /* validate the received measReqEvt */
571 /*LTE_L2_MEAS_PHASE2*/
573 measType = measReqEvt->measReq.measType;
575 if(measType & LKW_L2MEAS_DL_IP)
577 /* if measurement is for DL IP enable for all QCI */
578 for(cntr = 0; cntr < LKW_MAX_QCI; cntr++)
580 tRlcCb->u.dlCb->rlcL2Cb.measOn[cntr] |= LKW_L2MEAS_DL_IP;
585 /* for nonIpThroughput meas, enable only for the sent QCIs */
587 for(i = 0; i < LKW_MAX_QCI; i++)
589 tRlcCb->u.dlCb->rlcL2Cb.measOn[i] |= measType;
593 /* We need to copy the transId for sending back confirms later */
594 for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
596 RlcL2MeasEvtCb* measEvtCb = &(tRlcCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr]);
597 if(measEvtCb->measCb.measType & measType)
599 measEvtCb->transId= measReqEvt->transId;
604 SStopTask(startTime, PID_RLC_MEAS_START);
606 } /* rlcDlUdxMeasReq */
610 This function processes L2 Measurement stop request received from the layer manager.
611 After receving this request, RLC stops L2 Measurement
612 * @param[in] pst post structure
613 * @param[in] measType meas Type
616 * -# Failure : RFAILED
619 S16 rlcDlUdxL2MeasStopReq
626 RlcL2MeasEvtCb *measEvtCb = NULLP;
628 uint8_t status = ROK;
629 /* RlcL2MeasCfmEvt measCfmEvt; */
630 volatile uint32_t startTime = 0;
634 SStartTask(&startTime, PID_RLC_MEAS_STOP);
636 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
637 /* memset(&measCfmEvt, 0, sizeof(RlcL2MeasCfmEvt)); */
638 /* reset the counters for the measurement type passed */
639 for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
641 measEvtCb = &(tRlcCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr]);
642 if(measEvtCb->measCb.measType & measType)
644 rlcUtlResetDlL2MeasInRlcRb(tRlcCb, &measEvtCb->measCb, measType);
649 /* switch off the measurements for the type passed */
650 for(cntr = 0; cntr < LKW_MAX_QCI; cntr++)
652 tRlcCb->u.dlCb->rlcL2Cb.measOn[cntr] &= ~measType;
655 status = LCM_PRIM_OK;
656 /* Stop confirm is removed as UL thread is already sending it */
659 SStopTask(startTime, PID_RLC_MEAS_STOP);
665 This function processes L2 Measurement Send request received from the layer manager.
666 After receving this request, RLC sends L2 Measurement
667 * @param[in] pst post structure
668 * @param[in] measType meas Type
671 * -# Failure : RFAILED
674 S16 rlcDlUdxL2MeasSendReq
680 RlcL2MeasEvtCb *measEvtCb;
682 volatile uint32_t startTime = 0;
685 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
686 for(cntr = 0; cntr < LKW_MAX_L2MEAS; cntr++)
688 measEvtCb = &(tRlcCb->u.dlCb->rlcL2Cb.rlcL2EvtCb[cntr]);
689 if(measEvtCb->measCb.measType & measType)
692 SStartTask(&startTime, PID_RLC_MEAS_REPORT);
694 rlcUtlSndDlL2MeasCfm(tRlcCb, measEvtCb);
697 SStopTask(startTime, PID_RLC_MEAS_REPORT);
703 #endif /* LTE_L2_MEAS */
707 #endif /* __cplusplus */
710 /**********************************************************************
712 **********************************************************************/