[Epic-ID: ODUHIGH-461][Task-ID: ODUHIGH-468]Unused files and functions removed/disabled
[o-du/l2.git] / src / 5gnrmac / rg_utl.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  
21      Name:     LTE-MAC layer
22   
23      Type:     C source file
24   
25      Desc:     C source code for Entry point fucntions
26   
27      File:     rg_utl.c
28   
29 **********************************************************************/
30
31 /** @file rg_utl.c
32 @brief This file implements utility functions for LTE MAC
33 */
34
35
36 /* header include files (.h) */
37 #include "common_def.h"
38 #include "rg_env.h"        /* MAC Environment Defines */
39 #include "crg.h"           /* CRG Interface defines */
40 #include "rgu.h"           /* RGU Interface defines */
41 #include "tfu.h"           /* TFU Interface defines */
42 #include "rg_sch_inf.h"    /* RGR Interface defines */
43 #include "lrg.h"           /* LRG Interface defines */
44 #include  "mac_utils.h"
45
46 #include "rg_prg.h"        /* PRG(MAC-MAC) Interface includes */
47 #include "rg.h"            /* MAC defines */
48 #include "rg_err.h"        /* MAC error defines */
49
50 /* header/extern include files (.x) */
51 #include "cm5.x"           /* Timer */
52
53 #include "crg.x"           /* CRG Interface includes */
54 #include "rgu.x"           /* RGU Interface includes */
55 #include "tfu.x"           /* TFU Interface includes */
56 #include "rg_sch_inf.x"    /* RGR Interface includes */
57 #include "lrg.x"           /* LRG Interface includes */
58 #include "rg_prg.x"        /* PRG(MAC-MAC) Interface includes */
59
60 #include "du_app_mac_inf.h"
61 #include "rg.x"            /* MAC includes */
62
63 /* local defines */
64 #define RG_NON_MIMO_IDX 0
65
66 /***********************************************************
67  *
68  *     Func : rgAllocSBuf
69  *
70  *     Desc : Utility Function to Allocate static buffer. 
71  *            Memory allocated is assumed contiguous.
72  *            
73  *
74  *     Ret  : ROK
75  *            RFAILED
76  *
77  *     Notes: Caller doesnt need to raise the alarm in case of memory
78  *            allocation gets failed. 
79  *
80  *     File : rg_utl.c
81  *
82  **********************************************************/
83 S16 rgAllocSBuf
84 (
85 Inst    inst,
86 Data    **pData,            /* Pointer of the data to be returned */
87 Size    size                /* size */
88 )
89 {
90    RgUstaDgn dgn;      /* Alarm diagnostics structure */
91
92    /* Initialize the param to NULLP */
93    *pData = NULLP;
94
95    if (size == 0)
96    {
97       return RFAILED;
98    }
99
100    /* allocate buffer */
101 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
102    MS_BUF_ADD_ALLOC_CALLER();
103 #endif /* */
104    MAC_ALLOC(pData, size);
105    if(pData == NULLP)
106    {
107      dgn.type = LRG_USTA_DGNVAL_MEM;
108      dgn.u.mem.region = rgCb[inst].rgInit.region;
109      dgn.u.mem.pool = rgCb[inst].rgInit.pool;
110      /*  Send an alarm to Layer Manager */
111      rgLMMStaInd(inst,LCM_CATEGORY_RESOURCE, LCM_EVENT_SMEM_ALLOC_FAIL,
112                                        LCM_CAUSE_MEM_ALLOC_FAIL, &dgn);
113       DU_LOG("\nERROR  -->  MAC : Unable to Allocate Buffer");
114       return RFAILED;
115    }
116
117    /* zero out the allocated memory */
118    memset(*pData, 0x00, size);
119
120    return ROK;
121
122 } /* end of rgAllocSBuf */
123
124 /*
125 *
126 *       Fun:   rgFreeSharableSBuf
127 *
128 *       Desc:  The argument to rgFreeSBuf() is a pointer to a block
129 *              previously allocated by rgAllocSBuf() and size. It 
130 *              deallocates the memory. 
131 *
132 *       Ret:   void
133 *
134 *       Notes: ccpu00117052 - MOD- changed the Data parameter from 
135 *                             pointer to address of pointer so that
136 *                             the freed memory could be set to NULLP
137 *
138 *       File:  rg_utl.c
139 */
140 Void rgFreeSharableSBuf
141 (
142 Inst inst,
143 Data **data,         /* address of pointer to data */
144 Size size            /* size */
145 )
146 {
147
148    if ((data == NULLP) || (*data == NULLP) || (size == 0))
149    {
150       return;
151    }
152
153    /* Deallocate buffer */
154    MAC_FREE_SHRABL_BUF(rgCb[inst].rgInit.region, rgCb[inst].rgInit.pool, *data, size);
155    
156    if (data != NULLP)
157    {
158       return;
159    }
160
161    *data = NULLP;
162
163    return;
164
165 } /* end of rgFreeSharableBuf */
166
167
168
169 /*
170 *
171 *       Fun:   rgFreeSBuf
172 *
173 *       Desc:  The argument to rgFreeSBuf() is a pointer to a block
174 *              previously allocated by rgAllocSBuf() and size. It 
175 *              deallocates the memory. 
176 *
177 *       Ret:   void
178 *
179 *       Notes: ccpu00117052 - MOD- changed the Data parameter from 
180 *                             pointer to address of pointer so that
181 *                             the freed memory could be set to NULLP
182 *
183 *       File:  rg_utl.c
184 */
185 Void rgFreeSBuf
186 (
187 Inst inst,
188 Data **data,         /* address of pointer to data */
189 Size size            /* size */
190 )
191 {
192
193    if ((data == NULLP) || (*data == NULLP) || (size == 0))
194    {
195       return;
196    }
197
198
199 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
200    MS_BUF_ADD_CALLER();
201 #endif /* */
202    /* Deallocate buffer */
203    MAC_FREE(data, size);
204
205    if (data != NULLP)
206    {
207       DU_LOG("\nERROR  -->  MAC : rgFreeSBuf failed.\n");
208       return;
209    }
210
211    *data = NULLP;
212
213    return;
214
215 } /* end of rgFreeSBuf */
216
217
218 /***********************************************************
219  *
220  *     Func : rgFillDgnParams
221  *
222  *     Desc : Utility Function to Fill Diagonostic params. 
223  *
224  *     Ret  : None.
225  *
226  *     Notes: None.
227  *
228  *     File : rg_utl.c
229  *
230  **********************************************************/
231 Void rgFillDgnParams
232 (
233 Inst        inst,
234 RgUstaDgn   *dgn,
235 uint8_t     dgnType
236 )
237 {
238
239    switch(dgnType)
240    {
241       case LRG_USTA_DGNVAL_MEM:
242          dgn->type = (uint8_t) LRG_USTA_DGNVAL_MEM;
243          dgn->u.mem.region  = rgCb[inst].rgInit.region;
244          dgn->u.mem.pool    = rgCb[inst].rgInit.pool;
245       break;
246
247       default:
248       break;
249    }
250
251    return;
252 } /* end of rgFillDgnParams */
253
254
255 /**********************************************************************
256  
257          End of file
258 **********************************************************************/