blob: 69f1911cf30f67ba3d2ec8d9a6d8e0d9066f16ef [file] [log] [blame]
Tomd700e762016-09-20 18:24:13 +05301#include <mapper.h>
Chris Austenac4604a2015-10-13 12:43:27 -05002#include <stdio.h>
3#include <string.h>
Tom Josephbe703f72017-03-09 12:34:35 +05304#include <bitset>
Chris Austen10ccc0f2015-12-10 18:27:04 -06005#include <systemd/sd-bus.h>
Tom Josephbe703f72017-03-09 12:34:35 +05306#include "host-ipmid/ipmid-api.h"
7#include <phosphor-logging/log.hpp>
Tomd700e762016-09-20 18:24:13 +05308#include "ipmid.hpp"
Tom Josephbe703f72017-03-09 12:34:35 +05309#include "sensorhandler.h"
10#include "types.hpp"
11#include "utils.hpp"
Chris Austenac4604a2015-10-13 12:43:27 -050012
Chris Austen8a45e7c2015-10-15 00:31:46 -050013extern int updateSensorRecordFromSSRAESC(const void *);
Tomd700e762016-09-20 18:24:13 +053014extern sd_bus *bus;
Tom Josephbe703f72017-03-09 12:34:35 +053015extern const ipmi::sensor::IdInfoMap sensors;
16using namespace phosphor::logging;
Chris Austenac4604a2015-10-13 12:43:27 -050017
18void register_netfn_sen_functions() __attribute__((constructor));
19
Chris Austen0012e9b2015-10-22 01:37:46 -050020struct sensorTypemap_t {
21 uint8_t number;
Chris Austend7cf0e42015-11-07 14:27:12 -060022 uint8_t typecode;
Chris Austen0012e9b2015-10-22 01:37:46 -050023 char dbusname[32];
24} ;
25
26
27sensorTypemap_t g_SensorTypeMap[] = {
28
Chris Austend7cf0e42015-11-07 14:27:12 -060029 {0x01, 0x6F, "Temp"},
30 {0x0C, 0x6F, "DIMM"},
31 {0x0C, 0x6F, "MEMORY_BUFFER"},
32 {0x07, 0x6F, "PROC"},
33 {0x07, 0x6F, "CORE"},
34 {0x07, 0x6F, "CPU"},
35 {0x0F, 0x6F, "BootProgress"},
36 {0xe9, 0x09, "OccStatus"}, // E9 is an internal mapping to handle sensor type code os 0x09
37 {0xC3, 0x6F, "BootCount"},
38 {0x1F, 0x6F, "OperatingSystemStatus"},
Chris Austen800ba712015-12-03 15:31:00 -060039 {0x12, 0x6F, "SYSTEM_EVENT"},
40 {0xC7, 0x03, "SYSTEM"},
41 {0xC7, 0x03, "MAIN_PLANAR"},
Chris Austen10ccc0f2015-12-10 18:27:04 -060042 {0xC2, 0x6F, "PowerCap"},
Dhruvaraj S07248292017-03-21 02:14:52 -050043 {0xD8, 0x03, "PowerSupplyRedundancy"},
Jayanth Othayoth0661beb2017-03-22 06:00:58 -050044 {0xDA, 0x03, "TurboAllowed"},
Jayanth Othayothd5b2ac02017-03-27 08:19:18 -050045 {0xB4, 0x6F, "PowerSupplyDerating"},
Chris Austend7cf0e42015-11-07 14:27:12 -060046 {0xFF, 0x00, ""},
Chris Austen0012e9b2015-10-22 01:37:46 -050047};
48
49
Chris Austenac4604a2015-10-13 12:43:27 -050050struct sensor_data_t {
51 uint8_t sennum;
52} __attribute__ ((packed)) ;
53
Chris Austen10ccc0f2015-12-10 18:27:04 -060054struct sensorreadingresp_t {
55 uint8_t value;
56 uint8_t operation;
57 uint8_t indication[2];
58} __attribute__ ((packed)) ;
Chris Austenac4604a2015-10-13 12:43:27 -050059
Tomd700e762016-09-20 18:24:13 +053060// Use a lookup table to find the interface name of a specific sensor
61// This will be used until an alternative is found. this is the first
62// step for mapping IPMI
63int find_interface_property_fru_type(dbus_interface_t *interface, const char *property_name, char *property_value) {
64
65 char *str1;
66 sd_bus_error error = SD_BUS_ERROR_NULL;
67 sd_bus_message *reply = NULL, *m=NULL;
68
69
70 int r;
71
72 r = sd_bus_message_new_method_call(bus,&m,interface->bus,interface->path,"org.freedesktop.DBus.Properties","Get");
73 if (r < 0) {
74 fprintf(stderr, "Failed to create a method call: %s", strerror(-r));
75 fprintf(stderr,"Bus: %s Path: %s Interface: %s \n",
76 interface->bus, interface->path, interface->interface);
77 goto final;
78 }
79
80 r = sd_bus_message_append(m, "ss", "org.openbmc.InventoryItem", property_name);
81 if (r < 0) {
82 fprintf(stderr, "Failed to create a input parameter: %s", strerror(-r));
83 fprintf(stderr,"Bus: %s Path: %s Interface: %s \n",
84 interface->bus, interface->path, interface->interface);
85 goto final;
86 }
87
88 r = sd_bus_call(bus, m, 0, &error, &reply);
89 if (r < 0) {
90 fprintf(stderr, "Failed to call the method: %s", strerror(-r));
91 goto final;
92 }
93
94 r = sd_bus_message_read(reply, "v", "s", &str1) ;
95 if (r < 0) {
96 fprintf(stderr, "Failed to get a response: %s", strerror(-r));
97 goto final;
98 }
99
100 strcpy(property_value, str1);
101
102final:
103
104 sd_bus_error_free(&error);
105 m = sd_bus_message_unref(m);
106 reply = sd_bus_message_unref(reply);
107
108 return r;
109}
110
111
112// Use a lookup table to find the interface name of a specific sensor
113// This will be used until an alternative is found. this is the first
114// step for mapping IPMI
115int find_openbmc_path(const char *type, const uint8_t num, dbus_interface_t *interface) {
116 char *busname = NULL;
117 const char *iface = "org.openbmc.managers.System";
118 const char *objname = "/org/openbmc/managers/System";
119 char *str1 = NULL, *str2, *str3;
120 sd_bus_error error = SD_BUS_ERROR_NULL;
121 sd_bus_message *reply = NULL;
122
123
124 int r;
125 r = mapper_get_service(bus, objname, &busname);
126 if (r < 0) {
Brad Bishop819ddd42016-10-05 21:19:19 -0400127 fprintf(stderr, "Failed to get %s busname: %s\n",
128 objname, strerror(-r));
Tomd700e762016-09-20 18:24:13 +0530129 goto final;
130 }
131
132 r = sd_bus_call_method(bus,busname,objname,iface, "getObjectFromByteId",
133 &error, &reply, "sy", type, num);
134 if (r < 0) {
135 fprintf(stderr, "Failed to create a method call: %s", strerror(-r));
136 goto final;
137 }
138
139 r = sd_bus_message_read(reply, "(ss)", &str2, &str3);
140 if (r < 0) {
141 fprintf(stderr, "Failed to get a response: %s", strerror(-r));
142 goto final;
143 }
144
145 r = mapper_get_service(bus, str2, &str1);
146 if (r < 0) {
Brad Bishop819ddd42016-10-05 21:19:19 -0400147 fprintf(stderr, "Failed to get %s busname: %s\n",
148 str2, strerror(-r));
Tomd700e762016-09-20 18:24:13 +0530149 goto final;
150 }
151
152 strncpy(interface->bus, str1, MAX_DBUS_PATH);
153 strncpy(interface->path, str2, MAX_DBUS_PATH);
154 strncpy(interface->interface, str3, MAX_DBUS_PATH);
155
156 interface->sensornumber = num;
157
158final:
159
160 sd_bus_error_free(&error);
161 reply = sd_bus_message_unref(reply);
162 free(busname);
163 free(str1);
164
165 return r;
166}
167
168
169/////////////////////////////////////////////////////////////////////
170//
171// Routines used by ipmi commands wanting to interact on the dbus
172//
173/////////////////////////////////////////////////////////////////////
174int set_sensor_dbus_state_s(uint8_t number, const char *method, const char *value) {
175
176
177 dbus_interface_t a;
178 int r;
179 sd_bus_error error = SD_BUS_ERROR_NULL;
180 sd_bus_message *m=NULL;
181
182 fprintf(ipmidbus, "Attempting to set a dbus Variant Sensor 0x%02x via %s with a value of %s\n",
183 number, method, value);
184
185 r = find_openbmc_path("SENSOR", number, &a);
186
187 if (r < 0) {
188 fprintf(stderr, "Failed to find Sensor 0x%02x\n", number);
189 return 0;
190 }
191
192 r = sd_bus_message_new_method_call(bus,&m,a.bus,a.path,a.interface,method);
193 if (r < 0) {
194 fprintf(stderr, "Failed to create a method call: %s", strerror(-r));
195 goto final;
196 }
197
198 r = sd_bus_message_append(m, "v", "s", value);
199 if (r < 0) {
200 fprintf(stderr, "Failed to create a input parameter: %s", strerror(-r));
201 goto final;
202 }
203
204
205 r = sd_bus_call(bus, m, 0, &error, NULL);
206 if (r < 0) {
207 fprintf(stderr, "Failed to call the method: %s", strerror(-r));
208 }
209
210final:
211 sd_bus_error_free(&error);
212 m = sd_bus_message_unref(m);
213
214 return 0;
215}
216int set_sensor_dbus_state_y(uint8_t number, const char *method, const uint8_t value) {
217
218
219 dbus_interface_t a;
220 int r;
221 sd_bus_error error = SD_BUS_ERROR_NULL;
222 sd_bus_message *m=NULL;
223
224 fprintf(ipmidbus, "Attempting to set a dbus Variant Sensor 0x%02x via %s with a value of 0x%02x\n",
225 number, method, value);
226
227 r = find_openbmc_path("SENSOR", number, &a);
228
229 if (r < 0) {
230 fprintf(stderr, "Failed to find Sensor 0x%02x\n", number);
231 return 0;
232 }
233
234 r = sd_bus_message_new_method_call(bus,&m,a.bus,a.path,a.interface,method);
235 if (r < 0) {
236 fprintf(stderr, "Failed to create a method call: %s", strerror(-r));
237 goto final;
238 }
239
240 r = sd_bus_message_append(m, "v", "i", value);
241 if (r < 0) {
242 fprintf(stderr, "Failed to create a input parameter: %s", strerror(-r));
243 goto final;
244 }
245
246
247 r = sd_bus_call(bus, m, 0, &error, NULL);
248 if (r < 0) {
249 fprintf(stderr, "12 Failed to call the method: %s", strerror(-r));
250 }
251
252final:
253 sd_bus_error_free(&error);
254 m = sd_bus_message_unref(m);
255
256 return 0;
257}
258
Chris Austen0012e9b2015-10-22 01:37:46 -0500259uint8_t dbus_to_sensor_type(char *p) {
Chris Austenac4604a2015-10-13 12:43:27 -0500260
Chris Austen0012e9b2015-10-22 01:37:46 -0500261 sensorTypemap_t *s = g_SensorTypeMap;
262 char r=0;
Chris Austenac4604a2015-10-13 12:43:27 -0500263
Chris Austen0012e9b2015-10-22 01:37:46 -0500264 while (s->number != 0xFF) {
265 if (!strcmp(s->dbusname,p)) {
266 r = s->number;
267 break;
Chris Austenac4604a2015-10-13 12:43:27 -0500268 }
Chris Austen0012e9b2015-10-22 01:37:46 -0500269 s++;
Chris Austenac4604a2015-10-13 12:43:27 -0500270 }
271
Chris Austend7cf0e42015-11-07 14:27:12 -0600272
Chris Austen0012e9b2015-10-22 01:37:46 -0500273 if (s->number == 0xFF)
274 printf("Failed to find Sensor Type %s\n", p);
Chris Austenac4604a2015-10-13 12:43:27 -0500275
Chris Austen0012e9b2015-10-22 01:37:46 -0500276 return r;
Chris Austenac4604a2015-10-13 12:43:27 -0500277}
278
Chris Austen0012e9b2015-10-22 01:37:46 -0500279
280uint8_t dbus_to_sensor_type_from_dbus(dbus_interface_t *a) {
281 char fru_type_name[64];
282 int r= 0;
283
284 r = find_interface_property_fru_type(a, "fru_type", fru_type_name);
285 if (r<0) {
286 fprintf(stderr, "Failed to get a fru type: %s", strerror(-r));
287 return -1;
288 } else {
289 return dbus_to_sensor_type(fru_type_name);
290 }
291}
292
Emily Shaffer391f3302017-04-03 10:27:08 -0700293uint8_t get_type_from_interface(dbus_interface_t dbus_if) {
Chris Austen0012e9b2015-10-22 01:37:46 -0500294
Chris Austen0012e9b2015-10-22 01:37:46 -0500295 char *p;
Brad Bishop56003452016-10-05 21:49:19 -0400296 uint8_t type;
Chris Austen0012e9b2015-10-22 01:37:46 -0500297
Chris Austen0012e9b2015-10-22 01:37:46 -0500298 // This is where sensors that do not exist in dbus but do
299 // exist in the host code stop. This should indicate it
300 // is not a supported sensor
Emily Shaffer391f3302017-04-03 10:27:08 -0700301 if (dbus_if.interface[0] == 0) { return 0;}
Chris Austen0012e9b2015-10-22 01:37:46 -0500302
Emily Shaffer391f3302017-04-03 10:27:08 -0700303 if (strstr(dbus_if.interface, "InventoryItem")) {
Chris Austen0012e9b2015-10-22 01:37:46 -0500304 // InventoryItems are real frus. So need to get the
305 // fru_type property
Emily Shaffer391f3302017-04-03 10:27:08 -0700306 type = dbus_to_sensor_type_from_dbus(&dbus_if);
Chris Austen0012e9b2015-10-22 01:37:46 -0500307 } else {
308 // Non InventoryItems
Emily Shaffer391f3302017-04-03 10:27:08 -0700309 p = strrchr (dbus_if.path, '/');
Brad Bishop56003452016-10-05 21:49:19 -0400310 type = dbus_to_sensor_type(p+1);
Chris Austen0012e9b2015-10-22 01:37:46 -0500311 }
312
Brad Bishop56003452016-10-05 21:49:19 -0400313 return type;
Chris Austen0012e9b2015-10-22 01:37:46 -0500314 }
315
Emily Shaffer391f3302017-04-03 10:27:08 -0700316// Replaces find_sensor
317uint8_t find_type_for_sensor_number(uint8_t num) {
318 int r;
319 dbus_interface_t dbus_if;
320 r = find_openbmc_path("SENSOR", num, &dbus_if);
321 if (r < 0) {
322 fprintf(stderr, "Could not find sensor %d\n", num);
323 return r;
324 }
325 return get_type_from_interface(dbus_if);
326}
327
Chris Austen10ccc0f2015-12-10 18:27:04 -0600328
329
330
331
Chris Austen0012e9b2015-10-22 01:37:46 -0500332ipmi_ret_t ipmi_sen_get_sensor_type(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
333 ipmi_request_t request, ipmi_response_t response,
Chris Austenac4604a2015-10-13 12:43:27 -0500334 ipmi_data_len_t data_len, ipmi_context_t context)
335{
336 sensor_data_t *reqptr = (sensor_data_t*)request;
337 ipmi_ret_t rc = IPMI_CC_OK;
338
339 printf("IPMI GET_SENSOR_TYPE [0x%02X]\n",reqptr->sennum);
340
341 // TODO Not sure what the System-event-sensor is suppose to return
342 // need to ask Hostboot team
343 unsigned char buf[] = {0x00,0x6F};
344
Emily Shaffer391f3302017-04-03 10:27:08 -0700345 buf[0] = find_type_for_sensor_number(reqptr->sennum);
Chris Austen0012e9b2015-10-22 01:37:46 -0500346
347 // HACK UNTIL Dbus gets updated or we find a better way
348 if (buf[0] == 0) {
Chris Austen800ba712015-12-03 15:31:00 -0600349 rc = IPMI_CC_SENSOR_INVALID;
Chris Austen0012e9b2015-10-22 01:37:46 -0500350 }
351
Chris Austenac4604a2015-10-13 12:43:27 -0500352
353 *data_len = sizeof(buf);
354 memcpy(response, &buf, *data_len);
355
Chris Austenac4604a2015-10-13 12:43:27 -0500356 return rc;
357}
358
Tom Josephbe703f72017-03-09 12:34:35 +0530359ipmi_ret_t setSensorReading(void *request)
360{
361 auto cmdData = static_cast<SetSensorReadingReq *>(request);
Chris Austenac4604a2015-10-13 12:43:27 -0500362
Tom Josephbe703f72017-03-09 12:34:35 +0530363 auto assertionStates =
364 (static_cast<uint16_t>(cmdData->assertOffset8_14)) << 8 |
365 cmdData->assertOffset0_7;
366
367 auto deassertionStates =
368 (static_cast<uint16_t>(cmdData->deassertOffset8_14)) << 8 |
369 cmdData->deassertOffset0_7;
370
371 std::bitset<16> assertionSet(assertionStates);
372 std::bitset<16> deassertionSet(deassertionStates);
373
374 // Check if the Sensor Number is present
375 auto iter = sensors.find(cmdData->number);
376 if (iter == sensors.end())
377 {
378 return IPMI_CC_SENSOR_INVALID;
379 }
380
381 auto& interfaceList = iter->second.sensorInterfaces;
382 if (interfaceList.empty())
383 {
384 log<level::ERR>("Interface List empty for the sensor",
385 entry("Sensor Number = %d", cmdData->number));
386 return IPMI_CC_UNSPECIFIED_ERROR;
387 }
388
389 ipmi::sensor::ObjectMap objects;
390 ipmi::sensor::InterfaceMap interfaces;
391 for (const auto& interface : interfaceList)
392 {
393 for (const auto& property : interface.second)
394 {
395 ipmi::sensor::PropertyMap props;
396 bool valid = false;
397 for (const auto& value : property.second)
398 {
399 if (assertionSet.test(value.first))
400 {
401 props.emplace(property.first, value.second.assert);
402 valid = true;
403 }
404 else if (deassertionSet.test(value.first))
405 {
406 props.emplace(property.first, value.second.deassert);
407 valid = true;
408 }
409 }
410 if (valid)
411 {
412 interfaces.emplace(interface.first, std::move(props));
413 }
414 }
415 }
416 objects.emplace(iter->second.sensorPath, std::move(interfaces));
417
Patrick Williams4736b912017-04-18 11:50:57 -0500418 sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()};
Tom Josephbe703f72017-03-09 12:34:35 +0530419 using namespace std::string_literals;
420 static const auto intf = "xyz.openbmc_project.Inventory.Manager"s;
421 static const auto path = "/xyz/openbmc_project/inventory"s;
422 std::string service;
423
424 try
425 {
426 service = ipmi::getService(bus, intf, path);
427
428 // Update the inventory manager
429 auto pimMsg = bus.new_method_call(service.c_str(),
430 path.c_str(),
431 intf.c_str(),
432 "Notify");
433 pimMsg.append(std::move(objects));
434 auto inventoryMgrResponseMsg = bus.call(pimMsg);
435 if (inventoryMgrResponseMsg.is_method_error())
436 {
437 log<level::ERR>("Error in notify call");
438 return IPMI_CC_UNSPECIFIED_ERROR;
439 }
440 }
441 catch (const std::runtime_error& e)
442 {
443 log<level::ERR>(e.what());
444 return IPMI_CC_UNSPECIFIED_ERROR;
445 }
446
447 return IPMI_CC_OK;
448}
Chris Austenac4604a2015-10-13 12:43:27 -0500449
Chris Austen0012e9b2015-10-22 01:37:46 -0500450ipmi_ret_t ipmi_sen_set_sensor(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
451 ipmi_request_t request, ipmi_response_t response,
Chris Austenac4604a2015-10-13 12:43:27 -0500452 ipmi_data_len_t data_len, ipmi_context_t context)
453{
Chris Austenac4604a2015-10-13 12:43:27 -0500454 sensor_data_t *reqptr = (sensor_data_t*)request;
Chris Austenac4604a2015-10-13 12:43:27 -0500455
Chris Austen0012e9b2015-10-22 01:37:46 -0500456 printf("IPMI SET_SENSOR [0x%02x]\n",reqptr->sennum);
Chris Austenac4604a2015-10-13 12:43:27 -0500457
Tom Josephbe703f72017-03-09 12:34:35 +0530458 /*
459 * This would support the Set Sensor Reading command for the presence
460 * and functional state of Processor, Core & DIMM. For the remaining
461 * sensors the existing support is invoked.
462 */
463 auto ipmiRC = setSensorReading(request);
464
465 if(ipmiRC == IPMI_CC_SENSOR_INVALID)
466 {
467 updateSensorRecordFromSSRAESC(reqptr);
468 ipmiRC = IPMI_CC_OK;
469 }
Chris Austen8a45e7c2015-10-15 00:31:46 -0500470
Chris Austenac4604a2015-10-13 12:43:27 -0500471 *data_len=0;
Tom Josephbe703f72017-03-09 12:34:35 +0530472 return ipmiRC;
Chris Austenac4604a2015-10-13 12:43:27 -0500473}
474
Chris Austen10ccc0f2015-12-10 18:27:04 -0600475
476ipmi_ret_t ipmi_sen_get_sensor_reading(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
477 ipmi_request_t request, ipmi_response_t response,
478 ipmi_data_len_t data_len, ipmi_context_t context)
479{
480 sensor_data_t *reqptr = (sensor_data_t*)request;
481 ipmi_ret_t rc = IPMI_CC_SENSOR_INVALID;
482 uint8_t type;
483 sensorreadingresp_t *resp = (sensorreadingresp_t*) response;
484 int r;
485 dbus_interface_t a;
486 sd_bus *bus = ipmid_get_sd_bus_connection();
487 sd_bus_message *reply = NULL;
Adriana Kobylak93125982016-03-01 12:48:10 -0600488 int reading = 0;
Chris Austen10ccc0f2015-12-10 18:27:04 -0600489
490
491 printf("IPMI GET_SENSOR_READING [0x%02x]\n",reqptr->sennum);
492
493 r = find_openbmc_path("SENSOR", reqptr->sennum, &a);
494
Nan Li36deb762016-05-12 10:23:41 +0800495 if (r < 0) {
496 fprintf(stderr, "Failed to find Sensor 0x%02x\n", reqptr->sennum);
497 return IPMI_CC_SENSOR_INVALID;
498 }
499
Emily Shaffer391f3302017-04-03 10:27:08 -0700500 type = get_type_from_interface(a);
Brad Bishop56003452016-10-05 21:49:19 -0400501 if(type == 0) {
502 fprintf(stderr, "Failed to find Sensor 0x%02x\n", reqptr->sennum);
503 return IPMI_CC_SENSOR_INVALID;
504 }
Chris Austen10ccc0f2015-12-10 18:27:04 -0600505
506 fprintf(stderr, "Bus: %s, Path: %s, Interface: %s\n", a.bus, a.path, a.interface);
507
508 *data_len=0;
509
510 switch(type) {
511 case 0xC3:
512 case 0xC2:
Adriana Kobylak93125982016-03-01 12:48:10 -0600513 r = sd_bus_get_property(bus,a.bus, a.path, a.interface, "value", NULL, &reply, "i");
Chris Austen10ccc0f2015-12-10 18:27:04 -0600514 if (r < 0) {
515 fprintf(stderr, "Failed to call sd_bus_get_property:%d, %s\n", r, strerror(-r));
516 fprintf(stderr, "Bus: %s, Path: %s, Interface: %s\n",
517 a.bus, a.path, a.interface);
518 break;
519 }
520
Adriana Kobylak93125982016-03-01 12:48:10 -0600521 r = sd_bus_message_read(reply, "i", &reading);
Chris Austen10ccc0f2015-12-10 18:27:04 -0600522 if (r < 0) {
Adriana Kobylak93125982016-03-01 12:48:10 -0600523 fprintf(stderr, "Failed to read sensor: %s\n", strerror(-r));
Chris Austen10ccc0f2015-12-10 18:27:04 -0600524 break;
525 }
526
527 printf("Contents of a 0x%02x is 0x%02x\n", type, reading);
528
529 rc = IPMI_CC_OK;
530 *data_len=sizeof(sensorreadingresp_t);
531
Adriana Kobylak93125982016-03-01 12:48:10 -0600532 resp->value = (uint8_t)reading;
Chris Austen10ccc0f2015-12-10 18:27:04 -0600533 resp->operation = 0;
534 resp->indication[0] = 0;
535 resp->indication[1] = 0;
536 break;
537
538 default:
539 *data_len=0;
540 rc = IPMI_CC_SENSOR_INVALID;
541 break;
542 }
543
544
vishwa1eaea4f2016-02-26 11:57:40 -0600545 reply = sd_bus_message_unref(reply);
Chris Austen10ccc0f2015-12-10 18:27:04 -0600546
547 return rc;
548}
549
Chris Austen0012e9b2015-10-22 01:37:46 -0500550ipmi_ret_t ipmi_sen_wildcard(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
551 ipmi_request_t request, ipmi_response_t response,
Chris Austenac4604a2015-10-13 12:43:27 -0500552 ipmi_data_len_t data_len, ipmi_context_t context)
553{
Nan Li70aa8d92016-08-29 00:11:10 +0800554 ipmi_ret_t rc = IPMI_CC_INVALID;
Chris Austenac4604a2015-10-13 12:43:27 -0500555
556 printf("IPMI S/E Wildcard Netfn:[0x%X], Cmd:[0x%X]\n",netfn,cmd);
557 *data_len = 0;
558
559 return rc;
560}
561
562
563void register_netfn_sen_functions()
564{
Tom05732372016-09-06 17:21:23 +0530565 // <Wildcard Command>
Chris Austenac4604a2015-10-13 12:43:27 -0500566 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_SENSOR, IPMI_CMD_WILDCARD);
Tom05732372016-09-06 17:21:23 +0530567 ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_WILDCARD, NULL, ipmi_sen_wildcard,
568 PRIVILEGE_USER);
Chris Austenac4604a2015-10-13 12:43:27 -0500569
Tom05732372016-09-06 17:21:23 +0530570 // <Get Sensor Type>
Chris Austenac4604a2015-10-13 12:43:27 -0500571 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_SENSOR, IPMI_CMD_GET_SENSOR_TYPE);
Tom05732372016-09-06 17:21:23 +0530572 ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_GET_SENSOR_TYPE, NULL, ipmi_sen_get_sensor_type,
573 PRIVILEGE_USER);
Chris Austenac4604a2015-10-13 12:43:27 -0500574
Tom05732372016-09-06 17:21:23 +0530575 // <Set Sensor Reading and Event Status>
Chris Austenac4604a2015-10-13 12:43:27 -0500576 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_SENSOR, IPMI_CMD_SET_SENSOR);
Tom05732372016-09-06 17:21:23 +0530577 ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_SET_SENSOR, NULL, ipmi_sen_set_sensor,
578 PRIVILEGE_OPERATOR);
Chris Austen8a45e7c2015-10-15 00:31:46 -0500579
Tom05732372016-09-06 17:21:23 +0530580 // <Get Sensor Reading>
Chris Austen10ccc0f2015-12-10 18:27:04 -0600581 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_SENSOR, IPMI_CMD_GET_SENSOR_READING);
Tom05732372016-09-06 17:21:23 +0530582 ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_GET_SENSOR_READING, NULL,
583 ipmi_sen_get_sensor_reading, PRIVILEGE_USER);
Chris Austen10ccc0f2015-12-10 18:27:04 -0600584
Chris Austenac4604a2015-10-13 12:43:27 -0500585 return;
586}