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