]> mj.ucw.cz Git - pciutils.git/blobdiff - ls-ecaps.c
Added helper macros BITS and TABLE
[pciutils.git] / ls-ecaps.c
index 2d8153b8398092c696a1c317e551cdc4dd4eb3bb..1c696b49a43a74c4c269407071af4038ee81c0e3 100644 (file)
@@ -20,8 +20,8 @@ cap_dsn(struct device *d, int where)
   t1 = get_conf_long(d, where + 4);
   t2 = get_conf_long(d, where + 8);
   printf("Device Serial Number %02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x\n",
-       t1 & 0xff, (t1 >> 8) & 0xff, (t1 >> 16) & 0xff, t1 >> 24,
-       t2 & 0xff, (t2 >> 8) & 0xff, (t2 >> 16) & 0xff, t2 >> 24);
+       t2 >> 24, (t2 >> 16) & 0xff, (t2 >> 8) & 0xff, t2 & 0xff,
+       t1 >> 24, (t1 >> 16) & 0xff, (t1 >> 8) & 0xff, t1 & 0xff);
 }
 
 static void
@@ -30,6 +30,9 @@ cap_aer(struct device *d, int where)
   u32 l;
 
   printf("Advanced Error Reporting\n");
+  if (verbose < 2)
+    return;
+
   if (!config_fetch(d, where + PCI_ERR_UNCOR_STATUS, 24))
     return;
 
@@ -75,6 +78,9 @@ cap_acs(struct device *d, int where)
   u16 w;
 
   printf("Access Control Services\n");
+  if (verbose < 2)
+    return;
+
   if (!config_fetch(d, where + PCI_ACS_CAP, 4))
     return;
 
@@ -98,6 +104,9 @@ cap_ari(struct device *d, int where)
   u16 w;
 
   printf("Alternative Routing-ID Interpretation (ARI)\n");
+  if (verbose < 2)
+    return;
+
   if (!config_fetch(d, where + PCI_ARI_CAP, 4))
     return;
 
@@ -117,6 +126,9 @@ cap_ats(struct device *d, int where)
   u16 w;
 
   printf("Address Translation Service (ATS)\n");
+  if (verbose < 2)
+    return;
+
   if (!config_fetch(d, where + PCI_ATS_CAP, 4))
     return;
 
@@ -133,8 +145,12 @@ cap_sriov(struct device *d, int where)
   u16 b;
   u16 w;
   u32 l;
+  int i;
 
   printf("Single Root I/O Virtualization (SR-IOV)\n");
+  if (verbose < 2)
+    return;
+
   if (!config_fetch(d, where + PCI_IOV_CAP, 0x3c))
     return;
 
@@ -166,11 +182,123 @@ cap_sriov(struct device *d, int where)
   printf("\t\tSupported Page Size: %08x, ", l);
   l = get_conf_long(d, where + PCI_IOV_SYSPS);
   printf("System Page Size: %08x\n", l);
+
+  for (i=0; i < PCI_IOV_NUM_BAR; i++)
+    {
+      u32 addr;
+      int type;
+      u32 h;
+      l = get_conf_long(d, where + PCI_IOV_BAR_BASE + 4*i);
+      if (l == 0xffffffff)
+       l = 0;
+      if (!l)
+       continue;
+      printf("\t\tRegion %d: Memory at ", i);
+      addr = l & PCI_ADDR_MEM_MASK;
+      type = l & PCI_BASE_ADDRESS_MEM_TYPE_MASK;
+      if (type == PCI_BASE_ADDRESS_MEM_TYPE_64)
+       {
+         i++;
+         h = get_conf_long(d, where + PCI_IOV_BAR_BASE + (i*4));
+         printf("%08x", h);
+       }
+      printf("%08x (%s-bit, %sprefetchable)\n",
+       addr,
+       (type == PCI_BASE_ADDRESS_MEM_TYPE_32) ? "32" : "64",
+       (l & PCI_BASE_ADDRESS_MEM_PREFETCH) ? "" : "non-");
+    }
+
   l = get_conf_long(d, where + PCI_IOV_MSAO);
   printf("\t\tVF Migration: offset: %08x, BIR: %x\n", PCI_IOV_MSA_OFFSET(l),
        PCI_IOV_MSA_BIR(l));
 }
 
