1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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 *******************************************************************************/
19 /********************************************************************20**
21 Name: LTE-RLC Layer - System Services Interface Functions
25 Desc: C source code for the interface to System Services
30 *********************************************************************21*/
31 static const char* RLOG_MODULE_NAME="RLC_DL";
32 static int RLOG_MODULE_ID=2048;
33 static int RLOG_FILE_ID=195;
35 /** @filekw_dl_ex_ms.c
36 @brief RLC System Services Interface
40 /* header (.h) include files */
41 #include "envopt.h" /* environment options */
42 #include "envdep.h" /* environment dependent */
43 #include "envind.h" /* environment independent */
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 */
64 /* extern (.x) include files */
65 #include "gen.x" /* general */
66 #include "ssi.x" /* system services */
68 #include "cm5.x" /* common timer library */
69 #include "cm_tkns.x" /* common tokens */
70 #include "cm_mblk.x" /* common memory allocation */
71 #include "cm_llist.x" /* common link list */
72 #include "cm_hash.x" /* common hash list */
73 #include "cm_lte.x" /* common LTE includes */
74 #include "cm_lib.x" /* common memory allocation library */
75 #include "lkw.x" /* LKW */
76 #include "ckw.x" /* CKW */
77 #include "kwu.x" /* KWU */
78 #include "rgu.x" /* RGU */
84 PUBLIC S16 kwUtlDlBatchProcPkts(Void);
85 PUBLIC S16 kwDlBatchProc(Void);
86 #if (defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS))
87 U32 isDatReqProcessed;
88 PUBLIC void kwUtlDlBatchProcHqStaInd ARGS ((Void));
91 #if (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF))
92 EXTERN S16 kwDlBatchProcSplit ARGS((Void));
96 U32 kwAmmStaPduList[512] = {0};
97 EXTERN S16 ssGetDBufOfSize ARGS((Region region, Size size, Buffer **dBuf));
99 PUBLIC S16 kwDlInitExt ARGS (( Void ));
105 * <b> Initialize External </b>
108 * Initializes variables used to interface with Upper/Lower Layer
116 PUBLIC S16 kwDlInitExt
120 PUBLIC S16 kwDlInitExt()
130 /***********************************************************************
131 System Service Interface Functions
132 ***********************************************************************/
137 * <b> Activates Initialization </b>
140 * This function is invoked by system services to initialize the LTE-RLC
141 * layer. This is an entry point used by LTE_RLC layer to initialize its
142 * global variables, before becoming operational.
144 * Allowable values for parameters are specified in ssi.h.
146 * @param[in] ent - Specify the entity id of the LTE-RLC task.
147 * @param[in] inst - Specify the entity id of the LTE-RLC task.
148 * @param[in] region - Specifies the memory region from which
149 * LTE-RLC should allocate structures and buffers.
150 * @param[in] reason - Specifies the reason for calling this
151 * initialization function.
158 PUBLIC S16 kwDlActvInit
160 Ent ent, /* entity */
161 Inst inst, /* instance */
162 Region region, /* region */
163 Reason reason /* reason */
166 PUBLIC S16 kwDlActvInit(ent, inst, region, reason)
167 Ent ent; /* entity */
168 Inst inst; /* instance */
169 Region region; /* region */
170 Reason reason; /* reason */
176 if (inst >= KW_MAX_RLC_INSTANCES)
178 /* intance greater than MAX instances */
182 if (kwCb[inst] != NULLP)
187 if (SGetSBuf(region, 0, (Data **)&tKwCb,
188 (Size)sizeof (KwCb)) != ROK)
192 /* Initialize kwCb */
193 KW_MEM_SET(tKwCb, 0, sizeof(KwCb));
195 /* Initialize task configuration parameters */
196 tKwCb->init.ent = ent; /* entity */
197 tKwCb->init.inst = inst; /* instance */
198 tKwCb->init.region = region; /* static region */
199 tKwCb->init.pool = 0; /* static pool */
200 tKwCb->init.reason = reason; /* reason */
201 tKwCb->init.cfgDone = FALSE; /* configuration done */
202 tKwCb->init.acnt = TRUE; /* enable accounting */
203 tKwCb->init.usta = TRUE; /* enable unsolicited status */
204 tKwCb->init.trc = FALSE; /* enable trace */
205 tKwCb->init.procId = SFndProcId();
211 for(int i = 0; i < 512; i++)
214 Buffer *bufPtr = NULL;
215 SGetMsg(1, 0 , &mBuf);
216 ssGetDBufOfSize(1 , 1800, &bufPtr);
217 SUpdMsg(mBuf, bufPtr, 0);
218 kwAmmStaPduList[i] = (U32)mBuf;
221 /* call external function for intialization */
236 * <b> Activation Task </b>
239 * Processes events received for MLTE-RLC layer via System Services from
242 * @param[in] pst - Pst Structure
243 * @param[in] mBuf - Message Buffer
249 #if (defined (MAC_FREE_RING_BUF) || defined (RLC_FREE_RING_BUF))
250 pthread_t gRlcTId = 0;
253 PUBLIC S16 kwDlActvTsk
255 Pst *pst, /* pst structure */
256 Buffer *mBuf /* message buffer */
259 PUBLIC S16 kwDlActvTsk(pst, mBuf)
260 Pst *pst; /* pst structure */
261 Buffer *mBuf; /* message buffer */
267 #ifdef RLC_FREE_RING_BUF
268 gRlcTId = pthread_self();
278 case LKW_EVT_CFG_REQ:
280 ret = cmUnpkLkwCfgReq(KwMiLkwCfgReq, pst, mBuf);
284 case LKW_EVT_CNTRL_REQ:
286 ret = cmUnpkLkwCntrlReq(KwMiLkwCntrlReq, pst, mBuf);
290 case LKW_EVT_STS_REQ:
292 ret = cmUnpkLkwStsReq(KwMiLkwStsReq, pst, mBuf);
296 case LKW_EVT_STA_REQ:
298 ret = cmUnpkLkwStaReq(KwMiLkwStaReq, pst, mBuf);
301 /* kw005.201 added support for L2 Measurement */
305 if (pst->dstInst < KW_MAX_RLC_INSTANCES)
307 RLOG1(L_ERROR,"Received Invalid Event[%d] from SM",
323 case UDX_EVT_BND_REQ: /* Bind request */
325 ret = cmUnpkUdxBndReq(KwDlUdxBndReq, pst, mBuf );
329 case UDX_EVT_UBND_REQ: /* Bind request */
331 ret = cmUnpkUdxUbndReq(KwDlUdxUbndReq, pst, mBuf );
334 case UDX_EVT_CFG_REQ: /* Unbind request */
336 ret = cmUnpkUdxCfgReq(KwDlUdxCfgReq, pst, mBuf );
340 case UDX_EVT_UEIDCHG_REQ: /* Configuration request */
342 ret = cmUnpkUdxUeIdChgReq(KwDlUdxUeIdChgReq, pst, mBuf);
346 case UDX_EVT_STA_UPD_REQ: /* Configuration request */
348 ret = cmUnpkUdxStaUpdReq(KwDlUdxStaUpdReq, pst, mBuf);
352 case UDX_EVT_STA_PDU_REQ: /* Configuration request */
354 ret = cmUnpkUdxStaPduReq(KwDlUdxStaPduReq, pst, mBuf);
359 case UDX_EVT_L2MEAS_REQ:
361 ret = cmUnpkUdxL2MeasReq(KwDlUdxL2MeasReq, pst, mBuf);
364 case UDX_EVT_L2MEAS_SEND_REQ:
367 ret = cmUnpkUdxL2MeasSendReq(KwDlUdxL2MeasSendReq, pst, mBuf);
371 case UDX_EVT_L2MEAS_STOP_REQ:
373 ret = cmUnpkUdxL2MeasStopReq(KwDlUdxL2MeasStopReq, pst, mBuf);
379 case UDX_EVT_DL_CLEANUP_MEM:
381 kwUtlFreeDlMemory(KW_GET_KWCB(pst->dstInst));
387 if (pst->dstInst < KW_MAX_RLC_INSTANCES)
389 RLOG1(L_ERROR,"Received Invalid Event[%d] from RLC UL",
404 case KWU_EVT_BND_REQ: /* Bind request */
406 ret = cmUnpkKwuBndReq(KwUiKwuBndReq, pst, mBuf );
410 case KWU_EVT_UBND_REQ: /* Unbind request */
412 ret = cmUnpkKwuUbndReq(KwUiKwuUbndReq, pst, mBuf );
416 case KWU_EVT_CPLANE_DAT_REQ: /* C-Plane Data request */
418 ret = cmUnpkKwuDatReq(KwUiKwuDatReq, pst, mBuf);
422 case KWU_EVT_DAT_REQ: /* Data request */
424 ret = cmUnpkKwuDatReq(KwUiKwuDatReq, pst, mBuf);
428 case KWU_EVT_DISC_SDU_REQ: /* Discard SDU request */
430 ret = cmUnpkKwuDiscSduReq(KwUiKwuDiscSduReq, pst, mBuf);
437 if (pst->dstInst < KW_MAX_RLC_INSTANCES)
439 RLOG1(L_ERROR,"Received Invalid Event[%d] from RRC",
454 case KWU_EVT_BND_REQ: /* Bind request */
456 ret = cmUnpkKwuBndReq(KwUiKwuBndReq, pst, mBuf );
460 case KWU_EVT_UBND_REQ: /* Unbind request */
462 ret = cmUnpkKwuUbndReq(KwUiKwuUbndReq, pst, mBuf );
466 case KWU_EVT_CPLANE_DAT_REQ: /* C-Plane Data request */
467 case KWU_EVT_UPLANE_DAT_REQ: /* U-Plane Data request */
469 ret = cmUnpkKwuDatReq(KwUiKwuDatReq, pst, mBuf);
473 case KWU_EVT_DAT_REQ: /* Data request */
475 ret = cmUnpkKwuDatReq(KwUiKwuDatReq, pst, mBuf);
479 case KWU_EVT_DISC_SDU_REQ: /* Discard SDU request */
481 ret = cmUnpkKwuDiscSduReq(KwUiKwuDiscSduReq, pst, mBuf);
487 if (pst->dstInst < KW_MAX_RLC_INSTANCES)
489 RLOG1(L_ERROR,"Received Invalid Event[%d] from PDCP",
504 case EVTRGUBNDCFM: /* Bind request */
506 ret = cmUnpkRguBndCfm(KwLiRguBndCfm, pst, mBuf );
510 case EVTRGUCSTAIND: /* Coomon Channel Status Response */
512 ret = cmUnpkRguCStaInd(KwLiRguCStaInd, pst, mBuf);
516 case EVTRGUDSTAIND: /* Dedicated Channel Status Response */
518 ret = cmUnpkRguDStaInd(KwLiRguDStaInd, pst, mBuf);
521 /* kw005.201 added support for L2 Measurement */
523 case EVTRGUHQSTAIND: /* Harq status indication */
525 ret = cmUnpkRguHqStaInd(KwLiRguHqStaInd, pst, mBuf);
529 case EVTRGUFLOWCNTRLIND:
531 ret = cmUnpkRguFlowCntrlInd(KwLiRguFlowCntrlInd,pst,mBuf);
535 #ifdef RLC_STA_PROC_IN_MAC/* RLC Status PDU Processing */
536 case UDX_EVT_STA_UPD_REQ: /* Configuration request */
538 ret = cmUnpkUdxStaUpdReq(KwDlUdxStaUpdReq, pst, mBuf);
545 if (pst->dstInst < KW_MAX_RLC_INSTANCES)
547 RLOG1(L_ERROR,"Received Invalid Event[%d] from MAC",
560 case EVTCTFBTCHPROCTICK:
562 kwUtlDlBatchProcPkts();
574 case KWU_EVT_TTI_IND:
576 #if (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF))
577 kwDlBatchProcSplit();
579 #if defined(PDCP_RLC_DL_RBUF)
584 #if (defined(SPLIT_RLC_DL_TASK) && defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS))
585 //KwDlHarqStaBatchProc();
586 kwUtlDlBatchProcHqStaInd();
588 #ifndef KWSELFPSTDLCLEAN
590 /* Moving Cleanup from self post event to TTI event */
604 if (pst->dstInst < KW_MAX_RLC_INSTANCES)
606 /*KwCb *tKwCb = KW_GET_KWCB(pst->dstInst);*/
607 RLOG1(L_ERROR, "Received Invalid Source Entity[%d]",
622 /********************************************************************30**
624 **********************************************************************/