summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pciconf/cap.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/pciconf/cap.c')
-rw-r--r--usr.sbin/pciconf/cap.c72
1 files changed, 59 insertions, 13 deletions
diff --git a/usr.sbin/pciconf/cap.c b/usr.sbin/pciconf/cap.c
index 980e2c7..cd5ae26 100644
--- a/usr.sbin/pciconf/cap.c
+++ b/usr.sbin/pciconf/cap.c
@@ -410,14 +410,38 @@ aspm_string(uint8_t aspm)
}
}
+static int
+slot_power(uint32_t cap)
+{
+ int mwatts;
+
+ mwatts = (cap & PCIEM_SLOT_CAP_SPLV) >> 7;
+ switch (cap & PCIEM_SLOT_CAP_SPLS) {
+ case 0x0:
+ mwatts *= 1000;
+ break;
+ case 0x1:
+ mwatts *= 100;
+ break;
+ case 0x2:
+ mwatts *= 10;
+ break;
+ default:
+ break;
+ }
+ return (mwatts);
+}
+
static void
cap_express(int fd, struct pci_conf *p, uint8_t ptr)
{
- uint32_t cap, cap2;
+ uint32_t cap;
uint16_t ctl, flags, sta;
+ unsigned int version;
flags = read_config(fd, &p->pc_sel, ptr + PCIER_FLAGS, 2);
- printf("PCI-Express %d ", flags & PCIEM_FLAGS_VERSION);
+ version = flags & PCIEM_FLAGS_VERSION;
+ printf("PCI-Express %u ", version);
switch (flags & PCIEM_FLAGS_TYPE) {
case PCIEM_TYPE_ENDPOINT:
printf("endpoint");
@@ -450,12 +474,9 @@ cap_express(int fd, struct pci_conf *p, uint8_t ptr)
printf("type %d", (flags & PCIEM_FLAGS_TYPE) >> 4);
break;
}
- if (flags & PCIEM_FLAGS_SLOT)
- printf(" slot");
if (flags & PCIEM_FLAGS_IRQ)
- printf(" IRQ %d", (flags & PCIEM_FLAGS_IRQ) >> 9);
+ printf(" MSI %d", (flags & PCIEM_FLAGS_IRQ) >> 9);
cap = read_config(fd, &p->pc_sel, ptr + PCIER_DEVICE_CAP, 4);
- cap2 = read_config(fd, &p->pc_sel, ptr + PCIER_DEVICE_CAP2, 4);
ctl = read_config(fd, &p->pc_sel, ptr + PCIER_DEVICE_CTL, 2);
printf(" max data %d(%d)",
MAX_PAYLOAD((ctl & PCIEM_CTL_MAX_PAYLOAD) >> 5),
@@ -466,12 +487,22 @@ cap_express(int fd, struct pci_conf *p, uint8_t ptr)
printf(" RO");
if (ctl & PCIEM_CTL_NOSNOOP_ENABLE)
printf(" NS");
+ if (version >= 2) {
+ cap = read_config(fd, &p->pc_sel, ptr + PCIER_DEVICE_CAP2, 4);
+ if ((cap & PCIEM_CAP2_ARI) != 0) {
+ ctl = read_config(fd, &p->pc_sel,
+ ptr + PCIER_DEVICE_CTL2, 4);
+ printf(" ARI %s",
+ (ctl & PCIEM_CTL2_ARI) ? "enabled" : "disabled");
+ }
+ }
cap = read_config(fd, &p->pc_sel, ptr + PCIER_LINK_CAP, 4);
sta = read_config(fd, &p->pc_sel, ptr + PCIER_LINK_STA, 2);
+ if (cap == 0 && sta == 0)
+ return;
+ printf("\n ");
printf(" link x%d(x%d)", (sta & PCIEM_LINK_STA_WIDTH) >> 4,
(cap & PCIEM_LINK_CAP_MAX_WIDTH) >> 4);
- if ((cap & (PCIEM_LINK_CAP_MAX_WIDTH | PCIEM_LINK_CAP_ASPM)) != 0)
- printf("\n ");
if ((cap & PCIEM_LINK_CAP_MAX_WIDTH) != 0) {
printf(" speed %s(%s)", (sta & PCIEM_LINK_STA_WIDTH) == 0 ?
"0.0" : link_speed_string(sta & PCIEM_LINK_STA_SPEED),
@@ -482,11 +513,26 @@ cap_express(int fd, struct pci_conf *p, uint8_t ptr)
printf(" ASPM %s(%s)", aspm_string(ctl & PCIEM_LINK_CTL_ASPMC),
aspm_string((cap & PCIEM_LINK_CAP_ASPM) >> 10));
}
- if ((cap2 & PCIEM_CAP2_ARI) != 0) {
- ctl = read_config(fd, &p->pc_sel, ptr + PCIER_DEVICE_CTL2, 4);
- printf(" ARI %s",
- (ctl & PCIEM_CTL2_ARI) ? "enabled" : "disabled");
- }
+ if (!(flags & PCIEM_FLAGS_SLOT))
+ return;
+ cap = read_config(fd, &p->pc_sel, ptr + PCIER_SLOT_CAP, 4);
+ sta = read_config(fd, &p->pc_sel, ptr + PCIER_SLOT_STA, 2);
+ ctl = read_config(fd, &p->pc_sel, ptr + PCIER_SLOT_CTL, 2);
+ printf("\n ");
+ printf(" slot %d", (cap & PCIEM_SLOT_CAP_PSN) >> 19);
+ printf(" power limit %d mW", slot_power(cap));
+ if (cap & PCIEM_SLOT_CAP_HPC)
+ printf(" HotPlug(%s)", sta & PCIEM_SLOT_STA_PDS ? "present" :
+ "empty");
+ if (cap & PCIEM_SLOT_CAP_HPS)
+ printf(" surprise");
+ if (cap & PCIEM_SLOT_CAP_APB)
+ printf(" Attn Button");
+ if (cap & PCIEM_SLOT_CAP_PCP)
+ printf(" PC(%s)", ctl & PCIEM_SLOT_CTL_PCC ? "on" : "off");
+ if (cap & PCIEM_SLOT_CAP_MRLSP)
+ printf(" MRL(%s)", sta & PCIEM_SLOT_STA_MRLSS ? "open" :
+ "closed");
}
static void
OpenPOWER on IntegriCloud