summaryrefslogtreecommitdiffstats
path: root/common/recipes-core/ipmid/files
diff options
context:
space:
mode:
authorTian Fang <tfang@fb.com>2015-12-14 22:08:40 -0800
committerTian Fang <tfang@fb.com>2015-12-15 09:49:21 -0800
commite65a7944211c70f6b5cfb6cedd73cc31105319de (patch)
tree067082251bc52bc6c09ca87feaa1352d0468a5ac /common/recipes-core/ipmid/files
parent8a67fbdd0e251bb34d55992b0771edba1837d589 (diff)
downloadast2050-yocto-openbmc-e65a7944211c70f6b5cfb6cedd73cc31105319de.zip
ast2050-yocto-openbmc-e65a7944211c70f6b5cfb6cedd73cc31105319de.tar.gz
Sync to internal OpenBMC repo f926614
Diffstat (limited to 'common/recipes-core/ipmid/files')
-rw-r--r--common/recipes-core/ipmid/files/ipmid.c270
-rw-r--r--common/recipes-core/ipmid/files/sdr.c18
-rw-r--r--common/recipes-core/ipmid/files/sel.c306
-rw-r--r--common/recipes-core/ipmid/files/sel.h18
4 files changed, 438 insertions, 174 deletions
diff --git a/common/recipes-core/ipmid/files/ipmid.c b/common/recipes-core/ipmid/files/ipmid.c
index c79d3e2..0930cc2 100644
--- a/common/recipes-core/ipmid/files/ipmid.c
+++ b/common/recipes-core/ipmid/files/ipmid.c
@@ -35,6 +35,11 @@
#include <sys/un.h>
#include <openbmc/ipmi.h>
+#define SIZE_IANA_ID 3
+#define SIZE_SYS_GUID 16
+
+extern void plat_lan_init(lan_config_t *lan);
+
// TODO: Once data storage is finalized, the following structure needs
// to be retrieved/updated from persistant backend storage
static lan_config_t g_lan_config = { 0 };
@@ -245,6 +250,27 @@ app_get_device_guid (unsigned char *response, unsigned char *res_len)
*res_len = data - &res->data[0];
}
+// Get Device System GUID (IPMI/Section 22.14)
+static void
+app_get_device_sys_guid (unsigned char *request, unsigned char *response,
+ unsigned char *res_len)
+{
+ int ret;
+
+ ipmi_mn_req_t *req = (ipmi_mn_req_t *) request;
+ ipmi_res_t *res = (ipmi_res_t *) response;
+
+ // Get the 16 bytes of System GUID from PAL library
+ ret = pal_get_sys_guid(req->payload_id, res->data);
+ if (ret) {
+ res->cc = CC_UNSPECIFIED_ERROR;
+ *res_len = 0x00;
+ } else {
+ res->cc = CC_SUCCESS;
+ *res_len = SIZE_SYS_GUID;
+ }
+}
+
// Get BMC Global Enables (IPMI/Section 22.2)
static void
app_get_global_enables (unsigned char *response, unsigned char *res_len)
@@ -255,7 +281,7 @@ app_get_global_enables (unsigned char *response, unsigned char *res_len)
res->cc = CC_SUCCESS;
- *data++ = 0x09; // Global Enable
+ *data++ = 0x0D; // Global Enable
*res_len = data - &res->data[0];
}
@@ -279,6 +305,7 @@ app_set_sys_info_params (unsigned char *request, unsigned char *response,
break;
case SYS_INFO_PARAM_SYSFW_VER:
memcpy(g_sys_info_params.sysfw_ver, &req->data[1], SIZE_SYSFW_VER);
+ pal_set_sysfw_ver(req->payload_id, g_sys_info_params.sysfw_ver);
break;
case SYS_INFO_PARAM_SYS_NAME:
memcpy(g_sys_info_params.sys_name, &req->data[1], SIZE_SYS_NAME);
@@ -327,6 +354,7 @@ app_get_sys_info_params (unsigned char *request, unsigned char *response,
*data++ = g_sys_info_params.set_in_prog;
break;
case SYS_INFO_PARAM_SYSFW_VER:
+ pal_get_sysfw_ver(req->payload_id, g_sys_info_params.sysfw_ver);
memcpy(data, g_sys_info_params.sysfw_ver, SIZE_SYSFW_VER);
data += SIZE_SYSFW_VER;
break;
@@ -385,12 +413,11 @@ ipmi_handle_app (unsigned char *request, unsigned char req_len,
app_get_selftest_results (response, res_len);
break;
case CMD_APP_GET_DEVICE_GUID:
- case CMD_APP_GET_SYSTEM_GUID:
- // Get Device GUID and Get System GUID returns same data
- // from IPMI stack. FYI, Get System GUID will have to be
- // sent with in an IPMI session that includes session info
app_get_device_guid (response, res_len);
break;
+ case CMD_APP_GET_SYSTEM_GUID:
+ app_get_device_sys_guid (request, response, res_len);
+ break;
case CMD_APP_GET_GLOBAL_ENABLES:
app_get_global_enables (response, res_len);
break;
@@ -558,8 +585,10 @@ storage_get_sdr (unsigned char *request, unsigned char *response,
}
static void
-storage_get_sel_info (unsigned char *response, unsigned char *res_len)
+storage_get_sel_info (unsigned char *request, unsigned char *response,
+ unsigned char *res_len)
{
+ ipmi_mn_req_t *req = (ipmi_mn_req_t *) request;
ipmi_res_t *res = (ipmi_res_t *) response;
unsigned char *data = &res->data[0];
int num_entries; // number of log entries
@@ -568,10 +597,10 @@ storage_get_sel_info (unsigned char *response, unsigned char *res_len)
time_stamp_t ts_recent_erase; // Recent Erasure Timestamp
// Use platform APIs to get SEL information
- num_entries = sel_num_entries ();
- free_space = sel_free_space ();
- sel_ts_recent_add (&ts_recent_add);
- sel_ts_recent_erase (&ts_recent_erase);
+ num_entries = sel_num_entries (req->payload_id);
+ free_space = sel_free_space (req->payload_id);
+ sel_ts_recent_add (req->payload_id, &ts_recent_add);
+ sel_ts_recent_erase (req->payload_id, &ts_recent_erase);
res->cc = CC_SUCCESS;
@@ -595,14 +624,16 @@ storage_get_sel_info (unsigned char *response, unsigned char *res_len)
}
static void
-storage_rsv_sel (unsigned char *response, unsigned char *res_len)
+storage_rsv_sel (unsigned char * request, unsigned char *response,
+ unsigned char *res_len)
{
+ ipmi_mn_req_t *req = (ipmi_mn_req_t *) request;
ipmi_res_t *res = (ipmi_res_t *) response;
unsigned char *data = &res->data[0];
int rsv_id; // SEL reservation ID
// Use platform APIs to get a SEL reservation ID
- rsv_id = sel_rsv_id ();
+ rsv_id = sel_rsv_id (req->payload_id);
if (rsv_id < 0)
{
res->cc = CC_SEL_ERASE_PROG;
@@ -634,7 +665,7 @@ storage_get_sel (unsigned char *request, unsigned char *response,
read_rec_id = (req->data[3] >> 8) | req->data[2];
// Use platform API to read the record Id and get next ID
- ret = sel_get_entry (read_rec_id, &entry, &next_rec_id);
+ ret = sel_get_entry (req->payload_id, read_rec_id, &entry, &next_rec_id);
if (ret)
{
res->cc = CC_UNSPECIFIED_ERROR;
@@ -670,7 +701,7 @@ storage_add_sel (unsigned char *request, unsigned char *response,
memcpy(entry.msg, req->data, SIZE_SEL_REC);
// Use platform APIs to add the new SEL entry
- ret = sel_add_entry (&entry, &record_id);
+ ret = sel_add_entry (req->payload_id, &entry, &record_id);
if (ret)
{
res->cc = CC_UNSPECIFIED_ERROR;
@@ -711,11 +742,11 @@ storage_clr_sel (unsigned char *request, unsigned char *response,
// Use platform APIs to clear or get status
if (req->data[5] == IPMI_SEL_INIT_ERASE)
{
- ret = sel_erase (rsv_id);
+ ret = sel_erase (req->payload_id, rsv_id);
}
else if (req->data[5] == IPMI_SEL_ERASE_STAT)
{
- ret = sel_erase_status (rsv_id, &status);
+ ret = sel_erase_status (req->payload_id, rsv_id, &status);
}
else
{
@@ -739,6 +770,37 @@ storage_clr_sel (unsigned char *request, unsigned char *response,
}
static void
+storage_get_sel_time (unsigned char *response, unsigned char *res_len)
+{
+ ipmi_res_t *res = (ipmi_res_t *) response;
+
+ res->cc = CC_SUCCESS;
+
+ time_stamp_fill(res->data);
+
+ *res_len = SIZE_TIME_STAMP;
+
+ return;
+}
+
+static void
+storage_get_sel_utc (unsigned char *response, unsigned char *res_len)
+{
+ ipmi_res_t *res = (ipmi_res_t *) response;
+ unsigned char *data = &res->data[0];
+
+ res->cc = CC_SUCCESS;
+
+ // TODO: For now, the SEL time stamp is based on UTC time,
+ // so return 0x0000 as offset. Might need to change once
+ // supporting zones in SEL time stamps
+ *data++ = 0x00;
+ *data++ = 0x00;
+
+ *res_len = data - &res->data[0];
+}
+
+static void
ipmi_handle_storage (unsigned char *request, unsigned char req_len,
unsigned char *response, unsigned char *res_len)
{
@@ -759,10 +821,10 @@ ipmi_handle_storage (unsigned char *request, unsigned char req_len,
storage_get_fruid_data (request, response, res_len);
break;
case CMD_STORAGE_GET_SEL_INFO:
- storage_get_sel_info (response, res_len);
+ storage_get_sel_info (request, response, res_len);
break;
case CMD_STORAGE_RSV_SEL:
- storage_rsv_sel (response, res_len);
+ storage_rsv_sel (request, response, res_len);
break;
case CMD_STORAGE_ADD_SEL:
storage_add_sel (request, response, res_len);
@@ -773,6 +835,12 @@ ipmi_handle_storage (unsigned char *request, unsigned char req_len,
case CMD_STORAGE_CLR_SEL:
storage_clr_sel (request, response, res_len);
break;
+ case CMD_STORAGE_GET_SEL_TIME:
+ storage_get_sel_time (response, res_len);
+ break;
+ case CMD_STORAGE_GET_SEL_UTC:
+ storage_get_sel_utc (response, res_len);
+ break;
case CMD_STORAGE_GET_SDR_INFO:
storage_get_sdr_info (response, res_len);
break;
@@ -871,6 +939,9 @@ transport_set_lan_config (unsigned char *request, unsigned char *response,
case LAN_PARAM_DEST_ADDR:
memcpy(g_lan_config.dest_addr, &req->data[2], SIZE_DEST_ADDR);
break;
+ case LAN_PARAM_IP6_ADDR:
+ memcpy(g_lan_config.ip6_addr, &req->data[2], SIZE_IP6_ADDR);
+ break;
default:
res->cc = CC_INVALID_PARAM;
break;
@@ -905,6 +976,7 @@ transport_get_lan_config (unsigned char *request, unsigned char *response,
data += SIZE_AUTH_ENABLES;
break;
case LAN_PARAM_IP_ADDR:
+ plat_lan_init(&g_lan_config);
memcpy(data, g_lan_config.ip_addr, SIZE_IP_ADDR);
data += SIZE_IP_ADDR;
break;
@@ -968,6 +1040,11 @@ transport_get_lan_config (unsigned char *request, unsigned char *response,
memcpy(data, g_lan_config.dest_addr, SIZE_DEST_ADDR);
data += SIZE_DEST_ADDR;
break;
+ case LAN_PARAM_IP6_ADDR:
+ plat_lan_init(&g_lan_config);
+ memcpy(data, g_lan_config.ip6_addr, SIZE_IP6_ADDR);
+ data += SIZE_IP6_ADDR;
+ break;
default:
res->cc = CC_INVALID_PARAM;
break;
@@ -1070,6 +1147,42 @@ oem_set_post_end (unsigned char *request, unsigned char *response,
}
static void
+oem_get_slot_info(unsigned char *request, unsigned char *response,
+ unsigned char *res_len)
+{
+ ipmi_mn_req_t *req = (ipmi_mn_req_t *) request;
+ ipmi_res_t *res = (ipmi_res_t *) response;
+
+ int ret;
+ uint8_t pres = 0x00;
+ uint8_t sinfo = 0x00;
+
+ // Slot info:
+ // Bit[7]: Not Present/Present (from pal)
+ // Bit[6]: Platform type (TODO from pal)
+ // Bit[5-0] : Slot# (payload_id indicates)
+ ret = pal_is_server_prsnt(req->payload_id, &pres);
+ if (ret) {
+ res->cc = CC_UNSPECIFIED_ERROR;
+ *res_len = 0x00;
+ return;
+ }
+
+ // Populate the presence bit[7]
+ if (pres) {
+ sinfo = 0x80;
+ }
+
+ // Populate the slot number
+ sinfo |= req->payload_id;
+
+ // Prepare response buffer
+ res->cc = CC_SUCCESS;
+ res->data[0] = sinfo;
+ *res_len = 0x01;
+}
+
+static void
ipmi_handle_oem (unsigned char *request, unsigned char req_len,
unsigned char *response, unsigned char *res_len)
{
@@ -1093,6 +1206,9 @@ ipmi_handle_oem (unsigned char *request, unsigned char req_len,
case CMD_OEM_SET_POST_END:
oem_set_post_end (request, response, res_len);
break;
+ case CMD_OEM_GET_SLOT_INFO:
+ oem_get_slot_info (request, response, res_len);
+ break;
default:
res->cc = CC_INVALID_CMD;
break;
@@ -1114,21 +1230,22 @@ oem_1s_handle_ipmb_kcs(unsigned char *request, unsigned char req_len,
// Add the payload id from the bridged command
req_buf[0] = req->payload_id;
- // Remove OEM IPMI Header + 1 byte for BIC interface
+ // Remove OEM IPMI Header (including 1 byte for interface type, 3 bytes for IANA ID)
// The offset moves by one due to the payload ID
- memcpy(&req_buf[1], &request[BIC_INTF_HDR_SIZE + 1], req_len - BIC_INTF_HDR_SIZE);
+ memcpy(&req_buf[1], &request[BIC_INTF_HDR_SIZE], req_len - BIC_INTF_HDR_SIZE + 1);
// Send the bridged KCS command along with the payload ID
// The offset moves by one due to the payload ID
ipmi_handle(req_buf, req_len - BIC_INTF_HDR_SIZE + 1, res_buf, res_len);
- // Copy the response back
- memcpy(&res->data[1], res_buf, *res_len);
+ // Copy the response back (1 byte interface type, 3 bytes for IANA ID)
+ memcpy(&res->data[4], res_buf, *res_len);
// Add the OEM command's response
res->cc = CC_SUCCESS;
- res->data[0] = req->data[0]; // Bridge-IC interface
- *res_len += 1;
+ memcpy(res->data, &req->data, SIZE_IANA_ID); // IANA ID
+ res->data[3] = req->data[3]; // Bridge-IC interface
+ *res_len += 4; // Interface type + IANA ID
}
static void
@@ -1139,32 +1256,38 @@ oem_1s_handle_ipmb_req(unsigned char *request, unsigned char req_len,
ipmi_res_t *res = (ipmi_res_t *) response;
// handle based on Bridge-IC interface
- switch(req->data[0]) {
+ switch(req->data[3]) {
case BIC_INTF_ME:
// TODO: Need to call ME command handler
+#ifdef DEBUG
syslog(LOG_INFO, "oem_1s_handle_ipmb_req: Command received from ME for "
"payload#%d\n", req->payload_id);
- res->data[0] = BIC_INTF_ME;
+#endif
+ memcpy(res->data, req->data, 4); //IANA ID + Interface type
res->cc = CC_SUCCESS;
- *res_len = 1;
+ *res_len = 4;
break;
case BIC_INTF_SOL:
// TODO: Need to call Optional SoL message handler
+#ifdef DEBUG
syslog(LOG_INFO, "oem_1s_handle_ipmb_req: Command received from SOL for "
"payload#%d\n", req->payload_id);
- res->data[0] = BIC_INTF_SOL;
+#endif
+ memcpy(res->data, req->data, 4); //IANA ID + Interface type
res->cc = CC_SUCCESS;
- *res_len = 1;
+ *res_len = 4;
break;
case BIC_INTF_KCS:
+ case BIC_INTF_KCS_SMM:
oem_1s_handle_ipmb_kcs(request, req_len, response, res_len);
break;
default:
// TODO: Need to add additonal interface handler, if supported
- syslog(LOG_ALERT, "oem_1s_handle_ipmb_req: Command received on intf#%d "
- "for payload#%d", req->data[0], req->payload_id);
+ syslog(LOG_WARNING, "oem_1s_handle_ipmb_req: Command received on intf#%d "
+ "for payload#%d", req->data[3], req->payload_id);
+ memcpy(res->data, req->data, 4); //IANA ID + Interface type
res->cc = CC_INVALID_PARAM;
- *res_len = 0;
+ *res_len = 4;
break;
}
}
@@ -1187,62 +1310,70 @@ ipmi_handle_oem_1s(unsigned char *request, unsigned char req_len,
break;
case CMD_OEM_1S_INTR:
syslog(LOG_INFO, "ipmi_handle_oem_1s: 1S server interrupt#%d received "
- "for payload#%d\n", req->data[0], req->payload_id);
+ "for payload#%d\n", req->data[3], req->payload_id);
res->cc = CC_SUCCESS;
- *res_len = 0;
+ memcpy(res->data, req->data, SIZE_IANA_ID); //IANA ID
+ *res_len = 3;
break;
case CMD_OEM_1S_POST_BUF:
- for (i = 1; i <= req->data[0]; i++) {
+ // Skip the first 3 bytes of IANA ID and one byte of length field
+ for (i = SIZE_IANA_ID+1; i <= req->data[3]; i++) {
pal_post_handle(req->payload_id, req->data[i]);
}
res->cc = CC_SUCCESS;
- *res_len = 0;
+ memcpy(res->data, req->data, SIZE_IANA_ID); //IANA ID
+ *res_len = 3;
break;
case CMD_OEM_1S_PLAT_DISC:
syslog(LOG_INFO, "ipmi_handle_oem_1s: Platform Discovery received for "
"payload#%d\n", req->payload_id);
res->cc = CC_SUCCESS;
- *res_len = 0;
+ memcpy(res->data, req->data, SIZE_IANA_ID); //IANA ID
+ *res_len = 3;
break;
case CMD_OEM_1S_BIC_RESET:
syslog(LOG_INFO, "ipmi_handle_oem_1s: BIC Reset received "
"for payload#%d\n", req->payload_id);
- if (req->data[0] == 0x0) {
- syslog(LOG_ALERT, "Cold Reset by Firmware Update\n");
+ if (req->data[3] == 0x0) {
+ syslog(LOG_WARNING, "Cold Reset by Firmware Update\n");
res->cc = CC_SUCCESS;
- } else if (req->data[1] == 0x01) {
- syslog(LOG_ALERT, "WDT Reset\n");
+ } else if (req->data[3] == 0x01) {
+ syslog(LOG_WARNING, "WDT Reset\n");
res->cc = CC_SUCCESS;
} else {
- syslog(LOG_ALERT, "Error\n");
+ syslog(LOG_WARNING, "Error\n");
res->cc = CC_INVALID_PARAM;
}
- *res_len = 0;
+ memcpy(res->data, req->data, SIZE_IANA_ID); //IANA ID
+ *res_len = 3;
break;
case CMD_OEM_1S_BIC_UPDATE_MODE:
+#ifdef DEBUG
syslog(LOG_INFO, "ipmi_handle_oem_1s: BIC Update Mode received "
"for payload#%d\n", req->payload_id);
-
- if (req->data[0] == 0x0) {
+#endif
+ if (req->data[3] == 0x0) {
syslog(LOG_INFO, "Normal Mode\n");
res->cc = CC_SUCCESS;
- } else if (req->data[1] == 0x0F) {
+ } else if (req->data[3] == 0x0F) {
syslog(LOG_INFO, "Update Mode\n");
res->cc = CC_SUCCESS;
} else {
- syslog(LOG_ALERT, "Error\n");
+ syslog(LOG_WARNING, "Error\n");
res->cc = CC_INVALID_PARAM;
}
- *res_len = 0;
+ memcpy(res->data, req->data, SIZE_IANA_ID); //IANA ID
+ *res_len = 3;
break;
default:
res->cc = CC_INVALID_CMD;
- *res_len = 0;
+ memcpy(res->data, req->data, SIZE_IANA_ID); //IANA ID
+ *res_len = 3;
break;
}
pthread_mutex_unlock(&m_oem_1s);
@@ -1306,26 +1437,37 @@ ipmi_handle (unsigned char *request, unsigned char req_len,
void
*conn_handler(void *socket_desc) {
- int sock = *(int*)socket_desc;
+ int *p_sock = (int*)socket_desc;
+ int sock = *p_sock;
int n;
unsigned char req_buf[MAX_IPMI_MSG_SIZE];
unsigned char res_buf[MAX_IPMI_MSG_SIZE];
unsigned char res_len = 0;
+ struct timeval tv;
+ int rc = 0;
+
+ // setup timeout for receving on socket
+ tv.tv_sec = TIMEOUT_IPMI;
+ tv.tv_usec = 0;
+
+ setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv,sizeof(struct timeval));
n = recv (sock, req_buf, sizeof(req_buf), 0);
+ rc = errno;
if (n <= 0) {
- syslog(LOG_ALERT, "ipmid: recv() failed with %d\n", n);
+ syslog(LOG_WARNING, "ipmid: recv() failed with %d, errno: %d\n", n, rc);
goto conn_cleanup;
}
ipmi_handle(req_buf, n, res_buf, &res_len);
if (send (sock, res_buf, res_len, 0) < 0) {
- syslog(LOG_ALERT, "ipmid: send() failed\n");
+ syslog(LOG_WARNING, "ipmid: send() failed\n");
}
conn_cleanup:
close(sock);
+ free(p_sock);
pthread_exit(NULL);
return 0;
@@ -1338,13 +1480,16 @@ main (void)
int s, s2, t, len;
struct sockaddr_un local, remote;
pthread_t tid;
+ int *p_s2;
+ int rc = 0;
- daemon(1, 0);
+ daemon(1, 1);
openlog("ipmid", LOG_CONS, LOG_DAEMON);
plat_fruid_init();
plat_sensor_init();
+ plat_lan_init(&g_lan_config);
sdr_init();
sel_init();
@@ -1358,7 +1503,7 @@ main (void)
if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) == -1)
{
- syslog(LOG_ALERT, "ipmid: socket() failed\n");
+ syslog(LOG_WARNING, "ipmid: socket() failed\n");
exit (1);
}
@@ -1368,30 +1513,35 @@ main (void)
len = strlen (local.sun_path) + sizeof (local.sun_family);
if (bind (s, (struct sockaddr *) &local, len) == -1)
{
- syslog(LOG_ALERT, "ipmid: bind() failed\n");
+ syslog(LOG_WARNING, "ipmid: bind() failed\n");
exit (1);
}
if (listen (s, 5) == -1)
{
- syslog(LOG_ALERT, "ipmid: listen() failed\n");
+ syslog(LOG_WARNING, "ipmid: listen() failed\n");
exit (1);
}
while(1) {
int n;
t = sizeof (remote);
+ // TODO: seen accept() call fails and need further debug
if ((s2 = accept (s, (struct sockaddr *) &remote, &t)) < 0) {
- syslog(LOG_ALERT, "ipmid: accept() failed\n");
- break;
+ rc = errno;
+ syslog(LOG_WARNING, "ipmid: accept() failed with ret: %x, errno: %x\n", s2, rc);
+ sleep(5);
+ continue;
}
// Creating a worker thread to handle the request
// TODO: Need to monitor the server performance with higher load and
// see if we need to create pre-defined number of workers and schedule
// the requests among them.
- if (pthread_create(&tid, NULL, conn_handler, (void*) &s2) < 0) {
- syslog(LOG_ALERT, "ipmid: pthread_create failed\n");
+ p_s2 = malloc(sizeof(int));
+ *p_s2 = s2;
+ if (pthread_create(&tid, NULL, conn_handler, (void*) p_s2) < 0) {
+ syslog(LOG_WARNING, "ipmid: pthread_create failed\n");
close(s2);
continue;
}
diff --git a/common/recipes-core/ipmid/files/sdr.c b/common/recipes-core/ipmid/files/sdr.c
index 91a4df5..78d74c3 100644
--- a/common/recipes-core/ipmid/files/sdr.c
+++ b/common/recipes-core/ipmid/files/sdr.c
@@ -88,7 +88,7 @@ static int
sdr_add_entry(sdr_rec_t *rec, int *rec_id) {
// If SDR is full, return error
if (sdr_num_entries() == SDR_RECORDS_MAX) {
- syslog(LOG_ALERT, "sdr_add_entry: SDR full\n");
+ syslog(LOG_WARNING, "sdr_add_entry: SDR full\n");
return -1;
}
@@ -137,7 +137,7 @@ sdr_add_mgmt_rec(sensor_mgmt_t *p_rec) {
// Add this record to SDR repo
if (sdr_add_entry(&sdr, &rec_id)) {
- syslog(LOG_ALERT, "sdr_add_mgmt_rec: sdr_add_entry failed\n");
+ syslog(LOG_WARNING, "sdr_add_mgmt_rec: sdr_add_entry failed\n");
return -1;
}
@@ -176,7 +176,7 @@ sdr_add_disc_rec(sensor_disc_t *p_rec) {
// Add this record to SDR repo
if (sdr_add_entry(&sdr, &rec_id)) {
- syslog(LOG_ALERT, "sdr_add_disc_rec: sdr_add_entry failed\n");
+ syslog(LOG_WARNING, "sdr_add_disc_rec: sdr_add_entry failed\n");
return -1;
}
@@ -237,7 +237,7 @@ sdr_add_thresh_rec(sensor_thresh_t *p_rec) {
// Add this record to SDR repo
if (sdr_add_entry(&sdr, &rec_id)) {
- syslog(LOG_ALERT, "sdr_add_thresh_rec: sdr_add_entry failed\n");
+ syslog(LOG_WARNING, "sdr_add_thresh_rec: sdr_add_entry failed\n");
return -1;
}
@@ -263,7 +263,7 @@ sdr_add_oem_rec(sensor_oem_t *p_rec) {
// Add this record to SDR repo
if (sdr_add_entry(&sdr, &rec_id)) {
- syslog(LOG_ALERT, "sdr_add_oem_rec: sdr_add_entry failed\n");
+ syslog(LOG_WARNING, "sdr_add_oem_rec: sdr_add_entry failed\n");
return -1;
}
@@ -323,7 +323,7 @@ sdr_get_entry(int rsv_id, int read_rec_id, sdr_rec_t *rec,
// Make sure the rsv_id matches
if (rsv_id != g_rsv_id) {
- syslog(LOG_ALERT, "sdr_get_entry: Reservation ID mismatch\n");
+ syslog(LOG_WARNING, "sdr_get_entry: Reservation ID mismatch\n");
return -1;
}
@@ -338,19 +338,19 @@ sdr_get_entry(int rsv_id, int read_rec_id, sdr_rec_t *rec,
// If the SDR repo is empty return error
if (sdr_num_entries() == 0) {
- syslog(LOG_ALERT, "sdr_get_entry: No entries\n");
+ syslog(LOG_WARNING, "sdr_get_entry: No entries\n");
return -1;
}
// Check for boundary conditions
if ((index < SDR_INDEX_MIN) || (index > SDR_INDEX_MAX)) {
- syslog(LOG_ALERT, "sdr_get_entry: Invalid Record ID %d\n", read_rec_id);
+ syslog(LOG_WARNING, "sdr_get_entry: Invalid Record ID %d\n", read_rec_id);
return -1;
}
// Check to make sure the given id is valid
if (index < g_sdr_hdr.begin || index >= g_sdr_hdr.end) {
- syslog(LOG_ALERT, "sdr_get_entry: Wrong Record ID %d\n", read_rec_id);
+ syslog(LOG_WARNING, "sdr_get_entry: Wrong Record ID %d\n", read_rec_id);
return -1;
}
diff --git a/common/recipes-core/ipmid/files/sel.c b/common/recipes-core/ipmid/files/sel.c
index d598bb1..1b45b42 100644
--- a/common/recipes-core/ipmid/files/sel.c
+++ b/common/recipes-core/ipmid/files/sel.c
@@ -31,9 +31,19 @@
#include <errno.h>
#include <syslog.h>
#include <string.h>
+#include <stdint.h>
+#include <sys/types.h>
+
+
+#if defined(CONFIG_YOSEMITE)
+#define MAX_NODES 4
+#else
+#define MAX_NODES 1
+#endif
// SEL File.
-#define SEL_LOG_FILE "/mnt/data/sel.bin"
+#define SEL_LOG_FILE "/mnt/data/sel%d.bin"
+#define SIZE_PATH_MAX 32
// SEL Header magic number
#define SEL_HDR_MAGIC 0xFBFBFBFB
@@ -75,24 +85,27 @@ typedef struct {
} sel_hdr_t;
// Keep track of last Reservation ID
-static int g_rsv_id = 0x01;
+static int g_rsv_id[MAX_NODES+1];
// Cached version of SEL Header and data
-static sel_hdr_t g_sel_hdr;
-static sel_msg_t g_sel_data[SEL_ELEMS_MAX];
+static sel_hdr_t g_sel_hdr[MAX_NODES+1];
+static sel_msg_t g_sel_data[MAX_NODES+1][SEL_ELEMS_MAX];
// Local helper functions to interact with file system
static int
-file_get_sel_hdr(void) {
+file_get_sel_hdr(int node) {
FILE *fp;
+ char fpath[SIZE_PATH_MAX] = {0};
+
+ sprintf(fpath, SEL_LOG_FILE, node);
- fp = fopen(SEL_LOG_FILE, "r");
+ fp = fopen(fpath, "r");
if (fp == NULL) {
return -1;
}
- if (fread(&g_sel_hdr, sizeof(sel_hdr_t), 1, fp) <= 0) {
- syslog(LOG_ALERT, "file_get_sel_hdr: fread\n");
+ if (fread(&g_sel_hdr[node], sizeof(sel_hdr_t), 1, fp) <= 0) {
+ syslog(LOG_WARNING, "file_get_sel_hdr: fread\n");
fclose (fp);
return -1;
}
@@ -102,25 +115,28 @@ file_get_sel_hdr(void) {
}
static int
-file_get_sel_data(void) {
+file_get_sel_data(int node) {
FILE *fp;
int i, j;
+ char fpath[SIZE_PATH_MAX] = {0};
- fp = fopen(SEL_LOG_FILE, "r");
+ sprintf(fpath, SEL_LOG_FILE, node);
+
+ fp = fopen(fpath, "r");
if (fp == NULL) {
- syslog(LOG_ALERT, "file_get_sel_data: fopen\n");
+ syslog(LOG_WARNING, "file_get_sel_data: fopen\n");
return -1;
}
if (fseek(fp, SEL_DATA_OFFSET, SEEK_SET)) {
- syslog(LOG_ALERT, "file_get_sel_data: fseek\n");
+ syslog(LOG_WARNING, "file_get_sel_data: fseek\n");
fclose(fp);
return -1;
}
unsigned char buf[SEL_ELEMS_MAX * 16];
if (fread(buf, 1, SEL_ELEMS_MAX * sizeof(sel_msg_t), fp) <= 0) {
- syslog(LOG_ALERT, "file_get_sel_data: fread\n");
+ syslog(LOG_WARNING, "file_get_sel_data: fread\n");
fclose(fp);
return -1;
}
@@ -129,7 +145,7 @@ file_get_sel_data(void) {
for (i = 0; i < SEL_ELEMS_MAX; i++) {
for (j = 0; j < sizeof(sel_msg_t);j++) {
- g_sel_data[i].msg[j] = buf[i*16 + j];
+ g_sel_data[node][i].msg[j] = buf[i*16 + j];
}
}
@@ -137,17 +153,20 @@ file_get_sel_data(void) {
}
static int
-file_store_sel_hdr(void) {
+file_store_sel_hdr(int node) {
FILE *fp;
+ char fpath[SIZE_PATH_MAX] = {0};
+
+ sprintf(fpath, SEL_LOG_FILE, node);
- fp = fopen(SEL_LOG_FILE, "r+");
+ fp = fopen(fpath, "r+");
if (fp == NULL) {
- syslog(LOG_ALERT, "file_store_sel_hdr: fopen\n");
+ syslog(LOG_WARNING, "file_store_sel_hdr: fopen\n");
return -1;
}
- if (fwrite(&g_sel_hdr, sizeof(sel_hdr_t), 1, fp) <= 0) {
- syslog(LOG_ALERT, "file_store_sel_hdr: fwrite\n");
+ if (fwrite(&g_sel_hdr[node], sizeof(sel_hdr_t), 1, fp) <= 0) {
+ syslog(LOG_WARNING, "file_store_sel_hdr: fwrite\n");
fclose(fp);
return -1;
}
@@ -158,13 +177,16 @@ file_store_sel_hdr(void) {
}
static int
-file_store_sel_data(int recId, sel_msg_t *data) {
+file_store_sel_data(int node, int recId, sel_msg_t *data) {
FILE *fp;
int index;
+ char fpath[SIZE_PATH_MAX] = {0};
- fp = fopen(SEL_LOG_FILE, "r+");
+ sprintf(fpath, SEL_LOG_FILE, node);
+
+ fp = fopen(fpath, "r+");
if (fp == NULL) {
- syslog(LOG_ALERT, "file_store_sel_data: fopen\n");
+ syslog(LOG_WARNING, "file_store_sel_data: fopen\n");
return -1;
}
@@ -172,13 +194,13 @@ file_store_sel_data(int recId, sel_msg_t *data) {
index = (recId-1) * sizeof(sel_msg_t);
if (fseek(fp, SEL_DATA_OFFSET+index, SEEK_SET)) {
- syslog(LOG_ALERT, "file_store_sel_data: fseek\n");
+ syslog(LOG_WARNING, "file_store_sel_data: fseek\n");
fclose(fp);
return -1;
}
if (fwrite(data->msg, sizeof(sel_msg_t), 1, fp) <= 0) {
- syslog(LOG_ALERT, "file_store_sel_data: fwrite\n");
+ syslog(LOG_WARNING, "file_store_sel_data: fwrite\n");
fclose(fp);
return -1;
}
@@ -188,37 +210,103 @@ file_store_sel_data(int recId, sel_msg_t *data) {
return 0;
}
+static void
+dump_sel_syslog(int fru, sel_msg_t *data) {
+ int i = 0;
+ char temp_str[8] = {0};
+ char str[128] = {0};
+
+ for (i = 0; i < 15; i++) {
+ sprintf(temp_str, "%02X:", data->msg[i]);
+ strcat(str, temp_str);
+ }
+ sprintf(temp_str, "%02X", data->msg[15]);
+ strcat(str, temp_str);
+
+ syslog(LOG_CRIT, "SEL Entry, FRU: %d, Content: %s\n", fru, str);
+}
+
+static void
+parse_sel(uint8_t fru, sel_msg_t *data) {
+ int i = 0;
+ uint32_t timestamp;
+ char *sel = data->msg;
+ uint8_t sensor_type;
+ uint8_t sensor_num;
+ uint8_t event_dir;
+ uint8_t type_num;
+ uint8_t event_data[3];
+ char sensor_name[32];
+ char error_log[64];
+ char error_type[64];
+ char status[16];
+ int ret;
+
+ //memcpy(timestamp, (uint8_t *) &sel[3], 4);
+ timestamp = 0;
+ timestamp |= sel[3];
+ timestamp |= sel[4] << 8;
+ timestamp |= sel[5] << 16;
+ timestamp |= sel[6] << 24;
+
+ sensor_type = (uint8_t) sel[10];
+ sensor_num = (uint8_t) sel[11];
+ event_dir = ((uint8_t) sel[12] & (1 << 7)) >> 7; /* Bit 7 of sel[12] */
+ type_num = (uint8_t) sel[12]; /* Bits 6:0 */
+ memcpy(event_data, (uint8_t *) &sel[13], 3);
+
+ sprintf(status, event_dir ? "DEASSERT" : "ASSERT");
+
+ if (type_num == 0x1) {
+ sprintf(error_type, "Threshold");
+ } else if (type_num >= 0x2 || type_num <= 0xC || type_num == 0x6F) {
+ sprintf(error_type, "Discrete");
+ } else if (type_num >= 0x70 || type_num <= 0x7F) {
+ sprintf(error_type, "OEM");
+ } else {
+ sprintf(error_type, "Unknown");
+ }
+
+ ret = pal_get_event_sensor_name(fru, sensor_num, sensor_name);
+ ret = pal_parse_sel(fru, sensor_num, event_data, error_log);
+ ret = pal_sel_handler(fru, sensor_num);
+
+ syslog(LOG_CRIT, "SEL Entry, %s: FRU: %d, Sensor: 0x%X, Name: %s,"
+ " Timestamp: %u, Event Type: %s, Event Data: %s",
+ status, fru, sensor_num, sensor_name, timestamp, error_type, error_log);
+}
+
// Platform specific SEL API entry points
// Retrieve time stamp for recent add operation
void
-sel_ts_recent_add(time_stamp_t *ts) {
- memcpy(ts->ts, g_sel_hdr.ts_add.ts, 0x04);
+sel_ts_recent_add(int node, time_stamp_t *ts) {
+ memcpy(ts->ts, g_sel_hdr[node].ts_add.ts, 0x04);
}
// Retrieve time stamp for recent erase operation
void
-sel_ts_recent_erase(time_stamp_t *ts) {
- memcpy(ts->ts, g_sel_hdr.ts_erase.ts, 0x04);
+sel_ts_recent_erase(int node, time_stamp_t *ts) {
+ memcpy(ts->ts, g_sel_hdr[node].ts_erase.ts, 0x04);
}
// Retrieve total number of entries in SEL log
int
-sel_num_entries(void) {
- if (g_sel_hdr.begin <= g_sel_hdr.end) {
- return (g_sel_hdr.end - g_sel_hdr.begin);
+sel_num_entries(int node) {
+ if (g_sel_hdr[node].begin <= g_sel_hdr[node].end) {
+ return (g_sel_hdr[node].end - g_sel_hdr[node].begin);
} else {
- return (g_sel_hdr.end + (SEL_INDEX_MAX - g_sel_hdr.begin + 1));
+ return (g_sel_hdr[node].end + (SEL_INDEX_MAX - g_sel_hdr[node].begin + 1));
}
}
// Retrieve total free space available in SEL log
int
-sel_free_space(void) {
+sel_free_space(int node) {
int total_space;
int used_space;
total_space = SEL_RECORDS_MAX * sizeof(sel_msg_t);
- used_space = sel_num_entries() * sizeof(sel_msg_t);
+ used_space = sel_num_entries(node) * sizeof(sel_msg_t);
return (total_space - used_space);
}
@@ -226,28 +314,28 @@ sel_free_space(void) {
// Reserve an ID that will be used in later operations
// IPMI/Section 31.4
int
-sel_rsv_id() {
+sel_rsv_id(int node) {
// Increment the current reservation ID and return
- if (g_rsv_id++ == SEL_RSVID_MAX) {
- g_rsv_id = SEL_RSVID_MIN;
+ if (g_rsv_id[node]++ == SEL_RSVID_MAX) {
+ g_rsv_id[node] = SEL_RSVID_MIN;
}
- return g_rsv_id;
+ return g_rsv_id[node];
}
// Get the SEL entry for a given record ID
// IPMI/Section 31.5
int
-sel_get_entry(int read_rec_id, sel_msg_t *msg, int *next_rec_id) {
+sel_get_entry(int node, int read_rec_id, sel_msg_t *msg, int *next_rec_id) {
int index;
// Find the index in to array based on given index
if (read_rec_id == SEL_RECID_FIRST) {
- index = g_sel_hdr.begin;
+ index = g_sel_hdr[node].begin;
} else if (read_rec_id == SEL_RECID_LAST) {
- if (g_sel_hdr.end) {
- index = g_sel_hdr.end - 1;
+ if (g_sel_hdr[node].end) {
+ index = g_sel_hdr[node].end - 1;
} else {
index = SEL_INDEX_MAX;
}
@@ -256,34 +344,34 @@ sel_get_entry(int read_rec_id, sel_msg_t *msg, int *next_rec_id) {
}
// If the log is empty return error
- if (sel_num_entries() == 0) {
- syslog(LOG_ALERT, "sel_get_entry: No entries\n");
+ if (sel_num_entries(node) == 0) {
+ syslog(LOG_WARNING, "sel_get_entry: No entries\n");
return -1;
}
// Check for boundary conditions
if ((index < SEL_INDEX_MIN) || (index > SEL_INDEX_MAX)) {
- syslog(LOG_ALERT, "sel_get_entry: Invalid Record ID %d\n", read_rec_id);
+ syslog(LOG_WARNING, "sel_get_entry: Invalid Record ID %d\n", read_rec_id);
return -1;
}
// If begin < end, check to make sure the given id falls between
- if (g_sel_hdr.begin < g_sel_hdr.end) {
- if (index < g_sel_hdr.begin || index >= g_sel_hdr.end) {
- syslog(LOG_ALERT, "sel_get_entry: Wrong Record ID %d\n", read_rec_id);
+ if (g_sel_hdr[node].begin < g_sel_hdr[node].end) {
+ if (index < g_sel_hdr[node].begin || index >= g_sel_hdr[node].end) {
+ syslog(LOG_WARNING, "sel_get_entry: Wrong Record ID %d\n", read_rec_id);
return -1;
}
}
// If end < begin, check to make sure the given id is valid
- if (g_sel_hdr.begin > g_sel_hdr.end) {
- if (index >= g_sel_hdr.end && index < g_sel_hdr.begin) {
- syslog(LOG_ALERT, "sel_get_entry: Wrong Record ID2 %d\n", read_rec_id);
+ if (g_sel_hdr[node].begin > g_sel_hdr[node].end) {
+ if (index >= g_sel_hdr[node].end && index < g_sel_hdr[node].begin) {
+ syslog(LOG_WARNING, "sel_get_entry: Wrong Record ID2 %d\n", read_rec_id);
return -1;
}
}
- memcpy(msg->msg, g_sel_data[index].msg, sizeof(sel_msg_t));
+ memcpy(msg->msg, g_sel_data[node][index].msg, sizeof(sel_msg_t));
// Return the next record ID in the log
*next_rec_id = read_rec_id++;
@@ -292,7 +380,7 @@ sel_get_entry(int read_rec_id, sel_msg_t *msg, int *next_rec_id) {
}
// If this is the last entry in the log, return 0xFFFF
- if (*next_rec_id == g_sel_hdr.end) {
+ if (*next_rec_id == g_sel_hdr[node].end) {
*next_rec_id = SEL_RECID_LAST;
}
@@ -302,13 +390,13 @@ sel_get_entry(int read_rec_id, sel_msg_t *msg, int *next_rec_id) {
// Add a new entry in to SEL log
// IPMI/Section 31.6
int
-sel_add_entry(sel_msg_t *msg, int *rec_id) {
+sel_add_entry(int node, sel_msg_t *msg, int *rec_id) {
// If the SEL if full, roll over. To keep track of empty condition, use
// one empty location less than the max records.
- if (sel_num_entries() == SEL_RECORDS_MAX) {
- syslog(LOG_ALERT, "sel_add_entry: SEL rollover\n");
- if (++g_sel_hdr.begin > SEL_INDEX_MAX) {
- g_sel_hdr.begin = SEL_INDEX_MIN;
+ if (sel_num_entries(node) == SEL_RECORDS_MAX) {
+ syslog(LOG_WARNING, "sel_add_entry: SEL rollover\n");
+ if (++g_sel_hdr[node].begin > SEL_INDEX_MAX) {
+ g_sel_hdr[node].begin = SEL_INDEX_MIN;
}
}
@@ -316,27 +404,33 @@ sel_add_entry(sel_msg_t *msg, int *rec_id) {
time_stamp_fill(&msg->msg[3]);
// Add the enry at end
- memcpy(g_sel_data[g_sel_hdr.end].msg, msg->msg, sizeof(sel_msg_t));
+ memcpy(g_sel_data[node][g_sel_hdr[node].end].msg, msg->msg, sizeof(sel_msg_t));
// Return the newly added record ID
- *rec_id = g_sel_hdr.end+1;
+ *rec_id = g_sel_hdr[node].end+1;
- if (file_store_sel_data(*rec_id, msg)) {
- syslog(LOG_ALERT, "sel_add_entry: file_store_sel_data\n");
+ // Print the data in syslog
+ dump_sel_syslog(node, msg);
+
+ // Parse the SEL message
+ parse_sel((uint8_t) node, msg);
+
+ if (file_store_sel_data(node, *rec_id, msg)) {
+ syslog(LOG_WARNING, "sel_add_entry: file_store_sel_data\n");
return -1;
}
// Increment the end pointer
- if (++g_sel_hdr.end > SEL_INDEX_MAX) {
- g_sel_hdr.end = SEL_INDEX_MIN;
+ if (++g_sel_hdr[node].end > SEL_INDEX_MAX) {
+ g_sel_hdr[node].end = SEL_INDEX_MIN;
}
// Update timestamp for add in header
- time_stamp_fill(g_sel_hdr.ts_add.ts);
+ time_stamp_fill(g_sel_hdr[node].ts_add.ts);
// Store the structure persistently
- if (file_store_sel_hdr()) {
- syslog(LOG_ALERT, "sel_add_entry: file_store_sel_hdr\n");
+ if (file_store_sel_hdr(node)) {
+ syslog(LOG_WARNING, "sel_add_entry: file_store_sel_hdr\n");
return -1;
}
@@ -347,21 +441,21 @@ sel_add_entry(sel_msg_t *msg, int *rec_id) {
// IPMI/Section 31.9
// Note: To reduce wear/tear, instead of erasing, manipulating the metadata
int
-sel_erase(int rsv_id) {
- if (rsv_id != g_rsv_id) {
+sel_erase(int node, int rsv_id) {
+ if (rsv_id != g_rsv_id[node]) {
return -1;
}
// Erase SEL Logs
- g_sel_hdr.begin = SEL_INDEX_MIN;
- g_sel_hdr.end = SEL_INDEX_MIN;
+ g_sel_hdr[node].begin = SEL_INDEX_MIN;
+ g_sel_hdr[node].end = SEL_INDEX_MIN;
// Update timestamp for erase in header
- time_stamp_fill(g_sel_hdr.ts_erase.ts);
+ time_stamp_fill(g_sel_hdr[node].ts_erase.ts);
// Store the structure persistently
- if (file_store_sel_hdr()) {
- syslog(LOG_ALERT, "sel_erase: file_store_sel_hdr\n");
+ if (file_store_sel_hdr(node)) {
+ syslog(LOG_WARNING, "sel_erase: file_store_sel_hdr\n");
return -1;
}
@@ -372,8 +466,8 @@ sel_erase(int rsv_id) {
// IPMI/Section 31.2
// Note: Since we are not doing offline erasing, need not return in-progress state
int
-sel_erase_status(int rsv_id, sel_erase_stat_t *status) {
- if (rsv_id != g_rsv_id) {
+sel_erase_status(int node, int rsv_id, sel_erase_stat_t *status) {
+ if (rsv_id != g_rsv_id[node]) {
return -1;
}
@@ -384,21 +478,24 @@ sel_erase_status(int rsv_id, sel_erase_stat_t *status) {
}
// Initialize SEL log file
-int
-sel_init(void) {
+static int
+sel_node_init(int node) {
FILE *fp;
int i;
+ char fpath[SIZE_PATH_MAX] = {0};
+
+ sprintf(fpath, SEL_LOG_FILE, node);
// Check if the file exists or not
- if (access(SEL_LOG_FILE, F_OK) == 0) {
+ if (access(fpath, F_OK) == 0) {
// Since file is present, fetch all the contents to cache
- if (file_get_sel_hdr()) {
- syslog(LOG_ALERT, "init_sel: file_get_sel_hdr\n");
+ if (file_get_sel_hdr(node)) {
+ syslog(LOG_WARNING, "init_sel: file_get_sel_hdr\n");
return -1;
}
- if (file_get_sel_data()) {
- syslog(LOG_ALERT, "init_sel: file_get_sel_data\n");
+ if (file_get_sel_data(node)) {
+ syslog(LOG_WARNING, "init_sel: file_get_sel_data\n");
return -1;
}
@@ -406,35 +503,52 @@ sel_init(void) {
}
// File not present, so create the file
- fp = fopen(SEL_LOG_FILE, "w+");
+ fp = fopen(fpath, "w+");
if (fp == NULL) {
- syslog(LOG_ALERT, "init_sel: fopen\n");
+ syslog(LOG_WARNING, "init_sel: fopen\n");
return -1;
}
fclose (fp);
// Populate SEL Header in to the file
- g_sel_hdr.magic = SEL_HDR_MAGIC;
- g_sel_hdr.version = SEL_HDR_VERSION;
- g_sel_hdr.begin = SEL_INDEX_MIN;
- g_sel_hdr.end = SEL_INDEX_MIN;
- memset(g_sel_hdr.ts_add.ts, 0x0, 4);
- memset(g_sel_hdr.ts_erase.ts, 0x0, 4);
-
- if (file_store_sel_hdr()) {
- syslog(LOG_ALERT, "init_sel: file_store_sel_hdr\n");
+ g_sel_hdr[node].magic = SEL_HDR_MAGIC;
+ g_sel_hdr[node].version = SEL_HDR_VERSION;
+ g_sel_hdr[node].begin = SEL_INDEX_MIN;
+ g_sel_hdr[node].end = SEL_INDEX_MIN;
+ memset(g_sel_hdr[node].ts_add.ts, 0x0, 4);
+ memset(g_sel_hdr[node].ts_erase.ts, 0x0, 4);
+
+ if (file_store_sel_hdr(node)) {
+ syslog(LOG_WARNING, "init_sel: file_store_sel_hdr\n");
return -1;
}
// Populate SEL Data in to the file
for (i = 1; i <= SEL_RECORDS_MAX; i++) {
sel_msg_t msg = {0};
- if (file_store_sel_data(i, &msg)) {
- syslog(LOG_ALERT, "init_sel: file_store_sel_data\n");
+ if (file_store_sel_data(node, i, &msg)) {
+ syslog(LOG_WARNING, "init_sel: file_store_sel_data\n");
return -1;
}
}
+ g_rsv_id[node] = 0x01;
+
return 0;
}
+
+int
+sel_init(void) {
+ int ret;
+ int i;
+
+ for (i = 1; i < MAX_NODES+1; i++) {
+ ret = sel_node_init(i);
+ if (ret) {
+ return ret;
+ }
+ }
+
+ return ret;
+}
diff --git a/common/recipes-core/ipmid/files/sel.h b/common/recipes-core/ipmid/files/sel.h
index 3bb9a2f..500b078 100644
--- a/common/recipes-core/ipmid/files/sel.h
+++ b/common/recipes-core/ipmid/files/sel.h
@@ -37,15 +37,15 @@ typedef struct {
unsigned char msg[16];
} sel_msg_t;
-void sel_ts_recent_add(time_stamp_t *ts);
-void sel_ts_recent_erase(time_stamp_t *ts);
-int sel_num_entries(void);
-int sel_free_space(void);
-int sel_rsv_id();
-int sel_get_entry(int read_rec_id, sel_msg_t *msg, int *next_rec_id);
-int sel_add_entry(sel_msg_t *msg, int *rec_id);
-int sel_erase(int rsv_id);
-int sel_erase_status(int rsv_id, sel_erase_stat_t *status);
+void sel_ts_recent_add(int node, time_stamp_t *ts);
+void sel_ts_recent_erase(int node, time_stamp_t *ts);
+int sel_num_entries(int node);
+int sel_free_space(int node);
+int sel_rsv_id(int node);
+int sel_get_entry(int node, int read_rec_id, sel_msg_t *msg, int *next_rec_id);
+int sel_add_entry(int node, sel_msg_t *msg, int *rec_id);
+int sel_erase(int node, int rsv_id);
+int sel_erase_status(int node, int rsv_id, sel_erase_stat_t *status);
int sel_init(void);
#endif /* __SEL_H__ */
OpenPOWER on IntegriCloud