Enabling NVMe sensor support

This commit introduces the support for NVMe drives for sensors.

All the NVMe drives which are detected by the FRU manager and are
present in the inventory are scanned at regular interval for reading
the temperature values of the NVMe devices.

Tested:

NAME                                          TYPE      SIGNATURE RESULT/VALUE
org.freedesktop.DBus.Introspectable           interface -         -
.Introspect                                   method    -         s
org.freedesktop.DBus.Peer                     interface -         -
.GetMachineId                                 method    -         s
.Ping                                         method    -         -
org.freedesktop.DBus.Properties               interface -         -
.Get                                          method    ss        v
.GetAll                                       method    s         a{sv}
.Set                                          method    ssv       -
.PropertiesChanged                            signal    sa{sv}as  -
xyz.openbmc_project.Association.Definitions   interface -         -
.Associations                                 property  a(sss)    1 "chassis" "all_sensors" "/xyz/openb...
xyz.openbmc_project.Sensor.Threshold.Critical interface -         -
.CriticalAlarmHigh                            property  b         false
.CriticalAlarmLow                             property  b         false
.CriticalHigh                                 property  d         115
.CriticalLow                                  property  d         0
xyz.openbmc_project.Sensor.Threshold.Warning  interface -         -
.WarningAlarmHigh                             property  b         false
.WarningAlarmLow                              property  b         false
.WarningHigh                                  property  d         110
.WarningLow                                   property  d         5
xyz.openbmc_project.Sensor.Value              interface -         -
.MaxValue                                     property  d         127
.MinValue                                     property  d         -60
.Value                                        property  d         22

Change-Id: Icb119b424234d548c8ff5cda9c7a9517ec9696bb
Signed-off-by: Nikhil Potade <nikhil.potade@linux.intel.com>
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a28c613..645a1a8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -45,6 +45,7 @@
 option (DISABLE_IPMB "Disable installing IPMB sensor" OFF)
 option (DISABLE_MCUTEMP "Disable installing MCU temperature sensor" OFF)
 option (DISABLE_PSU "Disable installing PSU sensor" OFF)
+option (DISABLE_NVME "Disable installing NVME sensor" ON)
 
 include ("cmake/HunterGate.cmake")
 
@@ -74,10 +75,13 @@
 set (PSU_SRC_FILES src/Utils.cpp src/PSUSensor.cpp src/Thresholds.cpp
      src/PwmSensor.cpp src/PSUEvent.cpp)
 
+set (NVME_SRC_FILES src/Utils.cpp src/NVMeSensorMain.cpp src/NVMeSensor.cpp src/Thresholds.cpp)
+
 set (EXTERNAL_PACKAGES Boost sdbusplus-project nlohmann-json)
 set (SENSOR_LINK_LIBS -lsystemd stdc++fs sdbusplus)
 
 if (NOT YOCTO)
+    set (DISABLE_NVME ON) # todo allow this to build out of tree
     option (ENABLE_TEST "Enable Google Test" OFF)
 
     externalproject_add (
@@ -112,6 +116,7 @@
                          CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND
                          "" LOG_DOWNLOAD ON)
     include_directories (SYSTEM ${CMAKE_BINARY_DIR}/nlohmann-json-src/include)
+
     if (ENABLE_TEST)
         option (HUNTER_ENABLED "Enable hunter package pulling" ON)
         hunter_add_package (GTest)
@@ -190,6 +195,12 @@
 add_dependencies (psusensor sdbusplus-project)
 target_link_libraries (psusensor ${SENSOR_LINK_LIBS})
 
+if (NOT DISABLE_NVME)
+    add_executable (nvmesensor ${NVME_SRC_FILES})
+    add_dependencies (nvmesensor sdbusplus-project)
+    target_link_libraries (nvmesensor liblibmctp.a i2c ${SENSOR_LINK_LIBS})
+endif()
+
 if (NOT YOCTO)
     add_dependencies (adcsensor ${EXTERNAL_PACKAGES})
     add_dependencies (cpusensor ${EXTERNAL_PACKAGES})
@@ -273,3 +284,10 @@
                  ${SERVICE_FILE_SRC_DIR}/xyz.openbmc_project.psusensor.service
                  DESTINATION ${SERVICE_FILE_INSTALL_DIR})
 endif ()
+
+if (NOT DISABLE_NVME)
+    install (TARGETS nvmesensor DESTINATION bin)
+    install (FILES
+                 ${SERVICE_FILE_SRC_DIR}/xyz.openbmc_project.nvmesensor.service
+                 DESTINATION ${SERVICE_FILE_INSTALL_DIR})
+endif ()