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 void rlcUtlDlBatchProcHqStaInd ARGS ((Void));
77 Void rlcUtlFreeDlMem ARGS((Void));
79 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
258 Pst *pst, /* post structure */
259 SuId suId, /* Service User Id */
260 uint8_t status /* Status */
264 /* jump to specific primitive depending on configured selector */
265 (*kwUiKwuBndCfmMt[pst->selector])(pst, suId, status);
269 } /* end of RlcUiKwuBndCfm */
276 * Handler for sending the data(SDU) from upper layer.
280 * This function is used to transfer a SDU received from the peer
281 * RLC entity to the service user(RRC/PDCP).
283 * @param[in] pst Post structure
284 * @param[in] suId Service User SAP ID
285 * @param[in] datIndInfo Data Request Information
286 * @param[in] mBuf Data Buffer (SDU)
292 S16 rlcSendUlDataToDu
295 KwuDatIndInfo *datInd,
300 /* jump to specific primitive depending on configured selector */
301 (*kwUiKwuDatIndMt[pst->selector])(pst, datInd, mBuf);
305 } /* end of rlcSendUlDataToDu */
307 int rlcDatCfmsSent = 0;
314 * Handler for sending the data confirmation to upper layer.
318 * This function is used to send a confirmation to the service
319 * user about the data received by the peer RLC entity.
321 * @param[in] pst Post structure
322 * @param[in] suId Service User SAP ID
323 * @param[in] datCfmInfo Data Confirmation Information
333 KwuDatCfmInfo *datCfm
338 /* jump to specific primitive depending on configured selector */
339 (*kwUiKwuDatCfmMt[pst->selector])(pst, suId, datCfm);
343 } /* end of RlcUiKwuDatCfm */
350 * Handler for sending the Status Indication to the upper layer.
354 * This function is used only by RLC AM entity.It send status
355 * indication to the upper layer about the maximum number of
356 * re-transmissions reached for a RLC AM entity.
358 * @param[in] pst Post structure
359 * @param[in] suId Service User SAP ID
360 * @param[in] staInd RLC Entity Id
370 KwuStaIndInfo *staInd
374 /* jump to specific primitive depending on configured selector */
375 (*kwUiKwuStaIndMt[pst->selector])(pst, suId, staInd);
379 } /* end of RlcUiKwuStaInd */
386 * Handler for sending the Status Indication to the upper layer.
390 * This function is used only by RLC AM entity.It send status
391 * indication to the upper layer about the maximum number of
392 * re-transmissions reached for a RLC AM entity.
394 * @param[in] pst Post structure
395 * @param[in] suId Service User SAP ID
396 * @param[in] staInd RLC Entity Id
402 S16 RlcUiKwuReEstCmpInd
409 RLOG0(L_DEBUG, "In RlcUiKwuReEstCmpInd");
411 /* jump to specific primitive depending on configured selector */
412 (*kwUiKwuReEstCmpIndMt[pst->selector])(pst, suId, rlcId);
416 } /* end of RlcUiKwuReEstCmpInd */
417 /* kw005.201 added support for L2 Measurement */
423 * Handler for sending the Sdu Disc Cfm to the upper layer.
427 * This function confirms the discard of an SDU .
429 * @param[in] pst Post structure
430 * @param[in] suId Service User SAP ID
431 * @param[in] discCfm Disc information.
437 S16 RlcUiKwuDiscSduCfm
441 KwuDiscSduInfo *discCfm
445 /* jump to specific primitive depending on configured selector */
446 (*kwUiKwuDiscSduCfmMt[pst->selector])(pst, suId, discCfm);
450 } /* end of RlcUiKwuDiscSduCfm */
456 * Handler for sending Flow indication to the upper layer.
460 * This function indicates to PDCP if packets need to be stopped or
461 * started for a particular RB
463 * @param[in] pst Post structure
464 * @param[in] suId Service User SAP ID
465 * @param[in] flowCntrlIndInfo Flow control information.
471 S16 RlcUiKwuFlowCntrlInd(Pst *pst,SuId suId,KwuFlowCntrlIndInfo *flowCntrlIndInfo)
474 /* jump to specific primitive depending on configured selector */
475 (*kwUiKwuFlowCntrlIndMt[pst->selector])(pst, suId, flowCntrlIndInfo);
479 } /* end of RlcUiKwuFlowCntrlInd */
486 * Handler for sending the Data ack indication to the upper layer.
490 * This function confirms the succesfull transmission of SDU
492 * @param[in] pst Post structure
493 * @param[in] suId Service User SAP ID
494 * @param[in] datAckInd DatAckInd
500 S16 RlcUiKwuDatAckInd(Pst *pst,SuId suId,KwuDatAckInfo *datAckInd)
503 /* jump to specific primitive depending on configured selector */
504 (*kwUiKwuDatAckIndMt[pst->selector])(pst, suId, datAckInd);
508 } /* end of RlcUiKwuDatAckInd */
509 #endif /* LTE_L2_MEAS */
514 /*********************************************************************
515 * Primitives for CKW interface
516 ********************************************************************/
518 /* CKW Bind Confirm primitive */
520 CkwBndCfm kwUiCkwBndCfmMt[] =
523 cmPkCkwBndCfm, /* 0 - loosely coupled */
524 #endif /* LCCKUICKW */
526 NhLiCkwBndCfm, /* 1 - tightly coupled, RRC */
530 /* CKW Configuration confirm primitive */
532 RlcCfgCfm kwUiRlcCfgCfmMt[] =
535 cmPkRlcCfgCfm, /* 0 - loosely coupled */
536 #endif /* LCKWUICKW */
538 NhLiRlcCfgCfm, /* 1 - tightly coupled, RRC */
542 CkwUeIdChgCfm kwUiCkwUeIdChgCfmMt[] =
545 cmPkCkwUeIdChgCfm, /* 0 - loosely coupled */
546 #endif /* LCKWUICKW */
548 NhLiCkwUeIdChgCfm, /* 1 - tightly coupled, RRC */
554 /****************************************************************************
555 * CKW Interface Mt functions
556 ***************************************************************************/
561 * Handler for confirming the bind request received from CKW
566 * This function send the bind confirm primitive to the RLC user,
567 * when it receives a bind request from its service user.
569 * @param[in] pst - Post structure
570 * @param[in] suId - Service user SAP ID
571 * @param[in] status - Status
578 Pst *pst, /* post structure */
579 SuId suId, /* Service User Id */
580 uint8_t status /* Status */
584 /* jump to specific primitive depending on configured selector */
585 (*kwUiCkwBndCfmMt[pst->selector])(pst, suId, status);
589 } /* end of RlcUiCkwBndCfm */
596 * Handler for sending a configuration confirm to RRC.
600 * This function is used by RLC user to send a configuration
601 * confirmation to RRC after configuring(add/delete/modify)
604 * @param[in] pst Post structure
605 * @param[in] transId Transaction Id
606 * @param[in] cfmInfo Config Confirmation Info
614 Pst *pst, /* post structure */
615 SuId suId, /* Service User Id */
616 RlcCfgCfmInfo *cfmInfo /* Configuration Confirm */
620 /* jump to specific primitive depending on configured selector */
621 (*kwUiRlcCfgCfmMt[pst->selector])(pst, suId, cfmInfo);
625 } /* end of RlcUiRlcCfgCfm */
632 * Handler for sending a configuration for UE ID change.
636 * This function is used by RLC to send a configuration
637 * confirm for UE ID change.
639 * @param[in] pst Post structure
640 * @param[in] suId Service User Id
641 * @param[in] transId Transaction Id
642 * @param[in] cfmInfo Config Confirmation Info
648 S16 RlcUiCkwUeIdChgCfm
650 Pst *pst, /* post structure */
651 SuId suId, /* Service User Id */
658 /* jump to specific primitive depending on configured selector */
659 (*kwUiCkwUeIdChgCfmMt[pst->selector])(pst, suId, transId, ueInfo, status);
663 } /* end of RlcUiRlcCfgCfm */
666 #if (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF))
671 * rlcDlBatchProcSplit- process rbug messages
676 S16 rlcDlBatchProcSplit(Void)
679 /* Read from Ring Buffer and process PDCP packets */
680 Void *elmIndx = NULLP;
681 RxmBufReq *datReq = NULLP;
683 uint32_t dlPktCount = 0;
685 uint8_t rngBufDeqIndx = 0;
686 uint32_t rngBufDeqMaxCnt;
687 uint32_t rngBufCurrCnt;
689 rngBufDeqMaxCnt = SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT;
690 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
691 rngBufCurrCnt = SGetNumElemInRng(SS_RNG_BUF_RX_TO_DLRLC);
692 if ( rngBufCurrCnt > (3 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT))
694 if ( rngBufCurrCnt > (6 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT))
696 /* Restablishment scenario */
697 rngBufDeqMaxCnt = (4 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT);
701 rngBufDeqMaxCnt = (3 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT)/2;
705 elmIndx = SRngGetRIndx(SS_RNG_BUF_RX_TO_DLRLC);
706 while(NULLP != elmIndx)
708 datReq = (RxmBufReq *)elmIndx;
709 if(datReq->mBuf != NULLP)
711 cmUnpkKwuDatReq(rlcProcDlData, &datReq->pst, datReq->mBuf);
715 RLOG0(L_ERROR, "mBuf is NULL");
717 cmUnpkKwuDatReq(rlcProcDlData, &datReq->pst, datReq->mBuf);
720 SsRngInfoTbl[SS_RNG_BUF_RX_TO_DLRLC].nPktProc++;//Number of pkt processed in tti
721 datReq->mBuf = NULLP;
722 SRngIncrRIndx(SS_RNG_BUF_RX_TO_DLRLC);
724 if(rngBufDeqIndx >= rngBufDeqMaxCnt)
737 if((elmIndx = SRngGetRIndx(SS_RNG_BUF_RX_TO_DLRLC)) == NULLP)
747 #if defined(PDCP_RLC_DL_RBUF) || defined(SS_RBUF)
748 S16 rlcDlBatchProc(Void)
750 /* Read from Ring Buffer and process PDCP packets */
752 uint8_t rngBufDeqIndx = 0;
753 uint32_t rngBufDeqMaxCnt;
754 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
755 uint32_t rngBufCurrCnt;
757 /* Memory regions different for BRCM and Intel */
758 /*dstProcId,srcProcId,dstEnt,dstInst,srcEnt,srcInst,prior,route,event,region,pool,selector*/
760 static Pst rlcDlRbfuPst ={1,1,ENTRLC,1,ENTPJ,1,PRIOR0,RTESPEC,KWU_EVT_DAT_REQ,1,1,0,0};
762 static Pst rlcDlRbfuPst ={1,1,ENTRLC,1,ENTPJ,1,PRIOR0,RTESPEC,KWU_EVT_DAT_REQ,2,1,0,0};
764 Void *elmIndx = NULLP;
765 KwuDatReqDetl *kwuDatReqDetl = NULLP;
766 KwuDatReqInfo datReq;
768 rngBufDeqMaxCnt = SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT;
769 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
770 rngBufCurrCnt = SGetNumElemInRng(SS_RNG_BUF_DLPDCP_TO_DLRLC);
771 if ( rngBufCurrCnt > (3 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT))
773 if ( rngBufCurrCnt > (5 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT))
775 /* Restablishment scenario */
776 rngBufDeqMaxCnt = (4 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT);
780 rngBufDeqMaxCnt = (2 * SS_RNG_MAX_DLPDCP_TO_DLRLC_DQ_CNT);
784 elmIndx = SRngGetRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
785 while(NULLP != elmIndx)
787 kwuDatReqDetl = (KwuDatReqDetl *)elmIndx;
788 datReq.rlcId = kwuDatReqDetl->rlcId;
789 datReq.sduId = kwuDatReqDetl->sduId;
790 datReq.lcType = kwuDatReqDetl->lcType;
791 SsRngInfoTbl[SS_RNG_BUF_DLPDCP_TO_DLRLC].nPktProc++;//Number of pkt processed in tti
792 if(kwuDatReqDetl->mBuf != NULLP)
794 rlcProcDlData(&rlcDlRbfuPst, kwuDatReqDetl->spId, &datReq, kwuDatReqDetl->mBuf);
796 SRngIncrRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
799 if(rngBufDeqIndx >= rngBufDeqMaxCnt)
803 elmIndx = (Void *)SRngGetRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
810 S16 rlcUtlDlBatchProcPkts(Void)
815 rlcUtlDlBatchProcHqStaInd();
823 S16 rlcUtlDlFreeRlcRBuf(Void)
825 /* Read from Ring Buffer and process PDCP packets */
826 Void *elmIndx = NULLP;
827 KwuDatReqDetl *kwuDatReqDetl = NULLP;
828 /* Free SS_RNG_BUF_DLPDCP_TO_DLRLC */
829 elmIndx = SRngGetRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
830 while(NULLP != elmIndx)
832 kwuDatReqDetl = (KwuDatReqDetl *)elmIndx;
833 SRngIncrRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
834 SsRngInfoTbl[SS_RNG_BUF_DLPDCP_TO_DLRLC].nPktProc++;
835 SPutMsg(kwuDatReqDetl->mBuf);
837 kwuDatReqDetl = NULLP;
838 if((elmIndx = SRngGetRIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC)) == NULLP)
848 #endif /* __cplusplus */
849 /********************************************************************30**
851 **********************************************************************/