Skip to contentSkip to conversation

lspci: Add Flit mode information and Dev3 from gen6

PATCH New Ilpo Järvinen 1 participant 3 messages Dec 11, 2024

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

cover lspci: Add Flit mode information and Dev3 from gen6

Add Flit mode related flags and Device 3 Extended Capability into lspci. The latter patch does not print all the Dev 3 fields but already feels useful for checking many things (UIO and the exit latency fields are not printed).

Ilpo Järvinen (2):
lspci: Add Flit Mode information
lspci: Add Dev3 Extended Capability

 lib/header.h | 23 +++++++++++++++++++++++
 ls-caps.c    | 18 +++++++++++-------
 ls-ecaps.c   | 41 ++++++++++++++++++++++++++++++++++++++++-
 lspci.h      |  2 +-
 4 files changed, 75 insertions(+), 9 deletions(-)
Signature · 1 line
2.39.5
#1 lore raw

PATCH 1/2 lspci: Add Flit Mode information

Add Flit Mode related information:

- Flit Mode Supported to Express Capabilities line (PCIe r6.1 sec 7.5.3.2).
- Flit Mode Disable to LnkCtl register (PCIe r6.1 sec 7.5.3.7).
- Flit Mode Status to LnkSta2 register (PCIe r6.1 sec 7.5.3.20).

---
 lib/header.h |  3 +++
 ls-caps.c    | 14 ++++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)
lib/header.h +3 -0
index 0827ac0d4b73..b188313ea033 100644
@@ -763,6 +763,7 @@
 #define  PCI_EXP_TYPE_ROOT_INT_EP 0x9	/* Root Complex Integrated Endpoint */
 #define  PCI_EXP_TYPE_ROOT_EC 0xa	/* Root Complex Event Collector */
 #define PCI_EXP_FLAGS_SLOT	0x0100	/* Slot implemented */
+#define PCI_EXP_FLAGS_FLIT	0x8000	/* Flit Mode Supported */
 #define PCI_EXP_FLAGS_IRQ	0x3e00	/* Interrupt message number */
 #define PCI_EXP_DEVCAP		0x4	/* Device capabilities */
 #define  PCI_EXP_DEVCAP_PAYLOAD	0x07	/* Max_Payload_Size */
@@ -822,6 +823,7 @@
 #define  PCI_EXP_LNKCTL_HWAUTWD	0x0200	/* Hardware Autonomous Width Disable */
 #define  PCI_EXP_LNKCTL_BWMIE	0x0400	/* Bandwidth Mgmt Interrupt Enable */
 #define  PCI_EXP_LNKCTL_AUTBWIE	0x0800	/* Autonomous Bandwidth Mgmt Interrupt Enable */
+#define  PCI_EXP_LNKCTL_FLIT_DIS	0x2000	/* Flit Mode Disable */
 #define PCI_EXP_LNKSTA		0x12	/* Link Status */
 #define  PCI_EXP_LNKSTA_SPEED	0x000f	/* Negotiated Link Speed */
 #define  PCI_EXP_LNKSTA_WIDTH	0x03f0	/* Negotiated Link Width */
@@ -938,6 +940,7 @@
 #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_FLIT		0x0400	/* Flit Mode Status */
 #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 */
ls-caps.c +8 -6
index c2aaea573234..38a171a5fe4d 100644
@@ -843,14 +843,15 @@ static void cap_express_link(struct device *d, int where, int type)
   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(" LnkDisable%c CommClk%c\n\t\t\tExtSynch%c ClockPM%c AutWidDis%c BWInt%c AutBWInt%c\n",
+  printf(" LnkDisable%c CommClk%c\n\t\t\tExtSynch%c ClockPM%c AutWidDis%c BWInt%c AutBWInt%c\n\t\t\tFlitModeDis%c\n",
 	FLAG(w, PCI_EXP_LNKCTL_DISABLE),
 	FLAG(w, PCI_EXP_LNKCTL_CLOCK),
 	FLAG(w, PCI_EXP_LNKCTL_XSYNCH),
 	FLAG(w, PCI_EXP_LNKCTL_CLOCKPM),
 	FLAG(w, PCI_EXP_LNKCTL_HWAUTWD),
 	FLAG(w, PCI_EXP_LNKCTL_BWMIE),
-	FLAG(w, PCI_EXP_LNKCTL_AUTBWIE));
+	FLAG(w, PCI_EXP_LNKCTL_AUTBWIE),
+	FLAG(w, PCI_EXP_LNKCTL_FLIT_DIS));
 
   w = get_conf_word(d, where + PCI_EXP_LNKSTA);
   sta_speed = w & PCI_EXP_LNKSTA_SPEED;
