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 **********************************************************************/
32 @brief UDX Uplink Module
35 /* header include files (.h) */
36 #include "common_def.h"
37 #include "lkw.h" /* LKW defines */
38 #include "ckw.h" /* CKW defines */
39 #include "kwu.h" /* KWU defines */
40 #include "rgu.h" /* RGU defines */
41 #include "kw_err.h" /* Err defines */
42 #include "kw_env.h" /* RLC environment options */
44 #include "kw.h" /* RLC defines */
49 /* extern (.x) include files */
50 #include "lkw.x" /* LKW */
51 #include "ckw.x" /* CKW */
52 #include "kwu.x" /* KWU */
53 #include "rgu.x" /* RGU */
60 #include "du_app_rlc_inf.h"
62 #include "rlc_utils.h"
64 #define RLC_MODULE RLC_DBGMASK_UDX
69 /* forward references */
71 /* public variable declarations */
72 S16 rlcHdlCrlcUlCfgReq ARGS((RlcCb *gCb,RlcUlCfgTmpData *cfgTmpData,
73 RlcCfgCfmInfo *cfmInfo, RlcCfgCfmInfo *cfgCfm));
81 * Handler for bind confirmation from DL.
84 * This function handles the bind confirmation received
87 * @param[in] pst Post structure
88 * @param[in] suId Service User ID
89 * @param[in] status Status of confirmation
105 RlcUdxUlSapCb *udxSap; /* RGU SAP Control Block */
108 #if (ERRCLASS & ERRCLS_INT_PAR)
109 if (pst->dstInst >= MAX_RLC_INSTANCES)
114 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
116 RLCDBGP_BRIEF(tRlcCb, "rlcUlUdxBndCfm(post, suId(%d), status(%d)\n",
119 #if (ERRCLASS & ERRCLS_INT_PAR)
120 if (tRlcCb->init.cfgDone != TRUE)
122 DU_LOG("\nERROR --> RLC_UL : General configuration not done");
123 RLC_SEND_SAPID_ALARM(tRlcCb,suId,
124 LKW_EVENT_LI_BND_CFM, LCM_CAUSE_INV_STATE);
131 DU_LOG("\nERROR --> RLC_UL : Invalid suId");
132 RLC_SEND_SAPID_ALARM(tRlcCb,suId,
133 LKW_EVENT_LI_BND_CFM, LCM_CAUSE_INV_SUID);
137 #endif /* ERRCLASS & ERRCLS_INT_PAR */
139 udxSap = tRlcCb->u.ulCb->udxUlSap + suId;
141 RLCDBGP_DETAIL(tRlcCb, "RlcLiRguBndCfm: For RGU SAP state=%d\n",
144 /* Check rguSap state */
145 switch (udxSap->state)
147 case RLC_SAP_BINDING:
149 if(TRUE == rlcChkTmr(tRlcCb,(PTR)udxSap,EVENT_RLC_WAIT_BNDCFM))
151 rlcStopTmr (tRlcCb,(PTR)udxSap, EVENT_RLC_WAIT_BNDCFM);
153 udxSap->retryCnt = 0;
155 if (status == CM_BND_OK)
157 udxSap->state = RLC_SAP_BND;
158 event = LCM_EVENT_BND_OK;
159 cause = LKW_CAUSE_SAP_BNDENB;
163 udxSap->state = RLC_SAP_CFG;
164 event = LCM_EVENT_BND_FAIL;
165 cause = LKW_CAUSE_UNKNOWN;
171 event = LKW_EVENT_RGU_BND_CFM;
172 cause = LCM_CAUSE_INV_STATE;
175 /* Send an alarm with proper event and cause */
176 RLC_SEND_SAPID_ALARM(tRlcCb,suId, event, cause);
183 * Handles UDX Configuration Confirm
186 * This function handles the UDX configuration Confirm from DL Instance
188 * @param[in] pst Post structure
189 * @param[in] suId Service User ID
190 * @param[in] cfmInfo Confirm Information
200 RlcCfgCfmInfo *cfmInfo
204 RlcCfgCfmInfo *cfgCfm;
205 RlcUlCfgTmpData *cfgTmpData;
207 memset(&rspPst, 0, sizeof(Pst));
209 #if (ERRCLASS & ERRCLS_INT_PAR)
210 if (pst->dstInst >= MAX_RLC_INSTANCES)
212 RLC_FREE_SHRABL_BUF(pst->region,
215 sizeof(RlcCfgCfmInfo));
219 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
220 RLCDBGP_BRIEF(tRlcCb, " suId(%d)\n", suId);
222 #if (ERRCLASS & ERRCLS_INT_PAR)
225 DU_LOG("\nERROR --> RLC_UL : Invalid suId");
226 RLC_SEND_SAPID_ALARM(tRlcCb,suId,
227 LKW_EVENT_LI_BND_CFM, LCM_CAUSE_INV_SUID);
228 RLC_FREE_SHRABL_BUF(pst->region,
231 sizeof(RlcCfgCfmInfo));
234 #endif /* ERRCLASS & ERRCLS_INT_PAR */
236 if(ROK != rlcDbmFindUlTransaction(tRlcCb,cfmInfo->transId, &cfgTmpData))
238 DU_LOG("\nERROR --> RLC_UL : Invalid transId");
239 RLC_FREE_SHRABL_BUF(pst->region,
242 sizeof(RlcCfgCfmInfo));
246 if(ROK != rlcDbmDelUlTransaction(tRlcCb, cfgTmpData))
248 RLC_FREE_SHRABL_BUF(pst->region,
251 sizeof(RlcCfgCfmInfo));
254 /* Allocate memory and memset to 0 for cfmInfo */
255 RLC_ALLOC(tRlcCb,cfgCfm, sizeof(RlcCfgCfmInfo));
256 #if (ERRCLASS & ERRCLS_ADD_RES)
259 DU_LOG("\nERROR --> RLC_UL : Memory Allocation failed.");
260 RLC_FREE_SHRABL_BUF(pst->region,
263 sizeof(RlcCfgCfmInfo));
266 #endif /* ERRCLASS & ERRCLS_ADD_RES */
267 rlcHdlCrlcUlCfgReq(tRlcCb,cfgTmpData, cfmInfo, cfgCfm);
268 if(tRlcCb->u.ulCb->rlcUlUdxEventType == EVENT_RLC_UE_CREATE_REQ)
270 FILL_PST_RLC_TO_DUAPP(rspPst, RLC_UL_INST, EVENT_RLC_UE_CREATE_RSP);
272 else if(tRlcCb->u.ulCb->rlcUlUdxEventType == EVENT_RLC_UE_RECONFIG_REQ)
274 FILL_PST_RLC_TO_DUAPP(rspPst, RLC_UL_INST, EVENT_RLC_UE_RECONFIG_RSP);
276 SendRlcUeRspToDu(&rspPst, cfgCfm);
278 /* free the memory from DL */
279 RLC_FREE_SHRABL_BUF(pst->region,
282 sizeof(RlcCfgCfmInfo));
284 /* free the cfgInfo that came from LM */
285 RLC_PST_FREE(pst->region, pst->pool, cfgTmpData->cfgInfo, sizeof(RlcCfgInfo));
286 RLC_FREE(tRlcCb,cfgTmpData,sizeof(RlcUlCfgTmpData));
293 * Handler for UeId change confirm
296 * This function handles the UeId Change Confirm from DL Instance
298 * @param[in] pst Post structure
299 * @param[in] suId Service User ID
300 * @param[in] transId Transaction Id
301 * @param[in] status Status of confirmation
307 S16 rlcUlUdxUeIdChgCfm
316 RlcUlCfgTmpData *cfgTmpData;
318 #if (ERRCLASS & ERRCLS_INT_PAR)
319 if (pst->dstInst >= MAX_RLC_INSTANCES)
324 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
326 RLCDBGP_BRIEF(tRlcCb, " suId(%d) \n", suId);
328 #if (ERRCLASS & ERRCLS_INT_PAR)
331 DU_LOG("\nERROR --> RLC_UL : Invalid suId");
334 #endif /* ERRCLASS & ERRCLS_INT_PAR */
336 if(ROK != rlcDbmFindUlTransaction(tRlcCb, transId, &cfgTmpData))
338 DU_LOG("\nERROR --> RLC_UL : Invalid transId");
342 if(ROK != rlcDbmDelUlTransaction(tRlcCb, cfgTmpData))
347 if(status.status == CKW_CFG_CFM_OK)
349 if(cfgTmpData->ueCb != NULLP)
351 rlcCfgApplyUlUeIdChng(tRlcCb, cfgTmpData->ueInfo, cfgTmpData->newUeInfo, cfgTmpData);
354 RlcUiCkwUeIdChgCfm(&(tRlcCb->u.ulCb->ckwSap.pst),
355 tRlcCb->u.ulCb->ckwSap.suId,
356 transId,cfgTmpData->ueInfo,status);
357 /* only newUeInfo needs to be freed here, ueInfo would be freed at the
358 interface or by he receipient in case of tight coupling */
359 RLC_PST_FREE(pst->region, pst->pool, cfgTmpData->newUeInfo, sizeof(CkwUeInfo));
360 RLC_FREE(tRlcCb, cfgTmpData, sizeof (RlcUlCfgTmpData));
366 * Udx Status Prohibit Timer Start
368 * @param[in] pst Post structure
369 * @param[in] suId Service User ID
370 * @param[in] rlcId rlc Id
375 S16 rlcUlUdxStaProhTmrStart
382 RlcCb *tRlcCb= NULLP;
385 #if (ERRCLASS & ERRCLS_INT_PAR)
386 if (pst->dstInst >= MAX_RLC_INSTANCES)
391 tRlcCb = RLC_GET_RLCCB(pst->dstInst);
393 rlcDbmFetchUlRbCbByRbId(tRlcCb, rlcId, &rbCb);
396 DU_LOG("\nERROR --> RLC_UL : CellId [%u]:RbId[%d] not found",
397 rlcId->cellId,rlcId->rbId);
401 /* Start staProhTmr */
402 rlcStartTmr(tRlcCb,(PTR)rbCb, EVENT_RLC_AMUL_STA_PROH_TMR);
409 * Handler for configuration confirm from DL.
411 * @param[in] gCb - RLC Instance Control Block
412 * @param[in] cfgTmpData - Configuration Temporary Data
413 * @param[in] cfmInfo - DL Configuration Confirm Info
414 * @param[out] cfgCfm - Configuration Confirm to be sent to RRC
420 S16 rlcHdlCrlcUlCfgReq
423 RlcUlCfgTmpData *cfgTmpData,
424 RlcCfgCfmInfo *cfmInfo,
425 RlcCfgCfmInfo *cfgCfm
432 cfg = cfgTmpData->cfgInfo;
433 maxEnt = (cfg->numEnt < CKW_MAX_ENT_CFG)? cfg->numEnt:CKW_MAX_ENT_CFG;
435 for (idx = 0; idx < maxEnt; idx++)
437 RlcEntCfgCfmInfo *entCfgCfm;
438 RlcEntCfgCfmInfo *entDlCfgCfm;
439 RlcEntCfgInfo *entCfg;
441 entCfg = &(cfg->entCfg[idx]);
442 entCfgCfm = &(cfgCfm->entCfgCfm[idx]);
443 entDlCfgCfm = &(cfmInfo->entCfgCfm[idx]);
444 switch (entCfg->cfgType)
450 if (entCfg->dir == RLC_DIR_UL)
452 RLC_MEM_CPY(entCfgCfm,
453 &cfgTmpData->cfgEntData[idx].entUlCfgCfm,
454 sizeof(RlcEntCfgCfmInfo));
456 else if (entCfg->dir == RLC_DIR_DL)
458 RLC_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(RlcEntCfgCfmInfo));
460 else if(entCfg->dir == RLC_DIR_BOTH)
462 if (entDlCfgCfm->status.status != CKW_CFG_CFM_OK)
464 rlcCfgRollBackUlRb(gCb,
467 &cfgTmpData->cfgEntData[idx]);
473 &cfgTmpData->cfgEntData[idx],
476 RLC_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(RlcEntCfgCfmInfo));
480 RLC_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType,
481 CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_DIR);
482 DU_LOG("\nDEBUG --> RLC_UL : RBID[%d] direction[%d] is invalid",
483 entCfg->rbId,entCfg->dir);
488 case CKW_CFG_REESTABLISH:
490 if (entCfg->dir == RLC_DIR_UL)
492 RLC_MEM_CPY(entCfgCfm,
493 &cfgTmpData->cfgEntData[idx].entUlCfgCfm,
494 sizeof(RlcEntCfgCfmInfo));
496 else if (entCfg->dir == RLC_DIR_DL)
498 RLC_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(RlcEntCfgCfmInfo));
502 if (entCfg->dir & RLC_DIR_UL)
504 /* Reestablish indication is sent from UL Instance only*/
505 if (entDlCfgCfm->status.status == CKW_CFG_CFM_OK)
507 rlcCfgApplyReEstUlRb (gCb, cfg->ueId,
509 &cfgTmpData->cfgEntData[idx]);
511 RLC_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(RlcEntCfgCfmInfo));
516 case CKW_CFG_DELETE_UE:
518 if (cfgTmpData->cfgEntData[idx].entUlCfgCfm.status.status == CKW_CFG_CFM_OK)
520 rlcCfgApplyDelUlUe(gCb, cfgTmpData);
521 RLC_MEM_CPY(entCfgCfm,
522 &cfgTmpData->cfgEntData[idx].entUlCfgCfm,
523 sizeof(RlcEntCfgCfmInfo));
527 RLC_MEM_CPY(entCfgCfm, entDlCfgCfm,
528 sizeof(RlcEntCfgCfmInfo));
532 case CKW_CFG_DELETE_CELL:
534 if (cfgTmpData->cfgEntData[idx].entUlCfgCfm.status.status == CKW_CFG_CFM_OK)
536 rlcCfgApplyDelUlCell(gCb, cfgTmpData);
537 RLC_MEM_CPY(entCfgCfm,
538 &cfgTmpData->cfgEntData[idx].entUlCfgCfm,
539 sizeof(RlcEntCfgCfmInfo));
543 RLC_MEM_CPY(entCfgCfm, entDlCfgCfm,
544 sizeof(RlcEntCfgCfmInfo));
550 RLC_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType,
551 CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_CFG);
553 DU_LOG("\nERROR --> RLC_UL : Invalid configuration type");
558 /* Assign number of entity configurations and suId */
559 cfgCfm->transId = cfgTmpData->uprLyrTransId;
560 cfgCfm->ueId = cfg->ueId;
561 cfgCfm->cellId = cfg->cellId;
562 cfgCfm->numEnt = cfg->numEnt;
568 #endif /* __cplusplus */
571 /**********************************************************************
573 **********************************************************************/