/* 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. */ #include "dpaa_sys.h" #include <soc/fsl/qman.h> #include <linux/dma-mapping.h> #include <linux/iommu.h> #if defined(CONFIG_FSL_PAMU) #include <asm/fsl_pamu_stash.h> #endif struct qm_mcr_querywq { … } __packed; static inline u16 qm_mcr_querywq_get_chan(const struct qm_mcr_querywq *wq) { … } struct __qm_mcr_querycongestion { … }; /* "Query Congestion Group State" */ struct qm_mcr_querycongestion { … } __packed; /* "Query CGR" */ struct qm_mcr_querycgr { … } __packed; static inline u64 qm_mcr_querycgr_i_get64(const struct qm_mcr_querycgr *q) { … } static inline u64 qm_mcr_querycgr_a_get64(const struct qm_mcr_querycgr *q) { … } /* Congestion Groups */ /* * This wrapper represents a bit-array for the state of the 256 QMan congestion * groups. Is also used as a *mask* for congestion groups, eg. so we ignore * those that don't concern us. We harness the structure and accessor details * already used in the management command to query congestion groups. */ #define CGR_BITS_PER_WORD … #define CGR_WORD(x) … #define CGR_BIT(x) … #define CGR_NUM … struct qman_cgrs { … }; static inline void qman_cgrs_init(struct qman_cgrs *c) { … } static inline void qman_cgrs_fill(struct qman_cgrs *c) { … } static inline int qman_cgrs_get(struct qman_cgrs *c, u8 cgr) { … } static inline void qman_cgrs_cp(struct qman_cgrs *dest, const struct qman_cgrs *src) { … } static inline void qman_cgrs_and(struct qman_cgrs *dest, const struct qman_cgrs *a, const struct qman_cgrs *b) { … } static inline void qman_cgrs_xor(struct qman_cgrs *dest, const struct qman_cgrs *a, const struct qman_cgrs *b) { … } void qman_init_cgr_all(void); struct qm_portal_config { … }; /* Revision info (for errata and feature handling) */ #define QMAN_REV11 … #define QMAN_REV12 … #define QMAN_REV20 … #define QMAN_REV30 … #define QMAN_REV31 … #define QMAN_REV32 … extern u16 qman_ip_rev; /* 0 if uninitialised, otherwise QMAN_REVx */ #define QM_FQID_RANGE_START … extern struct gen_pool *qm_fqalloc; /* FQID allocator */ extern struct gen_pool *qm_qpalloc; /* pool-channel allocator */ extern struct gen_pool *qm_cgralloc; /* CGR ID allocator */ u32 qm_get_pools_sdqcr(void); int qman_wq_alloc(void); #ifdef CONFIG_FSL_PAMU #define qman_liodn_fixup … #else static inline void qman_liodn_fixup(u16 channel) { … } #endif void __qman_liodn_fixup(u16 channel); void qman_set_sdest(u16 channel, unsigned int cpu_idx); struct qman_portal *qman_create_affine_portal( const struct qm_portal_config *config, const struct qman_cgrs *cgrs); const struct qm_portal_config *qman_destroy_affine_portal(void); /* * qman_query_fq - Queries FQD fields (via h/w query command) * @fq: the frame queue object to be queried * @fqd: storage for the queried FQD fields */ int qman_query_fq(struct qman_fq *fq, struct qm_fqd *fqd); int qman_alloc_fq_table(u32 num_fqids); /* QMan s/w corenet portal, low-level i/face */ /* * For qm_dqrr_sdqcr_set(); Choose one SOURCE. Choose one COUNT. Choose one * dequeue TYPE. Choose TOKEN (8-bit). * If SOURCE == CHANNELS, * Choose CHANNELS_DEDICATED and/or CHANNELS_POOL(n). * You can choose DEDICATED_PRECEDENCE if the portal channel should have * priority. * If SOURCE == SPECIFICWQ, * Either select the work-queue ID with SPECIFICWQ_WQ(), or select the * channel (SPECIFICWQ_DEDICATED or SPECIFICWQ_POOL()) and specify the * work-queue priority (0-7) with SPECIFICWQ_WQ() - either way, you get the * same value. */ #define QM_SDQCR_SOURCE_CHANNELS … #define QM_SDQCR_SOURCE_SPECIFICWQ … #define QM_SDQCR_COUNT_EXACT1 … #define QM_SDQCR_COUNT_UPTO3 … #define QM_SDQCR_DEDICATED_PRECEDENCE … #define QM_SDQCR_TYPE_MASK … #define QM_SDQCR_TYPE_NULL … #define QM_SDQCR_TYPE_PRIO_QOS … #define QM_SDQCR_TYPE_ACTIVE_QOS … #define QM_SDQCR_TYPE_ACTIVE … #define QM_SDQCR_TOKEN_MASK … #define QM_SDQCR_TOKEN_SET(v) … #define QM_SDQCR_TOKEN_GET(v) … #define QM_SDQCR_CHANNELS_DEDICATED … #define QM_SDQCR_SPECIFICWQ_MASK … #define QM_SDQCR_SPECIFICWQ_DEDICATED … #define QM_SDQCR_SPECIFICWQ_POOL(n) … #define QM_SDQCR_SPECIFICWQ_WQ(n) … /* For qm_dqrr_vdqcr_set(): use FQID(n) to fill in the frame queue ID */ #define QM_VDQCR_FQID_MASK … #define QM_VDQCR_FQID(n) … /* * Used by all portal interrupt registers except 'inhibit' * Channels with frame availability */ #define QM_PIRQ_DQAVAIL … /* The DQAVAIL interrupt fields break down into these bits; */ #define QM_DQAVAIL_PORTAL … #define QM_DQAVAIL_POOL(n) … #define QM_DQAVAIL_MASK … /* This mask contains all the "irqsource" bits visible to API users */ #define QM_PIRQ_VISIBLE … extern struct qman_portal *affine_portals[NR_CPUS]; extern struct qman_portal *qman_dma_portal; const struct qm_portal_config *qman_get_qm_portal_config( struct qman_portal *portal); unsigned int qm_get_fqid_maxcnt(void); int qman_shutdown_fq(u32 fqid); int qman_requires_cleanup(void); void qman_done_cleanup(void); void qman_enable_irqs(void);