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 */
61 #include "du_app_rlc_inf.h"
62 #include "rlc_mac_inf.h"
65 S16 rlcUtlDlBatchProcPkts(Void);
66 S16 rlcDlBatchProc(Void);
67 #if (defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS))
68 uint32_t isDatReqProcessed;
69 void rlcUtlDlBatchProcHqStaInd ARGS ((Void));
72 #if (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF))
73 S16 rlcDlBatchProcSplit ARGS((Void));
77 uint32_t rlcAmmStaPduList[512] = {0};
78 S16 ssGetDBufOfSize ARGS((Region region, Size size, Buffer **dBuf));
80 S16 rlcDlInitExt ARGS (( Void ));
86 * <b> Initialize External </b>
89 * Initializes variables used to interface with Upper/Lower Layer
103 /***********************************************************************
104 System Service Interface Functions
105 ***********************************************************************/
110 * <b> Activates Initialization </b>
113 * This function is invoked by system services to initialize the LTE-RLC
114 * layer. This is an entry point used by LTE_RLC layer to initialize its
115 * global variables, before becoming operational.
117 * Allowable values for parameters are specified in ssi.h.
119 * @param[in] ent - Specify the entity id of the LTE-RLC task.
120 * @param[in] inst - Specify the entity id of the LTE-RLC task.
121 * @param[in] region - Specifies the memory region from which
122 * LTE-RLC should allocate structures and buffers.
123 * @param[in] reason - Specifies the reason for calling this
124 * initialization function.
132 Ent ent, /* entity */
133 Inst inst, /* instance */
134 Region region, /* region */
135 Reason reason /* reason */
140 if (inst >= MAX_RLC_INSTANCES)
142 /* intance greater than MAX instances */
146 if (rlcCb[inst] != NULLP)
151 if (SGetSBuf(region, 0, (Data **)&tRlcCb,
152 (Size)sizeof (RlcCb)) != ROK)
156 /* Initialize rlcCb */
157 RLC_MEM_SET(tRlcCb, 0, sizeof(RlcCb));
159 /* Initialize task configuration parameters */
160 tRlcCb->init.ent = ent; /* entity */
161 tRlcCb->init.inst = inst; /* instance */
162 tRlcCb->init.region = region; /* static region */
163 tRlcCb->init.pool = 0; /* static pool */
164 tRlcCb->init.reason = reason; /* reason */
165 tRlcCb->init.cfgDone = FALSE; /* configuration done */
166 tRlcCb->init.acnt = TRUE; /* enable accounting */
167 tRlcCb->init.usta = TRUE; /* enable unsolicited status */
168 tRlcCb->init.trc = FALSE; /* enable trace */
169 tRlcCb->init.procId = ODU_GET_PROCID();
171 rlcCb[inst] = tRlcCb;
175 for(int i = 0; i < 512; i++)
178 Buffer *bufPtr = NULL;
179 SGetMsg(1, 0 , &mBuf);
180 ssGetDBufOfSize(1 , 1800, &bufPtr);
181 SUpdMsg(mBuf, bufPtr, 0);
182 rlcAmmStaPduList[i] = (uint32_t)mBuf;
185 /* call external function for intialization */
200 * <b> Activation Task </b>
203 * Processes events received for MLTE-RLC layer via System Services from
206 * @param[in] pst - Pst Structure
207 * @param[in] mBuf - Message Buffer
213 #if (defined (MAC_FREE_RING_BUF) || defined (RLC_FREE_RING_BUF))
214 pthread_t gRlcTId = 0;
218 Pst *pst, /* pst structure */
219 Buffer *mBuf /* message buffer */
224 #ifdef RLC_FREE_RING_BUF
225 gRlcTId = pthread_self();
235 case LKW_EVT_CFG_REQ:
237 ret = unpackRlcConfigReq(RlcMiRlcConfigReq, pst, mBuf);
241 case LKW_EVT_CNTRL_REQ:
243 ret = cmUnpkLkwCntrlReq(RlcMiLkwCntrlReq, pst, mBuf);
247 case LKW_EVT_STS_REQ:
249 ret = cmUnpkLkwStsReq(RlcMiLkwStsReq, pst, mBuf);
253 case LKW_EVT_STA_REQ:
255 ret = cmUnpkLkwStaReq(RlcMiLkwStaReq, pst, mBuf);
258 /* kw005.201 added support for L2 Measurement */
262 case KWU_EVT_DAT_REQ: /* Data request */
264 //ret = cmUnpkKwuDatReq(rlcProcDlData, pst, mBuf);
269 case EVENT_DL_RRC_MSG_TRANS_TO_RLC:
271 ret = unpackDlRrcMsgToRlc(RlcProcDlRrcMsgTransfer, pst, mBuf);
274 case EVENT_DL_USER_DATA_TRANS_TO_RLC:
276 ret = unpackRlcDlUserDataToRlc(RlcProcDlUserDataTransfer, pst, mBuf);
280 ODU_PUT_MSG_BUF(mBuf);
281 if (pst->dstInst < MAX_RLC_INSTANCES)
283 RLOG1(L_ERROR,"Received Invalid Event[%d] from SM",
299 case UDX_EVT_BND_REQ: /* Bind request */
301 ret = cmUnpkUdxBndReq(rlcDlUdxBndReq, pst, mBuf );
305 case UDX_EVT_UBND_REQ: /* Bind request */
307 ret = cmUnpkUdxUbndReq(rlcDlUdxUbndReq, pst, mBuf );
310 case UDX_EVT_CFG_REQ: /* Unbind request */
312 ret = cmUnpkUdxCfgReq(rlcDlUdxCfgReq, pst, mBuf );
316 case UDX_EVT_UEIDCHG_REQ: /* Configuration request */
318 ret = cmUnpkUdxUeIdChgReq(rlcDlUdxUeIdChgReq, pst, mBuf);
322 case UDX_EVT_STA_UPD_REQ: /* Configuration request */
324 ret = cmUnpkUdxStaUpdReq(rlcDlUdxStaUpdReq, pst, mBuf);
328 case UDX_EVT_STA_PDU_REQ: /* Configuration request */
330 ret = cmUnpkUdxStaPduReq(rlcDlUdxStaPduReq, pst, mBuf);
335 case UDX_EVT_L2MEAS_REQ:
337 ret = cmUnpkUdxL2MeasReq(rlcDlUdxL2MeasReq, pst, mBuf);
340 case UDX_EVT_L2MEAS_SEND_REQ:
343 ret = cmUnpkUdxL2MeasSendReq(rlcDlUdxL2MeasSendReq, pst, mBuf);
347 case UDX_EVT_L2MEAS_STOP_REQ:
349 ret = cmUnpkUdxL2MeasStopReq(rlcDlUdxL2MeasStopReq, pst, mBuf);
355 case UDX_EVT_DL_CLEANUP_MEM:
357 rlcUtlFreeDlMemory(RLC_GET_RLCCB(pst->dstInst));
362 ODU_PUT_MSG_BUF(mBuf);
363 if (pst->dstInst < MAX_RLC_INSTANCES)
365 RLOG1(L_ERROR,"Received Invalid Event[%d] from RLC UL",
380 case KWU_EVT_BND_REQ: /* Bind request */
382 ret = cmUnpkKwuBndReq(RlcUiKwuBndReq, pst, mBuf );
386 case KWU_EVT_UBND_REQ: /* Unbind request */
388 ret = cmUnpkKwuUbndReq(RlcUiKwuUbndReq, pst, mBuf );
392 case KWU_EVT_CPLANE_DAT_REQ: /* C-Plane Data request */
394 ret = cmUnpkKwuDatReq(rlcProcDlData, pst, mBuf);
398 case KWU_EVT_DAT_REQ: /* Data request */
400 //ret = cmUnpkKwuDatReq(rlcProcDlData, pst, mBuf);
404 case KWU_EVT_DISC_SDU_REQ: /* Discard SDU request */
406 ret = cmUnpkKwuDiscSduReq(RlcUiKwuDiscSduReq, pst, mBuf);
412 ODU_PUT_MSG_BUF(mBuf);
413 if (pst->dstInst < MAX_RLC_INSTANCES)
415 RLOG1(L_ERROR,"Received Invalid Event[%d] from RRC",
430 case KWU_EVT_BND_REQ: /* Bind request */
432 ret = cmUnpkKwuBndReq(RlcUiKwuBndReq, pst, mBuf );
436 case KWU_EVT_UBND_REQ: /* Unbind request */
438 ret = cmUnpkKwuUbndReq(RlcUiKwuUbndReq, pst, mBuf );
442 case KWU_EVT_CPLANE_DAT_REQ: /* C-Plane Data request */
443 case KWU_EVT_UPLANE_DAT_REQ: /* U-Plane Data request */
445 ret = cmUnpkKwuDatReq(rlcProcDlData, pst, mBuf);
449 case KWU_EVT_DAT_REQ: /* Data request */
451 //ret = cmUnpkKwuDatReq(rlcProcDlData, pst, mBuf);
455 case KWU_EVT_DISC_SDU_REQ: /* Discard SDU request */
457 ret = cmUnpkKwuDiscSduReq(RlcUiKwuDiscSduReq, pst, mBuf);
462 ODU_PUT_MSG_BUF(mBuf);
463 if (pst->dstInst < MAX_RLC_INSTANCES)
465 RLOG1(L_ERROR,"Received Invalid Event[%d] from PDCP",
480 case EVTRGUBNDCFM: /* Bind request */
482 ret = cmUnpkRguBndCfm(RlcLiRguBndCfm, pst, mBuf );
485 case EVENT_SCHED_RESULT_TO_RLC:
487 ret = unpackSchedResultRpt(RlcProcSchedResultRpt, pst, mBuf);
490 /* kw005.201 added support for L2 Measurement */
492 case EVTRGUHQSTAIND: /* Harq status indication */
494 ret = cmUnpkRguHqStaInd(RlcLiRguHqStaInd, pst, mBuf);
498 case EVTRGUFLOWCNTRLIND:
500 ret = cmUnpkRguFlowCntrlInd(RlcLiRguFlowCntrlInd,pst,mBuf);
504 #ifdef RLC_STA_PROC_IN_MAC/* RLC Status PDU Processing */
505 case UDX_EVT_STA_UPD_REQ: /* Configuration request */
507 ret = cmUnpkUdxStaUpdReq(rlcDlUdxStaUpdReq, pst, mBuf);
513 ODU_PUT_MSG_BUF(mBuf);
514 if (pst->dstInst < MAX_RLC_INSTANCES)
516 RLOG1(L_ERROR,"Received Invalid Event[%d] from MAC",
529 case EVTCTFBTCHPROCTICK:
531 rlcUtlDlBatchProcPkts();
535 ODU_PUT_MSG_BUF(mBuf);
543 case KWU_EVT_TTI_IND:
545 #if (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF))
546 rlcDlBatchProcSplit();
548 #if defined(PDCP_RLC_DL_RBUF)
553 #if (defined(SPLIT_RLC_DL_TASK) && defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS))
554 //RlcDlHarqStaBatchProc();
555 rlcUtlDlBatchProcHqStaInd();
557 #ifndef KWSELFPSTDLCLEAN
559 /* Moving Cleanup from self post event to TTI event */
563 ODU_PUT_MSG_BUF(mBuf);
573 if (pst->dstInst < MAX_RLC_INSTANCES)
575 /*RlcCb *tRlcCb = RLC_GET_RLCCB(pst->dstInst);*/
576 RLOG1(L_ERROR, "Received Invalid Source Entity[%d]",
579 ODU_PUT_MSG_BUF(mBuf);
591 /********************************************************************30**
593 **********************************************************************/