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 "envopt.h" /* environment options */
38 #include "envdep.h" /* environment dependent */
39 #include "envind.h" /* environment independent */
41 #include "gen.h" /* general */
42 #include "ssi.h" /* system services */
43 #include "cm5.h" /* common timer defines */
44 #include "cm_tkns.h" /* common tokens defines */
45 #include "cm_mblk.h" /* common memory allocation library defines */
46 #include "cm_llist.h" /* common link list defines */
47 #include "cm_hash.h" /* common hash list defines */
48 #include "cm_lte.h" /* common LTE defines */
49 #include "lkw.h" /* LKW defines */
50 #include "ckw.h" /* CKW defines */
51 #include "kwu.h" /* KWU defines */
52 #include "rgu.h" /* RGU defines */
54 #include "cpj.h" /* CPJ defines */
55 #include "pju.h" /* PJU defines */
56 #include "lpj.h" /* LPJ defines */
59 #include "kw_env.h" /* RLC environment options */
60 #include "kw.h" /* RLC defines */
62 /* extern (.x) include files */
63 #include "gen.x" /* general */
64 #include "ssi.x" /* system services */
66 #include "cm5.x" /* common timer library */
67 #include "cm_tkns.x" /* common tokens */
68 #include "cm_mblk.x" /* common memory allocation */
69 #include "cm_llist.x" /* common link list */
70 #include "cm_hash.x" /* common hash list */
71 #include "cm_lte.x" /* common LTE includes */
72 #include "cm_lib.x" /* common memory allocation library */
73 #include "lkw.x" /* LKW */
74 #include "ckw.x" /* CKW */
75 #include "kwu.x" /* KWU */
76 #include "rgu.x" /* RGU */
78 #include "cpj.x" /* CPJ defines */
79 #include "pju.x" /* PJU defines */
80 #include "lpj.x" /* LPJ defines */
88 #endif /* EGTP_TEST */
100 #endif /* __cplusplus */
104 #ifdef RLC_MAC_DAT_REQ_RBUF
105 PUBLIC S16 kwLiRguDatReqRbuf(Pst *Post,SpId spId,Void *datReq);
108 #ifdef RLC_MAC_STA_RSP_RBUF
109 PUBLIC S16 kwLiRguStaRspRbuf(Pst *Post,SpId spId,Void *staRsp);
111 #if defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS)
112 EXTERN S16 KwDlHarqStaBatchProc (Void);
116 /*********************************************************************
117 * Primitives for RGU interface
118 ********************************************************************/
120 /* RGU Bind Request primitive */
122 PUBLIC RguBndReq kwLiRguBndReqMt[] =
125 cmPkRguBndReq, /* 0 - loosely coupled */
126 #endif /* LCRGUIRGU */
128 RgUiRguBndReq, /* 1 - tightly coupled, MAC */
131 cmPkRguBndReq, /* 0 - loosely coupled */
132 #endif /* LCRGUIRGU */
135 /* RGU Unbind Request primitive */
137 PUBLIC RguBndReq kwLiRguUbndReqMt[] =
140 cmPkRguUbndReq, /* 0 - loosely coupled */
141 #endif /* LCRGUIRGU */
143 RgUiRguUbndReq, /* 1 - tightly coupled, MAC */
146 cmPkRguUbndReq, /* 0 - loosely coupled */
147 #endif /* LCRGUIRGU */
150 /* RGU Dedicated Channel Data Request primitive */
152 PUBLIC RlcMacDlData rlcMacSendDlDataOpts[] =
158 #else /* EGTP_TEST */
160 packDlData, /* 0 - loosely coupled */
161 #endif /* LCRGUIRGU */
163 MacRlcProcDlData, /* 1 - tightly coupled, MAC */
166 packDlData, /* 0 - loosely coupled */
167 #endif /* LCRGUIRGU */
168 #endif /* EGTP_TEST */
172 /* RLC logical Channel Status primitive */
174 PUBLIC RlcMacBoStatus rlcMacSendBOStatusOpts[] =
180 #else /* EGTP_TEST */
182 packBOStatus, /* 0 - loosely coupled */
183 #endif /* LCRGUIRGU */
185 MacRlcProcBOStatus, /* 1 - tightly coupled, MAC */
188 packBOStatus, /* 0 - LWLC loosely coupled */
189 #endif /* LCRGUIRGU */
190 #endif /* EGTP_TEST */
193 /* kw005.201 added support for L2 Measurement */
196 /* RGU L2 Measurement Ul Ip Throughput Measurement Request primitive */
198 PUBLIC RguL2MUlThrpMeasReq kwLiRguL2MUlThrpMeasReqMt[] =
201 cmPkRguL2MUlThrpMeasReq, /* 0 - loosely coupled */
202 #endif /* LCRGUIRGU */
204 RgUiRguL2MUlThrpMeasReq, /* 1 - tightly coupled, MAC */
207 #endif /* LTE_RLC_R9 */
208 #endif /* LTE_L2_MEAS */
210 /****************************************************************************
211 * RGU Interface Mt functions
212 ***************************************************************************/
217 * Handler for RGU SAP bind Request.
221 * This function is used by RLC to request for binding to
222 * MAC for accessing MAC services.This function binds MAC's
223 * SAP (identified by spId) with the service user's SAP
224 * (identified by suId).
226 * @param[in] pst Post structure
227 * @param[in] suId Service user SAP ID
228 * @param[in] spId Service provider ID
235 PUBLIC S16 KwLiRguBndReq
237 Pst *post, /* post structure */
238 SuId suId, /* Service User Id */
239 SpId spId /* Service Provider Id */
242 PUBLIC S16 KwLiRguBndReq(post, suId, spId)
243 Pst *post; /* post structure */
244 SuId suId; /* Service User Id */
245 SpId spId; /* Service Provider Id */
250 /* jump to specific primitive depending on configured selector */
251 (*kwLiRguBndReqMt[post->selector])(post, suId, spId);
255 } /* end of KwLiRguBndReq */
262 * Handler for bind confirmation from MAC.
266 * This function handles the bind confirmation received
269 * @param[in] post - Post structure
270 * @param[in] suId - Service provider SAP ID
271 * @param[in] reason - Reason of confirmation
278 PUBLIC S16 KwLiRguUbndReq
285 PUBLIC S16 KwLiRguUbndReq(post, spId, reason)
293 /* jump to specific primitive depending on configured selector */
294 (*kwLiRguUbndReqMt[post->selector])(post, spId, reason);
298 } /* end of KwLiRguUbndReq */
305 * Handler for sending PDU(s) from RLC to MAC for dedicated logical channels.
309 * This function sends PDU(s) to MAC via one or more dedicated
310 * logical channels along with the Buffer Occupancy of these
313 * @param[in] post Post structure
314 * @param[in] spId Service Provider ID
315 * @param[in] datIndInfo Data Request Information
323 PUBLIC S16 RlcMacSendDlData
330 PUBLIC S16 RlcMacSendDlData(post, spId, dlData)
336 TRC3(RlcMacSendDlData)
337 #ifdef RLC_MAC_DAT_REQ_RBUF
338 post->event=EVTRGUDDATREQ;
339 if((kwLiRguDatReqRbuf(post, spId, datReq)) != ROK)
342 SPutStaticBuffer(post->region, post->pool,
343 (Data *) datReq, sizeof(RguDDatReqInfo), 0);
347 /* jump to specific primitive depending on configured selector */
348 (*rlcMacSendDlDataOpts[post->selector])(post, spId, dlData);
352 } /* end of KwLiRguDDatReq */
360 * Handler for reporting the Buffer Occupancy to MAC
361 * for logical channels.
365 * This function reports the Buffer Occupancy of one or more
366 * logical channels to MAC.
368 * @param[in] post Post structure
369 * @param[in] spId Service Provider ID
370 * @param[in] boSta BO Status Information
378 PUBLIC S16 RlcMacSendBOStatus
382 RlcMacBOStatus *boSta
385 PUBLIC S16 RlcMacSendBOStatus(post, spId, staRsp)
388 RlcMacBOStatus *boSta;
391 TRC3(RlcMacSendBOStatus)
392 #if defined(SPLIT_RLC_DL_TASK) && defined(RLC_MAC_STA_RSP_RBUF)
393 post->event= EVTRGUDSTARSP;
394 if((kwLiRguStaRspRbuf(post, spId, staRsp)) != ROK)
399 /* jump to specific primitive depending on configured selector */
400 (*rlcMacSendBOStatusOpts[post->selector])(post, spId, boSta);
404 } /* end of RlcMacSendBOStatus */
407 /* kw005.201 added support for L2 Measurement */
415 * Handler for sending ulThrpMeasReqInfo from RLC to MAC for UL ip throughput measurement.
419 * This function sends ulThrpMeasReqInfo from RLC to MAC whenver UL ip throughput
420 * measurement is ON for a single or multiple qci in a UE. This is an indication for MAC
421 * to start the T2/T1 time stamps for the coresponding LCHs in the UE.
423 * @param[in] post Post structure
424 * @param[in] spId Service Provider ID
425 * @param[in] ulThrpMeasReqInfo Ul ip measurement request info
433 PUBLIC S16 KwLiRguL2MUlThrpMeasReq
437 RguL2MUlThrpMeasReqInfo *l2mUlThrpMeasReq
440 PUBLIC S16 KwLiRguL2MUlThrpMeasReq(post, spId, l2mUlThrpMeasReq)
443 RguL2MUlThrpMeasReqInfo *l2mUlThrpMeasReq;
446 TRC3(KwLiRguL2MUlThrpMeasReq)
448 /* jump to specific primitive depending on configured selector */
449 (*kwLiRguL2MUlThrpMeasReqMt[post->selector])(post, spId, l2mUlThrpMeasReq);
453 } /* end of KwLiRguL2MUlThrpMeasReq */
455 #endif /* LTE_RLC_R9 */
456 #endif /* LTE_L2_MEAS */
459 #ifdef MAC_RLC_UL_RBUF
460 PUBLIC S16 kwUlBatchProc ARGS ((Void));
461 EXTERN Void kwUtlFreeUlRBuf ARGS((void));
464 PUBLIC S16 kwUlBatchProc
469 PUBLIC S16 kwUlBatchProc()
473 /* Read from Ring Buffer and process PDCP packets */
474 RguDDatIndInfo *datInd;
475 Void *elmIndx = NULLP;
476 PRIVATE Pst rlcUlRbfuPst={1,1,ENTKW,0,ENTRG,0,PRIOR0,RTESPEC,EVTRLCULDAT,0,0,0,0};
477 /* Read from Ring Buffer and process PDCP packets */
480 RguDedDatInd1 *rguDatInd = NULLP;
481 U8 rngBufDeqIndx = 0;
483 elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
484 while(NULLP != elmIndx)
486 rguDatInd = (RguDedDatInd1 *)elmIndx;
487 datInd = (RguDDatIndInfo*) rguDatInd->msg;
488 SsRngInfoTbl[SS_RNG_BUF_ULMAC_TO_ULRLC].nPktProc++;;//Number of pkt processed in tti
491 KwLiRguDDatInd(&rlcUlRbfuPst, 0, datInd);
495 RLOG0(L_ERROR,"Received NULL buffer");
497 rguDatInd->msg=NULLP;
498 SRngIncrRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
504 //if(rngBufDeqIndx >= SS_RNG_MAX_ULMAC_TO_ULRLC_DQ_CNT)
507 if((elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC)) == NULLP)
511 elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
512 while(NULLP != elmIndx)
514 datInd = (RguDDatIndInfo *)elmIndx;
515 KwLiRguDDatInd(&rlcUlRbfuPst, 0, datInd);
519 SRngIncrRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
521 if((elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC)) == NULLP)
532 * Handler to clear Ring buffer from UL RLC
535 * This function clears all the ring buffer content from UL RLC
543 PUBLIC Void kwUtlFreeUlRBuf(void)
545 PUBLIC Void kwUtlFreeUlRBuf()
548 RguDDatIndInfo *datInd;
553 TRC2(kwUtlFreeUlRBuf)
554 /* Free SS_RNG_BUF_ULMAC_TO_ULRLC */
555 while((SDeqSRngBuf (SS_RNG_BUF_ULMAC_TO_ULRLC, &elem) == ROK))
557 datInd = (RguDDatIndInfo *)elem;
558 for(numLch = 0; numLch< datInd->numLch; numLch++)
560 for(numPdu = 0; numPdu < datInd->lchData[numLch].pdu.numPdu; numPdu++)
562 if(datInd->lchData[numLch].pdu.mBuf[numPdu])
564 KW_FREE_BUF_WC(datInd->lchData[numLch].pdu.mBuf[numPdu]);
568 KW_PST_FREE(0, 0, datInd, sizeof(RguDDatIndInfo));
572 #ifdef RLC_MAC_STA_RSP_RBUF
574 PUBLIC S16 kwLiRguStaRspRbuf
581 PUBLIC S16 kwLiRguStaRspRbuf(post, spId, staRsp)
591 RguDStaRspInfo *staRspInfo = NULL;
592 elem = SRngGetWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC);
595 staRspInfo = (RguDStaRspInfo *)elem;
596 cmMemcpy((U8 *)staRspInfo, (U8 *)staRsp, sizeof(RguDStaRspInfo));
597 staRspInfo->post = *post;
598 SRngIncrWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC);
599 SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC].pktRate++;
603 RLOG0(L_ERROR,"RLC DL STA RSP RBUF is FULL!!! ");
604 SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC].pktDrop++;
608 } /* cmPkKwuDatReq */
611 #ifdef RLC_MAC_DAT_REQ_RBUF
613 PUBLIC S16 kwLiRguDatReqRbuf
620 PUBLIC S16 kwLiRguDatReqRbuf(post, spId, datReq)
629 RguInfoRingElem *datReqRing=NULLP;
630 elem = SRngGetWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ);
633 datReqRing = (RguInfoRingElem *) elem;
634 datReqRing->spId = spId;
635 datReqRing->event = post->event;
636 datReqRing->msg =datReq;
637 SRngIncrWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ);
638 SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ].pktRate++;
642 printf("RLC DL DAT REQ RBUF is FULL!!! \n");
643 SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ].pktDrop++;
647 } /* cmPkKwuDatReq */
653 #endif /* __cplusplus */
655 /********************************************************************30**
657 **********************************************************************/