Path: blob/main/sys/contrib/ncsw/Peripherals/QM/qm.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 qm.h3738@Description QM header39*//***************************************************************************/40#ifndef __QM_H41#define __QM_H4243#include "std_ext.h"44#include "list_ext.h"45#include "qm_ext.h"46#include "qman_private.h"47#include "qm_ipc.h"484950#define __ERR_MODULE__ MODULE_QM5152#define QM_NUM_OF_SWP 1053#define QM_NUM_OF_DCP 55455#define CACHELINE_SIZE 6456#define QM_CONTEXTA_MAX_STASH_SIZE (3 * CACHELINE_SIZE)5758/**************************************************************************//**59@Description Exceptions60*//***************************************************************************/61#define QM_EX_CORENET_INITIATOR_DATA 0x2000000062#define QM_EX_CORENET_TARGET_DATA 0x1000000063#define QM_EX_CORENET_INVALID_TARGET_TRANSACTION 0x0800000064#define QM_EX_PFDR_THRESHOLD 0x0400000065#define QM_EX_MULTI_ECC 0x0200000066#define QM_EX_SINGLE_ECC 0x0100000067#define QM_EX_PFDR_ENQUEUE_BLOCKED 0x0080000068#define QM_EX_INVALID_COMMAND 0x0001000069#define QM_EX_DEQUEUE_DCP 0x0000080070#define QM_EX_DEQUEUE_FQ 0x0000040071#define QM_EX_DEQUEUE_SOURCE 0x0000020072#define QM_EX_DEQUEUE_QUEUE 0x0000010073#define QM_EX_ENQUEUE_OVERFLOW 0x0000000874#define QM_EX_ENQUEUE_STATE 0x0000000475#define QM_EX_ENQUEUE_CHANNEL 0x0000000276#define QM_EX_ENQUEUE_QUEUE 0x000000017778#define GET_EXCEPTION_FLAG(bitMask, exception) switch(exception){ \79case e_QM_EX_CORENET_INITIATOR_DATA: \80bitMask = QM_EX_CORENET_INITIATOR_DATA; break; \81case e_QM_EX_CORENET_TARGET_DATA: \82bitMask = QM_EX_CORENET_TARGET_DATA; break; \83case e_QM_EX_CORENET_INVALID_TARGET_TRANSACTION: \84bitMask = QM_EX_CORENET_INVALID_TARGET_TRANSACTION; break; \85case e_QM_EX_PFDR_THRESHOLD: \86bitMask = QM_EX_PFDR_THRESHOLD; break; \87case e_QM_EX_PFDR_ENQUEUE_BLOCKED: \88bitMask = QM_EX_PFDR_ENQUEUE_BLOCKED; break; \89case e_QM_EX_SINGLE_ECC: \90bitMask = QM_EX_SINGLE_ECC; break; \91case e_QM_EX_MULTI_ECC: \92bitMask = QM_EX_MULTI_ECC; break; \93case e_QM_EX_INVALID_COMMAND: \94bitMask = QM_EX_INVALID_COMMAND; break; \95case e_QM_EX_DEQUEUE_DCP: \96bitMask = QM_EX_DEQUEUE_DCP; break; \97case e_QM_EX_DEQUEUE_FQ: \98bitMask = QM_EX_DEQUEUE_FQ; break; \99case e_QM_EX_DEQUEUE_SOURCE: \100bitMask = QM_EX_DEQUEUE_SOURCE; break; \101case e_QM_EX_DEQUEUE_QUEUE: \102bitMask = QM_EX_DEQUEUE_QUEUE; break; \103case e_QM_EX_ENQUEUE_OVERFLOW: \104bitMask = QM_EX_ENQUEUE_OVERFLOW; break; \105case e_QM_EX_ENQUEUE_STATE: \106bitMask = QM_EX_ENQUEUE_STATE; break; \107case e_QM_EX_ENQUEUE_CHANNEL: \108bitMask = QM_EX_ENQUEUE_CHANNEL; break; \109case e_QM_EX_ENQUEUE_QUEUE: \110bitMask = QM_EX_ENQUEUE_QUEUE; break; \111default: bitMask = 0;break;}112113/**************************************************************************//**114@Description defaults115*//***************************************************************************/116/* QM defaults */117#define DEFAULT_exceptions ((uint32_t)(QM_EX_CORENET_INITIATOR_DATA | \118QM_EX_CORENET_TARGET_DATA | \119QM_EX_CORENET_INVALID_TARGET_TRANSACTION | \120QM_EX_PFDR_THRESHOLD | \121QM_EX_SINGLE_ECC | \122QM_EX_MULTI_ECC | \123QM_EX_PFDR_ENQUEUE_BLOCKED | \124QM_EX_INVALID_COMMAND | \125QM_EX_DEQUEUE_DCP | \126QM_EX_DEQUEUE_FQ | \127QM_EX_DEQUEUE_SOURCE | \128QM_EX_DEQUEUE_QUEUE | \129QM_EX_ENQUEUE_OVERFLOW | \130QM_EX_ENQUEUE_STATE | \131QM_EX_ENQUEUE_CHANNEL | \132QM_EX_ENQUEUE_QUEUE ))133#define DEFAULT_rtFramesDepth 30000134#define DEFAULT_pfdrThreshold 0135#define DEFAULT_sfdrThreshold 0136#define DEFAULT_pfdrBaseConstant 64137/* Corenet initiator settings. Stash request queues are 4-deep to match cores'138ability to snart. Stash priority is 3, other priorities are 2. */139#define DEFAULT_initiatorSrcciv 0140#define DEFAULT_initiatorSrqW 3141#define DEFAULT_initiatorRwW 2142#define DEFAULT_initiatorBmanW 2143144145/* QM-Portal defaults */146#define DEFAULT_dequeueDcaMode FALSE147#define DEFAULT_dequeueUpToThreeFrames TRUE148#define DEFAULT_dequeueCommandType e_QM_PORTAL_PRIORITY_PRECEDENCE_INTRA_CLASS_SCHEDULING149#define DEFAULT_dequeueUserToken 0xab150#define DEFAULT_dequeueSpecifiedWq FALSE151#define DEFAULT_dequeueDedicatedChannel TRUE152#define DEFAULT_dequeuePoolChannelId 0153#define DEFAULT_dequeueWqId 0154#define DEFAULT_dequeueDedicatedChannelHasPrecedenceOverPoolChannels TRUE155#define DEFAULT_dqrrSize DQRR_MAXFILL156#define DEFAULT_pullMode FALSE157#define DEFAULT_portalExceptions ((uint32_t)(QM_PIRQ_EQCI | \158QM_PIRQ_EQRI | \159QM_PIRQ_DQRI | \160QM_PIRQ_MRI | \161QM_PIRQ_CSCI))162163/**************************************************************************//**164@Description Memory Mapped Registers165*//***************************************************************************/166167#if defined(__MWERKS__) && !defined(__GNUC__)168#pragma pack(push,1)169#endif /* defined(__MWERKS__) && ... */170#define MEM_MAP_START171172typedef _Packed struct173{174/* QMan Software Portal Configuration Registers */175_Packed struct {176volatile uint32_t lio_cfg; /**< QMan Software Portal LIO Configuration */177volatile uint32_t io_cfg; /**< QMan Software Portal 0 IO Configuration */178volatile uint8_t res1[4]; /**< reserved */179volatile uint32_t dd_cfg; /**< Software Portal Dynamic Debug Configuration */180} _PackedType swpConfRegs[QM_NUM_OF_SWP];181volatile uint8_t res1[352]; /**< reserved */182183/* Dynamic Debug (DD) Configuration Registers */184volatile uint32_t qman_dd_cfg; /**< QMan Dynamic Debug (DD) Configuration */185volatile uint8_t res2[12]; /**< reserved */186volatile uint32_t qcsp_dd_ihrsr; /**< Software Portal DD Internal Halt Request Status */187volatile uint32_t qcsp_dd_ihrfr; /**< Software Portal DD Internal Halt Request Force */188volatile uint32_t qcsp_dd_hasr; /**< Software Portal DD Halt Acknowledge Status */189volatile uint8_t res3[4]; /**< reserved */190volatile uint32_t dcp_dd_ihrsr; /**< DCP DD Internal Halt Request Status */191volatile uint32_t dcp_dd_ihrfr; /**< DCP DD Internal Halt Request Force */192volatile uint32_t dcp_dd_hasr; /**< DCP DD Halt Acknowledge Status */193volatile uint8_t res4[212]; /**< reserved */194195/* Direct Connect Portal (DCP) Configuration Registers */196_Packed struct {197volatile uint32_t cfg; /**< DCP Configuration */198volatile uint32_t dd_cfg; /**< DCP Dynamic Debug Configuration */199volatile uint32_t dlm_cfg; /**< DCP Dequeue Latency Monitor Configuration */200volatile uint32_t dlm_avg; /**< DCP Dequeue Latency Monitor Average */201} _PackedType dcpConfRegs[QM_NUM_OF_DCP];202volatile uint8_t res5[176]; /**< reserved */203204/* Packed Frame Descriptor Record (PFDR) Manager Query Registers */205volatile uint32_t pfdr_fpc; /**< PFDR Free Pool Count */206volatile uint32_t pfdr_fp_head; /**< PFDR Free Pool Head Pointer */207volatile uint32_t pfdr_fp_tail; /**< PFDR Free Pool Tail Pointer */208volatile uint8_t res6[4]; /**< reserved */209volatile uint32_t pfdr_fp_lwit; /**< PFDR Free Pool Low Watermark Interrupt Threshold */210volatile uint32_t pfdr_cfg; /**< PFDR Configuration */211volatile uint8_t res7[232]; /**< reserved */212213/* Single Frame Descriptor Record (SFDR) Manager Registers */214volatile uint32_t sfdr_cfg; /**< SFDR Configuration */215volatile uint32_t sfdr_in_use; /**< SFDR In Use Register */216volatile uint8_t res8[248]; /**< reserved */217218/* Work Queue Semaphore and Context Manager Registers */219volatile uint32_t wq_cs_cfg[6]; /**< Work Queue Class Scheduler Configuration */220volatile uint8_t res9[24]; /**< reserved */221volatile uint32_t wq_def_enq_wqid; /**< Work Queue Default Enqueue WQID */222volatile uint8_t res10[12]; /**< reserved */223volatile uint32_t wq_sc_dd_cfg[5]; /**< WQ S/W Channel Dynamic Debug Config */224volatile uint8_t res11[44]; /**< reserved */225volatile uint32_t wq_pc_dd_cs_cfg[8]; /**< WQ Pool Channel Dynamic Debug Config */226volatile uint8_t res12[32]; /**< reserved */227volatile uint32_t wq_dc0_dd_cs_cfg[6]; /**< WQ DCP0 Chan. Dynamic Debug Config */228volatile uint8_t res13[40]; /**< reserved */229volatile uint32_t wq_dc1_dd_cs_cfg[6]; /**< WQ DCP1 Chan. Dynamic Debug Config */230volatile uint8_t res14[40]; /**< reserved */231volatile uint32_t wq_dc2_dd_cs_cfg; /**< WQ DCP2 Chan. Dynamic Debug Config */232volatile uint8_t res15[60]; /**< reserved */233volatile uint32_t wq_dc3_dd_cs_cfg; /**< WQ DCP3 Chan. Dynamic Debug Config */234volatile uint8_t res16[124]; /**< reserved */235236/* Congestion Manager (CM) Registers */237volatile uint32_t cm_cfg; /**< CM Configuration Register */238volatile uint8_t res17[508]; /**< reserved */239240/* QMan Error Capture Registers */241volatile uint32_t ecsr; /**< QMan Error Capture Status Register */242volatile uint32_t ecir; /**< QMan Error Capture Information Register */243volatile uint32_t eadr; /**< QMan Error Capture Address Register */244volatile uint8_t res18[4]; /**< reserved */245volatile uint32_t edata[16]; /**< QMan ECC Error Data Register */246volatile uint8_t res19[32]; /**< reserved */247volatile uint32_t sbet; /**< QMan Single Bit ECC Error Threshold Register */248volatile uint8_t res20[12]; /**< reserved */249volatile uint32_t sbec[7]; /**< QMan Single Bit ECC Error Count Register */250volatile uint8_t res21[100]; /**< reserved */251252/* QMan Initialization and Debug Control Registers */253volatile uint32_t mcr; /**< QMan Management Command/Result Register */254volatile uint32_t mcp0; /**< QMan Management Command Parameter 0 Register */255volatile uint32_t mcp1; /**< QMan Management Command Parameter 1 Register */256volatile uint8_t res22[20]; /**< reserved */257volatile uint32_t mr[16]; /**< QMan Management Return Register */258volatile uint8_t res23[148]; /**< reserved */259volatile uint32_t idle_stat; /**< QMan Idle Status Register */260261/* QMan ID/Revision Registers */262volatile uint32_t ip_rev_1; /**< QMan IP Block Revision 1 register */263volatile uint32_t ip_rev_2; /**< QMan IP Block Revision 2 register */264265/* QMan Initiator Interface Memory Window Configuration Registers */266volatile uint32_t fqd_bare; /**< FQD Extended Base Address Register */267volatile uint32_t fqd_bar; /**< Frame Queue Descriptor (FQD) Base Address Register */268volatile uint8_t res24[8]; /**< reserved */269volatile uint32_t fqd_ar; /**< FQD Attributes Register */270volatile uint8_t res25[12]; /**< reserved */271volatile uint32_t pfdr_bare; /**< PFDR Extended Base Address Register */272volatile uint32_t pfdr_bar; /**< Packed Frame Descriptor Record (PFDR) Base Addr */273volatile uint8_t res26[8]; /**< reserved */274volatile uint32_t pfdr_ar; /**< PFDR Attributes Register */275volatile uint8_t res27[76]; /**< reserved */276volatile uint32_t qcsp_bare; /**< QCSP Extended Base Address */277volatile uint32_t qcsp_bar; /**< QMan Software Portal Base Address */278volatile uint8_t res28[120]; /**< reserved */279volatile uint32_t ci_sched_cfg; /**< Initiator Scheduling Configuration */280volatile uint32_t srcidr; /**< QMan Source ID Register */281volatile uint32_t liodnr; /**< QMan Logical I/O Device Number Register */282volatile uint8_t res29[4]; /**< reserved */283volatile uint32_t ci_rlm_cfg; /**< Initiator Read Latency Monitor Configuration */284volatile uint32_t ci_rlm_avg; /**< Initiator Read Latency Monitor Average */285volatile uint8_t res30[232]; /**< reserved */286287/* QMan Interrupt and Error Registers */288volatile uint32_t err_isr; /**< QMan Error Interrupt Status Register */289volatile uint32_t err_ier; /**< QMan Error Interrupt Enable Register */290volatile uint32_t err_isdr; /**< QMan Error Interrupt Status Disable Register */291volatile uint32_t err_iir; /**< QMan Error Interrupt Inhibit Register */292volatile uint8_t res31[4]; /**< reserved */293volatile uint32_t err_her; /**< QMan Error Halt Enable Register */294295} _PackedType t_QmRegs;296297#define MEM_MAP_END298#if defined(__MWERKS__) && !defined(__GNUC__)299#pragma pack(pop)300#endif /* defined(__MWERKS__) && ... */301302303/**************************************************************************//**304@Description General defines305*//***************************************************************************/306307#define MODULE_NAME_SIZE 30308309#define PORTALS_OFFSET_CE(portal) (0x4000 * portal)310#define PORTALS_OFFSET_CI(portal) (0x1000 * portal)311312#define PFDR_ENTRY_SIZE 64 /* 64 bytes */313#define FQD_ENTRY_SIZE 64 /* 64 bytes */314315/* Compilation constants */316#define DQRR_MAXFILL 15317#define EQCR_THRESH 1 /* reread h/w CI when running out of space */318319/**************************************************************************//**320@Description Register defines321*//***************************************************************************/322323/* Assists for QMAN_MCR */324#define MCR_INIT_PFDR 0x01000000325#define MCR_get_rslt(v) (uint8_t)((v) >> 24)326#define MCR_rslt_idle(r) (!rslt || (rslt >= 0xf0))327#define MCR_rslt_ok(r) (rslt == 0xf0)328#define MCR_rslt_eaccess(r) (rslt == 0xf8)329#define MCR_rslt_inval(r) (rslt == 0xff)330331/* masks */332#define REV1_MAJOR_MASK 0x0000FF00333#define REV1_MINOR_MASK 0x000000FF334335#define REV2_INTEG_MASK 0x00FF0000336#define REV2_ERR_MASK 0x0000FF00337#define REV2_CFG_MASK 0x000000FF338339#define AR_ENABLE 0x80000000340#define AR_PRIORITY 0x40000000341#define AR_STASH 0x20000000342#define AR_SIZE_MASK 0x0000003f343344#define ECIR_PORTAL_TYPE 0x20000000345#define ECIR_PORTAL_MASK 0x1f000000346#define ECIR_FQID_MASK 0x00ffffff347348#define CI_SCHED_CFG_EN 0x80000000349/* shifts */350#define REV1_MAJOR_SHIFT 8351#define REV1_MINOR_SHIFT 0352353#define REV2_INTEG_SHIFT 16354#define REV2_ERR_SHIFT 8355#define REV2_CFG_SHIFT 0356357#define AR_SIZE_SHIFT 0358359#define ECIR_PORTAL_SHIFT 24360#define ECIR_FQID_SHIFT 0361362#define CI_SCHED_CFG_SRCCIV_SHIFT 24363#define CI_SCHED_CFG_SRQ_W_SHIFT 8364#define CI_SCHED_CFG_RW_W_SHIFT 4365#define CI_SCHED_CFG_BMAN_W_SHIFT 0366367368/********* CGR ******************************/369#define QM_CGR_TARG_FIRST_SWPORTAL 0x80000000370#define QM_CGR_TARG_FIRST_DCPORTAL 0x00200000371#define QM_CGR_TARGET_SWP(portlaId) (QM_CGR_TARG_FIRST_SWPORTAL >> portlaId)372#define QM_CGR_TARGET_DCP(portlaId) (QM_CGR_TARG_FIRST_DCPORTAL >> portlaId)373374375#define QM_DCP_CFG_ED 0x00000100376/*377#define CGR_VALID 0x80378#define CGR_VERB_INIT 0x50379#define CGR_VERB_MODIFY 0x51380#define CGR_WRITE_ALL 0x07FF381#define CGR_WRITE_ENABLE_CSCN 0x0010382#define CGR_WRITE_ENABLE_GREEN_MODIFY 0x0380383#define CGR_WRITE_ENABLE_YELLOW_MODIFY 0x0240384#define CGR_WRITE_ENABLE_RED_MODIFY 0x0120385386387#define CGR_MODE_BYTE 0x00388#define CGR_MODE_FRAME 0x01389#define GCR_ENABLE_WRED 0x01390#define GCR_ENABLE_TD 0x01391#define GCR_ENABLE_CSCN 0x01392*/393394395/* Lock/unlock frame queues, subject to the "UNLOCKED" flag. This is about396* inter-processor locking only. */397#define FQLOCK(fq) \398do { \399if (fq->flags & QMAN_FQ_FLAG_LOCKED) \400XX_LockSpinlock(&fq->fqlock); \401} while(0)402#define FQUNLOCK(fq) \403do { \404if (fq->flags & QMAN_FQ_FLAG_LOCKED) \405XX_UnlockSpinlock(&fq->fqlock); \406} while(0)407408/* Lock/unlock portals, subject to "UNLOCKED" flag. This is about disabling409* interrupts/preemption and, if FLAG_UNLOCKED isn't defined, inter-processor410* locking as well. */411#define NCSW_PLOCK(p) ((t_QmPortal*)(p))->irq_flags = XX_DisableAllIntr()412#define PUNLOCK(p) XX_RestoreAllIntr(((t_QmPortal*)(p))->irq_flags)413414415typedef void (t_QmLoopDequeueRing)(t_Handle h_QmPortal);416417/* Follows WQ_CS_CFG0-5 */418typedef enum {419e_QM_WQ_SW_PORTALS = 0,420e_QM_WQ_POOLS,421e_QM_WQ_DCP0,422e_QM_WQ_DCP1,423e_QM_WQ_DCP2,424e_QM_WQ_DCP3425} e_QmWqClass;426427typedef enum {428e_QM_PORTAL_NO_DEQUEUES = 0,429e_QM_PORTAL_PRIORITY_PRECEDENCE_INTRA_CLASS_SCHEDULING,430e_QM_PORTAL_ACTIVE_FQ_PRECEDENCE_INTRA_CLASS_SCHEDULING,431e_QM_PORTAL_ACTIVE_FQ_PRECEDENCE_OVERRIDE_INTRA_CLASS_SCHEDULING432} e_QmPortalDequeueCommandType;433434typedef enum e_QmInterModuleCounters {435e_QM_IM_COUNTERS_SFDR_IN_USE = 0,436e_QM_IM_COUNTERS_PFDR_IN_USE,437e_QM_IM_COUNTERS_PFDR_FREE_POOL438} e_QmInterModuleCounters;439440typedef struct t_QmInterModulePortalInitParams {441uint8_t portalId;442uint8_t stashDestQueue;443uint16_t liodn;444uint16_t dqrrLiodn;445uint16_t fdFqLiodn;446} t_QmInterModulePortalInitParams;447448typedef struct t_QmCg {449t_Handle h_Qm;450t_Handle h_QmPortal;451t_QmExceptionsCallback *f_Exception;452t_Handle h_App;453uint8_t id;454} t_QmCg;455456typedef struct {457uintptr_t swPortalsBaseAddress; /**< QM Software Portals Base Address (virtual) */458uint32_t partFqidBase;459uint32_t partNumOfFqids;460uint32_t totalNumOfFqids;461uint32_t rtFramesDepth;462uint32_t fqdMemPartitionId;463uint32_t pfdrMemPartitionId;464uint32_t pfdrThreshold;465uint32_t sfdrThreshold;466uint32_t pfdrBaseConstant;467uint16_t liodn;468t_QmDcPortalParams dcPortalsParams[DPAA_MAX_NUM_OF_DC_PORTALS];469} t_QmDriverParams;470471typedef struct {472uint8_t guestId;473t_Handle h_RsrvFqidMm;474t_Handle h_FqidMm;475t_Handle h_Session;476char moduleName[MODULE_NAME_SIZE];477t_Handle h_Portals[DPAA_MAX_NUM_OF_SW_PORTALS];478t_QmRegs *p_QmRegs;479uint32_t *p_FqdBase;480uint32_t *p_PfdrBase;481uint32_t exceptions;482t_QmExceptionsCallback *f_Exception;483t_Handle h_App;484uintptr_t errIrq; /**< error interrupt line; NO_IRQ if interrupts not used */485uint32_t numOfPfdr;486uint16_t partNumOfCgs;487uint16_t partCgsBase;488uint8_t cgsUsed[QM_MAX_NUM_OF_CGS];489t_Handle lock;490t_QmDriverParams *p_QmDriverParams;491} t_Qm;492493typedef struct {494uint32_t hwExtStructsMemAttr;495uint8_t dqrrSize;496bool pullMode;497bool dequeueDcaMode;498bool dequeueUpToThreeFrames;499e_QmPortalDequeueCommandType commandType;500uint8_t userToken;501bool specifiedWq;502bool dedicatedChannel;503bool dedicatedChannelHasPrecedenceOverPoolChannels;504uint8_t poolChannels[QM_MAX_NUM_OF_POOL_CHANNELS];505uint8_t poolChannelId;506uint8_t wqId;507uint16_t fdLiodnOffset;508uint8_t stashDestQueue;509uint8_t eqcr;510bool eqcrHighPri;511bool dqrr;512uint16_t dqrrLiodn;513bool dqrrHighPri;514bool fdFq;515uint16_t fdFqLiodn;516bool fdFqHighPri;517bool fdFqDrop;518} t_QmPortalDriverParams;519520/*typedef struct t_QmPortalCgs{521uint32_t cgsMask[QM_MAX_NUM_OF_CGS/32];522}t_QmPortalCgs;523*/524typedef struct t_QmPortal {525t_Handle h_Qm;526struct qm_portal *p_LowQmPortal;527uint32_t bits; /* PORTAL_BITS_*** - dynamic, strictly internal */528t_Handle h_App;529t_QmLoopDequeueRing *f_LoopDequeueRingCB;530bool pullMode;531/* To avoid overloading the term "flags", we use these 2; */532uint32_t options; /* QMAN_PORTAL_FLAG_*** - static, caller-provided */533uint32_t irq_flags;534/* The wrap-around eq_[prod|cons] counters are used to support535* QMAN_ENQUEUE_FLAG_WAIT_SYNC. */536uint32_t eqProd;537volatile int disable_count;538struct qman_cgrs cgrs[2]; /* 2-element array. cgrs[0] is mask, cgrs[1] is previous snapshot. */539/* If we receive a DQRR or MR ring entry for a "null" FQ, ie. for which540* FQD::contextB is NULL rather than pointing to a FQ object, we use541* these handlers. (This is not considered a fast-path mechanism.) */542t_Handle cgsHandles[QM_MAX_NUM_OF_CGS];543struct qman_fq_cb *p_NullCB;544t_QmReceivedFrameCallback *f_DfltFrame;545t_QmRejectedFrameCallback *f_RejectedFrame;546t_QmPortalDriverParams *p_QmPortalDriverParams;547} t_QmPortal;548549struct qman_fq {550struct qman_fq_cb cb;551t_Handle h_App;552t_Handle h_QmFqr;553t_Handle fqlock;554uint32_t fqid;555uint32_t fqidOffset;556uint32_t flags;557/* s/w-visible states. Ie. tentatively scheduled + truly scheduled +558* active + held-active + held-suspended are just "sched". Things like559* 'retired' will not be assumed until it is complete (ie.560* QMAN_FQ_STATE_CHANGING is set until then, to indicate it's completing561* and to gate attempts to retry the retire command). Note, park562* commands do not set QMAN_FQ_STATE_CHANGING because it's technically563* impossible in the case of enqueue DCAs (which refer to DQRR ring564* index rather than the FQ that ring entry corresponds to), so repeated565* park commands are allowed (if you're silly enough to try) but won't566* change FQ state, and the resulting park notifications move FQs from567* 'sched' to 'parked'. */568enum qman_fq_state state;569int cgr_groupid;570};571572typedef struct {573t_Handle h_Qm;574t_Handle h_QmPortal;575e_QmFQChannel channel;576uint8_t workQueue;577bool shadowMode;578uint32_t fqidBase;579uint32_t numOfFqids;580t_QmFqrDrainedCompletionCB *f_CompletionCB;581t_Handle h_App;582uint32_t numOfDrainedFqids;583bool *p_DrainedFqs;584struct qman_fq **p_Fqs;585} t_QmFqr;586587588/****************************************/589/* Inter-Module functions */590/****************************************/591uint32_t QmGetCounter(t_Handle h_Qm, e_QmInterModuleCounters counter);592t_Error QmGetRevision(t_Handle h_Qm, t_QmRevisionInfo *p_QmRevisionInfo);593t_Error QmGetSetPortalParams(t_Handle h_Qm, t_QmInterModulePortalInitParams *p_PortalParams);594t_Error QmFreeDcPortal(t_Handle h_Qm, e_DpaaDcPortal dcPortalId);595uint32_t QmFqidGet(t_Qm *p_Qm, uint32_t size, uint32_t alignment, bool force, uint32_t base);596t_Error QmFqidPut(t_Qm *p_Qm, uint32_t base);597t_Error QmGetCgId(t_Handle h_Qm, uint8_t *p_CgId);598t_Error QmFreeCgId(t_Handle h_Qm, uint8_t cgId);599600601static __inline__ void QmSetPortalHandle(t_Handle h_Qm, t_Handle h_Portal, e_DpaaSwPortal portalId)602{603ASSERT_COND(!((t_Qm*)h_Qm)->h_Portals[portalId] || !h_Portal);604((t_Qm*)h_Qm)->h_Portals[portalId] = h_Portal;605}606607static __inline__ t_Handle QmGetPortalHandle(t_Handle h_Qm)608{609t_Qm *p_Qm = (t_Qm*)h_Qm;610611ASSERT_COND(p_Qm);612return p_Qm->h_Portals[CORE_GetId()];613}614615static __inline__ uint32_t GenerateCgrThresh(uint64_t val, int roundup)616{617uint32_t e = 0; /* co-efficient, exponent */618uint32_t oddbit = 0;619while(val > 0xff) {620oddbit = (uint32_t)val & 1;621val >>= 1;622e++;623if(roundup && oddbit)624val++;625}626return (uint32_t)((val << 5) | e);627}628629static __inline__ t_Error SetException(t_Qm *p_Qm, e_QmExceptions exception, bool enable)630{631uint32_t bitMask = 0;632633ASSERT_COND(p_Qm);634635GET_EXCEPTION_FLAG(bitMask, exception);636if(bitMask)637{638if (enable)639p_Qm->exceptions |= bitMask;640else641p_Qm->exceptions &= ~bitMask;642}643else644RETURN_ERROR(MAJOR, E_INVALID_VALUE, ("Undefined exception"));645646return E_OK;647}648649650#endif /* __QM_H */651652653