RLC-MAC Interface APIs and Memory configuration Changes
[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 RLC_EVT_UE_CREATE_REQ:        /* UE Create Request */
261                   {
262                      ret = unpackUeCreateReq(RlcDuappProcUeCreateReq, pst, mBuf);
263                      break;
264                   }
265
266                case LKW_EVT_STS_REQ:
267                   {
268                      ret = cmUnpkLkwStsReq(KwMiLkwStsReq, pst, mBuf);
269                      break;
270                   }
271
272                case LKW_EVT_STA_REQ:
273                   {
274                      ret = cmUnpkLkwStaReq(KwMiLkwStaReq, pst, mBuf);
275                      break;
276                   }
277                   /* kw005.201 added support for L2 Measurement */
278 #ifdef LTE_L2_MEAS
279                case LKW_EVT_L2MEAS_REQ:
280                   {
281                      ret = cmUnpkLkwL2MeasReq(KwMiLkwL2MeasReq, pst, mBuf);
282                      break;
283                   }
284                case LKW_EVT_L2MEAS_SEND_REQ:
285                  {
286
287                     ret = cmUnpkLkwL2MeasSendReq(KwMiLkwL2MeasSendReq, pst, mBuf); 
288   
289                      break;
290                  }
291                case LKW_EVT_L2MEAS_STOP_REQ:
292                  {
293                      ret = cmUnpkLkwL2MeasStopReq(KwMiLkwL2MeasStopReq, pst, mBuf);
294                      break;
295                  }
296 #endif
297 #endif  /* LCLKW */
298                default:
299                   SPutMsg(mBuf);
300                   if (pst->dstInst < KW_MAX_RLC_INSTANCES)
301                   {
302                      RLOG1(L_FATAL,"Received Invalid Event[%d] from SM",
303                             pst->event);
304                   }
305                   ret = RFAILED;
306                   break;
307
308             }
309             break;
310          }
311
312       case ENTKW:
313          {
314             switch(pst->event)
315             {
316 #ifdef LCUDX
317                case UDX_EVT_BND_CFM:              /* Bind request */
318                   {
319                      ret = cmUnpkUdxBndCfm(KwUlUdxBndCfm, pst, mBuf );
320                      break;
321                   }
322
323                case UDX_EVT_CFG_CFM:             /* Unbind request */
324                   {
325                      ret = cmUnpkUdxCfgCfm(KwUlUdxCfgCfm, pst, mBuf );
326                      break;
327                   }
328
329                case UDX_EVT_UEIDCHG_CFM:              /* Configuration request */
330                   {
331                      ret = cmUnpkUdxUeIdChgCfm(KwUlUdxUeIdChgCfm, pst, mBuf);
332                      break;
333                   }
334                
335                case UDX_EVT_STA_PHBT_TMR_START:              /* Status Prohibit Timer Start */
336                   {
337                      ret = cmUnpkUdxStaProhTmrStart(KwUlUdxStaProhTmrStart, pst, mBuf);
338                      break;
339                   }               
340
341 #endif  /* LCCKW */
342
343                default:
344                   SPutMsg(mBuf);
345                   if (pst->dstInst < KW_MAX_RLC_INSTANCES)
346                   {
347                       RLOG1(L_ERROR,"Received Invalid Event[%d] from RLC UL",
348                             pst->event);
349                   }
350                   ret = RFAILED;
351                   break;
352
353             }
354             break;
355          }
356
357       case ENTNH:
358          {
359             switch(pst->event)
360             {
361 #ifdef LCCKW
362                case CKW_EVT_BND_REQ:              /* Bind request */
363                   {
364                      ret = cmUnpkCkwBndReq(KwUiCkwBndReq, pst, mBuf );
365                      break;
366                   }
367
368                case CKW_EVT_UBND_REQ:             /* Unbind request */
369                   {
370                      ret = cmUnpkCkwUbndReq(KwUiCkwUbndReq, 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 EVTRLCULDAT:    /* Dedicated Channel Data request */
452                   {
453                      ret = unpackRcvdUlData(RlcMacProcUlData, pst, mBuf);
454                      break;
455                   }
456
457 #endif  /* LCRGU */
458
459                default:
460                   SPutMsg(mBuf);
461                   if (pst->dstInst < KW_MAX_RLC_INSTANCES)
462                   {
463                       RLOG1(L_ERROR,"Received Invalid Event[%d] from MAC",
464                             pst->event);
465                   }
466                   ret = RFAILED;
467                   break;
468             }
469             break;
470          }
471 #if defined(L2_L3_SPLIT) && defined (TENB_T2K3K_SPECIFIC_CHANGES) && defined (MAC_RLC_UL_RBUF)
472       case ENTYS:
473          {
474             switch(pst->event)
475             {
476                case KWU_EVT_TTI_IND:
477                   {
478                      kwUlBatchProc();
479                      SPutMsg(mBuf);
480                      break;
481                   }
482             }
483             break;
484          }
485 #endif/* End for TENB_T2K3K_SPECIFIC_CHANGES and L2_L3_SPLIT */
486 #ifndef UL_RLC_NET_CLUSTER
487 #ifdef TENB_STATS
488       case ENTTF:
489          {
490             switch(pst->event)
491             {
492                case TENBSTATSINIT:
493                {
494                   
495                   KwCb *tKwCb;
496                   tKwCb = KW_GET_KWCB(pst->dstInst);
497
498                   TSL2SendStatsToApp(&(tKwCb->genCfg.lmPst), 0);
499                   SPutMsg(mBuf);
500                   break;
501                }
502                default:
503                {
504                   printf("\n ERROR Invalid Event[%d] from CL to PDCPUL\n", 
505                          pst->event);
506                   SPutMsg(mBuf);
507                   break;
508                }
509             }
510             break;
511          }
512 #endif
513 #endif
514       default:
515          {
516           if (pst->dstInst < KW_MAX_RLC_INSTANCES)
517            {
518               RLOG1(L_ERROR, "Received Invalid Source Entity[%d]",pst->event);
519            }
520             SPutMsg(mBuf);
521             ret = RFAILED;
522             break;
523          }
524     }
525    SExitTsk();
526
527    RETVALUE(ret);
528 } /* kwActvTsk */
529
530
531 \f  
532 /********************************************************************30**
533          End of file
534 **********************************************************************/