aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/ipmi.h153
-rw-r--r--include/linux/ipmi_smi.h129
2 files changed, 165 insertions, 117 deletions
diff --git a/include/linux/ipmi.h b/include/linux/ipmi.h
index 8b0626cec980..41f5c086f670 100644
--- a/include/linux/ipmi.h
+++ b/include/linux/ipmi.h
@@ -23,8 +23,10 @@
23struct module; 23struct module;
24struct device; 24struct device;
25 25
26/* Opaque type for a IPMI message user. One of these is needed to 26/*
27 send and receive messages. */ 27 * Opaque type for a IPMI message user. One of these is needed to
28 * send and receive messages.
29 */
28typedef struct ipmi_user *ipmi_user_t; 30typedef struct ipmi_user *ipmi_user_t;
29 31
30/* 32/*
@@ -37,28 +39,36 @@ typedef struct ipmi_user *ipmi_user_t;
37struct ipmi_recv_msg { 39struct ipmi_recv_msg {
38 struct list_head link; 40 struct list_head link;
39 41
40 /* The type of message as defined in the "Receive Types" 42 /*
41 defines above. */ 43 * The type of message as defined in the "Receive Types"
44 * defines above.
45 */
42 int recv_type; 46 int recv_type;
43 47
44 ipmi_user_t user; 48 struct ipmi_user *user;
45 struct ipmi_addr addr; 49 struct ipmi_addr addr;
46 long msgid; 50 long msgid;
47 struct kernel_ipmi_msg msg; 51 struct kernel_ipmi_msg msg;
48 52
49 /* The user_msg_data is the data supplied when a message was 53 /*
50 sent, if this is a response to a sent message. If this is 54 * The user_msg_data is the data supplied when a message was
51 not a response to a sent message, then user_msg_data will 55 * sent, if this is a response to a sent message. If this is
52 be NULL. If the user above is NULL, then this will be the 56 * not a response to a sent message, then user_msg_data will
53 intf. */ 57 * be NULL. If the user above is NULL, then this will be the
58 * intf.
59 */
54 void *user_msg_data; 60 void *user_msg_data;
55 61
56 /* Call this when done with the message. It will presumably free 62 /*
57 the message and do any other necessary cleanup. */ 63 * Call this when done with the message. It will presumably free
64 * the message and do any other necessary cleanup.
65 */
58 void (*done)(struct ipmi_recv_msg *msg); 66 void (*done)(struct ipmi_recv_msg *msg);
59 67
60 /* Place-holder for the data, don't make any assumptions about 68 /*
61 the size or existence of this, since it may change. */ 69 * Place-holder for the data, don't make any assumptions about
70 * the size or existence of this, since it may change.
71 */
62 unsigned char msg_data[IPMI_MAX_MSG_LENGTH]; 72 unsigned char msg_data[IPMI_MAX_MSG_LENGTH];
63}; 73};
64 74
@@ -66,54 +76,77 @@ struct ipmi_recv_msg {
66void ipmi_free_recv_msg(struct ipmi_recv_msg *msg); 76void ipmi_free_recv_msg(struct ipmi_recv_msg *msg);
67 77
68struct ipmi_user_hndl { 78struct ipmi_user_hndl {
69 /* Routine type to call when a message needs to be routed to 79 /*
70 the upper layer. This will be called with some locks held, 80 * Routine type to call when a message needs to be routed to
71 the only IPMI routines that can be called are ipmi_request 81 * the upper layer. This will be called with some locks held,
72 and the alloc/free operations. The handler_data is the 82 * the only IPMI routines that can be called are ipmi_request
73 variable supplied when the receive handler was registered. */ 83 * and the alloc/free operations. The handler_data is the
84 * variable supplied when the receive handler was registered.
85 */
74 void (*ipmi_recv_hndl)(struct ipmi_recv_msg *msg, 86 void (*ipmi_recv_hndl)(struct ipmi_recv_msg *msg,
75 void *user_msg_data); 87 void *user_msg_data);
76 88
77 /* Called when the interface detects a watchdog pre-timeout. If 89 /*
78 this is NULL, it will be ignored for the user. */ 90 * Called when the interface detects a watchdog pre-timeout. If
91 * this is NULL, it will be ignored for the user.
92 */
79 void (*ipmi_watchdog_pretimeout)(void *handler_data); 93 void (*ipmi_watchdog_pretimeout)(void *handler_data);
94
95 /*
96 * If not NULL, called at panic time after the interface has
97 * been set up to handle run to completion.
98 */
99 void (*ipmi_panic_handler)(void *handler_data);
100
101 /*
102 * Called when the interface has been removed. After this returns
103 * the user handle will be invalid. The interface may or may
104 * not be usable when this is called, but it will return errors
105 * if it is not usable.
106 */
107 void (*shutdown)(void *handler_data);
80}; 108};
81 109
82/* Create a new user of the IPMI layer on the given interface number. */ 110/* Create a new user of the IPMI layer on the given interface number. */
83int ipmi_create_user(unsigned int if_num, 111int ipmi_create_user(unsigned int if_num,
84 const struct ipmi_user_hndl *handler, 112 const struct ipmi_user_hndl *handler,
85 void *handler_data, 113 void *handler_data,
86 ipmi_user_t *user); 114 struct ipmi_user **user);
87 115
88/* Destroy the given user of the IPMI layer. Note that after this 116/*
89 function returns, the system is guaranteed to not call any 117 * Destroy the given user of the IPMI layer. Note that after this
90 callbacks for the user. Thus as long as you destroy all the users 118 * function returns, the system is guaranteed to not call any
91 before you unload a module, you will be safe. And if you destroy 119 * callbacks for the user. Thus as long as you destroy all the users
92 the users before you destroy the callback structures, it should be 120 * before you unload a module, you will be safe. And if you destroy
93 safe, too. */ 121 * the users before you destroy the callback structures, it should be
94int ipmi_destroy_user(ipmi_user_t user); 122 * safe, too.
123 */
124int ipmi_destroy_user(struct ipmi_user *user);
95 125
96/* Get the IPMI version of the BMC we are talking to. */ 126/* Get the IPMI version of the BMC we are talking to. */
97int ipmi_get_version(ipmi_user_t user, 127int ipmi_get_version(struct ipmi_user *user,
98 unsigned char *major, 128 unsigned char *major,
99 unsigned char *minor); 129 unsigned char *minor);
100 130
101/* Set and get the slave address and LUN that we will use for our 131/*
102 source messages. Note that this affects the interface, not just 132 * Set and get the slave address and LUN that we will use for our
103 this user, so it will affect all users of this interface. This is 133 * source messages. Note that this affects the interface, not just
104 so some initialization code can come in and do the OEM-specific 134 * this user, so it will affect all users of this interface. This is
105 things it takes to determine your address (if not the BMC) and set 135 * so some initialization code can come in and do the OEM-specific
106 it for everyone else. Note that each channel can have its own address. */ 136 * things it takes to determine your address (if not the BMC) and set
107int ipmi_set_my_address(ipmi_user_t user, 137 * it for everyone else. Note that each channel can have its own
138 * address.
139 */
140int ipmi_set_my_address(struct ipmi_user *user,
108 unsigned int channel, 141 unsigned int channel,
109 unsigned char address); 142 unsigned char address);
110int ipmi_get_my_address(ipmi_user_t user, 143int ipmi_get_my_address(struct ipmi_user *user,
111 unsigned int channel, 144 unsigned int channel,
112 unsigned char *address); 145 unsigned char *address);
113int ipmi_set_my_LUN(ipmi_user_t user, 146int ipmi_set_my_LUN(struct ipmi_user *user,
114 unsigned int channel, 147 unsigned int channel,
115 unsigned char LUN); 148 unsigned char LUN);
116int ipmi_get_my_LUN(ipmi_user_t user, 149int ipmi_get_my_LUN(struct ipmi_user *user,
117 unsigned int channel, 150 unsigned int channel,
118 unsigned char *LUN); 151 unsigned char *LUN);
119 152
@@ -130,7 +163,7 @@ int ipmi_get_my_LUN(ipmi_user_t user,
130 * it makes no sense to do it here. However, this can be used if you 163 * it makes no sense to do it here. However, this can be used if you
131 * have unusual requirements. 164 * have unusual requirements.
132 */ 165 */
133int ipmi_request_settime(ipmi_user_t user, 166int ipmi_request_settime(struct ipmi_user *user,
134 struct ipmi_addr *addr, 167 struct ipmi_addr *addr,
135 long msgid, 168 long msgid,
136 struct kernel_ipmi_msg *msg, 169 struct kernel_ipmi_msg *msg,
@@ -148,7 +181,7 @@ int ipmi_request_settime(ipmi_user_t user,
148 * change as the system changes, so don't use it unless you REALLY 181 * change as the system changes, so don't use it unless you REALLY
149 * have to. 182 * have to.
150 */ 183 */
151int ipmi_request_supply_msgs(ipmi_user_t user, 184int ipmi_request_supply_msgs(struct ipmi_user *user,
152 struct ipmi_addr *addr, 185 struct ipmi_addr *addr,
153 long msgid, 186 long msgid,
154 struct kernel_ipmi_msg *msg, 187 struct kernel_ipmi_msg *msg,
@@ -164,7 +197,7 @@ int ipmi_request_supply_msgs(ipmi_user_t user,
164 * way. This is useful if you need to spin waiting for something to 197 * way. This is useful if you need to spin waiting for something to
165 * happen in the IPMI driver. 198 * happen in the IPMI driver.
166 */ 199 */
167void ipmi_poll_interface(ipmi_user_t user); 200void ipmi_poll_interface(struct ipmi_user *user);
168 201
169/* 202/*
170 * When commands come in to the SMS, the user can register to receive 203 * When commands come in to the SMS, the user can register to receive
@@ -175,11 +208,11 @@ void ipmi_poll_interface(ipmi_user_t user);
175 * error. Channels are specified as a bitfield, use IPMI_CHAN_ALL to 208 * error. Channels are specified as a bitfield, use IPMI_CHAN_ALL to
176 * mean all channels. 209 * mean all channels.
177 */ 210 */
178int ipmi_register_for_cmd(ipmi_user_t user, 211int ipmi_register_for_cmd(struct ipmi_user *user,
179 unsigned char netfn, 212 unsigned char netfn,
180 unsigned char cmd, 213 unsigned char cmd,
181 unsigned int chans); 214 unsigned int chans);
182int ipmi_unregister_for_cmd(ipmi_user_t user, 215int ipmi_unregister_for_cmd(struct ipmi_user *user,
183 unsigned char netfn, 216 unsigned char netfn,
184 unsigned char cmd, 217 unsigned char cmd,
185 unsigned int chans); 218 unsigned int chans);
@@ -210,8 +243,8 @@ int ipmi_unregister_for_cmd(ipmi_user_t user,
210 * 243 *
211 * See the IPMI_MAINTENANCE_MODE_xxx defines for what the mode means. 244 * See the IPMI_MAINTENANCE_MODE_xxx defines for what the mode means.
212 */ 245 */
213int ipmi_get_maintenance_mode(ipmi_user_t user); 246int ipmi_get_maintenance_mode(struct ipmi_user *user);
214int ipmi_set_maintenance_mode(ipmi_user_t user, int mode); 247int ipmi_set_maintenance_mode(struct ipmi_user *user, int mode);
215 248
216/* 249/*
217 * When the user is created, it will not receive IPMI events by 250 * When the user is created, it will not receive IPMI events by
@@ -219,7 +252,7 @@ int ipmi_set_maintenance_mode(ipmi_user_t user, int mode);
219 * The first user that sets this to TRUE will receive all events that 252 * The first user that sets this to TRUE will receive all events that
220 * have been queued while no one was waiting for events. 253 * have been queued while no one was waiting for events.
221 */ 254 */
222int ipmi_set_gets_events(ipmi_user_t user, bool val); 255int ipmi_set_gets_events(struct ipmi_user *user, bool val);
223 256
224/* 257/*
225 * Called when a new SMI is registered. This will also be called on 258 * Called when a new SMI is registered. This will also be called on
@@ -229,14 +262,18 @@ int ipmi_set_gets_events(ipmi_user_t user, bool val);
229struct ipmi_smi_watcher { 262struct ipmi_smi_watcher {
230 struct list_head link; 263 struct list_head link;
231 264
232 /* You must set the owner to the current module, if you are in 265 /*
233 a module (generally just set it to "THIS_MODULE"). */ 266 * You must set the owner to the current module, if you are in
267 * a module (generally just set it to "THIS_MODULE").
268 */
234 struct module *owner; 269 struct module *owner;
235 270
236 /* These two are called with read locks held for the interface 271 /*
237 the watcher list. So you can add and remove users from the 272 * These two are called with read locks held for the interface
238 IPMI interface, send messages, etc., but you cannot add 273 * the watcher list. So you can add and remove users from the
239 or remove SMI watchers or SMI interfaces. */ 274 * IPMI interface, send messages, etc., but you cannot add
275 * or remove SMI watchers or SMI interfaces.
276 */
240 void (*new_smi)(int if_num, struct device *dev); 277 void (*new_smi)(int if_num, struct device *dev);
241 void (*smi_gone)(int if_num); 278 void (*smi_gone)(int if_num);
242}; 279};
@@ -244,8 +281,10 @@ struct ipmi_smi_watcher {
244int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher); 281int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher);
245int ipmi_smi_watcher_unregister(struct ipmi_smi_watcher *watcher); 282int ipmi_smi_watcher_unregister(struct ipmi_smi_watcher *watcher);
246 283
247/* The following are various helper functions for dealing with IPMI 284/*
248 addresses. */ 285 * The following are various helper functions for dealing with IPMI
286 * addresses.
287 */
249 288
250/* Return the maximum length of an IPMI address given it's type. */ 289/* Return the maximum length of an IPMI address given it's type. */
251unsigned int ipmi_addr_length(int addr_type); 290unsigned int ipmi_addr_length(int addr_type);
@@ -291,7 +330,7 @@ struct ipmi_smi_info {
291 union ipmi_smi_info_union addr_info; 330 union ipmi_smi_info_union addr_info;
292}; 331};
293 332
294/* This is to get the private info of ipmi_smi_t */ 333/* This is to get the private info of struct ipmi_smi */
295extern int ipmi_get_smi_info(int if_num, struct ipmi_smi_info *data); 334extern int ipmi_get_smi_info(int if_num, struct ipmi_smi_info *data);
296 335
297#endif /* __LINUX_IPMI_H */ 336#endif /* __LINUX_IPMI_H */
diff --git a/include/linux/ipmi_smi.h b/include/linux/ipmi_smi.h
index af457b5a689e..7d5fd38d5282 100644
--- a/include/linux/ipmi_smi.h
+++ b/include/linux/ipmi_smi.h
@@ -22,8 +22,10 @@
22 22
23struct device; 23struct device;
24 24
25/* This files describes the interface for IPMI system management interface 25/*
26 drivers to bind into the IPMI message handler. */ 26 * This files describes the interface for IPMI system management interface
27 * drivers to bind into the IPMI message handler.
28 */
27 29
28/* Structure for the low-level drivers. */ 30/* Structure for the low-level drivers. */
29typedef struct ipmi_smi *ipmi_smi_t; 31typedef struct ipmi_smi *ipmi_smi_t;
@@ -61,12 +63,20 @@ struct ipmi_smi_msg {
61struct ipmi_smi_handlers { 63struct ipmi_smi_handlers {
62 struct module *owner; 64 struct module *owner;
63 65
64 /* The low-level interface cannot start sending messages to 66 /*
65 the upper layer until this function is called. This may 67 * The low-level interface cannot start sending messages to
66 not be NULL, the lower layer must take the interface from 68 * the upper layer until this function is called. This may
67 this call. */ 69 * not be NULL, the lower layer must take the interface from
68 int (*start_processing)(void *send_info, 70 * this call.
69 ipmi_smi_t new_intf); 71 */
72 int (*start_processing)(void *send_info,
73 struct ipmi_smi *new_intf);
74
75 /*
76 * When called, the low-level interface should disable all
77 * processing, it should be complete shut down when it returns.
78 */
79 void (*shutdown)(void *send_info);
70 80
71 /* 81 /*
72 * Get the detailed private info of the low level interface and store 82 * Get the detailed private info of the low level interface and store
@@ -75,25 +85,31 @@ struct ipmi_smi_handlers {
75 */ 85 */
76 int (*get_smi_info)(void *send_info, struct ipmi_smi_info *data); 86 int (*get_smi_info)(void *send_info, struct ipmi_smi_info *data);
77 87
78 /* Called to enqueue an SMI message to be sent. This 88 /*
79 operation is not allowed to fail. If an error occurs, it 89 * Called to enqueue an SMI message to be sent. This
80 should report back the error in a received message. It may 90 * operation is not allowed to fail. If an error occurs, it
81 do this in the current call context, since no write locks 91 * should report back the error in a received message. It may
82 are held when this is run. Message are delivered one at 92 * do this in the current call context, since no write locks
83 a time by the message handler, a new message will not be 93 * are held when this is run. Message are delivered one at
84 delivered until the previous message is returned. */ 94 * a time by the message handler, a new message will not be
95 * delivered until the previous message is returned.
96 */
85 void (*sender)(void *send_info, 97 void (*sender)(void *send_info,
86 struct ipmi_smi_msg *msg); 98 struct ipmi_smi_msg *msg);
87 99
88 /* Called by the upper layer to request that we try to get 100 /*
89 events from the BMC we are attached to. */ 101 * Called by the upper layer to request that we try to get
102 * events from the BMC we are attached to.
103 */
90 void (*request_events)(void *send_info); 104 void (*request_events)(void *send_info);
91 105
92 /* Called by the upper layer when some user requires that the 106 /*
93 interface watch for events, received messages, watchdog 107 * Called by the upper layer when some user requires that the
94 pretimeouts, or not. Used by the SMI to know if it should 108 * interface watch for events, received messages, watchdog
95 watch for these. This may be NULL if the SMI does not 109 * pretimeouts, or not. Used by the SMI to know if it should
96 implement it. */ 110 * watch for these. This may be NULL if the SMI does not
111 * implement it.
112 */
97 void (*set_need_watch)(void *send_info, bool enable); 113 void (*set_need_watch)(void *send_info, bool enable);
98 114
99 /* 115 /*
@@ -101,30 +117,29 @@ struct ipmi_smi_handlers {
101 */ 117 */
102 void (*flush_messages)(void *send_info); 118 void (*flush_messages)(void *send_info);
103 119
104 /* Called when the interface should go into "run to 120 /*
105 completion" mode. If this call sets the value to true, the 121 * Called when the interface should go into "run to
106 interface should make sure that all messages are flushed 122 * completion" mode. If this call sets the value to true, the
107 out and that none are pending, and any new requests are run 123 * interface should make sure that all messages are flushed
108 to completion immediately. */ 124 * out and that none are pending, and any new requests are run
125 * to completion immediately.
126 */
109 void (*set_run_to_completion)(void *send_info, bool run_to_completion); 127 void (*set_run_to_completion)(void *send_info, bool run_to_completion);
110 128
111 /* Called to poll for work to do. This is so upper layers can 129 /*
112 poll for operations during things like crash dumps. */ 130 * Called to poll for work to do. This is so upper layers can
131 * poll for operations during things like crash dumps.
132 */
113 void (*poll)(void *send_info); 133 void (*poll)(void *send_info);
114 134
115 /* Enable/disable firmware maintenance mode. Note that this 135 /*
116 is *not* the modes defined, this is simply an on/off 136 * Enable/disable firmware maintenance mode. Note that this
117 setting. The message handler does the mode handling. Note 137 * is *not* the modes defined, this is simply an on/off
118 that this is called from interrupt context, so it cannot 138 * setting. The message handler does the mode handling. Note
119 block. */ 139 * that this is called from interrupt context, so it cannot
140 * block.
141 */
120 void (*set_maintenance_mode)(void *send_info, bool enable); 142 void (*set_maintenance_mode)(void *send_info, bool enable);
121
122 /* Tell the handler that we are using it/not using it. The
123 message handler get the modules that this handler belongs
124 to; this function lets the SMI claim any modules that it
125 uses. These may be NULL if this is not required. */
126 int (*inc_usecount)(void *send_info);
127 void (*dec_usecount)(void *send_info);
128}; 143};
129 144
130struct ipmi_device_id { 145struct ipmi_device_id {
@@ -143,7 +158,8 @@ struct ipmi_device_id {
143#define ipmi_version_major(v) ((v)->ipmi_version & 0xf) 158#define ipmi_version_major(v) ((v)->ipmi_version & 0xf)
144#define ipmi_version_minor(v) ((v)->ipmi_version >> 4) 159#define ipmi_version_minor(v) ((v)->ipmi_version >> 4)
145 160
146/* Take a pointer to an IPMI response and extract device id information from 161/*
162 * Take a pointer to an IPMI response and extract device id information from
147 * it. @netfn is in the IPMI_NETFN_ format, so may need to be shifted from 163 * it. @netfn is in the IPMI_NETFN_ format, so may need to be shifted from
148 * a SI response. 164 * a SI response.
149 */ 165 */
@@ -187,12 +203,14 @@ static inline int ipmi_demangle_device_id(uint8_t netfn, uint8_t cmd,
187 return 0; 203 return 0;
188} 204}
189 205
190/* Add a low-level interface to the IPMI driver. Note that if the 206/*
191 interface doesn't know its slave address, it should pass in zero. 207 * Add a low-level interface to the IPMI driver. Note that if the
192 The low-level interface should not deliver any messages to the 208 * interface doesn't know its slave address, it should pass in zero.
193 upper layer until the start_processing() function in the handlers 209 * The low-level interface should not deliver any messages to the
194 is called, and the lower layer must get the interface from that 210 * upper layer until the start_processing() function in the handlers
195 call. */ 211 * is called, and the lower layer must get the interface from that
212 * call.
213 */
196int ipmi_register_smi(const struct ipmi_smi_handlers *handlers, 214int ipmi_register_smi(const struct ipmi_smi_handlers *handlers,
197 void *send_info, 215 void *send_info,
198 struct device *dev, 216 struct device *dev,
@@ -202,7 +220,7 @@ int ipmi_register_smi(const struct ipmi_smi_handlers *handlers,
202 * Remove a low-level interface from the IPMI driver. This will 220 * Remove a low-level interface from the IPMI driver. This will
203 * return an error if the interface is still in use by a user. 221 * return an error if the interface is still in use by a user.
204 */ 222 */
205int ipmi_unregister_smi(ipmi_smi_t intf); 223void ipmi_unregister_smi(struct ipmi_smi *intf);
206 224
207/* 225/*
208 * The lower layer reports received messages through this interface. 226 * The lower layer reports received messages through this interface.
@@ -210,11 +228,11 @@ int ipmi_unregister_smi(ipmi_smi_t intf);
210 * the lower layer gets an error sending a message, it should format 228 * the lower layer gets an error sending a message, it should format
211 * an error response in the message response. 229 * an error response in the message response.
212 */ 230 */
213void ipmi_smi_msg_received(ipmi_smi_t intf, 231void ipmi_smi_msg_received(struct ipmi_smi *intf,
214 struct ipmi_smi_msg *msg); 232 struct ipmi_smi_msg *msg);
215 233
216/* The lower layer received a watchdog pre-timeout on interface. */ 234/* The lower layer received a watchdog pre-timeout on interface. */
217void ipmi_smi_watchdog_pretimeout(ipmi_smi_t intf); 235void ipmi_smi_watchdog_pretimeout(struct ipmi_smi *intf);
218 236
219struct ipmi_smi_msg *ipmi_alloc_smi_msg(void); 237struct ipmi_smi_msg *ipmi_alloc_smi_msg(void);
220static inline void ipmi_free_smi_msg(struct ipmi_smi_msg *msg) 238static inline void ipmi_free_smi_msg(struct ipmi_smi_msg *msg)
@@ -222,13 +240,4 @@ static inline void ipmi_free_smi_msg(struct ipmi_smi_msg *msg)
222 msg->done(msg); 240 msg->done(msg);
223} 241}
224 242
225#ifdef CONFIG_IPMI_PROC_INTERFACE
226/* Allow the lower layer to add things to the proc filesystem
227 directory for this interface. Note that the entry will
228 automatically be dstroyed when the interface is destroyed. */
229int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
230 const struct file_operations *proc_ops,
231 void *data);
232#endif
233
234#endif /* __LINUX_IPMI_SMI_H */ 243#endif /* __LINUX_IPMI_SMI_H */