xref: /linux/drivers/soc/fsl/qbman/qman_priv.h (revision 290d638e04e7b94ff34d2f5e9426e7ce617e9a59)
1c535e923SClaudiu Manoil /* Copyright 2008 - 2016 Freescale Semiconductor, Inc.
2c535e923SClaudiu Manoil  *
3c535e923SClaudiu Manoil  * Redistribution and use in source and binary forms, with or without
4c535e923SClaudiu Manoil  * modification, are permitted provided that the following conditions are met:
5c535e923SClaudiu Manoil  *     * Redistributions of source code must retain the above copyright
6c535e923SClaudiu Manoil  *	 notice, this list of conditions and the following disclaimer.
7c535e923SClaudiu Manoil  *     * Redistributions in binary form must reproduce the above copyright
8c535e923SClaudiu Manoil  *	 notice, this list of conditions and the following disclaimer in the
9c535e923SClaudiu Manoil  *	 documentation and/or other materials provided with the distribution.
10c535e923SClaudiu Manoil  *     * Neither the name of Freescale Semiconductor nor the
11c535e923SClaudiu Manoil  *	 names of its contributors may be used to endorse or promote products
12c535e923SClaudiu Manoil  *	 derived from this software without specific prior written permission.
13c535e923SClaudiu Manoil  *
14c535e923SClaudiu Manoil  * ALTERNATIVELY, this software may be distributed under the terms of the
15c535e923SClaudiu Manoil  * GNU General Public License ("GPL") as published by the Free Software
16c535e923SClaudiu Manoil  * Foundation, either version 2 of that License or (at your option) any
17c535e923SClaudiu Manoil  * later version.
18c535e923SClaudiu Manoil  *
19c535e923SClaudiu Manoil  * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
20c535e923SClaudiu Manoil  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21c535e923SClaudiu Manoil  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22c535e923SClaudiu Manoil  * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
23c535e923SClaudiu Manoil  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24c535e923SClaudiu Manoil  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25c535e923SClaudiu Manoil  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26c535e923SClaudiu Manoil  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27c535e923SClaudiu Manoil  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28c535e923SClaudiu Manoil  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29c535e923SClaudiu Manoil  */
30c535e923SClaudiu Manoil 
31c535e923SClaudiu Manoil #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
32c535e923SClaudiu Manoil 
33c535e923SClaudiu Manoil #include "dpaa_sys.h"
34c535e923SClaudiu Manoil 
35c535e923SClaudiu Manoil #include <soc/fsl/qman.h>
36*290d638eSPaul Gortmaker #include <linux/dma-mapping.h>
37c535e923SClaudiu Manoil #include <linux/iommu.h>
38c535e923SClaudiu Manoil 
39c535e923SClaudiu Manoil #if defined(CONFIG_FSL_PAMU)
40c535e923SClaudiu Manoil #include <asm/fsl_pamu_stash.h>
41c535e923SClaudiu Manoil #endif
42c535e923SClaudiu Manoil 
43c535e923SClaudiu Manoil struct qm_mcr_querywq {
44c535e923SClaudiu Manoil 	u8 verb;
45c535e923SClaudiu Manoil 	u8 result;
46c535e923SClaudiu Manoil 	u16 channel_wq; /* ignores wq (3 lsbits): _res[0-2] */
47c535e923SClaudiu Manoil 	u8 __reserved[28];
48c535e923SClaudiu Manoil 	u32 wq_len[8];
49c535e923SClaudiu Manoil } __packed;
50c535e923SClaudiu Manoil 
51c535e923SClaudiu Manoil static inline u16 qm_mcr_querywq_get_chan(const struct qm_mcr_querywq *wq)
52c535e923SClaudiu Manoil {
53c535e923SClaudiu Manoil 	return wq->channel_wq >> 3;
54c535e923SClaudiu Manoil }
55c535e923SClaudiu Manoil 
56c535e923SClaudiu Manoil struct __qm_mcr_querycongestion {
57c535e923SClaudiu Manoil 	u32 state[8];
58c535e923SClaudiu Manoil };
59c535e923SClaudiu Manoil 
60c535e923SClaudiu Manoil /* "Query Congestion Group State" */
61c535e923SClaudiu Manoil struct qm_mcr_querycongestion {
62c535e923SClaudiu Manoil 	u8 verb;
63c535e923SClaudiu Manoil 	u8 result;
64c535e923SClaudiu Manoil 	u8 __reserved[30];
65c535e923SClaudiu Manoil 	/* Access this struct using qman_cgrs_get() */
66c535e923SClaudiu Manoil 	struct __qm_mcr_querycongestion state;
67c535e923SClaudiu Manoil } __packed;
68c535e923SClaudiu Manoil 
69c535e923SClaudiu Manoil /* "Query CGR" */
70c535e923SClaudiu Manoil struct qm_mcr_querycgr {
71c535e923SClaudiu Manoil 	u8 verb;
72c535e923SClaudiu Manoil 	u8 result;
73c535e923SClaudiu Manoil 	u16 __reserved1;
74c535e923SClaudiu Manoil 	struct __qm_mc_cgr cgr; /* CGR fields */
75c535e923SClaudiu Manoil 	u8 __reserved2[6];
76c535e923SClaudiu Manoil 	u8 i_bcnt_hi;	/* high 8-bits of 40-bit "Instant" */
7718058822SClaudiu Manoil 	__be32 i_bcnt_lo;	/* low 32-bits of 40-bit */
78c535e923SClaudiu Manoil 	u8 __reserved3[3];
79c535e923SClaudiu Manoil 	u8 a_bcnt_hi;	/* high 8-bits of 40-bit "Average" */
8018058822SClaudiu Manoil 	__be32 a_bcnt_lo;	/* low 32-bits of 40-bit */
8118058822SClaudiu Manoil 	__be32 cscn_targ_swp[4];
82c535e923SClaudiu Manoil } __packed;
83c535e923SClaudiu Manoil 
84c535e923SClaudiu Manoil static inline u64 qm_mcr_querycgr_i_get64(const struct qm_mcr_querycgr *q)
85c535e923SClaudiu Manoil {
8618058822SClaudiu Manoil 	return ((u64)q->i_bcnt_hi << 32) | be32_to_cpu(q->i_bcnt_lo);
87c535e923SClaudiu Manoil }
88c535e923SClaudiu Manoil static inline u64 qm_mcr_querycgr_a_get64(const struct qm_mcr_querycgr *q)
89c535e923SClaudiu Manoil {
9018058822SClaudiu Manoil 	return ((u64)q->a_bcnt_hi << 32) | be32_to_cpu(q->a_bcnt_lo);
91c535e923SClaudiu Manoil }
92c535e923SClaudiu Manoil 
93c535e923SClaudiu Manoil /* "Query FQ Non-Programmable Fields" */
94c535e923SClaudiu Manoil 
95c535e923SClaudiu Manoil struct qm_mcr_queryfq_np {
96c535e923SClaudiu Manoil 	u8 verb;
97c535e923SClaudiu Manoil 	u8 result;
98c535e923SClaudiu Manoil 	u8 __reserved1;
99c535e923SClaudiu Manoil 	u8 state;		/* QM_MCR_NP_STATE_*** */
100c535e923SClaudiu Manoil 	u32 fqd_link;		/* 24-bit, _res2[24-31] */
101c535e923SClaudiu Manoil 	u16 odp_seq;		/* 14-bit, _res3[14-15] */
102c535e923SClaudiu Manoil 	u16 orp_nesn;		/* 14-bit, _res4[14-15] */
103c535e923SClaudiu Manoil 	u16 orp_ea_hseq;	/* 15-bit, _res5[15] */
104c535e923SClaudiu Manoil 	u16 orp_ea_tseq;	/* 15-bit, _res6[15] */
105c535e923SClaudiu Manoil 	u32 orp_ea_hptr;	/* 24-bit, _res7[24-31] */
106c535e923SClaudiu Manoil 	u32 orp_ea_tptr;	/* 24-bit, _res8[24-31] */
107c535e923SClaudiu Manoil 	u32 pfdr_hptr;		/* 24-bit, _res9[24-31] */
108c535e923SClaudiu Manoil 	u32 pfdr_tptr;		/* 24-bit, _res10[24-31] */
109c535e923SClaudiu Manoil 	u8 __reserved2[5];
110c535e923SClaudiu Manoil 	u8 is;			/* 1-bit, _res12[1-7] */
111c535e923SClaudiu Manoil 	u16 ics_surp;
112c535e923SClaudiu Manoil 	u32 byte_cnt;
113c535e923SClaudiu Manoil 	u32 frm_cnt;		/* 24-bit, _res13[24-31] */
114c535e923SClaudiu Manoil 	u32 __reserved3;
115c535e923SClaudiu Manoil 	u16 ra1_sfdr;		/* QM_MCR_NP_RA1_*** */
116c535e923SClaudiu Manoil 	u16 ra2_sfdr;		/* QM_MCR_NP_RA2_*** */
117c535e923SClaudiu Manoil 	u16 __reserved4;
118c535e923SClaudiu Manoil 	u16 od1_sfdr;		/* QM_MCR_NP_OD1_*** */
119c535e923SClaudiu Manoil 	u16 od2_sfdr;		/* QM_MCR_NP_OD2_*** */
120c535e923SClaudiu Manoil 	u16 od3_sfdr;		/* QM_MCR_NP_OD3_*** */
121c535e923SClaudiu Manoil } __packed;
122c535e923SClaudiu Manoil 
123c535e923SClaudiu Manoil #define QM_MCR_NP_STATE_FE		0x10
124c535e923SClaudiu Manoil #define QM_MCR_NP_STATE_R		0x08
125c535e923SClaudiu Manoil #define QM_MCR_NP_STATE_MASK		0x07	/* Reads FQD::STATE; */
126c535e923SClaudiu Manoil #define QM_MCR_NP_STATE_OOS		0x00
127c535e923SClaudiu Manoil #define QM_MCR_NP_STATE_RETIRED		0x01
128c535e923SClaudiu Manoil #define QM_MCR_NP_STATE_TEN_SCHED	0x02
129c535e923SClaudiu Manoil #define QM_MCR_NP_STATE_TRU_SCHED	0x03
130c535e923SClaudiu Manoil #define QM_MCR_NP_STATE_PARKED		0x04
131c535e923SClaudiu Manoil #define QM_MCR_NP_STATE_ACTIVE		0x05
132c535e923SClaudiu Manoil #define QM_MCR_NP_PTR_MASK		0x07ff	/* for RA[12] & OD[123] */
133c535e923SClaudiu Manoil #define QM_MCR_NP_RA1_NRA(v)		(((v) >> 14) & 0x3)	/* FQD::NRA */
134c535e923SClaudiu Manoil #define QM_MCR_NP_RA2_IT(v)		(((v) >> 14) & 0x1)	/* FQD::IT */
135c535e923SClaudiu Manoil #define QM_MCR_NP_OD1_NOD(v)		(((v) >> 14) & 0x3)	/* FQD::NOD */
136c535e923SClaudiu Manoil #define QM_MCR_NP_OD3_NPC(v)		(((v) >> 14) & 0x3)	/* FQD::NPC */
137c535e923SClaudiu Manoil 
138c535e923SClaudiu Manoil enum qm_mcr_queryfq_np_masks {
139c535e923SClaudiu Manoil 	qm_mcr_fqd_link_mask = BIT(24)-1,
140c535e923SClaudiu Manoil 	qm_mcr_odp_seq_mask = BIT(14)-1,
141c535e923SClaudiu Manoil 	qm_mcr_orp_nesn_mask = BIT(14)-1,
142c535e923SClaudiu Manoil 	qm_mcr_orp_ea_hseq_mask = BIT(15)-1,
143c535e923SClaudiu Manoil 	qm_mcr_orp_ea_tseq_mask = BIT(15)-1,
144c535e923SClaudiu Manoil 	qm_mcr_orp_ea_hptr_mask = BIT(24)-1,
145c535e923SClaudiu Manoil 	qm_mcr_orp_ea_tptr_mask = BIT(24)-1,
146c535e923SClaudiu Manoil 	qm_mcr_pfdr_hptr_mask = BIT(24)-1,
147c535e923SClaudiu Manoil 	qm_mcr_pfdr_tptr_mask = BIT(24)-1,
148c535e923SClaudiu Manoil 	qm_mcr_is_mask = BIT(1)-1,
149c535e923SClaudiu Manoil 	qm_mcr_frm_cnt_mask = BIT(24)-1,
150c535e923SClaudiu Manoil };
151c535e923SClaudiu Manoil #define qm_mcr_np_get(np, field) \
152c535e923SClaudiu Manoil 	((np)->field & (qm_mcr_##field##_mask))
153c535e923SClaudiu Manoil 
154c535e923SClaudiu Manoil /* Congestion Groups */
155c535e923SClaudiu Manoil 
156c535e923SClaudiu Manoil /*
157c535e923SClaudiu Manoil  * This wrapper represents a bit-array for the state of the 256 QMan congestion
158c535e923SClaudiu Manoil  * groups. Is also used as a *mask* for congestion groups, eg. so we ignore
159c535e923SClaudiu Manoil  * those that don't concern us. We harness the structure and accessor details
160c535e923SClaudiu Manoil  * already used in the management command to query congestion groups.
161c535e923SClaudiu Manoil  */
162c535e923SClaudiu Manoil #define CGR_BITS_PER_WORD 5
163c535e923SClaudiu Manoil #define CGR_WORD(x)	((x) >> CGR_BITS_PER_WORD)
164c535e923SClaudiu Manoil #define CGR_BIT(x)	(BIT(31) >> ((x) & 0x1f))
165c535e923SClaudiu Manoil #define CGR_NUM	(sizeof(struct __qm_mcr_querycongestion) << 3)
166c535e923SClaudiu Manoil 
167c535e923SClaudiu Manoil struct qman_cgrs {
168c535e923SClaudiu Manoil 	struct __qm_mcr_querycongestion q;
169c535e923SClaudiu Manoil };
170c535e923SClaudiu Manoil 
171c535e923SClaudiu Manoil static inline void qman_cgrs_init(struct qman_cgrs *c)
172c535e923SClaudiu Manoil {
173c535e923SClaudiu Manoil 	memset(c, 0, sizeof(*c));
174c535e923SClaudiu Manoil }
175c535e923SClaudiu Manoil 
176c535e923SClaudiu Manoil static inline void qman_cgrs_fill(struct qman_cgrs *c)
177c535e923SClaudiu Manoil {
178c535e923SClaudiu Manoil 	memset(c, 0xff, sizeof(*c));
179c535e923SClaudiu Manoil }
180c535e923SClaudiu Manoil 
181c535e923SClaudiu Manoil static inline int qman_cgrs_get(struct qman_cgrs *c, u8 cgr)
182c535e923SClaudiu Manoil {
183c535e923SClaudiu Manoil 	return c->q.state[CGR_WORD(cgr)] & CGR_BIT(cgr);
184c535e923SClaudiu Manoil }
185c535e923SClaudiu Manoil 
186c535e923SClaudiu Manoil static inline void qman_cgrs_cp(struct qman_cgrs *dest,
187c535e923SClaudiu Manoil 				const struct qman_cgrs *src)
188c535e923SClaudiu Manoil {
189c535e923SClaudiu Manoil 	*dest = *src;
190c535e923SClaudiu Manoil }
191c535e923SClaudiu Manoil 
192c535e923SClaudiu Manoil static inline void qman_cgrs_and(struct qman_cgrs *dest,
193c535e923SClaudiu Manoil 			const struct qman_cgrs *a, const struct qman_cgrs *b)
194c535e923SClaudiu Manoil {
195c535e923SClaudiu Manoil 	int ret;
196c535e923SClaudiu Manoil 	u32 *_d = dest->q.state;
197c535e923SClaudiu Manoil 	const u32 *_a = a->q.state;
198c535e923SClaudiu Manoil 	const u32 *_b = b->q.state;
199c535e923SClaudiu Manoil 
200c535e923SClaudiu Manoil 	for (ret = 0; ret < 8; ret++)
201c535e923SClaudiu Manoil 		*_d++ = *_a++ & *_b++;
202c535e923SClaudiu Manoil }
203c535e923SClaudiu Manoil 
204c535e923SClaudiu Manoil static inline void qman_cgrs_xor(struct qman_cgrs *dest,
205c535e923SClaudiu Manoil 			const struct qman_cgrs *a, const struct qman_cgrs *b)
206c535e923SClaudiu Manoil {
207c535e923SClaudiu Manoil 	int ret;
208c535e923SClaudiu Manoil 	u32 *_d = dest->q.state;
209c535e923SClaudiu Manoil 	const u32 *_a = a->q.state;
210c535e923SClaudiu Manoil 	const u32 *_b = b->q.state;
211c535e923SClaudiu Manoil 
212c535e923SClaudiu Manoil 	for (ret = 0; ret < 8; ret++)
213c535e923SClaudiu Manoil 		*_d++ = *_a++ ^ *_b++;
214c535e923SClaudiu Manoil }
215c535e923SClaudiu Manoil 
216c535e923SClaudiu Manoil void qman_init_cgr_all(void);
217c535e923SClaudiu Manoil 
218c535e923SClaudiu Manoil struct qm_portal_config {
219c535e923SClaudiu Manoil 	/*
220c535e923SClaudiu Manoil 	 * Corenet portal addresses;
221c535e923SClaudiu Manoil 	 * [0]==cache-enabled, [1]==cache-inhibited.
222c535e923SClaudiu Manoil 	 */
223c535e923SClaudiu Manoil 	void __iomem *addr_virt[2];
224c535e923SClaudiu Manoil 	struct device *dev;
225c535e923SClaudiu Manoil 	struct iommu_domain *iommu_domain;
226c535e923SClaudiu Manoil 	/* Allow these to be joined in lists */
227c535e923SClaudiu Manoil 	struct list_head list;
228c535e923SClaudiu Manoil 	/* User-visible portal configuration settings */
229c535e923SClaudiu Manoil 	/* portal is affined to this cpu */
230c535e923SClaudiu Manoil 	int cpu;
231c535e923SClaudiu Manoil 	/* portal interrupt line */
232c535e923SClaudiu Manoil 	int irq;
233c535e923SClaudiu Manoil 	/*
234c535e923SClaudiu Manoil 	 * the portal's dedicated channel id, used initialising
235c535e923SClaudiu Manoil 	 * frame queues to target this portal when scheduled
236c535e923SClaudiu Manoil 	 */
237c535e923SClaudiu Manoil 	u16 channel;
238c535e923SClaudiu Manoil 	/*
239c535e923SClaudiu Manoil 	 * mask of pool channels this portal has dequeue access to
240c535e923SClaudiu Manoil 	 * (using QM_SDQCR_CHANNELS_POOL(n) for the bitmask)
241c535e923SClaudiu Manoil 	 */
242c535e923SClaudiu Manoil 	u32 pools;
243c535e923SClaudiu Manoil };
244c535e923SClaudiu Manoil 
245c535e923SClaudiu Manoil /* Revision info (for errata and feature handling) */
246c535e923SClaudiu Manoil #define QMAN_REV11 0x0101
247c535e923SClaudiu Manoil #define QMAN_REV12 0x0102
248c535e923SClaudiu Manoil #define QMAN_REV20 0x0200
249c535e923SClaudiu Manoil #define QMAN_REV30 0x0300
250c535e923SClaudiu Manoil #define QMAN_REV31 0x0301
251c535e923SClaudiu Manoil extern u16 qman_ip_rev; /* 0 if uninitialised, otherwise QMAN_REVx */
252c535e923SClaudiu Manoil 
253c535e923SClaudiu Manoil #define QM_FQID_RANGE_START 1 /* FQID 0 reserved for internal use */
254c535e923SClaudiu Manoil extern struct gen_pool *qm_fqalloc; /* FQID allocator */
255c535e923SClaudiu Manoil extern struct gen_pool *qm_qpalloc; /* pool-channel allocator */
256c535e923SClaudiu Manoil extern struct gen_pool *qm_cgralloc; /* CGR ID allocator */
257c535e923SClaudiu Manoil u32 qm_get_pools_sdqcr(void);
258c535e923SClaudiu Manoil 
259c535e923SClaudiu Manoil int qman_wq_alloc(void);
260c535e923SClaudiu Manoil void qman_liodn_fixup(u16 channel);
261c535e923SClaudiu Manoil void qman_set_sdest(u16 channel, unsigned int cpu_idx);
262c535e923SClaudiu Manoil 
263c535e923SClaudiu Manoil struct qman_portal *qman_create_affine_portal(
264c535e923SClaudiu Manoil 			const struct qm_portal_config *config,
265c535e923SClaudiu Manoil 			const struct qman_cgrs *cgrs);
266c535e923SClaudiu Manoil const struct qm_portal_config *qman_destroy_affine_portal(void);
267c535e923SClaudiu Manoil 
268c535e923SClaudiu Manoil /*
269c535e923SClaudiu Manoil  * qman_query_fq - Queries FQD fields (via h/w query command)
270c535e923SClaudiu Manoil  * @fq: the frame queue object to be queried
271c535e923SClaudiu Manoil  * @fqd: storage for the queried FQD fields
272c535e923SClaudiu Manoil  */
273c535e923SClaudiu Manoil int qman_query_fq(struct qman_fq *fq, struct qm_fqd *fqd);
274c535e923SClaudiu Manoil 
275c535e923SClaudiu Manoil /*
276c535e923SClaudiu Manoil  * For qman_volatile_dequeue(); Choose one PRECEDENCE. EXACT is optional. Use
277c535e923SClaudiu Manoil  * NUMFRAMES(n) (6-bit) or NUMFRAMES_TILLEMPTY to fill in the frame-count. Use
278c535e923SClaudiu Manoil  * FQID(n) to fill in the frame queue ID.
279c535e923SClaudiu Manoil  */
280c535e923SClaudiu Manoil #define QM_VDQCR_PRECEDENCE_VDQCR	0x0
281c535e923SClaudiu Manoil #define QM_VDQCR_PRECEDENCE_SDQCR	0x80000000
282c535e923SClaudiu Manoil #define QM_VDQCR_EXACT			0x40000000
283c535e923SClaudiu Manoil #define QM_VDQCR_NUMFRAMES_MASK		0x3f000000
284c535e923SClaudiu Manoil #define QM_VDQCR_NUMFRAMES_SET(n)	(((n) & 0x3f) << 24)
285c535e923SClaudiu Manoil #define QM_VDQCR_NUMFRAMES_GET(n)	(((n) >> 24) & 0x3f)
286c535e923SClaudiu Manoil #define QM_VDQCR_NUMFRAMES_TILLEMPTY	QM_VDQCR_NUMFRAMES_SET(0)
287c535e923SClaudiu Manoil 
288c535e923SClaudiu Manoil #define QMAN_VOLATILE_FLAG_WAIT	     0x00000001 /* wait if VDQCR is in use */
289c535e923SClaudiu Manoil #define QMAN_VOLATILE_FLAG_WAIT_INT  0x00000002 /* if wait, interruptible? */
290c535e923SClaudiu Manoil #define QMAN_VOLATILE_FLAG_FINISH    0x00000004 /* wait till VDQCR completes */
291c535e923SClaudiu Manoil 
292c535e923SClaudiu Manoil /*
293c535e923SClaudiu Manoil  * qman_volatile_dequeue - Issue a volatile dequeue command
294c535e923SClaudiu Manoil  * @fq: the frame queue object to dequeue from
295c535e923SClaudiu Manoil  * @flags: a bit-mask of QMAN_VOLATILE_FLAG_*** options
296c535e923SClaudiu Manoil  * @vdqcr: bit mask of QM_VDQCR_*** options, as per qm_dqrr_vdqcr_set()
297c535e923SClaudiu Manoil  *
298c535e923SClaudiu Manoil  * Attempts to lock access to the portal's VDQCR volatile dequeue functionality.
299c535e923SClaudiu Manoil  * The function will block and sleep if QMAN_VOLATILE_FLAG_WAIT is specified and
300c535e923SClaudiu Manoil  * the VDQCR is already in use, otherwise returns non-zero for failure. If
301c535e923SClaudiu Manoil  * QMAN_VOLATILE_FLAG_FINISH is specified, the function will only return once
302c535e923SClaudiu Manoil  * the VDQCR command has finished executing (ie. once the callback for the last
303c535e923SClaudiu Manoil  * DQRR entry resulting from the VDQCR command has been called). If not using
304c535e923SClaudiu Manoil  * the FINISH flag, completion can be determined either by detecting the
305c535e923SClaudiu Manoil  * presence of the QM_DQRR_STAT_UNSCHEDULED and QM_DQRR_STAT_DQCR_EXPIRED bits
306c535e923SClaudiu Manoil  * in the "stat" parameter passed to the FQ's dequeue callback, or by waiting
307c535e923SClaudiu Manoil  * for the QMAN_FQ_STATE_VDQCR bit to disappear.
308c535e923SClaudiu Manoil  */
309c535e923SClaudiu Manoil int qman_volatile_dequeue(struct qman_fq *fq, u32 flags, u32 vdqcr);
310c535e923SClaudiu Manoil 
311c535e923SClaudiu Manoil int qman_alloc_fq_table(u32 num_fqids);
312c535e923SClaudiu Manoil 
313c535e923SClaudiu Manoil /*   QMan s/w corenet portal, low-level i/face	 */
314c535e923SClaudiu Manoil 
315c535e923SClaudiu Manoil /*
316c535e923SClaudiu Manoil  * For qm_dqrr_sdqcr_set(); Choose one SOURCE. Choose one COUNT. Choose one
317c535e923SClaudiu Manoil  * dequeue TYPE. Choose TOKEN (8-bit).
318c535e923SClaudiu Manoil  * If SOURCE == CHANNELS,
319c535e923SClaudiu Manoil  *   Choose CHANNELS_DEDICATED and/or CHANNELS_POOL(n).
320c535e923SClaudiu Manoil  *   You can choose DEDICATED_PRECEDENCE if the portal channel should have
321c535e923SClaudiu Manoil  *   priority.
322c535e923SClaudiu Manoil  * If SOURCE == SPECIFICWQ,
323c535e923SClaudiu Manoil  *     Either select the work-queue ID with SPECIFICWQ_WQ(), or select the
324c535e923SClaudiu Manoil  *     channel (SPECIFICWQ_DEDICATED or SPECIFICWQ_POOL()) and specify the
325c535e923SClaudiu Manoil  *     work-queue priority (0-7) with SPECIFICWQ_WQ() - either way, you get the
326c535e923SClaudiu Manoil  *     same value.
327c535e923SClaudiu Manoil  */
328c535e923SClaudiu Manoil #define QM_SDQCR_SOURCE_CHANNELS	0x0
329c535e923SClaudiu Manoil #define QM_SDQCR_SOURCE_SPECIFICWQ	0x40000000
330c535e923SClaudiu Manoil #define QM_SDQCR_COUNT_EXACT1		0x0
331c535e923SClaudiu Manoil #define QM_SDQCR_COUNT_UPTO3		0x20000000
332c535e923SClaudiu Manoil #define QM_SDQCR_DEDICATED_PRECEDENCE	0x10000000
333c535e923SClaudiu Manoil #define QM_SDQCR_TYPE_MASK		0x03000000
334c535e923SClaudiu Manoil #define QM_SDQCR_TYPE_NULL		0x0
335c535e923SClaudiu Manoil #define QM_SDQCR_TYPE_PRIO_QOS		0x01000000
336c535e923SClaudiu Manoil #define QM_SDQCR_TYPE_ACTIVE_QOS	0x02000000
337c535e923SClaudiu Manoil #define QM_SDQCR_TYPE_ACTIVE		0x03000000
338c535e923SClaudiu Manoil #define QM_SDQCR_TOKEN_MASK		0x00ff0000
339c535e923SClaudiu Manoil #define QM_SDQCR_TOKEN_SET(v)		(((v) & 0xff) << 16)
340c535e923SClaudiu Manoil #define QM_SDQCR_TOKEN_GET(v)		(((v) >> 16) & 0xff)
341c535e923SClaudiu Manoil #define QM_SDQCR_CHANNELS_DEDICATED	0x00008000
342c535e923SClaudiu Manoil #define QM_SDQCR_SPECIFICWQ_MASK	0x000000f7
343c535e923SClaudiu Manoil #define QM_SDQCR_SPECIFICWQ_DEDICATED	0x00000000
344c535e923SClaudiu Manoil #define QM_SDQCR_SPECIFICWQ_POOL(n)	((n) << 4)
345c535e923SClaudiu Manoil #define QM_SDQCR_SPECIFICWQ_WQ(n)	(n)
346c535e923SClaudiu Manoil 
347c535e923SClaudiu Manoil /* For qm_dqrr_vdqcr_set(): use FQID(n) to fill in the frame queue ID */
348c535e923SClaudiu Manoil #define QM_VDQCR_FQID_MASK		0x00ffffff
349c535e923SClaudiu Manoil #define QM_VDQCR_FQID(n)		((n) & QM_VDQCR_FQID_MASK)
350c535e923SClaudiu Manoil 
351c535e923SClaudiu Manoil /*
352c535e923SClaudiu Manoil  * Used by all portal interrupt registers except 'inhibit'
353c535e923SClaudiu Manoil  * Channels with frame availability
354c535e923SClaudiu Manoil  */
355c535e923SClaudiu Manoil #define QM_PIRQ_DQAVAIL	0x0000ffff
356c535e923SClaudiu Manoil 
357c535e923SClaudiu Manoil /* The DQAVAIL interrupt fields break down into these bits; */
358c535e923SClaudiu Manoil #define QM_DQAVAIL_PORTAL	0x8000		/* Portal channel */
359c535e923SClaudiu Manoil #define QM_DQAVAIL_POOL(n)	(0x8000 >> (n))	/* Pool channel, n==[1..15] */
360c535e923SClaudiu Manoil #define QM_DQAVAIL_MASK		0xffff
361c535e923SClaudiu Manoil /* This mask contains all the "irqsource" bits visible to API users */
362c535e923SClaudiu Manoil #define QM_PIRQ_VISIBLE	(QM_PIRQ_SLOW | QM_PIRQ_DQRI)
363c535e923SClaudiu Manoil 
364c535e923SClaudiu Manoil extern struct qman_portal *affine_portals[NR_CPUS];
3650fbeac3bSClaudiu Manoil extern struct qman_portal *qman_dma_portal;
366c535e923SClaudiu Manoil const struct qm_portal_config *qman_get_qm_portal_config(
367c535e923SClaudiu Manoil 						struct qman_portal *portal);
368