blob: 6bd991fb911e2247c2aa3b31006a24b6468e41a7 [file] [log] [blame]
vishwabmcba0bd5f2015-09-30 16:50:23 +05301#ifndef __HOST_IPMID_IPMI_COMMON_H__
2#define __HOST_IPMID_IPMI_COMMON_H__
3#include <stdlib.h>
Chris Austen30195fa2015-11-13 14:39:19 -06004#include <systemd/sd-bus.h>
vishwabmcba0bd5f2015-09-30 16:50:23 +05305
Joel Stanleyc99350c2015-11-25 17:27:25 +10306#ifdef __cplusplus
7extern "C" {
8#endif
9
vishwabmcba0bd5f2015-09-30 16:50:23 +053010// length of Completion Code and its ALWAYS _1_
11#define IPMI_CC_LEN 1
12
13// IPMI Net Function number as specified by IPMI V2.0 spec.
14// Example :
15// NETFUN_APP = (0x06 << 2),
16typedef unsigned char ipmi_netfn_t;
17
18// IPMI Command for a Net Function number as specified by IPMI V2.0 spec.
19typedef unsigned char ipmi_cmd_t;
20
21// Buffer containing data from sender of netfn and command as part of request
22typedef void* ipmi_request_t;
23
24// This is the response buffer that the provider of [netfn,cmd] will send back
25// to the caller. Provider will allocate the memory inside the handler and then
26// will do a memcpy to this response buffer and also will set the data size
27// parameter to the size of the buffer.
28// EXAMPLE :
29// unsigned char str[] = {0x00, 0x01, 0xFE, 0xFF, 0x0A, 0x01};
30// *data_len = 6;
31// memcpy(response, &str, *data_len);
32typedef void* ipmi_response_t;
33
34// This buffer contains any *user specific* data that is of interest only to the
35// plugin. For a ipmi function router, this data is opaque. At the time of
36// registering the plugin handlers, plugin may optionally allocate a memory and
37// fill in whatever needed that will be of help during the actual handling of
38// command. IPMID will just pass the netfn, cmd and also this data to plugins
39// during the command handler invocation.
40typedef void* ipmi_context_t;
41
42// Length of request / response buffer depending on whether the data is a
43// request or a response from a plugin handler.
44typedef size_t* ipmi_data_len_t;
45
46// Plugin function return the status code
47typedef unsigned char ipmi_ret_t;
48
49// This is the callback handler that the plugin registers with IPMID. IPMI
50// function router will then make a call to this callback handler with the
51// necessary arguments of netfn, cmd, request, response, size and context.
52typedef ipmi_ret_t (*ipmid_callback_t)(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t,
53 ipmi_response_t, ipmi_data_len_t, ipmi_context_t);
54
55// This is the constructor function that is called into by each plugin handlers.
56// When ipmi sets up the callback handlers, a call is made to this with
57// information of netfn, cmd, callback handler pointer and context data.
Joel Stanleyc99350c2015-11-25 17:27:25 +103058void ipmi_register_callback(ipmi_netfn_t, ipmi_cmd_t,
vishwabmcba0bd5f2015-09-30 16:50:23 +053059 ipmi_context_t, ipmid_callback_t);
60
Nan Li36c0cb62016-03-31 11:16:08 +080061unsigned short get_sel_reserve_id(void);
62
vishwabmcba0bd5f2015-09-30 16:50:23 +053063// These are the command network functions, the response
64// network functions are the function + 1. So to determine
65// the proper network function which issued the command
66// associated with a response, subtract 1.
67// Note: these are also shifted left to make room for the LUN.
68enum ipmi_net_fns
69{
Adriana Kobylak5d6481f2015-10-29 21:44:55 -050070 NETFUN_CHASSIS = 0x00,
71 NETFUN_BRIDGE = 0x02,
72 NETFUN_SENSOR = 0x04,
73 NETFUN_APP = 0x06,
74 NETFUN_FIRMWARE = 0x08,
75 NETFUN_STORAGE = 0x0a,
76 NETFUN_TRANSPORT = 0x0c,
77 NETFUN_GRPEXT = 0x2c,
78 NETFUN_NONE = 0x30,
79 NETFUN_OEM = 0x32
vishwabmcba0bd5f2015-09-30 16:50:23 +053080};
81
82// IPMI commands for net functions. Since this is to be used both by the ipmi
83// function router and also the callback handler registration function, its put
84// in this .H file.
85enum ipmi_netfn_wild_card_cmd
86{
87 IPMI_CMD_WILDCARD = 0xFF,
88};
89
Adriana Kobylakd100ee52015-10-20 17:02:37 -050090// Return (completion) codes from a IPMI operation as needed by IPMI V2.0 spec.
vishwabmcba0bd5f2015-09-30 16:50:23 +053091enum ipmi_return_codes
92{
93 IPMI_CC_OK = 0x00,
Chris Austen1810bec2015-10-13 12:12:39 -050094 IPMI_DCMI_CC_NO_ACTIVE_POWER_LIMIT = 0x80,
Chris Austen8339f9d2015-10-21 20:07:31 -050095 IPMI_CC_INVALID = 0xC1,
Nan Li36c0cb62016-03-31 11:16:08 +080096 IPMI_CC_INVALID_RESERVATION_ID = 0xC5,
Tom63a3db72016-09-23 18:20:52 +053097 IPMI_CC_REQ_DATA_LEN_INVALID = 0xC7,
Chris Austenc2cd29d2016-02-05 20:02:29 -060098 IPMI_CC_PARM_OUT_OF_RANGE = 0xC9,
Adriana Kobylakd100ee52015-10-20 17:02:37 -050099 IPMI_CC_SENSOR_INVALID = 0xCB,
100 IPMI_CC_RESPONSE_ERROR = 0xCE,
Tom Joseph9a61b4f2016-07-11 06:56:11 -0500101 IPMI_CC_INSUFFICIENT_PRIVILEGE = 0xD4,
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500102 IPMI_CC_UNSPECIFIED_ERROR = 0xFF,
vishwabmcba0bd5f2015-09-30 16:50:23 +0530103};
104
Joel Stanleyc99350c2015-11-25 17:27:25 +1030105sd_bus *ipmid_get_sd_bus_connection(void);
vishwab9f559a2016-01-13 01:53:08 -0600106sd_bus_slot *ipmid_get_sd_bus_slot(void);
Joel Stanleyc99350c2015-11-25 17:27:25 +1030107
108#ifdef __cplusplus
109}
110#endif
111
vishwabmcba0bd5f2015-09-30 16:50:23 +0530112#endif