1*4882a593Smuzhiyun /***********************license start***************
2*4882a593Smuzhiyun * Author: Cavium Networks
3*4882a593Smuzhiyun *
4*4882a593Smuzhiyun * Contact: support@caviumnetworks.com
5*4882a593Smuzhiyun * This file is part of the OCTEON SDK
6*4882a593Smuzhiyun *
7*4882a593Smuzhiyun * Copyright (c) 2003-2008 Cavium Networks
8*4882a593Smuzhiyun *
9*4882a593Smuzhiyun * This file is free software; you can redistribute it and/or modify
10*4882a593Smuzhiyun * it under the terms of the GNU General Public License, Version 2, as
11*4882a593Smuzhiyun * published by the Free Software Foundation.
12*4882a593Smuzhiyun *
13*4882a593Smuzhiyun * This file is distributed in the hope that it will be useful, but
14*4882a593Smuzhiyun * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
15*4882a593Smuzhiyun * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
16*4882a593Smuzhiyun * NONINFRINGEMENT. See the GNU General Public License for more
17*4882a593Smuzhiyun * details.
18*4882a593Smuzhiyun *
19*4882a593Smuzhiyun * You should have received a copy of the GNU General Public License
20*4882a593Smuzhiyun * along with this file; if not, write to the Free Software
21*4882a593Smuzhiyun * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22*4882a593Smuzhiyun * or visit http://www.gnu.org/licenses/.
23*4882a593Smuzhiyun *
24*4882a593Smuzhiyun * This file may also be available under a different license from Cavium.
25*4882a593Smuzhiyun * Contact Cavium Networks for more information
26*4882a593Smuzhiyun ***********************license end**************************************/
27*4882a593Smuzhiyun
28*4882a593Smuzhiyun /**
29*4882a593Smuzhiyun * Interface to the hardware Packet Order / Work unit.
30*4882a593Smuzhiyun *
31*4882a593Smuzhiyun * New, starting with SDK 1.7.0, cvmx-pow supports a number of
32*4882a593Smuzhiyun * extended consistency checks. The define
33*4882a593Smuzhiyun * CVMX_ENABLE_POW_CHECKS controls the runtime insertion of POW
34*4882a593Smuzhiyun * internal state checks to find common programming errors. If
35*4882a593Smuzhiyun * CVMX_ENABLE_POW_CHECKS is not defined, checks are by default
36*4882a593Smuzhiyun * enabled. For example, cvmx-pow will check for the following
37*4882a593Smuzhiyun * program errors or POW state inconsistency.
38*4882a593Smuzhiyun * - Requesting a POW operation with an active tag switch in
39*4882a593Smuzhiyun * progress.
40*4882a593Smuzhiyun * - Waiting for a tag switch to complete for an excessively
41*4882a593Smuzhiyun * long period. This is normally a sign of an error in locking
42*4882a593Smuzhiyun * causing deadlock.
43*4882a593Smuzhiyun * - Illegal tag switches from NULL_NULL.
44*4882a593Smuzhiyun * - Illegal tag switches from NULL.
45*4882a593Smuzhiyun * - Illegal deschedule request.
46*4882a593Smuzhiyun * - WQE pointer not matching the one attached to the core by
47*4882a593Smuzhiyun * the POW.
48*4882a593Smuzhiyun *
49*4882a593Smuzhiyun */
50*4882a593Smuzhiyun
51*4882a593Smuzhiyun #ifndef __CVMX_POW_H__
52*4882a593Smuzhiyun #define __CVMX_POW_H__
53*4882a593Smuzhiyun
54*4882a593Smuzhiyun #include <asm/octeon/cvmx-pow-defs.h>
55*4882a593Smuzhiyun
56*4882a593Smuzhiyun #include <asm/octeon/cvmx-scratch.h>
57*4882a593Smuzhiyun #include <asm/octeon/cvmx-wqe.h>
58*4882a593Smuzhiyun
59*4882a593Smuzhiyun /* Default to having all POW constancy checks turned on */
60*4882a593Smuzhiyun #ifndef CVMX_ENABLE_POW_CHECKS
61*4882a593Smuzhiyun #define CVMX_ENABLE_POW_CHECKS 1
62*4882a593Smuzhiyun #endif
63*4882a593Smuzhiyun
64*4882a593Smuzhiyun enum cvmx_pow_tag_type {
65*4882a593Smuzhiyun /* Tag ordering is maintained */
66*4882a593Smuzhiyun CVMX_POW_TAG_TYPE_ORDERED = 0L,
67*4882a593Smuzhiyun /* Tag ordering is maintained, and at most one PP has the tag */
68*4882a593Smuzhiyun CVMX_POW_TAG_TYPE_ATOMIC = 1L,
69*4882a593Smuzhiyun /*
70*4882a593Smuzhiyun * The work queue entry from the order - NEVER tag switch from
71*4882a593Smuzhiyun * NULL to NULL
72*4882a593Smuzhiyun */
73*4882a593Smuzhiyun CVMX_POW_TAG_TYPE_NULL = 2L,
74*4882a593Smuzhiyun /* A tag switch to NULL, and there is no space reserved in POW
75*4882a593Smuzhiyun * - NEVER tag switch to NULL_NULL
76*4882a593Smuzhiyun * - NEVER tag switch from NULL_NULL
77*4882a593Smuzhiyun * - NULL_NULL is entered at the beginning of time and on a deschedule.
78*4882a593Smuzhiyun * - NULL_NULL can be exited by a new work request. A NULL_SWITCH
79*4882a593Smuzhiyun * load can also switch the state to NULL
80*4882a593Smuzhiyun */
81*4882a593Smuzhiyun CVMX_POW_TAG_TYPE_NULL_NULL = 3L
82*4882a593Smuzhiyun };
83*4882a593Smuzhiyun
84*4882a593Smuzhiyun /**
85*4882a593Smuzhiyun * Wait flag values for pow functions.
86*4882a593Smuzhiyun */
87*4882a593Smuzhiyun typedef enum {
88*4882a593Smuzhiyun CVMX_POW_WAIT = 1,
89*4882a593Smuzhiyun CVMX_POW_NO_WAIT = 0,
90*4882a593Smuzhiyun } cvmx_pow_wait_t;
91*4882a593Smuzhiyun
92*4882a593Smuzhiyun /**
93*4882a593Smuzhiyun * POW tag operations. These are used in the data stored to the POW.
94*4882a593Smuzhiyun */
95*4882a593Smuzhiyun typedef enum {
96*4882a593Smuzhiyun /*
97*4882a593Smuzhiyun * switch the tag (only) for this PP
98*4882a593Smuzhiyun * - the previous tag should be non-NULL in this case
99*4882a593Smuzhiyun * - tag switch response required
100*4882a593Smuzhiyun * - fields used: op, type, tag
101*4882a593Smuzhiyun */
102*4882a593Smuzhiyun CVMX_POW_TAG_OP_SWTAG = 0L,
103*4882a593Smuzhiyun /*
104*4882a593Smuzhiyun * switch the tag for this PP, with full information
105*4882a593Smuzhiyun * - this should be used when the previous tag is NULL
106*4882a593Smuzhiyun * - tag switch response required
107*4882a593Smuzhiyun * - fields used: address, op, grp, type, tag
108*4882a593Smuzhiyun */
109*4882a593Smuzhiyun CVMX_POW_TAG_OP_SWTAG_FULL = 1L,
110*4882a593Smuzhiyun /*
111*4882a593Smuzhiyun * switch the tag (and/or group) for this PP and de-schedule
112*4882a593Smuzhiyun * - OK to keep the tag the same and only change the group
113*4882a593Smuzhiyun * - fields used: op, no_sched, grp, type, tag
114*4882a593Smuzhiyun */
115*4882a593Smuzhiyun CVMX_POW_TAG_OP_SWTAG_DESCH = 2L,
116*4882a593Smuzhiyun /*
117*4882a593Smuzhiyun * just de-schedule
118*4882a593Smuzhiyun * - fields used: op, no_sched
119*4882a593Smuzhiyun */
120*4882a593Smuzhiyun CVMX_POW_TAG_OP_DESCH = 3L,
121*4882a593Smuzhiyun /*
122*4882a593Smuzhiyun * create an entirely new work queue entry
123*4882a593Smuzhiyun * - fields used: address, op, qos, grp, type, tag
124*4882a593Smuzhiyun */
125*4882a593Smuzhiyun CVMX_POW_TAG_OP_ADDWQ = 4L,
126*4882a593Smuzhiyun /*
127*4882a593Smuzhiyun * just update the work queue pointer and grp for this PP
128*4882a593Smuzhiyun * - fields used: address, op, grp
129*4882a593Smuzhiyun */
130*4882a593Smuzhiyun CVMX_POW_TAG_OP_UPDATE_WQP_GRP = 5L,
131*4882a593Smuzhiyun /*
132*4882a593Smuzhiyun * set the no_sched bit on the de-schedule list
133*4882a593Smuzhiyun *
134*4882a593Smuzhiyun * - does nothing if the selected entry is not on the
135*4882a593Smuzhiyun * de-schedule list
136*4882a593Smuzhiyun *
137*4882a593Smuzhiyun * - does nothing if the stored work queue pointer does not
138*4882a593Smuzhiyun * match the address field
139*4882a593Smuzhiyun *
140*4882a593Smuzhiyun * - fields used: address, index, op
141*4882a593Smuzhiyun *
142*4882a593Smuzhiyun * Before issuing a *_NSCHED operation, SW must guarantee
143*4882a593Smuzhiyun * that all prior deschedules and set/clr NSCHED operations
144*4882a593Smuzhiyun * are complete and all prior switches are complete. The
145*4882a593Smuzhiyun * hardware provides the opsdone bit and swdone bit for SW
146*4882a593Smuzhiyun * polling. After issuing a *_NSCHED operation, SW must
147*4882a593Smuzhiyun * guarantee that the set/clr NSCHED is complete before any
148*4882a593Smuzhiyun * subsequent operations.
149*4882a593Smuzhiyun */
150*4882a593Smuzhiyun CVMX_POW_TAG_OP_SET_NSCHED = 6L,
151*4882a593Smuzhiyun /*
152*4882a593Smuzhiyun * clears the no_sched bit on the de-schedule list
153*4882a593Smuzhiyun *
154*4882a593Smuzhiyun * - does nothing if the selected entry is not on the
155*4882a593Smuzhiyun * de-schedule list
156*4882a593Smuzhiyun *
157*4882a593Smuzhiyun * - does nothing if the stored work queue pointer does not
158*4882a593Smuzhiyun * match the address field
159*4882a593Smuzhiyun *
160*4882a593Smuzhiyun * - fields used: address, index, op
161*4882a593Smuzhiyun *
162*4882a593Smuzhiyun * Before issuing a *_NSCHED operation, SW must guarantee that
163*4882a593Smuzhiyun * all prior deschedules and set/clr NSCHED operations are
164*4882a593Smuzhiyun * complete and all prior switches are complete. The hardware
165*4882a593Smuzhiyun * provides the opsdone bit and swdone bit for SW
166*4882a593Smuzhiyun * polling. After issuing a *_NSCHED operation, SW must
167*4882a593Smuzhiyun * guarantee that the set/clr NSCHED is complete before any
168*4882a593Smuzhiyun * subsequent operations.
169*4882a593Smuzhiyun */
170*4882a593Smuzhiyun CVMX_POW_TAG_OP_CLR_NSCHED = 7L,
171*4882a593Smuzhiyun /* do nothing */
172*4882a593Smuzhiyun CVMX_POW_TAG_OP_NOP = 15L
173*4882a593Smuzhiyun } cvmx_pow_tag_op_t;
174*4882a593Smuzhiyun
175*4882a593Smuzhiyun /**
176*4882a593Smuzhiyun * This structure defines the store data on a store to POW
177*4882a593Smuzhiyun */
178*4882a593Smuzhiyun typedef union {
179*4882a593Smuzhiyun uint64_t u64;
180*4882a593Smuzhiyun struct {
181*4882a593Smuzhiyun #ifdef __BIG_ENDIAN_BITFIELD
182*4882a593Smuzhiyun /*
183*4882a593Smuzhiyun * Don't reschedule this entry. no_sched is used for
184*4882a593Smuzhiyun * CVMX_POW_TAG_OP_SWTAG_DESCH and
185*4882a593Smuzhiyun * CVMX_POW_TAG_OP_DESCH
186*4882a593Smuzhiyun */
187*4882a593Smuzhiyun uint64_t no_sched:1;
188*4882a593Smuzhiyun uint64_t unused:2;
189*4882a593Smuzhiyun /* Tontains index of entry for a CVMX_POW_TAG_OP_*_NSCHED */
190*4882a593Smuzhiyun uint64_t index:13;
191*4882a593Smuzhiyun /* The operation to perform */
192*4882a593Smuzhiyun cvmx_pow_tag_op_t op:4;
193*4882a593Smuzhiyun uint64_t unused2:2;
194*4882a593Smuzhiyun /*
195*4882a593Smuzhiyun * The QOS level for the packet. qos is only used for
196*4882a593Smuzhiyun * CVMX_POW_TAG_OP_ADDWQ
197*4882a593Smuzhiyun */
198*4882a593Smuzhiyun uint64_t qos:3;
199*4882a593Smuzhiyun /*
200*4882a593Smuzhiyun * The group that the work queue entry will be
201*4882a593Smuzhiyun * scheduled to grp is used for CVMX_POW_TAG_OP_ADDWQ,
202*4882a593Smuzhiyun * CVMX_POW_TAG_OP_SWTAG_FULL,
203*4882a593Smuzhiyun * CVMX_POW_TAG_OP_SWTAG_DESCH, and
204*4882a593Smuzhiyun * CVMX_POW_TAG_OP_UPDATE_WQP_GRP
205*4882a593Smuzhiyun */
206*4882a593Smuzhiyun uint64_t grp:4;
207*4882a593Smuzhiyun /*
208*4882a593Smuzhiyun * The type of the tag. type is used for everything
209*4882a593Smuzhiyun * except CVMX_POW_TAG_OP_DESCH,
210*4882a593Smuzhiyun * CVMX_POW_TAG_OP_UPDATE_WQP_GRP, and
211*4882a593Smuzhiyun * CVMX_POW_TAG_OP_*_NSCHED
212*4882a593Smuzhiyun */
213*4882a593Smuzhiyun uint64_t type:3;
214*4882a593Smuzhiyun /*
215*4882a593Smuzhiyun * The actual tag. tag is used for everything except
216*4882a593Smuzhiyun * CVMX_POW_TAG_OP_DESCH,
217*4882a593Smuzhiyun * CVMX_POW_TAG_OP_UPDATE_WQP_GRP, and
218*4882a593Smuzhiyun * CVMX_POW_TAG_OP_*_NSCHED
219*4882a593Smuzhiyun */
220*4882a593Smuzhiyun uint64_t tag:32;
221*4882a593Smuzhiyun #else
222*4882a593Smuzhiyun uint64_t tag:32;
223*4882a593Smuzhiyun uint64_t type:3;
224*4882a593Smuzhiyun uint64_t grp:4;
225*4882a593Smuzhiyun uint64_t qos:3;
226*4882a593Smuzhiyun uint64_t unused2:2;
227*4882a593Smuzhiyun cvmx_pow_tag_op_t op:4;
228*4882a593Smuzhiyun uint64_t index:13;
229*4882a593Smuzhiyun uint64_t unused:2;
230*4882a593Smuzhiyun uint64_t no_sched:1;
231*4882a593Smuzhiyun #endif
232*4882a593Smuzhiyun } s;
233*4882a593Smuzhiyun } cvmx_pow_tag_req_t;
234*4882a593Smuzhiyun
235*4882a593Smuzhiyun /**
236*4882a593Smuzhiyun * This structure describes the address to load stuff from POW
237*4882a593Smuzhiyun */
238*4882a593Smuzhiyun typedef union {
239*4882a593Smuzhiyun uint64_t u64;
240*4882a593Smuzhiyun
241*4882a593Smuzhiyun /**
242*4882a593Smuzhiyun * Address for new work request loads (did<2:0> == 0)
243*4882a593Smuzhiyun */
244*4882a593Smuzhiyun struct {
245*4882a593Smuzhiyun #ifdef __BIG_ENDIAN_BITFIELD
246*4882a593Smuzhiyun /* Mips64 address region. Should be CVMX_IO_SEG */
247*4882a593Smuzhiyun uint64_t mem_region:2;
248*4882a593Smuzhiyun /* Must be zero */
249*4882a593Smuzhiyun uint64_t reserved_49_61:13;
250*4882a593Smuzhiyun /* Must be one */
251*4882a593Smuzhiyun uint64_t is_io:1;
252*4882a593Smuzhiyun /* the ID of POW -- did<2:0> == 0 in this case */
253*4882a593Smuzhiyun uint64_t did:8;
254*4882a593Smuzhiyun /* Must be zero */
255*4882a593Smuzhiyun uint64_t reserved_4_39:36;
256*4882a593Smuzhiyun /*
257*4882a593Smuzhiyun * If set, don't return load response until work is
258*4882a593Smuzhiyun * available.
259*4882a593Smuzhiyun */
260*4882a593Smuzhiyun uint64_t wait:1;
261*4882a593Smuzhiyun /* Must be zero */
262*4882a593Smuzhiyun uint64_t reserved_0_2:3;
263*4882a593Smuzhiyun #else
264*4882a593Smuzhiyun uint64_t reserved_0_2:3;
265*4882a593Smuzhiyun uint64_t wait:1;
266*4882a593Smuzhiyun uint64_t reserved_4_39:36;
267*4882a593Smuzhiyun uint64_t did:8;
268*4882a593Smuzhiyun uint64_t is_io:1;
269*4882a593Smuzhiyun uint64_t reserved_49_61:13;
270*4882a593Smuzhiyun uint64_t mem_region:2;
271*4882a593Smuzhiyun #endif
272*4882a593Smuzhiyun } swork;
273*4882a593Smuzhiyun
274*4882a593Smuzhiyun /**
275*4882a593Smuzhiyun * Address for loads to get POW internal status
276*4882a593Smuzhiyun */
277*4882a593Smuzhiyun struct {
278*4882a593Smuzhiyun #ifdef __BIG_ENDIAN_BITFIELD
279*4882a593Smuzhiyun /* Mips64 address region. Should be CVMX_IO_SEG */
280*4882a593Smuzhiyun uint64_t mem_region:2;
281*4882a593Smuzhiyun /* Must be zero */
282*4882a593Smuzhiyun uint64_t reserved_49_61:13;
283*4882a593Smuzhiyun /* Must be one */
284*4882a593Smuzhiyun uint64_t is_io:1;
285*4882a593Smuzhiyun /* the ID of POW -- did<2:0> == 1 in this case */
286*4882a593Smuzhiyun uint64_t did:8;
287*4882a593Smuzhiyun /* Must be zero */
288*4882a593Smuzhiyun uint64_t reserved_10_39:30;
289*4882a593Smuzhiyun /* The core id to get status for */
290*4882a593Smuzhiyun uint64_t coreid:4;
291*4882a593Smuzhiyun /*
292*4882a593Smuzhiyun * If set and get_cur is set, return reverse tag-list
293*4882a593Smuzhiyun * pointer rather than forward tag-list pointer.
294*4882a593Smuzhiyun */
295*4882a593Smuzhiyun uint64_t get_rev:1;
296*4882a593Smuzhiyun /*
297*4882a593Smuzhiyun * If set, return current status rather than pending
298*4882a593Smuzhiyun * status.
299*4882a593Smuzhiyun */
300*4882a593Smuzhiyun uint64_t get_cur:1;
301*4882a593Smuzhiyun /*
302*4882a593Smuzhiyun * If set, get the work-queue pointer rather than
303*4882a593Smuzhiyun * tag/type.
304*4882a593Smuzhiyun */
305*4882a593Smuzhiyun uint64_t get_wqp:1;
306*4882a593Smuzhiyun /* Must be zero */
307*4882a593Smuzhiyun uint64_t reserved_0_2:3;
308*4882a593Smuzhiyun #else
309*4882a593Smuzhiyun uint64_t reserved_0_2:3;
310*4882a593Smuzhiyun uint64_t get_wqp:1;
311*4882a593Smuzhiyun uint64_t get_cur:1;
312*4882a593Smuzhiyun uint64_t get_rev:1;
313*4882a593Smuzhiyun uint64_t coreid:4;
314*4882a593Smuzhiyun uint64_t reserved_10_39:30;
315*4882a593Smuzhiyun uint64_t did:8;
316*4882a593Smuzhiyun uint64_t is_io:1;
317*4882a593Smuzhiyun uint64_t reserved_49_61:13;
318*4882a593Smuzhiyun uint64_t mem_region:2;
319*4882a593Smuzhiyun #endif
320*4882a593Smuzhiyun } sstatus;
321*4882a593Smuzhiyun
322*4882a593Smuzhiyun /**
323*4882a593Smuzhiyun * Address for memory loads to get POW internal state
324*4882a593Smuzhiyun */
325*4882a593Smuzhiyun struct {
326*4882a593Smuzhiyun #ifdef __BIG_ENDIAN_BITFIELD
327*4882a593Smuzhiyun /* Mips64 address region. Should be CVMX_IO_SEG */
328*4882a593Smuzhiyun uint64_t mem_region:2;
329*4882a593Smuzhiyun /* Must be zero */
330*4882a593Smuzhiyun uint64_t reserved_49_61:13;
331*4882a593Smuzhiyun /* Must be one */
332*4882a593Smuzhiyun uint64_t is_io:1;
333*4882a593Smuzhiyun /* the ID of POW -- did<2:0> == 2 in this case */
334*4882a593Smuzhiyun uint64_t did:8;
335*4882a593Smuzhiyun /* Must be zero */
336*4882a593Smuzhiyun uint64_t reserved_16_39:24;
337*4882a593Smuzhiyun /* POW memory index */
338*4882a593Smuzhiyun uint64_t index:11;
339*4882a593Smuzhiyun /*
340*4882a593Smuzhiyun * If set, return deschedule information rather than
341*4882a593Smuzhiyun * the standard response for work-queue index (invalid
342*4882a593Smuzhiyun * if the work-queue entry is not on the deschedule
343*4882a593Smuzhiyun * list).
344*4882a593Smuzhiyun */
345*4882a593Smuzhiyun uint64_t get_des:1;
346*4882a593Smuzhiyun /*
347*4882a593Smuzhiyun * If set, get the work-queue pointer rather than
348*4882a593Smuzhiyun * tag/type (no effect when get_des set).
349*4882a593Smuzhiyun */
350*4882a593Smuzhiyun uint64_t get_wqp:1;
351*4882a593Smuzhiyun /* Must be zero */
352*4882a593Smuzhiyun uint64_t reserved_0_2:3;
353*4882a593Smuzhiyun #else
354*4882a593Smuzhiyun uint64_t reserved_0_2:3;
355*4882a593Smuzhiyun uint64_t get_wqp:1;
356*4882a593Smuzhiyun uint64_t get_des:1;
357*4882a593Smuzhiyun uint64_t index:11;
358*4882a593Smuzhiyun uint64_t reserved_16_39:24;
359*4882a593Smuzhiyun uint64_t did:8;
360*4882a593Smuzhiyun uint64_t is_io:1;
361*4882a593Smuzhiyun uint64_t reserved_49_61:13;
362*4882a593Smuzhiyun uint64_t mem_region:2;
363*4882a593Smuzhiyun #endif
364*4882a593Smuzhiyun } smemload;
365*4882a593Smuzhiyun
366*4882a593Smuzhiyun /**
367*4882a593Smuzhiyun * Address for index/pointer loads
368*4882a593Smuzhiyun */
369*4882a593Smuzhiyun struct {
370*4882a593Smuzhiyun #ifdef __BIG_ENDIAN_BITFIELD
371*4882a593Smuzhiyun /* Mips64 address region. Should be CVMX_IO_SEG */
372*4882a593Smuzhiyun uint64_t mem_region:2;
373*4882a593Smuzhiyun /* Must be zero */
374*4882a593Smuzhiyun uint64_t reserved_49_61:13;
375*4882a593Smuzhiyun /* Must be one */
376*4882a593Smuzhiyun uint64_t is_io:1;
377*4882a593Smuzhiyun /* the ID of POW -- did<2:0> == 3 in this case */
378*4882a593Smuzhiyun uint64_t did:8;
379*4882a593Smuzhiyun /* Must be zero */
380*4882a593Smuzhiyun uint64_t reserved_9_39:31;
381*4882a593Smuzhiyun /*
382*4882a593Smuzhiyun * when {get_rmt ==0 AND get_des_get_tail == 0}, this
383*4882a593Smuzhiyun * field selects one of eight POW internal-input
384*4882a593Smuzhiyun * queues (0-7), one per QOS level; values 8-15 are
385*4882a593Smuzhiyun * illegal in this case; when {get_rmt ==0 AND
386*4882a593Smuzhiyun * get_des_get_tail == 1}, this field selects one of
387*4882a593Smuzhiyun * 16 deschedule lists (per group); when get_rmt ==1,
388*4882a593Smuzhiyun * this field selects one of 16 memory-input queue
389*4882a593Smuzhiyun * lists. The two memory-input queue lists associated
390*4882a593Smuzhiyun * with each QOS level are:
391*4882a593Smuzhiyun *
392*4882a593Smuzhiyun * - qosgrp = 0, qosgrp = 8: QOS0
393*4882a593Smuzhiyun * - qosgrp = 1, qosgrp = 9: QOS1
394*4882a593Smuzhiyun * - qosgrp = 2, qosgrp = 10: QOS2
395*4882a593Smuzhiyun * - qosgrp = 3, qosgrp = 11: QOS3
396*4882a593Smuzhiyun * - qosgrp = 4, qosgrp = 12: QOS4
397*4882a593Smuzhiyun * - qosgrp = 5, qosgrp = 13: QOS5
398*4882a593Smuzhiyun * - qosgrp = 6, qosgrp = 14: QOS6
399*4882a593Smuzhiyun * - qosgrp = 7, qosgrp = 15: QOS7
400*4882a593Smuzhiyun */
401*4882a593Smuzhiyun uint64_t qosgrp:4;
402*4882a593Smuzhiyun /*
403*4882a593Smuzhiyun * If set and get_rmt is clear, return deschedule list
404*4882a593Smuzhiyun * indexes rather than indexes for the specified qos
405*4882a593Smuzhiyun * level; if set and get_rmt is set, return the tail
406*4882a593Smuzhiyun * pointer rather than the head pointer for the
407*4882a593Smuzhiyun * specified qos level.
408*4882a593Smuzhiyun */
409*4882a593Smuzhiyun uint64_t get_des_get_tail:1;
410*4882a593Smuzhiyun /*
411*4882a593Smuzhiyun * If set, return remote pointers rather than the
412*4882a593Smuzhiyun * local indexes for the specified qos level.
413*4882a593Smuzhiyun */
414*4882a593Smuzhiyun uint64_t get_rmt:1;
415*4882a593Smuzhiyun /* Must be zero */
416*4882a593Smuzhiyun uint64_t reserved_0_2:3;
417*4882a593Smuzhiyun #else
418*4882a593Smuzhiyun uint64_t reserved_0_2:3;
419*4882a593Smuzhiyun uint64_t get_rmt:1;
420*4882a593Smuzhiyun uint64_t get_des_get_tail:1;
421*4882a593Smuzhiyun uint64_t qosgrp:4;
422*4882a593Smuzhiyun uint64_t reserved_9_39:31;
423*4882a593Smuzhiyun uint64_t did:8;
424*4882a593Smuzhiyun uint64_t is_io:1;
425*4882a593Smuzhiyun uint64_t reserved_49_61:13;
426*4882a593Smuzhiyun uint64_t mem_region:2;
427*4882a593Smuzhiyun #endif
428*4882a593Smuzhiyun } sindexload;
429*4882a593Smuzhiyun
430*4882a593Smuzhiyun /**
431*4882a593Smuzhiyun * address for NULL_RD request (did<2:0> == 4) when this is read,
432*4882a593Smuzhiyun * HW attempts to change the state to NULL if it is NULL_NULL (the
433*4882a593Smuzhiyun * hardware cannot switch from NULL_NULL to NULL if a POW entry is
434*4882a593Smuzhiyun * not available - software may need to recover by finishing
435*4882a593Smuzhiyun * another piece of work before a POW entry can ever become
436*4882a593Smuzhiyun * available.)
437*4882a593Smuzhiyun */
438*4882a593Smuzhiyun struct {
439*4882a593Smuzhiyun #ifdef __BIG_ENDIAN_BITFIELD
440*4882a593Smuzhiyun /* Mips64 address region. Should be CVMX_IO_SEG */
441*4882a593Smuzhiyun uint64_t mem_region:2;
442*4882a593Smuzhiyun /* Must be zero */
443*4882a593Smuzhiyun uint64_t reserved_49_61:13;
444*4882a593Smuzhiyun /* Must be one */
445*4882a593Smuzhiyun uint64_t is_io:1;
446*4882a593Smuzhiyun /* the ID of POW -- did<2:0> == 4 in this case */
447*4882a593Smuzhiyun uint64_t did:8;
448*4882a593Smuzhiyun /* Must be zero */
449*4882a593Smuzhiyun uint64_t reserved_0_39:40;
450*4882a593Smuzhiyun #else
451*4882a593Smuzhiyun uint64_t reserved_0_39:40;
452*4882a593Smuzhiyun uint64_t did:8;
453*4882a593Smuzhiyun uint64_t is_io:1;
454*4882a593Smuzhiyun uint64_t reserved_49_61:13;
455*4882a593Smuzhiyun uint64_t mem_region:2;
456*4882a593Smuzhiyun #endif
457*4882a593Smuzhiyun } snull_rd;
458*4882a593Smuzhiyun } cvmx_pow_load_addr_t;
459*4882a593Smuzhiyun
460*4882a593Smuzhiyun /**
461*4882a593Smuzhiyun * This structure defines the response to a load/SENDSINGLE to POW
462*4882a593Smuzhiyun * (except CSR reads)
463*4882a593Smuzhiyun */
464*4882a593Smuzhiyun typedef union {
465*4882a593Smuzhiyun uint64_t u64;
466*4882a593Smuzhiyun
467*4882a593Smuzhiyun /**
468*4882a593Smuzhiyun * Response to new work request loads
469*4882a593Smuzhiyun */
470*4882a593Smuzhiyun struct {
471*4882a593Smuzhiyun #ifdef __BIG_ENDIAN_BITFIELD
472*4882a593Smuzhiyun /*
473*4882a593Smuzhiyun * Set when no new work queue entry was returned. *
474*4882a593Smuzhiyun * If there was de-scheduled work, the HW will
475*4882a593Smuzhiyun * definitely return it. When this bit is set, it
476*4882a593Smuzhiyun * could mean either mean:
477*4882a593Smuzhiyun *
478*4882a593Smuzhiyun * - There was no work, or
479*4882a593Smuzhiyun *
480*4882a593Smuzhiyun * - There was no work that the HW could find. This
481*4882a593Smuzhiyun * case can happen, regardless of the wait bit value
482*4882a593Smuzhiyun * in the original request, when there is work in
483*4882a593Smuzhiyun * the IQ's that is too deep down the list.
484*4882a593Smuzhiyun */
485*4882a593Smuzhiyun uint64_t no_work:1;
486*4882a593Smuzhiyun /* Must be zero */
487*4882a593Smuzhiyun uint64_t reserved_40_62:23;
488*4882a593Smuzhiyun /* 36 in O1 -- the work queue pointer */
489*4882a593Smuzhiyun uint64_t addr:40;
490*4882a593Smuzhiyun #else
491*4882a593Smuzhiyun uint64_t addr:40;
492*4882a593Smuzhiyun uint64_t reserved_40_62:23;
493*4882a593Smuzhiyun uint64_t no_work:1;
494*4882a593Smuzhiyun #endif
495*4882a593Smuzhiyun } s_work;
496*4882a593Smuzhiyun
497*4882a593Smuzhiyun /**
498*4882a593Smuzhiyun * Result for a POW Status Load (when get_cur==0 and get_wqp==0)
499*4882a593Smuzhiyun */
500*4882a593Smuzhiyun struct {
501*4882a593Smuzhiyun #ifdef __BIG_ENDIAN_BITFIELD
502*4882a593Smuzhiyun uint64_t reserved_62_63:2;
503*4882a593Smuzhiyun /* Set when there is a pending non-NULL SWTAG or
504*4882a593Smuzhiyun * SWTAG_FULL, and the POW entry has not left the list
505*4882a593Smuzhiyun * for the original tag. */
506*4882a593Smuzhiyun uint64_t pend_switch:1;
507*4882a593Smuzhiyun /* Set when SWTAG_FULL and pend_switch is set. */
508*4882a593Smuzhiyun uint64_t pend_switch_full:1;
509*4882a593Smuzhiyun /*
510*4882a593Smuzhiyun * Set when there is a pending NULL SWTAG, or an
511*4882a593Smuzhiyun * implicit switch to NULL.
512*4882a593Smuzhiyun */
513*4882a593Smuzhiyun uint64_t pend_switch_null:1;
514*4882a593Smuzhiyun /* Set when there is a pending DESCHED or SWTAG_DESCHED. */
515*4882a593Smuzhiyun uint64_t pend_desched:1;
516*4882a593Smuzhiyun /*
517*4882a593Smuzhiyun * Set when there is a pending SWTAG_DESCHED and
518*4882a593Smuzhiyun * pend_desched is set.
519*4882a593Smuzhiyun */
520*4882a593Smuzhiyun uint64_t pend_desched_switch:1;
521*4882a593Smuzhiyun /* Set when nosched is desired and pend_desched is set. */
522*4882a593Smuzhiyun uint64_t pend_nosched:1;
523*4882a593Smuzhiyun /* Set when there is a pending GET_WORK. */
524*4882a593Smuzhiyun uint64_t pend_new_work:1;
525*4882a593Smuzhiyun /*
526*4882a593Smuzhiyun * When pend_new_work is set, this bit indicates that
527*4882a593Smuzhiyun * the wait bit was set.
528*4882a593Smuzhiyun */
529*4882a593Smuzhiyun uint64_t pend_new_work_wait:1;
530*4882a593Smuzhiyun /* Set when there is a pending NULL_RD. */
531*4882a593Smuzhiyun uint64_t pend_null_rd:1;
532*4882a593Smuzhiyun /* Set when there is a pending CLR_NSCHED. */
533*4882a593Smuzhiyun uint64_t pend_nosched_clr:1;
534*4882a593Smuzhiyun uint64_t reserved_51:1;
535*4882a593Smuzhiyun /* This is the index when pend_nosched_clr is set. */
536*4882a593Smuzhiyun uint64_t pend_index:11;
537*4882a593Smuzhiyun /*
538*4882a593Smuzhiyun * This is the new_grp when (pend_desched AND
539*4882a593Smuzhiyun * pend_desched_switch) is set.
540*4882a593Smuzhiyun */
541*4882a593Smuzhiyun uint64_t pend_grp:4;
542*4882a593Smuzhiyun uint64_t reserved_34_35:2;
543*4882a593Smuzhiyun /*
544*4882a593Smuzhiyun * This is the tag type when pend_switch or
545*4882a593Smuzhiyun * (pend_desched AND pend_desched_switch) are set.
546*4882a593Smuzhiyun */
547*4882a593Smuzhiyun uint64_t pend_type:2;
548*4882a593Smuzhiyun /*
549*4882a593Smuzhiyun * - this is the tag when pend_switch or (pend_desched
550*4882a593Smuzhiyun * AND pend_desched_switch) are set.
551*4882a593Smuzhiyun */
552*4882a593Smuzhiyun uint64_t pend_tag:32;
553*4882a593Smuzhiyun #else
554*4882a593Smuzhiyun uint64_t pend_tag:32;
555*4882a593Smuzhiyun uint64_t pend_type:2;
556*4882a593Smuzhiyun uint64_t reserved_34_35:2;
557*4882a593Smuzhiyun uint64_t pend_grp:4;
558*4882a593Smuzhiyun uint64_t pend_index:11;
559*4882a593Smuzhiyun uint64_t reserved_51:1;
560*4882a593Smuzhiyun uint64_t pend_nosched_clr:1;
561*4882a593Smuzhiyun uint64_t pend_null_rd:1;
562*4882a593Smuzhiyun uint64_t pend_new_work_wait:1;
563*4882a593Smuzhiyun uint64_t pend_new_work:1;
564*4882a593Smuzhiyun uint64_t pend_nosched:1;
565*4882a593Smuzhiyun uint64_t pend_desched_switch:1;
566*4882a593Smuzhiyun uint64_t pend_desched:1;
567*4882a593Smuzhiyun uint64_t pend_switch_null:1;
568*4882a593Smuzhiyun uint64_t pend_switch_full:1;
569*4882a593Smuzhiyun uint64_t pend_switch:1;
570*4882a593Smuzhiyun uint64_t reserved_62_63:2;
571*4882a593Smuzhiyun #endif
572*4882a593Smuzhiyun } s_sstatus0;
573*4882a593Smuzhiyun
574*4882a593Smuzhiyun /**
575*4882a593Smuzhiyun * Result for a POW Status Load (when get_cur==0 and get_wqp==1)
576*4882a593Smuzhiyun */
577*4882a593Smuzhiyun struct {
578*4882a593Smuzhiyun #ifdef __BIG_ENDIAN_BITFIELD
579*4882a593Smuzhiyun uint64_t reserved_62_63:2;
580*4882a593Smuzhiyun /*
581*4882a593Smuzhiyun * Set when there is a pending non-NULL SWTAG or
582*4882a593Smuzhiyun * SWTAG_FULL, and the POW entry has not left the list
583*4882a593Smuzhiyun * for the original tag.
584*4882a593Smuzhiyun */
585*4882a593Smuzhiyun uint64_t pend_switch:1;
586*4882a593Smuzhiyun /* Set when SWTAG_FULL and pend_switch is set. */
587*4882a593Smuzhiyun uint64_t pend_switch_full:1;
588*4882a593Smuzhiyun /*
589*4882a593Smuzhiyun * Set when there is a pending NULL SWTAG, or an
590*4882a593Smuzhiyun * implicit switch to NULL.
591*4882a593Smuzhiyun */
592*4882a593Smuzhiyun uint64_t pend_switch_null:1;
593*4882a593Smuzhiyun /*
594*4882a593Smuzhiyun * Set when there is a pending DESCHED or
595*4882a593Smuzhiyun * SWTAG_DESCHED.
596*4882a593Smuzhiyun */
597*4882a593Smuzhiyun uint64_t pend_desched:1;
598*4882a593Smuzhiyun /*
599*4882a593Smuzhiyun * Set when there is a pending SWTAG_DESCHED and
600*4882a593Smuzhiyun * pend_desched is set.
601*4882a593Smuzhiyun */
602*4882a593Smuzhiyun uint64_t pend_desched_switch:1;
603*4882a593Smuzhiyun /* Set when nosched is desired and pend_desched is set. */
604*4882a593Smuzhiyun uint64_t pend_nosched:1;
605*4882a593Smuzhiyun /* Set when there is a pending GET_WORK. */
606*4882a593Smuzhiyun uint64_t pend_new_work:1;
607*4882a593Smuzhiyun /*
608*4882a593Smuzhiyun * When pend_new_work is set, this bit indicates that
609*4882a593Smuzhiyun * the wait bit was set.
610*4882a593Smuzhiyun */
611*4882a593Smuzhiyun uint64_t pend_new_work_wait:1;
612*4882a593Smuzhiyun /* Set when there is a pending NULL_RD. */
613*4882a593Smuzhiyun uint64_t pend_null_rd:1;
614*4882a593Smuzhiyun /* Set when there is a pending CLR_NSCHED. */
615*4882a593Smuzhiyun uint64_t pend_nosched_clr:1;
616*4882a593Smuzhiyun uint64_t reserved_51:1;
617*4882a593Smuzhiyun /* This is the index when pend_nosched_clr is set. */
618*4882a593Smuzhiyun uint64_t pend_index:11;
619*4882a593Smuzhiyun /*
620*4882a593Smuzhiyun * This is the new_grp when (pend_desched AND
621*4882a593Smuzhiyun * pend_desched_switch) is set.
622*4882a593Smuzhiyun */
623*4882a593Smuzhiyun uint64_t pend_grp:4;
624*4882a593Smuzhiyun /* This is the wqp when pend_nosched_clr is set. */
625*4882a593Smuzhiyun uint64_t pend_wqp:36;
626*4882a593Smuzhiyun #else
627*4882a593Smuzhiyun uint64_t pend_wqp:36;
628*4882a593Smuzhiyun uint64_t pend_grp:4;
629*4882a593Smuzhiyun uint64_t pend_index:11;
630*4882a593Smuzhiyun uint64_t reserved_51:1;
631*4882a593Smuzhiyun uint64_t pend_nosched_clr:1;
632*4882a593Smuzhiyun uint64_t pend_null_rd:1;
633*4882a593Smuzhiyun uint64_t pend_new_work_wait:1;
634*4882a593Smuzhiyun uint64_t pend_new_work:1;
635*4882a593Smuzhiyun uint64_t pend_nosched:1;
636*4882a593Smuzhiyun uint64_t pend_desched_switch:1;
637*4882a593Smuzhiyun uint64_t pend_desched:1;
638*4882a593Smuzhiyun uint64_t pend_switch_null:1;
639*4882a593Smuzhiyun uint64_t pend_switch_full:1;
640*4882a593Smuzhiyun uint64_t pend_switch:1;
641*4882a593Smuzhiyun uint64_t reserved_62_63:2;
642*4882a593Smuzhiyun #endif
643*4882a593Smuzhiyun } s_sstatus1;
644*4882a593Smuzhiyun
645*4882a593Smuzhiyun /**
646*4882a593Smuzhiyun * Result for a POW Status Load (when get_cur==1, get_wqp==0, and
647*4882a593Smuzhiyun * get_rev==0)
648*4882a593Smuzhiyun */
649*4882a593Smuzhiyun struct {
650*4882a593Smuzhiyun #ifdef __BIG_ENDIAN_BITFIELD
651*4882a593Smuzhiyun uint64_t reserved_62_63:2;
652*4882a593Smuzhiyun /*
653*4882a593Smuzhiyun * Points to the next POW entry in the tag list when
654*4882a593Smuzhiyun * tail == 0 (and tag_type is not NULL or NULL_NULL).
655*4882a593Smuzhiyun */
656*4882a593Smuzhiyun uint64_t link_index:11;
657*4882a593Smuzhiyun /* The POW entry attached to the core. */
658*4882a593Smuzhiyun uint64_t index:11;
659*4882a593Smuzhiyun /*
660*4882a593Smuzhiyun * The group attached to the core (updated when new
661*4882a593Smuzhiyun * tag list entered on SWTAG_FULL).
662*4882a593Smuzhiyun */
663*4882a593Smuzhiyun uint64_t grp:4;
664*4882a593Smuzhiyun /*
665*4882a593Smuzhiyun * Set when this POW entry is at the head of its tag
666*4882a593Smuzhiyun * list (also set when in the NULL or NULL_NULL
667*4882a593Smuzhiyun * state).
668*4882a593Smuzhiyun */
669*4882a593Smuzhiyun uint64_t head:1;
670*4882a593Smuzhiyun /*
671*4882a593Smuzhiyun * Set when this POW entry is at the tail of its tag
672*4882a593Smuzhiyun * list (also set when in the NULL or NULL_NULL
673*4882a593Smuzhiyun * state).
674*4882a593Smuzhiyun */
675*4882a593Smuzhiyun uint64_t tail:1;
676*4882a593Smuzhiyun /*
677*4882a593Smuzhiyun * The tag type attached to the core (updated when new
678*4882a593Smuzhiyun * tag list entered on SWTAG, SWTAG_FULL, or
679*4882a593Smuzhiyun * SWTAG_DESCHED).
680*4882a593Smuzhiyun */
681*4882a593Smuzhiyun uint64_t tag_type:2;
682*4882a593Smuzhiyun /*
683*4882a593Smuzhiyun * The tag attached to the core (updated when new tag
684*4882a593Smuzhiyun * list entered on SWTAG, SWTAG_FULL, or
685*4882a593Smuzhiyun * SWTAG_DESCHED).
686*4882a593Smuzhiyun */
687*4882a593Smuzhiyun uint64_t tag:32;
688*4882a593Smuzhiyun #else
689*4882a593Smuzhiyun uint64_t tag:32;
690*4882a593Smuzhiyun uint64_t tag_type:2;
691*4882a593Smuzhiyun uint64_t tail:1;
692*4882a593Smuzhiyun uint64_t head:1;
693*4882a593Smuzhiyun uint64_t grp:4;
694*4882a593Smuzhiyun uint64_t index:11;
695*4882a593Smuzhiyun uint64_t link_index:11;
696*4882a593Smuzhiyun uint64_t reserved_62_63:2;
697*4882a593Smuzhiyun #endif
698*4882a593Smuzhiyun } s_sstatus2;
699*4882a593Smuzhiyun
700*4882a593Smuzhiyun /**
701*4882a593Smuzhiyun * Result for a POW Status Load (when get_cur==1, get_wqp==0, and get_rev==1)
702*4882a593Smuzhiyun */
703*4882a593Smuzhiyun struct {
704*4882a593Smuzhiyun #ifdef __BIG_ENDIAN_BITFIELD
705*4882a593Smuzhiyun uint64_t reserved_62_63:2;
706*4882a593Smuzhiyun /*
707*4882a593Smuzhiyun * Points to the prior POW entry in the tag list when
708*4882a593Smuzhiyun * head == 0 (and tag_type is not NULL or
709*4882a593Smuzhiyun * NULL_NULL). This field is unpredictable when the
710*4882a593Smuzhiyun * core's state is NULL or NULL_NULL.
711*4882a593Smuzhiyun */
712*4882a593Smuzhiyun uint64_t revlink_index:11;
713*4882a593Smuzhiyun /* The POW entry attached to the core. */
714*4882a593Smuzhiyun uint64_t index:11;
715*4882a593Smuzhiyun /*
716*4882a593Smuzhiyun * The group attached to the core (updated when new
717*4882a593Smuzhiyun * tag list entered on SWTAG_FULL).
718*4882a593Smuzhiyun */
719*4882a593Smuzhiyun uint64_t grp:4;
720*4882a593Smuzhiyun /* Set when this POW entry is at the head of its tag
721*4882a593Smuzhiyun * list (also set when in the NULL or NULL_NULL
722*4882a593Smuzhiyun * state).
723*4882a593Smuzhiyun */
724*4882a593Smuzhiyun uint64_t head:1;
725*4882a593Smuzhiyun /*
726*4882a593Smuzhiyun * Set when this POW entry is at the tail of its tag
727*4882a593Smuzhiyun * list (also set when in the NULL or NULL_NULL
728*4882a593Smuzhiyun * state).
729*4882a593Smuzhiyun */
730*4882a593Smuzhiyun uint64_t tail:1;
731*4882a593Smuzhiyun /*
732*4882a593Smuzhiyun * The tag type attached to the core (updated when new
733*4882a593Smuzhiyun * tag list entered on SWTAG, SWTAG_FULL, or
734*4882a593Smuzhiyun * SWTAG_DESCHED).
735*4882a593Smuzhiyun */
736*4882a593Smuzhiyun uint64_t tag_type:2;
737*4882a593Smuzhiyun /*
738*4882a593Smuzhiyun * The tag attached to the core (updated when new tag
739*4882a593Smuzhiyun * list entered on SWTAG, SWTAG_FULL, or
740*4882a593Smuzhiyun * SWTAG_DESCHED).
741*4882a593Smuzhiyun */
742*4882a593Smuzhiyun uint64_t tag:32;
743*4882a593Smuzhiyun #else
744*4882a593Smuzhiyun uint64_t tag:32;
745*4882a593Smuzhiyun uint64_t tag_type:2;
746*4882a593Smuzhiyun uint64_t tail:1;
747*4882a593Smuzhiyun uint64_t head:1;
748*4882a593Smuzhiyun uint64_t grp:4;
749*4882a593Smuzhiyun uint64_t index:11;
750*4882a593Smuzhiyun uint64_t revlink_index:11;
751*4882a593Smuzhiyun uint64_t reserved_62_63:2;
752*4882a593Smuzhiyun #endif
753*4882a593Smuzhiyun } s_sstatus3;
754*4882a593Smuzhiyun
755*4882a593Smuzhiyun /**
756*4882a593Smuzhiyun * Result for a POW Status Load (when get_cur==1, get_wqp==1, and
757*4882a593Smuzhiyun * get_rev==0)
758*4882a593Smuzhiyun */
759*4882a593Smuzhiyun struct {
760*4882a593Smuzhiyun #ifdef __BIG_ENDIAN_BITFIELD
761*4882a593Smuzhiyun uint64_t reserved_62_63:2;
762*4882a593Smuzhiyun /*
763*4882a593Smuzhiyun * Points to the next POW entry in the tag list when
764*4882a593Smuzhiyun * tail == 0 (and tag_type is not NULL or NULL_NULL).
765*4882a593Smuzhiyun */
766*4882a593Smuzhiyun uint64_t link_index:11;
767*4882a593Smuzhiyun /* The POW entry attached to the core. */
768*4882a593Smuzhiyun uint64_t index:11;
769*4882a593Smuzhiyun /*
770*4882a593Smuzhiyun * The group attached to the core (updated when new
771*4882a593Smuzhiyun * tag list entered on SWTAG_FULL).
772*4882a593Smuzhiyun */
773*4882a593Smuzhiyun uint64_t grp:4;
774*4882a593Smuzhiyun /*
775*4882a593Smuzhiyun * The wqp attached to the core (updated when new tag
776*4882a593Smuzhiyun * list entered on SWTAG_FULL).
777*4882a593Smuzhiyun */
778*4882a593Smuzhiyun uint64_t wqp:36;
779*4882a593Smuzhiyun #else
780*4882a593Smuzhiyun uint64_t wqp:36;
781*4882a593Smuzhiyun uint64_t grp:4;
782*4882a593Smuzhiyun uint64_t index:11;
783*4882a593Smuzhiyun uint64_t link_index:11;
784*4882a593Smuzhiyun uint64_t reserved_62_63:2;
785*4882a593Smuzhiyun #endif
786*4882a593Smuzhiyun } s_sstatus4;
787*4882a593Smuzhiyun
788*4882a593Smuzhiyun /**
789*4882a593Smuzhiyun * Result for a POW Status Load (when get_cur==1, get_wqp==1, and
790*4882a593Smuzhiyun * get_rev==1)
791*4882a593Smuzhiyun */
792*4882a593Smuzhiyun struct {
793*4882a593Smuzhiyun #ifdef __BIG_ENDIAN_BITFIELD
794*4882a593Smuzhiyun uint64_t reserved_62_63:2;
795*4882a593Smuzhiyun /*
796*4882a593Smuzhiyun * Points to the prior POW entry in the tag list when
797*4882a593Smuzhiyun * head == 0 (and tag_type is not NULL or
798*4882a593Smuzhiyun * NULL_NULL). This field is unpredictable when the
799*4882a593Smuzhiyun * core's state is NULL or NULL_NULL.
800*4882a593Smuzhiyun */
801*4882a593Smuzhiyun uint64_t revlink_index:11;
802*4882a593Smuzhiyun /* The POW entry attached to the core. */
803*4882a593Smuzhiyun uint64_t index:11;
804*4882a593Smuzhiyun /*
805*4882a593Smuzhiyun * The group attached to the core (updated when new
806*4882a593Smuzhiyun * tag list entered on SWTAG_FULL).
807*4882a593Smuzhiyun */
808*4882a593Smuzhiyun uint64_t grp:4;
809*4882a593Smuzhiyun /*
810*4882a593Smuzhiyun * The wqp attached to the core (updated when new tag
811*4882a593Smuzhiyun * list entered on SWTAG_FULL).
812*4882a593Smuzhiyun */
813*4882a593Smuzhiyun uint64_t wqp:36;
814*4882a593Smuzhiyun #else
815*4882a593Smuzhiyun uint64_t wqp:36;
816*4882a593Smuzhiyun uint64_t grp:4;
817*4882a593Smuzhiyun uint64_t index:11;
818*4882a593Smuzhiyun uint64_t revlink_index:11;
819*4882a593Smuzhiyun uint64_t reserved_62_63:2;
820*4882a593Smuzhiyun #endif
821*4882a593Smuzhiyun } s_sstatus5;
822*4882a593Smuzhiyun
823*4882a593Smuzhiyun /**
824*4882a593Smuzhiyun * Result For POW Memory Load (get_des == 0 and get_wqp == 0)
825*4882a593Smuzhiyun */
826*4882a593Smuzhiyun struct {
827*4882a593Smuzhiyun #ifdef __BIG_ENDIAN_BITFIELD
828*4882a593Smuzhiyun uint64_t reserved_51_63:13;
829*4882a593Smuzhiyun /*
830*4882a593Smuzhiyun * The next entry in the input, free, descheduled_head
831*4882a593Smuzhiyun * list (unpredictable if entry is the tail of the
832*4882a593Smuzhiyun * list).
833*4882a593Smuzhiyun */
834*4882a593Smuzhiyun uint64_t next_index:11;
835*4882a593Smuzhiyun /* The group of the POW entry. */
836*4882a593Smuzhiyun uint64_t grp:4;
837*4882a593Smuzhiyun uint64_t reserved_35:1;
838*4882a593Smuzhiyun /*
839*4882a593Smuzhiyun * Set when this POW entry is at the tail of its tag
840*4882a593Smuzhiyun * list (also set when in the NULL or NULL_NULL
841*4882a593Smuzhiyun * state).
842*4882a593Smuzhiyun */
843*4882a593Smuzhiyun uint64_t tail:1;
844*4882a593Smuzhiyun /* The tag type of the POW entry. */
845*4882a593Smuzhiyun uint64_t tag_type:2;
846*4882a593Smuzhiyun /* The tag of the POW entry. */
847*4882a593Smuzhiyun uint64_t tag:32;
848*4882a593Smuzhiyun #else
849*4882a593Smuzhiyun uint64_t tag:32;
850*4882a593Smuzhiyun uint64_t tag_type:2;
851*4882a593Smuzhiyun uint64_t tail:1;
852*4882a593Smuzhiyun uint64_t reserved_35:1;
853*4882a593Smuzhiyun uint64_t grp:4;
854*4882a593Smuzhiyun uint64_t next_index:11;
855*4882a593Smuzhiyun uint64_t reserved_51_63:13;
856*4882a593Smuzhiyun #endif
857*4882a593Smuzhiyun } s_smemload0;
858*4882a593Smuzhiyun
859*4882a593Smuzhiyun /**
860*4882a593Smuzhiyun * Result For POW Memory Load (get_des == 0 and get_wqp == 1)
861*4882a593Smuzhiyun */
862*4882a593Smuzhiyun struct {
863*4882a593Smuzhiyun #ifdef __BIG_ENDIAN_BITFIELD
864*4882a593Smuzhiyun uint64_t reserved_51_63:13;
865*4882a593Smuzhiyun /*
866*4882a593Smuzhiyun * The next entry in the input, free, descheduled_head
867*4882a593Smuzhiyun * list (unpredictable if entry is the tail of the
868*4882a593Smuzhiyun * list).
869*4882a593Smuzhiyun */
870*4882a593Smuzhiyun uint64_t next_index:11;
871*4882a593Smuzhiyun /* The group of the POW entry. */
872*4882a593Smuzhiyun uint64_t grp:4;
873*4882a593Smuzhiyun /* The WQP held in the POW entry. */
874*4882a593Smuzhiyun uint64_t wqp:36;
875*4882a593Smuzhiyun #else
876*4882a593Smuzhiyun uint64_t wqp:36;
877*4882a593Smuzhiyun uint64_t grp:4;
878*4882a593Smuzhiyun uint64_t next_index:11;
879*4882a593Smuzhiyun uint64_t reserved_51_63:13;
880*4882a593Smuzhiyun #endif
881*4882a593Smuzhiyun } s_smemload1;
882*4882a593Smuzhiyun
883*4882a593Smuzhiyun /**
884*4882a593Smuzhiyun * Result For POW Memory Load (get_des == 1)
885*4882a593Smuzhiyun */
886*4882a593Smuzhiyun struct {
887*4882a593Smuzhiyun #ifdef __BIG_ENDIAN_BITFIELD
888*4882a593Smuzhiyun uint64_t reserved_51_63:13;
889*4882a593Smuzhiyun /*
890*4882a593Smuzhiyun * The next entry in the tag list connected to the
891*4882a593Smuzhiyun * descheduled head.
892*4882a593Smuzhiyun */
893*4882a593Smuzhiyun uint64_t fwd_index:11;
894*4882a593Smuzhiyun /* The group of the POW entry. */
895*4882a593Smuzhiyun uint64_t grp:4;
896*4882a593Smuzhiyun /* The nosched bit for the POW entry. */
897*4882a593Smuzhiyun uint64_t nosched:1;
898*4882a593Smuzhiyun /* There is a pending tag switch */
899*4882a593Smuzhiyun uint64_t pend_switch:1;
900*4882a593Smuzhiyun /*
901*4882a593Smuzhiyun * The next tag type for the new tag list when
902*4882a593Smuzhiyun * pend_switch is set.
903*4882a593Smuzhiyun */
904*4882a593Smuzhiyun uint64_t pend_type:2;
905*4882a593Smuzhiyun /*
906*4882a593Smuzhiyun * The next tag for the new tag list when pend_switch
907*4882a593Smuzhiyun * is set.
908*4882a593Smuzhiyun */
909*4882a593Smuzhiyun uint64_t pend_tag:32;
910*4882a593Smuzhiyun #else
911*4882a593Smuzhiyun uint64_t pend_tag:32;
912*4882a593Smuzhiyun uint64_t pend_type:2;
913*4882a593Smuzhiyun uint64_t pend_switch:1;
914*4882a593Smuzhiyun uint64_t nosched:1;
915*4882a593Smuzhiyun uint64_t grp:4;
916*4882a593Smuzhiyun uint64_t fwd_index:11;
917*4882a593Smuzhiyun uint64_t reserved_51_63:13;
918*4882a593Smuzhiyun #endif
919*4882a593Smuzhiyun } s_smemload2;
920*4882a593Smuzhiyun
921*4882a593Smuzhiyun /**
922*4882a593Smuzhiyun * Result For POW Index/Pointer Load (get_rmt == 0/get_des_get_tail == 0)
923*4882a593Smuzhiyun */
924*4882a593Smuzhiyun struct {
925*4882a593Smuzhiyun #ifdef __BIG_ENDIAN_BITFIELD
926*4882a593Smuzhiyun uint64_t reserved_52_63:12;
927*4882a593Smuzhiyun /*
928*4882a593Smuzhiyun * set when there is one or more POW entries on the
929*4882a593Smuzhiyun * free list.
930*4882a593Smuzhiyun */
931*4882a593Smuzhiyun uint64_t free_val:1;
932*4882a593Smuzhiyun /*
933*4882a593Smuzhiyun * set when there is exactly one POW entry on the free
934*4882a593Smuzhiyun * list.
935*4882a593Smuzhiyun */
936*4882a593Smuzhiyun uint64_t free_one:1;
937*4882a593Smuzhiyun uint64_t reserved_49:1;
938*4882a593Smuzhiyun /*
939*4882a593Smuzhiyun * when free_val is set, indicates the first entry on
940*4882a593Smuzhiyun * the free list.
941*4882a593Smuzhiyun */
942*4882a593Smuzhiyun uint64_t free_head:11;
943*4882a593Smuzhiyun uint64_t reserved_37:1;
944*4882a593Smuzhiyun /*
945*4882a593Smuzhiyun * when free_val is set, indicates the last entry on
946*4882a593Smuzhiyun * the free list.
947*4882a593Smuzhiyun */
948*4882a593Smuzhiyun uint64_t free_tail:11;
949*4882a593Smuzhiyun /*
950*4882a593Smuzhiyun * set when there is one or more POW entries on the
951*4882a593Smuzhiyun * input Q list selected by qosgrp.
952*4882a593Smuzhiyun */
953*4882a593Smuzhiyun uint64_t loc_val:1;
954*4882a593Smuzhiyun /*
955*4882a593Smuzhiyun * set when there is exactly one POW entry on the
956*4882a593Smuzhiyun * input Q list selected by qosgrp.
957*4882a593Smuzhiyun */
958*4882a593Smuzhiyun uint64_t loc_one:1;
959*4882a593Smuzhiyun uint64_t reserved_23:1;
960*4882a593Smuzhiyun /*
961*4882a593Smuzhiyun * when loc_val is set, indicates the first entry on
962*4882a593Smuzhiyun * the input Q list selected by qosgrp.
963*4882a593Smuzhiyun */
964*4882a593Smuzhiyun uint64_t loc_head:11;
965*4882a593Smuzhiyun uint64_t reserved_11:1;
966*4882a593Smuzhiyun /*
967*4882a593Smuzhiyun * when loc_val is set, indicates the last entry on
968*4882a593Smuzhiyun * the input Q list selected by qosgrp.
969*4882a593Smuzhiyun */
970*4882a593Smuzhiyun uint64_t loc_tail:11;
971*4882a593Smuzhiyun #else
972*4882a593Smuzhiyun uint64_t loc_tail:11;
973*4882a593Smuzhiyun uint64_t reserved_11:1;
974*4882a593Smuzhiyun uint64_t loc_head:11;
975*4882a593Smuzhiyun uint64_t reserved_23:1;
976*4882a593Smuzhiyun uint64_t loc_one:1;
977*4882a593Smuzhiyun uint64_t loc_val:1;
978*4882a593Smuzhiyun uint64_t free_tail:11;
979*4882a593Smuzhiyun uint64_t reserved_37:1;
980*4882a593Smuzhiyun uint64_t free_head:11;
981*4882a593Smuzhiyun uint64_t reserved_49:1;
982*4882a593Smuzhiyun uint64_t free_one:1;
983*4882a593Smuzhiyun uint64_t free_val:1;
984*4882a593Smuzhiyun uint64_t reserved_52_63:12;
985*4882a593Smuzhiyun #endif
986*4882a593Smuzhiyun } sindexload0;
987*4882a593Smuzhiyun
988*4882a593Smuzhiyun /**
989*4882a593Smuzhiyun * Result For POW Index/Pointer Load (get_rmt == 0/get_des_get_tail == 1)
990*4882a593Smuzhiyun */
991*4882a593Smuzhiyun struct {
992*4882a593Smuzhiyun #ifdef __BIG_ENDIAN_BITFIELD
993*4882a593Smuzhiyun uint64_t reserved_52_63:12;
994*4882a593Smuzhiyun /*
995*4882a593Smuzhiyun * set when there is one or more POW entries on the
996*4882a593Smuzhiyun * nosched list.
997*4882a593Smuzhiyun */
998*4882a593Smuzhiyun uint64_t nosched_val:1;
999*4882a593Smuzhiyun /*
1000*4882a593Smuzhiyun * set when there is exactly one POW entry on the
1001*4882a593Smuzhiyun * nosched list.
1002*4882a593Smuzhiyun */
1003*4882a593Smuzhiyun uint64_t nosched_one:1;
1004*4882a593Smuzhiyun uint64_t reserved_49:1;
1005*4882a593Smuzhiyun /*
1006*4882a593Smuzhiyun * when nosched_val is set, indicates the first entry
1007*4882a593Smuzhiyun * on the nosched list.
1008*4882a593Smuzhiyun */
1009*4882a593Smuzhiyun uint64_t nosched_head:11;
1010*4882a593Smuzhiyun uint64_t reserved_37:1;
1011*4882a593Smuzhiyun /*
1012*4882a593Smuzhiyun * when nosched_val is set, indicates the last entry
1013*4882a593Smuzhiyun * on the nosched list.
1014*4882a593Smuzhiyun */
1015*4882a593Smuzhiyun uint64_t nosched_tail:11;
1016*4882a593Smuzhiyun /*
1017*4882a593Smuzhiyun * set when there is one or more descheduled heads on
1018*4882a593Smuzhiyun * the descheduled list selected by qosgrp.
1019*4882a593Smuzhiyun */
1020*4882a593Smuzhiyun uint64_t des_val:1;
1021*4882a593Smuzhiyun /*
1022*4882a593Smuzhiyun * set when there is exactly one descheduled head on
1023*4882a593Smuzhiyun * the descheduled list selected by qosgrp.
1024*4882a593Smuzhiyun */
1025*4882a593Smuzhiyun uint64_t des_one:1;
1026*4882a593Smuzhiyun uint64_t reserved_23:1;
1027*4882a593Smuzhiyun /*
1028*4882a593Smuzhiyun * when des_val is set, indicates the first
1029*4882a593Smuzhiyun * descheduled head on the descheduled list selected
1030*4882a593Smuzhiyun * by qosgrp.
1031*4882a593Smuzhiyun */
1032*4882a593Smuzhiyun uint64_t des_head:11;
1033*4882a593Smuzhiyun uint64_t reserved_11:1;
1034*4882a593Smuzhiyun /*
1035*4882a593Smuzhiyun * when des_val is set, indicates the last descheduled
1036*4882a593Smuzhiyun * head on the descheduled list selected by qosgrp.
1037*4882a593Smuzhiyun */
1038*4882a593Smuzhiyun uint64_t des_tail:11;
1039*4882a593Smuzhiyun #else
1040*4882a593Smuzhiyun uint64_t des_tail:11;
1041*4882a593Smuzhiyun uint64_t reserved_11:1;
1042*4882a593Smuzhiyun uint64_t des_head:11;
1043*4882a593Smuzhiyun uint64_t reserved_23:1;
1044*4882a593Smuzhiyun uint64_t des_one:1;
1045*4882a593Smuzhiyun uint64_t des_val:1;
1046*4882a593Smuzhiyun uint64_t nosched_tail:11;
1047*4882a593Smuzhiyun uint64_t reserved_37:1;
1048*4882a593Smuzhiyun uint64_t nosched_head:11;
1049*4882a593Smuzhiyun uint64_t reserved_49:1;
1050*4882a593Smuzhiyun uint64_t nosched_one:1;
1051*4882a593Smuzhiyun uint64_t nosched_val:1;
1052*4882a593Smuzhiyun uint64_t reserved_52_63:12;
1053*4882a593Smuzhiyun #endif
1054*4882a593Smuzhiyun } sindexload1;
1055*4882a593Smuzhiyun
1056*4882a593Smuzhiyun /**
1057*4882a593Smuzhiyun * Result For POW Index/Pointer Load (get_rmt == 1/get_des_get_tail == 0)
1058*4882a593Smuzhiyun */
1059*4882a593Smuzhiyun struct {
1060*4882a593Smuzhiyun #ifdef __BIG_ENDIAN_BITFIELD
1061*4882a593Smuzhiyun uint64_t reserved_39_63:25;
1062*4882a593Smuzhiyun /*
1063*4882a593Smuzhiyun * Set when this DRAM list is the current head
1064*4882a593Smuzhiyun * (i.e. is the next to be reloaded when the POW
1065*4882a593Smuzhiyun * hardware reloads a POW entry from DRAM). The POW
1066*4882a593Smuzhiyun * hardware alternates between the two DRAM lists
1067*4882a593Smuzhiyun * associated with a QOS level when it reloads work
1068*4882a593Smuzhiyun * from DRAM into the POW unit.
1069*4882a593Smuzhiyun */
1070*4882a593Smuzhiyun uint64_t rmt_is_head:1;
1071*4882a593Smuzhiyun /*
1072*4882a593Smuzhiyun * Set when the DRAM portion of the input Q list
1073*4882a593Smuzhiyun * selected by qosgrp contains one or more pieces of
1074*4882a593Smuzhiyun * work.
1075*4882a593Smuzhiyun */
1076*4882a593Smuzhiyun uint64_t rmt_val:1;
1077*4882a593Smuzhiyun /*
1078*4882a593Smuzhiyun * Set when the DRAM portion of the input Q list
1079*4882a593Smuzhiyun * selected by qosgrp contains exactly one piece of
1080*4882a593Smuzhiyun * work.
1081*4882a593Smuzhiyun */
1082*4882a593Smuzhiyun uint64_t rmt_one:1;
1083*4882a593Smuzhiyun /*
1084*4882a593Smuzhiyun * When rmt_val is set, indicates the first piece of
1085*4882a593Smuzhiyun * work on the DRAM input Q list selected by
1086*4882a593Smuzhiyun * qosgrp.
1087*4882a593Smuzhiyun */
1088*4882a593Smuzhiyun uint64_t rmt_head:36;
1089*4882a593Smuzhiyun #else
1090*4882a593Smuzhiyun uint64_t rmt_head:36;
1091*4882a593Smuzhiyun uint64_t rmt_one:1;
1092*4882a593Smuzhiyun uint64_t rmt_val:1;
1093*4882a593Smuzhiyun uint64_t rmt_is_head:1;
1094*4882a593Smuzhiyun uint64_t reserved_39_63:25;
1095*4882a593Smuzhiyun #endif
1096*4882a593Smuzhiyun } sindexload2;
1097*4882a593Smuzhiyun
1098*4882a593Smuzhiyun /**
1099*4882a593Smuzhiyun * Result For POW Index/Pointer Load (get_rmt ==
1100*4882a593Smuzhiyun * 1/get_des_get_tail == 1)
1101*4882a593Smuzhiyun */
1102*4882a593Smuzhiyun struct {
1103*4882a593Smuzhiyun #ifdef __BIG_ENDIAN_BITFIELD
1104*4882a593Smuzhiyun uint64_t reserved_39_63:25;
1105*4882a593Smuzhiyun /*
1106*4882a593Smuzhiyun * set when this DRAM list is the current head
1107*4882a593Smuzhiyun * (i.e. is the next to be reloaded when the POW
1108*4882a593Smuzhiyun * hardware reloads a POW entry from DRAM). The POW
1109*4882a593Smuzhiyun * hardware alternates between the two DRAM lists
1110*4882a593Smuzhiyun * associated with a QOS level when it reloads work
1111*4882a593Smuzhiyun * from DRAM into the POW unit.
1112*4882a593Smuzhiyun */
1113*4882a593Smuzhiyun uint64_t rmt_is_head:1;
1114*4882a593Smuzhiyun /*
1115*4882a593Smuzhiyun * set when the DRAM portion of the input Q list
1116*4882a593Smuzhiyun * selected by qosgrp contains one or more pieces of
1117*4882a593Smuzhiyun * work.
1118*4882a593Smuzhiyun */
1119*4882a593Smuzhiyun uint64_t rmt_val:1;
1120*4882a593Smuzhiyun /*
1121*4882a593Smuzhiyun * set when the DRAM portion of the input Q list
1122*4882a593Smuzhiyun * selected by qosgrp contains exactly one piece of
1123*4882a593Smuzhiyun * work.
1124*4882a593Smuzhiyun */
1125*4882a593Smuzhiyun uint64_t rmt_one:1;
1126*4882a593Smuzhiyun /*
1127*4882a593Smuzhiyun * when rmt_val is set, indicates the last piece of
1128*4882a593Smuzhiyun * work on the DRAM input Q list selected by
1129*4882a593Smuzhiyun * qosgrp.
1130*4882a593Smuzhiyun */
1131*4882a593Smuzhiyun uint64_t rmt_tail:36;
1132*4882a593Smuzhiyun #else
1133*4882a593Smuzhiyun uint64_t rmt_tail:36;
1134*4882a593Smuzhiyun uint64_t rmt_one:1;
1135*4882a593Smuzhiyun uint64_t rmt_val:1;
1136*4882a593Smuzhiyun uint64_t rmt_is_head:1;
1137*4882a593Smuzhiyun uint64_t reserved_39_63:25;
1138*4882a593Smuzhiyun #endif
1139*4882a593Smuzhiyun } sindexload3;
1140*4882a593Smuzhiyun
1141*4882a593Smuzhiyun /**
1142*4882a593Smuzhiyun * Response to NULL_RD request loads
1143*4882a593Smuzhiyun */
1144*4882a593Smuzhiyun struct {
1145*4882a593Smuzhiyun #ifdef __BIG_ENDIAN_BITFIELD
1146*4882a593Smuzhiyun uint64_t unused:62;
1147*4882a593Smuzhiyun /* of type cvmx_pow_tag_type_t. state is one of the
1148*4882a593Smuzhiyun * following:
1149*4882a593Smuzhiyun *
1150*4882a593Smuzhiyun * - CVMX_POW_TAG_TYPE_ORDERED
1151*4882a593Smuzhiyun * - CVMX_POW_TAG_TYPE_ATOMIC
1152*4882a593Smuzhiyun * - CVMX_POW_TAG_TYPE_NULL
1153*4882a593Smuzhiyun * - CVMX_POW_TAG_TYPE_NULL_NULL
1154*4882a593Smuzhiyun */
1155*4882a593Smuzhiyun uint64_t state:2;
1156*4882a593Smuzhiyun #else
1157*4882a593Smuzhiyun uint64_t state:2;
1158*4882a593Smuzhiyun uint64_t unused:62;
1159*4882a593Smuzhiyun #endif
1160*4882a593Smuzhiyun } s_null_rd;
1161*4882a593Smuzhiyun
1162*4882a593Smuzhiyun } cvmx_pow_tag_load_resp_t;
1163*4882a593Smuzhiyun
1164*4882a593Smuzhiyun /**
1165*4882a593Smuzhiyun * This structure describes the address used for stores to the POW.
1166*4882a593Smuzhiyun * The store address is meaningful on stores to the POW. The
1167*4882a593Smuzhiyun * hardware assumes that an aligned 64-bit store was used for all
1168*4882a593Smuzhiyun * these stores. Note the assumption that the work queue entry is
1169*4882a593Smuzhiyun * aligned on an 8-byte boundary (since the low-order 3 address bits
1170*4882a593Smuzhiyun * must be zero). Note that not all fields are used by all
1171*4882a593Smuzhiyun * operations.
1172*4882a593Smuzhiyun *
1173*4882a593Smuzhiyun * NOTE: The following is the behavior of the pending switch bit at the PP
1174*4882a593Smuzhiyun * for POW stores (i.e. when did<7:3> == 0xc)
1175*4882a593Smuzhiyun * - did<2:0> == 0 => pending switch bit is set
1176*4882a593Smuzhiyun * - did<2:0> == 1 => no affect on the pending switch bit
1177*4882a593Smuzhiyun * - did<2:0> == 3 => pending switch bit is cleared
1178*4882a593Smuzhiyun * - did<2:0> == 7 => no affect on the pending switch bit
1179*4882a593Smuzhiyun * - did<2:0> == others => must not be used
1180*4882a593Smuzhiyun * - No other loads/stores have an affect on the pending switch bit
1181*4882a593Smuzhiyun * - The switch bus from POW can clear the pending switch bit
1182*4882a593Smuzhiyun *
1183*4882a593Smuzhiyun * NOTE: did<2:0> == 2 is used by the HW for a special single-cycle
1184*4882a593Smuzhiyun * ADDWQ command that only contains the pointer). SW must never use
1185*4882a593Smuzhiyun * did<2:0> == 2.
1186*4882a593Smuzhiyun */
1187*4882a593Smuzhiyun typedef union {
1188*4882a593Smuzhiyun /**
1189*4882a593Smuzhiyun * Unsigned 64 bit integer representation of store address
1190*4882a593Smuzhiyun */
1191*4882a593Smuzhiyun uint64_t u64;
1192*4882a593Smuzhiyun
1193*4882a593Smuzhiyun struct {
1194*4882a593Smuzhiyun #ifdef __BIG_ENDIAN_BITFIELD
1195*4882a593Smuzhiyun /* Memory region. Should be CVMX_IO_SEG in most cases */
1196*4882a593Smuzhiyun uint64_t mem_reg:2;
1197*4882a593Smuzhiyun uint64_t reserved_49_61:13; /* Must be zero */
1198*4882a593Smuzhiyun uint64_t is_io:1; /* Must be one */
1199*4882a593Smuzhiyun /* Device ID of POW. Note that different sub-dids are used. */
1200*4882a593Smuzhiyun uint64_t did:8;
1201*4882a593Smuzhiyun uint64_t reserved_36_39:4; /* Must be zero */
1202*4882a593Smuzhiyun /* Address field. addr<2:0> must be zero */
1203*4882a593Smuzhiyun uint64_t addr:36;
1204*4882a593Smuzhiyun #else
1205*4882a593Smuzhiyun uint64_t addr:36;
1206*4882a593Smuzhiyun uint64_t reserved_36_39:4;
1207*4882a593Smuzhiyun uint64_t did:8;
1208*4882a593Smuzhiyun uint64_t is_io:1;
1209*4882a593Smuzhiyun uint64_t reserved_49_61:13;
1210*4882a593Smuzhiyun uint64_t mem_reg:2;
1211*4882a593Smuzhiyun #endif
1212*4882a593Smuzhiyun } stag;
1213*4882a593Smuzhiyun } cvmx_pow_tag_store_addr_t;
1214*4882a593Smuzhiyun
1215*4882a593Smuzhiyun /**
1216*4882a593Smuzhiyun * decode of the store data when an IOBDMA SENDSINGLE is sent to POW
1217*4882a593Smuzhiyun */
1218*4882a593Smuzhiyun typedef union {
1219*4882a593Smuzhiyun uint64_t u64;
1220*4882a593Smuzhiyun
1221*4882a593Smuzhiyun struct {
1222*4882a593Smuzhiyun #ifdef __BIG_ENDIAN_BITFIELD
1223*4882a593Smuzhiyun /*
1224*4882a593Smuzhiyun * the (64-bit word) location in scratchpad to write
1225*4882a593Smuzhiyun * to (if len != 0)
1226*4882a593Smuzhiyun */
1227*4882a593Smuzhiyun uint64_t scraddr:8;
1228*4882a593Smuzhiyun /* the number of words in the response (0 => no response) */
1229*4882a593Smuzhiyun uint64_t len:8;
1230*4882a593Smuzhiyun /* the ID of the device on the non-coherent bus */
1231*4882a593Smuzhiyun uint64_t did:8;
1232*4882a593Smuzhiyun uint64_t unused:36;
1233*4882a593Smuzhiyun /* if set, don't return load response until work is available */
1234*4882a593Smuzhiyun uint64_t wait:1;
1235*4882a593Smuzhiyun uint64_t unused2:3;
1236*4882a593Smuzhiyun #else
1237*4882a593Smuzhiyun uint64_t unused2:3;
1238*4882a593Smuzhiyun uint64_t wait:1;
1239*4882a593Smuzhiyun uint64_t unused:36;
1240*4882a593Smuzhiyun uint64_t did:8;
1241*4882a593Smuzhiyun uint64_t len:8;
1242*4882a593Smuzhiyun uint64_t scraddr:8;
1243*4882a593Smuzhiyun #endif
1244*4882a593Smuzhiyun } s;
1245*4882a593Smuzhiyun
1246*4882a593Smuzhiyun } cvmx_pow_iobdma_store_t;
1247*4882a593Smuzhiyun
1248*4882a593Smuzhiyun /* CSR typedefs have been moved to cvmx-csr-*.h */
1249*4882a593Smuzhiyun
1250*4882a593Smuzhiyun /**
1251*4882a593Smuzhiyun * Get the POW tag for this core. This returns the current
1252*4882a593Smuzhiyun * tag type, tag, group, and POW entry index associated with
1253*4882a593Smuzhiyun * this core. Index is only valid if the tag type isn't NULL_NULL.
1254*4882a593Smuzhiyun * If a tag switch is pending this routine returns the tag before
1255*4882a593Smuzhiyun * the tag switch, not after.
1256*4882a593Smuzhiyun *
1257*4882a593Smuzhiyun * Returns Current tag
1258*4882a593Smuzhiyun */
cvmx_pow_get_current_tag(void)1259*4882a593Smuzhiyun static inline cvmx_pow_tag_req_t cvmx_pow_get_current_tag(void)
1260*4882a593Smuzhiyun {
1261*4882a593Smuzhiyun cvmx_pow_load_addr_t load_addr;
1262*4882a593Smuzhiyun cvmx_pow_tag_load_resp_t load_resp;
1263*4882a593Smuzhiyun cvmx_pow_tag_req_t result;
1264*4882a593Smuzhiyun
1265*4882a593Smuzhiyun load_addr.u64 = 0;
1266*4882a593Smuzhiyun load_addr.sstatus.mem_region = CVMX_IO_SEG;
1267*4882a593Smuzhiyun load_addr.sstatus.is_io = 1;
1268*4882a593Smuzhiyun load_addr.sstatus.did = CVMX_OCT_DID_TAG_TAG1;
1269*4882a593Smuzhiyun load_addr.sstatus.coreid = cvmx_get_core_num();
1270*4882a593Smuzhiyun load_addr.sstatus.get_cur = 1;
1271*4882a593Smuzhiyun load_resp.u64 = cvmx_read_csr(load_addr.u64);
1272*4882a593Smuzhiyun result.u64 = 0;
1273*4882a593Smuzhiyun result.s.grp = load_resp.s_sstatus2.grp;
1274*4882a593Smuzhiyun result.s.index = load_resp.s_sstatus2.index;
1275*4882a593Smuzhiyun result.s.type = load_resp.s_sstatus2.tag_type;
1276*4882a593Smuzhiyun result.s.tag = load_resp.s_sstatus2.tag;
1277*4882a593Smuzhiyun return result;
1278*4882a593Smuzhiyun }
1279*4882a593Smuzhiyun
1280*4882a593Smuzhiyun /**
1281*4882a593Smuzhiyun * Get the POW WQE for this core. This returns the work queue
1282*4882a593Smuzhiyun * entry currently associated with this core.
1283*4882a593Smuzhiyun *
1284*4882a593Smuzhiyun * Returns WQE pointer
1285*4882a593Smuzhiyun */
cvmx_pow_get_current_wqp(void)1286*4882a593Smuzhiyun static inline struct cvmx_wqe *cvmx_pow_get_current_wqp(void)
1287*4882a593Smuzhiyun {
1288*4882a593Smuzhiyun cvmx_pow_load_addr_t load_addr;
1289*4882a593Smuzhiyun cvmx_pow_tag_load_resp_t load_resp;
1290*4882a593Smuzhiyun
1291*4882a593Smuzhiyun load_addr.u64 = 0;
1292*4882a593Smuzhiyun load_addr.sstatus.mem_region = CVMX_IO_SEG;
1293*4882a593Smuzhiyun load_addr.sstatus.is_io = 1;
1294*4882a593Smuzhiyun load_addr.sstatus.did = CVMX_OCT_DID_TAG_TAG1;
1295*4882a593Smuzhiyun load_addr.sstatus.coreid = cvmx_get_core_num();
1296*4882a593Smuzhiyun load_addr.sstatus.get_cur = 1;
1297*4882a593Smuzhiyun load_addr.sstatus.get_wqp = 1;
1298*4882a593Smuzhiyun load_resp.u64 = cvmx_read_csr(load_addr.u64);
1299*4882a593Smuzhiyun return (struct cvmx_wqe *) cvmx_phys_to_ptr(load_resp.s_sstatus4.wqp);
1300*4882a593Smuzhiyun }
1301*4882a593Smuzhiyun
1302*4882a593Smuzhiyun #ifndef CVMX_MF_CHORD
1303*4882a593Smuzhiyun #define CVMX_MF_CHORD(dest) CVMX_RDHWR(dest, 30)
1304*4882a593Smuzhiyun #endif
1305*4882a593Smuzhiyun
1306*4882a593Smuzhiyun /**
1307*4882a593Smuzhiyun * Print a warning if a tag switch is pending for this core
1308*4882a593Smuzhiyun *
1309*4882a593Smuzhiyun * @function: Function name checking for a pending tag switch
1310*4882a593Smuzhiyun */
__cvmx_pow_warn_if_pending_switch(const char * function)1311*4882a593Smuzhiyun static inline void __cvmx_pow_warn_if_pending_switch(const char *function)
1312*4882a593Smuzhiyun {
1313*4882a593Smuzhiyun uint64_t switch_complete;
1314*4882a593Smuzhiyun CVMX_MF_CHORD(switch_complete);
1315*4882a593Smuzhiyun if (!switch_complete)
1316*4882a593Smuzhiyun pr_warn("%s called with tag switch in progress\n", function);
1317*4882a593Smuzhiyun }
1318*4882a593Smuzhiyun
1319*4882a593Smuzhiyun /**
1320*4882a593Smuzhiyun * Waits for a tag switch to complete by polling the completion bit.
1321*4882a593Smuzhiyun * Note that switches to NULL complete immediately and do not need
1322*4882a593Smuzhiyun * to be waited for.
1323*4882a593Smuzhiyun */
cvmx_pow_tag_sw_wait(void)1324*4882a593Smuzhiyun static inline void cvmx_pow_tag_sw_wait(void)
1325*4882a593Smuzhiyun {
1326*4882a593Smuzhiyun const uint64_t MAX_CYCLES = 1ull << 31;
1327*4882a593Smuzhiyun uint64_t switch_complete;
1328*4882a593Smuzhiyun uint64_t start_cycle = cvmx_get_cycle();
1329*4882a593Smuzhiyun while (1) {
1330*4882a593Smuzhiyun CVMX_MF_CHORD(switch_complete);
1331*4882a593Smuzhiyun if (unlikely(switch_complete))
1332*4882a593Smuzhiyun break;
1333*4882a593Smuzhiyun if (unlikely(cvmx_get_cycle() > start_cycle + MAX_CYCLES)) {
1334*4882a593Smuzhiyun pr_warn("Tag switch is taking a long time, possible deadlock\n");
1335*4882a593Smuzhiyun start_cycle = -MAX_CYCLES - 1;
1336*4882a593Smuzhiyun }
1337*4882a593Smuzhiyun }
1338*4882a593Smuzhiyun }
1339*4882a593Smuzhiyun
1340*4882a593Smuzhiyun /**
1341*4882a593Smuzhiyun * Synchronous work request. Requests work from the POW.
1342*4882a593Smuzhiyun * This function does NOT wait for previous tag switches to complete,
1343*4882a593Smuzhiyun * so the caller must ensure that there is not a pending tag switch.
1344*4882a593Smuzhiyun *
1345*4882a593Smuzhiyun * @wait: When set, call stalls until work becomes avaiable, or times out.
1346*4882a593Smuzhiyun * If not set, returns immediately.
1347*4882a593Smuzhiyun *
1348*4882a593Smuzhiyun * Returns: the WQE pointer from POW. Returns NULL if no work
1349*4882a593Smuzhiyun * was available.
1350*4882a593Smuzhiyun */
cvmx_pow_work_request_sync_nocheck(cvmx_pow_wait_t wait)1351*4882a593Smuzhiyun static inline struct cvmx_wqe *cvmx_pow_work_request_sync_nocheck(cvmx_pow_wait_t
1352*4882a593Smuzhiyun wait)
1353*4882a593Smuzhiyun {
1354*4882a593Smuzhiyun cvmx_pow_load_addr_t ptr;
1355*4882a593Smuzhiyun cvmx_pow_tag_load_resp_t result;
1356*4882a593Smuzhiyun
1357*4882a593Smuzhiyun if (CVMX_ENABLE_POW_CHECKS)
1358*4882a593Smuzhiyun __cvmx_pow_warn_if_pending_switch(__func__);
1359*4882a593Smuzhiyun
1360*4882a593Smuzhiyun ptr.u64 = 0;
1361*4882a593Smuzhiyun ptr.swork.mem_region = CVMX_IO_SEG;
1362*4882a593Smuzhiyun ptr.swork.is_io = 1;
1363*4882a593Smuzhiyun ptr.swork.did = CVMX_OCT_DID_TAG_SWTAG;
1364*4882a593Smuzhiyun ptr.swork.wait = wait;
1365*4882a593Smuzhiyun
1366*4882a593Smuzhiyun result.u64 = cvmx_read_csr(ptr.u64);
1367*4882a593Smuzhiyun
1368*4882a593Smuzhiyun if (result.s_work.no_work)
1369*4882a593Smuzhiyun return NULL;
1370*4882a593Smuzhiyun else
1371*4882a593Smuzhiyun return (struct cvmx_wqe *) cvmx_phys_to_ptr(result.s_work.addr);
1372*4882a593Smuzhiyun }
1373*4882a593Smuzhiyun
1374*4882a593Smuzhiyun /**
1375*4882a593Smuzhiyun * Synchronous work request. Requests work from the POW.
1376*4882a593Smuzhiyun * This function waits for any previous tag switch to complete before
1377*4882a593Smuzhiyun * requesting the new work.
1378*4882a593Smuzhiyun *
1379*4882a593Smuzhiyun * @wait: When set, call stalls until work becomes avaiable, or times out.
1380*4882a593Smuzhiyun * If not set, returns immediately.
1381*4882a593Smuzhiyun *
1382*4882a593Smuzhiyun * Returns: the WQE pointer from POW. Returns NULL if no work
1383*4882a593Smuzhiyun * was available.
1384*4882a593Smuzhiyun */
cvmx_pow_work_request_sync(cvmx_pow_wait_t wait)1385*4882a593Smuzhiyun static inline struct cvmx_wqe *cvmx_pow_work_request_sync(cvmx_pow_wait_t wait)
1386*4882a593Smuzhiyun {
1387*4882a593Smuzhiyun if (CVMX_ENABLE_POW_CHECKS)
1388*4882a593Smuzhiyun __cvmx_pow_warn_if_pending_switch(__func__);
1389*4882a593Smuzhiyun
1390*4882a593Smuzhiyun /* Must not have a switch pending when requesting work */
1391*4882a593Smuzhiyun cvmx_pow_tag_sw_wait();
1392*4882a593Smuzhiyun return cvmx_pow_work_request_sync_nocheck(wait);
1393*4882a593Smuzhiyun
1394*4882a593Smuzhiyun }
1395*4882a593Smuzhiyun
1396*4882a593Smuzhiyun /**
1397*4882a593Smuzhiyun * Synchronous null_rd request. Requests a switch out of NULL_NULL POW state.
1398*4882a593Smuzhiyun * This function waits for any previous tag switch to complete before
1399*4882a593Smuzhiyun * requesting the null_rd.
1400*4882a593Smuzhiyun *
1401*4882a593Smuzhiyun * Returns: the POW state of type cvmx_pow_tag_type_t.
1402*4882a593Smuzhiyun */
cvmx_pow_work_request_null_rd(void)1403*4882a593Smuzhiyun static inline enum cvmx_pow_tag_type cvmx_pow_work_request_null_rd(void)
1404*4882a593Smuzhiyun {
1405*4882a593Smuzhiyun cvmx_pow_load_addr_t ptr;
1406*4882a593Smuzhiyun cvmx_pow_tag_load_resp_t result;
1407*4882a593Smuzhiyun
1408*4882a593Smuzhiyun if (CVMX_ENABLE_POW_CHECKS)
1409*4882a593Smuzhiyun __cvmx_pow_warn_if_pending_switch(__func__);
1410*4882a593Smuzhiyun
1411*4882a593Smuzhiyun /* Must not have a switch pending when requesting work */
1412*4882a593Smuzhiyun cvmx_pow_tag_sw_wait();
1413*4882a593Smuzhiyun
1414*4882a593Smuzhiyun ptr.u64 = 0;
1415*4882a593Smuzhiyun ptr.snull_rd.mem_region = CVMX_IO_SEG;
1416*4882a593Smuzhiyun ptr.snull_rd.is_io = 1;
1417*4882a593Smuzhiyun ptr.snull_rd.did = CVMX_OCT_DID_TAG_NULL_RD;
1418*4882a593Smuzhiyun
1419*4882a593Smuzhiyun result.u64 = cvmx_read_csr(ptr.u64);
1420*4882a593Smuzhiyun
1421*4882a593Smuzhiyun return (enum cvmx_pow_tag_type) result.s_null_rd.state;
1422*4882a593Smuzhiyun }
1423*4882a593Smuzhiyun
1424*4882a593Smuzhiyun /**
1425*4882a593Smuzhiyun * Asynchronous work request. Work is requested from the POW unit,
1426*4882a593Smuzhiyun * and should later be checked with function
1427*4882a593Smuzhiyun * cvmx_pow_work_response_async. This function does NOT wait for
1428*4882a593Smuzhiyun * previous tag switches to complete, so the caller must ensure that
1429*4882a593Smuzhiyun * there is not a pending tag switch.
1430*4882a593Smuzhiyun *
1431*4882a593Smuzhiyun * @scr_addr: Scratch memory address that response will be returned
1432*4882a593Smuzhiyun * to, which is either a valid WQE, or a response with the
1433*4882a593Smuzhiyun * invalid bit set. Byte address, must be 8 byte aligned.
1434*4882a593Smuzhiyun *
1435*4882a593Smuzhiyun * @wait: 1 to cause response to wait for work to become available (or
1436*4882a593Smuzhiyun * timeout), 0 to cause response to return immediately
1437*4882a593Smuzhiyun */
cvmx_pow_work_request_async_nocheck(int scr_addr,cvmx_pow_wait_t wait)1438*4882a593Smuzhiyun static inline void cvmx_pow_work_request_async_nocheck(int scr_addr,
1439*4882a593Smuzhiyun cvmx_pow_wait_t wait)
1440*4882a593Smuzhiyun {
1441*4882a593Smuzhiyun cvmx_pow_iobdma_store_t data;
1442*4882a593Smuzhiyun
1443*4882a593Smuzhiyun if (CVMX_ENABLE_POW_CHECKS)
1444*4882a593Smuzhiyun __cvmx_pow_warn_if_pending_switch(__func__);
1445*4882a593Smuzhiyun
1446*4882a593Smuzhiyun /* scr_addr must be 8 byte aligned */
1447*4882a593Smuzhiyun data.s.scraddr = scr_addr >> 3;
1448*4882a593Smuzhiyun data.s.len = 1;
1449*4882a593Smuzhiyun data.s.did = CVMX_OCT_DID_TAG_SWTAG;
1450*4882a593Smuzhiyun data.s.wait = wait;
1451*4882a593Smuzhiyun cvmx_send_single(data.u64);
1452*4882a593Smuzhiyun }
1453*4882a593Smuzhiyun
1454*4882a593Smuzhiyun /**
1455*4882a593Smuzhiyun * Asynchronous work request. Work is requested from the POW unit,
1456*4882a593Smuzhiyun * and should later be checked with function
1457*4882a593Smuzhiyun * cvmx_pow_work_response_async. This function waits for any previous
1458*4882a593Smuzhiyun * tag switch to complete before requesting the new work.
1459*4882a593Smuzhiyun *
1460*4882a593Smuzhiyun * @scr_addr: Scratch memory address that response will be returned
1461*4882a593Smuzhiyun * to, which is either a valid WQE, or a response with the
1462*4882a593Smuzhiyun * invalid bit set. Byte address, must be 8 byte aligned.
1463*4882a593Smuzhiyun *
1464*4882a593Smuzhiyun * @wait: 1 to cause response to wait for work to become available (or
1465*4882a593Smuzhiyun * timeout), 0 to cause response to return immediately
1466*4882a593Smuzhiyun */
cvmx_pow_work_request_async(int scr_addr,cvmx_pow_wait_t wait)1467*4882a593Smuzhiyun static inline void cvmx_pow_work_request_async(int scr_addr,
1468*4882a593Smuzhiyun cvmx_pow_wait_t wait)
1469*4882a593Smuzhiyun {
1470*4882a593Smuzhiyun if (CVMX_ENABLE_POW_CHECKS)
1471*4882a593Smuzhiyun __cvmx_pow_warn_if_pending_switch(__func__);
1472*4882a593Smuzhiyun
1473*4882a593Smuzhiyun /* Must not have a switch pending when requesting work */
1474*4882a593Smuzhiyun cvmx_pow_tag_sw_wait();
1475*4882a593Smuzhiyun cvmx_pow_work_request_async_nocheck(scr_addr, wait);
1476*4882a593Smuzhiyun }
1477*4882a593Smuzhiyun
1478*4882a593Smuzhiyun /**
1479*4882a593Smuzhiyun * Gets result of asynchronous work request. Performs a IOBDMA sync
1480*4882a593Smuzhiyun * to wait for the response.
1481*4882a593Smuzhiyun *
1482*4882a593Smuzhiyun * @scr_addr: Scratch memory address to get result from Byte address,
1483*4882a593Smuzhiyun * must be 8 byte aligned.
1484*4882a593Smuzhiyun *
1485*4882a593Smuzhiyun * Returns: the WQE from the scratch register, or NULL if no
1486*4882a593Smuzhiyun * work was available.
1487*4882a593Smuzhiyun */
cvmx_pow_work_response_async(int scr_addr)1488*4882a593Smuzhiyun static inline struct cvmx_wqe *cvmx_pow_work_response_async(int scr_addr)
1489*4882a593Smuzhiyun {
1490*4882a593Smuzhiyun cvmx_pow_tag_load_resp_t result;
1491*4882a593Smuzhiyun
1492*4882a593Smuzhiyun CVMX_SYNCIOBDMA;
1493*4882a593Smuzhiyun result.u64 = cvmx_scratch_read64(scr_addr);
1494*4882a593Smuzhiyun
1495*4882a593Smuzhiyun if (result.s_work.no_work)
1496*4882a593Smuzhiyun return NULL;
1497*4882a593Smuzhiyun else
1498*4882a593Smuzhiyun return (struct cvmx_wqe *) cvmx_phys_to_ptr(result.s_work.addr);
1499*4882a593Smuzhiyun }
1500*4882a593Smuzhiyun
1501*4882a593Smuzhiyun /**
1502*4882a593Smuzhiyun * Checks if a work queue entry pointer returned by a work
1503*4882a593Smuzhiyun * request is valid. It may be invalid due to no work
1504*4882a593Smuzhiyun * being available or due to a timeout.
1505*4882a593Smuzhiyun *
1506*4882a593Smuzhiyun * @wqe_ptr: pointer to a work queue entry returned by the POW
1507*4882a593Smuzhiyun *
1508*4882a593Smuzhiyun * Returns 0 if pointer is valid
1509*4882a593Smuzhiyun * 1 if invalid (no work was returned)
1510*4882a593Smuzhiyun */
cvmx_pow_work_invalid(struct cvmx_wqe * wqe_ptr)1511*4882a593Smuzhiyun static inline uint64_t cvmx_pow_work_invalid(struct cvmx_wqe *wqe_ptr)
1512*4882a593Smuzhiyun {
1513*4882a593Smuzhiyun return wqe_ptr == NULL;
1514*4882a593Smuzhiyun }
1515*4882a593Smuzhiyun
1516*4882a593Smuzhiyun /**
1517*4882a593Smuzhiyun * Starts a tag switch to the provided tag value and tag type.
1518*4882a593Smuzhiyun * Completion for the tag switch must be checked for separately. This
1519*4882a593Smuzhiyun * function does NOT update the work queue entry in dram to match tag
1520*4882a593Smuzhiyun * value and type, so the application must keep track of these if they
1521*4882a593Smuzhiyun * are important to the application. This tag switch command must not
1522*4882a593Smuzhiyun * be used for switches to NULL, as the tag switch pending bit will be
1523*4882a593Smuzhiyun * set by the switch request, but never cleared by the hardware.
1524*4882a593Smuzhiyun *
1525*4882a593Smuzhiyun * NOTE: This should not be used when switching from a NULL tag. Use
1526*4882a593Smuzhiyun * cvmx_pow_tag_sw_full() instead.
1527*4882a593Smuzhiyun *
1528*4882a593Smuzhiyun * This function does no checks, so the caller must ensure that any
1529*4882a593Smuzhiyun * previous tag switch has completed.
1530*4882a593Smuzhiyun *
1531*4882a593Smuzhiyun * @tag: new tag value
1532*4882a593Smuzhiyun * @tag_type: new tag type (ordered or atomic)
1533*4882a593Smuzhiyun */
cvmx_pow_tag_sw_nocheck(uint32_t tag,enum cvmx_pow_tag_type tag_type)1534*4882a593Smuzhiyun static inline void cvmx_pow_tag_sw_nocheck(uint32_t tag,
1535*4882a593Smuzhiyun enum cvmx_pow_tag_type tag_type)
1536*4882a593Smuzhiyun {
1537*4882a593Smuzhiyun cvmx_addr_t ptr;
1538*4882a593Smuzhiyun cvmx_pow_tag_req_t tag_req;
1539*4882a593Smuzhiyun
1540*4882a593Smuzhiyun if (CVMX_ENABLE_POW_CHECKS) {
1541*4882a593Smuzhiyun cvmx_pow_tag_req_t current_tag;
1542*4882a593Smuzhiyun __cvmx_pow_warn_if_pending_switch(__func__);
1543*4882a593Smuzhiyun current_tag = cvmx_pow_get_current_tag();
1544*4882a593Smuzhiyun if (current_tag.s.type == CVMX_POW_TAG_TYPE_NULL_NULL)
1545*4882a593Smuzhiyun pr_warn("%s called with NULL_NULL tag\n", __func__);
1546*4882a593Smuzhiyun if (current_tag.s.type == CVMX_POW_TAG_TYPE_NULL)
1547*4882a593Smuzhiyun pr_warn("%s called with NULL tag\n", __func__);
1548*4882a593Smuzhiyun if ((current_tag.s.type == tag_type)
1549*4882a593Smuzhiyun && (current_tag.s.tag == tag))
1550*4882a593Smuzhiyun pr_warn("%s called to perform a tag switch to the same tag\n",
1551*4882a593Smuzhiyun __func__);
1552*4882a593Smuzhiyun if (tag_type == CVMX_POW_TAG_TYPE_NULL)
1553*4882a593Smuzhiyun pr_warn("%s called to perform a tag switch to NULL. Use cvmx_pow_tag_sw_null() instead\n",
1554*4882a593Smuzhiyun __func__);
1555*4882a593Smuzhiyun }
1556*4882a593Smuzhiyun
1557*4882a593Smuzhiyun /*
1558*4882a593Smuzhiyun * Note that WQE in DRAM is not updated here, as the POW does
1559*4882a593Smuzhiyun * not read from DRAM once the WQE is in flight. See hardware
1560*4882a593Smuzhiyun * manual for complete details. It is the application's
1561*4882a593Smuzhiyun * responsibility to keep track of the current tag value if
1562*4882a593Smuzhiyun * that is important.
1563*4882a593Smuzhiyun */
1564*4882a593Smuzhiyun
1565*4882a593Smuzhiyun tag_req.u64 = 0;
1566*4882a593Smuzhiyun tag_req.s.op = CVMX_POW_TAG_OP_SWTAG;
1567*4882a593Smuzhiyun tag_req.s.tag = tag;
1568*4882a593Smuzhiyun tag_req.s.type = tag_type;
1569*4882a593Smuzhiyun
1570*4882a593Smuzhiyun ptr.u64 = 0;
1571*4882a593Smuzhiyun ptr.sio.mem_region = CVMX_IO_SEG;
1572*4882a593Smuzhiyun ptr.sio.is_io = 1;
1573*4882a593Smuzhiyun ptr.sio.did = CVMX_OCT_DID_TAG_SWTAG;
1574*4882a593Smuzhiyun
1575*4882a593Smuzhiyun /* once this store arrives at POW, it will attempt the switch
1576*4882a593Smuzhiyun software must wait for the switch to complete separately */
1577*4882a593Smuzhiyun cvmx_write_io(ptr.u64, tag_req.u64);
1578*4882a593Smuzhiyun }
1579*4882a593Smuzhiyun
1580*4882a593Smuzhiyun /**
1581*4882a593Smuzhiyun * Starts a tag switch to the provided tag value and tag type.
1582*4882a593Smuzhiyun * Completion for the tag switch must be checked for separately. This
1583*4882a593Smuzhiyun * function does NOT update the work queue entry in dram to match tag
1584*4882a593Smuzhiyun * value and type, so the application must keep track of these if they
1585*4882a593Smuzhiyun * are important to the application. This tag switch command must not
1586*4882a593Smuzhiyun * be used for switches to NULL, as the tag switch pending bit will be
1587*4882a593Smuzhiyun * set by the switch request, but never cleared by the hardware.
1588*4882a593Smuzhiyun *
1589*4882a593Smuzhiyun * NOTE: This should not be used when switching from a NULL tag. Use
1590*4882a593Smuzhiyun * cvmx_pow_tag_sw_full() instead.
1591*4882a593Smuzhiyun *
1592*4882a593Smuzhiyun * This function waits for any previous tag switch to complete, and also
1593*4882a593Smuzhiyun * displays an error on tag switches to NULL.
1594*4882a593Smuzhiyun *
1595*4882a593Smuzhiyun * @tag: new tag value
1596*4882a593Smuzhiyun * @tag_type: new tag type (ordered or atomic)
1597*4882a593Smuzhiyun */
cvmx_pow_tag_sw(uint32_t tag,enum cvmx_pow_tag_type tag_type)1598*4882a593Smuzhiyun static inline void cvmx_pow_tag_sw(uint32_t tag,
1599*4882a593Smuzhiyun enum cvmx_pow_tag_type tag_type)
1600*4882a593Smuzhiyun {
1601*4882a593Smuzhiyun if (CVMX_ENABLE_POW_CHECKS)
1602*4882a593Smuzhiyun __cvmx_pow_warn_if_pending_switch(__func__);
1603*4882a593Smuzhiyun
1604*4882a593Smuzhiyun /*
1605*4882a593Smuzhiyun * Note that WQE in DRAM is not updated here, as the POW does
1606*4882a593Smuzhiyun * not read from DRAM once the WQE is in flight. See hardware
1607*4882a593Smuzhiyun * manual for complete details. It is the application's
1608*4882a593Smuzhiyun * responsibility to keep track of the current tag value if
1609*4882a593Smuzhiyun * that is important.
1610*4882a593Smuzhiyun */
1611*4882a593Smuzhiyun
1612*4882a593Smuzhiyun /*
1613*4882a593Smuzhiyun * Ensure that there is not a pending tag switch, as a tag
1614*4882a593Smuzhiyun * switch cannot be started if a previous switch is still
1615*4882a593Smuzhiyun * pending.
1616*4882a593Smuzhiyun */
1617*4882a593Smuzhiyun cvmx_pow_tag_sw_wait();
1618*4882a593Smuzhiyun cvmx_pow_tag_sw_nocheck(tag, tag_type);
1619*4882a593Smuzhiyun }
1620*4882a593Smuzhiyun
1621*4882a593Smuzhiyun /**
1622*4882a593Smuzhiyun * Starts a tag switch to the provided tag value and tag type.
1623*4882a593Smuzhiyun * Completion for the tag switch must be checked for separately. This
1624*4882a593Smuzhiyun * function does NOT update the work queue entry in dram to match tag
1625*4882a593Smuzhiyun * value and type, so the application must keep track of these if they
1626*4882a593Smuzhiyun * are important to the application. This tag switch command must not
1627*4882a593Smuzhiyun * be used for switches to NULL, as the tag switch pending bit will be
1628*4882a593Smuzhiyun * set by the switch request, but never cleared by the hardware.
1629*4882a593Smuzhiyun *
1630*4882a593Smuzhiyun * This function must be used for tag switches from NULL.
1631*4882a593Smuzhiyun *
1632*4882a593Smuzhiyun * This function does no checks, so the caller must ensure that any
1633*4882a593Smuzhiyun * previous tag switch has completed.
1634*4882a593Smuzhiyun *
1635*4882a593Smuzhiyun * @wqp: pointer to work queue entry to submit. This entry is
1636*4882a593Smuzhiyun * updated to match the other parameters
1637*4882a593Smuzhiyun * @tag: tag value to be assigned to work queue entry
1638*4882a593Smuzhiyun * @tag_type: type of tag
1639*4882a593Smuzhiyun * @group: group value for the work queue entry.
1640*4882a593Smuzhiyun */
cvmx_pow_tag_sw_full_nocheck(struct cvmx_wqe * wqp,uint32_t tag,enum cvmx_pow_tag_type tag_type,uint64_t group)1641*4882a593Smuzhiyun static inline void cvmx_pow_tag_sw_full_nocheck(struct cvmx_wqe *wqp, uint32_t tag,
1642*4882a593Smuzhiyun enum cvmx_pow_tag_type tag_type,
1643*4882a593Smuzhiyun uint64_t group)
1644*4882a593Smuzhiyun {
1645*4882a593Smuzhiyun cvmx_addr_t ptr;
1646*4882a593Smuzhiyun cvmx_pow_tag_req_t tag_req;
1647*4882a593Smuzhiyun
1648*4882a593Smuzhiyun if (CVMX_ENABLE_POW_CHECKS) {
1649*4882a593Smuzhiyun cvmx_pow_tag_req_t current_tag;
1650*4882a593Smuzhiyun __cvmx_pow_warn_if_pending_switch(__func__);
1651*4882a593Smuzhiyun current_tag = cvmx_pow_get_current_tag();
1652*4882a593Smuzhiyun if (current_tag.s.type == CVMX_POW_TAG_TYPE_NULL_NULL)
1653*4882a593Smuzhiyun pr_warn("%s called with NULL_NULL tag\n", __func__);
1654*4882a593Smuzhiyun if ((current_tag.s.type == tag_type)
1655*4882a593Smuzhiyun && (current_tag.s.tag == tag))
1656*4882a593Smuzhiyun pr_warn("%s called to perform a tag switch to the same tag\n",
1657*4882a593Smuzhiyun __func__);
1658*4882a593Smuzhiyun if (tag_type == CVMX_POW_TAG_TYPE_NULL)
1659*4882a593Smuzhiyun pr_warn("%s called to perform a tag switch to NULL. Use cvmx_pow_tag_sw_null() instead\n",
1660*4882a593Smuzhiyun __func__);
1661*4882a593Smuzhiyun if (wqp != cvmx_phys_to_ptr(0x80))
1662*4882a593Smuzhiyun if (wqp != cvmx_pow_get_current_wqp())
1663*4882a593Smuzhiyun pr_warn("%s passed WQE(%p) doesn't match the address in the POW(%p)\n",
1664*4882a593Smuzhiyun __func__, wqp,
1665*4882a593Smuzhiyun cvmx_pow_get_current_wqp());
1666*4882a593Smuzhiyun }
1667*4882a593Smuzhiyun
1668*4882a593Smuzhiyun /*
1669*4882a593Smuzhiyun * Note that WQE in DRAM is not updated here, as the POW does
1670*4882a593Smuzhiyun * not read from DRAM once the WQE is in flight. See hardware
1671*4882a593Smuzhiyun * manual for complete details. It is the application's
1672*4882a593Smuzhiyun * responsibility to keep track of the current tag value if
1673*4882a593Smuzhiyun * that is important.
1674*4882a593Smuzhiyun */
1675*4882a593Smuzhiyun
1676*4882a593Smuzhiyun tag_req.u64 = 0;
1677*4882a593Smuzhiyun tag_req.s.op = CVMX_POW_TAG_OP_SWTAG_FULL;
1678*4882a593Smuzhiyun tag_req.s.tag = tag;
1679*4882a593Smuzhiyun tag_req.s.type = tag_type;
1680*4882a593Smuzhiyun tag_req.s.grp = group;
1681*4882a593Smuzhiyun
1682*4882a593Smuzhiyun ptr.u64 = 0;
1683*4882a593Smuzhiyun ptr.sio.mem_region = CVMX_IO_SEG;
1684*4882a593Smuzhiyun ptr.sio.is_io = 1;
1685*4882a593Smuzhiyun ptr.sio.did = CVMX_OCT_DID_TAG_SWTAG;
1686*4882a593Smuzhiyun ptr.sio.offset = CAST64(wqp);
1687*4882a593Smuzhiyun
1688*4882a593Smuzhiyun /*
1689*4882a593Smuzhiyun * once this store arrives at POW, it will attempt the switch
1690*4882a593Smuzhiyun * software must wait for the switch to complete separately.
1691*4882a593Smuzhiyun */
1692*4882a593Smuzhiyun cvmx_write_io(ptr.u64, tag_req.u64);
1693*4882a593Smuzhiyun }
1694*4882a593Smuzhiyun
1695*4882a593Smuzhiyun /**
1696*4882a593Smuzhiyun * Starts a tag switch to the provided tag value and tag type.
1697*4882a593Smuzhiyun * Completion for the tag switch must be checked for separately. This
1698*4882a593Smuzhiyun * function does NOT update the work queue entry in dram to match tag
1699*4882a593Smuzhiyun * value and type, so the application must keep track of these if they
1700*4882a593Smuzhiyun * are important to the application. This tag switch command must not
1701*4882a593Smuzhiyun * be used for switches to NULL, as the tag switch pending bit will be
1702*4882a593Smuzhiyun * set by the switch request, but never cleared by the hardware.
1703*4882a593Smuzhiyun *
1704*4882a593Smuzhiyun * This function must be used for tag switches from NULL.
1705*4882a593Smuzhiyun *
1706*4882a593Smuzhiyun * This function waits for any pending tag switches to complete
1707*4882a593Smuzhiyun * before requesting the tag switch.
1708*4882a593Smuzhiyun *
1709*4882a593Smuzhiyun * @wqp: pointer to work queue entry to submit. This entry is updated
1710*4882a593Smuzhiyun * to match the other parameters
1711*4882a593Smuzhiyun * @tag: tag value to be assigned to work queue entry
1712*4882a593Smuzhiyun * @tag_type: type of tag
1713*4882a593Smuzhiyun * @group: group value for the work queue entry.
1714*4882a593Smuzhiyun */
cvmx_pow_tag_sw_full(struct cvmx_wqe * wqp,uint32_t tag,enum cvmx_pow_tag_type tag_type,uint64_t group)1715*4882a593Smuzhiyun static inline void cvmx_pow_tag_sw_full(struct cvmx_wqe *wqp, uint32_t tag,
1716*4882a593Smuzhiyun enum cvmx_pow_tag_type tag_type,
1717*4882a593Smuzhiyun uint64_t group)
1718*4882a593Smuzhiyun {
1719*4882a593Smuzhiyun if (CVMX_ENABLE_POW_CHECKS)
1720*4882a593Smuzhiyun __cvmx_pow_warn_if_pending_switch(__func__);
1721*4882a593Smuzhiyun
1722*4882a593Smuzhiyun /*
1723*4882a593Smuzhiyun * Ensure that there is not a pending tag switch, as a tag
1724*4882a593Smuzhiyun * switch cannot be started if a previous switch is still
1725*4882a593Smuzhiyun * pending.
1726*4882a593Smuzhiyun */
1727*4882a593Smuzhiyun cvmx_pow_tag_sw_wait();
1728*4882a593Smuzhiyun cvmx_pow_tag_sw_full_nocheck(wqp, tag, tag_type, group);
1729*4882a593Smuzhiyun }
1730*4882a593Smuzhiyun
1731*4882a593Smuzhiyun /**
1732*4882a593Smuzhiyun * Switch to a NULL tag, which ends any ordering or
1733*4882a593Smuzhiyun * synchronization provided by the POW for the current
1734*4882a593Smuzhiyun * work queue entry. This operation completes immediately,
1735*4882a593Smuzhiyun * so completion should not be waited for.
1736*4882a593Smuzhiyun * This function does NOT wait for previous tag switches to complete,
1737*4882a593Smuzhiyun * so the caller must ensure that any previous tag switches have completed.
1738*4882a593Smuzhiyun */
cvmx_pow_tag_sw_null_nocheck(void)1739*4882a593Smuzhiyun static inline void cvmx_pow_tag_sw_null_nocheck(void)
1740*4882a593Smuzhiyun {
1741*4882a593Smuzhiyun cvmx_addr_t ptr;
1742*4882a593Smuzhiyun cvmx_pow_tag_req_t tag_req;
1743*4882a593Smuzhiyun
1744*4882a593Smuzhiyun if (CVMX_ENABLE_POW_CHECKS) {
1745*4882a593Smuzhiyun cvmx_pow_tag_req_t current_tag;
1746*4882a593Smuzhiyun __cvmx_pow_warn_if_pending_switch(__func__);
1747*4882a593Smuzhiyun current_tag = cvmx_pow_get_current_tag();
1748*4882a593Smuzhiyun if (current_tag.s.type == CVMX_POW_TAG_TYPE_NULL_NULL)
1749*4882a593Smuzhiyun pr_warn("%s called with NULL_NULL tag\n", __func__);
1750*4882a593Smuzhiyun if (current_tag.s.type == CVMX_POW_TAG_TYPE_NULL)
1751*4882a593Smuzhiyun pr_warn("%s called when we already have a NULL tag\n",
1752*4882a593Smuzhiyun __func__);
1753*4882a593Smuzhiyun }
1754*4882a593Smuzhiyun
1755*4882a593Smuzhiyun tag_req.u64 = 0;
1756*4882a593Smuzhiyun tag_req.s.op = CVMX_POW_TAG_OP_SWTAG;
1757*4882a593Smuzhiyun tag_req.s.type = CVMX_POW_TAG_TYPE_NULL;
1758*4882a593Smuzhiyun
1759*4882a593Smuzhiyun ptr.u64 = 0;
1760*4882a593Smuzhiyun ptr.sio.mem_region = CVMX_IO_SEG;
1761*4882a593Smuzhiyun ptr.sio.is_io = 1;
1762*4882a593Smuzhiyun ptr.sio.did = CVMX_OCT_DID_TAG_TAG1;
1763*4882a593Smuzhiyun
1764*4882a593Smuzhiyun cvmx_write_io(ptr.u64, tag_req.u64);
1765*4882a593Smuzhiyun
1766*4882a593Smuzhiyun /* switch to NULL completes immediately */
1767*4882a593Smuzhiyun }
1768*4882a593Smuzhiyun
1769*4882a593Smuzhiyun /**
1770*4882a593Smuzhiyun * Switch to a NULL tag, which ends any ordering or
1771*4882a593Smuzhiyun * synchronization provided by the POW for the current
1772*4882a593Smuzhiyun * work queue entry. This operation completes immediately,
1773*4882a593Smuzhiyun * so completion should not be waited for.
1774*4882a593Smuzhiyun * This function waits for any pending tag switches to complete
1775*4882a593Smuzhiyun * before requesting the switch to NULL.
1776*4882a593Smuzhiyun */
cvmx_pow_tag_sw_null(void)1777*4882a593Smuzhiyun static inline void cvmx_pow_tag_sw_null(void)
1778*4882a593Smuzhiyun {
1779*4882a593Smuzhiyun if (CVMX_ENABLE_POW_CHECKS)
1780*4882a593Smuzhiyun __cvmx_pow_warn_if_pending_switch(__func__);
1781*4882a593Smuzhiyun
1782*4882a593Smuzhiyun /*
1783*4882a593Smuzhiyun * Ensure that there is not a pending tag switch, as a tag
1784*4882a593Smuzhiyun * switch cannot be started if a previous switch is still
1785*4882a593Smuzhiyun * pending.
1786*4882a593Smuzhiyun */
1787*4882a593Smuzhiyun cvmx_pow_tag_sw_wait();
1788*4882a593Smuzhiyun cvmx_pow_tag_sw_null_nocheck();
1789*4882a593Smuzhiyun
1790*4882a593Smuzhiyun /* switch to NULL completes immediately */
1791*4882a593Smuzhiyun }
1792*4882a593Smuzhiyun
1793*4882a593Smuzhiyun /**
1794*4882a593Smuzhiyun * Submits work to an input queue. This function updates the work
1795*4882a593Smuzhiyun * queue entry in DRAM to match the arguments given. Note that the
1796*4882a593Smuzhiyun * tag provided is for the work queue entry submitted, and is
1797*4882a593Smuzhiyun * unrelated to the tag that the core currently holds.
1798*4882a593Smuzhiyun *
1799*4882a593Smuzhiyun * @wqp: pointer to work queue entry to submit. This entry is
1800*4882a593Smuzhiyun * updated to match the other parameters
1801*4882a593Smuzhiyun * @tag: tag value to be assigned to work queue entry
1802*4882a593Smuzhiyun * @tag_type: type of tag
1803*4882a593Smuzhiyun * @qos: Input queue to add to.
1804*4882a593Smuzhiyun * @grp: group value for the work queue entry.
1805*4882a593Smuzhiyun */
cvmx_pow_work_submit(struct cvmx_wqe * wqp,uint32_t tag,enum cvmx_pow_tag_type tag_type,uint64_t qos,uint64_t grp)1806*4882a593Smuzhiyun static inline void cvmx_pow_work_submit(struct cvmx_wqe *wqp, uint32_t tag,
1807*4882a593Smuzhiyun enum cvmx_pow_tag_type tag_type,
1808*4882a593Smuzhiyun uint64_t qos, uint64_t grp)
1809*4882a593Smuzhiyun {
1810*4882a593Smuzhiyun cvmx_addr_t ptr;
1811*4882a593Smuzhiyun cvmx_pow_tag_req_t tag_req;
1812*4882a593Smuzhiyun
1813*4882a593Smuzhiyun wqp->word1.tag = tag;
1814*4882a593Smuzhiyun wqp->word1.tag_type = tag_type;
1815*4882a593Smuzhiyun
1816*4882a593Smuzhiyun cvmx_wqe_set_qos(wqp, qos);
1817*4882a593Smuzhiyun cvmx_wqe_set_grp(wqp, grp);
1818*4882a593Smuzhiyun
1819*4882a593Smuzhiyun tag_req.u64 = 0;
1820*4882a593Smuzhiyun tag_req.s.op = CVMX_POW_TAG_OP_ADDWQ;
1821*4882a593Smuzhiyun tag_req.s.type = tag_type;
1822*4882a593Smuzhiyun tag_req.s.tag = tag;
1823*4882a593Smuzhiyun tag_req.s.qos = qos;
1824*4882a593Smuzhiyun tag_req.s.grp = grp;
1825*4882a593Smuzhiyun
1826*4882a593Smuzhiyun ptr.u64 = 0;
1827*4882a593Smuzhiyun ptr.sio.mem_region = CVMX_IO_SEG;
1828*4882a593Smuzhiyun ptr.sio.is_io = 1;
1829*4882a593Smuzhiyun ptr.sio.did = CVMX_OCT_DID_TAG_TAG1;
1830*4882a593Smuzhiyun ptr.sio.offset = cvmx_ptr_to_phys(wqp);
1831*4882a593Smuzhiyun
1832*4882a593Smuzhiyun /*
1833*4882a593Smuzhiyun * SYNC write to memory before the work submit. This is
1834*4882a593Smuzhiyun * necessary as POW may read values from DRAM at this time.
1835*4882a593Smuzhiyun */
1836*4882a593Smuzhiyun CVMX_SYNCWS;
1837*4882a593Smuzhiyun cvmx_write_io(ptr.u64, tag_req.u64);
1838*4882a593Smuzhiyun }
1839*4882a593Smuzhiyun
1840*4882a593Smuzhiyun /**
1841*4882a593Smuzhiyun * This function sets the group mask for a core. The group mask
1842*4882a593Smuzhiyun * indicates which groups each core will accept work from. There are
1843*4882a593Smuzhiyun * 16 groups.
1844*4882a593Smuzhiyun *
1845*4882a593Smuzhiyun * @core_num: core to apply mask to
1846*4882a593Smuzhiyun * @mask: Group mask. There are 16 groups, so only bits 0-15 are valid,
1847*4882a593Smuzhiyun * representing groups 0-15.
1848*4882a593Smuzhiyun * Each 1 bit in the mask enables the core to accept work from
1849*4882a593Smuzhiyun * the corresponding group.
1850*4882a593Smuzhiyun */
cvmx_pow_set_group_mask(uint64_t core_num,uint64_t mask)1851*4882a593Smuzhiyun static inline void cvmx_pow_set_group_mask(uint64_t core_num, uint64_t mask)
1852*4882a593Smuzhiyun {
1853*4882a593Smuzhiyun union cvmx_pow_pp_grp_mskx grp_msk;
1854*4882a593Smuzhiyun
1855*4882a593Smuzhiyun grp_msk.u64 = cvmx_read_csr(CVMX_POW_PP_GRP_MSKX(core_num));
1856*4882a593Smuzhiyun grp_msk.s.grp_msk = mask;
1857*4882a593Smuzhiyun cvmx_write_csr(CVMX_POW_PP_GRP_MSKX(core_num), grp_msk.u64);
1858*4882a593Smuzhiyun }
1859*4882a593Smuzhiyun
1860*4882a593Smuzhiyun /**
1861*4882a593Smuzhiyun * This function sets POW static priorities for a core. Each input queue has
1862*4882a593Smuzhiyun * an associated priority value.
1863*4882a593Smuzhiyun *
1864*4882a593Smuzhiyun * @core_num: core to apply priorities to
1865*4882a593Smuzhiyun * @priority: Vector of 8 priorities, one per POW Input Queue (0-7).
1866*4882a593Smuzhiyun * Highest priority is 0 and lowest is 7. A priority value
1867*4882a593Smuzhiyun * of 0xF instructs POW to skip the Input Queue when
1868*4882a593Smuzhiyun * scheduling to this specific core.
1869*4882a593Smuzhiyun * NOTE: priorities should not have gaps in values, meaning
1870*4882a593Smuzhiyun * {0,1,1,1,1,1,1,1} is a valid configuration while
1871*4882a593Smuzhiyun * {0,2,2,2,2,2,2,2} is not.
1872*4882a593Smuzhiyun */
cvmx_pow_set_priority(uint64_t core_num,const uint8_t priority[])1873*4882a593Smuzhiyun static inline void cvmx_pow_set_priority(uint64_t core_num,
1874*4882a593Smuzhiyun const uint8_t priority[])
1875*4882a593Smuzhiyun {
1876*4882a593Smuzhiyun /* POW priorities are supported on CN5xxx and later */
1877*4882a593Smuzhiyun if (!OCTEON_IS_MODEL(OCTEON_CN3XXX)) {
1878*4882a593Smuzhiyun union cvmx_pow_pp_grp_mskx grp_msk;
1879*4882a593Smuzhiyun
1880*4882a593Smuzhiyun grp_msk.u64 = cvmx_read_csr(CVMX_POW_PP_GRP_MSKX(core_num));
1881*4882a593Smuzhiyun grp_msk.s.qos0_pri = priority[0];
1882*4882a593Smuzhiyun grp_msk.s.qos1_pri = priority[1];
1883*4882a593Smuzhiyun grp_msk.s.qos2_pri = priority[2];
1884*4882a593Smuzhiyun grp_msk.s.qos3_pri = priority[3];
1885*4882a593Smuzhiyun grp_msk.s.qos4_pri = priority[4];
1886*4882a593Smuzhiyun grp_msk.s.qos5_pri = priority[5];
1887*4882a593Smuzhiyun grp_msk.s.qos6_pri = priority[6];
1888*4882a593Smuzhiyun grp_msk.s.qos7_pri = priority[7];
1889*4882a593Smuzhiyun
1890*4882a593Smuzhiyun /* Detect gaps between priorities and flag error */
1891*4882a593Smuzhiyun {
1892*4882a593Smuzhiyun int i;
1893*4882a593Smuzhiyun uint32_t prio_mask = 0;
1894*4882a593Smuzhiyun
1895*4882a593Smuzhiyun for (i = 0; i < 8; i++)
1896*4882a593Smuzhiyun if (priority[i] != 0xF)
1897*4882a593Smuzhiyun prio_mask |= 1 << priority[i];
1898*4882a593Smuzhiyun
1899*4882a593Smuzhiyun if (prio_mask ^ ((1 << cvmx_pop(prio_mask)) - 1)) {
1900*4882a593Smuzhiyun pr_err("POW static priorities should be "
1901*4882a593Smuzhiyun "contiguous (0x%llx)\n",
1902*4882a593Smuzhiyun (unsigned long long)prio_mask);
1903*4882a593Smuzhiyun return;
1904*4882a593Smuzhiyun }
1905*4882a593Smuzhiyun }
1906*4882a593Smuzhiyun
1907*4882a593Smuzhiyun cvmx_write_csr(CVMX_POW_PP_GRP_MSKX(core_num), grp_msk.u64);
1908*4882a593Smuzhiyun }
1909*4882a593Smuzhiyun }
1910*4882a593Smuzhiyun
1911*4882a593Smuzhiyun /**
1912*4882a593Smuzhiyun * Performs a tag switch and then an immediate deschedule. This completes
1913*4882a593Smuzhiyun * immediately, so completion must not be waited for. This function does NOT
1914*4882a593Smuzhiyun * update the wqe in DRAM to match arguments.
1915*4882a593Smuzhiyun *
1916*4882a593Smuzhiyun * This function does NOT wait for any prior tag switches to complete, so the
1917*4882a593Smuzhiyun * calling code must do this.
1918*4882a593Smuzhiyun *
1919*4882a593Smuzhiyun * Note the following CAVEAT of the Octeon HW behavior when
1920*4882a593Smuzhiyun * re-scheduling DE-SCHEDULEd items whose (next) state is
1921*4882a593Smuzhiyun * ORDERED:
1922*4882a593Smuzhiyun * - If there are no switches pending at the time that the
1923*4882a593Smuzhiyun * HW executes the de-schedule, the HW will only re-schedule
1924*4882a593Smuzhiyun * the head of the FIFO associated with the given tag. This
1925*4882a593Smuzhiyun * means that in many respects, the HW treats this ORDERED
1926*4882a593Smuzhiyun * tag as an ATOMIC tag. Note that in the SWTAG_DESCH
1927*4882a593Smuzhiyun * case (to an ORDERED tag), the HW will do the switch
1928*4882a593Smuzhiyun * before the deschedule whenever it is possible to do
1929*4882a593Smuzhiyun * the switch immediately, so it may often look like
1930*4882a593Smuzhiyun * this case.
1931*4882a593Smuzhiyun * - If there is a pending switch to ORDERED at the time
1932*4882a593Smuzhiyun * the HW executes the de-schedule, the HW will perform
1933*4882a593Smuzhiyun * the switch at the time it re-schedules, and will be
1934*4882a593Smuzhiyun * able to reschedule any/all of the entries with the
1935*4882a593Smuzhiyun * same tag.
1936*4882a593Smuzhiyun * Due to this behavior, the RECOMMENDATION to software is
1937*4882a593Smuzhiyun * that they have a (next) state of ATOMIC when they
1938*4882a593Smuzhiyun * DE-SCHEDULE. If an ORDERED tag is what was really desired,
1939*4882a593Smuzhiyun * SW can choose to immediately switch to an ORDERED tag
1940*4882a593Smuzhiyun * after the work (that has an ATOMIC tag) is re-scheduled.
1941*4882a593Smuzhiyun * Note that since there are never any tag switches pending
1942*4882a593Smuzhiyun * when the HW re-schedules, this switch can be IMMEDIATE upon
1943*4882a593Smuzhiyun * the reception of the pointer during the re-schedule.
1944*4882a593Smuzhiyun *
1945*4882a593Smuzhiyun * @tag: New tag value
1946*4882a593Smuzhiyun * @tag_type: New tag type
1947*4882a593Smuzhiyun * @group: New group value
1948*4882a593Smuzhiyun * @no_sched: Control whether this work queue entry will be rescheduled.
1949*4882a593Smuzhiyun * - 1 : don't schedule this work
1950*4882a593Smuzhiyun * - 0 : allow this work to be scheduled.
1951*4882a593Smuzhiyun */
cvmx_pow_tag_sw_desched_nocheck(uint32_t tag,enum cvmx_pow_tag_type tag_type,uint64_t group,uint64_t no_sched)1952*4882a593Smuzhiyun static inline void cvmx_pow_tag_sw_desched_nocheck(
1953*4882a593Smuzhiyun uint32_t tag,
1954*4882a593Smuzhiyun enum cvmx_pow_tag_type tag_type,
1955*4882a593Smuzhiyun uint64_t group,
1956*4882a593Smuzhiyun uint64_t no_sched)
1957*4882a593Smuzhiyun {
1958*4882a593Smuzhiyun cvmx_addr_t ptr;
1959*4882a593Smuzhiyun cvmx_pow_tag_req_t tag_req;
1960*4882a593Smuzhiyun
1961*4882a593Smuzhiyun if (CVMX_ENABLE_POW_CHECKS) {
1962*4882a593Smuzhiyun cvmx_pow_tag_req_t current_tag;
1963*4882a593Smuzhiyun __cvmx_pow_warn_if_pending_switch(__func__);
1964*4882a593Smuzhiyun current_tag = cvmx_pow_get_current_tag();
1965*4882a593Smuzhiyun if (current_tag.s.type == CVMX_POW_TAG_TYPE_NULL_NULL)
1966*4882a593Smuzhiyun pr_warn("%s called with NULL_NULL tag\n", __func__);
1967*4882a593Smuzhiyun if (current_tag.s.type == CVMX_POW_TAG_TYPE_NULL)
1968*4882a593Smuzhiyun pr_warn("%s called with NULL tag. Deschedule not allowed from NULL state\n",
1969*4882a593Smuzhiyun __func__);
1970*4882a593Smuzhiyun if ((current_tag.s.type != CVMX_POW_TAG_TYPE_ATOMIC)
1971*4882a593Smuzhiyun && (tag_type != CVMX_POW_TAG_TYPE_ATOMIC))
1972*4882a593Smuzhiyun pr_warn("%s called where neither the before or after tag is ATOMIC\n",
1973*4882a593Smuzhiyun __func__);
1974*4882a593Smuzhiyun }
1975*4882a593Smuzhiyun
1976*4882a593Smuzhiyun tag_req.u64 = 0;
1977*4882a593Smuzhiyun tag_req.s.op = CVMX_POW_TAG_OP_SWTAG_DESCH;
1978*4882a593Smuzhiyun tag_req.s.tag = tag;
1979*4882a593Smuzhiyun tag_req.s.type = tag_type;
1980*4882a593Smuzhiyun tag_req.s.grp = group;
1981*4882a593Smuzhiyun tag_req.s.no_sched = no_sched;
1982*4882a593Smuzhiyun
1983*4882a593Smuzhiyun ptr.u64 = 0;
1984*4882a593Smuzhiyun ptr.sio.mem_region = CVMX_IO_SEG;
1985*4882a593Smuzhiyun ptr.sio.is_io = 1;
1986*4882a593Smuzhiyun ptr.sio.did = CVMX_OCT_DID_TAG_TAG3;
1987*4882a593Smuzhiyun /*
1988*4882a593Smuzhiyun * since TAG3 is used, this store will clear the local pending
1989*4882a593Smuzhiyun * switch bit.
1990*4882a593Smuzhiyun */
1991*4882a593Smuzhiyun cvmx_write_io(ptr.u64, tag_req.u64);
1992*4882a593Smuzhiyun }
1993*4882a593Smuzhiyun
1994*4882a593Smuzhiyun /**
1995*4882a593Smuzhiyun * Performs a tag switch and then an immediate deschedule. This completes
1996*4882a593Smuzhiyun * immediately, so completion must not be waited for. This function does NOT
1997*4882a593Smuzhiyun * update the wqe in DRAM to match arguments.
1998*4882a593Smuzhiyun *
1999*4882a593Smuzhiyun * This function waits for any prior tag switches to complete, so the
2000*4882a593Smuzhiyun * calling code may call this function with a pending tag switch.
2001*4882a593Smuzhiyun *
2002*4882a593Smuzhiyun * Note the following CAVEAT of the Octeon HW behavior when
2003*4882a593Smuzhiyun * re-scheduling DE-SCHEDULEd items whose (next) state is
2004*4882a593Smuzhiyun * ORDERED:
2005*4882a593Smuzhiyun * - If there are no switches pending at the time that the
2006*4882a593Smuzhiyun * HW executes the de-schedule, the HW will only re-schedule
2007*4882a593Smuzhiyun * the head of the FIFO associated with the given tag. This
2008*4882a593Smuzhiyun * means that in many respects, the HW treats this ORDERED
2009*4882a593Smuzhiyun * tag as an ATOMIC tag. Note that in the SWTAG_DESCH
2010*4882a593Smuzhiyun * case (to an ORDERED tag), the HW will do the switch
2011*4882a593Smuzhiyun * before the deschedule whenever it is possible to do
2012*4882a593Smuzhiyun * the switch immediately, so it may often look like
2013*4882a593Smuzhiyun * this case.
2014*4882a593Smuzhiyun * - If there is a pending switch to ORDERED at the time
2015*4882a593Smuzhiyun * the HW executes the de-schedule, the HW will perform
2016*4882a593Smuzhiyun * the switch at the time it re-schedules, and will be
2017*4882a593Smuzhiyun * able to reschedule any/all of the entries with the
2018*4882a593Smuzhiyun * same tag.
2019*4882a593Smuzhiyun * Due to this behavior, the RECOMMENDATION to software is
2020*4882a593Smuzhiyun * that they have a (next) state of ATOMIC when they
2021*4882a593Smuzhiyun * DE-SCHEDULE. If an ORDERED tag is what was really desired,
2022*4882a593Smuzhiyun * SW can choose to immediately switch to an ORDERED tag
2023*4882a593Smuzhiyun * after the work (that has an ATOMIC tag) is re-scheduled.
2024*4882a593Smuzhiyun * Note that since there are never any tag switches pending
2025*4882a593Smuzhiyun * when the HW re-schedules, this switch can be IMMEDIATE upon
2026*4882a593Smuzhiyun * the reception of the pointer during the re-schedule.
2027*4882a593Smuzhiyun *
2028*4882a593Smuzhiyun * @tag: New tag value
2029*4882a593Smuzhiyun * @tag_type: New tag type
2030*4882a593Smuzhiyun * @group: New group value
2031*4882a593Smuzhiyun * @no_sched: Control whether this work queue entry will be rescheduled.
2032*4882a593Smuzhiyun * - 1 : don't schedule this work
2033*4882a593Smuzhiyun * - 0 : allow this work to be scheduled.
2034*4882a593Smuzhiyun */
cvmx_pow_tag_sw_desched(uint32_t tag,enum cvmx_pow_tag_type tag_type,uint64_t group,uint64_t no_sched)2035*4882a593Smuzhiyun static inline void cvmx_pow_tag_sw_desched(uint32_t tag,
2036*4882a593Smuzhiyun enum cvmx_pow_tag_type tag_type,
2037*4882a593Smuzhiyun uint64_t group, uint64_t no_sched)
2038*4882a593Smuzhiyun {
2039*4882a593Smuzhiyun if (CVMX_ENABLE_POW_CHECKS)
2040*4882a593Smuzhiyun __cvmx_pow_warn_if_pending_switch(__func__);
2041*4882a593Smuzhiyun
2042*4882a593Smuzhiyun /* Need to make sure any writes to the work queue entry are complete */
2043*4882a593Smuzhiyun CVMX_SYNCWS;
2044*4882a593Smuzhiyun /*
2045*4882a593Smuzhiyun * Ensure that there is not a pending tag switch, as a tag
2046*4882a593Smuzhiyun * switch cannot be started if a previous switch is still
2047*4882a593Smuzhiyun * pending.
2048*4882a593Smuzhiyun */
2049*4882a593Smuzhiyun cvmx_pow_tag_sw_wait();
2050*4882a593Smuzhiyun cvmx_pow_tag_sw_desched_nocheck(tag, tag_type, group, no_sched);
2051*4882a593Smuzhiyun }
2052*4882a593Smuzhiyun
2053*4882a593Smuzhiyun /**
2054*4882a593Smuzhiyun * Deschedules the current work queue entry.
2055*4882a593Smuzhiyun *
2056*4882a593Smuzhiyun * @no_sched: no schedule flag value to be set on the work queue
2057*4882a593Smuzhiyun * entry. If this is set the entry will not be
2058*4882a593Smuzhiyun * rescheduled.
2059*4882a593Smuzhiyun */
cvmx_pow_desched(uint64_t no_sched)2060*4882a593Smuzhiyun static inline void cvmx_pow_desched(uint64_t no_sched)
2061*4882a593Smuzhiyun {
2062*4882a593Smuzhiyun cvmx_addr_t ptr;
2063*4882a593Smuzhiyun cvmx_pow_tag_req_t tag_req;
2064*4882a593Smuzhiyun
2065*4882a593Smuzhiyun if (CVMX_ENABLE_POW_CHECKS) {
2066*4882a593Smuzhiyun cvmx_pow_tag_req_t current_tag;
2067*4882a593Smuzhiyun __cvmx_pow_warn_if_pending_switch(__func__);
2068*4882a593Smuzhiyun current_tag = cvmx_pow_get_current_tag();
2069*4882a593Smuzhiyun if (current_tag.s.type == CVMX_POW_TAG_TYPE_NULL_NULL)
2070*4882a593Smuzhiyun pr_warn("%s called with NULL_NULL tag\n", __func__);
2071*4882a593Smuzhiyun if (current_tag.s.type == CVMX_POW_TAG_TYPE_NULL)
2072*4882a593Smuzhiyun pr_warn("%s called with NULL tag. Deschedule not expected from NULL state\n",
2073*4882a593Smuzhiyun __func__);
2074*4882a593Smuzhiyun }
2075*4882a593Smuzhiyun
2076*4882a593Smuzhiyun /* Need to make sure any writes to the work queue entry are complete */
2077*4882a593Smuzhiyun CVMX_SYNCWS;
2078*4882a593Smuzhiyun
2079*4882a593Smuzhiyun tag_req.u64 = 0;
2080*4882a593Smuzhiyun tag_req.s.op = CVMX_POW_TAG_OP_DESCH;
2081*4882a593Smuzhiyun tag_req.s.no_sched = no_sched;
2082*4882a593Smuzhiyun
2083*4882a593Smuzhiyun ptr.u64 = 0;
2084*4882a593Smuzhiyun ptr.sio.mem_region = CVMX_IO_SEG;
2085*4882a593Smuzhiyun ptr.sio.is_io = 1;
2086*4882a593Smuzhiyun ptr.sio.did = CVMX_OCT_DID_TAG_TAG3;
2087*4882a593Smuzhiyun /*
2088*4882a593Smuzhiyun * since TAG3 is used, this store will clear the local pending
2089*4882a593Smuzhiyun * switch bit.
2090*4882a593Smuzhiyun */
2091*4882a593Smuzhiyun cvmx_write_io(ptr.u64, tag_req.u64);
2092*4882a593Smuzhiyun }
2093*4882a593Smuzhiyun
2094*4882a593Smuzhiyun /****************************************************
2095*4882a593Smuzhiyun * Define usage of bits within the 32 bit tag values.
2096*4882a593Smuzhiyun *****************************************************/
2097*4882a593Smuzhiyun
2098*4882a593Smuzhiyun /*
2099*4882a593Smuzhiyun * Number of bits of the tag used by software. The SW bits are always
2100*4882a593Smuzhiyun * a contiguous block of the high starting at bit 31. The hardware
2101*4882a593Smuzhiyun * bits are always the low bits. By default, the top 8 bits of the
2102*4882a593Smuzhiyun * tag are reserved for software, and the low 24 are set by the IPD
2103*4882a593Smuzhiyun * unit.
2104*4882a593Smuzhiyun */
2105*4882a593Smuzhiyun #define CVMX_TAG_SW_BITS (8)
2106*4882a593Smuzhiyun #define CVMX_TAG_SW_SHIFT (32 - CVMX_TAG_SW_BITS)
2107*4882a593Smuzhiyun
2108*4882a593Smuzhiyun /* Below is the list of values for the top 8 bits of the tag. */
2109*4882a593Smuzhiyun /*
2110*4882a593Smuzhiyun * Tag values with top byte of this value are reserved for internal
2111*4882a593Smuzhiyun * executive uses.
2112*4882a593Smuzhiyun */
2113*4882a593Smuzhiyun #define CVMX_TAG_SW_BITS_INTERNAL 0x1
2114*4882a593Smuzhiyun /* The executive divides the remaining 24 bits as follows:
2115*4882a593Smuzhiyun * - the upper 8 bits (bits 23 - 16 of the tag) define a subgroup
2116*4882a593Smuzhiyun *
2117*4882a593Smuzhiyun * - the lower 16 bits (bits 15 - 0 of the tag) define are the value
2118*4882a593Smuzhiyun * with the subgroup
2119*4882a593Smuzhiyun *
2120*4882a593Smuzhiyun * Note that this section describes the format of tags generated by
2121*4882a593Smuzhiyun * software - refer to the hardware documentation for a description of
2122*4882a593Smuzhiyun * the tags values generated by the packet input hardware. Subgroups
2123*4882a593Smuzhiyun * are defined here.
2124*4882a593Smuzhiyun */
2125*4882a593Smuzhiyun /* Mask for the value portion of the tag */
2126*4882a593Smuzhiyun #define CVMX_TAG_SUBGROUP_MASK 0xFFFF
2127*4882a593Smuzhiyun #define CVMX_TAG_SUBGROUP_SHIFT 16
2128*4882a593Smuzhiyun #define CVMX_TAG_SUBGROUP_PKO 0x1
2129*4882a593Smuzhiyun
2130*4882a593Smuzhiyun /* End of executive tag subgroup definitions */
2131*4882a593Smuzhiyun
2132*4882a593Smuzhiyun /*
2133*4882a593Smuzhiyun * The remaining values software bit values 0x2 - 0xff are available
2134*4882a593Smuzhiyun * for application use.
2135*4882a593Smuzhiyun */
2136*4882a593Smuzhiyun
2137*4882a593Smuzhiyun /**
2138*4882a593Smuzhiyun * This function creates a 32 bit tag value from the two values provided.
2139*4882a593Smuzhiyun *
2140*4882a593Smuzhiyun * @sw_bits: The upper bits (number depends on configuration) are set
2141*4882a593Smuzhiyun * to this value. The remainder of bits are set by the
2142*4882a593Smuzhiyun * hw_bits parameter.
2143*4882a593Smuzhiyun *
2144*4882a593Smuzhiyun * @hw_bits: The lower bits (number depends on configuration) are set
2145*4882a593Smuzhiyun * to this value. The remainder of bits are set by the
2146*4882a593Smuzhiyun * sw_bits parameter.
2147*4882a593Smuzhiyun *
2148*4882a593Smuzhiyun * Returns 32 bit value of the combined hw and sw bits.
2149*4882a593Smuzhiyun */
cvmx_pow_tag_compose(uint64_t sw_bits,uint64_t hw_bits)2150*4882a593Smuzhiyun static inline uint32_t cvmx_pow_tag_compose(uint64_t sw_bits, uint64_t hw_bits)
2151*4882a593Smuzhiyun {
2152*4882a593Smuzhiyun return ((sw_bits & cvmx_build_mask(CVMX_TAG_SW_BITS)) <<
2153*4882a593Smuzhiyun CVMX_TAG_SW_SHIFT) |
2154*4882a593Smuzhiyun (hw_bits & cvmx_build_mask(32 - CVMX_TAG_SW_BITS));
2155*4882a593Smuzhiyun }
2156*4882a593Smuzhiyun
2157*4882a593Smuzhiyun /**
2158*4882a593Smuzhiyun * Extracts the bits allocated for software use from the tag
2159*4882a593Smuzhiyun *
2160*4882a593Smuzhiyun * @tag: 32 bit tag value
2161*4882a593Smuzhiyun *
2162*4882a593Smuzhiyun * Returns N bit software tag value, where N is configurable with the
2163*4882a593Smuzhiyun * CVMX_TAG_SW_BITS define
2164*4882a593Smuzhiyun */
cvmx_pow_tag_get_sw_bits(uint64_t tag)2165*4882a593Smuzhiyun static inline uint32_t cvmx_pow_tag_get_sw_bits(uint64_t tag)
2166*4882a593Smuzhiyun {
2167*4882a593Smuzhiyun return (tag >> (32 - CVMX_TAG_SW_BITS)) &
2168*4882a593Smuzhiyun cvmx_build_mask(CVMX_TAG_SW_BITS);
2169*4882a593Smuzhiyun }
2170*4882a593Smuzhiyun
2171*4882a593Smuzhiyun /**
2172*4882a593Smuzhiyun *
2173*4882a593Smuzhiyun * Extracts the bits allocated for hardware use from the tag
2174*4882a593Smuzhiyun *
2175*4882a593Smuzhiyun * @tag: 32 bit tag value
2176*4882a593Smuzhiyun *
2177*4882a593Smuzhiyun * Returns (32 - N) bit software tag value, where N is configurable
2178*4882a593Smuzhiyun * with the CVMX_TAG_SW_BITS define
2179*4882a593Smuzhiyun */
cvmx_pow_tag_get_hw_bits(uint64_t tag)2180*4882a593Smuzhiyun static inline uint32_t cvmx_pow_tag_get_hw_bits(uint64_t tag)
2181*4882a593Smuzhiyun {
2182*4882a593Smuzhiyun return tag & cvmx_build_mask(32 - CVMX_TAG_SW_BITS);
2183*4882a593Smuzhiyun }
2184*4882a593Smuzhiyun
2185*4882a593Smuzhiyun /**
2186*4882a593Smuzhiyun * Store the current POW internal state into the supplied
2187*4882a593Smuzhiyun * buffer. It is recommended that you pass a buffer of at least
2188*4882a593Smuzhiyun * 128KB. The format of the capture may change based on SDK
2189*4882a593Smuzhiyun * version and Octeon chip.
2190*4882a593Smuzhiyun *
2191*4882a593Smuzhiyun * @buffer: Buffer to store capture into
2192*4882a593Smuzhiyun * @buffer_size:
2193*4882a593Smuzhiyun * The size of the supplied buffer
2194*4882a593Smuzhiyun *
2195*4882a593Smuzhiyun * Returns Zero on success, negative on failure
2196*4882a593Smuzhiyun */
2197*4882a593Smuzhiyun extern int cvmx_pow_capture(void *buffer, int buffer_size);
2198*4882a593Smuzhiyun
2199*4882a593Smuzhiyun /**
2200*4882a593Smuzhiyun * Dump a POW capture to the console in a human readable format.
2201*4882a593Smuzhiyun *
2202*4882a593Smuzhiyun * @buffer: POW capture from cvmx_pow_capture()
2203*4882a593Smuzhiyun * @buffer_size:
2204*4882a593Smuzhiyun * Size of the buffer
2205*4882a593Smuzhiyun */
2206*4882a593Smuzhiyun extern void cvmx_pow_display(void *buffer, int buffer_size);
2207*4882a593Smuzhiyun
2208*4882a593Smuzhiyun /**
2209*4882a593Smuzhiyun * Return the number of POW entries supported by this chip
2210*4882a593Smuzhiyun *
2211*4882a593Smuzhiyun * Returns Number of POW entries
2212*4882a593Smuzhiyun */
2213*4882a593Smuzhiyun extern int cvmx_pow_get_num_entries(void);
2214*4882a593Smuzhiyun
2215*4882a593Smuzhiyun #endif /* __CVMX_POW_H__ */
2216