phosphor-health-monitor: add new D-Bus interface

This commit introduces following changes -
- A new Metrics Value Interface.
- An interface to reset the metrics, if needed.
- Common Threshold interface so it can be used in Metrics and Sensors.

For more detail, please refer to design -
https://gerrit.openbmc.org/c/openbmc/docs/+/64917

Unit Test: meson build passes.

Change-Id: I014a047f9db6fe470124baa41dcce93caf7ceb4b
Signed-off-by: Jagpal Singh Gill <paligill@gmail.com>
diff --git a/gen/xyz/openbmc_project/Common/Threshold/meson.build b/gen/xyz/openbmc_project/Common/Threshold/meson.build
new file mode 100644
index 0000000..0bf3482
--- /dev/null
+++ b/gen/xyz/openbmc_project/Common/Threshold/meson.build
@@ -0,0 +1,15 @@
+# Generated file; do not modify.
+generated_sources += custom_target(
+    'xyz/openbmc_project/Common/Threshold__cpp'.underscorify(),
+    input: [ '../../../../../yaml/xyz/openbmc_project/Common/Threshold.interface.yaml',  ],
+    output: [ 'common.hpp', 'server.cpp', 'server.hpp', 'aserver.hpp', 'client.hpp',  ],
+    depend_files: sdbusplusplus_depfiles,
+    command: [
+        sdbuspp_gen_meson_prog, '--command', 'cpp',
+        '--output', meson.current_build_dir(),
+        '--tool', sdbusplusplus_prog,
+        '--directory', meson.current_source_dir() / '../../../../../yaml',
+        'xyz/openbmc_project/Common/Threshold',
+    ],
+)
+
diff --git a/gen/xyz/openbmc_project/Common/meson.build b/gen/xyz/openbmc_project/Common/meson.build
index 7004139..95ff8d4 100644
--- a/gen/xyz/openbmc_project/Common/meson.build
+++ b/gen/xyz/openbmc_project/Common/meson.build
@@ -163,6 +163,21 @@
     ],
 )
 
