Tom | d700e76 | 2016-09-20 18:24:13 +0530 | [diff] [blame] | 1 | #include <mapper.h> |
Emily Shaffer | 1fabf22 | 2017-04-05 08:53:21 -0700 | [diff] [blame] | 2 | #include <math.h> |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 3 | #include <stdio.h> |
| 4 | #include <string.h> |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 5 | #include <set> |
Tom Joseph | be703f7 | 2017-03-09 12:34:35 +0530 | [diff] [blame] | 6 | #include <bitset> |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 7 | #include <xyz/openbmc_project/Sensor/Value/server.hpp> |
Chris Austen | 10ccc0f | 2015-12-10 18:27:04 -0600 | [diff] [blame] | 8 | #include <systemd/sd-bus.h> |
Tom Joseph | be703f7 | 2017-03-09 12:34:35 +0530 | [diff] [blame] | 9 | #include "host-ipmid/ipmid-api.h" |
| 10 | #include <phosphor-logging/log.hpp> |
Dhruvaraj Subhashchandran | 18e9999 | 2017-08-09 09:10:47 -0500 | [diff] [blame] | 11 | #include <phosphor-logging/elog-errors.hpp> |
Ratan Gupta | e0cc855 | 2018-01-22 14:23:04 +0530 | [diff] [blame] | 12 | #include "fruread.hpp" |
Tom | d700e76 | 2016-09-20 18:24:13 +0530 | [diff] [blame] | 13 | #include "ipmid.hpp" |
Tom Joseph | be703f7 | 2017-03-09 12:34:35 +0530 | [diff] [blame] | 14 | #include "sensorhandler.h" |
| 15 | #include "types.hpp" |
| 16 | #include "utils.hpp" |
Dhruvaraj Subhashchandran | 18e9999 | 2017-08-09 09:10:47 -0500 | [diff] [blame] | 17 | #include "xyz/openbmc_project/Common/error.hpp" |
| 18 | |
Ratan Gupta | e0cc855 | 2018-01-22 14:23:04 +0530 | [diff] [blame] | 19 | static constexpr uint8_t fruInventoryDevice = 0x10; |
| 20 | static constexpr uint8_t IPMIFruInventory = 0x02; |
| 21 | static constexpr uint8_t BMCSlaveAddress = 0x20; |
| 22 | |
Chris Austen | 8a45e7c | 2015-10-15 00:31:46 -0500 | [diff] [blame] | 23 | extern int updateSensorRecordFromSSRAESC(const void *); |
Tom | d700e76 | 2016-09-20 18:24:13 +0530 | [diff] [blame] | 24 | extern sd_bus *bus; |
Tom Joseph | be703f7 | 2017-03-09 12:34:35 +0530 | [diff] [blame] | 25 | extern const ipmi::sensor::IdInfoMap sensors; |
Ratan Gupta | e0cc855 | 2018-01-22 14:23:04 +0530 | [diff] [blame] | 26 | extern const FruMap frus; |
| 27 | |
| 28 | |
Tom Joseph | be703f7 | 2017-03-09 12:34:35 +0530 | [diff] [blame] | 29 | using namespace phosphor::logging; |
Dhruvaraj Subhashchandran | 18e9999 | 2017-08-09 09:10:47 -0500 | [diff] [blame] | 30 | using InternalFailure = |
| 31 | sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 32 | |
| 33 | void register_netfn_sen_functions() __attribute__((constructor)); |
| 34 | |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 35 | struct sensorTypemap_t { |
| 36 | uint8_t number; |
Chris Austen | d7cf0e4 | 2015-11-07 14:27:12 -0600 | [diff] [blame] | 37 | uint8_t typecode; |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 38 | char dbusname[32]; |
| 39 | } ; |
| 40 | |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 41 | sensorTypemap_t g_SensorTypeMap[] = { |
| 42 | |
Chris Austen | d7cf0e4 | 2015-11-07 14:27:12 -0600 | [diff] [blame] | 43 | {0x01, 0x6F, "Temp"}, |
| 44 | {0x0C, 0x6F, "DIMM"}, |
| 45 | {0x0C, 0x6F, "MEMORY_BUFFER"}, |
| 46 | {0x07, 0x6F, "PROC"}, |
| 47 | {0x07, 0x6F, "CORE"}, |
| 48 | {0x07, 0x6F, "CPU"}, |
| 49 | {0x0F, 0x6F, "BootProgress"}, |
| 50 | {0xe9, 0x09, "OccStatus"}, // E9 is an internal mapping to handle sensor type code os 0x09 |
| 51 | {0xC3, 0x6F, "BootCount"}, |
| 52 | {0x1F, 0x6F, "OperatingSystemStatus"}, |
Chris Austen | 800ba71 | 2015-12-03 15:31:00 -0600 | [diff] [blame] | 53 | {0x12, 0x6F, "SYSTEM_EVENT"}, |
| 54 | {0xC7, 0x03, "SYSTEM"}, |
| 55 | {0xC7, 0x03, "MAIN_PLANAR"}, |
Chris Austen | 10ccc0f | 2015-12-10 18:27:04 -0600 | [diff] [blame] | 56 | {0xC2, 0x6F, "PowerCap"}, |
Tom Joseph | 558184e | 2017-09-01 13:45:05 +0530 | [diff] [blame] | 57 | {0x0b, 0xCA, "PowerSupplyRedundancy"}, |
Jayanth Othayoth | 0661beb | 2017-03-22 06:00:58 -0500 | [diff] [blame] | 58 | {0xDA, 0x03, "TurboAllowed"}, |
Tom Joseph | 558184e | 2017-09-01 13:45:05 +0530 | [diff] [blame] | 59 | {0xD8, 0xC8, "PowerSupplyDerating"}, |
Chris Austen | d7cf0e4 | 2015-11-07 14:27:12 -0600 | [diff] [blame] | 60 | {0xFF, 0x00, ""}, |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 64 | struct sensor_data_t { |
| 65 | uint8_t sennum; |
| 66 | } __attribute__ ((packed)) ; |
| 67 | |
Chris Austen | 10ccc0f | 2015-12-10 18:27:04 -0600 | [diff] [blame] | 68 | struct sensorreadingresp_t { |
| 69 | uint8_t value; |
| 70 | uint8_t operation; |
| 71 | uint8_t indication[2]; |
| 72 | } __attribute__ ((packed)) ; |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 73 | |
Emily Shaffer | 2ae09b9 | 2017-04-05 15:09:41 -0700 | [diff] [blame] | 74 | int get_bus_for_path(const char *path, char **busname) { |
| 75 | return mapper_get_service(bus, path, busname); |
| 76 | } |
Tom | d700e76 | 2016-09-20 18:24:13 +0530 | [diff] [blame] | 77 | |
Emily Shaffer | 2ae09b9 | 2017-04-05 15:09:41 -0700 | [diff] [blame] | 78 | int legacy_dbus_openbmc_path(const char *type, const uint8_t num, dbus_interface_t *interface) { |
Tom | d700e76 | 2016-09-20 18:24:13 +0530 | [diff] [blame] | 79 | char *busname = NULL; |
| 80 | const char *iface = "org.openbmc.managers.System"; |
| 81 | const char *objname = "/org/openbmc/managers/System"; |
| 82 | char *str1 = NULL, *str2, *str3; |
| 83 | sd_bus_error error = SD_BUS_ERROR_NULL; |
| 84 | sd_bus_message *reply = NULL; |
| 85 | |
| 86 | |
| 87 | int r; |
Emily Shaffer | 2ae09b9 | 2017-04-05 15:09:41 -0700 | [diff] [blame] | 88 | r = get_bus_for_path(objname, &busname); |
Tom | d700e76 | 2016-09-20 18:24:13 +0530 | [diff] [blame] | 89 | if (r < 0) { |
Brad Bishop | 819ddd4 | 2016-10-05 21:19:19 -0400 | [diff] [blame] | 90 | fprintf(stderr, "Failed to get %s busname: %s\n", |
| 91 | objname, strerror(-r)); |
Tom | d700e76 | 2016-09-20 18:24:13 +0530 | [diff] [blame] | 92 | goto final; |
| 93 | } |
| 94 | |
| 95 | r = sd_bus_call_method(bus,busname,objname,iface, "getObjectFromByteId", |
| 96 | &error, &reply, "sy", type, num); |
| 97 | if (r < 0) { |
| 98 | fprintf(stderr, "Failed to create a method call: %s", strerror(-r)); |
| 99 | goto final; |
| 100 | } |
| 101 | |
| 102 | r = sd_bus_message_read(reply, "(ss)", &str2, &str3); |
| 103 | if (r < 0) { |
| 104 | fprintf(stderr, "Failed to get a response: %s", strerror(-r)); |
| 105 | goto final; |
| 106 | } |
| 107 | |
Emily Shaffer | 2ae09b9 | 2017-04-05 15:09:41 -0700 | [diff] [blame] | 108 | r = get_bus_for_path(str2, &str1); |
Tom | d700e76 | 2016-09-20 18:24:13 +0530 | [diff] [blame] | 109 | if (r < 0) { |
Brad Bishop | 819ddd4 | 2016-10-05 21:19:19 -0400 | [diff] [blame] | 110 | fprintf(stderr, "Failed to get %s busname: %s\n", |
| 111 | str2, strerror(-r)); |
Tom | d700e76 | 2016-09-20 18:24:13 +0530 | [diff] [blame] | 112 | goto final; |
| 113 | } |
| 114 | |
| 115 | strncpy(interface->bus, str1, MAX_DBUS_PATH); |
| 116 | strncpy(interface->path, str2, MAX_DBUS_PATH); |
| 117 | strncpy(interface->interface, str3, MAX_DBUS_PATH); |
| 118 | |
| 119 | interface->sensornumber = num; |
Emily Shaffer | 7117441 | 2017-04-05 15:10:40 -0700 | [diff] [blame] | 120 | // Make sure we know that the type hasn't been set, as newer codebase will |
| 121 | // set it automatically from the YAML at this step. |
| 122 | interface->sensortype = 0; |
Tom | d700e76 | 2016-09-20 18:24:13 +0530 | [diff] [blame] | 123 | |
| 124 | final: |
| 125 | |
| 126 | sd_bus_error_free(&error); |
| 127 | reply = sd_bus_message_unref(reply); |
| 128 | free(busname); |
| 129 | free(str1); |
| 130 | |
| 131 | return r; |
| 132 | } |
| 133 | |
Emily Shaffer | 2ae09b9 | 2017-04-05 15:09:41 -0700 | [diff] [blame] | 134 | // Use a lookup table to find the interface name of a specific sensor |
| 135 | // This will be used until an alternative is found. this is the first |
| 136 | // step for mapping IPMI |
| 137 | int find_openbmc_path(uint8_t num, dbus_interface_t *interface) { |
| 138 | int rc; |
| 139 | |
| 140 | // When the sensor map does not contain the sensor requested, |
| 141 | // fall back to the legacy DBus lookup (deprecated) |
| 142 | const auto& sensor_it = sensors.find(num); |
| 143 | if (sensor_it == sensors.end()) |
| 144 | { |
| 145 | return legacy_dbus_openbmc_path("SENSOR", num, interface); |
| 146 | } |
| 147 | |
| 148 | const auto& info = sensor_it->second; |
| 149 | |
Patrick Williams | 8451edf | 2017-06-13 09:01:06 -0500 | [diff] [blame] | 150 | char* busname = nullptr; |
Emily Shaffer | 2ae09b9 | 2017-04-05 15:09:41 -0700 | [diff] [blame] | 151 | rc = get_bus_for_path(info.sensorPath.c_str(), &busname); |
| 152 | if (rc < 0) { |
| 153 | fprintf(stderr, "Failed to get %s busname: %s\n", |
| 154 | info.sensorPath.c_str(), |
| 155 | busname); |
| 156 | goto final; |
| 157 | } |
| 158 | |
| 159 | interface->sensortype = info.sensorType; |
| 160 | strcpy(interface->bus, busname); |
| 161 | strcpy(interface->path, info.sensorPath.c_str()); |
| 162 | // Take the interface name from the beginning of the DbusInterfaceMap. This |
| 163 | // works for the Value interface but may not suffice for more complex |
| 164 | // sensors. |
| 165 | // tracked https://github.com/openbmc/phosphor-host-ipmid/issues/103 |
Deepak Kodihalli | 1bb0d38 | 2017-08-12 02:01:27 -0500 | [diff] [blame] | 166 | strcpy(interface->interface, info.propertyInterfaces.begin()->first.c_str()); |
Emily Shaffer | 2ae09b9 | 2017-04-05 15:09:41 -0700 | [diff] [blame] | 167 | interface->sensornumber = num; |
| 168 | |
| 169 | final: |
| 170 | free(busname); |
| 171 | return rc; |
| 172 | } |
| 173 | |
Tom | d700e76 | 2016-09-20 18:24:13 +0530 | [diff] [blame] | 174 | |
| 175 | ///////////////////////////////////////////////////////////////////// |
| 176 | // |
| 177 | // Routines used by ipmi commands wanting to interact on the dbus |
| 178 | // |
| 179 | ///////////////////////////////////////////////////////////////////// |
| 180 | int set_sensor_dbus_state_s(uint8_t number, const char *method, const char *value) { |
| 181 | |
| 182 | |
| 183 | dbus_interface_t a; |
| 184 | int r; |
| 185 | sd_bus_error error = SD_BUS_ERROR_NULL; |
| 186 | sd_bus_message *m=NULL; |
| 187 | |
| 188 | fprintf(ipmidbus, "Attempting to set a dbus Variant Sensor 0x%02x via %s with a value of %s\n", |
| 189 | number, method, value); |
| 190 | |
Emily Shaffer | 2ae09b9 | 2017-04-05 15:09:41 -0700 | [diff] [blame] | 191 | r = find_openbmc_path(number, &a); |
Tom | d700e76 | 2016-09-20 18:24:13 +0530 | [diff] [blame] | 192 | |
| 193 | if (r < 0) { |
| 194 | fprintf(stderr, "Failed to find Sensor 0x%02x\n", number); |
| 195 | return 0; |
| 196 | } |
| 197 | |
| 198 | r = sd_bus_message_new_method_call(bus,&m,a.bus,a.path,a.interface,method); |
| 199 | if (r < 0) { |
| 200 | fprintf(stderr, "Failed to create a method call: %s", strerror(-r)); |
| 201 | goto final; |
| 202 | } |
| 203 | |
| 204 | r = sd_bus_message_append(m, "v", "s", value); |
| 205 | if (r < 0) { |
| 206 | fprintf(stderr, "Failed to create a input parameter: %s", strerror(-r)); |
| 207 | goto final; |
| 208 | } |
| 209 | |
| 210 | |
| 211 | r = sd_bus_call(bus, m, 0, &error, NULL); |
| 212 | if (r < 0) { |
| 213 | fprintf(stderr, "Failed to call the method: %s", strerror(-r)); |
| 214 | } |
| 215 | |
| 216 | final: |
| 217 | sd_bus_error_free(&error); |
| 218 | m = sd_bus_message_unref(m); |
| 219 | |
| 220 | return 0; |
| 221 | } |
| 222 | int set_sensor_dbus_state_y(uint8_t number, const char *method, const uint8_t value) { |
| 223 | |
| 224 | |
| 225 | dbus_interface_t a; |
| 226 | int r; |
| 227 | sd_bus_error error = SD_BUS_ERROR_NULL; |
| 228 | sd_bus_message *m=NULL; |
| 229 | |
| 230 | fprintf(ipmidbus, "Attempting to set a dbus Variant Sensor 0x%02x via %s with a value of 0x%02x\n", |
| 231 | number, method, value); |
| 232 | |
Emily Shaffer | 2ae09b9 | 2017-04-05 15:09:41 -0700 | [diff] [blame] | 233 | r = find_openbmc_path(number, &a); |
Tom | d700e76 | 2016-09-20 18:24:13 +0530 | [diff] [blame] | 234 | |
| 235 | if (r < 0) { |
| 236 | fprintf(stderr, "Failed to find Sensor 0x%02x\n", number); |
| 237 | return 0; |
| 238 | } |
| 239 | |
| 240 | r = sd_bus_message_new_method_call(bus,&m,a.bus,a.path,a.interface,method); |
| 241 | if (r < 0) { |
| 242 | fprintf(stderr, "Failed to create a method call: %s", strerror(-r)); |
| 243 | goto final; |
| 244 | } |
| 245 | |
| 246 | r = sd_bus_message_append(m, "v", "i", value); |
| 247 | if (r < 0) { |
| 248 | fprintf(stderr, "Failed to create a input parameter: %s", strerror(-r)); |
| 249 | goto final; |
| 250 | } |
| 251 | |
| 252 | |
| 253 | r = sd_bus_call(bus, m, 0, &error, NULL); |
| 254 | if (r < 0) { |
| 255 | fprintf(stderr, "12 Failed to call the method: %s", strerror(-r)); |
| 256 | } |
| 257 | |
| 258 | final: |
| 259 | sd_bus_error_free(&error); |
| 260 | m = sd_bus_message_unref(m); |
| 261 | |
| 262 | return 0; |
| 263 | } |
| 264 | |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 265 | uint8_t dbus_to_sensor_type(char *p) { |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 266 | |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 267 | sensorTypemap_t *s = g_SensorTypeMap; |
| 268 | char r=0; |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 269 | while (s->number != 0xFF) { |
| 270 | if (!strcmp(s->dbusname,p)) { |
Tom Joseph | 558184e | 2017-09-01 13:45:05 +0530 | [diff] [blame] | 271 | r = s->typecode; |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 272 | break; |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 273 | } |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 274 | s++; |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 275 | } |
| 276 | |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 277 | if (s->number == 0xFF) |
| 278 | printf("Failed to find Sensor Type %s\n", p); |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 279 | |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 280 | return r; |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 281 | } |
| 282 | |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 283 | |
Emily Shaffer | 391f330 | 2017-04-03 10:27:08 -0700 | [diff] [blame] | 284 | uint8_t get_type_from_interface(dbus_interface_t dbus_if) { |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 285 | |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 286 | char *p; |
Brad Bishop | 5600345 | 2016-10-05 21:49:19 -0400 | [diff] [blame] | 287 | uint8_t type; |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 288 | |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 289 | // This is where sensors that do not exist in dbus but do |
| 290 | // exist in the host code stop. This should indicate it |
| 291 | // is not a supported sensor |
Emily Shaffer | 391f330 | 2017-04-03 10:27:08 -0700 | [diff] [blame] | 292 | if (dbus_if.interface[0] == 0) { return 0;} |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 293 | |
Emily Shaffer | 7117441 | 2017-04-05 15:10:40 -0700 | [diff] [blame] | 294 | // Fetch type from interface itself. |
| 295 | if (dbus_if.sensortype != 0) |
| 296 | { |
| 297 | type = dbus_if.sensortype; |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 298 | } else { |
| 299 | // Non InventoryItems |
Emily Shaffer | 391f330 | 2017-04-03 10:27:08 -0700 | [diff] [blame] | 300 | p = strrchr (dbus_if.path, '/'); |
Brad Bishop | 5600345 | 2016-10-05 21:49:19 -0400 | [diff] [blame] | 301 | type = dbus_to_sensor_type(p+1); |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 302 | } |
| 303 | |
Brad Bishop | 5600345 | 2016-10-05 21:49:19 -0400 | [diff] [blame] | 304 | return type; |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 305 | } |
| 306 | |
Emily Shaffer | 391f330 | 2017-04-03 10:27:08 -0700 | [diff] [blame] | 307 | // Replaces find_sensor |
| 308 | uint8_t find_type_for_sensor_number(uint8_t num) { |
| 309 | int r; |
| 310 | dbus_interface_t dbus_if; |
Emily Shaffer | 2ae09b9 | 2017-04-05 15:09:41 -0700 | [diff] [blame] | 311 | r = find_openbmc_path(num, &dbus_if); |
Emily Shaffer | 391f330 | 2017-04-03 10:27:08 -0700 | [diff] [blame] | 312 | if (r < 0) { |
| 313 | fprintf(stderr, "Could not find sensor %d\n", num); |
| 314 | return r; |
| 315 | } |
| 316 | return get_type_from_interface(dbus_if); |
| 317 | } |
| 318 | |
Chris Austen | 10ccc0f | 2015-12-10 18:27:04 -0600 | [diff] [blame] | 319 | |
| 320 | |
| 321 | |
| 322 | |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 323 | ipmi_ret_t ipmi_sen_get_sensor_type(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 324 | ipmi_request_t request, ipmi_response_t response, |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 325 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 326 | { |
| 327 | sensor_data_t *reqptr = (sensor_data_t*)request; |
| 328 | ipmi_ret_t rc = IPMI_CC_OK; |
| 329 | |
| 330 | printf("IPMI GET_SENSOR_TYPE [0x%02X]\n",reqptr->sennum); |
| 331 | |
| 332 | // TODO Not sure what the System-event-sensor is suppose to return |
| 333 | // need to ask Hostboot team |
| 334 | unsigned char buf[] = {0x00,0x6F}; |
| 335 | |
Emily Shaffer | 391f330 | 2017-04-03 10:27:08 -0700 | [diff] [blame] | 336 | buf[0] = find_type_for_sensor_number(reqptr->sennum); |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 337 | |
| 338 | // HACK UNTIL Dbus gets updated or we find a better way |
| 339 | if (buf[0] == 0) { |
Chris Austen | 800ba71 | 2015-12-03 15:31:00 -0600 | [diff] [blame] | 340 | rc = IPMI_CC_SENSOR_INVALID; |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 341 | } |
| 342 | |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 343 | |
| 344 | *data_len = sizeof(buf); |
| 345 | memcpy(response, &buf, *data_len); |
| 346 | |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 347 | return rc; |
| 348 | } |
| 349 | |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 350 | const std::set<std::string> analogSensorInterfaces = |
| 351 | { |
| 352 | "xyz.openbmc_project.Sensor.Value", |
Patrick Venture | e9a6405 | 2017-08-18 19:17:27 -0700 | [diff] [blame] | 353 | "xyz.openbmc_project.Control.FanPwm", |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 354 | }; |
| 355 | |
| 356 | bool isAnalogSensor(const std::string& interface) |
| 357 | { |
| 358 | return (analogSensorInterfaces.count(interface)); |
| 359 | } |
| 360 | |
Tom Joseph | be703f7 | 2017-03-09 12:34:35 +0530 | [diff] [blame] | 361 | ipmi_ret_t setSensorReading(void *request) |
| 362 | { |
Tom Joseph | 816e92b | 2017-09-06 19:23:00 +0530 | [diff] [blame] | 363 | ipmi::sensor::SetSensorReadingReq cmdData = |
| 364 | *(static_cast<ipmi::sensor::SetSensorReadingReq *>(request)); |
Tom Joseph | be703f7 | 2017-03-09 12:34:35 +0530 | [diff] [blame] | 365 | |
| 366 | // Check if the Sensor Number is present |
Dhruvaraj Subhashchandran | e0af720 | 2017-07-12 06:35:20 -0500 | [diff] [blame] | 367 | const auto iter = sensors.find(cmdData.number); |
Tom Joseph | be703f7 | 2017-03-09 12:34:35 +0530 | [diff] [blame] | 368 | if (iter == sensors.end()) |
| 369 | { |
| 370 | return IPMI_CC_SENSOR_INVALID; |
| 371 | } |
| 372 | |
Dhruvaraj Subhashchandran | 18e9999 | 2017-08-09 09:10:47 -0500 | [diff] [blame] | 373 | try |
| 374 | { |
| 375 | return iter->second.updateFunc(cmdData, iter->second); |
| 376 | } |
| 377 | catch (InternalFailure& e) |
| 378 | { |
| 379 | log<level::ERR>("Set sensor failed", |
| 380 | entry("SENSOR_NUM=%d", cmdData.number)); |
| 381 | commit<InternalFailure>(); |
| 382 | } |
Tom Joseph | 8202432 | 2017-09-28 20:07:29 +0530 | [diff] [blame] | 383 | catch (const std::runtime_error& e) |
| 384 | { |
| 385 | log<level::ERR>(e.what()); |
| 386 | } |
Dhruvaraj Subhashchandran | 18e9999 | 2017-08-09 09:10:47 -0500 | [diff] [blame] | 387 | |
| 388 | return IPMI_CC_UNSPECIFIED_ERROR; |
Tom Joseph | be703f7 | 2017-03-09 12:34:35 +0530 | [diff] [blame] | 389 | } |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 390 | |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 391 | ipmi_ret_t ipmi_sen_set_sensor(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 392 | ipmi_request_t request, ipmi_response_t response, |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 393 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 394 | { |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 395 | sensor_data_t *reqptr = (sensor_data_t*)request; |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 396 | |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 397 | printf("IPMI SET_SENSOR [0x%02x]\n",reqptr->sennum); |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 398 | |
Tom Joseph | be703f7 | 2017-03-09 12:34:35 +0530 | [diff] [blame] | 399 | /* |
| 400 | * This would support the Set Sensor Reading command for the presence |
| 401 | * and functional state of Processor, Core & DIMM. For the remaining |
| 402 | * sensors the existing support is invoked. |
| 403 | */ |
| 404 | auto ipmiRC = setSensorReading(request); |
| 405 | |
| 406 | if(ipmiRC == IPMI_CC_SENSOR_INVALID) |
| 407 | { |
| 408 | updateSensorRecordFromSSRAESC(reqptr); |
| 409 | ipmiRC = IPMI_CC_OK; |
| 410 | } |
Chris Austen | 8a45e7c | 2015-10-15 00:31:46 -0500 | [diff] [blame] | 411 | |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 412 | *data_len=0; |
Tom Joseph | be703f7 | 2017-03-09 12:34:35 +0530 | [diff] [blame] | 413 | return ipmiRC; |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 414 | } |
| 415 | |
Chris Austen | 10ccc0f | 2015-12-10 18:27:04 -0600 | [diff] [blame] | 416 | |
| 417 | ipmi_ret_t ipmi_sen_get_sensor_reading(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 418 | ipmi_request_t request, ipmi_response_t response, |
| 419 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 420 | { |
| 421 | sensor_data_t *reqptr = (sensor_data_t*)request; |
| 422 | ipmi_ret_t rc = IPMI_CC_SENSOR_INVALID; |
Tom Joseph | 40c35b1 | 2017-09-07 02:04:42 +0530 | [diff] [blame] | 423 | uint8_t type = 0; |
Chris Austen | 10ccc0f | 2015-12-10 18:27:04 -0600 | [diff] [blame] | 424 | sensorreadingresp_t *resp = (sensorreadingresp_t*) response; |
| 425 | int r; |
| 426 | dbus_interface_t a; |
| 427 | sd_bus *bus = ipmid_get_sd_bus_connection(); |
| 428 | sd_bus_message *reply = NULL; |
Adriana Kobylak | 9312598 | 2016-03-01 12:48:10 -0600 | [diff] [blame] | 429 | int reading = 0; |
Dhruvaraj Subhashchandran | 6244f93 | 2017-11-23 01:08:46 -0600 | [diff] [blame] | 430 | char* assertion = NULL; |
Tom Joseph | c6162fb | 2018-01-25 01:55:20 +0530 | [diff] [blame] | 431 | ipmi::sensor::GetSensorResponse getResponse {}; |
| 432 | static constexpr auto scanningEnabledBit = 6; |
Chris Austen | 10ccc0f | 2015-12-10 18:27:04 -0600 | [diff] [blame] | 433 | |
Chris Austen | 10ccc0f | 2015-12-10 18:27:04 -0600 | [diff] [blame] | 434 | printf("IPMI GET_SENSOR_READING [0x%02x]\n",reqptr->sennum); |
| 435 | |
Emily Shaffer | 2ae09b9 | 2017-04-05 15:09:41 -0700 | [diff] [blame] | 436 | r = find_openbmc_path(reqptr->sennum, &a); |
Chris Austen | 10ccc0f | 2015-12-10 18:27:04 -0600 | [diff] [blame] | 437 | |
Tom Joseph | 40c35b1 | 2017-09-07 02:04:42 +0530 | [diff] [blame] | 438 | if (r < 0) |
| 439 | { |
Nan Li | 36deb76 | 2016-05-12 10:23:41 +0800 | [diff] [blame] | 440 | fprintf(stderr, "Failed to find Sensor 0x%02x\n", reqptr->sennum); |
Nan Li | 36deb76 | 2016-05-12 10:23:41 +0800 | [diff] [blame] | 441 | } |
Tom Joseph | 40c35b1 | 2017-09-07 02:04:42 +0530 | [diff] [blame] | 442 | else |
| 443 | { |
| 444 | type = get_type_from_interface(a); |
| 445 | if(type == 0) { |
| 446 | fprintf(stderr, "Failed to find Sensor 0x%02x\n", reqptr->sennum); |
| 447 | return IPMI_CC_SENSOR_INVALID; |
| 448 | } |
Nan Li | 36deb76 | 2016-05-12 10:23:41 +0800 | [diff] [blame] | 449 | |
Tom Joseph | 40c35b1 | 2017-09-07 02:04:42 +0530 | [diff] [blame] | 450 | fprintf(stderr, "Bus: %s, Path: %s, Interface: %s\n", a.bus, a.path, |
| 451 | a.interface); |
Brad Bishop | 5600345 | 2016-10-05 21:49:19 -0400 | [diff] [blame] | 452 | } |
Chris Austen | 10ccc0f | 2015-12-10 18:27:04 -0600 | [diff] [blame] | 453 | |
Chris Austen | 10ccc0f | 2015-12-10 18:27:04 -0600 | [diff] [blame] | 454 | *data_len=0; |
| 455 | |
| 456 | switch(type) { |
Chris Austen | 10ccc0f | 2015-12-10 18:27:04 -0600 | [diff] [blame] | 457 | case 0xC2: |
Dhruvaraj Subhashchandran | d12ae75 | 2017-10-04 00:33:27 -0500 | [diff] [blame] | 458 | case 0xC8: |
Adriana Kobylak | 9312598 | 2016-03-01 12:48:10 -0600 | [diff] [blame] | 459 | r = sd_bus_get_property(bus,a.bus, a.path, a.interface, "value", NULL, &reply, "i"); |
Chris Austen | 10ccc0f | 2015-12-10 18:27:04 -0600 | [diff] [blame] | 460 | if (r < 0) { |
| 461 | fprintf(stderr, "Failed to call sd_bus_get_property:%d, %s\n", r, strerror(-r)); |
| 462 | fprintf(stderr, "Bus: %s, Path: %s, Interface: %s\n", |
| 463 | a.bus, a.path, a.interface); |
| 464 | break; |
| 465 | } |
| 466 | |
Adriana Kobylak | 9312598 | 2016-03-01 12:48:10 -0600 | [diff] [blame] | 467 | r = sd_bus_message_read(reply, "i", &reading); |
Chris Austen | 10ccc0f | 2015-12-10 18:27:04 -0600 | [diff] [blame] | 468 | if (r < 0) { |
Adriana Kobylak | 9312598 | 2016-03-01 12:48:10 -0600 | [diff] [blame] | 469 | fprintf(stderr, "Failed to read sensor: %s\n", strerror(-r)); |
Chris Austen | 10ccc0f | 2015-12-10 18:27:04 -0600 | [diff] [blame] | 470 | break; |
| 471 | } |
| 472 | |
| 473 | printf("Contents of a 0x%02x is 0x%02x\n", type, reading); |
| 474 | |
| 475 | rc = IPMI_CC_OK; |
| 476 | *data_len=sizeof(sensorreadingresp_t); |
| 477 | |
Adriana Kobylak | 9312598 | 2016-03-01 12:48:10 -0600 | [diff] [blame] | 478 | resp->value = (uint8_t)reading; |
Chris Austen | 10ccc0f | 2015-12-10 18:27:04 -0600 | [diff] [blame] | 479 | resp->operation = 0; |
| 480 | resp->indication[0] = 0; |
| 481 | resp->indication[1] = 0; |
| 482 | break; |
| 483 | |
Dhruvaraj Subhashchandran | 6244f93 | 2017-11-23 01:08:46 -0600 | [diff] [blame] | 484 | //TODO openbmc/openbmc#2154 Move this sensor to right place. |
| 485 | case 0xCA: |
| 486 | r = sd_bus_get_property(bus,a.bus, a.path, a.interface, "value", NULL, &reply, "s"); |
| 487 | if (r < 0) { |
| 488 | fprintf(stderr, "Failed to call sd_bus_get_property:%d, %s\n", r, strerror(-r)); |
| 489 | fprintf(stderr, "Bus: %s, Path: %s, Interface: %s\n", |
| 490 | a.bus, a.path, a.interface); |
| 491 | break; |
| 492 | } |
| 493 | |
| 494 | r = sd_bus_message_read(reply, "s", &assertion); |
| 495 | if (r < 0) { |
| 496 | fprintf(stderr, "Failed to read sensor: %s\n", strerror(-r)); |
| 497 | break; |
| 498 | } |
| 499 | |
| 500 | rc = IPMI_CC_OK; |
| 501 | *data_len=sizeof(sensorreadingresp_t); |
| 502 | |
| 503 | resp->value = 0; |
| 504 | resp->operation = 0; |
| 505 | if (strcmp(assertion,"Enabled") == 0) |
| 506 | { |
| 507 | resp->indication[0] = 0x02; |
| 508 | } |
| 509 | else |
| 510 | { |
| 511 | resp->indication[0] = 0x1; |
| 512 | } |
| 513 | resp->indication[1] = 0; |
Dhruvaraj Subhashchandran | 6244f93 | 2017-11-23 01:08:46 -0600 | [diff] [blame] | 514 | break; |
| 515 | |
Chris Austen | 10ccc0f | 2015-12-10 18:27:04 -0600 | [diff] [blame] | 516 | default: |
Tom Joseph | 14c1546 | 2017-09-07 02:16:51 +0530 | [diff] [blame] | 517 | { |
| 518 | const auto iter = sensors.find(reqptr->sennum); |
| 519 | if (iter == sensors.end()) |
| 520 | { |
| 521 | return IPMI_CC_SENSOR_INVALID; |
| 522 | } |
Tom Joseph | 13b87a3 | 2018-02-16 09:37:43 +0530 | [diff] [blame] | 523 | if (ipmi::sensor::Mutability::Read != |
| 524 | (iter->second.mutability & ipmi::sensor::Mutability::Read)) |
| 525 | { |
| 526 | return IPMI_CC_SENSOR_INVALID; |
| 527 | } |
Tom Joseph | 14c1546 | 2017-09-07 02:16:51 +0530 | [diff] [blame] | 528 | |
| 529 | try |
| 530 | { |
Tom Joseph | c6162fb | 2018-01-25 01:55:20 +0530 | [diff] [blame] | 531 | getResponse = iter->second.getFunc(iter->second); |
Tom Joseph | 14c1546 | 2017-09-07 02:16:51 +0530 | [diff] [blame] | 532 | *data_len = getResponse.size(); |
| 533 | memcpy(resp, getResponse.data(), *data_len); |
Tom Joseph | c6162fb | 2018-01-25 01:55:20 +0530 | [diff] [blame] | 534 | resp->operation = 1 << scanningEnabledBit; |
Tom Joseph | 14c1546 | 2017-09-07 02:16:51 +0530 | [diff] [blame] | 535 | return IPMI_CC_OK; |
| 536 | } |
| 537 | catch (InternalFailure& e) |
| 538 | { |
Tom Joseph | c6162fb | 2018-01-25 01:55:20 +0530 | [diff] [blame] | 539 | *data_len = getResponse.size(); |
| 540 | memcpy(resp, getResponse.data(), *data_len); |
| 541 | return IPMI_CC_OK; |
Tom Joseph | 14c1546 | 2017-09-07 02:16:51 +0530 | [diff] [blame] | 542 | } |
Tom Joseph | 8202432 | 2017-09-28 20:07:29 +0530 | [diff] [blame] | 543 | catch (const std::runtime_error& e) |
| 544 | { |
Tom Joseph | c6162fb | 2018-01-25 01:55:20 +0530 | [diff] [blame] | 545 | *data_len = getResponse.size(); |
| 546 | memcpy(resp, getResponse.data(), *data_len); |
| 547 | return IPMI_CC_OK; |
Tom Joseph | 8202432 | 2017-09-28 20:07:29 +0530 | [diff] [blame] | 548 | } |
Tom Joseph | 14c1546 | 2017-09-07 02:16:51 +0530 | [diff] [blame] | 549 | } |
Chris Austen | 10ccc0f | 2015-12-10 18:27:04 -0600 | [diff] [blame] | 550 | } |
| 551 | |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 552 | reply = sd_bus_message_unref(reply); |
Chris Austen | 10ccc0f | 2015-12-10 18:27:04 -0600 | [diff] [blame] | 553 | |
| 554 | return rc; |
| 555 | } |
| 556 | |
Tom Joseph | 0ac0dd2 | 2018-02-16 09:14:45 +0530 | [diff] [blame] | 557 | void getSensorThresholds(uint8_t sensorNum, |
| 558 | get_sdr::GetSensorThresholdsResponse* response) |
Dhruvaraj Subhashchandran | 5c0beec | 2018-01-23 04:47:06 -0600 | [diff] [blame] | 559 | { |
Tom Joseph | 0ac0dd2 | 2018-02-16 09:14:45 +0530 | [diff] [blame] | 560 | constexpr auto warningThreshIntf = |
Dhruvaraj Subhashchandran | 5c0beec | 2018-01-23 04:47:06 -0600 | [diff] [blame] | 561 | "xyz.openbmc_project.Sensor.Threshold.Warning"; |
Tom Joseph | 0ac0dd2 | 2018-02-16 09:14:45 +0530 | [diff] [blame] | 562 | constexpr auto criticalThreshIntf = |
Dhruvaraj Subhashchandran | 5c0beec | 2018-01-23 04:47:06 -0600 | [diff] [blame] | 563 | "xyz.openbmc_project.Sensor.Threshold.Critical"; |
Dhruvaraj Subhashchandran | 5c0beec | 2018-01-23 04:47:06 -0600 | [diff] [blame] | 564 | |
| 565 | sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; |
| 566 | |
Tom Joseph | 0ac0dd2 | 2018-02-16 09:14:45 +0530 | [diff] [blame] | 567 | const auto iter = sensors.find(sensorNum); |
| 568 | const auto info = iter->second; |
| 569 | |
| 570 | auto service = ipmi::getService(bus, info.sensorInterface, info.sensorPath); |
| 571 | |
| 572 | auto warnThresholds = ipmi::getAllDbusProperties(bus, |
| 573 | service, |
| 574 | info.sensorPath, |
| 575 | warningThreshIntf); |
| 576 | |
| 577 | double warnLow = warnThresholds["WarningLow"].get<int64_t>(); |
| 578 | double warnHigh = warnThresholds["WarningHigh"].get<int64_t>(); |
| 579 | |
| 580 | if (warnLow != 0) |
| 581 | { |
| 582 | warnLow *= pow(10, info.scale - info.exponentR); |
| 583 | response->lowerNonCritical = static_cast<uint8_t>(( |
| 584 | warnLow - info.scaledOffset) / info.coefficientM); |
| 585 | response->validMask |= static_cast<uint8_t>( |
| 586 | ipmi::sensor::ThresholdMask::NON_CRITICAL_LOW_MASK); |
| 587 | } |
| 588 | |
| 589 | if (warnHigh != 0) |
| 590 | { |
| 591 | warnHigh *= pow(10, info.scale - info.exponentR); |
| 592 | response->upperNonCritical = static_cast<uint8_t>(( |
| 593 | warnHigh - info.scaledOffset) / info.coefficientM); |
| 594 | response->validMask |= static_cast<uint8_t>( |
| 595 | ipmi::sensor::ThresholdMask::NON_CRITICAL_HIGH_MASK); |
| 596 | } |
| 597 | |
| 598 | auto critThresholds = ipmi::getAllDbusProperties(bus, |
| 599 | service, |
| 600 | info.sensorPath, |
| 601 | criticalThreshIntf); |
| 602 | double critLow = critThresholds["CriticalLow"].get<int64_t>(); |
| 603 | double critHigh = critThresholds["CriticalHigh"].get<int64_t>(); |
| 604 | |
| 605 | if (critLow != 0) |
| 606 | { |
| 607 | critLow *= pow(10, info.scale - info.exponentR); |
| 608 | response->lowerCritical = static_cast<uint8_t>(( |
| 609 | critLow - info.scaledOffset) / info.coefficientM); |
| 610 | response->validMask |= static_cast<uint8_t>( |
| 611 | ipmi::sensor::ThresholdMask::CRITICAL_LOW_MASK); |
| 612 | } |
| 613 | |
| 614 | if (critHigh != 0) |
| 615 | { |
| 616 | critHigh *= pow(10, info.scale - info.exponentR); |
| 617 | response->upperCritical = static_cast<uint8_t>(( |
| 618 | critHigh - info.scaledOffset)/ info.coefficientM); |
| 619 | response->validMask |= static_cast<uint8_t>( |
| 620 | ipmi::sensor::ThresholdMask::CRITICAL_HIGH_MASK); |
| 621 | } |
| 622 | } |
| 623 | |
| 624 | ipmi_ret_t ipmi_sen_get_sensor_thresholds(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 625 | ipmi_request_t request, ipmi_response_t response, |
| 626 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 627 | { |
| 628 | constexpr auto valueInterface = "xyz.openbmc_project.Sensor.Value"; |
| 629 | |
Dhruvaraj Subhashchandran | 5c0beec | 2018-01-23 04:47:06 -0600 | [diff] [blame] | 630 | if (*data_len != sizeof(uint8_t)) |
| 631 | { |
Tom Joseph | 0ac0dd2 | 2018-02-16 09:14:45 +0530 | [diff] [blame] | 632 | *data_len = 0; |
Dhruvaraj Subhashchandran | 5c0beec | 2018-01-23 04:47:06 -0600 | [diff] [blame] | 633 | return IPMI_CC_REQ_DATA_LEN_INVALID; |
| 634 | } |
Dhruvaraj Subhashchandran | 5c0beec | 2018-01-23 04:47:06 -0600 | [diff] [blame] | 635 | |
Tom Joseph | 0ac0dd2 | 2018-02-16 09:14:45 +0530 | [diff] [blame] | 636 | auto sensorNum = *(reinterpret_cast<const uint8_t *>(request)); |
| 637 | *data_len = 0; |
Dhruvaraj Subhashchandran | 5c0beec | 2018-01-23 04:47:06 -0600 | [diff] [blame] | 638 | |
| 639 | const auto iter = sensors.find(sensorNum); |
| 640 | if (iter == sensors.end()) |
| 641 | { |
| 642 | return IPMI_CC_SENSOR_INVALID; |
| 643 | } |
| 644 | |
Tom Joseph | 0ac0dd2 | 2018-02-16 09:14:45 +0530 | [diff] [blame] | 645 | const auto info = iter->second; |
Dhruvaraj Subhashchandran | 5c0beec | 2018-01-23 04:47:06 -0600 | [diff] [blame] | 646 | |
| 647 | //Proceed only if the sensor value interface is implemented. |
Tom Joseph | 0ac0dd2 | 2018-02-16 09:14:45 +0530 | [diff] [blame] | 648 | if (info.propertyInterfaces.find(valueInterface) == |
| 649 | info.propertyInterfaces.end()) |
Dhruvaraj Subhashchandran | 5c0beec | 2018-01-23 04:47:06 -0600 | [diff] [blame] | 650 | { |
| 651 | //return with valid mask as 0 |
| 652 | return IPMI_CC_OK; |
| 653 | } |
| 654 | |
Tom Joseph | 0ac0dd2 | 2018-02-16 09:14:45 +0530 | [diff] [blame] | 655 | auto responseData = |
| 656 | reinterpret_cast<get_sdr::GetSensorThresholdsResponse*>(response); |
Dhruvaraj Subhashchandran | 5c0beec | 2018-01-23 04:47:06 -0600 | [diff] [blame] | 657 | |
| 658 | try |
| 659 | { |
Tom Joseph | 0ac0dd2 | 2018-02-16 09:14:45 +0530 | [diff] [blame] | 660 | getSensorThresholds(sensorNum, responseData); |
Dhruvaraj Subhashchandran | 5c0beec | 2018-01-23 04:47:06 -0600 | [diff] [blame] | 661 | } |
Tom Joseph | 0ac0dd2 | 2018-02-16 09:14:45 +0530 | [diff] [blame] | 662 | catch (std::exception& e) |
Dhruvaraj Subhashchandran | 5c0beec | 2018-01-23 04:47:06 -0600 | [diff] [blame] | 663 | { |
Tom Joseph | 0ac0dd2 | 2018-02-16 09:14:45 +0530 | [diff] [blame] | 664 | //Mask if the property is not present |
Dhruvaraj Subhashchandran | 5c0beec | 2018-01-23 04:47:06 -0600 | [diff] [blame] | 665 | responseData->validMask = 0; |
| 666 | } |
| 667 | |
| 668 | *data_len = sizeof(get_sdr::GetSensorThresholdsResponse); |
| 669 | return IPMI_CC_OK; |
| 670 | } |
| 671 | |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 672 | ipmi_ret_t ipmi_sen_wildcard(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 673 | ipmi_request_t request, ipmi_response_t response, |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 674 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 675 | { |
Nan Li | 70aa8d9 | 2016-08-29 00:11:10 +0800 | [diff] [blame] | 676 | ipmi_ret_t rc = IPMI_CC_INVALID; |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 677 | |
| 678 | printf("IPMI S/E Wildcard Netfn:[0x%X], Cmd:[0x%X]\n",netfn,cmd); |
| 679 | *data_len = 0; |
| 680 | |
| 681 | return rc; |
| 682 | } |
| 683 | |
Emily Shaffer | d06e0e7 | 2017-04-05 09:08:57 -0700 | [diff] [blame] | 684 | ipmi_ret_t ipmi_sen_get_sdr_info(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 685 | ipmi_request_t request, |
| 686 | ipmi_response_t response, |
| 687 | ipmi_data_len_t data_len, |
| 688 | ipmi_context_t context) |
| 689 | { |
| 690 | auto resp = static_cast<get_sdr_info::GetSdrInfoResp*>(response); |
| 691 | if (request == nullptr || |
| 692 | get_sdr_info::request::get_count(request) == false) |
| 693 | { |
| 694 | // Get Sensor Count |
Ratan Gupta | e0cc855 | 2018-01-22 14:23:04 +0530 | [diff] [blame] | 695 | resp->count = sensors.size() + frus.size(); |
Emily Shaffer | d06e0e7 | 2017-04-05 09:08:57 -0700 | [diff] [blame] | 696 | } |
| 697 | else |
| 698 | { |
| 699 | resp->count = 1; |
| 700 | } |
| 701 | |
| 702 | // Multiple LUNs not supported. |
| 703 | namespace response = get_sdr_info::response; |
| 704 | response::set_lun_present(0, &(resp->luns_and_dynamic_population)); |
| 705 | response::set_lun_not_present(1, &(resp->luns_and_dynamic_population)); |
| 706 | response::set_lun_not_present(2, &(resp->luns_and_dynamic_population)); |
| 707 | response::set_lun_not_present(3, &(resp->luns_and_dynamic_population)); |
| 708 | response::set_static_population(&(resp->luns_and_dynamic_population)); |
| 709 | |
| 710 | *data_len = SDR_INFO_RESP_SIZE; |
| 711 | |
| 712 | return IPMI_CC_OK; |
| 713 | } |
| 714 | |
Emily Shaffer | a344afc | 2017-04-13 15:09:39 -0700 | [diff] [blame] | 715 | ipmi_ret_t ipmi_sen_reserve_sdr(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 716 | ipmi_request_t request, |
| 717 | ipmi_response_t response, |
| 718 | ipmi_data_len_t data_len, |
| 719 | ipmi_context_t context) |
| 720 | { |
| 721 | // A constant reservation ID is okay until we implement add/remove SDR. |
| 722 | const uint16_t reservation_id = 1; |
| 723 | *(uint16_t*)response = reservation_id; |
Emily Shaffer | 5a5a628 | 2017-08-15 11:17:17 -0700 | [diff] [blame] | 724 | *data_len = sizeof(uint16_t); |
Emily Shaffer | a344afc | 2017-04-13 15:09:39 -0700 | [diff] [blame] | 725 | |
| 726 | printf("Created new IPMI SDR reservation ID %d\n", *(uint16_t*)response); |
| 727 | return IPMI_CC_OK; |
| 728 | } |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 729 | |
Tom Joseph | dc212b2 | 2018-02-16 09:59:57 +0530 | [diff] [blame] | 730 | void setUnitFieldsForObject(const ipmi::sensor::Info *info, |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 731 | get_sdr::SensorDataFullRecordBody *body) |
| 732 | { |
Tom Joseph | dc212b2 | 2018-02-16 09:59:57 +0530 | [diff] [blame] | 733 | namespace server = sdbusplus::xyz::openbmc_project::Sensor::server; |
| 734 | try |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 735 | { |
Tom Joseph | dc212b2 | 2018-02-16 09:59:57 +0530 | [diff] [blame] | 736 | auto unit = server::Value::convertUnitFromString(info->unit); |
| 737 | // Unit strings defined in |
| 738 | // phosphor-dbus-interfaces/xyz/openbmc_project/Sensor/Value.interface.yaml |
| 739 | switch (unit) |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 740 | { |
Tom Joseph | dc212b2 | 2018-02-16 09:59:57 +0530 | [diff] [blame] | 741 | case server::Value::Unit::DegreesC: |
| 742 | body->sensor_units_2_base = get_sdr::SENSOR_UNIT_DEGREES_C; |
| 743 | break; |
| 744 | case server::Value::Unit::RPMS: |
| 745 | body->sensor_units_2_base = get_sdr::SENSOR_UNIT_REVOLUTIONS; // revolutions |
| 746 | get_sdr::body::set_rate_unit(0b100, body); // per minute |
| 747 | break; |
| 748 | case server::Value::Unit::Volts: |
| 749 | body->sensor_units_2_base = get_sdr::SENSOR_UNIT_VOLTS; |
| 750 | break; |
| 751 | case server::Value::Unit::Meters: |
| 752 | body->sensor_units_2_base = get_sdr::SENSOR_UNIT_METERS; |
| 753 | break; |
| 754 | case server::Value::Unit::Amperes: |
| 755 | body->sensor_units_2_base = get_sdr::SENSOR_UNIT_AMPERES; |
| 756 | break; |
| 757 | case server::Value::Unit::Joules: |
| 758 | body->sensor_units_2_base = get_sdr::SENSOR_UNIT_JOULES; |
| 759 | break; |
| 760 | case server::Value::Unit::Watts: |
| 761 | body->sensor_units_2_base = get_sdr::SENSOR_UNIT_WATTS; |
| 762 | break; |
| 763 | default: |
| 764 | // Cannot be hit. |
| 765 | fprintf(stderr, "Unknown value unit type: = %s\n", |
| 766 | info->unit.c_str()); |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 767 | } |
| 768 | } |
Tom Joseph | dc212b2 | 2018-02-16 09:59:57 +0530 | [diff] [blame] | 769 | catch (sdbusplus::exception::InvalidEnumString e) |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 770 | { |
Tom Joseph | dc212b2 | 2018-02-16 09:59:57 +0530 | [diff] [blame] | 771 | log<level::WARNING>("Warning: no unit provided for sensor!"); |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 772 | } |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 773 | } |
| 774 | |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 775 | ipmi_ret_t populate_record_from_dbus(get_sdr::SensorDataFullRecordBody *body, |
| 776 | const ipmi::sensor::Info *info, |
| 777 | ipmi_data_len_t data_len) |
| 778 | { |
| 779 | /* Functional sensor case */ |
Emily Shaffer | cc941e1 | 2017-06-14 13:06:26 -0700 | [diff] [blame] | 780 | if (isAnalogSensor(info->propertyInterfaces.begin()->first)) |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 781 | { |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 782 | |
| 783 | body->sensor_units_1 = 0; // unsigned, no rate, no modifier, not a % |
| 784 | |
| 785 | /* Unit info */ |
Tom Joseph | dc212b2 | 2018-02-16 09:59:57 +0530 | [diff] [blame] | 786 | setUnitFieldsForObject(info, body); |
Emily Shaffer | 10f4959 | 2017-05-10 12:01:10 -0700 | [diff] [blame] | 787 | |
| 788 | get_sdr::body::set_b(info->coefficientB, body); |
| 789 | get_sdr::body::set_m(info->coefficientM, body); |
| 790 | get_sdr::body::set_b_exp(info->exponentB, body); |
Tom Joseph | dc212b2 | 2018-02-16 09:59:57 +0530 | [diff] [blame] | 791 | get_sdr::body::set_r_exp(info->exponentR, body); |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 792 | |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 793 | get_sdr::body::set_id_type(0b00, body); // 00 = unicode |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 794 | } |
| 795 | |
Tom Joseph | 9642391 | 2018-01-25 00:14:34 +0530 | [diff] [blame] | 796 | /* ID string */ |
| 797 | auto id_string = info->sensorNameFunc(*info); |
| 798 | |
| 799 | if (id_string.length() > FULL_RECORD_ID_STR_MAX_LENGTH) |
| 800 | { |
| 801 | get_sdr::body::set_id_strlen(FULL_RECORD_ID_STR_MAX_LENGTH, body); |
| 802 | } |
| 803 | else |
| 804 | { |
| 805 | get_sdr::body::set_id_strlen(id_string.length(), body); |
| 806 | } |
| 807 | strncpy(body->id_string, id_string.c_str(), |
| 808 | get_sdr::body::get_id_strlen(body)); |
| 809 | |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 810 | return IPMI_CC_OK; |
| 811 | }; |
| 812 | |
Ratan Gupta | e0cc855 | 2018-01-22 14:23:04 +0530 | [diff] [blame] | 813 | ipmi_ret_t ipmi_fru_get_sdr(ipmi_request_t request, ipmi_response_t response, |
| 814 | ipmi_data_len_t data_len) |
| 815 | { |
| 816 | auto req = reinterpret_cast<get_sdr::GetSdrReq*>(request); |
| 817 | auto resp = reinterpret_cast<get_sdr::GetSdrResp*>(response); |
| 818 | get_sdr::SensorDataFruRecord record {}; |
| 819 | auto dataLength = 0; |
| 820 | |
| 821 | auto fru = frus.begin(); |
| 822 | uint8_t fruID {}; |
| 823 | auto recordID = get_sdr::request::get_record_id(req); |
| 824 | |
| 825 | fruID = recordID - FRU_RECORD_ID_START; |
| 826 | fru = frus.find(fruID); |
| 827 | if (fru == frus.end()) |
| 828 | { |
| 829 | return IPMI_CC_SENSOR_INVALID; |
| 830 | } |
| 831 | |
| 832 | /* Header */ |
| 833 | get_sdr::header::set_record_id(recordID, &(record.header)); |
| 834 | record.header.sdr_version = SDR_VERSION; // Based on IPMI Spec v2.0 rev 1.1 |
| 835 | record.header.record_type = get_sdr::SENSOR_DATA_FRU_RECORD; |
| 836 | record.header.record_length = sizeof(record.key) + sizeof(record.body); |
| 837 | |
| 838 | /* Key */ |
| 839 | record.key.fruID = fruID; |
| 840 | record.key.accessLun |= IPMI_LOGICAL_FRU; |
| 841 | record.key.deviceAddress = BMCSlaveAddress; |
| 842 | |
| 843 | /* Body */ |
| 844 | record.body.entityID = fru->second[0].entityID; |
| 845 | record.body.entityInstance = fru->second[0].entityInstance; |
| 846 | record.body.deviceType = fruInventoryDevice; |
| 847 | record.body.deviceTypeModifier = IPMIFruInventory; |
| 848 | |
| 849 | /* Device ID string */ |
| 850 | auto deviceID = fru->second[0].path.substr( |
| 851 | fru->second[0].path.find_last_of('/') + 1, |
| 852 | fru->second[0].path.length()); |
| 853 | |
| 854 | |
| 855 | if (deviceID.length() > get_sdr::FRU_RECORD_DEVICE_ID_MAX_LENGTH) |
| 856 | { |
| 857 | get_sdr::body::set_device_id_strlen( |
| 858 | get_sdr::FRU_RECORD_DEVICE_ID_MAX_LENGTH, |
| 859 | &(record.body)); |
| 860 | } |
| 861 | else |
| 862 | { |
| 863 | get_sdr::body::set_device_id_strlen(deviceID.length(), |
| 864 | &(record.body)); |
| 865 | } |
| 866 | |
| 867 | strncpy(record.body.deviceID, deviceID.c_str(), |
| 868 | get_sdr::body::get_device_id_strlen(&(record.body))); |
| 869 | |
| 870 | if (++fru == frus.end()) |
| 871 | { |
| 872 | get_sdr::response::set_next_record_id(END_OF_RECORD, resp); // last record |
| 873 | } |
| 874 | else |
| 875 | { |
| 876 | get_sdr::response::set_next_record_id( |
| 877 | (FRU_RECORD_ID_START + fru->first), resp); |
| 878 | } |
| 879 | |
| 880 | if (req->bytes_to_read > (sizeof(*resp) - req->offset)) |
| 881 | { |
| 882 | dataLength = (sizeof(*resp) - req->offset); |
| 883 | } |
| 884 | else |
| 885 | { |
| 886 | dataLength = req->bytes_to_read; |
| 887 | } |
| 888 | |
| 889 | if (dataLength <= 0) |
| 890 | { |
| 891 | return IPMI_CC_REQ_DATA_LEN_INVALID; |
| 892 | } |
| 893 | |
| 894 | memcpy(resp->record_data, |
| 895 | reinterpret_cast<uint8_t*>(&record) + req->offset, |
| 896 | (dataLength)); |
| 897 | |
| 898 | *data_len = dataLength; |
| 899 | *data_len += 2; // additional 2 bytes for next record ID |
| 900 | |
| 901 | return IPMI_CC_OK; |
| 902 | } |
| 903 | |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 904 | ipmi_ret_t ipmi_sen_get_sdr(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 905 | ipmi_request_t request, ipmi_response_t response, |
| 906 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 907 | { |
| 908 | ipmi_ret_t ret = IPMI_CC_OK; |
| 909 | get_sdr::GetSdrReq *req = (get_sdr::GetSdrReq*)request; |
| 910 | get_sdr::GetSdrResp *resp = (get_sdr::GetSdrResp*)response; |
| 911 | get_sdr::SensorDataFullRecord record = {0}; |
| 912 | if (req != NULL) |
| 913 | { |
| 914 | // Note: we use an iterator so we can provide the next ID at the end of |
| 915 | // the call. |
| 916 | auto sensor = sensors.begin(); |
Ratan Gupta | e0cc855 | 2018-01-22 14:23:04 +0530 | [diff] [blame] | 917 | auto recordID = get_sdr::request::get_record_id(req); |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 918 | |
| 919 | // At the beginning of a scan, the host side will send us id=0. |
Ratan Gupta | e0cc855 | 2018-01-22 14:23:04 +0530 | [diff] [blame] | 920 | if (recordID != 0) |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 921 | { |
Ratan Gupta | e0cc855 | 2018-01-22 14:23:04 +0530 | [diff] [blame] | 922 | // recordID greater then 255,it means it is a FRU record. |
| 923 | // Currently we are supporting two record types either FULL record |
| 924 | // or FRU record. |
| 925 | if (recordID >= FRU_RECORD_ID_START) |
| 926 | { |
| 927 | return ipmi_fru_get_sdr(request, response, data_len); |
| 928 | } |
| 929 | else |
| 930 | { |
| 931 | sensor = sensors.find(recordID); |
| 932 | if (sensor == sensors.end()) |
| 933 | { |
| 934 | return IPMI_CC_SENSOR_INVALID; |
| 935 | } |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 936 | } |
| 937 | } |
| 938 | |
| 939 | uint8_t sensor_id = sensor->first; |
| 940 | |
| 941 | /* Header */ |
| 942 | get_sdr::header::set_record_id(sensor_id, &(record.header)); |
| 943 | record.header.sdr_version = 0x51; // Based on IPMI Spec v2.0 rev 1.1 |
| 944 | record.header.record_type = get_sdr::SENSOR_DATA_FULL_RECORD; |
| 945 | record.header.record_length = sizeof(get_sdr::SensorDataFullRecord); |
| 946 | |
| 947 | /* Key */ |
Tom Joseph | 9642391 | 2018-01-25 00:14:34 +0530 | [diff] [blame] | 948 | get_sdr::key::set_owner_id_bmc(&(record.key)); |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 949 | record.key.sensor_number = sensor_id; |
| 950 | |
| 951 | /* Body */ |
Tom Joseph | 9642391 | 2018-01-25 00:14:34 +0530 | [diff] [blame] | 952 | record.body.entity_id = sensor->second.entityType; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 953 | record.body.sensor_type = sensor->second.sensorType; |
| 954 | record.body.event_reading_type = sensor->second.sensorReadingType; |
Tom Joseph | 9642391 | 2018-01-25 00:14:34 +0530 | [diff] [blame] | 955 | record.body.entity_instance = sensor->second.instance; |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 956 | |
| 957 | // Set the type-specific details given the DBus interface |
| 958 | ret = populate_record_from_dbus(&(record.body), &(sensor->second), |
| 959 | data_len); |
| 960 | |
| 961 | if (++sensor == sensors.end()) |
| 962 | { |
Ratan Gupta | e0cc855 | 2018-01-22 14:23:04 +0530 | [diff] [blame] | 963 | // we have reached till end of sensor, so assign the next record id |
| 964 | // to 256(Max Sensor ID = 255) + FRU ID(may start with 0). |
| 965 | auto next_record_id = (frus.size()) ? |
| 966 | frus.begin()->first + FRU_RECORD_ID_START : |
| 967 | END_OF_RECORD; |
| 968 | |
| 969 | get_sdr::response::set_next_record_id(next_record_id, resp); |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 970 | } |
| 971 | else |
| 972 | { |
| 973 | get_sdr::response::set_next_record_id(sensor->first, resp); |
| 974 | } |
| 975 | |
| 976 | *data_len = sizeof(get_sdr::GetSdrResp) - req->offset; |
| 977 | memcpy(resp->record_data, (char*)&record + req->offset, |
| 978 | sizeof(get_sdr::SensorDataFullRecord) - req->offset); |
| 979 | } |
| 980 | |
| 981 | return ret; |
| 982 | } |
| 983 | |
| 984 | |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 985 | void register_netfn_sen_functions() |
| 986 | { |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 987 | // <Wildcard Command> |
Emily Shaffer | a344afc | 2017-04-13 15:09:39 -0700 | [diff] [blame] | 988 | printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n", |
| 989 | NETFUN_SENSOR, IPMI_CMD_WILDCARD); |
| 990 | ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_WILDCARD, |
| 991 | nullptr, ipmi_sen_wildcard, |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 992 | PRIVILEGE_USER); |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 993 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 994 | // <Get Sensor Type> |
Emily Shaffer | a344afc | 2017-04-13 15:09:39 -0700 | [diff] [blame] | 995 | printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n", |
| 996 | NETFUN_SENSOR, IPMI_CMD_GET_SENSOR_TYPE); |
| 997 | ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_GET_SENSOR_TYPE, |
| 998 | nullptr, ipmi_sen_get_sensor_type, |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 999 | PRIVILEGE_USER); |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 1000 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 1001 | // <Set Sensor Reading and Event Status> |
Emily Shaffer | a344afc | 2017-04-13 15:09:39 -0700 | [diff] [blame] | 1002 | printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n", |
| 1003 | NETFUN_SENSOR, IPMI_CMD_SET_SENSOR); |
| 1004 | ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_SET_SENSOR, |
| 1005 | nullptr, ipmi_sen_set_sensor, |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 1006 | PRIVILEGE_OPERATOR); |
Chris Austen | 8a45e7c | 2015-10-15 00:31:46 -0500 | [diff] [blame] | 1007 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 1008 | // <Get Sensor Reading> |
Emily Shaffer | a344afc | 2017-04-13 15:09:39 -0700 | [diff] [blame] | 1009 | printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n", |
| 1010 | NETFUN_SENSOR, IPMI_CMD_GET_SENSOR_READING); |
| 1011 | ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_GET_SENSOR_READING, |
| 1012 | nullptr, ipmi_sen_get_sensor_reading, |
| 1013 | PRIVILEGE_USER); |
| 1014 | |
Tom Joseph | 5ca5095 | 2018-02-22 00:33:38 +0530 | [diff] [blame] | 1015 | // <Reserve Device SDR Repository> |
| 1016 | ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_RESERVE_DEVICE_SDR_REPO, |
Emily Shaffer | a344afc | 2017-04-13 15:09:39 -0700 | [diff] [blame] | 1017 | nullptr, ipmi_sen_reserve_sdr, |
| 1018 | PRIVILEGE_USER); |
Chris Austen | 10ccc0f | 2015-12-10 18:27:04 -0600 | [diff] [blame] | 1019 | |
Tom Joseph | 5ca5095 | 2018-02-22 00:33:38 +0530 | [diff] [blame] | 1020 | // <Get Device SDR Info> |
| 1021 | ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_GET_DEVICE_SDR_INFO, |
Emily Shaffer | a344afc | 2017-04-13 15:09:39 -0700 | [diff] [blame] | 1022 | nullptr, ipmi_sen_get_sdr_info, |
| 1023 | PRIVILEGE_USER); |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 1024 | |
Tom Joseph | 5ca5095 | 2018-02-22 00:33:38 +0530 | [diff] [blame] | 1025 | // <Get Device SDR> |
| 1026 | ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_GET_DEVICE_SDR, |
Emily Shaffer | bbef71c | 2017-05-08 16:36:17 -0700 | [diff] [blame] | 1027 | nullptr, ipmi_sen_get_sdr, |
| 1028 | PRIVILEGE_USER); |
| 1029 | |
Dhruvaraj Subhashchandran | 5c0beec | 2018-01-23 04:47:06 -0600 | [diff] [blame] | 1030 | // <Get Sensor Thresholds> |
| 1031 | ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_GET_SENSOR_THRESHOLDS, |
| 1032 | nullptr, ipmi_sen_get_sensor_thresholds, |
| 1033 | PRIVILEGE_USER); |
| 1034 | |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 1035 | return; |
| 1036 | } |