Deleted the rlog folder
[o-du/l2.git] / src / 5gnrrlc / kw_tmm_ul.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
19 /**********************************************************************
20
21      Name:     NR RLC Layer 
22   
23      Type:     C file
24   
25      Desc:     Source code for RLC Transparent mode assembly and
26                reassembly.This file contains following functions
27                 
28                   --rlcTmmQSdu
29                   --rlcTmmSendToMac
30                   --rlcTmmRcvFrmMac
31                   --kwTmmReEstablish 
32
33      File:     kw_tmm_ul.c
34
35 **********************************************************************/
36
37 /** @file kw_tmm_ul.c
38 @brief RLC Transparent Mode module
39 */
40 \f
41 /* header (.h) include files */
42 #include "common_def.h"
43 #include "lkw.h"           /* LKW defines */
44 #include "ckw.h"           /* CKW defines */
45 #include "kwu.h"           /* KWU defines */
46 #include "rgu.h"           /* RGU defines */
47 #include "kw_env.h"        /* RLC environment options */
48
49 #include "kw.h"            /* RLC defines */
50 #include "kw_err.h"            /* RLC defines */
51 #include "kw_ul.h"
52
53 /* extern (.x) include files */
54 #include "lkw.x"           /* LKW */
55 #include "ckw.x"           /* CKW */
56 #include "kwu.x"           /* KWU */
57 #include "rgu.x"           /* RGU */
58
59 #include "kw.x"
60 #include "kw_ul.x"
61 #include "du_app_rlc_inf.h"
62 #include "rlc_utils.h"
63 #include "rlc_upr_inf_api.h"
64
65 #if defined(PRE_DEF_UE_CTX) || defined(PRE_DEF_UE_CTX_HO)
66 #ifdef EG_GEN_LOAD_5GTF
67 uint32_t loadStart;
68 #endif
69
70 S16 PjUiPjuDatInd(Pst* pst,SuId suId,CmLtePdcpId * pdcpId,Buffer *mBuf);
71 Void AddUeContext
72 (
73 CmLteRnti   crnti,
74 uint8_t rrcMsgType
75 )
76 {
77    KwuDatIndInfo   *datIndInfo;   /* Data Indication Information */
78    uint8_t rrcConReq[6] ={ 0x50, 0x30, 0x30, 0x30, 0x30, 0x34 };
79    uint8_t rrcConSetupComplete[34] ={ 0x20, 0x00, 0x3e, 0x0e, 0x82, 0x02, 0x10, 0x12, 0x20, 0x02, 0x20, 0x64, 0xa8, 0x2c, 0x48, 0x05, 0x00, 0x80, 0x00, 0x08, 0x04, 0x03, 0xa0, 0x02, 0xa0, 0x10, 0x12, 0x20, 0x02, 0x20, 0x64, 0xa8, 0x2c, 0x48};
80 #ifndef CA_PAL_5GTF 
81    uint8_t rrcUeCapabilityInfo[12] ={0x38, 0x01, 0x00, 0x80, 0x1b, 0xff, 0x0c, 0x00, 0x20, 0x00, 0x80, 0x00};
82 #else
83   /* uint8_t rrcUeCapabilityInfo[44] ={0x38,0x01,0x02,0x84,0x9b,0xff,0x0c,0x00,0x20,0x00,0x80,0x1f,0xfe,0xf4,0x4f,0xe0,0x40,0x03,0x80,0x11,0x04,0x0c,0x20,0x88,0x20,0x7f,0xff,0xff,0xff,0xf3,0xff,0x81,0xff,0xff,0xff,0xff,0x7f,0xf0,0x3f,0xff,0xff,0xff,0xe0,0x00};
84 */
85 uint8_t rrcUeCapabilityInfo[] = 
86 {
87  0x38,0x01,0x03,0x34,0x9b,0xff,0x0c,0x00,0x20,0x00,0x80,0x1f,0xfe,0xf4,0x4f,0xe0
88  ,0x40,0x09,0x80,0x11,0x04,0x0c,0x20,0x88,0x20,0x63,0x04,0x41,0x03,0x20,0x22,0x08
89  ,0x19,0x61,0x10,0x40,0xff,0xff,0xff,0xff,0xe7,0xff,0x03,0xff,0xff,0xff,0xfe,0xff
90  ,0xe0,0x7f,0xff,0xff,0xff,0xc0,0x00
91 };
92
93 #endif
94    uint8_t rrcSecurityModeComplete[2] ={0x28, 0x80};
95    uint8_t rrcReconfigComplete[2] ={0x10, 0x80};
96
97    Buffer *pdu;
98
99    Pst ulPst1 ={100,100,217,0,215,0,PRIOR0,0,81,1,1,0,0};
100 #ifdef PJ
101    Pst ulPst2 ={100,100,217,0,216,0,PRIOR0,0,68,0,1,0,0};
102 #endif
103
104   if(1 == rrcMsgType)
105   {
106
107    KwuDatIndInfo datIndInfoTmp;
108    datIndInfo = &datIndInfoTmp;
109    datIndInfo->rlcId.rbId = 5;
110    datIndInfo->rlcId.rbType = 0;
111    datIndInfo->rlcId.ueId = 0;
112    datIndInfo->rlcId.cellId = 1;
113    datIndInfo->tCrnti = crnti;
114    datIndInfo->isOutOfSeq = 16;
115
116    SGetMsg(DFLT_REGION, DFLT_POOL, (Buffer **) &pdu);
117   
118    SAddPstMsgMult(rrcConReq,6,pdu);
119
120    DU_LOG("\nINFO  -->  RLC_UL : Profiling Framework Sending RRC Connection Req to RRC for UE :%d\n",crnti);
121    rlcSendUlDataToDu(&ulPst1, datIndInfo, pdu);
122  }
123  else if(2 == rrcMsgType)
124  {
125 #ifdef PJ
126     CmLtePdcpId pdcpId;
127     pdcpId.cellId = 1;
128     pdcpId.ueId = crnti;
129     pdcpId.rbId = 1;
130     pdcpId.rbType = 0;
131 #endif   
132     SGetMsg(DFLT_REGION, DFLT_POOL, (Buffer **) &pdu);
133   
134     SAddPstMsgMult(rrcConSetupComplete,34,pdu);
135
136     DU_LOG("\nINFO  -->  RLC_UL : Profiling Framework: Sending RRC Connection Setup Complete to RRC for UE :%d\n",crnti);
137 #ifdef PJ
138     PjUiPjuDatInd(&ulPst2, 1, &pdcpId, pdu);
139 #endif
140  }
141  
142  else if(3 == rrcMsgType)
143  {
144 #ifdef PJ
145     CmLtePdcpId pdcpId;
146     pdcpId.cellId = 1;
147     pdcpId.ueId = crnti;
148     pdcpId.rbId = 1;
149     pdcpId.rbType = 0;
150 #endif   
151     SGetMsg(DFLT_REGION, DFLT_POOL, (Buffer **) &pdu);
152   
153 #ifndef CA_PAL_5GTF 
154     SAddPstMsgMult(rrcUeCapabilityInfo,12,pdu);
155 #else    
156     SAddPstMsgMult(rrcUeCapabilityInfo,sizeof(rrcUeCapabilityInfo),pdu);
157 #endif
158     DU_LOG("\nINFO  -->  RLC_UL : Profiling Framework: Sending RRC UE Capability Info to RRC for UE :%d\n",crnti);
159 #ifdef PJ
160     PjUiPjuDatInd(&ulPst2, 1, &pdcpId, pdu);
161 #endif
162
163  }
164  else if(4 == rrcMsgType)
165  {
166 #ifdef PJ
167     CmLtePdcpId pdcpId;
168     pdcpId.cellId = 1;
169     pdcpId.ueId = crnti;
170     pdcpId.rbId = 1;
171     pdcpId.rbType = 0;
172 #endif
173    
174     SGetMsg(DFLT_REGION, DFLT_POOL, (Buffer **) &pdu);
175   
176     SAddPstMsgMult(rrcSecurityModeComplete,2,pdu);
177
178     DU_LOG("\nINFO  -->  RLC_UL : Profiling Framework: Sending RRC Security Mode Complete to RRC for UE :%d\n",crnti);
179 #ifdef PJ
180     PjUiPjuDatInd(&ulPst2, 1, &pdcpId, pdu);
181 #endif
182  }
183  else if(5 == rrcMsgType)
184  {
185 #ifdef PJ
186     CmLtePdcpId pdcpId;
187     pdcpId.cellId = 1;
188     pdcpId.ueId = crnti;
189     pdcpId.rbId = 1;
190     pdcpId.rbType = 0;
191 #endif
192    
193     SGetMsg(DFLT_REGION, DFLT_POOL, (Buffer **) &pdu);
194   
195     SAddPstMsgMult(rrcReconfigComplete,2,pdu);
196
197     DU_LOG("\nINFO  -->  RLC_UL : Profiling Framework: Sending RRC Reconfig Complete to RRC for UE :%d\n",crnti);
198 #ifdef PJ
199     PjUiPjuDatInd(&ulPst2, 1, &pdcpId, pdu);
200 #ifdef EG_GEN_LOAD_5GTF
201     loadStart=1;
202 #endif
203 #endif
204  }
205  return;
206 }
207 #endif 
208 /** @addtogroup tmmode */
209 /*@{*/
210
211 #define RLC_MODULE (RLC_DBGMASK_TM | RLC_DBGMASK_UL)
212
213 /**
214  * @brief
215  *    Handler to process the Data Indication from the lower layer and send the 
216  *    SDU to upper layer.
217  *
218  * @details
219  *    This function processes the PDU receivied from the lower layer and sends 
220  *    the same pdu as SDU to the upper layer.It sends CRNTI along with the SDU 
221  *    for CCCH.
222  *            
223  * @param[in] gCb     RLC Instance Control Block
224  * @param[in] rbCb    RB control block. 
225  * @param[in] tCrnti  TCRNTI  
226  * @param[in] pdu     PDU
227  * 
228  * @return  S16
229  *    -# ROK 
230  *    -# RFAILED 
231  */
232 #ifdef CCPU_OPT
233 void rlcTmmRcvFrmMac(RlcCb *gCb, RlcUlRbCb *rbCb, CmLteRnti tCrnti, Buffer *pdu)
234 #else
235 void rlcTmmRcvFrmMac(RlcCb *gCb, RlcUlRbCb *rbCb, Buffer *pdu)
236 #endif
237 {
238    RlcUlRrcMsgInfo  *ulRrcMsgInfo;
239    uint16_t         msgLen;
240    uint16_t         copyLen;    /* Number of bytes copied */
241    Pst              pst;
242  
243    gCb->genSts.pdusRecv++;
244    ODU_GET_MSG_LEN(pdu, (MsgLen *)&msgLen);
245    gCb->genSts.bytesRecv += msgLen;
246   
247    /* Filling UL RRC Message Info */
248    RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL,
249       ulRrcMsgInfo, sizeof(RlcUlRrcMsgInfo));
250    if (ulRrcMsgInfo)
251    {
252       ulRrcMsgInfo->cellId = rbCb->rlcId.cellId;
253       ulRrcMsgInfo->ueIdx = rbCb->rlcId.ueId;
254       ulRrcMsgInfo->lcId = rbCb->lch.lChId;
255       RLC_ALLOC_SHRABL_BUF(RLC_MEM_REGION_UL, RLC_POOL,
256          ulRrcMsgInfo->rrcMsg, msgLen);
257       if (ulRrcMsgInfo->rrcMsg)
258       {
259          ODU_COPY_MSG_TO_FIX_BUF(pdu, 0, msgLen, ulRrcMsgInfo->rrcMsg, (MsgLen *)&copyLen);
260          ulRrcMsgInfo->msgLen = msgLen;
261
262          /* Sending UL RRC Message transfeer to DU APP */
263          memset(&pst, 0, sizeof(Pst));
264          FILL_PST_RLC_TO_DUAPP(pst, RLC_UL_INST, EVENT_UL_RRC_MSG_TRANS_TO_DU);
265          rlcSendUlRrcMsgToDu(&pst, ulRrcMsgInfo);
266       }
267       else
268       {
269          DU_LOG("\nERROR  -->  RLC_UL : rlcTmmRcvFrmMac: Memory allocation failed for UL RRC Msg");
270       }
271    }
272    else
273    {
274       DU_LOG("\nERROR  -->  RLC_UL : rlcTmmRcvFrmMac: Memory allocation failed for ulRrcMsgInfo");
275    }
276  
277    return;
278 }
279
280 /**
281  * @brief 
282  *    Handler to process the re-establishment request received from the upper 
283  *    layer. It is just a hook for future enhancement. 
284  *
285  *            
286  * @param[in] gCb   RLC Instance Control Block
287  * @param[in] rbCb  RB control block. 
288  *
289  * @return  S16
290  *    -# ROK 
291  *       
292  **/
293 Void rlcTmmUlReEstablish
294 (
295 RlcCb        *gCb,
296 RlcUlRbCb    *rbCb        
297 )
298 {
299    DU_LOG("\nINFO  -->  RLC_UL : do nothing for TMM for ReEstablish");
300    return;
301 }
302
303 #ifdef _cplusplus
304 }
305 #endif
306 /*@}*/
307 /********************************************************************30**
308          End of file
309 **********************************************************************/