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