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 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
168 Pst *post, /* post structure */
169 SuId suId, /* Service User Id */
170 SpId spId /* Service Provider Id */
174 /* jump to specific primitive depending on configured selector */
175 (*kwLiRguBndReqMt[post->selector])(post, suId, spId);
179 } /* end of RlcLiRguBndReq */
186 * Handler for bind confirmation from MAC.
190 * This function handles the bind confirmation received
193 * @param[in] post - Post structure
194 * @param[in] suId - Service provider SAP ID
195 * @param[in] reason - Reason of confirmation
201 S16 RlcLiRguUbndReq(Pst *post,SpId spId,Reason reason)
204 /* jump to specific primitive depending on configured selector */
205 (*kwLiRguUbndReqMt[post->selector])(post, spId, reason);
209 } /* end of RlcLiRguUbndReq */
211 /* kw005.201 added support for L2 Measurement */
219 * Handler for sending ulThrpMeasReqInfo from RLC to MAC for UL ip throughput measurement.
223 * This function sends ulThrpMeasReqInfo from RLC to MAC whenver UL ip throughput
224 * measurement is ON for a single or multiple qci in a UE. This is an indication for MAC
225 * to start the T2/T1 time stamps for the coresponding LCHs in the UE.
227 * @param[in] post Post structure
228 * @param[in] spId Service Provider ID
229 * @param[in] ulThrpMeasReqInfo Ul ip measurement request info
236 S16 RlcLiRguL2MUlThrpMeasReq(Pst *post,SpId spId,RguL2MUlThrpMeasReqInfo *l2mUlThrpMeasReq)
239 /* jump to specific primitive depending on configured selector */
240 (*kwLiRguL2MUlThrpMeasReqMt[post->selector])(post, spId, l2mUlThrpMeasReq);
244 } /* end of RlcLiRguL2MUlThrpMeasReq */
246 #endif /* LTE_RLC_R9 */
247 #endif /* LTE_L2_MEAS */
250 #ifdef MAC_RLC_UL_RBUF
251 S16 rlcUlBatchProc ARGS ((Void));
252 Void rlcUtlFreeUlRBuf ARGS((void));
254 S16 rlcUlBatchProc(Void)
256 /* Read from Ring Buffer and process PDCP packets */
257 RguDDatIndInfo *datInd;
258 Void *elmIndx = NULLP;
259 static Pst rlcUlRbfuPst={1,1,ENTRLC,0,ENTMAC,0,PRIOR0,RTESPEC,EVTRLCULDAT,0,0,0,0};
260 /* Read from Ring Buffer and process PDCP packets */
263 RguDedDatInd1 *rguDatInd = NULLP;
264 uint8_t rngBufDeqIndx = 0;
266 elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
267 while(NULLP != elmIndx)
269 rguDatInd = (RguDedDatInd1 *)elmIndx;
270 datInd = (RguDDatIndInfo*) rguDatInd->msg;
271 SsRngInfoTbl[SS_RNG_BUF_ULMAC_TO_ULRLC].nPktProc++;//Number of pkt processed in tti
274 RlcProcDedLcUlData(&rlcUlRbfuPst, 0, datInd);
278 RLOG0(L_ERROR,"Received NULL buffer");
280 rguDatInd->msg=NULLP;
281 SRngIncrRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
287 //if(rngBufDeqIndx >= SS_RNG_MAX_ULMAC_TO_ULRLC_DQ_CNT)
290 if((elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC)) == NULLP)
294 elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
295 while(NULLP != elmIndx)
297 datInd = (RguDDatIndInfo *)elmIndx;
298 RlcProcDedLcUlData(&rlcUlRbfuPst, 0, datInd);
302 SRngIncrRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
304 if((elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC)) == NULLP)
315 * Handler to clear Ring buffer from UL RLC
318 * This function clears all the ring buffer content from UL RLC
325 Void rlcUtlFreeUlRBuf(void)
327 RguDDatIndInfo *datInd;
332 /* Free SS_RNG_BUF_ULMAC_TO_ULRLC */
333 while((SDeqSRngBuf (SS_RNG_BUF_ULMAC_TO_ULRLC, &elem) == ROK))
335 datInd = (RguDDatIndInfo *)elem;
336 for(numLch = 0; numLch< datInd->numLch; numLch++)
338 for(numPdu = 0; numPdu < datInd->lchData[numLch].pdu.numPdu; numPdu++)
340 if(datInd->lchData[numLch].pdu.mBuf[numPdu])
342 RLC_FREE_BUF_WC(datInd->lchData[numLch].pdu.mBuf[numPdu]);
346 RLC_PST_FREE(0, 0, datInd, sizeof(RguDDatIndInfo));
350 #ifdef RLC_MAC_STA_RSP_RBUF
351 S16 rlcLiRguStaRspRbuf(Pst *post,SpId spId,Void *staRsp)
357 RguDStaRspInfo *staRspInfo = NULL;
358 elem = SRngGetWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC);
361 staRspInfo = (RguDStaRspInfo *)elem;
362 memcpy(staRspInfo, staRsp, sizeof(RguDStaRspInfo));
363 staRspInfo->post = *post;
364 SRngIncrWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC);
365 SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC].pktRate++;
369 RLOG0(L_ERROR,"RLC DL STA RSP RBUF is FULL!!! ");
370 SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC].pktDrop++;
374 } /* cmPkKwuDatReq */
377 #ifdef RLC_MAC_DAT_REQ_RBUF
378 S16 rlcLiRguDatReqRbuf(Pst *post,SpId spId,Void *datReq)
383 RguInfoRingElem *datReqRing=NULLP;
384 elem = SRngGetWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ);
387 datReqRing = (RguInfoRingElem *) elem;
388 datReqRing->spId = spId;
389 datReqRing->event = post->event;
390 datReqRing->msg =datReq;
391 SRngIncrWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ);
392 SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ].pktRate++;
396 printf("RLC DL DAT REQ RBUF is FULL!!! \n");
397 SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ].pktDrop++;
401 } /* cmPkKwuDatReq */
407 #endif /* __cplusplus */
409 /********************************************************************30**
411 **********************************************************************/