1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
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 #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
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 *******************************************************************************/
19 /************************************************************************
25 Desc: C source code for Entry point fucntions
29 **********************************************************************/
32 @brief This file implements utility functions for LTE MAC
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"
46 #include "rg_prg.h" /* PRG(MAC-MAC) Interface includes */
47 #include "rg.h" /* MAC defines */
48 #include "rg_err.h" /* MAC error defines */
50 /* header/extern include files (.x) */
51 #include "cm5.x" /* Timer */
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 */
60 #include "du_app_mac_inf.h"
61 #include "rg.x" /* MAC includes */
64 #define RG_NON_MIMO_IDX 0
66 RgCb rgCb[RG_MAX_INST];
67 /***********************************************************
71 * Desc : Utility Function to Allocate static buffer.
72 * Memory allocated is assumed contiguous.
78 * Notes: Caller doesnt need to raise the alarm in case of memory
79 * allocation gets failed.
83 **********************************************************/
87 Data **pData, /* Pointer of the data to be returned */
91 RgUstaDgn dgn; /* Alarm diagnostics structure */
93 /* Initialize the param to NULLP */
101 /* allocate buffer */
102 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
103 MS_BUF_ADD_ALLOC_CALLER();
105 MAC_ALLOC(pData, size);
108 dgn.type = LRG_USTA_DGNVAL_MEM;
109 dgn.u.mem.region = rgCb[inst].rgInit.region;
110 dgn.u.mem.pool = rgCb[inst].rgInit.pool;
111 /* Send an alarm to Layer Manager */
112 rgLMMStaInd(inst,LCM_CATEGORY_RESOURCE, LCM_EVENT_SMEM_ALLOC_FAIL,
113 LCM_CAUSE_MEM_ALLOC_FAIL, &dgn);
114 DU_LOG("\nERROR --> MAC : Unable to Allocate Buffer");
118 /* zero out the allocated memory */
119 memset(*pData, 0x00, size);
123 } /* end of rgAllocSBuf */
127 * Fun: rgFreeSharableSBuf
129 * Desc: The argument to rgFreeSBuf() is a pointer to a block
130 * previously allocated by rgAllocSBuf() and size. It
131 * deallocates the memory.
135 * Notes: ccpu00117052 - MOD- changed the Data parameter from
136 * pointer to address of pointer so that
137 * the freed memory could be set to NULLP
141 Void rgFreeSharableSBuf
144 Data **data, /* address of pointer to data */
149 if ((data == NULLP) || (*data == NULLP) || (size == 0))
154 /* Deallocate buffer */
155 MAC_FREE_SHRABL_BUF(rgCb[inst].rgInit.region, rgCb[inst].rgInit.pool, *data, size);
166 } /* end of rgFreeSharableBuf */
174 * Desc: The argument to rgFreeSBuf() is a pointer to a block
175 * previously allocated by rgAllocSBuf() and size. It
176 * deallocates the memory.
180 * Notes: ccpu00117052 - MOD- changed the Data parameter from
181 * pointer to address of pointer so that
182 * the freed memory could be set to NULLP
189 Data **data, /* address of pointer to data */
194 if ((data == NULLP) || (*data == NULLP) || (size == 0))
200 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
203 /* Deallocate buffer */
204 MAC_FREE(data, size);
208 DU_LOG("\nERROR --> MAC : rgFreeSBuf failed.\n");
216 } /* end of rgFreeSBuf */
219 /***********************************************************
221 * Func : rgFillDgnParams
223 * Desc : Utility Function to Fill Diagonostic params.
231 **********************************************************/
242 case LRG_USTA_DGNVAL_MEM:
243 dgn->type = (uint8_t) LRG_USTA_DGNVAL_MEM;
244 dgn->u.mem.region = rgCb[inst].rgInit.region;
245 dgn->u.mem.pool = rgCb[inst].rgInit.pool;
253 } /* end of rgFillDgnParams */
256 /**********************************************************************
259 **********************************************************************/