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