Skip to contentSkip to conversation

ls-ecaps: Decode DPC RP PIO registers

PATCH Superseded Mattias Nissler 2 participants 5 messages Apr 16 – Apr 17

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ls-ecaps: Decode DPC RP PIO registers

The RP PIO registers in the DPC extended capability contain status information and control bits related to how root ports handle failing requests.

Sample output:
Capabilities: [380 v1] Downstream Port Containment
DpcCap: IntMsgNum 0, RPExt+ PoisonedTLP+ SwTrigger+ RP PIO Log 6, DL_ActiveErr+
DpcCtl: Trigger:0 Cmpl+ INT+ ErrCor+ PoisonedTLP- SwTrigger- DL_ActiveErr-
DpcSta: Trigger- Reason:00 INT- RPBusy- TriggerExt:00 RP PIO ErrPtr:11
Source: 0000
RP PIO:
Sta: CfgUR+ CfgCA- CfgCTO- IOUR- IOCA- IOCTO- MemUR- MemCA+ MemCTO-
Msk: CfgUR+ CfgCA+ CfgCTO+ IOUR+ IOCA+ IOCTO+ MemUR- MemCA- MemCTO-
Sev: CfgUR- CfgCA- CfgCTO- IOUR- IOCA- IOCTO- MemUR- MemCA- MemCTO-
Err: CfgUR- CfgCA- CfgCTO- IOUR- IOCA- IOCTO- MemUR- MemCA- MemCTO-
Exc: CfgUR- CfgCA- CfgCTO- IOUR- IOCA- IOCTO- MemUR- MemCA- MemCTO-
HeaderLog: 00001001 0000220f f7a01100 00000000
ImpSpecLog: 00000000
TLPPrefixLog: 00000000

---
 lib/header.h | 18 ++++++++++++
 ls-ecaps.c   | 83 ++++++++++++++++++++++++++++++++++++++++++++--------
 2 files changed, 88 insertions(+), 13 deletions(-)
lib/header.h +18 -0
index 21fb628..f74a124 100644
@@ -1454,6 +1454,7 @@
 #define  PCI_DPC_CAP_SW_TRIGGER	0x80		/* DPC Software Trigger */
 #define  PCI_DPC_CAP_RP_LOG(x)	(((x) >> 8) & 0xf) /* DPC RP PIO Log Size */
 #define  PCI_DPC_CAP_DL_ACT_ERR	0x1000		/* DPC DL_Active ERR_COR Signal */
+#define  PCI_DPC_CAP_RP_PIO_LOG_SIZE4	0x2000	/* RP PIO Log Size [4] */
 #define PCI_DPC_CTL		6	/* DPC Control */
 #define  PCI_DPC_CTL_TRIGGER(x) ((x) & 0x3)	/* DPC Trigger Enable */
 #define  PCI_DPC_CTL_CMPL	0x4		/* DPC Completion Control */
@@ -1470,6 +1471,23 @@
 #define  PCI_DPC_STS_TRIGGER_EXT(x) (((x) >> 5) & 0x3) /* Trigger Reason Extension */
 #define  PCI_DPC_STS_PIO_FEP(x) (((x) >> 8) & 0x1f) /* DPC PIO First Error Pointer */
 #define PCI_DPC_SOURCE		10	/* DPC Source ID */
