sensorhandler: Enable mutability based set function
Resolves openbmc/openbmc#2980
Change-Id: I67afd4e84ec96e5cfc2dd315604d70f41c67a438
Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
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 @@
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 @@
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)