+static void
+cap_vc(struct device *d, int where)
+{
+  u32 cr1, cr2;
+  u16 ctrl, status;
+  int evc_cnt;
+  int arb_table_pos;
+  int i, j;
+  static const char ref_clocks[4][6] = { "100ns", "?1", "?2", "?3" };
+  static const char arb_selects[8][7] = { "Fixed", "WRR32", "WRR64", "WRR128", "?4", "?5", "?6", "?7" };
+  static const char vc_arb_selects[8][8] = { "Fixed", "WRR32", "WRR64", "WRR128", "TWRR128", "WRR256", "?6", "?7" };
+
+  printf("Virtual Channel\n");
+  if (verbose < 2)
+    return;
+
+  if (!config_fetch(d, where + 4, 0x1c - 4))
+    return;
+
+  cr1 = get_conf_long(d, where + PCI_VC_PORT_REG1);
+  cr2 = get_conf_long(d, where + PCI_VC_PORT_REG2);
+  ctrl = get_conf_word(d, where + PCI_VC_PORT_CTRL);
+  status = get_conf_word(d, where + PCI_VC_PORT_STATUS);
+
+  evc_cnt = cr1 & 7;
+  printf("\t\tCaps:\tLPEVC=%d RefClk=%s PATEntrySize=%d\n",
+    (cr1 >> 4) & 7,
+    ref_clocks[(cr1 >> 8) & 3],
+    (cr1 >> 10) & 3);
+
+  printf("\t\tArb:\t");
+  for (i=0; i<8; i++)
+    if (arb_selects[i][0] != '?' || cr2 & (1 << i))
+      printf("%s%c ", arb_selects[i], FLAG(cr2, 1 << i));
+  arb_table_pos = (cr2 >> 24) & 0xff;
+  printf("TableOffset=%x\n", arb_table_pos);
+
+  printf("\t\tCtrl:\tArbSelect=%s\n", arb_selects[(ctrl >> 1) & 7]);
+  printf("\t\tStatus:\tInProgress%c\n", FLAG(status, 1));
+
+  if (arb_table_pos)
+    printf("\t\tPort Arbitration Table <?>\n");
+
+  for (i=0; i<=evc_cnt; i++)
+    {
+      int pos = where + PCI_VC_RES_CAP + 12*i;
+      u32 rcap, rctrl;
+      u16 rstatus;
+      int pat_pos;
+
+      if (!config_fetch(d, pos, 12))
+       {
+         printf("VC%d <unreadable>\n", i);
+         continue;
+       }
+      rcap = get_conf_long(d, pos);
+      rctrl = get_conf_long(d, pos+4);
+      rstatus = get_conf_word(d, pos+8);
+
+      pat_pos = (rcap >> 24) & 0xff;
+      printf("\t\tVC%d:\tCaps:\tPATOffset=%02x MaxTimeSlots=%d RejSnoopTrans%c\n",
+       i,
+       pat_pos,
+       ((rcap >> 16) & 0x3f) + 1,
+       FLAG(rcap, 1 << 15));
+
+      printf("\t\t\tArb:");
+      for (j=0; j<8; j++)
+       if (vc_arb_selects[j][0] != '?' || rcap & (1 << j))
+         printf("%c%s%c", (j ? ' ' : '\t'), vc_arb_selects[j], FLAG(rcap, 1 << j));
+
+      printf("\n\t\t\tCtrl:\tEnable%c ID=%d ArbSelect=%s TC/VC=%02x\n",
+       FLAG(rctrl, 1 << 31),
+       (rctrl >> 24) & 7,
+       vc_arb_selects[(rctrl >> 17) & 7],
+       rctrl & 0xff);
+
+      printf("\t\t\tStatus:\tNegoPending%c InProgress%c\n",
+       FLAG(rstatus, 2),
+       FLAG(rstatus, 1));
+
+      if (pat_pos)
+       printf("\t\t\tPort Arbitration Table <?>\n");
+    }
+}
+
 void
 show_ext_caps(struct device *d)
 {
@@ -180,7 +308,7 @@ show_ext_caps(struct device *d)
   do
     {
       u32 header;
-      int id;
+      int id, version;
 
       if (!config_fetch(d, where, 4))
        break;
@@ -188,7 +316,11 @@ show_ext_caps(struct device *d)
       if (!header)
        break;
       id = header & 0xffff;
-      printf("\tCapabilities: [%03x] ", where);
+      version = (header >> 16) & 0xf;
+      printf("\tCapabilities: [%03x", where);
+      if (verbose > 1)
+       printf(" v%d", version);
+      printf("] ");
       if (been_there[where]++)
        {
          printf("<chain looped>\n");
@@ -200,7 +332,8 @@ show_ext_caps(struct device *d)
            cap_aer(d, where);
            break;
          case PCI_EXT_CAP_ID_VC:
-           printf("Virtual Channel <?>\n");
+         case PCI_EXT_CAP_ID_VC2:
+           cap_vc(d, where);
            break;
          case PCI_EXT_CAP_ID_DSN:
            cap_dsn(d, where);
@@ -242,6 +375,6 @@ show_ext_caps(struct device *d)
            printf("#%02x\n", id);
            break;
        }
-      where = header >> 20;
+      where = (header >> 20) & ~3;
     } while (where);
 }