aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/ipmi/ipmi_msghandler.c
diff options
context:
space:
mode:
authorCorey Minyard <cminyard@mvista.com>2008-04-29 04:01:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-29 11:06:15 -0400
commitc70d749986f6f1d4e2bb008bfc0c5fc22ec3fc64 (patch)
tree69ddc91cf39938e5ec3ba7924cff78c6760de927 /drivers/char/ipmi/ipmi_msghandler.c
parentba8ff1c61eb119e687b06ca35f7f4ab041bf0422 (diff)
ipmi: style fixes in the base code
Lots of style fixes for the base IPMI driver. No functional changes. Basically fixes everything reported by checkpatch and fixes the comment style. Signed-off-by: Corey Minyard <cminyard@mvista.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/ipmi/ipmi_msghandler.c')
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c995
1 files changed, 581 insertions, 414 deletions
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index ea6ba35b3d7e..5b13579ca21d 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -63,15 +63,16 @@ static struct proc_dir_entry *proc_ipmi_root;
63 63
64#define MAX_EVENTS_IN_QUEUE 25 64#define MAX_EVENTS_IN_QUEUE 25
65 65
66/* Don't let a message sit in a queue forever, always time it with at lest 66/*
67 the max message timer. This is in milliseconds. */ 67 * Don't let a message sit in a queue forever, always time it with at lest
68 * the max message timer. This is in milliseconds.
69 */
68#define MAX_MSG_TIMEOUT 60000 70#define MAX_MSG_TIMEOUT 60000
69 71
70/* 72/*
71 * The main "user" data structure. 73 * The main "user" data structure.
72 */ 74 */
73struct ipmi_user 75struct ipmi_user {
74{
75 struct list_head link; 76 struct list_head link;
76 77
77 /* Set to "0" when the user is destroyed. */ 78 /* Set to "0" when the user is destroyed. */
@@ -90,8 +91,7 @@ struct ipmi_user
90 int gets_events; 91 int gets_events;
91}; 92};
92 93
93struct cmd_rcvr 94struct cmd_rcvr {
94{
95 struct list_head link; 95 struct list_head link;
96 96
97 ipmi_user_t user; 97 ipmi_user_t user;
@@ -105,12 +105,12 @@ struct cmd_rcvr
105 * or change any data until the RCU period completes. So we 105 * or change any data until the RCU period completes. So we
106 * use this next variable during mass deletion so we can have 106 * use this next variable during mass deletion so we can have
107 * a list and don't have to wait and restart the search on 107 * a list and don't have to wait and restart the search on
108 * every individual deletion of a command. */ 108 * every individual deletion of a command.
109 */
109 struct cmd_rcvr *next; 110 struct cmd_rcvr *next;
110}; 111};
111 112
112struct seq_table 113struct seq_table {
113{
114 unsigned int inuse : 1; 114 unsigned int inuse : 1;
115 unsigned int broadcast : 1; 115 unsigned int broadcast : 1;
116 116
@@ -118,53 +118,60 @@ struct seq_table
118 unsigned long orig_timeout; 118 unsigned long orig_timeout;
119 unsigned int retries_left; 119 unsigned int retries_left;
120 120
121 /* To verify on an incoming send message response that this is 121 /*
122 the message that the response is for, we keep a sequence id 122 * To verify on an incoming send message response that this is
123 and increment it every time we send a message. */ 123 * the message that the response is for, we keep a sequence id
124 * and increment it every time we send a message.
125 */
124 long seqid; 126 long seqid;
125 127
126 /* This is held so we can properly respond to the message on a 128 /*
127 timeout, and it is used to hold the temporary data for 129 * This is held so we can properly respond to the message on a
128 retransmission, too. */ 130 * timeout, and it is used to hold the temporary data for
131 * retransmission, too.
132 */
129 struct ipmi_recv_msg *recv_msg; 133 struct ipmi_recv_msg *recv_msg;
130}; 134};
131 135
132/* Store the information in a msgid (long) to allow us to find a 136/*
133 sequence table entry from the msgid. */ 137 * Store the information in a msgid (long) to allow us to find a
138 * sequence table entry from the msgid.
139 */
134#define STORE_SEQ_IN_MSGID(seq, seqid) (((seq&0xff)<<26) | (seqid&0x3ffffff)) 140#define STORE_SEQ_IN_MSGID(seq, seqid) (((seq&0xff)<<26) | (seqid&0x3ffffff))
135 141
136#define GET_SEQ_FROM_MSGID(msgid, seq, seqid) \ 142#define GET_SEQ_FROM_MSGID(msgid, seq, seqid) \
137 do { \ 143 do { \
138 seq = ((msgid >> 26) & 0x3f); \ 144 seq = ((msgid >> 26) & 0x3f); \
139 seqid = (msgid & 0x3fffff); \ 145 seqid = (msgid & 0x3fffff); \
140 } while (0) 146 } while (0)
141 147
142#define NEXT_SEQID(seqid) (((seqid) + 1) & 0x3fffff) 148#define NEXT_SEQID(seqid) (((seqid) + 1) & 0x3fffff)
143 149
144struct ipmi_channel 150struct ipmi_channel {
145{
146 unsigned char medium; 151 unsigned char medium;
147 unsigned char protocol; 152 unsigned char protocol;
148 153
149 /* My slave address. This is initialized to IPMI_BMC_SLAVE_ADDR, 154 /*
150 but may be changed by the user. */ 155 * My slave address. This is initialized to IPMI_BMC_SLAVE_ADDR,
156 * but may be changed by the user.
157 */
151 unsigned char address; 158 unsigned char address;
152 159
153 /* My LUN. This should generally stay the SMS LUN, but just in 160 /*
154 case... */ 161 * My LUN. This should generally stay the SMS LUN, but just in
162 * case...
163 */
155 unsigned char lun; 164 unsigned char lun;
156}; 165};
157 166
158#ifdef CONFIG_PROC_FS 167#ifdef CONFIG_PROC_FS
159struct ipmi_proc_entry 168struct ipmi_proc_entry {
160{
161 char *name; 169 char *name;
162 struct ipmi_proc_entry *next; 170 struct ipmi_proc_entry *next;
163}; 171};
164#endif 172#endif
165 173
166struct bmc_device 174struct bmc_device {
167{
168 struct platform_device *dev; 175 struct platform_device *dev;
169 struct ipmi_device_id id; 176 struct ipmi_device_id id;
170 unsigned char guid[16]; 177 unsigned char guid[16];
@@ -286,8 +293,7 @@ enum ipmi_stat_indexes {
286 293
287#define IPMI_IPMB_NUM_SEQ 64 294#define IPMI_IPMB_NUM_SEQ 64
288#define IPMI_MAX_CHANNELS 16 295#define IPMI_MAX_CHANNELS 16
289struct ipmi_smi 296struct ipmi_smi {
290{
291 /* What interface number are we? */ 297 /* What interface number are we? */
292 int intf_num; 298 int intf_num;
293 299
@@ -296,8 +302,10 @@ struct ipmi_smi
296 /* Used for a list of interfaces. */ 302 /* Used for a list of interfaces. */
297 struct list_head link; 303 struct list_head link;
298 304
299 /* The list of upper layers that are using me. seq_lock 305 /*
300 * protects this. */ 306 * The list of upper layers that are using me. seq_lock
307 * protects this.
308 */
301 struct list_head users; 309 struct list_head users;
302 310
303 /* Information to supply to users. */ 311 /* Information to supply to users. */
@@ -311,10 +319,12 @@ struct ipmi_smi
311 char *my_dev_name; 319 char *my_dev_name;
312 char *sysfs_name; 320 char *sysfs_name;
313 321
314 /* This is the lower-layer's sender routine. Note that you 322 /*
323 * This is the lower-layer's sender routine. Note that you
315 * must either be holding the ipmi_interfaces_mutex or be in 324 * must either be holding the ipmi_interfaces_mutex or be in
316 * an umpreemptible region to use this. You must fetch the 325 * an umpreemptible region to use this. You must fetch the
317 * value into a local variable and make sure it is not NULL. */ 326 * value into a local variable and make sure it is not NULL.
327 */
318 struct ipmi_smi_handlers *handlers; 328 struct ipmi_smi_handlers *handlers;
319 void *send_info; 329 void *send_info;
320 330
@@ -327,35 +337,45 @@ struct ipmi_smi
327 /* Driver-model device for the system interface. */ 337 /* Driver-model device for the system interface. */
328 struct device *si_dev; 338 struct device *si_dev;
329 339
330 /* A table of sequence numbers for this interface. We use the 340 /*
331 sequence numbers for IPMB messages that go out of the 341 * A table of sequence numbers for this interface. We use the
332 interface to match them up with their responses. A routine 342 * sequence numbers for IPMB messages that go out of the
333 is called periodically to time the items in this list. */ 343 * interface to match them up with their responses. A routine
344 * is called periodically to time the items in this list.
345 */
334 spinlock_t seq_lock; 346 spinlock_t seq_lock;
335 struct seq_table seq_table[IPMI_IPMB_NUM_SEQ]; 347 struct seq_table seq_table[IPMI_IPMB_NUM_SEQ];
336 int curr_seq; 348 int curr_seq;
337 349
338 /* Messages that were delayed for some reason (out of memory, 350 /*
339 for instance), will go in here to be processed later in a 351 * Messages that were delayed for some reason (out of memory,
340 periodic timer interrupt. */ 352 * for instance), will go in here to be processed later in a
353 * periodic timer interrupt.
354 */
341 spinlock_t waiting_msgs_lock; 355 spinlock_t waiting_msgs_lock;
342 struct list_head waiting_msgs; 356 struct list_head waiting_msgs;
343 357
344 /* The list of command receivers that are registered for commands 358 /*
345 on this interface. */ 359 * The list of command receivers that are registered for commands
360 * on this interface.
361 */
346 struct mutex cmd_rcvrs_mutex; 362 struct mutex cmd_rcvrs_mutex;
347 struct list_head cmd_rcvrs; 363 struct list_head cmd_rcvrs;
348 364
349 /* Events that were queues because no one was there to receive 365 /*
350 them. */ 366 * Events that were queues because no one was there to receive
367 * them.
368 */
351 spinlock_t events_lock; /* For dealing with event stuff. */ 369 spinlock_t events_lock; /* For dealing with event stuff. */
352 struct list_head waiting_events; 370 struct list_head waiting_events;
353 unsigned int waiting_events_count; /* How many events in queue? */ 371 unsigned int waiting_events_count; /* How many events in queue? */
354 char delivering_events; 372 char delivering_events;
355 char event_msg_printed; 373 char event_msg_printed;
356 374
357 /* The event receiver for my BMC, only really used at panic 375 /*
358 shutdown as a place to store this. */ 376 * The event receiver for my BMC, only really used at panic
377 * shutdown as a place to store this.
378 */
359 unsigned char event_receiver; 379 unsigned char event_receiver;
360 unsigned char event_receiver_lun; 380 unsigned char event_receiver_lun;
361 unsigned char local_sel_device; 381 unsigned char local_sel_device;
@@ -367,14 +387,18 @@ struct ipmi_smi
367 int auto_maintenance_timeout; 387 int auto_maintenance_timeout;
368 spinlock_t maintenance_mode_lock; /* Used in a timer... */ 388 spinlock_t maintenance_mode_lock; /* Used in a timer... */
369 389
370 /* A cheap hack, if this is non-null and a message to an 390 /*
371 interface comes in with a NULL user, call this routine with 391 * A cheap hack, if this is non-null and a message to an
372 it. Note that the message will still be freed by the 392 * interface comes in with a NULL user, call this routine with
373 caller. This only works on the system interface. */ 393 * it. Note that the message will still be freed by the
394 * caller. This only works on the system interface.
395 */
374 void (*null_user_handler)(ipmi_smi_t intf, struct ipmi_recv_msg *msg); 396 void (*null_user_handler)(ipmi_smi_t intf, struct ipmi_recv_msg *msg);
375 397
376 /* When we are scanning the channels for an SMI, this will 398 /*
377 tell which channel we are scanning. */ 399 * When we are scanning the channels for an SMI, this will
400 * tell which channel we are scanning.
401 */
378 int curr_channel; 402 int curr_channel;
379 403
380 /* Channel information */ 404 /* Channel information */
@@ -407,8 +431,9 @@ static DEFINE_MUTEX(ipmidriver_mutex);
407static LIST_HEAD(ipmi_interfaces); 431static LIST_HEAD(ipmi_interfaces);
408static DEFINE_MUTEX(ipmi_interfaces_mutex); 432static DEFINE_MUTEX(ipmi_interfaces_mutex);
409 433
410/* List of watchers that want to know when smi's are added and 434/*
411 deleted. */ 435 * List of watchers that want to know when smi's are added and deleted.
436 */
412static LIST_HEAD(smi_watchers); 437static LIST_HEAD(smi_watchers);
413static DEFINE_MUTEX(smi_watchers_mutex); 438static DEFINE_MUTEX(smi_watchers_mutex);
414 439
@@ -462,10 +487,8 @@ static void clean_up_interface_data(ipmi_smi_t intf)
462 487
463 for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) { 488 for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) {
464 if ((intf->seq_table[i].inuse) 489 if ((intf->seq_table[i].inuse)
465 && (intf->seq_table[i].recv_msg)) 490 && (intf->seq_table[i].recv_msg))
466 {
467 ipmi_free_recv_msg(intf->seq_table[i].recv_msg); 491 ipmi_free_recv_msg(intf->seq_table[i].recv_msg);
468 }
469 } 492 }
470} 493}
471 494
@@ -532,6 +555,7 @@ int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher)
532 } 555 }
533 return -ENOMEM; 556 return -ENOMEM;
534} 557}
558EXPORT_SYMBOL(ipmi_smi_watcher_register);
535 559
536int ipmi_smi_watcher_unregister(struct ipmi_smi_watcher *watcher) 560int ipmi_smi_watcher_unregister(struct ipmi_smi_watcher *watcher)
537{ 561{
@@ -540,6 +564,7 @@ int ipmi_smi_watcher_unregister(struct ipmi_smi_watcher *watcher)
540 mutex_unlock(&smi_watchers_mutex); 564 mutex_unlock(&smi_watchers_mutex);
541 return 0; 565 return 0;
542} 566}
567EXPORT_SYMBOL(ipmi_smi_watcher_unregister);
543 568
544/* 569/*
545 * Must be called with smi_watchers_mutex held. 570 * Must be called with smi_watchers_mutex held.
@@ -575,8 +600,7 @@ ipmi_addr_equal(struct ipmi_addr *addr1, struct ipmi_addr *addr2)
575 } 600 }
576 601
577 if ((addr1->addr_type == IPMI_IPMB_ADDR_TYPE) 602 if ((addr1->addr_type == IPMI_IPMB_ADDR_TYPE)
578 || (addr1->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) 603 || (addr1->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) {
579 {
580 struct ipmi_ipmb_addr *ipmb_addr1 604 struct ipmi_ipmb_addr *ipmb_addr1
581 = (struct ipmi_ipmb_addr *) addr1; 605 = (struct ipmi_ipmb_addr *) addr1;
582 struct ipmi_ipmb_addr *ipmb_addr2 606 struct ipmi_ipmb_addr *ipmb_addr2
@@ -604,9 +628,8 @@ ipmi_addr_equal(struct ipmi_addr *addr1, struct ipmi_addr *addr2)
604 628
605int ipmi_validate_addr(struct ipmi_addr *addr, int len) 629int ipmi_validate_addr(struct ipmi_addr *addr, int len)
606{ 630{
607 if (len < sizeof(struct ipmi_system_interface_addr)) { 631 if (len < sizeof(struct ipmi_system_interface_addr))
608 return -EINVAL; 632 return -EINVAL;
609 }
610 633
611 if (addr->addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE) { 634 if (addr->addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE) {
612 if (addr->channel != IPMI_BMC_CHANNEL) 635 if (addr->channel != IPMI_BMC_CHANNEL)
@@ -620,23 +643,21 @@ int ipmi_validate_addr(struct ipmi_addr *addr, int len)
620 return -EINVAL; 643 return -EINVAL;
621 644
622 if ((addr->addr_type == IPMI_IPMB_ADDR_TYPE) 645 if ((addr->addr_type == IPMI_IPMB_ADDR_TYPE)
623 || (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) 646 || (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) {
624 { 647 if (len < sizeof(struct ipmi_ipmb_addr))
625 if (len < sizeof(struct ipmi_ipmb_addr)) {
626 return -EINVAL; 648 return -EINVAL;
627 }
628 return 0; 649 return 0;
629 } 650 }
630 651
631 if (addr->addr_type == IPMI_LAN_ADDR_TYPE) { 652 if (addr->addr_type == IPMI_LAN_ADDR_TYPE) {
632 if (len < sizeof(struct ipmi_lan_addr)) { 653 if (len < sizeof(struct ipmi_lan_addr))
633 return -EINVAL; 654 return -EINVAL;
634 }
635 return 0; 655 return 0;
636 } 656 }
637 657
638 return -EINVAL; 658 return -EINVAL;
639} 659}
660EXPORT_SYMBOL(ipmi_validate_addr);
640 661
641unsigned int ipmi_addr_length(int addr_type) 662unsigned int ipmi_addr_length(int addr_type)
642{ 663{
@@ -644,16 +665,15 @@ unsigned int ipmi_addr_length(int addr_type)
644 return sizeof(struct ipmi_system_interface_addr); 665 return sizeof(struct ipmi_system_interface_addr);
645 666
646 if ((addr_type == IPMI_IPMB_ADDR_TYPE) 667 if ((addr_type == IPMI_IPMB_ADDR_TYPE)
647 || (addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) 668 || (addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE))
648 {
649 return sizeof(struct ipmi_ipmb_addr); 669 return sizeof(struct ipmi_ipmb_addr);
650 }
651 670
652 if (addr_type == IPMI_LAN_ADDR_TYPE) 671 if (addr_type == IPMI_LAN_ADDR_TYPE)
653 return sizeof(struct ipmi_lan_addr); 672 return sizeof(struct ipmi_lan_addr);
654 673
655 return 0; 674 return 0;
656} 675}
676EXPORT_SYMBOL(ipmi_addr_length);
657 677
658static void deliver_response(struct ipmi_recv_msg *msg) 678static void deliver_response(struct ipmi_recv_msg *msg)
659{ 679{
@@ -686,9 +706,11 @@ deliver_err_response(struct ipmi_recv_msg *msg, int err)
686 deliver_response(msg); 706 deliver_response(msg);
687} 707}
688 708
689/* Find the next sequence number not being used and add the given 709/*
690 message with the given timeout to the sequence table. This must be 710 * Find the next sequence number not being used and add the given
691 called with the interface's seq_lock held. */ 711 * message with the given timeout to the sequence table. This must be
712 * called with the interface's seq_lock held.
713 */
692static int intf_next_seq(ipmi_smi_t intf, 714static int intf_next_seq(ipmi_smi_t intf,
693 struct ipmi_recv_msg *recv_msg, 715 struct ipmi_recv_msg *recv_msg,
694 unsigned long timeout, 716 unsigned long timeout,
@@ -700,10 +722,8 @@ static int intf_next_seq(ipmi_smi_t intf,
700 int rv = 0; 722 int rv = 0;
701 unsigned int i; 723 unsigned int i;
702 724
703 for (i = intf->curr_seq; 725 for (i = intf->curr_seq; (i+1)%IPMI_IPMB_NUM_SEQ != intf->curr_seq;
704 (i+1)%IPMI_IPMB_NUM_SEQ != intf->curr_seq; 726 i = (i+1)%IPMI_IPMB_NUM_SEQ) {
705 i = (i+1)%IPMI_IPMB_NUM_SEQ)
706 {
707 if (!intf->seq_table[i].inuse) 727 if (!intf->seq_table[i].inuse)
708 break; 728 break;
709 } 729 }
@@ -711,8 +731,10 @@ static int intf_next_seq(ipmi_smi_t intf,
711 if (!intf->seq_table[i].inuse) { 731 if (!intf->seq_table[i].inuse) {
712 intf->seq_table[i].recv_msg = recv_msg; 732 intf->seq_table[i].recv_msg = recv_msg;
713 733
714 /* Start with the maximum timeout, when the send response 734 /*
715 comes in we will start the real timer. */ 735 * Start with the maximum timeout, when the send response
736 * comes in we will start the real timer.
737 */
716 intf->seq_table[i].timeout = MAX_MSG_TIMEOUT; 738 intf->seq_table[i].timeout = MAX_MSG_TIMEOUT;
717 intf->seq_table[i].orig_timeout = timeout; 739 intf->seq_table[i].orig_timeout = timeout;
718 intf->seq_table[i].retries_left = retries; 740 intf->seq_table[i].retries_left = retries;
@@ -725,15 +747,17 @@ static int intf_next_seq(ipmi_smi_t intf,
725 } else { 747 } else {
726 rv = -EAGAIN; 748 rv = -EAGAIN;
727 } 749 }
728 750
729 return rv; 751 return rv;
730} 752}
731 753
732/* Return the receive message for the given sequence number and 754/*
733 release the sequence number so it can be reused. Some other data 755 * Return the receive message for the given sequence number and
734 is passed in to be sure the message matches up correctly (to help 756 * release the sequence number so it can be reused. Some other data
735 guard against message coming in after their timeout and the 757 * is passed in to be sure the message matches up correctly (to help
736 sequence number being reused). */ 758 * guard against message coming in after their timeout and the
759 * sequence number being reused).
760 */
737static int intf_find_seq(ipmi_smi_t intf, 761static int intf_find_seq(ipmi_smi_t intf,
738 unsigned char seq, 762 unsigned char seq,
739 short channel, 763 short channel,
@@ -752,11 +776,9 @@ static int intf_find_seq(ipmi_smi_t intf,
752 if (intf->seq_table[seq].inuse) { 776 if (intf->seq_table[seq].inuse) {
753 struct ipmi_recv_msg *msg = intf->seq_table[seq].recv_msg; 777 struct ipmi_recv_msg *msg = intf->seq_table[seq].recv_msg;
754 778
755 if ((msg->addr.channel == channel) 779 if ((msg->addr.channel == channel) && (msg->msg.cmd == cmd)
756 && (msg->msg.cmd == cmd) 780 && (msg->msg.netfn == netfn)
757 && (msg->msg.netfn == netfn) 781 && (ipmi_addr_equal(addr, &(msg->addr)))) {
758 && (ipmi_addr_equal(addr, &(msg->addr))))
759 {
760 *recv_msg = msg; 782 *recv_msg = msg;
761 intf->seq_table[seq].inuse = 0; 783 intf->seq_table[seq].inuse = 0;
762 rv = 0; 784 rv = 0;
@@ -781,11 +803,12 @@ static int intf_start_seq_timer(ipmi_smi_t intf,
781 GET_SEQ_FROM_MSGID(msgid, seq, seqid); 803 GET_SEQ_FROM_MSGID(msgid, seq, seqid);
782 804
783 spin_lock_irqsave(&(intf->seq_lock), flags); 805 spin_lock_irqsave(&(intf->seq_lock), flags);
784 /* We do this verification because the user can be deleted 806 /*
785 while a message is outstanding. */ 807 * We do this verification because the user can be deleted
808 * while a message is outstanding.
809 */
786 if ((intf->seq_table[seq].inuse) 810 if ((intf->seq_table[seq].inuse)
787 && (intf->seq_table[seq].seqid == seqid)) 811 && (intf->seq_table[seq].seqid == seqid)) {
788 {
789 struct seq_table *ent = &(intf->seq_table[seq]); 812 struct seq_table *ent = &(intf->seq_table[seq]);
790 ent->timeout = ent->orig_timeout; 813 ent->timeout = ent->orig_timeout;
791 rv = 0; 814 rv = 0;
@@ -810,11 +833,12 @@ static int intf_err_seq(ipmi_smi_t intf,
810 GET_SEQ_FROM_MSGID(msgid, seq, seqid); 833 GET_SEQ_FROM_MSGID(msgid, seq, seqid);
811 834
812 spin_lock_irqsave(&(intf->seq_lock), flags); 835 spin_lock_irqsave(&(intf->seq_lock), flags);
813 /* We do this verification because the user can be deleted 836 /*
814 while a message is outstanding. */ 837 * We do this verification because the user can be deleted
838 * while a message is outstanding.
839 */
815 if ((intf->seq_table[seq].inuse) 840 if ((intf->seq_table[seq].inuse)
816 && (intf->seq_table[seq].seqid == seqid)) 841 && (intf->seq_table[seq].seqid == seqid)) {
817 {
818 struct seq_table *ent = &(intf->seq_table[seq]); 842 struct seq_table *ent = &(intf->seq_table[seq]);
819 843
820 ent->inuse = 0; 844 ent->inuse = 0;
@@ -840,24 +864,30 @@ int ipmi_create_user(unsigned int if_num,
840 int rv = 0; 864 int rv = 0;
841 ipmi_smi_t intf; 865 ipmi_smi_t intf;
842 866
843 /* There is no module usecount here, because it's not 867 /*
844 required. Since this can only be used by and called from 868 * There is no module usecount here, because it's not
845 other modules, they will implicitly use this module, and 869 * required. Since this can only be used by and called from
846 thus this can't be removed unless the other modules are 870 * other modules, they will implicitly use this module, and
847 removed. */ 871 * thus this can't be removed unless the other modules are
872 * removed.
873 */
848 874
849 if (handler == NULL) 875 if (handler == NULL)
850 return -EINVAL; 876 return -EINVAL;
851 877
852 /* Make sure the driver is actually initialized, this handles 878 /*
853 problems with initialization order. */ 879 * Make sure the driver is actually initialized, this handles
880 * problems with initialization order.
881 */
854 if (!initialized) { 882 if (!initialized) {
855 rv = ipmi_init_msghandler(); 883 rv = ipmi_init_msghandler();
856 if (rv) 884 if (rv)
857 return rv; 885 return rv;
858 886
859 /* The init code doesn't return an error if it was turned 887 /*
860 off, but it won't initialize. Check that. */ 888 * The init code doesn't return an error if it was turned
889 * off, but it won't initialize. Check that.
890 */
861 if (!initialized) 891 if (!initialized)
862 return -ENODEV; 892 return -ENODEV;
863 } 893 }
@@ -898,8 +928,10 @@ int ipmi_create_user(unsigned int if_num,
898 } 928 }
899 } 929 }
900 930
901 /* Hold the lock so intf->handlers is guaranteed to be good 931 /*
902 * until now */ 932 * Hold the lock so intf->handlers is guaranteed to be good
933 * until now
934 */
903 mutex_unlock(&ipmi_interfaces_mutex); 935 mutex_unlock(&ipmi_interfaces_mutex);
904 936
905 new_user->valid = 1; 937 new_user->valid = 1;
@@ -916,6 +948,7 @@ out_kfree:
916 kfree(new_user); 948 kfree(new_user);
917 return rv; 949 return rv;
918} 950}
951EXPORT_SYMBOL(ipmi_create_user);
919 952
920static void free_user(struct kref *ref) 953static void free_user(struct kref *ref)
921{ 954{
@@ -939,8 +972,7 @@ int ipmi_destroy_user(ipmi_user_t user)
939 972
940 for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) { 973 for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) {
941 if (intf->seq_table[i].inuse 974 if (intf->seq_table[i].inuse
942 && (intf->seq_table[i].recv_msg->user == user)) 975 && (intf->seq_table[i].recv_msg->user == user)) {
943 {
944 intf->seq_table[i].inuse = 0; 976 intf->seq_table[i].inuse = 0;
945 ipmi_free_recv_msg(intf->seq_table[i].recv_msg); 977 ipmi_free_recv_msg(intf->seq_table[i].recv_msg);
946 } 978 }
@@ -983,6 +1015,7 @@ int ipmi_destroy_user(ipmi_user_t user)
983 1015
984 return 0; 1016 return 0;
985} 1017}
1018EXPORT_SYMBOL(ipmi_destroy_user);
986 1019
987void ipmi_get_version(ipmi_user_t user, 1020void ipmi_get_version(ipmi_user_t user,
988 unsigned char *major, 1021 unsigned char *major,
@@ -991,6 +1024,7 @@ void ipmi_get_version(ipmi_user_t user,
991 *major = user->intf->ipmi_version_major; 1024 *major = user->intf->ipmi_version_major;
992 *minor = user->intf->ipmi_version_minor; 1025 *minor = user->intf->ipmi_version_minor;
993} 1026}
1027EXPORT_SYMBOL(ipmi_get_version);
994 1028
995int ipmi_set_my_address(ipmi_user_t user, 1029int ipmi_set_my_address(ipmi_user_t user,
996 unsigned int channel, 1030 unsigned int channel,
@@ -1001,6 +1035,7 @@ int ipmi_set_my_address(ipmi_user_t user,
1001 user->intf->channels[channel].address = address; 1035 user->intf->channels[channel].address = address;
1002 return 0; 1036 return 0;
1003} 1037}
1038EXPORT_SYMBOL(ipmi_set_my_address);
1004 1039
1005int ipmi_get_my_address(ipmi_user_t user, 1040int ipmi_get_my_address(ipmi_user_t user,
1006 unsigned int channel, 1041 unsigned int channel,
@@ -1011,6 +1046,7 @@ int ipmi_get_my_address(ipmi_user_t user,
1011 *address = user->intf->channels[channel].address; 1046 *address = user->intf->channels[channel].address;
1012 return 0; 1047 return 0;
1013} 1048}
1049EXPORT_SYMBOL(ipmi_get_my_address);
1014 1050
1015int ipmi_set_my_LUN(ipmi_user_t user, 1051int ipmi_set_my_LUN(ipmi_user_t user,
1016 unsigned int channel, 1052 unsigned int channel,
@@ -1021,6 +1057,7 @@ int ipmi_set_my_LUN(ipmi_user_t user,
1021 user->intf->channels[channel].lun = LUN & 0x3; 1057 user->intf->channels[channel].lun = LUN & 0x3;
1022 return 0; 1058 return 0;
1023} 1059}
1060EXPORT_SYMBOL(ipmi_set_my_LUN);
1024 1061
1025int ipmi_get_my_LUN(ipmi_user_t user, 1062int ipmi_get_my_LUN(ipmi_user_t user,
1026 unsigned int channel, 1063 unsigned int channel,
@@ -1031,6 +1068,7 @@ int ipmi_get_my_LUN(ipmi_user_t user,
1031 *address = user->intf->channels[channel].lun; 1068 *address = user->intf->channels[channel].lun;
1032 return 0; 1069 return 0;
1033} 1070}
1071EXPORT_SYMBOL(ipmi_get_my_LUN);
1034 1072
1035int ipmi_get_maintenance_mode(ipmi_user_t user) 1073int ipmi_get_maintenance_mode(ipmi_user_t user)
1036{ 1074{
@@ -1139,6 +1177,7 @@ int ipmi_set_gets_events(ipmi_user_t user, int val)
1139 1177
1140 return 0; 1178 return 0;
1141} 1179}
1180EXPORT_SYMBOL(ipmi_set_gets_events);
1142 1181
1143static struct cmd_rcvr *find_cmd_rcvr(ipmi_smi_t intf, 1182static struct cmd_rcvr *find_cmd_rcvr(ipmi_smi_t intf,
1144 unsigned char netfn, 1183 unsigned char netfn,
@@ -1204,6 +1243,7 @@ int ipmi_register_for_cmd(ipmi_user_t user,
1204 1243
1205 return rv; 1244 return rv;
1206} 1245}
1246EXPORT_SYMBOL(ipmi_register_for_cmd);
1207 1247
1208int ipmi_unregister_for_cmd(ipmi_user_t user, 1248int ipmi_unregister_for_cmd(ipmi_user_t user,
1209 unsigned char netfn, 1249 unsigned char netfn,
@@ -1241,12 +1281,13 @@ int ipmi_unregister_for_cmd(ipmi_user_t user,
1241 } 1281 }
1242 return rv; 1282 return rv;
1243} 1283}
1284EXPORT_SYMBOL(ipmi_unregister_for_cmd);
1244 1285
1245static unsigned char 1286static unsigned char
1246ipmb_checksum(unsigned char *data, int size) 1287ipmb_checksum(unsigned char *data, int size)
1247{ 1288{
1248 unsigned char csum = 0; 1289 unsigned char csum = 0;
1249 1290
1250 for (; size > 0; size--, data++) 1291 for (; size > 0; size--, data++)
1251 csum += *data; 1292 csum += *data;
1252 1293
@@ -1288,8 +1329,10 @@ static inline void format_ipmb_msg(struct ipmi_smi_msg *smi_msg,
1288 = ipmb_checksum(&(smi_msg->data[i+6]), 1329 = ipmb_checksum(&(smi_msg->data[i+6]),
1289 smi_msg->data_size-6); 1330 smi_msg->data_size-6);
1290 1331
1291 /* Add on the checksum size and the offset from the 1332 /*
1292 broadcast. */ 1333 * Add on the checksum size and the offset from the
1334 * broadcast.
1335 */
1293 smi_msg->data_size += 1 + i; 1336 smi_msg->data_size += 1 + i;
1294 1337
1295 smi_msg->msgid = msgid; 1338 smi_msg->msgid = msgid;
@@ -1325,17 +1368,21 @@ static inline void format_lan_msg(struct ipmi_smi_msg *smi_msg,
1325 = ipmb_checksum(&(smi_msg->data[7]), 1368 = ipmb_checksum(&(smi_msg->data[7]),
1326 smi_msg->data_size-7); 1369 smi_msg->data_size-7);
1327 1370
1328 /* Add on the checksum size and the offset from the 1371 /*
1329 broadcast. */ 1372 * Add on the checksum size and the offset from the
1373 * broadcast.
1374 */
1330 smi_msg->data_size += 1; 1375 smi_msg->data_size += 1;
1331 1376
1332 smi_msg->msgid = msgid; 1377 smi_msg->msgid = msgid;
1333} 1378}
1334 1379
1335/* Separate from ipmi_request so that the user does not have to be 1380/*
1336 supplied in certain circumstances (mainly at panic time). If 1381 * Separate from ipmi_request so that the user does not have to be
1337 messages are supplied, they will be freed, even if an error 1382 * supplied in certain circumstances (mainly at panic time). If
1338 occurs. */ 1383 * messages are supplied, they will be freed, even if an error
1384 * occurs.
1385 */
1339static int i_ipmi_request(ipmi_user_t user, 1386static int i_ipmi_request(ipmi_user_t user,
1340 ipmi_smi_t intf, 1387 ipmi_smi_t intf,
1341 struct ipmi_addr *addr, 1388 struct ipmi_addr *addr,
@@ -1357,19 +1404,18 @@ static int i_ipmi_request(ipmi_user_t user,
1357 struct ipmi_smi_handlers *handlers; 1404 struct ipmi_smi_handlers *handlers;
1358 1405
1359 1406
1360 if (supplied_recv) { 1407 if (supplied_recv)
1361 recv_msg = supplied_recv; 1408 recv_msg = supplied_recv;
1362 } else { 1409 else {
1363 recv_msg = ipmi_alloc_recv_msg(); 1410 recv_msg = ipmi_alloc_recv_msg();
1364 if (recv_msg == NULL) { 1411 if (recv_msg == NULL)
1365 return -ENOMEM; 1412 return -ENOMEM;
1366 }
1367 } 1413 }
1368 recv_msg->user_msg_data = user_msg_data; 1414 recv_msg->user_msg_data = user_msg_data;
1369 1415
1370 if (supplied_smi) { 1416 if (supplied_smi)
1371 smi_msg = (struct ipmi_smi_msg *) supplied_smi; 1417 smi_msg = (struct ipmi_smi_msg *) supplied_smi;
1372 } else { 1418 else {
1373 smi_msg = ipmi_alloc_smi_msg(); 1419 smi_msg = ipmi_alloc_smi_msg();
1374 if (smi_msg == NULL) { 1420 if (smi_msg == NULL) {
1375 ipmi_free_recv_msg(recv_msg); 1421 ipmi_free_recv_msg(recv_msg);
@@ -1388,8 +1434,10 @@ static int i_ipmi_request(ipmi_user_t user,
1388 if (user) 1434 if (user)
1389 kref_get(&user->refcount); 1435 kref_get(&user->refcount);
1390 recv_msg->msgid = msgid; 1436 recv_msg->msgid = msgid;
1391 /* Store the message to send in the receive message so timeout 1437 /*
1392 responses can get the proper response data. */ 1438 * Store the message to send in the receive message so timeout
1439 * responses can get the proper response data.
1440 */
1393 recv_msg->msg = *msg; 1441 recv_msg->msg = *msg;
1394 1442
1395 if (addr->addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE) { 1443 if (addr->addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE) {
@@ -1413,10 +1461,11 @@ static int i_ipmi_request(ipmi_user_t user,
1413 if ((msg->netfn == IPMI_NETFN_APP_REQUEST) 1461 if ((msg->netfn == IPMI_NETFN_APP_REQUEST)
1414 && ((msg->cmd == IPMI_SEND_MSG_CMD) 1462 && ((msg->cmd == IPMI_SEND_MSG_CMD)
1415 || (msg->cmd == IPMI_GET_MSG_CMD) 1463 || (msg->cmd == IPMI_GET_MSG_CMD)
1416 || (msg->cmd == IPMI_READ_EVENT_MSG_BUFFER_CMD))) 1464 || (msg->cmd == IPMI_READ_EVENT_MSG_BUFFER_CMD))) {
1417 { 1465 /*
1418 /* We don't let the user do these, since we manage 1466 * We don't let the user do these, since we manage
1419 the sequence numbers. */ 1467 * the sequence numbers.
1468 */
1420 ipmi_inc_stat(intf, sent_invalid_commands); 1469 ipmi_inc_stat(intf, sent_invalid_commands);
1421 rv = -EINVAL; 1470 rv = -EINVAL;
1422 goto out_err; 1471 goto out_err;
@@ -1425,14 +1474,12 @@ static int i_ipmi_request(ipmi_user_t user,
1425 if (((msg->netfn == IPMI_NETFN_APP_REQUEST) 1474 if (((msg->netfn == IPMI_NETFN_APP_REQUEST)
1426 && ((msg->cmd == IPMI_COLD_RESET_CMD) 1475 && ((msg->cmd == IPMI_COLD_RESET_CMD)
1427 || (msg->cmd == IPMI_WARM_RESET_CMD))) 1476 || (msg->cmd == IPMI_WARM_RESET_CMD)))
1428 || (msg->netfn == IPMI_NETFN_FIRMWARE_REQUEST)) 1477 || (msg->netfn == IPMI_NETFN_FIRMWARE_REQUEST)) {
1429 {
1430 spin_lock_irqsave(&intf->maintenance_mode_lock, flags); 1478 spin_lock_irqsave(&intf->maintenance_mode_lock, flags);
1431 intf->auto_maintenance_timeout 1479 intf->auto_maintenance_timeout
1432 = IPMI_MAINTENANCE_MODE_TIMEOUT; 1480 = IPMI_MAINTENANCE_MODE_TIMEOUT;
1433 if (!intf->maintenance_mode 1481 if (!intf->maintenance_mode
1434 && !intf->maintenance_mode_enable) 1482 && !intf->maintenance_mode_enable) {
1435 {
1436 intf->maintenance_mode_enable = 1; 1483 intf->maintenance_mode_enable = 1;
1437 maintenance_mode_update(intf); 1484 maintenance_mode_update(intf);
1438 } 1485 }
@@ -1455,8 +1502,7 @@ static int i_ipmi_request(ipmi_user_t user,
1455 smi_msg->data_size = msg->data_len + 2; 1502 smi_msg->data_size = msg->data_len + 2;
1456 ipmi_inc_stat(intf, sent_local_commands); 1503 ipmi_inc_stat(intf, sent_local_commands);
1457 } else if ((addr->addr_type == IPMI_IPMB_ADDR_TYPE) 1504 } else if ((addr->addr_type == IPMI_IPMB_ADDR_TYPE)
1458 || (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) 1505 || (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) {
1459 {
1460 struct ipmi_ipmb_addr *ipmb_addr; 1506 struct ipmi_ipmb_addr *ipmb_addr;
1461 unsigned char ipmb_seq; 1507 unsigned char ipmb_seq;
1462 long seqid; 1508 long seqid;
@@ -1469,8 +1515,7 @@ static int i_ipmi_request(ipmi_user_t user,
1469 } 1515 }
1470 1516
1471 if (intf->channels[addr->channel].medium 1517 if (intf->channels[addr->channel].medium
1472 != IPMI_CHANNEL_MEDIUM_IPMB) 1518 != IPMI_CHANNEL_MEDIUM_IPMB) {
1473 {
1474 ipmi_inc_stat(intf, sent_invalid_commands); 1519 ipmi_inc_stat(intf, sent_invalid_commands);
1475 rv = -EINVAL; 1520 rv = -EINVAL;
1476 goto out_err; 1521 goto out_err;
@@ -1483,9 +1528,11 @@ static int i_ipmi_request(ipmi_user_t user,
1483 retries = 4; 1528 retries = 4;
1484 } 1529 }
1485 if (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE) { 1530 if (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE) {
1486 /* Broadcasts add a zero at the beginning of the 1531 /*
1487 message, but otherwise is the same as an IPMB 1532 * Broadcasts add a zero at the beginning of the
1488 address. */ 1533 * message, but otherwise is the same as an IPMB
1534 * address.
1535 */
1489 addr->addr_type = IPMI_IPMB_ADDR_TYPE; 1536 addr->addr_type = IPMI_IPMB_ADDR_TYPE;
1490 broadcast = 1; 1537 broadcast = 1;
1491 } 1538 }
@@ -1495,8 +1542,10 @@ static int i_ipmi_request(ipmi_user_t user,
1495 if (retry_time_ms == 0) 1542 if (retry_time_ms == 0)
1496 retry_time_ms = 1000; 1543 retry_time_ms = 1000;
1497 1544
1498 /* 9 for the header and 1 for the checksum, plus 1545 /*
1499 possibly one for the broadcast. */ 1546 * 9 for the header and 1 for the checksum, plus
1547 * possibly one for the broadcast.
1548 */
1500 if ((msg->data_len + 10 + broadcast) > IPMI_MAX_MSG_LENGTH) { 1549 if ((msg->data_len + 10 + broadcast) > IPMI_MAX_MSG_LENGTH) {
1501 ipmi_inc_stat(intf, sent_invalid_commands); 1550 ipmi_inc_stat(intf, sent_invalid_commands);
1502 rv = -EMSGSIZE; 1551 rv = -EMSGSIZE;
@@ -1513,15 +1562,19 @@ static int i_ipmi_request(ipmi_user_t user,
1513 memcpy(&recv_msg->addr, ipmb_addr, sizeof(*ipmb_addr)); 1562 memcpy(&recv_msg->addr, ipmb_addr, sizeof(*ipmb_addr));
1514 1563
1515 if (recv_msg->msg.netfn & 0x1) { 1564 if (recv_msg->msg.netfn & 0x1) {
1516 /* It's a response, so use the user's sequence 1565 /*
1517 from msgid. */ 1566 * It's a response, so use the user's sequence
1567 * from msgid.
1568 */
1518 ipmi_inc_stat(intf, sent_ipmb_responses); 1569 ipmi_inc_stat(intf, sent_ipmb_responses);
1519 format_ipmb_msg(smi_msg, msg, ipmb_addr, msgid, 1570 format_ipmb_msg(smi_msg, msg, ipmb_addr, msgid,
1520 msgid, broadcast, 1571 msgid, broadcast,
1521 source_address, source_lun); 1572 source_address, source_lun);
1522 1573
1523 /* Save the receive message so we can use it 1574 /*
1524 to deliver the response. */ 1575 * Save the receive message so we can use it
1576 * to deliver the response.
1577 */
1525 smi_msg->user_data = recv_msg; 1578 smi_msg->user_data = recv_msg;
1526 } else { 1579 } else {
1527 /* It's a command, so get a sequence for it. */ 1580 /* It's a command, so get a sequence for it. */
@@ -1530,8 +1583,10 @@ static int i_ipmi_request(ipmi_user_t user,
1530 1583
1531 ipmi_inc_stat(intf, sent_ipmb_commands); 1584 ipmi_inc_stat(intf, sent_ipmb_commands);
1532 1585
1533 /* Create a sequence number with a 1 second 1586 /*
1534 timeout and 4 retries. */ 1587 * Create a sequence number with a 1 second
1588 * timeout and 4 retries.
1589 */
1535 rv = intf_next_seq(intf, 1590 rv = intf_next_seq(intf,
1536 recv_msg, 1591 recv_msg,
1537 retry_time_ms, 1592 retry_time_ms,
@@ -1540,34 +1595,42 @@ static int i_ipmi_request(ipmi_user_t user,
1540 &ipmb_seq, 1595 &ipmb_seq,
1541 &seqid); 1596 &seqid);
1542 if (rv) { 1597 if (rv) {
1543 /* We have used up all the sequence numbers, 1598 /*
1544 probably, so abort. */ 1599 * We have used up all the sequence numbers,
1600 * probably, so abort.
1601 */
1545 spin_unlock_irqrestore(&(intf->seq_lock), 1602 spin_unlock_irqrestore(&(intf->seq_lock),
1546 flags); 1603 flags);
1547 goto out_err; 1604 goto out_err;
1548 } 1605 }
1549 1606
1550 /* Store the sequence number in the message, 1607 /*
1551 so that when the send message response 1608 * Store the sequence number in the message,
1552 comes back we can start the timer. */ 1609 * so that when the send message response
1610 * comes back we can start the timer.
1611 */
1553 format_ipmb_msg(smi_msg, msg, ipmb_addr, 1612 format_ipmb_msg(smi_msg, msg, ipmb_addr,
1554 STORE_SEQ_IN_MSGID(ipmb_seq, seqid), 1613 STORE_SEQ_IN_MSGID(ipmb_seq, seqid),
1555 ipmb_seq, broadcast, 1614 ipmb_seq, broadcast,
1556 source_address, source_lun); 1615 source_address, source_lun);
1557 1616
1558 /* Copy the message into the recv message data, so we 1617 /*
1559 can retransmit it later if necessary. */ 1618 * Copy the message into the recv message data, so we
1619 * can retransmit it later if necessary.
1620 */
1560 memcpy(recv_msg->msg_data, smi_msg->data, 1621 memcpy(recv_msg->msg_data, smi_msg->data,
1561 smi_msg->data_size); 1622 smi_msg->data_size);
1562 recv_msg->msg.data = recv_msg->msg_data; 1623 recv_msg->msg.data = recv_msg->msg_data;
1563 recv_msg->msg.data_len = smi_msg->data_size; 1624 recv_msg->msg.data_len = smi_msg->data_size;
1564 1625
1565 /* We don't unlock until here, because we need 1626 /*
1566 to copy the completed message into the 1627 * We don't unlock until here, because we need
1567 recv_msg before we release the lock. 1628 * to copy the completed message into the
1568 Otherwise, race conditions may bite us. I 1629 * recv_msg before we release the lock.
1569 know that's pretty paranoid, but I prefer 1630 * Otherwise, race conditions may bite us. I
1570 to be correct. */ 1631 * know that's pretty paranoid, but I prefer
1632 * to be correct.
1633 */
1571 spin_unlock_irqrestore(&(intf->seq_lock), flags); 1634 spin_unlock_irqrestore(&(intf->seq_lock), flags);
1572 } 1635 }
1573 } else if (addr->addr_type == IPMI_LAN_ADDR_TYPE) { 1636 } else if (addr->addr_type == IPMI_LAN_ADDR_TYPE) {
@@ -1582,10 +1645,9 @@ static int i_ipmi_request(ipmi_user_t user,
1582 } 1645 }
1583 1646
1584 if ((intf->channels[addr->channel].medium 1647 if ((intf->channels[addr->channel].medium
1585 != IPMI_CHANNEL_MEDIUM_8023LAN) 1648 != IPMI_CHANNEL_MEDIUM_8023LAN)
1586 && (intf->channels[addr->channel].medium 1649 && (intf->channels[addr->channel].medium
1587 != IPMI_CHANNEL_MEDIUM_ASYNC)) 1650 != IPMI_CHANNEL_MEDIUM_ASYNC)) {
1588 {
1589 ipmi_inc_stat(intf, sent_invalid_commands); 1651 ipmi_inc_stat(intf, sent_invalid_commands);
1590 rv = -EINVAL; 1652 rv = -EINVAL;
1591 goto out_err; 1653 goto out_err;
@@ -1614,14 +1676,18 @@ static int i_ipmi_request(ipmi_user_t user,
1614 memcpy(&recv_msg->addr, lan_addr, sizeof(*lan_addr)); 1676 memcpy(&recv_msg->addr, lan_addr, sizeof(*lan_addr));
1615 1677
1616 if (recv_msg->msg.netfn & 0x1) { 1678 if (recv_msg->msg.netfn & 0x1) {
1617 /* It's a response, so use the user's sequence 1679 /*
1618 from msgid. */ 1680 * It's a response, so use the user's sequence
1681 * from msgid.
1682 */
1619 ipmi_inc_stat(intf, sent_lan_responses); 1683 ipmi_inc_stat(intf, sent_lan_responses);
1620 format_lan_msg(smi_msg, msg, lan_addr, msgid, 1684 format_lan_msg(smi_msg, msg, lan_addr, msgid,
1621 msgid, source_lun); 1685 msgid, source_lun);
1622 1686
1623 /* Save the receive message so we can use it 1687 /*
1624 to deliver the response. */ 1688 * Save the receive message so we can use it
1689 * to deliver the response.
1690 */
1625 smi_msg->user_data = recv_msg; 1691 smi_msg->user_data = recv_msg;
1626 } else { 1692 } else {
1627 /* It's a command, so get a sequence for it. */ 1693 /* It's a command, so get a sequence for it. */
@@ -1630,8 +1696,10 @@ static int i_ipmi_request(ipmi_user_t user,
1630 1696
1631 ipmi_inc_stat(intf, sent_lan_commands); 1697 ipmi_inc_stat(intf, sent_lan_commands);
1632 1698
1633 /* Create a sequence number with a 1 second 1699 /*
1634 timeout and 4 retries. */ 1700 * Create a sequence number with a 1 second
1701 * timeout and 4 retries.
1702 */
1635 rv = intf_next_seq(intf, 1703 rv = intf_next_seq(intf,
1636 recv_msg, 1704 recv_msg,
1637 retry_time_ms, 1705 retry_time_ms,
@@ -1640,33 +1708,41 @@ static int i_ipmi_request(ipmi_user_t user,
1640 &ipmb_seq, 1708 &ipmb_seq,
1641 &seqid); 1709 &seqid);
1642 if (rv) { 1710 if (rv) {
1643 /* We have used up all the sequence numbers, 1711 /*
1644 probably, so abort. */ 1712 * We have used up all the sequence numbers,
1713 * probably, so abort.
1714 */
1645 spin_unlock_irqrestore(&(intf->seq_lock), 1715 spin_unlock_irqrestore(&(intf->seq_lock),
1646 flags); 1716 flags);
1647 goto out_err; 1717 goto out_err;
1648 } 1718 }
1649 1719
1650 /* Store the sequence number in the message, 1720 /*
1651 so that when the send message response 1721 * Store the sequence number in the message,
1652 comes back we can start the timer. */ 1722 * so that when the send message response
1723 * comes back we can start the timer.
1724 */
1653 format_lan_msg(smi_msg, msg, lan_addr, 1725 format_lan_msg(smi_msg, msg, lan_addr,
1654 STORE_SEQ_IN_MSGID(ipmb_seq, seqid), 1726 STORE_SEQ_IN_MSGID(ipmb_seq, seqid),
1655 ipmb_seq, source_lun); 1727 ipmb_seq, source_lun);
1656 1728
1657 /* Copy the message into the recv message data, so we 1729 /*
1658 can retransmit it later if necessary. */ 1730 * Copy the message into the recv message data, so we
1731 * can retransmit it later if necessary.
1732 */
1659 memcpy(recv_msg->msg_data, smi_msg->data, 1733 memcpy(recv_msg->msg_data, smi_msg->data,
1660 smi_msg->data_size); 1734 smi_msg->data_size);
1661 recv_msg->msg.data = recv_msg->msg_data; 1735 recv_msg->msg.data = recv_msg->msg_data;
1662 recv_msg->msg.data_len = smi_msg->data_size; 1736 recv_msg->msg.data_len = smi_msg->data_size;
1663 1737
1664 /* We don't unlock until here, because we need 1738 /*
1665 to copy the completed message into the 1739 * We don't unlock until here, because we need
1666 recv_msg before we release the lock. 1740 * to copy the completed message into the
1667 Otherwise, race conditions may bite us. I 1741 * recv_msg before we release the lock.
1668 know that's pretty paranoid, but I prefer 1742 * Otherwise, race conditions may bite us. I
1669 to be correct. */ 1743 * know that's pretty paranoid, but I prefer
1744 * to be correct.
1745 */
1670 spin_unlock_irqrestore(&(intf->seq_lock), flags); 1746 spin_unlock_irqrestore(&(intf->seq_lock), flags);
1671 } 1747 }
1672 } else { 1748 } else {
@@ -1739,6 +1815,7 @@ int ipmi_request_settime(ipmi_user_t user,
1739 retries, 1815 retries,
1740 retry_time_ms); 1816 retry_time_ms);
1741} 1817}
1818EXPORT_SYMBOL(ipmi_request_settime);
1742 1819
1743int ipmi_request_supply_msgs(ipmi_user_t user, 1820int ipmi_request_supply_msgs(ipmi_user_t user,
1744 struct ipmi_addr *addr, 1821 struct ipmi_addr *addr,
@@ -1770,6 +1847,7 @@ int ipmi_request_supply_msgs(ipmi_user_t user,
1770 lun, 1847 lun,
1771 -1, 0); 1848 -1, 0);
1772} 1849}
1850EXPORT_SYMBOL(ipmi_request_supply_msgs);
1773 1851
1774#ifdef CONFIG_PROC_FS 1852#ifdef CONFIG_PROC_FS
1775static int ipmb_file_read_proc(char *page, char **start, off_t off, 1853static int ipmb_file_read_proc(char *page, char **start, off_t off,
@@ -1903,6 +1981,7 @@ int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
1903 1981
1904 return rv; 1982 return rv;
1905} 1983}
1984EXPORT_SYMBOL(ipmi_smi_add_proc_entry);
1906 1985
1907static int add_proc_entries(ipmi_smi_t smi, int num) 1986static int add_proc_entries(ipmi_smi_t smi, int num)
1908{ 1987{
@@ -1913,9 +1992,8 @@ static int add_proc_entries(ipmi_smi_t smi, int num)
1913 smi->proc_dir = proc_mkdir(smi->proc_dir_name, proc_ipmi_root); 1992 smi->proc_dir = proc_mkdir(smi->proc_dir_name, proc_ipmi_root);
1914 if (!smi->proc_dir) 1993 if (!smi->proc_dir)
1915 rv = -ENOMEM; 1994 rv = -ENOMEM;
1916 else { 1995 else
1917 smi->proc_dir->owner = THIS_MODULE; 1996 smi->proc_dir->owner = THIS_MODULE;
1918 }
1919 1997
1920 if (rv == 0) 1998 if (rv == 0)
1921 rv = ipmi_smi_add_proc_entry(smi, "stats", 1999 rv = ipmi_smi_add_proc_entry(smi, "stats",
@@ -2214,37 +2292,47 @@ static int create_files(struct bmc_device *bmc)
2214 2292
2215 err = device_create_file(&bmc->dev->dev, 2293 err = device_create_file(&bmc->dev->dev,
2216 &bmc->device_id_attr); 2294 &bmc->device_id_attr);
2217 if (err) goto out; 2295 if (err)
2296 goto out;
2218 err = device_create_file(&bmc->dev->dev, 2297 err = device_create_file(&bmc->dev->dev,
2219 &bmc->provides_dev_sdrs_attr); 2298 &bmc->provides_dev_sdrs_attr);
2220 if (err) goto out_devid; 2299 if (err)
2300 goto out_devid;
2221 err = device_create_file(&bmc->dev->dev, 2301 err = device_create_file(&bmc->dev->dev,
2222 &bmc->revision_attr); 2302 &bmc->revision_attr);
2223 if (err) goto out_sdrs; 2303 if (err)
2304 goto out_sdrs;
2224 err = device_create_file(&bmc->dev->dev, 2305 err = device_create_file(&bmc->dev->dev,
2225 &bmc->firmware_rev_attr); 2306 &bmc->firmware_rev_attr);
2226 if (err) goto out_rev; 2307 if (err)
2308 goto out_rev;
2227 err = device_create_file(&bmc->dev->dev, 2309 err = device_create_file(&bmc->dev->dev,
2228 &bmc->version_attr); 2310 &bmc->version_attr);
2229 if (err) goto out_firm; 2311 if (err)
2312 goto out_firm;
2230 err = device_create_file(&bmc->dev->dev, 2313 err = device_create_file(&bmc->dev->dev,
2231 &bmc->add_dev_support_attr); 2314 &bmc->add_dev_support_attr);
2232 if (err) goto out_version; 2315 if (err)
2316 goto out_version;
2233 err = device_create_file(&bmc->dev->dev, 2317 err = device_create_file(&bmc->dev->dev,
2234 &bmc->manufacturer_id_attr); 2318 &bmc->manufacturer_id_attr);
2235 if (err) goto out_add_dev; 2319 if (err)
2320 goto out_add_dev;
2236 err = device_create_file(&bmc->dev->dev, 2321 err = device_create_file(&bmc->dev->dev,
2237 &bmc->product_id_attr); 2322 &bmc->product_id_attr);
2238 if (err) goto out_manu; 2323 if (err)
2324 goto out_manu;
2239 if (bmc->id.aux_firmware_revision_set) { 2325 if (bmc->id.aux_firmware_revision_set) {
2240 err = device_create_file(&bmc->dev->dev, 2326 err = device_create_file(&bmc->dev->dev,
2241 &bmc->aux_firmware_rev_attr); 2327 &bmc->aux_firmware_rev_attr);
2242 if (err) goto out_prod_id; 2328 if (err)
2329 goto out_prod_id;
2243 } 2330 }
2244 if (bmc->guid_set) { 2331 if (bmc->guid_set) {
2245 err = device_create_file(&bmc->dev->dev, 2332 err = device_create_file(&bmc->dev->dev,
2246 &bmc->guid_attr); 2333 &bmc->guid_attr);
2247 if (err) goto out_aux_firm; 2334 if (err)
2335 goto out_aux_firm;
2248 } 2336 }
2249 2337
2250 return 0; 2338 return 0;
@@ -2372,8 +2460,10 @@ static int ipmi_bmc_register(ipmi_smi_t intf, int ifnum,
2372 "ipmi_msghandler:" 2460 "ipmi_msghandler:"
2373 " Unable to register bmc device: %d\n", 2461 " Unable to register bmc device: %d\n",
2374 rv); 2462 rv);
2375 /* Don't go to out_err, you can only do that if 2463 /*
2376 the device is registered already. */ 2464 * Don't go to out_err, you can only do that if
2465 * the device is registered already.
2466 */
2377 return rv; 2467 return rv;
2378 } 2468 }
2379 2469
@@ -2564,17 +2654,18 @@ channel_handler(ipmi_smi_t intf, struct ipmi_recv_msg *msg)
2564 2654
2565 if ((msg->addr.addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE) 2655 if ((msg->addr.addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE)
2566 && (msg->msg.netfn == IPMI_NETFN_APP_RESPONSE) 2656 && (msg->msg.netfn == IPMI_NETFN_APP_RESPONSE)
2567 && (msg->msg.cmd == IPMI_GET_CHANNEL_INFO_CMD)) 2657 && (msg->msg.cmd == IPMI_GET_CHANNEL_INFO_CMD)) {
2568 {
2569 /* It's the one we want */ 2658 /* It's the one we want */
2570 if (msg->msg.data[0] != 0) { 2659 if (msg->msg.data[0] != 0) {
2571 /* Got an error from the channel, just go on. */ 2660 /* Got an error from the channel, just go on. */
2572 2661
2573 if (msg->msg.data[0] == IPMI_INVALID_COMMAND_ERR) { 2662 if (msg->msg.data[0] == IPMI_INVALID_COMMAND_ERR) {
2574 /* If the MC does not support this 2663 /*
2575 command, that is legal. We just 2664 * If the MC does not support this
2576 assume it has one IPMB at channel 2665 * command, that is legal. We just
2577 zero. */ 2666 * assume it has one IPMB at channel
2667 * zero.
2668 */
2578 intf->channels[0].medium 2669 intf->channels[0].medium
2579 = IPMI_CHANNEL_MEDIUM_IPMB; 2670 = IPMI_CHANNEL_MEDIUM_IPMB;
2580 intf->channels[0].protocol 2671 intf->channels[0].protocol
@@ -2595,7 +2686,7 @@ channel_handler(ipmi_smi_t intf, struct ipmi_recv_msg *msg)
2595 intf->channels[chan].medium = msg->msg.data[2] & 0x7f; 2686 intf->channels[chan].medium = msg->msg.data[2] & 0x7f;
2596 intf->channels[chan].protocol = msg->msg.data[3] & 0x1f; 2687 intf->channels[chan].protocol = msg->msg.data[3] & 0x1f;
2597 2688
2598 next_channel: 2689 next_channel:
2599 intf->curr_channel++; 2690 intf->curr_channel++;
2600 if (intf->curr_channel >= IPMI_MAX_CHANNELS) 2691 if (intf->curr_channel >= IPMI_MAX_CHANNELS)
2601 wake_up(&intf->waitq); 2692 wake_up(&intf->waitq);
@@ -2623,6 +2714,7 @@ void ipmi_poll_interface(ipmi_user_t user)
2623 if (intf->handlers->poll) 2714 if (intf->handlers->poll)
2624 intf->handlers->poll(intf->send_info); 2715 intf->handlers->poll(intf->send_info);
2625} 2716}
2717EXPORT_SYMBOL(ipmi_poll_interface);
2626 2718
2627int ipmi_register_smi(struct ipmi_smi_handlers *handlers, 2719int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
2628 void *send_info, 2720 void *send_info,
@@ -2637,14 +2729,18 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
2637 ipmi_smi_t tintf; 2729 ipmi_smi_t tintf;
2638 struct list_head *link; 2730 struct list_head *link;
2639 2731
2640 /* Make sure the driver is actually initialized, this handles 2732 /*
2641 problems with initialization order. */ 2733 * Make sure the driver is actually initialized, this handles
2734 * problems with initialization order.
2735 */
2642 if (!initialized) { 2736 if (!initialized) {
2643 rv = ipmi_init_msghandler(); 2737 rv = ipmi_init_msghandler();
2644 if (rv) 2738 if (rv)
2645 return rv; 2739 return rv;
2646 /* The init code doesn't return an error if it was turned 2740 /*
2647 off, but it won't initialize. Check that. */ 2741 * The init code doesn't return an error if it was turned
2742 * off, but it won't initialize. Check that.
2743 */
2648 if (!initialized) 2744 if (!initialized)
2649 return -ENODEV; 2745 return -ENODEV;
2650 } 2746 }
@@ -2722,11 +2818,12 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
2722 get_guid(intf); 2818 get_guid(intf);
2723 2819
2724 if ((intf->ipmi_version_major > 1) 2820 if ((intf->ipmi_version_major > 1)
2725 || ((intf->ipmi_version_major == 1) 2821 || ((intf->ipmi_version_major == 1)
2726 && (intf->ipmi_version_minor >= 5))) 2822 && (intf->ipmi_version_minor >= 5))) {
2727 { 2823 /*
2728 /* Start scanning the channels to see what is 2824 * Start scanning the channels to see what is
2729 available. */ 2825 * available.
2826 */
2730 intf->null_user_handler = channel_handler; 2827 intf->null_user_handler = channel_handler;
2731 intf->curr_channel = 0; 2828 intf->curr_channel = 0;
2732 rv = send_channel_info_cmd(intf, 0); 2829 rv = send_channel_info_cmd(intf, 0);
@@ -2774,6 +2871,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
2774 2871
2775 return rv; 2872 return rv;
2776} 2873}
2874EXPORT_SYMBOL(ipmi_register_smi);
2777 2875
2778static void cleanup_smi_msgs(ipmi_smi_t intf) 2876static void cleanup_smi_msgs(ipmi_smi_t intf)
2779{ 2877{
@@ -2808,8 +2906,10 @@ int ipmi_unregister_smi(ipmi_smi_t intf)
2808 2906
2809 remove_proc_entries(intf); 2907 remove_proc_entries(intf);
2810 2908
2811 /* Call all the watcher interfaces to tell them that 2909 /*
2812 an interface is gone. */ 2910 * Call all the watcher interfaces to tell them that
2911 * an interface is gone.
2912 */
2813 list_for_each_entry(w, &smi_watchers, link) 2913 list_for_each_entry(w, &smi_watchers, link)
2814 w->smi_gone(intf_num); 2914 w->smi_gone(intf_num);
2815 mutex_unlock(&smi_watchers_mutex); 2915 mutex_unlock(&smi_watchers_mutex);
@@ -2817,6 +2917,7 @@ int ipmi_unregister_smi(ipmi_smi_t intf)
2817 kref_put(&intf->refcount, intf_free); 2917 kref_put(&intf->refcount, intf_free);
2818 return 0; 2918 return 0;
2819} 2919}
2920EXPORT_SYMBOL(ipmi_unregister_smi);
2820 2921
2821static int handle_ipmb_get_msg_rsp(ipmi_smi_t intf, 2922static int handle_ipmb_get_msg_rsp(ipmi_smi_t intf,
2822 struct ipmi_smi_msg *msg) 2923 struct ipmi_smi_msg *msg)
@@ -2824,9 +2925,10 @@ static int handle_ipmb_get_msg_rsp(ipmi_smi_t intf,
2824 struct ipmi_ipmb_addr ipmb_addr; 2925 struct ipmi_ipmb_addr ipmb_addr;
2825 struct ipmi_recv_msg *recv_msg; 2926 struct ipmi_recv_msg *recv_msg;
2826 2927
2827 2928 /*
2828 /* This is 11, not 10, because the response must contain a 2929 * This is 11, not 10, because the response must contain a
2829 * completion code. */ 2930 * completion code.
2931 */
2830 if (msg->rsp_size < 11) { 2932 if (msg->rsp_size < 11) {
2831 /* Message not big enough, just ignore it. */ 2933 /* Message not big enough, just ignore it. */
2832 ipmi_inc_stat(intf, invalid_ipmb_responses); 2934 ipmi_inc_stat(intf, invalid_ipmb_responses);
@@ -2843,18 +2945,21 @@ static int handle_ipmb_get_msg_rsp(ipmi_smi_t intf,
2843 ipmb_addr.channel = msg->rsp[3] & 0x0f; 2945 ipmb_addr.channel = msg->rsp[3] & 0x0f;
2844 ipmb_addr.lun = msg->rsp[7] & 3; 2946 ipmb_addr.lun = msg->rsp[7] & 3;
2845 2947
2846 /* It's a response from a remote entity. Look up the sequence 2948 /*
2847 number and handle the response. */ 2949 * It's a response from a remote entity. Look up the sequence
2950 * number and handle the response.
2951 */
2848 if (intf_find_seq(intf, 2952 if (intf_find_seq(intf,
2849 msg->rsp[7] >> 2, 2953 msg->rsp[7] >> 2,
2850 msg->rsp[3] & 0x0f, 2954 msg->rsp[3] & 0x0f,
2851 msg->rsp[8], 2955 msg->rsp[8],
2852 (msg->rsp[4] >> 2) & (~1), 2956 (msg->rsp[4] >> 2) & (~1),
2853 (struct ipmi_addr *) &(ipmb_addr), 2957 (struct ipmi_addr *) &(ipmb_addr),
2854 &recv_msg)) 2958 &recv_msg)) {
2855 { 2959 /*
2856 /* We were unable to find the sequence number, 2960 * We were unable to find the sequence number,
2857 so just nuke the message. */ 2961 * so just nuke the message.
2962 */
2858 ipmi_inc_stat(intf, unhandled_ipmb_responses); 2963 ipmi_inc_stat(intf, unhandled_ipmb_responses);
2859 return 0; 2964 return 0;
2860 } 2965 }
@@ -2862,9 +2967,11 @@ static int handle_ipmb_get_msg_rsp(ipmi_smi_t intf,
2862 memcpy(recv_msg->msg_data, 2967 memcpy(recv_msg->msg_data,
2863 &(msg->rsp[9]), 2968 &(msg->rsp[9]),
2864 msg->rsp_size - 9); 2969 msg->rsp_size - 9);
2865 /* THe other fields matched, so no need to set them, except 2970 /*
2866 for netfn, which needs to be the response that was 2971 * The other fields matched, so no need to set them, except
2867 returned, not the request value. */ 2972 * for netfn, which needs to be the response that was
2973 * returned, not the request value.
2974 */
2868 recv_msg->msg.netfn = msg->rsp[4] >> 2; 2975 recv_msg->msg.netfn = msg->rsp[4] >> 2;
2869 recv_msg->msg.data = recv_msg->msg_data; 2976 recv_msg->msg.data = recv_msg->msg_data;
2870 recv_msg->msg.data_len = msg->rsp_size - 10; 2977 recv_msg->msg.data_len = msg->rsp_size - 10;
@@ -2920,11 +3027,11 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf,
2920 msg->data[1] = IPMI_SEND_MSG_CMD; 3027 msg->data[1] = IPMI_SEND_MSG_CMD;
2921 msg->data[2] = msg->rsp[3]; 3028 msg->data[2] = msg->rsp[3];
2922 msg->data[3] = msg->rsp[6]; 3029 msg->data[3] = msg->rsp[6];
2923 msg->data[4] = ((netfn + 1) << 2) | (msg->rsp[7] & 0x3); 3030 msg->data[4] = ((netfn + 1) << 2) | (msg->rsp[7] & 0x3);
2924 msg->data[5] = ipmb_checksum(&(msg->data[3]), 2); 3031 msg->data[5] = ipmb_checksum(&(msg->data[3]), 2);
2925 msg->data[6] = intf->channels[msg->rsp[3] & 0xf].address; 3032 msg->data[6] = intf->channels[msg->rsp[3] & 0xf].address;
2926 /* rqseq/lun */ 3033 /* rqseq/lun */
2927 msg->data[7] = (msg->rsp[7] & 0xfc) | (msg->rsp[4] & 0x3); 3034 msg->data[7] = (msg->rsp[7] & 0xfc) | (msg->rsp[4] & 0x3);
2928 msg->data[8] = msg->rsp[8]; /* cmd */ 3035 msg->data[8] = msg->rsp[8]; /* cmd */
2929 msg->data[9] = IPMI_INVALID_CMD_COMPLETION_CODE; 3036 msg->data[9] = IPMI_INVALID_CMD_COMPLETION_CODE;
2930 msg->data[10] = ipmb_checksum(&(msg->data[6]), 4); 3037 msg->data[10] = ipmb_checksum(&(msg->data[6]), 4);
@@ -2943,9 +3050,11 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf,
2943 handlers = intf->handlers; 3050 handlers = intf->handlers;
2944 if (handlers) { 3051 if (handlers) {
2945 handlers->sender(intf->send_info, msg, 0); 3052 handlers->sender(intf->send_info, msg, 0);
2946 /* We used the message, so return the value 3053 /*
2947 that causes it to not be freed or 3054 * We used the message, so return the value
2948 queued. */ 3055 * that causes it to not be freed or
3056 * queued.
3057 */
2949 rv = -1; 3058 rv = -1;
2950 } 3059 }
2951 rcu_read_unlock(); 3060 rcu_read_unlock();
@@ -2955,9 +3064,11 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf,
2955 3064
2956 recv_msg = ipmi_alloc_recv_msg(); 3065 recv_msg = ipmi_alloc_recv_msg();
2957 if (!recv_msg) { 3066 if (!recv_msg) {
2958 /* We couldn't allocate memory for the 3067 /*
2959 message, so requeue it for handling 3068 * We couldn't allocate memory for the
2960 later. */ 3069 * message, so requeue it for handling
3070 * later.
3071 */
2961 rv = 1; 3072 rv = 1;
2962 kref_put(&user->refcount, free_user); 3073 kref_put(&user->refcount, free_user);
2963 } else { 3074 } else {
@@ -2968,8 +3079,10 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf,
2968 ipmb_addr->lun = msg->rsp[7] & 3; 3079 ipmb_addr->lun = msg->rsp[7] & 3;
2969 ipmb_addr->channel = msg->rsp[3] & 0xf; 3080 ipmb_addr->channel = msg->rsp[3] & 0xf;
2970 3081
2971 /* Extract the rest of the message information 3082 /*
2972 from the IPMB header.*/ 3083 * Extract the rest of the message information
3084 * from the IPMB header.
3085 */
2973 recv_msg->user = user; 3086 recv_msg->user = user;
2974 recv_msg->recv_type = IPMI_CMD_RECV_TYPE; 3087 recv_msg->recv_type = IPMI_CMD_RECV_TYPE;
2975 recv_msg->msgid = msg->rsp[7] >> 2; 3088 recv_msg->msgid = msg->rsp[7] >> 2;
@@ -2977,8 +3090,10 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf,
2977 recv_msg->msg.cmd = msg->rsp[8]; 3090 recv_msg->msg.cmd = msg->rsp[8];
2978 recv_msg->msg.data = recv_msg->msg_data; 3091 recv_msg->msg.data = recv_msg->msg_data;
2979 3092
2980 /* We chop off 10, not 9 bytes because the checksum 3093 /*
2981 at the end also needs to be removed. */ 3094 * We chop off 10, not 9 bytes because the checksum
3095 * at the end also needs to be removed.
3096 */
2982 recv_msg->msg.data_len = msg->rsp_size - 10; 3097 recv_msg->msg.data_len = msg->rsp_size - 10;
2983 memcpy(recv_msg->msg_data, 3098 memcpy(recv_msg->msg_data,
2984 &(msg->rsp[9]), 3099 &(msg->rsp[9]),
@@ -2997,8 +3112,10 @@ static int handle_lan_get_msg_rsp(ipmi_smi_t intf,
2997 struct ipmi_recv_msg *recv_msg; 3112 struct ipmi_recv_msg *recv_msg;
2998 3113
2999 3114
3000 /* This is 13, not 12, because the response must contain a 3115 /*
3001 * completion code. */ 3116 * This is 13, not 12, because the response must contain a
3117 * completion code.
3118 */
3002 if (msg->rsp_size < 13) { 3119 if (msg->rsp_size < 13) {
3003 /* Message not big enough, just ignore it. */ 3120 /* Message not big enough, just ignore it. */
3004 ipmi_inc_stat(intf, invalid_lan_responses); 3121 ipmi_inc_stat(intf, invalid_lan_responses);
@@ -3018,18 +3135,21 @@ static int handle_lan_get_msg_rsp(ipmi_smi_t intf,
3018 lan_addr.privilege = msg->rsp[3] >> 4; 3135 lan_addr.privilege = msg->rsp[3] >> 4;
3019 lan_addr.lun = msg->rsp[9] & 3; 3136 lan_addr.lun = msg->rsp[9] & 3;
3020 3137
3021 /* It's a response from a remote entity. Look up the sequence 3138 /*
3022 number and handle the response. */ 3139 * It's a response from a remote entity. Look up the sequence
3140 * number and handle the response.
3141 */
3023 if (intf_find_seq(intf, 3142 if (intf_find_seq(intf,
3024 msg->rsp[9] >> 2, 3143 msg->rsp[9] >> 2,
3025 msg->rsp[3] & 0x0f, 3144 msg->rsp[3] & 0x0f,
3026 msg->rsp[10], 3145 msg->rsp[10],
3027 (msg->rsp[6] >> 2) & (~1), 3146 (msg->rsp[6] >> 2) & (~1),
3028 (struct ipmi_addr *) &(lan_addr), 3147 (struct ipmi_addr *) &(lan_addr),
3029 &recv_msg)) 3148 &recv_msg)) {
3030 { 3149 /*
3031 /* We were unable to find the sequence number, 3150 * We were unable to find the sequence number,
3032 so just nuke the message. */ 3151 * so just nuke the message.
3152 */
3033 ipmi_inc_stat(intf, unhandled_lan_responses); 3153 ipmi_inc_stat(intf, unhandled_lan_responses);
3034 return 0; 3154 return 0;
3035 } 3155 }
@@ -3037,9 +3157,11 @@ static int handle_lan_get_msg_rsp(ipmi_smi_t intf,
3037 memcpy(recv_msg->msg_data, 3157 memcpy(recv_msg->msg_data,
3038 &(msg->rsp[11]), 3158 &(msg->rsp[11]),
3039 msg->rsp_size - 11); 3159 msg->rsp_size - 11);
3040 /* The other fields matched, so no need to set them, except 3160 /*
3041 for netfn, which needs to be the response that was 3161 * The other fields matched, so no need to set them, except
3042 returned, not the request value. */ 3162 * for netfn, which needs to be the response that was
3163 * returned, not the request value.
3164 */
3043 recv_msg->msg.netfn = msg->rsp[6] >> 2; 3165 recv_msg->msg.netfn = msg->rsp[6] >> 2;
3044 recv_msg->msg.data = recv_msg->msg_data; 3166 recv_msg->msg.data = recv_msg->msg_data;
3045 recv_msg->msg.data_len = msg->rsp_size - 12; 3167 recv_msg->msg.data_len = msg->rsp_size - 12;
@@ -3090,17 +3212,21 @@ static int handle_lan_get_msg_cmd(ipmi_smi_t intf,
3090 /* We didn't find a user, just give up. */ 3212 /* We didn't find a user, just give up. */
3091 ipmi_inc_stat(intf, unhandled_commands); 3213 ipmi_inc_stat(intf, unhandled_commands);
3092 3214
3093 rv = 0; /* Don't do anything with these messages, just 3215 /*
3094 allow them to be freed. */ 3216 * Don't do anything with these messages, just allow
3217 * them to be freed.
3218 */
3219 rv = 0;
3095 } else { 3220 } else {
3096 /* Deliver the message to the user. */ 3221 /* Deliver the message to the user. */
3097 ipmi_inc_stat(intf, handled_commands); 3222 ipmi_inc_stat(intf, handled_commands);
3098 3223
3099 recv_msg = ipmi_alloc_recv_msg(); 3224 recv_msg = ipmi_alloc_recv_msg();
3100 if (!recv_msg) { 3225 if (!recv_msg) {
3101 /* We couldn't allocate memory for the 3226 /*
3102 message, so requeue it for handling 3227 * We couldn't allocate memory for the
3103 later. */ 3228 * message, so requeue it for handling later.
3229 */
3104 rv = 1; 3230 rv = 1;
3105 kref_put(&user->refcount, free_user); 3231 kref_put(&user->refcount, free_user);
3106 } else { 3232 } else {
@@ -3114,8 +3240,10 @@ static int handle_lan_get_msg_cmd(ipmi_smi_t intf,
3114 lan_addr->channel = msg->rsp[3] & 0xf; 3240 lan_addr->channel = msg->rsp[3] & 0xf;
3115 lan_addr->privilege = msg->rsp[3] >> 4; 3241 lan_addr->privilege = msg->rsp[3] >> 4;
3116 3242
3117 /* Extract the rest of the message information 3243 /*
3118 from the IPMB header.*/ 3244 * Extract the rest of the message information
3245 * from the IPMB header.
3246 */
3119 recv_msg->user = user; 3247 recv_msg->user = user;
3120 recv_msg->recv_type = IPMI_CMD_RECV_TYPE; 3248 recv_msg->recv_type = IPMI_CMD_RECV_TYPE;
3121 recv_msg->msgid = msg->rsp[9] >> 2; 3249 recv_msg->msgid = msg->rsp[9] >> 2;
@@ -3123,8 +3251,10 @@ static int handle_lan_get_msg_cmd(ipmi_smi_t intf,
3123 recv_msg->msg.cmd = msg->rsp[10]; 3251 recv_msg->msg.cmd = msg->rsp[10];
3124 recv_msg->msg.data = recv_msg->msg_data; 3252 recv_msg->msg.data = recv_msg->msg_data;
3125 3253
3126 /* We chop off 12, not 11 bytes because the checksum 3254 /*
3127 at the end also needs to be removed. */ 3255 * We chop off 12, not 11 bytes because the checksum
3256 * at the end also needs to be removed.
3257 */
3128 recv_msg->msg.data_len = msg->rsp_size - 12; 3258 recv_msg->msg.data_len = msg->rsp_size - 12;
3129 memcpy(recv_msg->msg_data, 3259 memcpy(recv_msg->msg_data,
3130 &(msg->rsp[11]), 3260 &(msg->rsp[11]),
@@ -3140,7 +3270,7 @@ static void copy_event_into_recv_msg(struct ipmi_recv_msg *recv_msg,
3140 struct ipmi_smi_msg *msg) 3270 struct ipmi_smi_msg *msg)
3141{ 3271{
3142 struct ipmi_system_interface_addr *smi_addr; 3272 struct ipmi_system_interface_addr *smi_addr;
3143 3273
3144 recv_msg->msgid = 0; 3274 recv_msg->msgid = 0;
3145 smi_addr = (struct ipmi_system_interface_addr *) &(recv_msg->addr); 3275 smi_addr = (struct ipmi_system_interface_addr *) &(recv_msg->addr);
3146 smi_addr->addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; 3276 smi_addr->addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
@@ -3181,8 +3311,10 @@ static int handle_read_event_rsp(ipmi_smi_t intf,
3181 3311
3182 ipmi_inc_stat(intf, events); 3312 ipmi_inc_stat(intf, events);
3183 3313
3184 /* Allocate and fill in one message for every user that is getting 3314 /*
3185 events. */ 3315 * Allocate and fill in one message for every user that is
3316 * getting events.
3317 */
3186 rcu_read_lock(); 3318 rcu_read_lock();
3187 list_for_each_entry_rcu(user, &intf->users, link) { 3319 list_for_each_entry_rcu(user, &intf->users, link) {
3188 if (!user->gets_events) 3320 if (!user->gets_events)
@@ -3196,9 +3328,11 @@ static int handle_read_event_rsp(ipmi_smi_t intf,
3196 list_del(&recv_msg->link); 3328 list_del(&recv_msg->link);
3197 ipmi_free_recv_msg(recv_msg); 3329 ipmi_free_recv_msg(recv_msg);
3198 } 3330 }
3199 /* We couldn't allocate memory for the 3331 /*
3200 message, so requeue it for handling 3332 * We couldn't allocate memory for the
3201 later. */ 3333 * message, so requeue it for handling
3334 * later.
3335 */
3202 rv = 1; 3336 rv = 1;
3203 goto out; 3337 goto out;
3204 } 3338 }
@@ -3219,13 +3353,17 @@ static int handle_read_event_rsp(ipmi_smi_t intf,
3219 deliver_response(recv_msg); 3353 deliver_response(recv_msg);
3220 } 3354 }
3221 } else if (intf->waiting_events_count < MAX_EVENTS_IN_QUEUE) { 3355 } else if (intf->waiting_events_count < MAX_EVENTS_IN_QUEUE) {
3222 /* No one to receive the message, put it in queue if there's 3356 /*
3223 not already too many things in the queue. */ 3357 * No one to receive the message, put it in queue if there's
3358 * not already too many things in the queue.
3359 */
3224 recv_msg = ipmi_alloc_recv_msg(); 3360 recv_msg = ipmi_alloc_recv_msg();
3225 if (!recv_msg) { 3361 if (!recv_msg) {
3226 /* We couldn't allocate memory for the 3362 /*
3227 message, so requeue it for handling 3363 * We couldn't allocate memory for the
3228 later. */ 3364 * message, so requeue it for handling
3365 * later.
3366 */
3229 rv = 1; 3367 rv = 1;
3230 goto out; 3368 goto out;
3231 } 3369 }
@@ -3234,8 +3372,10 @@ static int handle_read_event_rsp(ipmi_smi_t intf,
3234 list_add_tail(&(recv_msg->link), &(intf->waiting_events)); 3372 list_add_tail(&(recv_msg->link), &(intf->waiting_events));
3235 intf->waiting_events_count++; 3373 intf->waiting_events_count++;
3236 } else if (!intf->event_msg_printed) { 3374 } else if (!intf->event_msg_printed) {
3237 /* There's too many things in the queue, discard this 3375 /*
3238 message. */ 3376 * There's too many things in the queue, discard this
3377 * message.
3378 */
3239 printk(KERN_WARNING PFX "Event queue full, discarding" 3379 printk(KERN_WARNING PFX "Event queue full, discarding"
3240 " incoming events\n"); 3380 " incoming events\n");
3241 intf->event_msg_printed = 1; 3381 intf->event_msg_printed = 1;
@@ -3254,12 +3394,12 @@ static int handle_bmc_rsp(ipmi_smi_t intf,
3254 struct ipmi_user *user; 3394 struct ipmi_user *user;
3255 3395
3256 recv_msg = (struct ipmi_recv_msg *) msg->user_data; 3396 recv_msg = (struct ipmi_recv_msg *) msg->user_data;
3257 if (recv_msg == NULL) 3397 if (recv_msg == NULL) {
3258 { 3398 printk(KERN_WARNING
3259 printk(KERN_WARNING"IPMI message received with no owner. This\n" 3399 "IPMI message received with no owner. This\n"
3260 "could be because of a malformed message, or\n" 3400 "could be because of a malformed message, or\n"
3261 "because of a hardware error. Contact your\n" 3401 "because of a hardware error. Contact your\n"
3262 "hardware vender for assistance\n"); 3402 "hardware vender for assistance\n");
3263 return 0; 3403 return 0;
3264 } 3404 }
3265 3405
@@ -3293,9 +3433,11 @@ static int handle_bmc_rsp(ipmi_smi_t intf,
3293 return 0; 3433 return 0;
3294} 3434}
3295 3435
3296/* Handle a new message. Return 1 if the message should be requeued, 3436/*
3297 0 if the message should be freed, or -1 if the message should not 3437 * Handle a new message. Return 1 if the message should be requeued,
3298 be freed or requeued. */ 3438 * 0 if the message should be freed, or -1 if the message should not
3439 * be freed or requeued.
3440 */
3299static int handle_new_recv_msg(ipmi_smi_t intf, 3441static int handle_new_recv_msg(ipmi_smi_t intf,
3300 struct ipmi_smi_msg *msg) 3442 struct ipmi_smi_msg *msg)
3301{ 3443{
@@ -3320,10 +3462,12 @@ static int handle_new_recv_msg(ipmi_smi_t intf,
3320 msg->rsp[1] = msg->data[1]; 3462 msg->rsp[1] = msg->data[1];
3321 msg->rsp[2] = IPMI_ERR_UNSPECIFIED; 3463 msg->rsp[2] = IPMI_ERR_UNSPECIFIED;
3322 msg->rsp_size = 3; 3464 msg->rsp_size = 3;
3323 } else if (((msg->rsp[0] >> 2) != ((msg->data[0] >> 2) | 1))/* Netfn */ 3465 } else if (((msg->rsp[0] >> 2) != ((msg->data[0] >> 2) | 1))
3324 || (msg->rsp[1] != msg->data[1])) /* Command */ 3466 || (msg->rsp[1] != msg->data[1])) {
3325 { 3467 /*
3326 /* The response is not even marginally correct. */ 3468 * The NetFN and Command in the response is not even
3469 * marginally correct.
3470 */
3327 printk(KERN_WARNING PFX "BMC returned incorrect response," 3471 printk(KERN_WARNING PFX "BMC returned incorrect response,"
3328 " expected netfn %x cmd %x, got netfn %x cmd %x\n", 3472 " expected netfn %x cmd %x, got netfn %x cmd %x\n",
3329 (msg->data[0] >> 2) | 1, msg->data[1], 3473 (msg->data[0] >> 2) | 1, msg->data[1],
@@ -3338,10 +3482,11 @@ static int handle_new_recv_msg(ipmi_smi_t intf,
3338 3482
3339 if ((msg->rsp[0] == ((IPMI_NETFN_APP_REQUEST|1) << 2)) 3483 if ((msg->rsp[0] == ((IPMI_NETFN_APP_REQUEST|1) << 2))
3340 && (msg->rsp[1] == IPMI_SEND_MSG_CMD) 3484 && (msg->rsp[1] == IPMI_SEND_MSG_CMD)
3341 && (msg->user_data != NULL)) 3485 && (msg->user_data != NULL)) {
3342 { 3486 /*
3343 /* It's a response to a response we sent. For this we 3487 * It's a response to a response we sent. For this we
3344 deliver a send message response to the user. */ 3488 * deliver a send message response to the user.
3489 */
3345 struct ipmi_recv_msg *recv_msg = msg->user_data; 3490 struct ipmi_recv_msg *recv_msg = msg->user_data;
3346 3491
3347 requeue = 0; 3492 requeue = 0;
@@ -3367,8 +3512,7 @@ static int handle_new_recv_msg(ipmi_smi_t intf,
3367 recv_msg->msg_data[0] = msg->rsp[2]; 3512 recv_msg->msg_data[0] = msg->rsp[2];
3368 deliver_response(recv_msg); 3513 deliver_response(recv_msg);
3369 } else if ((msg->rsp[0] == ((IPMI_NETFN_APP_REQUEST|1) << 2)) 3514 } else if ((msg->rsp[0] == ((IPMI_NETFN_APP_REQUEST|1) << 2))
3370 && (msg->rsp[1] == IPMI_GET_MSG_CMD)) 3515 && (msg->rsp[1] == IPMI_GET_MSG_CMD)) {
3371 {
3372 /* It's from the receive queue. */ 3516 /* It's from the receive queue. */
3373 chan = msg->rsp[3] & 0xf; 3517 chan = msg->rsp[3] & 0xf;
3374 if (chan >= IPMI_MAX_CHANNELS) { 3518 if (chan >= IPMI_MAX_CHANNELS) {
@@ -3380,12 +3524,16 @@ static int handle_new_recv_msg(ipmi_smi_t intf,
3380 switch (intf->channels[chan].medium) { 3524 switch (intf->channels[chan].medium) {
3381 case IPMI_CHANNEL_MEDIUM_IPMB: 3525 case IPMI_CHANNEL_MEDIUM_IPMB:
3382 if (msg->rsp[4] & 0x04) { 3526 if (msg->rsp[4] & 0x04) {
3383 /* It's a response, so find the 3527 /*
3384 requesting message and send it up. */ 3528 * It's a response, so find the
3529 * requesting message and send it up.
3530 */
3385 requeue = handle_ipmb_get_msg_rsp(intf, msg); 3531 requeue = handle_ipmb_get_msg_rsp(intf, msg);
3386 } else { 3532 } else {
3387 /* It's a command to the SMS from some other 3533 /*
3388 entity. Handle that. */ 3534 * It's a command to the SMS from some other
3535 * entity. Handle that.
3536 */
3389 requeue = handle_ipmb_get_msg_cmd(intf, msg); 3537 requeue = handle_ipmb_get_msg_cmd(intf, msg);
3390 } 3538 }
3391 break; 3539 break;
@@ -3393,25 +3541,30 @@ static int handle_new_recv_msg(ipmi_smi_t intf,
3393 case IPMI_CHANNEL_MEDIUM_8023LAN: 3541 case IPMI_CHANNEL_MEDIUM_8023LAN:
3394 case IPMI_CHANNEL_MEDIUM_ASYNC: 3542 case IPMI_CHANNEL_MEDIUM_ASYNC:
3395 if (msg->rsp[6] & 0x04) { 3543 if (msg->rsp[6] & 0x04) {
3396 /* It's a response, so find the 3544 /*
3397 requesting message and send it up. */ 3545 * It's a response, so find the
3546 * requesting message and send it up.
3547 */
3398 requeue = handle_lan_get_msg_rsp(intf, msg); 3548 requeue = handle_lan_get_msg_rsp(intf, msg);
3399 } else { 3549 } else {
3400 /* It's a command to the SMS from some other 3550 /*
3401 entity. Handle that. */ 3551 * It's a command to the SMS from some other
3552 * entity. Handle that.
3553 */
3402 requeue = handle_lan_get_msg_cmd(intf, msg); 3554 requeue = handle_lan_get_msg_cmd(intf, msg);
3403 } 3555 }
3404 break; 3556 break;
3405 3557
3406 default: 3558 default:
3407 /* We don't handle the channel type, so just 3559 /*
3408 * free the message. */ 3560 * We don't handle the channel type, so just
3561 * free the message.
3562 */
3409 requeue = 0; 3563 requeue = 0;
3410 } 3564 }
3411 3565
3412 } else if ((msg->rsp[0] == ((IPMI_NETFN_APP_REQUEST|1) << 2)) 3566 } else if ((msg->rsp[0] == ((IPMI_NETFN_APP_REQUEST|1) << 2))
3413 && (msg->rsp[1] == IPMI_READ_EVENT_MSG_BUFFER_CMD)) 3567 && (msg->rsp[1] == IPMI_READ_EVENT_MSG_BUFFER_CMD)) {
3414 {
3415 /* It's an asyncronous event. */ 3568 /* It's an asyncronous event. */
3416 requeue = handle_read_event_rsp(intf, msg); 3569 requeue = handle_read_event_rsp(intf, msg);
3417 } else { 3570 } else {
@@ -3435,23 +3588,25 @@ void ipmi_smi_msg_received(ipmi_smi_t intf,
3435 if ((msg->data_size >= 2) 3588 if ((msg->data_size >= 2)
3436 && (msg->data[0] == (IPMI_NETFN_APP_REQUEST << 2)) 3589 && (msg->data[0] == (IPMI_NETFN_APP_REQUEST << 2))
3437 && (msg->data[1] == IPMI_SEND_MSG_CMD) 3590 && (msg->data[1] == IPMI_SEND_MSG_CMD)
3438 && (msg->user_data == NULL)) 3591 && (msg->user_data == NULL)) {
3439 { 3592 /*
3440 /* This is the local response to a command send, start 3593 * This is the local response to a command send, start
3441 the timer for these. The user_data will not be 3594 * the timer for these. The user_data will not be
3442 NULL if this is a response send, and we will let 3595 * NULL if this is a response send, and we will let
3443 response sends just go through. */ 3596 * response sends just go through.
3444 3597 */
3445 /* Check for errors, if we get certain errors (ones 3598
3446 that mean basically we can try again later), we 3599 /*
3447 ignore them and start the timer. Otherwise we 3600 * Check for errors, if we get certain errors (ones
3448 report the error immediately. */ 3601 * that mean basically we can try again later), we
3602 * ignore them and start the timer. Otherwise we
3603 * report the error immediately.
3604 */
3449 if ((msg->rsp_size >= 3) && (msg->rsp[2] != 0) 3605 if ((msg->rsp_size >= 3) && (msg->rsp[2] != 0)
3450 && (msg->rsp[2] != IPMI_NODE_BUSY_ERR) 3606 && (msg->rsp[2] != IPMI_NODE_BUSY_ERR)
3451 && (msg->rsp[2] != IPMI_LOST_ARBITRATION_ERR) 3607 && (msg->rsp[2] != IPMI_LOST_ARBITRATION_ERR)
3452 && (msg->rsp[2] != IPMI_BUS_ERR) 3608 && (msg->rsp[2] != IPMI_BUS_ERR)
3453 && (msg->rsp[2] != IPMI_NAK_ON_WRITE_ERR)) 3609 && (msg->rsp[2] != IPMI_NAK_ON_WRITE_ERR)) {
3454 {
3455 int chan = msg->rsp[3] & 0xf; 3610 int chan = msg->rsp[3] & 0xf;
3456 3611
3457 /* Got an error sending the message, handle it. */ 3612 /* Got an error sending the message, handle it. */
@@ -3465,17 +3620,18 @@ void ipmi_smi_msg_received(ipmi_smi_t intf,
3465 else 3620 else
3466 ipmi_inc_stat(intf, sent_ipmb_command_errs); 3621 ipmi_inc_stat(intf, sent_ipmb_command_errs);
3467 intf_err_seq(intf, msg->msgid, msg->rsp[2]); 3622 intf_err_seq(intf, msg->msgid, msg->rsp[2]);
3468 } else { 3623 } else
3469 /* The message was sent, start the timer. */ 3624 /* The message was sent, start the timer. */
3470 intf_start_seq_timer(intf, msg->msgid); 3625 intf_start_seq_timer(intf, msg->msgid);
3471 }
3472 3626
3473 ipmi_free_smi_msg(msg); 3627 ipmi_free_smi_msg(msg);
3474 goto out; 3628 goto out;
3475 } 3629 }
3476 3630
3477 /* To preserve message order, if the list is not empty, we 3631 /*
3478 tack this message onto the end of the list. */ 3632 * To preserve message order, if the list is not empty, we
3633 * tack this message onto the end of the list.
3634 */
3479 run_to_completion = intf->run_to_completion; 3635 run_to_completion = intf->run_to_completion;
3480 if (!run_to_completion) 3636 if (!run_to_completion)
3481 spin_lock_irqsave(&intf->waiting_msgs_lock, flags); 3637 spin_lock_irqsave(&intf->waiting_msgs_lock, flags);
@@ -3487,11 +3643,13 @@ void ipmi_smi_msg_received(ipmi_smi_t intf,
3487 } 3643 }
3488 if (!run_to_completion) 3644 if (!run_to_completion)
3489 spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags); 3645 spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags);
3490 3646
3491 rv = handle_new_recv_msg(intf, msg); 3647 rv = handle_new_recv_msg(intf, msg);
3492 if (rv > 0) { 3648 if (rv > 0) {
3493 /* Could not handle the message now, just add it to a 3649 /*
3494 list to handle later. */ 3650 * Could not handle the message now, just add it to a
3651 * list to handle later.
3652 */
3495 run_to_completion = intf->run_to_completion; 3653 run_to_completion = intf->run_to_completion;
3496 if (!run_to_completion) 3654 if (!run_to_completion)
3497 spin_lock_irqsave(&intf->waiting_msgs_lock, flags); 3655 spin_lock_irqsave(&intf->waiting_msgs_lock, flags);
@@ -3505,6 +3663,7 @@ void ipmi_smi_msg_received(ipmi_smi_t intf,
3505 out: 3663 out:
3506 return; 3664 return;
3507} 3665}
3666EXPORT_SYMBOL(ipmi_smi_msg_received);
3508 3667
3509void ipmi_smi_watchdog_pretimeout(ipmi_smi_t intf) 3668void ipmi_smi_watchdog_pretimeout(ipmi_smi_t intf)
3510{ 3669{
@@ -3519,7 +3678,7 @@ void ipmi_smi_watchdog_pretimeout(ipmi_smi_t intf)
3519 } 3678 }
3520 rcu_read_unlock(); 3679 rcu_read_unlock();
3521} 3680}
3522 3681EXPORT_SYMBOL(ipmi_smi_watchdog_pretimeout);
3523 3682
3524static struct ipmi_smi_msg * 3683static struct ipmi_smi_msg *
3525smi_from_recv_msg(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg, 3684smi_from_recv_msg(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg,
@@ -3527,14 +3686,16 @@ smi_from_recv_msg(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg,
3527{ 3686{
3528 struct ipmi_smi_msg *smi_msg = ipmi_alloc_smi_msg(); 3687 struct ipmi_smi_msg *smi_msg = ipmi_alloc_smi_msg();
3529 if (!smi_msg) 3688 if (!smi_msg)
3530 /* If we can't allocate the message, then just return, we 3689 /*
3531 get 4 retries, so this should be ok. */ 3690 * If we can't allocate the message, then just return, we
3691 * get 4 retries, so this should be ok.
3692 */
3532 return NULL; 3693 return NULL;
3533 3694
3534 memcpy(smi_msg->data, recv_msg->msg.data, recv_msg->msg.data_len); 3695 memcpy(smi_msg->data, recv_msg->msg.data, recv_msg->msg.data_len);
3535 smi_msg->data_size = recv_msg->msg.data_len; 3696 smi_msg->data_size = recv_msg->msg.data_len;
3536 smi_msg->msgid = STORE_SEQ_IN_MSGID(seq, seqid); 3697 smi_msg->msgid = STORE_SEQ_IN_MSGID(seq, seqid);
3537 3698
3538#ifdef DEBUG_MSGING 3699#ifdef DEBUG_MSGING
3539 { 3700 {
3540 int m; 3701 int m;
@@ -3579,8 +3740,10 @@ static void check_msg_timeout(ipmi_smi_t intf, struct seq_table *ent,
3579 struct ipmi_smi_msg *smi_msg; 3740 struct ipmi_smi_msg *smi_msg;
3580 /* More retries, send again. */ 3741 /* More retries, send again. */
3581 3742
3582 /* Start with the max timer, set to normal 3743 /*
3583 timer after the message is sent. */ 3744 * Start with the max timer, set to normal timer after
3745 * the message is sent.
3746 */
3584 ent->timeout = MAX_MSG_TIMEOUT; 3747 ent->timeout = MAX_MSG_TIMEOUT;
3585 ent->retries_left--; 3748 ent->retries_left--;
3586 if (ent->recv_msg->addr.addr_type == IPMI_LAN_ADDR_TYPE) 3749 if (ent->recv_msg->addr.addr_type == IPMI_LAN_ADDR_TYPE)
@@ -3595,11 +3758,13 @@ static void check_msg_timeout(ipmi_smi_t intf, struct seq_table *ent,
3595 3758
3596 spin_unlock_irqrestore(&intf->seq_lock, *flags); 3759 spin_unlock_irqrestore(&intf->seq_lock, *flags);
3597 3760
3598 /* Send the new message. We send with a zero 3761 /*
3599 * priority. It timed out, I doubt time is 3762 * Send the new message. We send with a zero
3600 * that critical now, and high priority 3763 * priority. It timed out, I doubt time is that
3601 * messages are really only for messages to the 3764 * critical now, and high priority messages are really
3602 * local MC, which don't get resent. */ 3765 * only for messages to the local MC, which don't get
3766 * resent.
3767 */
3603 handlers = intf->handlers; 3768 handlers = intf->handlers;
3604 if (handlers) 3769 if (handlers)
3605 intf->handlers->sender(intf->send_info, 3770 intf->handlers->sender(intf->send_info,
@@ -3630,16 +3795,20 @@ static void ipmi_timeout_handler(long timeout_period)
3630 list_del(&smi_msg->link); 3795 list_del(&smi_msg->link);
3631 ipmi_free_smi_msg(smi_msg); 3796 ipmi_free_smi_msg(smi_msg);
3632 } else { 3797 } else {
3633 /* To preserve message order, quit if we 3798 /*
3634 can't handle a message. */ 3799 * To preserve message order, quit if we
3800 * can't handle a message.
3801 */
3635 break; 3802 break;
3636 } 3803 }
3637 } 3804 }
3638 spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags); 3805 spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags);
3639 3806
3640 /* Go through the seq table and find any messages that 3807 /*
3641 have timed out, putting them in the timeouts 3808 * Go through the seq table and find any messages that
3642 list. */ 3809 * have timed out, putting them in the timeouts
3810 * list.
3811 */
3643 INIT_LIST_HEAD(&timeouts); 3812 INIT_LIST_HEAD(&timeouts);
3644 spin_lock_irqsave(&intf->seq_lock, flags); 3813 spin_lock_irqsave(&intf->seq_lock, flags);
3645 for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) 3814 for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++)
@@ -3665,8 +3834,7 @@ static void ipmi_timeout_handler(long timeout_period)
3665 intf->auto_maintenance_timeout 3834 intf->auto_maintenance_timeout
3666 -= timeout_period; 3835 -= timeout_period;
3667 if (!intf->maintenance_mode 3836 if (!intf->maintenance_mode
3668 && (intf->auto_maintenance_timeout <= 0)) 3837 && (intf->auto_maintenance_timeout <= 0)) {
3669 {
3670 intf->maintenance_mode_enable = 0; 3838 intf->maintenance_mode_enable = 0;
3671 maintenance_mode_update(intf); 3839 maintenance_mode_update(intf);
3672 } 3840 }
@@ -3684,8 +3852,10 @@ static void ipmi_request_event(void)
3684 struct ipmi_smi_handlers *handlers; 3852 struct ipmi_smi_handlers *handlers;
3685 3853
3686 rcu_read_lock(); 3854 rcu_read_lock();
3687 /* Called from the timer, no need to check if handlers is 3855 /*
3688 * valid. */ 3856 * Called from the timer, no need to check if handlers is
3857 * valid.
3858 */
3689 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) { 3859 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
3690 /* No event requests when in maintenance mode. */ 3860 /* No event requests when in maintenance mode. */
3691 if (intf->maintenance_mode_enable) 3861 if (intf->maintenance_mode_enable)
@@ -3706,10 +3876,12 @@ static struct timer_list ipmi_timer;
3706/* How many jiffies does it take to get to the timeout time. */ 3876/* How many jiffies does it take to get to the timeout time. */
3707#define IPMI_TIMEOUT_JIFFIES ((IPMI_TIMEOUT_TIME * HZ) / 1000) 3877#define IPMI_TIMEOUT_JIFFIES ((IPMI_TIMEOUT_TIME * HZ) / 1000)
3708 3878
3709/* Request events from the queue every second (this is the number of 3879/*
3710 IPMI_TIMEOUT_TIMES between event requests). Hopefully, in the 3880 * Request events from the queue every second (this is the number of
3711 future, IPMI will add a way to know immediately if an event is in 3881 * IPMI_TIMEOUT_TIMES between event requests). Hopefully, in the
3712 the queue and this silliness can go away. */ 3882 * future, IPMI will add a way to know immediately if an event is in
3883 * the queue and this silliness can go away.
3884 */
3713#define IPMI_REQUEST_EV_TIME (1000 / (IPMI_TIMEOUT_TIME)) 3885#define IPMI_REQUEST_EV_TIME (1000 / (IPMI_TIMEOUT_TIME))
3714 3886
3715static atomic_t stop_operation; 3887static atomic_t stop_operation;
@@ -3753,6 +3925,7 @@ struct ipmi_smi_msg *ipmi_alloc_smi_msg(void)
3753 } 3925 }
3754 return rv; 3926 return rv;
3755} 3927}
3928EXPORT_SYMBOL(ipmi_alloc_smi_msg);
3756 3929
3757static void free_recv_msg(struct ipmi_recv_msg *msg) 3930static void free_recv_msg(struct ipmi_recv_msg *msg)
3758{ 3931{
@@ -3779,6 +3952,7 @@ void ipmi_free_recv_msg(struct ipmi_recv_msg *msg)
3779 kref_put(&msg->user->refcount, free_user); 3952 kref_put(&msg->user->refcount, free_user);
3780 msg->done(msg); 3953 msg->done(msg);
3781} 3954}
3955EXPORT_SYMBOL(ipmi_free_recv_msg);
3782 3956
3783#ifdef CONFIG_IPMI_PANIC_EVENT 3957#ifdef CONFIG_IPMI_PANIC_EVENT
3784 3958
@@ -3796,8 +3970,7 @@ static void event_receiver_fetcher(ipmi_smi_t intf, struct ipmi_recv_msg *msg)
3796 if ((msg->addr.addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE) 3970 if ((msg->addr.addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE)
3797 && (msg->msg.netfn == IPMI_NETFN_SENSOR_EVENT_RESPONSE) 3971 && (msg->msg.netfn == IPMI_NETFN_SENSOR_EVENT_RESPONSE)
3798 && (msg->msg.cmd == IPMI_GET_EVENT_RECEIVER_CMD) 3972 && (msg->msg.cmd == IPMI_GET_EVENT_RECEIVER_CMD)
3799 && (msg->msg.data[0] == IPMI_CC_NO_ERROR)) 3973 && (msg->msg.data[0] == IPMI_CC_NO_ERROR)) {
3800 {
3801 /* A get event receiver command, save it. */ 3974 /* A get event receiver command, save it. */
3802 intf->event_receiver = msg->msg.data[1]; 3975 intf->event_receiver = msg->msg.data[1];
3803 intf->event_receiver_lun = msg->msg.data[2] & 0x3; 3976 intf->event_receiver_lun = msg->msg.data[2] & 0x3;
@@ -3809,10 +3982,11 @@ static void device_id_fetcher(ipmi_smi_t intf, struct ipmi_recv_msg *msg)
3809 if ((msg->addr.addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE) 3982 if ((msg->addr.addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE)
3810 && (msg->msg.netfn == IPMI_NETFN_APP_RESPONSE) 3983 && (msg->msg.netfn == IPMI_NETFN_APP_RESPONSE)
3811 && (msg->msg.cmd == IPMI_GET_DEVICE_ID_CMD) 3984 && (msg->msg.cmd == IPMI_GET_DEVICE_ID_CMD)
3812 && (msg->msg.data[0] == IPMI_CC_NO_ERROR)) 3985 && (msg->msg.data[0] == IPMI_CC_NO_ERROR)) {
3813 { 3986 /*
3814 /* A get device id command, save if we are an event 3987 * A get device id command, save if we are an event
3815 receiver or generator. */ 3988 * receiver or generator.
3989 */
3816 intf->local_sel_device = (msg->msg.data[6] >> 2) & 1; 3990 intf->local_sel_device = (msg->msg.data[6] >> 2) & 1;
3817 intf->local_event_generator = (msg->msg.data[6] >> 5) & 1; 3991 intf->local_event_generator = (msg->msg.data[6] >> 5) & 1;
3818 } 3992 }
@@ -3845,8 +4019,10 @@ static void send_panic_events(char *str)
3845 data[4] = 0x6f; /* Sensor specific, IPMI table 36-1 */ 4019 data[4] = 0x6f; /* Sensor specific, IPMI table 36-1 */
3846 data[5] = 0xa1; /* Runtime stop OEM bytes 2 & 3. */ 4020 data[5] = 0xa1; /* Runtime stop OEM bytes 2 & 3. */
3847 4021
3848 /* Put a few breadcrumbs in. Hopefully later we can add more things 4022 /*
3849 to make the panic events more useful. */ 4023 * Put a few breadcrumbs in. Hopefully later we can add more things
4024 * to make the panic events more useful.
4025 */
3850 if (str) { 4026 if (str) {
3851 data[3] = str[0]; 4027 data[3] = str[0];
3852 data[6] = str[1]; 4028 data[6] = str[1];
@@ -3880,9 +4056,11 @@ static void send_panic_events(char *str)
3880 } 4056 }
3881 4057
3882#ifdef CONFIG_IPMI_PANIC_STRING 4058#ifdef CONFIG_IPMI_PANIC_STRING
3883 /* On every interface, dump a bunch of OEM event holding the 4059 /*
3884 string. */ 4060 * On every interface, dump a bunch of OEM event holding the
3885 if (!str) 4061 * string.
4062 */
4063 if (!str)
3886 return; 4064 return;
3887 4065
3888 /* For every registered interface, send the event. */ 4066 /* For every registered interface, send the event. */
@@ -3903,11 +4081,13 @@ static void send_panic_events(char *str)
3903 */ 4081 */
3904 smp_rmb(); 4082 smp_rmb();
3905 4083
3906 /* First job here is to figure out where to send the 4084 /*
3907 OEM events. There's no way in IPMI to send OEM 4085 * First job here is to figure out where to send the
3908 events using an event send command, so we have to 4086 * OEM events. There's no way in IPMI to send OEM
3909 find the SEL to put them in and stick them in 4087 * events using an event send command, so we have to
3910 there. */ 4088 * find the SEL to put them in and stick them in
4089 * there.
4090 */
3911 4091
3912 /* Get capabilities from the get device id. */ 4092 /* Get capabilities from the get device id. */
3913 intf->local_sel_device = 0; 4093 intf->local_sel_device = 0;
@@ -3955,24 +4135,29 @@ static void send_panic_events(char *str)
3955 } 4135 }
3956 intf->null_user_handler = NULL; 4136 intf->null_user_handler = NULL;
3957 4137
3958 /* Validate the event receiver. The low bit must not 4138 /*
3959 be 1 (it must be a valid IPMB address), it cannot 4139 * Validate the event receiver. The low bit must not
3960 be zero, and it must not be my address. */ 4140 * be 1 (it must be a valid IPMB address), it cannot
3961 if (((intf->event_receiver & 1) == 0) 4141 * be zero, and it must not be my address.
4142 */
4143 if (((intf->event_receiver & 1) == 0)
3962 && (intf->event_receiver != 0) 4144 && (intf->event_receiver != 0)
3963 && (intf->event_receiver != intf->channels[0].address)) 4145 && (intf->event_receiver != intf->channels[0].address)) {
3964 { 4146 /*
3965 /* The event receiver is valid, send an IPMB 4147 * The event receiver is valid, send an IPMB
3966 message. */ 4148 * message.
4149 */
3967 ipmb = (struct ipmi_ipmb_addr *) &addr; 4150 ipmb = (struct ipmi_ipmb_addr *) &addr;
3968 ipmb->addr_type = IPMI_IPMB_ADDR_TYPE; 4151 ipmb->addr_type = IPMI_IPMB_ADDR_TYPE;
3969 ipmb->channel = 0; /* FIXME - is this right? */ 4152 ipmb->channel = 0; /* FIXME - is this right? */
3970 ipmb->lun = intf->event_receiver_lun; 4153 ipmb->lun = intf->event_receiver_lun;
3971 ipmb->slave_addr = intf->event_receiver; 4154 ipmb->slave_addr = intf->event_receiver;
3972 } else if (intf->local_sel_device) { 4155 } else if (intf->local_sel_device) {
3973 /* The event receiver was not valid (or was 4156 /*
3974 me), but I am an SEL device, just dump it 4157 * The event receiver was not valid (or was
3975 in my SEL. */ 4158 * me), but I am an SEL device, just dump it
4159 * in my SEL.
4160 */
3976 si = (struct ipmi_system_interface_addr *) &addr; 4161 si = (struct ipmi_system_interface_addr *) &addr;
3977 si->addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; 4162 si->addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
3978 si->channel = IPMI_BMC_CHANNEL; 4163 si->channel = IPMI_BMC_CHANNEL;
@@ -3980,7 +4165,6 @@ static void send_panic_events(char *str)
3980 } else 4165 } else
3981 continue; /* No where to send the event. */ 4166 continue; /* No where to send the event. */
3982 4167
3983
3984 msg.netfn = IPMI_NETFN_STORAGE_REQUEST; /* Storage. */ 4168 msg.netfn = IPMI_NETFN_STORAGE_REQUEST; /* Storage. */
3985 msg.cmd = IPMI_ADD_SEL_ENTRY_CMD; 4169 msg.cmd = IPMI_ADD_SEL_ENTRY_CMD;
3986 msg.data = data; 4170 msg.data = data;
@@ -3997,8 +4181,10 @@ static void send_panic_events(char *str)
3997 data[2] = 0xf0; /* OEM event without timestamp. */ 4181 data[2] = 0xf0; /* OEM event without timestamp. */
3998 data[3] = intf->channels[0].address; 4182 data[3] = intf->channels[0].address;
3999 data[4] = j++; /* sequence # */ 4183 data[4] = j++; /* sequence # */
4000 /* Always give 11 bytes, so strncpy will fill 4184 /*
4001 it with zeroes for me. */ 4185 * Always give 11 bytes, so strncpy will fill
4186 * it with zeroes for me.
4187 */
4002 strncpy(data+5, p, 11); 4188 strncpy(data+5, p, 11);
4003 p += size; 4189 p += size;
4004 4190
@@ -4015,7 +4201,7 @@ static void send_panic_events(char *str)
4015 intf->channels[0].lun, 4201 intf->channels[0].lun,
4016 0, 1); /* no retry, and no wait. */ 4202 0, 1); /* no retry, and no wait. */
4017 } 4203 }
4018 } 4204 }
4019#endif /* CONFIG_IPMI_PANIC_STRING */ 4205#endif /* CONFIG_IPMI_PANIC_STRING */
4020} 4206}
4021#endif /* CONFIG_IPMI_PANIC_EVENT */ 4207#endif /* CONFIG_IPMI_PANIC_EVENT */
@@ -4024,7 +4210,7 @@ static int has_panicked;
4024 4210
4025static int panic_event(struct notifier_block *this, 4211static int panic_event(struct notifier_block *this,
4026 unsigned long event, 4212 unsigned long event,
4027 void *ptr) 4213 void *ptr)
4028{ 4214{
4029 ipmi_smi_t intf; 4215 ipmi_smi_t intf;
4030 4216
@@ -4106,11 +4292,16 @@ static __exit void cleanup_ipmi(void)
4106 4292
4107 atomic_notifier_chain_unregister(&panic_notifier_list, &panic_block); 4293 atomic_notifier_chain_unregister(&panic_notifier_list, &panic_block);
4108 4294
4109 /* This can't be called if any interfaces exist, so no worry about 4295 /*
4110 shutting down the interfaces. */ 4296 * This can't be called if any interfaces exist, so no worry
4297 * about shutting down the interfaces.
4298 */
4111 4299
4112 /* Tell the timer to stop, then wait for it to stop. This avoids 4300 /*
4113 problems with race conditions removing the timer here. */ 4301 * Tell the timer to stop, then wait for it to stop. This
4302 * avoids problems with race conditions removing the timer
4303 * here.
4304 */
4114 atomic_inc(&stop_operation); 4305 atomic_inc(&stop_operation);
4115 del_timer_sync(&ipmi_timer); 4306 del_timer_sync(&ipmi_timer);
4116 4307
@@ -4137,30 +4328,6 @@ module_exit(cleanup_ipmi);
4137module_init(ipmi_init_msghandler_mod); 4328module_init(ipmi_init_msghandler_mod);
4138MODULE_LICENSE("GPL"); 4329MODULE_LICENSE("GPL");
4139MODULE_AUTHOR("Corey Minyard <minyard@mvista.com>"); 4330MODULE_AUTHOR("Corey Minyard <minyard@mvista.com>");
4140MODULE_DESCRIPTION("Incoming and outgoing message routing for an IPMI interface."); 4331MODULE_DESCRIPTION("Incoming and outgoing message routing for an IPMI"
4332 " interface.");
4141MODULE_VERSION(IPMI_DRIVER_VERSION); 4333MODULE_VERSION(IPMI_DRIVER_VERSION);
4142
4143EXPORT_SYMBOL(ipmi_create_user);
4144EXPORT_SYMBOL(ipmi_destroy_user);
4145EXPORT_SYMBOL(ipmi_get_version);
4146EXPORT_SYMBOL(ipmi_request_settime);
4147EXPORT_SYMBOL(ipmi_request_supply_msgs);
4148EXPORT_SYMBOL(ipmi_poll_interface);
4149EXPORT_SYMBOL(ipmi_register_smi);
4150EXPORT_SYMBOL(ipmi_unregister_smi);
4151EXPORT_SYMBOL(ipmi_register_for_cmd);
4152EXPORT_SYMBOL(ipmi_unregister_for_cmd);
4153EXPORT_SYMBOL(ipmi_smi_msg_received);
4154EXPORT_SYMBOL(ipmi_smi_watchdog_pretimeout);
4155EXPORT_SYMBOL(ipmi_alloc_smi_msg);
4156EXPORT_SYMBOL(ipmi_addr_length);
4157EXPORT_SYMBOL(ipmi_validate_addr);
4158EXPORT_SYMBOL(ipmi_set_gets_events);
4159EXPORT_SYMBOL(ipmi_smi_watcher_register);
4160EXPORT_SYMBOL(ipmi_smi_watcher_unregister);
4161EXPORT_SYMBOL(ipmi_set_my_address);
4162EXPORT_SYMBOL(ipmi_get_my_address);
4163EXPORT_SYMBOL(ipmi_set_my_LUN);
4164EXPORT_SYMBOL(ipmi_get_my_LUN);
4165EXPORT_SYMBOL(ipmi_smi_add_proc_entry);
4166EXPORT_SYMBOL(ipmi_free_recv_msg);