Committing in PDCP code
[o-du/l2.git] / src / 5gnrpdcp / pj_dbm_dl.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:    PDCP - Database module file
22     
23         Type:    C source file
24   
25         Desc:    Source code for Database Module functions such as, 
26
27                   -  pjDbmBufInit
28                   -  pjDbmInsTxEnt
29                   -  pjDbmGetTxEnt
30                   -  pjDbmGetTxEntSn
31                   -  pjDbmDelTxEnt
32                   -  pjDbmTxDeInit
33                   -  pjDbmInsRxEnt
34                   -  pjDbmGetRxEnt
35                   -  pjDbmDelRxEnt
36                   -  pjDbmRxDeInit
37
38         File:    pj_dbm_dl.c
39   
40 *********************************************************************21*/
41   
42 static const char* RLOG_MODULE_NAME="PDCP";
43 static int RLOG_MODULE_ID=1024;
44 static int RLOG_FILE_ID=215;
45 \f
46 /* header (.h) include files */
47 #include "envopt.h"        /* environment options */
48 #include "envdep.h"        /* environment dependent */
49 #include "envind.h"        /* environment independent */
50
51 #include "gen.h"                /* general */
52 #include "ssi.h"                /* system services interface */
53 #include "cm5.h"                /* Timer Functions */
54 #include "cm_lte.h"             /* common LTE header file */
55 #include "cm_hash.h"            /* common hash module  file */
56 #include "cm_llist.h"           /* common list header file */
57 #include "cpj.h"                /* RRC layer */
58 #include "pju.h"                /* PDCP service user */
59 #include "lpj.h"                /* RRC layer */
60 #include "pj_env.h"             /* RLC environment options */
61 #include "pj.h"                 /* RLC layer */
62 #include "pj_dl.h"
63 #include "pj_err.h"
64 #include "pj_ptsec.h"
65 /* extern (.x) include files */
66 #include "gen.x"                /* general */
67 #include "ssi.x"                /* system services interface */
68 #include "cm_lib.x"             /* common library */
69 #include "cm5.x"                /* Timer Functions */
70 #include "cm_hash.x"            /* common hash module */
71 #include "cm_lte.x"             /* common LTE file */
72 #include "cm_llist.x"           /* common list header file */
73 #include "cpj.x"                /* RRC layer */
74 #include "pju.x"                /* PDCP service user */
75 #include "lpj.x"                /* LM Interface */
76 #include "pj.x"                 /* RLC layer */
77 #include "pj_udx.h"
78 #include "pj_udx.x"
79 #include "pj_dl.x"
80 #include "pj_ul.x"
81 U32 pjTotDlPckCntPerCell;
82 \f
83 /* local defines */
84
85 /* local externs */
86
87 /* forward references */
88
89 /* public variable declarations */
90 PUBLIC S16 pjCiphStateChek ARGS ((PjCb *gCb, PjTxEnt *txEnt));
91 /* This structure holds all the global structs we need. */
92
93 /* private variable declarations */
94
95 /* private function declarations */
96
97 /** @file gp_pj_dbm.c
98 @brief PDCP DBM Module
99 **/
100 /*****************************************************************************
101  *                  HANDLER FOR THE TRANSMISSION BUFFER
102  ****************************************************************************/
103 \f
104 /**
105  *
106  * @brief Handler to initialize  Buffer
107  *
108  * @b Description
109  *        This function is invoked by config to initialize the Buffer
110  *        hash List
111  *
112  *  @param[in]    buf       Rx/Tx Buffer Control Point
113  *  @param[in]    numBins   number of Bins
114  *
115  *  @return  S16
116  *      -# ROK 
117  *      -# RFAILED 
118  *
119 */
120 #ifdef ANSI
121 PUBLIC S16 pjDbmDlBufInit
122 (
123 PjCb        *gCb,
124 PjBuf       *buf,            /* !< Rx/Tx Buffer */
125 U8          numBins          /* !< number of Bins */
126 )
127 #else
128 PUBLIC S16 pjDbmDlBufInit(gCb, buf, numBins)
129 PjCb        *gCb;
130 PjBuf       *buf;            /* !< Rx/Tx Buffer */ 
131 U8          numBins;         /* !< number of Bins */             
132 #endif
133 {
134    U8       hashIndex;        /* HashIndex of array */
135
136    TRC3(pjDbmDlBufInit)
137
138    RLOG1(L_DEBUG, "pjDbmBufInit(buf, numBins(%d)", numBins);
139
140    /* Initialize CmLListCps*/
141    PJ_ALLOC(gCb, buf->datQ, (sizeof(CmLListCp) * numBins));
142 #if (ERRCLASS & ERRCLS_DEBUG)
143    if (buf->datQ == NULLP)
144    {
145       RLOG0(L_FATAL, "Memory Allocation failed.");
146       RETVALUE(RFAILED);
147    }
148 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
149
150    for(hashIndex = 0; hashIndex < numBins; hashIndex++)
151    {
152       cmLListInit(&buf->datQ[hashIndex]);
153    }
154
155    /* Initialistations of buf */
156    buf->numEntries = 0;
157    buf->numBins    = numBins;
158    
159    cmLListInit(&buf->datCfmQ);
160    cmLListInit(&buf->sduSubmitQ);
161    cmLListInit(&buf->reEstPktQ);
162
163    RETVALUE(ROK);
164 } /* pjDbmBufInit */
165
166 \f
167 /**
168  *
169  * @brief Handler to insert into a TX Buffer
170  *
171  * @b Description
172  *        This function is invoked to insert into
173  *        the transmission buffer hash List
174  *
175  *  @param[in]    buf         Tx Buffer 
176  *  @param[in]    txEnt       Transmission Entry
177  *
178  *  @return  S16
179  *      -# ROK 
180  *      -# RFAILED 
181  *
182 */
183 #ifdef ANSI
184 PUBLIC S16 pjDbmInsTxEnt
185 (
186 PjCb        *gCb,
187 PjBuf       *buf,             /* !< Tx Buffer */  
188 PjTxEnt     *txEnt            /* !< Tx Entry */              
189 )
190 #else
191 PUBLIC S16 pjDbmInsTxEnt(gCb, buf, txEnt)
192 PjCb        *gCb;
193 PjBuf       *buf;             /* !< Tx Buffer */              
194 PjTxEnt     *txEnt;           /* !< Tx Entry */               
195 #endif
196 {
197    U8       hashKey;          /* Computed HashKey */
198
199    TRC3(pjDbmInsTxEnt)
200
201 //   pjTotDlPckCntPerCell++; 
202 #ifndef ALIGN_64BIT
203    PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\
204             "pjDbmInsTxEnt(buf, txEnt(%ld)\n", txEnt->count));
205 #else
206    PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\
207             "pjDbmInsTxEnt(buf, txEnt(%d)\n", txEnt->count));
208 #endif
209    /* Get the hash index */
210    hashKey = (U8)PJ_HASH_FN(buf, txEnt->count); /*KW_FIX*/
211
212    txEnt->lstEnt.node = (PTR)txEnt;
213    cmLListAdd2Tail(&buf->datQ[hashKey], &txEnt->lstEnt);
214    buf->numEntries ++;
215  
216    txEnt->sduSubmitEnt.node = (PTR)txEnt;
217    cmLListAdd2Tail(&buf->sduSubmitQ, &txEnt->sduSubmitEnt);
218
219    RETVALUE(ROK);
220 } /* pjDbmTxBufIns */
221
222 \f
223 /**
224  *
225  * @brief Handler to fetch from a TX Buffer
226  *
227  * @b Description
228  *        This function is invoked to fetch from
229  *         the transmission buffer hash List
230  *
231  *  @param[in]    buf         Tx Buffer 
232  *  @param[in]    count       Count of the PjTxEnt to retrieve
233  *
234  *  @return  S16
235  *      -# ROK 
236  *      -# RFAILED 
237  *
238 */
239 #ifdef ANSI
240 PUBLIC PjTxEnt* pjDbmGetTxEnt
241 (
242 PjCb        *gCb,
243 PjBuf       *buf,        /* !< Tx Buffer  */                    
244 U32          count       /* !< Count of the PjTxEnt to retrieve */
245 )
246 #else
247 PUBLIC PjTxEnt* pjDbmGetTxEnt(gCb, buf, count)
248 PjCb        *gCb;
249 PjBuf       *buf;        /* !<Tx Buffer  */                     
250 U32         count;       /* !<Count of the PjTxEnt to retrieve */ 
251 #endif
252 {
253    U8          hashKey;     /* Computed Hash Key */
254    CmLListCp   *datQ;       /* Pointer to the ListCp */
255    PjTxEnt     *tmpEnt;     /* Loop Var - Pointer to PjTxEnt */
256
257    TRC3(pjDbmGetTxEnt) 
258 #ifndef ALIGN_64BIT
259    PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\
260             "pjDbmGetTxEnt(buf, txEnt(%ld)\n", count));
261 #else
262    PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\
263             "pjDbmGetTxEnt(buf, txEnt(%d)\n", count));
264 #endif 
265    /* Call the hash function */
266    hashKey = (U8)PJ_HASH_FN(buf, count); /*KW_FIX*/
267
268    datQ = &buf->datQ[hashKey];
269
270    cmLListFirst(datQ);
271    while(cmLListCrnt(datQ))
272    {
273       tmpEnt = (PjTxEnt *) cmLListNode(cmLListCrnt(datQ));
274       if(tmpEnt->count  == count)
275       {
276          RETVALUE(tmpEnt);
277       }
278       cmLListNext(datQ);
279    }
280    RETVALUE(NULLP);
281 } /* pjDbmGetTxEnt */
282
283 \f
284 /**
285  *
286  * @brief Handler to fetch from a TX Buffer
287  *
288  * @b Description
289  *        This function is fetch the node based on the SN.
290  *        This function will be called only for the case of a 
291  *        PDCP STATUS REPORT being received by the DRB AM. 
292  *
293  *  @param[in]    buf         Tx Buffer 
294  *  @param[in]    sn          SN to get the Ent
295  *
296  *  @return  S16
297  *      -# ROK 
298  *      -# RFAILED 
299  *
300 */
301 #ifdef ANSI
302 PUBLIC PjTxEnt* pjDbmGetTxEntSn
303 (
304 PjCb        *gCb,
305 PjBuf       *buf,        /* !< Tx Buffer  */                     
306 U16          sn          /* !< SN of the PjTxEnt to retrieve */ 
307 )
308 #else
309 PUBLIC PjTxEnt* pjDbmGetTxEntSn(gCb, buf, sn)
310 PjCb        *gCb;
311 PjBuf       *buf;        /* !< Tx Buffer  */                      
312 U16         sn;          /* !< SN of the PjTxEnt to retrieve */     
313 #endif
314 {
315    U8          hashKey;  /* Computed hash index */
316    CmLListCp   *datQ;    /* Pointer to the ListCP */
317    PjTxEnt     *tmpEnt;  /* Loop Var - pointer to PjTxEnt */
318
319    TRC3(pjDbmGetTxEntSn) 
320
321    RLOG1(L_DEBUG, "pjDbmGetTxEnt(buf, sn(%d)", sn);
322
323    /* Call the hash function */
324    hashKey = (U8)PJ_HASH_FN(buf, sn); /*KW_FIX*/
325
326    datQ = &buf->datQ[hashKey];
327
328    /* Loop through to find the entry that matches */
329    cmLListFirst(datQ);
330    while(cmLListCrnt(datQ))
331    {
332       tmpEnt = (PjTxEnt *) cmLListNode(cmLListCrnt(datQ));
333       if(tmpEnt->sn == sn)
334       {
335          RETVALUE(tmpEnt);
336       }
337       cmLListNext(datQ);
338    }
339    RETVALUE(NULLP);
340
341 } /* pjDbmGetTxEntSn */
342   
343 /* ccpu00136902 */
344 #if (defined (LTE_PAL_ENB) || defined (TENB_ACC))
345 /**
346  *  @brief This fn is called to chek the state of the PDCP pkts in DL before Ciphering operation
347  *         and appropriate action is taken accordingly
348  *
349  *  @details
350  *      Function : pjCiphStateChek
351  *
352  *  Processing Steps:
353  *
354  *
355  * @return  S16
356  *        -# Success : ROK
357  *        -# Failure : RFAILED
358 */
359 #ifdef ANSI
360 PUBLIC S16 pjCiphStateChek
361 (
362 PjCb        *gCb,
363 PjTxEnt     *txEnt
364 )
365 #else
366 PUBLIC S16 pjCiphStateChek(gCb, txEnt)
367 PjCb        *gCb;
368 PjTxEnt     *txEnt;
369 #endif
370 {
371   TRC3(pjCiphStateChek);
372   PJ_FREE_BUF(txEnt->sdu);
373   PJ_FREE_BUF(txEnt->pdu);
374 #ifdef FLAT_BUFFER_OPT
375    if(txEnt->fb.startAddr)
376    {
377        PJ_FREE_FLAT_BUF(gCb, (&(txEnt->fb)));
378    }
379 #endif
380
381   PJ_FREE(gCb, txEnt, sizeof(PjTxEnt));
382   RETVALUE(ROK);
383 }
384 #endif
385
386 \f
387 /**
388  *
389  * @brief Handler to delete from a TX Buffer
390  *
391  * @b Description
392  *        This function is invoked by to insert into
393  *         the transaction buffer hash List
394  *
395  *  @param[in]    buf         Tx Buffer 
396  *  @param[in]    count       count to get the Ent
397  *
398  *  @return  S16
399  *      -# ROK 
400  *      -# RFAILED 
401  *
402 */
403 #ifdef ANSI
404 PUBLIC S16 pjDbmDelTxEnt
405 (
406 PjCb        *gCb,
407 PjBuf       *buf,     /* !< Tx Buffer  */                     
408 U32         count     /* !< Count of the PjTxEnt to delete */ 
409 )
410 #else
411 PUBLIC S16 pjDbmDelTxEnt(gCb, buf, count)
412 PjCb        *gCb;
413 PjBuf       *buf;     /* !< Tx Buffer  */                      
414 U32         count;    /* !< Count of the PjTxEnt to delete */    
415 #endif
416 {
417    U8          hashKey;      /* Computed Hash Key */
418    CmLListCp   *datQ;        /* Pointer to the ListCP */
419    PjTxEnt     *delEnt;      /* Loop Var - pointer to PjTxEnt */
420
421    TRC3(pjDbmDelTxEnt)
422 #ifndef ALIGN_64BIT
423    PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\
424             "pjDbmDelTxEnt(buf,  count(%ld)\n", count));
425 #else
426    PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\
427             "pjDbmDelTxEnt(buf,  count(%d)\n", count));
428 #endif
429
430    /* search for the entry */
431    delEnt   =  pjDbmGetTxEnt(gCb, buf, count);
432    if(delEnt == NULLP)
433    {
434       RETVALUE(RFAILED);
435    }
436
437    /* Compute the hash index */
438    hashKey = (U8)PJ_HASH_FN(buf, delEnt->count); /*KW_FIX*/
439    datQ  =  &buf->datQ[hashKey];
440
441    /* delete the entry */
442    cmLListDelFrm(datQ, &delEnt->lstEnt);
443
444    if (delEnt->sduSubmitEnt.node != NULLP)
445    {
446       delEnt->sduSubmitEnt.node = NULLP;
447       cmLListDelFrm(&buf->sduSubmitQ,&delEnt->sduSubmitEnt);
448    }
449    if(delEnt->datCfmEnt.node != NULLP)
450    {
451       delEnt->datCfmEnt.node = NULLP;
452       cmLListDelFrm(&buf->datCfmQ, &delEnt->datCfmEnt);
453       pjTotDlPckCntPerCell--;
454    }
455
456    if(delEnt->reEstPktEnt.node != NULLP)
457    {
458       delEnt->reEstPktEnt.node = NULLP;
459       cmLListDelFrm(&buf->reEstPktQ, &delEnt->reEstPktEnt);
460    }
461    /* NULLing off to prevent double dealloc */
462    if(delEnt->pdu == delEnt->sdu)
463    {
464       delEnt->pdu =  NULLP;
465    }
466 /* ccpu00136902 */
467    pjCiphStateChek(gCb, delEnt);
468    buf->numEntries --;
469
470    RETVALUE(ROK);
471 } /* pjDbmDelTxEnt */
472
473 \f
474 /**
475  *
476  * @brief Handler to Delete all the elements in the hashlist
477  *       
478  *
479  * @b Description
480  *        This function is invoked to Delete all the elements in the
481  *        hash List
482  *
483  *  @return  S16
484  *      -# ROK 
485  *      -# RFAILED 
486  *
487 */
488 #ifdef ANSI
489 PUBLIC S16 pjDbmTxDelAll
490 (
491 PjCb  *gCb,
492 PjBuf *buf        /* !< Tx Buffer  */                     
493 )
494 #else
495 PUBLIC S16 pjDbmTxDelAll(gCb,buf)
496 PjCb  *gCb;
497 PjBuf *buf;       /* !< Tx Buffer  */                     
498 #endif
499 {
500    U8         i;         /* index counter */
501    CmLListCp *datQ;      /* CmLListcp Ptr */
502    CmLList   *lstEnt;   /* CmLList Ptr - Loop var */
503    PjTxEnt   *txEnt;     /* Tx Entry Ptr - Loop var */
504
505    TRC3(pjDbmTxDelAll);
506
507    RLOG0(L_DEBUG, "pjDbmTxDelAll(buf)");
508
509    /* cleanup the entries */
510    for(i = 0; i< buf->numBins; i++)
511    {
512       datQ = &buf->datQ[i];
513       while(cmLListFirst(datQ))
514       {
515          lstEnt = cmLListDelFrm(datQ, cmLListCrnt(datQ));
516          if(lstEnt != NULLP)
517          {
518             txEnt =  (PjTxEnt *)cmLListNode(lstEnt);
519             if(txEnt->datCfmEnt.node != NULLP)
520             {
521                txEnt->datCfmEnt.node = NULLP;
522                cmLListDelFrm(&buf->datCfmQ, &txEnt->datCfmEnt);
523                pjTotDlPckCntPerCell--;
524             }
525
526             if (txEnt->sduSubmitEnt.node != NULLP)
527             {
528                txEnt->sduSubmitEnt.node = NULLP;
529                cmLListDelFrm(&buf->sduSubmitQ,&txEnt->sduSubmitEnt);
530             }
531
532             if(txEnt->reEstPktEnt.node != NULLP)
533             {
534                txEnt->reEstPktEnt.node = NULLP;
535                cmLListDelFrm(&buf->reEstPktQ, &txEnt->reEstPktEnt);
536             }
537
538             if ( txEnt->sdu == txEnt->pdu )
539             {
540                txEnt->sdu = NULLP;
541             }
542             /* ccpu00136902 */
543             pjCiphStateChek(gCb, txEnt);
544          }
545       }
546       cmLListInit(datQ);
547    }
548
549    RETVALUE(ROK);
550 } /* pjDbmTxDelAll */
551 \f
552 /**
553  *
554  * @brief Handler to De initialize hash list
555  *       
556  *
557  * @b Description
558  *        This function is invoked by LMM to De initialize the 
559  *        hash List
560  *
561  *  @return  S16
562  *      -# ROK 
563  *      -# RFAILED 
564  *
565 */
566 #ifdef ANSI
567 PUBLIC S16 pjDbmTxDeInit
568 (
569 PjCb  *gCb,
570 PjBuf *buf        /* !< Tx Buffer  */                     
571 )
572 #else
573 PUBLIC S16 pjDbmTxDeInit(gCb,buf)
574 PjCb  *gCb;
575 PjBuf *buf;       /* !< Tx Buffer  */                     
576 #endif
577 {
578
579    TRC3(pjDbmTxDeInit);
580
581    RLOG0(L_DEBUG, "pjDbmTxDeInit(buf)");
582
583    /* cleanup the entries */
584    pjDbmTxDelAll(gCb,buf);
585    
586    /* Cleanup the listCps */
587    PJ_FREE(gCb, buf->datQ, (sizeof(CmLListCp) * buf->numBins));
588    buf->numBins   =  NULLP;
589
590    RETVALUE(ROK);
591 } /* pjDbmDeInit */
592
593
594 \f
595 /**
596  *
597  * @brief Handler to initialize hash list
598  *       
599  *
600  * @b Description
601  *        This function is invoked by LMM to initialize the UeCb and CellCb
602  *        hash List
603  *
604  *  @return  S16
605  *      -# ROK 
606  *      -# RFAILED 
607  *
608 */
609 #ifdef ANSI
610 PUBLIC S16 pjDbmDlInit  
611 (
612 PjCb *gCb
613 )
614 #else
615 PUBLIC S16 pjDbmDlInit(gCb)
616 PjCb *gCb;
617 #endif
618 {
619    S16      ret;              /* Return Value */
620
621    TRC3(pjDbmDlInit)
622
623 #ifdef DEBUGP
624    RLOG0(L_DEBUG, "pjDbmInit()");
625 #endif
626
627    /* Initialize ueCb Hash List */
628    ret = cmHashListInit(&(gCb->u.dlCb->ueLstCp), (U16) PJ_UE_LIST_BUCKET_SIZE,
629          (U16) 0, (Bool) FALSE, (U16) CM_HASH_KEYTYPE_DEF,
630          gCb->init.region, gCb->init.pool);
631    if (ret != ROK)
632    {
633 #ifdef DEBUGP
634       RLOG0(L_DEBUG, "pjDbmInit: cmHashListInit Failed for gCb.ueLstCp.");
635 #endif
636       RETVALUE(ret);
637    }
638
639    RETVALUE(ROK);
640 } /* pjDbmInit */
641
642 \f
643 /**
644  *
645  * @brief Handler to De initialize hash list
646  *       
647  *
648  * @b Description
649  *        This function is invoked by LMM to De initialize the UeCb and CellCb
650  *        hash List
651  *
652  *  @return  S16
653  *      -# ROK 
654  *      -# RFAILED 
655  *
656 */
657 #ifdef ANSI
658 PUBLIC S16 pjDbmDlDeInit
659 (
660 PjCb *gCb
661 )
662 #else
663 PUBLIC S16 pjDbmDlDeInit(gCb)
664 PjCb *gCb;
665 #endif
666 {
667    S16      ret;                       /* Return Value */
668
669    TRC3(pjDbmDlDeInit);
670
671 #ifdef DEBUGP
672    RLOG0(L_DEBUG, "pjDbmDeInit()");
673 #endif
674
675    /* Initialize ueCb Hash List */
676    ret = cmHashListDeinit(&(gCb->u.dlCb->ueLstCp));
677    if (ret != ROK)
678    {
679 #ifdef DEBUGP
680       RLOG0(L_ERROR, "pjDbmDeInit: cmHashListDeinit Failed for gCb.ueLstCp.");
681 #endif
682       RETVALUE(ret);
683    }
684    RETVALUE(ROK);
685 } /* pjDbmDeInit */
686
687 \f
688 /**
689  *
690  * @brief Handler to fetch rbCb in the Upper Interface
691  *       
692  *
693  * @b Description
694  *        This function is invoked by CFG to fetch rbCb from the cellCb/ueCb in
695  *        the upper interface (CPJ/PJU).
696  *
697  *  @param[in]    rlcId    RLC Identifier 
698  *  @param[out]   rbCb     RB Control Block
699  *
700  *  @return  S16
701  *      -# ROK 
702  *      -# RFAILED 
703  *
704 */
705 #ifdef ANSI
706 PUBLIC S16 pjDbmFetchDlRbCb
707 (
708 PjCb           *gCb,
709 CmLteRlcId     rlcId,      /* RLC Identifier */
710 PjDlRbCb       **rbCb       /* RB Cb */
711 )
712 #else
713 PUBLIC S16 pjDbmFetchDlRbCb(gCb, rlcId, rbCb)
714 PjCb           *gCb;
715 CmLteRlcId     rlcId;      /* RLC Identifier */
716 PjDlRbCb         **rbCb;      /* RB Cb */
717 #endif
718 {
719    PjDlUeCb      *ueCb;                  /* UE Control Block */
720    PjDlRbCb        *tRbCb;                 /* Local RB CB */
721    S16         ret;                    /* Return Value */
722
723    TRC3(pjDbmFetchDlRbCb)
724
725 #ifdef DEBUGP
726    RLOG3(L_DEBUG, "pjDbmFetchRbCbForLi(rlcId(ueId(%d), cellId(%d), rbId(%d)),   rbCb)",
727              rlcId.ueId, rlcId.cellId, rlcId.rbId);
728 #endif
729
730    ueCb = NULLP;
731    ret = ROK;
732
733    /* Validate the RBID in case of TM/UM/AM */
734    PJ_VALIDATE_RBID(rlcId.ueId, rlcId.rbId, rlcId.rbType, ret);
735    if (ret != ROK)
736    {
737 #ifdef DEBUGP
738       /* DEBUG_PRINT EROR */
739       RLOG_ARG2(L_ERROR,DBG_UEID,rlcId.ueId, 
740             "PJ_VALIDATE_RBID Failed -- rbId(%d), cellId(%d)",
741                rlcId.rbId, rlcId.cellId);
742
743 #endif
744       RETVALUE(ret);
745    }
746    if (pjDbmFetchDlUeCb(gCb, rlcId.ueId, rlcId.cellId, &ueCb) != ROK)
747    {
748          RLOG_ARG1(L_ERROR, DBG_CELLID, rlcId.cellId,"UeId[%u] not found",
749             rlcId.ueId);
750          RETVALUE(RFAILED);
751
752    }
753
754    PJ_DBM_FETCH_DL_RBCB(rlcId.rbId, rlcId.rbType, ueCb, tRbCb);
755
756    if (tRbCb == NULLP)
757    {
758       RLOG_ARG2(L_ERROR, DBG_UEID,rlcId.ueId, "CellId[%u]:RbId[%d] not found",
759             rlcId.cellId, rlcId.rbId);
760       RETVALUE(RFAILED);
761    }
762
763    *rbCb = tRbCb;
764
765    RETVALUE(ROK);
766 } /* pjDbmFetchRbCb */
767
768 \f
769 /**
770  *
771  * @brief Handler to delete RbCb
772  *       
773  *
774  * @b Description
775  *        This function is invoked by CFG to remove RbCb from Ue/Cell hashlist 
776  *
777  *
778  *  @param[in] rbCbLst   - Rb Cb List
779  *  @param[in] numRbCb   - Number of rbCbs
780  *
781  *  @return  S16
782  *      -# ROK 
783  *      -# RFAILED 
784  *
785 */
786 #ifdef ANSI
787 PUBLIC S16 pjDbmDelAllDlRb
788 (
789 PjCb             *gCb,
790 PjDlRbCb         **rbCbLst,              /* RB Cb list */
791 U8             numRbCb                 /* Number of rbCbs */
792 )
793 #else
794 PUBLIC S16 pjDbmDelAllDlRb(gCb,rbCbLst, numRbCb)
795 PjCb             *gCb;
796 PjDlRbCb         **rbCbLst;              /* RB Cb list */
797 U8             numRbCb;                /* Number of rbCbs */
798 #endif
799 {
800    U8          idx;                    /* Index */
801    PjDlRbCb        *rbCb;                  /* RB Control Block */
802
803    TRC3(pjDbmDelAllDlRb)
804
805 #ifdef DEBUGP
806    RLOG1(L_DEBUG, "pjDbmDelAllRb(rbCbLst, numRbCb(%d))", numRbCb);
807 #endif
808
809    for (idx = 0; idx < numRbCb; idx++)
810    {
811       rbCb = rbCbLst[idx];
812       if (rbCb != NULLP)
813       {
814          PJ_DBM_DELETE_DL_RBCB(gCb, rbCb);
815          rbCbLst[idx] = NULLP;
816       }
817    }
818
819    RETVALUE(ROK);
820 } /* pjDbmDelAllRb */
821
822 \f
823 /**
824  *
825  * @brief Handler to create an UeCb
826  *       
827  *
828  * @b Description
829  *        This function is invoked by CFG to create UeCb and insert into the Ue hashlist 
830  *        of KwCb.
831  *
832  *
833  *  @param[in] ueId     UE Identifier 
834  *  @param[in] cellId   Cell Identifier 
835  *
836  *  @return  S16
837  *      -# ROK 
838  *      -# RFAILED 
839  *
840 */
841 #ifdef ANSI
842 PUBLIC S16 pjDbmCreateDlUeCb
843 (
844 PjCb              *gCb,
845 CmLteRnti         ueId,       /* UE Identifier */
846 CmLteCellId       cellId,     /* Cell Identifier */
847 PjDlUeCb            **ueCb       /* UE Control Block */
848 )
849 #else
850 PUBLIC S16 pjDbmCreateDlUeCb(gCb, ueId, cellId, ueCb)
851 PjCb              *gCb; 
852 CmLteRnti         ueId;       /* UE Identifier */
853 CmLteCellId       cellId;     /* Cell Identifier */
854 PjDlUeCb            **ueCb;     /* UE Control Block */
855 #endif
856 {
857    S16      ret;              /* Return Value */
858    PjDlUeCb   *tUeCb;           /* UE Control Block */
859
860    TRC3(PjDbmCreateDlUeCb)
861
862 #ifdef DEBUGP
863    RLOG2(L_DEBUG, "pjDbmCreateUeCb(ueId(%d), cellId(%d))", ueId, cellId);
864 #endif
865
866    PJ_ALLOC(gCb, *ueCb, sizeof(PjDlUeCb));
867
868 #if (ERRCLASS & ERRCLS_ADD_RES)
869    if (*ueCb == NULLP)
870    {
871       ret = RFAILED;
872       RLOG0(L_FATAL, "Memory Allocation failed.");
873       RETVALUE(ret);
874    }
875 #endif /* ERRCLASS & ERRCLS_ADD_RES */
876
877    tUeCb = *ueCb;
878    tUeCb->key.ueId = ueId;
879    tUeCb->key.cellId = cellId;
880
881    ret = cmHashListInsert(&(gCb->u.dlCb->ueLstCp), (PTR)tUeCb, (U8 *)&(tUeCb->key),
882          (U16) sizeof(PjUeKey));
883    if (ret != ROK)
884    {
885 #ifdef DEBUGP
886       RLOG_ARG1(L_ERROR,DBG_UEID,ueId, 
887             "DL UE CB Hash Insert Failed for cellId (%d)", cellId);
888 #endif
889       RETVALUE(ret);
890    }
891
892    /* kw005.201 ccpu00117318, updating the statistics */
893    gCb->u.dlCb->pjGenSts.numUe++;
894    (*ueCb)->libInfo.state =  PJ_STATE_NORMAL;
895    cmInitTimers(&((*ueCb)->libInfo.obdTmr), 1);
896    RETVALUE(ret);
897 } /* kwDbmCreateUeCb */
898
899 \f
900 /**
901  *
902  * @brief Handler to Fetch an UeCb
903  *       
904  *
905  * @b Description
906  *        This function is invoked by CFG to fetch UeCb from the Ue hashlist 
907  *        of KwCb.
908  *
909  *
910  *  @param[in]    ueId     UE Identifier 
911  *  @param[in]    cellId   Cell Identifier 
912  *  @param[out]   ueCb     UE Control Block
913  *
914  *  @return  S16
915  *      -# ROK 
916  *      -# RFAILED 
917  *
918 */
919 #ifdef ANSI
920 PUBLIC S16 pjDbmFetchDlUeCb
921 (
922 PjCb              *gCb,
923 CmLteRnti         ueId,       /* UE Identifier */
924 CmLteCellId       cellId,     /* Cell Identifier */
925 PjDlUeCb            **ueCb       /* UE Control Block */
926 )
927 #else
928 PUBLIC S16 pjDbmFetchDlUeCb(gCb, ueId, cellId, ueCb)
929 PjCb              *gCb;
930 CmLteRnti         ueId;       /* UE Identifier */
931 CmLteCellId       cellId;     /* Cell Identifier */
932 PjDlUeCb            **ueCb;      /* UE Control Block */
933 #endif
934 {
935    S16      ret;              /* Return Value */
936    PjUeKey  key;              /* Key for UE Hash List */
937
938    TRC3(pjDbmFetchDlUeCb)
939
940
941    key.ueId = ueId;
942    key.cellId = cellId;
943
944    ret = cmHashListFind(&(gCb->u.dlCb->ueLstCp), (U8 *)&(key), sizeof(PjUeKey),
945          PJ_DEF_SEQ_NUM, (PTR *) ueCb);
946    if (ret != ROK)
947    {
948 #ifdef DEBUGP
949       RLOG_ARG0(L_WARNING,DBG_UEID,ueId, 
950             "pjDbmFetchUeCb: cmHashListFind Failed for ueCb.");
951 #endif
952       RETVALUE(ret);
953    }
954
955    RETVALUE(ROK);
956 } /* pjDbmFetchUeCb */
957
958 \f
959 /**
960  *
961  * @brief Handler to delete an UeCb
962  *       
963  *
964  * @b Description
965  *        This function is invoked by CFG to delete UeCb from the Ue hashlist 
966  *        of KwCb.
967  *
968  *
969  *  @param[in] ueCb     UE Control Block
970  *  @param[in] abrtFlag Abort Flag
971  *
972  *  @return  S16
973  *      -# ROK 
974  *      -# RFAILED 
975  *
976 */
977 #ifdef ANSI
978 PUBLIC S16 pjDbmDelDlUeCb
979 (
980 PjCb        *gCb,
981 PjDlUeCb      *ueCb,       /* UE Identifier */
982 Bool        abortFlag    /* Abort Flag */
983 )
984 #else
985 PUBLIC S16 pjDbmDelDlUeCb(gCb, ueCb, abortFlag)
986 PjCb        *gCb;
987 PjDlUeCb      *ueCb;       /* UE Identifier */
988 Bool        abortFlag;   /* Abort Flag */
989 #endif
990 {
991    S16         ret;      /* Return Value */
992    U8          idx;      /* Index */
993
994    TRC3(pjDbmDelDlUeCb)
995
996 #ifdef DEBUGP
997    RLOG2(L_DEBUG, "pjDbmDelUeCb(ueId(%d), cellId(%d))",
998             ueCb->key.ueId, ueCb->key.cellId);
999 #endif
1000
1001 /* kw005.201 Check to see if there is atleast one logical channel */
1002
1003    for ( idx = 0; idx< PJ_MAX_SRB_PER_UE; idx++)
1004        pjCfgDelPjDlRbCb(gCb, ueCb, ueCb->srbCb[idx]);
1005
1006    for ( idx = 0; idx< PJ_MAX_DRB_PER_UE; idx++) 
1007        pjCfgDelPjDlRbCb(gCb, ueCb, ueCb->drbCb[idx]);
1008
1009    /* Close the Integrity/Ciphering channels */
1010    if(ueCb->secInfo.secAct)
1011    {
1012 #ifdef INTEL_QAT_DP
1013       pjUtlDlIntClose(gCb,ueCb->secInfo.cpIntSessCxtId);
1014       pjUtlDlCipherClose(gCb,ueCb->secInfo.cpCiphSessCxtId);
1015       pjUtlDlCipherClose(gCb,ueCb->secInfo.upCiphSessCxtId);
1016 #else
1017       pjUtlDlIntClose(gCb,ueCb->secInfo.intCxtId);
1018       pjUtlDlCipherClose(gCb,ueCb->secInfo.cpCxtId);
1019       pjUtlDlCipherClose(gCb,ueCb->secInfo.upCxtId);
1020 #endif
1021    }
1022
1023    /* Delete hoInfo if present */
1024    if (ueCb->hoInfo != NULLP)
1025    {
1026       for (idx = 0; idx < PJ_MAX_DRB_PER_UE; idx++)
1027       {
1028          if (ueCb->hoInfo->hoCfmInfo[idx].pres == TRUE)
1029          { /* should these be dl? */
1030    
1031          }
1032       }
1033
1034       PJ_FREE(gCb, ueCb->hoInfo->hoCfmInfo, (PJ_MAX_DRB_PER_UE * sizeof(PjDlHoCfmInfo)));
1035       PJ_FREE(gCb, ueCb->hoInfo, sizeof(PjDlHoInfo));  
1036    }
1037
1038    /* Delete ueCb entry from ueLstCp */
1039    ret = cmHashListDelete(&(gCb->u.dlCb->ueLstCp), (PTR) ueCb); 
1040    if (ret != ROK)
1041    {
1042
1043 #ifdef DEBUGP
1044       RLOG_ARG0(L_ERROR,DBG_UEID,ueCb->key.ueId,"Hash Delete Failed for ueCb");
1045 #endif
1046    }
1047    /* kw005.201 ccpu00117318, updating the statistics */
1048    gCb->pjGenSts.numUe--; 
1049    /* Deallocate ueCb */
1050    PJ_FREE(gCb, ueCb, sizeof(PjDlUeCb));
1051
1052    RETVALUE(ret);
1053 } /* pjDbmDelUeCb */
1054
1055 \f
1056 /**
1057  *
1058  * @brief Handler to delete all UeCbs
1059  *       
1060  *
1061  * @b Description
1062  *        This function is invoked by CFG to delete all UeCbs from the Ue
1063  *        hashlist of KwCb.
1064  *
1065  *  @return  S16
1066  *      -# ROK 
1067  *      -# RFAILED 
1068  *
1069 */
1070 #ifdef ANSI
1071 PUBLIC S16 PjDbmDelAllDlUe
1072 (
1073 PjCb  *gCb
1074 )
1075 #else
1076 PUBLIC S16 PjDbmDelAllDlUe(gCb)
1077 PjCb  *gCb;
1078 #endif
1079 {
1080    S16         ret;
1081    PjDlUeCb      *ueCb;            /* UE Control Block */
1082
1083    TRC3(pjDbmDelAllDlUe)
1084
1085 #ifdef DEBUGP
1086    RLOG0(L_DEBUG, "pjDbmDelAllUe()");
1087 #endif
1088
1089    ret = ROK;
1090    ueCb = NULLP;
1091
1092    /* Until no more ueCb is ueLstCp hash list get and delete ueCb */
1093    while (cmHashListGetNext(&(gCb->u.dlCb->ueLstCp), (PTR) ueCb, (PTR *)&ueCb) == ROK)
1094    {
1095       /* Delete ueCb */
1096       ret = pjDbmDelDlUeCb(gCb,ueCb, TRUE);
1097       if (ret != ROK)
1098       {
1099 #ifdef DEBUGP
1100          RLOG_ARG0(L_ERROR,DBG_UEID,ueCb->key.ueId,"DL Ue Cb Deletion Failed");
1101 #endif
1102          RETVALUE(ret);
1103       }
1104       ueCb = NULLP;
1105    }
1106
1107    RETVALUE(ret);
1108 } /* pjDbmDelAllUe */
1109
1110 #ifdef ANSI
1111 PUBLIC S16 pjDbmDlShutdown 
1112 (
1113 PjCb *gCb
1114 )
1115 #else
1116 PUBLIC S16 pjDbmDlShutdown(gCb)
1117 PjCb *gCb;
1118 #endif
1119 {
1120 #if (ERRCLASS & ERRCLS_DEBUG)
1121     S16 ret;
1122 #endif
1123    TRC3(pjDbmDlShutdown)
1124
1125 #if (ERRCLASS & ERRCLS_DEBUG)
1126    ret = pjDbmDlDeInit(gCb);
1127    if (ret != ROK)
1128    {
1129       RLOG0(L_FATAL, "DL DeInitialization Failed");
1130    }
1131 #else
1132    pjDbmDlDeInit(gCb);
1133 #endif /* ERRCLASS & ERRCLS_DEBUG */
1134
1135    RETVALUE(ROK);
1136 } /* pjDbmShutdown */
1137
1138 /**
1139  *
1140  * @brief Handler to create a RB control block.
1141  *       
1142  *
1143  * @b Description
1144  *        This function is called to create a RLC control block or PDCP 
1145  *        control block based on rb flag and update the pointers in RbCb.
1146  *        If the RbCb is already allocated, the rbId is updated in KwRbCb
1147  *        or PjDlRbCb based on rb. If the RbCb has not been allocated earlier,
1148  *        a new RbCb is created and the pointers are updated along with the
1149  *        rbIds.
1150  *
1151  *  @param[in] rbId      RB ID of the entity
1152  *  @param[in] rbCbLst   List of the RBs in the UeCb
1153  *  @param[in] rb        The RB to be created. This can be
1154  *                       PJ_CFG_PDCP when PDCP is created
1155  *                       or PJ_CFG_RLC when RLC is being
1156  *                       created. 
1157  *  
1158  *  @return  S16
1159  *      -# ROK 
1160  *      -# RFAILED 
1161  *
1162 */
1163 #ifdef ANSI
1164 PUBLIC PjDlRbCb* pjDbmCreateDlRbCb
1165 (
1166 PjCb    *gCb,
1167 U8      rbId,
1168 U8      rbType, 
1169 PjDlUeCb  *ueCb, 
1170 U8      rb
1171 )
1172 #else
1173 PUBLIC PjDlRbCb* pjDbmCreateDlRbCb(gCb,rbId,rbType,ueCb,rb)
1174 PjCb    *gCb;
1175 U8      rbId; 
1176 U8      rbType;
1177 PjDlUeCb  *ueCb; 
1178 U8      rb;
1179 #endif
1180 {
1181    PjDlRbCb   *rbCb;
1182    PjDlRbCb   **rbCbLst;
1183
1184    TRC2(pjDbmCreateDlRbCb)
1185
1186    rbCb = NULLP;
1187    rbCbLst = NULLP;
1188
1189    PJ_DBM_FETCH_DL_RBCB(rbId, rbType, ueCb, rbCb);
1190
1191    if(rbCb == NULLP)
1192    {
1193       PJ_ALLOC(gCb, rbCb, sizeof(PjDlRbCb));
1194       if ( rbCb == NULLP )
1195       {
1196          RLOG0(L_FATAL, "Memory Allocation failed.");
1197          RETVALUE(rbCb);
1198       }
1199    }
1200
1201    rbCb->rbId   = rbId;
1202    rbCb->rbType = rbType;
1203
1204    rbCbLst = ((rbType == CM_LTE_SRB)? ueCb->srbCb:ueCb->drbCb); 
1205    rbCbLst[rbId] = rbCb;
1206    /* kw005.201 ccpu00117318, updating the statistics */   
1207    PJ_LMM_RB_STS_INC(gCb);                                    
1208    
1209    RETVALUE(rbCb); 
1210    
1211 } /* pjDbmCreateRbCb */
1212
1213 /**
1214  *
1215  * @brief Handler to fetch a  PDCP RB control block.
1216  *       
1217  *
1218  * @b Description
1219  *        This function is used to fetch the PDCP RB control block based on 
1220  *        the RB id. The pointer to PjDlRbCb is returned.
1221  *       
1222  *  @param[in]  ueCb    UE control block of the PDCP RB
1223  *  @param[in]  rbId    RB ID of the required PDCP entity.
1224  *  @param[out] pjRbCb  PDCP RB Control Block.
1225  *
1226  *  @return  S16
1227  *      -# ROK 
1228  *      -# RFAILED 
1229  *
1230  */
1231 #ifdef ANSI
1232 PUBLIC S16 pjDbmFetchPjDlRbCb
1233 (
1234 PjDlUeCb  *ueCb,
1235 U8       rbId,
1236 U8       rbType,
1237 PjDlRbCb  **pjRbCb 
1238 )
1239 #else
1240 PUBLIC S16 pjDbmFetchPjDlRbCb(ueCb,rbId,rbType,pjRbCb)
1241 PjDlUeCb  *ueCb;      
1242 U8       rbId;
1243 U8       rbType;
1244 PjDlRbCb  **pjRbCb;
1245 #endif
1246 {
1247    PjDlRbCb    *rbCb;
1248
1249    TRC2(PjDbmFetchPjDlRbCb)
1250
1251    *pjRbCb = NULLP;
1252
1253    PJ_DBM_FETCH_DL_RBCB(rbId, rbType, ueCb, rbCb);
1254    if ( rbCb != NULLP )
1255    {
1256       *pjRbCb = rbCb;
1257    }
1258
1259    RETVALUE(ROK);
1260
1261 } /* pjDbmFetchPjDlRbCb */
1262
1263 /**
1264  *
1265  * @brief Handler to delete a PDCP/RLC RB control block.
1266  *       
1267  *
1268  * @b Description
1269  *        This function is used to delete the PDCP/RLC RB control block based 
1270  *        on RB id and the RB type (PDCP/RLC). If the corresponding RB is 
1271  *        present, the cfgStat flag is unset. If the cfgStat flag is zero,
1272  *        the RBCB is freed.
1273  *
1274  *  @param[in]  rbId    RB ID of the to be deleted RB
1275  *  @param[in]  rbCbLst RbCb list in UE CB
1276  *  @param[in]  rb      The RB to be deleted. This can be
1277  *                      PJ_CFG_PDCP when PDCP is created
1278  *                      or PJ_CFG_RLC when RLC is being
1279  *                      created.
1280  *  @return  S16
1281  *      -# ROK 
1282  *      -# RFAILED 
1283  *
1284  */
1285 #ifdef ANSI
1286 PUBLIC S16 pjDbmDelDlRbCb
1287 (
1288 PjCb   *gCb,
1289 U8      rbId,
1290 U8      rbType,
1291 PjDlRbCb   **rbCb, 
1292 U8      rb,
1293 PjDlUeCb  *ueCb
1294 )
1295 #else
1296 PUBLIC S16 pjDbmDelDlRbCb(gCb,rbId,rbType,rbCb,rb,ueCb)
1297 PjCb   *gCb;
1298 U8      rbId;
1299 U8      rbType;
1300 PjDlRbCb   **rbCb;
1301 U8      rb;
1302 PjDlUeCb  *ueCb;
1303 #endif
1304 {
1305    S16      ret;
1306    PjDlRbCb   **rbCbLst;
1307    rbCbLst = NULLP;
1308    
1309    TRC2(pjDbmDelDlRbCb)
1310
1311    ret   = RFAILED;
1312    /*updating rbCbList */
1313    rbCbLst = ((rbType == CM_LTE_SRB)? ueCb->srbCb:ueCb->drbCb);
1314
1315    if ( (*rbCb) != NULLP )
1316    {
1317       PJ_DBM_DELETE_DL_RBCB(gCb,*rbCb);
1318       ret = ROK;
1319       /*updating rbCbList */
1320       rbCbLst[rbId] = NULLP;
1321    }
1322    RETVALUE(ret);
1323
1324 } /* pjDbmDelRbCb */
1325
1326
1327
1328
1329 /********************************************************************30**
1330   
1331          End of file
1332 **********************************************************************/