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"
86 #endif /* __cplusplus */
89 /*********************************************************************
90 * Forward Declartion for KWU Porting Functions
91 ********************************************************************/
92 #if defined(PDCP_RLC_DL_RBUF) || defined(SS_RBUF)
93 PUBLIC S16 kwDlBatchProc ARGS ((Void));
94 PUBLIC S16 kwUtlDlFreeRlcRBuf ARGS((Void));
95 EXTERN void kwUtlDlBatchProcHqStaInd ARGS ((Void));
96 EXTERN Void kwUtlFreeDlMem ARGS((Void));
97 EXTERN SsRngBufCnt rngCb;
98 EXTERN S16 kwUtlDlBatchProcPkts ARGS((Void));
101 #if (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF))
102 PUBLIC S16 kwDlBatchProcSplit ARGS((Void));
106 /*********************************************************************
107 * Primitives for KWU interface
108 ********************************************************************/
110 /* KWU Bind Confirm primitive */
112 PUBLIC KwuBndCfm kwUiKwuBndCfmMt[] =
115 cmPkKwuBndCfm, /* 0 - loosely coupled */
116 #endif /* LCKWUIKWU */
118 NhLiKwuBndCfm, /* 1 - tightly coupled, RRC */
122 PjLiKwuBndCfm, /* 2 - tightly coupled, PDCP */
127 cmPkKwuBndCfm, /* 3 - light weight loosely coupled */
128 #endif /* LCKWUIKWU */
132 /* KWU Data Indication primitive */
134 PUBLIC KwuDatInd kwUiKwuDatIndMt[] =
137 cmPkKwuDatInd, /* 0 - loosely coupled */
138 #endif /* LCKWUIKWU */
140 NhLiKwuDatInd, /* 1 - tightly coupled, RRC */
145 PjLiKwuDatInd, /* 2 - tightly coupled, PDCP */
149 cmPkKwuDatInd, /* 3 - light weight loosely coupled */
150 #endif /* LCKWUIKWU */
156 PUBLIC KwuDatCfm kwUiKwuDatCfmMt[] =
159 cmPkKwuDatCfm, /* 0 - loosely coupled */
160 #endif /* LCKWUIKWU */
162 PjLiKwuDatCfm, /* 2 - tightly coupled, PDCP */
166 cmPkKwuDatCfm, /* 3 - light weight loosely coupled */
167 #endif /* LCKWUIKWU */
171 /* KWU AM Status Indication primitive */
173 PUBLIC KwuStaInd kwUiKwuStaIndMt[] =
176 cmPkKwuStaInd, /* 0 - loosely coupled */
177 #endif /* LCKWUIKWU */
179 PjLiKwuStaInd, /* 2 - tightly coupled, PDCP */
183 cmPkKwuStaInd, /* 3 - light weight loosely coupled */
184 #endif /* LCKWUIKWU */
188 PUBLIC KwuReEstCmpInd kwUiKwuReEstCmpIndMt[] =
191 cmPkKwuReEstCmpInd, /* 0 - loosely coupled */
192 #endif /* LCKWUIKWU */
194 PjLiKwuReEstCmpInd, /* 2 - tightly coupled, PDCP */
199 cmPkKwuReEstCmpInd, /* 3 - light weight loosely coupled */
200 #endif /* LCKWUIKWU */
204 /* kw005.201 added support for L2 measurement */
205 PUBLIC KwuDiscSduCfm kwUiKwuDiscSduCfmMt[] =
208 cmPkKwuDiscSduCfm, /* 0 - loosely coupled */
209 #endif /* LCKWUIKWU */
211 PjLiKwuDiscSduCfm, /* 2 - tightly coupled, PDCP */
215 cmPkKwuDiscSduCfm, /* 3 - light weight loosely coupled */
219 PUBLIC KwuFlowCntrlInd kwUiKwuFlowCntrlIndMt[] =
222 cmPkKwuFlowCntrlInd, /* 0 - loosely coupled */
223 #endif /* LCKWUIKWU */
225 PjLiKwuFlowCntrlInd, /* 2 - tightly coupled, PDCP */
228 cmPkKwuFlowCntrlInd, /* 3 - light weight loosely coupled */
229 #endif /* LCKWUIKWU */
232 PUBLIC KwuDatAckInd kwUiKwuDatAckIndMt[] =
235 cmPkKwuDatAckInd, /* 0 - loosely coupled */
236 #endif /* LCKWUIKWU */
238 PjLiKwuDatAckInd, /* 2 - tightly coupled, PDCP */
242 cmPkKwuDatAckInd, /* 3 - light weight loosely coupled, portable */
246 #endif /* LTE_L2_MEAS */
247 /* KWU AM Data confirm primitive */
252 /****************************************************************************
253 * KWU Interface Mt functions
254 ***************************************************************************/
\f
259 * Handler for confirming the bind request received from KWU
264 * This function send the bind confirm primitive to the RLC user,
265 * when it receives a bind request from its service user.
267 * @param[in] pst Post structure
268 * @param[in] suId Service user SAP ID
269 * @param[in] status Status of Confirmation
276 PUBLIC S16 KwUiKwuBndCfm
278 Pst *pst, /* post structure */
279 SuId suId, /* Service User Id */
280 U8 status /* Status */
283 PUBLIC S16 KwUiKwuBndCfm(pst, suId, status)
284 Pst *pst; /* post structure */
285 SuId suId; /* Service User Id */
286 U8 status; /* Status */
291 /* jump to specific primitive depending on configured selector */
292 (*kwUiKwuBndCfmMt[pst->selector])(pst, suId, status);
296 } /* end of KwUiKwuBndCfm */
303 * Handler for sending the data(SDU) from upper layer.
307 * This function is used to transfer a SDU received from the peer
308 * RLC entity to the service user(RRC/PDCP).
310 * @param[in] pst Post structure
311 * @param[in] suId Service User SAP ID
312 * @param[in] datIndInfo Data Request Information
313 * @param[in] mBuf Data Buffer (SDU)
320 PUBLIC S16 KwUiKwuDatInd
323 KwuDatIndInfo *datInd,
327 PUBLIC S16 KwUiKwuDatInd(pst, datInd, mBuf)
329 KwuDatIndInfo *datInd;
335 /* jump to specific primitive depending on configured selector */
336 (*kwUiKwuDatIndMt[pst->selector])(pst, datInd, mBuf);
340 } /* end of KwUiKwuDatInd */
342 PUBLIC int rlcDatCfmsSent = 0;
349 * Handler for sending the data confirmation to upper layer.
353 * This function is used to send a confirmation to the service
354 * user about the data received by the peer RLC entity.
356 * @param[in] pst Post structure
357 * @param[in] suId Service User SAP ID
358 * @param[in] datCfmInfo Data Confirmation Information
365 PUBLIC S16 KwUiKwuDatCfm
369 KwuDatCfmInfo *datCfm
372 PUBLIC S16 KwUiKwuDatCfm(pst, suId, datCfm)
375 KwuDatCfmInfo *datCfm;
381 /* jump to specific primitive depending on configured selector */
382 (*kwUiKwuDatCfmMt[pst->selector])(pst, suId, datCfm);
386 } /* end of KwUiKwuDatCfm */
393 * Handler for sending the Status Indication to the upper layer.
397 * This function is used only by RLC AM entity.It send status
398 * indication to the upper layer about the maximum number of
399 * re-transmissions reached for a RLC AM entity.
401 * @param[in] pst Post structure
402 * @param[in] suId Service User SAP ID
403 * @param[in] staInd RLC Entity Id
410 PUBLIC S16 KwUiKwuStaInd
414 KwuStaIndInfo *staInd
417 PUBLIC S16 KwUiKwuStaInd(pst, suId, staInd)
420 KwuStaIndInfo *staInd;
425 /* jump to specific primitive depending on configured selector */
426 (*kwUiKwuStaIndMt[pst->selector])(pst, suId, staInd);
430 } /* end of KwUiKwuStaInd */
437 * Handler for sending the Status Indication to the upper layer.
441 * This function is used only by RLC AM entity.It send status
442 * indication to the upper layer about the maximum number of
443 * re-transmissions reached for a RLC AM entity.
445 * @param[in] pst Post structure
446 * @param[in] suId Service User SAP ID
447 * @param[in] staInd RLC Entity Id
454 PUBLIC S16 KwUiKwuReEstCmpInd
461 PUBLIC S16 KwUiKwuReEstCmpInd(pst, suId, rlcId)
467 TRC3(KwUiKwuReEstCmpInd)
468 RLOG0(L_DEBUG, "In KwUiKwuReEstCmpInd");
470 /* jump to specific primitive depending on configured selector */
471 (*kwUiKwuReEstCmpIndMt[pst->selector])(pst, suId, rlcId);
475 } /* end of KwUiKwuReEstCmpInd */
476 /* kw005.201 added support for L2 Measurement */
482 * Handler for sending the Sdu Disc Cfm to the upper layer.
486 * This function confirms the discard of an SDU .
488 * @param[in] pst Post structure
489 * @param[in] suId Service User SAP ID
490 * @param[in] discCfm Disc information.
497 PUBLIC S16 KwUiKwuDiscSduCfm
501 KwuDiscSduInfo *discCfm
504 PUBLIC S16 KwUiKwuDiscSduCfm(pst, suId, discCfm)
507 KwuDiscSduInfo *discCfm;
510 TRC3(KwUiKwuDiscSduCfm)
512 /* jump to specific primitive depending on configured selector */
513 (*kwUiKwuDiscSduCfmMt[pst->selector])(pst, suId, discCfm);
517 } /* end of KwUiKwuDiscSduCfm */
523 * Handler for sending Flow indication to the upper layer.
527 * This function indicates to PDCP if packets need to be stopped or
528 * started for a particular RB
530 * @param[in] pst Post structure
531 * @param[in] suId Service User SAP ID
532 * @param[in] flowCntrlIndInfo Flow control information.
539 PUBLIC S16 KwUiKwuFlowCntrlInd
543 KwuFlowCntrlIndInfo *flowCntrlIndInfo
546 PUBLIC S16 KwUiKwuFlowCntrlInd(pst, suId, flowCntrlIndInfo)
549 KwuFlowCntrlIndInfo *flowCntrlIndInfo;
552 TRC3(KwUiKwuFlowCntrlInd)
554 /* jump to specific primitive depending on configured selector */
555 (*kwUiKwuFlowCntrlIndMt[pst->selector])(pst, suId, flowCntrlIndInfo);
559 } /* end of KwUiKwuFlowCntrlInd */
566 * Handler for sending the Data ack indication to the upper layer.
570 * This function confirms the succesfull transmission of SDU
572 * @param[in] pst Post structure
573 * @param[in] suId Service User SAP ID
574 * @param[in] datAckInd DatAckInd
581 PUBLIC S16 KwUiKwuDatAckInd
585 KwuDatAckInfo *datAckInd
588 PUBLIC S16 KwUiKwuDatAckInd(pst, suId, datAckInd)
591 KwuDatAckInfo *datAckInd;
594 TRC3(KwUiKwuDatAckInd)
596 /* jump to specific primitive depending on configured selector */
597 (*kwUiKwuDatAckIndMt[pst->selector])(pst, suId, datAckInd);
601 } /* end of KwUiKwuDatAckInd */
602 #endif /* LTE_L2_MEAS */
607 /*********************************************************************
608 * Primitives for CKW interface
609 ********************************************************************/
611 /* CKW Bind Confirm primitive */
613 PUBLIC CkwBndCfm kwUiCkwBndCfmMt[] =
616 cmPkCkwBndCfm, /* 0 - loosely coupled */
617 #endif /* LCCKUICKW */
619 NhLiCkwBndCfm, /* 1 - tightly coupled, RRC */
623 /* CKW Configuration confirm primitive */
625 PUBLIC CkwCfgCfm kwUiCkwCfgCfmMt[] =
628 cmPkCkwCfgCfm, /* 0 - loosely coupled */
629 #endif /* LCKWUICKW */
631 NhLiCkwCfgCfm, /* 1 - tightly coupled, RRC */
635 PUBLIC CkwUeIdChgCfm kwUiCkwUeIdChgCfmMt[] =
638 cmPkCkwUeIdChgCfm, /* 0 - loosely coupled */
639 #endif /* LCKWUICKW */
641 NhLiCkwUeIdChgCfm, /* 1 - tightly coupled, RRC */
647 /****************************************************************************
648 * CKW Interface Mt functions
649 ***************************************************************************/
654 * Handler for confirming the bind request received from CKW
659 * This function send the bind confirm primitive to the RLC user,
660 * when it receives a bind request from its service user.
662 * @param[in] pst - Post structure
663 * @param[in] suId - Service user SAP ID
664 * @param[in] status - Status
670 PUBLIC S16 KwUiCkwBndCfm
672 Pst *pst, /* post structure */
673 SuId suId, /* Service User Id */
674 U8 status /* Status */
677 PUBLIC S16 KwUiCkwBndCfm(pst, suId, status)
678 Pst *pst; /* post structure */
679 SuId suId; /* Service User Id */
680 U8 status; /* Status */
685 /* jump to specific primitive depending on configured selector */
686 (*kwUiCkwBndCfmMt[pst->selector])(pst, suId, status);
690 } /* end of KwUiCkwBndCfm */
697 * Handler for sending a configuration confirm to RRC.
701 * This function is used by RLC user to send a configuration
702 * confirmation to RRC after configuring(add/delete/modify)
705 * @param[in] pst Post structure
706 * @param[in] transId Transaction Id
707 * @param[in] cfmInfo Config Confirmation Info
714 PUBLIC S16 KwUiCkwCfgCfm
716 Pst *pst, /* post structure */
717 SuId suId, /* Service User Id */
718 CkwCfgCfmInfo *cfmInfo /* Configuration Confirm */
721 PUBLIC S16 KwUiCkwCfgCfm(pst, suId, cfmInfo)
722 Pst *pst; /* post structure */
723 SuId suId; /* Service User Id */
724 CkwCfgCfmInfo *cfmInfo; /* Configuration Confirm */
729 /* jump to specific primitive depending on configured selector */
730 (*kwUiCkwCfgCfmMt[pst->selector])(pst, suId, cfmInfo);
734 } /* end of KwUiCkwCfgCfm */
741 * Handler for sending a configuration for UE ID change.
745 * This function is used by RLC to send a configuration
746 * confirm for UE ID change.
748 * @param[in] pst Post structure
749 * @param[in] suId Service User Id
750 * @param[in] transId Transaction Id
751 * @param[in] cfmInfo Config Confirmation Info
758 PUBLIC S16 KwUiCkwUeIdChgCfm
760 Pst *pst, /* post structure */
761 SuId suId, /* Service User Id */
767 PUBLIC S16 KwUiCkwUeIdChgCfm(pst, suId, transId,ueInfo,status)
768 Pst *pst; /* post structure */
769 SuId suId; /* Service User Id */
775 TRC3(KwUiCkwUeIdChgCfm)
777 /* jump to specific primitive depending on configured selector */
778 (*kwUiCkwUeIdChgCfmMt[pst->selector])(pst, suId, transId, ueInfo, status);
782 } /* end of KwUiCkwCfgCfm */
785 #if (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF))
790 * kwDlBatchProcSplit- process rbug messages
796 PUBLIC S16 kwDlBatchProcSplit
801 PUBLIC S16 kwDlBatchProcSplit()
806 /* Read from Ring Buffer and process PDCP packets */
807 Void *elmIndx = NULLP;
808 RxmBufReq *datReq = NULLP;
812 U8 rngBufDeqIndx = 0;
816 rngBufDeqMaxCnt = SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT;
817 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
818 rngBufCurrCnt = SGetNumElemInRng(SS_RNG_BUF_RX_TO_DLRLC);
819 if ( rngBufCurrCnt > (3 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT))
821 if ( rngBufCurrCnt > (6 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT))
823 /* Restablishment scenario */
824 rngBufDeqMaxCnt = (4 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT);
828 rngBufDeqMaxCnt = (3 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT)/2;
832 elmIndx = SRngGetRIndx(SS_RNG_BUF_RX_TO_DLRLC);
833 while(NULLP != elmIndx)
835 datReq = (RxmBufReq *)elmIndx;
836 if(datReq->mBuf != NULLP)
838 cmUnpkKwuDatReq(KwUiKwuDatReq, &datReq->pst, datReq->mBuf);
842 RLOG0(L_ERROR, "mBuf is NULL");
844 cmUnpkKwuDatReq(KwUiKwuDatReq, &datReq->pst, datReq->mBuf);
847 SsRngInfoTbl[SS_RNG_BUF_RX_TO_DLRLC].nPktProc++;//Number of pkt processed in tti
848 datReq->mBuf = NULLP;
849 SRngIncrRIndx(SS_RNG_BUF_RX_TO_DLRLC);
851 if(rngBufDeqIndx >= rngBufDeqMaxCnt)
864 if((elmIndx = SRngGetRIndx(SS_RNG_BUF_RX_TO_DLRLC)) == NULLP)
874 #if defined(PDCP_RLC_DL_RBUF) || defined(SS_RBUF)
876 PUBLIC S16 kwDlBatchProc
881 PUBLIC S16 kwDlBatchProc()
885 /* Read from Ring Buffer and process PDCP packets */
887 U8 rngBufDeqIndx = 0;
889 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
892 /* Memory regions different for BRCM and Intel */
893 /*dstProcId,srcProcId,dstEnt,dstInst,srcEnt,srcInst,prior,route,event,region,pool,selector*/
895 PRIVATE Pst rlcDlRbfuPst ={1,1,ENTKW,1,ENTPJ,1,PRIOR0,RTESPEC,KWU_EVT_DAT_REQ,1,1,0,0};
897 PRIVATE Pst rlcDlRbfuPst ={1,1,ENTKW,1,ENTPJ,1,PRIOR0,RTESPEC,KWU_EVT_DAT_REQ,2,1,0,0};
899 Void *elmIndx = NULLP;
900 KwuDatReqDetl *kwuDatReqDetl = NULLP;
901 KwuDatReqInfo datReq;
903 rngBufDeqMaxCnt = SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT;
904 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
905 rngBufCurrCnt = SGetNumElemInRng(SS_RNG_BUF_DLPDCP_TO_DLRLC);
906 if ( rngBufCurrCnt > (3 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT))
908 if ( rngBufCurrCnt > (5 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT))
910 /* Restablishment scenario */
911 rngBufDeqMaxCnt = (4 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT);
915 rngBufDeqMaxCnt = (2 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT);
919 elmIndx = SRngGetRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
920 while(NULLP != elmIndx)
922 kwuDatReqDetl = (KwuDatReqDetl *)elmIndx;
923 datReq.rlcId = kwuDatReqDetl->rlcId;
924 datReq.sduId = kwuDatReqDetl->sduId;
925 datReq.lcType = kwuDatReqDetl->lcType;
926 SsRngInfoTbl[SS_RNG_BUF_DLPDCP_TO_DLRLC].nPktProc++;;//Number of pkt processed in tti
927 if(kwuDatReqDetl->mBuf != NULLP)
929 KwUiKwuDatReq(&rlcDlRbfuPst, kwuDatReqDetl->spId, &datReq, kwuDatReqDetl->mBuf);
931 SRngIncrRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
934 if(rngBufDeqIndx >= rngBufDeqMaxCnt)
938 elmIndx = (Void *)SRngGetRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
946 PUBLIC S16 kwUtlDlBatchProcPkts
951 PUBLIC S16 kwUtlDlBatchProcPkts
958 kwUtlDlBatchProcHqStaInd();
967 PUBLIC S16 kwUtlDlFreeRlcRBuf
972 PUBLIC S16 kwUtlDlFreeRlcRBuf
976 /* Read from Ring Buffer and process PDCP packets */
977 Void *elmIndx = NULLP;
978 KwuDatReqDetl *kwuDatReqDetl = NULLP;
979 /* Free SS_RNG_BUF_DLPDCP_TO_DLRLC */
980 elmIndx = SRngGetRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
981 while(NULLP != elmIndx)
983 kwuDatReqDetl = (KwuDatReqDetl *)elmIndx;
984 SRngIncrRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
985 SsRngInfoTbl[SS_RNG_BUF_DLPDCP_TO_DLRLC].nPktProc++;
986 SPutMsg(kwuDatReqDetl->mBuf);
988 kwuDatReqDetl = NULLP;
989 if((elmIndx = SRngGetRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC)) == NULLP)
999 #endif /* __cplusplus */
1000 /********************************************************************30**
1002 **********************************************************************/