xref: /onnv-gate/usr/src/uts/common/sys/bmc_intf.h (revision 3798:36499f71540b)
12042Ssethg /*
22042Ssethg  * CDDL HEADER START
32042Ssethg  *
42042Ssethg  * The contents of this file are subject to the terms of the
52042Ssethg  * Common Development and Distribution License (the "License").
62042Ssethg  * You may not use this file except in compliance with the License.
72042Ssethg  *
82042Ssethg  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
92042Ssethg  * or http://www.opensolaris.org/os/licensing.
102042Ssethg  * See the License for the specific language governing permissions
112042Ssethg  * and limitations under the License.
122042Ssethg  *
132042Ssethg  * When distributing Covered Code, include this CDDL HEADER in each
142042Ssethg  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
152042Ssethg  * If applicable, add the following below this CDDL HEADER, with the
162042Ssethg  * fields enclosed by brackets "[]" replaced with your own identifying
172042Ssethg  * information: Portions Copyright [yyyy] [name of copyright owner]
182042Ssethg  *
192042Ssethg  * CDDL HEADER END
202042Ssethg  */
212042Ssethg 
222042Ssethg /*
23*3798Seschrock  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
242042Ssethg  * Use is subject to license terms.
252042Ssethg  */
262042Ssethg 
272042Ssethg #ifndef _BMC_INTF_H
282042Ssethg #define	_BMC_INTF_H
292042Ssethg 
302042Ssethg #pragma ident	"%Z%%M%	%I%	%E% SMI"
312042Ssethg 
32*3798Seschrock #include <sys/types.h>
33*3798Seschrock 
342042Ssethg #ifdef __cplusplus
352042Ssethg extern "C" {
362042Ssethg #endif
372042Ssethg 
382042Ssethg #define	BMC_SUCCESS		0x0
392042Ssethg #define	BMC_FAILURE		0x1
402042Ssethg 
412042Ssethg #define	BMC_NETFN_CHASSIS		0x0
422042Ssethg #define	BMC_NETFN_BRIDGE		0x2
432042Ssethg #define	BMC_NETFN_SE			0x4
442042Ssethg #define	BMC_NETFN_APP			0x6
452042Ssethg #define	BMC_NETFN_FIRMWARE		0x8
462042Ssethg #define	BMC_NETFN_STORAGE		0xa
472042Ssethg #define	BMC_NETFN_TRANSPORT		0xc
482042Ssethg 
492042Ssethg #define	SEND_MAX_PAYLOAD_SIZE		34	/* MAX payload */
502042Ssethg #define	RECV_MAX_PAYLOAD_SIZE		33	/* MAX payload */
512042Ssethg #define	BMC_MIN_RESPONSE_SIZE		3
522042Ssethg #define	BMC_MIN_REQUEST_SIZE		2
532042Ssethg #define	BMC_MAX_RESPONSE_SIZE   (BMC_MIN_RESPONSE_SIZE + RECV_MAX_PAYLOAD_SIZE)
542042Ssethg #define	BMC_MAX_REQUEST_SIZE	(BMC_MIN_REQUEST_SIZE + BMC_MAX_RESPONSE_SIZE)
552042Ssethg 
562042Ssethg #define	BUF_SIZE 256
572042Ssethg #define	MAX_BUF_SIZE			256
582042Ssethg 
592042Ssethg /*
602042Ssethg  * Useful macros
612042Ssethg  */
622042Ssethg #define	FORM_NETFNLUN(net, lun)	((((net) << 2) | ((lun) & 0x3)))
632042Ssethg #define	GET_NETFN(netfn)	(((netfn) >> 2) & 0x3f)
642042Ssethg #define	GET_LUN(netfn)		(netfn & 0x3)
652042Ssethg #define	RESP_NETFN(nflun)	((nflun) | 1)
662042Ssethg #define	ISREQUEST(nl)		(((nl) & 1) == 0)	/* test for request */
672042Ssethg #define	ISRESPONSE(nl)		(((nl) & 1) == 1)	/* test for response */
682042Ssethg 
692042Ssethg 
702042Ssethg /* for checking BMC specific stuff */
712042Ssethg #define	BMC_GET_DEVICE_ID		0x1	/* GET DEVICE ID COMMAND */
722042Ssethg #define	BMC_IPMI_15_VER		0x51	/* IPMI 1.5 definion */
732042Ssethg 
742042Ssethg /* BMC Completion Code and OEM Completion Code */
752042Ssethg #define	BMC_IPMI_UNSPECIFIC_ERROR	0xFF	/* Unspecific Error */
762042Ssethg #define	BMC_IPMI_INVALID_COMMAND	0xC1	/* Invalid Command */
772042Ssethg #define	BMC_IPMI_COMMAND_TIMEOUT	0xC3	/* Command Timeout */
782042Ssethg #define	BMC_IPMI_DATA_LENGTH_EXCEED	0xC8	/* DataLength exceeded limit */
792042Ssethg #define	BMC_IPMI_OEM_FAILURE_SENDBMC	0x7E	/* Cannot send BMC req */
802042Ssethg 
812042Ssethg 
822042Ssethg #define	IOCTL_IPMI_KCS_ACTION		0x01
832042Ssethg #define	IOCTL_IPMI_INTERFACE_METHOD	0x02
842042Ssethg 
852042Ssethg /* Interface methods returned from IOCTL_IPMI_INTERFACE_METHOD ioctl: */
862042Ssethg 
872042Ssethg #define	BMC_IOCTL_METHOD		0	/* Not returned from ioctl, */
882042Ssethg 						/* but can be used by	*/
892042Ssethg 						/* applications that want to */
902042Ssethg 						/* compare against an	*/
912042Ssethg 						/* alternative method.	*/
922042Ssethg #define	BMC_PUTMSG_METHOD		1
932042Ssethg 
942042Ssethg /*
952042Ssethg  * bmc_req_t is the data structure to send
962042Ssethg  * request packet from applications to the driver
972042Ssethg  * module.
982042Ssethg  *
992042Ssethg  * the request pkt is mainly for KCS-interface-BMC
1002042Ssethg  * messages. Since the system interface is session-less
1012042Ssethg  * connections, the packet won't have any session
1022042Ssethg  * information.
1032042Ssethg  *
1042042Ssethg  * the data payload will be 2 bytes less than max
1052042Ssethg  * BMC supported packet size.
1062042Ssethg  * the address of the responder is always BMC and so
1072042Ssethg  * rsSa field is not required.
1082042Ssethg  */
1092042Ssethg typedef struct bmc_req {
1102042Ssethg 	uint8_t fn;			/* netFn for command */
1112042Ssethg 	uint8_t lun;			/* logical unit on responder */
1122042Ssethg 	uint8_t cmd;			/* command */
1132042Ssethg 	uint8_t datalength;		/* length of following data */
1142042Ssethg 	uint8_t data[SEND_MAX_PAYLOAD_SIZE]; /* request data */
1152042Ssethg } bmc_req_t;
1162042Ssethg 
1172042Ssethg /*
1182042Ssethg  * bmc_rsp_t is the data structure to send
1192042Ssethg  * respond packet from applications to the driver
1202042Ssethg  * module.
1212042Ssethg  *
1222042Ssethg  * the respond pkt is mainly for KCS-interface-BMC
1232042Ssethg  * messages. Since the system interface is session-less
1242042Ssethg  * connections, the packet won't have any session
1252042Ssethg  * information.
1262042Ssethg  *
1272042Ssethg  * the data payload will be 2 bytes less than max
1282042Ssethg  * BMC supported packet size.
1292042Ssethg  */
1302042Ssethg typedef struct bmc_rsp {
1312042Ssethg 	uint8_t	fn;			/* netFn for command */
1322042Ssethg 	uint8_t	lun;			/* logical unit on responder */
1332042Ssethg 	uint8_t	cmd;			/* command */
1342042Ssethg 	uint8_t	ccode;			/* completion code */
1352042Ssethg 	uint8_t	datalength;		/* Length */
1362042Ssethg 	uint8_t	data[RECV_MAX_PAYLOAD_SIZE]; /* response */
1372042Ssethg } bmc_rsp_t;
1382042Ssethg 
1392042Ssethg /*
1402042Ssethg  * the data structure for synchronous operation via ioctl (DEPRECATED)
1412042Ssethg  */
1422042Ssethg typedef struct bmc_reqrsp {
1432042Ssethg 	bmc_req_t	req;			/* request half */
1442042Ssethg 	bmc_rsp_t	rsp;			/* response half */
1452042Ssethg } bmc_reqrsp_t;
1462042Ssethg 
1472042Ssethg 
1482042Ssethg /*
1492042Ssethg  * The new way of communicating with the bmc driver is to use putmsg() to
1502042Ssethg  * send a message of a particular type.  Replies from the driver also have this
1512042Ssethg  * form, and will require the user to process the type field before examining
1522042Ssethg  * the rest of the reply.
1532042Ssethg  *
1542042Ssethg  * The only change that must be observed when using the request and response
1552042Ssethg  * structures defined above is as follows:
1562042Ssethg  * when sending messages to the bmc driver, the data portion is now variable
1572042Ssethg  * (the caller must allocate enough space to store the all structure members,
1582042Ssethg  * plus enough space to cover the amount of data in the request), e.g.:
1592042Ssethg  *
1602042Ssethg  * bmc_msg_t *msg = malloc(offsetof(bmc_msg_t, msg) + sizeof(bmc_req_t) + 10);
1612042Ssethg  *
1622042Ssethg  * The amount allocated for the message is (# of bytes before the msg field) +
1632042Ssethg  * the size of a bmc_req_t (which includes SEND_MAX_PAYLOAD_SIZE
1642042Ssethg  * bytes in the data field), plus an additional 10 bytes for the data
1652042Ssethg  * field (so the data field would occupy (SEND_MAX_PAYLOAD_SIZE + 10)
1662042Ssethg  * bytes).  The datalength member must reflect the amount of data in the
1672042Ssethg  * request's data field (as was required when using the ioctl interface).
1682042Ssethg  */
1692042Ssethg typedef struct bmc_msg {
1702042Ssethg 	uint8_t		m_type;		/* Message type (see below) */
1712042Ssethg 	uint32_t	m_id;		/* Message ID */
1722042Ssethg 	uint8_t		reserved[32];
1732042Ssethg 	uint8_t		msg[1];		/* Variable length message data */
1742042Ssethg } bmc_msg_t;
1752042Ssethg 
1762042Ssethg 
1772042Ssethg /*
1782042Ssethg  * An error response passed back from the bmc driver will have its m_id
1792042Ssethg  * field set to BMC_UNKNOWN_MSG_ID if a message is sent to it that is not
1802042Ssethg  * at least as large as a bmc_msg_t.
1812042Ssethg  */
1822042Ssethg #define	BMC_UNKNOWN_MSG_ID	~((uint32_t)0)
1832042Ssethg 
1842042Ssethg 
1852042Ssethg /*
1862042Ssethg  * Possible values for the m_type field in bmc_msg_t:
1872042Ssethg  */
1882042Ssethg #define	BMC_MSG_REQUEST		1	/* BMC request (as above, sent to the */
1892042Ssethg 					/* driver by the user), bmc_msg.msg */
1902042Ssethg 					/* begins with the bmc_req_t	*/
1912042Ssethg 					/* structure.			*/
1922042Ssethg #define	BMC_MSG_RESPONSE	2	/* BMC response (sent by the driver) */
1932042Ssethg 					/* bmc_msg.msg begins with the	*/
1942042Ssethg 					/* bmc_rsp_t structure.		*/
1952042Ssethg #define	BMC_MSG_ERROR		3	/* Error while processing a user msg */
1962042Ssethg 					/* msg[0] is the error code	*/
1972042Ssethg 					/* (interpret as an errno value) */
1982042Ssethg 
1992042Ssethg #ifdef	__cplusplus
2002042Ssethg }
2012042Ssethg #endif
2022042Ssethg 
2032042Ssethg #endif /* _BMC_INTF_H */
204