1296177Sjhibbits/******************************************************************************
2296177Sjhibbits
3296177Sjhibbits � 1995-2003, 2004, 2005-2011 Freescale Semiconductor, Inc.
4296177Sjhibbits All rights reserved.
5296177Sjhibbits
6296177Sjhibbits This is proprietary source code of Freescale Semiconductor Inc.,
7296177Sjhibbits and its use is subject to the NetComm Device Drivers EULA.
8296177Sjhibbits The copyright notice above does not evidence any actual or intended
9296177Sjhibbits publication of such source code.
10296177Sjhibbits
11296177Sjhibbits ALTERNATIVELY, redistribution and use in source and binary forms, with
12296177Sjhibbits or without modification, are permitted provided that the following
13296177Sjhibbits conditions are met:
14296177Sjhibbits     * Redistributions of source code must retain the above copyright
15296177Sjhibbits       notice, this list of conditions and the following disclaimer.
16296177Sjhibbits     * Redistributions in binary form must reproduce the above copyright
17296177Sjhibbits       notice, this list of conditions and the following disclaimer in the
18296177Sjhibbits       documentation and/or other materials provided with the distribution.
19296177Sjhibbits     * Neither the name of Freescale Semiconductor nor the
20296177Sjhibbits       names of its contributors may be used to endorse or promote products
21296177Sjhibbits       derived from this software without specific prior written permission.
22296177Sjhibbits
23296177Sjhibbits THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
24296177Sjhibbits EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25296177Sjhibbits WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26296177Sjhibbits DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
27296177Sjhibbits DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28296177Sjhibbits (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29296177Sjhibbits LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30296177Sjhibbits ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31296177Sjhibbits (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32296177Sjhibbits SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33296177Sjhibbits *
34296177Sjhibbits
35296177Sjhibbits **************************************************************************/
36296177Sjhibbits/******************************************************************************
37296177Sjhibbits @File          bm_ext.h
38296177Sjhibbits
39296177Sjhibbits @Description   BM API
40296177Sjhibbits*//***************************************************************************/
41296177Sjhibbits#ifndef __BM_EXT_H
42296177Sjhibbits#define __BM_EXT_H
43296177Sjhibbits
44296177Sjhibbits#include "error_ext.h"
45296177Sjhibbits#include "std_ext.h"
46296177Sjhibbits
47296177Sjhibbits
48296177Sjhibbits/**************************************************************************//**
49296177Sjhibbits @Group         BM_grp Buffer Manager API
50296177Sjhibbits
51296177Sjhibbits @Description   BM API functions, definitions and enums.
52296177Sjhibbits
53296177Sjhibbits @{
54296177Sjhibbits*//***************************************************************************/
55296177Sjhibbits
56296177Sjhibbits/**************************************************************************//**
57296177Sjhibbits @Description   This callback type is used when handling pool depletion entry/exit.
58296177Sjhibbits
59296177Sjhibbits                User provides this function. Driver invokes it.
60296177Sjhibbits
61296177Sjhibbits @Param[in]     h_App       - User's application descriptor.
62296177Sjhibbits @Param[in]     in          - TRUE when entered depletion state
63296177Sjhibbits                              FALSE when exit the depletion state.
64296177Sjhibbits *//***************************************************************************/
65296177Sjhibbitstypedef void (t_BmDepletionCallback)(t_Handle h_App, bool in);
66296177Sjhibbits
67296177Sjhibbits/**************************************************************************//**
68296177Sjhibbits @Group         BM_lib_grp BM common API
69296177Sjhibbits
70296177Sjhibbits @Description   BM common API functions, definitions and enums.
71296177Sjhibbits
72296177Sjhibbits @{
73296177Sjhibbits*//***************************************************************************/
74296177Sjhibbits
75296177Sjhibbits/**************************************************************************//**
76296177Sjhibbits @Description   BM Exceptions
77296177Sjhibbits*//***************************************************************************/
78296177Sjhibbitstypedef enum e_BmExceptions {
79296177Sjhibbits    e_BM_EX_INVALID_COMMAND = 0 ,   /**< Invalid Command Verb Interrupt */
80296177Sjhibbits    e_BM_EX_FBPR_THRESHOLD,         /**< FBPR Low Watermark Interrupt. */
81296177Sjhibbits    e_BM_EX_SINGLE_ECC,             /**< Single Bit ECC Error Interrupt. */
82296177Sjhibbits    e_BM_EX_MULTI_ECC               /**< Multi Bit ECC Error Interrupt */
83296177Sjhibbits} e_BmExceptions;
84296177Sjhibbits
85296177Sjhibbits
86296177Sjhibbits/**************************************************************************//**
87296177Sjhibbits @Group         BM_init_grp BM (common) Initialization Unit
88296177Sjhibbits
89296177Sjhibbits @Description   BM (common) Initialization Unit
90296177Sjhibbits
91296177Sjhibbits @{
92296177Sjhibbits*//***************************************************************************/
93296177Sjhibbits
94296177Sjhibbits/**************************************************************************//**
95296177Sjhibbits @Function      t_BmExceptionsCallback
96296177Sjhibbits
97296177Sjhibbits @Description   Exceptions user callback routine, will be called upon an
98296177Sjhibbits                exception passing the exception identification.
99296177Sjhibbits
100296177Sjhibbits @Param[in]     h_App      - User's application descriptor.
101296177Sjhibbits @Param[in]     exception  - The exception.
102296177Sjhibbits*//***************************************************************************/
103296177Sjhibbitstypedef void (t_BmExceptionsCallback) (t_Handle              h_App,
104296177Sjhibbits                                       e_BmExceptions        exception);
105296177Sjhibbits
106296177Sjhibbits/**************************************************************************//**
107296177Sjhibbits @Description   structure representing BM initialization parameters
108296177Sjhibbits*//***************************************************************************/
109296177Sjhibbitstypedef struct {
110296177Sjhibbits    uint8_t                 guestId;                /**< BM Partition Id */
111296177Sjhibbits
112296177Sjhibbits    uintptr_t               baseAddress;            /**< Bm base address (virtual).
113296177Sjhibbits                                                         NOTE: this parameter relevant only for BM in master mode ('guestId'=NCSW_MASTER_ID). */
114296177Sjhibbits    uint16_t                liodn;                  /**< This value is attached to every transaction initiated by
115296177Sjhibbits                                                         BMan when accessing its private data structures
116296177Sjhibbits                                                         NOTE: this parameter relevant only for BM in master mode ('guestId'=NCSW_MASTER_ID). */
117296177Sjhibbits    uint32_t                totalNumOfBuffers;      /**< Total number of buffers
118296177Sjhibbits                                                         NOTE: this parameter relevant only for BM in master mode ('guestId'=NCSW_MASTER_ID). */
119296177Sjhibbits    uint32_t                fbprMemPartitionId;     /**< FBPR's mem partition id;
120296177Sjhibbits                                                         NOTE: The memory partition must be non-cacheable and no-coherent area.
121296177Sjhibbits                                                         NOTE: this parameter relevant only for BM in master mode ('guestId'=NCSW_MASTER_ID). */
122296177Sjhibbits    t_BmExceptionsCallback  *f_Exception;           /**< An application callback routine to handle exceptions.
123296177Sjhibbits                                                         NOTE: this parameter relevant only for BM in master mode ('guestId'=NCSW_MASTER_ID). */
124296177Sjhibbits    t_Handle                h_App;                  /**< A handle to an application layer object; This handle will
125296177Sjhibbits                                                         be passed by the driver upon calling the above callbacks.
126296177Sjhibbits                                                         NOTE: this parameter relevant only for BM in master mode ('guestId'=NCSW_MASTER_ID). */
127296177Sjhibbits    int                     errIrq;                 /**< BM error interrupt line; NO_IRQ if interrupts not used.
128296177Sjhibbits                                                         NOTE: this parameter relevant only for BM in master mode ('guestId'=NCSW_MASTER_ID). */
129296177Sjhibbits
130296177Sjhibbits    uint8_t                 partBpidBase;           /**< The first buffer-pool-id dedicated to this partition.
131296177Sjhibbits                                                         NOTE: this parameter relevant only when working with multiple partitions. */
132296177Sjhibbits    uint8_t                 partNumOfPools;         /**< Number of Pools dedicated to this partition.
133296177Sjhibbits                                                         NOTE: this parameter relevant only when working with multiple partitions. */
134296177Sjhibbits} t_BmParam;
135296177Sjhibbits
136296177Sjhibbits
137296177Sjhibbits/**************************************************************************//**
138296177Sjhibbits @Function      BM_Config
139296177Sjhibbits
140296177Sjhibbits @Description   Creates descriptor for the BM module and initializes the BM module.
141296177Sjhibbits
142296177Sjhibbits                The routine returns a handle (descriptor) to the BM object.
143296177Sjhibbits                This descriptor must be passed as first parameter to all other
144296177Sjhibbits                BM function calls.
145296177Sjhibbits
146296177Sjhibbits @Param[in]     p_BmParam   - A pointer to data structure of parameters
147296177Sjhibbits
148296177Sjhibbits @Return        Handle to BM object, or NULL for Failure.
149296177Sjhibbits*//***************************************************************************/
150296177Sjhibbitst_Handle    BM_Config(t_BmParam *p_BmParam);
151296177Sjhibbits
152296177Sjhibbits/**************************************************************************//**
153296177Sjhibbits @Function      BM_Init
154296177Sjhibbits
155296177Sjhibbits @Description   Initializes the BM module
156296177Sjhibbits
157296177Sjhibbits @Param[in]     h_Bm            - A handle to the BM module
158296177Sjhibbits
159296177Sjhibbits @Return        E_OK on success; Error code otherwise.
160296177Sjhibbits
161296177Sjhibbits @Cautions      Allowed only following BM_Config().
162296177Sjhibbits*//***************************************************************************/
163296177Sjhibbitst_Error    BM_Init(t_Handle h_Bm);
164296177Sjhibbits
165296177Sjhibbits/**************************************************************************//**
166296177Sjhibbits @Function      BM_Free
167296177Sjhibbits
168296177Sjhibbits @Description   Frees all resources that were assigned to BM module.
169296177Sjhibbits
170296177Sjhibbits                Calling this routine invalidates the descriptor.
171296177Sjhibbits
172296177Sjhibbits @Param[in]     h_Bm            - A handle to the BM module
173296177Sjhibbits
174296177Sjhibbits @Return        E_OK on success; Error code otherwise.
175296177Sjhibbits*//***************************************************************************/
176296177Sjhibbitst_Error     BM_Free(t_Handle h_Bm);
177296177Sjhibbits
178296177Sjhibbits/**************************************************************************//**
179296177Sjhibbits @Group         BM_advanced_init_grp    BM (common) Advanced Configuration Unit
180296177Sjhibbits
181296177Sjhibbits @Description   Configuration functions used to change default values.
182296177Sjhibbits
183296177Sjhibbits @{
184296177Sjhibbits*//***************************************************************************/
185296177Sjhibbits
186296177Sjhibbits/**************************************************************************//**
187296177Sjhibbits @Function      BM_ConfigFbprThreshold
188296177Sjhibbits
189296177Sjhibbits @Description   Change the fbpr threshold from its default
190296177Sjhibbits                configuration [0].
191296177Sjhibbits                An interrupt if enables is asserted when the number of FBPRs is below this threshold.
192296177Sjhibbits                NOTE: this parameter relevant only for BM in master mode ('guestId'=NCSW_MASTER_ID).
193296177Sjhibbits
194296177Sjhibbits @Param[in]     h_Bm            - A handle to the BM module
195296177Sjhibbits @Param[in]     threshold       - threshold value.
196296177Sjhibbits
197296177Sjhibbits @Return        E_OK on success; Error code otherwise.
198296177Sjhibbits
199296177Sjhibbits @Cautions      Allowed only following BM_Config() and before BM_Init().
200296177Sjhibbits*//***************************************************************************/
201296177Sjhibbitst_Error     BM_ConfigFbprThreshold(t_Handle h_Bm, uint32_t threshold);
202296177Sjhibbits
203296177Sjhibbits/** @} */ /* end of BM_advanced_init_grp group */
204296177Sjhibbits/** @} */ /* end of BM_init_grp group */
205296177Sjhibbits
206296177Sjhibbits/**************************************************************************//**
207296177Sjhibbits @Group         BM_runtime_control_grp BM (common) Runtime Control Unit
208296177Sjhibbits
209296177Sjhibbits @Description   BM (common) Runtime control unit API functions, definitions and enums.
210296177Sjhibbits
211296177Sjhibbits @{
212296177Sjhibbits*//***************************************************************************/
213296177Sjhibbits
214296177Sjhibbits/**************************************************************************//**
215296177Sjhibbits @Description   enum for defining BM counters
216296177Sjhibbits*//***************************************************************************/
217296177Sjhibbitstypedef enum e_BmCounters {
218296177Sjhibbits    e_BM_COUNTERS_FBPR = 0              /**< Total Free Buffer Proxy Record (FBPR) Free Pool Count in external memory */
219296177Sjhibbits} e_BmCounters;
220296177Sjhibbits
221296177Sjhibbits/**************************************************************************//**
222296177Sjhibbits @Description   structure for returning revision information
223296177Sjhibbits*//***************************************************************************/
224296177Sjhibbitstypedef struct t_BmRevisionInfo {
225296177Sjhibbits    uint8_t         majorRev;               /**< Major revision */
226296177Sjhibbits    uint8_t         minorRev;               /**< Minor revision */
227296177Sjhibbits} t_BmRevisionInfo;
228296177Sjhibbits
229296177Sjhibbits#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))
230296177Sjhibbits/**************************************************************************//**
231296177Sjhibbits @Function      BM_DumpRegs
232296177Sjhibbits
233296177Sjhibbits @Description   Dumps all BM registers
234296177Sjhibbits                NOTE: this parameter relevant only for BM in master mode ('guestId'=NCSW_MASTER_ID).
235296177Sjhibbits
236296177Sjhibbits @Param[in]     h_Bm      A handle to an BM Module.
237296177Sjhibbits
238296177Sjhibbits @Return        E_OK on success;
239296177Sjhibbits
240296177Sjhibbits @Cautions      Allowed only after BM_Init().
241296177Sjhibbits*//***************************************************************************/
242296177Sjhibbitst_Error BM_DumpRegs(t_Handle h_Bm);
243296177Sjhibbits#endif /* (defined(DEBUG_ERRORS) && ... */
244296177Sjhibbits
245296177Sjhibbits/**************************************************************************//**
246296177Sjhibbits @Function      BM_SetException
247296177Sjhibbits
248296177Sjhibbits @Description   Calling this routine enables/disables the specified exception.
249296177Sjhibbits                NOTE: this parameter relevant only for BM in master mode ('guestId'=NCSW_MASTER_ID).
250296177Sjhibbits
251296177Sjhibbits @Param[in]     h_Bm        - A handle to the BM Module.
252296177Sjhibbits @Param[in]     exception   - The exception to be selected.
253296177Sjhibbits @Param[in]     enable      - TRUE to enable interrupt, FALSE to mask it.
254296177Sjhibbits
255296177Sjhibbits @Cautions      Allowed only following BM_Init().
256296177Sjhibbits*//***************************************************************************/
257296177Sjhibbitst_Error     BM_SetException(t_Handle h_Bm, e_BmExceptions exception, bool enable);
258296177Sjhibbits
259296177Sjhibbits/**************************************************************************//**
260296177Sjhibbits @Function      BM_ErrorIsr
261296177Sjhibbits
262296177Sjhibbits @Description   BM interrupt-service-routine for errors.
263296177Sjhibbits                NOTE: this parameter relevant only for BM in master mode ('guestId'=NCSW_MASTER_ID).
264296177Sjhibbits
265296177Sjhibbits @Param[in]     h_Bm        - A handle to the BM Module.
266296177Sjhibbits
267296177Sjhibbits @Cautions      Allowed only following BM_Init().
268296177Sjhibbits*//***************************************************************************/
269296177Sjhibbitsvoid        BM_ErrorIsr(t_Handle h_Bm);
270296177Sjhibbits
271296177Sjhibbits/**************************************************************************//**
272296177Sjhibbits @Function      BM_GetCounter
273296177Sjhibbits
274296177Sjhibbits @Description   Reads one of the BM counters.
275296177Sjhibbits
276296177Sjhibbits @Param[in]     h_Bm        - A handle to the BM Module.
277296177Sjhibbits @Param[in]     counter     - The requested counter.
278296177Sjhibbits
279296177Sjhibbits @Return        Counter's current value.
280296177Sjhibbits*//***************************************************************************/
281296177Sjhibbitsuint32_t    BM_GetCounter(t_Handle h_Bm, e_BmCounters counter);
282296177Sjhibbits
283296177Sjhibbits/**************************************************************************//**
284296177Sjhibbits @Function      BM_GetRevision
285296177Sjhibbits
286296177Sjhibbits @Description   Returns the BM revision
287296177Sjhibbits
288296177Sjhibbits @Param[in]     h_Bm                A handle to a BM Module.
289296177Sjhibbits @Param[out]    p_BmRevisionInfo    A structure of revision information parameters.
290296177Sjhibbits
291296177Sjhibbits @Return        E_OK on success; Error code otherwise.
292296177Sjhibbits
293296177Sjhibbits @Cautions      Allowed only following QM_Init().
294296177Sjhibbits*//***************************************************************************/
295296177Sjhibbitst_Error  BM_GetRevision(t_Handle h_Bm, t_BmRevisionInfo *p_BmRevisionInfo);
296296177Sjhibbits
297296177Sjhibbits/** @} */ /* end of BM_runtime_control_grp group */
298296177Sjhibbits/** @} */ /* end of BM_lib_grp group */
299296177Sjhibbits
300296177Sjhibbits
301296177Sjhibbits/**************************************************************************//**
302296177Sjhibbits @Group         BM_portal_grp BM-Portal API
303296177Sjhibbits
304296177Sjhibbits @Description   BM-Portal API functions, definitions and enums.
305296177Sjhibbits
306296177Sjhibbits @{
307296177Sjhibbits*//***************************************************************************/
308296177Sjhibbits
309296177Sjhibbits/**************************************************************************//**
310296177Sjhibbits @Group         BM_portal_init_grp BM-Portal Initialization Unit
311296177Sjhibbits
312296177Sjhibbits @Description   BM-Portal Initialization Unit
313296177Sjhibbits
314296177Sjhibbits @{
315296177Sjhibbits*//***************************************************************************/
316296177Sjhibbits
317296177Sjhibbits/**************************************************************************//**
318296177Sjhibbits @Description   structure representing BM Portal initialization parameters
319296177Sjhibbits*//***************************************************************************/
320296177Sjhibbitstypedef struct {
321296177Sjhibbits    uintptr_t       ceBaseAddress;          /**< Cache-enabled base address (virtual) */
322296177Sjhibbits    uintptr_t       ciBaseAddress;          /**< Cache-inhibited base address (virtual) */
323296177Sjhibbits    t_Handle        h_Bm;                   /**< Bm Handle */
324296177Sjhibbits    e_DpaaSwPortal  swPortalId;             /**< Portal id */
325296177Sjhibbits    int             irq;                    /**< portal interrupt line; NO_IRQ if interrupts not used */
326296177Sjhibbits} t_BmPortalParam;
327296177Sjhibbits
328296177Sjhibbits
329296177Sjhibbits/**************************************************************************//**
330296177Sjhibbits @Function      BM_PORTAL_Config
331296177Sjhibbits
332296177Sjhibbits @Description   Creates descriptor for the BM Portal;
333296177Sjhibbits
334296177Sjhibbits                The routine returns a handle (descriptor) to a BM-Portal object;
335296177Sjhibbits                This descriptor must be passed as first parameter to all other
336296177Sjhibbits                BM-Portal function calls.
337296177Sjhibbits
338296177Sjhibbits                No actual initialization or configuration of QM-Portal hardware is
339296177Sjhibbits                done by this routine.
340296177Sjhibbits
341296177Sjhibbits @Param[in]     p_BmPortalParam   - Pointer to data structure of parameters
342296177Sjhibbits
343296177Sjhibbits @Retval        Handle to a BM-Portal object, or NULL for Failure.
344296177Sjhibbits*//***************************************************************************/
345296177Sjhibbitst_Handle BM_PORTAL_Config(t_BmPortalParam *p_BmPortalParam);
346296177Sjhibbits
347296177Sjhibbits/**************************************************************************//**
348296177Sjhibbits @Function      BM_PORTAL_Init
349296177Sjhibbits
350296177Sjhibbits @Description   Initializes a BM-Portal module
351296177Sjhibbits
352296177Sjhibbits @Param[in]     h_BmPortal - A handle to a BM-Portal module
353296177Sjhibbits
354296177Sjhibbits @Return        E_OK on success; Error code otherwise.
355296177Sjhibbits*//***************************************************************************/
356296177Sjhibbitst_Error  BM_PORTAL_Init(t_Handle h_BmPortal);
357296177Sjhibbits
358296177Sjhibbits/**************************************************************************//**
359296177Sjhibbits @Function      BM_PortalFree
360296177Sjhibbits
361296177Sjhibbits @Description   Frees all resources that were assigned to BM Portal module.
362296177Sjhibbits
363296177Sjhibbits                Calling this routine invalidates the descriptor.
364296177Sjhibbits
365296177Sjhibbits @Param[in]     h_BmPortal  - BM Portal module descriptor
366296177Sjhibbits
367296177Sjhibbits @Return        E_OK on success; Error code otherwise.
368296177Sjhibbits*//***************************************************************************/
369296177Sjhibbitst_Error     BM_PORTAL_Free(t_Handle h_BmPortal);
370296177Sjhibbits
371296177Sjhibbits/**************************************************************************//**
372296177Sjhibbits @Function      BM_PORTAL_ConfigMemAttr
373296177Sjhibbits
374296177Sjhibbits @Description   Change the memory attributes
375296177Sjhibbits                from its default configuration [MEMORY_ATTR_CACHEABLE].
376296177Sjhibbits
377296177Sjhibbits @Param[in]     h_BmPortal          - A handle to a BM-Portal module
378296177Sjhibbits @Param[in]     hwExtStructsMemAttr - memory attributes (cache/non-cache, etc.)
379296177Sjhibbits
380296177Sjhibbits @Return        E_OK on success; Error code otherwise.
381296177Sjhibbits
382296177Sjhibbits @Cautions      Allowed only following BM_PORTAL_Config() and before BM_PORTAL_Init().
383296177Sjhibbits*//***************************************************************************/
384296177Sjhibbitst_Error  BM_PORTAL_ConfigMemAttr(t_Handle h_BmPortal, uint32_t hwExtStructsMemAttr);
385296177Sjhibbits
386296177Sjhibbits/** @} */ /* end of BM_portal_init_grp group */
387296177Sjhibbits/** @} */ /* end of BM_portal_grp group */
388296177Sjhibbits
389296177Sjhibbits
390296177Sjhibbits/**************************************************************************//**
391296177Sjhibbits @Group         BM_pool_grp BM-Pool API
392296177Sjhibbits
393296177Sjhibbits @Description   BM-Pool API functions, definitions and enums.
394296177Sjhibbits
395296177Sjhibbits @{
396296177Sjhibbits*//***************************************************************************/
397296177Sjhibbits
398296177Sjhibbits/**************************************************************************//**
399296177Sjhibbits @Group         BM_pool_init_grp BM-Pool Initialization Unit
400296177Sjhibbits
401296177Sjhibbits @Description   BM-Pool Initialization Unit
402296177Sjhibbits
403296177Sjhibbits @{
404296177Sjhibbits*//***************************************************************************/
405296177Sjhibbits
406296177Sjhibbits/**************************************************************************//**
407296177Sjhibbits @Collection    BM Pool Depletion Thresholds macros
408296177Sjhibbits                The thresholds are represent by an array of size MAX_DEPLETION_THRESHOLDS
409296177Sjhibbits                Use the following macros to access the appropriate location in the array.
410296177Sjhibbits*//***************************************************************************/
411296177Sjhibbits#define BM_POOL_DEP_THRESH_SW_ENTRY 0
412296177Sjhibbits#define BM_POOL_DEP_THRESH_SW_EXIT  1
413296177Sjhibbits#define BM_POOL_DEP_THRESH_HW_ENTRY 2
414296177Sjhibbits#define BM_POOL_DEP_THRESH_HW_EXIT  3
415296177Sjhibbits
416296177Sjhibbits#define MAX_DEPLETION_THRESHOLDS    4
417296177Sjhibbits/* @} */
418296177Sjhibbits
419296177Sjhibbits
420296177Sjhibbits/**************************************************************************//**
421296177Sjhibbits @Description   structure representing BM Pool initialization parameters
422296177Sjhibbits*//***************************************************************************/
423296177Sjhibbitstypedef struct {
424296177Sjhibbits    t_Handle                    h_Bm;               /**< A handle to a BM Module. */
425296177Sjhibbits    t_Handle                    h_BmPortal;         /**< A handle to a BM Portal Module.
426296177Sjhibbits                                                         will be used only for Init and Free routines.
427296177Sjhibbits                                                         NOTE: if NULL, assuming affinity */
428296177Sjhibbits    uint32_t                    numOfBuffers;       /**< Number of buffers use by this pool
429296177Sjhibbits                                                         NOTE: If zero, empty pool buffer is created. */
430296177Sjhibbits    t_BufferPoolInfo            bufferPoolInfo;     /**< Data buffers pool information */
431296177Sjhibbits    t_Handle                    h_App;              /**< opaque user value passed as a parameter to callbacks */
432296177Sjhibbits    bool                        shadowMode;         /**< If TRUE, numOfBuffers will be set to '0'. */
433296177Sjhibbits    uint8_t                     bpid;               /**< index of the shadow buffer pool (0-BM_MAX_NUM_OF_POOLS).
434296177Sjhibbits                                                         valid only if shadowMode='TRUE'. */
435296177Sjhibbits} t_BmPoolParam;
436296177Sjhibbits
437296177Sjhibbits
438296177Sjhibbits/**************************************************************************//**
439296177Sjhibbits @Function      BM_POOL_Config
440296177Sjhibbits
441296177Sjhibbits @Description   Creates descriptor for the BM Pool;
442296177Sjhibbits
443296177Sjhibbits                The routine returns a handle (descriptor) to the BM Pool object.
444296177Sjhibbits
445296177Sjhibbits @Param[in]     p_BmPoolParam   - A pointer to data structure of parameters
446296177Sjhibbits
447296177Sjhibbits @Return        Handle to BM Portal object, or NULL for Failure.
448296177Sjhibbits*//***************************************************************************/
449296177Sjhibbitst_Handle    BM_POOL_Config(t_BmPoolParam *p_BmPoolParam);
450296177Sjhibbits
451296177Sjhibbits/**************************************************************************//**
452296177Sjhibbits @Function      BM_POOL_Init
453296177Sjhibbits
454296177Sjhibbits @Description   Initializes a BM-Pool module
455296177Sjhibbits
456296177Sjhibbits @Param[in]     h_BmPool - A handle to a BM-Pool module
457296177Sjhibbits
458296177Sjhibbits @Return        E_OK on success; Error code otherwise.
459296177Sjhibbits*//***************************************************************************/
460296177Sjhibbitst_Error     BM_POOL_Init(t_Handle h_BmPool);
461296177Sjhibbits
462296177Sjhibbits/**************************************************************************//**
463296177Sjhibbits @Function      BM_PoolFree
464296177Sjhibbits
465296177Sjhibbits @Description   Frees all resources that were assigned to BM Pool module.
466296177Sjhibbits
467296177Sjhibbits                Calling this routine invalidates the descriptor.
468296177Sjhibbits
469296177Sjhibbits @Param[in]     h_BmPool    - BM Pool module descriptor
470296177Sjhibbits
471296177Sjhibbits @Return        E_OK on success; Error code otherwise.
472296177Sjhibbits*//***************************************************************************/
473296177Sjhibbitst_Error     BM_POOL_Free(t_Handle h_BmPool);
474296177Sjhibbits
475296177Sjhibbits/**************************************************************************//**
476296177Sjhibbits @Function      BM_POOL_ConfigBpid
477296177Sjhibbits
478296177Sjhibbits @Description   Config a specific pool id rather than dynamic pool id.
479296177Sjhibbits
480296177Sjhibbits @Param[in]     h_BmPool    - A handle to a BM-Pool module
481296177Sjhibbits @Param[in]     bpid        - index of the buffer pool (0-BM_MAX_NUM_OF_POOLS).
482296177Sjhibbits
483296177Sjhibbits @Return        E_OK on success; Error code otherwise.
484296177Sjhibbits
485296177Sjhibbits @Cautions      Allowed only following BM_POOL_Config() and before BM_POOL_Init().
486296177Sjhibbits*//***************************************************************************/
487296177Sjhibbitst_Error  BM_POOL_ConfigBpid(t_Handle h_BmPool, uint8_t bpid);
488296177Sjhibbits
489296177Sjhibbits/**************************************************************************//**
490296177Sjhibbits @Function      BM_POOL_ConfigDepletion
491296177Sjhibbits
492296177Sjhibbits @Description   Config depletion-entry/exit thresholds and callback.
493296177Sjhibbits
494296177Sjhibbits @Param[in]     h_BmPool        - A handle to a BM-Pool module
495296177Sjhibbits @Param[in]     f_Depletion     - depletion-entry/exit callback.
496296177Sjhibbits @Param[in]     thresholds      - depletion-entry/exit thresholds.
497296177Sjhibbits
498296177Sjhibbits @Return        E_OK on success; Error code otherwise.
499296177Sjhibbits
500296177Sjhibbits @Cautions      Allowed only following BM_POOL_Config() and before BM_POOL_Init();
501296177Sjhibbits                Allowed only if shadowMode='FALSE'.
502296177Sjhibbits                Allowed only if BM in master mode ('guestId'=NCSW_MASTER_ID), or
503296177Sjhibbits                the BM is in guest mode BUT than this routine will invoke IPC
504296177Sjhibbits                call to the master.
505296177Sjhibbits*//***************************************************************************/
506296177Sjhibbitst_Error  BM_POOL_ConfigDepletion(t_Handle               h_BmPool,
507296177Sjhibbits                                 t_BmDepletionCallback  *f_Depletion,
508296177Sjhibbits                                 uint32_t               thresholds[MAX_DEPLETION_THRESHOLDS]);
509296177Sjhibbits
510296177Sjhibbits/**************************************************************************//**
511296177Sjhibbits @Function      BM_POOL_ConfigStockpile
512296177Sjhibbits
513296177Sjhibbits @Description   Config software stockpile.
514296177Sjhibbits
515296177Sjhibbits @Param[in]     h_BmPool     - A handle to a BM-Pool module
516296177Sjhibbits @Param[in]     maxBuffers   - the software data structure size saved for stockpile;
517296177Sjhibbits                               when reached this value, release to hw command performed.
518296177Sjhibbits @Param[in]     minBuffers   - if current capacity is equal or lower then this value,
519296177Sjhibbits                               acquire from hw command performed.
520296177Sjhibbits
521296177Sjhibbits @Return        E_OK on success; Error code otherwise.
522296177Sjhibbits
523296177Sjhibbits @Cautions      Allowed only following BM_POOL_Config() and before BM_POOL_Init().
524296177Sjhibbits*//***************************************************************************/
525296177Sjhibbitst_Error  BM_POOL_ConfigStockpile(t_Handle h_BmPool, uint16_t maxBuffers, uint16_t minBuffers);
526296177Sjhibbits
527296177Sjhibbits/**************************************************************************//**
528296177Sjhibbits @Function      BM_POOL_ConfigBuffContextMode
529296177Sjhibbits
530296177Sjhibbits @Description   Config the BM pool to set/unset buffer-context
531296177Sjhibbits
532296177Sjhibbits @Param[in]     h_BmPool     - A handle to a BM-Pool module
533296177Sjhibbits @Param[in]     en           - enable/disable buffer context mode
534296177Sjhibbits
535296177Sjhibbits @Return        E_OK on success; Error code otherwise.
536296177Sjhibbits
537296177Sjhibbits @Cautions      Allowed only following BM_POOL_Config() and before BM_POOL_Init().
538296177Sjhibbits*//***************************************************************************/
539296177Sjhibbitst_Error  BM_POOL_ConfigBuffContextMode(t_Handle h_BmPool, bool en);
540296177Sjhibbits
541296177Sjhibbits/** @} */ /* end of BM_pool_init_grp group */
542296177Sjhibbits
543296177Sjhibbits
544296177Sjhibbits/**************************************************************************//**
545296177Sjhibbits @Group         BM_pool_runtime_control_grp BM-Pool Runtime Control Unit
546296177Sjhibbits
547296177Sjhibbits @Description   BM-Pool Runtime control unit API functions, definitions and enums.
548296177Sjhibbits
549296177Sjhibbits @{
550296177Sjhibbits*//***************************************************************************/
551296177Sjhibbits
552296177Sjhibbits/**************************************************************************//**
553296177Sjhibbits @Description   enum for defining BM Pool counters
554296177Sjhibbits*//***************************************************************************/
555296177Sjhibbitstypedef enum e_BmPoolCounters {
556296177Sjhibbits    e_BM_POOL_COUNTERS_CONTENT = 0,         /**< number of free buffers for a particular pool */
557296177Sjhibbits    e_BM_POOL_COUNTERS_SW_DEPLETION,        /**< number of times pool entered sw depletion */
558296177Sjhibbits    e_BM_POOL_COUNTERS_HW_DEPLETION         /**< number of times pool entered hw depletion */
559296177Sjhibbits} e_BmPoolCounters;
560296177Sjhibbits
561296177Sjhibbits/**************************************************************************//**
562296177Sjhibbits @Function      BM_POOL_GetId
563296177Sjhibbits
564296177Sjhibbits @Description   return a buffer pool id.
565296177Sjhibbits
566296177Sjhibbits @Param[in]     h_BmPool    - A handle to a BM-pool
567296177Sjhibbits
568296177Sjhibbits @Return        Pool ID.
569296177Sjhibbits*//***************************************************************************/
570296177Sjhibbitsuint8_t BM_POOL_GetId(t_Handle h_BmPool);
571296177Sjhibbits
572296177Sjhibbits/**************************************************************************//**
573296177Sjhibbits @Function      BM_POOL_GetBufferSize
574296177Sjhibbits
575296177Sjhibbits @Description   returns the pool's buffer size.
576296177Sjhibbits
577296177Sjhibbits @Param[in]     h_BmPool    - A handle to a BM-pool
578296177Sjhibbits
579296177Sjhibbits @Return        pool's buffer size.
580296177Sjhibbits*//***************************************************************************/
581296177Sjhibbitsuint16_t BM_POOL_GetBufferSize(t_Handle h_BmPool);
582296177Sjhibbits
583296177Sjhibbits/**************************************************************************//**
584296177Sjhibbits @Function      BM_POOL_GetBufferContext
585296177Sjhibbits
586296177Sjhibbits @Description   Returns the user's private context that
587296177Sjhibbits                should be associated with the buffer.
588296177Sjhibbits
589296177Sjhibbits @Param[in]     h_BmPool    - A handle to a BM-pool
590296177Sjhibbits @Param[in]     p_Buff      - A Pointer to the buffer
591296177Sjhibbits
592296177Sjhibbits @Return        user's private context.
593296177Sjhibbits*//***************************************************************************/
594296177Sjhibbitst_Handle BM_POOL_GetBufferContext(t_Handle h_BmPool, void *p_Buff);
595296177Sjhibbits
596296177Sjhibbits/**************************************************************************//**
597296177Sjhibbits @Function      BM_POOL_PhysToVirt
598296177Sjhibbits
599296177Sjhibbits @Description   Translates a physical address to the matching virtual address.
600296177Sjhibbits
601296177Sjhibbits @Param[in]     h_BmPool    - A handle to a BM-pool
602296177Sjhibbits @Param[in]     addr        - The physical address to translate
603296177Sjhibbits
604296177Sjhibbits @Return        Virtual address.
605296177Sjhibbits*//***************************************************************************/
606296177Sjhibbitsvoid * BM_POOL_PhysToVirt(t_Handle h_BmPool, physAddress_t addr);
607296177Sjhibbits
608296177Sjhibbits/**************************************************************************//**
609296177Sjhibbits @Function      BM_POOL_VirtToPhys
610296177Sjhibbits
611296177Sjhibbits @Description   Translates a virtual address to the matching physical address.
612296177Sjhibbits
613296177Sjhibbits @Param[in]     h_BmPool    - A handle to a BM-pool
614296177Sjhibbits @Param[in]     addr        - The virtual address to translate
615296177Sjhibbits
616296177Sjhibbits @Return        Physical address.
617296177Sjhibbits*//***************************************************************************/
618296177SjhibbitsphysAddress_t BM_POOL_VirtToPhys(t_Handle h_BmPool, void *addr);
619296177Sjhibbits
620296177Sjhibbits/**************************************************************************//**
621296177Sjhibbits @Function      BM_POOL_GetCounter
622296177Sjhibbits
623296177Sjhibbits @Description   Reads one of the BM Pool counters.
624296177Sjhibbits
625296177Sjhibbits @Param[in]     h_BmPool    - A handle to a BM-pool
626296177Sjhibbits @Param[in]     counter     - The requested counter.
627296177Sjhibbits
628296177Sjhibbits @Return        Counter's current value.
629296177Sjhibbits*//***************************************************************************/
630296177Sjhibbitsuint32_t BM_POOL_GetCounter(t_Handle h_BmPool, e_BmPoolCounters counter);
631296177Sjhibbits
632296177Sjhibbits/** @} */ /* end of BM_pool_runtime_control_grp group */
633296177Sjhibbits
634296177Sjhibbits
635296177Sjhibbits/**************************************************************************//**
636296177Sjhibbits @Group         BM_pool_runtime_data_grp BM-Pool Runtime Data Unit
637296177Sjhibbits
638296177Sjhibbits @Description   BM-Pool Runtime data unit API functions, definitions and enums.
639296177Sjhibbits
640296177Sjhibbits @{
641296177Sjhibbits*//***************************************************************************/
642296177Sjhibbits
643296177Sjhibbits/**************************************************************************//**
644296177Sjhibbits @Function      BM_POOL_GetBuf
645296177Sjhibbits
646296177Sjhibbits @Description   Allocate buffer from a buffer pool.
647296177Sjhibbits
648296177Sjhibbits @Param[in]     h_BmPool    - A handle to a BM-pool
649296177Sjhibbits @Param[in]     h_BmPortal  - A handle to a BM Portal Module;
650296177Sjhibbits                              NOTE : if NULL, assuming affinity.
651296177Sjhibbits
652296177Sjhibbits @Return        A Pointer to the allocated buffer.
653296177Sjhibbits*//***************************************************************************/
654296177Sjhibbitsvoid *      BM_POOL_GetBuf(t_Handle h_BmPool, t_Handle h_BmPortal);
655296177Sjhibbits
656296177Sjhibbits/**************************************************************************//**
657296177Sjhibbits @Function      BM_POOL_PutBuf
658296177Sjhibbits
659296177Sjhibbits @Description   Deallocate buffer to a buffer pool.
660296177Sjhibbits
661296177Sjhibbits @Param[in]     h_BmPool    - A handle to a BM-pool
662296177Sjhibbits @Param[in]     h_BmPortal  - A handle to a BM Portal Module;
663296177Sjhibbits                              NOTE : if NULL, assuming affinity.
664296177Sjhibbits @Param[in]     p_Buff      - A Pointer to the buffer.
665296177Sjhibbits
666296177Sjhibbits @Return        E_OK on success; Error code otherwise.
667296177Sjhibbits*//***************************************************************************/
668296177Sjhibbitst_Error     BM_POOL_PutBuf(t_Handle h_BmPool, t_Handle h_BmPortal, void *p_Buff);
669296177Sjhibbits
670296177Sjhibbits/**************************************************************************//**
671296177Sjhibbits @Function      BM_POOL_FillBufs
672296177Sjhibbits
673296177Sjhibbits @Description   Fill a BM pool with new buffers.
674296177Sjhibbits
675296177Sjhibbits @Param[in]     h_BmPool    - A handle to a BM-pool
676296177Sjhibbits @Param[in]     h_BmPortal  - A handle to a BM Portal Module;
677296177Sjhibbits                              NOTE : if NULL, assuming affinity.
678296177Sjhibbits @Param[in]     numBufs     - How many buffers to fill into the pool.
679296177Sjhibbits
680296177Sjhibbits @Return        E_OK on success; Error code otherwise.
681296177Sjhibbits*//***************************************************************************/
682296177Sjhibbitst_Error     BM_POOL_FillBufs(t_Handle h_BmPool, t_Handle h_BmPortal, uint32_t numBufs);
683296177Sjhibbits
684296177Sjhibbits/** @} */ /* end of BM_pool_runtime_data_grp group */
685296177Sjhibbits/** @} */ /* end of BM_pool_grp group */
686296177Sjhibbits/** @} */ /* end of BM_grp group */
687296177Sjhibbits
688296177Sjhibbits#endif /* __BM_EXT_H */
689