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 - Upper Interface
25 Desc: C source code for the upper interface of LTE-RLC
29 *********************************************************************21*/
30 static const char* RLOG_MODULE_NAME="UIM";
31 static int RLOG_MODULE_ID=2048;
32 static int RLOG_FILE_ID=199;
35 @brief RLC Upper Interface
39 /* header (.h) include files */
40 #include "common_def.h"
41 #include "lkw.h" /* LKW defines */
42 #include "ckw.h" /* CKW defines */
43 #include "kwu.h" /* KWU defines */
44 #include "rgu.h" /* RGU defines */
47 #include "kw_env.h" /* RLC environment options */
48 #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 */
55 #if defined(MAC_RLC_UL_RBUF) || (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF)) || defined(SS_RBUF)
60 #if defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF)
61 #include "mt_plat_t33.h"
62 #include "mt_plat_t33.x"
67 #endif /* __cplusplus */
70 /*********************************************************************
71 * Forward Declartion for KWU Porting Functions
72 ********************************************************************/
73 #if defined(PDCP_RLC_DL_RBUF) || defined(SS_RBUF)
74 S16 rlcDlBatchProc ARGS ((Void));
75 S16 rlcUtlDlFreeRlcRBuf ARGS((Void));
76 EXTERN void rlcUtlDlBatchProcHqStaInd ARGS ((Void));
77 EXTERN Void rlcUtlFreeDlMem ARGS((Void));
78 EXTERN SsRngBufCnt rngCb;
79 EXTERN S16 rlcUtlDlBatchProcPkts ARGS((Void));
82 #if (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF))
83 S16 rlcDlBatchProcSplit ARGS((Void));
87 /*********************************************************************
88 * Primitives for KWU interface
89 ********************************************************************/
91 /* KWU Bind Confirm primitive */
93 KwuBndCfm kwUiKwuBndCfmMt[] =
96 cmPkKwuBndCfm, /* 0 - loosely coupled */
97 #endif /* LCKWUIKWU */
99 NhLiKwuBndCfm, /* 1 - tightly coupled, RRC */
103 PjLiKwuBndCfm, /* 2 - tightly coupled, PDCP */
108 cmPkKwuBndCfm, /* 3 - light weight loosely coupled */
109 #endif /* LCKWUIKWU */
113 /* KWU Data Indication primitive */
115 KwuDatInd kwUiKwuDatIndMt[] =
118 cmPkKwuDatInd, /* 0 - loosely coupled */
119 #endif /* LCKWUIKWU */
121 NhLiKwuDatInd, /* 1 - tightly coupled, RRC */
126 PjLiKwuDatInd, /* 2 - tightly coupled, PDCP */
130 cmPkKwuDatInd, /* 3 - light weight loosely coupled */
131 #endif /* LCKWUIKWU */
137 KwuDatCfm kwUiKwuDatCfmMt[] =
140 cmPkKwuDatCfm, /* 0 - loosely coupled */
141 #endif /* LCKWUIKWU */
143 PjLiKwuDatCfm, /* 2 - tightly coupled, PDCP */
147 cmPkKwuDatCfm, /* 3 - light weight loosely coupled */
148 #endif /* LCKWUIKWU */
152 /* KWU AM Status Indication primitive */
154 KwuStaInd kwUiKwuStaIndMt[] =
157 cmPkKwuStaInd, /* 0 - loosely coupled */
158 #endif /* LCKWUIKWU */
160 PjLiKwuStaInd, /* 2 - tightly coupled, PDCP */
164 cmPkKwuStaInd, /* 3 - light weight loosely coupled */
165 #endif /* LCKWUIKWU */
169 KwuReEstCmpInd kwUiKwuReEstCmpIndMt[] =
172 cmPkKwuReEstCmpInd, /* 0 - loosely coupled */
173 #endif /* LCKWUIKWU */
175 PjLiKwuReEstCmpInd, /* 2 - tightly coupled, PDCP */
180 cmPkKwuReEstCmpInd, /* 3 - light weight loosely coupled */
181 #endif /* LCKWUIKWU */
185 /* kw005.201 added support for L2 measurement */
186 KwuDiscSduCfm kwUiKwuDiscSduCfmMt[] =
189 cmPkKwuDiscSduCfm, /* 0 - loosely coupled */
190 #endif /* LCKWUIKWU */
192 PjLiKwuDiscSduCfm, /* 2 - tightly coupled, PDCP */
196 cmPkKwuDiscSduCfm, /* 3 - light weight loosely coupled */
200 KwuFlowCntrlInd kwUiKwuFlowCntrlIndMt[] =
203 cmPkKwuFlowCntrlInd, /* 0 - loosely coupled */
204 #endif /* LCKWUIKWU */
206 PjLiKwuFlowCntrlInd, /* 2 - tightly coupled, PDCP */
209 cmPkKwuFlowCntrlInd, /* 3 - light weight loosely coupled */
210 #endif /* LCKWUIKWU */
213 KwuDatAckInd kwUiKwuDatAckIndMt[] =
216 cmPkKwuDatAckInd, /* 0 - loosely coupled */
217 #endif /* LCKWUIKWU */
219 PjLiKwuDatAckInd, /* 2 - tightly coupled, PDCP */
223 cmPkKwuDatAckInd, /* 3 - light weight loosely coupled, portable */
227 #endif /* LTE_L2_MEAS */
228 /* KWU AM Data confirm primitive */
233 /****************************************************************************
234 * KWU Interface Mt functions
235 ***************************************************************************/
\f
240 * Handler for confirming the bind request received from KWU
245 * This function send the bind confirm primitive to the RLC user,
246 * when it receives a bind request from its service user.
248 * @param[in] pst Post structure
249 * @param[in] suId Service user SAP ID
250 * @param[in] status Status of Confirmation
259 Pst *pst, /* post structure */
260 SuId suId, /* Service User Id */
261 U8 status /* Status */
264 S16 RlcUiKwuBndCfm(pst, suId, status)
265 Pst *pst; /* post structure */
266 SuId suId; /* Service User Id */
267 U8 status; /* Status */
272 /* jump to specific primitive depending on configured selector */
273 (*kwUiKwuBndCfmMt[pst->selector])(pst, suId, status);
277 } /* end of RlcUiKwuBndCfm */
284 * Handler for sending the data(SDU) from upper layer.
288 * This function is used to transfer a SDU received from the peer
289 * RLC entity to the service user(RRC/PDCP).
291 * @param[in] pst Post structure
292 * @param[in] suId Service User SAP ID
293 * @param[in] datIndInfo Data Request Information
294 * @param[in] mBuf Data Buffer (SDU)
301 S16 rlcSendUlDataToDu
304 KwuDatIndInfo *datInd,
308 S16 rlcSendUlDataToDu(pst, datInd, mBuf)
310 KwuDatIndInfo *datInd;
314 TRC3(rlcSendUlDataToDu)
316 /* jump to specific primitive depending on configured selector */
317 (*kwUiKwuDatIndMt[pst->selector])(pst, datInd, mBuf);
321 } /* end of rlcSendUlDataToDu */
323 int rlcDatCfmsSent = 0;
330 * Handler for sending the data confirmation to upper layer.
334 * This function is used to send a confirmation to the service
335 * user about the data received by the peer RLC entity.
337 * @param[in] pst Post structure
338 * @param[in] suId Service User SAP ID
339 * @param[in] datCfmInfo Data Confirmation Information
350 KwuDatCfmInfo *datCfm
353 S16 RlcUiKwuDatCfm(pst, suId, datCfm)
356 KwuDatCfmInfo *datCfm;
362 /* jump to specific primitive depending on configured selector */
363 (*kwUiKwuDatCfmMt[pst->selector])(pst, suId, datCfm);
367 } /* end of RlcUiKwuDatCfm */
374 * Handler for sending the Status Indication to the upper layer.
378 * This function is used only by RLC AM entity.It send status
379 * indication to the upper layer about the maximum number of
380 * re-transmissions reached for a RLC AM entity.
382 * @param[in] pst Post structure
383 * @param[in] suId Service User SAP ID
384 * @param[in] staInd RLC Entity Id
395 KwuStaIndInfo *staInd
398 S16 RlcUiKwuStaInd(pst, suId, staInd)
401 KwuStaIndInfo *staInd;
406 /* jump to specific primitive depending on configured selector */
407 (*kwUiKwuStaIndMt[pst->selector])(pst, suId, staInd);
411 } /* end of RlcUiKwuStaInd */
418 * Handler for sending the Status Indication to the upper layer.
422 * This function is used only by RLC AM entity.It send status
423 * indication to the upper layer about the maximum number of
424 * re-transmissions reached for a RLC AM entity.
426 * @param[in] pst Post structure
427 * @param[in] suId Service User SAP ID
428 * @param[in] staInd RLC Entity Id
435 S16 RlcUiKwuReEstCmpInd
442 S16 RlcUiKwuReEstCmpInd(pst, suId, rlcId)
448 TRC3(RlcUiKwuReEstCmpInd)
449 RLOG0(L_DEBUG, "In RlcUiKwuReEstCmpInd");
451 /* jump to specific primitive depending on configured selector */
452 (*kwUiKwuReEstCmpIndMt[pst->selector])(pst, suId, rlcId);
456 } /* end of RlcUiKwuReEstCmpInd */
457 /* kw005.201 added support for L2 Measurement */
463 * Handler for sending the Sdu Disc Cfm to the upper layer.
467 * This function confirms the discard of an SDU .
469 * @param[in] pst Post structure
470 * @param[in] suId Service User SAP ID
471 * @param[in] discCfm Disc information.
478 S16 RlcUiKwuDiscSduCfm
482 KwuDiscSduInfo *discCfm
485 S16 RlcUiKwuDiscSduCfm(pst, suId, discCfm)
488 KwuDiscSduInfo *discCfm;
491 TRC3(RlcUiKwuDiscSduCfm)
493 /* jump to specific primitive depending on configured selector */
494 (*kwUiKwuDiscSduCfmMt[pst->selector])(pst, suId, discCfm);
498 } /* end of RlcUiKwuDiscSduCfm */
504 * Handler for sending Flow indication to the upper layer.
508 * This function indicates to PDCP if packets need to be stopped or
509 * started for a particular RB
511 * @param[in] pst Post structure
512 * @param[in] suId Service User SAP ID
513 * @param[in] flowCntrlIndInfo Flow control information.
520 S16 RlcUiKwuFlowCntrlInd
524 KwuFlowCntrlIndInfo *flowCntrlIndInfo
527 S16 RlcUiKwuFlowCntrlInd(pst, suId, flowCntrlIndInfo)
530 KwuFlowCntrlIndInfo *flowCntrlIndInfo;
533 TRC3(RlcUiKwuFlowCntrlInd)
535 /* jump to specific primitive depending on configured selector */
536 (*kwUiKwuFlowCntrlIndMt[pst->selector])(pst, suId, flowCntrlIndInfo);
540 } /* end of RlcUiKwuFlowCntrlInd */
547 * Handler for sending the Data ack indication to the upper layer.
551 * This function confirms the succesfull transmission of SDU
553 * @param[in] pst Post structure
554 * @param[in] suId Service User SAP ID
555 * @param[in] datAckInd DatAckInd
562 S16 RlcUiKwuDatAckInd
566 KwuDatAckInfo *datAckInd
569 S16 RlcUiKwuDatAckInd(pst, suId, datAckInd)
572 KwuDatAckInfo *datAckInd;
575 TRC3(RlcUiKwuDatAckInd)
577 /* jump to specific primitive depending on configured selector */
578 (*kwUiKwuDatAckIndMt[pst->selector])(pst, suId, datAckInd);
582 } /* end of RlcUiKwuDatAckInd */
583 #endif /* LTE_L2_MEAS */
588 /*********************************************************************
589 * Primitives for CKW interface
590 ********************************************************************/
592 /* CKW Bind Confirm primitive */
594 CkwBndCfm kwUiCkwBndCfmMt[] =
597 cmPkCkwBndCfm, /* 0 - loosely coupled */
598 #endif /* LCCKUICKW */
600 NhLiCkwBndCfm, /* 1 - tightly coupled, RRC */
604 /* CKW Configuration confirm primitive */
606 RlcCfgCfm kwUiRlcCfgCfmMt[] =
609 cmPkRlcCfgCfm, /* 0 - loosely coupled */
610 #endif /* LCKWUICKW */
612 NhLiRlcCfgCfm, /* 1 - tightly coupled, RRC */
616 CkwUeIdChgCfm kwUiCkwUeIdChgCfmMt[] =
619 cmPkCkwUeIdChgCfm, /* 0 - loosely coupled */
620 #endif /* LCKWUICKW */
622 NhLiCkwUeIdChgCfm, /* 1 - tightly coupled, RRC */
628 /****************************************************************************
629 * CKW Interface Mt functions
630 ***************************************************************************/
635 * Handler for confirming the bind request received from CKW
640 * This function send the bind confirm primitive to the RLC user,
641 * when it receives a bind request from its service user.
643 * @param[in] pst - Post structure
644 * @param[in] suId - Service user SAP ID
645 * @param[in] status - Status
653 Pst *pst, /* post structure */
654 SuId suId, /* Service User Id */
655 U8 status /* Status */
658 S16 RlcUiCkwBndCfm(pst, suId, status)
659 Pst *pst; /* post structure */
660 SuId suId; /* Service User Id */
661 U8 status; /* Status */
666 /* jump to specific primitive depending on configured selector */
667 (*kwUiCkwBndCfmMt[pst->selector])(pst, suId, status);
671 } /* end of RlcUiCkwBndCfm */
678 * Handler for sending a configuration confirm to RRC.
682 * This function is used by RLC user to send a configuration
683 * confirmation to RRC after configuring(add/delete/modify)
686 * @param[in] pst Post structure
687 * @param[in] transId Transaction Id
688 * @param[in] cfmInfo Config Confirmation Info
697 Pst *pst, /* post structure */
698 SuId suId, /* Service User Id */
699 RlcCfgCfmInfo *cfmInfo /* Configuration Confirm */
702 S16 RlcUiRlcCfgCfm(pst, suId, cfmInfo)
703 Pst *pst; /* post structure */
704 SuId suId; /* Service User Id */
705 RlcCfgCfmInfo *cfmInfo; /* Configuration Confirm */
710 /* jump to specific primitive depending on configured selector */
711 (*kwUiRlcCfgCfmMt[pst->selector])(pst, suId, cfmInfo);
715 } /* end of RlcUiRlcCfgCfm */
722 * Handler for sending a configuration for UE ID change.
726 * This function is used by RLC to send a configuration
727 * confirm for UE ID change.
729 * @param[in] pst Post structure
730 * @param[in] suId Service User Id
731 * @param[in] transId Transaction Id
732 * @param[in] cfmInfo Config Confirmation Info
739 S16 RlcUiCkwUeIdChgCfm
741 Pst *pst, /* post structure */
742 SuId suId, /* Service User Id */
748 S16 RlcUiCkwUeIdChgCfm(pst, suId, transId,ueInfo,status)
749 Pst *pst; /* post structure */
750 SuId suId; /* Service User Id */
756 TRC3(RlcUiCkwUeIdChgCfm)
758 /* jump to specific primitive depending on configured selector */
759 (*kwUiCkwUeIdChgCfmMt[pst->selector])(pst, suId, transId, ueInfo, status);
763 } /* end of RlcUiRlcCfgCfm */
766 #if (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF))
771 * rlcDlBatchProcSplit- process rbug messages
777 S16 rlcDlBatchProcSplit
782 S16 rlcDlBatchProcSplit()
787 /* Read from Ring Buffer and process PDCP packets */
788 Void *elmIndx = NULLP;
789 RxmBufReq *datReq = NULLP;
793 U8 rngBufDeqIndx = 0;
797 rngBufDeqMaxCnt = SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT;
798 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
799 rngBufCurrCnt = SGetNumElemInRng(SS_RNG_BUF_RX_TO_DLRLC);
800 if ( rngBufCurrCnt > (3 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT))
802 if ( rngBufCurrCnt > (6 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT))
804 /* Restablishment scenario */
805 rngBufDeqMaxCnt = (4 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT);
809 rngBufDeqMaxCnt = (3 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT)/2;
813 elmIndx = SRngGetRIndx(SS_RNG_BUF_RX_TO_DLRLC);
814 while(NULLP != elmIndx)
816 datReq = (RxmBufReq *)elmIndx;
817 if(datReq->mBuf != NULLP)
819 cmUnpkKwuDatReq(rlcProcDlData, &datReq->pst, datReq->mBuf);
823 RLOG0(L_ERROR, "mBuf is NULL");
825 cmUnpkKwuDatReq(rlcProcDlData, &datReq->pst, datReq->mBuf);
828 SsRngInfoTbl[SS_RNG_BUF_RX_TO_DLRLC].nPktProc++;//Number of pkt processed in tti
829 datReq->mBuf = NULLP;
830 SRngIncrRIndx(SS_RNG_BUF_RX_TO_DLRLC);
832 if(rngBufDeqIndx >= rngBufDeqMaxCnt)
845 if((elmIndx = SRngGetRIndx(SS_RNG_BUF_RX_TO_DLRLC)) == NULLP)
855 #if defined(PDCP_RLC_DL_RBUF) || defined(SS_RBUF)
866 /* Read from Ring Buffer and process PDCP packets */
868 U8 rngBufDeqIndx = 0;
870 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
873 /* Memory regions different for BRCM and Intel */
874 /*dstProcId,srcProcId,dstEnt,dstInst,srcEnt,srcInst,prior,route,event,region,pool,selector*/
876 PRIVATE Pst rlcDlRbfuPst ={1,1,ENTRLC,1,ENTPJ,1,PRIOR0,RTESPEC,KWU_EVT_DAT_REQ,1,1,0,0};
878 PRIVATE Pst rlcDlRbfuPst ={1,1,ENTRLC,1,ENTPJ,1,PRIOR0,RTESPEC,KWU_EVT_DAT_REQ,2,1,0,0};
880 Void *elmIndx = NULLP;
881 KwuDatReqDetl *kwuDatReqDetl = NULLP;
882 KwuDatReqInfo datReq;
884 rngBufDeqMaxCnt = SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT;
885 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
886 rngBufCurrCnt = SGetNumElemInRng(SS_RNG_BUF_DLPDCP_TO_DLRLC);
887 if ( rngBufCurrCnt > (3 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT))
889 if ( rngBufCurrCnt > (5 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT))
891 /* Restablishment scenario */
892 rngBufDeqMaxCnt = (4 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT);
896 rngBufDeqMaxCnt = (2 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT);
900 elmIndx = SRngGetRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
901 while(NULLP != elmIndx)
903 kwuDatReqDetl = (KwuDatReqDetl *)elmIndx;
904 datReq.rlcId = kwuDatReqDetl->rlcId;
905 datReq.sduId = kwuDatReqDetl->sduId;
906 datReq.lcType = kwuDatReqDetl->lcType;
907 SsRngInfoTbl[SS_RNG_BUF_DLPDCP_TO_DLRLC].nPktProc++;;//Number of pkt processed in tti
908 if(kwuDatReqDetl->mBuf != NULLP)
910 rlcProcDlData(&rlcDlRbfuPst, kwuDatReqDetl->spId, &datReq, kwuDatReqDetl->mBuf);
912 SRngIncrRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
915 if(rngBufDeqIndx >= rngBufDeqMaxCnt)
919 elmIndx = (Void *)SRngGetRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
927 S16 rlcUtlDlBatchProcPkts
932 S16 rlcUtlDlBatchProcPkts
939 rlcUtlDlBatchProcHqStaInd();
948 S16 rlcUtlDlFreeRlcRBuf
953 S16 rlcUtlDlFreeRlcRBuf
957 /* Read from Ring Buffer and process PDCP packets */
958 Void *elmIndx = NULLP;
959 KwuDatReqDetl *kwuDatReqDetl = NULLP;
960 /* Free SS_RNG_BUF_DLPDCP_TO_DLRLC */
961 elmIndx = SRngGetRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
962 while(NULLP != elmIndx)
964 kwuDatReqDetl = (KwuDatReqDetl *)elmIndx;
965 SRngIncrRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
966 SsRngInfoTbl[SS_RNG_BUF_DLPDCP_TO_DLRLC].nPktProc++;
967 SPutMsg(kwuDatReqDetl->mBuf);
969 kwuDatReqDetl = NULLP;
970 if((elmIndx = SRngGetRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC)) == NULLP)
980 #endif /* __cplusplus */
981 /********************************************************************30**
983 **********************************************************************/