diff mbox series

[3/3] rasdaemon: ras-mc-ctl: Add support for HiSilicon KunPeng9xx common errors

Message ID 20201204101338.1060-4-shiju.jose@huawei.com (mailing list archive)
State New, archived
Headers show
Series rasdaemon: ras-mc-ctl: Support vendor-specific error events | expand

Commit Message

Shiju Jose Dec. 4, 2020, 10:13 a.m. UTC
Add support for the HiSilicon KunPeng9xx platforms common errors.

Signed-off-by: Shiju Jose <shiju.jose@huawei.com>
Reviewed-by: Xiaofei Tan <tanxiaofei@huawei.com>
---
 util/ras-mc-ctl.in | 52 ++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 50 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/util/ras-mc-ctl.in b/util/ras-mc-ctl.in
index 711e4b0..0885de1 100755
--- a/util/ras-mc-ctl.in
+++ b/util/ras-mc-ctl.in
@@ -1555,6 +1555,7 @@  sub errors
 # Definitions of the vendor platform IDs.
 use constant {
     HISILICON_KUNPENG_920 => "KunPeng920",
+    HISILICON_KUNPENG_9XX => "KunPeng9xx",
 };
 
 sub vendor_errors_summary
@@ -1562,7 +1563,7 @@  sub vendor_errors_summary
     require DBI;
     my ($num_args, $platform_id);
     my ($query, $query_handle, $count, $out);
-    my ($module_id, $sub_module_id, $err_severity, $err_sev);
+    my ($module_id, $sub_module_id, $err_severity, $err_sev, $err_info);
 
     $num_args = $#ARGV + 1;
     $platform_id = 0;
@@ -1651,6 +1652,28 @@  sub vendor_errors_summary
         };
     }
 
+    # HiSilicon KunPeng9xx common errors
+    if ($platform_id eq HISILICON_KUNPENG_9XX) {
+        try {
+            $query = "select err_info, count(*) from hisi_common_section";
+            $query_handle = $dbh->prepare($query);
+            $query_handle->execute();
+            $query_handle->bind_columns(\($err_info, $count));
+            $out = "";
+            while($query_handle->fetch()) {
+                $out .= "\terrors: $count\n";
+            }
+            if ($out ne "") {
+                print "HiSilicon KunPeng9xx common error events summary:\n$out\n";
+            } else {
+                print "No HiSilicon KunPeng9xx common errors.\n\n";
+            }
+            $query_handle->finish;
+        } catch {
+            print "Exception: $DBI::errstr\n\n";
+        };
+    }
+
     undef($dbh);
 }
 
@@ -1660,7 +1683,7 @@  sub vendor_errors
     my ($num_args, $platform_id);
     my ($query, $query_handle, $id, $timestamp, $out);
     my ($version, $soc_id, $socket_id, $nimbus_id, $core_id, $port_id);
-    my ($module_id, $sub_module_id, $err_severity, $err_type, $regs);
+    my ($module_id, $sub_module_id, $err_severity, $err_type, $err_info, $regs);
 
     $num_args = $#ARGV + 1;
     $platform_id = 0;
@@ -1760,6 +1783,30 @@  sub vendor_errors
         };
     }
 
+    # HiSilicon KunPeng9xx common errors
+    if ($platform_id eq HISILICON_KUNPENG_9XX) {
+        try {
+            $query = "select id, timestamp, err_info, regs_dump from hisi_common_section order by id";
+            $query_handle = $dbh->prepare($query);
+            $query_handle->execute();
+            $query_handle->bind_columns(\($id, $timestamp, $err_info, $regs));
+            $out = "";
+            while($query_handle->fetch()) {
+                $out .= "$id. $timestamp ";
+                $out .= "Error Info:$err_info \n" if ($err_info);
+                $out .= "Error Registers: $regs\n\n" if ($regs);
+            }
+            if ($out ne "") {
+                print "HiSilicon KunPeng9xx common error events:\n$out\n";
+            } else {
+                print "No HiSilicon KunPeng9xx common errors.\n";
+            }
+            $query_handle->finish;
+        } catch {
+            print "Exception: $DBI::errstr\n\n";
+        };
+    }
+
     undef($dbh);
 }
 
@@ -1767,6 +1814,7 @@  sub vendor_platforms
 {
         print "\nSupported platforms for the vendor-specific errors:\n";
         print "\tHiSilicon KunPeng920, platform-id=\"", HISILICON_KUNPENG_920, "\"\n";
+        print "\tHiSilicon KunPeng9xx, platform-id=\"", HISILICON_KUNPENG_9XX, "\"\n";
         print "\n";
 }