2023-10-18 16:08:48

by Bjorn Helgaas

[permalink] [raw]
Subject: [PATCH 0/8] lspci: Decode more DevCtl2 fields

From: Bjorn Helgaas <[email protected]>

Decode several more DevCtl2 fields and show Interrupt Message Numbers more
consistently.

Bjorn Helgaas (8):
lspci: Reorder PCIe DevCtl2 fields to match spec
lspci: Decode PCIe DevCtl2 ID-Based Ordering Enables
lspci: Decode PCIe DevCtl2 Emergency Power Reduction Request
lspci: Decode PCIe DevCtl2 End-to-End TLP Prefix Blocking
lspci: Decode PCIe LnkCtl Link Disable as 'LnkDisable'
lspci: Print PCIe Interrupt Message Numbers consistently
lspci: Remove spurious colon (':') from PCIe PTM decoding
setpci: Fix man page typo

lib/header.h | 4 ++++
ls-caps.c | 20 +++++++++++++-------
ls-ecaps.c | 12 ++++++------
setpci.man | 2 +-
4 files changed, 24 insertions(+), 14 deletions(-)

--
2.34.1


2023-10-18 16:08:56

by Bjorn Helgaas

[permalink] [raw]
Subject: [PATCH 1/8] lspci: Reorder PCIe DevCtl2 fields to match spec

From: Bjorn Helgaas <[email protected]>

Decode the PCIe DevCtl2 fields in the same order they're documented in the
PCIe spec.

Signed-off-by: Bjorn Helgaas <[email protected]>
---
ls-caps.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/ls-caps.c b/ls-caps.c
index 1b63262ef005..beb7446a926e 100644
--- a/ls-caps.c
+++ b/ls-caps.c
@@ -1153,12 +1153,9 @@ 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 10BitTagReq%c OBFF %s,",
+ printf("\t\tDevCtl2: Completion Timeout: %s, TimeoutDis%c",
cap_express_dev2_timeout_value(PCI_EXP_DEVCTL2_TIMEOUT_VALUE(w)),
- FLAG(w, PCI_EXP_DEVCTL2_TIMEOUT_DIS),
- FLAG(w, PCI_EXP_DEVCTL2_LTR),
- FLAG(w, PCI_EXP_DEVCTL2_10BIT_TAG_REQ),
- cap_express_devctl2_obff(PCI_EXP_DEVCTL2_OBFF(w)));
+ FLAG(w, PCI_EXP_DEVCTL2_TIMEOUT_DIS));
if (type == PCI_EXP_TYPE_ROOT_PORT || type == PCI_EXP_TYPE_DOWNSTREAM)
printf(" ARIFwd%c\n", FLAG(w, PCI_EXP_DEVCTL2_ARI));
else
@@ -1176,6 +1173,10 @@ static void cap_express_dev2(struct device *d, int where, int type)
printf(" EgressBlck%c", FLAG(w, PCI_EXP_DEVCTL2_ATOMICOP_EGRESS_BLOCK));
printf("\n");
}
+ printf("\t\t\t LTR%c 10BitTagReq%c OBFF %s\n",
+ FLAG(w, PCI_EXP_DEVCTL2_LTR),
+ FLAG(w, PCI_EXP_DEVCTL2_10BIT_TAG_REQ),
+ cap_express_devctl2_obff(PCI_EXP_DEVCTL2_OBFF(w)));
}

static const char *cap_express_link2_speed_cap(int vector)
--
2.34.1

2023-10-18 16:09:11

by Bjorn Helgaas

[permalink] [raw]
Subject: [PATCH 3/8] lspci: Decode PCIe DevCtl2 Emergency Power Reduction Request

From: Bjorn Helgaas <[email protected]>

Decode the PCIe DevCtl2 Emergency Power Reduction Request bit.

