Add virtual/phosphor-ipmi-inventory-sel

This virtual provides a YAML file that serves as a mapping between
inventory and sensor number for phosphor-ipmi-host. Add a native
recipe that builds the YAML from the MRW. This is the default for
the machines that support obmc-mrw.

Resolves openbmc/openbmc#1514

Change-Id: I3d856ab00c34d3e71926b863f207dd69f7fc8f3f
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
diff --git a/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-host.bb b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-host.bb
index 5bcef0a..7475414 100644
--- a/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-host.bb
+++ b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-host.bb
@@ -21,6 +21,7 @@
 DEPENDS += "sdbusplus"
 DEPENDS += "phosphor-dbus-interfaces"
 DEPENDS += "obmc-targets"
+DEPENDS += "virtual/phosphor-ipmi-inventory-sel"
 
 RDEPENDS_${PN}-dev += "phosphor-logging"
 RDEPENDS_${PN}-dev += "phosphor-mapper-dev"
@@ -45,6 +46,7 @@
 EXTRA_OECONF = " \
         WHITELIST_CONF="${WHITELIST_CONF}" \
         SENSOR_YAML_GEN=${STAGING_DIR_NATIVE}${sensor_datadir}/sensor.yaml \
+        INVSENSOR_YAML_GEN=${STAGING_DIR_NATIVE}${sensor_datadir}/invsensor.yaml \
         "
 
 S = "${WORKDIR}/git"
