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 - Upper Interface
25 Desc: C source code for the upper interface of NR RLC
29 *********************************************************************21*/
32 @brief RLC Upper Interface
36 /* header (.h) include files */
37 #include "common_def.h"
38 #include "lkw.h" /* LKW defines */
39 #include "ckw.h" /* CKW defines */
40 #include "kwu.h" /* KWU defines */
41 #include "rgu.h" /* RGU defines */
44 #include "kw_env.h" /* RLC environment options */
45 #include "kw.h" /* RLC defines */
47 /* extern (.x) include files */
48 #include "lkw.x" /* LKW */
49 #include "ckw.x" /* CKW */
50 #include "kwu.x" /* KWU */
51 #include "rgu.x" /* RGU */
52 #if defined(MAC_RLC_UL_RBUF) || (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF)) || defined(SS_RBUF)
57 #if defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF)
58 #include "mt_plat_t33.h"
59 #include "mt_plat_t33.x"
64 #endif /* __cplusplus */
67 /*********************************************************************
68 * Forward Declartion for KWU Porting Functions
69 ********************************************************************/
70 #if defined(PDCP_RLC_DL_RBUF) || defined(SS_RBUF)
71 S16 rlcDlBatchProc ARGS ((Void));
72 S16 rlcUtlDlFreeRlcRBuf ARGS((Void));
73 void rlcUtlDlBatchProcHqStaInd ARGS ((Void));
74 Void rlcUtlFreeDlMem ARGS((Void));
76 S16 rlcUtlDlBatchProcPkts ARGS((Void));
79 #if (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF))
80 S16 rlcDlBatchProcSplit ARGS((Void));
84 /*********************************************************************
85 * Primitives for KWU interface
86 ********************************************************************/
88 /* KWU Bind Confirm primitive */
90 KwuBndCfm kwUiKwuBndCfmMt[] =
93 cmPkKwuBndCfm, /* 0 - loosely coupled */
94 #endif /* LCKWUIKWU */
96 NhLiKwuBndCfm, /* 1 - tightly coupled, RRC */
100 PjLiKwuBndCfm, /* 2 - tightly coupled, PDCP */
105 cmPkKwuBndCfm, /* 3 - light weight loosely coupled */
106 #endif /* LCKWUIKWU */
110 /* KWU Data Indication primitive */
112 KwuDatInd kwUiKwuDatIndMt[] =
115 cmPkKwuDatInd, /* 0 - loosely coupled */
116 #endif /* LCKWUIKWU */
118 NhLiKwuDatInd, /* 1 - tightly coupled, RRC */
123 PjLiKwuDatInd, /* 2 - tightly coupled, PDCP */
127 cmPkKwuDatInd, /* 3 - light weight loosely coupled */
128 #endif /* LCKWUIKWU */
134 KwuDatCfm kwUiKwuDatCfmMt[] =
137 cmPkKwuDatCfm, /* 0 - loosely coupled */
138 #endif /* LCKWUIKWU */
140 PjLiKwuDatCfm, /* 2 - tightly coupled, PDCP */
144 cmPkKwuDatCfm, /* 3 - light weight loosely coupled */
145 #endif /* LCKWUIKWU */
149 /* KWU AM Status Indication primitive */
151 KwuStaInd kwUiKwuStaIndMt[] =
154 cmPkKwuStaInd, /* 0 - loosely coupled */
155 #endif /* LCKWUIKWU */
157 PjLiKwuStaInd, /* 2 - tightly coupled, PDCP */
161 cmPkKwuStaInd, /* 3 - light weight loosely coupled */
162 #endif /* LCKWUIKWU */
166 KwuReEstCmpInd kwUiKwuReEstCmpIndMt[] =
169 cmPkKwuReEstCmpInd, /* 0 - loosely coupled */
170 #endif /* LCKWUIKWU */
172 PjLiKwuReEstCmpInd, /* 2 - tightly coupled, PDCP */
177 cmPkKwuReEstCmpInd, /* 3 - light weight loosely coupled */
178 #endif /* LCKWUIKWU */
182 /* kw005.201 added support for L2 measurement */
183 KwuDiscSduCfm kwUiKwuDiscSduCfmMt[] =
186 cmPkKwuDiscSduCfm, /* 0 - loosely coupled */
187 #endif /* LCKWUIKWU */
189 PjLiKwuDiscSduCfm, /* 2 - tightly coupled, PDCP */
193 cmPkKwuDiscSduCfm, /* 3 - light weight loosely coupled */
197 KwuFlowCntrlInd kwUiKwuFlowCntrlIndMt[] =
200 cmPkKwuFlowCntrlInd, /* 0 - loosely coupled */
201 #endif /* LCKWUIKWU */
203 PjLiKwuFlowCntrlInd, /* 2 - tightly coupled, PDCP */
206 cmPkKwuFlowCntrlInd, /* 3 - light weight loosely coupled */
207 #endif /* LCKWUIKWU */
210 KwuDatAckInd kwUiKwuDatAckIndMt[] =
213 cmPkKwuDatAckInd, /* 0 - loosely coupled */
214 #endif /* LCKWUIKWU */
216 PjLiKwuDatAckInd, /* 2 - tightly coupled, PDCP */
220 cmPkKwuDatAckInd, /* 3 - light weight loosely coupled, portable */
224 #endif /* LTE_L2_MEAS */
225 /* KWU AM Data confirm primitive */
230 /****************************************************************************
231 * KWU Interface Mt functions
232 ***************************************************************************/
\f
237 * Handler for confirming the bind request received from KWU
242 * This function send the bind confirm primitive to the RLC user,
243 * when it receives a bind request from its service user.
245 * @param[in] pst Post structure
246 * @param[in] suId Service user SAP ID
247 * @param[in] status Status of Confirmation
255 Pst *pst, /* post structure */
256 SuId suId, /* Service User Id */
257 uint8_t status /* Status */
261 /* jump to specific primitive depending on configured selector */
262 (*kwUiKwuBndCfmMt[pst->selector])(pst, suId, status);
266 } /* end of RlcUiKwuBndCfm */
273 * Handler for sending the data(SDU) from upper layer.
277 * This function is used to transfer a SDU received from the peer
278 * RLC entity to the service user(RRC/PDCP).
280 * @param[in] pst Post structure
281 * @param[in] suId Service User SAP ID
282 * @param[in] datIndInfo Data Request Information
283 * @param[in] mBuf Data Buffer (SDU)
289 S16 rlcSendUlDataToDu
292 KwuDatIndInfo *datInd,
297 /* jump to specific primitive depending on configured selector */
298 (*kwUiKwuDatIndMt[pst->selector])(pst, datInd, mBuf);
302 } /* end of rlcSendUlDataToDu */
304 int rlcDatCfmsSent = 0;
311 * Handler for sending the data confirmation to upper layer.
315 * This function is used to send a confirmation to the service
316 * user about the data received by the peer RLC entity.
318 * @param[in] pst Post structure
319 * @param[in] suId Service User SAP ID
320 * @param[in] datCfmInfo Data Confirmation Information
330 KwuDatCfmInfo *datCfm
335 /* jump to specific primitive depending on configured selector */
336 (*kwUiKwuDatCfmMt[pst->selector])(pst, suId, datCfm);
340 } /* end of RlcUiKwuDatCfm */
347 * Handler for sending the Status Indication to the upper layer.
351 * This function is used only by RLC AM entity.It send status
352 * indication to the upper layer about the maximum number of
353 * re-transmissions reached for a RLC AM entity.
355 * @param[in] pst Post structure
356 * @param[in] suId Service User SAP ID
357 * @param[in] staInd RLC Entity Id
367 KwuStaIndInfo *staInd
371 /* jump to specific primitive depending on configured selector */
372 (*kwUiKwuStaIndMt[pst->selector])(pst, suId, staInd);
376 } /* end of RlcUiKwuStaInd */
383 * Handler for sending the Status Indication to the upper layer.
387 * This function is used only by RLC AM entity.It send status
388 * indication to the upper layer about the maximum number of
389 * re-transmissions reached for a RLC AM entity.
391 * @param[in] pst Post structure
392 * @param[in] suId Service User SAP ID
393 * @param[in] staInd RLC Entity Id
399 S16 RlcUiKwuReEstCmpInd
406 DU_LOG("\nINFO --> RLC : In RlcUiKwuReEstCmpInd");
408 /* jump to specific primitive depending on configured selector */
409 (*kwUiKwuReEstCmpIndMt[pst->selector])(pst, suId, rlcId);
413 } /* end of RlcUiKwuReEstCmpInd */
414 /* kw005.201 added support for L2 Measurement */
420 * Handler for sending the Sdu Disc Cfm to the upper layer.
424 * This function confirms the discard of an SDU .
426 * @param[in] pst Post structure
427 * @param[in] suId Service User SAP ID
428 * @param[in] discCfm Disc information.
434 S16 RlcUiKwuDiscSduCfm
438 KwuDiscSduInfo *discCfm
442 /* jump to specific primitive depending on configured selector */
443 (*kwUiKwuDiscSduCfmMt[pst->selector])(pst, suId, discCfm);
447 } /* end of RlcUiKwuDiscSduCfm */
453 * Handler for sending Flow indication to the upper layer.
457 * This function indicates to PDCP if packets need to be stopped or
458 * started for a particular RB
460 * @param[in] pst Post structure
461 * @param[in] suId Service User SAP ID
462 * @param[in] flowCntrlIndInfo Flow control information.
468 S16 RlcUiKwuFlowCntrlInd(Pst *pst,SuId suId,KwuFlowCntrlIndInfo *flowCntrlIndInfo)
471 /* jump to specific primitive depending on configured selector */
472 (*kwUiKwuFlowCntrlIndMt[pst->selector])(pst, suId, flowCntrlIndInfo);
476 } /* end of RlcUiKwuFlowCntrlInd */
483 * Handler for sending the Data ack indication to the upper layer.
487 * This function confirms the succesfull transmission of SDU
489 * @param[in] pst Post structure
490 * @param[in] suId Service User SAP ID
491 * @param[in] datAckInd DatAckInd
497 S16 RlcUiKwuDatAckInd(Pst *pst,SuId suId,KwuDatAckInfo *datAckInd)
500 /* jump to specific primitive depending on configured selector */
501 (*kwUiKwuDatAckIndMt[pst->selector])(pst, suId, datAckInd);
505 } /* end of RlcUiKwuDatAckInd */
506 #endif /* LTE_L2_MEAS */
511 /*********************************************************************
512 * Primitives for CKW interface
513 ********************************************************************/
515 /* CKW Bind Confirm primitive */
517 CkwBndCfm kwUiCkwBndCfmMt[] =
520 cmPkCkwBndCfm, /* 0 - loosely coupled */
521 #endif /* LCCKUICKW */
523 NhLiCkwBndCfm, /* 1 - tightly coupled, RRC */
527 /* CKW Configuration confirm primitive */
529 RlcCfgCfm kwUiRlcCfgCfmMt[] =
532 cmPkRlcCfgCfm, /* 0 - loosely coupled */
533 #endif /* LCKWUICKW */
535 NhLiRlcCfgCfm, /* 1 - tightly coupled, RRC */
539 CkwUeIdChgCfm kwUiCkwUeIdChgCfmMt[] =
542 cmPkCkwUeIdChgCfm, /* 0 - loosely coupled */
543 #endif /* LCKWUICKW */
545 NhLiCkwUeIdChgCfm, /* 1 - tightly coupled, RRC */
551 /****************************************************************************
552 * CKW Interface Mt functions
553 ***************************************************************************/
558 * Handler for confirming the bind request received from CKW
563 * This function send the bind confirm primitive to the RLC user,
564 * when it receives a bind request from its service user.
566 * @param[in] pst - Post structure
567 * @param[in] suId - Service user SAP ID
568 * @param[in] status - Status
575 Pst *pst, /* post structure */
576 SuId suId, /* Service User Id */
577 uint8_t status /* Status */
581 /* jump to specific primitive depending on configured selector */
582 (*kwUiCkwBndCfmMt[pst->selector])(pst, suId, status);
586 } /* end of RlcUiCkwBndCfm */
593 * Handler for sending a configuration confirm to RRC.
597 * This function is used by RLC user to send a configuration
598 * confirmation to RRC after configuring(add/delete/modify)
601 * @param[in] pst Post structure
602 * @param[in] transId Transaction Id
603 * @param[in] cfmInfo Config Confirmation Info
611 Pst *pst, /* post structure */
612 SuId suId, /* Service User Id */
613 RlcCfgCfmInfo *cfmInfo /* Configuration Confirm */
617 /* jump to specific primitive depending on configured selector */
618 (*kwUiRlcCfgCfmMt[pst->selector])(pst, suId, cfmInfo);
622 } /* end of RlcUiRlcCfgCfm */
629 * Handler for sending a configuration for UE ID change.
633 * This function is used by RLC to send a configuration
634 * confirm for UE ID change.
636 * @param[in] pst Post structure
637 * @param[in] suId Service User Id
638 * @param[in] transId Transaction Id
639 * @param[in] cfmInfo Config Confirmation Info
645 S16 RlcUiCkwUeIdChgCfm
647 Pst *pst, /* post structure */
648 SuId suId, /* Service User Id */
655 /* jump to specific primitive depending on configured selector */
656 (*kwUiCkwUeIdChgCfmMt[pst->selector])(pst, suId, transId, ueInfo, status);
660 } /* end of RlcUiRlcCfgCfm */
663 #if (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF))
668 * rlcDlBatchProcSplit- process rbug messages
673 S16 rlcDlBatchProcSplit(Void)
676 /* Read from Ring Buffer and process PDCP packets */
677 Void *elmIndx = NULLP;
678 RxmBufReq *datReq = NULLP;
680 uint32_t dlPktCount = 0;
682 uint8_t rngBufDeqIndx = 0;
683 uint32_t rngBufDeqMaxCnt;
684 uint32_t rngBufCurrCnt;
686 rngBufDeqMaxCnt = SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT;
687 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
688 rngBufCurrCnt = SGetNumElemInRng(SS_RNG_BUF_RX_TO_DLRLC);
689 if ( rngBufCurrCnt > (3 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT))
691 if ( rngBufCurrCnt > (6 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT))
693 /* Restablishment scenario */
694 rngBufDeqMaxCnt = (4 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT);
698 rngBufDeqMaxCnt = (3 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT)/2;
702 elmIndx = SRngGetRIndx(SS_RNG_BUF_RX_TO_DLRLC);
703 while(NULLP != elmIndx)
705 datReq = (RxmBufReq *)elmIndx;
706 if(datReq->mBuf != NULLP)
708 cmUnpkKwuDatReq(rlcProcDlData, &datReq->pst, datReq->mBuf);
712 DU_LOG("\nERROR --> RLC : mBuf is NULL");
714 cmUnpkKwuDatReq(rlcProcDlData, &datReq->pst, datReq->mBuf);
717 SsRngInfoTbl[SS_RNG_BUF_RX_TO_DLRLC].nPktProc++;//Number of pkt processed in tti
718 datReq->mBuf = NULLP;
719 SRngIncrRIndx(SS_RNG_BUF_RX_TO_DLRLC);
721 if(rngBufDeqIndx >= rngBufDeqMaxCnt)
734 if((elmIndx = SRngGetRIndx(SS_RNG_BUF_RX_TO_DLRLC)) == NULLP)
744 #if defined(PDCP_RLC_DL_RBUF) || defined(SS_RBUF)
745 S16 rlcDlBatchProc(Void)
747 /* Read from Ring Buffer and process PDCP packets */
749 uint8_t rngBufDeqIndx = 0;
750 uint32_t rngBufDeqMaxCnt;
751 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
752 uint32_t rngBufCurrCnt;
754 /* Memory regions different for BRCM and Intel */
755 /*dstProcId,srcProcId,dstEnt,dstInst,srcEnt,srcInst,prior,route,event,region,pool,selector*/
757 static Pst rlcDlRbfuPst ={1,1,ENTRLC,1,ENTPJ,1,PRIOR0,RTESPEC,KWU_EVT_DAT_REQ,1,1,0,0};
759 static Pst rlcDlRbfuPst ={1,1,ENTRLC,1,ENTPJ,1,PRIOR0,RTESPEC,KWU_EVT_DAT_REQ,2,1,0,0};
761 Void *elmIndx = NULLP;
762 KwuDatReqDetl *kwuDatReqDetl = NULLP;
763 RlcDatReqInfo datReq;
765 rngBufDeqMaxCnt = SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT;
766 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
767 rngBufCurrCnt = SGetNumElemInRng(SS_RNG_BUF_DLPDCP_TO_DLRLC);
768 if ( rngBufCurrCnt > (3 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT))
770 if ( rngBufCurrCnt > (5 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT))
772 /* Restablishment scenario */
773 rngBufDeqMaxCnt = (4 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT);
777 rngBufDeqMaxCnt = (2 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT);
781 elmIndx = SRngGetRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
782 while(NULLP != elmIndx)
784 kwuDatReqDetl = (KwuDatReqDetl *)elmIndx;
785 datReq.rlcId = kwuDatReqDetl->rlcId;
786 datReq.sduId = kwuDatReqDetl->sduId;
787 datReq.lcType = kwuDatReqDetl->lcType;
788 SsRngInfoTbl[SS_RNG_BUF_DLPDCP_TO_DLRLC].nPktProc++;//Number of pkt processed in tti
789 if(kwuDatReqDetl->mBuf != NULLP)
791 rlcProcDlData(&rlcDlRbfuPst, kwuDatReqDetl->spId, &datReq, kwuDatReqDetl->mBuf);
793 SRngIncrRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
796 if(rngBufDeqIndx >= rngBufDeqMaxCnt)
800 elmIndx = (Void *)SRngGetRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
807 S16 rlcUtlDlBatchProcPkts(Void)
812 rlcUtlDlBatchProcHqStaInd();
820 S16 rlcUtlDlFreeRlcRBuf(Void)
822 /* Read from Ring Buffer and process PDCP packets */
823 Void *elmIndx = NULLP;
824 KwuDatReqDetl *kwuDatReqDetl = NULLP;
825 /* Free SS_RNG_BUF_DLPDCP_TO_DLRLC */
826 elmIndx = SRngGetRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
827 while(NULLP != elmIndx)
829 kwuDatReqDetl = (KwuDatReqDetl *)elmIndx;
830 SRngIncrRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
831 SsRngInfoTbl[SS_RNG_BUF_DLPDCP_TO_DLRLC].nPktProc++;
832 SPutMsg(kwuDatReqDetl->mBuf);
834 kwuDatReqDetl = NULLP;
835 if((elmIndx = SRngGetRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC)) == NULLP)
845 #endif /* __cplusplus */
846 /********************************************************************30**
848 **********************************************************************/