aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/ipmi_smi.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/ipmi_smi.h')
-rw-r--r--include/linux/ipmi_smi.h156
1 files changed, 156 insertions, 0 deletions
diff --git a/include/linux/ipmi_smi.h b/include/linux/ipmi_smi.h
new file mode 100644
index 000000000000..e36ee157ad67
--- /dev/null
+++ b/include/linux/ipmi_smi.h
@@ -0,0 +1,156 @@
1/*
2 * ipmi_smi.h
3 *
4 * MontaVista IPMI system management 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_SMI_H
35#define __LINUX_IPMI_SMI_H
36
37#include <linux/ipmi_msgdefs.h>
38#include <linux/proc_fs.h>
39#include <linux/module.h>
40
41/* This files describes the interface for IPMI system management interface
42 drivers to bind into the IPMI message handler. */
43
44/* Structure for the low-level drivers. */
45typedef struct ipmi_smi *ipmi_smi_t;
46
47/*
48 * Messages to/from the lower layer. The smi interface will take one
49 * of these to send. After the send has occurred and a response has
50 * been received, it will report this same data structure back up to
51 * the upper layer. If an error occurs, it should fill in the
52 * response with an error code in the completion code location. When
53 * asynchronous data is received, one of these is allocated, the
54 * data_size is set to zero and the response holds the data from the
55 * get message or get event command that the interface initiated.
56 * Note that it is the interfaces responsibility to detect
57 * asynchronous data and messages and request them from the
58 * interface.
59 */
60struct ipmi_smi_msg
61{
62 struct list_head link;
63
64 long msgid;
65 void *user_data;
66
67 int data_size;
68 unsigned char data[IPMI_MAX_MSG_LENGTH];
69
70 int rsp_size;
71 unsigned char rsp[IPMI_MAX_MSG_LENGTH];
72
73 /* Will be called when the system is done with the message
74 (presumably to free it). */
75 void (*done)(struct ipmi_smi_msg *msg);
76};
77
78struct ipmi_smi_handlers
79{
80 struct module *owner;
81
82 /* Called to enqueue an SMI message to be sent. This
83 operation is not allowed to fail. If an error occurs, it
84 should report back the error in a received message. It may
85 do this in the current call context, since no write locks
86 are held when this is run. If the priority is > 0, the
87 message will go into a high-priority queue and be sent
88 first. Otherwise, it goes into a normal-priority queue. */
89 void (*sender)(void *send_info,
90 struct ipmi_smi_msg *msg,
91 int priority);
92
93 /* Called by the upper layer to request that we try to get
94 events from the BMC we are attached to. */
95 void (*request_events)(void *send_info);
96
97 /* Called when the interface should go into "run to
98 completion" mode. If this call sets the value to true, the
99 interface should make sure that all messages are flushed
100 out and that none are pending, and any new requests are run
101 to completion immediately. */
102 void (*set_run_to_completion)(void *send_info, int run_to_completion);
103
104 /* Called to poll for work to do. This is so upper layers can
105 poll for operations during things like crash dumps. */
106 void (*poll)(void *send_info);
107
108 /* Tell the handler that we are using it/not using it. The
109 message handler get the modules that this handler belongs
110 to; this function lets the SMI claim any modules that it
111 uses. These may be NULL if this is not required. */
112 int (*inc_usecount)(void *send_info);
113 void (*dec_usecount)(void *send_info);
114};
115
116/* Add a low-level interface to the IPMI driver. Note that if the
117 interface doesn't know its slave address, it should pass in zero. */
118int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
119 void *send_info,
120 unsigned char version_major,
121 unsigned char version_minor,
122 unsigned char slave_addr,
123 ipmi_smi_t *intf);
124
125/*
126 * Remove a low-level interface from the IPMI driver. This will
127 * return an error if the interface is still in use by a user.
128 */
129int ipmi_unregister_smi(ipmi_smi_t intf);
130
131/*
132 * The lower layer reports received messages through this interface.
133 * The data_size should be zero if this is an asyncronous message. If
134 * the lower layer gets an error sending a message, it should format
135 * an error response in the message response.
136 */
137void ipmi_smi_msg_received(ipmi_smi_t intf,
138 struct ipmi_smi_msg *msg);
139
140/* The lower layer received a watchdog pre-timeout on interface. */
141void ipmi_smi_watchdog_pretimeout(ipmi_smi_t intf);
142
143struct ipmi_smi_msg *ipmi_alloc_smi_msg(void);
144static inline void ipmi_free_smi_msg(struct ipmi_smi_msg *msg)
145{
146 msg->done(msg);
147}
148
149/* Allow the lower layer to add things to the proc filesystem
150 directory for this interface. Note that the entry will
151 automatically be dstroyed when the interface is destroyed. */
152int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
153 read_proc_t *read_proc, write_proc_t *write_proc,
154 void *data, struct module *owner);
155
156#endif /* __LINUX_IPMI_SMI_H */