/* Copyright 2008 - 2016 Freescale Semiconductor, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Freescale Semiconductor nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * ALTERNATIVELY, this software may be distributed under the terms of the * GNU General Public License ("GPL") as published by the Free Software * Foundation, either version 2 of that License or (at your option) any * later version. * * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef __FSL_QMAN_H #define __FSL_QMAN_H #include <linux/bitops.h> #include <linux/device.h> /* Hardware constants */ #define QM_CHANNEL_SWPORTAL0 … #define QMAN_CHANNEL_POOL1 … #define QMAN_CHANNEL_CAAM … #define QMAN_CHANNEL_POOL1_REV3 … #define QMAN_CHANNEL_CAAM_REV3 … extern u16 qm_channel_pool1; extern u16 qm_channel_caam; /* Portal processing (interrupt) sources */ #define QM_PIRQ_CSCI … #define QM_PIRQ_EQCI … #define QM_PIRQ_EQRI … #define QM_PIRQ_DQRI … #define QM_PIRQ_MRI … /* * This mask contains all the interrupt sources that need handling except DQRI, * ie. that if present should trigger slow-path processing. */ #define QM_PIRQ_SLOW … /* For qman_static_dequeue_*** APIs */ #define QM_SDQCR_CHANNELS_POOL_MASK … /* for n in [1,15] */ #define QM_SDQCR_CHANNELS_POOL(n) … /* for conversion from n of qm_channel */ static inline u32 QM_SDQCR_CHANNELS_POOL_CONV(u16 channel) { … } /* --- QMan data structures (and associated constants) --- */ /* "Frame Descriptor (FD)" */ struct qm_fd { … } __aligned(…); #define QM_FD_FORMAT_SG … #define QM_FD_FORMAT_LONG … #define QM_FD_FORMAT_COMPOUND … #define QM_FD_FORMAT_MASK … #define QM_FD_OFF_SHIFT … #define QM_FD_OFF_MASK … #define QM_FD_LEN_MASK … #define QM_FD_LEN_BIG_MASK … enum qm_fd_format { … }; static inline dma_addr_t qm_fd_addr(const struct qm_fd *fd) { … } static inline u64 qm_fd_addr_get64(const struct qm_fd *fd) { … } static inline void qm_fd_addr_set64(struct qm_fd *fd, u64 addr) { … } /* * The 'format' field indicates the interpretation of the remaining * 29 bits of the 32-bit word. * If 'format' is _contig or _sg, 20b length and 9b offset. * If 'format' is _contig_big or _sg_big, 29b length. * If 'format' is _compound, 29b "congestion weight". */ static inline enum qm_fd_format qm_fd_get_format(const struct qm_fd *fd) { … } static inline int qm_fd_get_offset(const struct qm_fd *fd) { … } static inline int qm_fd_get_length(const struct qm_fd *fd) { … } static inline int qm_fd_get_len_big(const struct qm_fd *fd) { … } static inline void qm_fd_set_param(struct qm_fd *fd, enum qm_fd_format fmt, int off, int len) { … } #define qm_fd_set_contig(fd, off, len) … #define qm_fd_set_sg(fd, off, len) … #define qm_fd_set_contig_big(fd, len) … #define qm_fd_set_sg_big(fd, len) … #define qm_fd_set_compound(fd, len) … static inline void qm_fd_clear_fd(struct qm_fd *fd) { … } /* Scatter/Gather table entry */ struct qm_sg_entry { … } __packed; #define QM_SG_LEN_MASK … #define QM_SG_OFF_MASK … #define QM_SG_FIN … #define QM_SG_EXT … static inline dma_addr_t qm_sg_addr(const struct qm_sg_entry *sg) { … } static inline u64 qm_sg_entry_get64(const struct qm_sg_entry *sg) { … } static inline void qm_sg_entry_set64(struct qm_sg_entry *sg, u64 addr) { … } static inline bool qm_sg_entry_is_final(const struct qm_sg_entry *sg) { … } static inline bool qm_sg_entry_is_ext(const struct qm_sg_entry *sg) { … } static inline int qm_sg_entry_get_len(const struct qm_sg_entry *sg) { … } static inline void qm_sg_entry_set_len(struct qm_sg_entry *sg, int len) { … } static inline void qm_sg_entry_set_f(struct qm_sg_entry *sg, int len) { … } static inline int qm_sg_entry_get_off(const struct qm_sg_entry *sg) { … } /* "Frame Dequeue Response" */ struct qm_dqrr_entry { … } __packed __aligned(…); #define QM_DQRR_VERB_VBIT … #define QM_DQRR_VERB_MASK … #define QM_DQRR_VERB_FRAME_DEQUEUE … #define QM_DQRR_STAT_FQ_EMPTY … #define QM_DQRR_STAT_FQ_HELDACTIVE … #define QM_DQRR_STAT_FQ_FORCEELIGIBLE … #define QM_DQRR_STAT_FD_VALID … #define QM_DQRR_STAT_UNSCHEDULED … #define QM_DQRR_STAT_DQCR_EXPIRED … /* 'fqid' is a 24-bit field in every h/w descriptor */ #define QM_FQID_MASK … #define qm_fqid_set(p, v) … #define qm_fqid_get(p) … /* "ERN Message Response" */ /* "FQ State Change Notification" */ qm_mr_entry; #define QM_MR_VERB_VBIT … /* * ERNs originating from direct-connect portals ("dcern") use 0x20 as a verb * which would be invalid as a s/w enqueue verb. A s/w ERN can be distinguished * from the other MR types by noting if the 0x20 bit is unset. */ #define QM_MR_VERB_TYPE_MASK … #define QM_MR_VERB_DC_ERN … #define QM_MR_VERB_FQRN … #define QM_MR_VERB_FQRNI … #define QM_MR_VERB_FQRL … #define QM_MR_VERB_FQPN … #define QM_MR_RC_MASK … #define QM_MR_RC_CGR_TAILDROP … #define QM_MR_RC_WRED … #define QM_MR_RC_ERROR … #define QM_MR_RC_ORPWINDOW_EARLY … #define QM_MR_RC_ORPWINDOW_LATE … #define QM_MR_RC_FQ_TAILDROP … #define QM_MR_RC_ORPWINDOW_RETIRED … #define QM_MR_RC_ORP_ZERO … #define QM_MR_FQS_ORLPRESENT … #define QM_MR_FQS_NOTEMPTY … /* * An identical structure of FQD fields is present in the "Init FQ" command and * the "Query FQ" result, it's suctioned out into the "struct qm_fqd" type. * Within that, the 'stashing' and 'taildrop' pieces are also factored out, the * latter has two inlines to assist with converting to/from the mant+exp * representation. */ struct qm_fqd_stashing { … }; struct qm_fqd_oac { … }; struct qm_fqd { … } __packed; #define QM_FQD_CHAN_OFF … #define QM_FQD_WQ_MASK … #define QM_FQD_TD_EXP_MASK … #define QM_FQD_TD_MANT_OFF … #define QM_FQD_TD_MANT_MASK … #define QM_FQD_TD_MAX … #define QM_FQD_TD_MANT_MAX … #define QM_FQD_OAC_OFF … #define QM_FQD_AS_OFF … #define QM_FQD_DS_OFF … #define QM_FQD_XS_MASK … /* 64-bit converters for context_hi/lo */ static inline u64 qm_fqd_stashing_get64(const struct qm_fqd *fqd) { … } static inline dma_addr_t qm_fqd_stashing_addr(const struct qm_fqd *fqd) { … } static inline u64 qm_fqd_context_a_get64(const struct qm_fqd *fqd) { … } static inline void qm_fqd_stashing_set64(struct qm_fqd *fqd, u64 addr) { … } static inline void qm_fqd_context_a_set64(struct qm_fqd *fqd, u64 addr) { … } /* convert a threshold value into mant+exp representation */ static inline int qm_fqd_set_taildrop(struct qm_fqd *fqd, u32 val, int roundup) { … } /* and the other direction */ static inline int qm_fqd_get_taildrop(const struct qm_fqd *fqd) { … } static inline void qm_fqd_set_stashing(struct qm_fqd *fqd, u8 as, u8 ds, u8 cs) { … } static inline u8 qm_fqd_get_stashing(const struct qm_fqd *fqd) { … } static inline void qm_fqd_set_oac(struct qm_fqd *fqd, u8 val) { … } static inline void qm_fqd_set_oal(struct qm_fqd *fqd, s8 val) { … } static inline void qm_fqd_set_destwq(struct qm_fqd *fqd, int ch, int wq) { … } static inline int qm_fqd_get_chan(const struct qm_fqd *fqd) { … } static inline int qm_fqd_get_wq(const struct qm_fqd *fqd) { … } /* See "Frame Queue Descriptor (FQD)" */ /* Frame Queue Descriptor (FQD) field 'fq_ctrl' uses these constants */ #define QM_FQCTRL_MASK … #define QM_FQCTRL_CGE … #define QM_FQCTRL_TDE … #define QM_FQCTRL_CTXASTASHING … #define QM_FQCTRL_CPCSTASH … #define QM_FQCTRL_FORCESFDR … #define QM_FQCTRL_AVOIDBLOCK … #define QM_FQCTRL_HOLDACTIVE … #define QM_FQCTRL_PREFERINCACHE … #define QM_FQCTRL_LOCKINCACHE … /* See "FQD Context_A field used for [...] */ /* Frame Queue Descriptor (FQD) field 'CONTEXT_A' uses these constants */ #define QM_STASHING_EXCL_ANNOTATION … #define QM_STASHING_EXCL_DATA … #define QM_STASHING_EXCL_CTX … /* See "Intra Class Scheduling" */ /* FQD field 'OAC' (Overhead ACcounting) uses these constants */ #define QM_OAC_ICS … #define QM_OAC_CG … /* * This struct represents the 32-bit "WR_PARM_[GYR]" parameters in CGR fields * and associated commands/responses. The WRED parameters are calculated from * these fields as follows; * MaxTH = MA * (2 ^ Mn) * Slope = SA / (2 ^ Sn) * MaxP = 4 * (Pn + 1) */ struct qm_cgr_wr_parm { … }; /* * This struct represents the 13-bit "CS_THRES" CGR field. In the corresponding * management commands, this is padded to a 16-bit structure field, so that's * how we represent it here. The congestion state threshold is calculated from * these fields as follows; * CS threshold = TA * (2 ^ Tn) */ struct qm_cgr_cs_thres { … }; /* * This identical structure of CGR fields is present in the "Init/Modify CGR" * commands and the "Query CGR" result. It's suctioned out here into its own * struct. */ struct __qm_mc_cgr { … } __packed; #define QM_CGR_EN … #define QM_CGR_TARG_UDP_CTRL_WRITE_BIT … #define QM_CGR_TARG_UDP_CTRL_DCP … #define QM_CGR_TARG_PORTAL(n) … #define QM_CGR_TARG_FMAN0 … #define QM_CGR_TARG_FMAN1 … /* Convert CGR thresholds to/from "cs_thres" format */ static inline u64 qm_cgr_cs_thres_get64(const struct qm_cgr_cs_thres *th) { … } static inline int qm_cgr_cs_thres_set64(struct qm_cgr_cs_thres *th, u64 val, int roundup) { … } /* "Initialize FQ" */ struct qm_mcc_initfq { … } __packed; /* "Initialize/Modify CGR" */ struct qm_mcc_initcgr { … } __packed; /* INITFQ-specific flags */ #define QM_INITFQ_WE_MASK … #define QM_INITFQ_WE_OAC … #define QM_INITFQ_WE_ORPC … #define QM_INITFQ_WE_CGID … #define QM_INITFQ_WE_FQCTRL … #define QM_INITFQ_WE_DESTWQ … #define QM_INITFQ_WE_ICSCRED … #define QM_INITFQ_WE_TDTHRESH … #define QM_INITFQ_WE_CONTEXTB … #define QM_INITFQ_WE_CONTEXTA … /* INITCGR/MODIFYCGR-specific flags */ #define QM_CGR_WE_MASK … #define QM_CGR_WE_WR_PARM_G … #define QM_CGR_WE_WR_PARM_Y … #define QM_CGR_WE_WR_PARM_R … #define QM_CGR_WE_WR_EN_G … #define QM_CGR_WE_WR_EN_Y … #define QM_CGR_WE_WR_EN_R … #define QM_CGR_WE_CSCN_EN … #define QM_CGR_WE_CSCN_TARG … #define QM_CGR_WE_CSTD_EN … #define QM_CGR_WE_CS_THRES … #define QM_CGR_WE_MODE … #define QMAN_CGR_FLAG_USE_INIT … #define QMAN_CGR_MODE_FRAME … /* Portal and Frame Queues */ /* Represents a managed portal */ struct qman_portal; /* * This object type represents QMan frame queue descriptors (FQD), it is * cacheline-aligned, and initialised by qman_create_fq(). The structure is * defined further down. */ struct qman_fq; /* * This object type represents a QMan congestion group, it is defined further * down. */ struct qman_cgr; /* * This enum, and the callback type that returns it, are used when handling * dequeued frames via DQRR. Note that for "null" callbacks registered with the * portal object (for handling dequeues that do not demux because context_b is * NULL), the return value *MUST* be qman_cb_dqrr_consume. */ enum qman_cb_dqrr_result { … }; qman_cb_dqrr; /* * This callback type is used when handling ERNs, FQRNs and FQRLs via MR. They * are always consumed after the callback returns. */ qman_cb_mr; /* * s/w-visible states. Ie. tentatively scheduled + truly scheduled + active + * held-active + held-suspended are just "sched". Things like "retired" will not * be assumed until it is complete (ie. QMAN_FQ_STATE_CHANGING is set until * then, to indicate it's completing and to gate attempts to retry the retire * command). Note, park commands do not set QMAN_FQ_STATE_CHANGING because it's * technically impossible in the case of enqueue DCAs (which refer to DQRR ring * index rather than the FQ that ring entry corresponds to), so repeated park * commands are allowed (if you're silly enough to try) but won't change FQ * state, and the resulting park notifications move FQs from "sched" to * "parked". */ enum qman_fq_state { … }; #define QMAN_FQ_STATE_CHANGING … #define QMAN_FQ_STATE_NE … #define QMAN_FQ_STATE_ORL … #define QMAN_FQ_STATE_BLOCKOOS … #define QMAN_FQ_STATE_CGR_EN … #define QMAN_FQ_STATE_VDQCR … /* * Frame queue objects (struct qman_fq) are stored within memory passed to * qman_create_fq(), as this allows stashing of caller-provided demux callback * pointers at no extra cost to stashing of (driver-internal) FQ state. If the * caller wishes to add per-FQ state and have it benefit from dequeue-stashing, * they should; * * (a) extend the qman_fq structure with their state; eg. * * // myfq is allocated and driver_fq callbacks filled in; * struct my_fq { * struct qman_fq base; * int an_extra_field; * [ ... add other fields to be associated with each FQ ...] * } *myfq = some_my_fq_allocator(); * struct qman_fq *fq = qman_create_fq(fqid, flags, &myfq->base); * * // in a dequeue callback, access extra fields from 'fq' via a cast; * struct my_fq *myfq = (struct my_fq *)fq; * do_something_with(myfq->an_extra_field); * [...] * * (b) when and if configuring the FQ for context stashing, specify how ever * many cachelines are required to stash 'struct my_fq', to accelerate not * only the QMan driver but the callback as well. */ struct qman_fq_cb { … }; struct qman_fq { … }; /* * This callback type is used when handling congestion group entry/exit. * 'congested' is non-zero on congestion-entry, and zero on congestion-exit. */ qman_cb_cgr; struct qman_cgr { … }; /* Flags to qman_create_fq() */ #define QMAN_FQ_FLAG_NO_ENQUEUE … #define QMAN_FQ_FLAG_NO_MODIFY … #define QMAN_FQ_FLAG_TO_DCPORTAL … #define QMAN_FQ_FLAG_DYNAMIC_FQID … /* Flags to qman_init_fq() */ #define QMAN_INITFQ_FLAG_SCHED … #define QMAN_INITFQ_FLAG_LOCAL … /* * For qman_volatile_dequeue(); Choose one PRECEDENCE. EXACT is optional. Use * NUMFRAMES(n) (6-bit) or NUMFRAMES_TILLEMPTY to fill in the frame-count. Use * FQID(n) to fill in the frame queue ID. */ #define QM_VDQCR_PRECEDENCE_VDQCR … #define QM_VDQCR_PRECEDENCE_SDQCR … #define QM_VDQCR_EXACT … #define QM_VDQCR_NUMFRAMES_MASK … #define QM_VDQCR_NUMFRAMES_SET(n) … #define QM_VDQCR_NUMFRAMES_GET(n) … #define QM_VDQCR_NUMFRAMES_TILLEMPTY … #define QMAN_VOLATILE_FLAG_WAIT … #define QMAN_VOLATILE_FLAG_WAIT_INT … #define QMAN_VOLATILE_FLAG_FINISH … /* "Query FQ Non-Programmable Fields" */ struct qm_mcr_queryfq_np { … } __packed; #define QM_MCR_NP_STATE_FE … #define QM_MCR_NP_STATE_R … #define QM_MCR_NP_STATE_MASK … #define QM_MCR_NP_STATE_OOS … #define QM_MCR_NP_STATE_RETIRED … #define QM_MCR_NP_STATE_TEN_SCHED … #define QM_MCR_NP_STATE_TRU_SCHED … #define QM_MCR_NP_STATE_PARKED … #define QM_MCR_NP_STATE_ACTIVE … #define QM_MCR_NP_PTR_MASK … #define QM_MCR_NP_RA1_NRA(v) … #define QM_MCR_NP_RA2_IT(v) … #define QM_MCR_NP_OD1_NOD(v) … #define QM_MCR_NP_OD3_NPC(v) … enum qm_mcr_queryfq_np_masks { … }; #define qm_mcr_np_get(np, field) … /* Portal Management */ /** * qman_p_irqsource_add - add processing sources to be interrupt-driven * @bits: bitmask of QM_PIRQ_**I processing sources * * Adds processing sources that should be interrupt-driven (rather than * processed via qman_poll_***() functions). */ void qman_p_irqsource_add(struct qman_portal *p, u32 bits); /** * qman_p_irqsource_remove - remove processing sources from being int-driven * @bits: bitmask of QM_PIRQ_**I processing sources * * Removes processing sources from being interrupt-driven, so that they will * instead be processed via qman_poll_***() functions. */ void qman_p_irqsource_remove(struct qman_portal *p, u32 bits); /** * qman_affine_cpus - return a mask of cpus that have affine portals */ const cpumask_t *qman_affine_cpus(void); /** * qman_affine_channel - return the channel ID of an portal * @cpu: the cpu whose affine portal is the subject of the query * * If @cpu is -1, the affine portal for the current CPU will be used. It is a * bug to call this function for any value of @cpu (other than -1) that is not a * member of the mask returned from qman_affine_cpus(). */ u16 qman_affine_channel(int cpu); /** * qman_get_affine_portal - return the portal pointer affine to cpu * @cpu: the cpu whose affine portal is the subject of the query */ struct qman_portal *qman_get_affine_portal(int cpu); /** * qman_start_using_portal - register a device link for the portal user * @p: the portal that will be in use * @dev: the device that will use the portal * * Makes sure that the devices that use the portal are unbound when the * portal is unbound */ int qman_start_using_portal(struct qman_portal *p, struct device *dev); /** * qman_p_poll_dqrr - process DQRR (fast-path) entries * @limit: the maximum number of DQRR entries to process * * Use of this function requires that DQRR processing not be interrupt-driven. * The return value represents the number of DQRR entries processed. */ int qman_p_poll_dqrr(struct qman_portal *p, unsigned int limit); /** * qman_p_static_dequeue_add - Add pool channels to the portal SDQCR * @pools: bit-mask of pool channels, using QM_SDQCR_CHANNELS_POOL(n) * * Adds a set of pool channels to the portal's static dequeue command register * (SDQCR). The requested pools are limited to those the portal has dequeue * access to. */ void qman_p_static_dequeue_add(struct qman_portal *p, u32 pools); /* FQ management */ /** * qman_create_fq - Allocates a FQ * @fqid: the index of the FQD to encapsulate, must be "Out of Service" * @flags: bit-mask of QMAN_FQ_FLAG_*** options * @fq: memory for storing the 'fq', with callbacks filled in * * Creates a frame queue object for the given @fqid, unless the * QMAN_FQ_FLAG_DYNAMIC_FQID flag is set in @flags, in which case a FQID is * dynamically allocated (or the function fails if none are available). Once * created, the caller should not touch the memory at 'fq' except as extended to * adjacent memory for user-defined fields (see the definition of "struct * qman_fq" for more info). NO_MODIFY is only intended for enqueuing to * pre-existing frame-queues that aren't to be otherwise interfered with, it * prevents all other modifications to the frame queue. The TO_DCPORTAL flag * causes the driver to honour any context_b modifications requested in the * qm_init_fq() API, as this indicates the frame queue will be consumed by a * direct-connect portal (PME, CAAM, or Fman). When frame queues are consumed by * software portals, the context_b field is controlled by the driver and can't * be modified by the caller. */ int qman_create_fq(u32 fqid, u32 flags, struct qman_fq *fq); /** * qman_destroy_fq - Deallocates a FQ * @fq: the frame queue object to release * * The memory for this frame queue object ('fq' provided in qman_create_fq()) is * not deallocated but the caller regains ownership, to do with as desired. The * FQ must be in the 'out-of-service' or in the 'parked' state. */ void qman_destroy_fq(struct qman_fq *fq); /** * qman_fq_fqid - Queries the frame queue ID of a FQ object * @fq: the frame queue object to query */ u32 qman_fq_fqid(struct qman_fq *fq); /** * qman_init_fq - Initialises FQ fields, leaves the FQ "parked" or "scheduled" * @fq: the frame queue object to modify, must be 'parked' or new. * @flags: bit-mask of QMAN_INITFQ_FLAG_*** options * @opts: the FQ-modification settings, as defined in the low-level API * * The @opts parameter comes from the low-level portal API. Select * QMAN_INITFQ_FLAG_SCHED in @flags to cause the frame queue to be scheduled * rather than parked. NB, @opts can be NULL. * * Note that some fields and options within @opts may be ignored or overwritten * by the driver; * 1. the 'count' and 'fqid' fields are always ignored (this operation only * affects one frame queue: @fq). * 2. the QM_INITFQ_WE_CONTEXTB option of the 'we_mask' field and the associated * 'fqd' structure's 'context_b' field are sometimes overwritten; * - if @fq was not created with QMAN_FQ_FLAG_TO_DCPORTAL, then context_b is * initialised to a value used by the driver for demux. * - if context_b is initialised for demux, so is context_a in case stashing * is requested (see item 4). * (So caller control of context_b is only possible for TO_DCPORTAL frame queue * objects.) * 3. if @flags contains QMAN_INITFQ_FLAG_LOCAL, the 'fqd' structure's * 'dest::channel' field will be overwritten to match the portal used to issue * the command. If the WE_DESTWQ write-enable bit had already been set by the * caller, the channel workqueue will be left as-is, otherwise the write-enable * bit is set and the workqueue is set to a default of 4. If the "LOCAL" flag * isn't set, the destination channel/workqueue fields and the write-enable bit * are left as-is. * 4. if the driver overwrites context_a/b for demux, then if * QM_INITFQ_WE_CONTEXTA is set, the driver will only overwrite * context_a.address fields and will leave the stashing fields provided by the * user alone, otherwise it will zero out the context_a.stashing fields. */ int qman_init_fq(struct qman_fq *fq, u32 flags, struct qm_mcc_initfq *opts); /** * qman_schedule_fq - Schedules a FQ * @fq: the frame queue object to schedule, must be 'parked' * * Schedules the frame queue, which must be Parked, which takes it to * Tentatively-Scheduled or Truly-Scheduled depending on its fill-level. */ int qman_schedule_fq(struct qman_fq *fq); /** * qman_retire_fq - Retires a FQ * @fq: the frame queue object to retire * @flags: FQ flags (QMAN_FQ_STATE*) if retirement completes immediately * * Retires the frame queue. This returns zero if it succeeds immediately, +1 if * the retirement was started asynchronously, otherwise it returns negative for * failure. When this function returns zero, @flags is set to indicate whether * the retired FQ is empty and/or whether it has any ORL fragments (to show up * as ERNs). Otherwise the corresponding flags will be known when a subsequent * FQRN message shows up on the portal's message ring. * * NB, if the retirement is asynchronous (the FQ was in the Truly Scheduled or * Active state), the completion will be via the message ring as a FQRN - but * the corresponding callback may occur before this function returns!! Ie. the * caller should be prepared to accept the callback as the function is called, * not only once it has returned. */ int qman_retire_fq(struct qman_fq *fq, u32 *flags); /** * qman_oos_fq - Puts a FQ "out of service" * @fq: the frame queue object to be put out-of-service, must be 'retired' * * The frame queue must be retired and empty, and if any order restoration list * was released as ERNs at the time of retirement, they must all be consumed. */ int qman_oos_fq(struct qman_fq *fq); /* * qman_volatile_dequeue - Issue a volatile dequeue command * @fq: the frame queue object to dequeue from * @flags: a bit-mask of QMAN_VOLATILE_FLAG_*** options * @vdqcr: bit mask of QM_VDQCR_*** options, as per qm_dqrr_vdqcr_set() * * Attempts to lock access to the portal's VDQCR volatile dequeue functionality. * The function will block and sleep if QMAN_VOLATILE_FLAG_WAIT is specified and * the VDQCR is already in use, otherwise returns non-zero for failure. If * QMAN_VOLATILE_FLAG_FINISH is specified, the function will only return once * the VDQCR command has finished executing (ie. once the callback for the last * DQRR entry resulting from the VDQCR command has been called). If not using * the FINISH flag, completion can be determined either by detecting the * presence of the QM_DQRR_STAT_UNSCHEDULED and QM_DQRR_STAT_DQCR_EXPIRED bits * in the "stat" parameter passed to the FQ's dequeue callback, or by waiting * for the QMAN_FQ_STATE_VDQCR bit to disappear. */ int qman_volatile_dequeue(struct qman_fq *fq, u32 flags, u32 vdqcr); /** * qman_enqueue - Enqueue a frame to a frame queue * @fq: the frame queue object to enqueue to * @fd: a descriptor of the frame to be enqueued * * Fills an entry in the EQCR of portal @qm to enqueue the frame described by * @fd. The descriptor details are copied from @fd to the EQCR entry, the 'pid' * field is ignored. The return value is non-zero on error, such as ring full. */ int qman_enqueue(struct qman_fq *fq, const struct qm_fd *fd); /** * qman_alloc_fqid_range - Allocate a contiguous range of FQIDs * @result: is set by the API to the base FQID of the allocated range * @count: the number of FQIDs required * * Returns 0 on success, or a negative error code. */ int qman_alloc_fqid_range(u32 *result, u32 count); #define qman_alloc_fqid(result) … /** * qman_release_fqid - Release the specified frame queue ID * @fqid: the FQID to be released back to the resource pool * * This function can also be used to seed the allocator with * FQID ranges that it can subsequently allocate from. * Returns 0 on success, or a negative error code. */ int qman_release_fqid(u32 fqid); /** * qman_query_fq_np - Queries non-programmable FQD fields * @fq: the frame queue object to be queried * @np: storage for the queried FQD fields */ int qman_query_fq_np(struct qman_fq *fq, struct qm_mcr_queryfq_np *np); /* Pool-channel management */ /** * qman_alloc_pool_range - Allocate a contiguous range of pool-channel IDs * @result: is set by the API to the base pool-channel ID of the allocated range * @count: the number of pool-channel IDs required * * Returns 0 on success, or a negative error code. */ int qman_alloc_pool_range(u32 *result, u32 count); #define qman_alloc_pool(result) … /** * qman_release_pool - Release the specified pool-channel ID * @id: the pool-chan ID to be released back to the resource pool * * This function can also be used to seed the allocator with * pool-channel ID ranges that it can subsequently allocate from. * Returns 0 on success, or a negative error code. */ int qman_release_pool(u32 id); /* CGR management */ /** * qman_create_cgr - Register a congestion group object * @cgr: the 'cgr' object, with fields filled in * @flags: QMAN_CGR_FLAG_* values * @opts: optional state of CGR settings * * Registers this object to receiving congestion entry/exit callbacks on the * portal affine to the cpu portal on which this API is executed. If opts is * NULL then only the callback (cgr->cb) function is registered. If @flags * contains QMAN_CGR_FLAG_USE_INIT, then an init hw command (which will reset * any unspecified parameters) will be used rather than a modify hw hardware * (which only modifies the specified parameters). */ int qman_create_cgr(struct qman_cgr *cgr, u32 flags, struct qm_mcc_initcgr *opts); /** * qman_delete_cgr - Deregisters a congestion group object * @cgr: the 'cgr' object to deregister * * "Unplugs" this CGR object from the portal affine to the cpu on which this API * is executed. This must be excuted on the same affine portal on which it was * created. */ int qman_delete_cgr(struct qman_cgr *cgr); /** * qman_delete_cgr_safe - Deregisters a congestion group object from any CPU * @cgr: the 'cgr' object to deregister * * This will select the proper CPU and run there qman_delete_cgr(). */ void qman_delete_cgr_safe(struct qman_cgr *cgr); /** * qman_update_cgr_safe - Modifies a congestion group object from any CPU * @cgr: the 'cgr' object to modify * @opts: state of the CGR settings * * This will select the proper CPU and modify the CGR settings. */ int qman_update_cgr_safe(struct qman_cgr *cgr, struct qm_mcc_initcgr *opts); /** * qman_query_cgr_congested - Queries CGR's congestion status * @cgr: the 'cgr' object to query * @result: returns 'cgr's congestion status, 1 (true) if congested */ int qman_query_cgr_congested(struct qman_cgr *cgr, bool *result); /** * qman_alloc_cgrid_range - Allocate a contiguous range of CGR IDs * @result: is set by the API to the base CGR ID of the allocated range * @count: the number of CGR IDs required * * Returns 0 on success, or a negative error code. */ int qman_alloc_cgrid_range(u32 *result, u32 count); #define qman_alloc_cgrid(result) … /** * qman_release_cgrid - Release the specified CGR ID * @id: the CGR ID to be released back to the resource pool * * This function can also be used to seed the allocator with * CGR ID ranges that it can subsequently allocate from. * Returns 0 on success, or a negative error code. */ int qman_release_cgrid(u32 id); /** * qman_is_probed - Check if qman is probed * * Returns 1 if the qman driver successfully probed, -1 if the qman driver * failed to probe or 0 if the qman driver did not probed yet. */ int qman_is_probed(void); /** * qman_portals_probed - Check if all cpu bound qman portals are probed * * Returns 1 if all the required cpu bound qman portals successfully probed, * -1 if probe errors appeared or 0 if the qman portals did not yet finished * probing. */ int qman_portals_probed(void); /** * qman_dqrr_get_ithresh - Get coalesce interrupt threshold * @portal: portal to get the value for * @ithresh: threshold pointer */ void qman_dqrr_get_ithresh(struct qman_portal *portal, u8 *ithresh); /** * qman_dqrr_set_ithresh - Set coalesce interrupt threshold * @portal: portal to set the new value on * @ithresh: new threshold value * * Returns 0 on success, or a negative error code. */ int qman_dqrr_set_ithresh(struct qman_portal *portal, u8 ithresh); /** * qman_dqrr_get_iperiod - Get coalesce interrupt period * @portal: portal to get the value for * @iperiod: period pointer */ void qman_portal_get_iperiod(struct qman_portal *portal, u32 *iperiod); /** * qman_dqrr_set_iperiod - Set coalesce interrupt period * @portal: portal to set the new value on * @ithresh: new period value * * Returns 0 on success, or a negative error code. */ int qman_portal_set_iperiod(struct qman_portal *portal, u32 iperiod); #endif /* __FSL_QMAN_H */