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 /* header include files (.h) */
20 #include "common_def.h"
21 #include "rgu.h" /* RGU interface includes*/
22 #include "lkw.h" /* LKW defines */
23 #include "ckw.h" /* CKW defines */
24 #include "kwu.h" /* KWU defines */
25 #include "kw_env.h" /* RLC environment options */
26 #include "kw.h" /* RLC defines */
29 /* header/extern include files (.x) */
31 #include "lkw.x" /* LKW */
32 #include "ckw.x" /* CKW */
33 #include "kwu.x" /* KWU */
37 #include "du_app_rlc_inf.h"
38 #include "rlc_utils.h"
40 /*******************************************************************
42 * @brief Fills RLC UL UE Cfg Rsp from RlcCRsp
46 * Function : fillRlcUlUeCfgRsp
49 * Fills RLC UL UE Cfg Rsp from RlcCRsp
51 * @params[in] Pointer to RlcCfgCfm
52 * Pointer to RlcUeCfgRsp
56 *****************************************************************/
58 void fillRlcUlUeCfgRsp(RlcUeCfgRsp *rlcCfgRsp, RlcCfgCfmInfo *rlcCRsp)
62 rlcCfgRsp->cellId = rlcCRsp->cellId;
63 rlcCfgRsp->ueIdx = rlcCRsp->ueId;
64 for(idx = 0; idx < rlcCRsp->numEnt; idx++)
66 if(rlcCRsp->entCfgCfm[idx].status.status == CKW_CFG_CFM_OK)
68 rlcCfgRsp->result = RLC_DU_APP_RSP_OK;
69 rlcCfgRsp->reason = rlcCRsp->entCfgCfm[idx].status.reason;
73 rlcCfgRsp->result = RLC_DU_APP_RSP_NOK;
74 rlcCfgRsp->reason = rlcCRsp->entCfgCfm[idx].status.reason;
79 /*******************************************************************
81 * @brief Fills the entity mode and direction compiling to seed code
85 * Function : fillEntModeAndDir
88 * Fills the entity mode and direction compiling to seed code
90 * @params[in] Pointer to entMode
91 * Pointer to direction
94 * ****************************************************************/
96 void fillEntModeAndDir(uint8_t *entMode, uint8_t *direction, RlcMode rlcMode)
101 *entMode = CM_LTE_MODE_AM;
102 *direction = RLC_CFG_DIR_BOTH;
104 case RLC_UM_BI_DIRECTIONAL:
105 *entMode = CM_LTE_MODE_UM;
106 *direction = RLC_CFG_DIR_BOTH;
108 case RLC_UM_UNI_DIRECTIONAL_UL:
109 *entMode = CM_LTE_MODE_UM;
110 *direction = RLC_CFG_DIR_UL;
112 case RLC_UM_UNI_DIRECTIONAL_DL:
113 *entMode = CM_LTE_MODE_UM;
114 *direction = RLC_CFG_DIR_DL;
117 DU_LOG("\nRLC: Rlc Mode invalid %d", rlcMode);
121 /*******************************************************************
123 * @brief Handles Ue Create Request from DU APP
127 * Function : RlcUlProcUeCreateReq
130 * Handles Ue create Request from DU APP
132 * @params[in] Post structure pointer
134 * @return ROK - success
137 * ****************************************************************/
138 uint8_t RlcUlProcUeCreateReq(Pst *pst, RlcUeCfg *ueCfg)
143 RlcCfgInfo *rlcUeCfg = NULLP;
145 RlcCb *rlcUeCb = NULLP;
146 rlcUeCb = RLC_GET_RLCCB(pst->dstInst);
147 RLC_ALLOC(rlcUeCb, rlcUeCfg, sizeof(RlcCfgInfo));
150 memset(rlcUeCfg, 0, sizeof(RlcCfgInfo));
152 rlcUeCfg->ueId = ueCfg->ueIdx;
153 rlcUeCfg->cellId = ueCfg->cellId;
154 rlcUeCfg->numEnt = ueCfg->numLcs;
155 rlcUeCfg->transId = getTransId();
157 for(idx = 0; idx < ueCfg->numLcs; idx++)
160 rlcUeCfg->entCfg[idx].rbId = ueCfg->rlcBearerCfg[idx].rbId;
161 rlcUeCfg->entCfg[idx].rbType = ueCfg->rlcBearerCfg[idx].rbType; // SRB or DRB
162 rlcUeCfg->entCfg[idx].lCh[lChRbIdx].lChId = ueCfg->rlcBearerCfg[idx].lcId;
163 rlcUeCfg->entCfg[idx].lCh[lChRbIdx].type = ueCfg->rlcBearerCfg[idx].lcType;
164 fillEntModeAndDir(&rlcUeCfg->entCfg[idx].entMode, &rlcUeCfg->entCfg[idx].dir,\
165 ueCfg->rlcBearerCfg[idx].rlcMode);
166 rlcUeCfg->entCfg[idx].cfgType = CKW_CFG_ADD;
167 switch(rlcUeCfg->entCfg[idx].entMode)
173 rlcUeCfg->entCfg[idx].m.amInfo.dl.snLen = ueCfg->rlcBearerCfg[idx].u.amCfg.dlAmCfg.snLenDl;
174 rlcUeCfg->entCfg[idx].m.amInfo.dl.pollRetxTmr = ueCfg->rlcBearerCfg[idx].u.amCfg.dlAmCfg.pollRetxTmr;
175 rlcUeCfg->entCfg[idx].m.amInfo.dl.pollPdu = ueCfg->rlcBearerCfg[idx].u.amCfg.dlAmCfg.pollPdu;
176 rlcUeCfg->entCfg[idx].m.amInfo.dl.pollByte = ueCfg->rlcBearerCfg[idx].u.amCfg.dlAmCfg.pollByte;
177 rlcUeCfg->entCfg[idx].m.amInfo.dl.maxRetx = ueCfg->rlcBearerCfg[idx].u.amCfg.dlAmCfg.maxRetxTh;
180 lChRbIdx++; //lChRbIdx = 1, indicates UL AM
181 rlcUeCfg->entCfg[idx].lCh[lChRbIdx].lChId = ueCfg->rlcBearerCfg[idx].lcId;
182 rlcUeCfg->entCfg[idx].lCh[lChRbIdx].type = ueCfg->rlcBearerCfg[idx].lcType;
183 rlcUeCfg->entCfg[idx].m.amInfo.ul.snLen = ueCfg->rlcBearerCfg[idx].u.amCfg.ulAmCfg.snLenUl;
184 rlcUeCfg->entCfg[idx].m.amInfo.ul.staProhTmr = ueCfg->rlcBearerCfg[idx].u.amCfg.ulAmCfg.statProhTmr;
185 rlcUeCfg->entCfg[idx].m.amInfo.ul.reOrdTmr = ueCfg->rlcBearerCfg[idx].u.amCfg.ulAmCfg.reAssemTmr;
191 rlcUeCfg->entCfg[idx].m.umInfo.ul.snLen = ueCfg->rlcBearerCfg[idx].u.umBiDirCfg.ulUmCfg.snLenUlUm;
192 rlcUeCfg->entCfg[idx].m.umInfo.ul.reOrdTmr = ueCfg->rlcBearerCfg[idx].u.umBiDirCfg.ulUmCfg.reAssemTmr;
195 rlcUeCfg->entCfg[idx].m.umInfo.dl.snLen = ueCfg->rlcBearerCfg[idx].u.umBiDirCfg.dlUmCfg.snLenDlUm;
200 }/* End of switch(entMode) */
202 ret = RlcProcCfgReq(pst, rlcUeCfg);
206 DU_LOG("\nRLC: Failed to allocate memory ");
209 RLC_FREE_SHRABL_BUF(pst->region, pst->pool, ueCfg, sizeof(RlcUeCfg));
213 /*******************************************************************
215 * @brief Process the DL RRC Message from DU APP
219 * Function : RlcProcDlRrcMsgTransfer
221 * Functionality: Process the DL RRC Message from DU APP
223 * @params[in] Post structure
224 * DL RRC Message info
225 * @return ROK - success
228 * ****************************************************************/
229 uint8_t RlcProcDlRrcMsgTransfer(Pst *pst, RlcDlRrcMsgInfo *dlRrcMsgInfo)
233 KwuDatReqInfo *datReqInfo;
235 RLC_SHRABL_STATIC_BUF_ALLOC(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(KwuDatReqInfo));
238 DU_LOG("\nRLC : Memory allocation failed in RlcProcDlRrcMsgTransfer");
242 datReqInfo->rlcId.rbType = dlRrcMsgInfo->rbType;
243 datReqInfo->rlcId.rbId = dlRrcMsgInfo->rbId;
244 datReqInfo->rlcId.ueId = dlRrcMsgInfo->ueIdx;
245 datReqInfo->rlcId.cellId = dlRrcMsgInfo->cellId;
246 datReqInfo->lcType = dlRrcMsgInfo->lcType;
247 datReqInfo->sduId = ++(rlcCb[pst->dstInst]->dlSduId);
249 /* Copy fixed buffer to message */
250 if(ODU_GET_MSG_BUF(RLC_MEM_REGION_UL, RLC_POOL, &mBuf) != ROK)
252 DU_LOG("\nRLC : Memory allocation failed at RlcMacProcUlData");
253 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(KwuDatReqInfo));
256 /* ODU_COPY_FIX_BUF_TO_MSG copies fixed buffer in reverse order. Hence reversing the
257 * fixed buffer before copying in order to maintain the actual order*/
258 reverseFixBuf(dlRrcMsgInfo->rrcMsg, dlRrcMsgInfo->msgLen);
259 ODU_COPY_FIX_BUF_TO_MSG(dlRrcMsgInfo->rrcMsg, mBuf, 0, dlRrcMsgInfo->msgLen, \
262 RlcUiKwuDatReq(pst, datReqInfo, mBuf);
264 /* Free memory allocated by du app */
265 RLC_SHRABL_STATIC_BUF_FREE(RLC_MEM_REGION_DL, RLC_POOL, datReqInfo, sizeof(KwuDatReqInfo));
266 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo->rrcMsg, dlRrcMsgInfo->msgLen);
267 RLC_SHRABL_STATIC_BUF_FREE(pst->region, pst->pool, dlRrcMsgInfo, sizeof(RlcDlRrcMsgInfo));
271 /**********************************************************************
273 **********************************************************************/