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 */
98 #endif /* __cplusplus */
102 #ifdef RLC_MAC_DAT_REQ_RBUF
103 PUBLIC S16 kwLiRguDatReqRbuf(Pst *Post,SpId spId,Void *datReq);
106 #ifdef RLC_MAC_STA_RSP_RBUF
107 PUBLIC S16 kwLiRguStaRspRbuf(Pst *Post,SpId spId,Void *staRsp);
109 #if defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS)
110 EXTERN S16 KwDlHarqStaBatchProc (Void);
114 /*********************************************************************
115 * Primitives for RGU interface
116 ********************************************************************/
118 /* RGU Bind Request primitive */
120 PUBLIC RguBndReq kwLiRguBndReqMt[] =
123 cmPkRguBndReq, /* 0 - loosely coupled */
124 #endif /* LCRGUIRGU */
126 RgUiRguBndReq, /* 1 - tightly coupled, MAC */
129 cmPkRguBndReq, /* 0 - loosely coupled */
130 #endif /* LCRGUIRGU */
133 /* RGU Unbind Request primitive */
135 PUBLIC RguBndReq kwLiRguUbndReqMt[] =
138 cmPkRguUbndReq, /* 0 - loosely coupled */
139 #endif /* LCRGUIRGU */
141 RgUiRguUbndReq, /* 1 - tightly coupled, MAC */
144 cmPkRguUbndReq, /* 0 - loosely coupled */
145 #endif /* LCRGUIRGU */
148 /* RGU Dedicated Channel Data Request primitive */
150 PUBLIC RguDDatReq rlcMacSendDlDataOpts[] =
153 packDlData, /* 0 - loosely coupled */
154 #endif /* LCRGUIRGU */
156 RgUiRguDDatReq, /* 1 - tightly coupled, MAC */
159 packDlData, /* 0 - loosely coupled */
160 #endif /* LCRGUIRGU */
164 /* RLC logical Channel Status primitive */
166 PUBLIC RguDStaRsp rlcMacSendBOStatusOpts[] =
169 packBOStatus, /* 0 - loosely coupled */
170 #endif /* LCRGUIRGU */
172 RgUiRguDStaRsp, /* 1 - tightly coupled, MAC */
175 packBOStatus, /* 0 - LWLC loosely coupled */
176 #endif /* LCRGUIRGU */
179 /* kw005.201 added support for L2 Measurement */
182 /* RGU L2 Measurement Ul Ip Throughput Measurement Request primitive */
184 PUBLIC RguL2MUlThrpMeasReq kwLiRguL2MUlThrpMeasReqMt[] =
187 cmPkRguL2MUlThrpMeasReq, /* 0 - loosely coupled */
188 #endif /* LCRGUIRGU */
190 RgUiRguL2MUlThrpMeasReq, /* 1 - tightly coupled, MAC */
193 #endif /* LTE_RLC_R9 */
194 #endif /* LTE_L2_MEAS */
196 /****************************************************************************
197 * RGU Interface Mt functions
198 ***************************************************************************/
203 * Handler for RGU SAP bind Request.
207 * This function is used by RLC to request for binding to
208 * MAC for accessing MAC services.This function binds MAC's
209 * SAP (identified by spId) with the service user's SAP
210 * (identified by suId).
212 * @param[in] pst Post structure
213 * @param[in] suId Service user SAP ID
214 * @param[in] spId Service provider ID
221 PUBLIC S16 KwLiRguBndReq
223 Pst *post, /* post structure */
224 SuId suId, /* Service User Id */
225 SpId spId /* Service Provider Id */
228 PUBLIC S16 KwLiRguBndReq(post, suId, spId)
229 Pst *post; /* post structure */
230 SuId suId; /* Service User Id */
231 SpId spId; /* Service Provider Id */
236 /* jump to specific primitive depending on configured selector */
237 (*kwLiRguBndReqMt[post->selector])(post, suId, spId);
241 } /* end of KwLiRguBndReq */
248 * Handler for bind confirmation from MAC.
252 * This function handles the bind confirmation received
255 * @param[in] post - Post structure
256 * @param[in] suId - Service provider SAP ID
257 * @param[in] reason - Reason of confirmation
264 PUBLIC S16 KwLiRguUbndReq
271 PUBLIC S16 KwLiRguUbndReq(post, spId, reason)
279 /* jump to specific primitive depending on configured selector */
280 (*kwLiRguUbndReqMt[post->selector])(post, spId, reason);
284 } /* end of KwLiRguUbndReq */
291 * Handler for sending PDU(s) from RLC to MAC for dedicated logical channels.
295 * This function sends PDU(s) to MAC via one or more dedicated
296 * logical channels along with the Buffer Occupancy of these
299 * @param[in] post Post structure
300 * @param[in] spId Service Provider ID
301 * @param[in] datIndInfo Data Request Information
309 PUBLIC S16 RlcMacSendDlData
316 PUBLIC S16 RlcMacSendDlData(post, spId, dlData)
322 TRC3(RlcMacSendDlData)
323 #ifdef RLC_MAC_DAT_REQ_RBUF
324 post->event=EVTRGUDDATREQ;
325 if((kwLiRguDatReqRbuf(post, spId, datReq)) != ROK)
328 SPutStaticBuffer(post->region, post->pool,
329 (Data *) datReq, sizeof(RguDDatReqInfo), 0);
333 /* jump to specific primitive depending on configured selector */
334 (*rlcMacSendDlDataOpts[post->selector])(post, spId, dlData);
338 } /* end of KwLiRguDDatReq */
346 * Handler for reporting the Buffer Occupancy to MAC
347 * for logical channels.
351 * This function reports the Buffer Occupancy of one or more
352 * logical channels to MAC.
354 * @param[in] post Post structure
355 * @param[in] spId Service Provider ID
356 * @param[in] boSta BO Status Information
364 PUBLIC S16 RlcMacSendBOStatus
368 RlcMacBOStatus *boSta
371 PUBLIC S16 RlcMacSendBOStatus(post, spId, staRsp)
374 RlcMacBOStatus *boSta;
377 TRC3(RlcMacSendBOStatus)
378 #if defined(SPLIT_RLC_DL_TASK) && defined(RLC_MAC_STA_RSP_RBUF)
379 post->event= EVTRGUDSTARSP;
380 if((kwLiRguStaRspRbuf(post, spId, staRsp)) != ROK)
385 /* jump to specific primitive depending on configured selector */
386 (*rlcMacSendBOStatusOpts[post->selector])(post, spId, boSta);
390 } /* end of RlcMacSendBOStatus */
393 /* kw005.201 added support for L2 Measurement */
401 * Handler for sending ulThrpMeasReqInfo from RLC to MAC for UL ip throughput measurement.
405 * This function sends ulThrpMeasReqInfo from RLC to MAC whenver UL ip throughput
406 * measurement is ON for a single or multiple qci in a UE. This is an indication for MAC
407 * to start the T2/T1 time stamps for the coresponding LCHs in the UE.
409 * @param[in] post Post structure
410 * @param[in] spId Service Provider ID
411 * @param[in] ulThrpMeasReqInfo Ul ip measurement request info
419 PUBLIC S16 KwLiRguL2MUlThrpMeasReq
423 RguL2MUlThrpMeasReqInfo *l2mUlThrpMeasReq
426 PUBLIC S16 KwLiRguL2MUlThrpMeasReq(post, spId, l2mUlThrpMeasReq)
429 RguL2MUlThrpMeasReqInfo *l2mUlThrpMeasReq;
432 TRC3(KwLiRguL2MUlThrpMeasReq)
434 /* jump to specific primitive depending on configured selector */
435 (*kwLiRguL2MUlThrpMeasReqMt[post->selector])(post, spId, l2mUlThrpMeasReq);
439 } /* end of KwLiRguL2MUlThrpMeasReq */
441 #endif /* LTE_RLC_R9 */
442 #endif /* LTE_L2_MEAS */
445 #ifdef MAC_RLC_UL_RBUF
446 PUBLIC S16 kwUlBatchProc ARGS ((Void));
447 EXTERN Void kwUtlFreeUlRBuf ARGS((void));
450 PUBLIC S16 kwUlBatchProc
455 PUBLIC S16 kwUlBatchProc()
459 /* Read from Ring Buffer and process PDCP packets */
460 RguDDatIndInfo *datInd;
461 Void *elmIndx = NULLP;
462 PRIVATE Pst rlcUlRbfuPst={1,1,ENTKW,0,ENTRG,0,PRIOR0,RTESPEC,EVTRLCULDAT,0,0,0,0};
463 /* Read from Ring Buffer and process PDCP packets */
466 RguDedDatInd1 *rguDatInd = NULLP;
467 U8 rngBufDeqIndx = 0;
469 elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
470 while(NULLP != elmIndx)
472 rguDatInd = (RguDedDatInd1 *)elmIndx;
473 datInd = (RguDDatIndInfo*) rguDatInd->msg;
474 SsRngInfoTbl[SS_RNG_BUF_ULMAC_TO_ULRLC].nPktProc++;;//Number of pkt processed in tti
477 KwLiRguDDatInd(&rlcUlRbfuPst, 0, datInd);
481 RLOG0(L_ERROR,"Received NULL buffer");
483 rguDatInd->msg=NULLP;
484 SRngIncrRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
490 //if(rngBufDeqIndx >= SS_RNG_MAX_ULMAC_TO_ULRLC_DQ_CNT)
493 if((elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC)) == NULLP)
497 elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
498 while(NULLP != elmIndx)
500 datInd = (RguDDatIndInfo *)elmIndx;
501 KwLiRguDDatInd(&rlcUlRbfuPst, 0, datInd);
505 SRngIncrRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
507 if((elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC)) == NULLP)
518 * Handler to clear Ring buffer from UL RLC
521 * This function clears all the ring buffer content from UL RLC
529 PUBLIC Void kwUtlFreeUlRBuf(void)
531 PUBLIC Void kwUtlFreeUlRBuf()
534 RguDDatIndInfo *datInd;
539 TRC2(kwUtlFreeUlRBuf)
540 /* Free SS_RNG_BUF_ULMAC_TO_ULRLC */
541 while((SDeqSRngBuf (SS_RNG_BUF_ULMAC_TO_ULRLC, &elem) == ROK))
543 datInd = (RguDDatIndInfo *)elem;
544 for(numLch = 0; numLch< datInd->numLch; numLch++)
546 for(numPdu = 0; numPdu < datInd->lchData[numLch].pdu.numPdu; numPdu++)
548 if(datInd->lchData[numLch].pdu.mBuf[numPdu])
550 KW_FREE_BUF_WC(datInd->lchData[numLch].pdu.mBuf[numPdu]);
554 KW_PST_FREE(0, 0, datInd, sizeof(RguDDatIndInfo));
558 #ifdef RLC_MAC_STA_RSP_RBUF
560 PUBLIC S16 kwLiRguStaRspRbuf
567 PUBLIC S16 kwLiRguStaRspRbuf(post, spId, staRsp)
577 RguDStaRspInfo *staRspInfo = NULL;
578 elem = SRngGetWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC);
581 staRspInfo = (RguDStaRspInfo *)elem;
582 cmMemcpy((U8 *)staRspInfo, (U8 *)staRsp, sizeof(RguDStaRspInfo));
583 staRspInfo->post = *post;
584 SRngIncrWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC);
585 SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC].pktRate++;
589 RLOG0(L_ERROR,"RLC DL STA RSP RBUF is FULL!!! ");
590 SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC].pktDrop++;
594 } /* cmPkKwuDatReq */
597 #ifdef RLC_MAC_DAT_REQ_RBUF
599 PUBLIC S16 kwLiRguDatReqRbuf
606 PUBLIC S16 kwLiRguDatReqRbuf(post, spId, datReq)
615 RguInfoRingElem *datReqRing=NULLP;
616 elem = SRngGetWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ);
619 datReqRing = (RguInfoRingElem *) elem;
620 datReqRing->spId = spId;
621 datReqRing->event = post->event;
622 datReqRing->msg =datReq;
623 SRngIncrWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ);
624 SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ].pktRate++;
628 printf("RLC DL DAT REQ RBUF is FULL!!! \n");
629 SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ].pktDrop++;
633 } /* cmPkKwuDatReq */
639 #endif /* __cplusplus */
641 /********************************************************************30**
643 **********************************************************************/