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*/
30 static const char* RLOG_MODULE_NAME="LIM";
31 static int RLOG_MODULE_ID=2048;
32 static int RLOG_FILE_ID=238;
34 @brief RLC Lower Interface
38 /* header (.h) include files */
39 #include "envopt.h" /* environment options */
40 #include "envdep.h" /* environment dependent */
41 #include "envind.h" /* environment independent */
43 #include "gen.h" /* general */
44 #include "ssi.h" /* system services */
45 #include "cm5.h" /* common timer defines */
46 #include "cm_tkns.h" /* common tokens defines */
47 #include "cm_mblk.h" /* common memory allocation library defines */
48 #include "cm_llist.h" /* common link list defines */
49 #include "cm_hash.h" /* common hash list defines */
50 #include "cm_lte.h" /* common LTE defines */
51 #include "lkw.h" /* LKW defines */
52 #include "ckw.h" /* CKW defines */
53 #include "kwu.h" /* KWU defines */
54 #include "rgu.h" /* RGU defines */
56 #include "cpj.h" /* CPJ defines */
57 #include "pju.h" /* PJU defines */
58 #include "lpj.h" /* LPJ defines */
61 #include "kw_env.h" /* RLC environment options */
62 #include "kw.h" /* RLC defines */
64 /* extern (.x) include files */
65 #include "gen.x" /* general */
66 #include "ssi.x" /* system services */
68 #include "cm5.x" /* common timer library */
69 #include "cm_tkns.x" /* common tokens */
70 #include "cm_mblk.x" /* common memory allocation */
71 #include "cm_llist.x" /* common link list */
72 #include "cm_hash.x" /* common hash list */
73 #include "cm_lte.x" /* common LTE includes */
74 #include "cm_lib.x" /* common memory allocation library */
75 #include "lkw.x" /* LKW */
76 #include "ckw.x" /* CKW */
77 #include "kwu.x" /* KWU */
78 #include "rgu.x" /* RGU */
80 #include "cpj.x" /* CPJ defines */
81 #include "pju.x" /* PJU defines */
82 #include "lpj.x" /* LPJ defines */
90 #endif /* EGTP_TEST */
102 #endif /* __cplusplus */
106 #ifdef RLC_MAC_DAT_REQ_RBUF
107 PUBLIC S16 kwLiRguDatReqRbuf(Pst *Post,SpId spId,Void *datReq);
110 #ifdef RLC_MAC_STA_RSP_RBUF
111 PUBLIC S16 kwLiRguStaRspRbuf(Pst *Post,SpId spId,Void *staRsp);
113 #if defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS)
114 EXTERN S16 KwDlHarqStaBatchProc (Void);
118 /*********************************************************************
119 * Primitives for RGU interface
120 ********************************************************************/
122 /* RGU Bind Request primitive */
124 PUBLIC RguBndReq kwLiRguBndReqMt[] =
127 cmPkRguBndReq, /* 0 - loosely coupled */
128 #endif /* LCRGUIRGU */
130 RgUiRguBndReq, /* 1 - tightly coupled, MAC */
133 cmPkRguBndReq, /* 0 - loosely coupled */
134 #endif /* LCRGUIRGU */
137 /* RGU Unbind Request primitive */
139 PUBLIC RguBndReq kwLiRguUbndReqMt[] =
142 cmPkRguUbndReq, /* 0 - loosely coupled */
143 #endif /* LCRGUIRGU */
145 RgUiRguUbndReq, /* 1 - tightly coupled, MAC */
148 cmPkRguUbndReq, /* 0 - loosely coupled */
149 #endif /* LCRGUIRGU */
152 /* RGU Dedicated Channel Data Request primitive */
154 PUBLIC RguDDatReq rlcMacSendDlDataOpts[] =
160 #else /* EGTP_TEST */
162 packDlData, /* 0 - loosely coupled */
163 #endif /* LCRGUIRGU */
165 RgUiRguDDatReq, /* 1 - tightly coupled, MAC */
168 packDlData, /* 0 - loosely coupled */
169 #endif /* LCRGUIRGU */
170 #endif /* EGTP_TEST */
174 /* RLC logical Channel Status primitive */
176 PUBLIC RguDStaRsp rlcMacSendBOStatusOpts[] =
182 #else /* EGTP_TEST */
184 packBOStatus, /* 0 - loosely coupled */
185 #endif /* LCRGUIRGU */
187 RgUiRguDStaRsp, /* 1 - tightly coupled, MAC */
190 packBOStatus, /* 0 - LWLC loosely coupled */
191 #endif /* LCRGUIRGU */
192 #endif /* EGTP_TEST */
195 /* kw005.201 added support for L2 Measurement */
198 /* RGU L2 Measurement Ul Ip Throughput Measurement Request primitive */
200 PUBLIC RguL2MUlThrpMeasReq kwLiRguL2MUlThrpMeasReqMt[] =
203 cmPkRguL2MUlThrpMeasReq, /* 0 - loosely coupled */
204 #endif /* LCRGUIRGU */
206 RgUiRguL2MUlThrpMeasReq, /* 1 - tightly coupled, MAC */
209 #endif /* LTE_RLC_R9 */
210 #endif /* LTE_L2_MEAS */
212 /****************************************************************************
213 * RGU Interface Mt functions
214 ***************************************************************************/
219 * Handler for RGU SAP bind Request.
223 * This function is used by RLC to request for binding to
224 * MAC for accessing MAC services.This function binds MAC's
225 * SAP (identified by spId) with the service user's SAP
226 * (identified by suId).
228 * @param[in] pst Post structure
229 * @param[in] suId Service user SAP ID
230 * @param[in] spId Service provider ID
237 PUBLIC S16 KwLiRguBndReq
239 Pst *post, /* post structure */
240 SuId suId, /* Service User Id */
241 SpId spId /* Service Provider Id */
244 PUBLIC S16 KwLiRguBndReq(post, suId, spId)
245 Pst *post; /* post structure */
246 SuId suId; /* Service User Id */
247 SpId spId; /* Service Provider Id */
252 /* jump to specific primitive depending on configured selector */
253 (*kwLiRguBndReqMt[post->selector])(post, suId, spId);
257 } /* end of KwLiRguBndReq */
264 * Handler for bind confirmation from MAC.
268 * This function handles the bind confirmation received
271 * @param[in] post - Post structure
272 * @param[in] suId - Service provider SAP ID
273 * @param[in] reason - Reason of confirmation
280 PUBLIC S16 KwLiRguUbndReq
287 PUBLIC S16 KwLiRguUbndReq(post, spId, reason)
295 /* jump to specific primitive depending on configured selector */
296 (*kwLiRguUbndReqMt[post->selector])(post, spId, reason);
300 } /* end of KwLiRguUbndReq */
307 * Handler for sending PDU(s) from RLC to MAC for dedicated logical channels.
311 * This function sends PDU(s) to MAC via one or more dedicated
312 * logical channels along with the Buffer Occupancy of these
315 * @param[in] post Post structure
316 * @param[in] spId Service Provider ID
317 * @param[in] datIndInfo Data Request Information
325 PUBLIC S16 RlcMacSendDlData
332 PUBLIC S16 RlcMacSendDlData(post, spId, dlData)
338 TRC3(RlcMacSendDlData)
339 #ifdef RLC_MAC_DAT_REQ_RBUF
340 post->event=EVTRGUDDATREQ;
341 if((kwLiRguDatReqRbuf(post, spId, datReq)) != ROK)
344 SPutStaticBuffer(post->region, post->pool,
345 (Data *) datReq, sizeof(RguDDatReqInfo), 0);
349 /* jump to specific primitive depending on configured selector */
350 (*rlcMacSendDlDataOpts[post->selector])(post, spId, dlData);
354 } /* end of KwLiRguDDatReq */
362 * Handler for reporting the Buffer Occupancy to MAC
363 * for logical channels.
367 * This function reports the Buffer Occupancy of one or more
368 * logical channels to MAC.
370 * @param[in] post Post structure
371 * @param[in] spId Service Provider ID
372 * @param[in] boSta BO Status Information
380 PUBLIC S16 RlcMacSendBOStatus
384 RlcMacBOStatus *boSta
387 PUBLIC S16 RlcMacSendBOStatus(post, spId, staRsp)
390 RlcMacBOStatus *boSta;
393 TRC3(RlcMacSendBOStatus)
394 #if defined(SPLIT_RLC_DL_TASK) && defined(RLC_MAC_STA_RSP_RBUF)
395 post->event= EVTRGUDSTARSP;
396 if((kwLiRguStaRspRbuf(post, spId, staRsp)) != ROK)
401 /* jump to specific primitive depending on configured selector */
402 (*rlcMacSendBOStatusOpts[post->selector])(post, spId, boSta);
406 } /* end of RlcMacSendBOStatus */
409 /* kw005.201 added support for L2 Measurement */
417 * Handler for sending ulThrpMeasReqInfo from RLC to MAC for UL ip throughput measurement.
421 * This function sends ulThrpMeasReqInfo from RLC to MAC whenver UL ip throughput
422 * measurement is ON for a single or multiple qci in a UE. This is an indication for MAC
423 * to start the T2/T1 time stamps for the coresponding LCHs in the UE.
425 * @param[in] post Post structure
426 * @param[in] spId Service Provider ID
427 * @param[in] ulThrpMeasReqInfo Ul ip measurement request info
435 PUBLIC S16 KwLiRguL2MUlThrpMeasReq
439 RguL2MUlThrpMeasReqInfo *l2mUlThrpMeasReq
442 PUBLIC S16 KwLiRguL2MUlThrpMeasReq(post, spId, l2mUlThrpMeasReq)
445 RguL2MUlThrpMeasReqInfo *l2mUlThrpMeasReq;
448 TRC3(KwLiRguL2MUlThrpMeasReq)
450 /* jump to specific primitive depending on configured selector */
451 (*kwLiRguL2MUlThrpMeasReqMt[post->selector])(post, spId, l2mUlThrpMeasReq);
455 } /* end of KwLiRguL2MUlThrpMeasReq */
457 #endif /* LTE_RLC_R9 */
458 #endif /* LTE_L2_MEAS */
461 #ifdef MAC_RLC_UL_RBUF
462 PUBLIC S16 kwUlBatchProc ARGS ((Void));
463 EXTERN Void kwUtlFreeUlRBuf ARGS((void));
466 PUBLIC S16 kwUlBatchProc
471 PUBLIC S16 kwUlBatchProc()
475 /* Read from Ring Buffer and process PDCP packets */
476 RguDDatIndInfo *datInd;
477 Void *elmIndx = NULLP;
478 PRIVATE Pst rlcUlRbfuPst={1,1,ENTKW,0,ENTRG,0,PRIOR0,RTESPEC,EVTRLCULDAT,0,0,0,0};
479 /* Read from Ring Buffer and process PDCP packets */
482 RguDedDatInd1 *rguDatInd = NULLP;
483 U8 rngBufDeqIndx = 0;
485 elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
486 while(NULLP != elmIndx)
488 rguDatInd = (RguDedDatInd1 *)elmIndx;
489 datInd = (RguDDatIndInfo*) rguDatInd->msg;
490 SsRngInfoTbl[SS_RNG_BUF_ULMAC_TO_ULRLC].nPktProc++;;//Number of pkt processed in tti
493 KwLiRguDDatInd(&rlcUlRbfuPst, 0, datInd);
497 RLOG0(L_ERROR,"Received NULL buffer");
499 rguDatInd->msg=NULLP;
500 SRngIncrRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
506 //if(rngBufDeqIndx >= SS_RNG_MAX_ULMAC_TO_ULRLC_DQ_CNT)
509 if((elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC)) == NULLP)
513 elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
514 while(NULLP != elmIndx)
516 datInd = (RguDDatIndInfo *)elmIndx;
517 KwLiRguDDatInd(&rlcUlRbfuPst, 0, datInd);
521 SRngIncrRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
523 if((elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC)) == NULLP)
534 * Handler to clear Ring buffer from UL RLC
537 * This function clears all the ring buffer content from UL RLC
545 PUBLIC Void kwUtlFreeUlRBuf(void)
547 PUBLIC Void kwUtlFreeUlRBuf()
550 RguDDatIndInfo *datInd;
555 TRC2(kwUtlFreeUlRBuf)
556 /* Free SS_RNG_BUF_ULMAC_TO_ULRLC */
557 while((SDeqSRngBuf (SS_RNG_BUF_ULMAC_TO_ULRLC, &elem) == ROK))
559 datInd = (RguDDatIndInfo *)elem;
560 for(numLch = 0; numLch< datInd->numLch; numLch++)
562 for(numPdu = 0; numPdu < datInd->lchData[numLch].pdu.numPdu; numPdu++)
564 if(datInd->lchData[numLch].pdu.mBuf[numPdu])
566 KW_FREE_BUF_WC(datInd->lchData[numLch].pdu.mBuf[numPdu]);
570 KW_PST_FREE(0, 0, datInd, sizeof(RguDDatIndInfo));
574 #ifdef RLC_MAC_STA_RSP_RBUF
576 PUBLIC S16 kwLiRguStaRspRbuf
583 PUBLIC S16 kwLiRguStaRspRbuf(post, spId, staRsp)
593 RguDStaRspInfo *staRspInfo = NULL;
594 elem = SRngGetWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC);
597 staRspInfo = (RguDStaRspInfo *)elem;
598 cmMemcpy((U8 *)staRspInfo, (U8 *)staRsp, sizeof(RguDStaRspInfo));
599 staRspInfo->post = *post;
600 SRngIncrWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC);
601 SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC].pktRate++;
605 RLOG0(L_ERROR,"RLC DL STA RSP RBUF is FULL!!! ");
606 SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC].pktDrop++;
610 } /* cmPkKwuDatReq */
613 #ifdef RLC_MAC_DAT_REQ_RBUF
615 PUBLIC S16 kwLiRguDatReqRbuf
622 PUBLIC S16 kwLiRguDatReqRbuf(post, spId, datReq)
631 RguInfoRingElem *datReqRing=NULLP;
632 elem = SRngGetWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ);
635 datReqRing = (RguInfoRingElem *) elem;
636 datReqRing->spId = spId;
637 datReqRing->event = post->event;
638 datReqRing->msg =datReq;
639 SRngIncrWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ);
640 SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ].pktRate++;
644 printf("RLC DL DAT REQ RBUF is FULL!!! \n");
645 SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ].pktDrop++;
649 } /* cmPkKwuDatReq */
655 #endif /* __cplusplus */
657 /********************************************************************30**
659 **********************************************************************/