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