+subdir('Threshold')
+generated_others += custom_target(
+    'xyz/openbmc_project/Common/Threshold__markdown'.underscorify(),
+    input: [ '../../../../yaml/xyz/openbmc_project/Common/Threshold.interface.yaml',  ],
+    output: [ 'Threshold.md' ],
+    depend_files: sdbusplusplus_depfiles,
+    command: [
+        sdbuspp_gen_meson_prog, '--command', 'markdown',
+        '--output', meson.current_build_dir(),
+        '--tool', sdbusplusplus_prog,
+        '--directory', meson.current_source_dir() / '../../../../yaml',
+        'xyz/openbmc_project/Common/Threshold',
+    ],
+)
+
 subdir('UUID')
 generated_others += custom_target(
     'xyz/openbmc_project/Common/UUID__markdown'.underscorify(),
diff --git a/gen/xyz/openbmc_project/Metrics/Value/meson.build b/gen/xyz/openbmc_project/Metrics/Value/meson.build
new file mode 100644
index 0000000..f22b1f2
--- /dev/null
+++ b/gen/xyz/openbmc_project/Metrics/Value/meson.build
@@ -0,0 +1,15 @@
+# Generated file; do not modify.
+generated_sources += custom_target(
+    'xyz/openbmc_project/Metrics/Value__cpp'.underscorify(),
+    input: [ '../../../../../yaml/xyz/openbmc_project/Metrics/Value.interface.yaml',  ],
+    output: [ 'common.hpp', 'server.cpp', 'server.hpp', 'aserver.hpp', 'client.hpp',  ],
+    depend_files: sdbusplusplus_depfiles,
+    command: [
+        sdbuspp_gen_meson_prog, '--command', 'cpp',
+        '--output', meson.current_build_dir(),
+        '--tool', sdbusplusplus_prog,
+        '--directory', meson.current_source_dir() / '../../../../../yaml',
+        'xyz/openbmc_project/Metrics/Value',
+    ],
+)
+
diff --git a/gen/xyz/openbmc_project/Metrics/meson.build b/gen/xyz/openbmc_project/Metrics/meson.build
new file mode 100644
index 0000000..1dd738e
--- /dev/null
+++ b/gen/xyz/openbmc_project/Metrics/meson.build
@@ -0,0 +1,16 @@
+# Generated file; do not modify.
+subdir('Value')
+generated_others += custom_target(
+    'xyz/openbmc_project/Metrics/Value__markdown'.underscorify(),
+    input: [ '../../../../yaml/xyz/openbmc_project/Metrics/Value.interface.yaml',  ],
+    output: [ 'Value.md' ],
+    depend_files: sdbusplusplus_depfiles,
+    command: [
+        sdbuspp_gen_meson_prog, '--command', 'markdown',
+        '--output', meson.current_build_dir(),
+        '--tool', sdbusplusplus_prog,
+        '--directory', meson.current_source_dir() / '../../../../yaml',
+        'xyz/openbmc_project/Metrics/Value',
+    ],
+)
+
diff --git a/gen/xyz/openbmc_project/meson.build b/gen/xyz/openbmc_project/meson.build
index f03b941..573a389 100644
--- a/gen/xyz/openbmc_project/meson.build
+++ b/gen/xyz/openbmc_project/meson.build
@@ -88,6 +88,7 @@
 subdir('Logging')
 subdir('MCTP')
 subdir('Memory')
+subdir('Metrics')
 subdir('Network')
 subdir('Nvme')
 subdir('Object')
diff --git a/yaml/xyz/openbmc_project/Common/Threshold.interface.yaml b/yaml/xyz/openbmc_project/Common/Threshold.interface.yaml
new file mode 100644
index 0000000..2186fa8
--- /dev/null
+++ b/yaml/xyz/openbmc_project/Common/Threshold.interface.yaml
@@ -0,0 +1,76 @@
+description: >
+    Provides threshold functionality for Metrics and Sensors. Any object
+    implementing Threshold interface must implement a Value interface at
+    corresponding path.
+
+properties:
+    - name: Value
+      type: dict[struct[enum[self.Type],enum[self.Bound]],double]
+      description: >
+          This indicates the threshold ranges applicable for the corresponding
+          Value interface. This property is experimental and may change based on
+          implementation.
+          map{struct{thresholdType,thresholdBound},thresholdValue}
+      flags:
+          - readonly
+    - name: Asserted
+      type: set[struct[enum[self.Type],enum[self.Bound]]]
+      description: >
+          This indicates the set of asserted thresholds.
+          set{struct{thresholdType,thresholdBound}}
+      flags:
+          - readonly
+
+signals:
+    - name: AssertionChanged
+      description: >
+          This indicates the assertion change for a threshold.
+      properties:
+          - name: ThresholdType
+            type: enum[self.Type]
+            description: >
+                This indicates the threshold type for the assertion.
+          - name: ThresholdBound
+            type: enum[self.Bound]
+            description: >
+                This indicates the threshold bound for the assertion.
+          - name: Status
+            type: boolean
+            description: >
+                This indicates whether the assertion has been asserted(true) or
+                deasserted(false).
+          - name: Value
+            type: double
+            description: >
+                The value that triggered the assertion change.
+
+enumerations:
+    - name: Type
+      description: >
+          This indicates the type of threshold.
+      values:
+          - name: Warning
+            description: >
+                Indicates the warning level.
+          - name: Critical
+            description: >
+                Indicates the critical level.
+          - name: PerformanceLoss
+            description: >
+                Indicates the performance loss level.
+          - name: SoftShutdown
+            description: >
+                Indicates the soft shutdown level.
+          - name: HardShutdown
+            description: >
+                Indicates the hard shutdown level.
+    - name: Bound
+      description: >
+          This indicates the threshold direction.
+      values:
+          - name: Upper
+            description: >
+                Indicates the upper bound of the threshold.
+          - name: Lower
+            description: >
+                Indicates the lower bound of the threshold.
diff --git a/yaml/xyz/openbmc_project/Inventory/Item.interface.yaml b/yaml/xyz/openbmc_project/Inventory/Item.interface.yaml
index 4ef840b..78cf994 100644
--- a/yaml/xyz/openbmc_project/Inventory/Item.interface.yaml
+++ b/yaml/xyz/openbmc_project/Inventory/Item.interface.yaml
@@ -71,3 +71,10 @@
       reverse_name: powering
       required_endpoint_interfaces:
           - xyz.openbmc_project.Inventory.Item.PowerSupply
+    - name: measured_by
+      description: >
+          Objects that implement Item can optionally implement the 'measured_by'
+          association to provide a link to one or more metrics.
+      reverse_name: measuring
+      required_endpoint_interfaces:
+          - xyz.openbmc_project.Metrics
diff --git a/yaml/xyz/openbmc_project/Metrics/Value.interface.yaml b/yaml/xyz/openbmc_project/Metrics/Value.interface.yaml
new file mode 100644
index 0000000..e0d6441
--- /dev/null
+++ b/yaml/xyz/openbmc_project/Metrics/Value.interface.yaml
@@ -0,0 +1,57 @@
+description: >
+    This interface provides the Board Manager Metric values for resource
+    utilization.
+
+properties:
+    - name: Value
+      type: double
+      description: >
+          The current metric value.
+      flags:
+          - readonly
+    - name: MaxValue
+      type: double
+      default: infinity
+      flags:
+          - readonly
+      description: >
+          The maximum supported metric value.
+    - name: MinValue
+      type: double
+      default: -infinity
+      flags:
+          - readonly
+      description: >
+          The minimum supported metric value.
+    - name: Unit
+      type: enum[self.Unit]
+      description: >
+          The unit for metric value. For example, memory in bytes, CPU in
+          percent, reboots in count.
+      flags:
+          - const
+
+enumerations:
+    - name: Unit
+      description: >
+          Metric value unit.
+      values:
+          - name: Bytes
+            description: >
+                Unit to indicate bytes.
+          - name: Count
+            description: >
+                Unit to indicate counts.
+          - name: Percent
+            description: >
+                Unit to indicate percentage.
+
+associations:
+    - name: measuring
+      description: >
+          Metrics measure the inventory item's resource utilization, therefore
+          implement an association to the inventory item.
+      reverse_names:
+          - measured_by
+      required_endpoint_interfaces:
+          - xyz.openbmc_project.Inventory.Item