Skip to contentSkip to conversation

lspci: Decode PCIe Link Capabilities 2

PATCH Applied Bjorn Helgaas 2 participants 4 messages May 21, 2020 – May 25, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover lspci: Decode PCIe Link Capabilities 2

From: Bjorn Helgaas <[email protected]>

Decode Link Capabilities 2, including the Supported Link Speeds Vector, and expand the decoding of Link Status 2.

Bjorn Helgaas (2):
lspci: Decode PCIe Link Capabilities 2, expand Link Status 2
lspci: Use commas more consistently

 lib/header.h          |   10 +
 ls-caps.c             |  115 +++-
 ls-ecaps.c            |    2 +-
 tests/cap-exp-lnkcap2 | 1317 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 1430 insertions(+), 14 deletions(-)
 create mode 100644 tests/cap-exp-lnkcap2

base-commit: 203854ccd133f40b8c121feee681cb9182b90566

Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/2 lspci: Decode PCIe Link Capabilities 2, expand Link Status 2

From: Bjorn Helgaas <[email protected]>

Decode Link Capabilities 2, which includes the Supported Link Speeds Vector, and decode more fields of Link Status 2.

The test case (data from https://bugzilla.kernel.org/show_bug.cgi?id=206837
comment #21) includes a Thunderbolt Downstream Port that advertises 2.5-8GT/s support in Link Capabilities 2.

---
 lib/header.h          |   10 +
 ls-caps.c             |   93 ++-
 tests/cap-exp-lnkcap2 | 1317 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1418 insertions(+), 2 deletions(-)
 create mode 100644 tests/cap-exp-lnkcap2
lib/header.h +10 -0
index bfdcc80..93a6e4f 100644
@@ -901,6 +901,11 @@
 #define  PCI_EXP_DEV2_OBFF(x)		(((x) >> 13) & 3) /* OBFF enabled */
 #define PCI_EXP_DEVSTA2			0x2a	/* Device Status */
 #define PCI_EXP_LNKCAP2			0x2c	/* Link Capabilities */
+#define  PCI_EXP_LNKCAP2_SPEED(x)	(((x) >> 1) & 0x7f)
+#define  PCI_EXP_LNKCAP2_CROSSLINK	0x00000100 /* Crosslink Supported */
+#define  PCI_EXP_LNKCAP2_RETIMER	0x00800000 /* Retimer Supported */
+#define  PCI_EXP_LNKCAP2_2RETIMERS	0x01000000 /* 2 Retimers Supported */
+#define  PCI_EXP_LNKCAP2_DRS		0x80000000 /* Device Readiness Status */
 #define PCI_EXP_LNKCTL2			0x30	/* Link Control */
 #define  PCI_EXP_LNKCTL2_SPEED(x)	((x) & 0xf) /* Target Link Speed */
 #define  PCI_EXP_LNKCTL2_CMPLNC		0x0010	/* Enter Compliance */
@@ -917,6 +922,11 @@
 #define  PCI_EXP_LINKSTA2_EQU_PHASE2	0x08	/* Equalization Phase 2 Successful */
 #define  PCI_EXP_LINKSTA2_EQU_PHASE3	0x10	/* Equalization Phase 3 Successful */
 #define  PCI_EXP_LINKSTA2_EQU_REQ	0x20	/* Link Equalization Request */
+#define  PCI_EXP_LINKSTA2_RETIMER	0x0040	/* Retimer Detected */
+#define  PCI_EXP_LINKSTA2_2RETIMERS	0x0080	/* 2 Retimers Detected */
+#define  PCI_EXP_LINKSTA2_CROSSLINK(x)	(((x) >> 8) & 0x3) /* Crosslink Res */
+#define  PCI_EXP_LINKSTA2_COMPONENT(x)	(((x) >> 12) & 0x7) /* Presence */
+#define  PCI_EXP_LINKSTA2_DRS_RCVD	0x8000	/* DRS Msg Received */
 #define PCI_EXP_SLTCAP2			0x34	/* Slot Capabilities */
 #define PCI_EXP_SLTCTL2			0x38	/* Slot Control */
 #define PCI_EXP_SLTSTA2			0x3a	/* Slot Status */
ls-caps.c +91 -2

128 lines not on this page · raw message

tests/cap-exp-lnkcap2 new file +1317 -0

1,317 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/2 lspci: Use commas more consistently

In reply to Bjorn Helgaas

From: Bjorn Helgaas <[email protected]>

General practice has been to use a comma after a multi-word item, but omit commas between single-bit flags. Do this more consistently.

Sample output changes:

- LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- CommClk+
+ LnkCtl: ASPM Disabled; RCB 64 bytes, Disabled- CommClk+

- DevCap2: Completion Timeout: Not Supported, TimeoutDis-, NROPrPrP-, LTR+
+ DevCap2: Completion Timeout: Not Supported, TimeoutDis- NROPrPrP- LTR+

- 10BitTagComp-, 10BitTagReq-, OBFF Not Supported, ExtFmt-, EETLPPrefix-
+ 10BitTagComp- 10BitTagReq- OBFF Not Supported, ExtFmt- EETLPPrefix-

- FRS-, ARIFwd-
+ FRS- ARIFwd-

---
 ls-caps.c  | 24 ++++++++++++------------
 ls-ecaps.c |  2 +-
 2 files changed, 13 insertions(+), 13 deletions(-)
ls-caps.c +12 -12
index c8a8bd6..a09b0cf 100644
@@ -822,7 +822,7 @@ static void cap_express_link(struct device *d, int where, int type)
   printf("\t\tLnkCtl:\tASPM %s;", aspm_enabled(w & PCI_EXP_LNKCTL_ASPM));
   if ((type == PCI_EXP_TYPE_ROOT_PORT) || (type == PCI_EXP_TYPE_ENDPOINT) ||
       (type == PCI_EXP_TYPE_LEG_END) || (type == PCI_EXP_TYPE_PCI_BRIDGE))
-    printf(" RCB %d bytes", w & PCI_EXP_LNKCTL_RCB ? 128 : 64);
+    printf(" RCB %d bytes,", w & PCI_EXP_LNKCTL_RCB ? 128 : 64);
   printf(" Disabled%c CommClk%c\n\t\t\tExtSynch%c ClockPM%c AutWidDis%c BWInt%c AutBWInt%c\n",
 	FLAG(w, PCI_EXP_LNKCTL_DISABLE),
 	FLAG(w, PCI_EXP_LNKCTL_CLOCK),
@@ -1031,14 +1031,14 @@ static const char *cap_express_devcap2_tphcomp(int tph)
   switch (tph)
     {
       case 1:
-        return "TPHComp+, ExtTPHComp-";
+        return "TPHComp+ ExtTPHComp-";
       case 2:
         /* Reserved; intentionally left blank */
         return "";
       case 3:
-        return "TPHComp+, ExtTPHComp+";
+        return "TPHComp+ ExtTPHComp+";
       default:
-        return "TPHComp-, ExtTPHComp-";
+        return "TPHComp- ExtTPHComp-";
     }
 }
 
@@ -1084,12 +1084,12 @@ static void cap_express_dev2(struct device *d, int where, int type)
   int has_mem_bar = device_has_memory_space_bar(d);
 
   l = get_conf_long(d, where + PCI_EXP_DEVCAP2);
-  printf("\t\tDevCap2: Completion Timeout: %s, TimeoutDis%c, NROPrPrP%c, LTR%c",
+  printf("\t\tDevCap2: Completion Timeout: %s, TimeoutDis%c NROPrPrP%c LTR%c",
         cap_express_dev2_timeout_range(PCI_EXP_DEV2_TIMEOUT_RANGE(l)),
         FLAG(l, PCI_EXP_DEV2_TIMEOUT_DIS),
 	FLAG(l, PCI_EXP_DEVCAP2_NROPRPRP),
         FLAG(l, PCI_EXP_DEVCAP2_LTR));
-  printf("\n\t\t\t 10BitTagComp%c, 10BitTagReq%c, OBFF %s, ExtFmt%c, EETLPPrefix%c",
+  printf("\n\t\t\t 10BitTagComp%c 10BitTagReq%c OBFF %s, ExtFmt%c EETLPPrefix%c",
         FLAG(l, PCI_EXP_DEVCAP2_10BIT_TAG_COMP),
         FLAG(l, PCI_EXP_DEVCAP2_10BIT_TAG_REQ),
         cap_express_devcap2_obff(PCI_EXP_DEVCAP2_OBFF(l)),
@@ -1108,14 +1108,14 @@ static void cap_express_dev2(struct device *d, int where, int type)
   printf("\n\t\t\t FRS%c", FLAG(l, PCI_EXP_DEVCAP2_FRS));
 
   if (type == PCI_EXP_TYPE_ROOT_PORT)
-    printf(", LN System CLS %s",
+    printf(" LN System CLS %s,",
           cap_express_devcap2_lncls(PCI_EXP_DEVCAP2_LN_CLS(l)));
 
   if (type == PCI_EXP_TYPE_ROOT_PORT || type == PCI_EXP_TYPE_ENDPOINT)
-    printf(", %s", cap_express_devcap2_tphcomp(PCI_EXP_DEVCAP2_TPH_COMP(l)));
+    printf(" %s", cap_express_devcap2_tphcomp(PCI_EXP_DEVCAP2_TPH_COMP(l)));
 
   if (type == PCI_EXP_TYPE_ROOT_PORT || type == PCI_EXP_TYPE_DOWNSTREAM)
-    printf(", ARIFwd%c\n", FLAG(l, PCI_EXP_DEV2_ARI));
+    printf(" ARIFwd%c\n", FLAG(l, PCI_EXP_DEV2_ARI));
   else
     printf("\n");
   if (type == PCI_EXP_TYPE_ROOT_PORT || type == PCI_EXP_TYPE_UPSTREAM ||
@@ -1134,7 +1134,7 @@ static void cap_express_dev2(struct device *d, int where, int type)
     }
 
   w = get_conf_word(d, where + PCI_EXP_DEVCTL2);
-  printf("\t\tDevCtl2: Completion Timeout: %s, TimeoutDis%c, LTR%c, OBFF %s",
+  printf("\t\tDevCtl2: Completion Timeout: %s, TimeoutDis%c LTR%c OBFF %s,",
 	cap_express_dev2_timeout_value(PCI_EXP_DEV2_TIMEOUT_VALUE(w)),
 	FLAG(w, PCI_EXP_DEV2_TIMEOUT_DIS),
 	FLAG(w, PCI_EXP_DEV2_LTR),
@@ -1303,8 +1303,8 @@ static void cap_express_link2(struct device *d, int where, int type)
   }
 
   w = get_conf_word(d, where + PCI_EXP_LNKSTA2);
-  printf("\t\tLnkSta2: Current De-emphasis Level: %s, EqualizationComplete%c, EqualizationPhase1%c\n"
-	"\t\t\t EqualizationPhase2%c, EqualizationPhase3%c, LinkEqualizationRequest%c\n"
+  printf("\t\tLnkSta2: Current De-emphasis Level: %s, EqualizationComplete%c EqualizationPhase1%c\n"
+	"\t\t\t EqualizationPhase2%c EqualizationPhase3%c LinkEqualizationRequest%c\n"
 	"\t\t\t Retimer%c 2Retimers%c CrosslinkRes: %s",
 	cap_express_link2_deemphasis(PCI_EXP_LINKSTA2_DEEMPHASIS(w)),
 	FLAG(w, PCI_EXP_LINKSTA2_EQU_COMP),
ls-ecaps.c +1 -1
index 0021734..49b6ec9 100644
@@ -89,7 +89,7 @@ cap_sec(struct device *d, int where)
     return;
 
   ctrl3 = get_conf_word(d, where + PCI_SEC_LNKCTL3);
-  printf("\t\tLnkCtl3: LnkEquIntrruptEn%c, PerformEqu%c\n",
+  printf("\t\tLnkCtl3: LnkEquIntrruptEn%c PerformEqu%c\n",
 	FLAG(ctrl3, PCI_SEC_LNKCTL3_LNK_EQU_REQ_INTR_EN),
 	FLAG(ctrl3, PCI_SEC_LNKCTL3_PERFORM_LINK_EQU));
 
Signature · 1 line
2.25.1
#3 lore raw
In reply to Bjorn Helgaas

Hello!

Quoted 6 lines

Decode Link Capabilities 2, including the Supported Link Speeds Vector, and expand the decoding of Link Status 2.

Bjorn Helgaas (2):
lspci: Decode PCIe Link Capabilities 2, expand Link Status 2
lspci: Use commas more consistently

Thanks, applied.

Martin