Path: blob/main/sys/contrib/ncsw/inc/Peripherals/bm_ext.h
48375 views
/******************************************************************************12� 1995-2003, 2004, 2005-2011 Freescale Semiconductor, Inc.3All rights reserved.45This is proprietary source code of Freescale Semiconductor Inc.,6and its use is subject to the NetComm Device Drivers EULA.7The copyright notice above does not evidence any actual or intended8publication of such source code.910ALTERNATIVELY, redistribution and use in source and binary forms, with11or without modification, are permitted provided that the following12conditions are met:13* Redistributions of source code must retain the above copyright14notice, this list of conditions and the following disclaimer.15* Redistributions in binary form must reproduce the above copyright16notice, this list of conditions and the following disclaimer in the17documentation and/or other materials provided with the distribution.18* Neither the name of Freescale Semiconductor nor the19names of its contributors may be used to endorse or promote products20derived from this software without specific prior written permission.2122THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY23EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED24WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE25DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY26DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES27(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;28LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND29ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT30(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS31SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.32*3334**************************************************************************/35/******************************************************************************36@File bm_ext.h3738@Description BM API39*//***************************************************************************/40#ifndef __BM_EXT_H41#define __BM_EXT_H4243#include "error_ext.h"44#include "std_ext.h"454647/**************************************************************************//**48@Group BM_grp Buffer Manager API4950@Description BM API functions, definitions and enums.5152@{53*//***************************************************************************/5455/**************************************************************************//**56@Description This callback type is used when handling pool depletion entry/exit.5758User provides this function. Driver invokes it.5960@Param[in] h_App - User's application descriptor.61@Param[in] in - TRUE when entered depletion state62FALSE when exit the depletion state.63*//***************************************************************************/64typedef void (t_BmDepletionCallback)(t_Handle h_App, bool in);6566/**************************************************************************//**67@Group BM_lib_grp BM common API6869@Description BM common API functions, definitions and enums.7071@{72*//***************************************************************************/7374/**************************************************************************//**75@Description BM Exceptions76*//***************************************************************************/77typedef enum e_BmExceptions {78e_BM_EX_INVALID_COMMAND = 0 , /**< Invalid Command Verb Interrupt */79e_BM_EX_FBPR_THRESHOLD, /**< FBPR Low Watermark Interrupt. */80e_BM_EX_SINGLE_ECC, /**< Single Bit ECC Error Interrupt. */81e_BM_EX_MULTI_ECC /**< Multi Bit ECC Error Interrupt */82} e_BmExceptions;838485/**************************************************************************//**86@Group BM_init_grp BM (common) Initialization Unit8788@Description BM (common) Initialization Unit8990@{91*//***************************************************************************/9293/**************************************************************************//**94@Function t_BmExceptionsCallback9596@Description Exceptions user callback routine, will be called upon an97exception passing the exception identification.9899@Param[in] h_App - User's application descriptor.100@Param[in] exception - The exception.101*//***************************************************************************/102typedef void (t_BmExceptionsCallback) (t_Handle h_App,103e_BmExceptions exception);104105/**************************************************************************//**106@Description structure representing BM initialization parameters107*//***************************************************************************/108typedef struct {109uint8_t guestId; /**< BM Partition Id */110111uintptr_t baseAddress; /**< Bm base address (virtual).112NOTE: this parameter relevant only for BM in master mode ('guestId'=NCSW_MASTER_ID). */113uint16_t liodn; /**< This value is attached to every transaction initiated by114BMan when accessing its private data structures115NOTE: this parameter relevant only for BM in master mode ('guestId'=NCSW_MASTER_ID). */116uint32_t totalNumOfBuffers; /**< Total number of buffers117NOTE: this parameter relevant only for BM in master mode ('guestId'=NCSW_MASTER_ID). */118uint32_t fbprMemPartitionId; /**< FBPR's mem partition id;119NOTE: The memory partition must be non-cacheable and no-coherent area.120NOTE: this parameter relevant only for BM in master mode ('guestId'=NCSW_MASTER_ID). */121t_BmExceptionsCallback *f_Exception; /**< An application callback routine to handle exceptions.122NOTE: this parameter relevant only for BM in master mode ('guestId'=NCSW_MASTER_ID). */123t_Handle h_App; /**< A handle to an application layer object; This handle will124be passed by the driver upon calling the above callbacks.125NOTE: this parameter relevant only for BM in master mode ('guestId'=NCSW_MASTER_ID). */126uintptr_t errIrq; /**< BM error interrupt line; NO_IRQ if interrupts not used.127NOTE: this parameter relevant only for BM in master mode ('guestId'=NCSW_MASTER_ID). */128129uint8_t partBpidBase; /**< The first buffer-pool-id dedicated to this partition.130NOTE: this parameter relevant only when working with multiple partitions. */131uint8_t partNumOfPools; /**< Number of Pools dedicated to this partition.132NOTE: this parameter relevant only when working with multiple partitions. */133} t_BmParam;134135136/**************************************************************************//**137@Function BM_Config138139@Description Creates descriptor for the BM module and initializes the BM module.140141The routine returns a handle (descriptor) to the BM object.142This descriptor must be passed as first parameter to all other143BM function calls.144145@Param[in] p_BmParam - A pointer to data structure of parameters146147@Return Handle to BM object, or NULL for Failure.148*//***************************************************************************/149t_Handle BM_Config(t_BmParam *p_BmParam);150151/**************************************************************************//**152@Function BM_Init153154@Description Initializes the BM module155156@Param[in] h_Bm - A handle to the BM module157158@Return E_OK on success; Error code otherwise.159160@Cautions Allowed only following BM_Config().161*//***************************************************************************/162t_Error BM_Init(t_Handle h_Bm);163164/**************************************************************************//**165@Function BM_Free166167@Description Frees all resources that were assigned to BM module.168169Calling this routine invalidates the descriptor.170171@Param[in] h_Bm - A handle to the BM module172173@Return E_OK on success; Error code otherwise.174*//***************************************************************************/175t_Error BM_Free(t_Handle h_Bm);176177/**************************************************************************//**178@Group BM_advanced_init_grp BM (common) Advanced Configuration Unit179180@Description Configuration functions used to change default values.181182@{183*//***************************************************************************/184185/**************************************************************************//**186@Function BM_ConfigFbprThreshold187188@Description Change the fbpr threshold from its default189configuration [0].190An interrupt if enables is asserted when the number of FBPRs is below this threshold.191NOTE: this parameter relevant only for BM in master mode ('guestId'=NCSW_MASTER_ID).192193@Param[in] h_Bm - A handle to the BM module194@Param[in] threshold - threshold value.195196@Return E_OK on success; Error code otherwise.197198@Cautions Allowed only following BM_Config() and before BM_Init().199*//***************************************************************************/200t_Error BM_ConfigFbprThreshold(t_Handle h_Bm, uint32_t threshold);201202/** @} */ /* end of BM_advanced_init_grp group */203/** @} */ /* end of BM_init_grp group */204205/**************************************************************************//**206@Group BM_runtime_control_grp BM (common) Runtime Control Unit207208@Description BM (common) Runtime control unit API functions, definitions and enums.209210@{211*//***************************************************************************/212213/**************************************************************************//**214@Description enum for defining BM counters215*//***************************************************************************/216typedef enum e_BmCounters {217e_BM_COUNTERS_FBPR = 0 /**< Total Free Buffer Proxy Record (FBPR) Free Pool Count in external memory */218} e_BmCounters;219220/**************************************************************************//**221@Description structure for returning revision information222*//***************************************************************************/223typedef struct t_BmRevisionInfo {224uint8_t majorRev; /**< Major revision */225uint8_t minorRev; /**< Minor revision */226} t_BmRevisionInfo;227228#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))229/**************************************************************************//**230@Function BM_DumpRegs231232@Description Dumps all BM registers233NOTE: this parameter relevant only for BM in master mode ('guestId'=NCSW_MASTER_ID).234235@Param[in] h_Bm A handle to an BM Module.236237@Return E_OK on success;238239@Cautions Allowed only after BM_Init().240*//***************************************************************************/241t_Error BM_DumpRegs(t_Handle h_Bm);242#endif /* (defined(DEBUG_ERRORS) && ... */243244/**************************************************************************//**245@Function BM_SetException246247@Description Calling this routine enables/disables the specified exception.248NOTE: this parameter relevant only for BM in master mode ('guestId'=NCSW_MASTER_ID).249250@Param[in] h_Bm - A handle to the BM Module.251@Param[in] exception - The exception to be selected.252@Param[in] enable - TRUE to enable interrupt, FALSE to mask it.253254@Cautions Allowed only following BM_Init().255*//***************************************************************************/256t_Error BM_SetException(t_Handle h_Bm, e_BmExceptions exception, bool enable);257258/**************************************************************************//**259@Function BM_ErrorIsr260261@Description BM interrupt-service-routine for errors.262NOTE: this parameter relevant only for BM in master mode ('guestId'=NCSW_MASTER_ID).263264@Param[in] h_Bm - A handle to the BM Module.265266@Cautions Allowed only following BM_Init().267*//***************************************************************************/268void BM_ErrorIsr(t_Handle h_Bm);269270/**************************************************************************//**271@Function BM_GetCounter272273@Description Reads one of the BM counters.274275@Param[in] h_Bm - A handle to the BM Module.276@Param[in] counter - The requested counter.277278@Return Counter's current value.279*//***************************************************************************/280uint32_t BM_GetCounter(t_Handle h_Bm, e_BmCounters counter);281282/**************************************************************************//**283@Function BM_GetRevision284285@Description Returns the BM revision286287@Param[in] h_Bm A handle to a BM Module.288@Param[out] p_BmRevisionInfo A structure of revision information parameters.289290@Return E_OK on success; Error code otherwise.291292@Cautions Allowed only following QM_Init().293*//***************************************************************************/294t_Error BM_GetRevision(t_Handle h_Bm, t_BmRevisionInfo *p_BmRevisionInfo);295296/** @} */ /* end of BM_runtime_control_grp group */297/** @} */ /* end of BM_lib_grp group */298299300/**************************************************************************//**301@Group BM_portal_grp BM-Portal API302303@Description BM-Portal API functions, definitions and enums.304305@{306*//***************************************************************************/307308/**************************************************************************//**309@Group BM_portal_init_grp BM-Portal Initialization Unit310311@Description BM-Portal Initialization Unit312313@{314*//***************************************************************************/315316/**************************************************************************//**317@Description structure representing BM Portal initialization parameters318*//***************************************************************************/319typedef struct {320uintptr_t ceBaseAddress; /**< Cache-enabled base address (virtual) */321uintptr_t ciBaseAddress; /**< Cache-inhibited base address (virtual) */322t_Handle h_Bm; /**< Bm Handle */323e_DpaaSwPortal swPortalId; /**< Portal id */324uintptr_t irq; /**< portal interrupt line; NO_IRQ if interrupts not used */325} t_BmPortalParam;326327328/**************************************************************************//**329@Function BM_PORTAL_Config330331@Description Creates descriptor for the BM Portal;332333The routine returns a handle (descriptor) to a BM-Portal object;334This descriptor must be passed as first parameter to all other335BM-Portal function calls.336337No actual initialization or configuration of QM-Portal hardware is338done by this routine.339340@Param[in] p_BmPortalParam - Pointer to data structure of parameters341342@Retval Handle to a BM-Portal object, or NULL for Failure.343*//***************************************************************************/344t_Handle BM_PORTAL_Config(t_BmPortalParam *p_BmPortalParam);345346/**************************************************************************//**347@Function BM_PORTAL_Init348349@Description Initializes a BM-Portal module350351@Param[in] h_BmPortal - A handle to a BM-Portal module352353@Return E_OK on success; Error code otherwise.354*//***************************************************************************/355t_Error BM_PORTAL_Init(t_Handle h_BmPortal);356357/**************************************************************************//**358@Function BM_PortalFree359360@Description Frees all resources that were assigned to BM Portal module.361362Calling this routine invalidates the descriptor.363364@Param[in] h_BmPortal - BM Portal module descriptor365366@Return E_OK on success; Error code otherwise.367*//***************************************************************************/368t_Error BM_PORTAL_Free(t_Handle h_BmPortal);369370/**************************************************************************//**371@Function BM_PORTAL_ConfigMemAttr372373@Description Change the memory attributes374from its default configuration [MEMORY_ATTR_CACHEABLE].375376@Param[in] h_BmPortal - A handle to a BM-Portal module377@Param[in] hwExtStructsMemAttr - memory attributes (cache/non-cache, etc.)378379@Return E_OK on success; Error code otherwise.380381@Cautions Allowed only following BM_PORTAL_Config() and before BM_PORTAL_Init().382*//***************************************************************************/383t_Error BM_PORTAL_ConfigMemAttr(t_Handle h_BmPortal, uint32_t hwExtStructsMemAttr);384385/** @} */ /* end of BM_portal_init_grp group */386/** @} */ /* end of BM_portal_grp group */387388389/**************************************************************************//**390@Group BM_pool_grp BM-Pool API391392@Description BM-Pool API functions, definitions and enums.393394@{395*//***************************************************************************/396397/**************************************************************************//**398@Group BM_pool_init_grp BM-Pool Initialization Unit399400@Description BM-Pool Initialization Unit401402@{403*//***************************************************************************/404405/**************************************************************************//**406@Collection BM Pool Depletion Thresholds macros407The thresholds are represent by an array of size MAX_DEPLETION_THRESHOLDS408Use the following macros to access the appropriate location in the array.409*//***************************************************************************/410#define BM_POOL_DEP_THRESH_SW_ENTRY 0411#define BM_POOL_DEP_THRESH_SW_EXIT 1412#define BM_POOL_DEP_THRESH_HW_ENTRY 2413#define BM_POOL_DEP_THRESH_HW_EXIT 3414415#define MAX_DEPLETION_THRESHOLDS 4416/* @} */417418419/**************************************************************************//**420@Description structure representing BM Pool initialization parameters421*//***************************************************************************/422typedef struct {423t_Handle h_Bm; /**< A handle to a BM Module. */424t_Handle h_BmPortal; /**< A handle to a BM Portal Module.425will be used only for Init and Free routines.426NOTE: if NULL, assuming affinity */427uint32_t numOfBuffers; /**< Number of buffers use by this pool428NOTE: If zero, empty pool buffer is created. */429t_BufferPoolInfo bufferPoolInfo; /**< Data buffers pool information */430t_Handle h_App; /**< opaque user value passed as a parameter to callbacks */431bool shadowMode; /**< If TRUE, numOfBuffers will be set to '0'. */432uint8_t bpid; /**< index of the shadow buffer pool (0-BM_MAX_NUM_OF_POOLS).433valid only if shadowMode='TRUE'. */434} t_BmPoolParam;435436437/**************************************************************************//**438@Function BM_POOL_Config439440@Description Creates descriptor for the BM Pool;441442The routine returns a handle (descriptor) to the BM Pool object.443444@Param[in] p_BmPoolParam - A pointer to data structure of parameters445446@Return Handle to BM Portal object, or NULL for Failure.447*//***************************************************************************/448t_Handle BM_POOL_Config(t_BmPoolParam *p_BmPoolParam);449450/**************************************************************************//**451@Function BM_POOL_Init452453@Description Initializes a BM-Pool module454455@Param[in] h_BmPool - A handle to a BM-Pool module456457@Return E_OK on success; Error code otherwise.458*//***************************************************************************/459t_Error BM_POOL_Init(t_Handle h_BmPool);460461/**************************************************************************//**462@Function BM_PoolFree463464@Description Frees all resources that were assigned to BM Pool module.465466Calling this routine invalidates the descriptor.467468@Param[in] h_BmPool - BM Pool module descriptor469470@Return E_OK on success; Error code otherwise.471*//***************************************************************************/472t_Error BM_POOL_Free(t_Handle h_BmPool);473474/**************************************************************************//**475@Function BM_POOL_ConfigBpid476477@Description Config a specific pool id rather than dynamic pool id.478479@Param[in] h_BmPool - A handle to a BM-Pool module480@Param[in] bpid - index of the buffer pool (0-BM_MAX_NUM_OF_POOLS).481482@Return E_OK on success; Error code otherwise.483484@Cautions Allowed only following BM_POOL_Config() and before BM_POOL_Init().485*//***************************************************************************/486t_Error BM_POOL_ConfigBpid(t_Handle h_BmPool, uint8_t bpid);487488/**************************************************************************//**489@Function BM_POOL_ConfigDepletion490491@Description Config depletion-entry/exit thresholds and callback.492493@Param[in] h_BmPool - A handle to a BM-Pool module494@Param[in] f_Depletion - depletion-entry/exit callback.495@Param[in] thresholds - depletion-entry/exit thresholds.496497@Return E_OK on success; Error code otherwise.498499@Cautions Allowed only following BM_POOL_Config() and before BM_POOL_Init();500Allowed only if shadowMode='FALSE'.501Allowed only if BM in master mode ('guestId'=NCSW_MASTER_ID), or502the BM is in guest mode BUT than this routine will invoke IPC503call to the master.504*//***************************************************************************/505t_Error BM_POOL_ConfigDepletion(t_Handle h_BmPool,506t_BmDepletionCallback *f_Depletion,507uint32_t thresholds[MAX_DEPLETION_THRESHOLDS]);508509/**************************************************************************//**510@Function BM_POOL_ConfigStockpile511512@Description Config software stockpile.513514@Param[in] h_BmPool - A handle to a BM-Pool module515@Param[in] maxBuffers - the software data structure size saved for stockpile;516when reached this value, release to hw command performed.517@Param[in] minBuffers - if current capacity is equal or lower then this value,518acquire from hw command performed.519520@Return E_OK on success; Error code otherwise.521522@Cautions Allowed only following BM_POOL_Config() and before BM_POOL_Init().523*//***************************************************************************/524t_Error BM_POOL_ConfigStockpile(t_Handle h_BmPool, uint16_t maxBuffers, uint16_t minBuffers);525526/**************************************************************************//**527@Function BM_POOL_ConfigBuffContextMode528529@Description Config the BM pool to set/unset buffer-context530531@Param[in] h_BmPool - A handle to a BM-Pool module532@Param[in] en - enable/disable buffer context mode533534@Return E_OK on success; Error code otherwise.535536@Cautions Allowed only following BM_POOL_Config() and before BM_POOL_Init().537*//***************************************************************************/538t_Error BM_POOL_ConfigBuffContextMode(t_Handle h_BmPool, bool en);539540/** @} */ /* end of BM_pool_init_grp group */541542543/**************************************************************************//**544@Group BM_pool_runtime_control_grp BM-Pool Runtime Control Unit545546@Description BM-Pool Runtime control unit API functions, definitions and enums.547548@{549*//***************************************************************************/550551/**************************************************************************//**552@Description enum for defining BM Pool counters553*//***************************************************************************/554typedef enum e_BmPoolCounters {555e_BM_POOL_COUNTERS_CONTENT = 0, /**< number of free buffers for a particular pool */556e_BM_POOL_COUNTERS_SW_DEPLETION, /**< number of times pool entered sw depletion */557e_BM_POOL_COUNTERS_HW_DEPLETION /**< number of times pool entered hw depletion */558} e_BmPoolCounters;559560/**************************************************************************//**561@Function BM_POOL_GetId562563@Description return a buffer pool id.564565@Param[in] h_BmPool - A handle to a BM-pool566567@Return Pool ID.568*//***************************************************************************/569uint8_t BM_POOL_GetId(t_Handle h_BmPool);570571/**************************************************************************//**572@Function BM_POOL_GetBufferSize573574@Description returns the pool's buffer size.575576@Param[in] h_BmPool - A handle to a BM-pool577578@Return pool's buffer size.579*//***************************************************************************/580uint16_t BM_POOL_GetBufferSize(t_Handle h_BmPool);581582/**************************************************************************//**583@Function BM_POOL_GetBufferContext584585@Description Returns the user's private context that586should be associated with the buffer.587588@Param[in] h_BmPool - A handle to a BM-pool589@Param[in] p_Buff - A Pointer to the buffer590591@Return user's private context.592*//***************************************************************************/593t_Handle BM_POOL_GetBufferContext(t_Handle h_BmPool, void *p_Buff);594595/**************************************************************************//**596@Function BM_POOL_GetCounter597598@Description Reads one of the BM Pool counters.599600@Param[in] h_BmPool - A handle to a BM-pool601@Param[in] counter - The requested counter.602603@Return Counter's current value.604*//***************************************************************************/605uint32_t BM_POOL_GetCounter(t_Handle h_BmPool, e_BmPoolCounters counter);606607/** @} */ /* end of BM_pool_runtime_control_grp group */608609610/**************************************************************************//**611@Group BM_pool_runtime_data_grp BM-Pool Runtime Data Unit612613@Description BM-Pool Runtime data unit API functions, definitions and enums.614615@{616*//***************************************************************************/617618/**************************************************************************//**619@Function BM_POOL_GetBuf620621@Description Allocate buffer from a buffer pool.622623@Param[in] h_BmPool - A handle to a BM-pool624@Param[in] h_BmPortal - A handle to a BM Portal Module;625NOTE : if NULL, assuming affinity.626627@Return A Pointer to the allocated buffer.628*//***************************************************************************/629void * BM_POOL_GetBuf(t_Handle h_BmPool, t_Handle h_BmPortal);630631/**************************************************************************//**632@Function BM_POOL_PutBuf633634@Description Deallocate buffer to a buffer pool.635636@Param[in] h_BmPool - A handle to a BM-pool637@Param[in] h_BmPortal - A handle to a BM Portal Module;638NOTE : if NULL, assuming affinity.639@Param[in] p_Buff - A Pointer to the buffer.640641@Return E_OK on success; Error code otherwise.642*//***************************************************************************/643t_Error BM_POOL_PutBuf(t_Handle h_BmPool, t_Handle h_BmPortal, void *p_Buff);644645/**************************************************************************//**646@Function BM_POOL_FillBufs647648@Description Fill a BM pool with new buffers.649650@Param[in] h_BmPool - A handle to a BM-pool651@Param[in] h_BmPortal - A handle to a BM Portal Module;652NOTE : if NULL, assuming affinity.653@Param[in] numBufs - How many buffers to fill into the pool.654655@Return E_OK on success; Error code otherwise.656*//***************************************************************************/657t_Error BM_POOL_FillBufs(t_Handle h_BmPool, t_Handle h_BmPortal, uint32_t numBufs);658659/** @} */ /* end of BM_pool_runtime_data_grp group */660/** @} */ /* end of BM_pool_grp group */661/** @} */ /* end of BM_grp group */662663#endif /* __BM_EXT_H */664665666