From: Martin Mares Date: Fri, 16 Mar 2018 16:53:42 +0000 (+0100) Subject: lspci: Report if the PCIe link speed/width is full or downgraded X-Git-Tag: v3.6.0~24 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=b47b5bd408e161901fcee67346f5ea8d26087c12;p=pciutils.git lspci: Report if the PCIe link speed/width is full or downgraded Based on an idea by Dmitry Monakhov. --- diff --git a/ls-caps.c b/ls-caps.c index 158ac38..e74d13a 100644 --- a/ls-caps.c +++ b/ls-caps.c @@ -1,7 +1,7 @@ /* * The PCI Utilities -- Show Capabilities * - * Copyright (c) 1997--2010 Martin Mares + * Copyright (c) 1997--2018 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ @@ -733,6 +733,15 @@ static char *link_speed(int speed) } } +static char *link_compare(int sta, int cap) +{ + if (sta < cap) + return "downgraded"; + if (sta > cap) + return "strange"; + return "ok"; +} + static char *aspm_support(int code) { switch (code) @@ -758,14 +767,16 @@ static const char *aspm_enabled(int code) static void cap_express_link(struct device *d, int where, int type) { - u32 t, aspm; + u32 t, aspm, cap_speed, cap_width, sta_speed, sta_width; u16 w; t = get_conf_long(d, where + PCI_EXP_LNKCAP); aspm = (t & PCI_EXP_LNKCAP_ASPM) >> 10; + cap_speed = t & PCI_EXP_LNKCAP_SPEED; + cap_width = (t & PCI_EXP_LNKCAP_WIDTH) >> 4; printf("\t\tLnkCap:\tPort #%d, Speed %s, Width x%d, ASPM %s", t >> 24, - link_speed(t & PCI_EXP_LNKCAP_SPEED), (t & PCI_EXP_LNKCAP_WIDTH) >> 4, + link_speed(cap_speed), cap_width, aspm_support(aspm)); if (aspm) { @@ -799,9 +810,14 @@ static void cap_express_link(struct device *d, int where, int type) FLAG(w, PCI_EXP_LNKCTL_AUTBWIE)); w = get_conf_word(d, where + PCI_EXP_LNKSTA); - printf("\t\tLnkSta:\tSpeed %s, Width x%d, TrErr%c Train%c SlotClk%c DLActive%c BWMgmt%c ABWMgmt%c\n", - link_speed(w & PCI_EXP_LNKSTA_SPEED), - (w & PCI_EXP_LNKSTA_WIDTH) >> 4, + sta_speed = w & PCI_EXP_LNKSTA_SPEED; + sta_width = (w & PCI_EXP_LNKSTA_WIDTH) >> 4; + printf("\t\tLnkSta:\tSpeed %s (%s), Width x%d (%s)\n", + link_speed(sta_speed), + link_compare(sta_speed, cap_speed), + sta_width, + link_compare(sta_width, cap_width)); + printf("\t\t\tTrErr%c Train%c SlotClk%c DLActive%c BWMgmt%c ABWMgmt%c\n", FLAG(w, PCI_EXP_LNKSTA_TR_ERR), FLAG(w, PCI_EXP_LNKSTA_TRAIN), FLAG(w, PCI_EXP_LNKSTA_SL_CLK),