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 "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 */
53 /* extern (.x) include files */
54 #include "lkw.x" /* LKW */
55 #include "ckw.x" /* CKW */
56 #include "kwu.x" /* KWU */
57 #include "rgu.x" /* RGU */
63 PUBLIC S16 kwUtlDlBatchProcPkts(Void);
64 PUBLIC S16 rlcDlBatchProc(Void);
65 #if (defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS))
66 U32 isDatReqProcessed;
67 PUBLIC void kwUtlDlBatchProcHqStaInd ARGS ((Void));
70 #if (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF))
71 EXTERN S16 rlcDlBatchProcSplit ARGS((Void));
75 U32 kwAmmStaPduList[512] = {0};
76 EXTERN S16 ssGetDBufOfSize ARGS((Region region, Size size, Buffer **dBuf));
78 PUBLIC S16 rlcDlInitExt ARGS (( Void ));
84 * <b> Initialize External </b>
87 * Initializes variables used to interface with Upper/Lower Layer
95 PUBLIC S16 rlcDlInitExt
99 PUBLIC S16 rlcDlInitExt()
109 /***********************************************************************
110 System Service Interface Functions
111 ***********************************************************************/
116 * <b> Activates Initialization </b>
119 * This function is invoked by system services to initialize the LTE-RLC
120 * layer. This is an entry point used by LTE_RLC layer to initialize its
121 * global variables, before becoming operational.
123 * Allowable values for parameters are specified in ssi.h.
125 * @param[in] ent - Specify the entity id of the LTE-RLC task.
126 * @param[in] inst - Specify the entity id of the LTE-RLC task.
127 * @param[in] region - Specifies the memory region from which
128 * LTE-RLC should allocate structures and buffers.
129 * @param[in] reason - Specifies the reason for calling this
130 * initialization function.
137 PUBLIC S16 rlcDlActvInit
139 Ent ent, /* entity */
140 Inst inst, /* instance */
141 Region region, /* region */
142 Reason reason /* reason */
145 PUBLIC S16 rlcDlActvInit(ent, inst, region, reason)
146 Ent ent; /* entity */
147 Inst inst; /* instance */
148 Region region; /* region */
149 Reason reason; /* reason */
155 if (inst >= MAX_RLC_INSTANCES)
157 /* intance greater than MAX instances */
161 if (rlcCb[inst] != NULLP)
166 if (SGetSBuf(region, 0, (Data **)&tRlcCb,
167 (Size)sizeof (RlcCb)) != ROK)
171 /* Initialize rlcCb */
172 RLC_MEM_SET(tRlcCb, 0, sizeof(RlcCb));
174 /* Initialize task configuration parameters */
175 tRlcCb->init.ent = ent; /* entity */
176 tRlcCb->init.inst = inst; /* instance */
177 tRlcCb->init.region = region; /* static region */
178 tRlcCb->init.pool = 0; /* static pool */
179 tRlcCb->init.reason = reason; /* reason */
180 tRlcCb->init.cfgDone = FALSE; /* configuration done */
181 tRlcCb->init.acnt = TRUE; /* enable accounting */
182 tRlcCb->init.usta = TRUE; /* enable unsolicited status */
183 tRlcCb->init.trc = FALSE; /* enable trace */
184 tRlcCb->init.procId = SFndProcId();
186 rlcCb[inst] = tRlcCb;
190 for(int i = 0; i < 512; i++)
193 Buffer *bufPtr = NULL;
194 SGetMsg(1, 0 , &mBuf);
195 ssGetDBufOfSize(1 , 1800, &bufPtr);
196 SUpdMsg(mBuf, bufPtr, 0);
197 kwAmmStaPduList[i] = (U32)mBuf;
200 /* call external function for intialization */
215 * <b> Activation Task </b>
218 * Processes events received for MLTE-RLC layer via System Services from
221 * @param[in] pst - Pst Structure
222 * @param[in] mBuf - Message Buffer
228 #if (defined (MAC_FREE_RING_BUF) || defined (RLC_FREE_RING_BUF))
229 pthread_t gRlcTId = 0;
232 PUBLIC S16 rlcDlActvTsk
234 Pst *pst, /* pst structure */
235 Buffer *mBuf /* message buffer */
238 PUBLIC S16 rlcDlActvTsk(pst, mBuf)
239 Pst *pst; /* pst structure */
240 Buffer *mBuf; /* message buffer */
246 #ifdef RLC_FREE_RING_BUF
247 gRlcTId = pthread_self();
257 case LKW_EVT_CFG_REQ:
259 ret = unpackRlcConfigReq(KwMiRlcConfigReq, pst, mBuf);
263 case LKW_EVT_CNTRL_REQ:
265 ret = cmUnpkLkwCntrlReq(KwMiLkwCntrlReq, pst, mBuf);
269 case LKW_EVT_STS_REQ:
271 ret = cmUnpkLkwStsReq(KwMiLkwStsReq, pst, mBuf);
275 case LKW_EVT_STA_REQ:
277 ret = cmUnpkLkwStaReq(KwMiLkwStaReq, pst, mBuf);
280 /* kw005.201 added support for L2 Measurement */
284 case KWU_EVT_DAT_REQ: /* Data request */
286 ret = cmUnpkKwuDatReq(KwUiKwuDatReq, pst, mBuf);
292 if (pst->dstInst < MAX_RLC_INSTANCES)
294 RLOG1(L_ERROR,"Received Invalid Event[%d] from SM",
310 case UDX_EVT_BND_REQ: /* Bind request */
312 ret = cmUnpkUdxBndReq(rlcDlUdxBndReq, pst, mBuf );
316 case UDX_EVT_UBND_REQ: /* Bind request */
318 ret = cmUnpkUdxUbndReq(rlcDlUdxUbndReq, pst, mBuf );
321 case UDX_EVT_CFG_REQ: /* Unbind request */
323 ret = cmUnpkUdxCfgReq(rlcDlUdxCfgReq, pst, mBuf );
327 case UDX_EVT_UEIDCHG_REQ: /* Configuration request */
329 ret = cmUnpkUdxUeIdChgReq(rlcDlUdxUeIdChgReq, pst, mBuf);
333 case UDX_EVT_STA_UPD_REQ: /* Configuration request */
335 ret = cmUnpkUdxStaUpdReq(rlcDlUdxStaUpdReq, pst, mBuf);
339 case UDX_EVT_STA_PDU_REQ: /* Configuration request */
341 ret = cmUnpkUdxStaPduReq(rlcDlUdxStaPduReq, pst, mBuf);
346 case UDX_EVT_L2MEAS_REQ:
348 ret = cmUnpkUdxL2MeasReq(rlcDlUdxL2MeasReq, pst, mBuf);
351 case UDX_EVT_L2MEAS_SEND_REQ:
354 ret = cmUnpkUdxL2MeasSendReq(rlcDlUdxL2MeasSendReq, pst, mBuf);
358 case UDX_EVT_L2MEAS_STOP_REQ:
360 ret = cmUnpkUdxL2MeasStopReq(rlcDlUdxL2MeasStopReq, pst, mBuf);
366 case UDX_EVT_DL_CLEANUP_MEM:
368 kwUtlFreeDlMemory(RLC_GET_RLCCB(pst->dstInst));
374 if (pst->dstInst < MAX_RLC_INSTANCES)
376 RLOG1(L_ERROR,"Received Invalid Event[%d] from RLC UL",
391 case KWU_EVT_BND_REQ: /* Bind request */
393 ret = cmUnpkKwuBndReq(KwUiKwuBndReq, pst, mBuf );
397 case KWU_EVT_UBND_REQ: /* Unbind request */
399 ret = cmUnpkKwuUbndReq(KwUiKwuUbndReq, pst, mBuf );
403 case KWU_EVT_CPLANE_DAT_REQ: /* C-Plane Data request */
405 ret = cmUnpkKwuDatReq(KwUiKwuDatReq, pst, mBuf);
409 case KWU_EVT_DAT_REQ: /* Data request */
411 ret = cmUnpkKwuDatReq(KwUiKwuDatReq, pst, mBuf);
415 case KWU_EVT_DISC_SDU_REQ: /* Discard SDU request */
417 ret = cmUnpkKwuDiscSduReq(KwUiKwuDiscSduReq, pst, mBuf);
424 if (pst->dstInst < MAX_RLC_INSTANCES)
426 RLOG1(L_ERROR,"Received Invalid Event[%d] from RRC",
441 case KWU_EVT_BND_REQ: /* Bind request */
443 ret = cmUnpkKwuBndReq(KwUiKwuBndReq, pst, mBuf );
447 case KWU_EVT_UBND_REQ: /* Unbind request */
449 ret = cmUnpkKwuUbndReq(KwUiKwuUbndReq, pst, mBuf );
453 case KWU_EVT_CPLANE_DAT_REQ: /* C-Plane Data request */
454 case KWU_EVT_UPLANE_DAT_REQ: /* U-Plane Data request */
456 ret = cmUnpkKwuDatReq(KwUiKwuDatReq, pst, mBuf);
460 case KWU_EVT_DAT_REQ: /* Data request */
462 ret = cmUnpkKwuDatReq(KwUiKwuDatReq, pst, mBuf);
466 case KWU_EVT_DISC_SDU_REQ: /* Discard SDU request */
468 ret = cmUnpkKwuDiscSduReq(KwUiKwuDiscSduReq, pst, mBuf);
474 if (pst->dstInst < MAX_RLC_INSTANCES)
476 RLOG1(L_ERROR,"Received Invalid Event[%d] from PDCP",
491 case EVTRGUBNDCFM: /* Bind request */
493 ret = cmUnpkRguBndCfm(KwLiRguBndCfm, pst, mBuf );
496 case EVTSCHREP: /* Dedicated Channel Status Response */
498 ret = unpackSchedRep(RlcMacProcSchedRep, pst, mBuf);
501 /* kw005.201 added support for L2 Measurement */
503 case EVTRGUHQSTAIND: /* Harq status indication */
505 ret = cmUnpkRguHqStaInd(KwLiRguHqStaInd, pst, mBuf);
509 case EVTRGUFLOWCNTRLIND:
511 ret = cmUnpkRguFlowCntrlInd(KwLiRguFlowCntrlInd,pst,mBuf);
515 #ifdef RLC_STA_PROC_IN_MAC/* RLC Status PDU Processing */
516 case UDX_EVT_STA_UPD_REQ: /* Configuration request */
518 ret = cmUnpkUdxStaUpdReq(rlcDlUdxStaUpdReq, pst, mBuf);
525 if (pst->dstInst < MAX_RLC_INSTANCES)
527 RLOG1(L_ERROR,"Received Invalid Event[%d] from MAC",
540 case EVTCTFBTCHPROCTICK:
542 kwUtlDlBatchProcPkts();
554 case KWU_EVT_TTI_IND:
556 #if (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF))
557 rlcDlBatchProcSplit();
559 #if defined(PDCP_RLC_DL_RBUF)
564 #if (defined(SPLIT_RLC_DL_TASK) && defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS))
565 //RlcDlHarqStaBatchProc();
566 kwUtlDlBatchProcHqStaInd();
568 #ifndef KWSELFPSTDLCLEAN
570 /* Moving Cleanup from self post event to TTI event */
584 if (pst->dstInst < MAX_RLC_INSTANCES)
586 /*RlcCb *tRlcCb = RLC_GET_RLCCB(pst->dstInst);*/
587 RLOG1(L_ERROR, "Received Invalid Source Entity[%d]",
602 /********************************************************************30**
604 **********************************************************************/