4 * Incoming and outgoing message routing for an IPMI interface.
6 * Author: MontaVista Software, Inc.
7 * Corey Minyard <minyard@mvista.com>
10 * Copyright 2002 MontaVista Software Inc.
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.
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.
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.
34 #include <linux/config.h>
35 #include <linux/module.h>
36 #include <linux/errno.h>
37 #include <asm/system.h>
38 #include <linux/sched.h>
39 #include <linux/poll.h>
40 #include <linux/spinlock.h>
41 #include <linux/rwsem.h>
42 #include <linux/slab.h>
43 #include <linux/ipmi.h>
44 #include <linux/ipmi_smi.h>
45 #include <linux/notifier.h>
46 #include <linux/init.h>
47 #include <linux/proc_fs.h>
49 #define PFX "IPMI message handler: "
51 #define IPMI_DRIVER_VERSION "36.0"
53 static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void);
54 static int ipmi_init_msghandler(void);
56 static int initialized = 0;
59 struct proc_dir_entry *proc_ipmi_root = NULL;
60 #endif /* CONFIG_PROC_FS */
62 #define MAX_EVENTS_IN_QUEUE 25
64 /* Don't let a message sit in a queue forever, always time it with at lest
65 the max message timer. This is in milliseconds. */
66 #define MAX_MSG_TIMEOUT 60000
70 struct list_head link;
72 /* The upper layer that handles receive messages. */
73 struct ipmi_user_hndl *handler;
76 /* The interface this user is bound to. */
79 /* Does this interface receive IPMI events? */
85 struct list_head link;
94 unsigned int inuse : 1;
95 unsigned int broadcast : 1;
97 unsigned long timeout;
98 unsigned long orig_timeout;
99 unsigned int retries_left;
101 /* To verify on an incoming send message response that this is
102 the message that the response is for, we keep a sequence id
103 and increment it every time we send a message. */
106 /* This is held so we can properly respond to the message on a
107 timeout, and it is used to hold the temporary data for
108 retransmission, too. */
109 struct ipmi_recv_msg *recv_msg;
112 /* Store the information in a msgid (long) to allow us to find a
113 sequence table entry from the msgid. */
114 #define STORE_SEQ_IN_MSGID(seq, seqid) (((seq&0xff)<<26) | (seqid&0x3ffffff))
116 #define GET_SEQ_FROM_MSGID(msgid, seq, seqid) \
118 seq = ((msgid >> 26) & 0x3f); \
119 seqid = (msgid & 0x3fffff); \
122 #define NEXT_SEQID(seqid) (((seqid) + 1) & 0x3fffff)
126 unsigned char medium;
127 unsigned char protocol;
129 /* My slave address. This is initialized to IPMI_BMC_SLAVE_ADDR,
130 but may be changed by the user. */
131 unsigned char address;
133 /* My LUN. This should generally stay the SMS LUN, but just in
138 #ifdef CONFIG_PROC_FS
139 struct ipmi_proc_entry
142 struct ipmi_proc_entry *next;
146 #define IPMI_IPMB_NUM_SEQ 64
147 #define IPMI_MAX_CHANNELS 16
150 /* What interface number are we? */
153 /* The list of upper layers that are using me. We read-lock
154 this when delivering messages to the upper layer to keep
155 the user from going away while we are processing the
156 message. This means that you cannot add or delete a user
157 from the receive callback. */
159 struct list_head users;
161 /* Used for wake ups at startup. */
162 wait_queue_head_t waitq;
164 /* The IPMI version of the BMC on the other end. */
165 unsigned char version_major;
166 unsigned char version_minor;
168 /* This is the lower-layer's sender routine. */
169 struct ipmi_smi_handlers *handlers;
172 #ifdef CONFIG_PROC_FS
173 /* A list of proc entries for this interface. This does not
174 need a lock, only one thread creates it and only one thread
176 spinlock_t proc_entry_lock;
177 struct ipmi_proc_entry *proc_entries;
180 /* A table of sequence numbers for this interface. We use the
181 sequence numbers for IPMB messages that go out of the
182 interface to match them up with their responses. A routine
183 is called periodically to time the items in this list. */
185 struct seq_table seq_table[IPMI_IPMB_NUM_SEQ];
188 /* Messages that were delayed for some reason (out of memory,
189 for instance), will go in here to be processed later in a
190 periodic timer interrupt. */
191 spinlock_t waiting_msgs_lock;
192 struct list_head waiting_msgs;
194 /* The list of command receivers that are registered for commands
195 on this interface. */
196 rwlock_t cmd_rcvr_lock;
197 struct list_head cmd_rcvrs;
199 /* Events that were queues because no one was there to receive
201 spinlock_t events_lock; /* For dealing with event stuff. */
202 struct list_head waiting_events;
203 unsigned int waiting_events_count; /* How many events in queue? */
205 /* The event receiver for my BMC, only really used at panic
206 shutdown as a place to store this. */
207 unsigned char event_receiver;
208 unsigned char event_receiver_lun;
209 unsigned char local_sel_device;
210 unsigned char local_event_generator;
212 /* A cheap hack, if this is non-null and a message to an
213 interface comes in with a NULL user, call this routine with
214 it. Note that the message will still be freed by the
215 caller. This only works on the system interface. */
216 void (*null_user_handler)(ipmi_smi_t intf, struct ipmi_recv_msg *msg);
218 /* When we are scanning the channels for an SMI, this will
219 tell which channel we are scanning. */
222 /* Channel information */
223 struct ipmi_channel channels[IPMI_MAX_CHANNELS];
226 struct proc_dir_entry *proc_dir;
227 char proc_dir_name[10];
229 spinlock_t counter_lock; /* For making counters atomic. */
231 /* Commands we got that were invalid. */
232 unsigned int sent_invalid_commands;
234 /* Commands we sent to the MC. */
235 unsigned int sent_local_commands;
236 /* Responses from the MC that were delivered to a user. */
237 unsigned int handled_local_responses;
238 /* Responses from the MC that were not delivered to a user. */
239 unsigned int unhandled_local_responses;
241 /* Commands we sent out to the IPMB bus. */
242 unsigned int sent_ipmb_commands;
243 /* Commands sent on the IPMB that had errors on the SEND CMD */
244 unsigned int sent_ipmb_command_errs;
245 /* Each retransmit increments this count. */
246 unsigned int retransmitted_ipmb_commands;
247 /* When a message times out (runs out of retransmits) this is
249 unsigned int timed_out_ipmb_commands;
251 /* This is like above, but for broadcasts. Broadcasts are
252 *not* included in the above count (they are expected to
254 unsigned int timed_out_ipmb_broadcasts;
256 /* Responses I have sent to the IPMB bus. */
257 unsigned int sent_ipmb_responses;
259 /* The response was delivered to the user. */
260 unsigned int handled_ipmb_responses;
261 /* The response had invalid data in it. */
262 unsigned int invalid_ipmb_responses;
263 /* The response didn't have anyone waiting for it. */
264 unsigned int unhandled_ipmb_responses;
266 /* Commands we sent out to the IPMB bus. */
267 unsigned int sent_lan_commands;
268 /* Commands sent on the IPMB that had errors on the SEND CMD */
269 unsigned int sent_lan_command_errs;
270 /* Each retransmit increments this count. */
271 unsigned int retransmitted_lan_commands;
272 /* When a message times out (runs out of retransmits) this is
274 unsigned int timed_out_lan_commands;
276 /* Responses I have sent to the IPMB bus. */
277 unsigned int sent_lan_responses;
279 /* The response was delivered to the user. */
280 unsigned int handled_lan_responses;
281 /* The response had invalid data in it. */
282 unsigned int invalid_lan_responses;
283 /* The response didn't have anyone waiting for it. */
284 unsigned int unhandled_lan_responses;
286 /* The command was delivered to the user. */
287 unsigned int handled_commands;
288 /* The command had invalid data in it. */
289 unsigned int invalid_commands;
290 /* The command didn't have anyone waiting for it. */
291 unsigned int unhandled_commands;
293 /* Invalid data in an event. */
294 unsigned int invalid_events;
295 /* Events that were received with the proper format. */
299 #define MAX_IPMI_INTERFACES 4
300 static ipmi_smi_t ipmi_interfaces[MAX_IPMI_INTERFACES];
302 /* Used to keep interfaces from going away while operations are
303 operating on interfaces. Grab read if you are not modifying the
304 interfaces, write if you are. */
305 static DECLARE_RWSEM(interfaces_sem);
307 /* Directly protects the ipmi_interfaces data structure. This is
308 claimed in the timer interrupt. */
309 static DEFINE_SPINLOCK(interfaces_lock);
311 /* List of watchers that want to know when smi's are added and
313 static struct list_head smi_watchers = LIST_HEAD_INIT(smi_watchers);
314 static DECLARE_RWSEM(smi_watchers_sem);
316 int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher)
320 down_read(&interfaces_sem);
321 down_write(&smi_watchers_sem);
322 list_add(&(watcher->link), &smi_watchers);
323 for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
324 if (ipmi_interfaces[i] != NULL) {
328 up_write(&smi_watchers_sem);
329 up_read(&interfaces_sem);
333 int ipmi_smi_watcher_unregister(struct ipmi_smi_watcher *watcher)
335 down_write(&smi_watchers_sem);
336 list_del(&(watcher->link));
337 up_write(&smi_watchers_sem);
342 call_smi_watchers(int i)
344 struct ipmi_smi_watcher *w;
346 down_read(&smi_watchers_sem);
347 list_for_each_entry(w, &smi_watchers, link) {
348 if (try_module_get(w->owner)) {
350 module_put(w->owner);
353 up_read(&smi_watchers_sem);
357 ipmi_addr_equal(struct ipmi_addr *addr1, struct ipmi_addr *addr2)
359 if (addr1->addr_type != addr2->addr_type)
362 if (addr1->channel != addr2->channel)
365 if (addr1->addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE) {
366 struct ipmi_system_interface_addr *smi_addr1
367 = (struct ipmi_system_interface_addr *) addr1;
368 struct ipmi_system_interface_addr *smi_addr2
369 = (struct ipmi_system_interface_addr *) addr2;
370 return (smi_addr1->lun == smi_addr2->lun);
373 if ((addr1->addr_type == IPMI_IPMB_ADDR_TYPE)
374 || (addr1->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE))
376 struct ipmi_ipmb_addr *ipmb_addr1
377 = (struct ipmi_ipmb_addr *) addr1;
378 struct ipmi_ipmb_addr *ipmb_addr2
379 = (struct ipmi_ipmb_addr *) addr2;
381 return ((ipmb_addr1->slave_addr == ipmb_addr2->slave_addr)
382 && (ipmb_addr1->lun == ipmb_addr2->lun));
385 if (addr1->addr_type == IPMI_LAN_ADDR_TYPE) {
386 struct ipmi_lan_addr *lan_addr1
387 = (struct ipmi_lan_addr *) addr1;
388 struct ipmi_lan_addr *lan_addr2
389 = (struct ipmi_lan_addr *) addr2;
391 return ((lan_addr1->remote_SWID == lan_addr2->remote_SWID)
392 && (lan_addr1->local_SWID == lan_addr2->local_SWID)
393 && (lan_addr1->session_handle
394 == lan_addr2->session_handle)
395 && (lan_addr1->lun == lan_addr2->lun));
401 int ipmi_validate_addr(struct ipmi_addr *addr, int len)
403 if (len < sizeof(struct ipmi_system_interface_addr)) {
407 if (addr->addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE) {
408 if (addr->channel != IPMI_BMC_CHANNEL)
413 if ((addr->channel == IPMI_BMC_CHANNEL)
414 || (addr->channel >= IPMI_NUM_CHANNELS)
415 || (addr->channel < 0))
418 if ((addr->addr_type == IPMI_IPMB_ADDR_TYPE)
419 || (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE))
421 if (len < sizeof(struct ipmi_ipmb_addr)) {
427 if (addr->addr_type == IPMI_LAN_ADDR_TYPE) {
428 if (len < sizeof(struct ipmi_lan_addr)) {
437 unsigned int ipmi_addr_length(int addr_type)
439 if (addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE)
440 return sizeof(struct ipmi_system_interface_addr);
442 if ((addr_type == IPMI_IPMB_ADDR_TYPE)
443 || (addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE))
445 return sizeof(struct ipmi_ipmb_addr);
448 if (addr_type == IPMI_LAN_ADDR_TYPE)
449 return sizeof(struct ipmi_lan_addr);
454 static void deliver_response(struct ipmi_recv_msg *msg)
457 ipmi_smi_t intf = msg->user_msg_data;
460 /* Special handling for NULL users. */
461 if (intf->null_user_handler) {
462 intf->null_user_handler(intf, msg);
463 spin_lock_irqsave(&intf->counter_lock, flags);
464 intf->handled_local_responses++;
465 spin_unlock_irqrestore(&intf->counter_lock, flags);
467 /* No handler, so give up. */
468 spin_lock_irqsave(&intf->counter_lock, flags);
469 intf->unhandled_local_responses++;
470 spin_unlock_irqrestore(&intf->counter_lock, flags);
472 ipmi_free_recv_msg(msg);
474 msg->user->handler->ipmi_recv_hndl(msg,
475 msg->user->handler_data);
479 /* Find the next sequence number not being used and add the given
480 message with the given timeout to the sequence table. This must be
481 called with the interface's seq_lock held. */
482 static int intf_next_seq(ipmi_smi_t intf,
483 struct ipmi_recv_msg *recv_msg,
484 unsigned long timeout,
493 for (i = intf->curr_seq;
494 (i+1)%IPMI_IPMB_NUM_SEQ != intf->curr_seq;
495 i = (i+1)%IPMI_IPMB_NUM_SEQ)
497 if (! intf->seq_table[i].inuse)
501 if (! intf->seq_table[i].inuse) {
502 intf->seq_table[i].recv_msg = recv_msg;
504 /* Start with the maximum timeout, when the send response
505 comes in we will start the real timer. */
506 intf->seq_table[i].timeout = MAX_MSG_TIMEOUT;
507 intf->seq_table[i].orig_timeout = timeout;
508 intf->seq_table[i].retries_left = retries;
509 intf->seq_table[i].broadcast = broadcast;
510 intf->seq_table[i].inuse = 1;
511 intf->seq_table[i].seqid = NEXT_SEQID(intf->seq_table[i].seqid);
513 *seqid = intf->seq_table[i].seqid;
514 intf->curr_seq = (i+1)%IPMI_IPMB_NUM_SEQ;
522 /* Return the receive message for the given sequence number and
523 release the sequence number so it can be reused. Some other data
524 is passed in to be sure the message matches up correctly (to help
525 guard against message coming in after their timeout and the
526 sequence number being reused). */
527 static int intf_find_seq(ipmi_smi_t intf,
532 struct ipmi_addr *addr,
533 struct ipmi_recv_msg **recv_msg)
538 if (seq >= IPMI_IPMB_NUM_SEQ)
541 spin_lock_irqsave(&(intf->seq_lock), flags);
542 if (intf->seq_table[seq].inuse) {
543 struct ipmi_recv_msg *msg = intf->seq_table[seq].recv_msg;
545 if ((msg->addr.channel == channel)
546 && (msg->msg.cmd == cmd)
547 && (msg->msg.netfn == netfn)
548 && (ipmi_addr_equal(addr, &(msg->addr))))
551 intf->seq_table[seq].inuse = 0;
555 spin_unlock_irqrestore(&(intf->seq_lock), flags);
561 /* Start the timer for a specific sequence table entry. */
562 static int intf_start_seq_timer(ipmi_smi_t intf,
571 GET_SEQ_FROM_MSGID(msgid, seq, seqid);
573 spin_lock_irqsave(&(intf->seq_lock), flags);
574 /* We do this verification because the user can be deleted
575 while a message is outstanding. */
576 if ((intf->seq_table[seq].inuse)
577 && (intf->seq_table[seq].seqid == seqid))
579 struct seq_table *ent = &(intf->seq_table[seq]);
580 ent->timeout = ent->orig_timeout;
583 spin_unlock_irqrestore(&(intf->seq_lock), flags);
588 /* Got an error for the send message for a specific sequence number. */
589 static int intf_err_seq(ipmi_smi_t intf,
597 struct ipmi_recv_msg *msg = NULL;
600 GET_SEQ_FROM_MSGID(msgid, seq, seqid);
602 spin_lock_irqsave(&(intf->seq_lock), flags);
603 /* We do this verification because the user can be deleted
604 while a message is outstanding. */
605 if ((intf->seq_table[seq].inuse)
606 && (intf->seq_table[seq].seqid == seqid))
608 struct seq_table *ent = &(intf->seq_table[seq]);
614 spin_unlock_irqrestore(&(intf->seq_lock), flags);
617 msg->recv_type = IPMI_RESPONSE_RECV_TYPE;
618 msg->msg_data[0] = err;
619 msg->msg.netfn |= 1; /* Convert to a response. */
620 msg->msg.data_len = 1;
621 msg->msg.data = msg->msg_data;
622 deliver_response(msg);
629 int ipmi_create_user(unsigned int if_num,
630 struct ipmi_user_hndl *handler,
635 ipmi_user_t new_user;
639 /* There is no module usecount here, because it's not
640 required. Since this can only be used by and called from
641 other modules, they will implicitly use this module, and
642 thus this can't be removed unless the other modules are
648 /* Make sure the driver is actually initialized, this handles
649 problems with initialization order. */
651 rv = ipmi_init_msghandler();
655 /* The init code doesn't return an error if it was turned
656 off, but it won't initialize. Check that. */
661 new_user = kmalloc(sizeof(*new_user), GFP_KERNEL);
665 down_read(&interfaces_sem);
666 if ((if_num >= MAX_IPMI_INTERFACES) || ipmi_interfaces[if_num] == NULL)
672 intf = ipmi_interfaces[if_num];
674 new_user->handler = handler;
675 new_user->handler_data = handler_data;
676 new_user->intf = intf;
677 new_user->gets_events = 0;
679 if (!try_module_get(intf->handlers->owner)) {
684 if (intf->handlers->inc_usecount) {
685 rv = intf->handlers->inc_usecount(intf->send_info);
687 module_put(intf->handlers->owner);
692 write_lock_irqsave(&intf->users_lock, flags);
693 list_add_tail(&new_user->link, &intf->users);
694 write_unlock_irqrestore(&intf->users_lock, flags);
703 up_read(&interfaces_sem);
707 static int ipmi_destroy_user_nolock(ipmi_user_t user)
711 struct cmd_rcvr *rcvr, *rcvr2;
715 /* Find the user and delete them from the list. */
716 list_for_each_entry(t_user, &(user->intf->users), link) {
717 if (t_user == user) {
718 list_del(&t_user->link);
728 /* Remove the user from the interfaces sequence table. */
729 spin_lock_irqsave(&(user->intf->seq_lock), flags);
730 for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) {
731 if (user->intf->seq_table[i].inuse
732 && (user->intf->seq_table[i].recv_msg->user == user))
734 user->intf->seq_table[i].inuse = 0;
737 spin_unlock_irqrestore(&(user->intf->seq_lock), flags);
739 /* Remove the user from the command receiver's table. */
740 write_lock_irqsave(&(user->intf->cmd_rcvr_lock), flags);
741 list_for_each_entry_safe(rcvr, rcvr2, &(user->intf->cmd_rcvrs), link) {
742 if (rcvr->user == user) {
743 list_del(&rcvr->link);
747 write_unlock_irqrestore(&(user->intf->cmd_rcvr_lock), flags);
756 int ipmi_destroy_user(ipmi_user_t user)
759 ipmi_smi_t intf = user->intf;
762 down_read(&interfaces_sem);
763 write_lock_irqsave(&intf->users_lock, flags);
764 rv = ipmi_destroy_user_nolock(user);
766 module_put(intf->handlers->owner);
767 if (intf->handlers->dec_usecount)
768 intf->handlers->dec_usecount(intf->send_info);
771 write_unlock_irqrestore(&intf->users_lock, flags);
772 up_read(&interfaces_sem);
776 void ipmi_get_version(ipmi_user_t user,
777 unsigned char *major,
778 unsigned char *minor)
780 *major = user->intf->version_major;
781 *minor = user->intf->version_minor;
784 int ipmi_set_my_address(ipmi_user_t user,
785 unsigned int channel,
786 unsigned char address)
788 if (channel >= IPMI_MAX_CHANNELS)
790 user->intf->channels[channel].address = address;
794 int ipmi_get_my_address(ipmi_user_t user,
795 unsigned int channel,
796 unsigned char *address)
798 if (channel >= IPMI_MAX_CHANNELS)
800 *address = user->intf->channels[channel].address;
804 int ipmi_set_my_LUN(ipmi_user_t user,
805 unsigned int channel,
808 if (channel >= IPMI_MAX_CHANNELS)
810 user->intf->channels[channel].lun = LUN & 0x3;
814 int ipmi_get_my_LUN(ipmi_user_t user,
815 unsigned int channel,
816 unsigned char *address)
818 if (channel >= IPMI_MAX_CHANNELS)
820 *address = user->intf->channels[channel].lun;
824 int ipmi_set_gets_events(ipmi_user_t user, int val)
827 struct ipmi_recv_msg *msg, *msg2;
829 read_lock(&(user->intf->users_lock));
830 spin_lock_irqsave(&(user->intf->events_lock), flags);
831 user->gets_events = val;
834 /* Deliver any queued events. */
835 list_for_each_entry_safe(msg, msg2, &(user->intf->waiting_events), link) {
836 list_del(&msg->link);
838 deliver_response(msg);
842 spin_unlock_irqrestore(&(user->intf->events_lock), flags);
843 read_unlock(&(user->intf->users_lock));
848 int ipmi_register_for_cmd(ipmi_user_t user,
852 struct cmd_rcvr *cmp;
854 struct cmd_rcvr *rcvr;
858 rcvr = kmalloc(sizeof(*rcvr), GFP_KERNEL);
862 read_lock(&(user->intf->users_lock));
863 write_lock_irqsave(&(user->intf->cmd_rcvr_lock), flags);
864 /* Make sure the command/netfn is not already registered. */
865 list_for_each_entry(cmp, &(user->intf->cmd_rcvrs), link) {
866 if ((cmp->netfn == netfn) && (cmp->cmd == cmd)) {
876 list_add_tail(&(rcvr->link), &(user->intf->cmd_rcvrs));
879 write_unlock_irqrestore(&(user->intf->cmd_rcvr_lock), flags);
880 read_unlock(&(user->intf->users_lock));
888 int ipmi_unregister_for_cmd(ipmi_user_t user,
893 struct cmd_rcvr *rcvr;
896 read_lock(&(user->intf->users_lock));
897 write_lock_irqsave(&(user->intf->cmd_rcvr_lock), flags);
898 /* Make sure the command/netfn is not already registered. */
899 list_for_each_entry(rcvr, &(user->intf->cmd_rcvrs), link) {
900 if ((rcvr->netfn == netfn) && (rcvr->cmd == cmd)) {
902 list_del(&rcvr->link);
907 write_unlock_irqrestore(&(user->intf->cmd_rcvr_lock), flags);
908 read_unlock(&(user->intf->users_lock));
913 void ipmi_user_set_run_to_completion(ipmi_user_t user, int val)
915 user->intf->handlers->set_run_to_completion(user->intf->send_info,
920 ipmb_checksum(unsigned char *data, int size)
922 unsigned char csum = 0;
924 for (; size > 0; size--, data++)
930 static inline void format_ipmb_msg(struct ipmi_smi_msg *smi_msg,
931 struct kernel_ipmi_msg *msg,
932 struct ipmi_ipmb_addr *ipmb_addr,
934 unsigned char ipmb_seq,
936 unsigned char source_address,
937 unsigned char source_lun)
941 /* Format the IPMB header data. */
942 smi_msg->data[0] = (IPMI_NETFN_APP_REQUEST << 2);
943 smi_msg->data[1] = IPMI_SEND_MSG_CMD;
944 smi_msg->data[2] = ipmb_addr->channel;
946 smi_msg->data[3] = 0;
947 smi_msg->data[i+3] = ipmb_addr->slave_addr;
948 smi_msg->data[i+4] = (msg->netfn << 2) | (ipmb_addr->lun & 0x3);
949 smi_msg->data[i+5] = ipmb_checksum(&(smi_msg->data[i+3]), 2);
950 smi_msg->data[i+6] = source_address;
951 smi_msg->data[i+7] = (ipmb_seq << 2) | source_lun;
952 smi_msg->data[i+8] = msg->cmd;
954 /* Now tack on the data to the message. */
955 if (msg->data_len > 0)
956 memcpy(&(smi_msg->data[i+9]), msg->data,
958 smi_msg->data_size = msg->data_len + 9;
960 /* Now calculate the checksum and tack it on. */
961 smi_msg->data[i+smi_msg->data_size]
962 = ipmb_checksum(&(smi_msg->data[i+6]),
963 smi_msg->data_size-6);
965 /* Add on the checksum size and the offset from the
967 smi_msg->data_size += 1 + i;
969 smi_msg->msgid = msgid;
972 static inline void format_lan_msg(struct ipmi_smi_msg *smi_msg,
973 struct kernel_ipmi_msg *msg,
974 struct ipmi_lan_addr *lan_addr,
976 unsigned char ipmb_seq,
977 unsigned char source_lun)
979 /* Format the IPMB header data. */
980 smi_msg->data[0] = (IPMI_NETFN_APP_REQUEST << 2);
981 smi_msg->data[1] = IPMI_SEND_MSG_CMD;
982 smi_msg->data[2] = lan_addr->channel;
983 smi_msg->data[3] = lan_addr->session_handle;
984 smi_msg->data[4] = lan_addr->remote_SWID;
985 smi_msg->data[5] = (msg->netfn << 2) | (lan_addr->lun & 0x3);
986 smi_msg->data[6] = ipmb_checksum(&(smi_msg->data[4]), 2);
987 smi_msg->data[7] = lan_addr->local_SWID;
988 smi_msg->data[8] = (ipmb_seq << 2) | source_lun;
989 smi_msg->data[9] = msg->cmd;
991 /* Now tack on the data to the message. */
992 if (msg->data_len > 0)
993 memcpy(&(smi_msg->data[10]), msg->data,
995 smi_msg->data_size = msg->data_len + 10;
997 /* Now calculate the checksum and tack it on. */
998 smi_msg->data[smi_msg->data_size]
999 = ipmb_checksum(&(smi_msg->data[7]),
1000 smi_msg->data_size-7);
1002 /* Add on the checksum size and the offset from the
1004 smi_msg->data_size += 1;
1006 smi_msg->msgid = msgid;
1009 /* Separate from ipmi_request so that the user does not have to be
1010 supplied in certain circumstances (mainly at panic time). If
1011 messages are supplied, they will be freed, even if an error
1013 static inline int i_ipmi_request(ipmi_user_t user,
1015 struct ipmi_addr *addr,
1017 struct kernel_ipmi_msg *msg,
1018 void *user_msg_data,
1020 struct ipmi_recv_msg *supplied_recv,
1022 unsigned char source_address,
1023 unsigned char source_lun,
1025 unsigned int retry_time_ms)
1028 struct ipmi_smi_msg *smi_msg;
1029 struct ipmi_recv_msg *recv_msg;
1030 unsigned long flags;
1033 if (supplied_recv) {
1034 recv_msg = supplied_recv;
1036 recv_msg = ipmi_alloc_recv_msg();
1037 if (recv_msg == NULL) {
1041 recv_msg->user_msg_data = user_msg_data;
1044 smi_msg = (struct ipmi_smi_msg *) supplied_smi;
1046 smi_msg = ipmi_alloc_smi_msg();
1047 if (smi_msg == NULL) {
1048 ipmi_free_recv_msg(recv_msg);
1053 recv_msg->user = user;
1054 recv_msg->msgid = msgid;
1055 /* Store the message to send in the receive message so timeout
1056 responses can get the proper response data. */
1057 recv_msg->msg = *msg;
1059 if (addr->addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE) {
1060 struct ipmi_system_interface_addr *smi_addr;
1062 if (msg->netfn & 1) {
1063 /* Responses are not allowed to the SMI. */
1068 smi_addr = (struct ipmi_system_interface_addr *) addr;
1069 if (smi_addr->lun > 3) {
1070 spin_lock_irqsave(&intf->counter_lock, flags);
1071 intf->sent_invalid_commands++;
1072 spin_unlock_irqrestore(&intf->counter_lock, flags);
1077 memcpy(&recv_msg->addr, smi_addr, sizeof(*smi_addr));
1079 if ((msg->netfn == IPMI_NETFN_APP_REQUEST)
1080 && ((msg->cmd == IPMI_SEND_MSG_CMD)
1081 || (msg->cmd == IPMI_GET_MSG_CMD)
1082 || (msg->cmd == IPMI_READ_EVENT_MSG_BUFFER_CMD)))
1084 /* We don't let the user do these, since we manage
1085 the sequence numbers. */
1086 spin_lock_irqsave(&intf->counter_lock, flags);
1087 intf->sent_invalid_commands++;
1088 spin_unlock_irqrestore(&intf->counter_lock, flags);
1093 if ((msg->data_len + 2) > IPMI_MAX_MSG_LENGTH) {
1094 spin_lock_irqsave(&intf->counter_lock, flags);
1095 intf->sent_invalid_commands++;
1096 spin_unlock_irqrestore(&intf->counter_lock, flags);
1101 smi_msg->data[0] = (msg->netfn << 2) | (smi_addr->lun & 0x3);
1102 smi_msg->data[1] = msg->cmd;
1103 smi_msg->msgid = msgid;
1104 smi_msg->user_data = recv_msg;
1105 if (msg->data_len > 0)
1106 memcpy(&(smi_msg->data[2]), msg->data, msg->data_len);
1107 smi_msg->data_size = msg->data_len + 2;
1108 spin_lock_irqsave(&intf->counter_lock, flags);
1109 intf->sent_local_commands++;
1110 spin_unlock_irqrestore(&intf->counter_lock, flags);
1111 } else if ((addr->addr_type == IPMI_IPMB_ADDR_TYPE)
1112 || (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE))
1114 struct ipmi_ipmb_addr *ipmb_addr;
1115 unsigned char ipmb_seq;
1119 if (addr->channel >= IPMI_MAX_CHANNELS) {
1120 spin_lock_irqsave(&intf->counter_lock, flags);
1121 intf->sent_invalid_commands++;
1122 spin_unlock_irqrestore(&intf->counter_lock, flags);
1127 if (intf->channels[addr->channel].medium
1128 != IPMI_CHANNEL_MEDIUM_IPMB)
1130 spin_lock_irqsave(&intf->counter_lock, flags);
1131 intf->sent_invalid_commands++;
1132 spin_unlock_irqrestore(&intf->counter_lock, flags);
1138 if (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)
1139 retries = 0; /* Don't retry broadcasts. */
1143 if (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE) {
1144 /* Broadcasts add a zero at the beginning of the
1145 message, but otherwise is the same as an IPMB
1147 addr->addr_type = IPMI_IPMB_ADDR_TYPE;
1152 /* Default to 1 second retries. */
1153 if (retry_time_ms == 0)
1154 retry_time_ms = 1000;
1156 /* 9 for the header and 1 for the checksum, plus
1157 possibly one for the broadcast. */
1158 if ((msg->data_len + 10 + broadcast) > IPMI_MAX_MSG_LENGTH) {
1159 spin_lock_irqsave(&intf->counter_lock, flags);
1160 intf->sent_invalid_commands++;
1161 spin_unlock_irqrestore(&intf->counter_lock, flags);
1166 ipmb_addr = (struct ipmi_ipmb_addr *) addr;
1167 if (ipmb_addr->lun > 3) {
1168 spin_lock_irqsave(&intf->counter_lock, flags);
1169 intf->sent_invalid_commands++;
1170 spin_unlock_irqrestore(&intf->counter_lock, flags);
1175 memcpy(&recv_msg->addr, ipmb_addr, sizeof(*ipmb_addr));
1177 if (recv_msg->msg.netfn & 0x1) {
1178 /* It's a response, so use the user's sequence
1180 spin_lock_irqsave(&intf->counter_lock, flags);
1181 intf->sent_ipmb_responses++;
1182 spin_unlock_irqrestore(&intf->counter_lock, flags);
1183 format_ipmb_msg(smi_msg, msg, ipmb_addr, msgid,
1185 source_address, source_lun);
1187 /* Save the receive message so we can use it
1188 to deliver the response. */
1189 smi_msg->user_data = recv_msg;
1191 /* It's a command, so get a sequence for it. */
1193 spin_lock_irqsave(&(intf->seq_lock), flags);
1195 spin_lock(&intf->counter_lock);
1196 intf->sent_ipmb_commands++;
1197 spin_unlock(&intf->counter_lock);
1199 /* Create a sequence number with a 1 second
1200 timeout and 4 retries. */
1201 rv = intf_next_seq(intf,
1209 /* We have used up all the sequence numbers,
1210 probably, so abort. */
1211 spin_unlock_irqrestore(&(intf->seq_lock),
1216 /* Store the sequence number in the message,
1217 so that when the send message response
1218 comes back we can start the timer. */
1219 format_ipmb_msg(smi_msg, msg, ipmb_addr,
1220 STORE_SEQ_IN_MSGID(ipmb_seq, seqid),
1221 ipmb_seq, broadcast,
1222 source_address, source_lun);
1224 /* Copy the message into the recv message data, so we
1225 can retransmit it later if necessary. */
1226 memcpy(recv_msg->msg_data, smi_msg->data,
1227 smi_msg->data_size);
1228 recv_msg->msg.data = recv_msg->msg_data;
1229 recv_msg->msg.data_len = smi_msg->data_size;
1231 /* We don't unlock until here, because we need
1232 to copy the completed message into the
1233 recv_msg before we release the lock.
1234 Otherwise, race conditions may bite us. I
1235 know that's pretty paranoid, but I prefer
1237 spin_unlock_irqrestore(&(intf->seq_lock), flags);
1239 } else if (addr->addr_type == IPMI_LAN_ADDR_TYPE) {
1240 struct ipmi_lan_addr *lan_addr;
1241 unsigned char ipmb_seq;
1244 if (addr->channel >= IPMI_NUM_CHANNELS) {
1245 spin_lock_irqsave(&intf->counter_lock, flags);
1246 intf->sent_invalid_commands++;
1247 spin_unlock_irqrestore(&intf->counter_lock, flags);
1252 if ((intf->channels[addr->channel].medium
1253 != IPMI_CHANNEL_MEDIUM_8023LAN)
1254 && (intf->channels[addr->channel].medium
1255 != IPMI_CHANNEL_MEDIUM_ASYNC))
1257 spin_lock_irqsave(&intf->counter_lock, flags);
1258 intf->sent_invalid_commands++;
1259 spin_unlock_irqrestore(&intf->counter_lock, flags);
1266 /* Default to 1 second retries. */
1267 if (retry_time_ms == 0)
1268 retry_time_ms = 1000;
1270 /* 11 for the header and 1 for the checksum. */
1271 if ((msg->data_len + 12) > IPMI_MAX_MSG_LENGTH) {
1272 spin_lock_irqsave(&intf->counter_lock, flags);
1273 intf->sent_invalid_commands++;
1274 spin_unlock_irqrestore(&intf->counter_lock, flags);
1279 lan_addr = (struct ipmi_lan_addr *) addr;
1280 if (lan_addr->lun > 3) {
1281 spin_lock_irqsave(&intf->counter_lock, flags);
1282 intf->sent_invalid_commands++;
1283 spin_unlock_irqrestore(&intf->counter_lock, flags);
1288 memcpy(&recv_msg->addr, lan_addr, sizeof(*lan_addr));
1290 if (recv_msg->msg.netfn & 0x1) {
1291 /* It's a response, so use the user's sequence
1293 spin_lock_irqsave(&intf->counter_lock, flags);
1294 intf->sent_lan_responses++;
1295 spin_unlock_irqrestore(&intf->counter_lock, flags);
1296 format_lan_msg(smi_msg, msg, lan_addr, msgid,
1299 /* Save the receive message so we can use it
1300 to deliver the response. */
1301 smi_msg->user_data = recv_msg;
1303 /* It's a command, so get a sequence for it. */
1305 spin_lock_irqsave(&(intf->seq_lock), flags);
1307 spin_lock(&intf->counter_lock);
1308 intf->sent_lan_commands++;
1309 spin_unlock(&intf->counter_lock);
1311 /* Create a sequence number with a 1 second
1312 timeout and 4 retries. */
1313 rv = intf_next_seq(intf,
1321 /* We have used up all the sequence numbers,
1322 probably, so abort. */
1323 spin_unlock_irqrestore(&(intf->seq_lock),
1328 /* Store the sequence number in the message,
1329 so that when the send message response
1330 comes back we can start the timer. */
1331 format_lan_msg(smi_msg, msg, lan_addr,
1332 STORE_SEQ_IN_MSGID(ipmb_seq, seqid),
1333 ipmb_seq, source_lun);
1335 /* Copy the message into the recv message data, so we
1336 can retransmit it later if necessary. */
1337 memcpy(recv_msg->msg_data, smi_msg->data,
1338 smi_msg->data_size);
1339 recv_msg->msg.data = recv_msg->msg_data;
1340 recv_msg->msg.data_len = smi_msg->data_size;
1342 /* We don't unlock until here, because we need
1343 to copy the completed message into the
1344 recv_msg before we release the lock.
1345 Otherwise, race conditions may bite us. I
1346 know that's pretty paranoid, but I prefer
1348 spin_unlock_irqrestore(&(intf->seq_lock), flags);
1351 /* Unknown address type. */
1352 spin_lock_irqsave(&intf->counter_lock, flags);
1353 intf->sent_invalid_commands++;
1354 spin_unlock_irqrestore(&intf->counter_lock, flags);
1362 for (m = 0; m < smi_msg->data_size; m++)
1363 printk(" %2.2x", smi_msg->data[m]);
1367 intf->handlers->sender(intf->send_info, smi_msg, priority);
1372 ipmi_free_smi_msg(smi_msg);
1373 ipmi_free_recv_msg(recv_msg);
1377 static int check_addr(ipmi_smi_t intf,
1378 struct ipmi_addr *addr,
1379 unsigned char *saddr,
1382 if (addr->channel >= IPMI_MAX_CHANNELS)
1384 *lun = intf->channels[addr->channel].lun;
1385 *saddr = intf->channels[addr->channel].address;
1389 int ipmi_request_settime(ipmi_user_t user,
1390 struct ipmi_addr *addr,
1392 struct kernel_ipmi_msg *msg,
1393 void *user_msg_data,
1396 unsigned int retry_time_ms)
1398 unsigned char saddr, lun;
1403 rv = check_addr(user->intf, addr, &saddr, &lun);
1406 return i_ipmi_request(user,
1420 int ipmi_request_supply_msgs(ipmi_user_t user,
1421 struct ipmi_addr *addr,
1423 struct kernel_ipmi_msg *msg,
1424 void *user_msg_data,
1426 struct ipmi_recv_msg *supplied_recv,
1429 unsigned char saddr, lun;
1434 rv = check_addr(user->intf, addr, &saddr, &lun);
1437 return i_ipmi_request(user,
1451 static int ipmb_file_read_proc(char *page, char **start, off_t off,
1452 int count, int *eof, void *data)
1454 char *out = (char *) page;
1455 ipmi_smi_t intf = data;
1459 for (i = 0; i < IPMI_MAX_CHANNELS; i++)
1460 rv += sprintf(out+rv, "%x ", intf->channels[i].address);
1461 out[rv-1] = '\n'; /* Replace the final space with a newline */
1467 static int version_file_read_proc(char *page, char **start, off_t off,
1468 int count, int *eof, void *data)
1470 char *out = (char *) page;
1471 ipmi_smi_t intf = data;
1473 return sprintf(out, "%d.%d\n",
1474 intf->version_major, intf->version_minor);
1477 static int stat_file_read_proc(char *page, char **start, off_t off,
1478 int count, int *eof, void *data)
1480 char *out = (char *) page;
1481 ipmi_smi_t intf = data;
1483 out += sprintf(out, "sent_invalid_commands: %d\n",
1484 intf->sent_invalid_commands);
1485 out += sprintf(out, "sent_local_commands: %d\n",
1486 intf->sent_local_commands);
1487 out += sprintf(out, "handled_local_responses: %d\n",
1488 intf->handled_local_responses);
1489 out += sprintf(out, "unhandled_local_responses: %d\n",
1490 intf->unhandled_local_responses);
1491 out += sprintf(out, "sent_ipmb_commands: %d\n",
1492 intf->sent_ipmb_commands);
1493 out += sprintf(out, "sent_ipmb_command_errs: %d\n",
1494 intf->sent_ipmb_command_errs);
1495 out += sprintf(out, "retransmitted_ipmb_commands: %d\n",
1496 intf->retransmitted_ipmb_commands);
1497 out += sprintf(out, "timed_out_ipmb_commands: %d\n",
1498 intf->timed_out_ipmb_commands);
1499 out += sprintf(out, "timed_out_ipmb_broadcasts: %d\n",
1500 intf->timed_out_ipmb_broadcasts);
1501 out += sprintf(out, "sent_ipmb_responses: %d\n",
1502 intf->sent_ipmb_responses);
1503 out += sprintf(out, "handled_ipmb_responses: %d\n",
1504 intf->handled_ipmb_responses);
1505 out += sprintf(out, "invalid_ipmb_responses: %d\n",
1506 intf->invalid_ipmb_responses);
1507 out += sprintf(out, "unhandled_ipmb_responses: %d\n",
1508 intf->unhandled_ipmb_responses);
1509 out += sprintf(out, "sent_lan_commands: %d\n",
1510 intf->sent_lan_commands);
1511 out += sprintf(out, "sent_lan_command_errs: %d\n",
1512 intf->sent_lan_command_errs);
1513 out += sprintf(out, "retransmitted_lan_commands: %d\n",
1514 intf->retransmitted_lan_commands);
1515 out += sprintf(out, "timed_out_lan_commands: %d\n",
1516 intf->timed_out_lan_commands);
1517 out += sprintf(out, "sent_lan_responses: %d\n",
1518 intf->sent_lan_responses);
1519 out += sprintf(out, "handled_lan_responses: %d\n",
1520 intf->handled_lan_responses);
1521 out += sprintf(out, "invalid_lan_responses: %d\n",
1522 intf->invalid_lan_responses);
1523 out += sprintf(out, "unhandled_lan_responses: %d\n",
1524 intf->unhandled_lan_responses);
1525 out += sprintf(out, "handled_commands: %d\n",
1526 intf->handled_commands);
1527 out += sprintf(out, "invalid_commands: %d\n",
1528 intf->invalid_commands);
1529 out += sprintf(out, "unhandled_commands: %d\n",
1530 intf->unhandled_commands);
1531 out += sprintf(out, "invalid_events: %d\n",
1532 intf->invalid_events);
1533 out += sprintf(out, "events: %d\n",
1536 return (out - ((char *) page));
1539 int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
1540 read_proc_t *read_proc, write_proc_t *write_proc,
1541 void *data, struct module *owner)
1544 #ifdef CONFIG_PROC_FS
1545 struct proc_dir_entry *file;
1546 struct ipmi_proc_entry *entry;
1548 /* Create a list element. */
1549 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
1552 entry->name = kmalloc(strlen(name)+1, GFP_KERNEL);
1557 strcpy(entry->name, name);
1559 file = create_proc_entry(name, 0, smi->proc_dir);
1567 file->read_proc = read_proc;
1568 file->write_proc = write_proc;
1569 file->owner = owner;
1571 spin_lock(&smi->proc_entry_lock);
1572 /* Stick it on the list. */
1573 entry->next = smi->proc_entries;
1574 smi->proc_entries = entry;
1575 spin_unlock(&smi->proc_entry_lock);
1577 #endif /* CONFIG_PROC_FS */
1582 static int add_proc_entries(ipmi_smi_t smi, int num)
1586 #ifdef CONFIG_PROC_FS
1587 sprintf(smi->proc_dir_name, "%d", num);
1588 smi->proc_dir = proc_mkdir(smi->proc_dir_name, proc_ipmi_root);
1592 smi->proc_dir->owner = THIS_MODULE;
1596 rv = ipmi_smi_add_proc_entry(smi, "stats",
1597 stat_file_read_proc, NULL,
1601 rv = ipmi_smi_add_proc_entry(smi, "ipmb",
1602 ipmb_file_read_proc, NULL,
1606 rv = ipmi_smi_add_proc_entry(smi, "version",
1607 version_file_read_proc, NULL,
1609 #endif /* CONFIG_PROC_FS */
1614 static void remove_proc_entries(ipmi_smi_t smi)
1616 #ifdef CONFIG_PROC_FS
1617 struct ipmi_proc_entry *entry;
1619 spin_lock(&smi->proc_entry_lock);
1620 while (smi->proc_entries) {
1621 entry = smi->proc_entries;
1622 smi->proc_entries = entry->next;
1624 remove_proc_entry(entry->name, smi->proc_dir);
1628 spin_unlock(&smi->proc_entry_lock);
1629 remove_proc_entry(smi->proc_dir_name, proc_ipmi_root);
1630 #endif /* CONFIG_PROC_FS */
1634 send_channel_info_cmd(ipmi_smi_t intf, int chan)
1636 struct kernel_ipmi_msg msg;
1637 unsigned char data[1];
1638 struct ipmi_system_interface_addr si;
1640 si.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
1641 si.channel = IPMI_BMC_CHANNEL;
1644 msg.netfn = IPMI_NETFN_APP_REQUEST;
1645 msg.cmd = IPMI_GET_CHANNEL_INFO_CMD;
1649 return i_ipmi_request(NULL,
1651 (struct ipmi_addr *) &si,
1658 intf->channels[0].address,
1659 intf->channels[0].lun,
1664 channel_handler(ipmi_smi_t intf, struct ipmi_recv_msg *msg)
1669 if ((msg->addr.addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE)
1670 && (msg->msg.netfn == IPMI_NETFN_APP_RESPONSE)
1671 && (msg->msg.cmd == IPMI_GET_CHANNEL_INFO_CMD))
1673 /* It's the one we want */
1674 if (msg->msg.data[0] != 0) {
1675 /* Got an error from the channel, just go on. */
1677 if (msg->msg.data[0] == IPMI_INVALID_COMMAND_ERR) {
1678 /* If the MC does not support this
1679 command, that is legal. We just
1680 assume it has one IPMB at channel
1682 intf->channels[0].medium
1683 = IPMI_CHANNEL_MEDIUM_IPMB;
1684 intf->channels[0].protocol
1685 = IPMI_CHANNEL_PROTOCOL_IPMB;
1688 intf->curr_channel = IPMI_MAX_CHANNELS;
1689 wake_up(&intf->waitq);
1694 if (msg->msg.data_len < 4) {
1695 /* Message not big enough, just go on. */
1698 chan = intf->curr_channel;
1699 intf->channels[chan].medium = msg->msg.data[2] & 0x7f;
1700 intf->channels[chan].protocol = msg->msg.data[3] & 0x1f;
1703 intf->curr_channel++;
1704 if (intf->curr_channel >= IPMI_MAX_CHANNELS)
1705 wake_up(&intf->waitq);
1707 rv = send_channel_info_cmd(intf, intf->curr_channel);
1710 /* Got an error somehow, just give up. */
1711 intf->curr_channel = IPMI_MAX_CHANNELS;
1712 wake_up(&intf->waitq);
1714 printk(KERN_WARNING PFX
1715 "Error sending channel information: %d\n",
1723 int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
1725 unsigned char version_major,
1726 unsigned char version_minor,
1727 unsigned char slave_addr,
1732 ipmi_smi_t new_intf;
1733 unsigned long flags;
1736 /* Make sure the driver is actually initialized, this handles
1737 problems with initialization order. */
1739 rv = ipmi_init_msghandler();
1742 /* The init code doesn't return an error if it was turned
1743 off, but it won't initialize. Check that. */
1748 new_intf = kmalloc(sizeof(*new_intf), GFP_KERNEL);
1751 memset(new_intf, 0, sizeof(*new_intf));
1753 new_intf->proc_dir = NULL;
1757 down_write(&interfaces_sem);
1758 for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
1759 if (ipmi_interfaces[i] == NULL) {
1760 new_intf->intf_num = i;
1761 new_intf->version_major = version_major;
1762 new_intf->version_minor = version_minor;
1763 for (j = 0; j < IPMI_MAX_CHANNELS; j++) {
1764 new_intf->channels[j].address
1765 = IPMI_BMC_SLAVE_ADDR;
1766 new_intf->channels[j].lun = 2;
1768 if (slave_addr != 0)
1769 new_intf->channels[0].address = slave_addr;
1770 rwlock_init(&(new_intf->users_lock));
1771 INIT_LIST_HEAD(&(new_intf->users));
1772 new_intf->handlers = handlers;
1773 new_intf->send_info = send_info;
1774 spin_lock_init(&(new_intf->seq_lock));
1775 for (j = 0; j < IPMI_IPMB_NUM_SEQ; j++) {
1776 new_intf->seq_table[j].inuse = 0;
1777 new_intf->seq_table[j].seqid = 0;
1779 new_intf->curr_seq = 0;
1780 #ifdef CONFIG_PROC_FS
1781 spin_lock_init(&(new_intf->proc_entry_lock));
1783 spin_lock_init(&(new_intf->waiting_msgs_lock));
1784 INIT_LIST_HEAD(&(new_intf->waiting_msgs));
1785 spin_lock_init(&(new_intf->events_lock));
1786 INIT_LIST_HEAD(&(new_intf->waiting_events));
1787 new_intf->waiting_events_count = 0;
1788 rwlock_init(&(new_intf->cmd_rcvr_lock));
1789 init_waitqueue_head(&new_intf->waitq);
1790 INIT_LIST_HEAD(&(new_intf->cmd_rcvrs));
1792 spin_lock_init(&(new_intf->counter_lock));
1794 spin_lock_irqsave(&interfaces_lock, flags);
1795 ipmi_interfaces[i] = new_intf;
1796 spin_unlock_irqrestore(&interfaces_lock, flags);
1804 downgrade_write(&interfaces_sem);
1807 rv = add_proc_entries(*intf, i);
1810 if ((version_major > 1)
1811 || ((version_major == 1) && (version_minor >= 5)))
1813 /* Start scanning the channels to see what is
1815 (*intf)->null_user_handler = channel_handler;
1816 (*intf)->curr_channel = 0;
1817 rv = send_channel_info_cmd(*intf, 0);
1821 /* Wait for the channel info to be read. */
1822 up_read(&interfaces_sem);
1823 wait_event((*intf)->waitq,
1824 ((*intf)->curr_channel>=IPMI_MAX_CHANNELS));
1825 down_read(&interfaces_sem);
1827 if (ipmi_interfaces[i] != new_intf)
1828 /* Well, it went away. Just return. */
1831 /* Assume a single IPMB channel at zero. */
1832 (*intf)->channels[0].medium = IPMI_CHANNEL_MEDIUM_IPMB;
1833 (*intf)->channels[0].protocol
1834 = IPMI_CHANNEL_PROTOCOL_IPMB;
1837 /* Call all the watcher interfaces to tell
1838 them that a new interface is available. */
1839 call_smi_watchers(i);
1843 up_read(&interfaces_sem);
1846 if (new_intf->proc_dir)
1847 remove_proc_entries(new_intf);
1854 static void free_recv_msg_list(struct list_head *q)
1856 struct ipmi_recv_msg *msg, *msg2;
1858 list_for_each_entry_safe(msg, msg2, q, link) {
1859 list_del(&msg->link);
1860 ipmi_free_recv_msg(msg);
1864 static void free_cmd_rcvr_list(struct list_head *q)
1866 struct cmd_rcvr *rcvr, *rcvr2;
1868 list_for_each_entry_safe(rcvr, rcvr2, q, link) {
1869 list_del(&rcvr->link);
1874 static void clean_up_interface_data(ipmi_smi_t intf)
1878 free_recv_msg_list(&(intf->waiting_msgs));
1879 free_recv_msg_list(&(intf->waiting_events));
1880 free_cmd_rcvr_list(&(intf->cmd_rcvrs));
1882 for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) {
1883 if ((intf->seq_table[i].inuse)
1884 && (intf->seq_table[i].recv_msg))
1886 ipmi_free_recv_msg(intf->seq_table[i].recv_msg);
1891 int ipmi_unregister_smi(ipmi_smi_t intf)
1895 struct ipmi_smi_watcher *w;
1896 unsigned long flags;
1898 down_write(&interfaces_sem);
1899 if (list_empty(&(intf->users)))
1901 for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
1902 if (ipmi_interfaces[i] == intf) {
1903 remove_proc_entries(intf);
1904 spin_lock_irqsave(&interfaces_lock, flags);
1905 ipmi_interfaces[i] = NULL;
1906 clean_up_interface_data(intf);
1907 spin_unlock_irqrestore(&interfaces_lock,flags);
1910 goto out_call_watcher;
1916 up_write(&interfaces_sem);
1921 downgrade_write(&interfaces_sem);
1923 /* Call all the watcher interfaces to tell them that
1924 an interface is gone. */
1925 down_read(&smi_watchers_sem);
1926 list_for_each_entry(w, &smi_watchers, link) {
1929 up_read(&smi_watchers_sem);
1930 up_read(&interfaces_sem);
1934 static int handle_ipmb_get_msg_rsp(ipmi_smi_t intf,
1935 struct ipmi_smi_msg *msg)
1937 struct ipmi_ipmb_addr ipmb_addr;
1938 struct ipmi_recv_msg *recv_msg;
1939 unsigned long flags;
1942 /* This is 11, not 10, because the response must contain a
1943 * completion code. */
1944 if (msg->rsp_size < 11) {
1945 /* Message not big enough, just ignore it. */
1946 spin_lock_irqsave(&intf->counter_lock, flags);
1947 intf->invalid_ipmb_responses++;
1948 spin_unlock_irqrestore(&intf->counter_lock, flags);
1952 if (msg->rsp[2] != 0) {
1953 /* An error getting the response, just ignore it. */
1957 ipmb_addr.addr_type = IPMI_IPMB_ADDR_TYPE;
1958 ipmb_addr.slave_addr = msg->rsp[6];
1959 ipmb_addr.channel = msg->rsp[3] & 0x0f;
1960 ipmb_addr.lun = msg->rsp[7] & 3;
1962 /* It's a response from a remote entity. Look up the sequence
1963 number and handle the response. */
1964 if (intf_find_seq(intf,
1968 (msg->rsp[4] >> 2) & (~1),
1969 (struct ipmi_addr *) &(ipmb_addr),
1972 /* We were unable to find the sequence number,
1973 so just nuke the message. */
1974 spin_lock_irqsave(&intf->counter_lock, flags);
1975 intf->unhandled_ipmb_responses++;
1976 spin_unlock_irqrestore(&intf->counter_lock, flags);
1980 memcpy(recv_msg->msg_data,
1983 /* THe other fields matched, so no need to set them, except
1984 for netfn, which needs to be the response that was
1985 returned, not the request value. */
1986 recv_msg->msg.netfn = msg->rsp[4] >> 2;
1987 recv_msg->msg.data = recv_msg->msg_data;
1988 recv_msg->msg.data_len = msg->rsp_size - 10;
1989 recv_msg->recv_type = IPMI_RESPONSE_RECV_TYPE;
1990 spin_lock_irqsave(&intf->counter_lock, flags);
1991 intf->handled_ipmb_responses++;
1992 spin_unlock_irqrestore(&intf->counter_lock, flags);
1993 deliver_response(recv_msg);
1998 static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf,
1999 struct ipmi_smi_msg *msg)
2001 struct cmd_rcvr *rcvr;
2003 unsigned char netfn;
2005 ipmi_user_t user = NULL;
2006 struct ipmi_ipmb_addr *ipmb_addr;
2007 struct ipmi_recv_msg *recv_msg;
2008 unsigned long flags;
2010 if (msg->rsp_size < 10) {
2011 /* Message not big enough, just ignore it. */
2012 spin_lock_irqsave(&intf->counter_lock, flags);
2013 intf->invalid_commands++;
2014 spin_unlock_irqrestore(&intf->counter_lock, flags);
2018 if (msg->rsp[2] != 0) {
2019 /* An error getting the response, just ignore it. */
2023 netfn = msg->rsp[4] >> 2;
2026 read_lock(&(intf->cmd_rcvr_lock));
2028 /* Find the command/netfn. */
2029 list_for_each_entry(rcvr, &(intf->cmd_rcvrs), link) {
2030 if ((rcvr->netfn == netfn) && (rcvr->cmd == cmd)) {
2035 read_unlock(&(intf->cmd_rcvr_lock));
2038 /* We didn't find a user, deliver an error response. */
2039 spin_lock_irqsave(&intf->counter_lock, flags);
2040 intf->unhandled_commands++;
2041 spin_unlock_irqrestore(&intf->counter_lock, flags);
2043 msg->data[0] = (IPMI_NETFN_APP_REQUEST << 2);
2044 msg->data[1] = IPMI_SEND_MSG_CMD;
2045 msg->data[2] = msg->rsp[3];
2046 msg->data[3] = msg->rsp[6];
2047 msg->data[4] = ((netfn + 1) << 2) | (msg->rsp[7] & 0x3);
2048 msg->data[5] = ipmb_checksum(&(msg->data[3]), 2);
2049 msg->data[6] = intf->channels[msg->rsp[3] & 0xf].address;
2051 msg->data[7] = (msg->rsp[7] & 0xfc) | (msg->rsp[4] & 0x3);
2052 msg->data[8] = msg->rsp[8]; /* cmd */
2053 msg->data[9] = IPMI_INVALID_CMD_COMPLETION_CODE;
2054 msg->data[10] = ipmb_checksum(&(msg->data[6]), 4);
2055 msg->data_size = 11;
2060 printk("Invalid command:");
2061 for (m = 0; m < msg->data_size; m++)
2062 printk(" %2.2x", msg->data[m]);
2066 intf->handlers->sender(intf->send_info, msg, 0);
2068 rv = -1; /* We used the message, so return the value that
2069 causes it to not be freed or queued. */
2071 /* Deliver the message to the user. */
2072 spin_lock_irqsave(&intf->counter_lock, flags);
2073 intf->handled_commands++;
2074 spin_unlock_irqrestore(&intf->counter_lock, flags);
2076 recv_msg = ipmi_alloc_recv_msg();
2078 /* We couldn't allocate memory for the
2079 message, so requeue it for handling
2083 /* Extract the source address from the data. */
2084 ipmb_addr = (struct ipmi_ipmb_addr *) &recv_msg->addr;
2085 ipmb_addr->addr_type = IPMI_IPMB_ADDR_TYPE;
2086 ipmb_addr->slave_addr = msg->rsp[6];
2087 ipmb_addr->lun = msg->rsp[7] & 3;
2088 ipmb_addr->channel = msg->rsp[3] & 0xf;
2090 /* Extract the rest of the message information
2091 from the IPMB header.*/
2092 recv_msg->user = user;
2093 recv_msg->recv_type = IPMI_CMD_RECV_TYPE;
2094 recv_msg->msgid = msg->rsp[7] >> 2;
2095 recv_msg->msg.netfn = msg->rsp[4] >> 2;
2096 recv_msg->msg.cmd = msg->rsp[8];
2097 recv_msg->msg.data = recv_msg->msg_data;
2099 /* We chop off 10, not 9 bytes because the checksum
2100 at the end also needs to be removed. */
2101 recv_msg->msg.data_len = msg->rsp_size - 10;
2102 memcpy(recv_msg->msg_data,
2104 msg->rsp_size - 10);
2105 deliver_response(recv_msg);
2112 static int handle_lan_get_msg_rsp(ipmi_smi_t intf,
2113 struct ipmi_smi_msg *msg)
2115 struct ipmi_lan_addr lan_addr;
2116 struct ipmi_recv_msg *recv_msg;
2117 unsigned long flags;
2120 /* This is 13, not 12, because the response must contain a
2121 * completion code. */
2122 if (msg->rsp_size < 13) {
2123 /* Message not big enough, just ignore it. */
2124 spin_lock_irqsave(&intf->counter_lock, flags);
2125 intf->invalid_lan_responses++;
2126 spin_unlock_irqrestore(&intf->counter_lock, flags);
2130 if (msg->rsp[2] != 0) {
2131 /* An error getting the response, just ignore it. */
2135 lan_addr.addr_type = IPMI_LAN_ADDR_TYPE;
2136 lan_addr.session_handle = msg->rsp[4];
2137 lan_addr.remote_SWID = msg->rsp[8];
2138 lan_addr.local_SWID = msg->rsp[5];
2139 lan_addr.channel = msg->rsp[3] & 0x0f;
2140 lan_addr.privilege = msg->rsp[3] >> 4;
2141 lan_addr.lun = msg->rsp[9] & 3;
2143 /* It's a response from a remote entity. Look up the sequence
2144 number and handle the response. */
2145 if (intf_find_seq(intf,
2149 (msg->rsp[6] >> 2) & (~1),
2150 (struct ipmi_addr *) &(lan_addr),
2153 /* We were unable to find the sequence number,
2154 so just nuke the message. */
2155 spin_lock_irqsave(&intf->counter_lock, flags);
2156 intf->unhandled_lan_responses++;
2157 spin_unlock_irqrestore(&intf->counter_lock, flags);
2161 memcpy(recv_msg->msg_data,
2163 msg->rsp_size - 11);
2164 /* The other fields matched, so no need to set them, except
2165 for netfn, which needs to be the response that was
2166 returned, not the request value. */
2167 recv_msg->msg.netfn = msg->rsp[6] >> 2;
2168 recv_msg->msg.data = recv_msg->msg_data;
2169 recv_msg->msg.data_len = msg->rsp_size - 12;
2170 recv_msg->recv_type = IPMI_RESPONSE_RECV_TYPE;
2171 spin_lock_irqsave(&intf->counter_lock, flags);
2172 intf->handled_lan_responses++;
2173 spin_unlock_irqrestore(&intf->counter_lock, flags);
2174 deliver_response(recv_msg);
2179 static int handle_lan_get_msg_cmd(ipmi_smi_t intf,
2180 struct ipmi_smi_msg *msg)
2182 struct cmd_rcvr *rcvr;
2184 unsigned char netfn;
2186 ipmi_user_t user = NULL;
2187 struct ipmi_lan_addr *lan_addr;
2188 struct ipmi_recv_msg *recv_msg;
2189 unsigned long flags;
2191 if (msg->rsp_size < 12) {
2192 /* Message not big enough, just ignore it. */
2193 spin_lock_irqsave(&intf->counter_lock, flags);
2194 intf->invalid_commands++;
2195 spin_unlock_irqrestore(&intf->counter_lock, flags);
2199 if (msg->rsp[2] != 0) {
2200 /* An error getting the response, just ignore it. */
2204 netfn = msg->rsp[6] >> 2;
2207 read_lock(&(intf->cmd_rcvr_lock));
2209 /* Find the command/netfn. */
2210 list_for_each_entry(rcvr, &(intf->cmd_rcvrs), link) {
2211 if ((rcvr->netfn == netfn) && (rcvr->cmd == cmd)) {
2216 read_unlock(&(intf->cmd_rcvr_lock));
2219 /* We didn't find a user, deliver an error response. */
2220 spin_lock_irqsave(&intf->counter_lock, flags);
2221 intf->unhandled_commands++;
2222 spin_unlock_irqrestore(&intf->counter_lock, flags);
2224 rv = 0; /* Don't do anything with these messages, just
2225 allow them to be freed. */
2227 /* Deliver the message to the user. */
2228 spin_lock_irqsave(&intf->counter_lock, flags);
2229 intf->handled_commands++;
2230 spin_unlock_irqrestore(&intf->counter_lock, flags);
2232 recv_msg = ipmi_alloc_recv_msg();
2234 /* We couldn't allocate memory for the
2235 message, so requeue it for handling
2239 /* Extract the source address from the data. */
2240 lan_addr = (struct ipmi_lan_addr *) &recv_msg->addr;
2241 lan_addr->addr_type = IPMI_LAN_ADDR_TYPE;
2242 lan_addr->session_handle = msg->rsp[4];
2243 lan_addr->remote_SWID = msg->rsp[8];
2244 lan_addr->local_SWID = msg->rsp[5];
2245 lan_addr->lun = msg->rsp[9] & 3;
2246 lan_addr->channel = msg->rsp[3] & 0xf;
2247 lan_addr->privilege = msg->rsp[3] >> 4;
2249 /* Extract the rest of the message information
2250 from the IPMB header.*/
2251 recv_msg->user = user;
2252 recv_msg->recv_type = IPMI_CMD_RECV_TYPE;
2253 recv_msg->msgid = msg->rsp[9] >> 2;
2254 recv_msg->msg.netfn = msg->rsp[6] >> 2;
2255 recv_msg->msg.cmd = msg->rsp[10];
2256 recv_msg->msg.data = recv_msg->msg_data;
2258 /* We chop off 12, not 11 bytes because the checksum
2259 at the end also needs to be removed. */
2260 recv_msg->msg.data_len = msg->rsp_size - 12;
2261 memcpy(recv_msg->msg_data,
2263 msg->rsp_size - 12);
2264 deliver_response(recv_msg);
2271 static void copy_event_into_recv_msg(struct ipmi_recv_msg *recv_msg,
2272 struct ipmi_smi_msg *msg)
2274 struct ipmi_system_interface_addr *smi_addr;
2276 recv_msg->msgid = 0;
2277 smi_addr = (struct ipmi_system_interface_addr *) &(recv_msg->addr);
2278 smi_addr->addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
2279 smi_addr->channel = IPMI_BMC_CHANNEL;
2280 smi_addr->lun = msg->rsp[0] & 3;
2281 recv_msg->recv_type = IPMI_ASYNC_EVENT_RECV_TYPE;
2282 recv_msg->msg.netfn = msg->rsp[0] >> 2;
2283 recv_msg->msg.cmd = msg->rsp[1];
2284 memcpy(recv_msg->msg_data, &(msg->rsp[3]), msg->rsp_size - 3);
2285 recv_msg->msg.data = recv_msg->msg_data;
2286 recv_msg->msg.data_len = msg->rsp_size - 3;
2289 /* This will be called with the intf->users_lock read-locked, so no need
2291 static int handle_read_event_rsp(ipmi_smi_t intf,
2292 struct ipmi_smi_msg *msg)
2294 struct ipmi_recv_msg *recv_msg, *recv_msg2;
2295 struct list_head msgs;
2298 int deliver_count = 0;
2299 unsigned long flags;
2301 if (msg->rsp_size < 19) {
2302 /* Message is too small to be an IPMB event. */
2303 spin_lock_irqsave(&intf->counter_lock, flags);
2304 intf->invalid_events++;
2305 spin_unlock_irqrestore(&intf->counter_lock, flags);
2309 if (msg->rsp[2] != 0) {
2310 /* An error getting the event, just ignore it. */
2314 INIT_LIST_HEAD(&msgs);
2316 spin_lock_irqsave(&(intf->events_lock), flags);
2318 spin_lock(&intf->counter_lock);
2320 spin_unlock(&intf->counter_lock);
2322 /* Allocate and fill in one message for every user that is getting
2324 list_for_each_entry(user, &(intf->users), link) {
2325 if (! user->gets_events)
2328 recv_msg = ipmi_alloc_recv_msg();
2330 list_for_each_entry_safe(recv_msg, recv_msg2, &msgs, link) {
2331 list_del(&recv_msg->link);
2332 ipmi_free_recv_msg(recv_msg);
2334 /* We couldn't allocate memory for the
2335 message, so requeue it for handling
2343 copy_event_into_recv_msg(recv_msg, msg);
2344 recv_msg->user = user;
2345 list_add_tail(&(recv_msg->link), &msgs);
2348 if (deliver_count) {
2349 /* Now deliver all the messages. */
2350 list_for_each_entry_safe(recv_msg, recv_msg2, &msgs, link) {
2351 list_del(&recv_msg->link);
2352 deliver_response(recv_msg);
2354 } else if (intf->waiting_events_count < MAX_EVENTS_IN_QUEUE) {
2355 /* No one to receive the message, put it in queue if there's
2356 not already too many things in the queue. */
2357 recv_msg = ipmi_alloc_recv_msg();
2359 /* We couldn't allocate memory for the
2360 message, so requeue it for handling
2366 copy_event_into_recv_msg(recv_msg, msg);
2367 list_add_tail(&(recv_msg->link), &(intf->waiting_events));
2369 /* There's too many things in the queue, discard this
2371 printk(KERN_WARNING PFX "Event queue full, discarding an"
2372 " incoming event\n");
2376 spin_unlock_irqrestore(&(intf->events_lock), flags);
2381 static int handle_bmc_rsp(ipmi_smi_t intf,
2382 struct ipmi_smi_msg *msg)
2384 struct ipmi_recv_msg *recv_msg;
2386 struct ipmi_user *user;
2387 unsigned long flags;
2389 recv_msg = (struct ipmi_recv_msg *) msg->user_data;
2390 if (recv_msg == NULL)
2392 printk(KERN_WARNING"IPMI message received with no owner. This\n"
2393 "could be because of a malformed message, or\n"
2394 "because of a hardware error. Contact your\n"
2395 "hardware vender for assistance\n");
2399 /* Make sure the user still exists. */
2400 list_for_each_entry(user, &(intf->users), link) {
2401 if (user == recv_msg->user) {
2402 /* Found it, so we can deliver it */
2408 if ((! found) && recv_msg->user) {
2409 /* The user for the message went away, so give up. */
2410 spin_lock_irqsave(&intf->counter_lock, flags);
2411 intf->unhandled_local_responses++;
2412 spin_unlock_irqrestore(&intf->counter_lock, flags);
2413 ipmi_free_recv_msg(recv_msg);
2415 struct ipmi_system_interface_addr *smi_addr;
2417 spin_lock_irqsave(&intf->counter_lock, flags);
2418 intf->handled_local_responses++;
2419 spin_unlock_irqrestore(&intf->counter_lock, flags);
2420 recv_msg->recv_type = IPMI_RESPONSE_RECV_TYPE;
2421 recv_msg->msgid = msg->msgid;
2422 smi_addr = ((struct ipmi_system_interface_addr *)
2424 smi_addr->addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
2425 smi_addr->channel = IPMI_BMC_CHANNEL;
2426 smi_addr->lun = msg->rsp[0] & 3;
2427 recv_msg->msg.netfn = msg->rsp[0] >> 2;
2428 recv_msg->msg.cmd = msg->rsp[1];
2429 memcpy(recv_msg->msg_data,
2432 recv_msg->msg.data = recv_msg->msg_data;
2433 recv_msg->msg.data_len = msg->rsp_size - 2;
2434 deliver_response(recv_msg);
2440 /* Handle a new message. Return 1 if the message should be requeued,
2441 0 if the message should be freed, or -1 if the message should not
2442 be freed or requeued. */
2443 static int handle_new_recv_msg(ipmi_smi_t intf,
2444 struct ipmi_smi_msg *msg)
2452 for (m = 0; m < msg->rsp_size; m++)
2453 printk(" %2.2x", msg->rsp[m]);
2456 if (msg->rsp_size < 2) {
2457 /* Message is too small to be correct. */
2458 printk(KERN_WARNING PFX "BMC returned to small a message"
2459 " for netfn %x cmd %x, got %d bytes\n",
2460 (msg->data[0] >> 2) | 1, msg->data[1], msg->rsp_size);
2462 /* Generate an error response for the message. */
2463 msg->rsp[0] = msg->data[0] | (1 << 2);
2464 msg->rsp[1] = msg->data[1];
2465 msg->rsp[2] = IPMI_ERR_UNSPECIFIED;
2467 } else if (((msg->rsp[0] >> 2) != ((msg->data[0] >> 2) | 1))/* Netfn */
2468 || (msg->rsp[1] != msg->data[1])) /* Command */
2470 /* The response is not even marginally correct. */
2471 printk(KERN_WARNING PFX "BMC returned incorrect response,"
2472 " expected netfn %x cmd %x, got netfn %x cmd %x\n",
2473 (msg->data[0] >> 2) | 1, msg->data[1],
2474 msg->rsp[0] >> 2, msg->rsp[1]);
2476 /* Generate an error response for the message. */
2477 msg->rsp[0] = msg->data[0] | (1 << 2);
2478 msg->rsp[1] = msg->data[1];
2479 msg->rsp[2] = IPMI_ERR_UNSPECIFIED;
2483 if ((msg->rsp[0] == ((IPMI_NETFN_APP_REQUEST|1) << 2))
2484 && (msg->rsp[1] == IPMI_SEND_MSG_CMD)
2485 && (msg->user_data != NULL))
2487 /* It's a response to a response we sent. For this we
2488 deliver a send message response to the user. */
2489 struct ipmi_recv_msg *recv_msg = msg->user_data;
2492 if (msg->rsp_size < 2)
2493 /* Message is too small to be correct. */
2496 chan = msg->data[2] & 0x0f;
2497 if (chan >= IPMI_MAX_CHANNELS)
2498 /* Invalid channel number */
2502 recv_msg->recv_type = IPMI_RESPONSE_RESPONSE_TYPE;
2503 recv_msg->msg.data = recv_msg->msg_data;
2504 recv_msg->msg.data_len = 1;
2505 recv_msg->msg_data[0] = msg->rsp[2];
2506 deliver_response(recv_msg);
2508 } else if ((msg->rsp[0] == ((IPMI_NETFN_APP_REQUEST|1) << 2))
2509 && (msg->rsp[1] == IPMI_GET_MSG_CMD))
2511 /* It's from the receive queue. */
2512 chan = msg->rsp[3] & 0xf;
2513 if (chan >= IPMI_MAX_CHANNELS) {
2514 /* Invalid channel number */
2519 switch (intf->channels[chan].medium) {
2520 case IPMI_CHANNEL_MEDIUM_IPMB:
2521 if (msg->rsp[4] & 0x04) {
2522 /* It's a response, so find the
2523 requesting message and send it up. */
2524 requeue = handle_ipmb_get_msg_rsp(intf, msg);
2526 /* It's a command to the SMS from some other
2527 entity. Handle that. */
2528 requeue = handle_ipmb_get_msg_cmd(intf, msg);
2532 case IPMI_CHANNEL_MEDIUM_8023LAN:
2533 case IPMI_CHANNEL_MEDIUM_ASYNC:
2534 if (msg->rsp[6] & 0x04) {
2535 /* It's a response, so find the
2536 requesting message and send it up. */
2537 requeue = handle_lan_get_msg_rsp(intf, msg);
2539 /* It's a command to the SMS from some other
2540 entity. Handle that. */
2541 requeue = handle_lan_get_msg_cmd(intf, msg);
2546 /* We don't handle the channel type, so just
2547 * free the message. */
2551 } else if ((msg->rsp[0] == ((IPMI_NETFN_APP_REQUEST|1) << 2))
2552 && (msg->rsp[1] == IPMI_READ_EVENT_MSG_BUFFER_CMD))
2554 /* It's an asyncronous event. */
2555 requeue = handle_read_event_rsp(intf, msg);
2557 /* It's a response from the local BMC. */
2558 requeue = handle_bmc_rsp(intf, msg);
2565 /* Handle a new message from the lower layer. */
2566 void ipmi_smi_msg_received(ipmi_smi_t intf,
2567 struct ipmi_smi_msg *msg)
2569 unsigned long flags;
2573 /* Lock the user lock so the user can't go away while we are
2575 read_lock(&(intf->users_lock));
2577 if ((msg->data_size >= 2)
2578 && (msg->data[0] == (IPMI_NETFN_APP_REQUEST << 2))
2579 && (msg->data[1] == IPMI_SEND_MSG_CMD)
2580 && (msg->user_data == NULL)) {
2581 /* This is the local response to a command send, start
2582 the timer for these. The user_data will not be
2583 NULL if this is a response send, and we will let
2584 response sends just go through. */
2586 /* Check for errors, if we get certain errors (ones
2587 that mean basically we can try again later), we
2588 ignore them and start the timer. Otherwise we
2589 report the error immediately. */
2590 if ((msg->rsp_size >= 3) && (msg->rsp[2] != 0)
2591 && (msg->rsp[2] != IPMI_NODE_BUSY_ERR)
2592 && (msg->rsp[2] != IPMI_LOST_ARBITRATION_ERR))
2594 int chan = msg->rsp[3] & 0xf;
2596 /* Got an error sending the message, handle it. */
2597 spin_lock_irqsave(&intf->counter_lock, flags);
2598 if (chan >= IPMI_MAX_CHANNELS)
2599 ; /* This shouldn't happen */
2600 else if ((intf->channels[chan].medium
2601 == IPMI_CHANNEL_MEDIUM_8023LAN)
2602 || (intf->channels[chan].medium
2603 == IPMI_CHANNEL_MEDIUM_ASYNC))
2604 intf->sent_lan_command_errs++;
2606 intf->sent_ipmb_command_errs++;
2607 spin_unlock_irqrestore(&intf->counter_lock, flags);
2608 intf_err_seq(intf, msg->msgid, msg->rsp[2]);
2610 /* The message was sent, start the timer. */
2611 intf_start_seq_timer(intf, msg->msgid);
2614 ipmi_free_smi_msg(msg);
2618 /* To preserve message order, if the list is not empty, we
2619 tack this message onto the end of the list. */
2620 spin_lock_irqsave(&(intf->waiting_msgs_lock), flags);
2621 if (!list_empty(&(intf->waiting_msgs))) {
2622 list_add_tail(&(msg->link), &(intf->waiting_msgs));
2623 spin_unlock(&(intf->waiting_msgs_lock));
2626 spin_unlock_irqrestore(&(intf->waiting_msgs_lock), flags);
2628 rv = handle_new_recv_msg(intf, msg);
2630 /* Could not handle the message now, just add it to a
2631 list to handle later. */
2632 spin_lock(&(intf->waiting_msgs_lock));
2633 list_add_tail(&(msg->link), &(intf->waiting_msgs));
2634 spin_unlock(&(intf->waiting_msgs_lock));
2635 } else if (rv == 0) {
2636 ipmi_free_smi_msg(msg);
2640 read_unlock(&(intf->users_lock));
2643 void ipmi_smi_watchdog_pretimeout(ipmi_smi_t intf)
2647 read_lock(&(intf->users_lock));
2648 list_for_each_entry(user, &(intf->users), link) {
2649 if (! user->handler->ipmi_watchdog_pretimeout)
2652 user->handler->ipmi_watchdog_pretimeout(user->handler_data);
2654 read_unlock(&(intf->users_lock));
2658 handle_msg_timeout(struct ipmi_recv_msg *msg)
2660 msg->recv_type = IPMI_RESPONSE_RECV_TYPE;
2661 msg->msg_data[0] = IPMI_TIMEOUT_COMPLETION_CODE;
2662 msg->msg.netfn |= 1; /* Convert to a response. */
2663 msg->msg.data_len = 1;
2664 msg->msg.data = msg->msg_data;
2665 deliver_response(msg);
2668 static struct ipmi_smi_msg *
2669 smi_from_recv_msg(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg,
2670 unsigned char seq, long seqid)
2672 struct ipmi_smi_msg *smi_msg = ipmi_alloc_smi_msg();
2674 /* If we can't allocate the message, then just return, we
2675 get 4 retries, so this should be ok. */
2678 memcpy(smi_msg->data, recv_msg->msg.data, recv_msg->msg.data_len);
2679 smi_msg->data_size = recv_msg->msg.data_len;
2680 smi_msg->msgid = STORE_SEQ_IN_MSGID(seq, seqid);
2686 for (m = 0; m < smi_msg->data_size; m++)
2687 printk(" %2.2x", smi_msg->data[m]);
2695 ipmi_timeout_handler(long timeout_period)
2698 struct list_head timeouts;
2699 struct ipmi_recv_msg *msg, *msg2;
2700 struct ipmi_smi_msg *smi_msg, *smi_msg2;
2701 unsigned long flags;
2704 INIT_LIST_HEAD(&timeouts);
2706 spin_lock(&interfaces_lock);
2707 for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
2708 intf = ipmi_interfaces[i];
2712 read_lock(&(intf->users_lock));
2714 /* See if any waiting messages need to be processed. */
2715 spin_lock_irqsave(&(intf->waiting_msgs_lock), flags);
2716 list_for_each_entry_safe(smi_msg, smi_msg2, &(intf->waiting_msgs), link) {
2717 if (! handle_new_recv_msg(intf, smi_msg)) {
2718 list_del(&smi_msg->link);
2719 ipmi_free_smi_msg(smi_msg);
2721 /* To preserve message order, quit if we
2722 can't handle a message. */
2726 spin_unlock_irqrestore(&(intf->waiting_msgs_lock), flags);
2728 /* Go through the seq table and find any messages that
2729 have timed out, putting them in the timeouts
2731 spin_lock_irqsave(&(intf->seq_lock), flags);
2732 for (j = 0; j < IPMI_IPMB_NUM_SEQ; j++) {
2733 struct seq_table *ent = &(intf->seq_table[j]);
2737 ent->timeout -= timeout_period;
2738 if (ent->timeout > 0)
2741 if (ent->retries_left == 0) {
2742 /* The message has used all its retries. */
2744 msg = ent->recv_msg;
2745 list_add_tail(&(msg->link), &timeouts);
2746 spin_lock(&intf->counter_lock);
2748 intf->timed_out_ipmb_broadcasts++;
2749 else if (ent->recv_msg->addr.addr_type
2750 == IPMI_LAN_ADDR_TYPE)
2751 intf->timed_out_lan_commands++;
2753 intf->timed_out_ipmb_commands++;
2754 spin_unlock(&intf->counter_lock);
2756 struct ipmi_smi_msg *smi_msg;
2757 /* More retries, send again. */
2759 /* Start with the max timer, set to normal
2760 timer after the message is sent. */
2761 ent->timeout = MAX_MSG_TIMEOUT;
2762 ent->retries_left--;
2763 spin_lock(&intf->counter_lock);
2764 if (ent->recv_msg->addr.addr_type
2765 == IPMI_LAN_ADDR_TYPE)
2766 intf->retransmitted_lan_commands++;
2768 intf->retransmitted_ipmb_commands++;
2769 spin_unlock(&intf->counter_lock);
2770 smi_msg = smi_from_recv_msg(intf,
2771 ent->recv_msg, j, ent->seqid);
2775 spin_unlock_irqrestore(&(intf->seq_lock),flags);
2776 /* Send the new message. We send with a zero
2777 * priority. It timed out, I doubt time is
2778 * that critical now, and high priority
2779 * messages are really only for messages to the
2780 * local MC, which don't get resent. */
2781 intf->handlers->sender(intf->send_info,
2783 spin_lock_irqsave(&(intf->seq_lock), flags);
2786 spin_unlock_irqrestore(&(intf->seq_lock), flags);
2788 list_for_each_entry_safe(msg, msg2, &timeouts, link) {
2789 handle_msg_timeout(msg);
2792 read_unlock(&(intf->users_lock));
2794 spin_unlock(&interfaces_lock);
2797 static void ipmi_request_event(void)
2802 spin_lock(&interfaces_lock);
2803 for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
2804 intf = ipmi_interfaces[i];
2808 intf->handlers->request_events(intf->send_info);
2810 spin_unlock(&interfaces_lock);
2813 static struct timer_list ipmi_timer;
2815 /* Call every ~100 ms. */
2816 #define IPMI_TIMEOUT_TIME 100
2818 /* How many jiffies does it take to get to the timeout time. */
2819 #define IPMI_TIMEOUT_JIFFIES ((IPMI_TIMEOUT_TIME * HZ) / 1000)
2821 /* Request events from the queue every second (this is the number of
2822 IPMI_TIMEOUT_TIMES between event requests). Hopefully, in the
2823 future, IPMI will add a way to know immediately if an event is in
2824 the queue and this silliness can go away. */
2825 #define IPMI_REQUEST_EV_TIME (1000 / (IPMI_TIMEOUT_TIME))
2827 static atomic_t stop_operation;
2828 static unsigned int ticks_to_req_ev = IPMI_REQUEST_EV_TIME;
2830 static void ipmi_timeout(unsigned long data)
2832 if (atomic_read(&stop_operation))
2836 if (ticks_to_req_ev == 0) {
2837 ipmi_request_event();
2838 ticks_to_req_ev = IPMI_REQUEST_EV_TIME;
2841 ipmi_timeout_handler(IPMI_TIMEOUT_TIME);
2843 mod_timer(&ipmi_timer, jiffies + IPMI_TIMEOUT_JIFFIES);
2847 static atomic_t smi_msg_inuse_count = ATOMIC_INIT(0);
2848 static atomic_t recv_msg_inuse_count = ATOMIC_INIT(0);
2850 /* FIXME - convert these to slabs. */
2851 static void free_smi_msg(struct ipmi_smi_msg *msg)
2853 atomic_dec(&smi_msg_inuse_count);
2857 struct ipmi_smi_msg *ipmi_alloc_smi_msg(void)
2859 struct ipmi_smi_msg *rv;
2860 rv = kmalloc(sizeof(struct ipmi_smi_msg), GFP_ATOMIC);
2862 rv->done = free_smi_msg;
2863 rv->user_data = NULL;
2864 atomic_inc(&smi_msg_inuse_count);
2869 static void free_recv_msg(struct ipmi_recv_msg *msg)
2871 atomic_dec(&recv_msg_inuse_count);
2875 struct ipmi_recv_msg *ipmi_alloc_recv_msg(void)
2877 struct ipmi_recv_msg *rv;
2879 rv = kmalloc(sizeof(struct ipmi_recv_msg), GFP_ATOMIC);
2881 rv->done = free_recv_msg;
2882 atomic_inc(&recv_msg_inuse_count);
2887 #ifdef CONFIG_IPMI_PANIC_EVENT
2889 static void dummy_smi_done_handler(struct ipmi_smi_msg *msg)
2893 static void dummy_recv_done_handler(struct ipmi_recv_msg *msg)
2897 #ifdef CONFIG_IPMI_PANIC_STRING
2898 static void event_receiver_fetcher(ipmi_smi_t intf, struct ipmi_recv_msg *msg)
2900 if ((msg->addr.addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE)
2901 && (msg->msg.netfn == IPMI_NETFN_SENSOR_EVENT_RESPONSE)
2902 && (msg->msg.cmd == IPMI_GET_EVENT_RECEIVER_CMD)
2903 && (msg->msg.data[0] == IPMI_CC_NO_ERROR))
2905 /* A get event receiver command, save it. */
2906 intf->event_receiver = msg->msg.data[1];
2907 intf->event_receiver_lun = msg->msg.data[2] & 0x3;
2911 static void device_id_fetcher(ipmi_smi_t intf, struct ipmi_recv_msg *msg)
2913 if ((msg->addr.addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE)
2914 && (msg->msg.netfn == IPMI_NETFN_APP_RESPONSE)
2915 && (msg->msg.cmd == IPMI_GET_DEVICE_ID_CMD)
2916 && (msg->msg.data[0] == IPMI_CC_NO_ERROR))
2918 /* A get device id command, save if we are an event
2919 receiver or generator. */
2920 intf->local_sel_device = (msg->msg.data[6] >> 2) & 1;
2921 intf->local_event_generator = (msg->msg.data[6] >> 5) & 1;
2926 static void send_panic_events(char *str)
2928 struct kernel_ipmi_msg msg;
2930 unsigned char data[16];
2932 struct ipmi_system_interface_addr *si;
2933 struct ipmi_addr addr;
2934 struct ipmi_smi_msg smi_msg;
2935 struct ipmi_recv_msg recv_msg;
2937 si = (struct ipmi_system_interface_addr *) &addr;
2938 si->addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
2939 si->channel = IPMI_BMC_CHANNEL;
2942 /* Fill in an event telling that we have failed. */
2943 msg.netfn = 0x04; /* Sensor or Event. */
2944 msg.cmd = 2; /* Platform event command. */
2947 data[0] = 0x21; /* Kernel generator ID, IPMI table 5-4 */
2948 data[1] = 0x03; /* This is for IPMI 1.0. */
2949 data[2] = 0x20; /* OS Critical Stop, IPMI table 36-3 */
2950 data[4] = 0x6f; /* Sensor specific, IPMI table 36-1 */
2951 data[5] = 0xa1; /* Runtime stop OEM bytes 2 & 3. */
2953 /* Put a few breadcrumbs in. Hopefully later we can add more things
2954 to make the panic events more useful. */
2961 smi_msg.done = dummy_smi_done_handler;
2962 recv_msg.done = dummy_recv_done_handler;
2964 /* For every registered interface, send the event. */
2965 for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
2966 intf = ipmi_interfaces[i];
2970 /* Send the event announcing the panic. */
2971 intf->handlers->set_run_to_completion(intf->send_info, 1);
2972 i_ipmi_request(NULL,
2981 intf->channels[0].address,
2982 intf->channels[0].lun,
2983 0, 1); /* Don't retry, and don't wait. */
2986 #ifdef CONFIG_IPMI_PANIC_STRING
2987 /* On every interface, dump a bunch of OEM event holding the
2992 for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
2994 struct ipmi_ipmb_addr *ipmb;
2997 intf = ipmi_interfaces[i];
3001 /* First job here is to figure out where to send the
3002 OEM events. There's no way in IPMI to send OEM
3003 events using an event send command, so we have to
3004 find the SEL to put them in and stick them in
3007 /* Get capabilities from the get device id. */
3008 intf->local_sel_device = 0;
3009 intf->local_event_generator = 0;
3010 intf->event_receiver = 0;
3012 /* Request the device info from the local MC. */
3013 msg.netfn = IPMI_NETFN_APP_REQUEST;
3014 msg.cmd = IPMI_GET_DEVICE_ID_CMD;
3017 intf->null_user_handler = device_id_fetcher;
3018 i_ipmi_request(NULL,
3027 intf->channels[0].address,
3028 intf->channels[0].lun,
3029 0, 1); /* Don't retry, and don't wait. */
3031 if (intf->local_event_generator) {
3032 /* Request the event receiver from the local MC. */
3033 msg.netfn = IPMI_NETFN_SENSOR_EVENT_REQUEST;
3034 msg.cmd = IPMI_GET_EVENT_RECEIVER_CMD;
3037 intf->null_user_handler = event_receiver_fetcher;
3038 i_ipmi_request(NULL,
3047 intf->channels[0].address,
3048 intf->channels[0].lun,
3049 0, 1); /* no retry, and no wait. */
3051 intf->null_user_handler = NULL;
3053 /* Validate the event receiver. The low bit must not
3054 be 1 (it must be a valid IPMB address), it cannot
3055 be zero, and it must not be my address. */
3056 if (((intf->event_receiver & 1) == 0)
3057 && (intf->event_receiver != 0)
3058 && (intf->event_receiver != intf->channels[0].address))
3060 /* The event receiver is valid, send an IPMB
3062 ipmb = (struct ipmi_ipmb_addr *) &addr;
3063 ipmb->addr_type = IPMI_IPMB_ADDR_TYPE;
3064 ipmb->channel = 0; /* FIXME - is this right? */
3065 ipmb->lun = intf->event_receiver_lun;
3066 ipmb->slave_addr = intf->event_receiver;
3067 } else if (intf->local_sel_device) {
3068 /* The event receiver was not valid (or was
3069 me), but I am an SEL device, just dump it
3071 si = (struct ipmi_system_interface_addr *) &addr;
3072 si->addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
3073 si->channel = IPMI_BMC_CHANNEL;
3076 continue; /* No where to send the event. */
3079 msg.netfn = IPMI_NETFN_STORAGE_REQUEST; /* Storage. */
3080 msg.cmd = IPMI_ADD_SEL_ENTRY_CMD;
3086 int size = strlen(p);
3092 data[2] = 0xf0; /* OEM event without timestamp. */
3093 data[3] = intf->channels[0].address;
3094 data[4] = j++; /* sequence # */
3095 /* Always give 11 bytes, so strncpy will fill
3096 it with zeroes for me. */
3097 strncpy(data+5, p, 11);
3100 i_ipmi_request(NULL,
3109 intf->channels[0].address,
3110 intf->channels[0].lun,
3111 0, 1); /* no retry, and no wait. */
3114 #endif /* CONFIG_IPMI_PANIC_STRING */
3116 #endif /* CONFIG_IPMI_PANIC_EVENT */
3118 static int has_paniced = 0;
3120 static int panic_event(struct notifier_block *this,
3121 unsigned long event,
3131 /* For every registered interface, set it to run to completion. */
3132 for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
3133 intf = ipmi_interfaces[i];
3137 intf->handlers->set_run_to_completion(intf->send_info, 1);
3140 #ifdef CONFIG_IPMI_PANIC_EVENT
3141 send_panic_events(ptr);
3147 static struct notifier_block panic_block = {
3148 .notifier_call = panic_event,
3150 .priority = 200 /* priority: INT_MAX >= x >= 0 */
3153 static int ipmi_init_msghandler(void)
3160 printk(KERN_INFO "ipmi message handler version "
3161 IPMI_DRIVER_VERSION "\n");
3163 for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
3164 ipmi_interfaces[i] = NULL;
3167 #ifdef CONFIG_PROC_FS
3168 proc_ipmi_root = proc_mkdir("ipmi", NULL);
3169 if (!proc_ipmi_root) {
3170 printk(KERN_ERR PFX "Unable to create IPMI proc dir");
3174 proc_ipmi_root->owner = THIS_MODULE;
3175 #endif /* CONFIG_PROC_FS */
3177 init_timer(&ipmi_timer);
3178 ipmi_timer.data = 0;
3179 ipmi_timer.function = ipmi_timeout;
3180 ipmi_timer.expires = jiffies + IPMI_TIMEOUT_JIFFIES;
3181 add_timer(&ipmi_timer);
3183 notifier_chain_register(&panic_notifier_list, &panic_block);
3190 static __init int ipmi_init_msghandler_mod(void)
3192 ipmi_init_msghandler();
3196 static __exit void cleanup_ipmi(void)
3203 notifier_chain_unregister(&panic_notifier_list, &panic_block);
3205 /* This can't be called if any interfaces exist, so no worry about
3206 shutting down the interfaces. */
3208 /* Tell the timer to stop, then wait for it to stop. This avoids
3209 problems with race conditions removing the timer here. */
3210 atomic_inc(&stop_operation);
3211 del_timer_sync(&ipmi_timer);
3213 #ifdef CONFIG_PROC_FS
3214 remove_proc_entry(proc_ipmi_root->name, &proc_root);
3215 #endif /* CONFIG_PROC_FS */
3219 /* Check for buffer leaks. */
3220 count = atomic_read(&smi_msg_inuse_count);
3222 printk(KERN_WARNING PFX "SMI message count %d at exit\n",
3224 count = atomic_read(&recv_msg_inuse_count);
3226 printk(KERN_WARNING PFX "recv message count %d at exit\n",
3229 module_exit(cleanup_ipmi);
3231 module_init(ipmi_init_msghandler_mod);
3232 MODULE_LICENSE("GPL");
3233 MODULE_AUTHOR("Corey Minyard <minyard@mvista.com>");
3234 MODULE_DESCRIPTION("Incoming and outgoing message routing for an IPMI interface.");
3235 MODULE_VERSION(IPMI_DRIVER_VERSION);
3237 EXPORT_SYMBOL(ipmi_create_user);
3238 EXPORT_SYMBOL(ipmi_destroy_user);
3239 EXPORT_SYMBOL(ipmi_get_version);
3240 EXPORT_SYMBOL(ipmi_request_settime);
3241 EXPORT_SYMBOL(ipmi_request_supply_msgs);
3242 EXPORT_SYMBOL(ipmi_register_smi);
3243 EXPORT_SYMBOL(ipmi_unregister_smi);
3244 EXPORT_SYMBOL(ipmi_register_for_cmd);
3245 EXPORT_SYMBOL(ipmi_unregister_for_cmd);
3246 EXPORT_SYMBOL(ipmi_smi_msg_received);
3247 EXPORT_SYMBOL(ipmi_smi_watchdog_pretimeout);
3248 EXPORT_SYMBOL(ipmi_alloc_smi_msg);
3249 EXPORT_SYMBOL(ipmi_addr_length);
3250 EXPORT_SYMBOL(ipmi_validate_addr);
3251 EXPORT_SYMBOL(ipmi_set_gets_events);
3252 EXPORT_SYMBOL(ipmi_smi_watcher_register);
3253 EXPORT_SYMBOL(ipmi_smi_watcher_unregister);
3254 EXPORT_SYMBOL(ipmi_set_my_address);
3255 EXPORT_SYMBOL(ipmi_get_my_address);
3256 EXPORT_SYMBOL(ipmi_set_my_LUN);
3257 EXPORT_SYMBOL(ipmi_get_my_LUN);
3258 EXPORT_SYMBOL(ipmi_smi_add_proc_entry);
3259 EXPORT_SYMBOL(proc_ipmi_root);
3260 EXPORT_SYMBOL(ipmi_user_set_run_to_completion);