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