xref: /openbmc/qemu/include/hw/ppc/xive_regs.h (revision 6b829602e2f10f301ff8508f3a6850a0e913142c)
17ff7ea92SCédric Le Goater /*
27ff7ea92SCédric Le Goater  * QEMU PowerPC XIVE internal structure definitions
37ff7ea92SCédric Le Goater  *
47ff7ea92SCédric Le Goater  *
57ff7ea92SCédric Le Goater  * The XIVE structures are accessed by the HW and their format is
67ff7ea92SCédric Le Goater  * architected to be big-endian. Some macros are provided to ease
77ff7ea92SCédric Le Goater  * access to the different fields.
87ff7ea92SCédric Le Goater  *
97ff7ea92SCédric Le Goater  *
107ff7ea92SCédric Le Goater  * Copyright (c) 2016-2018, IBM Corporation.
117ff7ea92SCédric Le Goater  *
127ff7ea92SCédric Le Goater  * This code is licensed under the GPL version 2 or later. See the
137ff7ea92SCédric Le Goater  * COPYING file in the top-level directory.
147ff7ea92SCédric Le Goater  */
157ff7ea92SCédric Le Goater 
167ff7ea92SCédric Le Goater #ifndef PPC_XIVE_REGS_H
177ff7ea92SCédric Le Goater #define PPC_XIVE_REGS_H
187ff7ea92SCédric Le Goater 
19ec150c7eSMarkus Armbruster #include "qemu/bswap.h"
20ec150c7eSMarkus Armbruster #include "qemu/host-utils.h"
21ec150c7eSMarkus Armbruster 
227ff7ea92SCédric Le Goater /*
237ff7ea92SCédric Le Goater  * Interrupt source number encoding on PowerBUS
247ff7ea92SCédric Le Goater  */
25106695abSCédric Le Goater /*
26106695abSCédric Le Goater  * Trigger data definition
27106695abSCédric Le Goater  *
28106695abSCédric Le Goater  * The trigger definition is used for triggers both for HW source
29106695abSCédric Le Goater  * interrupts (PHB, PSI), as well as for rerouting interrupts between
30106695abSCédric Le Goater  * Interrupt Controller.
31106695abSCédric Le Goater  *
32106695abSCédric Le Goater  * HW source controllers set bit0 of word0 to ‘0’ as they provide EAS
33106695abSCédric Le Goater  * information (EAS block + EAS index) in the 8 byte data and not END
34106695abSCédric Le Goater  * information, which is use for rerouting interrupts.
35106695abSCédric Le Goater  *
36106695abSCédric Le Goater  * bit1 of word0 to ‘1’ signals that the state bit check has been
37106695abSCédric Le Goater  * performed.
38106695abSCédric Le Goater  */
39106695abSCédric Le Goater #define XIVE_TRIGGER_END        PPC_BIT(0)
40106695abSCédric Le Goater #define XIVE_TRIGGER_PQ         PPC_BIT(1)
41106695abSCédric Le Goater 
42106695abSCédric Le Goater /*
43106695abSCédric Le Goater  * QEMU macros to manipulate the trigger payload in native endian
44106695abSCédric Le Goater  */
45106695abSCédric Le Goater #define XIVE_EAS_BLOCK(n)       (((n) >> 28) & 0xf)
46106695abSCédric Le Goater #define XIVE_EAS_INDEX(n)       ((n) & 0x0fffffff)
47106695abSCédric Le Goater #define XIVE_EAS(blk, idx)      ((uint32_t)(blk) << 28 | (idx))
487ff7ea92SCédric Le Goater 
49207d9fe9SCédric Le Goater #define TM_SHIFT                16
50207d9fe9SCédric Le Goater 
51afca9207SFrederic Barrat /*
52afca9207SFrederic Barrat  * TIMA addresses are 12-bits (4k page).
53afca9207SFrederic Barrat  * The MSB indicates a special op with side effect, which can be
54afca9207SFrederic Barrat  * refined with bit 10 (see below).
55afca9207SFrederic Barrat  * The registers, logically grouped in 4 rings (a quad-word each), are
56afca9207SFrederic Barrat  * defined on the 6 LSBs (offset below 0x40)
57afca9207SFrederic Barrat  * In between, we can add a cache line index from 0...3 (ie, 0, 0x80,
58afca9207SFrederic Barrat  * 0x100, 0x180) to select a specific snooper. Those 'snoop port
59afca9207SFrederic Barrat  * address' bits should be dropped when processing the operations as
60afca9207SFrederic Barrat  * they are all equivalent.
61afca9207SFrederic Barrat  */
62afca9207SFrederic Barrat #define TM_ADDRESS_MASK         0xC3F
63afca9207SFrederic Barrat #define TM_SPECIAL_OP           0x800
64afca9207SFrederic Barrat #define TM_RING_OFFSET          0x30
65afca9207SFrederic Barrat #define TM_REG_OFFSET           0x3F
66afca9207SFrederic Barrat 
67207d9fe9SCédric Le Goater /* TM register offsets */
68207d9fe9SCédric Le Goater #define TM_QW0_USER             0x000 /* All rings */
69207d9fe9SCédric Le Goater #define TM_QW1_OS               0x010 /* Ring 0..2 */
70207d9fe9SCédric Le Goater #define TM_QW2_HV_POOL          0x020 /* Ring 0..1 */
71207d9fe9SCédric Le Goater #define TM_QW3_HV_PHYS          0x030 /* Ring 0..1 */
72207d9fe9SCédric Le Goater 
73207d9fe9SCédric Le Goater /* Byte offsets inside a QW             QW0 QW1 QW2 QW3 */
74207d9fe9SCédric Le Goater #define TM_NSR                  0x0  /*  +   +   -   +  */
75207d9fe9SCédric Le Goater #define TM_CPPR                 0x1  /*  -   +   -   +  */
76207d9fe9SCédric Le Goater #define TM_IPB                  0x2  /*  -   +   +   +  */
77207d9fe9SCédric Le Goater #define TM_LSMFB                0x3  /*  -   +   +   +  */
78207d9fe9SCédric Le Goater #define TM_ACK_CNT              0x4  /*  -   +   -   -  */
79207d9fe9SCédric Le Goater #define TM_INC                  0x5  /*  -   +   -   +  */
80cebfeb9eSFrederic Barrat #define TM_LGS                  0x5  /*  +   +   +   +  */ /* Rename P10 */
81207d9fe9SCédric Le Goater #define TM_AGE                  0x6  /*  -   +   -   +  */
82cfe9a7f2SGlenn Miles #define TM_T                    0x6  /*  -   +   -   +  */ /* Rename P10 */
83207d9fe9SCédric Le Goater #define TM_PIPR                 0x7  /*  -   +   -   +  */
84b9deafe7SFrederic Barrat #define TM_OGEN                 0xF  /*  -   +   -   -  */ /* P10 only */
85207d9fe9SCédric Le Goater 
86207d9fe9SCédric Le Goater #define TM_WORD0                0x0
87207d9fe9SCédric Le Goater #define TM_WORD1                0x4
88207d9fe9SCédric Le Goater 
89207d9fe9SCédric Le Goater /*
90207d9fe9SCédric Le Goater  * QW word 2 contains the valid bit at the top and other fields
91207d9fe9SCédric Le Goater  * depending on the QW.
92207d9fe9SCédric Le Goater  */
93207d9fe9SCédric Le Goater #define   TM_WORD2              0x8
94207d9fe9SCédric Le Goater #define   TM_QW0W2_VU           PPC_BIT32(0)
95207d9fe9SCédric Le Goater #define   TM_QW0W2_LOGIC_SERV   PPC_BITMASK32(1, 31) /* XX 2,31 ? */
96207d9fe9SCédric Le Goater #define   TM_QW1W2_VO           PPC_BIT32(0)
97207d9fe9SCédric Le Goater #define   TM_QW1W2_OS_CAM       PPC_BITMASK32(8, 31)
98207d9fe9SCédric Le Goater #define   TM_QW2W2_VP           PPC_BIT32(0)
99207d9fe9SCédric Le Goater #define   TM_QW2W2_POOL_CAM     PPC_BITMASK32(8, 31)
100207d9fe9SCédric Le Goater #define   TM_QW3W2_VT           PPC_BIT32(0)
101207d9fe9SCédric Le Goater #define   TM_QW3W2_LP           PPC_BIT32(6)
102207d9fe9SCédric Le Goater #define   TM_QW3W2_LE           PPC_BIT32(7)
103207d9fe9SCédric Le Goater #define   TM_QW3W2_T            PPC_BIT32(31)
104f82fec6cSGlenn Miles #define   TM_QW3B8_VT           PPC_BIT8(0)
105207d9fe9SCédric Le Goater 
106207d9fe9SCédric Le Goater /*
107207d9fe9SCédric Le Goater  * In addition to normal loads to "peek" and writes (only when invalid)
108207d9fe9SCédric Le Goater  * using 4 and 8 bytes accesses, the above registers support these
109207d9fe9SCédric Le Goater  * "special" byte operations:
110207d9fe9SCédric Le Goater  *
111207d9fe9SCédric Le Goater  *   - Byte load from QW0[NSR] - User level NSR (EBB)
112207d9fe9SCédric Le Goater  *   - Byte store to QW0[NSR] - User level NSR (EBB)
113207d9fe9SCédric Le Goater  *   - Byte load/store to QW1[CPPR] and QW3[CPPR] - CPPR access
114207d9fe9SCédric Le Goater  *   - Byte load from QW3[TM_WORD2] - Read VT||00000||LP||LE on thrd 0
115207d9fe9SCédric Le Goater  *                                    otherwise VT||0000000
116207d9fe9SCédric Le Goater  *   - Byte store to QW3[TM_WORD2] - Set VT bit (and LP/LE if present)
117207d9fe9SCédric Le Goater  *
118207d9fe9SCédric Le Goater  * Then we have all these "special" CI ops at these offset that trigger
119207d9fe9SCédric Le Goater  * all sorts of side effects:
120207d9fe9SCédric Le Goater  */
121207d9fe9SCédric Le Goater #define TM_SPC_ACK_EBB          0x800   /* Load8 ack EBB to reg               */
122207d9fe9SCédric Le Goater #define TM_SPC_ACK_OS_REG       0x810   /* Load16 ack OS irq to reg           */
123207d9fe9SCédric Le Goater #define TM_SPC_PUSH_USR_CTX     0x808   /* Store32 Push/Validate user context */
124a5330463SMichael Kowal #define TM_SPC_PULL_USR_CTX     0x808   /* Load32 Pull/Invalidate user        */
125a5330463SMichael Kowal                                         /* context                            */
126207d9fe9SCédric Le Goater #define TM_SPC_SET_OS_PENDING   0x812   /* Store8 Set OS irq pending bit      */
127*85eed507SMichael Kowal #define TM_SPC_PULL_OS_CTX_G2   0x810   /* Load32/Load64 Pull/Invalidate OS   */
128*85eed507SMichael Kowal                                         /* context to reg                     */
129a5330463SMichael Kowal #define TM_SPC_PULL_OS_CTX      0x818   /* Load32/Load64 Pull/Invalidate OS   */
130a5330463SMichael Kowal                                         /* context to reg                     */
131*85eed507SMichael Kowal #define TM_SPC_PULL_POOL_CTX_G2 0x820   /* Load32/Load64 Pull/Invalidate Pool */
132*85eed507SMichael Kowal                                         /* context to reg                     */
133a5330463SMichael Kowal #define TM_SPC_PULL_POOL_CTX    0x828   /* Load32/Load64 Pull/Invalidate Pool */
134a5330463SMichael Kowal                                         /* context to reg                     */
135207d9fe9SCédric Le Goater #define TM_SPC_ACK_HV_REG       0x830   /* Load16 ack HV irq to reg           */
136*85eed507SMichael Kowal #define TM_SPC_PULL_PHYS_CTX_G2 0x830   /* Load32 Pull phys ctx to reg        */
137*85eed507SMichael Kowal #define TM_SPC_PULL_PHYS_CTX    0x838   /* Load8  Pull phys ctx to reg        */
138a5330463SMichael Kowal #define TM_SPC_PULL_USR_CTX_OL  0xc08   /* Store8 Pull/Inval usr ctx to odd   */
139a5330463SMichael Kowal                                         /* line                               */
140207d9fe9SCédric Le Goater #define TM_SPC_ACK_OS_EL        0xc10   /* Store8 ack OS irq to even line     */
141cebfeb9eSFrederic Barrat #define TM_SPC_PULL_OS_CTX_OL   0xc18   /* Pull/Invalidate OS context to      */
142cebfeb9eSFrederic Barrat                                         /* odd Thread reporting line          */
143a5330463SMichael Kowal #define TM_SPC_ACK_HV_POOL_EL   0xc20   /* Store8 ack HV evt pool to even     */
144a5330463SMichael Kowal                                         /* line                               */
145207d9fe9SCédric Le Goater #define TM_SPC_ACK_HV_EL        0xc30   /* Store8 ack HV irq to even line     */
14681939a92SGlenn Miles #define TM_SPC_PULL_PHYS_CTX_OL 0xc38   /* Pull phys ctx to odd cache line    */
147207d9fe9SCédric Le Goater /* XXX more... */
148207d9fe9SCédric Le Goater 
149207d9fe9SCédric Le Goater /* NSR fields for the various QW ack types */
150207d9fe9SCédric Le Goater #define TM_QW0_NSR_EB           PPC_BIT8(0)
151207d9fe9SCédric Le Goater #define TM_QW1_NSR_EO           PPC_BIT8(0)
152207d9fe9SCédric Le Goater #define TM_QW3_NSR_HE           PPC_BITMASK8(0, 1)
153207d9fe9SCédric Le Goater #define  TM_QW3_NSR_HE_NONE     0
154207d9fe9SCédric Le Goater #define  TM_QW3_NSR_HE_POOL     1
155207d9fe9SCédric Le Goater #define  TM_QW3_NSR_HE_PHYS     2
156207d9fe9SCédric Le Goater #define  TM_QW3_NSR_HE_LSI      3
157207d9fe9SCédric Le Goater #define TM_QW3_NSR_I            PPC_BIT8(2)
158207d9fe9SCédric Le Goater #define TM_QW3_NSR_GRP_LVL      PPC_BIT8(3, 7)
159207d9fe9SCédric Le Goater 
1607ff7ea92SCédric Le Goater /*
1617ff7ea92SCédric Le Goater  * EAS (Event Assignment Structure)
1627ff7ea92SCédric Le Goater  *
1637ff7ea92SCédric Le Goater  * One per interrupt source. Targets an interrupt to a given Event
1647ff7ea92SCédric Le Goater  * Notification Descriptor (END) and provides the corresponding
1657ff7ea92SCédric Le Goater  * logical interrupt number (END data)
1667ff7ea92SCédric Le Goater  */
1677ff7ea92SCédric Le Goater typedef struct XiveEAS {
1687ff7ea92SCédric Le Goater         /*
1697ff7ea92SCédric Le Goater          * Use a single 64-bit definition to make it easier to perform
1707ff7ea92SCédric Le Goater          * atomic updates
1717ff7ea92SCédric Le Goater          */
1727ff7ea92SCédric Le Goater         uint64_t        w;
1737ff7ea92SCédric Le Goater #define EAS_VALID       PPC_BIT(0)
1747ff7ea92SCédric Le Goater #define EAS_END_BLOCK   PPC_BITMASK(4, 7)        /* Destination END block# */
1757ff7ea92SCédric Le Goater #define EAS_END_INDEX   PPC_BITMASK(8, 31)       /* Destination END index */
1767ff7ea92SCédric Le Goater #define EAS_MASKED      PPC_BIT(32)              /* Masked */
1777ff7ea92SCédric Le Goater #define EAS_END_DATA    PPC_BITMASK(33, 63)      /* Data written to the END */
1787ff7ea92SCédric Le Goater } XiveEAS;
1797ff7ea92SCédric Le Goater 
1807ff7ea92SCédric Le Goater #define xive_eas_is_valid(eas)   (be64_to_cpu((eas)->w) & EAS_VALID)
1817ff7ea92SCédric Le Goater #define xive_eas_is_masked(eas)  (be64_to_cpu((eas)->w) & EAS_MASKED)
1827ff7ea92SCédric Le Goater 
183bc8c553bSPhilippe Mathieu-Daudé void xive_eas_pic_print_info(XiveEAS *eas, uint32_t lisn, GString *buf);
184c5e760e0SCédric Le Goater 
xive_get_field64(uint64_t mask,uint64_t word)1857ff7ea92SCédric Le Goater static inline uint64_t xive_get_field64(uint64_t mask, uint64_t word)
1867ff7ea92SCédric Le Goater {
1877ff7ea92SCédric Le Goater     return (be64_to_cpu(word) & mask) >> ctz64(mask);
1887ff7ea92SCédric Le Goater }
1897ff7ea92SCédric Le Goater 
xive_set_field64(uint64_t mask,uint64_t word,uint64_t value)1907ff7ea92SCédric Le Goater static inline uint64_t xive_set_field64(uint64_t mask, uint64_t word,
1917ff7ea92SCédric Le Goater                                         uint64_t value)
1927ff7ea92SCédric Le Goater {
1937ff7ea92SCédric Le Goater     uint64_t tmp =
1947ff7ea92SCédric Le Goater         (be64_to_cpu(word) & ~mask) | ((value << ctz64(mask)) & mask);
1957ff7ea92SCédric Le Goater     return cpu_to_be64(tmp);
1967ff7ea92SCédric Le Goater }
1977ff7ea92SCédric Le Goater 
xive_get_field32(uint32_t mask,uint32_t word)198e4ddaac6SCédric Le Goater static inline uint32_t xive_get_field32(uint32_t mask, uint32_t word)
199e4ddaac6SCédric Le Goater {
200e4ddaac6SCédric Le Goater     return (be32_to_cpu(word) & mask) >> ctz32(mask);
201e4ddaac6SCédric Le Goater }
202e4ddaac6SCédric Le Goater 
xive_set_field32(uint32_t mask,uint32_t word,uint32_t value)203e4ddaac6SCédric Le Goater static inline uint32_t xive_set_field32(uint32_t mask, uint32_t word,
204e4ddaac6SCédric Le Goater                                         uint32_t value)
205e4ddaac6SCédric Le Goater {
206e4ddaac6SCédric Le Goater     uint32_t tmp =
207e4ddaac6SCédric Le Goater         (be32_to_cpu(word) & ~mask) | ((value << ctz32(mask)) & mask);
208e4ddaac6SCédric Le Goater     return cpu_to_be32(tmp);
209e4ddaac6SCédric Le Goater }
210e4ddaac6SCédric Le Goater 
211e4ddaac6SCédric Le Goater /* Event Notification Descriptor (END) */
212e4ddaac6SCédric Le Goater typedef struct XiveEND {
213e4ddaac6SCédric Le Goater         uint32_t        w0;
214e4ddaac6SCédric Le Goater #define END_W0_VALID             PPC_BIT32(0) /* "v" bit */
215e4ddaac6SCédric Le Goater #define END_W0_ENQUEUE           PPC_BIT32(1) /* "q" bit */
216e4ddaac6SCédric Le Goater #define END_W0_UCOND_NOTIFY      PPC_BIT32(2) /* "n" bit */
217e4ddaac6SCédric Le Goater #define END_W0_BACKLOG           PPC_BIT32(3) /* "b" bit */
218e4ddaac6SCédric Le Goater #define END_W0_PRECL_ESC_CTL     PPC_BIT32(4) /* "p" bit */
219e4ddaac6SCédric Le Goater #define END_W0_ESCALATE_CTL      PPC_BIT32(5) /* "e" bit */
220e4ddaac6SCédric Le Goater #define END_W0_UNCOND_ESCALATE   PPC_BIT32(6) /* "u" bit - DD2.0 */
221e4ddaac6SCédric Le Goater #define END_W0_SILENT_ESCALATE   PPC_BIT32(7) /* "s" bit - DD2.0 */
222e4ddaac6SCédric Le Goater #define END_W0_QSIZE             PPC_BITMASK32(12, 15)
223e4ddaac6SCédric Le Goater #define END_W0_SW0               PPC_BIT32(16)
224e4ddaac6SCédric Le Goater #define END_W0_FIRMWARE          END_W0_SW0 /* Owned by FW */
225e4ddaac6SCédric Le Goater #define END_QSIZE_4K             0
226e4ddaac6SCédric Le Goater #define END_QSIZE_64K            4
227e4ddaac6SCédric Le Goater #define END_W0_HWDEP             PPC_BITMASK32(24, 31)
228e4ddaac6SCédric Le Goater         uint32_t        w1;
229e4ddaac6SCédric Le Goater #define END_W1_ESn               PPC_BITMASK32(0, 1)
230e4ddaac6SCédric Le Goater #define END_W1_ESn_P             PPC_BIT32(0)
231e4ddaac6SCédric Le Goater #define END_W1_ESn_Q             PPC_BIT32(1)
232e4ddaac6SCédric Le Goater #define END_W1_ESe               PPC_BITMASK32(2, 3)
233e4ddaac6SCédric Le Goater #define END_W1_ESe_P             PPC_BIT32(2)
234e4ddaac6SCédric Le Goater #define END_W1_ESe_Q             PPC_BIT32(3)
235e4ddaac6SCédric Le Goater #define END_W1_GENERATION        PPC_BIT32(9)
236e4ddaac6SCédric Le Goater #define END_W1_PAGE_OFF          PPC_BITMASK32(10, 31)
237e4ddaac6SCédric Le Goater         uint32_t        w2;
238e4ddaac6SCédric Le Goater #define END_W2_MIGRATION_REG     PPC_BITMASK32(0, 3)
239e4ddaac6SCédric Le Goater #define END_W2_OP_DESC_HI        PPC_BITMASK32(4, 31)
240e4ddaac6SCédric Le Goater         uint32_t        w3;
241e4ddaac6SCédric Le Goater #define END_W3_OP_DESC_LO        PPC_BITMASK32(0, 31)
242e4ddaac6SCédric Le Goater         uint32_t        w4;
243e4ddaac6SCédric Le Goater #define END_W4_ESC_END_BLOCK     PPC_BITMASK32(4, 7)
244e4ddaac6SCédric Le Goater #define END_W4_ESC_END_INDEX     PPC_BITMASK32(8, 31)
245e4ddaac6SCédric Le Goater         uint32_t        w5;
246e4ddaac6SCédric Le Goater #define END_W5_ESC_END_DATA      PPC_BITMASK32(1, 31)
247e4ddaac6SCédric Le Goater         uint32_t        w6;
248e4ddaac6SCédric Le Goater #define END_W6_FORMAT_BIT        PPC_BIT32(8)
249e4ddaac6SCédric Le Goater #define END_W6_NVT_BLOCK         PPC_BITMASK32(9, 12)
250e4ddaac6SCédric Le Goater #define END_W6_NVT_INDEX         PPC_BITMASK32(13, 31)
251e4ddaac6SCédric Le Goater         uint32_t        w7;
252e4ddaac6SCédric Le Goater #define END_W7_F0_IGNORE         PPC_BIT32(0)
253e4ddaac6SCédric Le Goater #define END_W7_F0_BLK_GROUPING   PPC_BIT32(1)
254e4ddaac6SCédric Le Goater #define END_W7_F0_PRIORITY       PPC_BITMASK32(8, 15)
255e4ddaac6SCédric Le Goater #define END_W7_F1_WAKEZ          PPC_BIT32(0)
256e4ddaac6SCédric Le Goater #define END_W7_F1_LOG_SERVER_ID  PPC_BITMASK32(1, 31)
257e4ddaac6SCédric Le Goater } XiveEND;
258e4ddaac6SCédric Le Goater 
259e4ddaac6SCédric Le Goater #define xive_end_is_valid(end)    (be32_to_cpu((end)->w0) & END_W0_VALID)
260e4ddaac6SCédric Le Goater #define xive_end_is_enqueue(end)  (be32_to_cpu((end)->w0) & END_W0_ENQUEUE)
261e4ddaac6SCédric Le Goater #define xive_end_is_notify(end)   (be32_to_cpu((end)->w0) & END_W0_UCOND_NOTIFY)
262e4ddaac6SCédric Le Goater #define xive_end_is_backlog(end)  (be32_to_cpu((end)->w0) & END_W0_BACKLOG)
263e4ddaac6SCédric Le Goater #define xive_end_is_escalate(end) (be32_to_cpu((end)->w0) & END_W0_ESCALATE_CTL)
26453e93492SCédric Le Goater #define xive_end_is_uncond_escalation(end)              \
26553e93492SCédric Le Goater     (be32_to_cpu((end)->w0) & END_W0_UNCOND_ESCALATE)
266ad31e2d2SCédric Le Goater #define xive_end_is_silent_escalation(end)              \
267ad31e2d2SCédric Le Goater     (be32_to_cpu((end)->w0) & END_W0_SILENT_ESCALATE)
268cb942864SCédric Le Goater #define xive_end_is_firmware(end)              \
269cb942864SCédric Le Goater     (be32_to_cpu((end)->w0) & END_W0_FIRMWARE)
270e4ddaac6SCédric Le Goater 
xive_end_qaddr(XiveEND * end)27113df9324SCédric Le Goater static inline uint64_t xive_end_qaddr(XiveEND *end)
27213df9324SCédric Le Goater {
27313df9324SCédric Le Goater     return ((uint64_t) be32_to_cpu(end->w2) & 0x0fffffff) << 32 |
27413df9324SCédric Le Goater         be32_to_cpu(end->w3);
27513df9324SCédric Le Goater }
27613df9324SCédric Le Goater 
277f1bca2caSPhilippe Mathieu-Daudé void xive_end_pic_print_info(XiveEND *end, uint32_t end_idx, GString *buf);
278ace6fcdeSPhilippe Mathieu-Daudé void xive_end_queue_pic_print_info(XiveEND *end, uint32_t width, GString *buf);
2793d1e062cSPhilippe Mathieu-Daudé void xive_end_eas_pic_print_info(XiveEND *end, uint32_t end_idx, GString *buf);
280c5e760e0SCédric Le Goater 
281af53dbf6SCédric Le Goater /* Notification Virtual Target (NVT) */
282af53dbf6SCédric Le Goater typedef struct XiveNVT {
283af53dbf6SCédric Le Goater         uint32_t        w0;
284af53dbf6SCédric Le Goater #define NVT_W0_VALID             PPC_BIT32(0)
285af53dbf6SCédric Le Goater         uint32_t        w1;
286d302e000SCédric Le Goater #define NVT_W1_EQ_BLOCK          PPC_BITMASK32(0, 3)
287d302e000SCédric Le Goater #define NVT_W1_EQ_INDEX          PPC_BITMASK32(4, 31)
288af53dbf6SCédric Le Goater         uint32_t        w2;
289af53dbf6SCédric Le Goater         uint32_t        w3;
290af53dbf6SCédric Le Goater         uint32_t        w4;
291516883c2SCédric Le Goater #define NVT_W4_IPB               PPC_BITMASK32(16, 23)
292af53dbf6SCédric Le Goater         uint32_t        w5;
293af53dbf6SCédric Le Goater         uint32_t        w6;
294af53dbf6SCédric Le Goater         uint32_t        w7;
295af53dbf6SCédric Le Goater         uint32_t        w8;
296af53dbf6SCédric Le Goater #define NVT_W8_GRP_VALID         PPC_BIT32(0)
297af53dbf6SCédric Le Goater         uint32_t        w9;
298af53dbf6SCédric Le Goater         uint32_t        wa;
299af53dbf6SCédric Le Goater         uint32_t        wb;
300af53dbf6SCédric Le Goater         uint32_t        wc;
301af53dbf6SCédric Le Goater         uint32_t        wd;
302af53dbf6SCédric Le Goater         uint32_t        we;
303af53dbf6SCédric Le Goater         uint32_t        wf;
304af53dbf6SCédric Le Goater } XiveNVT;
305af53dbf6SCédric Le Goater 
306af53dbf6SCédric Le Goater #define xive_nvt_is_valid(nvt)    (be32_to_cpu((nvt)->w0) & NVT_W0_VALID)
307af53dbf6SCédric Le Goater 
308e6488eebSCédric Le Goater /*
309e6488eebSCédric Le Goater  * The VP number space in a block is defined by the END_W6_NVT_INDEX
310e6488eebSCédric Le Goater  * field of the XIVE END
311e6488eebSCédric Le Goater  */
312e6488eebSCédric Le Goater #define XIVE_NVT_SHIFT                19
313d302e000SCédric Le Goater #define XIVE_NVT_COUNT                (1 << XIVE_NVT_SHIFT)
314e6488eebSCédric Le Goater 
xive_nvt_cam_line(uint8_t nvt_blk,uint32_t nvt_idx)315e6488eebSCédric Le Goater static inline uint32_t xive_nvt_cam_line(uint8_t nvt_blk, uint32_t nvt_idx)
316e6488eebSCédric Le Goater {
317e6488eebSCédric Le Goater     return (nvt_blk << XIVE_NVT_SHIFT) | nvt_idx;
318e6488eebSCédric Le Goater }
319e6488eebSCédric Le Goater 
xive_nvt_idx(uint32_t cam_line)320e6488eebSCédric Le Goater static inline uint32_t xive_nvt_idx(uint32_t cam_line)
321e6488eebSCédric Le Goater {
322e6488eebSCédric Le Goater     return cam_line & ((1 << XIVE_NVT_SHIFT) - 1);
323e6488eebSCédric Le Goater }
324e6488eebSCédric Le Goater 
xive_nvt_blk(uint32_t cam_line)325e6488eebSCédric Le Goater static inline uint32_t xive_nvt_blk(uint32_t cam_line)
326e6488eebSCédric Le Goater {
327e6488eebSCédric Le Goater     return (cam_line >> XIVE_NVT_SHIFT) & 0xf;
328e6488eebSCédric Le Goater }
329e6488eebSCédric Le Goater 
3307ff7ea92SCédric Le Goater #endif /* PPC_XIVE_REGS_H */
331