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 */
64 #include "du_app_rlc_inf.h"
67 #define KW_MODULE KW_DBGMASK_UDX
72 /* forward references */
74 /* public variable declarations */
75 EXTERN S16 kwHdlCrlcUlCfgReq 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
100 PUBLIC S16 rlcUlUdxBndCfm
107 PUBLIC S16 rlcUlUdxBndCfm (pst, suId, status)
115 KwUdxUlSapCb *udxSap; /* RGU SAP Control Block */
120 #if (ERRCLASS & ERRCLS_INT_PAR)
121 if (pst->dstInst >= MAX_RLC_INSTANCES)
126 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
128 KWDBGP_BRIEF(tRlcCb, "rlcUlUdxBndCfm(post, suId(%d), status(%d)\n",
131 #if (ERRCLASS & ERRCLS_INT_PAR)
132 if (tRlcCb->init.cfgDone != TRUE)
134 RLOG0(L_FATAL, "General configuration not done");
135 KW_SEND_SAPID_ALARM(tRlcCb,suId,
136 LKW_EVENT_LI_BND_CFM, LCM_CAUSE_INV_STATE);
143 RLOG0(L_ERROR, "Invalid suId");
144 KW_SEND_SAPID_ALARM(tRlcCb,suId,
145 LKW_EVENT_LI_BND_CFM, LCM_CAUSE_INV_SUID);
149 #endif /* ERRCLASS & ERRCLS_INT_PAR */
151 udxSap = tRlcCb->u.ulCb->udxUlSap + suId;
153 KWDBGP_DETAIL(tRlcCb, "KwLiRguBndCfm: For RGU SAP state=%d\n",
156 /* Check rguSap state */
157 switch (udxSap->state)
161 if(TRUE == kwChkTmr(tRlcCb,(PTR)udxSap,KW_EVT_WAIT_BNDCFM))
163 kwStopTmr (tRlcCb,(PTR)udxSap, KW_EVT_WAIT_BNDCFM);
165 udxSap->retryCnt = 0;
167 if (status == CM_BND_OK)
169 udxSap->state = KW_SAP_BND;
170 event = LCM_EVENT_BND_OK;
171 cause = LKW_CAUSE_SAP_BNDENB;
175 udxSap->state = KW_SAP_CFG;
176 event = LCM_EVENT_BND_FAIL;
177 cause = LKW_CAUSE_UNKNOWN;
183 event = LKW_EVENT_RGU_BND_CFM;
184 cause = LCM_CAUSE_INV_STATE;
187 /* Send an alarm with proper event and cause */
188 KW_SEND_SAPID_ALARM(tRlcCb,suId, event, cause);
195 * Handles UDX Configuration Confirm
198 * This function handles the UDX configuration Confirm from DL Instance
200 * @param[in] pst Post structure
201 * @param[in] suId Service User ID
202 * @param[in] cfmInfo Confirm Information
209 PUBLIC S16 rlcUlUdxCfgCfm
213 RlcCfgCfmInfo *cfmInfo
216 PUBLIC S16 rlcUlUdxCfgCfm (pst, suId, cfmInfo)
219 RlcCfgCfmInfo *cfmInfo;
223 RlcCfgCfmInfo *cfgCfm;
224 RlcUlCfgTmpData *cfgTmpData;
226 memset(&rspPst, 0, sizeof(Pst));
230 #if (ERRCLASS & ERRCLS_INT_PAR)
231 if (pst->dstInst >= MAX_RLC_INSTANCES)
233 RLC_FREE_SHRABL_BUF(pst->region,
236 sizeof(RlcCfgCfmInfo));
240 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
241 KWDBGP_BRIEF(tRlcCb, " suId(%d)\n", suId);
243 #if (ERRCLASS & ERRCLS_INT_PAR)
246 RLOG0(L_ERROR, "Invalid suId");
247 KW_SEND_SAPID_ALARM(tRlcCb,suId,
248 LKW_EVENT_LI_BND_CFM, LCM_CAUSE_INV_SUID);
249 RLC_FREE_SHRABL_BUF(pst->region,
252 sizeof(RlcCfgCfmInfo));
255 #endif /* ERRCLASS & ERRCLS_INT_PAR */
257 if(ROK != kwDbmFindUlTransaction(tRlcCb,cfmInfo->transId, &cfgTmpData))
259 RLOG0(L_ERROR, "Invalid transId");
260 RLC_FREE_SHRABL_BUF(pst->region,
263 sizeof(RlcCfgCfmInfo));
267 if(ROK != kwDbmDelUlTransaction(tRlcCb, cfgTmpData))
269 RLC_FREE_SHRABL_BUF(pst->region,
272 sizeof(RlcCfgCfmInfo));
275 /* Allocate memory and memset to 0 for cfmInfo */
276 RLC_ALLOC(tRlcCb,cfgCfm, sizeof(RlcCfgCfmInfo));
277 #if (ERRCLASS & ERRCLS_ADD_RES)
280 RLOG0(L_FATAL, "Memory Allocation failed.");
281 RLC_FREE_SHRABL_BUF(pst->region,
284 sizeof(RlcCfgCfmInfo));
287 #endif /* ERRCLASS & ERRCLS_ADD_RES */
288 kwHdlCrlcUlCfgReq(tRlcCb,cfgTmpData, cfmInfo, cfgCfm);
289 FILL_PST_RLC_TO_DUAPP(rspPst, tRlcCb->genCfg.lmPst.dstProcId, RLC_UL_INST, EVENT_RLC_UL_UE_CREATE_RSP);
290 SendRlcUlUeCreateRspToDu(&rspPst, cfgCfm);
292 /* free the memory from DL */
293 RLC_FREE_SHRABL_BUF(pst->region,
296 sizeof(RlcCfgCfmInfo));
298 /* free the cfgInfo that came from LM */
299 RLC_PST_FREE(pst->region, pst->pool, cfgTmpData->cfgInfo, sizeof(RlcCfgInfo));
300 RLC_FREE(tRlcCb,cfgTmpData,sizeof(RlcUlCfgTmpData));
307 * Handler for UeId change confirm
310 * This function handles the UeId Change Confirm from DL Instance
312 * @param[in] pst Post structure
313 * @param[in] suId Service User ID
314 * @param[in] transId Transaction Id
315 * @param[in] status Status of confirmation
322 PUBLIC S16 rlcUlUdxUeIdChgCfm
330 PUBLIC S16 rlcUlUdxUeIdChgCfm (pst, suId, cfmInfo)
338 RlcUlCfgTmpData *cfgTmpData;
340 TRC3(rlcUlUdxUeIdChgCfm)
342 #if (ERRCLASS & ERRCLS_INT_PAR)
343 if (pst->dstInst >= MAX_RLC_INSTANCES)
348 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
350 KWDBGP_BRIEF(tRlcCb, " suId(%d) \n", suId);
352 #if (ERRCLASS & ERRCLS_INT_PAR)
355 RLOG0(L_ERROR, "Invalid suId");
358 #endif /* ERRCLASS & ERRCLS_INT_PAR */
360 if(ROK != kwDbmFindUlTransaction(tRlcCb, transId, &cfgTmpData))
362 RLOG0(L_ERROR, "Invalid transId");
366 if(ROK != kwDbmDelUlTransaction(tRlcCb, cfgTmpData))
371 if(status.status == CKW_CFG_CFM_OK)
373 if(cfgTmpData->ueCb != NULLP)
375 rlcCfgApplyUlUeIdChng(tRlcCb, cfgTmpData->ueInfo, cfgTmpData->newUeInfo, cfgTmpData);
378 KwUiCkwUeIdChgCfm(&(tRlcCb->u.ulCb->ckwSap.pst),
379 tRlcCb->u.ulCb->ckwSap.suId,
380 transId,cfgTmpData->ueInfo,status);
381 /* only newUeInfo needs to be freed here, ueInfo would be freed at the
382 interface or by he receipient in case of tight coupling */
383 RLC_PST_FREE(pst->region, pst->pool, cfgTmpData->newUeInfo, sizeof(CkwUeInfo));
384 RLC_FREE_WC(tRlcCb, cfgTmpData, sizeof (RlcUlCfgTmpData));
390 * Udx Status Prohibit Timer Start
392 * @param[in] pst Post structure
393 * @param[in] suId Service User ID
394 * @param[in] rlcId rlc Id
399 PUBLIC S16 rlcUlUdxStaProhTmrStart
406 RlcCb *tRlcCb= NULLP;
409 #if (ERRCLASS & ERRCLS_INT_PAR)
410 if (pst->dstInst >= MAX_RLC_INSTANCES)
415 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
417 kwDbmFetchUlRbCbByRbId(tRlcCb, rlcId, &rbCb);
420 RLOG_ARG2(L_ERROR, DBG_UEID,rlcId->ueId, "CellId [%u]:RbId[%d] not found",
421 rlcId->cellId,rlcId->rbId);
425 /* Start staProhTmr */
426 kwStartTmr(tRlcCb,(PTR)rbCb, KW_EVT_AMUL_STA_PROH_TMR);
433 * Handler for configuration confirm from DL.
435 * @param[in] gCb - RLC Instance Control Block
436 * @param[in] cfgTmpData - Configuration Temporary Data
437 * @param[in] cfmInfo - DL Configuration Confirm Info
438 * @param[out] cfgCfm - Configuration Confirm to be sent to RRC
445 PUBLIC S16 kwHdlCrlcUlCfgReq
448 RlcUlCfgTmpData *cfgTmpData,
449 RlcCfgCfmInfo *cfmInfo,
450 RlcCfgCfmInfo *cfgCfm
453 PUBLIC S16 kwHdlCrlcUlCfgReq(gCb,cfgTmpData,cfmInfo,cfmInfo)
455 RlcUlCfgTmpData *cfgTmpData;
456 RlcCfgCfmInfo *cfmInfo;
457 RlcCfgCfmInfo *cfgCfm;
464 cfg = cfgTmpData->cfgInfo;
465 maxEnt = (cfg->numEnt < CKW_MAX_ENT_CFG)? cfg->numEnt:CKW_MAX_ENT_CFG;
467 for (idx = 0; idx < maxEnt; idx++)
469 RlcEntCfgCfmInfo *entCfgCfm;
470 RlcEntCfgCfmInfo *entDlCfgCfm;
471 RlcEntCfgInfo *entCfg;
473 entCfg = &(cfg->entCfg[idx]);
474 entCfgCfm = &(cfgCfm->entCfgCfm[idx]);
475 entDlCfgCfm = &(cfmInfo->entCfgCfm[idx]);
476 switch (entCfg->cfgType)
482 if (entCfg->dir == KW_DIR_UL)
484 KW_MEM_CPY(entCfgCfm,
485 &cfgTmpData->cfgEntData[idx].entUlCfgCfm,
486 sizeof(RlcEntCfgCfmInfo));
488 else if (entCfg->dir == KW_DIR_DL)
490 KW_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(RlcEntCfgCfmInfo));
492 else if(entCfg->dir == KW_DIR_BOTH)
494 if (entDlCfgCfm->status.status != CKW_CFG_CFM_OK)
496 rlcCfgRollBackUlRb(gCb,
499 &cfgTmpData->cfgEntData[idx]);
505 &cfgTmpData->cfgEntData[idx],
508 KW_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(RlcEntCfgCfmInfo));
512 KW_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType,
513 CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_DIR);
514 RLOG_ARG2(L_ERROR,DBG_UEID,cfg->ueId,"RBID[%d] direction[%d] is invalid",
515 entCfg->rbId,entCfg->dir);
520 case CKW_CFG_REESTABLISH:
522 if (entCfg->dir == KW_DIR_UL)
524 KW_MEM_CPY(entCfgCfm,
525 &cfgTmpData->cfgEntData[idx].entUlCfgCfm,
526 sizeof(RlcEntCfgCfmInfo));
528 else if (entCfg->dir == KW_DIR_DL)
530 KW_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(RlcEntCfgCfmInfo));
534 if (entCfg->dir & KW_DIR_UL)
536 /* Reestablish indication is sent from UL Instance only*/
537 if (entDlCfgCfm->status.status == CKW_CFG_CFM_OK)
539 rlcCfgApplyReEstUlRb (gCb, cfg->ueId,
541 &cfgTmpData->cfgEntData[idx]);
543 KW_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(RlcEntCfgCfmInfo));
548 case CKW_CFG_DELETE_UE:
550 if (cfgTmpData->cfgEntData[idx].entUlCfgCfm.status.status == CKW_CFG_CFM_OK)
552 rlcCfgApplyDelUlUe(gCb, cfgTmpData);
553 KW_MEM_CPY(entCfgCfm,
554 &cfgTmpData->cfgEntData[idx].entUlCfgCfm,
555 sizeof(RlcEntCfgCfmInfo));
559 KW_MEM_CPY(entCfgCfm, entDlCfgCfm,
560 sizeof(RlcEntCfgCfmInfo));
564 case CKW_CFG_DELETE_CELL:
566 if (cfgTmpData->cfgEntData[idx].entUlCfgCfm.status.status == CKW_CFG_CFM_OK)
568 rlcCfgApplyDelUlCell(gCb, cfgTmpData);
569 KW_MEM_CPY(entCfgCfm,
570 &cfgTmpData->cfgEntData[idx].entUlCfgCfm,
571 sizeof(RlcEntCfgCfmInfo));
575 KW_MEM_CPY(entCfgCfm, entDlCfgCfm,
576 sizeof(RlcEntCfgCfmInfo));
582 KW_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType,
583 CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_CFG);
585 RLOG0(L_ERROR,"Invalid configuration type");
590 /* Assign number of entity configurations and suId */
591 cfgCfm->transId = cfgTmpData->uprLyrTransId;
592 cfgCfm->ueId = cfg->ueId;
593 cfgCfm->cellId = cfg->cellId;
594 cfgCfm->numEnt = cfg->numEnt;
600 #endif /* __cplusplus */
603 /**********************************************************************
605 **********************************************************************/