5326573c188b7eb5ef974009f1a61110a0695a11
[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
392                case LKW_EVT_STS_REQ:
393                   {
394                      ret = cmUnpkLkwStsReq(RlcMiLkwStsReq, pst, mBuf);
395                      break;
396                   }
397
398                case LKW_EVT_STA_REQ:
399                   {
400                      ret = cmUnpkLkwStaReq(RlcMiLkwStaReq, pst, mBuf);
401                      break;
402                   }
403                   /* kw005.201 added support for L2 Measurement */
404 #ifdef LTE_L2_MEAS
405                case LKW_EVT_L2MEAS_REQ:
406                   {
407                      ret = cmUnpkLkwL2MeasReq(RlcMiLkwL2MeasReq, pst, mBuf);
408                      break;
409                   }
410                case LKW_EVT_L2MEAS_SEND_REQ:
411                  {
412
413                     ret = cmUnpkLkwL2MeasSendReq(RlcMiLkwL2MeasSendReq, pst, mBuf); 
414   
415                      break;
416                  }
417                case LKW_EVT_L2MEAS_STOP_REQ:
418                  {
419                      ret = cmUnpkLkwL2MeasStopReq(RlcMiLkwL2MeasStopReq, pst, mBuf);
420                      break;
421                  }
422 #endif
423 #endif  /* LCLKW */
424                default:
425                   ODU_PUT_MSG_BUF(mBuf);
426                   if (pst->dstInst < MAX_RLC_INSTANCES)
427                   {
428                      DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from SM",
429                             pst->event);
430                   }
431                   ret = RFAILED;
432                   break;
433
434             }
435             break;
436          }
437
438       case ENTRLC:
439          {
440             switch(pst->event)
441             {
442 #ifdef LCUDX
443                case UDX_EVT_BND_CFM:              /* Bind request */
444                   {
445                      ret = cmUnpkUdxBndCfm(rlcUlUdxBndCfm, pst, mBuf );
446                      break;
447                   }
448
449                case UDX_EVT_CFG_CFM:             /* Unbind request */
450                   {
451                      ret = cmUnpkUdxCfgCfm(rlcUlUdxCfgCfm, pst, mBuf );
452                      break;
453                   }
454
455                case UDX_EVT_UEIDCHG_CFM:              /* Configuration request */
456                   {
457                      ret = cmUnpkUdxUeIdChgCfm(rlcUlUdxUeIdChgCfm, pst, mBuf);
458                      break;
459                   }
460                
461                case UDX_EVT_STA_PHBT_TMR_START:              /* Status Prohibit Timer Start */
462                   {
463                      ret = cmUnpkUdxStaProhTmrStart(rlcUlUdxStaProhTmrStart, pst, mBuf);
464                      break;
465                   }               
466
467 #endif  /* LCCKW */
468
469                default:
470                   ODU_PUT_MSG_BUF(mBuf);
471                   if (pst->dstInst < MAX_RLC_INSTANCES)
472                   {
473                       DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from RLC UL",
474                             pst->event);
475                   }
476                   ret = RFAILED;
477                   break;
478
479             }
480             break;
481          }
482
483       case ENTNH:
484          {
485             switch(pst->event)
486             {
487 #ifdef LCCKW
488                case CKW_EVT_BND_REQ:              /* Bind request */
489                   {
490                      ret = cmUnpkCkwBndReq(RlcUiCkwBndReq, pst, mBuf );
491                      break;
492                   }
493
494                case CKW_EVT_UBND_REQ:             /* Unbind request */
495                   {
496                      ret = cmUnpkCkwUbndReq(RlcUiCkwUbndReq, pst, mBuf );
497                      break;
498                   }
499
500                case CKW_EVT_UEIDCHG_REQ:              /* Configuration request */
501                   {
502                      ret = cmUnpkCkwUeIdChgReq(RlcUiCkwUeIdChgReq, pst, mBuf);
503                      break;
504                   }
505
506 #endif  /* LCCKW */
507
508 #ifdef LCKWU
509                case KWU_EVT_BND_REQ:              /* Bind request */
510                   {
511                      ret = cmUnpkKwuBndReq(RlcUiKwuBndReq, pst, mBuf );
512                      break;
513                   }
514
515                case KWU_EVT_UBND_REQ:             /* Unbind request */
516                   {
517                      ret = cmUnpkKwuUbndReq(RlcUiKwuUbndReq, pst, mBuf );
518                      break;
519                   }
520 #endif  /* LCKWU */
521                default:
522                   ODU_PUT_MSG_BUF(mBuf);
523                   if (pst->dstInst < MAX_RLC_INSTANCES)
524                   {
525                       DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from RRC", 
526                             pst->event);
527                   }
528                   ret = RFAILED;
529                   break;
530
531             }
532             break;
533          }
534
535       case ENTPJ:
536          {
537             switch(pst->event)
538             {
539 #ifdef LCKWU
540                case KWU_EVT_BND_REQ:              /* Bind request */
541                   {
542                      ret = cmUnpkKwuBndReq(RlcUiKwuBndReq, pst, mBuf );
543                      break;
544                   }
545
546                case KWU_EVT_UBND_REQ:             /* Unbind request */
547                   {
548                      ret = cmUnpkKwuUbndReq(RlcUiKwuUbndReq, pst, mBuf );
549                      break;
550                   }
551
552                default:
553                   ODU_PUT_MSG_BUF(mBuf);
554                   if (pst->dstInst < MAX_RLC_INSTANCES)
555                   {
556                       DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from PDCP", 
557                             pst->event);
558                   }
559                   ret = RFAILED;
560                   break;
561 #endif  /* LCKWU */
562                }
563             break;
564          }
565
566       case ENTMAC:
567          {
568             switch(pst->event)
569             {
570 #ifdef LCRGU
571                case EVTRGUBNDCFM:     /* Bind request */
572                   {
573                      ret = cmUnpkRguBndCfm(RlcLiRguBndCfm, pst, mBuf );
574                      break;
575                   }
576
577                case EVENT_UL_DATA_TO_RLC:    /* UL Data request */
578                   {
579                      ret = unpackRlcUlData(RlcProcUlData, pst, mBuf);
580                      break;
581                   }
582
583 #endif  /* LCRGU */
584
585                default:
586                   ODU_PUT_MSG_BUF(mBuf);
587                   if (pst->dstInst < MAX_RLC_INSTANCES)
588                   {
589                       DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from MAC",
590                             pst->event);
591                   }
592                   ret = RFAILED;
593                   break;
594             }
595             break;
596          }
597 #if defined(L2_L3_SPLIT) && defined (TENB_T2K3K_SPECIFIC_CHANGES) && defined (MAC_RLC_UL_RBUF)
598       case ENTYS:
599          {
600             switch(pst->event)
601             {
602                case KWU_EVT_TTI_IND:
603                   {
604                      rlcUlBatchProc();
605                      ODU_PUT_MSG_BUF(mBuf);
606                      break;
607                   }
608             }
609             break;
610          }
611 #endif/* End for TENB_T2K3K_SPECIFIC_CHANGES and L2_L3_SPLIT */
612 #ifndef UL_RLC_NET_CLUSTER
613 #ifdef TENB_STATS
614       case ENTLWRMAC:
615          {
616             switch(pst->event)
617             {
618                case TENBSTATSINIT:
619                {
620                   
621                   RlcCb *tRlcCb;
622                   tRlcCb = RLC_GET_RLCCB(pst->dstInst);
623
624                   TSL2SendStatsToApp(&(tRlcCb->genCfg.lmPst), 0);
625                   ODU_PUT_MSG_BUF(mBuf);
626                   break;
627                }
628                default:
629                {
630                   DU_LOG("\nERROR  -->  RLC_UL : Invalid Event[%d] from CL to PDCPUL\n", 
631                          pst->event);
632                   ODU_PUT_MSG_BUF(mBuf);
633                   break;
634                }
635             }
636             break;
637          }
638 #endif
639 #endif
640       default:
641          {
642           if (pst->dstInst < MAX_RLC_INSTANCES)
643            {
644               DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Source Entity[%d]",pst->event);
645            }
646             ODU_PUT_MSG_BUF(mBuf);
647             ret = RFAILED;
648             break;
649          }
650     }
651    ODU_EXIT_TASK();
652
653    return (ret);
654 } /* kwActvTsk */
655
656
657 \f  
658 /********************************************************************30**
659          End of file
660 **********************************************************************/