blob: 65aae34759de5d9266c17bfef3deea3f01d644ea [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * ipmi.h
3 *
4 * MontaVista IPMI interface
5 *
6 * Author: MontaVista Software, Inc.
7 * Corey Minyard <minyard@mvista.com>
8 * source@mvista.com
9 *
10 * Copyright 2002 MontaVista Software Inc.
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 *
17 *
18 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
19 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
24 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
26 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
27 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * You should have received a copy of the GNU General Public License along
30 * with this program; if not, write to the Free Software Foundation, Inc.,
31 * 675 Mass Ave, Cambridge, MA 02139, USA.
32 */
33
34#ifndef __LINUX_IPMI_H
35#define __LINUX_IPMI_H
36
37#include <linux/ipmi_msgdefs.h>
Corey Minyard07766f22005-09-06 15:18:40 -070038#include <linux/compiler.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/*
41 * This file describes an interface to an IPMI driver. You have to
42 * have a fairly good understanding of IPMI to use this, so go read
43 * the specs first before actually trying to do anything.
44 *
45 * With that said, this driver provides a multi-user interface to the
46 * IPMI driver, and it allows multiple IPMI physical interfaces below
47 * the driver. The physical interfaces bind as a lower layer on the
48 * driver. They appear as interfaces to the application using this
49 * interface.
50 *
51 * Multi-user means that multiple applications may use the driver,
52 * send commands, receive responses, etc. The driver keeps track of
53 * commands the user sends and tracks the responses. The responses
54 * will go back to the application that send the command. If the
55 * response doesn't come back in time, the driver will return a
56 * timeout error response to the application. Asynchronous events
57 * from the BMC event queue will go to all users bound to the driver.
58 * The incoming event queue in the BMC will automatically be flushed
59 * if it becomes full and it is queried once a second to see if
60 * anything is in it. Incoming commands to the driver will get
61 * delivered as commands.
62 *
63 * This driver provides two main interfaces: one for in-kernel
64 * applications and another for userland applications. The
65 * capabilities are basically the same for both interface, although
66 * the interfaces are somewhat different. The stuff in the
Robert P. J. Day66ec2d72008-04-29 01:01:14 -070067 * #ifdef __KERNEL__ below is the in-kernel interface. The userland
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 * interface is defined later in the file. */
69
70
71
72/*
73 * This is an overlay for all the address types, so it's easy to
74 * determine the actual address type. This is kind of like addresses
75 * work for sockets.
76 */
77#define IPMI_MAX_ADDR_SIZE 32
Corey Minyardc70d7492008-04-29 01:01:09 -070078struct ipmi_addr {
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 /* Try to take these from the "Channel Medium Type" table
80 in section 6.5 of the IPMI 1.5 manual. */
81 int addr_type;
82 short channel;
83 char data[IPMI_MAX_ADDR_SIZE];
84};
85
86/*
87 * When the address is not used, the type will be set to this value.
88 * The channel is the BMC's channel number for the channel (usually
89 * 0), or IPMC_BMC_CHANNEL if communicating directly with the BMC.
90 */
91#define IPMI_SYSTEM_INTERFACE_ADDR_TYPE 0x0c
Corey Minyardc70d7492008-04-29 01:01:09 -070092struct ipmi_system_interface_addr {
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 int addr_type;
94 short channel;
95 unsigned char lun;
96};
97
98/* An IPMB Address. */
99#define IPMI_IPMB_ADDR_TYPE 0x01
100/* Used for broadcast get device id as described in section 17.9 of the
Corey Minyardc70d7492008-04-29 01:01:09 -0700101 IPMI 1.5 manual. */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102#define IPMI_IPMB_BROADCAST_ADDR_TYPE 0x41
Corey Minyardc70d7492008-04-29 01:01:09 -0700103struct ipmi_ipmb_addr {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 int addr_type;
105 short channel;
106 unsigned char slave_addr;
107 unsigned char lun;
108};
109
110/*
111 * A LAN Address. This is an address to/from a LAN interface bridged
112 * by the BMC, not an address actually out on the LAN.
113 *
114 * A concious decision was made here to deviate slightly from the IPMI
115 * spec. We do not use rqSWID and rsSWID like it shows in the
116 * message. Instead, we use remote_SWID and local_SWID. This means
117 * that any message (a request or response) from another device will
118 * always have exactly the same address. If you didn't do this,
119 * requests and responses from the same device would have different
120 * addresses, and that's not too cool.
121 *
122 * In this address, the remote_SWID is always the SWID the remote
123 * message came from, or the SWID we are sending the message to.
124 * local_SWID is always our SWID. Note that having our SWID in the
125 * message is a little weird, but this is required.
126 */
127#define IPMI_LAN_ADDR_TYPE 0x04
Corey Minyardc70d7492008-04-29 01:01:09 -0700128struct ipmi_lan_addr {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 int addr_type;
130 short channel;
131 unsigned char privilege;
132 unsigned char session_handle;
133 unsigned char remote_SWID;
134 unsigned char local_SWID;
135 unsigned char lun;
136};
137
138
139/*
140 * Channel for talking directly with the BMC. When using this
141 * channel, This is for the system interface address type only. FIXME
142 * - is this right, or should we use -1?
143 */
144#define IPMI_BMC_CHANNEL 0xf
145#define IPMI_NUM_CHANNELS 0x10
146
Corey Minyardc69c3122006-09-30 23:27:56 -0700147/*
148 * Used to signify an "all channel" bitmask. This is more than the
149 * actual number of channels because this is used in userland and
150 * will cover us if the number of channels is extended.
151 */
152#define IPMI_CHAN_ALL (~0)
153
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154
155/*
156 * A raw IPMI message without any addressing. This covers both
157 * commands and responses. The completion code is always the first
158 * byte of data in the response (as the spec shows the messages laid
159 * out).
160 */
Corey Minyardc70d7492008-04-29 01:01:09 -0700161struct ipmi_msg {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162 unsigned char netfn;
163 unsigned char cmd;
164 unsigned short data_len;
165 unsigned char __user *data;
166};
167
Corey Minyardc70d7492008-04-29 01:01:09 -0700168struct kernel_ipmi_msg {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169 unsigned char netfn;
170 unsigned char cmd;
171 unsigned short data_len;
172 unsigned char *data;
173};
174
175/*
176 * Various defines that are useful for IPMI applications.
177 */
178#define IPMI_INVALID_CMD_COMPLETION_CODE 0xC1
179#define IPMI_TIMEOUT_COMPLETION_CODE 0xC3
180#define IPMI_UNKNOWN_ERR_COMPLETION_CODE 0xff
181
182
183/*
184 * Receive types for messages coming from the receive interface. This
185 * is used for the receive in-kernel interface and in the receive
186 * IOCTL.
187 *
188 * The "IPMI_RESPONSE_RESPNOSE_TYPE" is a little strange sounding, but
189 * it allows you to get the message results when you send a response
190 * message.
191 */
192#define IPMI_RESPONSE_RECV_TYPE 1 /* A response to a command */
193#define IPMI_ASYNC_EVENT_RECV_TYPE 2 /* Something from the event queue */
194#define IPMI_CMD_RECV_TYPE 3 /* A command from somewhere else */
195#define IPMI_RESPONSE_RESPONSE_TYPE 4 /* The response for
196 a sent response, giving any
197 error status for sending the
198 response. When you send a
199 response message, this will
200 be returned. */
dann frazier4dec3022009-04-21 12:24:05 -0700201#define IPMI_OEM_RECV_TYPE 5 /* The response for OEM Channels */
202
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203/* Note that async events and received commands do not have a completion
204 code as the first byte of the incoming data, unlike a response. */
205
206
Corey Minyardb9675132006-12-06 20:41:02 -0800207/*
208 * Modes for ipmi_set_maint_mode() and the userland IOCTL. The AUTO
209 * setting is the default and means it will be set on certain
210 * commands. Hard setting it on and off will override automatic
211 * operation.
212 */
213#define IPMI_MAINTENANCE_MODE_AUTO 0
214#define IPMI_MAINTENANCE_MODE_OFF 1
215#define IPMI_MAINTENANCE_MODE_ON 2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216
217#ifdef __KERNEL__
218
219/*
220 * The in-kernel interface.
221 */
222#include <linux/list.h>
223#include <linux/module.h>
David Woodhouse2e0e1f92006-04-25 14:15:44 +0100224#include <linux/device.h>
Corey Minyard3b625942005-06-23 22:01:42 -0700225#include <linux/proc_fs.h>
Corey Minyard3b625942005-06-23 22:01:42 -0700226
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227/* Opaque type for a IPMI message user. One of these is needed to
228 send and receive messages. */
229typedef struct ipmi_user *ipmi_user_t;
230
231/*
232 * Stuff coming from the receive interface comes as one of these.
233 * They are allocated, the receiver must free them with
234 * ipmi_free_recv_msg() when done with the message. The link is not
235 * used after the message is delivered, so the upper layer may use the
236 * link to build a linked list, if it likes.
237 */
Corey Minyardc70d7492008-04-29 01:01:09 -0700238struct ipmi_recv_msg {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 struct list_head link;
240
241 /* The type of message as defined in the "Receive Types"
Corey Minyardc70d7492008-04-29 01:01:09 -0700242 defines above. */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 int recv_type;
244
245 ipmi_user_t user;
246 struct ipmi_addr addr;
247 long msgid;
248 struct kernel_ipmi_msg msg;
249
250 /* The user_msg_data is the data supplied when a message was
251 sent, if this is a response to a sent message. If this is
252 not a response to a sent message, then user_msg_data will
Corey Minyard56a55ec2005-09-06 15:18:42 -0700253 be NULL. If the user above is NULL, then this will be the
254 intf. */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 void *user_msg_data;
256
257 /* Call this when done with the message. It will presumably free
258 the message and do any other necessary cleanup. */
259 void (*done)(struct ipmi_recv_msg *msg);
260
261 /* Place-holder for the data, don't make any assumptions about
262 the size or existance of this, since it may change. */
263 unsigned char msg_data[IPMI_MAX_MSG_LENGTH];
264};
265
266/* Allocate and free the receive message. */
Corey Minyard393d2cc2005-11-07 00:59:54 -0800267void ipmi_free_recv_msg(struct ipmi_recv_msg *msg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268
Corey Minyardc70d7492008-04-29 01:01:09 -0700269struct ipmi_user_hndl {
270 /* Routine type to call when a message needs to be routed to
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271 the upper layer. This will be called with some locks held,
272 the only IPMI routines that can be called are ipmi_request
273 and the alloc/free operations. The handler_data is the
274 variable supplied when the receive handler was registered. */
275 void (*ipmi_recv_hndl)(struct ipmi_recv_msg *msg,
276 void *user_msg_data);
277
278 /* Called when the interface detects a watchdog pre-timeout. If
279 this is NULL, it will be ignored for the user. */
280 void (*ipmi_watchdog_pretimeout)(void *handler_data);
281};
282
283/* Create a new user of the IPMI layer on the given interface number. */
284int ipmi_create_user(unsigned int if_num,
285 struct ipmi_user_hndl *handler,
286 void *handler_data,
287 ipmi_user_t *user);
288
289/* Destroy the given user of the IPMI layer. Note that after this
290 function returns, the system is guaranteed to not call any
291 callbacks for the user. Thus as long as you destroy all the users
292 before you unload a module, you will be safe. And if you destroy
293 the users before you destroy the callback structures, it should be
294 safe, too. */
295int ipmi_destroy_user(ipmi_user_t user);
296
297/* Get the IPMI version of the BMC we are talking to. */
298void ipmi_get_version(ipmi_user_t user,
299 unsigned char *major,
300 unsigned char *minor);
301
302/* Set and get the slave address and LUN that we will use for our
303 source messages. Note that this affects the interface, not just
304 this user, so it will affect all users of this interface. This is
305 so some initialization code can come in and do the OEM-specific
306 things it takes to determine your address (if not the BMC) and set
Corey Minyardc14979b2005-09-06 15:18:38 -0700307 it for everyone else. Note that each channel can have its own address. */
308int ipmi_set_my_address(ipmi_user_t user,
309 unsigned int channel,
310 unsigned char address);
311int ipmi_get_my_address(ipmi_user_t user,
312 unsigned int channel,
313 unsigned char *address);
314int ipmi_set_my_LUN(ipmi_user_t user,
315 unsigned int channel,
316 unsigned char LUN);
317int ipmi_get_my_LUN(ipmi_user_t user,
318 unsigned int channel,
319 unsigned char *LUN);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320
321/*
322 * Like ipmi_request, but lets you specify the number of retries and
323 * the retry time. The retries is the number of times the message
324 * will be resent if no reply is received. If set to -1, the default
325 * value will be used. The retry time is the time in milliseconds
326 * between retries. If set to zero, the default value will be
327 * used.
328 *
329 * Don't use this unless you *really* have to. It's primarily for the
330 * IPMI over LAN converter; since the LAN stuff does its own retries,
331 * it makes no sense to do it here. However, this can be used if you
332 * have unusual requirements.
333 */
334int ipmi_request_settime(ipmi_user_t user,
335 struct ipmi_addr *addr,
336 long msgid,
337 struct kernel_ipmi_msg *msg,
338 void *user_msg_data,
339 int priority,
340 int max_retries,
341 unsigned int retry_time_ms);
342
343/*
344 * Like ipmi_request, but with messages supplied. This will not
345 * allocate any memory, and the messages may be statically allocated
346 * (just make sure to do the "done" handling on them). Note that this
347 * is primarily for the watchdog timer, since it should be able to
348 * send messages even if no memory is available. This is subject to
349 * change as the system changes, so don't use it unless you REALLY
350 * have to.
351 */
352int ipmi_request_supply_msgs(ipmi_user_t user,
353 struct ipmi_addr *addr,
354 long msgid,
355 struct kernel_ipmi_msg *msg,
356 void *user_msg_data,
357 void *supplied_smi,
358 struct ipmi_recv_msg *supplied_recv,
359 int priority);
360
361/*
Corey Minyardfcfa4722007-10-18 03:07:09 -0700362 * Poll the IPMI interface for the user. This causes the IPMI code to
363 * do an immediate check for information from the driver and handle
364 * anything that is immediately pending. This will not block in any
Corey Minyardbda4c302008-04-29 01:01:02 -0700365 * way. This is useful if you need to spin waiting for something to
366 * happen in the IPMI driver.
Corey Minyardfcfa4722007-10-18 03:07:09 -0700367 */
368void ipmi_poll_interface(ipmi_user_t user);
369
370/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 * When commands come in to the SMS, the user can register to receive
Corey Minyardc69c3122006-09-30 23:27:56 -0700372 * them. Only one user can be listening on a specific netfn/cmd/chan tuple
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 * at a time, you will get an EBUSY error if the command is already
374 * registered. If a command is received that does not have a user
375 * registered, the driver will automatically return the proper
Corey Minyardc69c3122006-09-30 23:27:56 -0700376 * error. Channels are specified as a bitfield, use IPMI_CHAN_ALL to
377 * mean all channels.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 */
379int ipmi_register_for_cmd(ipmi_user_t user,
380 unsigned char netfn,
Corey Minyardc69c3122006-09-30 23:27:56 -0700381 unsigned char cmd,
382 unsigned int chans);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383int ipmi_unregister_for_cmd(ipmi_user_t user,
384 unsigned char netfn,
Corey Minyardc69c3122006-09-30 23:27:56 -0700385 unsigned char cmd,
386 unsigned int chans);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387
388/*
Corey Minyardb9675132006-12-06 20:41:02 -0800389 * Go into a mode where the driver will not autonomously attempt to do
390 * things with the interface. It will still respond to attentions and
391 * interrupts, and it will expect that commands will complete. It
392 * will not automatcially check for flags, events, or things of that
393 * nature.
394 *
395 * This is primarily used for firmware upgrades. The idea is that
396 * when you go into firmware upgrade mode, you do this operation
397 * and the driver will not attempt to do anything but what you tell
398 * it or what the BMC asks for.
399 *
400 * Note that if you send a command that resets the BMC, the driver
401 * will still expect a response from that command. So the BMC should
402 * reset itself *after* the response is sent. Resetting before the
403 * response is just silly.
404 *
405 * If in auto maintenance mode, the driver will automatically go into
406 * maintenance mode for 30 seconds if it sees a cold reset, a warm
407 * reset, or a firmware NetFN. This means that code that uses only
408 * firmware NetFN commands to do upgrades will work automatically
409 * without change, assuming it sends a message every 30 seconds or
410 * less.
411 *
412 * See the IPMI_MAINTENANCE_MODE_xxx defines for what the mode means.
413 */
414int ipmi_get_maintenance_mode(ipmi_user_t user);
415int ipmi_set_maintenance_mode(ipmi_user_t user, int mode);
416
417/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 * When the user is created, it will not receive IPMI events by
419 * default. The user must set this to TRUE to get incoming events.
420 * The first user that sets this to TRUE will receive all events that
421 * have been queued while no one was waiting for events.
422 */
423int ipmi_set_gets_events(ipmi_user_t user, int val);
424
425/*
426 * Called when a new SMI is registered. This will also be called on
427 * every existing interface when a new watcher is registered with
428 * ipmi_smi_watcher_register().
429 */
Corey Minyardc70d7492008-04-29 01:01:09 -0700430struct ipmi_smi_watcher {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431 struct list_head link;
432
433 /* You must set the owner to the current module, if you are in
434 a module (generally just set it to "THIS_MODULE"). */
435 struct module *owner;
436
437 /* These two are called with read locks held for the interface
438 the watcher list. So you can add and remove users from the
439 IPMI interface, send messages, etc., but you cannot add
440 or remove SMI watchers or SMI interfaces. */
Corey Minyard50c812b2006-03-26 01:37:21 -0800441 void (*new_smi)(int if_num, struct device *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 void (*smi_gone)(int if_num);
443};
444
445int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher);
446int ipmi_smi_watcher_unregister(struct ipmi_smi_watcher *watcher);
447
448/* The following are various helper functions for dealing with IPMI
449 addresses. */
450
451/* Return the maximum length of an IPMI address given it's type. */
452unsigned int ipmi_addr_length(int addr_type);
453
454/* Validate that the given IPMI address is valid. */
455int ipmi_validate_addr(struct ipmi_addr *addr, int len);
456
457#endif /* __KERNEL__ */
458
459
460/*
461 * The userland interface
462 */
463
464/*
465 * The userland interface for the IPMI driver is a standard character
466 * device, with each instance of an interface registered as a minor
467 * number under the major character device.
468 *
469 * The read and write calls do not work, to get messages in and out
470 * requires ioctl calls because of the complexity of the data. select
471 * and poll do work, so you can wait for input using the file
472 * descriptor, you just can use read to get it.
473 *
474 * In general, you send a command down to the interface and receive
475 * responses back. You can use the msgid value to correlate commands
476 * and responses, the driver will take care of figuring out which
477 * incoming messages are for which command and find the proper msgid
478 * value to report. You will only receive reponses for commands you
479 * send. Asynchronous events, however, go to all open users, so you
480 * must be ready to handle these (or ignore them if you don't care).
481 *
482 * The address type depends upon the channel type. When talking
483 * directly to the BMC (IPMC_BMC_CHANNEL), the address is ignored
484 * (IPMI_UNUSED_ADDR_TYPE). When talking to an IPMB channel, you must
485 * supply a valid IPMB address with the addr_type set properly.
486 *
487 * When talking to normal channels, the driver takes care of the
488 * details of formatting and sending messages on that channel. You do
489 * not, for instance, have to format a send command, you just send
490 * whatever command you want to the channel, the driver will create
491 * the send command, automatically issue receive command and get even
492 * commands, and pass those up to the proper user.
493 */
494
495
496/* The magic IOCTL value for this interface. */
497#define IPMI_IOC_MAGIC 'i'
498
499
500/* Messages sent to the interface are this format. */
Corey Minyardc70d7492008-04-29 01:01:09 -0700501struct ipmi_req {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 unsigned char __user *addr; /* Address to send the message to. */
503 unsigned int addr_len;
504
505 long msgid; /* The sequence number for the message. This
506 exact value will be reported back in the
507 response to this request if it is a command.
508 If it is a response, this will be used as
509 the sequence value for the response. */
510
511 struct ipmi_msg msg;
512};
513/*
514 * Send a message to the interfaces. error values are:
515 * - EFAULT - an address supplied was invalid.
516 * - EINVAL - The address supplied was not valid, or the command
517 * was not allowed.
518 * - EMSGSIZE - The message to was too large.
519 * - ENOMEM - Buffers could not be allocated for the command.
520 */
521#define IPMICTL_SEND_COMMAND _IOR(IPMI_IOC_MAGIC, 13, \
522 struct ipmi_req)
523
524/* Messages sent to the interface with timing parameters are this
525 format. */
Corey Minyardc70d7492008-04-29 01:01:09 -0700526struct ipmi_req_settime {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 struct ipmi_req req;
528
529 /* See ipmi_request_settime() above for details on these
Corey Minyardc70d7492008-04-29 01:01:09 -0700530 values. */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 int retries;
532 unsigned int retry_time_ms;
533};
534/*
535 * Send a message to the interfaces with timing parameters. error values
536 * are:
537 * - EFAULT - an address supplied was invalid.
538 * - EINVAL - The address supplied was not valid, or the command
539 * was not allowed.
540 * - EMSGSIZE - The message to was too large.
541 * - ENOMEM - Buffers could not be allocated for the command.
542 */
543#define IPMICTL_SEND_COMMAND_SETTIME _IOR(IPMI_IOC_MAGIC, 21, \
544 struct ipmi_req_settime)
545
546/* Messages received from the interface are this format. */
Corey Minyardc70d7492008-04-29 01:01:09 -0700547struct ipmi_recv {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 int recv_type; /* Is this a command, response or an
549 asyncronous event. */
550
551 unsigned char __user *addr; /* Address the message was from is put
552 here. The caller must supply the
553 memory. */
554 unsigned int addr_len; /* The size of the address buffer.
555 The caller supplies the full buffer
556 length, this value is updated to
557 the actual message length when the
558 message is received. */
559
560 long msgid; /* The sequence number specified in the request
561 if this is a response. If this is a command,
562 this will be the sequence number from the
563 command. */
564
565 struct ipmi_msg msg; /* The data field must point to a buffer.
566 The data_size field must be set to the
567 size of the message buffer. The
568 caller supplies the full buffer
569 length, this value is updated to the
570 actual message length when the message
571 is received. */
572};
573
574/*
575 * Receive a message. error values:
576 * - EAGAIN - no messages in the queue.
577 * - EFAULT - an address supplied was invalid.
578 * - EINVAL - The address supplied was not valid.
579 * - EMSGSIZE - The message to was too large to fit into the message buffer,
580 * the message will be left in the buffer. */
581#define IPMICTL_RECEIVE_MSG _IOWR(IPMI_IOC_MAGIC, 12, \
582 struct ipmi_recv)
583
584/*
585 * Like RECEIVE_MSG, but if the message won't fit in the buffer, it
586 * will truncate the contents instead of leaving the data in the
587 * buffer.
588 */
589#define IPMICTL_RECEIVE_MSG_TRUNC _IOWR(IPMI_IOC_MAGIC, 11, \
590 struct ipmi_recv)
591
592/* Register to get commands from other entities on this interface. */
Corey Minyardc70d7492008-04-29 01:01:09 -0700593struct ipmi_cmdspec {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 unsigned char netfn;
595 unsigned char cmd;
596};
597
Corey Minyardc70d7492008-04-29 01:01:09 -0700598/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 * Register to receive a specific command. error values:
600 * - EFAULT - an address supplied was invalid.
601 * - EBUSY - The netfn/cmd supplied was already in use.
602 * - ENOMEM - could not allocate memory for the entry.
603 */
604#define IPMICTL_REGISTER_FOR_CMD _IOR(IPMI_IOC_MAGIC, 14, \
605 struct ipmi_cmdspec)
606/*
607 * Unregister a regsitered command. error values:
608 * - EFAULT - an address supplied was invalid.
609 * - ENOENT - The netfn/cmd was not found registered for this user.
610 */
611#define IPMICTL_UNREGISTER_FOR_CMD _IOR(IPMI_IOC_MAGIC, 15, \
612 struct ipmi_cmdspec)
613
Corey Minyardc69c3122006-09-30 23:27:56 -0700614/*
615 * Register to get commands from other entities on specific channels.
616 * This way, you can only listen on specific channels, or have messages
617 * from some channels go to one place and other channels to someplace
618 * else. The chans field is a bitmask, (1 << channel) for each channel.
619 * It may be IPMI_CHAN_ALL for all channels.
620 */
Corey Minyardc70d7492008-04-29 01:01:09 -0700621struct ipmi_cmdspec_chans {
Corey Minyardc69c3122006-09-30 23:27:56 -0700622 unsigned int netfn;
623 unsigned int cmd;
624 unsigned int chans;
625};
626
627/*
628 * Register to receive a specific command on specific channels. error values:
629 * - EFAULT - an address supplied was invalid.
630 * - EBUSY - One of the netfn/cmd/chans supplied was already in use.
631 * - ENOMEM - could not allocate memory for the entry.
632 */
633#define IPMICTL_REGISTER_FOR_CMD_CHANS _IOR(IPMI_IOC_MAGIC, 28, \
634 struct ipmi_cmdspec_chans)
635/*
636 * Unregister some netfn/cmd/chans. error values:
637 * - EFAULT - an address supplied was invalid.
638 * - ENOENT - None of the netfn/cmd/chans were found registered for this user.
639 */
640#define IPMICTL_UNREGISTER_FOR_CMD_CHANS _IOR(IPMI_IOC_MAGIC, 29, \
641 struct ipmi_cmdspec_chans)
642
Corey Minyardc70d7492008-04-29 01:01:09 -0700643/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 * Set whether this interface receives events. Note that the first
645 * user registered for events will get all pending events for the
646 * interface. error values:
647 * - EFAULT - an address supplied was invalid.
648 */
649#define IPMICTL_SET_GETS_EVENTS_CMD _IOR(IPMI_IOC_MAGIC, 16, int)
650
651/*
652 * Set and get the slave address and LUN that we will use for our
653 * source messages. Note that this affects the interface, not just
654 * this user, so it will affect all users of this interface. This is
655 * so some initialization code can come in and do the OEM-specific
656 * things it takes to determine your address (if not the BMC) and set
657 * it for everyone else. You should probably leave the LUN alone.
658 */
Corey Minyardc70d7492008-04-29 01:01:09 -0700659struct ipmi_channel_lun_address_set {
Corey Minyardc14979b2005-09-06 15:18:38 -0700660 unsigned short channel;
661 unsigned char value;
662};
Corey Minyardc70d7492008-04-29 01:01:09 -0700663#define IPMICTL_SET_MY_CHANNEL_ADDRESS_CMD \
664 _IOR(IPMI_IOC_MAGIC, 24, struct ipmi_channel_lun_address_set)
665#define IPMICTL_GET_MY_CHANNEL_ADDRESS_CMD \
666 _IOR(IPMI_IOC_MAGIC, 25, struct ipmi_channel_lun_address_set)
667#define IPMICTL_SET_MY_CHANNEL_LUN_CMD \
668 _IOR(IPMI_IOC_MAGIC, 26, struct ipmi_channel_lun_address_set)
669#define IPMICTL_GET_MY_CHANNEL_LUN_CMD \
670 _IOR(IPMI_IOC_MAGIC, 27, struct ipmi_channel_lun_address_set)
Corey Minyardc14979b2005-09-06 15:18:38 -0700671/* Legacy interfaces, these only set IPMB 0. */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672#define IPMICTL_SET_MY_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 17, unsigned int)
673#define IPMICTL_GET_MY_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 18, unsigned int)
674#define IPMICTL_SET_MY_LUN_CMD _IOR(IPMI_IOC_MAGIC, 19, unsigned int)
675#define IPMICTL_GET_MY_LUN_CMD _IOR(IPMI_IOC_MAGIC, 20, unsigned int)
676
677/*
678 * Get/set the default timing values for an interface. You shouldn't
679 * generally mess with these.
680 */
Corey Minyardc70d7492008-04-29 01:01:09 -0700681struct ipmi_timing_parms {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 int retries;
683 unsigned int retry_time_ms;
684};
685#define IPMICTL_SET_TIMING_PARMS_CMD _IOR(IPMI_IOC_MAGIC, 22, \
686 struct ipmi_timing_parms)
687#define IPMICTL_GET_TIMING_PARMS_CMD _IOR(IPMI_IOC_MAGIC, 23, \
688 struct ipmi_timing_parms)
689
Corey Minyardb9675132006-12-06 20:41:02 -0800690/*
691 * Set the maintenance mode. See ipmi_set_maintenance_mode() above
692 * for a description of what this does.
693 */
694#define IPMICTL_GET_MAINTENANCE_MODE_CMD _IOR(IPMI_IOC_MAGIC, 30, int)
695#define IPMICTL_SET_MAINTENANCE_MODE_CMD _IOW(IPMI_IOC_MAGIC, 31, int)
696
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697#endif /* __LINUX_IPMI_H */