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 #define KW_MODULE KW_DBGMASK_UDX
69 /* forward references */
71 /* public variable declarations */
72 EXTERN S16 kwHdlCkwUlCfgReq ARGS((KwCb *gCb,KwUlCfgTmpData *cfgTmpData,
73 CkwCfgCfmInfo *cfmInfo, CkwCfgCfmInfo *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
97 PUBLIC S16 KwUlUdxBndCfm
104 PUBLIC S16 KwUlUdxBndCfm (pst, suId, status)
112 KwUdxUlSapCb *udxSap; /* RGU SAP Control Block */
117 #if (ERRCLASS & ERRCLS_INT_PAR)
118 if (pst->dstInst >= KW_MAX_RLC_INSTANCES)
123 tKwCb = KW_GET_KWCB(pst->dstInst);
125 KWDBGP_BRIEF(tKwCb, "KwUlUdxBndCfm(post, suId(%d), status(%d)\n",
128 #if (ERRCLASS & ERRCLS_INT_PAR)
129 if (tKwCb->init.cfgDone != TRUE)
131 RLOG0(L_FATAL, "General configuration not done");
132 KW_SEND_SAPID_ALARM(tKwCb,suId,
133 LKW_EVENT_LI_BND_CFM, LCM_CAUSE_INV_STATE);
140 RLOG0(L_ERROR, "Invalid suId");
141 KW_SEND_SAPID_ALARM(tKwCb,suId,
142 LKW_EVENT_LI_BND_CFM, LCM_CAUSE_INV_SUID);
146 #endif /* ERRCLASS & ERRCLS_INT_PAR */
148 udxSap = tKwCb->u.ulCb->udxUlSap + suId;
150 KWDBGP_DETAIL(tKwCb, "KwLiRguBndCfm: For RGU SAP state=%d\n",
153 /* Check rguSap state */
154 switch (udxSap->state)
158 if(TRUE == kwChkTmr(tKwCb,(PTR)udxSap,KW_EVT_WAIT_BNDCFM))
160 kwStopTmr (tKwCb,(PTR)udxSap, KW_EVT_WAIT_BNDCFM);
162 udxSap->retryCnt = 0;
164 if (status == CM_BND_OK)
166 udxSap->state = KW_SAP_BND;
167 event = LCM_EVENT_BND_OK;
168 cause = LKW_CAUSE_SAP_BNDENB;
172 udxSap->state = KW_SAP_CFG;
173 event = LCM_EVENT_BND_FAIL;
174 cause = LKW_CAUSE_UNKNOWN;
180 event = LKW_EVENT_RGU_BND_CFM;
181 cause = LCM_CAUSE_INV_STATE;
184 /* Send an alarm with proper event and cause */
185 KW_SEND_SAPID_ALARM(tKwCb,suId, event, cause);
192 * Handles UDX Configuration Confirm
195 * This function handles the UDX configuration Confirm from DL Instance
197 * @param[in] pst Post structure
198 * @param[in] suId Service User ID
199 * @param[in] cfmInfo Confirm Information
206 PUBLIC S16 KwUlUdxCfgCfm
210 CkwCfgCfmInfo *cfmInfo
213 PUBLIC S16 KwUlUdxCfgCfm (pst, suId, cfmInfo)
216 CkwCfgCfmInfo *cfmInfo;
220 CkwCfgCfmInfo *cfgCfm;
221 KwUlCfgTmpData *cfgTmpData;
225 #if (ERRCLASS & ERRCLS_INT_PAR)
226 if (pst->dstInst >= KW_MAX_RLC_INSTANCES)
228 KW_FREE_SHRABL_BUF(pst->region,
231 sizeof(CkwCfgCfmInfo));
235 tKwCb = KW_GET_KWCB(pst->dstInst);
236 KWDBGP_BRIEF(tKwCb, " suId(%d)\n", suId);
238 #if (ERRCLASS & ERRCLS_INT_PAR)
241 RLOG0(L_ERROR, "Invalid suId");
242 KW_SEND_SAPID_ALARM(tKwCb,suId,
243 LKW_EVENT_LI_BND_CFM, LCM_CAUSE_INV_SUID);
244 KW_FREE_SHRABL_BUF(pst->region,
247 sizeof(CkwCfgCfmInfo));
250 #endif /* ERRCLASS & ERRCLS_INT_PAR */
252 if(ROK != kwDbmFindUlTransaction(tKwCb,cfmInfo->transId, &cfgTmpData))
254 RLOG0(L_ERROR, "Invalid transId");
255 KW_FREE_SHRABL_BUF(pst->region,
258 sizeof(CkwCfgCfmInfo));
262 if(ROK != kwDbmDelUlTransaction(tKwCb, cfgTmpData))
264 KW_FREE_SHRABL_BUF(pst->region,
267 sizeof(CkwCfgCfmInfo));
270 /* Allocate memory and memset to 0 for cfmInfo */
271 KW_ALLOC(tKwCb,cfgCfm, sizeof(CkwCfgCfmInfo));
272 #if (ERRCLASS & ERRCLS_ADD_RES)
275 RLOG0(L_FATAL, "Memory Allocation failed.");
276 KW_FREE_SHRABL_BUF(pst->region,
279 sizeof(CkwCfgCfmInfo));
282 #endif /* ERRCLASS & ERRCLS_ADD_RES */
283 kwHdlCkwUlCfgReq(tKwCb,cfgTmpData, cfmInfo, cfgCfm);
284 KwUiCkwCfgCfm(&(tKwCb->u.ulCb->ckwSap.pst),
285 tKwCb->u.ulCb->ckwSap.suId , cfgCfm);
287 /* free the memory from DL */
288 KW_FREE_SHRABL_BUF(pst->region,
291 sizeof(CkwCfgCfmInfo));
293 /* free the cfgInfo that came from LM */
294 KW_PST_FREE(pst->region, pst->pool, cfgTmpData->cfgInfo, sizeof(CkwCfgInfo));
295 KW_FREE(tKwCb,cfgTmpData,sizeof(KwUlCfgTmpData));
302 * Handler for UeId change confirm
305 * This function handles the UeId Change Confirm from DL Instance
307 * @param[in] pst Post structure
308 * @param[in] suId Service User ID
309 * @param[in] transId Transaction Id
310 * @param[in] status Status of confirmation
317 PUBLIC S16 KwUlUdxUeIdChgCfm
325 PUBLIC S16 KwUlUdxUeIdChgCfm (pst, suId, cfmInfo)
333 KwUlCfgTmpData *cfgTmpData;
335 TRC3(KwUlUdxUeIdChgCfm)
337 #if (ERRCLASS & ERRCLS_INT_PAR)
338 if (pst->dstInst >= KW_MAX_RLC_INSTANCES)
343 tKwCb = KW_GET_KWCB(pst->dstInst);
345 KWDBGP_BRIEF(tKwCb, " suId(%d) \n", suId);
347 #if (ERRCLASS & ERRCLS_INT_PAR)
350 RLOG0(L_ERROR, "Invalid suId");
353 #endif /* ERRCLASS & ERRCLS_INT_PAR */
355 if(ROK != kwDbmFindUlTransaction(tKwCb, transId, &cfgTmpData))
357 RLOG0(L_ERROR, "Invalid transId");
361 if(ROK != kwDbmDelUlTransaction(tKwCb, cfgTmpData))
366 if(status.status == CKW_CFG_CFM_OK)
368 if(cfgTmpData->ueCb != NULLP)
370 kwCfgApplyUlUeIdChng(tKwCb, cfgTmpData->ueInfo, cfgTmpData->newUeInfo, cfgTmpData);
373 KwUiCkwUeIdChgCfm(&(tKwCb->u.ulCb->ckwSap.pst),
374 tKwCb->u.ulCb->ckwSap.suId,
375 transId,cfgTmpData->ueInfo,status);
376 /* only newUeInfo needs to be freed here, ueInfo would be freed at the
377 interface or by he receipient in case of tight coupling */
378 KW_PST_FREE(pst->region, pst->pool, cfgTmpData->newUeInfo, sizeof(CkwUeInfo));
379 KW_FREE_WC(tKwCb, cfgTmpData, sizeof (KwUlCfgTmpData));
385 * Udx Status Prohibit Timer Start
387 * @param[in] pst Post structure
388 * @param[in] suId Service User ID
389 * @param[in] rlcId rlc Id
394 PUBLIC S16 KwUlUdxStaProhTmrStart
404 #if (ERRCLASS & ERRCLS_INT_PAR)
405 if (pst->dstInst >= KW_MAX_RLC_INSTANCES)
410 tKwCb = KW_GET_KWCB(pst->dstInst);
412 kwDbmFetchUlRbCbByRbId(tKwCb, rlcId, &rbCb);
415 RLOG_ARG2(L_ERROR, DBG_UEID,rlcId->ueId, "CellId [%u]:RbId[%d] not found",
416 rlcId->cellId,rlcId->rbId);
420 /* Start staProhTmr */
421 kwStartTmr(tKwCb,(PTR)rbCb, KW_EVT_AMUL_STA_PROH_TMR);
428 * Handler for configuration confirm from DL.
430 * @param[in] gCb - RLC Instance Control Block
431 * @param[in] cfgTmpData - Configuration Temporary Data
432 * @param[in] cfmInfo - DL Configuration Confirm Info
433 * @param[out] cfgCfm - Configuration Confirm to be sent to RRC
440 PUBLIC S16 kwHdlCkwUlCfgReq
443 KwUlCfgTmpData *cfgTmpData,
444 CkwCfgCfmInfo *cfmInfo,
445 CkwCfgCfmInfo *cfgCfm
448 PUBLIC S16 kwHdlCkwUlCfgReq(gCb,cfgTmpData,cfmInfo,cfmInfo)
450 KwUlCfgTmpData *cfgTmpData;
451 CkwCfgCfmInfo *cfmInfo;
452 CkwCfgCfmInfo *cfgCfm;
459 cfg = cfgTmpData->cfgInfo;
460 maxEnt = (cfg->numEnt < CKW_MAX_ENT_CFG)? cfg->numEnt:CKW_MAX_ENT_CFG;
462 for (idx = 0; idx < maxEnt; idx++)
464 CkwEntCfgCfmInfo *entCfgCfm;
465 CkwEntCfgCfmInfo *entDlCfgCfm;
466 CkwEntCfgInfo *entCfg;
468 entCfg = &(cfg->entCfg[idx]);
469 entCfgCfm = &(cfgCfm->entCfgCfm[idx]);
470 entDlCfgCfm = &(cfmInfo->entCfgCfm[idx]);
471 switch (entCfg->cfgType)
477 if (entCfg->dir == KW_DIR_UL)
479 KW_MEM_CPY(entCfgCfm,
480 &cfgTmpData->cfgEntData[idx].entUlCfgCfm,
481 sizeof(CkwEntCfgCfmInfo));
483 else if (entCfg->dir == KW_DIR_DL)
485 KW_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(CkwEntCfgCfmInfo));
487 else if(entCfg->dir == KW_DIR_BOTH)
489 if (entDlCfgCfm->status.status != CKW_CFG_CFM_OK)
491 kwCfgRollBackUlRb(gCb,
494 &cfgTmpData->cfgEntData[idx]);
500 &cfgTmpData->cfgEntData[idx],
503 KW_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(CkwEntCfgCfmInfo));
507 KW_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType,
508 CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_DIR);
509 RLOG_ARG2(L_ERROR,DBG_UEID,cfg->ueId,"RBID[%d] direction[%d] is invalid",
510 entCfg->rbId,entCfg->dir);
515 case CKW_CFG_REESTABLISH:
517 if (entCfg->dir == KW_DIR_UL)
519 KW_MEM_CPY(entCfgCfm,
520 &cfgTmpData->cfgEntData[idx].entUlCfgCfm,
521 sizeof(CkwEntCfgCfmInfo));
523 else if (entCfg->dir == KW_DIR_DL)
525 KW_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(CkwEntCfgCfmInfo));
529 if (entCfg->dir & KW_DIR_UL)
531 /* Reestablish indication is sent from UL Instance only*/
532 if (entDlCfgCfm->status.status == CKW_CFG_CFM_OK)
534 kwCfgApplyReEstUlRb (gCb, cfg->ueId,
536 &cfgTmpData->cfgEntData[idx]);
538 KW_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(CkwEntCfgCfmInfo));
543 case CKW_CFG_DELETE_UE:
545 if (cfgTmpData->cfgEntData[idx].entUlCfgCfm.status.status == CKW_CFG_CFM_OK)
547 kwCfgApplyDelUlUe(gCb, cfgTmpData);
548 KW_MEM_CPY(entCfgCfm,
549 &cfgTmpData->cfgEntData[idx].entUlCfgCfm,
550 sizeof(CkwEntCfgCfmInfo));
554 KW_MEM_CPY(entCfgCfm, entDlCfgCfm,
555 sizeof(CkwEntCfgCfmInfo));
559 case CKW_CFG_DELETE_CELL:
561 if (cfgTmpData->cfgEntData[idx].entUlCfgCfm.status.status == CKW_CFG_CFM_OK)
563 kwCfgApplyDelUlCell(gCb, cfgTmpData);
564 KW_MEM_CPY(entCfgCfm,
565 &cfgTmpData->cfgEntData[idx].entUlCfgCfm,
566 sizeof(CkwEntCfgCfmInfo));
570 KW_MEM_CPY(entCfgCfm, entDlCfgCfm,
571 sizeof(CkwEntCfgCfmInfo));
577 KW_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType,
578 CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_CFG);
580 RLOG0(L_ERROR,"Invalid configuration type");
585 /* Assign number of entity configurations and suId */
586 cfgCfm->transId = cfgTmpData->uprLyrTransId;
587 cfgCfm->ueId = cfg->ueId;
588 cfgCfm->cellId = cfg->cellId;
589 cfgCfm->numEnt = cfg->numEnt;
595 #endif /* __cplusplus */
598 /**********************************************************************
600 **********************************************************************/