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