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 case KWU_EVT_DAT_REQ: /* Data request */
307 ret = cmUnpkKwuDatReq(KwUiKwuDatReq, pst, mBuf);
313 if (pst->dstInst < KW_MAX_RLC_INSTANCES)
315 RLOG1(L_ERROR,"Received Invalid Event[%d] from SM",
331 case UDX_EVT_BND_REQ: /* Bind request */
333 ret = cmUnpkUdxBndReq(KwDlUdxBndReq, pst, mBuf );
337 case UDX_EVT_UBND_REQ: /* Bind request */
339 ret = cmUnpkUdxUbndReq(KwDlUdxUbndReq, pst, mBuf );
342 case UDX_EVT_CFG_REQ: /* Unbind request */
344 ret = cmUnpkUdxCfgReq(KwDlUdxCfgReq, pst, mBuf );
348 case UDX_EVT_UEIDCHG_REQ: /* Configuration request */
350 ret = cmUnpkUdxUeIdChgReq(KwDlUdxUeIdChgReq, pst, mBuf);
354 case UDX_EVT_STA_UPD_REQ: /* Configuration request */
356 ret = cmUnpkUdxStaUpdReq(KwDlUdxStaUpdReq, pst, mBuf);
360 case UDX_EVT_STA_PDU_REQ: /* Configuration request */
362 ret = cmUnpkUdxStaPduReq(KwDlUdxStaPduReq, pst, mBuf);
367 case UDX_EVT_L2MEAS_REQ:
369 ret = cmUnpkUdxL2MeasReq(KwDlUdxL2MeasReq, pst, mBuf);
372 case UDX_EVT_L2MEAS_SEND_REQ:
375 ret = cmUnpkUdxL2MeasSendReq(KwDlUdxL2MeasSendReq, pst, mBuf);
379 case UDX_EVT_L2MEAS_STOP_REQ:
381 ret = cmUnpkUdxL2MeasStopReq(KwDlUdxL2MeasStopReq, pst, mBuf);
387 case UDX_EVT_DL_CLEANUP_MEM:
389 kwUtlFreeDlMemory(KW_GET_KWCB(pst->dstInst));
395 if (pst->dstInst < KW_MAX_RLC_INSTANCES)
397 RLOG1(L_ERROR,"Received Invalid Event[%d] from RLC UL",
412 case KWU_EVT_BND_REQ: /* Bind request */
414 ret = cmUnpkKwuBndReq(KwUiKwuBndReq, pst, mBuf );
418 case KWU_EVT_UBND_REQ: /* Unbind request */
420 ret = cmUnpkKwuUbndReq(KwUiKwuUbndReq, pst, mBuf );
424 case KWU_EVT_CPLANE_DAT_REQ: /* C-Plane Data request */
426 ret = cmUnpkKwuDatReq(KwUiKwuDatReq, pst, mBuf);
430 case KWU_EVT_DAT_REQ: /* Data request */
432 ret = cmUnpkKwuDatReq(KwUiKwuDatReq, pst, mBuf);
436 case KWU_EVT_DISC_SDU_REQ: /* Discard SDU request */
438 ret = cmUnpkKwuDiscSduReq(KwUiKwuDiscSduReq, pst, mBuf);
445 if (pst->dstInst < KW_MAX_RLC_INSTANCES)
447 RLOG1(L_ERROR,"Received Invalid Event[%d] from RRC",
462 case KWU_EVT_BND_REQ: /* Bind request */
464 ret = cmUnpkKwuBndReq(KwUiKwuBndReq, pst, mBuf );
468 case KWU_EVT_UBND_REQ: /* Unbind request */
470 ret = cmUnpkKwuUbndReq(KwUiKwuUbndReq, pst, mBuf );
474 case KWU_EVT_CPLANE_DAT_REQ: /* C-Plane Data request */
475 case KWU_EVT_UPLANE_DAT_REQ: /* U-Plane Data request */
477 ret = cmUnpkKwuDatReq(KwUiKwuDatReq, pst, mBuf);
481 case KWU_EVT_DAT_REQ: /* Data request */
483 ret = cmUnpkKwuDatReq(KwUiKwuDatReq, pst, mBuf);
487 case KWU_EVT_DISC_SDU_REQ: /* Discard SDU request */
489 ret = cmUnpkKwuDiscSduReq(KwUiKwuDiscSduReq, pst, mBuf);
495 if (pst->dstInst < KW_MAX_RLC_INSTANCES)
497 RLOG1(L_ERROR,"Received Invalid Event[%d] from PDCP",
512 case EVTRGUBNDCFM: /* Bind request */
514 ret = cmUnpkRguBndCfm(KwLiRguBndCfm, pst, mBuf );
517 case EVTSCHREP: /* Dedicated Channel Status Response */
519 ret = unpackSchedRep(RlcMacProcSchedRep, pst, mBuf);
522 /* kw005.201 added support for L2 Measurement */
524 case EVTRGUHQSTAIND: /* Harq status indication */
526 ret = cmUnpkRguHqStaInd(KwLiRguHqStaInd, pst, mBuf);
530 case EVTRGUFLOWCNTRLIND:
532 ret = cmUnpkRguFlowCntrlInd(KwLiRguFlowCntrlInd,pst,mBuf);
536 #ifdef RLC_STA_PROC_IN_MAC/* RLC Status PDU Processing */
537 case UDX_EVT_STA_UPD_REQ: /* Configuration request */
539 ret = cmUnpkUdxStaUpdReq(KwDlUdxStaUpdReq, pst, mBuf);
546 if (pst->dstInst < KW_MAX_RLC_INSTANCES)
548 RLOG1(L_ERROR,"Received Invalid Event[%d] from MAC",
561 case EVTCTFBTCHPROCTICK:
563 kwUtlDlBatchProcPkts();
575 case KWU_EVT_TTI_IND:
577 #if (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF))
578 kwDlBatchProcSplit();
580 #if defined(PDCP_RLC_DL_RBUF)
585 #if (defined(SPLIT_RLC_DL_TASK) && defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS))
586 //KwDlHarqStaBatchProc();
587 kwUtlDlBatchProcHqStaInd();
589 #ifndef KWSELFPSTDLCLEAN
591 /* Moving Cleanup from self post event to TTI event */
605 if (pst->dstInst < KW_MAX_RLC_INSTANCES)
607 /*KwCb *tKwCb = KW_GET_KWCB(pst->dstInst);*/
608 RLOG1(L_ERROR, "Received Invalid Source Entity[%d]",
623 /********************************************************************30**
625 **********************************************************************/