blob: 892511a54ae0198ccf004160d2040c3f804b3d03 [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
293
294uint8_t find_sensor(uint8_t sensor_number) {
295
296 dbus_interface_t a;
297 char *p;
Brad Bishop56003452016-10-05 21:49:19 -0400298 int r;
299 uint8_t type;
Chris Austen0012e9b2015-10-22 01:37:46 -0500300
301 r = find_openbmc_path("SENSOR", sensor_number, &a);
302
303 if (r < 0) { return 0; }
304
305 // This is where sensors that do not exist in dbus but do
306 // exist in the host code stop. This should indicate it
307 // is not a supported sensor
Chris Austend7cf0e42015-11-07 14:27:12 -0600308 if (a.interface[0] == 0) { return 0;}
Chris Austen0012e9b2015-10-22 01:37:46 -0500309
310 if (strstr(a.interface, "InventoryItem")) {
311 // InventoryItems are real frus. So need to get the
312 // fru_type property
Brad Bishop56003452016-10-05 21:49:19 -0400313 type = dbus_to_sensor_type_from_dbus(&a);
Chris Austen0012e9b2015-10-22 01:37:46 -0500314 } else {
315 // Non InventoryItems
316 p = strrchr (a.path, '/');
Brad Bishop56003452016-10-05 21:49:19 -0400317 type = dbus_to_sensor_type(p+1);
Chris Austen0012e9b2015-10-22 01:37:46 -0500318 }
319
Brad Bishop56003452016-10-05 21:49:19 -0400320 return type;
Chris Austen0012e9b2015-10-22 01:37:46 -0500321 }
322
Chris Austen10ccc0f2015-12-10 18:27:04 -0600323
324
325
326
Chris Austen0012e9b2015-10-22 01:37:46 -0500327ipmi_ret_t ipmi_sen_get_sensor_type(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
328 ipmi_request_t request, ipmi_response_t response,
Chris Austenac4604a2015-10-13 12:43:27 -0500329 ipmi_data_len_t data_len, ipmi_context_t context)
330{
331 sensor_data_t *reqptr = (sensor_data_t*)request;
332 ipmi_ret_t rc = IPMI_CC_OK;
333
334 printf("IPMI GET_SENSOR_TYPE [0x%02X]\n",reqptr->sennum);
335
336 // TODO Not sure what the System-event-sensor is suppose to return
337 // need to ask Hostboot team
338 unsigned char buf[] = {0x00,0x6F};
339
Chris Austen0012e9b2015-10-22 01:37:46 -0500340 buf[0] = find_sensor(reqptr->sennum);
341
342 // HACK UNTIL Dbus gets updated or we find a better way
343 if (buf[0] == 0) {
Chris Austen800ba712015-12-03 15:31:00 -0600344 rc = IPMI_CC_SENSOR_INVALID;
Chris Austen0012e9b2015-10-22 01:37:46 -0500345 }
346
Chris Austenac4604a2015-10-13 12:43:27 -0500347
348 *data_len = sizeof(buf);
349 memcpy(response, &buf, *data_len);
350
Chris Austenac4604a2015-10-13 12:43:27 -0500351 return rc;
352}
353
Tom Josephbe703f72017-03-09 12:34:35 +0530354ipmi_ret_t setSensorReading(void *request)
355{
356 auto cmdData = static_cast<SetSensorReadingReq *>(request);
Chris Austenac4604a2015-10-13 12:43:27 -0500357
Tom Josephbe703f72017-03-09 12:34:35 +0530358 auto assertionStates =
359 (static_cast<uint16_t>(cmdData->assertOffset8_14)) << 8 |
360 cmdData->assertOffset0_7;
361
362 auto deassertionStates =
363 (static_cast<uint16_t>(cmdData->deassertOffset8_14)) << 8 |
364 cmdData->deassertOffset0_7;
365
366 std::bitset<16> assertionSet(assertionStates);
367 std::bitset<16> deassertionSet(deassertionStates);
368
369 // Check if the Sensor Number is present
370 auto iter = sensors.find(cmdData->number);
371 if (iter == sensors.end())
372 {
373 return IPMI_CC_SENSOR_INVALID;
374 }
375
376 auto& interfaceList = iter->second.sensorInterfaces;
377 if (interfaceList.empty())
378 {
379 log<level::ERR>("Interface List empty for the sensor",
380 entry("Sensor Number = %d", cmdData->number));
381 return IPMI_CC_UNSPECIFIED_ERROR;
382 }
383
384 ipmi::sensor::ObjectMap objects;
385 ipmi::sensor::InterfaceMap interfaces;
386 for (const auto& interface : interfaceList)
387 {
388 for (const auto& property : interface.second)
389 {
390 ipmi::sensor::PropertyMap props;
391 bool valid = false;
392 for (const auto& value : property.second)
393 {
394 if (assertionSet.test(value.first))
395 {
396 props.emplace(property.first, value.second.assert);
397 valid = true;
398 }
399 else if (deassertionSet.test(value.first))
400 {
401 props.emplace(property.first, value.second.deassert);
402 valid = true;
403 }
404 }
405 if (valid)
406 {
407 interfaces.emplace(interface.first, std::move(props));
408 }
409 }
410 }
411 objects.emplace(iter->second.sensorPath, std::move(interfaces));
412
Patrick Williams4736b912017-04-18 11:50:57 -0500413 sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()};
Tom Josephbe703f72017-03-09 12:34:35 +0530414 using namespace std::string_literals;
415 static const auto intf = "xyz.openbmc_project.Inventory.Manager"s;
416 static const auto path = "/xyz/openbmc_project/inventory"s;
417 std::string service;
418
419 try
420 {
421 service = ipmi::getService(bus, intf, path);
422
423 // Update the inventory manager
424 auto pimMsg = bus.new_method_call(service.c_str(),
425 path.c_str(),
426 intf.c_str(),
427 "Notify");
428 pimMsg.append(std::move(objects));
429 auto inventoryMgrResponseMsg = bus.call(pimMsg);
430 if (inventoryMgrResponseMsg.is_method_error())
431 {
432 log<level::ERR>("Error in notify call");
433 return IPMI_CC_UNSPECIFIED_ERROR;
434 }
435 }
436 catch (const std::runtime_error& e)
437 {
438 log<level::ERR>(e.what());
439 return IPMI_CC_UNSPECIFIED_ERROR;
440 }
441
442 return IPMI_CC_OK;
443}
Chris Austenac4604a2015-10-13 12:43:27 -0500444
Chris Austen0012e9b2015-10-22 01:37:46 -0500445ipmi_ret_t ipmi_sen_set_sensor(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
446 ipmi_request_t request, ipmi_response_t response,
Chris Austenac4604a2015-10-13 12:43:27 -0500447 ipmi_data_len_t data_len, ipmi_context_t context)
448{
Chris Austenac4604a2015-10-13 12:43:27 -0500449 sensor_data_t *reqptr = (sensor_data_t*)request;
Chris Austenac4604a2015-10-13 12:43:27 -0500450
Chris Austen0012e9b2015-10-22 01:37:46 -0500451 printf("IPMI SET_SENSOR [0x%02x]\n",reqptr->sennum);
Chris Austenac4604a2015-10-13 12:43:27 -0500452
Tom Josephbe703f72017-03-09 12:34:35 +0530453 /*
454 * This would support the Set Sensor Reading command for the presence
455 * and functional state of Processor, Core & DIMM. For the remaining
456 * sensors the existing support is invoked.
457 */
458 auto ipmiRC = setSensorReading(request);
459
460 if(ipmiRC == IPMI_CC_SENSOR_INVALID)
461 {
462 updateSensorRecordFromSSRAESC(reqptr);
463 ipmiRC = IPMI_CC_OK;
464 }
Chris Austen8a45e7c2015-10-15 00:31:46 -0500465
Chris Austenac4604a2015-10-13 12:43:27 -0500466 *data_len=0;
Tom Josephbe703f72017-03-09 12:34:35 +0530467 return ipmiRC;
Chris Austenac4604a2015-10-13 12:43:27 -0500468}
469
Chris Austen10ccc0f2015-12-10 18:27:04 -0600470
471ipmi_ret_t ipmi_sen_get_sensor_reading(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
472 ipmi_request_t request, ipmi_response_t response,
473 ipmi_data_len_t data_len, ipmi_context_t context)
474{
475 sensor_data_t *reqptr = (sensor_data_t*)request;
476 ipmi_ret_t rc = IPMI_CC_SENSOR_INVALID;
477 uint8_t type;
478 sensorreadingresp_t *resp = (sensorreadingresp_t*) response;
479 int r;
480 dbus_interface_t a;
481 sd_bus *bus = ipmid_get_sd_bus_connection();
482 sd_bus_message *reply = NULL;
Adriana Kobylak93125982016-03-01 12:48:10 -0600483 int reading = 0;
Chris Austen10ccc0f2015-12-10 18:27:04 -0600484
485
486 printf("IPMI GET_SENSOR_READING [0x%02x]\n",reqptr->sennum);
487
488 r = find_openbmc_path("SENSOR", reqptr->sennum, &a);
489
Nan Li36deb762016-05-12 10:23:41 +0800490 if (r < 0) {
491 fprintf(stderr, "Failed to find Sensor 0x%02x\n", reqptr->sennum);
492 return IPMI_CC_SENSOR_INVALID;
493 }
494
Chris Austen10ccc0f2015-12-10 18:27:04 -0600495 type = find_sensor(reqptr->sennum);
Brad Bishop56003452016-10-05 21:49:19 -0400496 if(type == 0) {
497 fprintf(stderr, "Failed to find Sensor 0x%02x\n", reqptr->sennum);
498 return IPMI_CC_SENSOR_INVALID;
499 }
Chris Austen10ccc0f2015-12-10 18:27:04 -0600500
501 fprintf(stderr, "Bus: %s, Path: %s, Interface: %s\n", a.bus, a.path, a.interface);
502
503 *data_len=0;
504
505 switch(type) {
506 case 0xC3:
507 case 0xC2:
Adriana Kobylak93125982016-03-01 12:48:10 -0600508 r = sd_bus_get_property(bus,a.bus, a.path, a.interface, "value", NULL, &reply, "i");
Chris Austen10ccc0f2015-12-10 18:27:04 -0600509 if (r < 0) {
510 fprintf(stderr, "Failed to call sd_bus_get_property:%d, %s\n", r, strerror(-r));
511 fprintf(stderr, "Bus: %s, Path: %s, Interface: %s\n",
512 a.bus, a.path, a.interface);
513 break;
514 }
515
Adriana Kobylak93125982016-03-01 12:48:10 -0600516 r = sd_bus_message_read(reply, "i", &reading);
Chris Austen10ccc0f2015-12-10 18:27:04 -0600517 if (r < 0) {
Adriana Kobylak93125982016-03-01 12:48:10 -0600518 fprintf(stderr, "Failed to read sensor: %s\n", strerror(-r));
Chris Austen10ccc0f2015-12-10 18:27:04 -0600519 break;
520 }
521
522 printf("Contents of a 0x%02x is 0x%02x\n", type, reading);
523
524 rc = IPMI_CC_OK;
525 *data_len=sizeof(sensorreadingresp_t);
526
Adriana Kobylak93125982016-03-01 12:48:10 -0600527 resp->value = (uint8_t)reading;
Chris Austen10ccc0f2015-12-10 18:27:04 -0600528 resp->operation = 0;
529 resp->indication[0] = 0;
530 resp->indication[1] = 0;
531 break;
532
533 default:
534 *data_len=0;
535 rc = IPMI_CC_SENSOR_INVALID;
536 break;
537 }
538
539
vishwa1eaea4f2016-02-26 11:57:40 -0600540 reply = sd_bus_message_unref(reply);
Chris Austen10ccc0f2015-12-10 18:27:04 -0600541
542 return rc;
543}
544
Chris Austen0012e9b2015-10-22 01:37:46 -0500545ipmi_ret_t ipmi_sen_wildcard(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
546 ipmi_request_t request, ipmi_response_t response,
Chris Austenac4604a2015-10-13 12:43:27 -0500547 ipmi_data_len_t data_len, ipmi_context_t context)
548{
Nan Li70aa8d92016-08-29 00:11:10 +0800549 ipmi_ret_t rc = IPMI_CC_INVALID;
Chris Austenac4604a2015-10-13 12:43:27 -0500550
551 printf("IPMI S/E Wildcard Netfn:[0x%X], Cmd:[0x%X]\n",netfn,cmd);
552 *data_len = 0;
553
554 return rc;
555}
556
557
558void register_netfn_sen_functions()
559{
Tom05732372016-09-06 17:21:23 +0530560 // <Wildcard Command>
Chris Austenac4604a2015-10-13 12:43:27 -0500561 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_SENSOR, IPMI_CMD_WILDCARD);
Tom05732372016-09-06 17:21:23 +0530562 ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_WILDCARD, NULL, ipmi_sen_wildcard,
563 PRIVILEGE_USER);
Chris Austenac4604a2015-10-13 12:43:27 -0500564
Tom05732372016-09-06 17:21:23 +0530565 // <Get Sensor Type>
Chris Austenac4604a2015-10-13 12:43:27 -0500566 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_SENSOR, IPMI_CMD_GET_SENSOR_TYPE);
Tom05732372016-09-06 17:21:23 +0530567 ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_GET_SENSOR_TYPE, NULL, ipmi_sen_get_sensor_type,
568 PRIVILEGE_USER);
Chris Austenac4604a2015-10-13 12:43:27 -0500569
Tom05732372016-09-06 17:21:23 +0530570 // <Set Sensor Reading and Event Status>
Chris Austenac4604a2015-10-13 12:43:27 -0500571 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_SENSOR, IPMI_CMD_SET_SENSOR);
Tom05732372016-09-06 17:21:23 +0530572 ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_SET_SENSOR, NULL, ipmi_sen_set_sensor,
573 PRIVILEGE_OPERATOR);
Chris Austen8a45e7c2015-10-15 00:31:46 -0500574
Tom05732372016-09-06 17:21:23 +0530575 // <Get Sensor Reading>
Chris Austen10ccc0f2015-12-10 18:27:04 -0600576 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_SENSOR, IPMI_CMD_GET_SENSOR_READING);
Tom05732372016-09-06 17:21:23 +0530577 ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_GET_SENSOR_READING, NULL,
578 ipmi_sen_get_sensor_reading, PRIVILEGE_USER);
Chris Austen10ccc0f2015-12-10 18:27:04 -0600579
Chris Austenac4604a2015-10-13 12:43:27 -0500580 return;
581}