@@ -1366,7 +1367,7 @@ 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"
-	"\t\t\t Retimer%c 2Retimers%c CrosslinkRes: %s",
+	"\t\t\t Retimer%c 2Retimers%c FlitMode%c CrosslinkRes: %s",
 	cap_express_link2_deemphasis(PCI_EXP_LINKSTA2_DEEMPHASIS(w)),
 	FLAG(w, PCI_EXP_LINKSTA2_EQU_COMP),
 	FLAG(w, PCI_EXP_LINKSTA2_EQU_PHASE1),
@@ -1375,11 +1376,11 @@ static void cap_express_link2(struct device *d, int where, int type)
 	FLAG(w, PCI_EXP_LINKSTA2_EQU_REQ),
 	FLAG(w, PCI_EXP_LINKSTA2_RETIMER),
 	FLAG(w, PCI_EXP_LINKSTA2_2RETIMERS),
+	FLAG(w, PCI_EXP_LINKSTA2_FLIT),
 	cap_express_link2_crosslink_res(PCI_EXP_LINKSTA2_CROSSLINK(w)));
 
   if (exp_downstream_port(type) && (l & PCI_EXP_LNKCAP2_DRS)) {
-    printf(", DRS%c\n"
-	"\t\t\t DownstreamComp: %s\n",
+    printf("\t\t\t DRS%c DownstreamComp: %s\n",
 	FLAG(w, PCI_EXP_LINKSTA2_DRS_RCVD),
 	cap_express_link2_component(PCI_EXP_LINKSTA2_COMPONENT(w)));
   } else
@@ -1502,7 +1503,8 @@ cap_express(struct device *d, int where, int cap)
     default:
       printf("Unknown type %d", type);
   }
-  printf(", IntMsgNum %d\n", (cap & PCI_EXP_FLAGS_IRQ) >> 9);
+  printf(", IntMsgNum %d, FlitMode%c\n", (cap & PCI_EXP_FLAGS_IRQ) >> 9,
+	 FLAG(cap, PCI_EXP_FLAGS_FLIT));
   if (verbose < 2)
     return type;
 
Signature · 1 line
2.39.5
#2 lore raw

PATCH 2/2 lspci: Add Dev3 Extended Capability

In reply to Ilpo Järvinen

Add Dev3 Extended Capability (PCIe spec r6.1 sec 7.7.9).

---
 lib/header.h | 20 ++++++++++++++++++++
 ls-caps.c    |  4 +++-
 ls-ecaps.c   | 41 ++++++++++++++++++++++++++++++++++++++++-
 lspci.h      |  2 +-
 4 files changed, 64 insertions(+), 3 deletions(-)
lib/header.h +20 -0
index b188313ea033..bb36ea1deeea 100644
@@ -256,6 +256,7 @@
 #define PCI_EXT_CAP_ID_NPEM	0x29	/* Native PCIe Enclosure Management */
 #define PCI_EXT_CAP_ID_32GT	0x2a	/* Physical Layer 32.0 GT/s */
 #define PCI_EXT_CAP_ID_DOE	0x2e	/* Data Object Exchange */
+#define PCI_EXT_CAP_ID_DEV3	0x2f	/* Device 3 */
 #define PCI_EXT_CAP_ID_IDE	0x30	/* Integrity and Data Encryption */
 
 /*** Definitions of capabilities ***/
