Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 1 | #ifndef __HOST_IPMI_SEN_HANDLER_H__ |
| 2 | #define __HOST_IPMI_SEN_HANDLER_H__ |
| 3 | |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 4 | #include <stdint.h> |
| 5 | |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 6 | // IPMI commands for net functions. |
| 7 | enum ipmi_netfn_sen_cmds |
| 8 | { |
Emily Shaffer | d06e0e7 | 2017-04-05 09:08:57 -0700 | [diff] [blame^] | 9 | IPMI_CMD_GET_SDR_INFO = 0x20, |
Chris Austen | 10ccc0f | 2015-12-10 18:27:04 -0600 | [diff] [blame] | 10 | IPMI_CMD_GET_SENSOR_READING = 0x2D, |
Emily Shaffer | d06e0e7 | 2017-04-05 09:08:57 -0700 | [diff] [blame^] | 11 | IPMI_CMD_GET_SENSOR_TYPE = 0x2F, |
| 12 | IPMI_CMD_SET_SENSOR = 0x30, |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 13 | }; |
| 14 | |
Emily Shaffer | 1fabf22 | 2017-04-05 08:53:21 -0700 | [diff] [blame] | 15 | // Discrete sensor types. |
| 16 | enum ipmi_sensor_types |
| 17 | { |
| 18 | IPMI_SENSOR_TEMP = 0x01, |
| 19 | IPMI_SENSOR_VOLTAGE = 0x02, |
| 20 | IPMI_SENSOR_CURRENT = 0x03, |
| 21 | IPMI_SENSOR_FAN = 0x04, |
| 22 | }; |
| 23 | |
Chris Austen | 0012e9b | 2015-10-22 01:37:46 -0500 | [diff] [blame] | 24 | #define MAX_DBUS_PATH 128 |
| 25 | struct dbus_interface_t { |
| 26 | uint8_t sensornumber; |
| 27 | uint8_t sensortype; |
| 28 | |
| 29 | char bus[MAX_DBUS_PATH]; |
| 30 | char path[MAX_DBUS_PATH]; |
| 31 | char interface[MAX_DBUS_PATH]; |
| 32 | }; |
Tom | d700e76 | 2016-09-20 18:24:13 +0530 | [diff] [blame] | 33 | |
| 34 | int set_sensor_dbus_state_s(uint8_t , const char *, const char *); |
| 35 | int set_sensor_dbus_state_y(uint8_t , const char *, const uint8_t); |
Emily Shaffer | 2ae09b9 | 2017-04-05 15:09:41 -0700 | [diff] [blame] | 36 | int find_openbmc_path(uint8_t , dbus_interface_t *); |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 37 | |
Tom Joseph | be703f7 | 2017-03-09 12:34:35 +0530 | [diff] [blame] | 38 | /** |
| 39 | * @struct SetSensorReadingReq |
| 40 | * |
| 41 | * IPMI Request data for Set Sensor Reading and Event Status Command |
| 42 | */ |
| 43 | struct SetSensorReadingReq |
| 44 | { |
| 45 | uint8_t number; |
| 46 | uint8_t operation; |
| 47 | uint8_t reading; |
| 48 | uint8_t assertOffset0_7; |
| 49 | uint8_t assertOffset8_14; |
| 50 | uint8_t deassertOffset0_7; |
| 51 | uint8_t deassertOffset8_14; |
| 52 | uint8_t eventData1; |
| 53 | uint8_t eventData2; |
| 54 | uint8_t eventData3; |
| 55 | } __attribute__((packed)); |
| 56 | |
Emily Shaffer | d06e0e7 | 2017-04-05 09:08:57 -0700 | [diff] [blame^] | 57 | /** |
| 58 | * Get SDR Info |
| 59 | */ |
| 60 | |
| 61 | namespace get_sdr_info |
| 62 | { |
| 63 | namespace request |
| 64 | { |
| 65 | // Note: for some reason the ipmi_request_t appears to be the |
| 66 | // raw value for this call. |
| 67 | inline bool get_count(void* req) |
| 68 | { |
| 69 | return (bool)((uint64_t)(req) & 1); |
| 70 | } |
| 71 | } // namespace request |
| 72 | |
| 73 | namespace response |
| 74 | { |
| 75 | #define SDR_INFO_RESP_SIZE 2 |
| 76 | inline void set_lun_present(int lun, uint8_t* resp) |
| 77 | { |
| 78 | *resp |= 1 << lun; |
| 79 | } |
| 80 | inline void set_lun_not_present(int lun, uint8_t* resp) |
| 81 | { |
| 82 | *resp &= ~(1 << lun); |
| 83 | } |
| 84 | inline void set_dynamic_population(uint8_t* resp) |
| 85 | { |
| 86 | *resp |= 1 << 7; |
| 87 | } |
| 88 | inline void set_static_population(uint8_t* resp) |
| 89 | { |
| 90 | *resp &= ~(1 << 7); |
| 91 | } |
| 92 | } // namespace response |
| 93 | |
| 94 | struct GetSdrInfoResp |
| 95 | { |
| 96 | uint8_t count; |
| 97 | uint8_t luns_and_dynamic_population; |
| 98 | }; |
| 99 | |
| 100 | } // namespace get_sdr_info |
Chris Austen | ac4604a | 2015-10-13 12:43:27 -0500 | [diff] [blame] | 101 | #endif |