vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 1 | #ifndef __HOST_IPMID_IPMI_COMMON_H__ |
| 2 | #define __HOST_IPMID_IPMI_COMMON_H__ |
| 3 | #include <stdlib.h> |
| 4 | |
| 5 | // length of Completion Code and its ALWAYS _1_ |
| 6 | #define IPMI_CC_LEN 1 |
| 7 | |
| 8 | // IPMI Net Function number as specified by IPMI V2.0 spec. |
| 9 | // Example : |
| 10 | // NETFUN_APP = (0x06 << 2), |
| 11 | typedef unsigned char ipmi_netfn_t; |
| 12 | |
| 13 | // IPMI Command for a Net Function number as specified by IPMI V2.0 spec. |
| 14 | typedef unsigned char ipmi_cmd_t; |
| 15 | |
| 16 | // Buffer containing data from sender of netfn and command as part of request |
| 17 | typedef void* ipmi_request_t; |
| 18 | |
| 19 | // This is the response buffer that the provider of [netfn,cmd] will send back |
| 20 | // to the caller. Provider will allocate the memory inside the handler and then |
| 21 | // will do a memcpy to this response buffer and also will set the data size |
| 22 | // parameter to the size of the buffer. |
| 23 | // EXAMPLE : |
| 24 | // unsigned char str[] = {0x00, 0x01, 0xFE, 0xFF, 0x0A, 0x01}; |
| 25 | // *data_len = 6; |
| 26 | // memcpy(response, &str, *data_len); |
| 27 | typedef void* ipmi_response_t; |
| 28 | |
| 29 | // This buffer contains any *user specific* data that is of interest only to the |
| 30 | // plugin. For a ipmi function router, this data is opaque. At the time of |
| 31 | // registering the plugin handlers, plugin may optionally allocate a memory and |
| 32 | // fill in whatever needed that will be of help during the actual handling of |
| 33 | // command. IPMID will just pass the netfn, cmd and also this data to plugins |
| 34 | // during the command handler invocation. |
| 35 | typedef void* ipmi_context_t; |
| 36 | |
| 37 | // Length of request / response buffer depending on whether the data is a |
| 38 | // request or a response from a plugin handler. |
| 39 | typedef size_t* ipmi_data_len_t; |
| 40 | |
| 41 | // Plugin function return the status code |
| 42 | typedef unsigned char ipmi_ret_t; |
| 43 | |
| 44 | // This is the callback handler that the plugin registers with IPMID. IPMI |
| 45 | // function router will then make a call to this callback handler with the |
| 46 | // necessary arguments of netfn, cmd, request, response, size and context. |
| 47 | typedef ipmi_ret_t (*ipmid_callback_t)(ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t, |
| 48 | ipmi_response_t, ipmi_data_len_t, ipmi_context_t); |
| 49 | |
| 50 | // This is the constructor function that is called into by each plugin handlers. |
| 51 | // When ipmi sets up the callback handlers, a call is made to this with |
| 52 | // information of netfn, cmd, callback handler pointer and context data. |
| 53 | // Making this a extern "C" so that plugin libraries written in C can also use |
| 54 | // it. |
| 55 | extern "C" void ipmi_register_callback(ipmi_netfn_t, ipmi_cmd_t, |
| 56 | ipmi_context_t, ipmid_callback_t); |
| 57 | |
| 58 | // These are the command network functions, the response |
| 59 | // network functions are the function + 1. So to determine |
| 60 | // the proper network function which issued the command |
| 61 | // associated with a response, subtract 1. |
| 62 | // Note: these are also shifted left to make room for the LUN. |
| 63 | enum ipmi_net_fns |
| 64 | { |
| 65 | NETFUN_CHASSIS = (0x00 << 2), |
| 66 | NETFUN_BRIDGE = (0x02 << 2), |
| 67 | NETFUN_SENSOR = (0x04 << 2), |
| 68 | NETFUN_APP = (0x06 << 2), |
| 69 | NETFUN_FIRMWARE = (0x08 << 2), |
| 70 | NETFUN_STORAGE = (0x0a << 2), |
| 71 | NETFUN_TRANPORT = (0x0c << 2), |
| 72 | NETFUN_GRPEXT = (0x2c << 2), |
Chris Austen | 74e1d09 | 2015-10-21 15:41:43 -0500 | [diff] [blame] | 73 | NETFUN_NONE = (0x30 << 2), |
| 74 | NETFUN_OEM = (0x32 << 2) |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | // IPMI commands for net functions. Since this is to be used both by the ipmi |
| 78 | // function router and also the callback handler registration function, its put |
| 79 | // in this .H file. |
| 80 | enum ipmi_netfn_wild_card_cmd |
| 81 | { |
| 82 | IPMI_CMD_WILDCARD = 0xFF, |
| 83 | }; |
| 84 | |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 85 | // Return (completion) codes from a IPMI operation as needed by IPMI V2.0 spec. |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 86 | enum ipmi_return_codes |
| 87 | { |
| 88 | IPMI_CC_OK = 0x00, |
Chris Austen | 1810bec | 2015-10-13 12:12:39 -0500 | [diff] [blame] | 89 | IPMI_DCMI_CC_NO_ACTIVE_POWER_LIMIT = 0x80, |
Chris Austen | 8339f9d | 2015-10-21 20:07:31 -0500 | [diff] [blame] | 90 | IPMI_CC_INVALID = 0xC1, |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 91 | IPMI_CC_SENSOR_INVALID = 0xCB, |
| 92 | IPMI_CC_RESPONSE_ERROR = 0xCE, |
| 93 | IPMI_CC_UNSPECIFIED_ERROR = 0xFF, |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 94 | }; |
| 95 | |
| 96 | #endif |