pcie.h revision 5fb1ded3757bc29bbdcedd110025238dbcbc8d76
/*
* 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 0x0000
#define PCIE_DEVCTL_MAX_READ_REQ_256 0x1000
#define PCIE_DEVCTL_MAX_READ_REQ_512 0x2000
#define PCIE_DEVCTL_MAX_READ_REQ_1024 0x3000
#define PCIE_DEVCTL_MAX_READ_REQ_2048 0x4000
#define PCIE_DEVCTL_MAX_READ_REQ_4096 0x5000
/*
* 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
*/
/* Endpoint Association */
/*
* 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 | \
#define PCIE_AER_SUCE_LOG_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-Express Device Serial Number Capability Offsets.
*/
/*
* 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
#define PCIE_CPL_STS_SUCCESS 0
#define PCIE_CPL_STS_UR 1
#define PCIE_CPL_STS_CRS 2
#define PCIE_CPL_STS_CA 4
#if defined(_BIT_FIELDS_LTOH)
/*
* PCI Express little-endian common TLP header format
*/
typedef struct pcie_tlp_hdr {
rsvd3 :2,
attr :2,
ep :1,
td :1,
rsvd2 :4,
tc :3,
rsvd1 :1,
type :5,
fmt :2,
rsvd0 :1;
typedef struct pcie_mem64 {
lbe :4,
tag :8,
rid :16;
addr0 :30;
} pcie_mem64_t;
typedef struct pcie_memio32 {
lbe :4,
tag :8,
rid :16;
addr0 :30;
typedef struct pcie_cfg {
lbe :4,
tag :8,
rid :16;
reg :6,
extreg :4,
rsvd0 :4,
func :3,
dev :5,
bus :8;
} pcie_cfg_t;
typedef struct pcie_cpl {
bcm :1,
status :3,
cid :16;
rsvd0 :1,
tag :8,
rid :16;
} pcie_cpl_t;
/*
* PCI-Express Message Request Header
*/
typedef struct pcie_msg {
tag :8,
rid :16;
} pcie_msg_t;
#elif defined(_BIT_FIELDS_HTOL)
/*
* PCI Express big-endian common TLP header format
*/
typedef struct pcie_tlp_hdr {
fmt :2,
type :5,
rsvd1 :1,
tc :3,
rsvd2 :4,
td :1,
ep :1,
attr :2,
rsvd3 :2,
len :10;
typedef struct pcie_mem64 {
tag :8,
lbe :4,
fbe :4;
rsvd0 :2;
} pcie_mem64_t;
typedef struct pcie_memio32 {
tag :8,
lbe :4,
fbe :4;
rsvd0 :2;
typedef struct pcie_cfg {
tag :8,
lbe :4,
fbe :4;
dev :5,
func :3,
rsvd0 :4,
extreg :4,
reg :6,
rsvd1 :2;
} pcie_cfg_t;
typedef struct pcie_cpl {
status :3,
bcm :1,
bc :12;
tag :8,
rsvd0 :1,
laddr :7;
} pcie_cpl_t;
/*
* PCI-Express Message Request Header
*/
typedef struct pcie_msg {
tag :8,
msg_code:8;
} pcie_msg_t;
#else
#error "bit field not defined"
#endif
#define PCIE_MSG_CODE_ERR_COR 0x30
#define PCIE_MSG_CODE_ERR_NONFATAL 0x31
#define PCIE_MSG_CODE_ERR_FATAL 0x33
#ifdef __cplusplus
}
#endif
#endif /* _SYS_PCIE_H */