Committing in PDCP code
[o-du/l2.git] / src / 5gnrpdcp / pj_dbm.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.c
39   
40 *********************************************************************21*/
41 static const char* RLOG_MODULE_NAME="PDCP";
42 static int RLOG_MODULE_ID=1024;
43 static int RLOG_FILE_ID=214;
44
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_err.h"
63
64 /* extern (.x) include files */
65 #include "gen.x"                /* general */
66 #include "ssi.x"                /* system services interface */
67 #include "cm_lib.x"             /* common library */
68 #include "cm5.x"                /* Timer Functions */
69 #include "cm_hash.x"            /* common hash module */
70 #include "cm_lte.x"             /* common LTE file */
71 #include "cm_llist.x"           /* common list header file */
72 #include "cpj.x"                /* RRC layer */
73 #include "pju.x"                /* PDCP service user */
74 #include "lpj.x"                /* LM Interface */
75 #include "pj.x"                 /* RLC layer */
76
77
78 \f
79 /* local defines */
80
81 /* local externs */
82
83 /* forward references */
84
85 /* public variable declarations */
86
87 /* This structure holds all the global structs we need. */
88
89 /* private variable declarations */
90
91 /* private function declarations */
92
93 /** @file gp_pj_dbm.c
94 @brief PDCP DBM Module
95 **/
96
97 /*****************************************************************************
98  *                  HANDLER FOR THE TRANSMISSION BUFFER
99  ****************************************************************************/
100 \f
101 /**
102  *
103  * @brief Handler to initialize  Buffer
104  *
105  * @b Description
106  *        This function is invoked by config to initialize the Buffer
107  *        hash List
108  *
109  *  @param[in]    buf       Rx/Tx Buffer Control Point
110  *  @param[in]    numBins   number of Bins
111  *
112  *  @return  S16
113  *      -# ROK 
114  *      -# RFAILED 
115  *
116 */
117 #ifdef ANSI
118 PUBLIC S16 pjDbmBufInit
119 (
120 PjCb        *gCb,
121 PjBuf       *buf,            /* !< Rx/Tx Buffer */
122 U8          numBins          /* !< number of Bins */
123 )
124 #else
125 PUBLIC S16 pjDbmBufInit(gCb,buf, numBins)
126 PjCb        *gCb;
127 PjBuf       *buf;            /* !< Rx/Tx Buffer */ 
128 U8          numBins;         /* !< number of Bins */             
129 #endif
130 {
131    U8       hashIndex;        /* HashIndex of array */
132
133    TRC3(pjDbmBufInit)
134
135    RLOG1(L_DEBUG, "pjDbmBufInit(buf, numBins(%d)", numBins);
136
137    /* Initialize CmLListCps*/
138    PJ_ALLOC(gCb,buf->datQ, (sizeof(CmLListCp) * numBins));
139 #if (ERRCLASS & ERRCLS_DEBUG)
140    if (buf->datQ == NULLP)
141    {
142       RLOG0(L_FATAL, "Memory Allocation failed.");
143       RETVALUE(RFAILED);
144    }
145 #endif /* (ERRCLASS & ERRCLS_DEBUG) */
146
147    for(hashIndex = 0; hashIndex < numBins; hashIndex++)
148    {
149       cmLListInit(&buf->datQ[hashIndex]);
150    }
151
152    /* Initialistations of buf */
153    buf->numEntries = 0;
154    buf->numBins    = numBins;
155
156    RETVALUE(ROK);
157 } /* pjDbmBufInit */
158
159
160 /********************************************************************30**
161   
162          End of file
163 **********************************************************************/