warning set 2: fixed warning related to du_app
[o-du/l2.git] / src / du_app / du_ue_mgr.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
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                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
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 *******************************************************************************/
18  /* This file contains UE management handling functionality for DU APP */
19 #include "du_ue_mgr.h"
20
21 #ifdef EGTP_TEST
22 U32 sduId = 0;
23 #endif
24
25 /******************************************************************
26  *
27  * @brief Send UE configuration to RLC
28  *
29  * @details
30  *
31  *    Function : duSendUeCreateReqToRlc
32  *
33  *    Functionality: Send UeCreateReqToRlc
34  *
35  * @return ROK     - success
36  *         RFAILED - failure
37  *
38  * ****************************************************************/
39 S16 duSendUeCreateReqToRlc()
40 {
41    U8  idx;
42    Pst pst;
43    CkwCfgInfo *ueCfg;
44    
45    DU_SET_ZERO(&ueCfg, sizeof(ueCfg));
46    DU_SET_ZERO(&pst, sizeof(Pst));
47
48    DU_ALLOC(ueCfg, sizeof(CkwCfgInfo));
49
50 #ifdef EGTP_TEST
51    ueCfg->ueId = UE_ID;
52 #endif
53    ueCfg->cellId = NR_CELL_ID;
54    ueCfg->numEnt = 1;
55    
56    for(idx = 0; idx < ueCfg->numEnt; idx++)
57    {
58 #ifdef EGTP_TEST
59       ueCfg->entCfg[idx].rbId           = RB_ID;
60       ueCfg->entCfg[idx].rbType         = CM_LTE_DRB;
61       ueCfg->entCfg[idx].lCh[0].lChId   = LC_ID;
62       ueCfg->entCfg[idx].lCh[0].type    = CM_LTE_LCH_DTCH;
63 #endif
64       ueCfg->entCfg[idx].entMode        = CM_LTE_MODE_UM;
65       ueCfg->entCfg[idx].dir            = CKW_CFG_DIR_BOTH;
66       switch(ueCfg->entCfg[idx].entMode)
67       {
68          case CM_LTE_MODE_TM:
69          {
70             break;
71          }
72
73          case CM_LTE_MODE_UM:
74          {
75             ueCfg->entCfg[idx].m.umInfo.dl.snLen = 1;      /* For 12 bit SN */
76             ueCfg->entCfg[idx].m.umInfo.ul.snLen = 1;      /* For 12 bit SN */
77             ueCfg->entCfg[idx].m.umInfo.ul.reOrdTmr = 10;  /* in msec */
78             break;
79          }
80
81          case CM_LTE_MODE_AM:
82          {
83             break;
84          }
85          
86          default:
87             break;
88       } /* End of switch(entMode) */
89    } /* End of entity configuration for loop */
90
91    /* Fill Pst */
92    pst.selector  = DU_SELECTOR_LWLC;
93    pst.srcEnt    = ENTDUAPP;
94    pst.dstEnt    = ENTKW;
95    pst.dstInst   = RLC_UL_INST;
96    pst.dstProcId = DU_PROC;
97    pst.srcProcId = DU_PROC;
98    pst.region    = duCb.init.region;
99
100    /* Sending to RLC */
101    packUeCreateReq(&pst, ueCfg);
102
103    RETVALUE(ROK); 
104 } /* End of duSendUeCreateReqToRlc */
105
106 /*******************************************************************
107  *
108  * @brief Handles EGTP data from CU 
109  *
110  * @details
111  *
112  *    Function : duHdlEgtpData
113  *
114  *    Functionality: 
115  *      Processes EGTP header and sends data to RLC
116  *
117  * @params[in]  Pointer to EGTP Message 
118  * @return ROK     - success
119  *         RFAILED - failure
120  *
121  * ****************************************************************/
122 S16 duHdlEgtpDlData(EgtpMsg  *egtpMsg)
123 {
124    /* TODO : Extract RbId/UeID/CellID/SduId from database
125       using tunnel id in egtp header */
126    
127    DU_LOG("\nDU_APP : Processing DL data");
128    
129    Pst pst;
130    KwuDatReqInfo datReqInfo;
131
132 #ifdef EGTP_TEST
133    datReqInfo.rlcId.rbId = RB_ID;
134    datReqInfo.rlcId.rbType = CM_LTE_DRB;
135    datReqInfo.rlcId.ueId = UE_ID;
136    datReqInfo.rlcId.cellId = NR_CELL_ID;
137    
138    datReqInfo.sduId = ++sduId;
139    datReqInfo.lcType = CM_LTE_LCH_DTCH;
140 #endif
141    /* Filling pst and Sending to RLC DL */
142    pst.selector  = DU_SELECTOR_LWLC;
143    pst.srcEnt    = ENTDUAPP;
144    pst.dstEnt    = ENTKW;
145    pst.dstInst   = RLC_DL_INST;
146    pst.dstProcId = DU_PROC;
147    pst.srcProcId = DU_PROC;
148    pst.region    = duCb.init.region;
149
150    cmPkKwuDatReq(&pst, &datReqInfo, egtpMsg->msg);
151    return ROK;
152 }
153
154 /*******************************************************************
155  *
156  * @brief Handles UL data and send to CU
157  *
158  * @details
159  *
160  *    Function : duHdlRlcUlData
161  *
162  *    Functionality: 
163  *     Processes UL Data from RLC and sends to CU
164  * 
165  *  @params[in]  Pointer to EGTP Message 
166  *  @return ROK     - success
167  *          RFAILED - failure
168  * 
169  *****************************************************************/
170
171 PUBLIC S16 duHdlRlcUlData(Pst *pst, KwuDatIndInfo* datInd, Buffer *mBuf)
172 {
173    DU_LOG("\nDU_APP : Received UL Data at DU_APP");
174  
175    /* Send UL data to CU via EGTP */
176    duSendEgtpDatInd(mBuf);
177    SPutMsg(mBuf);
178
179    return ROK;
180 }
181
182 /**********************************************************************
183          End of file
184 ***********************************************************************/