Skip to content

Commit c2cd29d

Browse files
author
Chris Austen
committed
Add minimal support for ipmitool
Adding just a couple of ipmi commands that ipmitool always calls. I'm doing this because in order to run the ipmitool lan 1 <parms> instead of just the raw command the get channel info was needed.
1 parent bec22bb commit c2cd29d

File tree

5 files changed

+80
-1
lines changed

5 files changed

+80
-1
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ LIB_APP_OBJ = apphandler.o \
1515
ipmisensor.o \
1616
storageaddsel.o \
1717
transporthandler.o \
18-
globalhandler.o
18+
globalhandler.o \
19+
groupext.o
1920

2021
LIB_HOST_SRV_OBJ = host-services.o
2122

apphandler.C

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,44 @@ ipmi_ret_t ipmi_app_reset_watchdog(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
351351
return rc;
352352
}
353353

354+
// ATTENTION: This ipmi function is very hardcoded on purpose
355+
// OpenBMC does not fully support IPMI. This command is useful
356+
// to have around because it enables testing of interfaces with
357+
// the IPMI tool.
358+
#define GET_CHANNEL_INFO_CHANNEL_OFFSET 0
359+
// IPMI Table 6-2
360+
#define IPMI_CHANNEL_TYPE_IPMB 1
361+
// IPMI Table 6-3
362+
#define IPMI_CHANNEL_MEDIUM_TYPE_OTHER 6
363+
364+
ipmi_ret_t ipmi_app_channel_info(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
365+
ipmi_request_t request, ipmi_response_t response,
366+
ipmi_data_len_t data_len, ipmi_context_t context)
367+
{
368+
ipmi_ret_t rc = IPMI_CC_OK;
369+
uint8_t resp[] = {
370+
1,
371+
IPMI_CHANNEL_MEDIUM_TYPE_OTHER,
372+
IPMI_CHANNEL_TYPE_IPMB,
373+
1,0x41,0xA7,0x00,0,0};
374+
uint8_t *p = (uint8_t*) request;
375+
376+
printf("IPMI APP GET CHANNEL INFO\n");
377+
378+
// I"m only supporting channel 1. 0xE is the 'default channel'
379+
if (*p == 0xe || *p == 1) {
380+
381+
*data_len = sizeof(resp);
382+
memcpy(response, resp, *data_len);
383+
384+
} else {
385+
rc = IPMI_CC_PARM_OUT_OF_RANGE;
386+
*data_len = 0;
387+
}
388+
389+
return rc;
390+
}
391+
354392
ipmi_ret_t ipmi_app_set_bmc_global_enables(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
355393
ipmi_request_t request, ipmi_response_t response,
356394
ipmi_data_len_t data_len, ipmi_context_t context)
@@ -417,6 +455,12 @@ void register_netfn_app_functions()
417455
printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_GET_MSG_FLAGS);
418456
ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_MSG_FLAGS, NULL, ipmi_app_get_msg_flags);
419457

458+
459+
printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_GET_CHAN_INFO);
460+
ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_CHAN_INFO, NULL, ipmi_app_channel_info);
461+
462+
463+
420464
return;
421465
}
422466

apphandler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ enum ipmi_netfn_app_cmds
2727
IPMI_CMD_GET_MSG_FLAGS = 0x31,
2828
IPMI_CMD_READ_EVENT = 0x35,
2929
IPMI_CMD_GET_CAP_BIT = 0x36,
30+
IPMI_CMD_GET_CHAN_INFO = 0x42,
31+
3032
};
3133

3234
// A Mechanism to tell host to shtudown hosts by sending this PEM SEL. Really

groupext.C

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include "ipmid-api.h"
2+
#include "ipmid.H"
3+
#include <stdio.h>
4+
#include <stdint.h>
5+
6+
#define GRPEXT_GET_GROUP_CMD 0
7+
void register_netfn_groupext_functions() __attribute__((constructor));
8+
9+
ipmi_ret_t ipmi_groupext(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
10+
ipmi_request_t request, ipmi_response_t response,
11+
ipmi_data_len_t data_len, ipmi_context_t context)
12+
{
13+
// Generic return from IPMI commands.
14+
ipmi_ret_t rc = IPMI_CC_OK;
15+
uint8_t *p = (uint8_t*) response;
16+
17+
printf("IPMI GROUP EXTENTIONS\n");
18+
19+
*data_len = 1;
20+
*p = 0;
21+
22+
return rc;
23+
}
24+
25+
void register_netfn_groupext_functions()
26+
{
27+
printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_GRPEXT, GRPEXT_GET_GROUP_CMD);
28+
ipmi_register_callback(NETFUN_GRPEXT, GRPEXT_GET_GROUP_CMD, NULL, ipmi_groupext);
29+
30+
return;
31+
}

ipmid-api.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ enum ipmi_return_codes
9191
IPMI_CC_OK = 0x00,
9292
IPMI_DCMI_CC_NO_ACTIVE_POWER_LIMIT = 0x80,
9393
IPMI_CC_INVALID = 0xC1,
94+
IPMI_CC_PARM_OUT_OF_RANGE = 0xC9,
9495
IPMI_CC_SENSOR_INVALID = 0xCB,
9596
IPMI_CC_RESPONSE_ERROR = 0xCE,
9697
IPMI_CC_UNSPECIFIED_ERROR = 0xFF,

0 commit comments

Comments
 (0)