]> mj.ucw.cz Git - pciutils.git/blobdiff - ls-ecaps.c
CXL3.0: Add DVSEC CXLCtrl3 and missing CXLCtl2
[pciutils.git] / ls-ecaps.c
index a9d8470b6d95b557f7540e549677809a2f3e3e1a..f58a5ff6127914b4dcaf845aefd75f917f45a04b 100644 (file)
@@ -701,7 +701,7 @@ cxl_range(u64 base, u64 size, int n)
 
   size &= ~0x0fffffffULL;
 
-  printf("\t\tRange%d: %016"PCI_U64_FMT_X"-%016"PCI_U64_FMT_X"\n", n, base, base + size - 1);
+  printf("\t\tRange%d: %016"PCI_U64_FMT_X"-%016"PCI_U64_FMT_X" [size=0x%"PCI_U64_FMT_X"]\n", n, base, base + size - 1, size);
   printf("\t\t\tValid%c Active%c Type=%s Class=%s interleave=%d timeout=%ds\n",
     FLAG(w, PCI_CXL_RANGE_VALID), FLAG(w, PCI_CXL_RANGE_ACTIVE),
     type[PCI_CXL_RANGE_TYPE(w)], class[PCI_CXL_RANGE_CLASS(w)],
@@ -716,61 +716,90 @@ dvsec_cxl_device(struct device *d, int rev, int where, int len)
   u64 range_base, range_size;
   u16 w;
 
-  if (len < PCI_CXL_DEV_LEN)
+  if (len < 0x38)
     return;
 
   /* Legacy 1.1 revs aren't handled */
-  if (rev < 1)
+  if (rev == 0)
     return;
 
-  w = get_conf_word(d, where + PCI_CXL_DEV_CAP);
-  printf("\t\tCXLCap:\tCache%c IO%c Mem%c Mem HW Init%c HDMCount %d Viral%c\n",
-    FLAG(w, PCI_CXL_DEV_CAP_CACHE), FLAG(w, PCI_CXL_DEV_CAP_IO), FLAG(w, PCI_CXL_DEV_CAP_MEM),
-    FLAG(w, PCI_CXL_DEV_CAP_MEM_HWINIT), PCI_CXL_DEV_CAP_HDM_CNT(w), FLAG(w, PCI_CXL_DEV_CAP_VIRAL));
-
-  w = get_conf_word(d, where + PCI_CXL_DEV_CTRL);
-  printf("\t\tCXLCtl:\tCache%c IO%c Mem%c Cache SF Cov %d Cache SF Gran %d Cache Clean%c Viral%c\n",
-    FLAG(w, PCI_CXL_DEV_CTRL_CACHE), FLAG(w, PCI_CXL_DEV_CTRL_IO), FLAG(w, PCI_CXL_DEV_CTRL_MEM),
-    PCI_CXL_DEV_CTRL_CACHE_SF_COV(w), PCI_CXL_DEV_CTRL_CACHE_SF_GRAN(w), FLAG(w, PCI_CXL_DEV_CTRL_CACHE_CLN),
-    FLAG(w, PCI_CXL_DEV_CTRL_VIRAL));
+  if (rev >= 1) {
+    w = get_conf_word(d, where + PCI_CXL_DEV_CAP);
+    printf("\t\tCXLCap:\tCache%c IO%c Mem%c MemHWInit%c HDMCount %d Viral%c\n",
+      FLAG(w, PCI_CXL_DEV_CAP_CACHE), FLAG(w, PCI_CXL_DEV_CAP_IO), FLAG(w, PCI_CXL_DEV_CAP_MEM),
+      FLAG(w, PCI_CXL_DEV_CAP_MEM_HWINIT), PCI_CXL_DEV_CAP_HDM_CNT(w), FLAG(w, PCI_CXL_DEV_CAP_VIRAL));
+
+    w = get_conf_word(d, where + PCI_CXL_DEV_CTRL);
+    printf("\t\tCXLCtl:\tCache%c IO%c Mem%c CacheSFCov %d CacheSFGran %d CacheClean%c Viral%c\n",
+      FLAG(w, PCI_CXL_DEV_CTRL_CACHE), FLAG(w, PCI_CXL_DEV_CTRL_IO), FLAG(w, PCI_CXL_DEV_CTRL_MEM),
+      PCI_CXL_DEV_CTRL_CACHE_SF_COV(w), PCI_CXL_DEV_CTRL_CACHE_SF_GRAN(w), FLAG(w, PCI_CXL_DEV_CTRL_CACHE_CLN),
+      FLAG(w, PCI_CXL_DEV_CTRL_VIRAL));
+
+    w = get_conf_word(d, where + PCI_CXL_DEV_STATUS);
+    printf("\t\tCXLSta:\tViral%c\n", FLAG(w, PCI_CXL_DEV_STATUS_VIRAL));
+
+    w = get_conf_word(d, where + PCI_CXL_DEV_CTRL2);
+    printf("\t\tCXLCtl2:\tDisableCaching%c InitCacheWB&Inval%c InitRst%c RstMemClrEn%c",
+      FLAG(w, PCI_CXL_DEV_CTRL2_DISABLE_CACHING),
+      FLAG(w, PCI_CXL_DEV_CTRL2_INIT_WB_INVAL),
+      FLAG(w, PCI_CXL_DEV_CTRL2_INIT_CXL_RST),
+      FLAG(w, PCI_CXL_DEV_CTRL2_INIT_CXL_RST_CLR_EN));
+    if (rev >= 2) {
+      printf(" DesiredVolatileHDMStateAfterHotReset%c", FLAG(w, PCI_CXL_DEV_CTRL2_INIT_CXL_HDM_STATE_HOTRST));
+    }
+    printf("\n");
+
+    w = get_conf_word(d, where + PCI_CXL_DEV_STATUS2);
+    printf("\t\tCXLSta2:\tResetComplete%c ResetError%c PMComplete%c\n",
+      FLAG(w, PCI_CXL_DEV_STATUS_RC), FLAG(w,PCI_CXL_DEV_STATUS_RE), FLAG(w, PCI_CXL_DEV_STATUS_PMC));
+
+    w = get_conf_word(d, where + PCI_CXL_DEV_CAP2);
+    printf("\t\tCXLCap2:\t");
+    cache_unit_size = BITS(w, 0, 4);
+    cache_size = BITS(w, 8, 8);
+    switch (cache_unit_size)
+      {
+        case PCI_CXL_DEV_CAP2_CACHE_1M:
+          printf("Cache Size: %08x\n", cache_size * (1<<20));
+    break;
+        case PCI_CXL_DEV_CAP2_CACHE_64K:
+          printf("Cache Size: %08x\n", cache_size * (64<<10));
+    break;
+        case PCI_CXL_DEV_CAP2_CACHE_UNK:
+          printf("Cache Size Not Reported\n");
+    break;
+        default:
+          printf("Cache Size: %d of unknown unit size (%d)\n", cache_size, cache_unit_size);
+    break;
+      }
 
-  w = get_conf_word(d, where + PCI_CXL_DEV_STATUS);
-  printf("\t\tCXLSta:\tViral%c\n", FLAG(w, PCI_CXL_DEV_STATUS_VIRAL));
+    range_size = (u64) get_conf_long(d, where + PCI_CXL_DEV_RANGE1_SIZE_HI) << 32;
+    range_size |= get_conf_long(d, where + PCI_CXL_DEV_RANGE1_SIZE_LO);
+    range_base = (u64) get_conf_long(d, where + PCI_CXL_DEV_RANGE1_BASE_HI) << 32;
+    range_base |= get_conf_long(d, where + PCI_CXL_DEV_RANGE1_BASE_LO);
+    cxl_range(range_base, range_size, 1);
+
+    range_size = (u64) get_conf_long(d, where + PCI_CXL_DEV_RANGE2_SIZE_HI) << 32;
+    range_size |= get_conf_long(d, where + PCI_CXL_DEV_RANGE2_SIZE_LO);
+    range_base = (u64) get_conf_long(d, where + PCI_CXL_DEV_RANGE2_BASE_HI) << 32;
+    range_base |= get_conf_long(d, where + PCI_CXL_DEV_RANGE2_BASE_LO);
+    cxl_range(range_base, range_size, 2);
+  }
 
-  w = get_conf_word(d, where + PCI_CXL_DEV_STATUS2);
-  printf("\t\tCXLSta2:\tResetComplete%c ResetError%c PMComplete%c\n",
-    FLAG(w, PCI_CXL_DEV_STATUS_RC), FLAG(w,PCI_CXL_DEV_STATUS_RE), FLAG(w, PCI_CXL_DEV_STATUS_PMC));
+  if (rev >= 2) {
+    w = get_conf_word(d, where + PCI_CXL_DEV_CAP3);
+    printf("\t\tCXLCap3:\tDefaultVolatile HDM State After:\tColdReset%c WarmReset%c HotReset%c HotResetConfigurability%c\n",
+      FLAG(w, PCI_CXL_DEV_CAP3_HDM_STATE_RST_COLD),
+      FLAG(w, PCI_CXL_DEV_CAP3_HDM_STATE_RST_WARM),
+      FLAG(w, PCI_CXL_DEV_CAP3_HDM_STATE_RST_HOT),
+      FLAG(w, PCI_CXL_DEV_CAP3_HDM_STATE_RST_HOT_CFG));
+  }
 
-  w = get_conf_word(d, where + PCI_CXL_DEV_CAP2);
-  cache_unit_size = BITS(w, 0, 4);
-  cache_size = BITS(w, 8, 8);
-  switch (cache_unit_size)
-    {
-      case PCI_CXL_DEV_CAP2_CACHE_1M:
-        printf("\t\tCache Size: %08x\n", cache_size * (1<<20));
-       break;
-      case PCI_CXL_DEV_CAP2_CACHE_64K:
-        printf("\t\tCache Size: %08x\n", cache_size * (64<<10));
-       break;
-      case PCI_CXL_DEV_CAP2_CACHE_UNK:
-        printf("\t\tCache Size Not Reported\n");
-       break;
-      default:
-        printf("\t\tCache Size: %d of unknown unit size (%d)\n", cache_size, cache_unit_size);
-       break;
-    }
+  // Unparsed data
+  if (len > PCI_CXL_DEV_LEN) {
+    printf("\t\t<?>\n");
+  }
 
-  range_size = (u64) get_conf_long(d, where + PCI_CXL_DEV_RANGE1_SIZE_HI) << 32;
-  range_size |= get_conf_long(d, where + PCI_CXL_DEV_RANGE1_SIZE_LO);
-  range_base = (u64) get_conf_long(d, where + PCI_CXL_DEV_RANGE1_BASE_HI) << 32;
-  range_base |= get_conf_long(d, where + PCI_CXL_DEV_RANGE1_BASE_LO);
-  cxl_range(range_base, range_size, 1);
-
-  range_size = (u64) get_conf_long(d, where + PCI_CXL_DEV_RANGE2_SIZE_HI) << 32;
-  range_size |= get_conf_long(d, where + PCI_CXL_DEV_RANGE2_SIZE_LO);
-  range_base = (u64) get_conf_long(d, where + PCI_CXL_DEV_RANGE2_BASE_HI) << 32;
-  range_base |= get_conf_long(d, where + PCI_CXL_DEV_RANGE2_BASE_LO);
-  cxl_range(range_base, range_size, 2);
 }
 
 static void