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