Signed-off-by: Bjorn Helgaas <[email protected]>
---
lib/header.h | 1 +
ls-caps.c | 4 +++-
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/header.h b/lib/header.h
index 5065465c33db..c3a720f716b7 100644
--- a/lib/header.h
+++ b/lib/header.h
@@ -906,6 +906,7 @@
#define PCI_EXP_DEVCTL2_IDO_REQ_EN 0x0100 /* Allow IDO for requests */
#define PCI_EXP_DEVCTL2_IDO_CMP_EN 0x0200 /* Allow IDO for completions */
#define PCI_EXP_DEVCTL2_LTR 0x0400 /* LTR enabled */
+#define PCI_EXP_DEVCTL2_EPR_REQ 0x0800 /* Emergency Power Reduction Request */
#define PCI_EXP_DEVCTL2_10BIT_TAG_REQ 0x1000 /* 10 Bit Tag Requester enabled */
#define PCI_EXP_DEVCTL2_OBFF(x) (((x) >> 13) & 3) /* OBFF enabled */
#define PCI_EXP_DEVSTA2 0x2a /* Device Status */
diff --git a/ls-caps.c b/ls-caps.c
index 0c7bef976144..19c59536f948 100644
--- a/ls-caps.c
+++ b/ls-caps.c
@@ -1173,10 +1173,12 @@ static void cap_express_dev2(struct device *d, int where, int type)
printf(" EgressBlck%c", FLAG(w, PCI_EXP_DEVCTL2_ATOMICOP_EGRESS_BLOCK));
printf("\n");
}
- printf("\t\t\t IDOReq%c IDOCompl%c LTR%c 10BitTagReq%c OBFF %s\n",
+ printf("\t\t\t IDOReq%c IDOCompl%c LTR%c EmergencyPowerReductionReq%c\n",
FLAG(w, PCI_EXP_DEVCTL2_IDO_REQ_EN),
FLAG(w, PCI_EXP_DEVCTL2_IDO_CMP_EN),
FLAG(w, PCI_EXP_DEVCTL2_LTR),
+ FLAG(w, PCI_EXP_DEVCTL2_EPR_REQ));
+ printf("\t\t\t 10BitTagReq%c OBFF %s\n",
FLAG(w, PCI_EXP_DEVCTL2_10BIT_TAG_REQ),
cap_express_devctl2_obff(PCI_EXP_DEVCTL2_OBFF(w)));
}
--
2.34.1

2023-10-18 16:09:26

by Bjorn Helgaas

[permalink] [raw]
Subject: [PATCH 5/8] lspci: Decode PCIe LnkCtl Link Disable as 'LnkDisable'

From: Bjorn Helgaas <[email protected]>

Decode the Link Disable bit as "LnkDisable" (not simply "Disable") to match
the spec terminology (PCIe r6.0, sec 7.5.3.7)

