Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
422 giacomo 1
/*
2
 * ipmi_smi.h
3
 *
4
 * MontaVista IPMI system management interface
5
 *
6
 * Author: MontaVista Software, Inc.
7
 *         Corey Minyard <minyard@mvista.com>
8
 *         source@mvista.com
9
 *
10
 * Copyright 2002 MontaVista Software Inc.
11
 *
12
 *  This program is free software; you can redistribute it and/or modify it
13
 *  under the terms of the GNU General Public License as published by the
14
 *  Free Software Foundation; either version 2 of the License, or (at your
15
 *  option) any later version.
16
 *
17
 *
18
 *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
19
 *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20
 *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21
 *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22
 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23
 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
24
 *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
 *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
26
 *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
27
 *  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 *
29
 *  You should have received a copy of the GNU General Public License along
30
 *  with this program; if not, write to the Free Software Foundation, Inc.,
31
 *  675 Mass Ave, Cambridge, MA 02139, USA.
32
 */
33
 
34
#ifndef __LINUX_IPMI_SMI_H
35
#define __LINUX_IPMI_SMI_H
36
 
37
#include <linux/ipmi_msgdefs.h>
38
 
39
/* This files describes the interface for IPMI system management interface
40
   drivers to bind into the IPMI message handler. */
41
 
42
/* Structure for the low-level drivers. */
43
typedef struct ipmi_smi *ipmi_smi_t;
44
 
45
/*
46
 * Messages to/from the lower layer.  The smi interface will take one
47
 * of these to send. After the send has occurred and a response has
48
 * been received, it will report this same data structure back up to
49
 * the upper layer.  If an error occurs, it should fill in the
50
 * response with an error code in the completion code location. When
51
 * asyncronous data is received, one of these is allocated, the
52
 * data_size is set to zero and the response holds the data from the
53
 * get message or get event command that the interface initiated.
54
 * Note that it is the interfaces responsibility to detect
55
 * asynchronous data and messages and request them from the
56
 * interface.
57
 */
58
struct ipmi_smi_msg
59
{
60
        struct list_head link;
61
 
62
        long    msgid;
63
        void    *user_data;
64
 
65
        /* If 0, add to the end of the queue.  If 1, add to the beginning. */
66
        int     prio;
67
 
68
        int           data_size;
69
        unsigned char data[IPMI_MAX_MSG_LENGTH];
70
 
71
        int           rsp_size;
72
        unsigned char rsp[IPMI_MAX_MSG_LENGTH];
73
 
74
        /* Will be called when the system is done with the message
75
           (presumably to free it). */
76
        void (*done)(struct ipmi_smi_msg *msg);
77
};
78
 
79
struct ipmi_smi_handlers
80
{
81
        struct module *owner;
82
 
83
        /* Called to enqueue an SMI message to be sent.  This
84
           operation is not allowed to fail.  If an error occurs, it
85
           should report back the error in a received message.  It may
86
           do this in the current call context, since no write locks
87
           are held when this is run.  If the priority is > 0, the
88
           message will go into a high-priority queue and be sent
89
           first.  Otherwise, it goes into a normal-priority queue. */
90
        void (*sender)(void                *send_info,
91
                       struct ipmi_smi_msg *msg,
92
                       int                 priority);
93
 
94
        /* Called by the upper layer to request that we try to get
95
           events from the BMC we are attached to. */
96
        void (*request_events)(void *send_info);
97
 
98
        /* Called when the interface should go into "run to
99
           completion" mode.  If this call sets the value to true, the
100
           interface should make sure that all messages are flushed
101
           out and that none are pending, and any new requests are run
102
           to completion immediately. */
103
        void (*set_run_to_completion)(void *send_info, int run_to_completion);
104
};
105
 
106
/* Add a low-level interface to the IPMI driver. */
107
int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
108
                      void                     *send_info,
109
                      unsigned char            version_major,
110
                      unsigned char            version_minor,
111
                      ipmi_smi_t               *intf);
112
 
113
/*
114
 * Remove a low-level interface from the IPMI driver.  This will
115
 * return an error if the interface is still in use by a user.
116
 */
117
int ipmi_unregister_smi(ipmi_smi_t intf);
118
 
119
/*
120
 * The lower layer reports received messages through this interface.
121
 * The data_size should be zero if this is an asyncronous message.  If
122
 * the lower layer gets an error sending a message, it should format
123
 * an error response in the message response.
124
 */
125
void ipmi_smi_msg_received(ipmi_smi_t          intf,
126
                           struct ipmi_smi_msg *msg);
127
 
128
/* The lower layer received a watchdog pre-timeout on interface. */
129
void ipmi_smi_watchdog_pretimeout(ipmi_smi_t intf);
130
 
131
struct ipmi_smi_msg *ipmi_alloc_smi_msg(void);
132
static inline void ipmi_free_smi_msg(struct ipmi_smi_msg *msg)
133
{
134
        msg->done(msg);
135
}
136
 
137
#endif /* __LINUX_IPMI_SMI_H */