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