metrics-ipmi-blobs: Support ECC Error Counts

Export the ECC Error Cournter from
http://github.com/openbmc/phosphor-ecc to ipmi blob.

Tested:
The blob output is updated if MemoryECC dbus object exists compared to
the blob output if MemoryECC doesn't exists.

Change-Id: I2c63dbcd0970afc587f5c2ee01f8c261909f0b08
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/subprojects/metrics-ipmi-blobs/metric.cpp b/subprojects/metrics-ipmi-blobs/metric.cpp
index 4b21347..59954c4 100644
--- a/subprojects/metrics-ipmi-blobs/metric.cpp
+++ b/subprojects/metrics-ipmi-blobs/metric.cpp
@@ -314,6 +314,20 @@
     };
 }
 
+static bmcmetrics_metricproto_BmcECCMetric getECCMetric(bool& use) noexcept
+{
+    EccCounts eccCounts;
+    use = getECCErrorCounts(eccCounts);
+    if (!use)
+    {
+        return {};
+    }
+    return bmcmetrics_metricproto_BmcECCMetric{
+        .correctable_error_count = eccCounts.correctableErrCount,
+        .uncorrectable_error_count = eccCounts.uncorrectableErrCount,
+    };
+}
+
 static bmcmetrics_metricproto_BmcMemoryMetric getMemMetric() noexcept
 {
     bmcmetrics_metricproto_BmcMemoryMetric ret = {};
@@ -460,6 +474,8 @@
         .has_fdstat_metric = false,
         .fdstat_metric = getFdStatMetric(*this, ticksPerSec, fds,
                                          snapshot.has_fdstat_metric),
+        .has_ecc_metric = false,
+        .ecc_metric = getECCMetric(snapshot.has_ecc_metric),
     };
     pb_ostream_t nost = {};
     if (!pb_encode(&nost, bmcmetrics_metricproto_BmcMetricSnapshot_fields,