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=204;
35 @brief UDX Uplink Module
38 /* header include files (.h) */
39 #include "common_def.h"
40 #include "lkw.h" /* LKW defines */
41 #include "ckw.h" /* CKW defines */
42 #include "kwu.h" /* KWU defines */
43 #include "rgu.h" /* RGU defines */
44 #include "kw_err.h" /* Err defines */
45 #include "kw_env.h" /* RLC environment options */
47 #include "kw.h" /* RLC defines */
52 /* extern (.x) include files */
53 #include "lkw.x" /* LKW */
54 #include "ckw.x" /* CKW */
55 #include "kwu.x" /* KWU */
56 #include "rgu.x" /* RGU */
63 #include "du_app_rlc_inf.h"
65 #include "rlc_utils.h"
67 #define RLC_MODULE RLC_DBGMASK_UDX
72 /* forward references */
74 /* public variable declarations */
75 EXTERN S16 rlcHdlCrlcUlCfgReq ARGS((RlcCb *gCb,RlcUlCfgTmpData *cfgTmpData,
76 RlcCfgCfmInfo *cfmInfo, RlcCfgCfmInfo *cfgCfm));
84 * Handler for bind confirmation from DL.
87 * This function handles the bind confirmation received
90 * @param[in] pst Post structure
91 * @param[in] suId Service User ID
92 * @param[in] status Status of confirmation
107 S16 rlcUlUdxBndCfm (pst, suId, status)
115 RlcUdxUlSapCb *udxSap; /* RGU SAP Control Block */
118 #if (ERRCLASS & ERRCLS_INT_PAR)
119 if (pst->dstInst >= MAX_RLC_INSTANCES)
124 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
126 RLCDBGP_BRIEF(tRlcCb, "rlcUlUdxBndCfm(post, suId(%d), status(%d)\n",
129 #if (ERRCLASS & ERRCLS_INT_PAR)
130 if (tRlcCb->init.cfgDone != TRUE)
132 RLOG0(L_FATAL, "General configuration not done");
133 RLC_SEND_SAPID_ALARM(tRlcCb,suId,
134 LKW_EVENT_LI_BND_CFM, LCM_CAUSE_INV_STATE);
141 RLOG0(L_ERROR, "Invalid suId");
142 RLC_SEND_SAPID_ALARM(tRlcCb,suId,
143 LKW_EVENT_LI_BND_CFM, LCM_CAUSE_INV_SUID);
147 #endif /* ERRCLASS & ERRCLS_INT_PAR */
149 udxSap = tRlcCb->u.ulCb->udxUlSap + suId;
151 RLCDBGP_DETAIL(tRlcCb, "RlcLiRguBndCfm: For RGU SAP state=%d\n",
154 /* Check rguSap state */
155 switch (udxSap->state)
157 case RLC_SAP_BINDING:
159 if(TRUE == rlcChkTmr(tRlcCb,(PTR)udxSap,RLC_EVT_WAIT_BNDCFM))
161 rlcStopTmr (tRlcCb,(PTR)udxSap, RLC_EVT_WAIT_BNDCFM);
163 udxSap->retryCnt = 0;
165 if (status == CM_BND_OK)
167 udxSap->state = RLC_SAP_BND;
168 event = LCM_EVENT_BND_OK;
169 cause = LKW_CAUSE_SAP_BNDENB;
173 udxSap->state = RLC_SAP_CFG;
174 event = LCM_EVENT_BND_FAIL;
175 cause = LKW_CAUSE_UNKNOWN;
181 event = LKW_EVENT_RGU_BND_CFM;
182 cause = LCM_CAUSE_INV_STATE;
185 /* Send an alarm with proper event and cause */
186 RLC_SEND_SAPID_ALARM(tRlcCb,suId, event, cause);
193 * Handles UDX Configuration Confirm
196 * This function handles the UDX configuration Confirm from DL Instance
198 * @param[in] pst Post structure
199 * @param[in] suId Service User ID
200 * @param[in] cfmInfo Confirm Information
211 RlcCfgCfmInfo *cfmInfo
214 S16 rlcUlUdxCfgCfm (pst, suId, cfmInfo)
217 RlcCfgCfmInfo *cfmInfo;
221 RlcCfgCfmInfo *cfgCfm;
222 RlcUlCfgTmpData *cfgTmpData;
224 memset(&rspPst, 0, sizeof(Pst));
226 #if (ERRCLASS & ERRCLS_INT_PAR)
227 if (pst->dstInst >= MAX_RLC_INSTANCES)
229 RLC_FREE_SHRABL_BUF(pst->region,
232 sizeof(RlcCfgCfmInfo));
236 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
237 RLCDBGP_BRIEF(tRlcCb, " suId(%d)\n", suId);
239 #if (ERRCLASS & ERRCLS_INT_PAR)
242 RLOG0(L_ERROR, "Invalid suId");
243 RLC_SEND_SAPID_ALARM(tRlcCb,suId,
244 LKW_EVENT_LI_BND_CFM, LCM_CAUSE_INV_SUID);
245 RLC_FREE_SHRABL_BUF(pst->region,
248 sizeof(RlcCfgCfmInfo));
251 #endif /* ERRCLASS & ERRCLS_INT_PAR */
253 if(ROK != rlcDbmFindUlTransaction(tRlcCb,cfmInfo->transId, &cfgTmpData))
255 RLOG0(L_ERROR, "Invalid transId");
256 RLC_FREE_SHRABL_BUF(pst->region,
259 sizeof(RlcCfgCfmInfo));
263 if(ROK != rlcDbmDelUlTransaction(tRlcCb, cfgTmpData))
265 RLC_FREE_SHRABL_BUF(pst->region,
268 sizeof(RlcCfgCfmInfo));
271 /* Allocate memory and memset to 0 for cfmInfo */
272 RLC_ALLOC(tRlcCb,cfgCfm, sizeof(RlcCfgCfmInfo));
273 #if (ERRCLASS & ERRCLS_ADD_RES)
276 RLOG0(L_FATAL, "Memory Allocation failed.");
277 RLC_FREE_SHRABL_BUF(pst->region,
280 sizeof(RlcCfgCfmInfo));
283 #endif /* ERRCLASS & ERRCLS_ADD_RES */
284 rlcHdlCrlcUlCfgReq(tRlcCb,cfgTmpData, cfmInfo, cfgCfm);
285 if(tRlcCb->u.ulCb->rlcUlUdxEventType == EVENT_RLC_UE_CONFIG_REQ)
287 FILL_PST_RLC_TO_DUAPP(rspPst, RLC_UL_INST, EVENT_RLC_UE_CONFIG_RSP);
289 else if(tRlcCb->u.ulCb->rlcUlUdxEventType == EVENT_RLC_UE_RECONFIG_REQ)
291 FILL_PST_RLC_TO_DUAPP(rspPst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_RSP);
293 SendRlcUeRspToDu(&rspPst, cfgCfm);
295 /* free the memory from DL */
296 RLC_FREE_SHRABL_BUF(pst->region,
299 sizeof(RlcCfgCfmInfo));
301 /* free the cfgInfo that came from LM */
302 RLC_PST_FREE(pst->region, pst->pool, cfgTmpData->cfgInfo, sizeof(RlcCfgInfo));
303 RLC_FREE(tRlcCb,cfgTmpData,sizeof(RlcUlCfgTmpData));
310 * Handler for UeId change confirm
313 * This function handles the UeId Change Confirm from DL Instance
315 * @param[in] pst Post structure
316 * @param[in] suId Service User ID
317 * @param[in] transId Transaction Id
318 * @param[in] status Status of confirmation
325 S16 rlcUlUdxUeIdChgCfm
333 S16 rlcUlUdxUeIdChgCfm (pst, suId, cfmInfo)
341 RlcUlCfgTmpData *cfgTmpData;
343 #if (ERRCLASS & ERRCLS_INT_PAR)
344 if (pst->dstInst >= MAX_RLC_INSTANCES)
349 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
351 RLCDBGP_BRIEF(tRlcCb, " suId(%d) \n", suId);
353 #if (ERRCLASS & ERRCLS_INT_PAR)
356 RLOG0(L_ERROR, "Invalid suId");
359 #endif /* ERRCLASS & ERRCLS_INT_PAR */
361 if(ROK != rlcDbmFindUlTransaction(tRlcCb, transId, &cfgTmpData))
363 RLOG0(L_ERROR, "Invalid transId");
367 if(ROK != rlcDbmDelUlTransaction(tRlcCb, cfgTmpData))
372 if(status.status == CKW_CFG_CFM_OK)
374 if(cfgTmpData->ueCb != NULLP)
376 rlcCfgApplyUlUeIdChng(tRlcCb, cfgTmpData->ueInfo, cfgTmpData->newUeInfo, cfgTmpData);
379 RlcUiCkwUeIdChgCfm(&(tRlcCb->u.ulCb->ckwSap.pst),
380 tRlcCb->u.ulCb->ckwSap.suId,
381 transId,cfgTmpData->ueInfo,status);
382 /* only newUeInfo needs to be freed here, ueInfo would be freed at the
383 interface or by he receipient in case of tight coupling */
384 RLC_PST_FREE(pst->region, pst->pool, cfgTmpData->newUeInfo, sizeof(CkwUeInfo));
385 RLC_FREE_WC(tRlcCb, cfgTmpData, sizeof (RlcUlCfgTmpData));
391 * Udx Status Prohibit Timer Start
393 * @param[in] pst Post structure
394 * @param[in] suId Service User ID
395 * @param[in] rlcId rlc Id
400 S16 rlcUlUdxStaProhTmrStart
407 RlcCb *tRlcCb= NULLP;
410 #if (ERRCLASS & ERRCLS_INT_PAR)
411 if (pst->dstInst >= MAX_RLC_INSTANCES)
416 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
418 rlcDbmFetchUlRbCbByRbId(tRlcCb, rlcId, &rbCb);
421 RLOG_ARG2(L_ERROR, DBG_UEID,rlcId->ueId, "CellId [%u]:RbId[%d] not found",
422 rlcId->cellId,rlcId->rbId);
426 /* Start staProhTmr */
427 rlcStartTmr(tRlcCb,(PTR)rbCb, RLC_EVT_AMUL_STA_PROH_TMR);
434 * Handler for configuration confirm from DL.
436 * @param[in] gCb - RLC Instance Control Block
437 * @param[in] cfgTmpData - Configuration Temporary Data
438 * @param[in] cfmInfo - DL Configuration Confirm Info
439 * @param[out] cfgCfm - Configuration Confirm to be sent to RRC
446 S16 rlcHdlCrlcUlCfgReq
449 RlcUlCfgTmpData *cfgTmpData,
450 RlcCfgCfmInfo *cfmInfo,
451 RlcCfgCfmInfo *cfgCfm
454 S16 rlcHdlCrlcUlCfgReq(gCb,cfgTmpData,cfmInfo,cfmInfo)
456 RlcUlCfgTmpData *cfgTmpData;
457 RlcCfgCfmInfo *cfmInfo;
458 RlcCfgCfmInfo *cfgCfm;
465 cfg = cfgTmpData->cfgInfo;
466 maxEnt = (cfg->numEnt < CKW_MAX_ENT_CFG)? cfg->numEnt:CKW_MAX_ENT_CFG;
468 for (idx = 0; idx < maxEnt; idx++)
470 RlcEntCfgCfmInfo *entCfgCfm;
471 RlcEntCfgCfmInfo *entDlCfgCfm;
472 RlcEntCfgInfo *entCfg;
474 entCfg = &(cfg->entCfg[idx]);
475 entCfgCfm = &(cfgCfm->entCfgCfm[idx]);
476 entDlCfgCfm = &(cfmInfo->entCfgCfm[idx]);
477 switch (entCfg->cfgType)
483 if (entCfg->dir == RLC_DIR_UL)
485 RLC_MEM_CPY(entCfgCfm,
486 &cfgTmpData->cfgEntData[idx].entUlCfgCfm,
487 sizeof(RlcEntCfgCfmInfo));
489 else if (entCfg->dir == RLC_DIR_DL)
491 RLC_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(RlcEntCfgCfmInfo));
493 else if(entCfg->dir == RLC_DIR_BOTH)
495 if (entDlCfgCfm->status.status != CKW_CFG_CFM_OK)
497 rlcCfgRollBackUlRb(gCb,
500 &cfgTmpData->cfgEntData[idx]);
506 &cfgTmpData->cfgEntData[idx],
509 RLC_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(RlcEntCfgCfmInfo));
513 RLC_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType,
514 CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_DIR);
515 RLOG_ARG2(L_ERROR,DBG_UEID,cfg->ueId,"RBID[%d] direction[%d] is invalid",
516 entCfg->rbId,entCfg->dir);
521 case CKW_CFG_REESTABLISH:
523 if (entCfg->dir == RLC_DIR_UL)
525 RLC_MEM_CPY(entCfgCfm,
526 &cfgTmpData->cfgEntData[idx].entUlCfgCfm,
527 sizeof(RlcEntCfgCfmInfo));
529 else if (entCfg->dir == RLC_DIR_DL)
531 RLC_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(RlcEntCfgCfmInfo));
535 if (entCfg->dir & RLC_DIR_UL)
537 /* Reestablish indication is sent from UL Instance only*/
538 if (entDlCfgCfm->status.status == CKW_CFG_CFM_OK)
540 rlcCfgApplyReEstUlRb (gCb, cfg->ueId,
542 &cfgTmpData->cfgEntData[idx]);
544 RLC_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(RlcEntCfgCfmInfo));
549 case CKW_CFG_DELETE_UE:
551 if (cfgTmpData->cfgEntData[idx].entUlCfgCfm.status.status == CKW_CFG_CFM_OK)
553 rlcCfgApplyDelUlUe(gCb, cfgTmpData);
554 RLC_MEM_CPY(entCfgCfm,
555 &cfgTmpData->cfgEntData[idx].entUlCfgCfm,
556 sizeof(RlcEntCfgCfmInfo));
560 RLC_MEM_CPY(entCfgCfm, entDlCfgCfm,
561 sizeof(RlcEntCfgCfmInfo));
565 case CKW_CFG_DELETE_CELL:
567 if (cfgTmpData->cfgEntData[idx].entUlCfgCfm.status.status == CKW_CFG_CFM_OK)
569 rlcCfgApplyDelUlCell(gCb, cfgTmpData);
570 RLC_MEM_CPY(entCfgCfm,
571 &cfgTmpData->cfgEntData[idx].entUlCfgCfm,
572 sizeof(RlcEntCfgCfmInfo));
576 RLC_MEM_CPY(entCfgCfm, entDlCfgCfm,
577 sizeof(RlcEntCfgCfmInfo));
583 RLC_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType,
584 CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_CFG);
586 RLOG0(L_ERROR,"Invalid configuration type");
591 /* Assign number of entity configurations and suId */
592 cfgCfm->transId = cfgTmpData->uprLyrTransId;
593 cfgCfm->ueId = cfg->ueId;
594 cfgCfm->cellId = cfg->cellId;
595 cfgCfm->numEnt = cfg->numEnt;
601 #endif /* __cplusplus */
604 /**********************************************************************
606 **********************************************************************/