+#define PCI_DPC_RP_PIO_STATUS	0xC	/* DPC RP PIO Status */
+#define  PCI_DPC_RP_PIO_CFG_UR		0x00000001	/* Cfg Request UR Completion */
+#define  PCI_DPC_RP_PIO_CFG_CA		0x00000002	/* Cfg Request CA Completion */
+#define  PCI_DPC_RP_PIO_CFG_CTO		0x00000004	/* Cfg Request Completion Timeout */
+#define  PCI_DPC_RP_PIO_IO_UR		0x00000100	/* I/O Request UR Completion */
+#define  PCI_DPC_RP_PIO_IO_CA		0x00000200	/* I/O Request CA Completion */
+#define  PCI_DPC_RP_PIO_IO_CTO		0x00000400	/* I/O Request Completion Timeout */
+#define  PCI_DPC_RP_PIO_MEM_UR		0x00010000	/* Mem Request UR Completion */
+#define  PCI_DPC_RP_PIO_MEM_CA		0x00020000	/* Mem Request CA Completion */
+#define  PCI_DPC_RP_PIO_MEM_CTO		0x00040000	/* Mem Request Completion Timeout */
+#define PCI_DPC_RP_PIO_MASK	0x10	/* DPC RP PIO Mask */
+#define PCI_DPC_RP_PIO_SEVERITY	0x14	/* DPC RP PIO Severity */
+#define PCI_DPC_RP_PIO_SYSERROR	0x18	/* DPC RP PIO SysError */
+#define PCI_DPC_RP_PIO_EXCEPTION	0x1C	/* DPC RP PIO Exception */
+#define PCI_DPC_RP_PIO_HEADER_LOG	0x20	/* DPC RP PIO Header Log */
+#define PCI_DPC_RP_PIO_IMPSPEC_LOG	0x30	/* DPC RP PIO ImpSpec Log */
+#define PCI_DPC_RP_PIO_TLP_PREFIX_LOG	0x34	/* DPC RP PIO TLP Prefix Log */
 
 /* L1 PM Substates Extended Capability */
 #define PCI_L1PM_SUBSTAT_CAP	0x4	/* L1 PM Substate Capability */
ls-ecaps.c +70 -13

101 lines not on this page · raw message

Signature · 1 line
2.52.0
#1 lore raw

Hello!

Quoted 1 line

+#define PCI_DPC_RP_PIO_EXCEPTION 0x1C /* DPC RP PIO Exception */

We use lower-case hex digits.

Quoted 1 line

