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 FILL_PST_RLC_TO_DUAPP(rspPst, RLC_UL_INST, EVENT_RLC_UL_UE_CREATE_RSP);
286 SendRlcUlUeCreateRspToDu(&rspPst, cfgCfm);
288 /* free the memory from DL */
289 RLC_FREE_SHRABL_BUF(pst->region,
292 sizeof(RlcCfgCfmInfo));
294 /* free the cfgInfo that came from LM */
295 RLC_PST_FREE(pst->region, pst->pool, cfgTmpData->cfgInfo, sizeof(RlcCfgInfo));
296 RLC_FREE(tRlcCb,cfgTmpData,sizeof(RlcUlCfgTmpData));
303 * Handler for UeId change confirm
306 * This function handles the UeId Change Confirm from DL Instance
308 * @param[in] pst Post structure
309 * @param[in] suId Service User ID
310 * @param[in] transId Transaction Id
311 * @param[in] status Status of confirmation
318 S16 rlcUlUdxUeIdChgCfm
326 S16 rlcUlUdxUeIdChgCfm (pst, suId, cfmInfo)
334 RlcUlCfgTmpData *cfgTmpData;
336 #if (ERRCLASS & ERRCLS_INT_PAR)
337 if (pst->dstInst >= MAX_RLC_INSTANCES)
342 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
344 RLCDBGP_BRIEF(tRlcCb, " suId(%d) \n", suId);
346 #if (ERRCLASS & ERRCLS_INT_PAR)
349 RLOG0(L_ERROR, "Invalid suId");
352 #endif /* ERRCLASS & ERRCLS_INT_PAR */
354 if(ROK != rlcDbmFindUlTransaction(tRlcCb, transId, &cfgTmpData))
356 RLOG0(L_ERROR, "Invalid transId");
360 if(ROK != rlcDbmDelUlTransaction(tRlcCb, cfgTmpData))
365 if(status.status == CKW_CFG_CFM_OK)
367 if(cfgTmpData->ueCb != NULLP)
369 rlcCfgApplyUlUeIdChng(tRlcCb, cfgTmpData->ueInfo, cfgTmpData->newUeInfo, cfgTmpData);
372 RlcUiCkwUeIdChgCfm(&(tRlcCb->u.ulCb->ckwSap.pst),
373 tRlcCb->u.ulCb->ckwSap.suId,
374 transId,cfgTmpData->ueInfo,status);
375 /* only newUeInfo needs to be freed here, ueInfo would be freed at the
376 interface or by he receipient in case of tight coupling */
377 RLC_PST_FREE(pst->region, pst->pool, cfgTmpData->newUeInfo, sizeof(CkwUeInfo));
378 RLC_FREE_WC(tRlcCb, cfgTmpData, sizeof (RlcUlCfgTmpData));
384 * Udx Status Prohibit Timer Start
386 * @param[in] pst Post structure
387 * @param[in] suId Service User ID
388 * @param[in] rlcId rlc Id
393 S16 rlcUlUdxStaProhTmrStart
400 RlcCb *tRlcCb= NULLP;
403 #if (ERRCLASS & ERRCLS_INT_PAR)
404 if (pst->dstInst >= MAX_RLC_INSTANCES)
409 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
411 rlcDbmFetchUlRbCbByRbId(tRlcCb, rlcId, &rbCb);
414 RLOG_ARG2(L_ERROR, DBG_UEID,rlcId->ueId, "CellId [%u]:RbId[%d] not found",
415 rlcId->cellId,rlcId->rbId);
419 /* Start staProhTmr */
420 rlcStartTmr(tRlcCb,(PTR)rbCb, RLC_EVT_AMUL_STA_PROH_TMR);
427 * Handler for configuration confirm from DL.
429 * @param[in] gCb - RLC Instance Control Block
430 * @param[in] cfgTmpData - Configuration Temporary Data
431 * @param[in] cfmInfo - DL Configuration Confirm Info
432 * @param[out] cfgCfm - Configuration Confirm to be sent to RRC
439 S16 rlcHdlCrlcUlCfgReq
442 RlcUlCfgTmpData *cfgTmpData,
443 RlcCfgCfmInfo *cfmInfo,
444 RlcCfgCfmInfo *cfgCfm
447 S16 rlcHdlCrlcUlCfgReq(gCb,cfgTmpData,cfmInfo,cfmInfo)
449 RlcUlCfgTmpData *cfgTmpData;
450 RlcCfgCfmInfo *cfmInfo;
451 RlcCfgCfmInfo *cfgCfm;
458 cfg = cfgTmpData->cfgInfo;
459 maxEnt = (cfg->numEnt < CKW_MAX_ENT_CFG)? cfg->numEnt:CKW_MAX_ENT_CFG;
461 for (idx = 0; idx < maxEnt; idx++)
463 RlcEntCfgCfmInfo *entCfgCfm;
464 RlcEntCfgCfmInfo *entDlCfgCfm;
465 RlcEntCfgInfo *entCfg;
467 entCfg = &(cfg->entCfg[idx]);
468 entCfgCfm = &(cfgCfm->entCfgCfm[idx]);
469 entDlCfgCfm = &(cfmInfo->entCfgCfm[idx]);
470 switch (entCfg->cfgType)
476 if (entCfg->dir == RLC_DIR_UL)
478 RLC_MEM_CPY(entCfgCfm,
479 &cfgTmpData->cfgEntData[idx].entUlCfgCfm,
480 sizeof(RlcEntCfgCfmInfo));
482 else if (entCfg->dir == RLC_DIR_DL)
484 RLC_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(RlcEntCfgCfmInfo));
486 else if(entCfg->dir == RLC_DIR_BOTH)
488 if (entDlCfgCfm->status.status != CKW_CFG_CFM_OK)
490 rlcCfgRollBackUlRb(gCb,
493 &cfgTmpData->cfgEntData[idx]);
499 &cfgTmpData->cfgEntData[idx],
502 RLC_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(RlcEntCfgCfmInfo));
506 RLC_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType,
507 CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_DIR);
508 RLOG_ARG2(L_ERROR,DBG_UEID,cfg->ueId,"RBID[%d] direction[%d] is invalid",
509 entCfg->rbId,entCfg->dir);
514 case CKW_CFG_REESTABLISH:
516 if (entCfg->dir == RLC_DIR_UL)
518 RLC_MEM_CPY(entCfgCfm,
519 &cfgTmpData->cfgEntData[idx].entUlCfgCfm,
520 sizeof(RlcEntCfgCfmInfo));
522 else if (entCfg->dir == RLC_DIR_DL)
524 RLC_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(RlcEntCfgCfmInfo));
528 if (entCfg->dir & RLC_DIR_UL)
530 /* Reestablish indication is sent from UL Instance only*/
531 if (entDlCfgCfm->status.status == CKW_CFG_CFM_OK)
533 rlcCfgApplyReEstUlRb (gCb, cfg->ueId,
535 &cfgTmpData->cfgEntData[idx]);
537 RLC_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(RlcEntCfgCfmInfo));
542 case CKW_CFG_DELETE_UE:
544 if (cfgTmpData->cfgEntData[idx].entUlCfgCfm.status.status == CKW_CFG_CFM_OK)
546 rlcCfgApplyDelUlUe(gCb, cfgTmpData);
547 RLC_MEM_CPY(entCfgCfm,
548 &cfgTmpData->cfgEntData[idx].entUlCfgCfm,
549 sizeof(RlcEntCfgCfmInfo));
553 RLC_MEM_CPY(entCfgCfm, entDlCfgCfm,
554 sizeof(RlcEntCfgCfmInfo));
558 case CKW_CFG_DELETE_CELL:
560 if (cfgTmpData->cfgEntData[idx].entUlCfgCfm.status.status == CKW_CFG_CFM_OK)
562 rlcCfgApplyDelUlCell(gCb, cfgTmpData);
563 RLC_MEM_CPY(entCfgCfm,
564 &cfgTmpData->cfgEntData[idx].entUlCfgCfm,
565 sizeof(RlcEntCfgCfmInfo));
569 RLC_MEM_CPY(entCfgCfm, entDlCfgCfm,
570 sizeof(RlcEntCfgCfmInfo));
576 RLC_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType,
577 CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_CFG);
579 RLOG0(L_ERROR,"Invalid configuration type");
584 /* Assign number of entity configurations and suId */
585 cfgCfm->transId = cfgTmpData->uprLyrTransId;
586 cfgCfm->ueId = cfg->ueId;
587 cfgCfm->cellId = cfg->cellId;
588 cfgCfm->numEnt = cfg->numEnt;
594 #endif /* __cplusplus */
597 /**********************************************************************
599 **********************************************************************/