source: svn/trunk/newcon3bcm2_21bu/toolchain/mips-linux-uclibc/include/linux/ipmi.h @ 2

Last change on this file since 2 was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 13.6 KB
Line 
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
39/*
40 * This file describes an interface to an IPMI driver.  You have to
41 * have a fairly good understanding of IPMI to use this, so go read
42 * the specs first before actually trying to do anything.
43 *
44 * With that said, this driver provides a multi-user interface to the
45 * IPMI driver, and it allows multiple IPMI physical interfaces below
46 * the driver.  The physical interfaces bind as a lower layer on the
47 * driver.  They appear as interfaces to the application using this
48 * interface.
49 *
50 * Multi-user means that multiple applications may use the driver,
51 * send commands, receive responses, etc.  The driver keeps track of
52 * commands the user sends and tracks the responses.  The responses
53 * will go back to the application that send the command.  If the
54 * response doesn't come back in time, the driver will return a
55 * timeout error response to the application.  Asynchronous events
56 * from the BMC event queue will go to all users bound to the driver.
57 * The incoming event queue in the BMC will automatically be flushed
58 * if it becomes full and it is queried once a second to see if
59 * anything is in it.  Incoming commands to the driver will get
60 * delivered as commands.
61 *
62 * This driver provides two main interfaces: one for in-kernel
63 * applications and another for userland applications.  The
64 * capabilities are basically the same for both interface, although
65 * the interfaces are somewhat different.  The stuff in the
66 * #ifdef KERNEL below is the in-kernel interface.  The userland
67 * interface is defined later in the file.  */
68
69
70
71/*
72 * This is an overlay for all the address types, so it's easy to
73 * determine the actual address type.  This is kind of like addresses
74 * work for sockets.
75 */
76#define IPMI_MAX_ADDR_SIZE 32
77struct ipmi_addr
78{
79         /* 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
92struct ipmi_system_interface_addr
93{
94        int           addr_type;
95        short         channel;
96        unsigned char lun;
97};
98
99/* An IPMB Address. */
100#define IPMI_IPMB_ADDR_TYPE             0x01
101/* Used for broadcast get device id as described in section 17.9 of the
102   IPMI 1.5 manual. */ 
103#define IPMI_IPMB_BROADCAST_ADDR_TYPE   0x41
104struct ipmi_ipmb_addr
105{
106        int           addr_type;
107        short         channel;
108        unsigned char slave_addr;
109        unsigned char lun;
110};
111
112/*
113 * A LAN Address.  This is an address to/from a LAN interface bridged
114 * by the BMC, not an address actually out on the LAN.
115 *
116 * A concious decision was made here to deviate slightly from the IPMI
117 * spec.  We do not use rqSWID and rsSWID like it shows in the
118 * message.  Instead, we use remote_SWID and local_SWID.  This means
119 * that any message (a request or response) from another device will
120 * always have exactly the same address.  If you didn't do this,
121 * requests and responses from the same device would have different
122 * addresses, and that's not too cool.
123 *
124 * In this address, the remote_SWID is always the SWID the remote
125 * message came from, or the SWID we are sending the message to.
126 * local_SWID is always our SWID.  Note that having our SWID in the
127 * message is a little weird, but this is required.
128 */
129#define IPMI_LAN_ADDR_TYPE              0x04
130struct ipmi_lan_addr
131{
132        int           addr_type;
133        short         channel;
134        unsigned char privilege;
135        unsigned char session_handle;
136        unsigned char remote_SWID;
137        unsigned char local_SWID;
138        unsigned char lun;
139};
140
141
142/*
143 * Channel for talking directly with the BMC.  When using this
144 * channel, This is for the system interface address type only.  FIXME
145 * - is this right, or should we use -1?
146 */
147#define IPMI_BMC_CHANNEL  0xf
148#define IPMI_NUM_CHANNELS 0x10
149
150
151/*
152 * A raw IPMI message without any addressing.  This covers both
153 * commands and responses.  The completion code is always the first
154 * byte of data in the response (as the spec shows the messages laid
155 * out).
156 */
157struct ipmi_msg
158{
159        unsigned char  netfn;
160        unsigned char  cmd;
161        unsigned short data_len;
162        unsigned char  *data;
163};
164
165/*
166 * Various defines that are useful for IPMI applications.
167 */
168#define IPMI_INVALID_CMD_COMPLETION_CODE        0xC1
169#define IPMI_TIMEOUT_COMPLETION_CODE            0xC3
170#define IPMI_UNKNOWN_ERR_COMPLETION_CODE        0xff
171
172
173/*
174 * Receive types for messages coming from the receive interface.  This
175 * is used for the receive in-kernel interface and in the receive
176 * IOCTL.
177 *
178 * The "IPMI_RESPONSE_RESPNOSE_TYPE" is a little strange sounding, but
179 * it allows you to get the message results when you send a response
180 * message.
181 */
182#define IPMI_RESPONSE_RECV_TYPE         1 /* A response to a command */
183#define IPMI_ASYNC_EVENT_RECV_TYPE      2 /* Something from the event queue */
184#define IPMI_CMD_RECV_TYPE              3 /* A command from somewhere else */
185#define IPMI_RESPONSE_RESPONSE_TYPE     4 /* The response for
186                                              a sent response, giving any
187                                              error status for sending the
188                                              response.  When you send a
189                                              response message, this will
190                                              be returned. */
191/* Note that async events and received commands do not have a completion
192   code as the first byte of the incoming data, unlike a response. */
193
194/*
195 * The userland interface
196 */
197
198/*
199 * The userland interface for the IPMI driver is a standard character
200 * device, with each instance of an interface registered as a minor
201 * number under the major character device.
202 *
203 * The read and write calls do not work, to get messages in and out
204 * requires ioctl calls because of the complexity of the data.  select
205 * and poll do work, so you can wait for input using the file
206 * descriptor, you just can use read to get it.
207 *
208 * In general, you send a command down to the interface and receive
209 * responses back.  You can use the msgid value to correlate commands
210 * and responses, the driver will take care of figuring out which
211 * incoming messages are for which command and find the proper msgid
212 * value to report.  You will only receive reponses for commands you
213 * send.  Asynchronous events, however, go to all open users, so you
214 * must be ready to handle these (or ignore them if you don't care).
215 *
216 * The address type depends upon the channel type.  When talking
217 * directly to the BMC (IPMC_BMC_CHANNEL), the address is ignored
218 * (IPMI_UNUSED_ADDR_TYPE).  When talking to an IPMB channel, you must
219 * supply a valid IPMB address with the addr_type set properly.
220 *
221 * When talking to normal channels, the driver takes care of the
222 * details of formatting and sending messages on that channel.  You do
223 * not, for instance, have to format a send command, you just send
224 * whatever command you want to the channel, the driver will create
225 * the send command, automatically issue receive command and get even
226 * commands, and pass those up to the proper user.
227 */
228
229
230/* The magic IOCTL value for this interface. */
231#define IPMI_IOC_MAGIC 'i'
232
233
234/* Messages sent to the interface are this format. */
235struct ipmi_req
236{
237        unsigned char *addr; /* Address to send the message to. */
238        unsigned int  addr_len;
239
240        long    msgid; /* The sequence number for the message.  This
241                          exact value will be reported back in the
242                          response to this request if it is a command.
243                          If it is a response, this will be used as
244                          the sequence value for the response.  */
245
246        struct ipmi_msg msg;
247};
248/*
249 * Send a message to the interfaces.  error values are:
250 *   - EFAULT - an address supplied was invalid.
251 *   - EINVAL - The address supplied was not valid, or the command
252 *              was not allowed.
253 *   - EMSGSIZE - The message to was too large.
254 *   - ENOMEM - Buffers could not be allocated for the command.
255 */
256#define IPMICTL_SEND_COMMAND            _IOR(IPMI_IOC_MAGIC, 13,        \
257                                             struct ipmi_req)
258
259/* Messages sent to the interface with timing parameters are this
260   format. */
261struct ipmi_req_settime
262{
263        struct ipmi_req req;
264
265        /* See ipmi_request_settime() above for details on these
266           values. */
267        int          retries;
268        unsigned int retry_time_ms;
269};
270/*
271 * Send a message to the interfaces with timing parameters.  error values
272 * are:
273 *   - EFAULT - an address supplied was invalid.
274 *   - EINVAL - The address supplied was not valid, or the command
275 *              was not allowed.
276 *   - EMSGSIZE - The message to was too large.
277 *   - ENOMEM - Buffers could not be allocated for the command.
278 */
279#define IPMICTL_SEND_COMMAND_SETTIME    _IOR(IPMI_IOC_MAGIC, 21,        \
280                                             struct ipmi_req_settime)
281
282/* Messages received from the interface are this format. */
283struct ipmi_recv
284{
285        int     recv_type; /* Is this a command, response or an
286                              asyncronous event. */
287
288        unsigned char *addr;    /* Address the message was from is put
289                                   here.  The caller must supply the
290                                   memory. */
291        unsigned int  addr_len; /* The size of the address buffer.
292                                   The caller supplies the full buffer
293                                   length, this value is updated to
294                                   the actual message length when the
295                                   message is received. */
296
297        long    msgid; /* The sequence number specified in the request
298                          if this is a response.  If this is a command,
299                          this will be the sequence number from the
300                          command. */
301
302        struct ipmi_msg msg; /* The data field must point to a buffer.
303                                The data_size field must be set to the
304                                size of the message buffer.  The
305                                caller supplies the full buffer
306                                length, this value is updated to the
307                                actual message length when the message
308                                is received. */
309};
310
311/*
312 * Receive a message.  error values:
313 *  - EAGAIN - no messages in the queue.
314 *  - EFAULT - an address supplied was invalid.
315 *  - EINVAL - The address supplied was not valid.
316 *  - EMSGSIZE - The message to was too large to fit into the message buffer,
317 *               the message will be left in the buffer. */
318#define IPMICTL_RECEIVE_MSG             _IOWR(IPMI_IOC_MAGIC, 12,       \
319                                              struct ipmi_recv)
320
321/*
322 * Like RECEIVE_MSG, but if the message won't fit in the buffer, it
323 * will truncate the contents instead of leaving the data in the
324 * buffer.
325 */
326#define IPMICTL_RECEIVE_MSG_TRUNC       _IOWR(IPMI_IOC_MAGIC, 11,       \
327                                              struct ipmi_recv)
328
329/* Register to get commands from other entities on this interface. */
330struct ipmi_cmdspec
331{
332        unsigned char netfn;
333        unsigned char cmd;
334};
335
336/*
337 * Register to receive a specific command.  error values:
338 *   - EFAULT - an address supplied was invalid.
339 *   - EBUSY - The netfn/cmd supplied was already in use.
340 *   - ENOMEM - could not allocate memory for the entry.
341 */
342#define IPMICTL_REGISTER_FOR_CMD        _IOR(IPMI_IOC_MAGIC, 14,        \
343                                             struct ipmi_cmdspec)
344/*
345 * Unregister a regsitered command.  error values:
346 *  - EFAULT - an address supplied was invalid.
347 *  - ENOENT - The netfn/cmd was not found registered for this user.
348 */
349#define IPMICTL_UNREGISTER_FOR_CMD      _IOR(IPMI_IOC_MAGIC, 15,        \
350                                             struct ipmi_cmdspec)
351
352/*
353 * Set whether this interface receives events.  Note that the first
354 * user registered for events will get all pending events for the
355 * interface.  error values:
356 *  - EFAULT - an address supplied was invalid.
357 */
358#define IPMICTL_SET_GETS_EVENTS_CMD     _IOR(IPMI_IOC_MAGIC, 16, int)
359
360/*
361 * Set and get the slave address and LUN that we will use for our
362 * source messages.  Note that this affects the interface, not just
363 * this user, so it will affect all users of this interface.  This is
364 * so some initialization code can come in and do the OEM-specific
365 * things it takes to determine your address (if not the BMC) and set
366 * it for everyone else.  You should probably leave the LUN alone.
367 */
368#define IPMICTL_SET_MY_ADDRESS_CMD      _IOR(IPMI_IOC_MAGIC, 17, unsigned int)
369#define IPMICTL_GET_MY_ADDRESS_CMD      _IOR(IPMI_IOC_MAGIC, 18, unsigned int)
370#define IPMICTL_SET_MY_LUN_CMD          _IOR(IPMI_IOC_MAGIC, 19, unsigned int)
371#define IPMICTL_GET_MY_LUN_CMD          _IOR(IPMI_IOC_MAGIC, 20, unsigned int)
372
373/*
374 * Get/set the default timing values for an interface.  You shouldn't
375 * generally mess with these.
376 */
377struct ipmi_timing_parms
378{
379        int          retries;
380        unsigned int retry_time_ms;
381};
382#define IPMICTL_SET_TIMING_PARMS_CMD    _IOR(IPMI_IOC_MAGIC, 22, \
383                                             struct ipmi_timing_parms)
384#define IPMICTL_GET_TIMING_PARMS_CMD    _IOR(IPMI_IOC_MAGIC, 23, \
385                                             struct ipmi_timing_parms)
386
387#endif /* __LINUX_IPMI_H */
Note: See TracBrowser for help on using the repository browser.