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 "envopt.h" /* environment options */
40 #include "envdep.h" /* environment dependent */
41 #include "envind.h" /* environment independent */
43 #include "gen.h" /* general */
44 #include "ssi.h" /* system services */
45 #include "cm5.h" /* common timer defines */
46 #include "cm_tkns.h" /* common tokens defines */
47 #include "cm_mblk.h" /* common memory allocation library defines */
48 #include "cm_llist.h" /* common link list defines */
49 #include "cm_hash.h" /* common hash list defines */
50 #include "cm_lte.h" /* common LTE defines */
51 #include "lkw.h" /* LKW defines */
52 #include "ckw.h" /* CKW defines */
53 #include "kwu.h" /* KWU defines */
54 #include "rgu.h" /* RGU defines */
55 #include "kw_err.h" /* Err defines */
56 #include "kw_env.h" /* RLC environment options */
58 #include "kw.h" /* RLC defines */
63 /* extern (.x) include files */
64 #include "gen.x" /* general */
65 #include "ssi.x" /* system services */
67 #include "cm5.x" /* common timer library */
68 #include "cm_tkns.x" /* common tokens */
69 #include "cm_mblk.x" /* common memory allocation */
70 #include "cm_llist.x" /* common link list */
71 #include "cm_hash.x" /* common hash list */
72 #include "cm_lte.x" /* common LTE includes */
73 #include "cm_lib.x" /* common memory allocation library */
74 #include "lkw.x" /* LKW */
75 #include "ckw.x" /* CKW */
76 #include "kwu.x" /* KWU */
77 #include "rgu.x" /* RGU */
85 #define KW_MODULE KW_DBGMASK_UDX
90 /* forward references */
92 /* public variable declarations */
93 EXTERN S16 kwHdlCkwUlCfgReq ARGS((KwCb *gCb,KwUlCfgTmpData *cfgTmpData,
94 CkwCfgCfmInfo *cfmInfo, CkwCfgCfmInfo *cfgCfm));
102 * Handler for bind confirmation from DL.
105 * This function handles the bind confirmation received
108 * @param[in] pst Post structure
109 * @param[in] suId Service User ID
110 * @param[in] status Status of confirmation
118 PUBLIC S16 KwUlUdxBndCfm
125 PUBLIC S16 KwUlUdxBndCfm (pst, suId, status)
133 KwUdxUlSapCb *udxSap; /* RGU SAP Control Block */
138 #if (ERRCLASS & ERRCLS_INT_PAR)
139 if (pst->dstInst >= KW_MAX_RLC_INSTANCES)
144 tKwCb = KW_GET_KWCB(pst->dstInst);
146 KWDBGP_BRIEF(tKwCb, "KwUlUdxBndCfm(post, suId(%d), status(%d)\n",
149 #if (ERRCLASS & ERRCLS_INT_PAR)
150 if (tKwCb->init.cfgDone != TRUE)
152 RLOG0(L_FATAL, "General configuration not done");
153 KW_SEND_SAPID_ALARM(tKwCb,suId,
154 LKW_EVENT_LI_BND_CFM, LCM_CAUSE_INV_STATE);
161 RLOG0(L_ERROR, "Invalid suId");
162 KW_SEND_SAPID_ALARM(tKwCb,suId,
163 LKW_EVENT_LI_BND_CFM, LCM_CAUSE_INV_SUID);
167 #endif /* ERRCLASS & ERRCLS_INT_PAR */
169 udxSap = tKwCb->u.ulCb->udxUlSap + suId;
171 KWDBGP_DETAIL(tKwCb, "KwLiRguBndCfm: For RGU SAP state=%d\n",
174 /* Check rguSap state */
175 switch (udxSap->state)
179 if(TRUE == kwChkTmr(tKwCb,(PTR)udxSap,KW_EVT_WAIT_BNDCFM))
181 kwStopTmr (tKwCb,(PTR)udxSap, KW_EVT_WAIT_BNDCFM);
183 udxSap->retryCnt = 0;
185 if (status == CM_BND_OK)
187 udxSap->state = KW_SAP_BND;
188 event = LCM_EVENT_BND_OK;
189 cause = LKW_CAUSE_SAP_BNDENB;
193 udxSap->state = KW_SAP_CFG;
194 event = LCM_EVENT_BND_FAIL;
195 cause = LKW_CAUSE_UNKNOWN;
201 event = LKW_EVENT_RGU_BND_CFM;
202 cause = LCM_CAUSE_INV_STATE;
205 /* Send an alarm with proper event and cause */
206 KW_SEND_SAPID_ALARM(tKwCb,suId, event, cause);
213 * Handles UDX Configuration Confirm
216 * This function handles the UDX configuration Confirm from DL Instance
218 * @param[in] pst Post structure
219 * @param[in] suId Service User ID
220 * @param[in] cfmInfo Confirm Information
227 PUBLIC S16 KwUlUdxCfgCfm
231 CkwCfgCfmInfo *cfmInfo
234 PUBLIC S16 KwUlUdxCfgCfm (pst, suId, cfmInfo)
237 CkwCfgCfmInfo *cfmInfo;
241 CkwCfgCfmInfo *cfgCfm;
242 KwUlCfgTmpData *cfgTmpData;
246 #if (ERRCLASS & ERRCLS_INT_PAR)
247 if (pst->dstInst >= KW_MAX_RLC_INSTANCES)
249 KW_FREE_SHRABL_BUF(pst->region,
252 sizeof(CkwCfgCfmInfo));
256 tKwCb = KW_GET_KWCB(pst->dstInst);
257 KWDBGP_BRIEF(tKwCb, " suId(%d)\n", suId);
259 #if (ERRCLASS & ERRCLS_INT_PAR)
262 RLOG0(L_ERROR, "Invalid suId");
263 KW_SEND_SAPID_ALARM(tKwCb,suId,
264 LKW_EVENT_LI_BND_CFM, LCM_CAUSE_INV_SUID);
265 KW_FREE_SHRABL_BUF(pst->region,
268 sizeof(CkwCfgCfmInfo));
271 #endif /* ERRCLASS & ERRCLS_INT_PAR */
273 if(ROK != kwDbmFindUlTransaction(tKwCb,cfmInfo->transId, &cfgTmpData))
275 RLOG0(L_ERROR, "Invalid transId");
276 KW_FREE_SHRABL_BUF(pst->region,
279 sizeof(CkwCfgCfmInfo));
283 if(ROK != kwDbmDelUlTransaction(tKwCb, cfgTmpData))
285 KW_FREE_SHRABL_BUF(pst->region,
288 sizeof(CkwCfgCfmInfo));
291 /* Allocate memory and memset to 0 for cfmInfo */
292 KW_ALLOC(tKwCb,cfgCfm, sizeof(CkwCfgCfmInfo));
293 #if (ERRCLASS & ERRCLS_ADD_RES)
296 RLOG0(L_FATAL, "Memory Allocation failed.");
297 KW_FREE_SHRABL_BUF(pst->region,
300 sizeof(CkwCfgCfmInfo));
303 #endif /* ERRCLASS & ERRCLS_ADD_RES */
304 kwHdlCkwUlCfgReq(tKwCb,cfgTmpData, cfmInfo, cfgCfm);
305 KwUiCkwCfgCfm(&(tKwCb->u.ulCb->ckwSap.pst),
306 tKwCb->u.ulCb->ckwSap.suId , cfgCfm);
308 /* free the memory from DL */
309 KW_FREE_SHRABL_BUF(pst->region,
312 sizeof(CkwCfgCfmInfo));
314 /* free the cfgInfo that came from LM */
315 KW_PST_FREE(pst->region, pst->pool, cfgTmpData->cfgInfo, sizeof(CkwCfgInfo));
316 KW_FREE(tKwCb,cfgTmpData,sizeof(KwUlCfgTmpData));
323 * Handler for UeId change confirm
326 * This function handles the UeId Change Confirm from DL Instance
328 * @param[in] pst Post structure
329 * @param[in] suId Service User ID
330 * @param[in] transId Transaction Id
331 * @param[in] status Status of confirmation
338 PUBLIC S16 KwUlUdxUeIdChgCfm
346 PUBLIC S16 KwUlUdxUeIdChgCfm (pst, suId, cfmInfo)
354 KwUlCfgTmpData *cfgTmpData;
356 TRC3(KwUlUdxUeIdChgCfm)
358 #if (ERRCLASS & ERRCLS_INT_PAR)
359 if (pst->dstInst >= KW_MAX_RLC_INSTANCES)
364 tKwCb = KW_GET_KWCB(pst->dstInst);
366 KWDBGP_BRIEF(tKwCb, " suId(%d) \n", suId);
368 #if (ERRCLASS & ERRCLS_INT_PAR)
371 RLOG0(L_ERROR, "Invalid suId");
374 #endif /* ERRCLASS & ERRCLS_INT_PAR */
376 if(ROK != kwDbmFindUlTransaction(tKwCb, transId, &cfgTmpData))
378 RLOG0(L_ERROR, "Invalid transId");
382 if(ROK != kwDbmDelUlTransaction(tKwCb, cfgTmpData))
387 if(status.status == CKW_CFG_CFM_OK)
389 if(cfgTmpData->ueCb != NULLP)
391 kwCfgApplyUlUeIdChng(tKwCb, cfgTmpData->ueInfo, cfgTmpData->newUeInfo, cfgTmpData);
394 KwUiCkwUeIdChgCfm(&(tKwCb->u.ulCb->ckwSap.pst),
395 tKwCb->u.ulCb->ckwSap.suId,
396 transId,cfgTmpData->ueInfo,status);
397 /* only newUeInfo needs to be freed here, ueInfo would be freed at the
398 interface or by he receipient in case of tight coupling */
399 KW_PST_FREE(pst->region, pst->pool, cfgTmpData->newUeInfo, sizeof(CkwUeInfo));
400 KW_FREE_WC(tKwCb, cfgTmpData, sizeof (KwUlCfgTmpData));
406 * Udx Status Prohibit Timer Start
408 * @param[in] pst Post structure
409 * @param[in] suId Service User ID
410 * @param[in] rlcId rlc Id
415 PUBLIC S16 KwUlUdxStaProhTmrStart
425 #if (ERRCLASS & ERRCLS_INT_PAR)
426 if (pst->dstInst >= KW_MAX_RLC_INSTANCES)
431 tKwCb = KW_GET_KWCB(pst->dstInst);
433 kwDbmFetchUlRbCbByRbId(tKwCb, rlcId, &rbCb);
436 RLOG_ARG2(L_ERROR, DBG_UEID,rlcId->ueId, "CellId [%u]:RbId[%d] not found",
437 rlcId->cellId,rlcId->rbId);
441 /* Start staProhTmr */
442 kwStartTmr(tKwCb,(PTR)rbCb, KW_EVT_AMUL_STA_PROH_TMR);
449 * Handler for configuration confirm from DL.
451 * @param[in] gCb - RLC Instance Control Block
452 * @param[in] cfgTmpData - Configuration Temporary Data
453 * @param[in] cfmInfo - DL Configuration Confirm Info
454 * @param[out] cfgCfm - Configuration Confirm to be sent to RRC
461 PUBLIC S16 kwHdlCkwUlCfgReq
464 KwUlCfgTmpData *cfgTmpData,
465 CkwCfgCfmInfo *cfmInfo,
466 CkwCfgCfmInfo *cfgCfm
469 PUBLIC S16 kwHdlCkwUlCfgReq(gCb,cfgTmpData,cfmInfo,cfmInfo)
471 KwUlCfgTmpData *cfgTmpData;
472 CkwCfgCfmInfo *cfmInfo;
473 CkwCfgCfmInfo *cfgCfm;
480 cfg = cfgTmpData->cfgInfo;
481 maxEnt = (cfg->numEnt < CKW_MAX_ENT_CFG)? cfg->numEnt:CKW_MAX_ENT_CFG;
483 for (idx = 0; idx < maxEnt; idx++)
485 CkwEntCfgCfmInfo *entCfgCfm;
486 CkwEntCfgCfmInfo *entDlCfgCfm;
487 CkwEntCfgInfo *entCfg;
489 entCfg = &(cfg->entCfg[idx]);
490 entCfgCfm = &(cfgCfm->entCfgCfm[idx]);
491 entDlCfgCfm = &(cfmInfo->entCfgCfm[idx]);
492 switch (entCfg->cfgType)
498 if (entCfg->dir == KW_DIR_UL)
500 KW_MEM_CPY(entCfgCfm,
501 &cfgTmpData->cfgEntData[idx].entUlCfgCfm,
502 sizeof(CkwEntCfgCfmInfo));
504 else if (entCfg->dir == KW_DIR_DL)
506 KW_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(CkwEntCfgCfmInfo));
508 else if(entCfg->dir == KW_DIR_BOTH)
510 if (entDlCfgCfm->status.status != CKW_CFG_CFM_OK)
512 kwCfgRollBackUlRb(gCb,
515 &cfgTmpData->cfgEntData[idx]);
521 &cfgTmpData->cfgEntData[idx],
524 KW_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(CkwEntCfgCfmInfo));
528 KW_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType,
529 CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_DIR);
530 RLOG_ARG2(L_ERROR,DBG_UEID,cfg->ueId,"RBID[%d] direction[%d] is invalid",
531 entCfg->rbId,entCfg->dir);
536 case CKW_CFG_REESTABLISH:
538 if (entCfg->dir == KW_DIR_UL)
540 KW_MEM_CPY(entCfgCfm,
541 &cfgTmpData->cfgEntData[idx].entUlCfgCfm,
542 sizeof(CkwEntCfgCfmInfo));
544 else if (entCfg->dir == KW_DIR_DL)
546 KW_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(CkwEntCfgCfmInfo));
550 if (entCfg->dir & KW_DIR_UL)
552 /* Reestablish indication is sent from UL Instance only*/
553 if (entDlCfgCfm->status.status == CKW_CFG_CFM_OK)
555 kwCfgApplyReEstUlRb (gCb, cfg->ueId,
557 &cfgTmpData->cfgEntData[idx]);
559 KW_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(CkwEntCfgCfmInfo));
564 case CKW_CFG_DELETE_UE:
566 if (cfgTmpData->cfgEntData[idx].entUlCfgCfm.status.status == CKW_CFG_CFM_OK)
568 kwCfgApplyDelUlUe(gCb, cfgTmpData);
569 KW_MEM_CPY(entCfgCfm,
570 &cfgTmpData->cfgEntData[idx].entUlCfgCfm,
571 sizeof(CkwEntCfgCfmInfo));
575 KW_MEM_CPY(entCfgCfm, entDlCfgCfm,
576 sizeof(CkwEntCfgCfmInfo));
580 case CKW_CFG_DELETE_CELL:
582 if (cfgTmpData->cfgEntData[idx].entUlCfgCfm.status.status == CKW_CFG_CFM_OK)
584 kwCfgApplyDelUlCell(gCb, cfgTmpData);
585 KW_MEM_CPY(entCfgCfm,
586 &cfgTmpData->cfgEntData[idx].entUlCfgCfm,
587 sizeof(CkwEntCfgCfmInfo));
591 KW_MEM_CPY(entCfgCfm, entDlCfgCfm,
592 sizeof(CkwEntCfgCfmInfo));
598 KW_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType,
599 CKW_CFG_CFM_NOK, CKW_CFG_REAS_INVALID_CFG);
601 RLOG0(L_ERROR,"Invalid configuration type");
606 /* Assign number of entity configurations and suId */
607 cfgCfm->transId = cfgTmpData->uprLyrTransId;
608 cfgCfm->ueId = cfg->ueId;
609 cfgCfm->cellId = cfg->cellId;
610 cfgCfm->numEnt = cfg->numEnt;
616 #endif /* __cplusplus */
619 /**********************************************************************
621 **********************************************************************/