24b55b76ddab25cb229198a5800e861d1d6642cb
[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 /*
171 * @brief
172 *
173 * Function:
174 *   name : callFlowRlcUlActvTsk 
175 *
176 *  @b Description:
177 *  Function used to print values of src, dest, message
178 *  received at the layer
179 *
180 *  @param[in] pst   - Pst Structure
181 *
182 *  @return void
183 */
184
185 void callFlowRlcUlActvTsk(Pst *pst)
186 {
187    char sourceTask[50];
188    char destTask[50]="ENTRLCUL";
189    char message[100];
190    
191    switch(pst->srcEnt)
192    {
193       case ENTDUAPP:
194          {
195             strcpy(sourceTask,"ENTDUAPP");
196             switch(pst->event)
197             {
198 #ifdef LCLKW
199                case LKW_EVT_CFG_REQ:
200                   {
201                      strcpy(message,"LKW_EVT_CFG_REQ");
202                      break;
203                   }
204
205                case LKW_EVT_CNTRL_REQ:
206                   {
207                      strcpy(message,"LKW_EVT_CNTRL_REQ");
208                      break;
209                   }
210                
211                case EVENT_RLC_UE_CREATE_REQ:        /* UE Create Request */
212                   {
213                      strcpy(message,"EVENT_RLC_UE_CREATE_REQ");
214                      break;
215                   }
216               case EVENT_RLC_UE_RECONFIG_REQ:      /* UE Reconfig Request */
217                   {
218                      strcpy(message,"EVENT_RLC_UE_RECONFIG_REQ");
219                      break;
220                   }
221                case EVENT_RLC_UE_DELETE_REQ:
222                   {
223                      strcpy(message,"EVENT_RLC_UE_DELETE_REQ");
224                      break;
225                   }
226
227                case LKW_EVT_STS_REQ:
228                   {
229                      strcpy(message,"LKW_EVT_STS_REQ");
230                      break;
231                   }
232
233                case LKW_EVT_STA_REQ:
234                   {
235                      strcpy(message,"LKW_EVT_STA_REQ");
236                      break;
237                   }
238                   /* kw005.201 added support for L2 Measurement */
239 #endif  /* LCLKW */
240                default:
241                   {
242                      strcpy(message,"Invalid Event");
243                   break;
244                  }
245             }
246             break;
247          }
248
249       case ENTRLC:
250          {
251             strcpy(sourceTask,"ENTRLC");
252             switch(pst->event)
253             {
254 #ifdef LCUDX
255                case UDX_EVT_BND_CFM:              /* Bind request */
256                   {
257                      strcpy(message,"UDX_EVT_BND_CFM");
258                      break;
259                   }
260
261                case UDX_EVT_CFG_CFM:             /* Unbind request */
262                   {
263                      strcpy(message,"UDX_EVT_CFG_CFM");
264                      break;
265                   }
266
267                case UDX_EVT_UEIDCHG_CFM:              /* Configuration request */
268                   {
269                      strcpy(message,"UDX_EVT_UEIDCHG_CFM");
270                      break;
271                   }
272                
273                case UDX_EVT_STA_PHBT_TMR_START:              /* Status Prohibit Timer Start */
274                   {
275                      strcpy(message,"UDX_EVT_STA_PHBT_TMR_START");
276                      break;
277                   }               
278
279 #endif  /* LCCKW */
280
281                default:
282                      strcpy(message,"Invalid Event");
283                   break;
284
285             }
286             break;
287          }
288
289       case ENTMAC:
290          {
291             strcpy(sourceTask,"ENTMAC");
292             switch(pst->event)
293             {
294 #ifdef LCRGU
295                case EVTRGUBNDCFM:     /* Bind request */
296                   {
297                      strcpy(message,"EVTRGUBNDCFM");
298                      break;
299                   }
300
301                case EVENT_UL_DATA_TO_RLC:    /* UL Data request */
302                   {
303                      strcpy(message,"EVENT_UL_DATA_TO_RLC");
304                      break;
305                   }
306
307 #endif  /* LCRGU */
308
309                default:
310                      strcpy(message,"Invalid Event");
311                   break;
312             }
313             break;
314          }
315       default:
316          {
317             strcpy(sourceTask,"Invalid Source Entity Id");
318          }
319     }
320     DU_LOG("\nCall Flow: %s -> %s : %s\n", sourceTask, destTask, message);
321
322
323
324
325 \f  
326 \f
327 /**
328  *
329  * @brief
330  *
331  *  <b> Activation Task </b>
332  *
333  *  @b Description:
334  *  Processes events received for NR RLC layer via System Services from
335  *  other layers.
336  *
337  *  @param[in] pst   - Pst Structure
338  *  @param[in] mBuf  - Message Buffer
339  *
340  *  @return  S16
341  *      -# ROK 
342  *
343  */
344 S16 rlcUlActvTsk
345 (
346 Pst *pst,              /* pst structure */
347 Buffer *mBuf            /* message buffer */
348 )
349 {
350    S16 ret = ROK;
351
352 #ifdef CALL_FLOW_DEBUG_LOG
353    callFlowRlcUlActvTsk(pst);
354 #endif
355
356    switch(pst->srcEnt)
357    {
358       case ENTDUAPP:
359          {
360             switch(pst->event)
361             {
362 #ifdef LCLKW
363                case LKW_EVT_CFG_REQ:
364                   {
365                      ret = unpackRlcConfigReq(RlcMiRlcConfigReq, pst, mBuf);
366                      break;
367                   }
368
369                case LKW_EVT_CNTRL_REQ:
370                   {
371                      ret = cmUnpkLkwCntrlReq(RlcMiLkwCntrlReq, pst, mBuf);
372                      break;
373                   }
374                
375                case EVENT_RLC_UE_CREATE_REQ:        /* UE Create Request */
376                   {
377                      ret = unpackRlcUeCreateReq(RlcProcUeCreateReq, pst, mBuf);
378                      break;
379                   }
380               case EVENT_RLC_UE_RECONFIG_REQ:      /* UE Reconfig Request */
381                   {
382                      ret = unpackRlcUeReconfigReq(RlcProcUeReconfigReq, pst, mBuf);
383                      break;
384                   }
385                case EVENT_RLC_UE_DELETE_REQ:
386                   {
387                      ret = unpackRlcUeDeleteReq(RlcProcUeDeleteReq, pst, mBuf);
388                      break;
389                   }
390
391                case LKW_EVT_STS_REQ:
392                   {
393                      ret = cmUnpkLkwStsReq(RlcMiLkwStsReq, pst, mBuf);
394                      break;
395                   }
396
397                case LKW_EVT_STA_REQ:
398                   {
399                      ret = cmUnpkLkwStaReq(RlcMiLkwStaReq, pst, mBuf);
400                      break;
401                   }
402                   /* kw005.201 added support for L2 Measurement */
403 #ifdef LTE_L2_MEAS
404                case LKW_EVT_L2MEAS_REQ:
405                   {
406                      ret = cmUnpkLkwL2MeasReq(RlcMiLkwL2MeasReq, pst, mBuf);
407                      break;
408                   }
409                case LKW_EVT_L2MEAS_SEND_REQ:
410                  {
411
412                     ret = cmUnpkLkwL2MeasSendReq(RlcMiLkwL2MeasSendReq, pst, mBuf); 
413   
414                      break;
415                  }
416                case LKW_EVT_L2MEAS_STOP_REQ:
417                  {
418                      ret = cmUnpkLkwL2MeasStopReq(RlcMiLkwL2MeasStopReq, pst, mBuf);
419                      break;
420                  }
421 #endif
422 #endif  /* LCLKW */
423                default:
424                   ODU_PUT_MSG_BUF(mBuf);
425                   if (pst->dstInst < MAX_RLC_INSTANCES)
426                   {
427                      DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from SM",
428                             pst->event);
429                   }
430                   ret = RFAILED;
431                   break;
432
433             }
434             break;
435          }
436
437       case ENTRLC:
438          {
439             switch(pst->event)
440             {
441 #ifdef LCUDX
442                case UDX_EVT_BND_CFM:              /* Bind request */
443                   {
444                      ret = cmUnpkUdxBndCfm(rlcUlUdxBndCfm, pst, mBuf );
445                      break;
446                   }
447
448                case UDX_EVT_CFG_CFM:             /* Unbind request */
449                   {
450                      ret = cmUnpkUdxCfgCfm(rlcUlUdxCfgCfm, pst, mBuf );
451                      break;
452                   }
453
454                case UDX_EVT_UEIDCHG_CFM:              /* Configuration request */
455                   {
456                      ret = cmUnpkUdxUeIdChgCfm(rlcUlUdxUeIdChgCfm, pst, mBuf);
457                      break;
458                   }
459                
460                case UDX_EVT_STA_PHBT_TMR_START:              /* Status Prohibit Timer Start */
461                   {
462                      ret = cmUnpkUdxStaProhTmrStart(rlcUlUdxStaProhTmrStart, pst, mBuf);
463                      break;
464                   }               
465
466 #endif  /* LCCKW */
467
468                default:
469                   ODU_PUT_MSG_BUF(mBuf);
470                   if (pst->dstInst < MAX_RLC_INSTANCES)
471                   {
472                       DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from RLC UL",
473                             pst->event);
474                   }
475                   ret = RFAILED;
476                   break;
477
478             }
479             break;
480          }
481
482       case ENTNH:
483          {
484             switch(pst->event)
485             {
486 #ifdef LCCKW
487                case CKW_EVT_BND_REQ:              /* Bind request */
488                   {
489                      ret = cmUnpkCkwBndReq(RlcUiCkwBndReq, pst, mBuf );
490                      break;
491                   }
492
493                case CKW_EVT_UBND_REQ:             /* Unbind request */
494                   {
495                      ret = cmUnpkCkwUbndReq(RlcUiCkwUbndReq, pst, mBuf );
496                      break;
497                   }
498
499                case CKW_EVT_UEIDCHG_REQ:              /* Configuration request */
500                   {
501                      ret = cmUnpkCkwUeIdChgReq(RlcUiCkwUeIdChgReq, pst, mBuf);
502                      break;
503                   }
504
505 #endif  /* LCCKW */
506
507 #ifdef LCKWU
508                case KWU_EVT_BND_REQ:              /* Bind request */
509                   {
510                      ret = cmUnpkKwuBndReq(RlcUiKwuBndReq, pst, mBuf );
511                      break;
512                   }
513
514                case KWU_EVT_UBND_REQ:             /* Unbind request */
515                   {
516                      ret = cmUnpkKwuUbndReq(RlcUiKwuUbndReq, pst, mBuf );
517                      break;
518                   }
519 #endif  /* LCKWU */
520                default:
521                   ODU_PUT_MSG_BUF(mBuf);
522                   if (pst->dstInst < MAX_RLC_INSTANCES)
523                   {
524                       DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from RRC", 
525                             pst->event);
526                   }
527                   ret = RFAILED;
528                   break;
529
530             }
531             break;
532          }
533
534       case ENTPJ:
535          {
536             switch(pst->event)
537             {
538 #ifdef LCKWU
539                case KWU_EVT_BND_REQ:              /* Bind request */
540                   {
541                      ret = cmUnpkKwuBndReq(RlcUiKwuBndReq, pst, mBuf );
542                      break;
543                   }
544
545                case KWU_EVT_UBND_REQ:             /* Unbind request */
546                   {
547                      ret = cmUnpkKwuUbndReq(RlcUiKwuUbndReq, pst, mBuf );
548                      break;
549                   }
550
551                default:
552                   ODU_PUT_MSG_BUF(mBuf);
553                   if (pst->dstInst < MAX_RLC_INSTANCES)
554                   {
555                       DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from PDCP", 
556                             pst->event);
557                   }
558                   ret = RFAILED;
559                   break;
560 #endif  /* LCKWU */
561                }
562             break;
563          }
564
565       case ENTMAC:
566          {
567             switch(pst->event)
568             {
569 #ifdef LCRGU
570                case EVTRGUBNDCFM:     /* Bind request */
571                   {
572                      ret = cmUnpkRguBndCfm(RlcLiRguBndCfm, pst, mBuf );
573                      break;
574                   }
575
576                case EVENT_UL_DATA_TO_RLC:    /* UL Data request */
577                   {
578                      ret = unpackRlcUlData(RlcProcUlData, pst, mBuf);
579                      break;
580                   }
581
582 #endif  /* LCRGU */
583
584                default:
585                   ODU_PUT_MSG_BUF(mBuf);
586                   if (pst->dstInst < MAX_RLC_INSTANCES)
587                   {
588                       DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from MAC",
589                             pst->event);
590                   }
591                   ret = RFAILED;
592                   break;
593             }
594             break;
595          }
596 #if defined(L2_L3_SPLIT) && defined (TENB_T2K3K_SPECIFIC_CHANGES) && defined (MAC_RLC_UL_RBUF)
597       case ENTYS:
598          {
599             switch(pst->event)
600             {
601                case KWU_EVT_TTI_IND:
602                   {
603                      rlcUlBatchProc();
604                      ODU_PUT_MSG_BUF(mBuf);
605                      break;
606                   }
607             }
608             break;
609          }
610 #endif/* End for TENB_T2K3K_SPECIFIC_CHANGES and L2_L3_SPLIT */
611 #ifndef UL_RLC_NET_CLUSTER
612 #ifdef TENB_STATS
613       case ENTLWRMAC:
614          {
615             switch(pst->event)
616             {
617                case TENBSTATSINIT:
618                {
619                   
620                   RlcCb *tRlcCb;
621                   tRlcCb = RLC_GET_RLCCB(pst->dstInst);
622
623                   TSL2SendStatsToApp(&(tRlcCb->genCfg.lmPst), 0);
624                   ODU_PUT_MSG_BUF(mBuf);
625                   break;
626                }
627                default:
628                {
629                   DU_LOG("\nERROR  -->  RLC_UL : Invalid Event[%d] from CL to PDCPUL\n", 
630                          pst->event);
631                   ODU_PUT_MSG_BUF(mBuf);
632                   break;
633                }
634             }
635             break;
636          }
637 #endif
638 #endif
639       default:
640          {
641           if (pst->dstInst < MAX_RLC_INSTANCES)
642            {
643               DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Source Entity[%d]",pst->event);
644            }
645             ODU_PUT_MSG_BUF(mBuf);
646             ret = RFAILED;
647             break;
648          }
649     }
650    ODU_EXIT_TASK();
651
652    return (ret);
653 } /* kwActvTsk */
654
655
656 \f  
657 /********************************************************************30**
658          End of file
659 **********************************************************************/