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 */
271 /* jump to specific primitive depending on configured selector */
272 (*kwUiKwuBndCfmMt[pst->selector])(pst, suId, status);
276 } /* end of RlcUiKwuBndCfm */
283 * Handler for sending the data(SDU) from upper layer.
287 * This function is used to transfer a SDU received from the peer
288 * RLC entity to the service user(RRC/PDCP).
290 * @param[in] pst Post structure
291 * @param[in] suId Service User SAP ID
292 * @param[in] datIndInfo Data Request Information
293 * @param[in] mBuf Data Buffer (SDU)
300 S16 rlcSendUlDataToDu
303 KwuDatIndInfo *datInd,
307 S16 rlcSendUlDataToDu(pst, datInd, mBuf)
309 KwuDatIndInfo *datInd;
314 /* jump to specific primitive depending on configured selector */
315 (*kwUiKwuDatIndMt[pst->selector])(pst, datInd, mBuf);
319 } /* end of rlcSendUlDataToDu */
321 int rlcDatCfmsSent = 0;
328 * Handler for sending the data confirmation to upper layer.
332 * This function is used to send a confirmation to the service
333 * user about the data received by the peer RLC entity.
335 * @param[in] pst Post structure
336 * @param[in] suId Service User SAP ID
337 * @param[in] datCfmInfo Data Confirmation Information
348 KwuDatCfmInfo *datCfm
351 S16 RlcUiKwuDatCfm(pst, suId, datCfm)
354 KwuDatCfmInfo *datCfm;
359 /* jump to specific primitive depending on configured selector */
360 (*kwUiKwuDatCfmMt[pst->selector])(pst, suId, datCfm);
364 } /* end of RlcUiKwuDatCfm */
371 * Handler for sending the Status Indication to the upper layer.
375 * This function is used only by RLC AM entity.It send status
376 * indication to the upper layer about the maximum number of
377 * re-transmissions reached for a RLC AM entity.
379 * @param[in] pst Post structure
380 * @param[in] suId Service User SAP ID
381 * @param[in] staInd RLC Entity Id
392 KwuStaIndInfo *staInd
395 S16 RlcUiKwuStaInd(pst, suId, staInd)
398 KwuStaIndInfo *staInd;
402 /* jump to specific primitive depending on configured selector */
403 (*kwUiKwuStaIndMt[pst->selector])(pst, suId, staInd);
407 } /* end of RlcUiKwuStaInd */
414 * Handler for sending the Status Indication to the upper layer.
418 * This function is used only by RLC AM entity.It send status
419 * indication to the upper layer about the maximum number of
420 * re-transmissions reached for a RLC AM entity.
422 * @param[in] pst Post structure
423 * @param[in] suId Service User SAP ID
424 * @param[in] staInd RLC Entity Id
431 S16 RlcUiKwuReEstCmpInd
438 S16 RlcUiKwuReEstCmpInd(pst, suId, rlcId)
444 RLOG0(L_DEBUG, "In RlcUiKwuReEstCmpInd");
446 /* jump to specific primitive depending on configured selector */
447 (*kwUiKwuReEstCmpIndMt[pst->selector])(pst, suId, rlcId);
451 } /* end of RlcUiKwuReEstCmpInd */
452 /* kw005.201 added support for L2 Measurement */
458 * Handler for sending the Sdu Disc Cfm to the upper layer.
462 * This function confirms the discard of an SDU .
464 * @param[in] pst Post structure
465 * @param[in] suId Service User SAP ID
466 * @param[in] discCfm Disc information.
473 S16 RlcUiKwuDiscSduCfm
477 KwuDiscSduInfo *discCfm
480 S16 RlcUiKwuDiscSduCfm(pst, suId, discCfm)
483 KwuDiscSduInfo *discCfm;
487 /* jump to specific primitive depending on configured selector */
488 (*kwUiKwuDiscSduCfmMt[pst->selector])(pst, suId, discCfm);
492 } /* end of RlcUiKwuDiscSduCfm */
498 * Handler for sending Flow indication to the upper layer.
502 * This function indicates to PDCP if packets need to be stopped or
503 * started for a particular RB
505 * @param[in] pst Post structure
506 * @param[in] suId Service User SAP ID
507 * @param[in] flowCntrlIndInfo Flow control information.
514 S16 RlcUiKwuFlowCntrlInd
518 KwuFlowCntrlIndInfo *flowCntrlIndInfo
521 S16 RlcUiKwuFlowCntrlInd(pst, suId, flowCntrlIndInfo)
524 KwuFlowCntrlIndInfo *flowCntrlIndInfo;
528 /* jump to specific primitive depending on configured selector */
529 (*kwUiKwuFlowCntrlIndMt[pst->selector])(pst, suId, flowCntrlIndInfo);
533 } /* end of RlcUiKwuFlowCntrlInd */
540 * Handler for sending the Data ack indication to the upper layer.
544 * This function confirms the succesfull transmission of SDU
546 * @param[in] pst Post structure
547 * @param[in] suId Service User SAP ID
548 * @param[in] datAckInd DatAckInd
555 S16 RlcUiKwuDatAckInd
559 KwuDatAckInfo *datAckInd
562 S16 RlcUiKwuDatAckInd(pst, suId, datAckInd)
565 KwuDatAckInfo *datAckInd;
569 /* jump to specific primitive depending on configured selector */
570 (*kwUiKwuDatAckIndMt[pst->selector])(pst, suId, datAckInd);
574 } /* end of RlcUiKwuDatAckInd */
575 #endif /* LTE_L2_MEAS */
580 /*********************************************************************
581 * Primitives for CKW interface
582 ********************************************************************/
584 /* CKW Bind Confirm primitive */
586 CkwBndCfm kwUiCkwBndCfmMt[] =
589 cmPkCkwBndCfm, /* 0 - loosely coupled */
590 #endif /* LCCKUICKW */
592 NhLiCkwBndCfm, /* 1 - tightly coupled, RRC */
596 /* CKW Configuration confirm primitive */
598 RlcCfgCfm kwUiRlcCfgCfmMt[] =
601 cmPkRlcCfgCfm, /* 0 - loosely coupled */
602 #endif /* LCKWUICKW */
604 NhLiRlcCfgCfm, /* 1 - tightly coupled, RRC */
608 CkwUeIdChgCfm kwUiCkwUeIdChgCfmMt[] =
611 cmPkCkwUeIdChgCfm, /* 0 - loosely coupled */
612 #endif /* LCKWUICKW */
614 NhLiCkwUeIdChgCfm, /* 1 - tightly coupled, RRC */
620 /****************************************************************************
621 * CKW Interface Mt functions
622 ***************************************************************************/
627 * Handler for confirming the bind request received from CKW
632 * This function send the bind confirm primitive to the RLC user,
633 * when it receives a bind request from its service user.
635 * @param[in] pst - Post structure
636 * @param[in] suId - Service user SAP ID
637 * @param[in] status - Status
645 Pst *pst, /* post structure */
646 SuId suId, /* Service User Id */
647 U8 status /* Status */
650 S16 RlcUiCkwBndCfm(pst, suId, status)
651 Pst *pst; /* post structure */
652 SuId suId; /* Service User Id */
653 U8 status; /* Status */
657 /* jump to specific primitive depending on configured selector */
658 (*kwUiCkwBndCfmMt[pst->selector])(pst, suId, status);
662 } /* end of RlcUiCkwBndCfm */
669 * Handler for sending a configuration confirm to RRC.
673 * This function is used by RLC user to send a configuration
674 * confirmation to RRC after configuring(add/delete/modify)
677 * @param[in] pst Post structure
678 * @param[in] transId Transaction Id
679 * @param[in] cfmInfo Config Confirmation Info
688 Pst *pst, /* post structure */
689 SuId suId, /* Service User Id */
690 RlcCfgCfmInfo *cfmInfo /* Configuration Confirm */
693 S16 RlcUiRlcCfgCfm(pst, suId, cfmInfo)
694 Pst *pst; /* post structure */
695 SuId suId; /* Service User Id */
696 RlcCfgCfmInfo *cfmInfo; /* Configuration Confirm */
700 /* jump to specific primitive depending on configured selector */
701 (*kwUiRlcCfgCfmMt[pst->selector])(pst, suId, cfmInfo);
705 } /* end of RlcUiRlcCfgCfm */
712 * Handler for sending a configuration for UE ID change.
716 * This function is used by RLC to send a configuration
717 * confirm for UE ID change.
719 * @param[in] pst Post structure
720 * @param[in] suId Service User Id
721 * @param[in] transId Transaction Id
722 * @param[in] cfmInfo Config Confirmation Info
729 S16 RlcUiCkwUeIdChgCfm
731 Pst *pst, /* post structure */
732 SuId suId, /* Service User Id */
738 S16 RlcUiCkwUeIdChgCfm(pst, suId, transId,ueInfo,status)
739 Pst *pst; /* post structure */
740 SuId suId; /* Service User Id */
747 /* jump to specific primitive depending on configured selector */
748 (*kwUiCkwUeIdChgCfmMt[pst->selector])(pst, suId, transId, ueInfo, status);
752 } /* end of RlcUiRlcCfgCfm */
755 #if (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF))
760 * rlcDlBatchProcSplit- process rbug messages
766 S16 rlcDlBatchProcSplit
771 S16 rlcDlBatchProcSplit()
776 /* Read from Ring Buffer and process PDCP packets */
777 Void *elmIndx = NULLP;
778 RxmBufReq *datReq = NULLP;
782 U8 rngBufDeqIndx = 0;
786 rngBufDeqMaxCnt = SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT;
787 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
788 rngBufCurrCnt = SGetNumElemInRng(SS_RNG_BUF_RX_TO_DLRLC);
789 if ( rngBufCurrCnt > (3 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT))
791 if ( rngBufCurrCnt > (6 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT))
793 /* Restablishment scenario */
794 rngBufDeqMaxCnt = (4 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT);
798 rngBufDeqMaxCnt = (3 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT)/2;
802 elmIndx = SRngGetRIndx(SS_RNG_BUF_RX_TO_DLRLC);
803 while(NULLP != elmIndx)
805 datReq = (RxmBufReq *)elmIndx;
806 if(datReq->mBuf != NULLP)
808 cmUnpkKwuDatReq(rlcProcDlData, &datReq->pst, datReq->mBuf);
812 RLOG0(L_ERROR, "mBuf is NULL");
814 cmUnpkKwuDatReq(rlcProcDlData, &datReq->pst, datReq->mBuf);
817 SsRngInfoTbl[SS_RNG_BUF_RX_TO_DLRLC].nPktProc++;//Number of pkt processed in tti
818 datReq->mBuf = NULLP;
819 SRngIncrRIndx(SS_RNG_BUF_RX_TO_DLRLC);
821 if(rngBufDeqIndx >= rngBufDeqMaxCnt)
834 if((elmIndx = SRngGetRIndx(SS_RNG_BUF_RX_TO_DLRLC)) == NULLP)
844 #if defined(PDCP_RLC_DL_RBUF) || defined(SS_RBUF)
855 /* Read from Ring Buffer and process PDCP packets */
857 U8 rngBufDeqIndx = 0;
859 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
862 /* Memory regions different for BRCM and Intel */
863 /*dstProcId,srcProcId,dstEnt,dstInst,srcEnt,srcInst,prior,route,event,region,pool,selector*/
865 PRIVATE Pst rlcDlRbfuPst ={1,1,ENTRLC,1,ENTPJ,1,PRIOR0,RTESPEC,KWU_EVT_DAT_REQ,1,1,0,0};
867 PRIVATE Pst rlcDlRbfuPst ={1,1,ENTRLC,1,ENTPJ,1,PRIOR0,RTESPEC,KWU_EVT_DAT_REQ,2,1,0,0};
869 Void *elmIndx = NULLP;
870 KwuDatReqDetl *kwuDatReqDetl = NULLP;
871 KwuDatReqInfo datReq;
873 rngBufDeqMaxCnt = SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT;
874 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
875 rngBufCurrCnt = SGetNumElemInRng(SS_RNG_BUF_DLPDCP_TO_DLRLC);
876 if ( rngBufCurrCnt > (3 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT))
878 if ( rngBufCurrCnt > (5 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT))
880 /* Restablishment scenario */
881 rngBufDeqMaxCnt = (4 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT);
885 rngBufDeqMaxCnt = (2 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT);
889 elmIndx = SRngGetRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
890 while(NULLP != elmIndx)
892 kwuDatReqDetl = (KwuDatReqDetl *)elmIndx;
893 datReq.rlcId = kwuDatReqDetl->rlcId;
894 datReq.sduId = kwuDatReqDetl->sduId;
895 datReq.lcType = kwuDatReqDetl->lcType;
896 SsRngInfoTbl[SS_RNG_BUF_DLPDCP_TO_DLRLC].nPktProc++;;//Number of pkt processed in tti
897 if(kwuDatReqDetl->mBuf != NULLP)
899 rlcProcDlData(&rlcDlRbfuPst, kwuDatReqDetl->spId, &datReq, kwuDatReqDetl->mBuf);
901 SRngIncrRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
904 if(rngBufDeqIndx >= rngBufDeqMaxCnt)
908 elmIndx = (Void *)SRngGetRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
916 S16 rlcUtlDlBatchProcPkts
921 S16 rlcUtlDlBatchProcPkts
928 rlcUtlDlBatchProcHqStaInd();
937 S16 rlcUtlDlFreeRlcRBuf
942 S16 rlcUtlDlFreeRlcRBuf
946 /* Read from Ring Buffer and process PDCP packets */
947 Void *elmIndx = NULLP;
948 KwuDatReqDetl *kwuDatReqDetl = NULLP;
949 /* Free SS_RNG_BUF_DLPDCP_TO_DLRLC */
950 elmIndx = SRngGetRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
951 while(NULLP != elmIndx)
953 kwuDatReqDetl = (KwuDatReqDetl *)elmIndx;
954 SRngIncrRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
955 SsRngInfoTbl[SS_RNG_BUF_DLPDCP_TO_DLRLC].nPktProc++;
956 SPutMsg(kwuDatReqDetl->mBuf);
958 kwuDatReqDetl = NULLP;
959 if((elmIndx = SRngGetRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC)) == NULLP)
969 #endif /* __cplusplus */
970 /********************************************************************30**
972 **********************************************************************/