Path: blob/main/sys/contrib/ncsw/inc/Peripherals/qm_ext.h
48378 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 qm_ext.h3738@Description QM & Portal API39*//***************************************************************************/40#ifndef __QM_EXT_H41#define __QM_EXT_H4243#include "error_ext.h"44#include "std_ext.h"45#include "dpaa_ext.h"46#include "part_ext.h"474849/**************************************************************************//**50@Group QM_grp Queue Manager API5152@Description QM API functions, definitions and enums.5354@{55*//***************************************************************************/5657/**************************************************************************//**58@Description This callback type is used when receiving frame.5960User provides this function. Driver invokes it.6162@Param[in] h_App A user argument to the callback63@Param[in] h_QmFqr A handle to an QM-FQR Module.64@Param[in] fqidOffset fqid offset from the FQR's fqid base.65@Param[in] p_Frame The Received Frame6667@Retval e_RX_STORE_RESPONSE_CONTINUE - order the driver to continue Rx68operation for all ready data.69@Retval e_RX_STORE_RESPONSE_PAUSE - order the driver to stop Rx operation.7071@Cautions p_Frame is local parameter; i.e. users must NOT access or use72this parameter in any means outside this callback context.73*//***************************************************************************/74typedef e_RxStoreResponse (t_QmReceivedFrameCallback)(t_Handle h_App,75t_Handle h_QmFqr,76t_Handle h_QmPortal,77uint32_t fqidOffset,78t_DpaaFD *p_Frame);7980/**************************************************************************//**81@Description This callback type is used when the FQR is completely was drained.8283User provides this function. Driver invokes it.8485@Param[in] h_App A user argument to the callback86@Param[in] h_QmFqr A handle to an QM-FQR Module.8788@Retval E_OK on success; Error code otherwise.89*//***************************************************************************/90typedef t_Error (t_QmFqrDrainedCompletionCB)(t_Handle h_App,91t_Handle h_QmFqr);9293/**************************************************************************//**94@Description QM Rejection code enum95*//***************************************************************************/96typedef enum e_QmRejectionCode97{98e_QM_RC_NONE,99100e_QM_RC_CG_TAILDROP, /**< This frames was rejected due to congestion101group taildrop situation */102e_QM_RC_CG_WRED, /**< This frames was rejected due to congestion103group WRED situation */104e_QM_RC_FQ_TAILDROP /**< This frames was rejected due to FQID TD105situation */106/* e_QM_RC_ERROR107e_QM_RC_ORPWINDOW_EARLY108e_QM_RC_ORPWINDOW_LATE109e_QM_RC_ORPWINDOW_RETIRED */110} e_QmRejectionCode;111112/**************************************************************************//**113@Description QM Rejected frame information114*//***************************************************************************/115typedef struct t_QmRejectedFrameInfo116{117e_QmRejectionCode rejectionCode; /**< Rejection code */118union119{120struct121{122uint8_t cgId; /**< congestion group id*/123} cg; /**< rejection parameters when rejectionCode =124e_QM_RC_CG_TAILDROP or e_QM_RC_CG_WRED. */125};126} t_QmRejectedFrameInfo;127128/**************************************************************************//**129@Description This callback type is used when receiving rejected frames.130131User provides this function. Driver invokes it.132133@Param[in] h_App A user argument to the callback134@Param[in] h_QmFqr A handle to an QM-FQR Module.135@Param[in] fqidOffset fqid offset from the FQR's fqid base.136@Param[in] p_Frame The Rejected Frame137@Param[in] p_QmRejectedFrameInfo Rejected Frame information138139@Retval e_RX_STORE_RESPONSE_CONTINUE - order the driver to continue Rx140operation for all ready data.141@Retval e_RX_STORE_RESPONSE_PAUSE - order the driver to stop Rx operation.142143@Cautions p_Frame is local parameter; i.e. users must NOT access or use144this parameter in any means outside this callback context.145*//***************************************************************************/146typedef e_RxStoreResponse (t_QmRejectedFrameCallback)(t_Handle h_App,147t_Handle h_QmFqr,148t_Handle h_QmPortal,149uint32_t fqidOffset,150t_DpaaFD *p_Frame,151t_QmRejectedFrameInfo *p_QmRejectedFrameInfo);152153154155/**************************************************************************//**156@Group QM_lib_grp QM common API157158@Description QM common API functions, definitions and enums.159160@{161*//***************************************************************************/162163/**************************************************************************//**164@Description QM Exceptions165*//***************************************************************************/166typedef enum e_QmExceptions {167e_QM_EX_CORENET_INITIATOR_DATA = 0, /**< Initiator Data Error */168e_QM_EX_CORENET_TARGET_DATA, /**< CoreNet Target Data Error */169e_QM_EX_CORENET_INVALID_TARGET_TRANSACTION, /**< Invalid Target Transaction */170e_QM_EX_PFDR_THRESHOLD, /**< PFDR Low Watermark Interrupt */171e_QM_EX_PFDR_ENQUEUE_BLOCKED, /**< PFDR Enqueues Blocked Interrupt */172e_QM_EX_SINGLE_ECC, /**< Single Bit ECC Error Interrupt */173e_QM_EX_MULTI_ECC, /**< Multi Bit ECC Error Interrupt */174e_QM_EX_INVALID_COMMAND, /**< Invalid Command Verb Interrupt */175e_QM_EX_DEQUEUE_DCP, /**< Invalid Dequeue Direct Connect Portal Interrupt */176e_QM_EX_DEQUEUE_FQ, /**< Invalid Dequeue FQ Interrupt */177e_QM_EX_DEQUEUE_SOURCE, /**< Invalid Dequeue Source Interrupt */178e_QM_EX_DEQUEUE_QUEUE, /**< Invalid Dequeue Queue Interrupt */179e_QM_EX_ENQUEUE_OVERFLOW, /**< Invalid Enqueue Overflow Interrupt */180e_QM_EX_ENQUEUE_STATE, /**< Invalid Enqueue State Interrupt */181e_QM_EX_ENQUEUE_CHANNEL, /**< Invalid Enqueue Channel Interrupt */182e_QM_EX_ENQUEUE_QUEUE, /**< Invalid Enqueue Queue Interrupt */183e_QM_EX_CG_STATE_CHANGE /**< CG change state notification */184} e_QmExceptions;185186/**************************************************************************//**187@Group QM_init_grp QM (common) Initialization Unit188189@Description QM (common) Initialization Unit190191@{192*//***************************************************************************/193194/**************************************************************************//**195@Function t_QmExceptionsCallback196197@Description Exceptions user callback routine, will be called upon an198exception passing the exception identification.199200@Param[in] h_App - User's application descriptor.201@Param[in] exception - The exception.202*//***************************************************************************/203typedef void (t_QmExceptionsCallback) ( t_Handle h_App,204e_QmExceptions exception);205206/**************************************************************************//**207@Description Frame's Type to poll208*//***************************************************************************/209typedef enum e_QmPortalPollSource {210e_QM_PORTAL_POLL_SOURCE_DATA_FRAMES = 0, /**< Poll only data frames */211e_QM_PORTAL_POLL_SOURCE_CONTROL_FRAMES, /**< Poll only control frames */212e_QM_PORTAL_POLL_SOURCE_BOTH /**< Poll both */213} e_QmPortalPollSource;214215/**************************************************************************//**216@Description structure representing QM contextA of FQ initialization parameters217Note that this is only "space-holder" for the Context-A. The "real"218Context-A is described in each specific driver (E.g. FM driver219has its own Context-A API).220*//***************************************************************************/221typedef struct {222uint32_t res[2]; /**< reserved size for context-a */223} t_QmContextA;224225/**************************************************************************//**226@Description structure representing QM contextB of FQ initialization parameters227Note that this is only "space-holder" for the Context-B. The "real"228Context-B is described in each specific driver (E.g. FM driver229has its own Context-B API).230*//***************************************************************************/231typedef uint32_t t_QmContextB;232233/**************************************************************************//**234@Description structure representing QM initialization parameters235*//***************************************************************************/236typedef struct {237uint8_t guestId; /**< QM Partition Id */238239uintptr_t baseAddress; /**< Qm base address (virtual)240NOTE: this parameter relevant only for BM in master mode ('guestId'=NCSW_MASTER_ID). */241uintptr_t swPortalsBaseAddress; /**< QM Software Portals Base Address (virtual) */242uint16_t liodn; /**< This value is attached to every transaction initiated by QMan when accessing its private data structures */243uint32_t totalNumOfFqids; /**< Total number of frame-queue-ids in the system */244uint32_t fqdMemPartitionId; /**< FQD's mem partition id;245NOTE: The memory partition must be non-cacheable and no-coherent area. */246uint32_t pfdrMemPartitionId; /**< PFDR's mem partition id;247NOTE: The memory partition must be non-cacheable and no-coherent area. */248t_QmExceptionsCallback *f_Exception; /**< An application callback routine to handle exceptions.*/249t_Handle h_App; /**< A handle to an application layer object; This handle will250be passed by the driver upon calling the above callbacks */251uintptr_t errIrq; /**< error interrupt line; NO_IRQ if interrupts not used */252uint32_t partFqidBase; /**< The first frame-queue-id dedicated to this partition.253NOTE: this parameter relevant only when working with multiple partitions. */254uint32_t partNumOfFqids; /**< Number of frame-queue-ids dedicated to this partition.255NOTE: this parameter relevant only when working with multiple partitions. */256uint16_t partCgsBase; /**< The first cgr dedicated to this partition.257NOTE: this parameter relevant only when working with multiple partitions. */258uint16_t partNumOfCgs; /**< Number of cgr's dedicated to this partition.259NOTE: this parameter relevant only when working with multiple partitions. */260} t_QmParam;261262263/**************************************************************************//**264@Function QM_Config265266@Description Creates descriptor for the QM module.267268The routine returns a handle (descriptor) to the QM object.269This descriptor must be passed as first parameter to all other270QM function calls.271272No actual initialization or configuration of QM hardware is273done by this routine.274275@Param[in] p_QmParam - Pointer to data structure of parameters276277@Retval Handle to the QM object, or NULL for Failure.278*//***************************************************************************/279t_Handle QM_Config(t_QmParam *p_QmParam);280281/**************************************************************************//**282@Function QM_Init283284@Description Initializes the QM module285286@Param[in] h_Qm - A handle to the QM module287288@Return E_OK on success; Error code otherwise.289*//***************************************************************************/290t_Error QM_Init(t_Handle h_Qm);291292/**************************************************************************//**293@Function QM_Free294295@Description Frees all resources that were assigned to the QM module.296297Calling this routine invalidates the descriptor.298299@Param[in] h_Qm - A handle to the QM module300301@Return E_OK on success; Error code otherwise.302*//***************************************************************************/303t_Error QM_Free(t_Handle h_Qm);304305306/**************************************************************************//**307@Group QM_advanced_init_grp QM (common) Advanced Configuration Unit308309@Description Configuration functions used to change default values.310311@{312*//***************************************************************************/313314/**************************************************************************//**315@Description structure for defining DC portal ERN destination316*//***************************************************************************/317typedef struct t_QmDcPortalParams {318bool sendToSw;319e_DpaaSwPortal swPortalId;320} t_QmDcPortalParams;321322323/**************************************************************************//**324@Function QM_ConfigRTFramesDepth325326@Description Change the run-time frames depth (i.e. the maximum total number327of frames that may be inside QM at a certain time) from its default328configuration [30000].329330@Param[in] h_Qm - A handle to the QM module331@Param[in] rtFramesDepth - run-time max num of frames.332333@Return E_OK on success; Error code otherwise.334335@Cautions Allowed only following QM_Config() and before QM_Init().336*//***************************************************************************/337t_Error QM_ConfigRTFramesDepth(t_Handle h_Qm, uint32_t rtFramesDepth);338339/**************************************************************************//**340@Function QM_ConfigPfdrThreshold341342@Description Change the pfdr threshold from its default343configuration [0].344An interrupt if enables is asserted when the number of PFDRs is below this threshold.345346@Param[in] h_Qm - A handle to the QM module347@Param[in] threshold - threshold value.348349@Return E_OK on success; Error code otherwise.350351@Cautions Allowed only following QM_Config() and before QM_Init().352*//***************************************************************************/353t_Error QM_ConfigPfdrThreshold(t_Handle h_Qm, uint32_t threshold);354355/**************************************************************************//**356@Function QM_ConfigSfdrReservationThreshold357358@Description Change the sfdr threshold from its default359configuration [0].360361@Param[in] h_Qm - A handle to the QM module362@Param[in] threshold - threshold value.363364@Return E_OK on success; Error code otherwise.365366@Cautions Allowed only following QM_Config() and before QM_Init().367*//***************************************************************************/368t_Error QM_ConfigSfdrReservationThreshold(t_Handle h_Qm, uint32_t threshold);369370/**************************************************************************//**371@Function QM_ConfigErrorRejectionNotificationDest372373@Description Change the destination of rejected frames for DC portals.374By default, depending on chip, some DC portals are set to reject375frames to HW and some to SW.376377@Param[in] h_Qm - A handle to the QM module378@Param[in] id - DC Portal id.379@Param[in] p_Params - Destination parameters.380381@Return E_OK on success; Error code otherwise.382383@Cautions Allowed only following QM_Config() and before QM_Init().384*//***************************************************************************/385t_Error QM_ConfigErrorRejectionNotificationDest(t_Handle h_Qm, e_DpaaDcPortal id, t_QmDcPortalParams *p_Params);386387/** @} */ /* end of QM_advanced_init_grp group */388/** @} */ /* end of QM_init_grp group */389390391/**************************************************************************//**392@Group QM_runtime_control_grp QM (common) Runtime Control Unit393394@Description QM (common) Runtime control unit API functions, definitions and enums.395396@{397*//***************************************************************************/398399/**************************************************************************//**400@Description enum for defining QM counters401*//***************************************************************************/402typedef enum e_QmCounters {403e_QM_COUNTERS_SFDR_IN_USE = 0, /**< Total Single Frame Descriptor Record (SFDR) currently in use */404e_QM_COUNTERS_PFDR_IN_USE, /**< Total Packed Frame Descriptor Record (PFDR) currently in use */405e_QM_COUNTERS_PFDR_FREE_POOL /**< Total Packed Frame Descriptor Record (PFDR) Free Pool Count in external memory */406} e_QmCounters;407408/**************************************************************************//**409@Description structure for returning revision information410*//***************************************************************************/411typedef struct t_QmRevisionInfo {412uint8_t majorRev; /**< Major revision */413uint8_t minorRev; /**< Minor revision */414} t_QmRevisionInfo;415416/**************************************************************************//**417@Description structure representing QM FQ-Range reservation parameters418*//***************************************************************************/419typedef struct t_QmRsrvFqrParams {420bool useForce; /**< TRUE - force reservation of specific fqids;421FALSE - reserve several fqids */422uint32_t numOfFqids; /**< number of fqids to be reserved. */423union{424struct {425uint32_t align; /**< alignment. will be used if useForce=FALSE */426} nonFrcQs;427struct {428uint32_t fqid; /**< the fqid base of the forced fqids. will be used if useForce=TRUE */429} frcQ;430} qs;431} t_QmRsrvFqrParams;432433/**************************************************************************//**434@Description structure representing QM Error information435*//***************************************************************************/436typedef struct t_QmErrorInfo {437bool portalValid;438bool hwPortal;439e_DpaaSwPortal swPortalId; /**< Sw Portal id */440e_DpaaDcPortal dcpId; /**< Dcp (hw Portal) id */441bool fqidValid;442uint32_t fqid;443} t_QmErrorInfo;444445446/**************************************************************************//**447@Function QM_ReserveQueues448449@Description Request to Reserved queues for future use.450451@Param[in] h_Qm - A handle to the QM Module.452@Param[in] p_QmFqrParams - A structure of parameters for defining the453desired queues parameters.454@Param[out] p_BaseFqid - base-fqid on success; '0' code otherwise.455456@Return E_OK on success;457458@Cautions Allowed only after QM_Init().459*//***************************************************************************/460t_Error QM_ReserveQueues(t_Handle h_Qm, t_QmRsrvFqrParams *p_QmFqrParams, uint32_t *p_BaseFqid);461462#if (defined(DEBUG_ERRORS) && (DEBUG_ERRORS > 0))463/**************************************************************************//**464@Function QM_DumpRegs465466@Description Dumps all QM registers467468@Param[in] h_Qm - A handle to the QM Module.469470@Return E_OK on success;471472@Cautions Allowed only after QM_Init().473*//***************************************************************************/474t_Error QM_DumpRegs(t_Handle h_Qm);475#endif /* (defined(DEBUG_ERRORS) && ... */476477/**************************************************************************//**478@Function QM_SetException479480@Description Calling this routine enables/disables the specified exception.481482@Param[in] h_Qm - A handle to the QM Module.483@Param[in] exception - The exception to be selected.484@Param[in] enable - TRUE to enable interrupt, FALSE to mask it.485486@Return E_OK on success; Error code otherwise.487488@Cautions Allowed only following QM_Init().489This routine should NOT be called from guest-partition490(i.e. guestId != NCSW_MASTER_ID)491*//***************************************************************************/492t_Error QM_SetException(t_Handle h_Qm, e_QmExceptions exception, bool enable);493494/**************************************************************************//**495@Function QM_ErrorIsr496497@Description QM interrupt-service-routine for errors.498499@Param[in] h_Qm - A handle to the QM module500501@Cautions Allowed only following QM_Init().502This routine should NOT be called from guest-partition503(i.e. guestId != NCSW_MASTER_ID)504*//***************************************************************************/505void QM_ErrorIsr(t_Handle h_Qm);506507/**************************************************************************//**508@Function QM_GetErrorInformation509510@Description Reads the last error information.511512@Param[in] h_Qm - A handle to the QM Module.513@Param[out] p_errInfo - the information will be loaded to this struct.514515@Return E_OK on success; Error code otherwise.516517@Cautions Allowed only following QM_Init().518This routine should NOT be called from guest-partition519(i.e. guestId != NCSW_MASTER_ID)520*//***************************************************************************/521t_Error QM_GetErrorInformation(t_Handle h_Qm, t_QmErrorInfo *p_errInfo);522523/**************************************************************************//**524@Function QM_GetCounter525526@Description Reads one of the QM counters.527528@Param[in] h_Qm - A handle to the QM Module.529@Param[in] counter - The requested counter.530531@Return Counter's current value.532533@Cautions Allowed only following QM_Init().534*//***************************************************************************/535uint32_t QM_GetCounter(t_Handle h_Qm, e_QmCounters counter);536537/**************************************************************************//**538@Function QM_GetRevision539540@Description Returns the QM revision541542@Param[in] h_Qm A handle to a QM Module.543@Param[out] p_QmRevisionInfo A structure of revision information parameters.544545@Return None.546547@Cautions Allowed only following QM_Init().548*//***************************************************************************/549t_Error QM_GetRevision(t_Handle h_Qm, t_QmRevisionInfo *p_QmRevisionInfo);550551/** @} */ /* end of QM_runtime_control_grp group */552553554/**************************************************************************//**555@Group QM_runtime_data_grp QM (common) Runtime Data Unit556557@Description QM (common) Runtime data unit API functions, definitions and enums.558559@{560*//***************************************************************************/561562/**************************************************************************//**563@Function QM_Poll564565@Description Poll frames from QM.566567@Param[in] h_Qm - A handle to the QM module568@Param[in] source - The selected frames type to poll569570@Return E_OK on success; Error code otherwise.571572@Cautions Allowed only following QM_Init().573*//***************************************************************************/574t_Error QM_Poll(t_Handle h_Qm, e_QmPortalPollSource source);575576/** @} */ /* end of QM_runtime_data_grp group */577/** @} */ /* end of QM_lib_grp group */578579580/**************************************************************************//**581@Group QM_portal_grp QM-Portal API582583@Description QM common API functions, definitions and enums.584585@{586*//***************************************************************************/587588/**************************************************************************//**589@Group QM_portal_init_grp QM-Portal Initialization Unit590591@Description QM-Portal Initialization Unit592593@{594*//***************************************************************************/595596/**************************************************************************//**597@Description structure representing QM-Portal Stash parameters598*//***************************************************************************/599typedef struct {600uint8_t stashDestQueue; /**< This value is used to direct all stashing transactions initiated on behalf of this software portal601to the specific Stashing Request Queues (SRQ) */602uint8_t eqcr; /**< If 0, disabled. If 1, for every EQCR entry consumed by QMan a new stash transaction is performed.603If 2-7, after 2-7 EQCR entries being consumed by QMAN a new stash transaction is performed. */604bool eqcrHighPri; /**< EQCR entry stash transactions for this software portal will be signaled with higher priority. */605bool dqrr; /**< DQRR entry stash enable/disable */606uint16_t dqrrLiodn; /**< This value is attached to every transaction initiated by QMan when performing DQRR entry or EQCR_CI stashing607on behalf of this software portal */608bool dqrrHighPri; /**< DQRR entry stash transactions for this software portal will be signaled with higher priority. */609bool fdFq; /**< Dequeued Frame Data, Annotation, and FQ Context Stashing enable/disable */610uint16_t fdFqLiodn; /**< This value is attached to every transaction initiated by QMan when performing dequeued frame data and611annotation stashing, or FQ context stashing on behalf of this software portal */612bool fdFqHighPri; /**< Dequeued frame data, annotation, and FQ context stash transactions for this software portal will be signaled613with higher priority. */614bool fdFqDrop; /**< If True, Dequeued frame data, annotation, and FQ context stash transactions for this software portal will be dropped615by QMan if the target SRQ is almost full, to prevent QMan sequencer stalling. Stash transactions that are616dropped will result in a fetch from main memory when a core reads the addressed coherency granule.617If FALSE, Dequeued frame data, annotation, and FQ context stash transactions for this software portal will never be618dropped by QMan. If the target SRQ is full a sequencer will stall until each stash transaction can be completed. */619} t_QmPortalStashParam;620621/**************************************************************************//**622@Description structure representing QM-Portal initialization parameters623*//***************************************************************************/624typedef struct {625uintptr_t ceBaseAddress; /**< Cache-enabled base address (virtual) */626uintptr_t ciBaseAddress; /**< Cache-inhibited base address (virtual) */627t_Handle h_Qm; /**< Qm Handle */628e_DpaaSwPortal swPortalId; /**< Portal id */629uintptr_t irq; /**< portal interrupt line; used only if useIrq set to TRUE */630uint16_t fdLiodnOffset; /**< liodn to be used for all frames enqueued via this software portal */631t_QmReceivedFrameCallback *f_DfltFrame; /**< this callback will be called unless specific callback assigned to the FQ*/632t_QmRejectedFrameCallback *f_RejectedFrame; /**< this callback will be called for rejected frames. */633t_Handle h_App; /**< a handle to the upper layer; It will be passed by the driver upon calling the CB */634} t_QmPortalParam;635636637/**************************************************************************//**638@Function QM_PORTAL_Config639640@Description Creates descriptor for a QM-Portal module.641642The routine returns a handle (descriptor) to a QM-Portal object.643This descriptor must be passed as first parameter to all other644QM-Portal function calls.645646No actual initialization or configuration of QM-Portal hardware is647done by this routine.648649@Param[in] p_QmPortalParam - Pointer to data structure of parameters650651@Retval Handle to a QM-Portal object, or NULL for Failure.652*//***************************************************************************/653t_Handle QM_PORTAL_Config(t_QmPortalParam *p_QmPortalParam);654655/**************************************************************************//**656@Function QM_PORTAL_Init657658@Description Initializes a QM-Portal module659660@Param[in] h_QmPortal - A handle to a QM-Portal module661662@Return E_OK on success; Error code otherwise.663*//***************************************************************************/664t_Error QM_PORTAL_Init(t_Handle h_QmPortal);665666/**************************************************************************//**667@Function QM_PORTAL_Free668669@Description Frees all resources that were assigned to a QM-Portal module.670671Calling this routine invalidates the descriptor.672673@Param[in] h_QmPortal - A handle to a QM-Portal module674675@Return E_OK on success; Error code otherwise.676*//***************************************************************************/677t_Error QM_PORTAL_Free(t_Handle h_QmPortal);678679/**************************************************************************//**680@Group QM_portal_advanced_init_grp QM-Portal Advanced Configuration Unit681682@Description Configuration functions used to change default values.683684@{685*//***************************************************************************/686687/**************************************************************************//**688@Function QM_PORTAL_ConfigDcaMode689690@Description Change the Discrate Consumption Acknowledge mode691from its default configuration [FALSE].692693@Param[in] h_QmPortal - A handle to a QM-Portal module694@Param[in] enable - Enable/Disable DCA mode695696@Return E_OK on success; Error code otherwise.697698@Cautions Allowed only following QM_PORTAL_Config() and before QM_PORTAL_Init().699*//***************************************************************************/700t_Error QM_PORTAL_ConfigDcaMode(t_Handle h_QmPortal, bool enable);701702/**************************************************************************//**703@Function QM_PORTAL_ConfigStash704705@Description Config the portal to active stash mode.706707@Param[in] h_QmPortal - A handle to a QM-Portal module708@Param[in] p_StashParams - Pointer to data structure of parameters709710@Return E_OK on success; Error code otherwise.711712@Cautions Allowed only following QM_PORTAL_Config() and before QM_PORTAL_Init().713*//***************************************************************************/714t_Error QM_PORTAL_ConfigStash(t_Handle h_QmPortal, t_QmPortalStashParam *p_StashParams);715716717/**************************************************************************//**718@Function QM_PORTAL_ConfigPullMode719720@Description Change the Pull Mode from its default configuration [FALSE].721722@Param[in] h_QmPortal - A handle to a QM-Portal module723@Param[in] pullMode - When TRUE, the Portal will work in pull mode.724725@Return E_OK on success; Error code otherwise.726727@Cautions Allowed only following QM_PORTAL_Config() and before QM_PORTAL_Init().728*//***************************************************************************/729t_Error QM_PORTAL_ConfigPullMode(t_Handle h_QmPortal, bool pullMode);730731/** @} */ /* end of QM_portal_advanced_init_grp group */732/** @} */ /* end of QM_portal_init_grp group */733734735/**************************************************************************//**736@Group QM_portal_runtime_control_grp QM-Portal Runtime Control Unit737738@Description QM-Portal Runtime control unit API functions, definitions and enums.739740@{741*//***************************************************************************/742743/**************************************************************************//**744@Function QM_PORTAL_AddPoolChannel745746@Description Adding the pool channel to the SW-Portal's scheduler.747the sw-portal will get frames that came from the pool channel.748749@Param[in] h_QmPortal - A handle to a QM-Portal module750@Param[in] poolChannelId - Pool channel id. must between '0' to QM_MAX_NUM_OF_POOL_CHANNELS751752@Return E_OK on success; Error code otherwise.753754@Cautions Allowed only following QM_PORTAL_Init().755*//***************************************************************************/756t_Error QM_PORTAL_AddPoolChannel(t_Handle h_QmPortal, uint8_t poolChannelId);757758/** @} */ /* end of QM_portal_runtime_control_grp group */759760761/**************************************************************************//**762@Group QM_portal_runtime_data_grp QM-Portal Runtime Data Unit763764@Description QM-Portal Runtime data unit API functions, definitions and enums.765766@{767*//***************************************************************************/768769/**************************************************************************//**770@Description structure representing QM Portal Frame Info771*//***************************************************************************/772typedef struct t_QmPortalFrameInfo {773t_Handle h_App;774t_Handle h_QmFqr;775uint32_t fqidOffset;776t_DpaaFD frame;777} t_QmPortalFrameInfo;778779/**************************************************************************//**780@Function QM_PORTAL_Poll781782@Description Poll frames from the specified sw-portal.783784@Param[in] h_QmPortal - A handle to a QM-Portal module785@Param[in] source - The selected frames type to poll786787@Return E_OK on success; Error code otherwise.788789@Cautions Allowed only following QM_PORTAL_Init().790*//***************************************************************************/791t_Error QM_PORTAL_Poll(t_Handle h_QmPortal, e_QmPortalPollSource source);792793/**************************************************************************//**794@Function QM_PORTAL_PollFrame795796@Description Poll frames from the specified sw-portal. will poll only data frames797798@Param[in] h_QmPortal - A handle to a QM-Portal module799@Param[out] p_frameInfo - A structure to hold the dequeued frame information800801@Return E_OK on success; Error code otherwise.802803@Cautions Allowed only following QM_PORTAL_Init().804*//***************************************************************************/805t_Error QM_PORTAL_PollFrame(t_Handle h_QmPortal, t_QmPortalFrameInfo *p_frameInfo);806807808/** @} */ /* end of QM_portal_runtime_data_grp group */809/** @} */ /* end of QM_portal_grp group */810811812/**************************************************************************//**813@Group QM_fqr_grp QM Frame-Queue-Range API814815@Description QM-FQR API functions, definitions and enums.816817@{818*//***************************************************************************/819820/**************************************************************************//**821@Group QM_fqr_init_grp QM-FQR Initialization Unit822823@Description QM-FQR Initialization Unit824825@{826*//***************************************************************************/827828829/**************************************************************************//**830@Description structure representing QM FQ-Range congestion group parameters831*//***************************************************************************/832typedef struct {833t_Handle h_QmCg; /**< A handle to the congestion group. */834int8_t overheadAccountingLength; /**< For each frame add this number for CG calculation835(may be negative), if 0 - disable feature */836uint32_t fqTailDropThreshold; /**< if not "0" - enable tail drop on this FQR */837} t_QmFqrCongestionAvoidanceParams;838839/**************************************************************************//**840@Description structure representing QM FQ-Range initialization parameters841*//***************************************************************************/842typedef struct {843t_Handle h_Qm; /**< A handle to a QM module */844t_Handle h_QmPortal; /**< A handle to a QM Portal Module;845will be used only for Init and Free routines;846NOTE : if NULL, assuming affinity */847bool initParked; /**< This FQ-Range will be initialize in park state (un-schedule) */848bool holdActive; /**< This FQ-Range can be parked (un-schedule);849This affects only on queues destined to software portals*/850bool preferInCache; /**< Prefer this FQ-Range to be in QMAN's internal cache for all states */851bool useContextAForStash;/**< This FQ-Range will use context A for stash */852union {853struct {854uint8_t frameAnnotationSize;/**< Size of Frame Annotation to be stashed */855uint8_t frameDataSize; /**< Size of Frame Data to be stashed. */856uint8_t fqContextSize; /**< Size of FQ context to be stashed. */857uint64_t fqContextAddr; /**< 40 bit memory address containing the FQ context information to be stashed;858Must be cacheline-aligned */859} stashingParams;860t_QmContextA *p_ContextA; /**< context-A field to be written in the FQ structure */861};862t_QmContextB *p_ContextB; /**< context-B field to be written in the FQ structure;863Note that this field may be used for Tx queues only! */864e_QmFQChannel channel; /**< Qm Channel */865uint8_t wq; /**< Work queue within the channel */866bool shadowMode; /**< If TRUE, useForce MUST set to TRUE and numOfFqids MUST set to '1' */867uint32_t numOfFqids; /**< number of fqids to be allocated*/868bool useForce; /**< TRUE - force allocation of specific fqids;869FALSE - allocate several fqids */870union{871struct {872uint32_t align; /**< alignment. will be used if useForce=FALSE */873} nonFrcQs;874struct {875uint32_t fqid; /**< the fqid base of the forced fqids. will be used if useForce=TRUE */876} frcQ;877} qs;878bool congestionAvoidanceEnable;879/**< TRUE to enable congestion avoidance mechanism */880t_QmFqrCongestionAvoidanceParams congestionAvoidanceParams;881/**< Parameters for congestion avoidance */882} t_QmFqrParams;883884885/**************************************************************************//**886@Function QM_FQR_Create887888@Description Initializing and enabling a Frame-Queue-Range.889This routine should be called for adding an FQR.890891@Param[in] p_QmFqrParams - A structure of parameters for defining the892desired queues parameters.893894@Return A handle to the initialized FQR on success; NULL code otherwise.895896@Cautions Allowed only following QM_Init().897*//***************************************************************************/898t_Handle QM_FQR_Create(t_QmFqrParams *p_QmFqrParams);899900/**************************************************************************//**901@Function QM_FQR_Free902903@Description Deleting and free all resources of an initialized FQR.904905@Param[in] h_QmFqr - A handle to a QM-FQR Module.906907@Return E_OK on success; Error code otherwise.908909@Cautions Allowed only following QM_Init() and QM_FQR_Create() for this FQR.910*//***************************************************************************/911t_Error QM_FQR_Free(t_Handle h_QmFqr);912913/**************************************************************************//**914@Function QM_FQR_FreeWDrain915916@Description Deleting and free all resources of an initialized FQR917with the option of draining.918919@Param[in] h_QmFqr - A handle to a QM-FQR Module.920@Param[in] f_CompletionCB - Pointer to a completion callback to be used in non-blocking mode.921@Param[in] deliverFrame - TRUE for deliver the drained frames to the user;922FALSE for not deliver the frames.923@Param[in] f_CallBack - Pointer to a callback to handle the delivered frames.924@Param[in] h_App - User's application descriptor.925926@Return E_OK on success; Error code otherwise.927928@Cautions Allowed only following QM_Init() and QM_FQR_Create() for this FQR.929*//***************************************************************************/930t_Error QM_FQR_FreeWDrain(t_Handle h_QmFqr,931t_QmFqrDrainedCompletionCB *f_CompletionCB,932bool deliverFrame,933t_QmReceivedFrameCallback *f_CallBack,934t_Handle h_App);935936/** @} */ /* end of QM_fqr_init_grp group */937938939/**************************************************************************//**940@Group QM_fqr_runtime_control_grp QM-FQR Runtime Control Unit941942@Description QM-FQR Runtime control unit API functions, definitions and enums.943944@{945*//***************************************************************************/946947/**************************************************************************//**948@Description enum for defining QM-FQR counters949*//***************************************************************************/950typedef enum e_QmFqrCounters {951e_QM_FQR_COUNTERS_FRAME = 0, /**< Total number of frames on this frame queue */952e_QM_FQR_COUNTERS_BYTE /**< Total number of bytes in all frames on this frame queue */953} e_QmFqrCounters;954955/**************************************************************************//**956@Function QM_FQR_RegisterCB957958@Description Register a callback routine to be called when a frame comes from this FQ-Range959960@Param[in] h_QmFqr - A handle to a QM-FQR Module.961@Param[in] f_CallBack - An application callback962@Param[in] h_App - User's application descriptor963964@Return E_OK on success; Error code otherwise.965966@Cautions Allowed only following QM_FQR_Create().967*//***************************************************************************/968t_Error QM_FQR_RegisterCB(t_Handle h_QmFqr, t_QmReceivedFrameCallback *f_CallBack, t_Handle h_App);969970/**************************************************************************//**971@Function QM_FQR_Resume972973@Description Request to Re-Schedule this Fqid.974975@Param[in] h_QmFqr - A handle to a QM-FQR Module.976@Param[in] h_QmPortal - A handle to a QM Portal Module;977NOTE : if NULL, assuming affinity.978@Param[in] fqidOffset - Fqid offset within the FQ-Range.979980@Return E_OK on success; Error code otherwise.981982@Cautions Allowed only following QM_FQR_Create().983*//***************************************************************************/984t_Error QM_FQR_Resume(t_Handle h_QmFqr, t_Handle h_QmPortal, uint32_t fqidOffset);985986/**************************************************************************//**987@Function QM_FQR_Suspend988989@Description Request to Un-Schedule this Fqid.990991@Param[in] h_QmFqr - A handle to a QM-FQR Module.992@Param[in] h_QmPortal - A handle to a QM Portal Module;993NOTE : if NULL, assuming affinity.994@Param[in] fqidOffset - Fqid offset within the FQ-Range.995996@Return E_OK on success; Error code otherwise.997998@Cautions Allowed only following QM_FQR_Create().999*//***************************************************************************/1000t_Error QM_FQR_Suspend(t_Handle h_QmFqr, t_Handle h_QmPortal, uint32_t fqidOffset);10011002/**************************************************************************//**1003@Function QM_FQR_GetFqid10041005@Description Returned the Fqid base of the FQ-Range10061007@Param[in] h_QmFqr - A handle to a QM-FQR Module.10081009@Return Fqid base.10101011@Cautions Allowed only following QM_FQR_Create().1012*//***************************************************************************/1013uint32_t QM_FQR_GetFqid(t_Handle h_QmFqr);10141015/**************************************************************************//**1016@Function QM_FQR_GetCounter10171018@Description Reads one of the QM-FQR counters.10191020@Param[in] h_QmFqr - A handle to a QM-FQR Module.1021@Param[in] h_QmPortal - A handle to a QM Portal Module;1022NOTE : if NULL, assuming affinity.1023@Param[in] fqidOffset - Fqid offset within the FQ-Range.1024@Param[in] counter - The requested counter.10251026@Return Counter's current value.10271028@Cautions Allowed only following QM_FQR_Create().1029*//***************************************************************************/1030uint32_t QM_FQR_GetCounter(t_Handle h_QmFqr, t_Handle h_QmPortal, uint32_t fqidOffset, e_QmFqrCounters counter);10311032/** @} */ /* end of QM_fqr_runtime_control_grp group */103310341035/**************************************************************************//**1036@Group QM_fqr_runtime_data_grp QM-FQR Runtime Data Unit10371038@Description QM-FQR Runtime data unit API functions, definitions and enums.10391040@{1041*//***************************************************************************/10421043/**************************************************************************//**1044@Function QM_FQR_Enqueue10451046@Description Enqueue the frame into the FQ to be transmitted.10471048@Param[in] h_QmFqr - A handle to a QM-FQR Module.1049@Param[in] h_QmPortal - A handle to a QM Portal Module;1050NOTE : if NULL, assuming affinity.1051@Param[in] fqidOffset - Fqid offset within the FQ-Range.1052@Param[in] p_Frame - Pointer to the frame to be enqueued.10531054@Return E_OK on success; Error code otherwise.10551056@Cautions Allowed only following QM_FQR_Create().1057*//***************************************************************************/1058t_Error QM_FQR_Enqueue(t_Handle h_QmFqr, t_Handle h_QmPortal, uint32_t fqidOffset, t_DpaaFD *p_Frame);10591060/**************************************************************************//**1061@Function QM_FQR_PullFrame10621063@Description Perform a Pull command.10641065@Param[in] h_QmFqr - A handle to a QM-FQR Module.1066@Param[in] h_QmPortal - A handle to a QM Portal Module;1067NOTE : if NULL, assuming affinity.1068@Param[in] fqidOffset - Fqid offset within the FQ-Range.1069@Param[out] p_Frame - The Received Frame10701071@Return E_OK on success; Error code otherwise.10721073@Cautions Allowed only following QM_PORTAL_Init().1074*//***************************************************************************/1075t_Error QM_FQR_PullFrame(t_Handle h_QmFqr, t_Handle h_QmPortal, uint32_t fqidOffset, t_DpaaFD *p_Frame);107610771078/** @} */ /* end of QM_fqr_runtime_data_grp group */1079/** @} */ /* end of QM_fqr_grp group */108010811082/**************************************************************************//**1083@Group QM_cg_grp QM Congestion Group API10841085@Description QM-CG API functions, definitions and enums.10861087@{1088*//***************************************************************************/10891090/**************************************************************************//**1091@Group QM_cg_init_grp QM-Congestion Group Initialization Unit10921093@Description QM-CG Initialization Unit10941095@{1096*//***************************************************************************/10971098/**************************************************************************//**1099@Description structure representing QM CG WRED curve1100*//***************************************************************************/1101typedef struct t_QmCgWredCurve {1102uint32_t maxTh; /**< minimum threshold - below this level1103all packets are rejected (approximated1104to be expressed as x*2^y due to HW1105implementation)*/1106uint32_t minTh; /**< minimum threshold - below this level1107all packets are accepted (approximated1108due to HW implementation)*/1109uint8_t probabilityDenominator; /**< 1-64, the fraction of packets dropped1110when the average queue depth is at the1111maximum threshold.(approximated due to HW1112implementation). */1113} t_QmCgWredCurve;11141115/**************************************************************************//**1116@Description structure representing QM CG WRED parameters1117*//***************************************************************************/1118typedef struct t_QmCgWredParams {1119bool enableGreen;1120t_QmCgWredCurve greenCurve;1121bool enableYellow;1122t_QmCgWredCurve yellowCurve;1123bool enableRed;1124t_QmCgWredCurve redCurve;1125} t_QmCgWredParams;11261127/**************************************************************************//**1128@Description structure representing QM CG configuration parameters1129*//***************************************************************************/1130typedef struct t_QmCgParams {1131t_Handle h_Qm; /**< A handle to a QM module */1132t_Handle h_QmPortal; /**< A handle to a QM Portal Module;1133will be used for Init, Free and as1134an interrupt destination for cg state1135change (if CgStateChangeEnable = TRUE) */1136bool frameCount; /**< TRUE for frame count, FALSE - byte count */1137bool wredEnable; /**< if TRUE - WRED enabled. Each color is enabled independently1138so that some colors may use WRED, but others may use1139Tail drop - if enabled, or none. */1140t_QmCgWredParams wredParams; /**< WRED parameters, relevant if wredEnable = TRUE*/1141bool tailDropEnable; /**< if TRUE - Tail drop enabled */1142uint32_t threshold; /**< If Tail drop - used as Tail drop threshold, otherwise1143'threshold' may still be used to receive notifications1144when threshold is passed. If threshold and f_Exception1145are set, interrupts are set defaultly by driver. */1146bool notifyDcPortal; /**< Relevant if this CG receives enqueues from a direct portal1147e_DPAA_DCPORTAL0 or e_DPAA_DCPORTAL1. TRUE to notify1148the DC portal, FALSE to notify this SW portal. */1149e_DpaaDcPortal dcPortalId; /**< relevant if notifyDcPortal=TRUE - DC Portal id */1150t_QmExceptionsCallback *f_Exception; /**< relevant and mandatory if threshold is configured and1151notifyDcPortal = FALSE. If threshold and f_Exception1152are set, interrupts are set defaultly by driver */1153t_Handle h_App; /**< A handle to the application layer, will be passed as1154argument to f_Exception */1155} t_QmCgParams;115611571158/**************************************************************************//**1159@Function QM_CG_Create11601161@Description Create and configure a congestion Group.11621163@Param[in] p_CgParams - CG parameters11641165@Return A handle to the CG module11661167@Cautions Allowed only following QM_Init().1168*//***************************************************************************/1169t_Handle QM_CG_Create(t_QmCgParams *p_CgParams);11701171/**************************************************************************//**1172@Function QM_CG_Free11731174@Description Deleting and free all resources of an initialized CG.11751176@Param[in] h_QmCg - A handle to a QM-CG Module.11771178@Return E_OK on success; Error code otherwise.11791180@Cautions Allowed only following QM_Init() and QM_CR_Create() for this CG.1181*//***************************************************************************/1182t_Error QM_CG_Free(t_Handle h_QmCg);11831184/** @} */ /* end of QM_cg_init_grp group */118511861187/**************************************************************************//**1188@Group QM_cg_runtime_control_grp QM-CG Runtime Control Unit11891190@Description QM-CG Runtime control unit API functions, definitions and enums.11911192@{1193*//***************************************************************************/11941195/**************************************************************************//**1196@Description structure representing QM CG WRED colors1197*//***************************************************************************/1198typedef enum e_QmCgColor {1199e_QM_CG_COLOR_GREEN,1200e_QM_CG_COLOR_YELLOW,1201e_QM_CG_COLOR_RED1202} e_QmCgColor;12031204/**************************************************************************//**1205@Description structure representing QM CG modification parameters1206*//***************************************************************************/1207typedef struct t_QmCgModifyWredParams {1208e_QmCgColor color;1209bool enable;1210t_QmCgWredCurve wredParams;1211} t_QmCgModifyWredParams;121212131214/**************************************************************************//**1215@Function QM_CG_SetException12161217@Description Set CG exception.12181219@Param[in] h_QmCg - A handle to a QM-CG Module.1220@Param[in] exception - exception enum1221@Param[in] enable - TRUE to enable, FALSE to disable.12221223@Return E_OK on success; Error code otherwise.12241225@Cautions Allowed only following QM_Init() and QM_CG_Create() for this CG.1226*//***************************************************************************/1227t_Error QM_CG_SetException(t_Handle h_QmCg, e_QmExceptions exception, bool enable);12281229/**************************************************************************//**1230@Function QM_CG_ModifyWredCurve12311232@Description Change WRED curve parameters for a selected color.1233Note that this routine may be called only for valid CG's that1234already have been configured for WRED, and only need a change1235in the WRED parameters.12361237@Param[in] h_QmCg - A handle to a QM-CG Module.1238@Param[in] p_QmCgModifyParams - A structure of new WRED parameters.12391240@Return E_OK on success; Error code otherwise.12411242@Cautions Allowed only following QM_Init() and QM_CG_Create() for this CG.1243*//***************************************************************************/1244t_Error QM_CG_ModifyWredCurve(t_Handle h_QmCg, t_QmCgModifyWredParams *p_QmCgModifyParams);12451246/**************************************************************************//**1247@Function QM_CG_ModifyTailDropThreshold12481249@Description Change WRED curve parameters for a selected color.1250Note that this routine may be called only for valid CG's that1251already have been configured for tail drop, and only need a change1252in the threshold value.12531254@Param[in] h_QmCg - A handle to a QM-CG Module.1255@Param[in] threshold - New threshold.12561257@Return E_OK on success; Error code otherwise.12581259@Cautions Allowed only following QM_Init() and QM_CG_Create() for this CG.1260*//***************************************************************************/1261t_Error QM_CG_ModifyTailDropThreshold(t_Handle h_QmCg, uint32_t threshold);126212631264/** @} */ /* end of QM_cg_runtime_control_grp group */1265/** @} */ /* end of QM_cg_grp group */1266/** @} */ /* end of QM_grp group */126712681269#endif /* __QM_EXT_H */127012711272