xref: /titanic_41/usr/src/uts/common/sys/ipmi.h (revision 989f28072d20c73ae0955d6a1e3e2fc74831cb39)
1*989f2807SJerry Jelinek /*
2*989f2807SJerry Jelinek  * Copyright (c) 2006 IronPort Systems Inc. <ambrisko@ironport.com>
3*989f2807SJerry Jelinek  * All rights reserved.
4*989f2807SJerry Jelinek  *
5*989f2807SJerry Jelinek  * Redistribution and use in source and binary forms, with or without
6*989f2807SJerry Jelinek  * modification, are permitted provided that the following conditions
7*989f2807SJerry Jelinek  * are met:
8*989f2807SJerry Jelinek  * 1. Redistributions of source code must retain the above copyright
9*989f2807SJerry Jelinek  *    notice, this list of conditions and the following disclaimer.
10*989f2807SJerry Jelinek  * 2. Redistributions in binary form must reproduce the above copyright
11*989f2807SJerry Jelinek  *    notice, this list of conditions and the following disclaimer in the
12*989f2807SJerry Jelinek  *    documentation and/or other materials provided with the distribution.
13*989f2807SJerry Jelinek  *
14*989f2807SJerry Jelinek  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15*989f2807SJerry Jelinek  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*989f2807SJerry Jelinek  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*989f2807SJerry Jelinek  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18*989f2807SJerry Jelinek  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*989f2807SJerry Jelinek  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*989f2807SJerry Jelinek  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*989f2807SJerry Jelinek  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*989f2807SJerry Jelinek  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*989f2807SJerry Jelinek  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*989f2807SJerry Jelinek  * SUCH DAMAGE.
25*989f2807SJerry Jelinek  *
26*989f2807SJerry Jelinek  * $FreeBSD: src/sys/sys/ipmi.h,v 1.2 2006/09/22 22:11:29 jhb Exp $
27*989f2807SJerry Jelinek  */
28*989f2807SJerry Jelinek 
29*989f2807SJerry Jelinek /*
30*989f2807SJerry Jelinek  * Copyright 2012 Joyent, Inc. All rights reserved.
31*989f2807SJerry Jelinek  */
32*989f2807SJerry Jelinek 
33*989f2807SJerry Jelinek #ifndef _SYS_IPMI_H_
34*989f2807SJerry Jelinek #define	_SYS_IPMI_H_
35*989f2807SJerry Jelinek 
36*989f2807SJerry Jelinek #include <sys/types.h>
37*989f2807SJerry Jelinek #include <sys/ioccom.h>
38*989f2807SJerry Jelinek 
39*989f2807SJerry Jelinek #ifdef	__cplusplus
40*989f2807SJerry Jelinek extern "C" {
41*989f2807SJerry Jelinek #endif
42*989f2807SJerry Jelinek 
43*989f2807SJerry Jelinek #define	IPMI_MAX_ADDR_SIZE		0x20
44*989f2807SJerry Jelinek #define	IPMI_MAX_RX			1024
45*989f2807SJerry Jelinek #define	IPMI_BMC_SLAVE_ADDR		0x20 /* Default slave address */
46*989f2807SJerry Jelinek #define	IPMI_BMC_CHANNEL		0x0f /* BMC channel */
47*989f2807SJerry Jelinek 
48*989f2807SJerry Jelinek #define	IPMI_BMC_SMS_LUN		0x02
49*989f2807SJerry Jelinek 
50*989f2807SJerry Jelinek #define	IPMI_SYSTEM_INTERFACE_ADDR_TYPE	0x0c
51*989f2807SJerry Jelinek #define	IPMI_IPMB_ADDR_TYPE		0x01
52*989f2807SJerry Jelinek #define	IPMI_IPMB_BROADCAST_ADDR_TYPE	0x41
53*989f2807SJerry Jelinek 
54*989f2807SJerry Jelinek #define	IPMI_IOC_MAGIC			'i'
55*989f2807SJerry Jelinek #define	IPMICTL_RECEIVE_MSG_TRUNC	\
56*989f2807SJerry Jelinek 				_IOWR(IPMI_IOC_MAGIC, 11, struct ipmi_recv)
57*989f2807SJerry Jelinek #define	IPMICTL_RECEIVE_MSG		\
58*989f2807SJerry Jelinek 				_IOWR(IPMI_IOC_MAGIC, 12, struct ipmi_recv)
59*989f2807SJerry Jelinek #define	IPMICTL_SEND_COMMAND		\
60*989f2807SJerry Jelinek 				_IOW(IPMI_IOC_MAGIC, 13, struct ipmi_req)
61*989f2807SJerry Jelinek #define	IPMICTL_REGISTER_FOR_CMD	\
62*989f2807SJerry Jelinek 				_IOW(IPMI_IOC_MAGIC, 14, struct ipmi_cmdspec)
63*989f2807SJerry Jelinek #define	IPMICTL_UNREGISTER_FOR_CMD	\
64*989f2807SJerry Jelinek 				_IOW(IPMI_IOC_MAGIC, 15, struct ipmi_cmdspec)
65*989f2807SJerry Jelinek #define	IPMICTL_SET_GETS_EVENTS_CMD	_IOW(IPMI_IOC_MAGIC, 16, int)
66*989f2807SJerry Jelinek #define	IPMICTL_SET_MY_ADDRESS_CMD	_IOW(IPMI_IOC_MAGIC, 17, unsigned int)
67*989f2807SJerry Jelinek #define	IPMICTL_GET_MY_ADDRESS_CMD	_IOR(IPMI_IOC_MAGIC, 18, unsigned int)
68*989f2807SJerry Jelinek #define	IPMICTL_SET_MY_LUN_CMD		_IOW(IPMI_IOC_MAGIC, 19, unsigned int)
69*989f2807SJerry Jelinek #define	IPMICTL_GET_MY_LUN_CMD		_IOR(IPMI_IOC_MAGIC, 20, unsigned int)
70*989f2807SJerry Jelinek 
71*989f2807SJerry Jelinek #define	IPMI_RESPONSE_RECV_TYPE		1
72*989f2807SJerry Jelinek #define	IPMI_ASYNC_EVENT_RECV_TYPE	2
73*989f2807SJerry Jelinek #define	IPMI_CMD_RECV_TYPE		3
74*989f2807SJerry Jelinek 
75*989f2807SJerry Jelinek #define	IPMI_APP_REQUEST		0x06
76*989f2807SJerry Jelinek #define	IPMI_GET_DEVICE_ID		0x01
77*989f2807SJerry Jelinek #define	IPMI_CLEAR_FLAGS		0x30
78*989f2807SJerry Jelinek #define	IPMI_GET_MSG_FLAGS		0x31
79*989f2807SJerry Jelinek #define	IPMI_MSG_AVAILABLE		0x01
80*989f2807SJerry Jelinek #define	IPMI_MSG_BUFFER_FULL		0x02
81*989f2807SJerry Jelinek #define	IPMI_WDT_PRE_TIMEOUT		0x08
82*989f2807SJerry Jelinek #define	IPMI_GET_MSG			0x33
83*989f2807SJerry Jelinek #define	IPMI_SEND_MSG			0x34
84*989f2807SJerry Jelinek #define	IPMI_GET_CHANNEL_INFO		0x42
85*989f2807SJerry Jelinek #define	IPMI_RESET_WDOG			0x22
86*989f2807SJerry Jelinek #define	IPMI_SET_WDOG			0x24
87*989f2807SJerry Jelinek #define	IPMI_GET_WDOG			0x25
88*989f2807SJerry Jelinek 
89*989f2807SJerry Jelinek #define	IPMI_SET_WD_TIMER_SMS_OS	0x04
90*989f2807SJerry Jelinek #define	IPMI_SET_WD_TIMER_DONT_STOP	0x40
91*989f2807SJerry Jelinek #define	IPMI_SET_WD_ACTION_RESET	0x01
92*989f2807SJerry Jelinek 
93*989f2807SJerry Jelinek struct ipmi_msg {
94*989f2807SJerry Jelinek 	unsigned char	netfn;
95*989f2807SJerry Jelinek 	unsigned char	cmd;
96*989f2807SJerry Jelinek 	unsigned short	data_len;
97*989f2807SJerry Jelinek 	unsigned char	*data;
98*989f2807SJerry Jelinek };
99*989f2807SJerry Jelinek 
100*989f2807SJerry Jelinek struct ipmi_req {
101*989f2807SJerry Jelinek 	unsigned char	*addr;
102*989f2807SJerry Jelinek 	unsigned int	addr_len;
103*989f2807SJerry Jelinek 	long		msgid;
104*989f2807SJerry Jelinek 	struct ipmi_msg	msg;
105*989f2807SJerry Jelinek };
106*989f2807SJerry Jelinek 
107*989f2807SJerry Jelinek struct ipmi_recv {
108*989f2807SJerry Jelinek 	int		recv_type;
109*989f2807SJerry Jelinek 	unsigned char	*addr;
110*989f2807SJerry Jelinek 	unsigned int	addr_len;
111*989f2807SJerry Jelinek 	long		msgid;
112*989f2807SJerry Jelinek 	struct ipmi_msg	msg;
113*989f2807SJerry Jelinek };
114*989f2807SJerry Jelinek 
115*989f2807SJerry Jelinek struct ipmi_cmdspec {
116*989f2807SJerry Jelinek 	unsigned char	netfn;
117*989f2807SJerry Jelinek 	unsigned char	cmd;
118*989f2807SJerry Jelinek };
119*989f2807SJerry Jelinek 
120*989f2807SJerry Jelinek struct ipmi_addr {
121*989f2807SJerry Jelinek 	int		addr_type;
122*989f2807SJerry Jelinek 	short		channel;
123*989f2807SJerry Jelinek 	unsigned char	data[IPMI_MAX_ADDR_SIZE];
124*989f2807SJerry Jelinek };
125*989f2807SJerry Jelinek 
126*989f2807SJerry Jelinek struct ipmi_system_interface_addr {
127*989f2807SJerry Jelinek 	int		addr_type;
128*989f2807SJerry Jelinek 	short		channel;
129*989f2807SJerry Jelinek 	unsigned char	lun;
130*989f2807SJerry Jelinek };
131*989f2807SJerry Jelinek 
132*989f2807SJerry Jelinek struct ipmi_ipmb_addr {
133*989f2807SJerry Jelinek 	int		addr_type;
134*989f2807SJerry Jelinek 	short		channel;
135*989f2807SJerry Jelinek 	unsigned char	slave_addr;
136*989f2807SJerry Jelinek 	unsigned char	lun;
137*989f2807SJerry Jelinek };
138*989f2807SJerry Jelinek 
139*989f2807SJerry Jelinek #ifdef _KERNEL
140*989f2807SJerry Jelinek 
141*989f2807SJerry Jelinek #define	IPMICTL_RECEIVE_MSG_TRUNC_32	\
142*989f2807SJerry Jelinek 		_IOWR(IPMI_IOC_MAGIC, 11, struct ipmi_recv32)
143*989f2807SJerry Jelinek #define	IPMICTL_RECEIVE_MSG_32		\
144*989f2807SJerry Jelinek 		_IOWR(IPMI_IOC_MAGIC, 12, struct ipmi_recv32)
145*989f2807SJerry Jelinek #define	IPMICTL_SEND_COMMAND_32		\
146*989f2807SJerry Jelinek 		_IOW(IPMI_IOC_MAGIC, 13, struct ipmi_req32)
147*989f2807SJerry Jelinek 
148*989f2807SJerry Jelinek struct ipmi_msg32 {
149*989f2807SJerry Jelinek 	unsigned char	netfn;
150*989f2807SJerry Jelinek 	unsigned char	cmd;
151*989f2807SJerry Jelinek 	unsigned short	data_len;
152*989f2807SJerry Jelinek 	uint32_t	data;
153*989f2807SJerry Jelinek };
154*989f2807SJerry Jelinek 
155*989f2807SJerry Jelinek struct ipmi_req32 {
156*989f2807SJerry Jelinek 	uint32_t	addr;
157*989f2807SJerry Jelinek 	unsigned int	addr_len;
158*989f2807SJerry Jelinek 	int32_t		msgid;
159*989f2807SJerry Jelinek 	struct ipmi_msg32 msg;
160*989f2807SJerry Jelinek };
161*989f2807SJerry Jelinek 
162*989f2807SJerry Jelinek struct ipmi_recv32 {
163*989f2807SJerry Jelinek 	int		recv_type;
164*989f2807SJerry Jelinek 	uint32_t	addr;
165*989f2807SJerry Jelinek 	unsigned int	addr_len;
166*989f2807SJerry Jelinek 	int32_t		msgid;
167*989f2807SJerry Jelinek 	struct ipmi_msg32 msg;
168*989f2807SJerry Jelinek };
169*989f2807SJerry Jelinek 
170*989f2807SJerry Jelinek #endif /* _KERNEL */
171*989f2807SJerry Jelinek 
172*989f2807SJerry Jelinek #ifdef	__cplusplus
173*989f2807SJerry Jelinek }
174*989f2807SJerry Jelinek #endif
175*989f2807SJerry Jelinek 
176*989f2807SJerry Jelinek #endif	/* _SYS_IPMI_H_ */
177