Signed-off-by: Bjorn Helgaas <[email protected]>
---
ls-caps.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ls-caps.c b/ls-caps.c
index 0d333d578407..6c5b73bf2dca 100644
--- a/ls-caps.c
+++ b/ls-caps.c
@@ -841,7 +841,7 @@ 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(" Disabled%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",
FLAG(w, PCI_EXP_LNKCTL_DISABLE),
FLAG(w, PCI_EXP_LNKCTL_CLOCK),
FLAG(w, PCI_EXP_LNKCTL_XSYNCH),
--
2.34.1

2023-10-18 16:09:28

by Bjorn Helgaas

[permalink] [raw]
Subject: [PATCH 2/8] lspci: Decode PCIe DevCtl2 ID-Based Ordering Enables

From: Bjorn Helgaas <[email protected]>

Decode the PCIe DevCtl2 ID-Based Ordering Enable bits.

Signed-off-by: Bjorn Helgaas <[email protected]>
---
lib/header.h | 2 ++
ls-caps.c | 4 +++-
2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/header.h b/lib/header.h
index 57ef0ae8a31e..5065465c33db 100644
--- a/lib/header.h
+++ b/lib/header.h
@@ -903,6 +903,8 @@
#define PCI_EXP_DEVCTL2_ARI 0x0020 /* ARI Forwarding */
#define PCI_EXP_DEVCTL2_ATOMICOP_REQUESTER_EN 0x0040 /* AtomicOp RequesterEnable */
#define PCI_EXP_DEVCTL2_ATOMICOP_EGRESS_BLOCK 0x0080 /* AtomicOp Egress Blocking */
+#define PCI_EXP_DEVCTL2_IDO_REQ_EN 0x0100 /* Allow IDO for requests */
+#define PCI_EXP_DEVCTL2_IDO_CMP_EN 0x0200 /* Allow IDO for completions */
#define PCI_EXP_DEVCTL2_LTR 0x0400 /* LTR enabled */
#define PCI_EXP_DEVCTL2_10BIT_TAG_REQ 0x1000 /* 10 Bit Tag Requester enabled */
#define PCI_EXP_DEVCTL2_OBFF(x) (((x) >> 13) & 3) /* OBFF enabled */
diff --git a/ls-caps.c b/ls-caps.c
index beb7446a926e..0c7bef976144 100644
--- a/ls-caps.c
+++ b/ls-caps.c
@@ -1173,7 +1173,9 @@ static void cap_express_dev2(struct device *d, int where, int type)
printf(" EgressBlck%c", FLAG(w, PCI_EXP_DEVCTL2_ATOMICOP_EGRESS_BLOCK));
printf("\n");
}
- printf("\t\t\t LTR%c 10BitTagReq%c OBFF %s\n",
+ printf("\t\t\t IDOReq%c IDOCompl%c LTR%c 10BitTagReq%c OBFF %s\n",
+ FLAG(w, PCI_EXP_DEVCTL2_IDO_REQ_EN),
+ FLAG(w, PCI_EXP_DEVCTL2_IDO_CMP_EN),
FLAG(w, PCI_EXP_DEVCTL2_LTR),
FLAG(w, PCI_EXP_DEVCTL2_10BIT_TAG_REQ),
cap_express_devctl2_obff(PCI_EXP_DEVCTL2_OBFF(w)));
--
2.34.1

2023-10-18 16:09:33

by Bjorn Helgaas

[permalink] [raw]
Subject: [PATCH 6/8] lspci: Print PCIe Interrupt Message Numbers consistently

From: Bjorn Helgaas <[email protected]>

Several Capabilities include MSI/MSI-X Interrupt Message Numbers, which
were decoded in various ways:

- MSI %02x PCIe Capability
- IntMsg %d AER Capability
- INT Msg #%d DPC Capability
- Interrupt Message Number %03x SR-IOV Capability
- Interrupt Message Number %03x DOE Capability

Print them all using the same format:

+ IntMsgNum %d

This better matches the "Interrupt Message Number" terminology used in the
spec, e.g., PCIe r6.0, sec 7.5.3.2.

Signed-off-by: Bjorn Helgaas <[email protected]>
Cc: Jonathan Cameron <[email protected]>
---
ls-caps.c | 2 +-
ls-ecaps.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/ls-caps.c b/ls-caps.c
index 6c5b73bf2dca..fce9502bd29a 100644
--- a/ls-caps.c
+++ b/ls-caps.c
@@ -1436,7 +1436,7 @@ cap_express(struct device *d, int where, int cap)
default:
printf("Unknown type %d", type);
}
- printf(", MSI %02x\n", (cap & PCI_EXP_FLAGS_IRQ) >> 9);
+ printf(", IntMsgNum %d\n", (cap & PCI_EXP_FLAGS_IRQ) >> 9);
if (verbose < 2)
return type;

diff --git a/ls-ecaps.c b/ls-ecaps.c
index 6028607e8217..5bc7a6907349 100644
--- a/ls-ecaps.c
+++ b/ls-ecaps.c
@@ -191,7 +191,7 @@ cap_aer(struct device *d, int where, int type)

