xref: /openbmc/linux/include/uapi/linux/ipmi.h (revision e2be04c7)
1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2607ca46eSDavid Howells /*
3607ca46eSDavid Howells  * ipmi.h
4607ca46eSDavid Howells  *
5607ca46eSDavid Howells  * MontaVista IPMI interface
6607ca46eSDavid Howells  *
7607ca46eSDavid Howells  * Author: MontaVista Software, Inc.
8607ca46eSDavid Howells  *         Corey Minyard <minyard@mvista.com>
9607ca46eSDavid Howells  *         source@mvista.com
10607ca46eSDavid Howells  *
11607ca46eSDavid Howells  * Copyright 2002 MontaVista Software Inc.
12607ca46eSDavid Howells  *
13607ca46eSDavid Howells  *  This program is free software; you can redistribute it and/or modify it
14607ca46eSDavid Howells  *  under the terms of the GNU General Public License as published by the
15607ca46eSDavid Howells  *  Free Software Foundation; either version 2 of the License, or (at your
16607ca46eSDavid Howells  *  option) any later version.
17607ca46eSDavid Howells  *
18607ca46eSDavid Howells  *
19607ca46eSDavid Howells  *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
20607ca46eSDavid Howells  *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21607ca46eSDavid Howells  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22607ca46eSDavid Howells  *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23607ca46eSDavid Howells  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24607ca46eSDavid Howells  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
25607ca46eSDavid Howells  *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26607ca46eSDavid Howells  *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27607ca46eSDavid Howells  *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
28607ca46eSDavid Howells  *  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29607ca46eSDavid Howells  *
30607ca46eSDavid Howells  *  You should have received a copy of the GNU General Public License along
31607ca46eSDavid Howells  *  with this program; if not, write to the Free Software Foundation, Inc.,
32607ca46eSDavid Howells  *  675 Mass Ave, Cambridge, MA 02139, USA.
33607ca46eSDavid Howells  */
34607ca46eSDavid Howells 
35607ca46eSDavid Howells #ifndef _UAPI__LINUX_IPMI_H
36607ca46eSDavid Howells #define _UAPI__LINUX_IPMI_H
37607ca46eSDavid Howells 
38607ca46eSDavid Howells #include <linux/ipmi_msgdefs.h>
39607ca46eSDavid Howells #include <linux/compiler.h>
40607ca46eSDavid Howells 
41607ca46eSDavid Howells /*
42607ca46eSDavid Howells  * This file describes an interface to an IPMI driver.  You have to
43607ca46eSDavid Howells  * have a fairly good understanding of IPMI to use this, so go read
44607ca46eSDavid Howells  * the specs first before actually trying to do anything.
45607ca46eSDavid Howells  *
46607ca46eSDavid Howells  * With that said, this driver provides a multi-user interface to the
47607ca46eSDavid Howells  * IPMI driver, and it allows multiple IPMI physical interfaces below
48607ca46eSDavid Howells  * the driver.  The physical interfaces bind as a lower layer on the
49607ca46eSDavid Howells  * driver.  They appear as interfaces to the application using this
50607ca46eSDavid Howells  * interface.
51607ca46eSDavid Howells  *
52607ca46eSDavid Howells  * Multi-user means that multiple applications may use the driver,
53607ca46eSDavid Howells  * send commands, receive responses, etc.  The driver keeps track of
54607ca46eSDavid Howells  * commands the user sends and tracks the responses.  The responses
55607ca46eSDavid Howells  * will go back to the application that send the command.  If the
56607ca46eSDavid Howells  * response doesn't come back in time, the driver will return a
57607ca46eSDavid Howells  * timeout error response to the application.  Asynchronous events
58607ca46eSDavid Howells  * from the BMC event queue will go to all users bound to the driver.
59607ca46eSDavid Howells  * The incoming event queue in the BMC will automatically be flushed
60607ca46eSDavid Howells  * if it becomes full and it is queried once a second to see if
61607ca46eSDavid Howells  * anything is in it.  Incoming commands to the driver will get
62607ca46eSDavid Howells  * delivered as commands.
6359fb1b9fSRobert P. J. Day  */
64607ca46eSDavid Howells 
65607ca46eSDavid Howells /*
66607ca46eSDavid Howells  * This is an overlay for all the address types, so it's easy to
67607ca46eSDavid Howells  * determine the actual address type.  This is kind of like addresses
68607ca46eSDavid Howells  * work for sockets.
69607ca46eSDavid Howells  */
70607ca46eSDavid Howells #define IPMI_MAX_ADDR_SIZE 32
71607ca46eSDavid Howells struct ipmi_addr {
72607ca46eSDavid Howells 	 /* Try to take these from the "Channel Medium Type" table
73607ca46eSDavid Howells 	    in section 6.5 of the IPMI 1.5 manual. */
74607ca46eSDavid Howells 	int   addr_type;
75607ca46eSDavid Howells 	short channel;
76607ca46eSDavid Howells 	char  data[IPMI_MAX_ADDR_SIZE];
77607ca46eSDavid Howells };
78607ca46eSDavid Howells 
79607ca46eSDavid Howells /*
80607ca46eSDavid Howells  * When the address is not used, the type will be set to this value.
81607ca46eSDavid Howells  * The channel is the BMC's channel number for the channel (usually
82607ca46eSDavid Howells  * 0), or IPMC_BMC_CHANNEL if communicating directly with the BMC.
83607ca46eSDavid Howells  */
84607ca46eSDavid Howells #define IPMI_SYSTEM_INTERFACE_ADDR_TYPE	0x0c
85607ca46eSDavid Howells struct ipmi_system_interface_addr {
86607ca46eSDavid Howells 	int           addr_type;
87607ca46eSDavid Howells 	short         channel;
88607ca46eSDavid Howells 	unsigned char lun;
89607ca46eSDavid Howells };
90607ca46eSDavid Howells 
91607ca46eSDavid Howells /* An IPMB Address. */
92607ca46eSDavid Howells #define IPMI_IPMB_ADDR_TYPE		0x01
93607ca46eSDavid Howells /* Used for broadcast get device id as described in section 17.9 of the
94607ca46eSDavid Howells    IPMI 1.5 manual. */
95607ca46eSDavid Howells #define IPMI_IPMB_BROADCAST_ADDR_TYPE	0x41
96607ca46eSDavid Howells struct ipmi_ipmb_addr {
97607ca46eSDavid Howells 	int           addr_type;
98607ca46eSDavid Howells 	short         channel;
99607ca46eSDavid Howells 	unsigned char slave_addr;
100607ca46eSDavid Howells 	unsigned char lun;
101607ca46eSDavid Howells };
102607ca46eSDavid Howells 
103607ca46eSDavid Howells /*
104607ca46eSDavid Howells  * A LAN Address.  This is an address to/from a LAN interface bridged
105607ca46eSDavid Howells  * by the BMC, not an address actually out on the LAN.
106607ca46eSDavid Howells  *
107607ca46eSDavid Howells  * A conscious decision was made here to deviate slightly from the IPMI
108607ca46eSDavid Howells  * spec.  We do not use rqSWID and rsSWID like it shows in the
109607ca46eSDavid Howells  * message.  Instead, we use remote_SWID and local_SWID.  This means
110607ca46eSDavid Howells  * that any message (a request or response) from another device will
111607ca46eSDavid Howells  * always have exactly the same address.  If you didn't do this,
112607ca46eSDavid Howells  * requests and responses from the same device would have different
113607ca46eSDavid Howells  * addresses, and that's not too cool.
114607ca46eSDavid Howells  *
115607ca46eSDavid Howells  * In this address, the remote_SWID is always the SWID the remote
116607ca46eSDavid Howells  * message came from, or the SWID we are sending the message to.
117607ca46eSDavid Howells  * local_SWID is always our SWID.  Note that having our SWID in the
118607ca46eSDavid Howells  * message is a little weird, but this is required.
119607ca46eSDavid Howells  */
120607ca46eSDavid Howells #define IPMI_LAN_ADDR_TYPE		0x04
121607ca46eSDavid Howells struct ipmi_lan_addr {
122607ca46eSDavid Howells 	int           addr_type;
123607ca46eSDavid Howells 	short         channel;
124607ca46eSDavid Howells 	unsigned char privilege;
125607ca46eSDavid Howells 	unsigned char session_handle;
126607ca46eSDavid Howells 	unsigned char remote_SWID;
127607ca46eSDavid Howells 	unsigned char local_SWID;
128607ca46eSDavid Howells 	unsigned char lun;
129607ca46eSDavid Howells };
130607ca46eSDavid Howells 
131607ca46eSDavid Howells 
132607ca46eSDavid Howells /*
133607ca46eSDavid Howells  * Channel for talking directly with the BMC.  When using this
134607ca46eSDavid Howells  * channel, This is for the system interface address type only.  FIXME
135607ca46eSDavid Howells  * - is this right, or should we use -1?
136607ca46eSDavid Howells  */
137607ca46eSDavid Howells #define IPMI_BMC_CHANNEL  0xf
138607ca46eSDavid Howells #define IPMI_NUM_CHANNELS 0x10
139607ca46eSDavid Howells 
140607ca46eSDavid Howells /*
141607ca46eSDavid Howells  * Used to signify an "all channel" bitmask.  This is more than the
142607ca46eSDavid Howells  * actual number of channels because this is used in userland and
143607ca46eSDavid Howells  * will cover us if the number of channels is extended.
144607ca46eSDavid Howells  */
145607ca46eSDavid Howells #define IPMI_CHAN_ALL     (~0)
146607ca46eSDavid Howells 
147607ca46eSDavid Howells 
148607ca46eSDavid Howells /*
149607ca46eSDavid Howells  * A raw IPMI message without any addressing.  This covers both
150607ca46eSDavid Howells  * commands and responses.  The completion code is always the first
151607ca46eSDavid Howells  * byte of data in the response (as the spec shows the messages laid
152607ca46eSDavid Howells  * out).
153607ca46eSDavid Howells  */
154607ca46eSDavid Howells struct ipmi_msg {
155607ca46eSDavid Howells 	unsigned char  netfn;
156607ca46eSDavid Howells 	unsigned char  cmd;
157607ca46eSDavid Howells 	unsigned short data_len;
158607ca46eSDavid Howells 	unsigned char  __user *data;
159607ca46eSDavid Howells };
160607ca46eSDavid Howells 
161607ca46eSDavid Howells struct kernel_ipmi_msg {
162607ca46eSDavid Howells 	unsigned char  netfn;
163607ca46eSDavid Howells 	unsigned char  cmd;
164607ca46eSDavid Howells 	unsigned short data_len;
165607ca46eSDavid Howells 	unsigned char  *data;
166607ca46eSDavid Howells };
167607ca46eSDavid Howells 
168607ca46eSDavid Howells /*
169607ca46eSDavid Howells  * Various defines that are useful for IPMI applications.
170607ca46eSDavid Howells  */
171607ca46eSDavid Howells #define IPMI_INVALID_CMD_COMPLETION_CODE	0xC1
172607ca46eSDavid Howells #define IPMI_TIMEOUT_COMPLETION_CODE		0xC3
173607ca46eSDavid Howells #define IPMI_UNKNOWN_ERR_COMPLETION_CODE	0xff
174607ca46eSDavid Howells 
175607ca46eSDavid Howells 
176607ca46eSDavid Howells /*
177607ca46eSDavid Howells  * Receive types for messages coming from the receive interface.  This
178607ca46eSDavid Howells  * is used for the receive in-kernel interface and in the receive
179607ca46eSDavid Howells  * IOCTL.
180607ca46eSDavid Howells  *
181607ca46eSDavid Howells  * The "IPMI_RESPONSE_RESPNOSE_TYPE" is a little strange sounding, but
182607ca46eSDavid Howells  * it allows you to get the message results when you send a response
183607ca46eSDavid Howells  * message.
184607ca46eSDavid Howells  */
185607ca46eSDavid Howells #define IPMI_RESPONSE_RECV_TYPE		1 /* A response to a command */
186607ca46eSDavid Howells #define IPMI_ASYNC_EVENT_RECV_TYPE	2 /* Something from the event queue */
187607ca46eSDavid Howells #define IPMI_CMD_RECV_TYPE		3 /* A command from somewhere else */
188607ca46eSDavid Howells #define IPMI_RESPONSE_RESPONSE_TYPE	4 /* The response for
189607ca46eSDavid Howells 					      a sent response, giving any
190607ca46eSDavid Howells 					      error status for sending the
191607ca46eSDavid Howells 					      response.  When you send a
192607ca46eSDavid Howells 					      response message, this will
193607ca46eSDavid Howells 					      be returned. */
194607ca46eSDavid Howells #define IPMI_OEM_RECV_TYPE		5 /* The response for OEM Channels */
195607ca46eSDavid Howells 
196607ca46eSDavid Howells /* Note that async events and received commands do not have a completion
197607ca46eSDavid Howells    code as the first byte of the incoming data, unlike a response. */
198607ca46eSDavid Howells 
199607ca46eSDavid Howells 
200607ca46eSDavid Howells /*
201607ca46eSDavid Howells  * Modes for ipmi_set_maint_mode() and the userland IOCTL.  The AUTO
202607ca46eSDavid Howells  * setting is the default and means it will be set on certain
203607ca46eSDavid Howells  * commands.  Hard setting it on and off will override automatic
204607ca46eSDavid Howells  * operation.
205607ca46eSDavid Howells  */
206607ca46eSDavid Howells #define IPMI_MAINTENANCE_MODE_AUTO	0
207607ca46eSDavid Howells #define IPMI_MAINTENANCE_MODE_OFF	1
208607ca46eSDavid Howells #define IPMI_MAINTENANCE_MODE_ON	2
209607ca46eSDavid Howells 
210607ca46eSDavid Howells 
211607ca46eSDavid Howells 
212607ca46eSDavid Howells /*
213607ca46eSDavid Howells  * The userland interface
214607ca46eSDavid Howells  */
215607ca46eSDavid Howells 
216607ca46eSDavid Howells /*
217607ca46eSDavid Howells  * The userland interface for the IPMI driver is a standard character
218607ca46eSDavid Howells  * device, with each instance of an interface registered as a minor
219607ca46eSDavid Howells  * number under the major character device.
220607ca46eSDavid Howells  *
221607ca46eSDavid Howells  * The read and write calls do not work, to get messages in and out
222607ca46eSDavid Howells  * requires ioctl calls because of the complexity of the data.  select
223607ca46eSDavid Howells  * and poll do work, so you can wait for input using the file
224607ca46eSDavid Howells  * descriptor, you just can use read to get it.
225607ca46eSDavid Howells  *
226607ca46eSDavid Howells  * In general, you send a command down to the interface and receive
227607ca46eSDavid Howells  * responses back.  You can use the msgid value to correlate commands
228607ca46eSDavid Howells  * and responses, the driver will take care of figuring out which
229607ca46eSDavid Howells  * incoming messages are for which command and find the proper msgid
230607ca46eSDavid Howells  * value to report.  You will only receive reponses for commands you
231607ca46eSDavid Howells  * send.  Asynchronous events, however, go to all open users, so you
232607ca46eSDavid Howells  * must be ready to handle these (or ignore them if you don't care).
233607ca46eSDavid Howells  *
234607ca46eSDavid Howells  * The address type depends upon the channel type.  When talking
235607ca46eSDavid Howells  * directly to the BMC (IPMC_BMC_CHANNEL), the address is ignored
236607ca46eSDavid Howells  * (IPMI_UNUSED_ADDR_TYPE).  When talking to an IPMB channel, you must
237607ca46eSDavid Howells  * supply a valid IPMB address with the addr_type set properly.
238607ca46eSDavid Howells  *
239607ca46eSDavid Howells  * When talking to normal channels, the driver takes care of the
240607ca46eSDavid Howells  * details of formatting and sending messages on that channel.  You do
241607ca46eSDavid Howells  * not, for instance, have to format a send command, you just send
242607ca46eSDavid Howells  * whatever command you want to the channel, the driver will create
243607ca46eSDavid Howells  * the send command, automatically issue receive command and get even
244607ca46eSDavid Howells  * commands, and pass those up to the proper user.
245607ca46eSDavid Howells  */
246607ca46eSDavid Howells 
247607ca46eSDavid Howells 
248607ca46eSDavid Howells /* The magic IOCTL value for this interface. */
249607ca46eSDavid Howells #define IPMI_IOC_MAGIC 'i'
250607ca46eSDavid Howells 
251607ca46eSDavid Howells 
252607ca46eSDavid Howells /* Messages sent to the interface are this format. */
253607ca46eSDavid Howells struct ipmi_req {
254607ca46eSDavid Howells 	unsigned char __user *addr; /* Address to send the message to. */
255607ca46eSDavid Howells 	unsigned int  addr_len;
256607ca46eSDavid Howells 
257607ca46eSDavid Howells 	long    msgid; /* The sequence number for the message.  This
258607ca46eSDavid Howells 			  exact value will be reported back in the
259607ca46eSDavid Howells 			  response to this request if it is a command.
260607ca46eSDavid Howells 			  If it is a response, this will be used as
261607ca46eSDavid Howells 			  the sequence value for the response.  */
262607ca46eSDavid Howells 
263607ca46eSDavid Howells 	struct ipmi_msg msg;
264607ca46eSDavid Howells };
265607ca46eSDavid Howells /*
266607ca46eSDavid Howells  * Send a message to the interfaces.  error values are:
267607ca46eSDavid Howells  *   - EFAULT - an address supplied was invalid.
268607ca46eSDavid Howells  *   - EINVAL - The address supplied was not valid, or the command
269607ca46eSDavid Howells  *              was not allowed.
270607ca46eSDavid Howells  *   - EMSGSIZE - The message to was too large.
271607ca46eSDavid Howells  *   - ENOMEM - Buffers could not be allocated for the command.
272607ca46eSDavid Howells  */
273607ca46eSDavid Howells #define IPMICTL_SEND_COMMAND		_IOR(IPMI_IOC_MAGIC, 13,	\
274607ca46eSDavid Howells 					     struct ipmi_req)
275607ca46eSDavid Howells 
276607ca46eSDavid Howells /* Messages sent to the interface with timing parameters are this
277607ca46eSDavid Howells    format. */
278607ca46eSDavid Howells struct ipmi_req_settime {
279607ca46eSDavid Howells 	struct ipmi_req req;
280607ca46eSDavid Howells 
281607ca46eSDavid Howells 	/* See ipmi_request_settime() above for details on these
282607ca46eSDavid Howells 	   values. */
283607ca46eSDavid Howells 	int          retries;
284607ca46eSDavid Howells 	unsigned int retry_time_ms;
285607ca46eSDavid Howells };
286607ca46eSDavid Howells /*
287607ca46eSDavid Howells  * Send a message to the interfaces with timing parameters.  error values
288607ca46eSDavid Howells  * are:
289607ca46eSDavid Howells  *   - EFAULT - an address supplied was invalid.
290607ca46eSDavid Howells  *   - EINVAL - The address supplied was not valid, or the command
291607ca46eSDavid Howells  *              was not allowed.
292607ca46eSDavid Howells  *   - EMSGSIZE - The message to was too large.
293607ca46eSDavid Howells  *   - ENOMEM - Buffers could not be allocated for the command.
294607ca46eSDavid Howells  */
295607ca46eSDavid Howells #define IPMICTL_SEND_COMMAND_SETTIME	_IOR(IPMI_IOC_MAGIC, 21,	\
296607ca46eSDavid Howells 					     struct ipmi_req_settime)
297607ca46eSDavid Howells 
298607ca46eSDavid Howells /* Messages received from the interface are this format. */
299607ca46eSDavid Howells struct ipmi_recv {
300607ca46eSDavid Howells 	int     recv_type; /* Is this a command, response or an
301607ca46eSDavid Howells 			      asyncronous event. */
302607ca46eSDavid Howells 
303607ca46eSDavid Howells 	unsigned char __user *addr;    /* Address the message was from is put
304607ca46eSDavid Howells 				   here.  The caller must supply the
305607ca46eSDavid Howells 				   memory. */
306607ca46eSDavid Howells 	unsigned int  addr_len; /* The size of the address buffer.
307607ca46eSDavid Howells 				   The caller supplies the full buffer
308607ca46eSDavid Howells 				   length, this value is updated to
309607ca46eSDavid Howells 				   the actual message length when the
310607ca46eSDavid Howells 				   message is received. */
311607ca46eSDavid Howells 
312607ca46eSDavid Howells 	long    msgid; /* The sequence number specified in the request
313607ca46eSDavid Howells 			  if this is a response.  If this is a command,
314607ca46eSDavid Howells 			  this will be the sequence number from the
315607ca46eSDavid Howells 			  command. */
316607ca46eSDavid Howells 
317607ca46eSDavid Howells 	struct ipmi_msg msg; /* The data field must point to a buffer.
318607ca46eSDavid Howells 				The data_size field must be set to the
319607ca46eSDavid Howells 				size of the message buffer.  The
320607ca46eSDavid Howells 				caller supplies the full buffer
321607ca46eSDavid Howells 				length, this value is updated to the
322607ca46eSDavid Howells 				actual message length when the message
323607ca46eSDavid Howells 				is received. */
324607ca46eSDavid Howells };
325607ca46eSDavid Howells 
326607ca46eSDavid Howells /*
327607ca46eSDavid Howells  * Receive a message.  error values:
328607ca46eSDavid Howells  *  - EAGAIN - no messages in the queue.
329607ca46eSDavid Howells  *  - EFAULT - an address supplied was invalid.
330607ca46eSDavid Howells  *  - EINVAL - The address supplied was not valid.
331607ca46eSDavid Howells  *  - EMSGSIZE - The message to was too large to fit into the message buffer,
332607ca46eSDavid Howells  *               the message will be left in the buffer. */
333607ca46eSDavid Howells #define IPMICTL_RECEIVE_MSG		_IOWR(IPMI_IOC_MAGIC, 12,	\
334607ca46eSDavid Howells 					      struct ipmi_recv)
335607ca46eSDavid Howells 
336607ca46eSDavid Howells /*
337607ca46eSDavid Howells  * Like RECEIVE_MSG, but if the message won't fit in the buffer, it
338607ca46eSDavid Howells  * will truncate the contents instead of leaving the data in the
339607ca46eSDavid Howells  * buffer.
340607ca46eSDavid Howells  */
341607ca46eSDavid Howells #define IPMICTL_RECEIVE_MSG_TRUNC	_IOWR(IPMI_IOC_MAGIC, 11,	\
342607ca46eSDavid Howells 					      struct ipmi_recv)
343607ca46eSDavid Howells 
344607ca46eSDavid Howells /* Register to get commands from other entities on this interface. */
345607ca46eSDavid Howells struct ipmi_cmdspec {
346607ca46eSDavid Howells 	unsigned char netfn;
347607ca46eSDavid Howells 	unsigned char cmd;
348607ca46eSDavid Howells };
349607ca46eSDavid Howells 
350607ca46eSDavid Howells /*
351607ca46eSDavid Howells  * Register to receive a specific command.  error values:
352607ca46eSDavid Howells  *   - EFAULT - an address supplied was invalid.
353607ca46eSDavid Howells  *   - EBUSY - The netfn/cmd supplied was already in use.
354607ca46eSDavid Howells  *   - ENOMEM - could not allocate memory for the entry.
355607ca46eSDavid Howells  */
356607ca46eSDavid Howells #define IPMICTL_REGISTER_FOR_CMD	_IOR(IPMI_IOC_MAGIC, 14,	\
357607ca46eSDavid Howells 					     struct ipmi_cmdspec)
358607ca46eSDavid Howells /*
359ad61dd30SStephen Boyd  * Unregister a registered command.  error values:
360607ca46eSDavid Howells  *  - EFAULT - an address supplied was invalid.
361607ca46eSDavid Howells  *  - ENOENT - The netfn/cmd was not found registered for this user.
362607ca46eSDavid Howells  */
363607ca46eSDavid Howells #define IPMICTL_UNREGISTER_FOR_CMD	_IOR(IPMI_IOC_MAGIC, 15,	\
364607ca46eSDavid Howells 					     struct ipmi_cmdspec)
365607ca46eSDavid Howells 
366607ca46eSDavid Howells /*
367607ca46eSDavid Howells  * Register to get commands from other entities on specific channels.
368607ca46eSDavid Howells  * This way, you can only listen on specific channels, or have messages
369607ca46eSDavid Howells  * from some channels go to one place and other channels to someplace
370607ca46eSDavid Howells  * else.  The chans field is a bitmask, (1 << channel) for each channel.
371607ca46eSDavid Howells  * It may be IPMI_CHAN_ALL for all channels.
372607ca46eSDavid Howells  */
373607ca46eSDavid Howells struct ipmi_cmdspec_chans {
374607ca46eSDavid Howells 	unsigned int netfn;
375607ca46eSDavid Howells 	unsigned int cmd;
376607ca46eSDavid Howells 	unsigned int chans;
377607ca46eSDavid Howells };
378607ca46eSDavid Howells 
379607ca46eSDavid Howells /*
380607ca46eSDavid Howells  * Register to receive a specific command on specific channels.  error values:
381607ca46eSDavid Howells  *   - EFAULT - an address supplied was invalid.
382607ca46eSDavid Howells  *   - EBUSY - One of the netfn/cmd/chans supplied was already in use.
383607ca46eSDavid Howells  *   - ENOMEM - could not allocate memory for the entry.
384607ca46eSDavid Howells  */
385607ca46eSDavid Howells #define IPMICTL_REGISTER_FOR_CMD_CHANS	_IOR(IPMI_IOC_MAGIC, 28,	\
386607ca46eSDavid Howells 					     struct ipmi_cmdspec_chans)
387607ca46eSDavid Howells /*
388607ca46eSDavid Howells  * Unregister some netfn/cmd/chans.  error values:
389607ca46eSDavid Howells  *  - EFAULT - an address supplied was invalid.
390607ca46eSDavid Howells  *  - ENOENT - None of the netfn/cmd/chans were found registered for this user.
391607ca46eSDavid Howells  */
392607ca46eSDavid Howells #define IPMICTL_UNREGISTER_FOR_CMD_CHANS _IOR(IPMI_IOC_MAGIC, 29,	\
393607ca46eSDavid Howells 					     struct ipmi_cmdspec_chans)
394607ca46eSDavid Howells 
395607ca46eSDavid Howells /*
396607ca46eSDavid Howells  * Set whether this interface receives events.  Note that the first
397607ca46eSDavid Howells  * user registered for events will get all pending events for the
398607ca46eSDavid Howells  * interface.  error values:
399607ca46eSDavid Howells  *  - EFAULT - an address supplied was invalid.
400607ca46eSDavid Howells  */
401607ca46eSDavid Howells #define IPMICTL_SET_GETS_EVENTS_CMD	_IOR(IPMI_IOC_MAGIC, 16, int)
402607ca46eSDavid Howells 
403607ca46eSDavid Howells /*
404607ca46eSDavid Howells  * Set and get the slave address and LUN that we will use for our
405607ca46eSDavid Howells  * source messages.  Note that this affects the interface, not just
406607ca46eSDavid Howells  * this user, so it will affect all users of this interface.  This is
407607ca46eSDavid Howells  * so some initialization code can come in and do the OEM-specific
408607ca46eSDavid Howells  * things it takes to determine your address (if not the BMC) and set
409607ca46eSDavid Howells  * it for everyone else.  You should probably leave the LUN alone.
410607ca46eSDavid Howells  */
411607ca46eSDavid Howells struct ipmi_channel_lun_address_set {
412607ca46eSDavid Howells 	unsigned short channel;
413607ca46eSDavid Howells 	unsigned char  value;
414607ca46eSDavid Howells };
415607ca46eSDavid Howells #define IPMICTL_SET_MY_CHANNEL_ADDRESS_CMD \
416607ca46eSDavid Howells 	_IOR(IPMI_IOC_MAGIC, 24, struct ipmi_channel_lun_address_set)
417607ca46eSDavid Howells #define IPMICTL_GET_MY_CHANNEL_ADDRESS_CMD \
418607ca46eSDavid Howells 	_IOR(IPMI_IOC_MAGIC, 25, struct ipmi_channel_lun_address_set)
419607ca46eSDavid Howells #define IPMICTL_SET_MY_CHANNEL_LUN_CMD \
420607ca46eSDavid Howells 	_IOR(IPMI_IOC_MAGIC, 26, struct ipmi_channel_lun_address_set)
421607ca46eSDavid Howells #define IPMICTL_GET_MY_CHANNEL_LUN_CMD \
422607ca46eSDavid Howells 	_IOR(IPMI_IOC_MAGIC, 27, struct ipmi_channel_lun_address_set)
423607ca46eSDavid Howells /* Legacy interfaces, these only set IPMB 0. */
424607ca46eSDavid Howells #define IPMICTL_SET_MY_ADDRESS_CMD	_IOR(IPMI_IOC_MAGIC, 17, unsigned int)
425607ca46eSDavid Howells #define IPMICTL_GET_MY_ADDRESS_CMD	_IOR(IPMI_IOC_MAGIC, 18, unsigned int)
426607ca46eSDavid Howells #define IPMICTL_SET_MY_LUN_CMD		_IOR(IPMI_IOC_MAGIC, 19, unsigned int)
427607ca46eSDavid Howells #define IPMICTL_GET_MY_LUN_CMD		_IOR(IPMI_IOC_MAGIC, 20, unsigned int)
428607ca46eSDavid Howells 
429607ca46eSDavid Howells /*
430607ca46eSDavid Howells  * Get/set the default timing values for an interface.  You shouldn't
431607ca46eSDavid Howells  * generally mess with these.
432607ca46eSDavid Howells  */
433607ca46eSDavid Howells struct ipmi_timing_parms {
434607ca46eSDavid Howells 	int          retries;
435607ca46eSDavid Howells 	unsigned int retry_time_ms;
436607ca46eSDavid Howells };
437607ca46eSDavid Howells #define IPMICTL_SET_TIMING_PARMS_CMD	_IOR(IPMI_IOC_MAGIC, 22, \
438607ca46eSDavid Howells 					     struct ipmi_timing_parms)
439607ca46eSDavid Howells #define IPMICTL_GET_TIMING_PARMS_CMD	_IOR(IPMI_IOC_MAGIC, 23, \
440607ca46eSDavid Howells 					     struct ipmi_timing_parms)
441607ca46eSDavid Howells 
442607ca46eSDavid Howells /*
443607ca46eSDavid Howells  * Set the maintenance mode.  See ipmi_set_maintenance_mode() above
444607ca46eSDavid Howells  * for a description of what this does.
445607ca46eSDavid Howells  */
446607ca46eSDavid Howells #define IPMICTL_GET_MAINTENANCE_MODE_CMD	_IOR(IPMI_IOC_MAGIC, 30, int)
447607ca46eSDavid Howells #define IPMICTL_SET_MAINTENANCE_MODE_CMD	_IOW(IPMI_IOC_MAGIC, 31, int)
448607ca46eSDavid Howells 
449607ca46eSDavid Howells #endif /* _UAPI__LINUX_IPMI_H */
450