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 */
67 #endif /* EGTP_TEST */
79 #endif /* __cplusplus */
83 #ifdef RLC_MAC_DAT_REQ_RBUF
84 PUBLIC S16 kwLiRguDatReqRbuf(Pst *Post,SpId spId,Void *datReq);
87 #ifdef RLC_MAC_STA_RSP_RBUF
88 PUBLIC S16 kwLiRguStaRspRbuf(Pst *Post,SpId spId,Void *staRsp);
90 #if defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS)
91 EXTERN S16 KwDlHarqStaBatchProc (Void);
95 /*********************************************************************
96 * Primitives for RGU interface
97 ********************************************************************/
99 /* RGU Bind Request primitive */
101 PUBLIC RguBndReq kwLiRguBndReqMt[] =
104 cmPkRguBndReq, /* 0 - loosely coupled */
105 #endif /* LCRGUIRGU */
107 RgUiRguBndReq, /* 1 - tightly coupled, MAC */
110 cmPkRguBndReq, /* 0 - loosely coupled */
111 #endif /* LCRGUIRGU */
114 /* RGU Unbind Request primitive */
116 PUBLIC RguBndReq kwLiRguUbndReqMt[] =
119 cmPkRguUbndReq, /* 0 - loosely coupled */
120 #endif /* LCRGUIRGU */
122 RgUiRguUbndReq, /* 1 - tightly coupled, MAC */
125 cmPkRguUbndReq, /* 0 - loosely coupled */
126 #endif /* LCRGUIRGU */
129 /* RGU Dedicated Channel Data Request primitive */
131 PUBLIC RlcMacDlData rlcMacSendDlDataOpts[] =
137 #else /* EGTP_TEST */
139 packDlData, /* 0 - loosely coupled */
140 #endif /* LCRGUIRGU */
142 MacRlcProcDlData, /* 1 - tightly coupled, MAC */
145 packDlData, /* 0 - loosely coupled */
146 #endif /* LCRGUIRGU */
147 #endif /* EGTP_TEST */
151 /* RLC logical Channel Status primitive */
153 PUBLIC RlcMacBoStatus rlcMacSendBOStatusOpts[] =
159 #else /* EGTP_TEST */
161 packBOStatus, /* 0 - loosely coupled */
162 #endif /* LCRGUIRGU */
164 MacRlcProcBOStatus, /* 1 - tightly coupled, MAC */
167 packBOStatus, /* 0 - LWLC loosely coupled */
168 #endif /* LCRGUIRGU */
169 #endif /* EGTP_TEST */
172 /* kw005.201 added support for L2 Measurement */
175 /* RGU L2 Measurement Ul Ip Throughput Measurement Request primitive */
177 PUBLIC RguL2MUlThrpMeasReq kwLiRguL2MUlThrpMeasReqMt[] =
180 cmPkRguL2MUlThrpMeasReq, /* 0 - loosely coupled */
181 #endif /* LCRGUIRGU */
183 RgUiRguL2MUlThrpMeasReq, /* 1 - tightly coupled, MAC */
186 #endif /* LTE_RLC_R9 */
187 #endif /* LTE_L2_MEAS */
189 /****************************************************************************
190 * RGU Interface Mt functions
191 ***************************************************************************/
196 * Handler for RGU SAP bind Request.
200 * This function is used by RLC to request for binding to
201 * MAC for accessing MAC services.This function binds MAC's
202 * SAP (identified by spId) with the service user's SAP
203 * (identified by suId).
205 * @param[in] pst Post structure
206 * @param[in] suId Service user SAP ID
207 * @param[in] spId Service provider ID
214 PUBLIC S16 KwLiRguBndReq
216 Pst *post, /* post structure */
217 SuId suId, /* Service User Id */
218 SpId spId /* Service Provider Id */
221 PUBLIC S16 KwLiRguBndReq(post, suId, spId)
222 Pst *post; /* post structure */
223 SuId suId; /* Service User Id */
224 SpId spId; /* Service Provider Id */
229 /* jump to specific primitive depending on configured selector */
230 (*kwLiRguBndReqMt[post->selector])(post, suId, spId);
234 } /* end of KwLiRguBndReq */
241 * Handler for bind confirmation from MAC.
245 * This function handles the bind confirmation received
248 * @param[in] post - Post structure
249 * @param[in] suId - Service provider SAP ID
250 * @param[in] reason - Reason of confirmation
257 PUBLIC S16 KwLiRguUbndReq
264 PUBLIC S16 KwLiRguUbndReq(post, spId, reason)
272 /* jump to specific primitive depending on configured selector */
273 (*kwLiRguUbndReqMt[post->selector])(post, spId, reason);
277 } /* end of KwLiRguUbndReq */
284 * Handler for sending PDU(s) from RLC to MAC for dedicated logical channels.
288 * This function sends PDU(s) to MAC via one or more dedicated
289 * logical channels along with the Buffer Occupancy of these
292 * @param[in] post Post structure
293 * @param[in] spId Service Provider ID
294 * @param[in] datIndInfo Data Request Information
302 PUBLIC S16 RlcMacSendDlData
309 PUBLIC S16 RlcMacSendDlData(post, spId, dlData)
315 TRC3(RlcMacSendDlData)
316 #ifdef RLC_MAC_DAT_REQ_RBUF
317 post->event=EVTRGUDDATREQ;
318 if((kwLiRguDatReqRbuf(post, spId, datReq)) != ROK)
321 SPutStaticBuffer(post->region, post->pool,
322 (Data *) datReq, sizeof(RguDDatReqInfo), 0);
326 /* jump to specific primitive depending on configured selector */
327 (*rlcMacSendDlDataOpts[post->selector])(post, spId, dlData);
331 } /* end of KwLiRguDDatReq */
339 * Handler for reporting the Buffer Occupancy to MAC
340 * for logical channels.
344 * This function reports the Buffer Occupancy of one or more
345 * logical channels to MAC.
347 * @param[in] post Post structure
348 * @param[in] spId Service Provider ID
349 * @param[in] boSta BO Status Information
357 PUBLIC S16 RlcMacSendBOStatus
361 RlcMacBOStatus *boSta
364 PUBLIC S16 RlcMacSendBOStatus(post, spId, staRsp)
367 RlcMacBOStatus *boSta;
370 TRC3(RlcMacSendBOStatus)
371 #if defined(SPLIT_RLC_DL_TASK) && defined(RLC_MAC_STA_RSP_RBUF)
372 post->event= EVTRGUDSTARSP;
373 if((kwLiRguStaRspRbuf(post, spId, staRsp)) != ROK)
378 /* jump to specific primitive depending on configured selector */
379 (*rlcMacSendBOStatusOpts[post->selector])(post, spId, boSta);
383 } /* end of RlcMacSendBOStatus */
386 /* kw005.201 added support for L2 Measurement */
394 * Handler for sending ulThrpMeasReqInfo from RLC to MAC for UL ip throughput measurement.
398 * This function sends ulThrpMeasReqInfo from RLC to MAC whenver UL ip throughput
399 * measurement is ON for a single or multiple qci in a UE. This is an indication for MAC
400 * to start the T2/T1 time stamps for the coresponding LCHs in the UE.
402 * @param[in] post Post structure
403 * @param[in] spId Service Provider ID
404 * @param[in] ulThrpMeasReqInfo Ul ip measurement request info
412 PUBLIC S16 KwLiRguL2MUlThrpMeasReq
416 RguL2MUlThrpMeasReqInfo *l2mUlThrpMeasReq
419 PUBLIC S16 KwLiRguL2MUlThrpMeasReq(post, spId, l2mUlThrpMeasReq)
422 RguL2MUlThrpMeasReqInfo *l2mUlThrpMeasReq;
425 TRC3(KwLiRguL2MUlThrpMeasReq)
427 /* jump to specific primitive depending on configured selector */
428 (*kwLiRguL2MUlThrpMeasReqMt[post->selector])(post, spId, l2mUlThrpMeasReq);
432 } /* end of KwLiRguL2MUlThrpMeasReq */
434 #endif /* LTE_RLC_R9 */
435 #endif /* LTE_L2_MEAS */
438 #ifdef MAC_RLC_UL_RBUF
439 PUBLIC S16 kwUlBatchProc ARGS ((Void));
440 EXTERN Void kwUtlFreeUlRBuf ARGS((void));
443 PUBLIC S16 kwUlBatchProc
448 PUBLIC S16 kwUlBatchProc()
452 /* Read from Ring Buffer and process PDCP packets */
453 RguDDatIndInfo *datInd;
454 Void *elmIndx = NULLP;
455 PRIVATE Pst rlcUlRbfuPst={1,1,ENTKW,0,ENTRG,0,PRIOR0,RTESPEC,EVTRLCULDAT,0,0,0,0};
456 /* Read from Ring Buffer and process PDCP packets */
459 RguDedDatInd1 *rguDatInd = NULLP;
460 U8 rngBufDeqIndx = 0;
462 elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
463 while(NULLP != elmIndx)
465 rguDatInd = (RguDedDatInd1 *)elmIndx;
466 datInd = (RguDDatIndInfo*) rguDatInd->msg;
467 SsRngInfoTbl[SS_RNG_BUF_ULMAC_TO_ULRLC].nPktProc++;;//Number of pkt processed in tti
470 KwLiRguDDatInd(&rlcUlRbfuPst, 0, datInd);
474 RLOG0(L_ERROR,"Received NULL buffer");
476 rguDatInd->msg=NULLP;
477 SRngIncrRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
483 //if(rngBufDeqIndx >= SS_RNG_MAX_ULMAC_TO_ULRLC_DQ_CNT)
486 if((elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC)) == NULLP)
490 elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
491 while(NULLP != elmIndx)
493 datInd = (RguDDatIndInfo *)elmIndx;
494 KwLiRguDDatInd(&rlcUlRbfuPst, 0, datInd);
498 SRngIncrRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
500 if((elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC)) == NULLP)
511 * Handler to clear Ring buffer from UL RLC
514 * This function clears all the ring buffer content from UL RLC
522 PUBLIC Void kwUtlFreeUlRBuf(void)
524 PUBLIC Void kwUtlFreeUlRBuf()
527 RguDDatIndInfo *datInd;
532 TRC2(kwUtlFreeUlRBuf)
533 /* Free SS_RNG_BUF_ULMAC_TO_ULRLC */
534 while((SDeqSRngBuf (SS_RNG_BUF_ULMAC_TO_ULRLC, &elem) == ROK))
536 datInd = (RguDDatIndInfo *)elem;
537 for(numLch = 0; numLch< datInd->numLch; numLch++)
539 for(numPdu = 0; numPdu < datInd->lchData[numLch].pdu.numPdu; numPdu++)
541 if(datInd->lchData[numLch].pdu.mBuf[numPdu])
543 KW_FREE_BUF_WC(datInd->lchData[numLch].pdu.mBuf[numPdu]);
547 KW_PST_FREE(0, 0, datInd, sizeof(RguDDatIndInfo));
551 #ifdef RLC_MAC_STA_RSP_RBUF
553 PUBLIC S16 kwLiRguStaRspRbuf
560 PUBLIC S16 kwLiRguStaRspRbuf(post, spId, staRsp)
570 RguDStaRspInfo *staRspInfo = NULL;
571 elem = SRngGetWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC);
574 staRspInfo = (RguDStaRspInfo *)elem;
575 cmMemcpy((U8 *)staRspInfo, (U8 *)staRsp, sizeof(RguDStaRspInfo));
576 staRspInfo->post = *post;
577 SRngIncrWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC);
578 SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC].pktRate++;
582 RLOG0(L_ERROR,"RLC DL STA RSP RBUF is FULL!!! ");
583 SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC].pktDrop++;
587 } /* cmPkKwuDatReq */
590 #ifdef RLC_MAC_DAT_REQ_RBUF
592 PUBLIC S16 kwLiRguDatReqRbuf
599 PUBLIC S16 kwLiRguDatReqRbuf(post, spId, datReq)
608 RguInfoRingElem *datReqRing=NULLP;
609 elem = SRngGetWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ);
612 datReqRing = (RguInfoRingElem *) elem;
613 datReqRing->spId = spId;
614 datReqRing->event = post->event;
615 datReqRing->msg =datReq;
616 SRngIncrWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ);
617 SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ].pktRate++;
621 printf("RLC DL DAT REQ RBUF is FULL!!! \n");
622 SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ].pktDrop++;
626 } /* cmPkKwuDatReq */
632 #endif /* __cplusplus */
634 /********************************************************************30**
636 **********************************************************************/