l = get_conf_long(d, where + PCI_ERR_ROOT_STATUS);
printf("\t\tRootSta: CERcvd%c MultCERcvd%c UERcvd%c MultUERcvd%c\n"
- "\t\t\t FirstFatal%c NonFatalMsg%c FatalMsg%c IntMsg %d\n",
+ "\t\t\t FirstFatal%c NonFatalMsg%c FatalMsg%c IntMsgNum %d\n",
FLAG(l, PCI_ERR_ROOT_COR_RCV),
FLAG(l, PCI_ERR_ROOT_MULTI_COR_RCV),
FLAG(l, PCI_ERR_ROOT_UNCOR_RCV),
@@ -221,7 +221,7 @@ static void cap_dpc(struct device *d, int where)
return;

l = get_conf_word(d, where + PCI_DPC_CAP);
- printf("\t\tDpcCap:\tINT Msg #%d, RPExt%c PoisonedTLP%c SwTrigger%c RP PIO Log %d, DL_ActiveErr%c\n",
+ printf("\t\tDpcCap:\tIntMsgNum %d, RPExt%c PoisonedTLP%c SwTrigger%c RP PIO Log %d, DL_ActiveErr%c\n",
PCI_DPC_CAP_INT_MSG(l), FLAG(l, PCI_DPC_CAP_RP_EXT), FLAG(l, PCI_DPC_CAP_TLP_BLOCK),
FLAG(l, PCI_DPC_CAP_SW_TRIGGER), PCI_DPC_CAP_RP_LOG(l), FLAG(l, PCI_DPC_CAP_DL_ACT_ERR));

@@ -371,7 +371,7 @@ cap_sriov(struct device *d, int where)
return;

l = get_conf_long(d, where + PCI_IOV_CAP);
- printf("\t\tIOVCap:\tMigration%c 10BitTagReq%c Interrupt Message Number: %03x\n",
+ printf("\t\tIOVCap:\tMigration%c 10BitTagReq%c IntMsgNum %d\n",
FLAG(l, PCI_IOV_CAP_VFM), FLAG(l, PCI_IOV_CAP_VF_10BIT_TAG_REQ), PCI_IOV_CAP_IMN(l));
w = get_conf_word(d, where + PCI_IOV_CTRL);
printf("\t\tIOVCtl:\tEnable%c Migration%c Interrupt%c MSE%c ARIHierarchy%c 10BitTagReq%c\n",
@@ -1394,7 +1394,7 @@ cap_doe(struct device *d, int where)
printf("\t\tDOECap: IntSup%c\n",
FLAG(l, PCI_DOE_CAP_INT_SUPP));
if (l & PCI_DOE_CAP_INT_SUPP)
- printf("\t\t\tInterrupt Message Number %03x\n",
+ printf("\t\t\tIntMsgNum %d\n",
PCI_DOE_CAP_INT_MSG(l));

l = get_conf_long(d, where + PCI_DOE_CTL);
--
2.34.1

2023-10-18 16:09:44

by Bjorn Helgaas

[permalink] [raw]
Subject: [PATCH 8/8] setpci: Fix man page typo

From: Bjorn Helgaas <[email protected]>

"Several ways how to identity a register" doesn't read correctly and
misspells "identify". Reword as "several ways to identify a register".

Signed-off-by: Bjorn Helgaas <[email protected]>
---
setpci.man | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setpci.man b/setpci.man
index 9e4e1d8a6c44..fd4495f4d1b4 100644
--- a/setpci.man
+++ b/setpci.man
@@ -135,7 +135,7 @@ are hexadecimal numbers. In the latter case, only the bits corresponding to bina
ones in the \fImask\fP are changed (technically, this is a read-modify-write operation).

.PP
-There are several ways how to identity a register:
+There are several ways to identify a register:
.IP \(bu
Tell its address in hexadecimal.
.IP \(bu
--
2.34.1

2023-10-18 16:09:48

by Bjorn Helgaas

[permalink] [raw]
Subject: [PATCH 4/8] lspci: Decode PCIe DevCtl2 End-to-End TLP Prefix Blocking

From: Bjorn Helgaas <[email protected]>

Decode the PCIe DevCtl2 End-to-End TLP Prefix Blocking bit. The
"EETLPPrefixBlk" format is analogous to the existing "EETLPPrefix" format
used for the corresponding DevCap2 bit.

Signed-off-by: Bjorn Helgaas <[email protected]>
---
lib/header.h | 1 +
ls-caps.c | 5 +++--
2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/header.h b/lib/header.h
index c3a720f716b7..4869617641f1 100644
--- a/lib/header.h
+++ b/lib/header.h
@@ -909,6 +909,7 @@
#define PCI_EXP_DEVCTL2_EPR_REQ 0x0800 /* Emergency Power Reduction Request */
#define PCI_EXP_DEVCTL2_10BIT_TAG_REQ 0x1000 /* 10 Bit Tag Requester enabled */
#define PCI_EXP_DEVCTL2_OBFF(x) (((x) >> 13) & 3) /* OBFF enabled */
+#define PCI_EXP_DEVCTL2_EE_TLP_BLK 0x8000 /* End-End TLP Prefix Blocking */
#define PCI_EXP_DEVSTA2 0x2a /* Device Status */
#define PCI_EXP_LNKCAP2 0x2c /* Link Capabilities */
#define PCI_EXP_LNKCAP2_SPEED(x) (((x) >> 1) & 0x7f)
diff --git a/ls-caps.c b/ls-caps.c
index 19c59536f948..0d333d578407 100644
--- a/ls-caps.c
+++ b/ls-caps.c
@@ -1178,9 +1178,10 @@ static void cap_express_dev2(struct device *d, int where, int type)
FLAG(w, PCI_EXP_DEVCTL2_IDO_CMP_EN),
FLAG(w, PCI_EXP_DEVCTL2_LTR),
FLAG(w, PCI_EXP_DEVCTL2_EPR_REQ));
- printf("\t\t\t 10BitTagReq%c OBFF %s\n",
+ printf("\t\t\t 10BitTagReq%c OBFF %s, EETLPPrefixBlk%c\n",
FLAG(w, PCI_EXP_DEVCTL2_10BIT_TAG_REQ),
- cap_express_devctl2_obff(PCI_EXP_DEVCTL2_OBFF(w)));
+ cap_express_devctl2_obff(PCI_EXP_DEVCTL2_OBFF(w)),
+ FLAG(w, PCI_EXP_DEVCTL2_EE_TLP_BLK));
}

static const char *cap_express_link2_speed_cap(int vector)
--
2.34.1

2023-10-18 16:10:02

by Bjorn Helgaas

[permalink] [raw]
Subject: [PATCH 7/8] lspci: Remove spurious colon (':') from PCIe PTM decoding

From: Bjorn Helgaas <[email protected]>

Remove spurious colon from PTM decoding to match other enabled/disabled
decoding.

Signed-off-by: Bjorn Helgaas <[email protected]>
---
ls-ecaps.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ls-ecaps.c b/ls-ecaps.c
index 5bc7a6907349..a22da6173e67 100644
--- a/ls-ecaps.c
+++ b/ls-ecaps.c
@@ -1245,7 +1245,7 @@ cap_ptm(struct device *d, int where)

buff = get_conf_long(d, where + 4);
printf("\t\tPTMCap: ");
- printf("Requester:%c Responder:%c Root:%c\n",
+ printf("Requester%c Responder%c Root%c\n",
FLAG(buff, 0x1),
FLAG(buff, 0x2),
FLAG(buff, 0x4));
@@ -1266,7 +1266,7 @@ cap_ptm(struct device *d, int where)

buff = get_conf_long(d, where + 8);
printf("\t\tPTMControl: ");
- printf("Enabled:%c RootSelected:%c\n",
+ printf("Enabled%c RootSelected%c\n",
FLAG(buff, 0x1),
FLAG(buff, 0x2));

--
2.34.1

2023-10-18 19:06:38

by Martin Mares

[permalink] [raw]
Subject: Re: [PATCH 0/8] lspci: Decode more DevCtl2 fields

Hi!

> Decode several more DevCtl2 fields and show Interrupt Message Numbers more
> consistently.
>
> Bjorn Helgaas (8):
> lspci: Reorder PCIe DevCtl2 fields to match spec
> lspci: Decode PCIe DevCtl2 ID-Based Ordering Enables
> lspci: Decode PCIe DevCtl2 Emergency Power Reduction Request
> lspci: Decode PCIe DevCtl2 End-to-End TLP Prefix Blocking
> lspci: Decode PCIe LnkCtl Link Disable as 'LnkDisable'
> lspci: Print PCIe Interrupt Message Numbers consistently
> lspci: Remove spurious colon (':') from PCIe PTM decoding
> setpci: Fix man page typo

Thanks, applied.

Martin