summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJayanth Othayoth <ojayanth@in.ibm.com>2018-04-02 07:59:34 -0500
committerVernon Mauery <vernon.mauery@linux.intel.com>2018-04-11 20:59:14 +0000
commit0922bde4e5a371b6493f178071f252c195f71e81 (patch)
tree99a4af15a22596b51a07a6e144c1da000979dccd
parent3d23048896b7171b940c56fe4e403b1d23103eef (diff)
downloadphosphor-host-ipmid-0922bde4e5a371b6493f178071f252c195f71e81.tar.gz
phosphor-host-ipmid-0922bde4e5a371b6493f178071f252c195f71e81.zip
sensorhandler: Enable mutability based set function
Resolves openbmc/openbmc#2980 Change-Id: I67afd4e84ec96e5cfc2dd315604d70f41c67a438 Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
-rw-r--r--host-ipmid/ipmid-api.h1
-rwxr-xr-xscripts/sensor-example.yaml7
-rw-r--r--sensorhandler.cpp7
3 files changed, 15 insertions, 0 deletions
diff --git a/host-ipmid/ipmid-api.h b/host-ipmid/ipmid-api.h
index 3bada47..e903deb 100644
--- a/host-ipmid/ipmid-api.h
+++ b/host-ipmid/ipmid-api.h
@@ -119,6 +119,7 @@ enum ipmi_return_codes
IPMI_CC_PARM_OUT_OF_RANGE = 0xC9,
IPMI_CC_SENSOR_INVALID = 0xCB,
IPMI_CC_INVALID_FIELD_REQUEST = 0xCC,
+ IPMI_CC_ILLEGAL_COMMAND = 0xCD,
IPMI_CC_RESPONSE_ERROR = 0xCE,
IPMI_CC_INSUFFICIENT_PRIVILEGE = 0xD4,
IPMI_CC_UNSPECIFIED_ERROR = 0xFF,
diff --git a/scripts/sensor-example.yaml b/scripts/sensor-example.yaml
index 06c8836..4a1472d 100755
--- a/scripts/sensor-example.yaml
+++ b/scripts/sensor-example.yaml
@@ -11,6 +11,9 @@
serviceInterface: org.freedesktop.DBus.Properties
# Where the sensor value is represented - assertion bits/reading/event data
readingType: assertion
+ # indicate if a sensor is READ/WRITE/RW.
+ # This particular sensor read and write operation is allowed
+ mutability: Mutability::Write|Mutability::Read
# Sensor name would be occ0
sensorNamePattern: nameLeaf
eventType: 0x6F
@@ -37,6 +40,7 @@
path: /system/chassis/motherboard/dimm1
serviceInterface: xyz.openbmc_project.Inventory.Manager
readingType: assertion
+ mutability: Mutability::Write|Mutability::Read
sensorNamePattern: nameLeaf
interfaces:
xyz.openbmc_project.State.Decorator.OperationalStatus:
@@ -76,6 +80,7 @@
# Sensor name would be AttemptsLeft
sensorNamePattern: nameProperty
sensorReadingType: 0x6F
+ mutability: Mutability::Write|Mutability::Read
sensorType: 0xC3
serviceInterface: org.freedesktop.DBus.Properties
@@ -90,6 +95,7 @@
readingType: readingAssertion
sensorNamePattern: nameProperty
sensorReadingType: 0x6F
+ mutability: Mutability::Write|Mutability::Read
sensorType: 0xC3
serviceInterface: org.freedesktop.DBus.Properties
@@ -122,6 +128,7 @@
sensorReadingType: 0x6F
serviceInterface: xyz.openbmc_project.Inventory.Manager
readingType: assertion
+ mutability: Mutability::Write|Mutability::Read
# Sensor name would be cpu0_core22
sensorNamePattern: nameParentLeaf
interfaces:
diff --git a/sensorhandler.cpp b/sensorhandler.cpp
index 3a47e20..1a66a1e 100644
--- a/sensorhandler.cpp
+++ b/sensorhandler.cpp
@@ -379,6 +379,13 @@ ipmi_ret_t setSensorReading(void *request)
try
{
+ if (ipmi::sensor::Mutability::Write !=
+ (iter->second.mutability & ipmi::sensor::Mutability::Write))
+ {
+ log<level::ERR>("Sensor Set operation is not allowed",
+ entry("SENSOR_NUM=%d", cmdData.number));
+ return IPMI_CC_ILLEGAL_COMMAND;
+ }
return iter->second.updateFunc(cmdData, iter->second);
}
catch (InternalFailure& e)
OpenPOWER on IntegriCloud