diff --git a/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-inventory-sel-mrw-native.bb b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-inventory-sel-mrw-native.bb
new file mode 100644
index 0000000..b852937
--- /dev/null
+++ b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-inventory-sel-mrw-native.bb
@@ -0,0 +1,28 @@
+SUMMARY = "Inventory to Sensor config for phosphor-host-ipmi"
+PR = "r1"
+
+inherit native
+inherit obmc-phosphor-license
+inherit phosphor-ipmi-host
+
+SRC_URI += "file://config.yaml"
+
+DEPENDS += " \
+           mrw-native \
+           mrw-perl-tools-native \
+           "
+
+PROVIDES += "virtual/phosphor-ipmi-inventory-sel"
+
+S = "${WORKDIR}"
+
+do_install() {
+        DEST=${D}${sensor_datadir}
+        install -d ${DEST}
+
+        ${bindir}/perl-native/perl \
+            ${bindir}/gen_ipmi_sel.pl \
+            -i ${datadir}/obmc-mrw/${MACHINE}.xml \
+            -m config.yaml \
+            -o ${DEST}/invsensor.yaml
+}
diff --git a/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-inventory-sel-mrw/config.yaml b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-inventory-sel-mrw/config.yaml
new file mode 100644
index 0000000..0caa123
--- /dev/null
+++ b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-inventory-sel-mrw/config.yaml
@@ -0,0 +1,20 @@
+# Maps the Entity ID to the interested Sensor Type & Offset
+0x01:
+   SensorType: 0x12
+   Offset: 0x02
+
+0x03:
+   SensorType: 0x07
+   Offset: 0x08
+
+0x07:
+   SensorType: 0xC7
+   Offset: 0x00
+
+0x20:
+   SensorType: 0x0C
+   Offset: 0x04
+
+0xD0:
+   SensorType: 0x07
+   Offset: 0x08
diff --git a/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-inventory-sel-native.bb b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-inventory-sel-native.bb
new file mode 100644
index 0000000..272e533
--- /dev/null
+++ b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-inventory-sel-native.bb
@@ -0,0 +1,21 @@
+SUMMARY = "Inventory to Sensor config for non-mrw machines"
+PR = "r1"
+
+inherit native
+inherit phosphor-ipmi-host
+inherit obmc-phosphor-license
+
+PROVIDES += "virtual/phosphor-ipmi-inventory-sel"
+
+SRC_URI += "file://config.yaml"
+
+S = "${WORKDIR}"
+
+do_install() {
+        # This recipe would provide the sample inventory to sensor config
+        # mapping, for non-mrw machines.
+
+        DEST=${D}${sensor_datadir}
+        install -d ${DEST}
+        install config.yaml ${DEST}/invsensor.yaml
+}
diff --git a/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-inventory-sel/config.yaml b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-inventory-sel/config.yaml
new file mode 100644
index 0000000..c3b4ba1
--- /dev/null
+++ b/meta-phosphor/common/recipes-phosphor/ipmi/phosphor-ipmi-inventory-sel/config.yaml
@@ -0,0 +1,340 @@
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm0:
+  sensorID: 0xa6
+  sensorType: 0x0C
+  eventReadingType: 0x6F
+  offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm1:
+  sensorID: 0xa8
+  sensorType: 0x0C
+  eventReadingType: 0x6F
+  offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm10:
+  sensorID: 0xba
+  sensorType: 0x0C
+  eventReadingType: 0x6F
+  offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm11:
+  sensorID: 0xbc
+  sensorType: 0x0C
+  eventReadingType: 0x6F
+  offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm12:
+  sensorID: 0xbe
+  sensorType: 0x0C
+  eventReadingType: 0x6F
+  offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm13:
+  sensorID: 0xc0
+  sensorType: 0x0C
+  eventReadingType: 0x6F
+  offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm14:
+  sensorID: 0xc2
+  sensorType: 0x0C
+  eventReadingType: 0x6F
+  offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm15:
+  sensorID: 0xc4
+  sensorType: 0x0C
+  eventReadingType: 0x6F
+  offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm2:
+  sensorID: 0xaa
+  sensorType: 0x0C
+  eventReadingType: 0x6F
+  offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm3:
+  sensorID: 0xac
+  sensorType: 0x0C
+  eventReadingType: 0x6F
+  offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm4:
+  sensorID: 0xae
+  sensorType: 0x0C
+  eventReadingType: 0x6F
+  offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm5:
+  sensorID: 0xb0
+  sensorType: 0x0C
+  eventReadingType: 0x6F
+  offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm6:
+  sensorID: 0xb2
+  sensorType: 0x0C
+  eventReadingType: 0x6F
+  offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm7:
+  sensorID: 0xb4
+  sensorType: 0x0C
+  eventReadingType: 0x6F
+  offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm8:
+  sensorID: 0xb6
+  sensorType: 0x0C
+  eventReadingType: 0x6F
+  offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/dimm9:
+  sensorID: 0xb8
+  sensorType: 0x0C
+  eventReadingType: 0x6F
+  offset: 0x04
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0:
+  sensorID: 0x5a
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core0:
+  sensorID: 0x12
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core1:
+  sensorID: 0x15
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core2:
+  sensorID: 0x18
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core3:
+  sensorID: 0x1b
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core4:
+  sensorID: 0x1e
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core5:
+  sensorID: 0x21
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core6:
+  sensorID: 0x24
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core7:
+  sensorID: 0x27
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core8:
+  sensorID: 0x2a
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core9:
+  sensorID: 0x2d
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core10:
+  sensorID: 0x30
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core11:
+  sensorID: 0x33
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core12:
+  sensorID: 0x36
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core13:
+  sensorID: 0x39
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core14:
+  sensorID: 0x3c
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core15:
+  sensorID: 0x3f
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core16:
+  sensorID: 0x42
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core17:
+  sensorID: 0x45
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core18:
+  sensorID: 0x48
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core19:
+  sensorID: 0x4b
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core20:
+  sensorID: 0x4e
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core21:
+  sensorID: 0x51
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core22:
+  sensorID: 0x54
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu0/core23:
+  sensorID: 0x57
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1:
+  sensorID: 0xa4
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core0:
+  sensorID: 0x5c
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core1:
+  sensorID: 0x5f
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core2:
+  sensorID: 0x62
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core3:
+  sensorID: 0x65
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core4:
+  sensorID: 0x68
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core5:
+  sensorID: 0x6b
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core6:
+  sensorID: 0x6e
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core7:
+  sensorID: 0x71
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core8:
+  sensorID: 0x74
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core9:
+  sensorID: 0x77
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core10:
+  sensorID: 0x7a
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core11:
+  sensorID: 0x7d
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core12:
+  sensorID: 0x80
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core13:
+  sensorID: 0x83
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core14:
+  sensorID: 0x86
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core15:
+  sensorID: 0x89
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core16:
+  sensorID: 0x8c
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core17:
+  sensorID: 0x8f
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core18:
+  sensorID: 0x92
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core19:
+  sensorID: 0x95
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core20:
+  sensorID: 0x98
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core21:
+  sensorID: 0x9b
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core22:
+  sensorID: 0x9e
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard/cpu1/core23:
+  sensorID: 0xa1
+  sensorType: 0x07
+  eventReadingType: 0x6F
+  offset: 0x08
+/xyz/openbmc_project/inventory/system/chassis/motherboard:
+  sensorID: 0x0c
+  sensorType: 0xC7
+  eventReadingType: 0x03
+  offset: 0x00
+/xyz/openbmc_project/inventory/system:
+  sensorID: 0x01
+  sensorType: 0x12
+  eventReadingType: 0x6F
+  offset: 0x02
\ No newline at end of file
diff --git a/meta-phosphor/conf/distro/include/phosphor-defaults.inc b/meta-phosphor/conf/distro/include/phosphor-defaults.inc
index 4f47453..62ae253 100644
--- a/meta-phosphor/conf/distro/include/phosphor-defaults.inc
+++ b/meta-phosphor/conf/distro/include/phosphor-defaults.inc
@@ -176,5 +176,13 @@
 PREFERRED_PROVIDER_virtual/phosphor-fan-control-fan-config ?= \
     "${@cf_enabled(d, 'obmc-mrw', 'phosphor-fan-control-fan-config-mrw-native', 'phosphor-fan-control-fan-config-native')}"
 
+# The phosphor-host-ipmid application is data-driven and requires an input
+# mapping of inventory object path to the sensor number and sensor metadata.
+# This virtual is a native recipe that provides that mapping by installing
+# configuration files in the format and native sysroot location expected by
+# the phosphor-host-ipmid build process in the native sysroot.
+PREFERRED_PROVIDER_virtual/phosphor-ipmi-inventory-sel ?= \
+    "${@cf_enabled(d, 'obmc-mrw', 'phosphor-ipmi-inventory-sel-mrw-native', 'phosphor-ipmi-inventory-sel-native')}"
+
 OBMC_DBUS_PATH_ROOT ?= "/xyz/openbmc_project"
 OBMC_DBUS_IFACE_ROOT ?= "xyz.openbmc_project"