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: NR RLC Layer - System Services Interface Functions
25 Desc: C source code for the interface to System Services
30 *********************************************************************21*/
32 /** @filekw_dl_ex_ms.c
33 @brief RLC System Services Interface
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 */
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 */
58 #include "du_app_rlc_inf.h"
59 #include "rlc_mac_inf.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));
69 #if (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF))
70 S16 rlcDlBatchProcSplit ARGS((Void));
74 uint32_t rlcAmmStaPduList[512] = {0};
75 S16 ssGetDBufOfSize ARGS((Region region, Size size, Buffer **dBuf));
77 S16 rlcDlInitExt ARGS (( Void ));
83 * <b> Initialize External </b>
86 * Initializes variables used to interface with Upper/Lower Layer
100 /***********************************************************************
101 System Service Interface Functions
102 ***********************************************************************/
107 * <b> Activates Initialization </b>
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.
114 * Allowable values for parameters are specified in ssi.h.
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.
129 Ent ent, /* entity */
130 Inst inst, /* instance */
131 Region region, /* region */
132 Reason reason /* reason */
137 if (inst >= MAX_RLC_INSTANCES)
139 /* intance greater than MAX instances */
143 if (rlcCb[inst] != NULLP)
148 if (SGetSBuf(region, 0, (Data **)&tRlcCb,
149 (Size)sizeof (RlcCb)) != ROK)
153 /* Initialize rlcCb */
154 RLC_MEM_SET(tRlcCb, 0, sizeof(RlcCb));
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();
168 rlcCb[inst] = tRlcCb;
172 for(int i = 0; i < 512; i++)
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;
182 /* call external function for intialization */
197 * <b> Activation Task </b>
200 * Processes events received for NR RLC layer via System Services from
203 * @param[in] pst - Pst Structure
204 * @param[in] mBuf - Message Buffer
210 #if (defined (MAC_FREE_RING_BUF) || defined (RLC_FREE_RING_BUF))
211 pthread_t gRlcTId = 0;
215 Pst *pst, /* pst structure */
216 Buffer *mBuf /* message buffer */
221 #ifdef RLC_FREE_RING_BUF
222 gRlcTId = pthread_self();
232 case LKW_EVT_CFG_REQ:
234 ret = unpackRlcConfigReq(RlcMiRlcConfigReq, pst, mBuf);
238 case LKW_EVT_CNTRL_REQ:
240 ret = cmUnpkLkwCntrlReq(RlcMiLkwCntrlReq, pst, mBuf);
244 case LKW_EVT_STS_REQ:
246 ret = cmUnpkLkwStsReq(RlcMiLkwStsReq, pst, mBuf);
250 case LKW_EVT_STA_REQ:
252 ret = cmUnpkLkwStaReq(RlcMiLkwStaReq, pst, mBuf);
255 /* kw005.201 added support for L2 Measurement */
259 case KWU_EVT_DAT_REQ: /* Data request */
261 //ret = cmUnpkKwuDatReq(rlcProcDlData, pst, mBuf);
266 case EVENT_DL_RRC_MSG_TRANS_TO_RLC:
268 ret = unpackDlRrcMsgToRlc(RlcProcDlRrcMsgTransfer, pst, mBuf);
271 case EVENT_DL_USER_DATA_TRANS_TO_RLC:
273 ret = unpackRlcDlUserDataToRlc(RlcProcDlUserDataTransfer, pst, mBuf);
277 ODU_PUT_MSG_BUF(mBuf);
278 if (pst->dstInst < MAX_RLC_INSTANCES)
280 DU_LOG("\nERROR --> RLC_DL : Received Invalid Event[%d] from SM",
296 case UDX_EVT_BND_REQ: /* Bind request */
298 ret = cmUnpkUdxBndReq(rlcDlUdxBndReq, pst, mBuf );
302 case UDX_EVT_UBND_REQ: /* Bind request */
304 ret = cmUnpkUdxUbndReq(rlcDlUdxUbndReq, pst, mBuf );
307 case UDX_EVT_CFG_REQ: /* Unbind request */
309 ret = cmUnpkUdxCfgReq(rlcDlUdxCfgReq, pst, mBuf );
313 case UDX_EVT_UEIDCHG_REQ: /* Configuration request */
315 ret = cmUnpkUdxUeIdChgReq(rlcDlUdxUeIdChgReq, pst, mBuf);
319 case UDX_EVT_STA_UPD_REQ: /* Configuration request */
321 ret = cmUnpkUdxStaUpdReq(rlcDlUdxStaUpdReq, pst, mBuf);
325 case UDX_EVT_STA_PDU_REQ: /* Configuration request */
327 ret = cmUnpkUdxStaPduReq(rlcDlUdxStaPduReq, pst, mBuf);
332 case UDX_EVT_L2MEAS_REQ:
334 ret = cmUnpkUdxL2MeasReq(rlcDlUdxL2MeasReq, pst, mBuf);
337 case UDX_EVT_L2MEAS_SEND_REQ:
340 ret = cmUnpkUdxL2MeasSendReq(rlcDlUdxL2MeasSendReq, pst, mBuf);
344 case UDX_EVT_L2MEAS_STOP_REQ:
346 ret = cmUnpkUdxL2MeasStopReq(rlcDlUdxL2MeasStopReq, pst, mBuf);
352 case UDX_EVT_DL_CLEANUP_MEM:
354 rlcUtlFreeDlMemory(RLC_GET_RLCCB(pst->dstInst));
359 ODU_PUT_MSG_BUF(mBuf);
360 if (pst->dstInst < MAX_RLC_INSTANCES)
362 DU_LOG("\nERROR --> RLC_DL : Received Invalid Event[%d] from RLC UL",
377 case KWU_EVT_BND_REQ: /* Bind request */
379 ret = cmUnpkKwuBndReq(RlcUiKwuBndReq, pst, mBuf );
383 case KWU_EVT_UBND_REQ: /* Unbind request */
385 ret = cmUnpkKwuUbndReq(RlcUiKwuUbndReq, pst, mBuf );
389 case KWU_EVT_CPLANE_DAT_REQ: /* C-Plane Data request */
391 ret = cmUnpkKwuDatReq(rlcProcDlData, pst, mBuf);
395 case KWU_EVT_DAT_REQ: /* Data request */
397 //ret = cmUnpkKwuDatReq(rlcProcDlData, pst, mBuf);
401 case KWU_EVT_DISC_SDU_REQ: /* Discard SDU request */
403 ret = cmUnpkKwuDiscSduReq(RlcUiKwuDiscSduReq, pst, mBuf);
409 ODU_PUT_MSG_BUF(mBuf);
410 if (pst->dstInst < MAX_RLC_INSTANCES)
412 DU_LOG("\nERROR --> RLC_DL : Received Invalid Event[%d] from RRC",
427 case KWU_EVT_BND_REQ: /* Bind request */
429 ret = cmUnpkKwuBndReq(RlcUiKwuBndReq, pst, mBuf );
433 case KWU_EVT_UBND_REQ: /* Unbind request */
435 ret = cmUnpkKwuUbndReq(RlcUiKwuUbndReq, pst, mBuf );
439 case KWU_EVT_CPLANE_DAT_REQ: /* C-Plane Data request */
440 case KWU_EVT_UPLANE_DAT_REQ: /* U-Plane Data request */
442 ret = cmUnpkKwuDatReq(rlcProcDlData, pst, mBuf);
446 case KWU_EVT_DAT_REQ: /* Data request */
448 //ret = cmUnpkKwuDatReq(rlcProcDlData, pst, mBuf);
452 case KWU_EVT_DISC_SDU_REQ: /* Discard SDU request */
454 ret = cmUnpkKwuDiscSduReq(RlcUiKwuDiscSduReq, pst, mBuf);
459 ODU_PUT_MSG_BUF(mBuf);
460 if (pst->dstInst < MAX_RLC_INSTANCES)
462 DU_LOG("\nERROR --> RLC_DL : Received Invalid Event[%d] from PDCP",
477 case EVTRGUBNDCFM: /* Bind request */
479 ret = cmUnpkRguBndCfm(RlcLiRguBndCfm, pst, mBuf );
482 case EVENT_SCHED_RESULT_TO_RLC:
484 ret = unpackSchedResultRpt(RlcProcSchedResultRpt, pst, mBuf);
487 /* kw005.201 added support for L2 Measurement */
489 case EVTRGUHQSTAIND: /* Harq status indication */
491 ret = cmUnpkRguHqStaInd(RlcLiRguHqStaInd, pst, mBuf);
495 case EVTRGUFLOWCNTRLIND:
497 ret = cmUnpkRguFlowCntrlInd(RlcLiRguFlowCntrlInd,pst,mBuf);
501 #ifdef RLC_STA_PROC_IN_MAC/* RLC Status PDU Processing */
502 case UDX_EVT_STA_UPD_REQ: /* Configuration request */
504 ret = cmUnpkUdxStaUpdReq(rlcDlUdxStaUpdReq, pst, mBuf);
510 ODU_PUT_MSG_BUF(mBuf);
511 if (pst->dstInst < MAX_RLC_INSTANCES)
513 DU_LOG("\nERROR --> RLC_DL : Received Invalid Event[%d] from MAC",
526 case EVTCTFBTCHPROCTICK:
528 rlcUtlDlBatchProcPkts();
532 ODU_PUT_MSG_BUF(mBuf);
540 case KWU_EVT_TTI_IND:
542 #if (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF))
543 rlcDlBatchProcSplit();
545 #if defined(PDCP_RLC_DL_RBUF)
550 #if (defined(SPLIT_RLC_DL_TASK) && defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS))
551 //RlcDlHarqStaBatchProc();
552 rlcUtlDlBatchProcHqStaInd();
554 #ifndef KWSELFPSTDLCLEAN
556 /* Moving Cleanup from self post event to TTI event */
560 ODU_PUT_MSG_BUF(mBuf);
570 if (pst->dstInst < MAX_RLC_INSTANCES)
572 /*RlcCb *tRlcCb = RLC_GET_RLCCB(pst->dstInst);*/
573 DU_LOG("\nERROR --> RLC_DL : Received Invalid Source Entity[%d]",
576 ODU_PUT_MSG_BUF(mBuf);
588 /********************************************************************30**
590 **********************************************************************/