[Epic-ID: ODUHIGH-488][Task-ID: ODUHIGH-501] WG8 Alignment | UE RLC Re-establishment...
[o-du/l2.git] / src / 5gnrrlc / rlc_ul_msg_router.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:    rlc_ul_msg_router.c
29   
30 *********************************************************************21*/
31
32 /** @file rlc_ul_msg_router.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 "rlc_err.h"        /* Err defines */
44 #include "rlc_env.h"        /* RLC environment options */
45
46
47 /* extern (.x) include files */
48 #include "lkw.x"           /* LKW */
49 #include "ckw.x"           /* CKW */
50 #include "kwu.x"           /* KWU */
51 #include "rgu.x"           /* RGU */
52
53 #include "rlc_utils.h"            /* RLC defines */
54 #include "rlc_dl_ul_inf.h"
55 #include "rlc_ul.h"
56 #include "rlc_mac_inf.h"
57 #include "du_app_rlc_inf.h"
58
59 #ifdef TENB_STATS 
60 #include "l2_tenb_stats.x"   
61 #endif
62
63
64 S16 rlcUlInitExt ARGS (( Void ));
65 \f
66 /**
67  *
68  * @brief
69  *
70  *  <b> Initialize External </b>
71  *
72  *  @b Description:
73  *  Initializes variables used to interface with Upper/Lower Layer  
74  *
75  *  @return  S16
76  *      -# ROK 
77  *
78 */
79   
80 S16 rlcUlInitExt()
81 {
82
83    return ROK;
84 } /* kwInitExt */
85
86
87 \f
88 /***********************************************************************
89                       System Service Interface Functions
90  ***********************************************************************/
91 /**
92  *
93  * @brief
94  *
95  *    <b> Activates Initialization </b>
96  *
97  *    @b Description:
98  *    This function is invoked by system services to initialize the NR RLC
99  *    layer. This is an entry point used by LTE_RLC layer to initialize its
100  *    global variables, before becoming operational.
101  *
102  *    Allowable values for parameters are specified in ssi.h.
103  *
104  *    @param[in] ent    - Specify the entity id of the NR RLC task.
105  *    @param[in] inst   - Specify the entity id of the NR RLC task.
106  *    @param[in] region - Specifies the memory region from which
107  *                         NR RLC should allocate structures and buffers.
108  *    @param[in] reason - Specifies the reason for calling this
109  *                         initialization function.
110  *
111  *  @return  S16
112  *      -# ROK 
113  *
114  */
115 S16 rlcUlActvInit
116 (
117 Ent    ent,                 /* entity */
118 Inst   inst,                /* instance */
119 Region region,              /* region */
120 Reason reason               /* reason */
121 )
122 {
123    RlcCb    *tRlcCb;
124
125    if (inst >= MAX_RLC_INSTANCES)
126    {
127        /* intance greater than MAX instances */ 
128        return RFAILED; 
129    }
130
131    if (rlcCb[inst] != NULLP)
132    {
133        return  (RFAILED);
134    }
135   
136    if (SGetSBuf(region, 0, (Data **)&tRlcCb,
137                 (Size)sizeof (RlcCb)) != ROK)    
138    {                     
139       return RFAILED;
140    }
141
142    /* Initialize rlcCb */
143    RLC_MEM_SET(tRlcCb, 0, sizeof(RlcCb));
144
145    /* Initialize task configuration parameters */
146    tRlcCb->init.ent     = ent;           /* entity */
147    tRlcCb->init.inst    = inst;          /* instance */
148    tRlcCb->init.region  = region;        /* static region */
149    tRlcCb->init.pool    = 0;             /* static pool */
150    tRlcCb->init.reason  = reason;        /* reason */
151    tRlcCb->init.cfgDone = FALSE;         /* configuration done */
152    tRlcCb->init.acnt    = TRUE;          /* enable accounting */
153    tRlcCb->init.usta    = TRUE;          /* enable unsolicited status */
154    tRlcCb->init.trc     = FALSE;         /* enable trace */
155    tRlcCb->init.procId  = ODU_GET_PROCID();
156
157    rlcCb[inst] = tRlcCb;
158
159    /* call external function for intialization */
160    /*
161    kwInitExt();
162    */
163 #ifdef TENB_STATS 
164    TSL2AllocStatsMem(tRlcCb->init.inst); 
165 #endif
166
167    return ROK;
168 } /* rlcUlActvInit */
169
170 #ifdef CALL_FLOW_DEBUG_LOG
171 /*
172 * @brief
173 *
174 * Function:
175 *   name : callFlowRlcUlActvTsk 
176 *
177 *  @b Description:
178 *  Function used to print values of src, dest, message
179 *  received at the layer
180 *
181 *  @param[in] pst   - Pst Structure
182 *
183 *  @return void
184 */
185
186 void callFlowRlcUlActvTsk(Pst *pst)
187 {
188    char sourceTask[50];
189    char destTask[50]="ENTRLCUL";
190    char message[100];
191    
192    switch(pst->srcEnt)
193    {
194       case ENTDUAPP:
195          {
196             strcpy(sourceTask,"ENTDUAPP");
197             switch(pst->event)
198             {
199 #ifdef LCLKW
200                case LKW_EVT_CFG_REQ:
201                   {
202                      strcpy(message,"LKW_EVT_CFG_REQ");
203                      break;
204                   }
205
206                case LKW_EVT_CNTRL_REQ:
207                   {
208                      strcpy(message,"LKW_EVT_CNTRL_REQ");
209                      break;
210                   }
211                
212                case EVENT_RLC_UE_CREATE_REQ:        /* UE Create Request */
213                   {
214                      strcpy(message,"EVENT_RLC_UE_CREATE_REQ");
215                      break;
216                   }
217               case EVENT_RLC_UE_RECONFIG_REQ:      /* UE Reconfig Request */
218                   {
219                      strcpy(message,"EVENT_RLC_UE_RECONFIG_REQ");
220                      break;
221                   }
222                case EVENT_RLC_UE_DELETE_REQ:
223                   {
224                      strcpy(message,"EVENT_RLC_UE_DELETE_REQ");
225                      break;
226                   }
227
228                case LKW_EVT_STS_REQ:
229                   {
230                      strcpy(message,"LKW_EVT_STS_REQ");
231                      break;
232                   }
233
234                case LKW_EVT_STA_REQ:
235                   {
236                      strcpy(message,"LKW_EVT_STA_REQ");
237                      break;
238                   }
239                   /* kw005.201 added support for L2 Measurement */
240 #endif  /* LCLKW */
241                default:
242                   {
243                      strcpy(message,"Invalid Event");
244                   break;
245                  }
246             }
247             break;
248          }
249
250       case ENTRLC:
251          {
252             strcpy(sourceTask,"ENTRLC");
253             switch(pst->event)
254             {
255 #ifdef LCUDX
256                case UDX_EVT_BND_CFM:              /* Bind request */
257                   {
258                      strcpy(message,"UDX_EVT_BND_CFM");
259                      break;
260                   }
261
262                case UDX_EVT_CFG_CFM:             /* Unbind request */
263                   {
264                      strcpy(message,"UDX_EVT_CFG_CFM");
265                      break;
266                   }
267
268                case UDX_EVT_UEIDCHG_CFM:              /* Configuration request */
269                   {
270                      strcpy(message,"UDX_EVT_UEIDCHG_CFM");
271                      break;
272                   }
273                
274                case UDX_EVT_STA_PHBT_TMR_START:              /* Status Prohibit Timer Start */
275                   {
276                      strcpy(message,"UDX_EVT_STA_PHBT_TMR_START");
277                      break;
278                   }               
279
280 #endif  /* LCCKW */
281
282                default:
283                      strcpy(message,"Invalid Event");
284                   break;
285
286             }
287             break;
288          }
289
290       case ENTMAC:
291          {
292             strcpy(sourceTask,"ENTMAC");
293             switch(pst->event)
294             {
295 #ifdef LCRGU
296                case EVTRGUBNDCFM:     /* Bind request */
297                   {
298                      strcpy(message,"EVTRGUBNDCFM");
299                      break;
300                   }
301
302                case EVENT_UL_DATA_TO_RLC:    /* UL Data request */
303                   {
304                      strcpy(message,"EVENT_UL_DATA_TO_RLC");
305                      break;
306                   }
307
308 #endif  /* LCRGU */
309
310                default:
311                      strcpy(message,"Invalid Event");
312                   break;
313             }
314             break;
315          }
316       default:
317          {
318             strcpy(sourceTask,"Invalid Source Entity Id");
319          }
320     }
321     DU_LOG("\nCall Flow: %s -> %s : %s\n", sourceTask, destTask, message);
322
323
324 #endif
325
326 \f  
327 \f
328 /**
329  *
330  * @brief
331  *
332  *  <b> Activation Task </b>
333  *
334  *  @b Description:
335  *  Processes events received for NR RLC layer via System Services from
336  *  other layers.
337  *
338  *  @param[in] pst   - Pst Structure
339  *  @param[in] mBuf  - Message Buffer
340  *
341  *  @return  S16
342  *      -# ROK 
343  *
344  */
345 S16 rlcUlActvTsk
346 (
347 Pst *pst,              /* pst structure */
348 Buffer *mBuf            /* message buffer */
349 )
350 {
351    S16 ret = ROK;
352
353 #ifdef CALL_FLOW_DEBUG_LOG
354    callFlowRlcUlActvTsk(pst);
355 #endif
356
357    switch(pst->srcEnt)
358    {
359       case ENTDUAPP:
360          {
361             switch(pst->event)
362             {
363 #ifdef LCLKW
364                case LKW_EVT_CFG_REQ:
365                   {
366                      ret = unpackRlcConfigReq(RlcMiRlcConfigReq, pst, mBuf);
367                      break;
368                   }
369
370                case LKW_EVT_CNTRL_REQ:
371                   {
372                      ret = cmUnpkLkwCntrlReq(RlcMiLkwCntrlReq, pst, mBuf);
373                      break;
374                   }
375                
376                case EVENT_RLC_UE_CREATE_REQ:        /* UE Create Request */
377                   {
378                      ret = unpackRlcUeCreateReq(RlcProcUeCreateReq, pst, mBuf);
379                      break;
380                   }
381               case EVENT_RLC_UE_RECONFIG_REQ:      /* UE Reconfig Request */
382                   {
383                      ret = unpackRlcUeReconfigReq(RlcProcUeReconfigReq, pst, mBuf);
384                      break;
385                   }
386                case EVENT_RLC_UE_DELETE_REQ:
387                   {
388                      ret = unpackRlcUeDeleteReq(RlcProcUeDeleteReq, pst, mBuf);
389                      break;
390                   }
391                case EVENT_RLC_UE_REESTABLISH_REQ:
392                   {
393                      ret = unpackRlcUeReestablishReq(RlcProcUeReestablishReq, pst, mBuf);
394                      break;
395                   }
396
397                case LKW_EVT_STS_REQ:
398                   {
399                      ret = cmUnpkLkwStsReq(RlcMiLkwStsReq, pst, mBuf);
400                      break;
401                   }
402
403                case LKW_EVT_STA_REQ:
404                   {
405                      ret = cmUnpkLkwStaReq(RlcMiLkwStaReq, pst, mBuf);
406                      break;
407                   }
408                   /* kw005.201 added support for L2 Measurement */
409 #ifdef LTE_L2_MEAS
410                case LKW_EVT_L2MEAS_REQ:
411                   {
412                      ret = cmUnpkLkwL2MeasReq(RlcMiLkwL2MeasReq, pst, mBuf);
413                      break;
414                   }
415                case LKW_EVT_L2MEAS_SEND_REQ:
416                  {
417
418                     ret = cmUnpkLkwL2MeasSendReq(RlcMiLkwL2MeasSendReq, pst, mBuf); 
419   
420                      break;
421                  }
422                case LKW_EVT_L2MEAS_STOP_REQ:
423                  {
424                      ret = cmUnpkLkwL2MeasStopReq(RlcMiLkwL2MeasStopReq, pst, mBuf);
425                      break;
426                  }
427 #endif
428 #endif  /* LCLKW */
429                default:
430                   ODU_PUT_MSG_BUF(mBuf);
431                   if (pst->dstInst < MAX_RLC_INSTANCES)
432                   {
433                      DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from SM",
434                             pst->event);
435                   }
436                   ret = RFAILED;
437                   break;
438
439             }
440             break;
441          }
442
443       case ENTRLC:
444          {
445             switch(pst->event)
446             {
447 #ifdef LCUDX
448                case UDX_EVT_BND_CFM:              /* Bind request */
449                   {
450                      ret = cmUnpkUdxBndCfm(rlcUlUdxBndCfm, pst, mBuf );
451                      break;
452                   }
453
454                case UDX_EVT_CFG_CFM:             /* Unbind request */
455                   {
456                      ret = cmUnpkUdxCfgCfm(rlcUlUdxCfgCfm, pst, mBuf );
457                      break;
458                   }
459
460                case UDX_EVT_UEIDCHG_CFM:              /* Configuration request */
461                   {
462                      ret = cmUnpkUdxUeIdChgCfm(rlcUlUdxUeIdChgCfm, pst, mBuf);
463                      break;
464                   }
465                
466                case UDX_EVT_STA_PHBT_TMR_START:              /* Status Prohibit Timer Start */
467                   {
468                      ret = cmUnpkUdxStaProhTmrStart(rlcUlUdxStaProhTmrStart, pst, mBuf);
469                      break;
470                   }               
471
472 #endif  /* LCCKW */
473
474                default:
475                   ODU_PUT_MSG_BUF(mBuf);
476                   if (pst->dstInst < MAX_RLC_INSTANCES)
477                   {
478                       DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from RLC UL",
479                             pst->event);
480                   }
481                   ret = RFAILED;
482                   break;
483
484             }
485             break;
486          }
487
488       case ENTNH:
489          {
490             switch(pst->event)
491             {
492 #ifdef LCCKW
493                case CKW_EVT_BND_REQ:              /* Bind request */
494                   {
495                      ret = cmUnpkCkwBndReq(RlcUiCkwBndReq, pst, mBuf );
496                      break;
497                   }
498
499                case CKW_EVT_UBND_REQ:             /* Unbind request */
500                   {
501                      ret = cmUnpkCkwUbndReq(RlcUiCkwUbndReq, pst, mBuf );
502                      break;
503                   }
504
505                case CKW_EVT_UEIDCHG_REQ:              /* Configuration request */
506                   {
507                      ret = cmUnpkCkwUeIdChgReq(RlcUiCkwUeIdChgReq, pst, mBuf);
508                      break;
509                   }
510
511 #endif  /* LCCKW */
512
513 #ifdef LCKWU
514                case KWU_EVT_BND_REQ:              /* Bind request */
515                   {
516                      ret = cmUnpkKwuBndReq(RlcUiKwuBndReq, pst, mBuf );
517                      break;
518                   }
519
520                case KWU_EVT_UBND_REQ:             /* Unbind request */
521                   {
522                      ret = cmUnpkKwuUbndReq(RlcUiKwuUbndReq, pst, mBuf );
523                      break;
524                   }
525 #endif  /* LCKWU */
526                default:
527                   ODU_PUT_MSG_BUF(mBuf);
528                   if (pst->dstInst < MAX_RLC_INSTANCES)
529                   {
530                       DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from RRC", 
531                             pst->event);
532                   }
533                   ret = RFAILED;
534                   break;
535
536             }
537             break;
538          }
539
540       case ENTPJ:
541          {
542             switch(pst->event)
543             {
544 #ifdef LCKWU
545                case KWU_EVT_BND_REQ:              /* Bind request */
546                   {
547                      ret = cmUnpkKwuBndReq(RlcUiKwuBndReq, pst, mBuf );
548                      break;
549                   }
550
551                case KWU_EVT_UBND_REQ:             /* Unbind request */
552                   {
553                      ret = cmUnpkKwuUbndReq(RlcUiKwuUbndReq, pst, mBuf );
554                      break;
555                   }
556
557                default:
558                   ODU_PUT_MSG_BUF(mBuf);
559                   if (pst->dstInst < MAX_RLC_INSTANCES)
560                   {
561                       DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from PDCP", 
562                             pst->event);
563                   }
564                   ret = RFAILED;
565                   break;
566 #endif  /* LCKWU */
567                }
568             break;
569          }
570
571       case ENTMAC:
572          {
573             switch(pst->event)
574             {
575 #ifdef LCRGU
576                case EVTRGUBNDCFM:     /* Bind request */
577                   {
578                      ret = cmUnpkRguBndCfm(RlcLiRguBndCfm, pst, mBuf );
579                      break;
580                   }
581
582                case EVENT_UL_DATA_TO_RLC:    /* UL Data request */
583                   {
584                      ret = unpackRlcUlData(RlcProcUlData, pst, mBuf);
585                      break;
586                   }
587
588 #endif  /* LCRGU */
589
590                default:
591                   ODU_PUT_MSG_BUF(mBuf);
592                   if (pst->dstInst < MAX_RLC_INSTANCES)
593                   {
594                       DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from MAC",
595                             pst->event);
596                   }
597                   ret = RFAILED;
598                   break;
599             }
600             break;
601          }
602 #if defined(L2_L3_SPLIT) && defined (TENB_T2K3K_SPECIFIC_CHANGES) && defined (MAC_RLC_UL_RBUF)
603       case ENTYS:
604          {
605             switch(pst->event)
606             {
607                case KWU_EVT_TTI_IND:
608                   {
609                      rlcUlBatchProc();
610                      ODU_PUT_MSG_BUF(mBuf);
611                      break;
612                   }
613             }
614             break;
615          }
616 #endif/* End for TENB_T2K3K_SPECIFIC_CHANGES and L2_L3_SPLIT */
617 #ifndef UL_RLC_NET_CLUSTER
618 #ifdef TENB_STATS
619       case ENTLWRMAC:
620          {
621             switch(pst->event)
622             {
623                case TENBSTATSINIT:
624                {
625                   
626                   RlcCb *tRlcCb;
627                   tRlcCb = RLC_GET_RLCCB(pst->dstInst);
628
629                   TSL2SendStatsToApp(&(tRlcCb->genCfg.lmPst), 0);
630                   ODU_PUT_MSG_BUF(mBuf);
631                   break;
632                }
633                default:
634                {
635                   DU_LOG("\nERROR  -->  RLC_UL : Invalid Event[%d] from CL to PDCPUL\n", 
636                          pst->event);
637                   ODU_PUT_MSG_BUF(mBuf);
638                   break;
639                }
640             }
641             break;
642          }
643 #endif
644 #endif
645       default:
646          {
647           if (pst->dstInst < MAX_RLC_INSTANCES)
648            {
649               DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Source Entity[%d]",pst->event);
650            }
651             ODU_PUT_MSG_BUF(mBuf);
652             ret = RFAILED;
653             break;
654          }
655     }
656    ODU_EXIT_TASK();
657
658    return (ret);
659 } /* kwActvTsk */
660
661
662 \f  
663 /********************************************************************30**
664          End of file
665 **********************************************************************/