From 5ca50959438c3c99acfafe4d0ff301eb29b84233 Mon Sep 17 00:00:00 2001 From: Tom Joseph Date: Thu, 22 Feb 2018 00:33:38 +0530 Subject: Implement Get SDR and Reserve SDR repository command Both Get SDR and Reserve SDR repository command is same as Get Device SDR and Reserve Device SDR command respectively. So the same implementation is shared. Resolves openbmc/openbmc#2615 Change-Id: I64e37837bc5a616bed41a3ceff7d63033d88455c Signed-off-by: Tom Joseph --- host-ipmid-whitelist.conf | 3 +++ sensorhandler.cpp | 18 ++++++------------ sensorhandler.h | 17 ++++++++++++++--- storagehandler.cpp | 11 +++++++++++ storagehandler.h | 2 ++ 5 files changed, 36 insertions(+), 15 deletions(-) diff --git a/host-ipmid-whitelist.conf b/host-ipmid-whitelist.conf index 5fa539a..66af810 100644 --- a/host-ipmid-whitelist.conf +++ b/host-ipmid-whitelist.conf @@ -21,6 +21,9 @@ 0x06:0x42 //: 0x0A:0x10 //: 0x0A:0x11 //: +0x0A:0x20 //: +0x0A:0x22 //: +0x0A:0x23 //: 0x0A:0x40 //: 0x0A:0x42 //: 0x0A:0x44 //: diff --git a/sensorhandler.cpp b/sensorhandler.cpp index 2bd022b..7d9d394 100644 --- a/sensorhandler.cpp +++ b/sensorhandler.cpp @@ -1082,24 +1082,18 @@ void register_netfn_sen_functions() nullptr, ipmi_sen_get_sensor_reading, PRIVILEGE_USER); - // - printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n", - NETFUN_SENSOR, IPMI_CMD_RESERVE_SDR_REPO); - ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_RESERVE_SDR_REPO, + // + ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_RESERVE_DEVICE_SDR_REPO, nullptr, ipmi_sen_reserve_sdr, PRIVILEGE_USER); - // - printf("Registering NetFn:[0x%X], Cmd:[0x%x]\n", - NETFUN_SENSOR, IPMI_CMD_GET_SDR_INFO); - ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_GET_SDR_INFO, + // + ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_GET_DEVICE_SDR_INFO, nullptr, ipmi_sen_get_sdr_info, PRIVILEGE_USER); - // - printf("Registering NetFn:[0x%X], Cmd:[0x%x]\n", - NETFUN_SENSOR, IPMI_CMD_GET_SDR); - ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_GET_SDR, + // + ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_GET_DEVICE_SDR, nullptr, ipmi_sen_get_sdr, PRIVILEGE_USER); diff --git a/sensorhandler.h b/sensorhandler.h index 4dd079d..d6426f6 100644 --- a/sensorhandler.h +++ b/sensorhandler.h @@ -3,13 +3,14 @@ #include #include "types.hpp" +#include "host-ipmid/ipmid-api.h" // IPMI commands for net functions. enum ipmi_netfn_sen_cmds { - IPMI_CMD_GET_SDR_INFO = 0x20, - IPMI_CMD_GET_SDR = 0x21, - IPMI_CMD_RESERVE_SDR_REPO = 0x22, + IPMI_CMD_GET_DEVICE_SDR_INFO = 0x20, + IPMI_CMD_GET_DEVICE_SDR = 0x21, + IPMI_CMD_RESERVE_DEVICE_SDR_REPO = 0x22, IPMI_CMD_GET_SENSOR_READING = 0x2D, IPMI_CMD_GET_SENSOR_TYPE = 0x2F, IPMI_CMD_SET_SENSOR = 0x30, @@ -50,6 +51,16 @@ int set_sensor_dbus_state_s(uint8_t , const char *, const char *); int set_sensor_dbus_state_y(uint8_t , const char *, const uint8_t); int find_openbmc_path(uint8_t , dbus_interface_t *); +ipmi_ret_t ipmi_sen_get_sdr(ipmi_netfn_t netfn, ipmi_cmd_t cmd, + ipmi_request_t request, ipmi_response_t response, + ipmi_data_len_t data_len, ipmi_context_t context); + +ipmi_ret_t ipmi_sen_reserve_sdr(ipmi_netfn_t netfn, ipmi_cmd_t cmd, + ipmi_request_t request, + ipmi_response_t response, + ipmi_data_len_t data_len, + ipmi_context_t context); + static const uint16_t FRU_RECORD_ID_START = 256; static const uint8_t SDR_VERSION = 0x51; static const uint16_t END_OF_RECORD = 0xFFFF; diff --git a/storagehandler.cpp b/storagehandler.cpp index 59dfdde..fa630e3 100644 --- a/storagehandler.cpp +++ b/storagehandler.cpp @@ -19,6 +19,7 @@ #include "storagehandler.h" #include "utils.hpp" #include "xyz/openbmc_project/Common/error.hpp" +#include "sensorhandler.h" void register_netfn_storage_functions() __attribute__((constructor)); @@ -762,6 +763,16 @@ void register_netfn_storage_functions() nullptr, ipmi_get_repository_info, PRIVILEGE_USER); + // + ipmi_register_callback(NETFUN_STORAGE, IPMI_CMD_RESERVE_SDR, + nullptr, ipmi_sen_reserve_sdr, + PRIVILEGE_USER); + + // + ipmi_register_callback(NETFUN_STORAGE, IPMI_CMD_GET_SDR, + nullptr, ipmi_sen_get_sdr, + PRIVILEGE_USER); + ipmi::fru::registerCallbackHandler(); return; } diff --git a/storagehandler.h b/storagehandler.h index 497db82..1849fc7 100644 --- a/storagehandler.h +++ b/storagehandler.h @@ -8,6 +8,8 @@ enum ipmi_netfn_storage_cmds IPMI_CMD_GET_FRU_INV_AREA_INFO = 0x10, IPMI_CMD_GET_REPOSITORY_INFO = 0x20, IPMI_CMD_READ_FRU_DATA = 0x11, + IPMI_CMD_RESERVE_SDR = 0x22, + IPMI_CMD_GET_SDR = 0x23, IPMI_CMD_GET_SEL_INFO = 0x40, IPMI_CMD_RESERVE_SEL = 0x42, IPMI_CMD_GET_SEL_ENTRY = 0x43, -- cgit v1.2.1