pcie.h revision 92e1ac0d7d0f8596dfc8b9e1302e1100e5b35efa
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_PCIE_H
#define _SYS_PCIE_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/*
* PCI Express capability registers in PCI configuration space relative to
* the PCI Express Capability structure.
*/
#define PCIE_CAP_ID PCI_CAP_ID
#define PCIE_CAP_NEXT_PTR PCI_CAP_NEXT_PTR
/*
* PCI-Express Config Space size
*/
/*
* PCI-Express Capabilities Register (2 bytes)
*/
/*
* Device Capabilities Register (4 bytes)
*/
#define PCIE_DEVCAP_MAX_PAYLOAD_128 0x0
#define PCIE_DEVCAP_MAX_PAYLOAD_256 0x1
#define PCIE_DEVCAP_MAX_PAYLOAD_512 0x2
#define PCIE_DEVCAP_MAX_PAYLOAD_1024 0x3
#define PCIE_DEVCAP_MAX_PAYLOAD_2048 0x4
#define PCIE_DEVCAP_MAX_PAYLOAD_4096 0x5
/*
* Device Control Register (2 bytes)
*/
#define PCIE_DEVCTL_MAX_PAYLOAD_128 0x00
#define PCIE_DEVCTL_MAX_PAYLOAD_256 0x20
#define PCIE_DEVCTL_MAX_PAYLOAD_512 0x40
#define PCIE_DEVCTL_MAX_PAYLOAD_1024 0x60
#define PCIE_DEVCTL_MAX_PAYLOAD_2048 0x80
#define PCIE_DEVCTL_MAX_PAYLOAD_4096 0xA0
#define PCIE_DEVCTL_MAX_READ_REQ_128 0x00
#define PCIE_DEVCTL_MAX_READ_REQ_256 0x10
#define PCIE_DEVCTL_MAX_READ_REQ_512 0x20
#define PCIE_DEVCTL_MAX_READ_REQ_1024 0x30
#define PCIE_DEVCTL_MAX_READ_REQ_2048 0x40
#define PCIE_DEVCTL_MAX_READ_REQ_4096 0x50
/*
* Device Status Register (2 bytes)
*/
/*
* Link Capability Register (4 bytes)
*/
#define PCIE_LINKCAP_MAX_WIDTH_X1 0x010
#define PCIE_LINKCAP_MAX_WIDTH_X2 0x020
#define PCIE_LINKCAP_MAX_WIDTH_X4 0x040
#define PCIE_LINKCAP_MAX_WIDTH_X8 0x080
#define PCIE_LINKCAP_MAX_WIDTH_X12 0x0C0
#define PCIE_LINKCAP_MAX_WIDTH_X16 0x100
#define PCIE_LINKCAP_MAX_WIDTH_X32 0x200
/* PCIe v1.1 spec based */
/* Capable bit */
/*
* Link Control Register (2 bytes)
*/
/*
* Link Status Register (2 bytes)
*/
#define PCIE_LINKSTS_NEG_WIDTH_X1 0x010
#define PCIE_LINKSTS_NEG_WIDTH_X2 0x020
#define PCIE_LINKSTS_NEG_WIDTH_X4 0x040
#define PCIE_LINKSTS_NEG_WIDTH_X8 0x080
#define PCIE_LINKSTS_NEG_WIDTH_X12 0x0C0
#define PCIE_LINKSTS_NEG_WIDTH_X16 0x100
#define PCIE_LINKSTS_NEG_WIDTH_X32 0x200
/* PCIe v1.1 spec based */
/*
* Slot Capability Register (4 bytes)
*/
#define PCIE_SLOTCAP_PHY_SLOT_NUM(reg) \
(((reg) >> PCIE_SLOTCAP_PHY_SLOT_NUM_SHIFT) & \
/*
* Slot Control Register (2 bytes)
*/
/* State values for the Power and Attention Indicators */
/*
* in the PCI Express Slot Control Register.
*/
#define pcie_slotctl_pwr_indicator_get(reg) \
#define pcie_slotctl_attn_indicator_get(ctrl) \
#define pcie_slotctl_attn_indicator_set(ctrl, v)\
#define pcie_slotctl_pwr_indicator_set(ctrl, v)\
/*
* Slot Status register (2 bytes)
*/
/*
* Root Control Register (2 bytes)
*/
/*
* Root Status Register (4 bytes)
*/
#define PCIE_ROOTSTS_PME_REQ_ID_SHIFT 0 /* PME Requestor ID */
/*
* PCI-Express Enhanced Capabilities Link Entry Bit Offsets
*/
#define PCIE_EXT_CAP_ID_SHIFT 0 /* PCI-e Ext Cap ID */
#define PCIE_EXT_CAP_ID_MASK 0xFFFF
#define PCIE_EXT_CAP_VER_MASK 0xF
#define PCIE_EXT_CAP_NEXT_PTR_MASK 0xFFF
#define PCIE_EXT_CAP_NEXT_PTR_NULL 0x0
/*
* PCI-Express Enhanced Capability Identifier Values
*/
/*
* PCI-Express Advanced Error Reporting Extended Capability Offsets
*/
/* Root Ports Only */
/* Bridges Only */
/*
*/
#define PCIE_AER_UCE_BITS (PCIE_AER_UCE_TRAINING | \
/*
*/
#define PCIE_AER_CE_BITS (PCIE_AER_CE_RECEIVER_ERR | \
/*
* AER Capability & Control
*/
/*
* AER Root Command Register
*/
/*
* AER Root Error Status Register
*/
/*
* AER Error Source Identification Register
*/
#define PCIE_AER_ERR_SRC_ID_CE_SHIFT 0 /* ERR_COR Source ID */
#define PCIE_AER_ERR_SRC_ID_CE_MASK 0xFFFF
#define PCIE_AER_ERR_SRC_ID_UE_MASK 0xFFF
/*
* AER Secondary Uncorrectable Error Register
*/
#define PCIE_AER_SUCE_BITS (PCIE_AER_SUCE_TA_ON_SC | \
/*
* AER Secondary Capability & Control
*/
/*
* AER Secondary Headers
* The Secondary Header Logs is 4 DW long.
* The first 2 DW are split into 3 sections
* o Transaction Attribute
* o Transaction Command Lower
* o Transaction Command Higher
* The last 2 DW is the Transaction Address
*/
#define PCIE_AER_SHDR_LOG_ATTR_MASK 0xFFFFFFFFF
#define PCIE_AER_SHDR_LOG_CMD_LOW_MASK 0xF000000000
#define PCIE_AER_SHDR_LOG_CMD_HIGH_MASK 0xF0000000000
#define PCIE_AER_SHDR_LOG_ADDR_MASK 0xFFFFFFFFFFFFFFFF
/*
* PCI-E Common TLP Header Fields
*/
#define PCIE_TLP_FMT_3DW 0x00
#define PCIE_TLP_FMT_4DW 0x20
#define PCIE_TLP_FMT_3DW_DATA 0x40
#define PCIE_TLP_FMT_4DW_DATA 0x60
#define PCIE_TLP_TYPE_MEM 0x0
#define PCIE_TLP_TYPE_MEMLK 0x1
#define PCIE_TLP_TYPE_IO 0x2
#define PCIE_TLP_TYPE_CFG0 0x4
#define PCIE_TLP_TYPE_CFG1 0x5
#define PCIE_TLP_TYPE_MSG 0x10
#define PCIE_TLP_TYPE_CPL 0xA
#define PCIE_TLP_TYPE_CPLLK 0xB
#define PCIE_TLP_TYPE_MSI 0x18
typedef uint16_t pcie_req_id_t;
#define PCIE_REQ_ID_BUS_SHIFT 8
#define PCIE_REQ_ID_BUS_MASK 0xFF00
#define PCIE_REQ_ID_DEV_SHIFT 3
#define PCIE_REQ_ID_DEV_MASK 0x00F1
#define PCIE_REQ_ID_FUNC_SHIFT 0
#define PCIE_REQ_ID_FUNC_MASK 0x0007
/*
* PCI-Express Message Request Header
*/
typedef struct pcie_msg {
td :1,
ep :1,
attr :2,
rsvd2 :2,
len :10;
tag :8,
msg_code:8;
} pcie_msg_t;
#define PCIE_MSG_CODE_ERR_COR 0x30
#define PCIE_MSG_CODE_ERR_NONFATAL 0x31
#define PCIE_MSG_CODE_ERR_FATAL 0x33
/*
* Exported PCI-express property names
*/
#define SAVED_PCIEX_CAP_REG "pciex-cap-reg"
#define SAVED_PCIEX_SLOTCAP_REG "pciex-slotcap-reg"
#ifdef __cplusplus
}
#endif
#endif /* _SYS_PCIE_H */