Path: blob/main/sys/contrib/ncsw/Peripherals/QM/fsl_qman.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 fsl_qman.h3738@Description QM header39*//***************************************************************************/40#ifndef __FSL_QMAN_H41#define __FSL_QMAN_H4243#include "std_ext.h"44#include "string_ext.h"45#include "qm_ext.h"464748/*************************************************/49/* QMan s/w corenet portal, low-level i/face */50/*************************************************/51typedef enum {52e_QmPortalPCI = 0, /* PI index, cache-inhibited */53e_QmPortalPCE, /* PI index, cache-enabled */54e_QmPortalPVB /* valid-bit */55} e_QmPortalProduceMode;5657typedef enum {58e_QmPortalEqcrCCI = 0, /* CI index, cache-inhibited */59e_QmPortalEqcrCCE /* CI index, cache-enabled */60} e_QmPortalEqcrConsumeMode;6162typedef enum {63e_QmPortalDqrrCCI = 0, /* CI index, cache-inhibited */64e_QmPortalDqrrCCE, /* CI index, cache-enabled */65e_QmPortalDqrrDCA /* Discrete Consumption Acknowledgment */66} e_QmPortalDqrrConsumeMode;6768typedef enum {69e_QmPortalMrCCI = 0, /* CI index, cache-inhibited */70e_QmPortalMrCCE /* CI index, cache-enabled */71} e_QmPortalMrConsumeMode;7273typedef enum {74e_QmPortalDequeuePushMode = 0, /* SDQCR + VDQCR */75e_QmPortalDequeuePullMode /* PDQCR */76} e_QmPortalDequeueMode;7778/* Portal constants */79#define QM_EQCR_SIZE 880#define QM_DQRR_SIZE 1681#define QM_MR_SIZE 88283/* Hardware constants */8485enum qm_isr_reg {86qm_isr_status = 0,87qm_isr_enable = 1,88qm_isr_disable = 2,89qm_isr_inhibit = 390};91enum qm_dc_portal {92qm_dc_portal_fman0 = 0,93qm_dc_portal_fman1 = 1,94qm_dc_portal_caam = 2,95qm_dc_portal_pme = 396};9798/* Represents s/w corenet portal mapped data structures */99struct qm_eqcr_entry; /* EQCR (EnQueue Command Ring) entries */100struct qm_dqrr_entry; /* DQRR (DeQueue Response Ring) entries */101struct qm_mr_entry; /* MR (Message Ring) entries */102struct qm_mc_command; /* MC (Management Command) command */103struct qm_mc_result; /* MC result */104105/* This type represents a s/w corenet portal space, and is used for creating the106* portal objects within it (EQCR, DQRR, etc) */107struct qm_portal;108109/* When iterating the available portals, this is the exposed config structure */110struct qm_portal_config {111/* If the caller enables DQRR stashing (and thus wishes to operate the112* portal from only one cpu), this is the logical CPU that the portal113* will stash to. Whether stashing is enabled or not, this setting is114* also used for any "core-affine" portals, ie. default portals115* associated to the corresponding cpu. -1 implies that there is no core116* affinity configured. */117int cpu;118/* portal interrupt line */119uintptr_t irq;120/* The portal's dedicated channel id, use this value for initializing121* frame queues to target this portal when scheduled. */122e_QmFQChannel channel;123/* A mask of which pool channels this portal has dequeue access to124* (using QM_SDQCR_CHANNELS_POOL(n) for the bitmask) */125uint32_t pools;126/* which portal sub-interfaces are already bound (ie. "in use") */127uint8_t bound;128};129/* qm_portal_config::bound uses these bit masks */130#define QM_BIND_EQCR 0x01131#define QM_BIND_DQRR 0x02132#define QM_BIND_MR 0x04133#define QM_BIND_MC 0x08134#define QM_BIND_ISR 0x10135136/* This struct represents a pool channel */137struct qm_pool_channel {138/* The QM_SDQCR_CHANNELS_POOL(n) bit that corresponds to this channel */139uint32_t pool;140/* The channel id, used for initialising frame queues to target this141* channel. */142e_QmFQChannel channel;143/* Bitmask of portal (logical-, not cell-)indices that have dequeue144* access to this channel;145* 0x001 -> qm_portal_get(0)146* 0x002 -> qm_portal_get(1)147* 0x004 -> qm_portal_get(2)148* ...149* 0x200 -> qm_portal_get(9)150*/151uint32_t portals;152};153154/* ------------------------------ */155/* --- Portal enumeration API --- */156157/* Obtain the number of portals available */158uint8_t qm_portal_num(void);159160/* Obtain a portal handle and configuration information about it */161struct qm_portal *qm_portal_get(uint8_t idx);162163164/* ------------------------------------ */165/* --- Pool channel enumeration API --- */166167/* Obtain a mask of the available pool channels, expressed using168* QM_SDQCR_CHANNELS_POOL(n). */169uint32_t qm_pools(void);170171/* Retrieve a pool channel configuration, given a QM_SDQCR_CHANNEL_POOL(n)172* bit-mask (the least significant bit of 'mask' is used if more than one bit is173* set). */174const struct qm_pool_channel *qm_pool_channel(uint32_t mask);175176/* Flags to qm_fq_free_flags() */177#define QM_FQ_FREE_WAIT 0x00000001 /* wait if RCR is full */178#define QM_FQ_FREE_WAIT_INT 0x00000002 /* if wait, interruptible? */179#define QM_FQ_FREE_WAIT_SYNC 0x00000004 /* if wait, until consumed? */180181182#define QM_SDQCR_SOURCE_CHANNELS 0x0183#define QM_SDQCR_SOURCE_SPECIFICWQ 0x40000000184#define QM_SDQCR_COUNT_EXACT1 0x0185#define QM_SDQCR_COUNT_UPTO3 0x20000000186#define QM_SDQCR_DEDICATED_PRECEDENCE 0x10000000187#define QM_SDQCR_TYPE_MASK 0x03000000188#define QM_SDQCR_TYPE_NULL 0x0189#define QM_SDQCR_TYPE_PRIO_QOS 0x01000000190#define QM_SDQCR_TYPE_ACTIVE_QOS 0x02000000191#define QM_SDQCR_TYPE_ACTIVE 0x03000000192#define QM_SDQCR_TYPE_SET(v) (((v) & 0x03) << (31-7))193#define QM_SDQCR_TOKEN_MASK 0x00ff0000194#define QM_SDQCR_TOKEN_SET(v) (((v) & 0xff) << 16)195#define QM_SDQCR_TOKEN_GET(v) (((v) >> 16) & 0xff)196#define QM_SDQCR_CHANNELS_DEDICATED 0x00008000197#define QM_SDQCR_CHANNELS_POOL_MASK 0x00007fff198#define QM_SDQCR_CHANNELS_POOL(n) (0x00008000 >> (n))199#define QM_SDQCR_SPECIFICWQ_MASK 0x000000f7200#define QM_SDQCR_SPECIFICWQ_DEDICATED 0x00000000201#define QM_SDQCR_SPECIFICWQ_POOL(n) ((n) << 4)202#define QM_SDQCR_SPECIFICWQ_WQ(n) (n)203204/* For qm_dqrr_vdqcr_set(); Choose one PRECEDENCE. EXACT is optional. Use205* NUMFRAMES(n) (6-bit) or NUMFRAMES_TILLEMPTY to fill in the frame-count. Use206* FQID(n) to fill in the frame queue ID. */207#define QM_VDQCR_PRECEDENCE_VDQCR 0x0208#define QM_VDQCR_PRECEDENCE_SDQCR 0x80000000209#define QM_VDQCR_EXACT 0x40000000210#define QM_VDQCR_NUMFRAMES_MASK 0x3f000000211#define QM_VDQCR_NUMFRAMES_SET(n) (((n) & 0x3f) << 24)212#define QM_VDQCR_NUMFRAMES_GET(n) (((n) >> 24) & 0x3f)213#define QM_VDQCR_NUMFRAMES_TILLEMPTY QM_VDQCR_NUMFRAMES_SET(0)214#define QM_VDQCR_FQID_MASK 0x00ffffff215#define QM_VDQCR_FQID(n) ((n) & QM_VDQCR_FQID_MASK)216217/* For qm_dqrr_pdqcr_set(); Choose one MODE. Choose one COUNT.218* If MODE==SCHEDULED219* Choose SCHEDULED_CHANNELS or SCHEDULED_SPECIFICWQ. Choose one dequeue TYPE.220* If CHANNELS,221* Choose CHANNELS_DEDICATED and/or CHANNELS_POOL() channels.222* You can choose DEDICATED_PRECEDENCE if the portal channel should have223* priority.224* If SPECIFICWQ,225* Either select the work-queue ID with SPECIFICWQ_WQ(), or select the226* channel (SPECIFICWQ_DEDICATED or SPECIFICWQ_POOL()) and specify the227* work-queue priority (0-7) with SPECIFICWQ_WQ() - either way, you get the228* same value.229* If MODE==UNSCHEDULED230* Choose FQID().231*/232#define QM_PDQCR_MODE_SCHEDULED 0x0233#define QM_PDQCR_MODE_UNSCHEDULED 0x80000000234#define QM_PDQCR_SCHEDULED_CHANNELS 0x0235#define QM_PDQCR_SCHEDULED_SPECIFICWQ 0x40000000236#define QM_PDQCR_COUNT_EXACT1 0x0237#define QM_PDQCR_COUNT_UPTO3 0x20000000238#define QM_PDQCR_DEDICATED_PRECEDENCE 0x10000000239#define QM_PDQCR_TYPE_MASK 0x03000000240#define QM_PDQCR_TYPE_NULL 0x0241#define QM_PDQCR_TYPE_PRIO_QOS 0x01000000242#define QM_PDQCR_TYPE_ACTIVE_QOS 0x02000000243#define QM_PDQCR_TYPE_ACTIVE 0x03000000244#define QM_PDQCR_CHANNELS_DEDICATED 0x00008000245#define QM_PDQCR_CHANNELS_POOL(n) (0x00008000 >> (n))246#define QM_PDQCR_SPECIFICWQ_MASK 0x000000f7247#define QM_PDQCR_SPECIFICWQ_DEDICATED 0x00000000248#define QM_PDQCR_SPECIFICWQ_POOL(n) ((n) << 4)249#define QM_PDQCR_SPECIFICWQ_WQ(n) (n)250#define QM_PDQCR_FQID(n) ((n) & 0xffffff)251252/* ------------------------------------- */253/* --- Portal interrupt register API --- */254255/* Quick explanation of the Qman interrupt model. Each bit has a source256* condition, that source is asserted iff the condition is true. Eg. Each257* DQAVAIL source bit tracks whether the corresponding channel's work queues258* contain any truly scheduled frame queues. That source exists "asserted" if259* and while there are truly-scheduled FQs available, it is deasserted as/when260* there are no longer any truly-scheduled FQs available. The same is true for261* the various other interrupt source conditions (QM_PIRQ_***). The following262* steps indicate what those source bits affect;263* 1. if the corresponding bit is set in the disable register, the source264* bit is masked off, we never see any effect from it.265* 2. otherwise, the corresponding bit is set in the status register. Once266* asserted in the status register, it must be write-1-to-clear'd - the267* status register bit will stay set even if the source condition268* deasserts.269* 3. if a bit is set in the status register but *not* set in the enable270* register, it will not cause the interrupt to assert. Other bits may271* still cause the interrupt to assert of course, and a read of the272* status register can still reveal un-enabled bits - this is why the273* enable and disable registers aren't strictly speaking "opposites".274* "Un-enabled" means it won't, on its own, trigger an interrupt.275* "Disabled" means it won't even show up in the status register.276* 4. if a bit is set in the status register *and* the enable register, the277* interrupt line will assert if and only if the inhibit register is278* zero. The inhibit register is the only interrupt-related register that279* does not share the bit definitions - it is a boolean on/off register.280*/281282/* Create/destroy */283284/* Used by all portal interrupt registers except 'inhibit' */285#define QM_PIRQ_CSCI 0x00100000 /* Congestion State Change */286#define QM_PIRQ_EQCI 0x00080000 /* Enqueue Command Committed */287#define QM_PIRQ_EQRI 0x00040000 /* EQCR Ring (below threshold) */288#define QM_PIRQ_DQRI 0x00020000 /* DQRR Ring (non-empty) */289#define QM_PIRQ_MRI 0x00010000 /* MR Ring (non-empty) */290/* The DQAVAIL interrupt fields break down into these bits; */291#define QM_PIRQ_DQAVAIL 0x0000ffff /* Channels with frame availability */292#define QM_DQAVAIL_PORTAL 0x8000 /* Portal channel */293#define QM_DQAVAIL_POOL(n) (0x8000 >> (n)) /* Pool channel, n==[1..15] */294295/* These are qm_<reg>_<verb>(). So for example, qm_disable_write() means "write296* the disable register" rather than "disable the ability to write". */297#define qm_isr_status_read(qm) __qm_isr_read(qm, qm_isr_status)298#define qm_isr_status_clear(qm, m) __qm_isr_write(qm, qm_isr_status, m)299#define qm_isr_enable_read(qm) __qm_isr_read(qm, qm_isr_enable)300#define qm_isr_enable_write(qm, v) __qm_isr_write(qm, qm_isr_enable, v)301#define qm_isr_disable_read(qm) __qm_isr_read(qm, qm_isr_disable)302#define qm_isr_disable_write(qm, v) __qm_isr_write(qm, qm_isr_disable, v)303#define qm_isr_inhibit(qm) __qm_isr_write(qm, qm_isr_inhibit, 1)304#define qm_isr_uninhibit(qm) __qm_isr_write(qm, qm_isr_inhibit, 0)305306/* ------------------------------------------------------- */307/* --- Qman data structures (and associated constants) --- */308309/* See David Lapp's "Frame formats" document, "dpateam", Jan 07, 2008 */310#define QM_FD_FORMAT_SG 0x4311#define QM_FD_FORMAT_LONG 0x2312#define QM_FD_FORMAT_COMPOUND 0x1313enum qm_fd_format {314/* 'contig' implies a contiguous buffer, whereas 'sg' implies a315* scatter-gather table. 'big' implies a 29-bit length with no offset316* field, otherwise length is 20-bit and offset is 9-bit. 'compound'317* implies a s/g-like table, where each entry itself represents a frame318* (contiguous or scatter-gather) and the 29-bit "length" is319* interpreted purely for congestion calculations, ie. a "congestion320* weight". */321qm_fd_contig = 0,322qm_fd_contig_big = QM_FD_FORMAT_LONG,323qm_fd_sg = QM_FD_FORMAT_SG,324qm_fd_sg_big = QM_FD_FORMAT_SG | QM_FD_FORMAT_LONG,325qm_fd_compound = QM_FD_FORMAT_COMPOUND326};327328#if defined(__MWERKS__) && !defined(__GNUC__)329#pragma pack(push,1)330#endif /* defined(__MWERKS__) && ... */331#define MEM_MAP_START332333_Packed struct qm_fqd_stashing {334/* See QM_STASHING_EXCL_<...> */335volatile uint8_t exclusive;336volatile uint8_t reserved1:2;337/* Numbers of cachelines */338volatile uint8_t annotation_cl:2;339volatile uint8_t data_cl:2;340volatile uint8_t context_cl:2;341} _PackedType;342343typedef _Packed union {344/* Treat it as 64-bit opaque */345_Packed struct {346volatile uint32_t hi;347volatile uint32_t lo;348} _PackedType;349/* Treat it as s/w portal stashing config */350/* See 1.5.6.7.1: "FQD Context_A field used for [...] */351_Packed struct {352struct qm_fqd_stashing stashing;353volatile uint8_t reserved1;354/* 40-bit address of FQ context to355* stash, must be cacheline-aligned */356volatile uint8_t context_hi;357volatile uint32_t context_lo;358} _PackedType;359} _PackedType u_QmFqdContextA;360361/* See 1.5.1.1: "Frame Descriptor (FD)" */362_Packed struct qm_fd {363volatile uint8_t dd:2; /* dynamic debug */364volatile uint8_t liodn_offset:6; /* aka. "Partition ID" in rev1.0 */365volatile uint8_t bpid; /* Buffer Pool ID */366volatile uint8_t eliodn_offset:4;367volatile uint8_t reserved:4;368volatile uint8_t addr_hi; /* high 8-bits of 40-bit address */369volatile uint32_t addr_lo; /* low 32-bits of 40-bit address */370/* The 'format' field indicates the interpretation of the remaining 29371* bits of the 32-bit word. For packing reasons, it is duplicated in the372* other union elements. */373_Packed union {374/* If 'format' is _contig or _sg, 20b length and 9b offset */375_Packed struct {376volatile enum qm_fd_format format:3;377volatile uint16_t offset:9;378volatile uint32_t length20:20;379} _PackedType;380/* If 'format' is _contig_big or _sg_big, 29b length */381_Packed struct {382volatile enum qm_fd_format _format1:3;383volatile uint32_t length29:29;384} _PackedType;385/* If 'format' is _compound, 29b "congestion weight" */386_Packed struct {387volatile enum qm_fd_format _format2:3;388volatile uint32_t cong_weight:29;389} _PackedType;390/* For easier/faster copying of this part of the fd (eg. from a391* DQRR entry to an EQCR entry) copy 'opaque' */392volatile uint32_t opaque;393} _PackedType;394_Packed union {395volatile uint32_t cmd;396volatile uint32_t status;397}_PackedType;398} _PackedType;399400#define QM_FD_DD_NULL 0x00401#define QM_FD_PID_MASK 0x3f402403/* See 1.5.8.1: "Enqueue Command" */404_Packed struct qm_eqcr_entry {405volatile uint8_t __dont_write_directly__verb;406volatile uint8_t dca;407volatile uint16_t seqnum;408volatile uint32_t orp; /* 24-bit */409volatile uint32_t fqid; /* 24-bit */410volatile uint32_t tag;411volatile struct qm_fd fd;412volatile uint8_t reserved3[32];413} _PackedType;414415#define QM_EQCR_VERB_VBIT 0x80416#define QM_EQCR_VERB_CMD_MASK 0x61 /* but only one value; */417#define QM_EQCR_VERB_CMD_ENQUEUE 0x01418#define QM_EQCR_VERB_COLOUR_MASK 0x18 /* 4 possible values; */419#define QM_EQCR_VERB_COLOUR_GREEN 0x00420#define QM_EQCR_VERB_COLOUR_YELLOW 0x08421#define QM_EQCR_VERB_COLOUR_RED 0x10422#define QM_EQCR_VERB_COLOUR_OVERRIDE 0x18423#define QM_EQCR_VERB_INTERRUPT 0x04 /* on command consumption */424#define QM_EQCR_VERB_ORP 0x02 /* enable order restoration */425#define QM_EQCR_DCA_ENABLE 0x80426#define QM_EQCR_DCA_PARK 0x40427#define QM_EQCR_DCA_IDXMASK 0x0f /* "DQRR::idx" goes here */428#define QM_EQCR_SEQNUM_NESN 0x8000 /* Advance NESN */429#define QM_EQCR_SEQNUM_NLIS 0x4000 /* More fragments to come */430#define QM_EQCR_SEQNUM_SEQMASK 0x3fff /* sequence number goes here */431#define QM_EQCR_FQID_NULL 0 /* eg. for an ORP seqnum hole */432433/* See 1.5.8.2: "Frame Dequeue Response" */434_Packed struct qm_dqrr_entry {435volatile uint8_t verb;436volatile uint8_t stat;437volatile uint16_t seqnum; /* 15-bit */438volatile uint8_t tok;439volatile uint8_t reserved2[3];440volatile uint32_t fqid; /* 24-bit */441volatile uint32_t contextB;442volatile struct qm_fd fd;443volatile uint8_t reserved4[32];444} _PackedType;445446#define QM_DQRR_VERB_VBIT 0x80447#define QM_DQRR_VERB_MASK 0x7f /* where the verb contains; */448#define QM_DQRR_VERB_FRAME_DEQUEUE 0x60 /* "this format" */449#define QM_DQRR_STAT_FQ_EMPTY 0x80 /* FQ empty */450#define QM_DQRR_STAT_FQ_HELDACTIVE 0x40 /* FQ held active */451#define QM_DQRR_STAT_FQ_FORCEELIGIBLE 0x20 /* FQ was force-eligible'd */452#define QM_DQRR_STAT_FD_VALID 0x10 /* has a non-NULL FD */453#define QM_DQRR_STAT_UNSCHEDULED 0x02 /* Unscheduled dequeue */454#define QM_DQRR_STAT_DQCR_EXPIRED 0x01 /* VDQCR or PDQCR expired*/455456#define VDQCR_DONE (QM_DQRR_STAT_UNSCHEDULED | QM_DQRR_STAT_DQCR_EXPIRED)457458459/* See 1.5.8.3: "ERN Message Response" */460/* See 1.5.8.4: "FQ State Change Notification" */461_Packed struct qm_mr_entry {462volatile uint8_t verb;463_Packed union {464_Packed struct {465volatile uint8_t dca;466volatile uint16_t seqnum;467volatile uint8_t rc; /* Rejection Code */468volatile uint32_t orp:24;469volatile uint32_t fqid; /* 24-bit */470volatile uint32_t tag;471volatile struct qm_fd fd;472} _PackedType ern;473_Packed struct {474volatile uint8_t colour:2; /* See QM_MR_DCERN_COLOUR_* */475volatile uint8_t reserved1:3;476volatile enum qm_dc_portal portal:3;477volatile uint16_t reserved2;478volatile uint8_t rc; /* Rejection Code */479volatile uint32_t reserved3:24;480volatile uint32_t fqid; /* 24-bit */481volatile uint32_t tag;482volatile struct qm_fd fd;483} _PackedType dcern;484_Packed struct {485volatile uint8_t fqs; /* Frame Queue Status */486volatile uint8_t reserved1[6];487volatile uint32_t fqid; /* 24-bit */488volatile uint32_t contextB;489volatile uint8_t reserved2[16];490} _PackedType fq; /* FQRN/FQRNI/FQRL/FQPN */491} _PackedType;492volatile uint8_t reserved2[32];493} _PackedType;494495#define QM_MR_VERB_VBIT 0x80496/* The "ern" VERB bits match QM_EQCR_VERB_*** so aren't reproduced here. ERNs497* originating from direct-connect portals ("dcern") use 0x20 as a verb which498* would be invalid as a s/w enqueue verb. A s/w ERN can be distinguished from499* the other MR types by noting if the 0x20 bit is unset. */500#define QM_MR_VERB_TYPE_MASK 0x23501#define QM_MR_VERB_DC_ERN 0x20502#define QM_MR_VERB_FQRN 0x21503#define QM_MR_VERB_FQRNI 0x22504#define QM_MR_VERB_FQRL 0x23505#define QM_MR_VERB_FQPN 0x24506#define QM_MR_RC_MASK 0xf0 /* contains one of; */507#define QM_MR_RC_CGR_TAILDROP 0x00508#define QM_MR_RC_WRED 0x10509#define QM_MR_RC_ERROR 0x20510#define QM_MR_RC_ORPWINDOW_EARLY 0x30511#define QM_MR_RC_ORPWINDOW_LATE 0x40512#define QM_MR_RC_FQ_TAILDROP 0x50513#define QM_MR_RC_ORP_RETIRED 0x60514#define QM_MR_RC_ORP_DISABLE 0x70515#define QM_MR_FQS_ORLPRESENT 0x02 /* ORL fragments to come */516#define QM_MR_FQS_NOTEMPTY 0x01 /* FQ has enqueued frames */517#define QM_MR_DCERN_COLOUR_GREEN 0x00518#define QM_MR_DCERN_COLOUR_YELLOW 0x01519#define QM_MR_DCERN_COLOUR_RED 0x02520#define QM_MR_DCERN_COLOUR_OVERRIDE 0x03521522/* This identical structure of FQD fields is present in the "Init FQ" command523* and the "Query FQ" result. It's suctioned out here into its own struct. It's524* also used as the qman_query_fq() result structure in the high-level API. */525526/* TODO What about OAC for intra-class? */527#define QM_FQD_TD_THRESH_OAC_EN 0x4000528529_Packed struct qm_fqd {530_Packed union {531volatile uint8_t orpc;532_Packed struct {533volatile uint8_t reserved1:2;534volatile uint8_t orprws:3;535volatile uint8_t oa:1;536volatile uint8_t olws:2;537} _PackedType;538} _PackedType;539volatile uint8_t cgid;540volatile uint16_t fq_ctrl; /* See QM_FQCTRL_<...> */541_Packed union {542volatile uint16_t dest_wq;543_Packed struct {544volatile uint16_t channel:13; /* enum qm_channel */545volatile uint16_t wq:3;546} _PackedType dest;547} _PackedType;548volatile uint16_t reserved2:1;549volatile uint16_t ics_cred:15;550_Packed union {551volatile uint16_t td_thresh;552_Packed struct {553volatile uint16_t reserved1:3;554volatile uint16_t mant:8;555volatile uint16_t exp:5;556} _PackedType td;557} _PackedType;558volatile uint32_t context_b;559volatile u_QmFqdContextA context_a;560} _PackedType;561562/* See 1.5.2.2: "Frame Queue Descriptor (FQD)" */563/* Frame Queue Descriptor (FQD) field 'fq_ctrl' uses these constants */564#define QM_FQCTRL_MASK 0x07ff /* 'fq_ctrl' flags; */565#define QM_FQCTRL_CGE 0x0400 /* Congestion Group Enable */566#define QM_FQCTRL_TDE 0x0200 /* Tail-Drop Enable */567#define QM_FQCTRL_ORP 0x0100 /* ORP Enable */568#define QM_FQCTRL_CTXASTASHING 0x0080 /* Context-A stashing */569#define QM_FQCTRL_CPCSTASH 0x0040 /* CPC Stash Enable */570#define QM_FQCTRL_FORCESFDR 0x0008 /* High-priority SFDRs */571#define QM_FQCTRL_AVOIDBLOCK 0x0004 /* Don't block active */572#define QM_FQCTRL_HOLDACTIVE 0x0002 /* Hold active in portal */573#define QM_FQCTRL_LOCKINCACHE 0x0001 /* Aggressively cache FQD */574575/* See 1.5.6.7.1: "FQD Context_A field used for [...] */576/* Frame Queue Descriptor (FQD) field 'CONTEXT_A' uses these constants */577#define QM_STASHING_EXCL_ANNOTATION 0x04578#define QM_STASHING_EXCL_DATA 0x02579#define QM_STASHING_EXCL_CONTEXT 0x01580581/* See 1.5.8.4: "FQ State Change Notification" */582/* This struct represents the 32-bit "WR_PARM_[GYR]" parameters in CGR fields583* and associated commands/responses. The WRED parameters are calculated from584* these fields as follows;585* MaxTH = MA * (2 ^ Mn)586* Slope = SA / (2 ^ Sn)587* MaxP = 4 * (Pn + 1)588*/589_Packed struct qm_cgr_wr_parm {590_Packed union {591volatile uint32_t word;592_Packed struct {593volatile uint32_t MA:8;594volatile uint32_t Mn:5;595volatile uint32_t SA:7; /* must be between 64-127 */596volatile uint32_t Sn:6;597volatile uint32_t Pn:6;598} _PackedType;599} _PackedType;600} _PackedType;601602/* This struct represents the 13-bit "CS_THRES" CGR field. In the corresponding603* management commands, this is padded to a 16-bit structure field, so that's604* how we represent it here. The congestion state threshold is calculated from605* these fields as follows;606* CS threshold = TA * (2 ^ Tn)607*/608_Packed struct qm_cgr_cs_thres {609volatile uint16_t reserved:3;610volatile uint16_t TA:8;611volatile uint16_t Tn:5;612} _PackedType;613614/* This identical structure of CGR fields is present in the "Init/Modify CGR"615* commands and the "Query CGR" result. It's suctioned out here into its own616* struct. */617_Packed struct __qm_mc_cgr {618volatile struct qm_cgr_wr_parm wr_parm_g;619volatile struct qm_cgr_wr_parm wr_parm_y;620volatile struct qm_cgr_wr_parm wr_parm_r;621volatile uint8_t wr_en_g; /* boolean, use QM_CGR_EN */622volatile uint8_t wr_en_y; /* boolean, use QM_CGR_EN */623volatile uint8_t wr_en_r; /* boolean, use QM_CGR_EN */624volatile uint8_t cscn_en; /* boolean, use QM_CGR_EN */625volatile uint32_t cscn_targ; /* use QM_CGR_TARG_* */626volatile uint8_t cstd_en; /* boolean, use QM_CGR_EN */627volatile uint8_t cs; /* boolean, only used in query response */628volatile struct qm_cgr_cs_thres cs_thres;629volatile uint8_t frame_mode; /* boolean, use QM_CGR_EN */630} _PackedType;631632#define QM_CGR_EN 0x01 /* For wr_en_*, cscn_en, cstd_en, frame_mode */633634/* See 1.5.8.5.1: "Initialize FQ" */635/* See 1.5.8.5.2: "Query FQ" */636/* See 1.5.8.5.3: "Query FQ Non-Programmable Fields" */637/* See 1.5.8.5.4: "Alter FQ State Commands " */638/* See 1.5.8.6.1: "Initialize/Modify CGR" */639/* See 1.5.8.6.2: "Query CGR" */640/* See 1.5.8.6.3: "Query Congestion Group State" */641_Packed struct qm_mc_command {642volatile uint8_t __dont_write_directly__verb;643_Packed union {644_Packed struct qm_mcc_initfq {645volatile uint8_t reserved1;646volatile uint16_t we_mask; /* Write Enable Mask */647volatile uint32_t fqid; /* 24-bit */648volatile uint16_t count; /* Initialises 'count+1' FQDs */649volatile struct qm_fqd fqd; /* the FQD fields go here */650volatile uint8_t reserved3[32];651} _PackedType initfq;652_Packed struct qm_mcc_queryfq {653volatile uint8_t reserved1[3];654volatile uint32_t fqid; /* 24-bit */655volatile uint8_t reserved2[56];656} _PackedType queryfq;657_Packed struct qm_mcc_queryfq_np {658volatile uint8_t reserved1[3];659volatile uint32_t fqid; /* 24-bit */660volatile uint8_t reserved2[56];661} _PackedType queryfq_np;662_Packed struct qm_mcc_alterfq {663volatile uint8_t reserved1[3];664volatile uint32_t fqid; /* 24-bit */665volatile uint8_t reserved2[12];666volatile uint32_t context_b;667volatile uint8_t reserved3[40];668} _PackedType alterfq;669_Packed struct qm_mcc_initcgr {670volatile uint8_t reserved1;671volatile uint16_t we_mask; /* Write Enable Mask */672volatile struct __qm_mc_cgr cgr; /* CGR fields */673volatile uint8_t reserved2[2];674volatile uint8_t cgid;675volatile uint8_t reserved4[32];676} _PackedType initcgr;677_Packed struct qm_mcc_querycgr {678volatile uint8_t reserved1[30];679volatile uint8_t cgid;680volatile uint8_t reserved2[32];681} _PackedType querycgr;682_Packed struct qm_mcc_querycongestion {683volatile uint8_t reserved[63];684} _PackedType querycongestion;685_Packed struct qm_mcc_querywq {686volatile uint8_t reserved;687/* select channel if verb != QUERYWQ_DEDICATED */688_Packed union {689volatile uint16_t channel_wq; /* ignores wq (3 lsbits) */690_Packed struct {691volatile uint16_t id:13; /* enum qm_channel */692volatile uint16_t reserved1:3;693} _PackedType channel;694} _PackedType;695volatile uint8_t reserved2[60];696} _PackedType querywq;697} _PackedType;698} _PackedType;699700#define QM_MCC_VERB_VBIT 0x80701#define QM_MCC_VERB_MASK 0x7f /* where the verb contains; */702#define QM_MCC_VERB_INITFQ_PARKED 0x40703#define QM_MCC_VERB_INITFQ_SCHED 0x41704#define QM_MCC_VERB_QUERYFQ 0x44705#define QM_MCC_VERB_QUERYFQ_NP 0x45 /* "non-programmable" fields */706#define QM_MCC_VERB_QUERYWQ 0x46707#define QM_MCC_VERB_QUERYWQ_DEDICATED 0x47708#define QM_MCC_VERB_ALTER_SCHED 0x48 /* Schedule FQ */709#define QM_MCC_VERB_ALTER_FE 0x49 /* Force Eligible FQ */710#define QM_MCC_VERB_ALTER_RETIRE 0x4a /* Retire FQ */711#define QM_MCC_VERB_ALTER_OOS 0x4b /* Take FQ out of service */712#define QM_MCC_VERB_ALTER_RETIRE_CTXB 0x4c /* Retire FQ with contextB*/713#define QM_MCC_VERB_INITCGR 0x50714#define QM_MCC_VERB_MODIFYCGR 0x51715#define QM_MCC_VERB_QUERYCGR 0x58716#define QM_MCC_VERB_QUERYCONGESTION 0x59717/* INITFQ-specific flags */718#define QM_INITFQ_WE_MASK 0x01ff /* 'Write Enable' flags; */719#define QM_INITFQ_WE_OAC 0x0100720#define QM_INITFQ_WE_ORPC 0x0080721#define QM_INITFQ_WE_CGID 0x0040722#define QM_INITFQ_WE_FQCTRL 0x0020723#define QM_INITFQ_WE_DESTWQ 0x0010724#define QM_INITFQ_WE_ICSCRED 0x0008725#define QM_INITFQ_WE_TDTHRESH 0x0004726#define QM_INITFQ_WE_CONTEXTB 0x0002727#define QM_INITFQ_WE_CONTEXTA 0x0001728/* INITCGR/MODIFYCGR-specific flags */729#define QM_CGR_WE_MASK 0x07ff /* 'Write Enable Mask'; */730#define QM_CGR_WE_WR_PARM_G 0x0400731#define QM_CGR_WE_WR_PARM_Y 0x0200732#define QM_CGR_WE_WR_PARM_R 0x0100733#define QM_CGR_WE_WR_EN_G 0x0080734#define QM_CGR_WE_WR_EN_Y 0x0040735#define QM_CGR_WE_WR_EN_R 0x0020736#define QM_CGR_WE_CSCN_EN 0x0010737#define QM_CGR_WE_CSCN_TARG 0x0008738#define QM_CGR_WE_CSTD_EN 0x0004739#define QM_CGR_WE_CS_THRES 0x0002740#define QM_CGR_WE_MODE 0x0001741742/* See 1.5.8.5.1: "Initialize FQ" */743/* See 1.5.8.5.2: "Query FQ" */744/* See 1.5.8.5.3: "Query FQ Non-Programmable Fields" */745/* See 1.5.8.5.4: "Alter FQ State Commands " */746/* See 1.5.8.6.1: "Initialize/Modify CGR" */747/* See 1.5.8.6.2: "Query CGR" */748/* See 1.5.8.6.3: "Query Congestion Group State" */749_Packed struct qm_mc_result {750volatile uint8_t verb;751volatile uint8_t result;752_Packed union {753_Packed struct qm_mcr_initfq {754volatile uint8_t reserved1[62];755} _PackedType initfq;756_Packed struct qm_mcr_queryfq {757volatile uint8_t reserved1[8];758volatile struct qm_fqd fqd; /* the FQD fields are here */759volatile uint16_t oac;760volatile uint8_t reserved2[30];761} _PackedType queryfq;762_Packed struct qm_mcr_queryfq_np {763volatile uint8_t reserved1;764volatile uint8_t state; /* QM_MCR_NP_STATE_*** */765volatile uint8_t reserved2;766volatile uint32_t fqd_link:24;767volatile uint16_t odp_seq;768volatile uint16_t orp_nesn;769volatile uint16_t orp_ea_hseq;770volatile uint16_t orp_ea_tseq;771volatile uint8_t reserved3;772volatile uint32_t orp_ea_hptr:24;773volatile uint8_t reserved4;774volatile uint32_t orp_ea_tptr:24;775volatile uint8_t reserved5;776volatile uint32_t pfdr_hptr:24;777volatile uint8_t reserved6;778volatile uint32_t pfdr_tptr:24;779volatile uint8_t reserved7[5];780volatile uint8_t reserved8:7;781volatile uint8_t is:1;782volatile uint16_t ics_surp;783volatile uint32_t byte_cnt;784volatile uint8_t reserved9;785volatile uint32_t frm_cnt:24;786volatile uint32_t reserved10;787volatile uint16_t ra1_sfdr; /* QM_MCR_NP_RA1_*** */788volatile uint16_t ra2_sfdr; /* QM_MCR_NP_RA2_*** */789volatile uint16_t reserved11;790volatile uint16_t od1_sfdr; /* QM_MCR_NP_OD1_*** */791volatile uint16_t od2_sfdr; /* QM_MCR_NP_OD2_*** */792volatile uint16_t od3_sfdr; /* QM_MCR_NP_OD3_*** */793} _PackedType queryfq_np;794_Packed struct qm_mcr_alterfq {795volatile uint8_t fqs; /* Frame Queue Status */796volatile uint8_t reserved1[61];797} _PackedType alterfq;798_Packed struct qm_mcr_initcgr {799volatile uint8_t reserved1[62];800} _PackedType initcgr;801_Packed struct qm_mcr_querycgr {802volatile uint16_t reserved1;803volatile struct __qm_mc_cgr cgr; /* CGR fields */804volatile uint8_t reserved2[3];805volatile uint32_t reserved3:24;806volatile uint32_t i_bcnt_hi:8;/* high 8-bits of 40-bit "Instant" */807volatile uint32_t i_bcnt_lo; /* low 32-bits of 40-bit */808volatile uint32_t reserved4:24;809volatile uint32_t a_bcnt_hi:8;/* high 8-bits of 40-bit "Average" */810volatile uint32_t a_bcnt_lo; /* low 32-bits of 40-bit */811volatile uint32_t lgt; /* Last Group Tick */812volatile uint8_t reserved5[12];813} _PackedType querycgr;814_Packed struct qm_mcr_querycongestion {815volatile uint8_t reserved[30];816/* Access this struct using QM_MCR_QUERYCONGESTION() */817_Packed struct __qm_mcr_querycongestion {818volatile uint32_t __state[8];819} _PackedType state;820} _PackedType querycongestion;821_Packed struct qm_mcr_querywq {822_Packed union {823volatile uint16_t channel_wq; /* ignores wq (3 lsbits) */824_Packed struct {825volatile uint16_t id:13; /* enum qm_channel */826volatile uint16_t reserved:3;827} _PackedType channel;828} _PackedType;829volatile uint8_t reserved[28];830volatile uint32_t wq_len[8];831} _PackedType querywq;832} _PackedType;833} _PackedType;834835#define QM_MCR_VERB_RRID 0x80836#define QM_MCR_VERB_MASK QM_MCC_VERB_MASK837#define QM_MCR_VERB_INITFQ_PARKED QM_MCC_VERB_INITFQ_PARKED838#define QM_MCR_VERB_INITFQ_SCHED QM_MCC_VERB_INITFQ_SCHED839#define QM_MCR_VERB_QUERYFQ QM_MCC_VERB_QUERYFQ840#define QM_MCR_VERB_QUERYFQ_NP QM_MCC_VERB_QUERYFQ_NP841#define QM_MCR_VERB_QUERYWQ QM_MCC_VERB_QUERYWQ842#define QM_MCR_VERB_QUERYWQ_DEDICATED QM_MCC_VERB_QUERYWQ_DEDICATED843#define QM_MCR_VERB_ALTER_SCHED QM_MCC_VERB_ALTER_SCHED844#define QM_MCR_VERB_ALTER_FE QM_MCC_VERB_ALTER_FE845#define QM_MCR_VERB_ALTER_RETIRE QM_MCC_VERB_ALTER_RETIRE846#define QM_MCR_VERB_ALTER_RETIRE_CTXB QM_MCC_VERB_ALTER_RETIRE_CTXB847#define QM_MCR_VERB_ALTER_OOS QM_MCC_VERB_ALTER_OOS848#define QM_MCR_RESULT_NULL 0x00849#define QM_MCR_RESULT_OK 0xf0850#define QM_MCR_RESULT_ERR_FQID 0xf1851#define QM_MCR_RESULT_ERR_FQSTATE 0xf2852#define QM_MCR_RESULT_ERR_NOTEMPTY 0xf3 /* OOS fails if FQ is !empty */853#define QM_MCR_RESULT_ERR_BADCHANNEL 0xf4854#define QM_MCR_RESULT_PENDING 0xf8855#define QM_MCR_RESULT_ERR_BADCOMMAND 0xff856#define QM_MCR_NP_STATE_FE 0x10857#define QM_MCR_NP_STATE_R 0x08858#define QM_MCR_NP_STATE_MASK 0x07 /* Reads FQD::STATE; */859#define QM_MCR_NP_STATE_OOS 0x00860#define QM_MCR_NP_STATE_RETIRED 0x01861#define QM_MCR_NP_STATE_TEN_SCHED 0x02862#define QM_MCR_NP_STATE_TRU_SCHED 0x03863#define QM_MCR_NP_STATE_PARKED 0x04864#define QM_MCR_NP_STATE_ACTIVE 0x05865#define QM_MCR_NP_PTR_MASK 0x07ff /* for RA[12] & OD[123] */866#define QM_MCR_NP_RA1_NRA(v) (((v) >> 14) & 0x3) /* FQD::NRA */867#define QM_MCR_NP_RA2_IT(v) (((v) >> 14) & 0x1) /* FQD::IT */868#define QM_MCR_NP_OD1_NOD(v) (((v) >> 14) & 0x3) /* FQD::NOD */869#define QM_MCR_NP_OD3_NPC(v) (((v) >> 14) & 0x3) /* FQD::NPC */870#define QM_MCR_FQS_ORLPRESENT 0x02 /* ORL fragments to come */871#define QM_MCR_FQS_NOTEMPTY 0x01 /* FQ has enqueued frames */872873#define MEM_MAP_END874#if defined(__MWERKS__) && !defined(__GNUC__)875#pragma pack(pop)876#endif /* defined(__MWERKS__) && ... */877878879/* This extracts the state for congestion group 'n' from a query response.880* Eg.881* uint8_t cgr = [...];882* struct qm_mc_result *res = [...];883* printf("congestion group %d congestion state: %d\n", cgr,884* QM_MCR_QUERYCONGESTION(&res->querycongestion.state, cgr));885*/886#define __CGR_WORD(num) (num >> 5)887#define __CGR_SHIFT(num) (num & 0x1f)888static __inline__ int QM_MCR_QUERYCONGESTION(struct __qm_mcr_querycongestion *p,889uint8_t cgr)890{891return (int)(p->__state[__CGR_WORD(cgr)] & (0x80000000 >> __CGR_SHIFT(cgr)));892}893894895/*********************/896/* Utility interface */897/*********************/898899/* Represents an allocator over a range of FQIDs. NB, accesses are not locked,900* spinlock them yourself if needed. */901struct qman_fqid_pool;902903/* Create/destroy a FQID pool, num must be a multiple of 32. NB, _destroy()904* always succeeds, but returns non-zero if there were "leaked" FQID905* allocations. */906struct qman_fqid_pool *qman_fqid_pool_create(uint32_t fqid_start, uint32_t num);907int qman_fqid_pool_destroy(struct qman_fqid_pool *pool);908/* Alloc/free a FQID from the range. _alloc() returns zero for success. */909int qman_fqid_pool_alloc(struct qman_fqid_pool *pool, uint32_t *fqid);910void qman_fqid_pool_free(struct qman_fqid_pool *pool, uint32_t fqid);911uint32_t qman_fqid_pool_used(struct qman_fqid_pool *pool);912913/*******************************************************************/914/* Managed (aka "shared" or "mux/demux") portal, high-level i/face */915/*******************************************************************/916917/* Congestion Groups */918/* ----------------- */919/* This wrapper represents a bit-array for the state of the 256 Qman congestion920* groups. Is also used as a *mask* for congestion groups, eg. so we ignore921* those that don't concern us. We harness the structure and accessor details922* already used in the management command to query congestion groups. */923struct qman_cgrs {924struct __qm_mcr_querycongestion q;925};926static __inline__ void QMAN_CGRS_INIT(struct qman_cgrs *c)927{928memset(c, 0, sizeof(*c));929}930static __inline__ int QMAN_CGRS_GET(struct qman_cgrs *c, int num)931{932return QM_MCR_QUERYCONGESTION(&c->q, (uint8_t)num);933}934static __inline__ void QMAN_CGRS_SET(struct qman_cgrs *c, int num)935{936c->q.__state[__CGR_WORD(num)] |= (0x80000000 >> __CGR_SHIFT(num));937}938static __inline__ void QMAN_CGRS_UNSET(struct qman_cgrs *c, int num)939{940c->q.__state[__CGR_WORD(num)] &= ~(0x80000000 >> __CGR_SHIFT(num));941}942943/* Portal and Frame Queues */944/* ----------------------- */945946/* This object type represents Qman frame queue descriptors (FQD), and is947* stored within a cacheline passed to qman_new_fq(). */948struct qman_fq;949950/* This enum, and the callback type that returns it, are used when handling951* dequeued frames via DQRR. Note that for "null" callbacks registered with the952* portal object (for handling dequeues that do not demux because contextB is953* NULL), the return value *MUST* be qman_cb_dqrr_consume. */954enum qman_cb_dqrr_result {955/* DQRR entry can be consumed */956qman_cb_dqrr_consume,957/* DQRR entry cannot be consumed now, pause until next poll request */958qman_cb_dqrr_pause,959/* Like _consume, but requests parking - FQ must be held-active */960qman_cb_dqrr_park,961/* Does not consume, for DCA mode only. This allows out-of-order962* consumes by explicit calls to qman_dca() and/or the use of implicit963* DCA via EQCR entries. */964qman_cb_dqrr_defer965};966967/*typedef enum qman_cb_dqrr_result (*qman_cb_dqrr)(t_Handle h_Arg,968t_Handle h_QmPortal,969struct qman_fq *fq,970const struct qm_dqrr_entry *dqrr);*/971typedef t_QmReceivedFrameCallback * qman_cb_dqrr;972typedef t_QmReceivedFrameCallback * qman_cb_fqs;973typedef t_QmRejectedFrameCallback * qman_cb_ern;974/* This callback type is used when handling ERNs, FQRNs and FQRLs via MR. They975* are always consumed after the callback returns. */976typedef void (*qman_cb_mr)(t_Handle h_Arg,977t_Handle h_QmPortal,978struct qman_fq *fq,979const struct qm_mr_entry *msg);980981struct qman_fq_cb {982qman_cb_dqrr dqrr; /* for dequeued frames */983qman_cb_ern ern; /* for s/w ERNs */984qman_cb_mr dc_ern; /* for diverted h/w ERNs */985qman_cb_mr fqs; /* frame-queue state changes*/986};987988enum qman_fq_state {989qman_fq_state_oos,990qman_fq_state_waiting_parked,991qman_fq_state_parked,992qman_fq_state_sched,993qman_fq_state_retired994};995996/* Flags to qman_create_portal() */997#define QMAN_PORTAL_FLAG_IRQ 0x00000001 /* use interrupt handler */998#define QMAN_PORTAL_FLAG_IRQ_FAST 0x00000002 /* ... for fast-path too! */999#define QMAN_PORTAL_FLAG_IRQ_SLOW 0x00000003 /* ... for slow-path too! */1000#define QMAN_PORTAL_FLAG_DCA 0x00000004 /* use DCA */1001#define QMAN_PORTAL_FLAG_LOCKED 0x00000008 /* multi-core locking */1002#define QMAN_PORTAL_FLAG_NOTAFFINE 0x00000010 /* not cpu-default portal */1003#define QMAN_PORTAL_FLAG_RSTASH 0x00000020 /* enable DQRR entry stashing */1004#define QMAN_PORTAL_FLAG_DSTASH 0x00000040 /* enable data stashing */1005#define QMAN_PORTAL_FLAG_RECOVER 0x00000080 /* recovery mode */1006#define QMAN_PORTAL_FLAG_WAIT 0x00000100 /* for recovery; can wait */1007#define QMAN_PORTAL_FLAG_WAIT_INT 0x00000200 /* for wait; interruptible */1008#define QMAN_PORTAL_FLAG_CACHE 0x00000400 /* use cachable area for EQCR/DQRR */10091010/* Flags to qman_create_fq() */1011#define QMAN_FQ_FLAG_NO_ENQUEUE 0x00000001 /* can't enqueue */1012#define QMAN_FQ_FLAG_NO_MODIFY 0x00000002 /* can only enqueue */1013#define QMAN_FQ_FLAG_TO_DCPORTAL 0x00000004 /* consumed by CAAM/PME/Fman */1014#define QMAN_FQ_FLAG_LOCKED 0x00000008 /* multi-core locking */1015#define QMAN_FQ_FLAG_RECOVER 0x00000010 /* recovery mode */1016#define QMAN_FQ_FLAG_DYNAMIC_FQID 0x00000020 /* (de)allocate fqid */10171018/* Flags to qman_destroy_fq() */1019#define QMAN_FQ_DESTROY_PARKED 0x00000001 /* FQ can be parked or OOS */10201021/* Flags from qman_fq_state() */1022#define QMAN_FQ_STATE_CHANGING 0x80000000 /* 'state' is changing */1023#define QMAN_FQ_STATE_NE 0x40000000 /* retired FQ isn't empty */1024#define QMAN_FQ_STATE_ORL 0x20000000 /* retired FQ has ORL */1025#define QMAN_FQ_STATE_BLOCKOOS 0xe0000000 /* if any are set, no OOS */1026#define QMAN_FQ_STATE_CGR_EN 0x10000000 /* CGR enabled */1027#define QMAN_FQ_STATE_VDQCR 0x08000000 /* being volatile dequeued */10281029/* Flags to qman_init_fq() */1030#define QMAN_INITFQ_FLAG_SCHED 0x00000001 /* schedule rather than park */1031#define QMAN_INITFQ_FLAG_NULL 0x00000002 /* zero 'contextB', no demux */1032#define QMAN_INITFQ_FLAG_LOCAL 0x00000004 /* set dest portal */10331034/* Flags to qman_volatile_dequeue() */1035#define QMAN_VOLATILE_FLAG_WAIT_INT 0x00000001 /* if we wait, interruptible? */1036#define QMAN_VOLATILE_FLAG_WAIT 0x00000002 /* wait if VDQCR is in use */1037#define QMAN_VOLATILE_FLAG_FINISH 0x00000004 /* wait till VDQCR completes */10381039/* Flags to qman_enqueue(). NB, the strange numbering is to align with1040* hardware, bit-wise. */1041#define QMAN_ENQUEUE_FLAG_WAIT 0x00010000 /* wait if EQCR is full */1042#define QMAN_ENQUEUE_FLAG_WAIT_INT 0x00020000 /* if wait, interruptible? */1043#define QMAN_ENQUEUE_FLAG_WAIT_SYNC 0x00040000 /* if wait, until consumed? */1044#define QMAN_ENQUEUE_FLAG_WATCH_CGR 0x00080000 /* watch congestion state */1045#define QMAN_ENQUEUE_FLAG_INTERRUPT 0x00000004 /* on command consumption */1046#define QMAN_ENQUEUE_FLAG_DCA 0x00008000 /* perform enqueue-DCA */1047#define QMAN_ENQUEUE_FLAG_DCA_PARK 0x00004000 /* If DCA, requests park */1048#define QMAN_ENQUEUE_FLAG_DCA_PTR(p) /* If DCA, p is DQRR entry */ \1049(((uint32_t)(p) << 2) & 0x00000f00)1050#define QMAN_ENQUEUE_FLAG_C_GREEN 0x00000000 /* choose one C_*** flag */1051#define QMAN_ENQUEUE_FLAG_C_YELLOW 0x000000081052#define QMAN_ENQUEUE_FLAG_C_RED 0x000000101053#define QMAN_ENQUEUE_FLAG_C_OVERRIDE 0x000000181054/* For the ORP-specific qman_enqueue_orp() variant, this flag indicates "Not1055* Last In Sequence", ie. a non-terminating fragment. */1056#define QMAN_ENQUEUE_FLAG_NLIS 0x010000001057/* - this flag performs no enqueue but fills in an ORP sequence number that1058* would otherwise block it (eg. if a frame has been dropped). */1059#define QMAN_ENQUEUE_FLAG_HOLE 0x020000001060/* - this flag performs no enqueue but advances NESN to the given sequence1061* number. */1062#define QMAN_ENQUEUE_FLAG_NESN 0x0400000010631064/* FQ management */1065/* ------------- */1066/**1067* qman_free_fq - Deallocates a FQ1068* @fq: the frame queue object to release1069* @flags: bit-mask of QMAN_FQ_FREE_*** options1070*1071* The memory for this frame queue object ('mem' provided in qman_new_fq()) is1072* not deallocated but the caller regains ownership, to do with as desired. The1073* FQ must be in the 'out-of-service' state unless the QMAN_FQ_FREE_PARKED flag1074* is specified, in which case it may also be in the 'parked' state.1075*/1076void qman_free_fq(struct qman_fq *fq, uint32_t flags);10771078/**1079* qman_fq_fqid - Queries the frame queue ID of a FQ object1080* @fq: the frame queue object to query1081*/1082uint32_t qman_fq_fqid(struct qman_fq *fq);10831084/**1085* qman_fq_state - Queries the state of a FQ object1086* @fq: the frame queue object to query1087* @state: pointer to state enum to return the FQ scheduling state1088* @flags: pointer to state flags to receive QMAN_FQ_STATE_*** bitmask1089*1090* Queries the state of the FQ object, without performing any h/w commands.1091* This captures the state, as seen by the driver, at the time the function1092* executes.1093*/1094void qman_fq_state(struct qman_fq *fq, enum qman_fq_state *state, uint32_t *flags);10951096#endif /* __FSL_QMAN_H */109710981099