Patchwork Only decode defined fields of PCI Express Link Control 2

login
register
mail settings
Submitter Ben Hutchings
Date May 17, 2012, 2:14 p.m.
Message ID <1337264056.2496.8.camel@bwh-desktop.uk.solarflarecom.com>
Download mbox | patch
Permalink /patch/159911/
State Not Applicable
Headers show

Comments

Ben Hutchings - May 17, 2012, 2:14 p.m.
On a PCI Express multi-function device associated with an upstream
port, all bits of the Link Control 2 register are currently reserved
on functions > 0.

The Selectable De-emphasis field is reserved on all but downstream
ports.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
 ls-caps.c |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)
Martin Mares - May 28, 2012, 1:39 p.m.
Hi!

> On a PCI Express multi-function device associated with an upstream
> port, all bits of the Link Control 2 register are currently reserved
> on functions > 0.
> 
> The Selectable De-emphasis field is reserved on all but downstream
> ports.

Thanks, applied.

				Have a nice fortnight

Patch

diff --git a/ls-caps.c b/ls-caps.c
index 9645e5a..4a75ce7 100644
--- a/ls-caps.c
+++ b/ls-caps.c
@@ -991,22 +991,28 @@  static const char *cap_express_link2_transmargin(int type)
     }
 }
 
-static void cap_express_link2(struct device *d, int where, int type UNUSED)
+static void cap_express_link2(struct device *d, int where, int type)
 {
   u16 w;
 
-  w = get_conf_word(d, where + PCI_EXP_LNKCTL2);
-  printf("\t\tLnkCtl2: Target Link Speed: %s, EnterCompliance%c SpeedDis%c, Selectable De-emphasis: %s\n"
-	"\t\t\t Transmit Margin: %s, EnterModifiedCompliance%c ComplianceSOS%c\n"
-	"\t\t\t Compliance De-emphasis: %s\n",
+  if (!((type == PCI_EXP_TYPE_ENDPOINT || type == PCI_EXP_TYPE_LEG_END) &&
+	(d->dev->dev != 0 || d->dev->func != 0))) {
+    w = get_conf_word(d, where + PCI_EXP_LNKCTL2);
+    printf("\t\tLnkCtl2: Target Link Speed: %s, EnterCompliance%c SpeedDis%c",
 	cap_express_link2_speed(PCI_EXP_LNKCTL2_SPEED(w)),
 	FLAG(w, PCI_EXP_LNKCTL2_CMPLNC),
-	FLAG(w, PCI_EXP_LNKCTL2_SPEED_DIS),
-	cap_express_link2_deemphasis(PCI_EXP_LNKCTL2_DEEMPHASIS(w)),
+	FLAG(w, PCI_EXP_LNKCTL2_SPEED_DIS));
+    if (type == PCI_EXP_TYPE_DOWNSTREAM)
+      printf(", Selectable De-emphasis: %s",
+	cap_express_link2_deemphasis(PCI_EXP_LNKCTL2_DEEMPHASIS(w)));
+    printf("\n"
+	"\t\t\t Transmit Margin: %s, EnterModifiedCompliance%c ComplianceSOS%c\n"
+	"\t\t\t Compliance De-emphasis: %s\n",
 	cap_express_link2_transmargin(PCI_EXP_LNKCTL2_MARGIN(w)),
 	FLAG(w, PCI_EXP_LNKCTL2_MOD_CMPLNC),
 	FLAG(w, PCI_EXP_LNKCTL2_CMPLNC_SOS),
 	cap_express_link2_deemphasis(PCI_EXP_LNKCTL2_COM_DEEMPHASIS(w)));
+  }
 
   w = get_conf_word(d, where + PCI_EXP_LNKSTA2);
   printf("\t\tLnkSta2: Current De-emphasis Level: %s, EqualizationComplete%c, EqualizationPhase1%c\n"