From 73131413e33d27e27d3f8b79bfcfe92cbbbd1b2f Mon Sep 17 00:00:00 2001 From: Robert Mustacchi Date: Mon, 8 Apr 2019 23:35:45 +0000 Subject: [PATCH] OS-7715 Update PCIe capability headers for PCIe 4.x OS-7716 Record PCIe gen 4 caps Reviewed by: Mike Zeller Reviewed by: Dan McDonald Approved by: Jerry Jelinek --- usr/src/uts/common/io/pciex/pcie.c | 10 ++- usr/src/uts/common/sys/pci.h | 5 +- usr/src/uts/common/sys/pcie.h | 125 +++++++++++++++++++++++++++-- usr/src/uts/common/sys/pcie_impl.h | 5 +- 4 files changed, 133 insertions(+), 12 deletions(-) diff --git a/usr/src/uts/common/io/pciex/pcie.c b/usr/src/uts/common/io/pciex/pcie.c index 2f424321f168..90ae4e8e4d0e 100644 --- a/usr/src/uts/common/io/pciex/pcie.c +++ b/usr/src/uts/common/io/pciex/pcie.c @@ -21,7 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2017, Joyent, Inc. + * Copyright 2019, Joyent, Inc. */ #include @@ -1002,6 +1002,9 @@ pcie_capture_speeds(pcie_bus_t *bus_p, pcie_req_id_t bdf, dev_info_t *rcdip) case PCIE_LINKSTS_SPEED_8: bus_p->bus_cur_speed = PCIE_LINK_SPEED_8; break; + case PCIE_LINKSTS_SPEED_16: + bus_p->bus_cur_speed = PCIE_LINK_SPEED_16; + break; default: bus_p->bus_cur_speed = PCIE_LINK_SPEED_UNKNOWN; break; @@ -1076,6 +1079,8 @@ pcie_capture_speeds(pcie_bus_t *bus_p, pcie_req_id_t bdf, dev_info_t *rcdip) bus_p->bus_sup_speed |= PCIE_LINK_SPEED_5; if (cap2 & PCIE_LINKCAP2_SPEED_8) bus_p->bus_sup_speed |= PCIE_LINK_SPEED_8; + if (cap2 & PCIE_LINKCAP2_SPEED_16) + bus_p->bus_sup_speed |= PCIE_LINK_SPEED_16; switch (cap & PCIE_LINKCAP_MAX_SPEED_MASK) { case PCIE_LINKCAP_MAX_SPEED_2_5: @@ -1087,6 +1092,9 @@ pcie_capture_speeds(pcie_bus_t *bus_p, pcie_req_id_t bdf, dev_info_t *rcdip) case PCIE_LINKCAP_MAX_SPEED_8: bus_p->bus_max_speed = PCIE_LINK_SPEED_8; break; + case PCIE_LINKCAP_MAX_SPEED_16: + bus_p->bus_max_speed = PCIE_LINK_SPEED_16; + break; default: bus_p->bus_max_speed = PCIE_LINK_SPEED_UNKNOWN; break; diff --git a/usr/src/uts/common/sys/pci.h b/usr/src/uts/common/sys/pci.h index 66ce71bcc2a1..d62d19c3a590 100644 --- a/usr/src/uts/common/sys/pci.h +++ b/usr/src/uts/common/sys/pci.h @@ -21,7 +21,7 @@ /* * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. - * Copyright 2018 Joyent, Inc. + * Copyright 2019, Joyent, Inc. */ #ifndef _SYS_PCI_H @@ -168,6 +168,7 @@ extern "C" { /* * PCI status register bits */ +#define PCI_STAT_READY 0x1 /* Immediate Readiness */ #define PCI_STAT_INTR 0x8 /* Interrupt state */ #define PCI_STAT_CAP 0x10 /* Implements Capabilities */ #define PCI_STAT_66MHZ 0x20 /* 66 MHz capable */ @@ -928,6 +929,8 @@ typedef struct pcix_attr { #define PCI_MSI_MME_SHIFT 0x4 /* Shift for MME bits */ #define PCI_MSI_64BIT_MASK 0x0080 /* 64bit support mask in MSI ctrl reg */ #define PCI_MSI_PVM_MASK 0x0100 /* PVM support mask in MSI ctrl reg */ +#define PCI_MSI_EMD_MASK 0x0200 /* EMD Capable Mask */ +#define PCI_MSI_EMD_ENABLE 0x0400 /* EMD Enable bit */ /* * PCI Extended Message Signalled Interrupts (MSI-X) capability entry offsets diff --git a/usr/src/uts/common/sys/pcie.h b/usr/src/uts/common/sys/pcie.h index 0e5f929164f6..a26729c523b6 100644 --- a/usr/src/uts/common/sys/pcie.h +++ b/usr/src/uts/common/sys/pcie.h @@ -23,7 +23,7 @@ * Use is subject to license terms. */ /* - * Copyright (c) 2017, Joyent, Inc. + * Copyright 2019, Joyent, Inc. */ #ifndef _SYS_PCIE_H @@ -52,6 +52,7 @@ extern "C" { #define PCIE_SLOTCTL 0x18 /* Slot Control */ #define PCIE_SLOTSTS 0x1A /* Slot Status */ #define PCIE_ROOTCTL 0x1C /* Root Control */ +#define PCIE_ROOTCAP 0x1E /* Root Capabilities */ #define PCIE_ROOTSTS 0x20 /* Root Status */ #define PCIE_DEVCAP2 0x24 /* Device Capability 2 */ #define PCIE_DEVCTL2 0x28 /* Device Control 2 */ @@ -128,6 +129,9 @@ extern "C" { #define PCIE_DEVCAP_EP_L1_LAT_MAX 0x1C0 /* > 64 us */ #define PCIE_DEVCAP_EP_L1_LAT_MASK 0x700 /* EP L1 Accetable Latency */ +/* + * As of PCIe 2.x these three bits are now undefined. + */ #define PCIE_DEVCAP_ATTN_BUTTON 0x1000 /* Attention Button Present */ #define PCIE_DEVCAP_ATTN_INDICATOR 0x2000 /* Attn Indicator Present */ #define PCIE_DEVCAP_PWR_INDICATOR 0x4000 /* Power Indicator Present */ @@ -179,7 +183,8 @@ extern "C" { #define PCIE_DEVCTL_MAX_READ_REQ_MASK 0x7000 /* Max_Read_Request_Size */ #define PCIE_DEVCTL_MAX_READ_REQ_SHIFT 0xC -#define PCIE_DEVCTL_INITIATE_FLR 0x8000 +#define PCIE_DEVCTL_BRIDGE_RETRY 0x8000 /* Bridge can return CRS */ +#define PCIE_DEVCTL_INITIATE_FLR 0x8000 /* Start Function Level Reset */ /* * Device Status Register (2 bytes) @@ -190,6 +195,7 @@ extern "C" { #define PCIE_DEVSTS_UR_DETECTED 0x8 /* Unsupported Req Detected */ #define PCIE_DEVSTS_AUX_POWER 0x10 /* AUX Power Detected */ #define PCIE_DEVSTS_TRANS_PENDING 0x20 /* Transactions Pending */ +#define PCIE_DEVSTS_EPR_DETECTED 0x40 /* Emergency Power Reduction */ /* * Link Capability Register (4 bytes) @@ -202,6 +208,7 @@ extern "C" { */ #define PCIE_LINKCAP_MAX_SPEED_5 0x2 /* 5.0 GT/s Speed */ #define PCIE_LINKCAP_MAX_SPEED_8 0x3 /* 8.0 GT/s Speed */ +#define PCIE_LINKCAP_MAX_SPEED_16 0x4 /* 16.0 GT/s Speed */ #define PCIE_LINKCAP_MAX_SPEED_MASK 0xF /* Maximum Link Speed */ #define PCIE_LINKCAP_MAX_WIDTH_X1 0x010 #define PCIE_LINKCAP_MAX_WIDTH_X2 0x020 @@ -213,6 +220,7 @@ extern "C" { #define PCIE_LINKCAP_MAX_WIDTH_MASK 0x3f0 /* Maximum Link Width */ #define PCIE_LINKCAP_ASPM_SUP_L0S 0x400 /* L0s Entry Supported */ +#define PCIE_LINKCAP_ASPM_SUP_L1 0x800 /* L1 Entry Supported */ #define PCIE_LINKCAP_ASPM_SUP_L0S_L1 0xC00 /* L0s abd L1 Supported */ #define PCIE_LINKCAP_ASPM_SUP_MASK 0xC00 /* ASPM Support */ @@ -236,9 +244,12 @@ extern "C" { #define PCIE_LINKCAP_L1_EXIT_LAT_MAX 0x38000 /* > 64 us */ #define PCIE_LINKCAP_L1_EXIT_LAT_MASK 0x38000 /* L1 Exit Latency */ -/* PCIe v1.1 spec based */ +#define PCIE_LINKCAP_CLOCK_POWER_MGMT 0x40000 /* Clock Power Management */ +#define PCIE_LINKCAP_SDER_CAP 0x80000 /* Surprise Down Err report */ #define PCIE_LINKCAP_DLL_ACTIVE_REP_CAPABLE 0x100000 /* DLL Active */ /* Capable bit */ +#define PCIE_LINKCAP_LINK_BW_NOTIFY_CAP 0x200000 /* Link Bandwidth Notify Cap */ +#define PCIE_LINKCAP_ASPM_OPTIONAL 0x400000 /* ASPM Opt. Comp. */ #define PCIE_LINKCAP_PORT_NUMBER 0xFF000000 /* Port Number */ #define PCIE_LINKCAP_PORT_NUMBER_SHIFT 24 /* Port Number Shift */ @@ -261,6 +272,15 @@ extern "C" { #define PCIE_LINKCTL_RETRAIN_LINK 0x20 /* Retrain Link */ #define PCIE_LINKCTL_COMMON_CLK_CFG 0x40 /* Common Clock Configuration */ #define PCIE_LINKCTL_EXT_SYNCH 0x80 /* Extended Synch */ +#define PCIE_LINKCTL_CLOCK_POWER_MGMT 0x100 /* Enable Clock Power Mgmt. */ +#define PCIE_LINKCTL_HW_WIDTH_DISABLE 0x200 /* hw auto width disable */ +#define PCIE_LINKCTL_LINK_BW_INTR_EN 0x400 /* Link bw mgmt intr */ +#define PCIE_LINKCTL_LINK_AUTO_BW_INTR_EN 0x800 /* Auto bw intr */ + +#define PCI_LINKCTRL_DRS_SIG_CTRL_NO_REP 0x00 +#define PCI_LINKCTRL_DRS_SIG_CTRL_IE 0x4000 +#define PCI_LINKCTRL_DRS_SIG_CTRL_DRS_FRS 0x8000 +#define PCIE_LINKCTL_DRS_SIG_CTRL_MASK 0xC000 /* DRS Signaling Control */ /* * Link Status Register (2 bytes) @@ -268,6 +288,7 @@ extern "C" { #define PCIE_LINKSTS_SPEED_2_5 0x1 /* 2.5 GT/s Link Speed */ #define PCIE_LINKSTS_SPEED_5 0x2 /* 5.0 GT/s Link Speed */ #define PCIE_LINKSTS_SPEED_8 0x3 /* 8.0 GT/s Link Speed */ +#define PCIE_LINKSTS_SPEED_16 0x4 /* 16.0 GT/s Link Speed */ #define PCIE_LINKSTS_SPEED_MASK 0xF /* Link Speed */ #define PCIE_LINKSTS_NEG_WIDTH_X1 0x010 @@ -279,12 +300,13 @@ extern "C" { #define PCIE_LINKSTS_NEG_WIDTH_X32 0x200 #define PCIE_LINKSTS_NEG_WIDTH_MASK 0x3F0 /* Negotiated Link Width */ +/* This bit is undefined as of PCIe 2.x */ #define PCIE_LINKSTS_TRAINING_ERROR 0x400 /* Training Error */ #define PCIE_LINKSTS_LINK_TRAINING 0x800 /* Link Training */ #define PCIE_LINKSTS_SLOT_CLK_CFG 0x1000 /* Slot Clock Configuration */ - -/* PCIe v1.1 spec based */ #define PCIE_LINKSTS_DLL_LINK_ACTIVE 0x2000 /* DLL Link Active */ +#define PCIE_LINKSTS_LINK_BW_MGMT 0x4000 /* Link bw mgmt status */ +#define PCIE_LINKSTS_AUTO_BW 0x8000 /* Link auto BW status */ /* * Slot Capability Register (4 bytes) @@ -327,6 +349,7 @@ extern "C" { #define PCIE_SLOTCTL_PWR_CONTROL 0x0400 /* Power controller Control */ #define PCIE_SLOTCTL_EMI_LOCK_CONTROL 0x0800 /* EMI Lock control */ #define PCIE_SLOTCTL_DLL_STATE_EN 0x1000 /* DLL State Changed En */ +#define PCIE_SLOTCTL_AUTO_SLOT_PL_DIS 0x2000 /* Auto Slot Power Limit Dis */ #define PCIE_SLOTCTL_ATTN_INDICATOR_MASK 0x00C0 /* Attn Indicator mask */ #define PCIE_SLOTCTL_PWR_INDICATOR_MASK 0x0300 /* Power Indicator mask */ #define PCIE_SLOTCTL_INTR_MASK 0x103f /* Supported intr mask */ @@ -370,6 +393,12 @@ extern "C" { #define PCIE_ROOTCTL_SYS_ERR_ON_NFE_EN 0x2 /* Sys Err on NF Err Enable */ #define PCIE_ROOTCTL_SYS_ERR_ON_FE_EN 0x4 /* Sys Err on Fatal Err En */ #define PCIE_ROOTCTL_PME_INTERRUPT_EN 0x8 /* PME Interrupt Enable */ +#define PCIE_ROOTCTL_CRS_SW_VIS_EN 0x10 /* CRS SW Visibility EN */ + +/* + * Root Capabilities register (2 bytes) + */ +#define PCIE_ROOTCAP_CRS_SW_VIS 0x01 /* CRS SW Visible */ /* * Root Status Register (4 bytes) @@ -394,10 +423,20 @@ extern "C" { #define PCIE_DEVCAP2_LTR_MECH 0x800 #define PCIE_DEVCAP2_TPH_COMP_SHIFT 12 #define PCIE_DEVCAP2_TPH_COMP_MASK 0x3 +#define PCIE_DEVCAP2_LNSYS_CLS_SHIFT 14 +#define PCIE_DEVCAP2_LNSYS_CLS_MASK 0x3 +#define PCIE_DEVCAP2_10B_TAG_COMP_SUP 0x10000 +#define PCIE_DEVCAP2_10B_TAG_REQ_SUP 0x20000 +#define PCIE_DEVCAP2_OBFF_SHIFT 18 +#define PCIE_DEVCAP2_OBFF_MASK 0x3 #define PCIE_DEVCAP2_EXT_FMT_FIELD 0x100000 #define PCIE_DEVCAP2_END_END_TLP_PREFIX 0x200000 #define PCIE_DEVCAP2_MAX_END_END_SHIFT 22 #define PCIE_DEVCAP2_MAX_END_END_MASK 0x3 +#define PCIE_DEVCAP2_EPR_SUP_SHIFT 24 +#define PCIE_DEVCAP2_EPR_SUP_MASK 0x3 +#define PCIE_DEVCAP2_EPR_INIT_REQ 0x4000000 +#define PCIE_DEVCAP2_FRS_SUP 0x80000000 /* * Device Control 2 Register (2 bytes) @@ -419,6 +458,13 @@ extern "C" { #define PCIE_DEVCTL2_IDO_REQ_EN 0x100 #define PCIE_DEVCTL2_IDO_COMPL_EN 0x200 #define PCIE_DEVCTL2_LTR_MECH_EN 0x400 +#define PCIE_DEVCTL2_EPR_REQ 0x800 +#define PCIE_DEVCTL2_10BTAG_REQ_EN 0x1000 +#define PCIE_DEVCTL2_OBFF_MASK 0x6000 +#define PCIE_DEVCTL2_OBFF_DISABLE 0x0000 +#define PCIE_DEVCTL2_OBFF_EN_VARA 0x2000 +#define PCIE_DEVCTL2_OBFF_EN_VARB 0x4000 +#define PCIE_DEVCTL2_OBFF_EN_WAKE 0x6000 #define PCIE_DEVCTL2_END_END_TLP_PREFIX 0x8000 @@ -428,8 +474,49 @@ extern "C" { #define PCIE_LINKCAP2_SPEED_2_5 0x02 #define PCIE_LINKCAP2_SPEED_5 0x04 #define PCIE_LINKCAP2_SPEED_8 0x08 +#define PCIE_LINKCAP2_SPEED_16 0x10 #define PCIE_LINKCAP2_SPEED_MASK 0xfe #define PCIE_LINKCAP2_CROSSLINK 0x100 +#define PCIE_LINKCAP2_LSKP_OSGSS_MASK 0xfe00 +#define PCIE_LINKCAP2_LKSP_OSGSS_2_5 0x0200 +#define PCIE_LINKCAP2_LKSP_OSGSS_5 0x0400 +#define PCIE_LINKCAP2_LKSP_OSGSS_8 0x0800 +#define PCIE_LINKCAP2_LKSP_OSGSS_16 0x1000 +#define PCIE_LINKCAP2_LKSP_OSRSS_MASK 0x7f0000 +#define PCIE_LINKCAP2_LKSP_OSRSS_2_5 0x010000 +#define PCIE_LINKCAP2_LKSP_OSRSS_5 0x020000 +#define PCIE_LINKCAP2_LKSP_OSRSS_8 0x040000 +#define PCIE_LINKCAP2_LKSP_OSRSS_16 0x080000 +#define PCIE_LINKCAP2_RTPD_SUP 0x800000 +#define PCIE_LINKCAP2_TRTPD_SUP 0x01000000 +#define PCIE_LINKCAP2_DRS 0x80000000 + +/* + * Link Control 2 Register (2 bytes) + */ +#define PCIE_LINKCTL2_TARGET_SPEED_MASK 0x000f +#define PICE_LINKCTL2_ENTER_COMPLIANCE 0x0010 +#define PCIE_LINKCTL2_HW_AUTO_SPEED_DIS 0x0020 +#define PCIE_LINKCTL2_SELECT_DEEMPH 0x0040 +#define PCIE_LINKCTL2_TX_MARGIN_MASK 0x0380 +#define PCIE_LINKCTL2_ENTER_MOD_COMP 0x0400 +#define PCIE_LINKCTL2_COMP_SOS 0x0800 +#define PCIE_LINKCTL2_COMP_DEEMPM_MASK 0xf000 + +/* + * Link Status 2 Register (2 bytes) + */ +#define PCIE_LINKSTS2_CUR_DEEMPH 0x0001 +#define PCIE_LINKSTS2_EQ8GT_COMP 0x0002 +#define PCIE_LINKSTS2_EQ8GT_P1_SUC 0x0004 +#define PCIE_LINKSTS2_EQ8GT_P2_SUC 0x0008 +#define PCIE_LINKSTS2_EQ8GT_P3_SUC 0x0010 +#define PCIE_LINKSTS2_LINK_EQ_REQ 0x0020 +#define PCIE_LINKSTS2_RETIMER_PRES_DET 0x0040 +#define PCIE_LINKSTS2_2RETIMER_PRES_DET 0x0080 +#define PCIE_LINKSTS2_XLINK_RES 0x0300 +#define PCIE_LINKSTS2_DS_COMP_PRES_MASK 0x7000 +#define PCIE_LINKSTS2_DRS_MSG_RX 0x8000 /* * PCI-Express Enhanced Capabilities Link Entry Bit Offsets @@ -464,6 +551,28 @@ extern "C" { #define PCIE_EXT_CAP_ID_ACS 0xD /* Access Control Services */ #define PCIE_EXT_CAP_ID_ARI 0xE /* Alternative Routing ID */ #define PCIE_EXT_CAP_ID_ATS 0xF /* Address Translation Svcs */ +#define PCIE_EXT_CAP_ID_SRIOV 0x10 /* Single Root I/O Virt. */ +#define PCIE_EXT_CAP_ID_MRIOV 0x11 /* Multi Root I/O Virt. */ +#define PCIE_EXT_CAP_ID_MULTICAST 0x12 /* Multicast Services */ +#define PCIE_EXT_CAP_ID_EA 0x14 /* Enhanced Allocation */ +#define PCIE_EXT_CAP_ID_RESIZE_BAR 0x15 /* Resizable BAR */ +#define PCIE_EXT_CAP_ID_DPA 0x16 /* Dynamic Power Allocation */ +#define PCIE_EXT_CAP_ID_TPH_REQ 0x17 /* TPH Requester */ +#define PCIE_EXT_CAP_ID_LTR 0x18 /* Latency Tolerance Report */ +#define PCIE_EXT_CAP_ID_PCIE2 0x19 /* PCI Express Capability 2 */ +#define PCIE_EXT_CAP_ID_PASID 0x1B /* PASID */ +#define PCIE_EXT_CAP_ID_LNR 0x1C /* LNR */ +#define PCIE_EXT_CAP_ID_DPC 0x1D /* DPC */ +#define PCIE_EXT_CAP_ID_L1PM 0x1E /* L1 PM Substrates */ +#define PCIE_EXT_CAP_ID_PTM 0x1F /* Precision Time Management */ +#define PCIE_EXT_CAP_ID_FRS 0x21 /* Function Ready Stat. Queue */ +#define PCIE_EXT_CAP_ID_RTR 0x22 /* Readiness Time Reporting */ +#define PCIE_EXT_CAP_ID_DVS 0x23 /* Designated Vendor-Specific */ +#define PCIE_EXT_CAP_ID_DLF 0x25 /* Data Link Feature */ +#define PCIE_EXT_CAP_ID_PL16GTE 0x26 /* Physical Layer 16.0 GT/s */ +#define PCIE_EXT_CAP_ID_LANE_MARGIN 0x27 /* Lane Margining */ +#define PCIE_EXT_CAP_ID_HIEARCHY_ID 0x28 /* Hierarchy ID */ +#define PCIE_EXT_CAP_ID_NPEM 0x29 /* Native PCIe Enclosure Mgmt */ /* * PCI-Express Advanced Error Reporting Extended Capability Offsets @@ -568,10 +677,10 @@ extern "C" { * AER Secondary Uncorrectable Error Register */ #define PCIE_AER_SUCE_TA_ON_SC 0x1 /* Target Abort on Split Comp */ -#define PCIE_AER_SUCE_MA_ON_SC 0x2 /* Master Abort on Split Comp */ +#define PCIE_AER_SUCE_MA_ON_SC 0x2 /* Master Abort on Split Comp */ #define PCIE_AER_SUCE_RCVD_TA 0x4 /* Received Target Abort */ -#define PCIE_AER_SUCE_RCVD_MA 0x8 /* Received Master Abort */ -#define PCIE_AER_SUCE_USC_ERR 0x20 /* Unexpected Split Comp Err */ +#define PCIE_AER_SUCE_RCVD_MA 0x8 /* Received Master Abort */ +#define PCIE_AER_SUCE_USC_ERR 0x20 /* Unexpected Split Comp Err */ #define PCIE_AER_SUCE_USC_MSG_DATA_ERR 0x40 /* USC Message Data Error */ #define PCIE_AER_SUCE_UC_DATA_ERR 0x80 /* Uncorrectable Data Error */ #define PCIE_AER_SUCE_UC_ATTR_ERR 0x100 /* UC Attribute Err */ diff --git a/usr/src/uts/common/sys/pcie_impl.h b/usr/src/uts/common/sys/pcie_impl.h index 6fa459b7d00f..9d433c5afbf1 100644 --- a/usr/src/uts/common/sys/pcie_impl.h +++ b/usr/src/uts/common/sys/pcie_impl.h @@ -20,7 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2017, Joyent, Inc. + * Copyright 2019, Joyent, Inc. */ /* @@ -305,7 +305,8 @@ typedef enum pcie_link_speed { PCIE_LINK_SPEED_UNKNOWN = 0x00, PCIE_LINK_SPEED_2_5 = 0x01, PCIE_LINK_SPEED_5 = 0x02, - PCIE_LINK_SPEED_8 = 0x04 + PCIE_LINK_SPEED_8 = 0x04, + PCIE_LINK_SPEED_16 = 0x08 } pcie_link_speed_t; /*