Merge "DL throughput calculation for UM [Issue-ID: ODUHIGH-319]"
[o-du/l2.git] / src / 5gnrrlc / kw_ul_ex_ms.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**
20   
21         Name:    NR RLC Layer - System Services Interface Functions
22     
23         Type:    C file
24   
25         Desc:    C source code for the interface to System Services
26                   of NR RLC
27  
28         File:    kw_ul_ex_ms.c
29   
30 *********************************************************************21*/
31
32 /** @file kw_ul_ex_ms.c
33 @brief RLC System Services Interface
34 */
35
36 \f
37 /* header (.h) include files */
38 #include "common_def.h"
39 #include "lkw.h"           /* LKW defines */
40 #include "ckw.h"           /* CKW defines */
41 #include "kwu.h"           /* KWU defines */
42 #include "rgu.h"           /* RGU defines */
43 #include "kw_err.h"        /* Err defines */
44 #include "kw_env.h"        /* RLC environment options */
45 #include "kw.h"            /* RLC defines */
46 #include "kw_ul.h"
47 #include "kw_udx.h"
48
49 /* extern (.x) include files */
50 #include "lkw.x"           /* LKW */
51 #include "ckw.x"           /* CKW */
52 #include "kwu.x"           /* KWU */
53 #include "rgu.x"           /* RGU */
54 #include "kw.x"
55 #include "kw_ul.x"
56 #include "kw_udx.x"
57
58 #include "rlc_mac_inf.h"
59 #include "du_app_rlc_inf.h"
60
61 #ifdef TENB_STATS 
62 #include "l2_tenb_stats.x"   
63 #endif
64
65 S16 rlcUlInitExt ARGS (( Void ));
66 \f
67 /**
68  *
69  * @brief
70  *
71  *  <b> Initialize External </b>
72  *
73  *  @b Description:
74  *  Initializes variables used to interface with Upper/Lower Layer  
75  *
76  *  @return  S16
77  *      -# ROK 
78  *
79 */
80   
81 S16 rlcUlInitExt()
82 {
83
84    return ROK;
85 } /* kwInitExt */
86
87
88 \f
89 /***********************************************************************
90                       System Service Interface Functions
91  ***********************************************************************/
92 /**
93  *
94  * @brief
95  *
96  *    <b> Activates Initialization </b>
97  *
98  *    @b Description:
99  *    This function is invoked by system services to initialize the NR RLC
100  *    layer. This is an entry point used by LTE_RLC layer to initialize its
101  *    global variables, before becoming operational.
102  *
103  *    Allowable values for parameters are specified in ssi.h.
104  *
105  *    @param[in] ent    - Specify the entity id of the NR RLC task.
106  *    @param[in] inst   - Specify the entity id of the NR RLC task.
107  *    @param[in] region - Specifies the memory region from which
108  *                         NR RLC should allocate structures and buffers.
109  *    @param[in] reason - Specifies the reason for calling this
110  *                         initialization function.
111  *
112  *  @return  S16
113  *      -# ROK 
114  *
115  */
116 S16 rlcUlActvInit
117 (
118 Ent    ent,                 /* entity */
119 Inst   inst,                /* instance */
120 Region region,              /* region */
121 Reason reason               /* reason */
122 )
123 {
124    RlcCb    *tRlcCb;
125
126    if (inst >= MAX_RLC_INSTANCES)
127    {
128        /* intance greater than MAX instances */ 
129        return RFAILED; 
130    }
131
132    if (rlcCb[inst] != NULLP)
133    {
134        return  (RFAILED);
135    }
136   
137    if (SGetSBuf(region, 0, (Data **)&tRlcCb,
138                 (Size)sizeof (RlcCb)) != ROK)    
139    {                     
140       return RFAILED;
141    }
142
143    /* Initialize rlcCb */
144    RLC_MEM_SET(tRlcCb, 0, sizeof(RlcCb));
145
146    /* Initialize task configuration parameters */
147    tRlcCb->init.ent     = ent;           /* entity */
148    tRlcCb->init.inst    = inst;          /* instance */
149    tRlcCb->init.region  = region;        /* static region */
150    tRlcCb->init.pool    = 0;             /* static pool */
151    tRlcCb->init.reason  = reason;        /* reason */
152    tRlcCb->init.cfgDone = FALSE;         /* configuration done */
153    tRlcCb->init.acnt    = TRUE;          /* enable accounting */
154    tRlcCb->init.usta    = TRUE;          /* enable unsolicited status */
155    tRlcCb->init.trc     = FALSE;         /* enable trace */
156    tRlcCb->init.procId  = ODU_GET_PROCID();
157
158    rlcCb[inst] = tRlcCb;
159
160    /* call external function for intialization */
161    /*
162    kwInitExt();
163    */
164 #ifdef TENB_STATS 
165    TSL2AllocStatsMem(tRlcCb->init.region, tRlcCb->init.pool); 
166 #endif
167
168    return ROK;
169 } /* rlcUlActvInit */
170
171 \f
172 /**
173  *
174  * @brief
175  *
176  *  <b> Activation Task </b>
177  *
178  *  @b Description:
179  *  Processes events received for NR RLC layer via System Services from
180  *  other layers.
181  *
182  *  @param[in] pst   - Pst Structure
183  *  @param[in] mBuf  - Message Buffer
184  *
185  *  @return  S16
186  *      -# ROK 
187  *
188  */
189 S16 rlcUlActvTsk
190 (
191 Pst *pst,              /* pst structure */
192 Buffer *mBuf            /* message buffer */
193 )
194 {
195    S16 ret = ROK;
196
197
198    switch(pst->srcEnt)
199    {
200       case ENTDUAPP:
201          {
202             switch(pst->event)
203             {
204 #ifdef LCLKW
205                case LKW_EVT_CFG_REQ:
206                   {
207                      ret = unpackRlcConfigReq(RlcMiRlcConfigReq, pst, mBuf);
208                      break;
209                   }
210
211                case LKW_EVT_CNTRL_REQ:
212                   {
213                      ret = cmUnpkLkwCntrlReq(RlcMiLkwCntrlReq, pst, mBuf);
214                      break;
215                   }
216                
217                case EVENT_RLC_UE_CREATE_REQ:        /* UE Create Request */
218                   {
219                      ret = unpackRlcUeCreateReq(RlcProcUeCreateReq, pst, mBuf);
220                      break;
221                   }
222               case EVENT_RLC_UE_RECONFIG_REQ:      /* UE Reconfig Request */
223                   {
224                      ret = unpackRlcUeReconfigReq(RlcProcUeReconfigReq, pst, mBuf);
225                      break;
226                   }
227                case EVENT_RLC_UE_DELETE_REQ:
228                   {
229                      ret = unpackRlcUeDeleteReq(RlcProcUeDeleteReq, pst, mBuf);
230                      break;
231                   }
232
233                case LKW_EVT_STS_REQ:
234                   {
235                      ret = cmUnpkLkwStsReq(RlcMiLkwStsReq, pst, mBuf);
236                      break;
237                   }
238
239                case LKW_EVT_STA_REQ:
240                   {
241                      ret = cmUnpkLkwStaReq(RlcMiLkwStaReq, pst, mBuf);
242                      break;
243                   }
244                   /* kw005.201 added support for L2 Measurement */
245 #ifdef LTE_L2_MEAS
246                case LKW_EVT_L2MEAS_REQ:
247                   {
248                      ret = cmUnpkLkwL2MeasReq(RlcMiLkwL2MeasReq, pst, mBuf);
249                      break;
250                   }
251                case LKW_EVT_L2MEAS_SEND_REQ:
252                  {
253
254                     ret = cmUnpkLkwL2MeasSendReq(RlcMiLkwL2MeasSendReq, pst, mBuf); 
255   
256                      break;
257                  }
258                case LKW_EVT_L2MEAS_STOP_REQ:
259                  {
260                      ret = cmUnpkLkwL2MeasStopReq(RlcMiLkwL2MeasStopReq, pst, mBuf);
261                      break;
262                  }
263 #endif
264 #endif  /* LCLKW */
265                default:
266                   ODU_PUT_MSG_BUF(mBuf);
267                   if (pst->dstInst < MAX_RLC_INSTANCES)
268                   {
269                      DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from SM",
270                             pst->event);
271                   }
272                   ret = RFAILED;
273                   break;
274
275             }
276             break;
277          }
278
279       case ENTRLC:
280          {
281             switch(pst->event)
282             {
283 #ifdef LCUDX
284                case UDX_EVT_BND_CFM:              /* Bind request */
285                   {
286                      ret = cmUnpkUdxBndCfm(rlcUlUdxBndCfm, pst, mBuf );
287                      break;
288                   }
289
290                case UDX_EVT_CFG_CFM:             /* Unbind request */
291                   {
292                      ret = cmUnpkUdxCfgCfm(rlcUlUdxCfgCfm, pst, mBuf );
293                      break;
294                   }
295
296                case UDX_EVT_UEIDCHG_CFM:              /* Configuration request */
297                   {
298                      ret = cmUnpkUdxUeIdChgCfm(rlcUlUdxUeIdChgCfm, pst, mBuf);
299                      break;
300                   }
301                
302                case UDX_EVT_STA_PHBT_TMR_START:              /* Status Prohibit Timer Start */
303                   {
304                      ret = cmUnpkUdxStaProhTmrStart(rlcUlUdxStaProhTmrStart, pst, mBuf);
305                      break;
306                   }               
307
308 #endif  /* LCCKW */
309
310                default:
311                   ODU_PUT_MSG_BUF(mBuf);
312                   if (pst->dstInst < MAX_RLC_INSTANCES)
313                   {
314                       DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from RLC UL",
315                             pst->event);
316                   }
317                   ret = RFAILED;
318                   break;
319
320             }
321             break;
322          }
323
324       case ENTNH:
325          {
326             switch(pst->event)
327             {
328 #ifdef LCCKW
329                case CKW_EVT_BND_REQ:              /* Bind request */
330                   {
331                      ret = cmUnpkCkwBndReq(RlcUiCkwBndReq, pst, mBuf );
332                      break;
333                   }
334
335                case CKW_EVT_UBND_REQ:             /* Unbind request */
336                   {
337                      ret = cmUnpkCkwUbndReq(RlcUiCkwUbndReq, pst, mBuf );
338                      break;
339                   }
340
341                case CKW_EVT_UEIDCHG_REQ:              /* Configuration request */
342                   {
343                      ret = cmUnpkCkwUeIdChgReq(RlcUiCkwUeIdChgReq, pst, mBuf);
344                      break;
345                   }
346
347 #endif  /* LCCKW */
348
349 #ifdef LCKWU
350                case KWU_EVT_BND_REQ:              /* Bind request */
351                   {
352                      ret = cmUnpkKwuBndReq(RlcUiKwuBndReq, pst, mBuf );
353                      break;
354                   }
355
356                case KWU_EVT_UBND_REQ:             /* Unbind request */
357                   {
358                      ret = cmUnpkKwuUbndReq(RlcUiKwuUbndReq, pst, mBuf );
359                      break;
360                   }
361 #endif  /* LCKWU */
362                default:
363                   ODU_PUT_MSG_BUF(mBuf);
364                   if (pst->dstInst < MAX_RLC_INSTANCES)
365                   {
366                       DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from RRC", 
367                             pst->event);
368                   }
369                   ret = RFAILED;
370                   break;
371
372             }
373             break;
374          }
375
376       case ENTPJ:
377          {
378             switch(pst->event)
379             {
380 #ifdef LCKWU
381                case KWU_EVT_BND_REQ:              /* Bind request */
382                   {
383                      ret = cmUnpkKwuBndReq(RlcUiKwuBndReq, pst, mBuf );
384                      break;
385                   }
386
387                case KWU_EVT_UBND_REQ:             /* Unbind request */
388                   {
389                      ret = cmUnpkKwuUbndReq(RlcUiKwuUbndReq, pst, mBuf );
390                      break;
391                   }
392
393                default:
394                   ODU_PUT_MSG_BUF(mBuf);
395                   if (pst->dstInst < MAX_RLC_INSTANCES)
396                   {
397                       DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from PDCP", 
398                             pst->event);
399                   }
400                   ret = RFAILED;
401                   break;
402 #endif  /* LCKWU */
403                }
404             break;
405          }
406
407       case ENTMAC:
408          {
409             switch(pst->event)
410             {
411 #ifdef LCRGU
412                case EVTRGUBNDCFM:     /* Bind request */
413                   {
414                      ret = cmUnpkRguBndCfm(RlcLiRguBndCfm, pst, mBuf );
415                      break;
416                   }
417
418                case EVENT_UL_DATA_TO_RLC:    /* UL Data request */
419                   {
420                      ret = unpackRlcUlData(RlcProcUlData, pst, mBuf);
421                      break;
422                   }
423
424 #endif  /* LCRGU */
425
426                default:
427                   ODU_PUT_MSG_BUF(mBuf);
428                   if (pst->dstInst < MAX_RLC_INSTANCES)
429                   {
430                       DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from MAC",
431                             pst->event);
432                   }
433                   ret = RFAILED;
434                   break;
435             }
436             break;
437          }
438 #if defined(L2_L3_SPLIT) && defined (TENB_T2K3K_SPECIFIC_CHANGES) && defined (MAC_RLC_UL_RBUF)
439       case ENTYS:
440          {
441             switch(pst->event)
442             {
443                case KWU_EVT_TTI_IND:
444                   {
445                      rlcUlBatchProc();
446                      ODU_PUT_MSG_BUF(mBuf);
447                      break;
448                   }
449             }
450             break;
451          }
452 #endif/* End for TENB_T2K3K_SPECIFIC_CHANGES and L2_L3_SPLIT */
453 #ifndef UL_RLC_NET_CLUSTER
454 #ifdef TENB_STATS
455       case ENTLWRMAC:
456          {
457             switch(pst->event)
458             {
459                case TENBSTATSINIT:
460                {
461                   
462                   RlcCb *tRlcCb;
463                   tRlcCb = RLC_GET_RLCCB(pst->dstInst);
464
465                   TSL2SendStatsToApp(&(tRlcCb->genCfg.lmPst), 0);
466                   ODU_PUT_MSG_BUF(mBuf);
467                   break;
468                }
469                default:
470                {
471                   DU_LOG("\nERROR  -->  RLC_UL : Invalid Event[%d] from CL to PDCPUL\n", 
472                          pst->event);
473                   ODU_PUT_MSG_BUF(mBuf);
474                   break;
475                }
476             }
477             break;
478          }
479 #endif
480 #endif
481       default:
482          {
483           if (pst->dstInst < MAX_RLC_INSTANCES)
484            {
485               DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Source Entity[%d]",pst->event);
486            }
487             ODU_PUT_MSG_BUF(mBuf);
488             ret = RFAILED;
489             break;
490          }
491     }
492    ODU_EXIT_TASK();
493
494    return (ret);
495 } /* kwActvTsk */
496
497
498 \f  
499 /********************************************************************30**
500          End of file
501 **********************************************************************/