State: Add BMC redundancy interface

Define an interface in support of redundant BMC functionality as
mentioned in the design doc
https://gerrit.openbmc.org/c/openbmc/docs/+/70233.  To start with, it
defines the Role and RedundancyEnabled properties.

With this usage one BMC is considered the active BMC, and the other is
the passive.  There will be a new application running on each BMC that
hosts this interface.

This implementation is not related to the one that uses the
xyz.openbmc_project.State.BMCRedundancy interface, of which there
doesn't appear to be any upstream uses of.

Change-Id: I6415175bbee03f6c07b14e1db1ee0082bd1724ed
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/gen/xyz/openbmc_project/State/BMC/Redundancy/meson.build b/gen/xyz/openbmc_project/State/BMC/Redundancy/meson.build
new file mode 100644
index 0000000..2c43c99
--- /dev/null
+++ b/gen/xyz/openbmc_project/State/BMC/Redundancy/meson.build
@@ -0,0 +1,35 @@
+# Generated file; do not modify.
+
+sdbusplus_current_path = 'xyz/openbmc_project/State/BMC/Redundancy'
+
+generated_sources += custom_target(
+    'xyz/openbmc_project/State/BMC/Redundancy__cpp'.underscorify(),
+    input: [
+        '../../../../../../yaml/xyz/openbmc_project/State/BMC/Redundancy.interface.yaml',
+    ],
+    output: [
+        'common.hpp',
+        'server.hpp',
+        'server.cpp',
+        '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/State/BMC/Redundancy',
+    ],
+    install: should_generate_cpp,
+    install_dir: [
+        get_option('includedir') / sdbusplus_current_path,
+        get_option('includedir') / sdbusplus_current_path,
+        false,
+        get_option('includedir') / sdbusplus_current_path,
+        get_option('includedir') / sdbusplus_current_path,
+    ],
+    build_by_default: should_generate_cpp,
+)
+
diff --git a/gen/xyz/openbmc_project/State/BMC/meson.build b/gen/xyz/openbmc_project/State/BMC/meson.build
index 16823d9..c19c9e5 100644
--- a/gen/xyz/openbmc_project/State/BMC/meson.build
+++ b/gen/xyz/openbmc_project/State/BMC/meson.build
@@ -1,4 +1,5 @@
 # Generated file; do not modify.
+subdir('Redundancy')
 
 sdbusplus_current_path = 'xyz/openbmc_project/State/BMC'
 
@@ -43,3 +44,20 @@
     build_by_default: should_generate_cpp,
 )
 
+generated_markdown += custom_target(
+    'xyz/openbmc_project/State/BMC/Redundancy__markdown'.underscorify(),
+    input: [ '../../../../../yaml/xyz/openbmc_project/State/BMC/Redundancy.interface.yaml',  ],
+    output: [ 'Redundancy.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/State/BMC/Redundancy',
+    ],
+    install: should_generate_markdown,
+    install_dir: [inst_markdown_dir / sdbusplus_current_path],
+    build_by_default: should_generate_markdown,
+)
+
diff --git a/yaml/xyz/openbmc_project/State/BMC/Redundancy.interface.yaml b/yaml/xyz/openbmc_project/State/BMC/Redundancy.interface.yaml
new file mode 100644
index 0000000..a9d8b85
--- /dev/null
+++ b/yaml/xyz/openbmc_project/State/BMC/Redundancy.interface.yaml
@@ -0,0 +1,83 @@
+description: >
+    This interface holds redundant BMC related information.  There would be
+    instance of this interface on each BMC.
+
+properties:
+    - name: Role
+      type: enum[self.Role]
+      flags:
+          - readonly
+      default: Unknown
+      description: >
+          The redundancy role of the BMC.
+    - name: RedundancyEnabled
+      type: boolean
+      flags:
+          - readonly
+      default: false
+      description: >
+          If redundancy is currently enabled.  In general, this means that the
+          BMCs are configured as active and passive and that the passive is able
+          to be failed over to.
+    - name: DisableRedundancyOverride
+      type: boolean
+      default: false
+      errors:
+          - xyz.openbmc_project.Common.Error.Unavailable
+      description: >
+          This is used to immediately and persistently disable redundancy.  The
+          use case is there are test phases where redundancy is not wanted and
+          this is how that is accomplished.
+
+          If set back to true, redundancy will immediately be re-enabled,
+          assuming nothing else is preventing it.
+
+          This can only be changed on the active BMC and when power is off,
+          otherwise it will throw the Unavailable error.
+    - name: FailoversPaused
+      type: boolean
+      flags:
+          - readonly
+      default: false
+      description: >
+          When redundancy is enabled, there may be periods when either failovers
+          are not allowed, such as in the middle of a code update, or won't work
+          because the passive BMC is temporarily offline, such as when the
+          passive BMC reboots. A timer would be put on how long redundancy could
+          still be considered enabled in this latter case in case the passive
+          BMC never comes back.  Redundancy is left enabled initially so as to
+          not trigger any intervention that could be necessary when redundancy
+          is lost just due to a BMC reboot.  Any time the passive BMC goes
+          offline a full file sync would be necessary when it comes back.
+
+enumerations:
+    - name: Role
+      description: >
+          Defines the redundancy role of the BMC.
+      values:
+          - name: Unknown
+            description: >
+                The role is unknown.
+          - name: Active
+            description: >
+                The role is for the active BMC.  This is the fully functioning
+                BMC and the main point of contact for external users.
+          - name: Passive
+            description: >
+                The role is for the passive BMC, which is the opposite of the
+                active BMC.  It may not have all services running, and would
+                require a failover to become active.
+
+signals:
+    - name: Heartbeat
+      description: >
+          This signal is to be emitted periodically from the management daemon
+          to let the sibling BMC interface daemon know it is alive.
+
+paths:
+    - namespace: /xyz/openbmc_project/state
+      segments:
+          - name: BMC
+            description: >
+                The object representing _this_ BMC is always at bmc0.
+            value: bmc0