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 /***********************************************************
70 * Desc : Utility Function to Allocate static buffer.
71 * Memory allocated is assumed contiguous.
77 * Notes: Caller doesnt need to raise the alarm in case of memory
78 * allocation gets failed.
82 **********************************************************/
86 Data **pData, /* Pointer of the data to be returned */
90 RgUstaDgn dgn; /* Alarm diagnostics structure */
92 /* Initialize the param to NULLP */
100 /* allocate buffer */
101 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
102 MS_BUF_ADD_ALLOC_CALLER();
104 MAC_ALLOC(pData, size);
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");
117 /* zero out the allocated memory */
118 memset(*pData, 0x00, size);
122 } /* end of rgAllocSBuf */
126 * Fun: rgFreeSharableSBuf
128 * Desc: The argument to rgFreeSBuf() is a pointer to a block
129 * previously allocated by rgAllocSBuf() and size. It
130 * deallocates the memory.
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
140 Void rgFreeSharableSBuf
143 Data **data, /* address of pointer to data */
148 if ((data == NULLP) || (*data == NULLP) || (size == 0))
153 /* Deallocate buffer */
154 MAC_FREE_SHRABL_BUF(rgCb[inst].rgInit.region, rgCb[inst].rgInit.pool, *data, size);
165 } /* end of rgFreeSharableBuf */
173 * Desc: The argument to rgFreeSBuf() is a pointer to a block
174 * previously allocated by rgAllocSBuf() and size. It
175 * deallocates the memory.
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
188 Data **data, /* address of pointer to data */
193 if ((data == NULLP) || (*data == NULLP) || (size == 0))
199 #ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */
202 /* Deallocate buffer */
203 MAC_FREE(data, size);
207 DU_LOG("\nERROR --> MAC : rgFreeSBuf failed.\n");
215 } /* end of rgFreeSBuf */
218 /***********************************************************
220 * Func : rgFillDgnParams
222 * Desc : Utility Function to Fill Diagonostic params.
230 **********************************************************/
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;
252 } /* end of rgFillDgnParams */
255 /**********************************************************************
258 **********************************************************************/