|
Packit Service |
ed0f68 |
/*
|
|
Packit Service |
ed0f68 |
* Copyright (c) 2004 Sun Microsystems, Inc. All Rights Reserved.
|
|
Packit Service |
ed0f68 |
*
|
|
Packit Service |
ed0f68 |
* Redistribution and use in source and binary forms, with or without
|
|
Packit Service |
ed0f68 |
* modification, are permitted provided that the following conditions
|
|
Packit Service |
ed0f68 |
* are met:
|
|
Packit Service |
ed0f68 |
*
|
|
Packit Service |
ed0f68 |
* Redistribution of source code must retain the above copyright
|
|
Packit Service |
ed0f68 |
* notice, this list of conditions and the following disclaimer.
|
|
Packit Service |
ed0f68 |
*
|
|
Packit Service |
ed0f68 |
* Redistribution in binary form must reproduce the above copyright
|
|
Packit Service |
ed0f68 |
* notice, this list of conditions and the following disclaimer in the
|
|
Packit Service |
ed0f68 |
* documentation and/or other materials provided with the distribution.
|
|
Packit Service |
ed0f68 |
*
|
|
Packit Service |
ed0f68 |
* Neither the name of Sun Microsystems, Inc. or the names of
|
|
Packit Service |
ed0f68 |
* contributors may be used to endorse or promote products derived
|
|
Packit Service |
ed0f68 |
* from this software without specific prior written permission.
|
|
Packit Service |
ed0f68 |
*
|
|
Packit Service |
ed0f68 |
* This software is provided "AS IS," without a warranty of any kind.
|
|
Packit Service |
ed0f68 |
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
|
|
Packit Service |
ed0f68 |
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
|
|
Packit Service |
ed0f68 |
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
|
|
Packit Service |
ed0f68 |
* SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE
|
|
Packit Service |
ed0f68 |
* FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
|
|
Packit Service |
ed0f68 |
* OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
|
|
Packit Service |
ed0f68 |
* SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
|
|
Packit Service |
ed0f68 |
* OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
|
|
Packit Service |
ed0f68 |
* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
|
|
Packit Service |
ed0f68 |
* LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
|
|
Packit Service |
ed0f68 |
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
Packit Service |
ed0f68 |
*/
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
#ifndef _BMC_INTF_H
|
|
Packit Service |
ed0f68 |
#define _BMC_INTF_H
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
#pragma ident "@(#)bmc_intf.h 1.2 05/03/07 SMI"
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
#ifdef __cplusplus
|
|
Packit Service |
ed0f68 |
extern "C" {
|
|
Packit Service |
ed0f68 |
#endif
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
#define BMC_SUCCESS 0x0
|
|
Packit Service |
ed0f68 |
#define BMC_FAILURE 0x1
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
#define BMC_NETFN_CHASSIS 0x0
|
|
Packit Service |
ed0f68 |
#define BMC_NETFN_BRIDGE 0x2
|
|
Packit Service |
ed0f68 |
#define BMC_NETFN_SE 0x4
|
|
Packit Service |
ed0f68 |
#define BMC_NETFN_APP 0x6
|
|
Packit Service |
ed0f68 |
#define BMC_NETFN_FIRMWARE 0x8
|
|
Packit Service |
ed0f68 |
#define BMC_NETFN_STORAGE 0xa
|
|
Packit Service |
ed0f68 |
#define BMC_NETFN_TRANSPORT 0xc
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
#define SEND_MAX_PAYLOAD_SIZE 34 /* MAX payload */
|
|
Packit Service |
ed0f68 |
#define RECV_MAX_PAYLOAD_SIZE 33 /* MAX payload */
|
|
Packit Service |
ed0f68 |
#define BMC_MIN_RESPONSE_SIZE 3
|
|
Packit Service |
ed0f68 |
#define BMC_MIN_REQUEST_SIZE 2
|
|
Packit Service |
ed0f68 |
#define BMC_MAX_RESPONSE_SIZE (BMC_MIN_RESPONSE_SIZE + RECV_MAX_PAYLOAD_SIZE)
|
|
Packit Service |
ed0f68 |
#define BMC_MAX_REQUEST_SIZE (BMC_MIN_REQUEST_SIZE + BMC_MAX_RESPONSE_SIZE)
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
#define BUF_SIZE 256
|
|
Packit Service |
ed0f68 |
#define MAX_BUF_SIZE 256
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
/*
|
|
Packit Service |
ed0f68 |
* Useful macros
|
|
Packit Service |
ed0f68 |
*/
|
|
Packit Service |
ed0f68 |
#define FORM_NETFNLUN(net, lun) ((((net) << 2) | ((lun) & 0x3)))
|
|
Packit Service |
ed0f68 |
#define GET_NETFN(netfn) (((netfn) >> 2) & 0x3f)
|
|
Packit Service |
ed0f68 |
#define GET_LUN(netfn) (netfn & 0x3)
|
|
Packit Service |
ed0f68 |
#define RESP_NETFN(nflun) ((nflun) | 1)
|
|
Packit Service |
ed0f68 |
#define ISREQUEST(nl) (((nl) & 1) == 0) /* test for request */
|
|
Packit Service |
ed0f68 |
#define ISRESPONSE(nl) (((nl) & 1) == 1) /* test for response */
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
/* for checking BMC specific stuff */
|
|
Packit Service |
ed0f68 |
#define BMC_GET_DEVICE_ID 0x1 /* GET DEVICE ID COMMAND */
|
|
Packit Service |
ed0f68 |
#define BMC_IPMI_15_VER 0x51 /* IPMI 1.5 definion */
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
/* BMC Completion Code and OEM Completion Code */
|
|
Packit Service |
ed0f68 |
#define BMC_IPMI_UNSPECIFIC_ERROR 0xFF /* Unspecific Error */
|
|
Packit Service |
ed0f68 |
#define BMC_IPMI_INVALID_COMMAND 0xC1 /* Invalid Command */
|
|
Packit Service |
ed0f68 |
#define BMC_IPMI_COMMAND_TIMEOUT 0xC3 /* Command Timeout */
|
|
Packit Service |
ed0f68 |
#define BMC_IPMI_DATA_LENGTH_EXCEED 0xC8 /* DataLength exceeded limit */
|
|
Packit Service |
ed0f68 |
#define BMC_IPMI_OEM_FAILURE_SENDBMC 0x7E /* Cannot send BMC req */
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
#define IOCTL_IPMI_KCS_ACTION 0x01
|
|
Packit Service |
ed0f68 |
#define IOCTL_IPMI_INTERFACE_METHOD 0x02
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
/* Interface methods returned from IOCTL_IPMI_INTERFACE_METHOD ioctl: */
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
#define BMC_IOCTL_METHOD 0 /* Not returned from ioctl, */
|
|
Packit Service |
ed0f68 |
/* but can be used by */
|
|
Packit Service |
ed0f68 |
/* applications that want to */
|
|
Packit Service |
ed0f68 |
/* compare against an */
|
|
Packit Service |
ed0f68 |
/* alternative method. */
|
|
Packit Service |
ed0f68 |
#define BMC_PUTMSG_METHOD 1
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
/*
|
|
Packit Service |
ed0f68 |
* bmc_req_t is the data structure to send
|
|
Packit Service |
ed0f68 |
* request packet from applications to the driver
|
|
Packit Service |
ed0f68 |
* module.
|
|
Packit Service |
ed0f68 |
*
|
|
Packit Service |
ed0f68 |
* the request pkt is mainly for KCS-interface-BMC
|
|
Packit Service |
ed0f68 |
* messages. Since the system interface is session-less
|
|
Packit Service |
ed0f68 |
* connections, the packet won't have any session
|
|
Packit Service |
ed0f68 |
* information.
|
|
Packit Service |
ed0f68 |
*
|
|
Packit Service |
ed0f68 |
* the data payload will be 2 bytes less than max
|
|
Packit Service |
ed0f68 |
* BMC supported packet size.
|
|
Packit Service |
ed0f68 |
* the address of the responder is always BMC and so
|
|
Packit Service |
ed0f68 |
* rsSa field is not required.
|
|
Packit Service |
ed0f68 |
*/
|
|
Packit Service |
ed0f68 |
typedef struct bmc_req {
|
|
Packit Service |
ed0f68 |
uint8_t fn; /* netFn for command */
|
|
Packit Service |
ed0f68 |
uint8_t lun; /* logical unit on responder */
|
|
Packit Service |
ed0f68 |
uint8_t cmd; /* command */
|
|
Packit Service |
ed0f68 |
uint8_t datalength; /* length of following data */
|
|
Packit Service |
ed0f68 |
uint8_t data[SEND_MAX_PAYLOAD_SIZE]; /* request data */
|
|
Packit Service |
ed0f68 |
} bmc_req_t;
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
/*
|
|
Packit Service |
ed0f68 |
* bmc_rsp_t is the data structure to send
|
|
Packit Service |
ed0f68 |
* respond packet from applications to the driver
|
|
Packit Service |
ed0f68 |
* module.
|
|
Packit Service |
ed0f68 |
*
|
|
Packit Service |
ed0f68 |
* the respond pkt is mainly for KCS-interface-BMC
|
|
Packit Service |
ed0f68 |
* messages. Since the system interface is session-less
|
|
Packit Service |
ed0f68 |
* connections, the packet won't have any session
|
|
Packit Service |
ed0f68 |
* information.
|
|
Packit Service |
ed0f68 |
*
|
|
Packit Service |
ed0f68 |
* the data payload will be 2 bytes less than max
|
|
Packit Service |
ed0f68 |
* BMC supported packet size.
|
|
Packit Service |
ed0f68 |
*/
|
|
Packit Service |
ed0f68 |
typedef struct bmc_rsp {
|
|
Packit Service |
ed0f68 |
uint8_t fn; /* netFn for command */
|
|
Packit Service |
ed0f68 |
uint8_t lun; /* logical unit on responder */
|
|
Packit Service |
ed0f68 |
uint8_t cmd; /* command */
|
|
Packit Service |
ed0f68 |
uint8_t ccode; /* completion code */
|
|
Packit Service |
ed0f68 |
uint8_t datalength; /* Length */
|
|
Packit Service |
ed0f68 |
uint8_t data[RECV_MAX_PAYLOAD_SIZE]; /* response */
|
|
Packit Service |
ed0f68 |
} bmc_rsp_t;
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
/*
|
|
Packit Service |
ed0f68 |
* the data structure for synchronous operation via ioctl (DEPRECATED)
|
|
Packit Service |
ed0f68 |
*/
|
|
Packit Service |
ed0f68 |
typedef struct bmc_reqrsp {
|
|
Packit Service |
ed0f68 |
bmc_req_t req; /* request half */
|
|
Packit Service |
ed0f68 |
bmc_rsp_t rsp; /* response half */
|
|
Packit Service |
ed0f68 |
} bmc_reqrsp_t;
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
/*
|
|
Packit Service |
ed0f68 |
* The new way of communicating with the bmc driver is to use putmsg() to
|
|
Packit Service |
ed0f68 |
* send a message of a particular type. Replies from the driver also have this
|
|
Packit Service |
ed0f68 |
* form, and will require the user to process the type field before examining
|
|
Packit Service |
ed0f68 |
* the rest of the reply.
|
|
Packit Service |
ed0f68 |
*
|
|
Packit Service |
ed0f68 |
* The only change that must be observed when using the request and response
|
|
Packit Service |
ed0f68 |
* structures defined above is as follows:
|
|
Packit Service |
ed0f68 |
* when sending messages to the bmc driver, the data portion is now variable
|
|
Packit Service |
ed0f68 |
* (the caller must allocate enough space to store the all structure members,
|
|
Packit Service |
ed0f68 |
* plus enough space to cover the amount of data in the request), e.g.:
|
|
Packit Service |
ed0f68 |
*
|
|
Packit Service |
ed0f68 |
* bmc_msg_t *msg = malloc(offsetof(bmc_msg_t, msg) + sizeof(bmc_req_t) + 10);
|
|
Packit Service |
ed0f68 |
*
|
|
Packit Service |
ed0f68 |
* The amount allocated for the message is (# of bytes before the msg field) +
|
|
Packit Service |
ed0f68 |
* the size of a bmc_req_t (which includes SEND_MAX_PAYLOAD_SIZE
|
|
Packit Service |
ed0f68 |
* bytes in the data field), plus an additional 10 bytes for the data
|
|
Packit Service |
ed0f68 |
* field (so the data field would occupy (SEND_MAX_PAYLOAD_SIZE + 10)
|
|
Packit Service |
ed0f68 |
* bytes). The datalength member must reflect the amount of data in the
|
|
Packit Service |
ed0f68 |
* request's data field (as was required when using the ioctl interface).
|
|
Packit Service |
ed0f68 |
*/
|
|
Packit Service |
ed0f68 |
typedef struct bmc_msg {
|
|
Packit Service |
ed0f68 |
uint8_t m_type; /* Message type (see below) */
|
|
Packit Service |
ed0f68 |
uint32_t m_id; /* Message ID */
|
|
Packit Service |
ed0f68 |
uint8_t reserved[32];
|
|
Packit Service |
ed0f68 |
uint8_t msg[1]; /* Variable length message data */
|
|
Packit Service |
ed0f68 |
} bmc_msg_t;
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
/*
|
|
Packit Service |
ed0f68 |
* An error response passed back from the bmc driver will have its m_id
|
|
Packit Service |
ed0f68 |
* field set to BMC_UNKNOWN_MSG_ID if a message is sent to it that is not
|
|
Packit Service |
ed0f68 |
* at least as large as a bmc_msg_t.
|
|
Packit Service |
ed0f68 |
*/
|
|
Packit Service |
ed0f68 |
#define BMC_UNKNOWN_MSG_ID ~((uint32_t)0)
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
/*
|
|
Packit Service |
ed0f68 |
* Possible values for the m_type field in bmc_msg_t:
|
|
Packit Service |
ed0f68 |
*/
|
|
Packit Service |
ed0f68 |
#define BMC_MSG_REQUEST 1 /* BMC request (as above, sent to the */
|
|
Packit Service |
ed0f68 |
/* driver by the user), bmc_msg.msg */
|
|
Packit Service |
ed0f68 |
/* begins with the bmc_req_t */
|
|
Packit Service |
ed0f68 |
/* structure. */
|
|
Packit Service |
ed0f68 |
#define BMC_MSG_RESPONSE 2 /* BMC response (sent by the driver) */
|
|
Packit Service |
ed0f68 |
/* bmc_msg.msg begins with the */
|
|
Packit Service |
ed0f68 |
/* bmc_rsp_t structure. */
|
|
Packit Service |
ed0f68 |
#define BMC_MSG_ERROR 3 /* Error while processing a user msg */
|
|
Packit Service |
ed0f68 |
/* msg[0] is the error code */
|
|
Packit Service |
ed0f68 |
/* (interpret as an errno value) */
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
#ifdef __cplusplus
|
|
Packit Service |
ed0f68 |
}
|
|
Packit Service |
ed0f68 |
#endif
|
|
Packit Service |
ed0f68 |
|
|
Packit Service |
ed0f68 |
#endif /* _BMC_INTF_H */
|