@@ -1501,6 +1502,25 @@
 /* IDE Address Association Register 2 is "Memory Limit Upper" */
 /* IDE Address Association Register 3 is "Memory Base Upper" */
 
+/* Device 3 Extended Capability */
+#define PCI_DEV3_DEVCAP3	0x4		/* Device Capabilities 3 Register */
+#define  PCI_DEV3_DEVCAP3_DMWR_REQ_ROUTING		0x1	/* DMWr Request Routing Support */
+#define  PCI_DEV3_DEVCAP3_14BIT_TAG_COMP		0x2	/* 14-Bit Tag Completer Support */
+#define  PCI_DEV3_DEVCAP3_14BIT_TAG_REQ			0x4	/* 14-Bit Tag Requester Support */
+#define  PCI_DEV3_DEVCAP3_L0P				0x8	/* L0p Support */
+#define  PCI_DEV3_DEVCAP3_PORT_L0P_EXIT			0x070	/* Port L0p Exit Latency */
+#define  PCI_DEV3_DEVCAP3_RETIMER_L0P_EXIT		0x380	/* Retimer L0p Exit Latency */
+#define PCI_DEV3_DEVCTL3	0x8		/* Device Control 3 Register */
+#define  PCI_DEV3_DEVCTL3_DMWR_REQ			0x1	/* DMWr Requester Enable */
+#define  PCI_DEV3_DEVCTL3_DMWR_EGRESS_BLOCK		0x2	/* DMWr Egress Blocking */
+#define  PCI_DEV3_DEVCTL3_14BIT_TAG_REQ			0x4	/* 14-Bit Tag Requester Enable */
+#define  PCI_DEV3_DEVCTL3_L0P				0x8	/* L0p Enable */
+#define  PCI_DEV3_DEVCTL3_TLW				0x70	/* Target Link Width */
+#define PCI_DEV3_DEVSTA3	0xC	/* Device Status 3 Register */
+#define  PCI_DEV3_DEVSTA3_ILW				0x7	/* Initial Link Width */
+#define  PCI_DEV3_DEVSTA3_SEG_CAPT			0x8	/* Segment Captured */
+#define  PCI_DEV3_DEVSTA3_REMOTE_L0P			0x10	/* Remote L0p Support */
+
 /*
  * The PCI interface treats multi-function devices as independent
  * devices.  The slot/function address of each device is encoded
ls-caps.c +3 -1
index 38a171a5fe4d..d9632b1d3a8e 100644
@@ -1798,6 +1798,7 @@ void
 show_caps(struct device *d, int where)
 {
   int can_have_ext_caps = 0;
+  u16 pci_exp_cap = 0;
   int type = -1;
 
   if (get_conf_word(d, PCI_STATUS) & PCI_STATUS_CAP_LIST)
@@ -1882,6 +1883,7 @@ show_caps(struct device *d, int where)
 	    case PCI_CAP_ID_EXP:
 	      type = cap_express(d, where, cap);
 	      can_have_ext_caps = 1;
+	      pci_exp_cap = cap;
 	      break;
 	    case PCI_CAP_ID_MSIX:
 	      cap_msix(d, where, cap);
@@ -1902,5 +1904,5 @@ show_caps(struct device *d, int where)
 	}
     }
   if (can_have_ext_caps)
-    show_ext_caps(d, type);
+    show_ext_caps(d, type, pci_exp_cap);
 }
ls-ecaps.c +40 -1

54 lines not on this page · raw message

lspci.h +1 -1
index 4d711a555d65..96f46722b2ef 100644
@@ -68,7 +68,7 @@ void show_caps(struct device *d, int where);
 
 /* ls-ecaps.c */
 
-void show_ext_caps(struct device *d, int type);
+void show_ext_caps(struct device *d, int type, u16 pci_exp_cap);
 
 /* ls-caps-vendor.c */
 
Signature · 1 line
2.39.5