10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51772Sjl139090 * Common Development and Distribution License (the "License"). 61772Sjl139090 * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 229707SDaniel.Ice@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _SYS_PX_IOAPI_H 270Sstevel@tonic-gate #define _SYS_PX_IOAPI_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #ifdef __cplusplus 300Sstevel@tonic-gate extern "C" { 310Sstevel@tonic-gate #endif 320Sstevel@tonic-gate 330Sstevel@tonic-gate #ifndef _ASM 340Sstevel@tonic-gate 350Sstevel@tonic-gate /* 360Sstevel@tonic-gate * SUN4V IO Data Definitions 370Sstevel@tonic-gate * 380Sstevel@tonic-gate * cpuid - A unique opaque value which represents a target cpu. 390Sstevel@tonic-gate * 400Sstevel@tonic-gate * devhandle - Device handle. The device handle uniquely 410Sstevel@tonic-gate * identifies a SUN4V device. It consists of the 420Sstevel@tonic-gate * the lower 28-bits of the hi-cell of the first 430Sstevel@tonic-gate * entry of the SUN4V device's "reg" property as defined 440Sstevel@tonic-gate * by the SUN4V Bus Binding to Open Firmware. 450Sstevel@tonic-gate * 460Sstevel@tonic-gate * devino - Device Interrupt Number. An unsigned integer representing 470Sstevel@tonic-gate * an interrupt within a specific device. 480Sstevel@tonic-gate * 490Sstevel@tonic-gate * sysino - System Interrupt Number. A 64-bit unsigned integer 500Sstevel@tonic-gate * representing a unique interrupt within a "system". 510Sstevel@tonic-gate * 520Sstevel@tonic-gate * intr_state - A flag representing the interrupt state for a 530Sstevel@tonic-gate * a given sysino. The state values are defined as: 540Sstevel@tonic-gate * 550Sstevel@tonic-gate * INTR_IDLE 0 560Sstevel@tonic-gate * INTR_RECEIVED 1 570Sstevel@tonic-gate * INTR_DELIVERED 2 580Sstevel@tonic-gate * 590Sstevel@tonic-gate * intr_valid_state - A flag representing the 'valid' state for 600Sstevel@tonic-gate * a given sysino. The state values are defined as: 610Sstevel@tonic-gate * 620Sstevel@tonic-gate * INTR_NOTVALID 0 sysino not enabled 630Sstevel@tonic-gate * INTR_VALID 1 sysino enabled 640Sstevel@tonic-gate */ 650Sstevel@tonic-gate 660Sstevel@tonic-gate typedef uint64_t devhandle_t; 670Sstevel@tonic-gate 680Sstevel@tonic-gate typedef uint32_t cpuid_t; 690Sstevel@tonic-gate typedef uint32_t devino_t; 700Sstevel@tonic-gate typedef uint64_t sysino_t; 710Sstevel@tonic-gate 720Sstevel@tonic-gate typedef enum intr_state { 730Sstevel@tonic-gate INTR_IDLE_STATE = (uint32_t)0, 740Sstevel@tonic-gate INTR_RECEIVED_STATE = (uint32_t)1, 750Sstevel@tonic-gate INTR_DELIVERED_STATE = (uint32_t)2 760Sstevel@tonic-gate } intr_state_t; 770Sstevel@tonic-gate 780Sstevel@tonic-gate typedef enum intr_valid_state { 790Sstevel@tonic-gate INTR_NOTVALID = (uint32_t)0, 800Sstevel@tonic-gate INTR_VALID = (uint32_t)1 810Sstevel@tonic-gate } intr_valid_state_t; 820Sstevel@tonic-gate 830Sstevel@tonic-gate /* 840Sstevel@tonic-gate * PCI IO Data Definitions 850Sstevel@tonic-gate * 860Sstevel@tonic-gate * tsbnum - TSB Number. Identifies which io-tsb is used. 870Sstevel@tonic-gate * For this version of the spec, tsbnum must be zero. 880Sstevel@tonic-gate * 890Sstevel@tonic-gate * tsbindex - TSB Index. Identifies which entry in the tsb is 900Sstevel@tonic-gate * is used. The first entry is zero. 910Sstevel@tonic-gate * 920Sstevel@tonic-gate * tsbid - A 64-bit aligned data structure which contains 930Sstevel@tonic-gate * a tsbnum and a tsbindex. 940Sstevel@tonic-gate * bits 63:32 contain the tsbnum. 950Sstevel@tonic-gate * bits 31:00 contain the tsbindex. 960Sstevel@tonic-gate * 970Sstevel@tonic-gate * io_attributes - IO Attributes for iommu mappings. 980Sstevel@tonic-gate * Attributes for iommu mappings. One or more of the 990Sstevel@tonic-gate * following attribute bits stored in a 64-bit unsigned int. 1000Sstevel@tonic-gate * 1013156Sgirish * 6 3 0 1023156Sgirish * 3 1 0 1033156Sgirish * 00000000 00000000 00000000 00000000 BBBBBBBB DDDDDFFF 00000000 00PP0LWR 1040Sstevel@tonic-gate * 1053156Sgirish * R: DMA data is transferred from main memory to device. 1063156Sgirish * W: DMA data is transferred from device to main memory. 1073156Sgirish * L: Requested DMA transaction can be relaxed ordered within RC. 1083156Sgirish * P: Value of PCI Express and PCI-X phantom function 1093156Sgirish * configuration. Its encoding is identical to the 1103156Sgirish * "Phantom Function Supported" field of the 1113156Sgirish * "Device Capabilities Register (offset 0x4)" 1123156Sgirish * in the "PCI Express Capability Structure". 1133156Sgirish * The structure is part of a device's config space. 1143156Sgirish * BDF: Bus, device and function number of the device 1153156Sgirish * that is going to issue DMA transactions. 1163156Sgirish * The BDF values are used to guarantee the mapping 1173156Sgirish * only be accessed by the specified device. 1183156Sgirish * If the BDF is set to all 0, RID based protection 1193156Sgirish * will be turned off. 1203156Sgirish * 1213156Sgirish * Relaxed Ordering (L) is advisory. Not all hardware implements a 1223156Sgirish * relaxed ordering attribute. If L attribute is not implemented in 1233156Sgirish * hardware, the implementation is permitted to ignore the L bit. 1243156Sgirish * 1253156Sgirish * Bits 3, 15:6 and 63:32 are unused and must be set to zero for 1263156Sgirish * this version of the specification. 1270Sstevel@tonic-gate * 1280Sstevel@tonic-gate * Note: For compatibility with future versions of this 1293156Sgirish * specification, the caller must set bits 3, 15:6 and 63:32 to 1303156Sgirish * zero. The implementation shall ignore these bits. 1310Sstevel@tonic-gate * 1320Sstevel@tonic-gate * r_addr - 64-bit Real Address. 1330Sstevel@tonic-gate * 1340Sstevel@tonic-gate * io_addr - 64-bit IO Address. 1350Sstevel@tonic-gate * 1360Sstevel@tonic-gate * pci_device - PCI device address. A PCI device address 1370Sstevel@tonic-gate * identifies a specific device on a specific PCI 1380Sstevel@tonic-gate * bus segment. A PCI device address is a 32-bit unsigned 1390Sstevel@tonic-gate * integer with the following format: 1400Sstevel@tonic-gate * 1410Sstevel@tonic-gate * 00000000.bbbbbbbb.dddddfff.00000000 1420Sstevel@tonic-gate * 1430Sstevel@tonic-gate * Where: 1440Sstevel@tonic-gate * 1450Sstevel@tonic-gate * bbbbbbbb is the 8-bit pci bus number 1460Sstevel@tonic-gate * ddddd is the 5-bit pci device number 1470Sstevel@tonic-gate * fff is the 3-bit pci function number 1480Sstevel@tonic-gate * 1490Sstevel@tonic-gate * 00000000 is the 8-bit literal zero. 1500Sstevel@tonic-gate * 1510Sstevel@tonic-gate * pci_config_offset - PCI Configuration Space offset. 1520Sstevel@tonic-gate * 1530Sstevel@tonic-gate * For conventional PCI, an unsigned integer in the range 1540Sstevel@tonic-gate * 0 .. 255 representing the offset of the field in pci config 1550Sstevel@tonic-gate * space. 1560Sstevel@tonic-gate * 1570Sstevel@tonic-gate * For PCI implementations with extended configuration space, 1580Sstevel@tonic-gate * an unsigned integer in the range 0 .. 4095, representing 1590Sstevel@tonic-gate * the offset of the field in configuration space. Conventional 1600Sstevel@tonic-gate * PCI config space is offset 0 .. 255. Extended config space 1610Sstevel@tonic-gate * is offset 256 .. 4095 1620Sstevel@tonic-gate * 1630Sstevel@tonic-gate * Note: For pci config space accesses, the offset must be 'size' 1640Sstevel@tonic-gate * aligned. 1650Sstevel@tonic-gate * 1660Sstevel@tonic-gate * error_flag - Error flag 1670Sstevel@tonic-gate * 1680Sstevel@tonic-gate * A return value specifies if the action succeeded 1690Sstevel@tonic-gate * or failed, where: 1700Sstevel@tonic-gate * 1710Sstevel@tonic-gate * 0 - No error occurred while performing the service. 1720Sstevel@tonic-gate * non-zero - Error occurred while performing the service. 1730Sstevel@tonic-gate * 1740Sstevel@tonic-gate * io_sync_direction - "direction" definition for pci_dma_sync 1750Sstevel@tonic-gate * 1760Sstevel@tonic-gate * A value specifying the direction for a memory/io sync 1770Sstevel@tonic-gate * operation, The direction value is a flag, one or both 1780Sstevel@tonic-gate * directions may be specified by the caller. 1790Sstevel@tonic-gate * 1800Sstevel@tonic-gate * 0x01 - For device (device read from memory) 1810Sstevel@tonic-gate * 0x02 - For cpu (device write to memory) 1820Sstevel@tonic-gate * 1830Sstevel@tonic-gate * io_page_list - A list of io_page_addresses. An io_page_address 1840Sstevel@tonic-gate * is an r_addr. 1850Sstevel@tonic-gate * 1860Sstevel@tonic-gate * io_page_list_p - A pointer to an io_page_list. 1870Sstevel@tonic-gate */ 1880Sstevel@tonic-gate typedef uint32_t tsbnum_t; 1890Sstevel@tonic-gate typedef uint32_t tsbindex_t; 1900Sstevel@tonic-gate typedef uint64_t tsbid_t; 1910Sstevel@tonic-gate typedef uint64_t r_addr_t; 1920Sstevel@tonic-gate typedef uint64_t io_addr_t; 1930Sstevel@tonic-gate typedef uint64_t io_page_list_t; 1940Sstevel@tonic-gate typedef uint32_t pages_t; 1950Sstevel@tonic-gate typedef uint32_t error_flag_t; 1960Sstevel@tonic-gate 1970Sstevel@tonic-gate typedef uint32_t pci_config_offset_t; 1980Sstevel@tonic-gate typedef uint64_t pci_device_t; 1990Sstevel@tonic-gate 2000Sstevel@tonic-gate #define PCI_TSB_INDEX 0 2010Sstevel@tonic-gate #define PCI_TSB_INDEX_MASK 0xFFFFFFFF 2020Sstevel@tonic-gate #define PCI_TSB_NUM 32 2030Sstevel@tonic-gate #define PCI_TSB_NUM_MASK 0xFFFFFFFF 2040Sstevel@tonic-gate 2050Sstevel@tonic-gate #define PCI_TSBID(tsbnum, tsbindex) \ 2060Sstevel@tonic-gate ((((tsbid_t)tsbnum & PCI_TSB_NUM_MASK) << PCI_TSB_NUM) | \ 2070Sstevel@tonic-gate (((tsbid_t)tsbindex & PCI_TSB_INDEX_MASK) << PCI_TSB_INDEX)) 2080Sstevel@tonic-gate 2090Sstevel@tonic-gate #define PCI_TSBID_TO_TSBNUM(tsbid) \ 2100Sstevel@tonic-gate ((tsbid >> PCI_TSB_NUM) & PCI_TSB_NUM_MASK) 2110Sstevel@tonic-gate 2120Sstevel@tonic-gate #define PCI_TSBID_TO_TSBINDEX(tsbid) \ 2130Sstevel@tonic-gate ((tsbid >> PCI_TSB_INDEX) & PCI_TSB_INDEX_MASK) 2140Sstevel@tonic-gate 2159707SDaniel.Ice@Sun.COM typedef uint64_t io_attributes_t; 2169707SDaniel.Ice@Sun.COM 2179707SDaniel.Ice@Sun.COM #define PCI_MAP_ATTR_READ 0x1ull 2189707SDaniel.Ice@Sun.COM #define PCI_MAP_ATTR_WRITE 0x2ull 2199707SDaniel.Ice@Sun.COM #define PCI_MAP_ATTR_RO 0x4ull 2200Sstevel@tonic-gate 2213156Sgirish #define PCI_MAP_ATTR_PHFUN 4 2223156Sgirish #define PCI_MAP_ATTR_BDF 16 2233156Sgirish 2249707SDaniel.Ice@Sun.COM #define PCI_MAP_ATTR_PHFUN_MASK 0x30 2259707SDaniel.Ice@Sun.COM #define PCI_MAP_ATTR_BDF_MASK 0xffff0000 2269707SDaniel.Ice@Sun.COM 2273156Sgirish #define PX_ADD_ATTR_EXTNS(attr, bdf) \ 228*9921SKrishna.Elango@Sun.COM (attr | (PCIE_CHECK_VALID_BDF(bdf) ? (bdf << PCI_MAP_ATTR_BDF) : 0)) 2293156Sgirish 2300Sstevel@tonic-gate typedef enum io_sync_direction { 2310Sstevel@tonic-gate IO_SYNC_DEVICE = (uint32_t)0x01, 2320Sstevel@tonic-gate IO_SYNC_CPU = (uint32_t)0x02 2330Sstevel@tonic-gate } io_sync_direction_t; 2340Sstevel@tonic-gate 2350Sstevel@tonic-gate /* 2360Sstevel@tonic-gate * MSI Definitions 2370Sstevel@tonic-gate * 2380Sstevel@tonic-gate * MSI - Message Signaled Interrupt 2390Sstevel@tonic-gate * 2400Sstevel@tonic-gate * Message Signaled Interrupt as defined in the PCI Local Bus 2410Sstevel@tonic-gate * Specification and the PCI Express Base Specification. 2420Sstevel@tonic-gate * A device signals an interrupt via MSI using a posted 2430Sstevel@tonic-gate * write cycle to an address specified by system software 2440Sstevel@tonic-gate * using a data value specified by system software. 2450Sstevel@tonic-gate * The MSI capability data structure contains fields for 2460Sstevel@tonic-gate * the PCI address and data values the device uses when 2470Sstevel@tonic-gate * sending an MSI message on the bus. MSI-X is an extended 2480Sstevel@tonic-gate * form of MSI, but uses the same mechanism for signaling 2490Sstevel@tonic-gate * the interrupt as MSI. For the purposes of this document, 2500Sstevel@tonic-gate * the term "MSI" refers to MSI or MSI-X. 2510Sstevel@tonic-gate * 2520Sstevel@tonic-gate * Root complexes that support MSI define an address range 2530Sstevel@tonic-gate * and set of data values that can be used to signal MSIs. 2540Sstevel@tonic-gate * 2550Sstevel@tonic-gate * SUN4V/pci requirements for MSI: 2560Sstevel@tonic-gate * 2570Sstevel@tonic-gate * The root complex defines two address ranges. One in 2580Sstevel@tonic-gate * the 32-bit pci memory space and one in the 64-bit 2590Sstevel@tonic-gate * pci memory address space used as the target of a posted 2600Sstevel@tonic-gate * write to signal an MSI. 2610Sstevel@tonic-gate * 2620Sstevel@tonic-gate * The root complex treats any write to these address 2630Sstevel@tonic-gate * ranges as signaling an MSI, however, only the data 2640Sstevel@tonic-gate * value used in the posted write signals the MSI. 2650Sstevel@tonic-gate * 2660Sstevel@tonic-gate * 2670Sstevel@tonic-gate * MSI EQ - MSI Event Queue 2680Sstevel@tonic-gate * 2690Sstevel@tonic-gate * The MSI Event Queue is a page-aligned main memory data 2700Sstevel@tonic-gate * structure used to store MSI data records. 2710Sstevel@tonic-gate * 2720Sstevel@tonic-gate * Each root port supports several MSI EQs, and each EQ has a 2730Sstevel@tonic-gate * system interrupt associated with it, and can be targeted 2740Sstevel@tonic-gate * (individually) to any cpu. The number of MSI EQs supported 2750Sstevel@tonic-gate * by a root complex is described by a property defined in [3]. 2760Sstevel@tonic-gate * Each MSI EQ must be large enough to contain all possible MSI 2770Sstevel@tonic-gate * data records generated by any one PCI root port. The number 2780Sstevel@tonic-gate * of entries in each MSI EQ is described by a property defined 2790Sstevel@tonic-gate * in [3]. 2800Sstevel@tonic-gate * 2810Sstevel@tonic-gate * Each MSI EQ is compliant with the definition of interrupt 2820Sstevel@tonic-gate * queues described in [5], however, instead of accessing the 2830Sstevel@tonic-gate * queue head/tail registers via ASI-based registers, an API 2840Sstevel@tonic-gate * is provided to access the head/tail registers. 2850Sstevel@tonic-gate * 2860Sstevel@tonic-gate * The SUN4V/pci compliant root complex has the ability to 2870Sstevel@tonic-gate * generate a system interrupt when the MSI EQ is non-empty. 2880Sstevel@tonic-gate * 2890Sstevel@tonic-gate * MSI/Message/INTx Data Record format 2900Sstevel@tonic-gate * 2910Sstevel@tonic-gate * Each data record consists of 64 bytes of data, aligned 2920Sstevel@tonic-gate * on a 64-byte boundary. 2930Sstevel@tonic-gate * 2940Sstevel@tonic-gate * The data record is defined as follows: 2950Sstevel@tonic-gate * 2960Sstevel@tonic-gate * 2970Sstevel@tonic-gate * 6666555555555544444444443333333333222222222211111111110000000000 2980Sstevel@tonic-gate * 3210987654321098765432109876543210987654321098765432109876543210 2990Sstevel@tonic-gate * 3000Sstevel@tonic-gate * 0x00: VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVxxxxxxxxxxxxxxxxxxxxxxxxTTTTTTTT 3010Sstevel@tonic-gate * 0x08: IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 3020Sstevel@tonic-gate * 0x10: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 3030Sstevel@tonic-gate * 0x18: SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS 3040Sstevel@tonic-gate * 0x20: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxRRRRRRRRRRRRRRRR 3050Sstevel@tonic-gate * 0x28: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 3060Sstevel@tonic-gate * 0x30: DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 3070Sstevel@tonic-gate * 0x38: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 3080Sstevel@tonic-gate * 3090Sstevel@tonic-gate * Where, 3100Sstevel@tonic-gate * 3110Sstevel@tonic-gate * xx..xx are unused bits and must be ignored by sw. 3120Sstevel@tonic-gate * 3130Sstevel@tonic-gate * VV..VV is the version number of this data record 3140Sstevel@tonic-gate * 3150Sstevel@tonic-gate * For this release of the spec, the version number 3160Sstevel@tonic-gate * field must be zero. 3170Sstevel@tonic-gate * 3180Sstevel@tonic-gate * TTTTTTTT is the data record type: 3190Sstevel@tonic-gate * 3200Sstevel@tonic-gate * Upper 4 bits are reserved, and must be zero 3210Sstevel@tonic-gate * 3220Sstevel@tonic-gate * 0000 - Not an MSI data record - reserved for sw use. 3230Sstevel@tonic-gate * 0001 - MSG 3240Sstevel@tonic-gate * 0010 - MSI32 3250Sstevel@tonic-gate * 0011 - MSI64 3260Sstevel@tonic-gate * 0010 - Reserved 3270Sstevel@tonic-gate * ... 3280Sstevel@tonic-gate * 0111 - Reserved 3290Sstevel@tonic-gate * 1000 - INTx 3300Sstevel@tonic-gate * 1001 - Reserved 3310Sstevel@tonic-gate * ... 3320Sstevel@tonic-gate * 1110 - Reserved 3330Sstevel@tonic-gate * 1111 - Not an MSI data record - reserved for sw use. 3340Sstevel@tonic-gate * 3350Sstevel@tonic-gate * All other encodings are reserved. 3360Sstevel@tonic-gate * 3370Sstevel@tonic-gate * II..II is the sysino for INTx (sw defined value), 3380Sstevel@tonic-gate * otherwise zero. 3390Sstevel@tonic-gate * 3400Sstevel@tonic-gate * SS..SS is the message timestamp if available. 3410Sstevel@tonic-gate * If supported by the implementation, a non-zero 3420Sstevel@tonic-gate * value in this field is a copy of the %stick register 3430Sstevel@tonic-gate * at the time the message is created. 3440Sstevel@tonic-gate * 3450Sstevel@tonic-gate * If unsupported, this field will contain zero. 3460Sstevel@tonic-gate * 3470Sstevel@tonic-gate * RR..RR is the requester ID of the device that initiated the MSI/MSG 3480Sstevel@tonic-gate * and has the following format: 3490Sstevel@tonic-gate * 3500Sstevel@tonic-gate * bbbbbbbb.dddddfff 3510Sstevel@tonic-gate * 3520Sstevel@tonic-gate * Where bb..bb is the bus number, 3530Sstevel@tonic-gate * dd..dd is the device number 3540Sstevel@tonic-gate * and fff is the function number. 3550Sstevel@tonic-gate * 3560Sstevel@tonic-gate * Note that for PCI devices or any message where 3570Sstevel@tonic-gate * the requester is unknown, this may be zero, 3580Sstevel@tonic-gate * or the device-id of an intermediate bridge. 3590Sstevel@tonic-gate * 3600Sstevel@tonic-gate * For intx messages, this field should be ignored. 3610Sstevel@tonic-gate * 3620Sstevel@tonic-gate * AA..AA is the MSI address. For MSI32, the upper 32-bits must be zero. 3630Sstevel@tonic-gate * (for data record type MSG or INTx, this field is ignored) 3640Sstevel@tonic-gate * 3650Sstevel@tonic-gate * DD..DD is the MSI/MSG data or INTx number 3660Sstevel@tonic-gate * 3670Sstevel@tonic-gate * For MSI-X, bits 31..0 contain the data from the MSI packet 3680Sstevel@tonic-gate * which is the msi-number. bits 63..32 shall be zero. 3690Sstevel@tonic-gate * 3700Sstevel@tonic-gate * For MSI, bits 15..0 contain the data from the MSI message 3710Sstevel@tonic-gate * which is the msi-number. bits 63..16 shall be zero 3720Sstevel@tonic-gate * 3730Sstevel@tonic-gate * For MSG data, the message code and message routing code 3740Sstevel@tonic-gate * are encoded as follows: 3750Sstevel@tonic-gate * 3760Sstevel@tonic-gate * 63:32 - 0000.0000.0000.0000.0000.0000.GGGG.GGGG 3770Sstevel@tonic-gate * 32:00 - 0000.0000.0000.0CCC.0000.0000.MMMM.MMMM 3780Sstevel@tonic-gate * 3790Sstevel@tonic-gate * Where, 3800Sstevel@tonic-gate * 3810Sstevel@tonic-gate * GG..GG is the target-id of the message in the 3820Sstevel@tonic-gate * following form: 3830Sstevel@tonic-gate * 3840Sstevel@tonic-gate * bbbbbbbb.dddddfff 3850Sstevel@tonic-gate * 3860Sstevel@tonic-gate * where bb..bb is the target bus number. 3870Sstevel@tonic-gate * ddddd is the target deviceid 3880Sstevel@tonic-gate * fff is the target function number. 3890Sstevel@tonic-gate * 3900Sstevel@tonic-gate * CCC is the message routing code as defined by [4] 3910Sstevel@tonic-gate * 3920Sstevel@tonic-gate * MM..MM is the message code as defined by [4] 3930Sstevel@tonic-gate * 3940Sstevel@tonic-gate * For INTx data, bits 63:2 must be zero and 3950Sstevel@tonic-gate * the low order 2 bits are defined as follows: 3960Sstevel@tonic-gate * 3970Sstevel@tonic-gate * 00 - INTA 3980Sstevel@tonic-gate * 01 - INTB 3990Sstevel@tonic-gate * 10 - INTC 4000Sstevel@tonic-gate * 11 - INTD 4010Sstevel@tonic-gate * 4020Sstevel@tonic-gate * cpuid - A unique opaque value which represents a target cpu. 4030Sstevel@tonic-gate * 4040Sstevel@tonic-gate * devhandle - Device handle. The device handle uniquely identifies a 4050Sstevel@tonic-gate * SUN4V device. It consists of the the lower 28-bits of the hi-cell 4060Sstevel@tonic-gate * of the first entry of the SUN4V device's "reg" property as defined 4070Sstevel@tonic-gate * by the SUN4V Bus Binding to Open Firmware. 4080Sstevel@tonic-gate * 4090Sstevel@tonic-gate * msinum - A value defining which MSI is being used. 4100Sstevel@tonic-gate * 4110Sstevel@tonic-gate * msiqhead - The index value of the current head index for a given 4120Sstevel@tonic-gate * MSI-EQ. 4130Sstevel@tonic-gate * 4140Sstevel@tonic-gate * msiqtail - The index value of the current tail index for a given 4150Sstevel@tonic-gate * MSI-EQ. 4160Sstevel@tonic-gate * 4170Sstevel@tonic-gate * msitype - Type specifier for MSI32 or MSI64 4180Sstevel@tonic-gate * 0 - type is MSI32 4190Sstevel@tonic-gate * 1 - type is MSI64 4200Sstevel@tonic-gate * 4210Sstevel@tonic-gate * msiqid - A number from 0 .. 'number of MSI-EQs - 1', defining 4220Sstevel@tonic-gate * which MSI EQ within the device is being used. 4230Sstevel@tonic-gate * 4240Sstevel@tonic-gate * msiqstate - An unsigned integer containing one of the 4250Sstevel@tonic-gate * following values: 4260Sstevel@tonic-gate * 4270Sstevel@tonic-gate * PCI_MSIQSTATE_IDLE 0 # idle (non-error) state 4280Sstevel@tonic-gate * PCI_MSIQSTATE_ERROR 1 # error state 4290Sstevel@tonic-gate * 4300Sstevel@tonic-gate * msiqvalid - An unsigned integer containing one of the 4310Sstevel@tonic-gate * following values: 4320Sstevel@tonic-gate * 4330Sstevel@tonic-gate * PCI_MSIQ_INVALID 0 # disabled/invalid 4340Sstevel@tonic-gate * PCI_MSIQ_VALID 1 # enabled/valid 4350Sstevel@tonic-gate * 4360Sstevel@tonic-gate * msistate - An unsigned integer containing one of the following 4370Sstevel@tonic-gate * values: 4380Sstevel@tonic-gate * 4390Sstevel@tonic-gate * PCI_MSISTATE_IDLE 0 # idle/not enabled 4400Sstevel@tonic-gate * PCI_MSISTATE_DELIVERED 1 # MSI Delivered 4410Sstevel@tonic-gate * 4420Sstevel@tonic-gate * msivalid - An unsigned integer containing one of the 4430Sstevel@tonic-gate * following values: 4440Sstevel@tonic-gate * 4450Sstevel@tonic-gate * PCI_MSI_INVALID 0 # disabled/invalid 4460Sstevel@tonic-gate * PCI_MSI_VALID 1 # enabled/valid 4470Sstevel@tonic-gate * 4480Sstevel@tonic-gate * msgtype - A value defining which MSG type is being used. An unsigned 4490Sstevel@tonic-gate * integer containing one of the following values: 4500Sstevel@tonic-gate * (as per PCIe spec 1.0a) 4510Sstevel@tonic-gate * 4520Sstevel@tonic-gate * PCIE_PME_MSG 0x18 PME message 4530Sstevel@tonic-gate * PCIE_PME_ACK_MSG 0x1b PME ACK message 4540Sstevel@tonic-gate * PCIE_CORR_MSG 0x30 Correctable message 4550Sstevel@tonic-gate * PCIE_NONFATAL_MSG 0x31 Non fatal message 4560Sstevel@tonic-gate * PCIE_FATAL_MSG 0x33 Fatal message 4570Sstevel@tonic-gate */ 4580Sstevel@tonic-gate 4590Sstevel@tonic-gate typedef uint32_t msinum_t; 4600Sstevel@tonic-gate typedef uint32_t msiqid_t; 4610Sstevel@tonic-gate typedef uint32_t msgcode_t; 4620Sstevel@tonic-gate typedef uint64_t msiqhead_t; 4630Sstevel@tonic-gate typedef uint64_t msiqtail_t; 4640Sstevel@tonic-gate 4650Sstevel@tonic-gate /* MSIQ state */ 4660Sstevel@tonic-gate typedef enum pci_msiq_state { 4670Sstevel@tonic-gate PCI_MSIQ_STATE_IDLE = (uint32_t)0, /* idle (non-error) state */ 4680Sstevel@tonic-gate PCI_MSIQ_STATE_ERROR = (uint32_t)1 /* error state */ 4690Sstevel@tonic-gate } pci_msiq_state_t; 4700Sstevel@tonic-gate 4710Sstevel@tonic-gate /* MSIQ valid */ 4720Sstevel@tonic-gate typedef enum pci_msiq_valid_state { 4730Sstevel@tonic-gate PCI_MSIQ_INVALID = (uint32_t)0, /* disabled/invalid */ 4740Sstevel@tonic-gate PCI_MSIQ_VALID = (uint32_t)1 /* enabled/valid */ 4750Sstevel@tonic-gate } pci_msiq_valid_state_t; 4760Sstevel@tonic-gate 4770Sstevel@tonic-gate /* MSIQ Record data structure */ 4780Sstevel@tonic-gate typedef struct msiq_rec { 4790Sstevel@tonic-gate uint64_t msiq_rec_version : 32, /* DW 0 - 63:32 */ 4800Sstevel@tonic-gate msiq_rec_rsvd0 : 24, /* DW 0 - 31:09 */ 4810Sstevel@tonic-gate msiq_rec_type : 8; /* DW 0 - 07:00 */ 4820Sstevel@tonic-gate uint64_t msiq_rec_intx; /* DW 1 */ 4830Sstevel@tonic-gate uint64_t msiq_rec_rsvd1; /* DW 2 */ 4840Sstevel@tonic-gate uint64_t msiq_rec_timestamp; /* DW 3 */ 4850Sstevel@tonic-gate uint64_t msiq_rec_rsvd2 : 48, /* DW 4 - 63:16 */ 4860Sstevel@tonic-gate msiq_rec_rid : 16; /* DW 4 - 15:00 */ 4870Sstevel@tonic-gate uint64_t msiq_rec_msi_addr; /* DW 5 - 63:00 */ 4880Sstevel@tonic-gate union { 4890Sstevel@tonic-gate struct { 4900Sstevel@tonic-gate uint64_t msix_rsvd0 : 32, /* DW 6 - 63:32 */ 4910Sstevel@tonic-gate msix_data : 32; /* DW 6 - 31:00 */ 4920Sstevel@tonic-gate } msix; 4930Sstevel@tonic-gate struct { 4940Sstevel@tonic-gate uint64_t msi_rsvd0 : 48, /* DW 6 - 63:16 */ 4950Sstevel@tonic-gate msi_data: 16; /* DW 6 - 15:00 */ 4960Sstevel@tonic-gate } msi; 4970Sstevel@tonic-gate struct { 4980Sstevel@tonic-gate uint64_t msg_rsvd0: 24, /* DW 6 - 63:40 */ 4990Sstevel@tonic-gate msg_targ: 8, /* DW 6 - 39:32 */ 5000Sstevel@tonic-gate msg_rsvd1: 13, /* DW 6 - 31:19 */ 5010Sstevel@tonic-gate msg_route: 3, /* DW 6 - 18:16 */ 5020Sstevel@tonic-gate msg_rsvd2: 8, /* DW 6 - 15:08 */ 5030Sstevel@tonic-gate msg_code: 8; /* DW 6 - 07:00 */ 5040Sstevel@tonic-gate } msg; 5050Sstevel@tonic-gate } msiq_rec_data; 5060Sstevel@tonic-gate uint64_t msiq_rec_rsvd3; /* DW 7 */ 5070Sstevel@tonic-gate } msiq_rec_t; 5080Sstevel@tonic-gate 5090Sstevel@tonic-gate /* MSIQ Record type */ 5100Sstevel@tonic-gate typedef enum msiq_rec_type { 5110Sstevel@tonic-gate MSG_REC = (uint32_t)1, /* PCIe message record */ 5120Sstevel@tonic-gate MSI32_REC = (uint32_t)2, /* MSI32 record */ 5130Sstevel@tonic-gate MSI64_REC = (uint32_t)3, /* MSI64 record */ 5140Sstevel@tonic-gate INTX_REC = (uint32_t)8 /* INTx record */ 5150Sstevel@tonic-gate } msiq_rec_type_t; 5160Sstevel@tonic-gate 5170Sstevel@tonic-gate /* MSIQ Record type */ 5180Sstevel@tonic-gate typedef enum msi_type { 5190Sstevel@tonic-gate MSI32_TYPE = (uint32_t)0, /* MSI32 type */ 5200Sstevel@tonic-gate MSI64_TYPE = (uint32_t)1 /* MSI64 type */ 5210Sstevel@tonic-gate } msi_type_t; 5220Sstevel@tonic-gate 5230Sstevel@tonic-gate /* MSI state */ 5240Sstevel@tonic-gate typedef enum pci_msi_state { 5250Sstevel@tonic-gate PCI_MSI_STATE_IDLE = (uint32_t)0, /* idle/not enabled */ 5260Sstevel@tonic-gate PCI_MSI_STATE_DELIVERED = (uint32_t)1 /* MSI delivered */ 5270Sstevel@tonic-gate } pci_msi_state_t; 5280Sstevel@tonic-gate 5290Sstevel@tonic-gate /* MSI valid */ 5300Sstevel@tonic-gate typedef enum pci_msi_valid_state { 5310Sstevel@tonic-gate PCI_MSI_INVALID = (uint32_t)0, /* disabled/invalid */ 5320Sstevel@tonic-gate PCI_MSI_VALID = (uint32_t)1 /* enabled/valid */ 5330Sstevel@tonic-gate } pci_msi_valid_state_t; 5340Sstevel@tonic-gate 5350Sstevel@tonic-gate /* MSG valid */ 5360Sstevel@tonic-gate typedef enum pcie_msg_valid_state { 5370Sstevel@tonic-gate PCIE_MSG_INVALID = (uint32_t)0, /* disabled/invalid */ 5380Sstevel@tonic-gate PCIE_MSG_VALID = (uint32_t)1 /* enabled/valid */ 5390Sstevel@tonic-gate } pcie_msg_valid_state_t; 5400Sstevel@tonic-gate 5410Sstevel@tonic-gate /* PCIe MSG types */ 5420Sstevel@tonic-gate typedef enum pcie_msg_type { 5430Sstevel@tonic-gate PCIE_PME_MSG = (uint64_t)0x18, /* PME message */ 5440Sstevel@tonic-gate PCIE_PME_ACK_MSG = (uint64_t)0x1b, /* PME ACK message */ 5450Sstevel@tonic-gate PCIE_CORR_MSG = (uint64_t)0x30, /* Correctable message */ 5460Sstevel@tonic-gate PCIE_NONFATAL_MSG = (uint64_t)0x31, /* Non fatal message */ 5470Sstevel@tonic-gate PCIE_FATAL_MSG = (uint64_t)0x33 /* Fatal message */ 5480Sstevel@tonic-gate } pcie_msg_type_t; 5490Sstevel@tonic-gate 5500Sstevel@tonic-gate #endif /* _ASM */ 5510Sstevel@tonic-gate 5520Sstevel@tonic-gate #ifdef __cplusplus 5530Sstevel@tonic-gate } 5540Sstevel@tonic-gate #endif 5550Sstevel@tonic-gate 5560Sstevel@tonic-gate #endif /* _SYS_PX_IOAPI_H */ 557