linux/include/linux/ipmi.h
<<
>>
Prefs
   1/*
   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>
  38#include <linux/compiler.h>
  39
  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
  67 * #ifdef KERNEL below is the in-kernel interface.  The userland
  68 * 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
  78struct ipmi_addr
  79{
  80         /* Try to take these from the "Channel Medium Type" table
  81            in section 6.5 of the IPMI 1.5 manual. */
  82        int   addr_type;
  83        short channel;
  84        char  data[IPMI_MAX_ADDR_SIZE];
  85};
  86
  87/*
  88 * When the address is not used, the type will be set to this value.
  89 * The channel is the BMC's channel number for the channel (usually
  90 * 0), or IPMC_BMC_CHANNEL if communicating directly with the BMC.
  91 */
  92#define IPMI_SYSTEM_INTERFACE_ADDR_TYPE 0x0c
  93struct ipmi_system_interface_addr
  94{
  95        int           addr_type;
  96        short         channel;
  97        unsigned char lun;
  98};
  99
 100/* An IPMB Address. */
 101#define IPMI_IPMB_ADDR_TYPE             0x01
 102/* Used for broadcast get device id as described in section 17.9 of the
 103   IPMI 1.5 manual. */ 
 104#define IPMI_IPMB_BROADCAST_ADDR_TYPE   0x41
 105struct ipmi_ipmb_addr
 106{
 107        int           addr_type;
 108        short         channel;
 109        unsigned char slave_addr;
 110        unsigned char lun;
 111};
 112
 113/*
 114 * A LAN Address.  This is an address to/from a LAN interface bridged
 115 * by the BMC, not an address actually out on the LAN.
 116 *
 117 * A concious decision was made here to deviate slightly from the IPMI
 118 * spec.  We do not use rqSWID and rsSWID like it shows in the
 119 * message.  Instead, we use remote_SWID and local_SWID.  This means
 120 * that any message (a request or response) from another device will
 121 * always have exactly the same address.  If you didn't do this,
 122 * requests and responses from the same device would have different
 123 * addresses, and that's not too cool.
 124 *
 125 * In this address, the remote_SWID is always the SWID the remote
 126 * message came from, or the SWID we are sending the message to.
 127 * local_SWID is always our SWID.  Note that having our SWID in the
 128 * message is a little weird, but this is required.
 129 */
 130#define IPMI_LAN_ADDR_TYPE              0x04
 131struct ipmi_lan_addr
 132{
 133        int           addr_type;
 134        short         channel;
 135        unsigned char privilege;
 136        unsigned char session_handle;
 137        unsigned char remote_SWID;
 138        unsigned char local_SWID;
 139        unsigned char lun;
 140};
 141
 142
 143/*
 144 * Channel for talking directly with the BMC.  When using this
 145 * channel, This is for the system interface address type only.  FIXME
 146 * - is this right, or should we use -1?
 147 */
 148#define IPMI_BMC_CHANNEL  0xf
 149#define IPMI_NUM_CHANNELS 0x10
 150
 151/*
 152 * Used to signify an "all channel" bitmask.  This is more than the
 153 * actual number of channels because this is used in userland and
 154 * will cover us if the number of channels is extended.
 155 */
 156#define IPMI_CHAN_ALL     (~0)
 157
 158
 159/*
 160 * A raw IPMI message without any addressing.  This covers both
 161 * commands and responses.  The completion code is always the first
 162 * byte of data in the response (as the spec shows the messages laid
 163 * out).
 164 */
 165struct ipmi_msg
 166{
 167        unsigned char  netfn;
 168        unsigned char  cmd;
 169        unsigned short data_len;
 170        unsigned char  __user *data;
 171};
 172
 173struct kernel_ipmi_msg
 174{
 175        unsigned char  netfn;
 176        unsigned char  cmd;
 177        unsigned short data_len;
 178        unsigned char  *data;
 179};
 180
 181/*
 182 * Various defines that are useful for IPMI applications.
 183 */
 184#define IPMI_INVALID_CMD_COMPLETION_CODE        0xC1
 185#define IPMI_TIMEOUT_COMPLETION_CODE            0xC3
 186#define IPMI_UNKNOWN_ERR_COMPLETION_CODE        0xff
 187
 188
 189/*
 190 * Receive types for messages coming from the receive interface.  This
 191 * is used for the receive in-kernel interface and in the receive
 192 * IOCTL.
 193 *
 194 * The "IPMI_RESPONSE_RESPNOSE_TYPE" is a little strange sounding, but
 195 * it allows you to get the message results when you send a response
 196 * message.
 197 */
 198#define IPMI_RESPONSE_RECV_TYPE         1 /* A response to a command */
 199#define IPMI_ASYNC_EVENT_RECV_TYPE      2 /* Something from the event queue */
 200#define IPMI_CMD_RECV_TYPE              3 /* A command from somewhere else */
 201#define IPMI_RESPONSE_RESPONSE_TYPE     4 /* The response for
 202                                              a sent response, giving any
 203                                              error status for sending the
 204                                              response.  When you send a
 205                                              response message, this will
 206                                              be returned. */
 207/* Note that async events and received commands do not have a completion
 208   code as the first byte of the incoming data, unlike a response. */
 209
 210
 211/*
 212 * Modes for ipmi_set_maint_mode() and the userland IOCTL.  The AUTO
 213 * setting is the default and means it will be set on certain
 214 * commands.  Hard setting it on and off will override automatic
 215 * operation.
 216 */
 217#define IPMI_MAINTENANCE_MODE_AUTO      0
 218#define IPMI_MAINTENANCE_MODE_OFF       1
 219#define IPMI_MAINTENANCE_MODE_ON        2
 220
 221#ifdef __KERNEL__
 222
 223/*
 224 * The in-kernel interface.
 225 */
 226#include <linux/list.h>
 227#include <linux/module.h>
 228#include <linux/device.h>
 229#include <linux/proc_fs.h>
 230
 231/* Opaque type for a IPMI message user.  One of these is needed to
 232   send and receive messages. */
 233typedef struct ipmi_user *ipmi_user_t;
 234
 235/*
 236 * Stuff coming from the receive interface comes as one of these.
 237 * They are allocated, the receiver must free them with
 238 * ipmi_free_recv_msg() when done with the message.  The link is not
 239 * used after the message is delivered, so the upper layer may use the
 240 * link to build a linked list, if it likes.
 241 */
 242struct ipmi_recv_msg
 243{
 244        struct list_head link;
 245
 246        /* The type of message as defined in the "Receive Types"
 247           defines above. */
 248        int              recv_type;
 249
 250        ipmi_user_t      user;
 251        struct ipmi_addr addr;
 252        long             msgid;
 253        struct kernel_ipmi_msg  msg;
 254
 255        /* The user_msg_data is the data supplied when a message was
 256           sent, if this is a response to a sent message.  If this is
 257           not a response to a sent message, then user_msg_data will
 258           be NULL.  If the user above is NULL, then this will be the
 259           intf. */
 260        void             *user_msg_data;
 261
 262        /* Call this when done with the message.  It will presumably free
 263           the message and do any other necessary cleanup. */
 264        void (*done)(struct ipmi_recv_msg *msg);
 265
 266        /* Place-holder for the data, don't make any assumptions about
 267           the size or existance of this, since it may change. */
 268        unsigned char   msg_data[IPMI_MAX_MSG_LENGTH];
 269};
 270
 271/* Allocate and free the receive message. */
 272void ipmi_free_recv_msg(struct ipmi_recv_msg *msg);
 273
 274struct ipmi_user_hndl
 275{
 276        /* Routine type to call when a message needs to be routed to
 277           the upper layer.  This will be called with some locks held,
 278           the only IPMI routines that can be called are ipmi_request
 279           and the alloc/free operations.  The handler_data is the
 280           variable supplied when the receive handler was registered. */
 281        void (*ipmi_recv_hndl)(struct ipmi_recv_msg *msg,
 282                               void                 *user_msg_data);
 283
 284        /* Called when the interface detects a watchdog pre-timeout.  If
 285           this is NULL, it will be ignored for the user. */
 286        void (*ipmi_watchdog_pretimeout)(void *handler_data);
 287};
 288
 289/* Create a new user of the IPMI layer on the given interface number. */
 290int ipmi_create_user(unsigned int          if_num,
 291                     struct ipmi_user_hndl *handler,
 292                     void                  *handler_data,
 293                     ipmi_user_t           *user);
 294
 295/* Destroy the given user of the IPMI layer.  Note that after this
 296   function returns, the system is guaranteed to not call any
 297   callbacks for the user.  Thus as long as you destroy all the users
 298   before you unload a module, you will be safe.  And if you destroy
 299   the users before you destroy the callback structures, it should be
 300   safe, too. */
 301int ipmi_destroy_user(ipmi_user_t user);
 302
 303/* Get the IPMI version of the BMC we are talking to. */
 304void ipmi_get_version(ipmi_user_t   user,
 305                      unsigned char *major,
 306                      unsigned char *minor);
 307
 308/* Set and get the slave address and LUN that we will use for our
 309   source messages.  Note that this affects the interface, not just
 310   this user, so it will affect all users of this interface.  This is
 311   so some initialization code can come in and do the OEM-specific
 312   things it takes to determine your address (if not the BMC) and set
 313   it for everyone else.  Note that each channel can have its own address. */
 314int ipmi_set_my_address(ipmi_user_t   user,
 315                        unsigned int  channel,
 316                        unsigned char address);
 317int ipmi_get_my_address(ipmi_user_t   user,
 318                        unsigned int  channel,
 319                        unsigned char *address);
 320int ipmi_set_my_LUN(ipmi_user_t   user,
 321                    unsigned int  channel,
 322                    unsigned char LUN);
 323int ipmi_get_my_LUN(ipmi_user_t   user,
 324                    unsigned int  channel,
 325                    unsigned char *LUN);
 326
 327/*
 328 * Like ipmi_request, but lets you specify the number of retries and
 329 * the retry time.  The retries is the number of times the message
 330 * will be resent if no reply is received.  If set to -1, the default
 331 * value will be used.  The retry time is the time in milliseconds
 332 * between retries.  If set to zero, the default value will be
 333 * used.
 334 *
 335 * Don't use this unless you *really* have to.  It's primarily for the
 336 * IPMI over LAN converter; since the LAN stuff does its own retries,
 337 * it makes no sense to do it here.  However, this can be used if you
 338 * have unusual requirements.
 339 */
 340int ipmi_request_settime(ipmi_user_t      user,
 341                         struct ipmi_addr *addr,
 342                         long             msgid,
 343                         struct kernel_ipmi_msg  *msg,
 344                         void             *user_msg_data,
 345                         int              priority,
 346                         int              max_retries,
 347                         unsigned int     retry_time_ms);
 348
 349/*
 350 * Like ipmi_request, but with messages supplied.  This will not
 351 * allocate any memory, and the messages may be statically allocated
 352 * (just make sure to do the "done" handling on them).  Note that this
 353 * is primarily for the watchdog timer, since it should be able to
 354 * send messages even if no memory is available.  This is subject to
 355 * change as the system changes, so don't use it unless you REALLY
 356 * have to.
 357 */
 358int ipmi_request_supply_msgs(ipmi_user_t          user,
 359                             struct ipmi_addr     *addr,
 360                             long                 msgid,
 361                             struct kernel_ipmi_msg *msg,
 362                             void                 *user_msg_data,
 363                             void                 *supplied_smi,
 364                             struct ipmi_recv_msg *supplied_recv,
 365                             int                  priority);
 366
 367/*
 368 * Poll the IPMI interface for the user.  This causes the IPMI code to
 369 * do an immediate check for information from the driver and handle
 370 * anything that is immediately pending.  This will not block in any
 371 * way.  This is useful if you need to implement polling from the user
 372 * for things like modifying the watchdog timeout when a panic occurs
 373 * or disabling the watchdog timer on a reboot.
 374 */
 375void ipmi_poll_interface(ipmi_user_t user);
 376
 377/*
 378 * When commands come in to the SMS, the user can register to receive
 379 * them.  Only one user can be listening on a specific netfn/cmd/chan tuple
 380 * at a time, you will get an EBUSY error if the command is already
 381 * registered.  If a command is received that does not have a user
 382 * registered, the driver will automatically return the proper
 383 * error.  Channels are specified as a bitfield, use IPMI_CHAN_ALL to
 384 * mean all channels.
 385 */
 386int ipmi_register_for_cmd(ipmi_user_t   user,
 387                          unsigned char netfn,
 388                          unsigned char cmd,
 389                          unsigned int  chans);
 390int ipmi_unregister_for_cmd(ipmi_user_t   user,
 391                            unsigned char netfn,
 392                            unsigned char cmd,
 393                            unsigned int  chans);
 394
 395/*
 396 * Go into a mode where the driver will not autonomously attempt to do
 397 * things with the interface.  It will still respond to attentions and
 398 * interrupts, and it will expect that commands will complete.  It
 399 * will not automatcially check for flags, events, or things of that
 400 * nature.
 401 *
 402 * This is primarily used for firmware upgrades.  The idea is that
 403 * when you go into firmware upgrade mode, you do this operation
 404 * and the driver will not attempt to do anything but what you tell
 405 * it or what the BMC asks for.
 406 *
 407 * Note that if you send a command that resets the BMC, the driver
 408 * will still expect a response from that command.  So the BMC should
 409 * reset itself *after* the response is sent.  Resetting before the
 410 * response is just silly.
 411 *
 412 * If in auto maintenance mode, the driver will automatically go into
 413 * maintenance mode for 30 seconds if it sees a cold reset, a warm
 414 * reset, or a firmware NetFN.  This means that code that uses only
 415 * firmware NetFN commands to do upgrades will work automatically
 416 * without change, assuming it sends a message every 30 seconds or
 417 * less.
 418 *
 419 * See the IPMI_MAINTENANCE_MODE_xxx defines for what the mode means.
 420 */
 421int ipmi_get_maintenance_mode(ipmi_user_t user);
 422int ipmi_set_maintenance_mode(ipmi_user_t user, int mode);
 423
 424/*
 425 * Allow run-to-completion mode to be set for the interface of
 426 * a specific user.
 427 */
 428void ipmi_user_set_run_to_completion(ipmi_user_t user, int val);
 429
 430/*
 431 * When the user is created, it will not receive IPMI events by
 432 * default.  The user must set this to TRUE to get incoming events.
 433 * The first user that sets this to TRUE will receive all events that
 434 * have been queued while no one was waiting for events.
 435 */
 436int ipmi_set_gets_events(ipmi_user_t user, int val);
 437
 438/*
 439 * Called when a new SMI is registered.  This will also be called on
 440 * every existing interface when a new watcher is registered with
 441 * ipmi_smi_watcher_register().
 442 */
 443struct ipmi_smi_watcher
 444{
 445        struct list_head link;
 446
 447        /* You must set the owner to the current module, if you are in
 448           a module (generally just set it to "THIS_MODULE"). */
 449        struct module *owner;
 450
 451        /* These two are called with read locks held for the interface
 452           the watcher list.  So you can add and remove users from the
 453           IPMI interface, send messages, etc., but you cannot add
 454           or remove SMI watchers or SMI interfaces. */
 455        void (*new_smi)(int if_num, struct device *dev);
 456        void (*smi_gone)(int if_num);
 457};
 458
 459int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher);
 460int ipmi_smi_watcher_unregister(struct ipmi_smi_watcher *watcher);
 461
 462/* The following are various helper functions for dealing with IPMI
 463   addresses. */
 464
 465/* Return the maximum length of an IPMI address given it's type. */
 466unsigned int ipmi_addr_length(int addr_type);
 467
 468/* Validate that the given IPMI address is valid. */
 469int ipmi_validate_addr(struct ipmi_addr *addr, int len);
 470
 471#endif /* __KERNEL__ */
 472
 473
 474/*
 475 * The userland interface
 476 */
 477
 478/*
 479 * The userland interface for the IPMI driver is a standard character
 480 * device, with each instance of an interface registered as a minor
 481 * number under the major character device.
 482 *
 483 * The read and write calls do not work, to get messages in and out
 484 * requires ioctl calls because of the complexity of the data.  select
 485 * and poll do work, so you can wait for input using the file
 486 * descriptor, you just can use read to get it.
 487 *
 488 * In general, you send a command down to the interface and receive
 489 * responses back.  You can use the msgid value to correlate commands
 490 * and responses, the driver will take care of figuring out which
 491 * incoming messages are for which command and find the proper msgid
 492 * value to report.  You will only receive reponses for commands you
 493 * send.  Asynchronous events, however, go to all open users, so you
 494 * must be ready to handle these (or ignore them if you don't care).
 495 *
 496 * The address type depends upon the channel type.  When talking
 497 * directly to the BMC (IPMC_BMC_CHANNEL), the address is ignored
 498 * (IPMI_UNUSED_ADDR_TYPE).  When talking to an IPMB channel, you must
 499 * supply a valid IPMB address with the addr_type set properly.
 500 *
 501 * When talking to normal channels, the driver takes care of the
 502 * details of formatting and sending messages on that channel.  You do
 503 * not, for instance, have to format a send command, you just send
 504 * whatever command you want to the channel, the driver will create
 505 * the send command, automatically issue receive command and get even
 506 * commands, and pass those up to the proper user.
 507 */
 508
 509
 510/* The magic IOCTL value for this interface. */
 511#define IPMI_IOC_MAGIC 'i'
 512
 513
 514/* Messages sent to the interface are this format. */
 515struct ipmi_req
 516{
 517        unsigned char __user *addr; /* Address to send the message to. */
 518        unsigned int  addr_len;
 519
 520        long    msgid; /* The sequence number for the message.  This
 521                          exact value will be reported back in the
 522                          response to this request if it is a command.
 523                          If it is a response, this will be used as
 524                          the sequence value for the response.  */
 525
 526        struct ipmi_msg msg;
 527};
 528/*
 529 * Send a message to the interfaces.  error values are:
 530 *   - EFAULT - an address supplied was invalid.
 531 *   - EINVAL - The address supplied was not valid, or the command
 532 *              was not allowed.
 533 *   - EMSGSIZE - The message to was too large.
 534 *   - ENOMEM - Buffers could not be allocated for the command.
 535 */
 536#define IPMICTL_SEND_COMMAND            _IOR(IPMI_IOC_MAGIC, 13,        \
 537                                             struct ipmi_req)
 538
 539/* Messages sent to the interface with timing parameters are this
 540   format. */
 541struct ipmi_req_settime
 542{
 543        struct ipmi_req req;
 544
 545        /* See ipmi_request_settime() above for details on these
 546           values. */
 547        int          retries;
 548        unsigned int retry_time_ms;
 549};
 550/*
 551 * Send a message to the interfaces with timing parameters.  error values
 552 * are:
 553 *   - EFAULT - an address supplied was invalid.
 554 *   - EINVAL - The address supplied was not valid, or the command
 555 *              was not allowed.
 556 *   - EMSGSIZE - The message to was too large.
 557 *   - ENOMEM - Buffers could not be allocated for the command.
 558 */
 559#define IPMICTL_SEND_COMMAND_SETTIME    _IOR(IPMI_IOC_MAGIC, 21,        \
 560                                             struct ipmi_req_settime)
 561
 562/* Messages received from the interface are this format. */
 563struct ipmi_recv
 564{
 565        int     recv_type; /* Is this a command, response or an
 566                              asyncronous event. */
 567
 568        unsigned char __user *addr;    /* Address the message was from is put
 569                                   here.  The caller must supply the
 570                                   memory. */
 571        unsigned int  addr_len; /* The size of the address buffer.
 572                                   The caller supplies the full buffer
 573                                   length, this value is updated to
 574                                   the actual message length when the
 575                                   message is received. */
 576
 577        long    msgid; /* The sequence number specified in the request
 578                          if this is a response.  If this is a command,
 579                          this will be the sequence number from the
 580                          command. */
 581
 582        struct ipmi_msg msg; /* The data field must point to a buffer.
 583                                The data_size field must be set to the
 584                                size of the message buffer.  The
 585                                caller supplies the full buffer
 586                                length, this value is updated to the
 587                                actual message length when the message
 588                                is received. */
 589};
 590
 591/*
 592 * Receive a message.  error values:
 593 *  - EAGAIN - no messages in the queue.
 594 *  - EFAULT - an address supplied was invalid.
 595 *  - EINVAL - The address supplied was not valid.
 596 *  - EMSGSIZE - The message to was too large to fit into the message buffer,
 597 *               the message will be left in the buffer. */
 598#define IPMICTL_RECEIVE_MSG             _IOWR(IPMI_IOC_MAGIC, 12,       \
 599                                              struct ipmi_recv)
 600
 601/*
 602 * Like RECEIVE_MSG, but if the message won't fit in the buffer, it
 603 * will truncate the contents instead of leaving the data in the
 604 * buffer.
 605 */
 606#define IPMICTL_RECEIVE_MSG_TRUNC       _IOWR(IPMI_IOC_MAGIC, 11,       \
 607                                              struct ipmi_recv)
 608
 609/* Register to get commands from other entities on this interface. */
 610struct ipmi_cmdspec
 611{
 612        unsigned char netfn;
 613        unsigned char cmd;
 614};
 615
 616/* 
 617 * Register to receive a specific command.  error values:
 618 *   - EFAULT - an address supplied was invalid.
 619 *   - EBUSY - The netfn/cmd supplied was already in use.
 620 *   - ENOMEM - could not allocate memory for the entry.
 621 */
 622#define IPMICTL_REGISTER_FOR_CMD        _IOR(IPMI_IOC_MAGIC, 14,        \
 623                                             struct ipmi_cmdspec)
 624/*
 625 * Unregister a regsitered command.  error values:
 626 *  - EFAULT - an address supplied was invalid.
 627 *  - ENOENT - The netfn/cmd was not found registered for this user.
 628 */
 629#define IPMICTL_UNREGISTER_FOR_CMD      _IOR(IPMI_IOC_MAGIC, 15,        \
 630                                             struct ipmi_cmdspec)
 631
 632/*
 633 * Register to get commands from other entities on specific channels.
 634 * This way, you can only listen on specific channels, or have messages
 635 * from some channels go to one place and other channels to someplace
 636 * else.  The chans field is a bitmask, (1 << channel) for each channel.
 637 * It may be IPMI_CHAN_ALL for all channels.
 638 */
 639struct ipmi_cmdspec_chans
 640{
 641        unsigned int netfn;
 642        unsigned int cmd;
 643        unsigned int chans;
 644};
 645
 646/*
 647 * Register to receive a specific command on specific channels.  error values:
 648 *   - EFAULT - an address supplied was invalid.
 649 *   - EBUSY - One of the netfn/cmd/chans supplied was already in use.
 650 *   - ENOMEM - could not allocate memory for the entry.
 651 */
 652#define IPMICTL_REGISTER_FOR_CMD_CHANS  _IOR(IPMI_IOC_MAGIC, 28,        \
 653                                             struct ipmi_cmdspec_chans)
 654/*
 655 * Unregister some netfn/cmd/chans.  error values:
 656 *  - EFAULT - an address supplied was invalid.
 657 *  - ENOENT - None of the netfn/cmd/chans were found registered for this user.
 658 */
 659#define IPMICTL_UNREGISTER_FOR_CMD_CHANS _IOR(IPMI_IOC_MAGIC, 29,       \
 660                                             struct ipmi_cmdspec_chans)
 661
 662/* 
 663 * Set whether this interface receives events.  Note that the first
 664 * user registered for events will get all pending events for the
 665 * interface.  error values:
 666 *  - EFAULT - an address supplied was invalid.
 667 */
 668#define IPMICTL_SET_GETS_EVENTS_CMD     _IOR(IPMI_IOC_MAGIC, 16, int)
 669
 670/*
 671 * Set and get the slave address and LUN that we will use for our
 672 * source messages.  Note that this affects the interface, not just
 673 * this user, so it will affect all users of this interface.  This is
 674 * so some initialization code can come in and do the OEM-specific
 675 * things it takes to determine your address (if not the BMC) and set
 676 * it for everyone else.  You should probably leave the LUN alone.
 677 */
 678struct ipmi_channel_lun_address_set
 679{
 680        unsigned short channel;
 681        unsigned char  value;
 682};
 683#define IPMICTL_SET_MY_CHANNEL_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 24, struct ipmi_channel_lun_address_set)
 684#define IPMICTL_GET_MY_CHANNEL_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 25, struct ipmi_channel_lun_address_set)
 685#define IPMICTL_SET_MY_CHANNEL_LUN_CMD     _IOR(IPMI_IOC_MAGIC, 26, struct ipmi_channel_lun_address_set)
 686#define IPMICTL_GET_MY_CHANNEL_LUN_CMD     _IOR(IPMI_IOC_MAGIC, 27, struct ipmi_channel_lun_address_set)
 687/* Legacy interfaces, these only set IPMB 0. */
 688#define IPMICTL_SET_MY_ADDRESS_CMD      _IOR(IPMI_IOC_MAGIC, 17, unsigned int)
 689#define IPMICTL_GET_MY_ADDRESS_CMD      _IOR(IPMI_IOC_MAGIC, 18, unsigned int)
 690#define IPMICTL_SET_MY_LUN_CMD          _IOR(IPMI_IOC_MAGIC, 19, unsigned int)
 691#define IPMICTL_GET_MY_LUN_CMD          _IOR(IPMI_IOC_MAGIC, 20, unsigned int)
 692
 693/*
 694 * Get/set the default timing values for an interface.  You shouldn't
 695 * generally mess with these.
 696 */
 697struct ipmi_timing_parms
 698{
 699        int          retries;
 700        unsigned int retry_time_ms;
 701};
 702#define IPMICTL_SET_TIMING_PARMS_CMD    _IOR(IPMI_IOC_MAGIC, 22, \
 703                                             struct ipmi_timing_parms)
 704#define IPMICTL_GET_TIMING_PARMS_CMD    _IOR(IPMI_IOC_MAGIC, 23, \
 705                                             struct ipmi_timing_parms)
 706
 707/*
 708 * Set the maintenance mode.  See ipmi_set_maintenance_mode() above
 709 * for a description of what this does.
 710 */
 711#define IPMICTL_GET_MAINTENANCE_MODE_CMD        _IOR(IPMI_IOC_MAGIC, 30, int)
 712#define IPMICTL_SET_MAINTENANCE_MODE_CMD        _IOW(IPMI_IOC_MAGIC, 31, int)
 713
 714#endif /* __LINUX_IPMI_H */
 715