Committing in PDCP code
[o-du/l2.git] / src / 5gnrpdcp / pj_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:    RLC service user (PDCP) lower interface
22     
23         Type:    C file
24   
25         Desc:    This file Contains the RLC service user lower interface
26                   primitive implementain
27  
28         File:    pj_ptli.c
29   
30 *********************************************************************21*/
31 \f
32 /* header (.h) include files */
33 #include "envopt.h"        /* environment options */
34 #include "envdep.h"        /* environment dependent */
35 #include "envind.h"        /* environment independent */
36
37 #include "gen.h"           /* general */
38 #include "ssi.h"           /* system services */
39 #include "cm5.h"           /* common timer defines */
40 #include "cm_tkns.h"       /* common tokens defines */
41 #include "cm_mblk.h"       /* common memory allocation library defines */
42 #include "cm_llist.h"      /* common link list  defines  */
43 #include "cm_hash.h"       /* common hash list  defines */
44 #include "cm_lte.h"        /* common LTE defines */
45 #include "kwu.h"           /* KWU defines */
46 #include "pj_err.h"        
47
48 /* extern (.x) include files */
49 #include "gen.x"           /* general */
50 #include "ssi.x"           /* system services */
51 //#if defined(PDCP_RLC_DL_RBUF)
52 #include "ss_rbuf.h"
53 #include "ss_rbuf.x"
54 #include "kwu.h"                /* PJU */
55 #include "ss_queue.h"
56 #include "ss_queue.x"
57 #include "ss_task.h"
58 #include "ss_task.x"
59 #include "ss_timer.x"           /* System services */
60 #include "ss_msg.h"           /* System services */
61 #include "ss_msg.x"           /* System services */
62 #include "ss_mem.h"           /* System services */
63 #include "ss_mem.x"           /* System services */
64 #include "ss_drvr.x"
65 #include "ss_gen.h"
66 #include "ss_gen.x"
67 //#endif
68
69 #include "cm5.x"           /* common timer library */
70 #include "cm_tkns.x"       /* common tokens */
71 #include "cm_mblk.x"       /* common memory allocation */
72 #include "cm_llist.x"      /* common link list */
73 #include "cm_hash.x"       /* common hash list */
74 #include "cm_lte.x"        /* common LTE includes */
75 #include "cm_lib.x"        /* common memory allocation library */
76 #include "kwu.x"           /* KWU */
77
78
79 PUBLIC U8 SUpdMbufMemInfo (Pst    *pst,Buffer *mBuf);
80 #if defined(PDCP_RLC_DL_RBUF) && !defined(SS_RBUF)
81 PUBLIC S16 pjKwuRbufDatReq(Pst * pst,SpId spId,KwuDatReqInfo* datReq,Buffer * mBuf);
82 #endif
83
84 EXTERN S16 PtLiKwuBndReq ARGS ((
85 Pst         *post,
86 SuId        suId,
87 SpId        spId
88 ));
89
90 EXTERN S16 PtLiKwuUbndReq ARGS ((
91 Pst         *post,
92 SpId        spId,
93 Reason      reason
94 ));
95
96 EXTERN S16 PtLiKwuDiscSduReq ARGS ((
97 Pst               *post,
98 SpId              spId,
99 KwuDiscSduInfo    *discSdu
100 ));
101
102 EXTERN S16 PtLiKwuDatReq ARGS ((
103 Pst            *post,
104 SpId           spId,
105 KwuDatReqInfo  *datReq,
106 Buffer         *mBuf
107 ));
108 \f
109 /************************************************************************
110                              KWU Interface Matrices
111 ************************************************************************/
112
113 PUBLIC KwuBndReq pjLiKwuBndReqMt [] =
114 {
115 #ifdef LCKWUIKWU
116    cmPkKwuBndReq,        /* 0 - loosely coupled */
117 #else
118    PtLiKwuBndReq,        /* 0 - loosely coupled, portable */
119 #endif
120 #ifdef KW
121    KwUiKwuBndReq,        /* 1 - tightly coupled, stub layer */
122 #else
123    PtLiKwuBndReq,        /* 1 - tightly coupled, portable */
124 #endif
125 #ifdef LWLCKWUIKWU
126    cmPkKwuBndReq,        /* 3 - light weight loosely coupled */
127 #else
128    PtLiKwuBndReq,        /* 3 - light weight loosely coupled, portable */
129 #endif
130 };
131
132 PUBLIC KwuUbndReq pjLiKwuUbndReqMt [] =
133 {
134 #ifdef LCKWUIKWU 
135    cmPkKwuUbndReq,        /* 0 - loosely coupled */
136 #else
137    PtLiKwuUbndReq,        /* 0 - loosely coupled, portable */
138 #endif
139 #ifdef KW
140    KwUiKwuUbndReq,        /* 1 - tightly coupled, stub layer */
141 #else
142    PtLiKwuUbndReq,        /* 1 - tightly coupled, portable */
143 #endif
144 #ifdef LWLCKWUIKWU 
145    cmPkKwuUbndReq,        /* 3 - light weight loosely coupled */
146 #else
147    PtLiKwuUbndReq,        /* 3 - light weight loosely coupled, portable */
148 #endif
149 };
150
151 PUBLIC KwuDatReq pjLiKwuDatReqMt [] =
152 {
153 #ifdef LCKWUIKWU
154    cmPkKwuDatReq,        /* 0 - loosely coupled */
155 #else
156    PtLiKwuDatReq,        /* 0 - loosely coupled, portable */
157 #endif
158 #ifdef KW
159    KwUiKwuDatReq,        /* 1 - tightly coupled, stub layer */
160 #else
161    PtLiKwuDatReq,        /* 1 - tightly coupled, portable */
162 #endif
163 #ifdef LWLCKWUIKWU
164    cmPkKwuDatReq,        /* 3 - light weight loosely coupled */
165 #else
166    PtLiKwuDatReq,        /* 3 - light weight loosely coupled, portable */
167 #endif
168 };
169
170 PUBLIC KwuDiscSduReq pjLiKwuDiscSduReqMt [] =
171 {
172 #ifdef LCKWUIKWU
173    cmPkKwuDiscSduReq,        /* 0 - loosely coupled */
174 #else
175    PtLiKwuDiscSduReq,        /* 0 - loosely coupled, portable */
176 #endif
177 #ifdef KW
178    KwUiKwuDiscSduReq,        /* 1 - tightly coupled, stub layer */
179 #else
180    PtLiKwuDiscSduReq,        /* 1 - tightly coupled, portable */
181 #endif
182 #ifdef LWLCKWUIKWU
183    cmPkKwuDiscSduReq,        /* 3 - light weight loosely coupled */
184 #else
185    PtLiKwuDiscSduReq,        /* 3 - light weight loosely coupled, portable */
186 #endif
187 };
188
189 \f
190 /****************************************************************************
191  *                         KWU Interface Mt functions
192  ***************************************************************************/
193 /**
194  *
195  * @brief 
196  *
197  *        PjLiKwuBndReq - KWU SAP bind Request
198  *
199  *  @param[in] pst   - Post structure  
200  *  @param[in] suId  - Service user SAP ID 
201  *  @param[in] spId  - Service provider ID
202  *
203  *  @return  S16
204  *      -# ROK 
205  */
206 #ifdef ANSI
207 PUBLIC S16 PjLiKwuBndReq
208 (
209 Pst *pst,                       /* post structure */
210 SuId suId,                      /* Service User Id */
211 SpId spId                       /* Service Provider Id */
212 )
213 #else
214 PUBLIC S16 PjLiKwuBndReq(pst, suId, spId)
215 Pst *pst;                       /* post structure */
216 SuId suId;                      /* Service User Id */
217 SpId spId;                      /* Service Provider Id */
218 #endif
219 {
220    TRC3(PjLiKwuBndReq)
221
222    /* jump to specific primitive depending on configured selector */
223    (*pjLiKwuBndReqMt[pst->selector])(pst, suId, spId);
224
225    RETVALUE(ROK);
226
227 } /* end of PjLiKwuBndReq */
228
229 \f
230 /**
231  *
232  * @brief 
233  *
234  *        PjLiKwuUbndReq - KWU SAP unbind Request
235  *
236  *  @param[in] pst     - Post structure  
237  *  @param[in] spId    - Service provider SAP ID 
238  *  @param[in] reason  - Reason
239  *
240  *  @return  S16
241  *      -# ROK 
242  */
243 #ifdef ANSI
244 PUBLIC S16 PjLiKwuUbndReq
245 (
246 Pst         *pst,
247 SpId        spId,
248 Reason      reason
249 )
250 #else
251 PUBLIC S16 PjLiKwuUbndReq(pst, spId, reason)
252 Pst         *pst;
253 SpId        spId;
254 Reason      reason;
255 #endif
256 {
257    TRC3(PjLiKwuUbndReq)
258
259    /* jump to specific primitive depending on configured selector */
260    (*pjLiKwuUbndReqMt[pst->selector])(pst, spId, reason);
261
262    RETVALUE(ROK);
263
264 } /* end of PjLiKwuUbndReq */
265
266 \f
267 /**
268  *
269  * @brief 
270  *
271  *        PjLiKwuDatReq - KWU Data Request
272  *
273  *  @param[in] pst     - Post structure  
274  *  @param[in] spId    - Service provider SAP ID 
275  *  @param[in] datReq  - Data Request
276  *
277  *  @return  S16
278  *      -# ROK 
279  */
280 #ifdef ANSI
281 PUBLIC S16 PjLiKwuDatReq
282 (
283 Pst            *pst,
284 SpId           spId,
285 KwuDatReqInfo  *datReq,
286 Buffer         *mBuf
287 )
288 #else
289 PUBLIC S16 PjLiKwuDatReq(pst, spId, datReq, mBuf)
290 Pst            *pst;
291 SpId           spId;
292 KwuDatReqInfo  *datReq;
293 Buffer         *mBuf;
294 #endif
295 {
296    S16 ret = ROK;
297
298    TRC3(PjLiKwuDatReq)
299 #if defined(PDCP_RLC_DL_RBUF) && !defined(SS_RBUF)
300    if(datReq->lcType == CM_LTE_LCH_DTCH)
301    {
302       if((pjKwuRbufDatReq(pst,spId, datReq, mBuf)) != ROK)
303       {
304          /* Posting the message as ring buffer write failure */
305          ret = RFAILED;
306       }
307    }
308    else
309 #endif
310    {   
311       /* jump to specific primitive depending on configured selector */
312       ret = (*pjLiKwuDatReqMt[pst->selector])(pst, spId, datReq, mBuf);
313    }
314    RETVALUE(ret);
315
316 } /* end of PjLiKwuDatReq */
317
318 \f
319 /**
320  *
321  * @brief 
322  *
323  *        PjLiKwuDiscSduReq - KWU Discard SDU Request
324  *
325  *  @param[in] pst     - Post structure  
326  *  @param[in] spId    - Service provider SAP ID 
327  *  @param[in] datReq  - Data Request
328  *
329  *  @return  S16
330  *      -# ROK 
331  */
332 #ifdef ANSI
333 PUBLIC S16 PjLiKwuDiscSduReq
334 (
335 Pst               *pst,
336 SpId              spId,
337 KwuDiscSduInfo    *discSdu
338 )
339 #else
340 PUBLIC S16 PjLiKwuDiscSduReq(pst, spId, discSdu)
341 Pst               *pst;
342 SpId              spId;
343 KwuDiscSduInfo    *discSdu;
344 #endif
345 {
346    TRC3(PjLiKwuDiscSduReq)
347
348    /* jump to specific primitive depending on configured selector */
349    (*pjLiKwuDiscSduReqMt[pst->selector])(pst, spId, discSdu);
350
351    RETVALUE(ROK);
352
353 } /* end of PjLiKwuDiscSduReq */
354
355 /****************************************************************************
356  *                         Porting Functions
357  ***************************************************************************/
358 /**
359  *
360  * @brief 
361  *
362  *        PtLiKwuBndReq - portable bind request
363  *
364  *  @param[in] pst   - Post structure  
365  *  @param[in] suId  - Service user SAP ID 
366  *  @param[in] spId  - Service provider ID
367  *
368  *  @return  S16
369  *      -# ROK 
370  */
371
372 #ifdef ANSI
373 PUBLIC S16 PtLiKwuBndReq
374 (
375 Pst         *post,
376 SuId        suId,
377 SpId        spId
378 )
379 #else
380 PUBLIC S16 PtLiKwuBndReq(post, suId, spId)
381 Pst         *post;
382 SuId        suId;
383 SpId        spId;
384 #endif /* ANSI */
385 {
386    TRC3(PtLiKwuBndReq)
387 #if (ERRCLASS & ERRCLS_DEBUG)
388  /*  S16 ret1;    */
389    SLogError(post->srcEnt, post->srcInst, post->srcProcId,
390         __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG,
391          (ErrVal)EPJXXX, (ErrVal)ERRZERO, "Improper selector for NhLiKwuBndReq\n");
392    RETVALUE( RFAILED );
393 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
394    UNUSED(post);
395    UNUSED(suId);
396    UNUSED(spId);
397
398    RETVALUE(ROK);
399 } /* end of PtLiKwuBndReq() */
400
401 \f  
402 /**
403  *
404  * @brief 
405  *
406  *        PtLiKwuUbndReq - portable unbind request
407  *
408  *  @param[in] pst     - Post structure  
409  *  @param[in] suId    - Service provider SAP ID 
410  *  @param[in] reason  - Reason
411  *
412  *  @return  S16
413  *      -# ROK 
414  */
415 #ifdef ANSI
416 PUBLIC S16 PtLiKwuUbndReq
417 (
418 Pst         *post,
419 SpId        spId,
420 Reason      reason
421 )
422 #else
423 PUBLIC S16 PtLiKwuUbndReq(post, spId, reason)
424 Pst         *post;
425 SpId        spId;
426 Reason      reason;
427 #endif /* ANSI */
428 {
429    TRC3(PtLiKwuUbndReq)
430 #if (ERRCLASS & ERRCLS_DEBUG)
431   /* S16 ret1; */
432    SLogError(post->srcEnt, post->srcInst, post->srcProcId,
433         __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG,
434          (ErrVal)EPJXXX, (ErrVal)ERRZERO, "Improper selector for NhLiKwuUbndReq\n");
435    RETVALUE( RFAILED );
436 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
437    UNUSED(post);
438    UNUSED(spId);
439    UNUSED(reason);
440    
441    RETVALUE(ROK);
442 } /* end of PtLiKwuUbndReq() */
443
444 /**
445  *
446  * @brief 
447  *
448  *        PtLiKwuDiscSduReq - portable discard SDU request
449  *
450  *  @param[in] pst     - Post structure  
451  *  @param[in] spId    - Service provider SAP ID 
452  *  @param[in] datReq  - Data Request
453  *
454  *  @return  S16
455  *      -# ROK 
456  */
457 #ifdef ANSI
458 PUBLIC S16 PtLiKwuDiscSduReq
459 (
460 Pst               *post,
461 SpId              spId,
462 KwuDiscSduInfo    *discSdu
463 )
464 #else
465 PUBLIC S16 PtLiKwuDiscSduReq(post, spId, discSdu)
466 Pst               *post;
467 SpId              spId;
468 KwuDiscSduInfo    *discSdu;
469 #endif /* ANSI */
470 {
471    TRC3(PtLiKwuDiscSduReq)
472 #if (ERRCLASS & ERRCLS_DEBUG)
473   /* S16 ret1; */
474    SLogError(post->srcEnt, post->srcInst, post->srcProcId,
475         __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG,
476          (ErrVal)EKWU010, (ErrVal)ERRZERO, "Improper selector for NhLiKwuDiscSduReq\n");
477    RETVALUE( RFAILED );
478
479 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
480    UNUSED(post);
481    UNUSED(spId);
482    UNUSED(discSdu);
483
484    RETVALUE(ROK);
485 } /* end of PtLiKwuDiscSduReq() */
486
487 /**
488  *
489  * @brief 
490  *
491  *        PtLiKwuDatReq - portable data request
492  *
493  *  @param[in] pst     - Post structure  
494  *  @param[in] spId    - Service provider SAP ID 
495  *  @param[in] datReq  - Data Request
496  *
497  *  @return  S16
498  *      -# ROK 
499  */
500 #ifdef ANSI
501 PUBLIC S16 PtLiKwuDatReq
502 (
503 Pst            *pst,
504 SpId           spId,
505 KwuDatReqInfo  *datReq,
506 Buffer         *mBuf
507 )
508 #else
509 PUBLIC S16 PtLiKwuDatReq(pst, spId, datReq, mBuf)
510 Pst            *pst;
511 SpId           spId;
512 KwuDatReqInfo  *datReq;
513 Buffer         *mBuf;
514 #endif /* ANSI */
515 {
516    TRC3(PtLiKwuDatReq)
517 #if (ERRCLASS & ERRCLS_DEBUG)
518   /* S16 ret1; */
519    SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId,
520         __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG,
521          (ErrVal)EPJXXX, (ErrVal)ERRZERO, "Improper selector for NhLiKwuDatReq\n");
522    RETVALUE( RFAILED );
523 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
524    UNUSED(pst);
525    UNUSED(spId);
526    UNUSED(datReq);
527    UNUSED(mBuf);
528
529    RETVALUE(ROK);
530 } /* end of PtLiKwuDatReq() */
531 /*
532 *
533 *       Fun:   SUpdMbufMemInfo
534 *
535 *       Desc:  This function is used to get the mem region info of a task.
536 *
537 *       Ret:   ROK      - ok
538 *              RFAILED  - failed, general (optional)
539 *
540 *
541 *       File:  ss_task.c
542 *
543 */
544 #ifdef TENB_T2K3K_SPECIFIC_CHANGES
545 #ifdef ANSI
546 PUBLIC U8 SUpdMbufMemInfo 
547 (
548 Pst    *pst,
549 Buffer *mBuf
550 )
551 #else
552 PUBLIC U8 SUpdMbufMemInfo(pst,mBuf)
553 Pst    *pst;
554 Buffer *mBuf;
555 #endif
556 {
557    SsMsgInfo *minfo;
558    SsTTskEntry *tTsk;
559    SsIdx       dstIdx;
560
561
562    minfo = (SsMsgInfo*) mBuf->b_rptr;
563
564    dstIdx = osCp.tTskIds[pst->dstEnt][pst->dstInst];
565    tTsk = &osCp.tTskTbl[dstIdx];
566 #ifdef SS_MULTICORE_SUPPORT
567    minfo->region = tTsk->sTsk->region;
568 #endif /* SS_MULTICORE_SUPPORT */
569    RETVALUE(ROK);
570 }
571 #endif
572
573 #if defined(PDCP_RLC_DL_RBUF) && !defined(SS_RBUF)
574 #ifdef ANSI
575 PUBLIC S16 pjKwuRbufDatReq
576 (
577 Pst * pst,
578 SpId spId,
579 KwuDatReqInfo* datReq,
580 Buffer * mBuf
581 )
582 #else
583 PUBLIC S16 pjKwuRbufDatReq(pst, spId, datReq, mBuf)
584 Pst * pst;
585 SpId spId;
586 KwuDatReqInfo* datReq;
587 Buffer * mBuf;
588 #endif
589 {
590    S16 ret1 = ROK;
591    
592    Void *elem = NULLP;
593    KwuDatReqDetl *kwuDatReqDetl = NULLP;
594
595    elem = SRngGetWIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
596    if (NULLP != elem)
597    {
598       kwuDatReqDetl = (KwuDatReqDetl *) elem;
599       kwuDatReqDetl->spId = spId;
600       kwuDatReqDetl->lcType = datReq->lcType;
601       kwuDatReqDetl->sduId = datReq->sduId;
602       kwuDatReqDetl->rlcId = datReq->rlcId;
603       kwuDatReqDetl->mBuf = mBuf;
604       /* Commenting below function because memory region mapped with threadId*/
605       /* SUpdMbufMemInfo(pst, mBuf);*/
606       SRngIncrWIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC);
607       SsRngInfoTbl[SS_RNG_BUF_DLPDCP_TO_DLRLC].pktRate++;
608    }   
609    else
610    {
611 #if (ERRCLASS & ERRCLS_DEBUG)
612        SLogError(ENTPJ, 0, SFndProcId(),
613                __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG,
614                (ErrVal)EPJXXX, (ErrVal)ERRZERO, "PDCP-DL RBUF is FULL!!!\n");
615 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
616       SsRngInfoTbl[SS_RNG_BUF_DLPDCP_TO_DLRLC].pktDrop++;
617       ret1 = RFAILED;
618    }
619    RETVALUE(ret1);
620 } /* cmPkKwuDatReq */
621
622 #endif /* PDCP_RLC_DL_RBUF */
623
624 \f  
625 /********************************************************************30**
626          End of file
627 **********************************************************************/