f136927a18ebbe79bcc1c125fa70453bc9327ea5
[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.region, tRlcCb->init.pool); 
165 #endif
166
167    return ROK;
168 } /* rlcUlActvInit */
169
170 \f
171 /**
172  *
173  * @brief
174  *
175  *  <b> Activation Task </b>
176  *
177  *  @b Description:
178  *  Processes events received for NR RLC layer via System Services from
179  *  other layers.
180  *
181  *  @param[in] pst   - Pst Structure
182  *  @param[in] mBuf  - Message Buffer
183  *
184  *  @return  S16
185  *      -# ROK 
186  *
187  */
188 S16 rlcUlActvTsk
189 (
190 Pst *pst,              /* pst structure */
191 Buffer *mBuf            /* message buffer */
192 )
193 {
194    S16 ret = ROK;
195
196
197    switch(pst->srcEnt)
198    {
199       case ENTDUAPP:
200          {
201             switch(pst->event)
202             {
203 #ifdef LCLKW
204                case LKW_EVT_CFG_REQ:
205                   {
206                      ret = unpackRlcConfigReq(RlcMiRlcConfigReq, pst, mBuf);
207                      break;
208                   }
209
210                case LKW_EVT_CNTRL_REQ:
211                   {
212                      ret = cmUnpkLkwCntrlReq(RlcMiLkwCntrlReq, pst, mBuf);
213                      break;
214                   }
215                
216                case EVENT_RLC_UE_CREATE_REQ:        /* UE Create Request */
217                   {
218                      ret = unpackRlcUeCreateReq(RlcProcUeCreateReq, pst, mBuf);
219                      break;
220                   }
221               case EVENT_RLC_UE_RECONFIG_REQ:      /* UE Reconfig Request */
222                   {
223                      ret = unpackRlcUeReconfigReq(RlcProcUeReconfigReq, pst, mBuf);
224                      break;
225                   }
226                case EVENT_RLC_UE_DELETE_REQ:
227                   {
228                      ret = unpackRlcUeDeleteReq(RlcProcUeDeleteReq, pst, mBuf);
229                      break;
230                   }
231
232                case LKW_EVT_STS_REQ:
233                   {
234                      ret = cmUnpkLkwStsReq(RlcMiLkwStsReq, pst, mBuf);
235                      break;
236                   }
237
238                case LKW_EVT_STA_REQ:
239                   {
240                      ret = cmUnpkLkwStaReq(RlcMiLkwStaReq, pst, mBuf);
241                      break;
242                   }
243                   /* kw005.201 added support for L2 Measurement */
244 #ifdef LTE_L2_MEAS
245                case LKW_EVT_L2MEAS_REQ:
246                   {
247                      ret = cmUnpkLkwL2MeasReq(RlcMiLkwL2MeasReq, pst, mBuf);
248                      break;
249                   }
250                case LKW_EVT_L2MEAS_SEND_REQ:
251                  {
252
253                     ret = cmUnpkLkwL2MeasSendReq(RlcMiLkwL2MeasSendReq, pst, mBuf); 
254   
255                      break;
256                  }
257                case LKW_EVT_L2MEAS_STOP_REQ:
258                  {
259                      ret = cmUnpkLkwL2MeasStopReq(RlcMiLkwL2MeasStopReq, pst, mBuf);
260                      break;
261                  }
262 #endif
263 #endif  /* LCLKW */
264                default:
265                   ODU_PUT_MSG_BUF(mBuf);
266                   if (pst->dstInst < MAX_RLC_INSTANCES)
267                   {
268                      DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from SM",
269                             pst->event);
270                   }
271                   ret = RFAILED;
272                   break;
273
274             }
275             break;
276          }
277
278       case ENTRLC:
279          {
280             switch(pst->event)
281             {
282 #ifdef LCUDX
283                case UDX_EVT_BND_CFM:              /* Bind request */
284                   {
285                      ret = cmUnpkUdxBndCfm(rlcUlUdxBndCfm, pst, mBuf );
286                      break;
287                   }
288
289                case UDX_EVT_CFG_CFM:             /* Unbind request */
290                   {
291                      ret = cmUnpkUdxCfgCfm(rlcUlUdxCfgCfm, pst, mBuf );
292                      break;
293                   }
294
295                case UDX_EVT_UEIDCHG_CFM:              /* Configuration request */
296                   {
297                      ret = cmUnpkUdxUeIdChgCfm(rlcUlUdxUeIdChgCfm, pst, mBuf);
298                      break;
299                   }
300                
301                case UDX_EVT_STA_PHBT_TMR_START:              /* Status Prohibit Timer Start */
302                   {
303                      ret = cmUnpkUdxStaProhTmrStart(rlcUlUdxStaProhTmrStart, pst, mBuf);
304                      break;
305                   }               
306
307 #endif  /* LCCKW */
308
309                default:
310                   ODU_PUT_MSG_BUF(mBuf);
311                   if (pst->dstInst < MAX_RLC_INSTANCES)
312                   {
313                       DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from RLC UL",
314                             pst->event);
315                   }
316                   ret = RFAILED;
317                   break;
318
319             }
320             break;
321          }
322
323       case ENTNH:
324          {
325             switch(pst->event)
326             {
327 #ifdef LCCKW
328                case CKW_EVT_BND_REQ:              /* Bind request */
329                   {
330                      ret = cmUnpkCkwBndReq(RlcUiCkwBndReq, pst, mBuf );
331                      break;
332                   }
333
334                case CKW_EVT_UBND_REQ:             /* Unbind request */
335                   {
336                      ret = cmUnpkCkwUbndReq(RlcUiCkwUbndReq, pst, mBuf );
337                      break;
338                   }
339
340                case CKW_EVT_UEIDCHG_REQ:              /* Configuration request */
341                   {
342                      ret = cmUnpkCkwUeIdChgReq(RlcUiCkwUeIdChgReq, pst, mBuf);
343                      break;
344                   }
345
346 #endif  /* LCCKW */
347
348 #ifdef LCKWU
349                case KWU_EVT_BND_REQ:              /* Bind request */
350                   {
351                      ret = cmUnpkKwuBndReq(RlcUiKwuBndReq, pst, mBuf );
352                      break;
353                   }
354
355                case KWU_EVT_UBND_REQ:             /* Unbind request */
356                   {
357                      ret = cmUnpkKwuUbndReq(RlcUiKwuUbndReq, pst, mBuf );
358                      break;
359                   }
360 #endif  /* LCKWU */
361                default:
362                   ODU_PUT_MSG_BUF(mBuf);
363                   if (pst->dstInst < MAX_RLC_INSTANCES)
364                   {
365                       DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from RRC", 
366                             pst->event);
367                   }
368                   ret = RFAILED;
369                   break;
370
371             }
372             break;
373          }
374
375       case ENTPJ:
376          {
377             switch(pst->event)
378             {
379 #ifdef LCKWU
380                case KWU_EVT_BND_REQ:              /* Bind request */
381                   {
382                      ret = cmUnpkKwuBndReq(RlcUiKwuBndReq, pst, mBuf );
383                      break;
384                   }
385
386                case KWU_EVT_UBND_REQ:             /* Unbind request */
387                   {
388                      ret = cmUnpkKwuUbndReq(RlcUiKwuUbndReq, pst, mBuf );
389                      break;
390                   }
391
392                default:
393                   ODU_PUT_MSG_BUF(mBuf);
394                   if (pst->dstInst < MAX_RLC_INSTANCES)
395                   {
396                       DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from PDCP", 
397                             pst->event);
398                   }
399                   ret = RFAILED;
400                   break;
401 #endif  /* LCKWU */
402                }
403             break;
404          }
405
406       case ENTMAC:
407          {
408             switch(pst->event)
409             {
410 #ifdef LCRGU
411                case EVTRGUBNDCFM:     /* Bind request */
412                   {
413                      ret = cmUnpkRguBndCfm(RlcLiRguBndCfm, pst, mBuf );
414                      break;
415                   }
416
417                case EVENT_UL_DATA_TO_RLC:    /* UL Data request */
418                   {
419                      ret = unpackRlcUlData(RlcProcUlData, pst, mBuf);
420                      break;
421                   }
422
423 #endif  /* LCRGU */
424
425                default:
426                   ODU_PUT_MSG_BUF(mBuf);
427                   if (pst->dstInst < MAX_RLC_INSTANCES)
428                   {
429                       DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Event[%d] from MAC",
430                             pst->event);
431                   }
432                   ret = RFAILED;
433                   break;
434             }
435             break;
436          }
437 #if defined(L2_L3_SPLIT) && defined (TENB_T2K3K_SPECIFIC_CHANGES) && defined (MAC_RLC_UL_RBUF)
438       case ENTYS:
439          {
440             switch(pst->event)
441             {
442                case KWU_EVT_TTI_IND:
443                   {
444                      rlcUlBatchProc();
445                      ODU_PUT_MSG_BUF(mBuf);
446                      break;
447                   }
448             }
449             break;
450          }
451 #endif/* End for TENB_T2K3K_SPECIFIC_CHANGES and L2_L3_SPLIT */
452 #ifndef UL_RLC_NET_CLUSTER
453 #ifdef TENB_STATS
454       case ENTLWRMAC:
455          {
456             switch(pst->event)
457             {
458                case TENBSTATSINIT:
459                {
460                   
461                   RlcCb *tRlcCb;
462                   tRlcCb = RLC_GET_RLCCB(pst->dstInst);
463
464                   TSL2SendStatsToApp(&(tRlcCb->genCfg.lmPst), 0);
465                   ODU_PUT_MSG_BUF(mBuf);
466                   break;
467                }
468                default:
469                {
470                   DU_LOG("\nERROR  -->  RLC_UL : Invalid Event[%d] from CL to PDCPUL\n", 
471                          pst->event);
472                   ODU_PUT_MSG_BUF(mBuf);
473                   break;
474                }
475             }
476             break;
477          }
478 #endif
479 #endif
480       default:
481          {
482           if (pst->dstInst < MAX_RLC_INSTANCES)
483            {
484               DU_LOG("\nERROR  -->  RLC_UL : Received Invalid Source Entity[%d]",pst->event);
485            }
486             ODU_PUT_MSG_BUF(mBuf);
487             ret = RFAILED;
488             break;
489          }
490     }
491    ODU_EXIT_TASK();
492
493    return (ret);
494 } /* kwActvTsk */
495
496
497 \f  
498 /********************************************************************30**
499          End of file
500 **********************************************************************/