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 - Lower Interface
25 Desc: C source code for the lower interface of LTE-RLC
29 *********************************************************************21*/
32 @brief RLC Lower 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 */
43 #include "cpj.h" /* CPJ defines */
44 #include "pju.h" /* PJU defines */
45 #include "lpj.h" /* LPJ defines */
48 #include "kw_env.h" /* RLC environment options */
49 #include "kw.h" /* RLC defines */
51 /* extern (.x) include files */
52 #include "lkw.x" /* LKW */
53 #include "ckw.x" /* CKW */
54 #include "kwu.x" /* KWU */
55 #include "rgu.x" /* RGU */
57 #include "cpj.x" /* CPJ defines */
58 #include "pju.x" /* PJU defines */
59 #include "lpj.x" /* LPJ defines */
75 #endif /* __cplusplus */
79 #ifdef RLC_MAC_DAT_REQ_RBUF
80 S16 rlcLiRguDatReqRbuf(Pst *Post,SpId spId,Void *datReq);
83 #ifdef RLC_MAC_STA_RSP_RBUF
84 S16 rlcLiRguStaRspRbuf(Pst *Post,SpId spId,Void *staRsp);
86 #if defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS)
87 EXTERN S16 RlcDlHarqStaBatchProc (Void);
91 /*********************************************************************
92 * Primitives for RGU interface
93 ********************************************************************/
95 /* RGU Bind Request primitive */
97 RguBndReq kwLiRguBndReqMt[] =
100 cmPkRguBndReq, /* 0 - loosely coupled */
101 #endif /* LCRGUIRGU */
103 RgUiRguBndReq, /* 1 - tightly coupled, MAC */
106 cmPkRguBndReq, /* 0 - loosely coupled */
107 #endif /* LCRGUIRGU */
110 /* RGU Unbind Request primitive */
112 RguBndReq kwLiRguUbndReqMt[] =
115 cmPkRguUbndReq, /* 0 - loosely coupled */
116 #endif /* LCRGUIRGU */
118 RgUiRguUbndReq, /* 1 - tightly coupled, MAC */
121 cmPkRguUbndReq, /* 0 - loosely coupled */
122 #endif /* LCRGUIRGU */
125 /* kw005.201 added support for L2 Measurement */
128 /* RGU L2 Measurement Ul Ip Throughput Measurement Request primitive */
130 RguL2MUlThrpMeasReq kwLiRguL2MUlThrpMeasReqMt[] =
133 cmPkRguL2MUlThrpMeasReq, /* 0 - loosely coupled */
134 #endif /* LCRGUIRGU */
136 RgUiRguL2MUlThrpMeasReq, /* 1 - tightly coupled, MAC */
139 #endif /* LTE_RLC_R9 */
140 #endif /* LTE_L2_MEAS */
142 /****************************************************************************
143 * RGU Interface Mt functions
144 ***************************************************************************/
149 * Handler for RGU SAP bind Request.
153 * This function is used by RLC to request for binding to
154 * MAC for accessing MAC services.This function binds MAC's
155 * SAP (identified by spId) with the service user's SAP
156 * (identified by suId).
158 * @param[in] pst Post structure
159 * @param[in] suId Service user SAP ID
160 * @param[in] spId Service provider ID
169 Pst *post, /* post structure */
170 SuId suId, /* Service User Id */
171 SpId spId /* Service Provider Id */
174 S16 RlcLiRguBndReq(post, suId, spId)
175 Pst *post; /* post structure */
176 SuId suId; /* Service User Id */
177 SpId spId; /* Service Provider Id */
182 /* jump to specific primitive depending on configured selector */
183 (*kwLiRguBndReqMt[post->selector])(post, suId, spId);
187 } /* end of RlcLiRguBndReq */
194 * Handler for bind confirmation from MAC.
198 * This function handles the bind confirmation received
201 * @param[in] post - Post structure
202 * @param[in] suId - Service provider SAP ID
203 * @param[in] reason - Reason of confirmation
217 S16 RlcLiRguUbndReq(post, spId, reason)
223 TRC3(RlcLiRguUbndReq)
225 /* jump to specific primitive depending on configured selector */
226 (*kwLiRguUbndReqMt[post->selector])(post, spId, reason);
230 } /* end of RlcLiRguUbndReq */
232 /* kw005.201 added support for L2 Measurement */
240 * Handler for sending ulThrpMeasReqInfo from RLC to MAC for UL ip throughput measurement.
244 * This function sends ulThrpMeasReqInfo from RLC to MAC whenver UL ip throughput
245 * measurement is ON for a single or multiple qci in a UE. This is an indication for MAC
246 * to start the T2/T1 time stamps for the coresponding LCHs in the UE.
248 * @param[in] post Post structure
249 * @param[in] spId Service Provider ID
250 * @param[in] ulThrpMeasReqInfo Ul ip measurement request info
258 S16 RlcLiRguL2MUlThrpMeasReq
262 RguL2MUlThrpMeasReqInfo *l2mUlThrpMeasReq
265 S16 RlcLiRguL2MUlThrpMeasReq(post, spId, l2mUlThrpMeasReq)
268 RguL2MUlThrpMeasReqInfo *l2mUlThrpMeasReq;
271 TRC3(RlcLiRguL2MUlThrpMeasReq)
273 /* jump to specific primitive depending on configured selector */
274 (*kwLiRguL2MUlThrpMeasReqMt[post->selector])(post, spId, l2mUlThrpMeasReq);
278 } /* end of RlcLiRguL2MUlThrpMeasReq */
280 #endif /* LTE_RLC_R9 */
281 #endif /* LTE_L2_MEAS */
284 #ifdef MAC_RLC_UL_RBUF
285 S16 rlcUlBatchProc ARGS ((Void));
286 EXTERN Void rlcUtlFreeUlRBuf ARGS((void));
298 /* Read from Ring Buffer and process PDCP packets */
299 RguDDatIndInfo *datInd;
300 Void *elmIndx = NULLP;
301 PRIVATE Pst rlcUlRbfuPst={1,1,ENTRLC,0,ENTMAC,0,PRIOR0,RTESPEC,EVTRLCULDAT,0,0,0,0};
302 /* Read from Ring Buffer and process PDCP packets */
305 RguDedDatInd1 *rguDatInd = NULLP;
306 U8 rngBufDeqIndx = 0;
308 elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
309 while(NULLP != elmIndx)
311 rguDatInd = (RguDedDatInd1 *)elmIndx;
312 datInd = (RguDDatIndInfo*) rguDatInd->msg;
313 SsRngInfoTbl[SS_RNG_BUF_ULMAC_TO_ULRLC].nPktProc++;;//Number of pkt processed in tti
316 RlcProcDedLcUlData(&rlcUlRbfuPst, 0, datInd);
320 RLOG0(L_ERROR,"Received NULL buffer");
322 rguDatInd->msg=NULLP;
323 SRngIncrRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
329 //if(rngBufDeqIndx >= SS_RNG_MAX_ULMAC_TO_ULRLC_DQ_CNT)
332 if((elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC)) == NULLP)
336 elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
337 while(NULLP != elmIndx)
339 datInd = (RguDDatIndInfo *)elmIndx;
340 RlcProcDedLcUlData(&rlcUlRbfuPst, 0, datInd);
344 SRngIncrRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
346 if((elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC)) == NULLP)
357 * Handler to clear Ring buffer from UL RLC
360 * This function clears all the ring buffer content from UL RLC
368 Void rlcUtlFreeUlRBuf(void)
370 Void rlcUtlFreeUlRBuf()
373 RguDDatIndInfo *datInd;
378 TRC2(rlcUtlFreeUlRBuf)
379 /* Free SS_RNG_BUF_ULMAC_TO_ULRLC */
380 while((SDeqSRngBuf (SS_RNG_BUF_ULMAC_TO_ULRLC, &elem) == ROK))
382 datInd = (RguDDatIndInfo *)elem;
383 for(numLch = 0; numLch< datInd->numLch; numLch++)
385 for(numPdu = 0; numPdu < datInd->lchData[numLch].pdu.numPdu; numPdu++)
387 if(datInd->lchData[numLch].pdu.mBuf[numPdu])
389 RLC_FREE_BUF_WC(datInd->lchData[numLch].pdu.mBuf[numPdu]);
393 RLC_PST_FREE(0, 0, datInd, sizeof(RguDDatIndInfo));
397 #ifdef RLC_MAC_STA_RSP_RBUF
399 S16 rlcLiRguStaRspRbuf
406 S16 rlcLiRguStaRspRbuf(post, spId, staRsp)
416 RguDStaRspInfo *staRspInfo = NULL;
417 elem = SRngGetWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC);
420 staRspInfo = (RguDStaRspInfo *)elem;
421 cmMemcpy((U8 *)staRspInfo, (U8 *)staRsp, sizeof(RguDStaRspInfo));
422 staRspInfo->post = *post;
423 SRngIncrWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC);
424 SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC].pktRate++;
428 RLOG0(L_ERROR,"RLC DL STA RSP RBUF is FULL!!! ");
429 SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC].pktDrop++;
433 } /* cmPkKwuDatReq */
436 #ifdef RLC_MAC_DAT_REQ_RBUF
438 S16 rlcLiRguDatReqRbuf
445 S16 rlcLiRguDatReqRbuf(post, spId, datReq)
454 RguInfoRingElem *datReqRing=NULLP;
455 elem = SRngGetWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ);
458 datReqRing = (RguInfoRingElem *) elem;
459 datReqRing->spId = spId;
460 datReqRing->event = post->event;
461 datReqRing->msg =datReq;
462 SRngIncrWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ);
463 SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ].pktRate++;
467 printf("RLC DL DAT REQ RBUF is FULL!!! \n");
468 SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ].pktDrop++;
472 } /* cmPkKwuDatReq */
478 #endif /* __cplusplus */
480 /********************************************************************30**
482 **********************************************************************/