Deleted the rlog folder
[o-du/l2.git] / src / 5gnrrlc / kw_dl_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:    NR 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 NR RLC
27  
28         File:    kw_dl_ex_ms.c
29   
30 *********************************************************************21*/
31
32 /** @filekw_dl_ex_ms.c 
33 @brief RLC System Services Interface
34 */
35
36 \f
37 /* header (.h) include files */
38 #include "common_def.h"
39 #include "lkw.h"           /* LKW defines */
40 #include "ckw.h"           /* CKW defines */
41 #include "kwu.h"           /* KWU defines */
42 #include "rgu.h"           /* RGU defines */
43 #include "kw_err.h"        /* Err defines */
44 #include "kw_env.h"        /* RLC environment options */
45 #include "kw.h"            /* RLC defines */
46 #include "kw_udx.h"
47 #include "kw_dl.h"
48
49
50 /* extern (.x) include files */
51 #include "lkw.x"           /* LKW */
52 #include "ckw.x"           /* CKW */
53 #include "kwu.x"           /* KWU */
54 #include "rgu.x"           /* RGU */
55 #include "kw.x"
56 #include "kw_udx.x"
57 #include "kw_dl.x"
58 #include "du_app_rlc_inf.h"
59 #include "rlc_mac_inf.h"
60
61 #include "ctf.h"
62 S16 rlcUtlDlBatchProcPkts(Void);
63 S16 rlcDlBatchProc(Void);
64 #if (defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS))
65 uint32_t isDatReqProcessed;
66 void rlcUtlDlBatchProcHqStaInd ARGS ((Void));
67 #endif
68
69 #if (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF))
70 S16 rlcDlBatchProcSplit  ARGS((Void));
71 #endif
72 //UDAY
73 #ifdef L2_OPTMZ
74 uint32_t rlcAmmStaPduList[512] = {0};
75 S16 ssGetDBufOfSize ARGS((Region region, Size size, Buffer **dBuf));
76 #endif
77 S16 rlcDlInitExt ARGS (( Void ));
78 \f
79 /**
80  *
81  * @brief
82  *
83  *  <b> Initialize External </b>
84  *
85  *  @b Description:
86  *  Initializes variables used to interface with Upper/Lower Layer  
87  *
88  *  @return  S16
89  *      -# ROK 
90  *
91 */
92   
93 S16 rlcDlInitExt()
94 {
95    return ROK;
96 } /* kwInitExt */
97
98
99 \f
100 /***********************************************************************
101                       System Service Interface Functions
102  ***********************************************************************/
103 /**
104  *
105  * @brief
106  *
107  *    <b> Activates Initialization </b>
108  *
109  *    @b Description:
110  *    This function is invoked by system services to initialize the NR RLC
111  *    layer. This is an entry point used by LTE_RLC layer to initialize its
112  *    global variables, before becoming operational.
113  *
114  *    Allowable values for parameters are specified in ssi.h.
115  *
116  *    @param[in] ent    - Specify the entity id of the NR RLC task.
117  *    @param[in] inst   - Specify the entity id of the NR RLC task.
118  *    @param[in] region - Specifies the memory region from which
119  *                         NR RLC should allocate structures and buffers.
120  *    @param[in] reason - Specifies the reason for calling this
121  *                         initialization function.
122  *
123  *  @return  S16
124  *      -# ROK 
125  *
126  */
127 S16 rlcDlActvInit
128 (
129 Ent    ent,                 /* entity */
130 Inst   inst,                /* instance */
131 Region region,              /* region */
132 Reason reason               /* reason */
133 )
134 {
135    RlcCb    *tRlcCb;
136
137    if (inst >= MAX_RLC_INSTANCES)
138    {
139        /* intance greater than MAX instances */ 
140        return RFAILED; 
141    }
142
143    if (rlcCb[inst] != NULLP)
144    {
145        return  (RFAILED);
146    }
147   
148    if (SGetSBuf(region, 0, (Data **)&tRlcCb,
149                 (Size)sizeof (RlcCb)) != ROK)    
150    {                     
151       return RFAILED;
152    }
153    /* Initialize rlcCb */
154    RLC_MEM_SET(tRlcCb, 0, sizeof(RlcCb));
155
156    /* Initialize task configuration parameters */
157    tRlcCb->init.ent     = ent;           /* entity */
158    tRlcCb->init.inst    = inst;          /* instance */
159    tRlcCb->init.region  = region;        /* static region */
160    tRlcCb->init.pool    = 0;             /* static pool */
161    tRlcCb->init.reason  = reason;        /* reason */
162    tRlcCb->init.cfgDone = FALSE;         /* configuration done */
163    tRlcCb->init.acnt    = TRUE;          /* enable accounting */
164    tRlcCb->init.usta    = TRUE;          /* enable unsolicited status */
165    tRlcCb->init.trc     = FALSE;         /* enable trace */
166    tRlcCb->init.procId  = ODU_GET_PROCID();
167
168    rlcCb[inst] = tRlcCb;
169
170 //UDAY
171 #ifdef L2_OPTMZ
172    for(int i = 0; i < 512; i++)
173    {
174       Buffer *mBuf = NULL;
175       Buffer *bufPtr = NULL;
176       SGetMsg(1, 0 , &mBuf);
177       ssGetDBufOfSize(1 , 1800, &bufPtr);
178       SUpdMsg(mBuf, bufPtr, 0);
179       rlcAmmStaPduList[i] = (uint32_t)mBuf; 
180    }
181 #endif
182    /* call external function for intialization */
183    /*
184    kwInitExt();
185    */
186
187    
188
189    return ROK;
190 } /* kwActvInit */
191
192 \f
193 /**
194  *
195  * @brief
196  *
197  *  <b> Activation Task </b>
198  *
199  *  @b Description:
200  *  Processes events received for NR RLC layer via System Services from
201  *  other layers.
202  *
203  *  @param[in] pst   - Pst Structure
204  *  @param[in] mBuf  - Message Buffer
205  *
206  *  @return  S16
207  *      -# ROK 
208  *
209  */
210 #if (defined (MAC_FREE_RING_BUF) || defined (RLC_FREE_RING_BUF))
211 pthread_t gRlcTId = 0;
212 #endif
213 S16 rlcDlActvTsk
214 (
215 Pst *pst,              /* pst structure */
216 Buffer *mBuf            /* message buffer */
217 )
218 {
219    S16 ret = ROK;
220
221 #ifdef RLC_FREE_RING_BUF
222    gRlcTId = pthread_self();
223 #endif
224
225    switch(pst->srcEnt)
226    {
227       case ENTDUAPP:
228          {
229             switch(pst->event)
230             {
231 #ifdef LCLKW
232                case LKW_EVT_CFG_REQ:
233                   {
234                      ret = unpackRlcConfigReq(RlcMiRlcConfigReq, pst, mBuf);
235                      break;
236                   }
237
238                case LKW_EVT_CNTRL_REQ:
239                   {
240                      ret = cmUnpkLkwCntrlReq(RlcMiLkwCntrlReq, pst, mBuf);
241                      break;
242                   }
243
244                case LKW_EVT_STS_REQ:
245                   {
246                      ret = cmUnpkLkwStsReq(RlcMiLkwStsReq, pst, mBuf);
247                      break;
248                   }
249
250                case LKW_EVT_STA_REQ:
251                   {
252                      ret = cmUnpkLkwStaReq(RlcMiLkwStaReq, pst, mBuf);
253                      break;
254                   }
255                   /* kw005.201 added support for L2 Measurement */
256 #endif  /* LCLKW */
257
258 #ifdef LCKWU
259                case KWU_EVT_DAT_REQ:              /* Data request */
260                   {
261                      //ret = cmUnpkKwuDatReq(rlcProcDlData, pst, mBuf);
262                      break;
263                   }
264 #endif /* LCKWU */
265                
266                case EVENT_DL_RRC_MSG_TRANS_TO_RLC:
267                   {
268                      ret = unpackDlRrcMsgToRlc(RlcProcDlRrcMsgTransfer, pst, mBuf);
269                      break;
270                   }
271                case EVENT_DL_USER_DATA_TRANS_TO_RLC:
272                   {
273                      ret = unpackRlcDlUserDataToRlc(RlcProcDlUserDataTransfer, pst, mBuf);
274                      break;
275                   }
276                default:
277                   ODU_PUT_MSG_BUF(mBuf);
278                   if (pst->dstInst < MAX_RLC_INSTANCES)
279                   {
280                       DU_LOG("\nERROR  --> RLC_DL : Received Invalid Event[%d] from SM",
281                             pst->event);
282                   }
283                   ret = RFAILED;
284                   break;
285
286             }
287             break;
288          }
289
290       case ENTRLC:
291          {
292
293             switch(pst->event)
294             {
295 #ifdef LCUDX
296                case UDX_EVT_BND_REQ:              /* Bind request */
297                   {
298                      ret = cmUnpkUdxBndReq(rlcDlUdxBndReq, pst, mBuf );
299                      break;
300                   }
301
302                case UDX_EVT_UBND_REQ:              /* Bind request */
303                   {
304                      ret = cmUnpkUdxUbndReq(rlcDlUdxUbndReq, pst, mBuf );
305                      break;
306                   }
307                case UDX_EVT_CFG_REQ:             /* Unbind request */
308                   {
309                      ret = cmUnpkUdxCfgReq(rlcDlUdxCfgReq, pst, mBuf );
310                      break;
311                   }
312
313                case UDX_EVT_UEIDCHG_REQ:              /* Configuration request */
314                   {
315                      ret = cmUnpkUdxUeIdChgReq(rlcDlUdxUeIdChgReq, pst, mBuf);
316                      break;
317                   }
318
319                case UDX_EVT_STA_UPD_REQ:              /* Configuration request */
320                   {
321                      ret = cmUnpkUdxStaUpdReq(rlcDlUdxStaUpdReq, pst, mBuf);
322                      break;
323                   }
324
325                case UDX_EVT_STA_PDU_REQ:              /* Configuration request */
326                   {
327                      ret = cmUnpkUdxStaPduReq(rlcDlUdxStaPduReq, pst, mBuf);
328                      break;
329                   }
330
331 #ifdef LTE_L2_MEAS
332                case UDX_EVT_L2MEAS_REQ:
333                   {
334                      ret = cmUnpkUdxL2MeasReq(rlcDlUdxL2MeasReq, pst, mBuf);
335                      break;
336                   }
337                case UDX_EVT_L2MEAS_SEND_REQ:
338                  {
339
340                     ret = cmUnpkUdxL2MeasSendReq(rlcDlUdxL2MeasSendReq, pst, mBuf); 
341   
342                      break;
343                  }
344                case UDX_EVT_L2MEAS_STOP_REQ:
345                  {
346                      ret = cmUnpkUdxL2MeasStopReq(rlcDlUdxL2MeasStopReq, pst, mBuf);
347                      break;
348                  }
349 #endif
350
351 #endif  /* LCCKW */
352                case UDX_EVT_DL_CLEANUP_MEM:
353                   {
354                      rlcUtlFreeDlMemory(RLC_GET_RLCCB(pst->dstInst));
355                      break;
356                   }
357                
358                default:
359                   ODU_PUT_MSG_BUF(mBuf);
360                   if (pst->dstInst < MAX_RLC_INSTANCES)
361                   {
362                       DU_LOG("\nERROR  --> RLC_DL : Received Invalid Event[%d] from RLC UL",
363                             pst->event);
364                   }
365                   ret = RFAILED;
366                   break;
367
368             }
369             break;
370          }
371
372       case ENTNH:
373          {
374             switch(pst->event)
375             {
376 #ifdef LCKWU
377                case KWU_EVT_BND_REQ:              /* Bind request */
378                   {
379                      ret = cmUnpkKwuBndReq(RlcUiKwuBndReq, pst, mBuf );
380                      break;
381                   }
382
383                case KWU_EVT_UBND_REQ:             /* Unbind request */
384                   {
385                      ret = cmUnpkKwuUbndReq(RlcUiKwuUbndReq, pst, mBuf );
386                      break;
387                   }
388 #ifdef L2_L3_SPLIT
389                case KWU_EVT_CPLANE_DAT_REQ:       /* C-Plane Data request */
390                   {
391                      ret = cmUnpkKwuDatReq(rlcProcDlData, pst, mBuf);
392                      break;
393                   }
394 #else
395                case KWU_EVT_DAT_REQ:              /* Data request */
396                   {
397                      //ret = cmUnpkKwuDatReq(rlcProcDlData, pst, mBuf);
398                      break;
399                   }
400 #endif
401                case KWU_EVT_DISC_SDU_REQ:         /* Discard SDU request */
402                   {
403                      ret = cmUnpkKwuDiscSduReq(RlcUiKwuDiscSduReq, pst, mBuf);
404                      break;
405                   }
406
407 #endif  /* LCKWU */
408                default:
409                   ODU_PUT_MSG_BUF(mBuf);
410                   if (pst->dstInst < MAX_RLC_INSTANCES)
411                   {
412                      DU_LOG("\nERROR  --> RLC_DL : Received Invalid Event[%d] from RRC",
413                             pst->event);
414                   }
415                   ret = RFAILED;
416                   break;
417
418             }
419             break;
420          }
421
422       case ENTPJ:
423          {
424             switch(pst->event)
425             {
426 #ifdef LCKWU
427                case KWU_EVT_BND_REQ:              /* Bind request */
428                   {
429                      ret = cmUnpkKwuBndReq(RlcUiKwuBndReq, pst, mBuf );
430                      break;
431                   }
432
433                case KWU_EVT_UBND_REQ:             /* Unbind request */
434                   {
435                      ret = cmUnpkKwuUbndReq(RlcUiKwuUbndReq, pst, mBuf );
436                      break;
437                   }
438 #ifdef L2_L3_SPLIT
439                case KWU_EVT_CPLANE_DAT_REQ:       /* C-Plane Data request */
440                case KWU_EVT_UPLANE_DAT_REQ:       /* U-Plane Data request */
441                   {
442                      ret = cmUnpkKwuDatReq(rlcProcDlData, pst, mBuf);
443                      break;
444                   }
445 #else
446                case KWU_EVT_DAT_REQ:              /* Data request */
447                   {
448                      //ret = cmUnpkKwuDatReq(rlcProcDlData, pst, mBuf);
449                      break;
450                   }
451 #endif
452                case KWU_EVT_DISC_SDU_REQ:         /* Discard SDU request */
453                   {
454                      ret = cmUnpkKwuDiscSduReq(RlcUiKwuDiscSduReq, pst, mBuf);
455                      break;
456                   }
457
458                default:
459                   ODU_PUT_MSG_BUF(mBuf);
460                   if (pst->dstInst < MAX_RLC_INSTANCES)
461                   {
462                      DU_LOG("\nERROR  --> RLC_DL : Received Invalid Event[%d] from PDCP",
463                             pst->event);
464                   }
465                   ret = RFAILED;
466                   break;
467 #endif  /* LCKWU */
468             }
469             break;
470          }
471
472       case ENTMAC:
473          {
474             switch(pst->event)
475             {
476 #ifdef LCRGU
477                case EVTRGUBNDCFM:     /* Bind request */
478                   {
479                      ret = cmUnpkRguBndCfm(RlcLiRguBndCfm, pst, mBuf );
480                      break;
481                   }
482                case EVENT_SCHED_RESULT_TO_RLC: 
483                   {
484                      ret = unpackSchedResultRpt(RlcProcSchedResultRpt, pst, mBuf);
485                      break;
486                   }
487                   /* kw005.201 added support for L2 Measurement */
488 #ifdef LTE_L2_MEAS
489                case EVTRGUHQSTAIND:    /* Harq status indication */
490                   {
491                      ret = cmUnpkRguHqStaInd(RlcLiRguHqStaInd, pst, mBuf);
492                      break;
493                   }
494 #endif
495                case EVTRGUFLOWCNTRLIND:
496                   {
497                      ret = cmUnpkRguFlowCntrlInd(RlcLiRguFlowCntrlInd,pst,mBuf);
498                      break;
499                   }   
500 #endif  /* LCRGU */
501 #ifdef RLC_STA_PROC_IN_MAC/* RLC Status PDU Processing */
502                case UDX_EVT_STA_UPD_REQ:              /* Configuration request */
503                   {
504                      ret = cmUnpkUdxStaUpdReq(rlcDlUdxStaUpdReq, pst, mBuf);
505                      break;
506                   }
507 #endif
508
509                default:
510                   ODU_PUT_MSG_BUF(mBuf);
511                   if (pst->dstInst < MAX_RLC_INSTANCES)
512                   {
513                       DU_LOG("\nERROR  --> RLC_DL : Received Invalid Event[%d] from MAC",
514                             pst->event);
515                   }
516                   ret = RFAILED;
517                   break;
518             }
519             break;
520          }
521 #ifdef SS_RBUF 
522       case ENTLWRMAC:
523       {
524             switch(pst->event)
525             {
526                case EVTCTFBTCHPROCTICK:
527                {
528                   rlcUtlDlBatchProcPkts();
529                   break;
530                }
531              }
532          ODU_PUT_MSG_BUF(mBuf);
533          break;
534       }
535 #endif
536       case ENTYS:
537          {
538             switch(pst->event)
539             {
540                case KWU_EVT_TTI_IND:
541                   {
542 #if (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF))
543                      rlcDlBatchProcSplit();
544 #else 
545 #if defined(PDCP_RLC_DL_RBUF)
546                      rlcDlBatchProc();
547 #endif
548 #endif
549
550 #if (defined(SPLIT_RLC_DL_TASK) && defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS))
551                      //RlcDlHarqStaBatchProc();
552                      rlcUtlDlBatchProcHqStaInd();
553 #endif 
554 #ifndef KWSELFPSTDLCLEAN
555                      /* Revanth_chg */
556                      /* Moving Cleanup from self post event to TTI event */
557                      rlcUtlFreeDlMem();
558 #endif 
559
560                      ODU_PUT_MSG_BUF(mBuf);
561                      break;
562                   }
563             }
564             break;
565          }
566
567
568       default:
569          {
570             if (pst->dstInst < MAX_RLC_INSTANCES)
571             {
572                /*RlcCb *tRlcCb = RLC_GET_RLCCB(pst->dstInst);*/
573                DU_LOG("\nERROR  --> RLC_DL : Received Invalid Source Entity[%d]",
574                      pst->event);
575             }
576             ODU_PUT_MSG_BUF(mBuf);
577             ret = RFAILED;
578             break;
579          }
580     }
581    ODU_EXIT_TASK();
582
583    return (ret);
584 } /* kwActvTsk */
585
586
587 \f  
588 /********************************************************************30**
589          End of file
590 **********************************************************************/