Blame SOURCES/0025-devtree-Add-VPD-info-for-BMC-based-IBM-Power-System.patch

21ef37
From d0791b8831e2eee3e6942dbcbe716021576a72bd Mon Sep 17 00:00:00 2001
21ef37
From: Jack Miller <jack@codezen.org>
21ef37
Date: Thu, 20 Oct 2016 16:43:22 +0530
21ef37
Subject: [PATCH 25/43] devtree: Add VPD info for BMC based IBM Power System
21ef37
21ef37
Power Systems supports various environment and various service
21ef37
processor types (like IBM FSP, industry standard BMC, etc).
21ef37
21ef37
We have processor chip level VPD (part number, serial number etc)
21ef37
and all cores under chip shares this information.
21ef37
21ef37
BMC based Power Systems provides chip VPD information under xscom
21ef37
node. This patch adds support for adding VPD information for CPU
21ef37
nodes on BMC based system.
21ef37
21ef37
Sample output:
21ef37
     *-cpu:0
21ef37
         description: POWER8 (raw), altivec supported
21ef37
         product: 00UM003
21ef37
         vendor: PROCESSOR
21ef37
         physical id: 16
21ef37
         bus info: cpu@0
21ef37
         version: 2.0 (pvr 004d 0200)
21ef37
         serial: YA1932579651
21ef37
         size: 2061MHz
21ef37
         capacity: 3491MHz
21ef37
         capabilities: performance-monitor cpufreq
21ef37
         configuration: threads=8
21ef37
21ef37
Signed-off-by: Jack Miller <jack@codezen.org>
21ef37
[Reorganized code, updated description - Vasant]
21ef37
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
21ef37
---
21ef37
 src/core/device-tree.cc | 58 +++++++++++++++++++++++++++++++++++++++++++++++--
21ef37
 1 file changed, 56 insertions(+), 2 deletions(-)
21ef37
21ef37
diff --git a/src/core/device-tree.cc b/src/core/device-tree.cc
21ef37
index 16406fd..d61347b 100644
21ef37
--- a/src/core/device-tree.cc
21ef37
+++ b/src/core/device-tree.cc
21ef37
@@ -443,16 +443,19 @@ static void scan_chip_vpd(map <uint32_t, chip_vpd_data *> & vpd)
21ef37
 
21ef37
 
21ef37
 static void fill_core_vpd(hwNode & cpu, string & basepath,
21ef37
-			  map <uint32_t, chip_vpd_data *> & chip_vpd)
21ef37
+			  map <uint32_t, chip_vpd_data *> & chip_vpd,
21ef37
+			  map <uint32_t, string> & xscoms)
21ef37
 {
21ef37
   uint32_t chip_id;
21ef37
   chip_vpd_data *data;
21ef37
+  string xscom_path;
21ef37
 
21ef37
   if (!exists(basepath + "/ibm,chip-id"))
21ef37
     return;
21ef37
 
21ef37
   chip_id = get_u32(basepath + "/ibm,chip-id");
21ef37
   data = chip_vpd[chip_id];
21ef37
+  xscom_path = xscoms[chip_id];
21ef37
 
21ef37
   if (data)
21ef37
   {
21ef37
@@ -460,6 +463,25 @@ static void fill_core_vpd(hwNode & cpu, string & basepath,
21ef37
     cpu.setSerial(data->serial);
21ef37
     cpu.setSlot(data->slot);
21ef37
   }
21ef37
+
21ef37
+  if (xscom_path != "")
21ef37
+  {
21ef37
+    vector <string> board_pieces;
21ef37
+
21ef37
+    splitlines(hw::strip(get_string(xscom_path + "/board-info")),
21ef37
+	       board_pieces, ' ');
21ef37
+    if (board_pieces.size() > 0)
21ef37
+      cpu.setVendor(board_pieces[0]);
21ef37
+
21ef37
+    if (exists(xscom_path + "/serial-number"))
21ef37
+      cpu.setSerial(hw::strip(get_string(xscom_path + "/serial-number")));
21ef37
+
21ef37
+    if (exists(xscom_path + "/ibm,slot-location-code"))
21ef37
+      cpu.setSlot(hw::strip(get_string(xscom_path + "/ibm,slot-location-code")));
21ef37
+
21ef37
+    if (exists(xscom_path + "/part-number"))
21ef37
+      cpu.setProduct(hw::strip(get_string(xscom_path + "/part-number")));
21ef37
+  }
21ef37
 }
21ef37
 
21ef37
 static void set_cpu_config_threads(hwNode & cpu, const string & basepath)
21ef37
@@ -488,6 +510,34 @@ static void set_cpu_config_threads(hwNode & cpu, const string & basepath)
21ef37
 }
21ef37
 
21ef37
 
21ef37
+static void scan_xscom_node(map <uint32_t, string> & xscoms)
21ef37
+{
21ef37
+  int n;
21ef37
+  struct dirent **namelist;
21ef37
+
21ef37
+  pushd(DEVICETREE);
21ef37
+  n = scandir(".", &namelist, selectdir, alphasort);
21ef37
+  popd();
21ef37
+
21ef37
+  if (n <= 0)
21ef37
+    return;
21ef37
+
21ef37
+  for (int i = 0; i < n; i++) {
21ef37
+    string sname = string(namelist[i]->d_name);
21ef37
+    string fullpath = "";
21ef37
+    int chip_id = 0;
21ef37
+
21ef37
+    if (sname.substr(0,5) == "xscom") {
21ef37
+      fullpath = string(DEVICETREE) + "/" + sname;
21ef37
+      chip_id = get_u32(fullpath + "/ibm,chip-id");
21ef37
+      xscoms.insert(std::pair<uint32_t, string>(chip_id, fullpath));
21ef37
+    }
21ef37
+
21ef37
+    free(namelist[i]);
21ef37
+  }
21ef37
+  free(namelist);
21ef37
+}
21ef37
+
21ef37
 static void scan_devtree_cpu_power(hwNode & core)
21ef37
 {
21ef37
   int n;
21ef37
@@ -496,6 +546,7 @@ static void scan_devtree_cpu_power(hwNode & core)
21ef37
   map <uint32_t, pair<uint32_t, vector <hwNode> > > l2_caches;
21ef37
   map <uint32_t, vector <hwNode> > l3_caches;
21ef37
   map <uint32_t, chip_vpd_data *> chip_vpd;
21ef37
+  map <uint32_t, string> xscoms;
21ef37
 
21ef37
   pushd(DEVICETREE "/cpus");
21ef37
   n = scandir(".", &namelist, selectdir, alphasort);
21ef37
@@ -578,6 +629,9 @@ static void scan_devtree_cpu_power(hwNode & core)
21ef37
    */
21ef37
   scan_chip_vpd(chip_vpd);
21ef37
 
21ef37
+  // List all xscom nodes under DT
21ef37
+  scan_xscom_node(xscoms);
21ef37
+
21ef37
   for (int i = 0; i < n; i++) //second and final pass
21ef37
   {
21ef37
     uint32_t l2_key = 0;
21ef37
@@ -608,7 +662,7 @@ static void scan_devtree_cpu_power(hwNode & core)
21ef37
     if (version != 0)
21ef37
       cpu.setVersion(tostring(version));
21ef37
 
21ef37
-    fill_core_vpd(cpu, basepath, chip_vpd);
21ef37
+    fill_core_vpd(cpu, basepath, chip_vpd, xscoms);
21ef37
 
21ef37
     if (hw::strip(get_string(basepath + "/status")) != "okay")
21ef37
       cpu.disable();
21ef37
-- 
21ef37
2.10.2
21ef37