+ if ((cap & PCI_DPC_CAP_RP_EXT) && config_fetch(d, where + PCI_DPC_CAP + 8, 24 + 4 * log_size)) {

Please follow the indentation style of the rest of the file.

Quoted 26 lines
ls-ecaps.c +26 -0
+    printf("\t\tRP PIO:\n");
+
+    l = get_conf_long(d, where + PCI_DPC_RP_PIO_STATUS);
+    printf("\t\t\tSta: CfgUR%c CfgCA%c CfgCTO%c IOUR%c IOCA%c IOCTO%c MemUR%c MemCA%c MemCTO%c\n",
+      FLAG(l, PCI_DPC_RP_PIO_CFG_UR), FLAG(l, PCI_DPC_RP_PIO_CFG_CA), FLAG(l, PCI_DPC_RP_PIO_CFG_CTO),
+      FLAG(l, PCI_DPC_RP_PIO_IO_UR), FLAG(l, PCI_DPC_RP_PIO_IO_CA), FLAG(l, PCI_DPC_RP_PIO_IO_CTO),
+      FLAG(l, PCI_DPC_RP_PIO_MEM_UR), FLAG(l, PCI_DPC_RP_PIO_MEM_CA), FLAG(l, PCI_DPC_RP_PIO_MEM_CTO));
+
+    l = get_conf_long(d, where + PCI_DPC_RP_PIO_MASK);
+    printf("\t\t\tMsk: CfgUR%c CfgCA%c CfgCTO%c IOUR%c IOCA%c IOCTO%c MemUR%c MemCA%c MemCTO%c\n",
+      FLAG(l, PCI_DPC_RP_PIO_CFG_UR), FLAG(l, PCI_DPC_RP_PIO_CFG_CA), FLAG(l, PCI_DPC_RP_PIO_CFG_CTO),
+      FLAG(l, PCI_DPC_RP_PIO_IO_UR), FLAG(l, PCI_DPC_RP_PIO_IO_CA), FLAG(l, PCI_DPC_RP_PIO_IO_CTO),
+      FLAG(l, PCI_DPC_RP_PIO_MEM_UR), FLAG(l, PCI_DPC_RP_PIO_MEM_CA), FLAG(l, PCI_DPC_RP_PIO_MEM_CTO));
+
+    l = get_conf_long(d, where + PCI_DPC_RP_PIO_SEVERITY);
+    printf("\t\t\tSev: CfgUR%c CfgCA%c CfgCTO%c IOUR%c IOCA%c IOCTO%c MemUR%c MemCA%c MemCTO%c\n",
+      FLAG(l, PCI_DPC_RP_PIO_CFG_UR), FLAG(l, PCI_DPC_RP_PIO_CFG_CA), FLAG(l, PCI_DPC_RP_PIO_CFG_CTO),
+      FLAG(l, PCI_DPC_RP_PIO_IO_UR), FLAG(l, PCI_DPC_RP_PIO_IO_CA), FLAG(l, PCI_DPC_RP_PIO_IO_CTO),
+      FLAG(l, PCI_DPC_RP_PIO_MEM_UR), FLAG(l, PCI_DPC_RP_PIO_MEM_CA), FLAG(l, PCI_DPC_RP_PIO_MEM_CTO));
+
+    l = get_conf_long(d, where + PCI_DPC_RP_PIO_SYSERROR);
+    printf("\t\t\tErr: CfgUR%c CfgCA%c CfgCTO%c IOUR%c IOCA%c IOCTO%c MemUR%c MemCA%c MemCTO%c\n",
+      FLAG(l, PCI_DPC_RP_PIO_CFG_UR), FLAG(l, PCI_DPC_RP_PIO_CFG_CA), FLAG(l, PCI_DPC_RP_PIO_CFG_CTO),
+      FLAG(l, PCI_DPC_RP_PIO_IO_UR), FLAG(l, PCI_DPC_RP_PIO_IO_CA), FLAG(l, PCI_DPC_RP_PIO_IO_CTO),
+      FLAG(l, PCI_DPC_RP_PIO_MEM_UR), FLAG(l, PCI_DPC_RP_PIO_MEM_CA), FLAG(l, PCI_DPC_RP_PIO_MEM_CTO));
+

ls-ecaps.c static void cap_dpc(struct device *d, int where) · line 303

Quoted 10 lines
ls-ecaps.c +10 -0
+    l = get_conf_long(d, where + PCI_DPC_RP_PIO_EXCEPTION);
+    printf("\t\t\tExc: CfgUR%c CfgCA%c CfgCTO%c IOUR%c IOCA%c IOCTO%c MemUR%c MemCA%c MemCTO%c\n",
+      FLAG(l, PCI_DPC_RP_PIO_CFG_UR), FLAG(l, PCI_DPC_RP_PIO_CFG_CA), FLAG(l, PCI_DPC_RP_PIO_CFG_CTO),
+      FLAG(l, PCI_DPC_RP_PIO_IO_UR), FLAG(l, PCI_DPC_RP_PIO_IO_CA), FLAG(l, PCI_DPC_RP_PIO_IO_CTO),
+      FLAG(l, PCI_DPC_RP_PIO_MEM_UR), FLAG(l, PCI_DPC_RP_PIO_MEM_CA), FLAG(l, PCI_DPC_RP_PIO_MEM_CTO));
+
+    l0 = get_conf_long(d, where + PCI_DPC_RP_PIO_HEADER_LOG);
+    l1 = get_conf_long(d, where + PCI_DPC_RP_PIO_HEADER_LOG + 4);
+    l2 = get_conf_long(d, where + PCI_DPC_RP_PIO_HEADER_LOG + 8);
+    l3 = get_conf_long(d, where + PCI_DPC_RP_PIO_HEADER_LOG + 12);

Shouldn't you check that the log is long enough before accessing the first 4 entries?

Martin

#2 lore raw
Quoted 7 lines · Martin Mareš
Quoted 2 lines

Hello!

Quoted 1 line

+#define PCI_DPC_RP_PIO_EXCEPTION 0x1C /* DPC RP PIO Exception */

We use lower-case hex digits.

Ack, will update.

Quoted 4 lines
Quoted 2 lines

+ if ((cap & PCI_DPC_CAP_RP_EXT) && config_fetch(d, where + PCI_DPC_CAP + 8, 24 + 4 * log_size)) {

Please follow the indentation style of the rest of the file.

Ack, adjusting.

Quoted 32 lines
Quoted 32 lines
ls-ecaps.c +31 -0
+    printf("\t\tRP PIO:\n");
+
+    l = get_conf_long(d, where + PCI_DPC_RP_PIO_STATUS);
+    printf("\t\t\tSta: CfgUR%c CfgCA%c CfgCTO%c IOUR%c IOCA%c IOCTO%c MemUR%c MemCA%c MemCTO%c\n",
+      FLAG(l, PCI_DPC_RP_PIO_CFG_UR), FLAG(l, PCI_DPC_RP_PIO_CFG_CA), FLAG(l, PCI_DPC_RP_PIO_CFG_CTO),
+      FLAG(l, PCI_DPC_RP_PIO_IO_UR), FLAG(l, PCI_DPC_RP_PIO_IO_CA), FLAG(l, PCI_DPC_RP_PIO_IO_CTO),
+      FLAG(l, PCI_DPC_RP_PIO_MEM_UR), FLAG(l, PCI_DPC_RP_PIO_MEM_CA), FLAG(l, PCI_DPC_RP_PIO_MEM_CTO));
+
+    l = get_conf_long(d, where + PCI_DPC_RP_PIO_MASK);
+    printf("\t\t\tMsk: CfgUR%c CfgCA%c CfgCTO%c IOUR%c IOCA%c IOCTO%c MemUR%c MemCA%c MemCTO%c\n",
+      FLAG(l, PCI_DPC_RP_PIO_CFG_UR), FLAG(l, PCI_DPC_RP_PIO_CFG_CA), FLAG(l, PCI_DPC_RP_PIO_CFG_CTO),
+      FLAG(l, PCI_DPC_RP_PIO_IO_UR), FLAG(l, PCI_DPC_RP_PIO_IO_CA), FLAG(l, PCI_DPC_RP_PIO_IO_CTO),
+      FLAG(l, PCI_DPC_RP_PIO_MEM_UR), FLAG(l, PCI_DPC_RP_PIO_MEM_CA), FLAG(l, PCI_DPC_RP_PIO_MEM_CTO));
+
+    l = get_conf_long(d, where + PCI_DPC_RP_PIO_SEVERITY);
+    printf("\t\t\tSev: CfgUR%c CfgCA%c CfgCTO%c IOUR%c IOCA%c IOCTO%c MemUR%c MemCA%c MemCTO%c\n",
+      FLAG(l, PCI_DPC_RP_PIO_CFG_UR), FLAG(l, PCI_DPC_RP_PIO_CFG_CA), FLAG(l, PCI_DPC_RP_PIO_CFG_CTO),
+      FLAG(l, PCI_DPC_RP_PIO_IO_UR), FLAG(l, PCI_DPC_RP_PIO_IO_CA), FLAG(l, PCI_DPC_RP_PIO_IO_CTO),
+      FLAG(l, PCI_DPC_RP_PIO_MEM_UR), FLAG(l, PCI_DPC_RP_PIO_MEM_CA), FLAG(l, PCI_DPC_RP_PIO_MEM_CTO));
+
+    l = get_conf_long(d, where + PCI_DPC_RP_PIO_SYSERROR);
+    printf("\t\t\tErr: CfgUR%c CfgCA%c CfgCTO%c IOUR%c IOCA%c IOCTO%c MemUR%c MemCA%c MemCTO%c\n",
+      FLAG(l, PCI_DPC_RP_PIO_CFG_UR), FLAG(l, PCI_DPC_RP_PIO_CFG_CA), FLAG(l, PCI_DPC_RP_PIO_CFG_CTO),
+      FLAG(l, PCI_DPC_RP_PIO_IO_UR), FLAG(l, PCI_DPC_RP_PIO_IO_CA), FLAG(l, PCI_DPC_RP_PIO_IO_CTO),
+      FLAG(l, PCI_DPC_RP_PIO_MEM_UR), FLAG(l, PCI_DPC_RP_PIO_MEM_CA), FLAG(l, PCI_DPC_RP_PIO_MEM_CTO));
+
+    l = get_conf_long(d, where + PCI_DPC_RP_PIO_EXCEPTION);
+    printf("\t\t\tExc: CfgUR%c CfgCA%c CfgCTO%c IOUR%c IOCA%c IOCTO%c MemUR%c MemCA%c MemCTO%c\n",
+      FLAG(l, PCI_DPC_RP_PIO_CFG_UR), FLAG(l, PCI_DPC_RP_PIO_CFG_CA), FLAG(l, PCI_DPC_RP_PIO_CFG_CTO),
+      FLAG(l, PCI_DPC_RP_PIO_IO_UR), FLAG(l, PCI_DPC_RP_PIO_IO_CA), FLAG(l, PCI_DPC_RP_PIO_IO_CTO),
+      FLAG(l, PCI_DPC_RP_PIO_MEM_UR), FLAG(l, PCI_DPC_RP_PIO_MEM_CA), FLAG(l, PCI_DPC_RP_PIO_MEM_CTO));
Quoted 8 lines

ls-ecaps.c static void cap_dpc(struct device *d, int where) · line 303

Quoted 5 lines
ls-ecaps.c +5 -0
+
+    l0 = get_conf_long(d, where + PCI_DPC_RP_PIO_HEADER_LOG);
+    l1 = get_conf_long(d, where + PCI_DPC_RP_PIO_HEADER_LOG + 4);
+    l2 = get_conf_long(d, where + PCI_DPC_RP_PIO_HEADER_LOG + 8);
+    l3 = get_conf_long(d, where + PCI_DPC_RP_PIO_HEADER_LOG + 12);

Shouldn't you check that the log is long enough before accessing the first 4 entries?

Per the spec, the 4DW Header Log register is always present, and there is language requiring the log size field to be >= 4.

Also, my understanding is that this is intentionally analogous to the AER Header Log register, so I took the same approach as used for that.

Quoted 2 lines

Martin

#3 lore raw

Hi!

Quoted 1 line

Ack, will update.

It's better, thanks!

Quoted 2 lines

Per the spec, the 4DW Header Log register is always present, and there is language requiring the log size field to be >= 4.

I know, but I've seen too many devices violating specs...

Generally, the pciutils try to cope with whatever incorrect data the hardware reports. It particular, they should not crash nor get caught in an infinite loop.

If the log size field were < 4, your code would call get_conf_long() on a part of the configuration space that was not read by a previous config_fetch(), which would trigger an internal error.

A simple fix is to condition printing the HeaderLog on log_size >= 4.

Quoted 2 lines

Also, my understanding is that this is intentionally analogous to the AER Header Log register, so I took the same approach as used for that.

That's fine, but in case of the AER Header Log, the config_fetch() has a fixed size, which always covers the log entries.

Have a nice day

Signature · 2 lines
Martin `MJ' Mareš                        <[email protected]>   http://mj.ucw.cz/
United Computer Wizards, Prague, Czech Republic, Europe, Earth, Universe
#4 lore raw
Quoted 17 lines · Martin Mareš
Quoted 2 lines

Hi!

Quoted 1 line

Ack, will update.

It's better, thanks!

Quoted 2 lines

Per the spec, the 4DW Header Log register is always present, and there is language requiring the log size field to be >= 4.

I know, but I've seen too many devices violating specs...

Generally, the pciutils try to cope with whatever incorrect data the hardware reports. It particular, they should not crash nor get caught in an infinite loop.

Quoted 5 lines

If the log size field were < 4, your code would call get_conf_long() on a part of the configuration space that was not read by a previous config_fetch(), which would trigger an internal error.

A simple fix is to condition printing the HeaderLog on log_size >= 4.

Ah, you're right, I had overlooked the config_fetch angle of this. Let me add the check as suggested.

Quoted 11 lines
Quoted 3 lines

Also, my understanding is that this is intentionally analogous to the AER Header Log register, so I took the same approach as used for that.

That's fine, but in case of the AER Header Log, the config_fetch() has a fixed size, which always covers the log entries.

Have a nice day
--
Martin `MJ' Mareš <[email protected]> https://urldefense.com/v3/__http://mj.ucw.cz/__;!!Bt8RZUm9aw!-k2ThkLRdBtx6B1hSdcfTt_X77CluV8P_POzwnd1bnjYf_8tS900yCUARV58jcCfD7LS3XA$
United Computer Wizards, Prague, Czech Republic, Europe, Earth, Universe