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