Initial commit
[o-du/l2.git] / src / 5gnrrlc / kw_ptli.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
4 #                                                                              #
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                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
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 *******************************************************************************/
18
19 /********************************************************************20**
20   
21         Name:    LTE-RLC Layer - Lower Interface
22     
23         Type:    C file
24   
25         Desc:    C source code for the lower interface of LTE-RLC
26  
27         File:    kw_ptli.c
28   
29 *********************************************************************21*/
30 static const char* RLOG_MODULE_NAME="LIM";
31 static int RLOG_MODULE_ID=2048;
32 static int RLOG_FILE_ID=238;
33 /** @file kw_ptli.c 
34 @brief RLC Lower Interface
35 */
36
37 \f
38 /* header (.h) include files */
39 #include "envopt.h"        /* environment options */
40 #include "envdep.h"        /* environment dependent */
41 #include "envind.h"        /* environment independent */
42
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 */
55 #ifdef KW_PDCP
56 #include "cpj.h"           /* CPJ defines */
57 #include "pju.h"           /* PJU defines */
58 #include "lpj.h"           /* LPJ defines */
59 #endif
60 #include "kw_err.h"
61 #include "kw_env.h"        /* RLC environment options */
62 #include "kw.h"            /* RLC defines */
63
64 /* extern (.x) include files */
65 #include "gen.x"           /* general */
66 #include "ssi.x"           /* system services */
67
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 */
79 #ifdef KW_PDCP
80 #include "cpj.x"           /* CPJ defines */
81 #include "pju.x"           /* PJU defines */
82 #include "lpj.x"           /* LPJ defines */
83 #endif
84 #include "kw.x"
85 #include "ss_rbuf.h"
86 #include "ss_rbuf.x"
87
88 #ifndef LCKWLIRGU
89 #define PTKWRGU
90 #endif
91
92 #ifndef RG
93 #define PTKWRGU
94 #endif
95
96 #ifdef __cplusplus
97 EXTERN "C" {
98 #endif /* __cplusplus */
99
100
101
102 #ifdef RLC_MAC_DAT_REQ_RBUF
103 PUBLIC S16 kwLiRguDatReqRbuf(Pst *Post,SpId spId,Void *datReq);
104 #endif
105
106 #ifdef RLC_MAC_STA_RSP_RBUF
107 PUBLIC S16 kwLiRguStaRspRbuf(Pst *Post,SpId spId,Void  *staRsp);
108 #endif
109 #if defined(MAC_RLC_HARQ_STA_RBUF) && defined(LTE_L2_MEAS)
110 EXTERN S16 KwDlHarqStaBatchProc (Void);
111 #endif
112
113 \f
114 /*********************************************************************
115  *             Forward Declaration of RGU Porting Functions
116  ********************************************************************/
117 EXTERN S16 PtLiRguBndReq ARGS((
118 Pst         *post,
119 SuId        suId,
120 SpId        spId
121 ));
122
123 EXTERN S16 PtLiRguUbndReq ARGS ((
124 Pst         *post,
125 SpId        spId,
126 Reason      reason
127 ));
128
129 EXTERN S16 PtLiRguCDatReq ARGS ((
130 Pst               *post,
131 SpId              spId,
132 RguCDatReqInfo    *datReq
133 ));
134
135 EXTERN S16 PtLiRguDDatReq ARGS ((
136 Pst               *post,
137 SpId              spId,
138 RguDDatReqInfo    *datReq
139 ));
140
141 EXTERN S16 PtLiRguCStaRsp ARGS ((
142 Pst               *post,
143 SpId              spId,
144 RguCStaRspInfo    *staRsp
145 ));
146
147 EXTERN S16 PtLiRguDStaRsp ARGS ((
148 Pst               *post,
149 SpId              spId,
150 RguDStaRspInfo    *staRsp
151 ));
152 /* kw005.201 added support for L2 Measurement */
153 #ifdef LTE_L2_MEAS
154 #ifdef LTE_RLC_R9
155 EXTERN S16 PtLiRguL2mUlThrpMeasReq ARGS ((
156 Pst                      *post,
157 SpId                     spId,
158 RguL2MUlThrpMeasReqInfo  *l2mUlThrpMeasReq
159 ));
160 #endif /* LTE_RLC_R9 */
161 #endif /* LTE_L2_MEAS  */
162
163 \f
164 /*********************************************************************
165  *             Primitives for RGU interface 
166  ********************************************************************/
167
168 /* RGU Bind Request primitive */
169
170 PUBLIC RguBndReq kwLiRguBndReqMt[] =
171 {
172 #ifdef LCKWLIRGU
173    cmPkRguBndReq,            /* 0 - loosely coupled */
174 #else
175    PtLiRguBndReq,            /* 0 - loosely coupled, portable  */
176 #endif /* LCRGUIRGU */
177 #ifdef RG 
178    RgUiRguBndReq,            /* 1 - tightly coupled, MAC  */
179 #else
180    PtLiRguBndReq,            /* 1 - tightly coupled, portable */
181 #endif /* RG */
182 #ifdef LCKWLIRGU
183    cmPkRguBndReq,            /* 0 - loosely coupled */
184 #else
185    PtLiRguBndReq,            /* 0 - loosely coupled, portable  */
186 #endif /* LCRGUIRGU */
187 };
188
189 /* RGU Unbind Request primitive */
190
191 PUBLIC RguBndReq kwLiRguUbndReqMt[] =
192 {
193 #ifdef LCKWLIRGU
194    cmPkRguUbndReq,            /* 0 - loosely coupled */
195 #else
196    PtLiRguUbndReq,            /* 0 - loosely coupled, portable  */
197 #endif /* LCRGUIRGU */
198 #ifdef RG 
199    RgUiRguUbndReq,            /* 1 - tightly coupled, MAC  */
200 #else
201    PtLiRguUbndReq,            /* 1 - tightly coupled, portable */ /* RG */
202 #endif /* RG */
203 #ifdef LCKWLIRGU
204    cmPkRguUbndReq,            /* 0 - loosely coupled */
205 #else
206    PtLiRguUbndReq,            /* 0 - loosely coupled, portable  */
207 #endif /* LCRGUIRGU */
208 };
209
210 /* RGU Common Channel Data Request primitive */
211
212 PUBLIC RguCDatReq kwLiRguCDatReqMt[] =
213 {
214 #ifdef LCKWLIRGU
215    cmPkRguCDatReq,            /* 0 - loosely coupled */
216 #else
217    PtLiRguCDatReq,            /* 0 - loosely coupled, portable  */
218 #endif /* LCRGUIRGU */
219 #ifdef RG 
220    RgUiRguCDatReq,            /* 1 - tightly coupled, MAC  */
221 #else
222    PtLiRguCDatReq,            /* 1 - tightly coupled, portable */
223 #endif /* RG */
224 #ifdef LCKWLIRGU
225    cmPkRguCDatReq,            /* 0 - loosely coupled */
226 #else
227    PtLiRguCDatReq,            /* 0 - loosely coupled, portable  */
228 #endif /* LCRGUIRGU */
229 };
230
231 /* RGU Dedicated Channel Data Request primitive */
232
233 PUBLIC RguDDatReq kwLiRguDDatReqMt[] =
234 {
235 #ifdef LCKWLIRGU
236    cmPkRguDDatReq,            /* 0 - loosely coupled */
237 #else
238    PtLiRguDDatReq,            /* 0 - loosely coupled, portable  */
239 #endif /* LCRGUIRGU */
240 #ifdef RG 
241    RgUiRguDDatReq,            /* 1 - tightly coupled, MAC  */
242 #else
243    PtLiRguDDatReq,            /* 1 - tightly coupled, portable */
244 #endif /* RG */
245 #ifdef LCKWLIRGU
246    cmPkRguDDatReq,            /* 0 - loosely coupled */
247 #else
248    PtLiRguDDatReq,            /* 0 - loosely coupled, portable  */
249 #endif /* LCRGUIRGU */
250 };
251
252 /* RGU Common Channel Status Response primitive */
253
254 PUBLIC RguCStaRsp kwLiRguCStaRspMt[] =
255 {
256 #ifdef LCKWLIRGU
257    cmPkRguCStaRsp,            /* 0 - loosely coupled */
258 #else
259    PtLiRguCStaRsp,            /* 0 - loosely coupled, portable  */
260 #endif /* LCRGUIRGU */
261 #ifdef RG 
262    RgUiRguCStaRsp,            /* 1 - tightly coupled, MAC  */
263 #else
264    PtLiRguCStaRsp,            /* 1 - tightly coupled, portable */
265 #endif /* RG */
266 #ifdef LCKWLIRGU
267    cmPkRguCStaRsp,            /* 0 - loosely coupled */
268 #else
269    PtLiRguCStaRsp,            /* 0 - loosely coupled, portable  */
270 #endif /* LCRGUIRGU */
271 };
272
273 /* RGU Dedicated Channel Status Response primitive */
274
275 PUBLIC RguDStaRsp kwLiRguDStaRspMt[] =
276 {
277 #ifdef LCKWLIRGU
278    cmPkRguDStaRsp,            /* 0 - loosely coupled */
279 #else
280    PtLiRguDStaRsp,            /* 0 - loosely coupled, portable  */
281 #endif /* LCRGUIRGU */
282 #ifdef RG 
283    RgUiRguDStaRsp,            /* 1 - tightly coupled, MAC  */
284 #else
285    PtLiRguDStaRsp,            /* 1 - tightly coupled, portable */
286 #endif /* RG */
287 #ifdef LCKWLIRGU
288    cmPkRguDStaRsp,            /* 0 - LWLC loosely coupled */
289 #else
290    PtLiRguDStaRsp,            /* 0 - LWLC loosely coupled, portable  */
291 #endif /* LCRGUIRGU */
292 };
293
294 /* kw005.201 added support for L2 Measurement */
295 #ifdef LTE_L2_MEAS
296 #ifdef LTE_RLC_R9
297 /* RGU L2 Measurement Ul Ip Throughput Measurement Request primitive */
298
299 PUBLIC RguL2MUlThrpMeasReq kwLiRguL2MUlThrpMeasReqMt[] =
300 {
301 #ifdef LCKWLIRGU
302    cmPkRguL2MUlThrpMeasReq,            /* 0 - loosely coupled */
303 #else
304    PtLiRguL2mUlThrpMeasReq,            /* 0 - loosely coupled, portable  */
305 #endif /* LCRGUIRGU */
306 #ifdef RG 
307    RgUiRguL2MUlThrpMeasReq,            /* 1 - tightly coupled, MAC  */
308 #else
309    PtLiRguL2mUlThrpMeasReq,            /* 1 - tightly coupled, portable */
310 #endif /* RG */
311 };
312 #endif /* LTE_RLC_R9 */
313 #endif /*  LTE_L2_MEAS */
314 \f
315 /****************************************************************************
316  *                         RGU Interface Mt functions
317  ***************************************************************************/
318 /**
319  *
320  * @brief 
321  *
322  *        Handler for RGU SAP bind Request.
323  *
324  * @b Description:
325  *
326  *        This function is used by RLC to request for binding to 
327  *        MAC for accessing MAC services.This function binds MAC's 
328  *        SAP (identified by spId) with the service user's SAP 
329  *        (identified by suId).
330  *
331  *  @param[in] pst   Post structure  
332  *  @param[in] suId  Service user SAP ID 
333  *  @param[in] spId  Service provider ID
334  *
335  *  @return  S16
336  *      -# ROK 
337  */
338
339 #ifdef ANSI
340 PUBLIC S16 KwLiRguBndReq
341 (
342 Pst  *post,                       /* post structure */
343 SuId suId,                      /* Service User Id */
344 SpId spId                       /* Service Provider Id */
345 )
346 #else
347 PUBLIC S16 KwLiRguBndReq(post, suId, spId)
348 Pst  *post;                       /* post structure */
349 SuId suId;                      /* Service User Id */
350 SpId spId;                      /* Service Provider Id */
351 #endif
352 {
353    TRC3(KwLiRguBndReq)
354
355    /* jump to specific primitive depending on configured selector */
356    (*kwLiRguBndReqMt[post->selector])(post, suId, spId);
357
358    RETVALUE(ROK);
359
360 } /* end of KwLiRguBndReq */
361
362 \f
363 /**
364  *
365  * @brief 
366  *
367  *        Handler for bind confirmation from MAC.
368  *
369  * @b Description:
370  *
371  *        This function handles the bind confirmation received
372  *        from MAC. 
373  *
374  *  @param[in] post     - Post structure  
375  *  @param[in] suId    - Service provider SAP ID 
376  *  @param[in] reason  - Reason of confirmation
377  *
378  *  @return  S16
379  *      -# ROK 
380  */
381
382 #ifdef ANSI
383 PUBLIC S16 KwLiRguUbndReq
384 (
385 Pst         *post,
386 SpId        spId,
387 Reason      reason
388 )
389 #else
390 PUBLIC S16 KwLiRguUbndReq(post, spId, reason)
391 Pst         *post;
392 SpId        spId;
393 Reason      reason;
394 #endif
395 {
396    TRC3(KwLiRguUbndReq)
397
398    /* jump to specific primitive depending on configured selector */
399    (*kwLiRguUbndReqMt[post->selector])(post, spId, reason);
400
401    RETVALUE(ROK);
402
403 } /* end of KwLiRguUbndReq */
404
405 \f  
406 /**
407  *
408  * @brief 
409  *
410  *        Handler for sending the PDU from RLC to MAC for common logical channels. 
411  *
412  * @b Description:
413  *
414  *        This function sends a PDU of a common logical channel to MAC
415  *        along with timing info for BCCH and PCCH and RNTI for CCCH. 
416  *
417  *  @param[in] post         Post structure  
418  *  @param[in] spId        Service Provider ID
419  *  @param[in] datIndInfo  Data Request Information 
420  *
421  *  @return  S16
422  *      -# ROK 
423  *      -# RFAILED
424  *
425  */
426 #ifdef ANSI
427 PUBLIC S16 KwLiRguCDatReq
428 (
429 Pst               *post,
430 SpId              spId,
431 RguCDatReqInfo    *datReq
432 )
433 #else
434 PUBLIC S16 KwLiRguCDatReq(post, spId, datReq)
435 Pst               *post;
436 SpId              spId;
437 RguCDatReqInfo    *datReq;
438 #endif
439 {
440    TRC3(KwLiRguCDatReq)
441 //    printf("CSHP: KwLiRguCDatReq  ");
442 #ifdef RLC_MAC_DAT_REQ_RBUF
443     //printf("to RING  \n");
444        post->event=EVTRGUCDATREQ;
445       if((kwLiRguDatReqRbuf(post, spId, datReq)) != ROK)
446       {
447
448             SPutStaticBuffer(post->region, post->pool,                      
449                       (Data *) datReq, sizeof(RguCDatReqInfo), 0);             
450          RETVALUE(RFAILED);
451       }
452 #else
453
454    // printf("to Pack Sel is %d  \n",post->selector);
455    /* jump to specific primitive depending on configured selector */
456    (*kwLiRguCDatReqMt[post->selector])(post, spId, datReq);
457 #endif
458    RETVALUE(ROK);
459
460 } /* end of KwLiRguCDatReq */
461
462 \f  
463 /**
464  *
465  * @brief 
466  *
467  *        Handler for sending PDU(s) from RLC to MAC for dedicated logical channels. 
468  *
469  * @b Description:
470  *
471  *        This function sends PDU(s) to MAC via one or more dedicated 
472  *        logical channels along with the Buffer Occupancy of these
473  *        channels.
474  *
475  *  @param[in] post         Post structure  
476  *  @param[in] spId        Service Provider ID
477  *  @param[in] datIndInfo  Data Request Information 
478  *
479  *  @return  S16
480  *      -# ROK 
481  *      -# RFAILED
482  *
483  */
484 #ifdef ANSI
485 PUBLIC S16 KwLiRguDDatReq
486 (
487 Pst               *post,
488 SpId              spId,
489 RguDDatReqInfo    *datReq
490 )
491 #else
492 PUBLIC S16 KwLiRguDDatReq(post, spId, datReq)
493 Pst               *post;
494 SpId              spId;
495 RguDDatReqInfo    *datReq;
496 #endif
497 {
498    TRC3(KwLiRguDDatReq)
499 #ifdef RLC_MAC_DAT_REQ_RBUF
500         post->event=EVTRGUDDATREQ;
501       if((kwLiRguDatReqRbuf(post, spId, datReq)) != ROK)
502       {
503
504       SPutStaticBuffer(post->region, post->pool,                      
505                       (Data *) datReq, sizeof(RguDDatReqInfo), 0);             
506          RETVALUE(RFAILED);
507       }
508 #else
509    /* jump to specific primitive depending on configured selector */
510    (*kwLiRguDDatReqMt[post->selector])(post, spId, datReq);
511 #endif 
512    RETVALUE(ROK);
513
514 } /* end of KwLiRguDDatReq */
515
516 \f  
517 /**
518  *
519  * @brief  
520  *
521  *        Handler for reporting the Buffer Occupancy to MAC 
522  *     for common logical channels.
523  *
524  * @b Description:
525  *
526  *        This function reports the Buffer Occupancy of a common logical
527  *        channel to MAC along with timing information for BCCH and PCCH
528  *        and RNTI for CCCH. 
529  *
530  *  @param[in] post         Post structure  
531  *  @param[in] spId        Service Provider ID
532  *  @param[in] staRspInfo  Status Response Information 
533  *
534  *  @return  S16
535  *      -# ROK 
536  *      -# RFAILED
537  *
538  */
539 #ifdef ANSI
540 PUBLIC S16 KwLiRguCStaRsp
541 (
542 Pst               *post,
543 SpId              spId,
544 RguCStaRspInfo    *staRsp
545 )
546 #else
547 PUBLIC S16 KwLiRguCStaRsp(post, spId, staRsp)
548 Pst               *post;
549 SpId              spId;
550 RguCStaRspInfo    *staRsp;
551 #endif
552 {
553    TRC3(KwLiRguCStaRsp)
554
555    /* jump to specific primitive depending on configured selector */
556    (*kwLiRguCStaRspMt[post->selector])(post, spId, staRsp);
557    RETVALUE(ROK);
558
559 } /* end of KwLiRguCStaRsp */
560
561 \f  
562 /**
563  *
564  * @brief  
565  *
566  *        Handler for reporting the Buffer Occupancy to MAC 
567  *        for dedicated logical channels.
568  *
569  * @b Description:
570  *
571  *        This function reports the Buffer Occupancy of one or more
572  *        dedicated logical channels to MAC. 
573  *
574  *  @param[in] post         Post structure  
575  *  @param[in] spId        Service Provider ID
576  *  @param[in] staRspInfo  Status Response Information 
577  *
578  *  @return  S16
579  *      -# ROK 
580  *      -# RFAILED
581  *
582  */
583 #ifdef ANSI
584 PUBLIC S16 KwLiRguDStaRsp
585 (
586 Pst               *post,
587 SpId              spId,
588 RguDStaRspInfo    *staRsp
589 )
590 #else
591 PUBLIC S16 KwLiRguDStaRsp(post, spId, staRsp)
592 Pst               *post;
593 SpId              spId;
594 RguDStaRspInfo    *staRsp;
595 #endif
596 {
597    TRC3(KwLiRguDStaRsp)
598 #if defined(SPLIT_RLC_DL_TASK) && defined(RLC_MAC_STA_RSP_RBUF)
599        post->event= EVTRGUDSTARSP;
600       if((kwLiRguStaRspRbuf(post, spId, staRsp)) != ROK)
601       {
602          RETVALUE(RFAILED);
603       }
604 #else
605      /* jump to specific primitive depending on configured selector */
606      (*kwLiRguDStaRspMt[post->selector])(post, spId, staRsp);
607 #endif 
608    RETVALUE(ROK);
609
610 } /* end of KwLiRguDStaRsp */
611
612
613 /* kw005.201 added support for L2 Measurement */
614 #ifdef LTE_L2_MEAS
615 #ifdef LTE_RLC_R9
616 \f  
617 /**
618  *
619  * @brief 
620  *
621  *        Handler for sending ulThrpMeasReqInfo from RLC to MAC for UL ip throughput measurement. 
622  *
623  * @b Description:
624  *
625  *        This function sends ulThrpMeasReqInfo from RLC to MAC whenver UL ip throughput
626  * measurement is ON for a single or multiple qci in a UE. This is an indication for MAC
627  * to start the T2/T1 time stamps for the coresponding LCHs in the UE.
628  *
629  *  @param[in] post                    Post structure  
630  *  @param[in] spId                   Service Provider ID
631  *  @param[in] ulThrpMeasReqInfo      Ul ip measurement request info
632  *
633  *  @return  S16
634  *      -# ROK 
635  *      -# RFAILED
636  *
637  */
638 #ifdef ANSI
639 PUBLIC S16 KwLiRguL2MUlThrpMeasReq
640 (
641 Pst                     *post,
642 SpId                    spId,
643 RguL2MUlThrpMeasReqInfo *l2mUlThrpMeasReq
644 )
645 #else
646 PUBLIC S16 KwLiRguL2MUlThrpMeasReq(post, spId, l2mUlThrpMeasReq)
647 Pst                     *post;
648 SpId                    spId;
649 RguL2MUlThrpMeasReqInfo *l2mUlThrpMeasReq;
650 #endif
651 {
652    TRC3(KwLiRguL2MUlThrpMeasReq)
653
654    /* jump to specific primitive depending on configured selector */
655    (*kwLiRguL2MUlThrpMeasReqMt[post->selector])(post, spId, l2mUlThrpMeasReq);
656
657    RETVALUE(ROK);
658
659 } /* end of KwLiRguL2MUlThrpMeasReq */
660
661 #endif /* LTE_RLC_R9 */
662 #endif /* LTE_L2_MEAS */
663
664
665
666 /****************************************************************************
667  *                         Porting Functions
668  ***************************************************************************/
669 \f
670 /**
671  *
672  * @brief 
673  *
674  *        PtLiRguBndReq - portable bind request
675  *
676  *  @param[in] post   - Post structure  
677  *  @param[in] suId  - Service user SAP ID 
678  *  @param[in] spId  - Service provider ID
679  *
680  *  @return  S16
681  *      -# ROK 
682  */
683
684 #ifdef ANSI
685 PUBLIC S16 PtLiRguBndReq
686 (
687 Pst         *post,
688 SuId        suId,
689 SpId        spId
690 )
691 #else
692 PUBLIC S16 PtLiRguBndReq(post, suId, spId)
693 Pst         *post;
694 SuId        suId;
695 SpId        spId;
696 #endif /* ANSI */
697 {
698 #if (ERRCLASS & ERRCLS_DEBUG)
699    KwCb   *tKwCb;
700 #endif
701
702    TRC3(PtLiRguBndReq)
703 #if (ERRCLASS & ERRCLS_DEBUG)
704    tKwCb = KW_GET_KWCB(post->srcInst);
705    RLOG0(L_ERROR,"Improper selector value");
706 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
707    RLOG0(L_ERROR,"Improper selector value");
708    UNUSED(post);
709    UNUSED(suId);
710    UNUSED(spId);
711
712    RETVALUE(ROK);
713 } /* end of PtLiRguBndReq() */
714
715 \f  
716 /**
717  *
718  * @brief 
719  *
720  *        PtLiRguUbndReq - portable bind request
721  *
722  *  @param[in] post    -  Post structure  
723  *  @param[in] spId   -  Service user SAP ID 
724  *  @param[in] reason -  Service provider ID
725  *
726  *  @return  S16
727  *      -# ROK 
728  */
729
730 #ifdef ANSI
731 PUBLIC S16 PtLiRguUbndReq
732 (
733 Pst         *post,
734 SpId        spId,
735 Reason      reason
736 )
737 #else
738 PUBLIC S16 PtLiRguUbndReq(post, spId, reason)
739 Pst         *post;
740 SpId        spId;
741 Reason      reason;
742 #endif /* ANSI */
743 {
744 #if (ERRCLASS & ERRCLS_DEBUG)
745    KwCb   *tKwCb;
746 #endif
747
748    TRC3(PtLiRguUbndReq)
749 #if (ERRCLASS & ERRCLS_DEBUG)
750    tKwCb = KW_GET_KWCB(post->srcInst);
751    RLOG0(L_ERROR,"Improper selector value");
752 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
753    UNUSED(post);
754    UNUSED(spId);
755    UNUSED(reason);
756
757    RETVALUE(ROK);
758 } /* end of PtLiRguUbndReq() */
759
760 \f  
761 /**
762  *
763  * @brief 
764  *
765  *        PtLiRguCDatReq - portable common channel data request
766  *
767  *  @param[in] post    -  Post structure  
768  *  @param[in] spId   -  Service user SAP ID 
769  *  @param[in] datReq -  Service provider ID
770  *
771  *  @return  S16
772  *      -# ROK 
773  */
774
775 #ifdef ANSI
776 PUBLIC S16 PtLiRguCDatReq
777 (
778 Pst               *post,
779 SpId              spId,
780 RguCDatReqInfo    *datReq
781 )
782 #else
783 PUBLIC S16 PtLiRguCDatReq(post, spId, datReq)
784 Pst               *post;
785 SpId              spId;
786 RguCDatReqInfo    *datReq;
787 #endif /* ANSI */
788 {
789 #if (ERRCLASS & ERRCLS_DEBUG)
790    KwCb   *tKwCb;
791 #endif
792
793    TRC3(PtLiRguCDatReq)
794 #if (ERRCLASS & ERRCLS_DEBUG)
795    tKwCb = KW_GET_KWCB(post->srcInst);
796    RLOG0(L_ERROR,"Improper selector value");
797 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
798    UNUSED(post);
799    UNUSED(spId);
800    UNUSED(datReq);
801
802    RETVALUE(ROK);
803 } /* end of PtLiRguCDatReq() */
804
805 \f  
806 /**
807  *
808  * @brief 
809  *
810  *        PtLiRguDDatReq - portable dedicated channel data request
811  *
812  *  @param[in] post    -  Post structure  
813  *  @param[in] spId   -  Service user SAP ID 
814  *  @param[in] datReq -  Service provider ID
815  *
816  *  @return  S16
817  *      -# ROK 
818  */
819
820 #ifdef ANSI
821 PUBLIC S16 PtLiRguDDatReq
822 (
823 Pst               *post,
824 SpId              spId,
825 RguDDatReqInfo    *datReq
826 )
827 #else
828 PUBLIC S16 PtLiRguDDatReq( post, spId, datReq)
829 Pst               *post;
830 SpId              spId;
831 RguDDatReqInfo    *datReq;
832 #endif /* ANSI */
833 {
834 #if (ERRCLASS & ERRCLS_DEBUG)
835    KwCb   *tKwCb;
836 #endif
837
838    TRC3(PtLiRguDDatReq)
839 #if (ERRCLASS & ERRCLS_DEBUG)
840    tKwCb = KW_GET_KWCB(post->srcInst);
841    RLOG0(L_ERROR,"Improper selector value");
842 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
843    UNUSED(post);
844    UNUSED(spId);
845    UNUSED(datReq);
846
847    RETVALUE(ROK);
848 } /* end of PtLiRguDDatReq() */
849
850 \f  
851 /**
852  *
853  * @brief 
854  *
855  *        PtLiRguCStaRsp - portable common channel Status Response
856  *
857  *  @param[in] post    -  Post structure  
858  *  @param[in] spId   -  Service user SAP ID 
859  *  @param[in] staRsp -  Service provider ID
860  *
861  *  @return  S16
862  *      -# ROK 
863  */
864
865 #ifdef ANSI
866 PUBLIC S16 PtLiRguCStaRsp
867 (
868 Pst               *post,
869 SpId              spId,
870 RguCStaRspInfo    *staRsp
871 )
872 #else
873 PUBLIC S16 PtLiRguCStaRsp(post, spId, staRsp)
874 Pst               *post;
875 SpId              spId;
876 RguCStaRspInfo    *staRsp;
877 #endif /* ANSI */
878 {
879 #if (ERRCLASS & ERRCLS_DEBUG)
880    KwCb   *tKwCb;
881 #endif
882
883    TRC3(PtLiRguCStaRsp)
884 #if (ERRCLASS & ERRCLS_DEBUG)
885    tKwCb = KW_GET_KWCB(post->srcInst);
886    RLOG0(L_ERROR,"Improper selector value");
887 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
888    UNUSED(post);
889    UNUSED(spId);
890    UNUSED(staRsp);
891
892    RETVALUE(ROK);
893 } /* end of PtLiRguCStaRsp() */
894
895 \f  
896 /**
897  *
898  * @brief 
899  *
900  *        PtLiRguDStaRsp - portable dedicated channel Status Response
901  *
902  *  @param[in] post    -  Post structure  
903  *  @param[in] spId   -  Service user SAP ID 
904  *  @param[in] staRsp -  Service provider ID
905  *
906  *  @return  S16
907  *      -# ROK 
908  */
909
910 #ifdef ANSI
911 PUBLIC S16 PtLiRguDStaRsp
912 (
913 Pst               *post,
914 SpId              spId,
915 RguDStaRspInfo    *staRsp
916 )
917 #else
918 PUBLIC S16 PtLiRguDStaRsp(post, spId, staRsp)
919 Pst               *post;
920 SpId              spId;
921 RguDStaRspInfo    *staRsp;
922 #endif /* ANSI */
923 {
924 #if (ERRCLASS & ERRCLS_DEBUG)
925    KwCb   *tKwCb;
926 #endif
927
928    TRC3(PtLiRguDStaRsp)
929 #if (ERRCLASS & ERRCLS_DEBUG)
930    tKwCb = KW_GET_KWCB(post->srcInst);
931    RLOG0(L_ERROR,"Improper selector value");
932 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
933    UNUSED(post);
934    UNUSED(spId);
935    UNUSED(staRsp);
936
937    RETVALUE(ROK);
938 } /* end of PtLiRguDStaRsp() */
939
940 /* kw005.201 added support for L2 Measurement */
941 #ifdef LTE_L2_MEAS
942 #ifdef LTE_RLC_R9
943 \f  
944 /**
945  *
946  * @brief 
947  *
948  *      PtLiRguL2mUlThrpMeasReq - portable L2 Measurement Ul Thoughput Measurement Request
949  *
950  *  @param[in] post    -  Post structure  
951  *  @param[in] spId   -  Service user SAP ID 
952  *  @param[in] l2mUlThrpMeasReq -  Ul Throughput Measurement Request
953  *
954  *  @return  S16
955  *      -# ROK 
956  */
957
958 #ifdef ANSI
959 PUBLIC S16 PtLiRguL2mUlThrpMeasReq
960 (
961 Pst                     *post,
962 SpId                    spId,
963 RguL2MUlThrpMeasReqInfo *l2mUlThrpMeasReq
964 )
965 #else
966 PUBLIC S16 PtLiRguL2mUlThrpMeasReq(post, spId, l2mUlThrpMeasReq)
967 Pst                     *post,
968 Pst                      *post;
969 SpId                     spId;
970 RguL2MUlThrpMeasReqInfo  *l2mUlThrpMeasReq;
971 #endif /* ANSI */
972 {
973 #if (ERRCLASS & ERRCLS_DEBUG)
974    KwCb   *tKwCb;
975 #endif
976
977    TRC3(PtLiRguL2mUlThrpMeasReq)
978 #if (ERRCLASS & ERRCLS_DEBUG)
979    tKwCb = KW_GET_KWCB(post->srcInst);
980    RLOG0(L_ERROR,"Improper selector value");
981 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
982    UNUSED(post);
983    UNUSED(spId);
984    UNUSED(l2mUlThrpMeasReq);
985
986    RETVALUE(ROK);
987 } /* end of PtLiRguL2mUlThrpMeasReq() */
988
989 #endif /* LTE_RLC_R9 */
990 #endif /* LTE_L2_MEAS */
991
992 #ifdef MAC_RLC_UL_RBUF
993 PUBLIC S16 kwUlBatchProc ARGS ((Void));
994 EXTERN Void kwUtlFreeUlRBuf ARGS((void));
995
996 #ifdef ANSI
997 PUBLIC S16 kwUlBatchProc
998 (
999 Void
1000 )
1001 #else
1002 PUBLIC S16 kwUlBatchProc()
1003 Void;
1004 #endif
1005 {
1006 /* Read from Ring Buffer and process PDCP packets */
1007    RguDDatIndInfo   *datInd;
1008    Void *elmIndx = NULLP;
1009    PRIVATE Pst rlcUlRbfuPst={1,1,ENTKW,0,ENTRG,0,PRIOR0,RTESPEC,EVTRGUDDATIND,0,0,0,0};
1010 /* Read from Ring Buffer and process PDCP packets */
1011
1012 #ifndef SS_RBUF
1013    RguDedDatInd1 *rguDatInd = NULLP;
1014    U8 rngBufDeqIndx = 0;
1015
1016    elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
1017    while(NULLP != elmIndx)
1018    {
1019       rguDatInd = (RguDedDatInd1 *)elmIndx;
1020       datInd = (RguDDatIndInfo*) rguDatInd->msg; 
1021       SsRngInfoTbl[SS_RNG_BUF_ULMAC_TO_ULRLC].nPktProc++;;//Number of pkt processed in tti
1022       if(datInd != NULLP)
1023       {
1024          KwLiRguDDatInd(&rlcUlRbfuPst, 0, datInd);
1025       }
1026       else
1027       {
1028          RLOG0(L_ERROR,"Received NULL buffer");
1029       }
1030       rguDatInd->msg=NULLP;
1031       SRngIncrRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
1032       elmIndx = NULLP;
1033       rguDatInd = NULLP;
1034
1035       rngBufDeqIndx++;
1036
1037       //if(rngBufDeqIndx >= SS_RNG_MAX_ULMAC_TO_ULRLC_DQ_CNT)
1038        // break;
1039
1040       if((elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC)) == NULLP)
1041       break;
1042    }
1043 #else
1044    elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
1045    while(NULLP != elmIndx)
1046    {
1047       datInd = (RguDDatIndInfo *)elmIndx;
1048       KwLiRguDDatInd(&rlcUlRbfuPst, 0, datInd);
1049
1050       elmIndx = NULLP;
1051       datInd = NULLP;
1052       SRngIncrRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC);
1053
1054       if((elmIndx = SRngGetRIndx(SS_RNG_BUF_ULMAC_TO_ULRLC)) == NULLP)
1055         break;
1056    }
1057 #endif
1058    RETVALUE(ROK);
1059
1060 }
1061
1062 /**
1063  *
1064  * @brief 
1065  *        Handler to clear Ring buffer from UL RLC
1066  *
1067  * @details
1068  *         This function clears all the ring buffer content from  UL RLC
1069  *
1070  * @return  S16
1071  *      -# ROK 
1072  *      -# RFAILED
1073  *
1074  */
1075 #ifdef ANSI
1076 PUBLIC Void kwUtlFreeUlRBuf(void)
1077 #else
1078 PUBLIC Void kwUtlFreeUlRBuf()  
1079 #endif
1080 {
1081    RguDDatIndInfo *datInd;
1082    PTR            elem;
1083    U8             numLch;
1084    U8             numPdu;
1085
1086    TRC2(kwUtlFreeUlRBuf)
1087    /* Free SS_RNG_BUF_ULMAC_TO_ULRLC  */
1088    while((SDeqSRngBuf (SS_RNG_BUF_ULMAC_TO_ULRLC, &elem) == ROK))
1089    {
1090       datInd = (RguDDatIndInfo *)elem; 
1091       for(numLch = 0; numLch< datInd->numLch; numLch++)
1092       {
1093          for(numPdu = 0; numPdu < datInd->lchData[numLch].pdu.numPdu; numPdu++)
1094          {
1095             if(datInd->lchData[numLch].pdu.mBuf[numPdu])
1096             {
1097                KW_FREE_BUF_WC(datInd->lchData[numLch].pdu.mBuf[numPdu]);
1098             }
1099          }
1100       }
1101       KW_PST_FREE(0, 0, datInd, sizeof(RguDDatIndInfo)); 
1102    }
1103 }
1104 #endif
1105 #ifdef RLC_MAC_STA_RSP_RBUF
1106 #ifdef ANSI
1107 PUBLIC S16 kwLiRguStaRspRbuf
1108 (
1109 Pst               *post,
1110 SpId              spId,
1111 Void             *staRsp
1112 )
1113 #else
1114 PUBLIC S16 kwLiRguStaRspRbuf(post, spId, staRsp)
1115 Pst               *post;
1116 SpId              spId;
1117 Void              *staRsp;
1118 #endif /* ANSI */
1119 {
1120    S16 ret1 = ROK;
1121    
1122    Void *elem = NULLP;
1123
1124    RguDStaRspInfo  *staRspInfo = NULL;
1125    elem = SRngGetWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC);
1126    if (NULLP != elem)
1127    {
1128       staRspInfo = (RguDStaRspInfo *)elem;
1129       cmMemcpy((U8 *)staRspInfo, (U8 *)staRsp, sizeof(RguDStaRspInfo)); 
1130       staRspInfo->post = *post;
1131       SRngIncrWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC);
1132       SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC].pktRate++;
1133    }   
1134    else
1135    {
1136       RLOG0(L_ERROR,"RLC DL STA RSP RBUF is FULL!!! ");
1137       SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC].pktDrop++;
1138       ret1 = RFAILED;
1139    }
1140    RETVALUE(ret1);
1141 } /* cmPkKwuDatReq */
1142
1143 #endif
1144 #ifdef RLC_MAC_DAT_REQ_RBUF
1145 #ifdef ANSI
1146 PUBLIC S16 kwLiRguDatReqRbuf
1147 (
1148 Pst               *post,
1149 SpId              spId,
1150 Void             *datReq
1151 )
1152 #else
1153 PUBLIC S16 kwLiRguDatReqRbuf(post, spId, datReq)
1154 Pst               *post;
1155 SpId              spId;
1156 Void             *datReq;
1157 #endif /* ANSI */
1158 {
1159    S16 ret1 = ROK;
1160    
1161    Void *elem = NULLP;
1162    RguInfoRingElem *datReqRing=NULLP;
1163    elem = SRngGetWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ);
1164    if (NULLP != elem)
1165    {
1166       datReqRing = (RguInfoRingElem *) elem;
1167       datReqRing->spId = spId;
1168       datReqRing->event = post->event;
1169       datReqRing->msg =datReq;
1170       SRngIncrWIndx(SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ);
1171       SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ].pktRate++;
1172    }   
1173    else
1174    {
1175       printf("RLC DL DAT REQ RBUF is FULL!!! \n");
1176       SsRngInfoTbl[SS_RNG_BUF_DLRLC_TO_DLMAC_DAT_REQ].pktDrop++;
1177       ret1 = RFAILED;
1178    }
1179    RETVALUE(ret1);
1180 } /* cmPkKwuDatReq */
1181
1182 #endif 
1183
1184 #ifdef __cplusplus
1185 }
1186 #endif /* __cplusplus */
1187 \f  
1188 /********************************************************************30**
1189          End of file
1190 **********************************************************************/