4
* MontaVista IPMI interface for management domains
6
* Author: MontaVista Software, Inc.
7
* Corey Minyard <minyard@mvista.com>
10
* Copyright 2002,2003 MontaVista Software Inc.
12
* This program is free software; you can redistribute it and/or
13
* modify it under the terms of the GNU Lesser General Public License
14
* as published by the Free Software Foundation; either version 2 of
15
* the License, or (at your option) any later version.
18
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
19
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
24
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
26
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
27
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
* You should have received a copy of the GNU Lesser General Public
30
* License along with this program; if not, write to the Free
31
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
34
#ifndef _IPMI_DOMAIN_H
35
#define _IPMI_DOMAIN_H
36
#include <OpenIPMI/ipmi_types.h>
37
#include <OpenIPMI/os_handler.h>
38
#include <OpenIPMI/ipmi_sdr.h>
39
#include <OpenIPMI/ipmi_addr.h>
41
#include <OpenIPMI/internal/ipmi_entity.h>
42
#include <OpenIPMI/internal/ipmi_sensor.h>
43
#include <OpenIPMI/internal/ipmi_control.h>
45
/* Handle validation and usecounts on domains. */
46
int _ipmi_domain_get(ipmi_domain_t *domain);
47
void _ipmi_domain_put(ipmi_domain_t *domain);
49
/* Return the OS handler used by the mc. */
50
os_handler_t *ipmi_domain_get_os_hnd(ipmi_domain_t *domain);
52
/* Return the entity info for the given domain. */
53
ipmi_entity_info_t *ipmi_domain_get_entities(ipmi_domain_t *domain);
55
/* Should the BMC do a full bus scan at startup? This is so OEM
56
code can turn this function off. The value is a boolean. */
57
int ipmi_domain_set_full_bus_scan(ipmi_domain_t *domain, int val);
59
int ipmi_domain_get_event_rcvr(ipmi_domain_t *domain);
61
/* Allocate an MC in the domain. It doesn't add it to the domain's
62
list, to allow the MC to be setup before that happens. */
63
int ipmi_create_mc(ipmi_domain_t *domain,
65
unsigned int addr_len,
68
int _ipmi_remove_mc_from_domain(ipmi_domain_t *domain, ipmi_mc_t *mc);
70
/* Attempt to find the MC, and if it doesn't exist create it and
72
int _ipmi_find_or_create_mc_by_slave_addr(ipmi_domain_t *domain,
74
unsigned int slave_addr,
77
/* Find the MC with the given IPMI address, or return NULL if not
79
ipmi_mc_t *_ipmi_find_mc_by_addr(ipmi_domain_t *domain,
81
unsigned int addr_len);
83
/* Return the SDRs for the given MC, or the main set of SDRs if the MC
85
void _ipmi_get_sdr_sensors(ipmi_domain_t *domain,
87
ipmi_sensor_t ***sensors,
90
/* Set the SDRs for the given MC, or the main set of SDRs if the MC is
92
void _ipmi_set_sdr_sensors(ipmi_domain_t *domain,
94
ipmi_sensor_t **sensors,
97
/* Returns/set the SDRs entity info for the given MC, or the main set
98
of SDRs if the MC is NULL. */
99
void *_ipmi_get_sdr_entities(ipmi_domain_t *domain,
101
void _ipmi_set_sdr_entities(ipmi_domain_t *domain,
105
/* Add an MC to the list of MCs in the domain. */
106
int ipmi_add_mc_to_domain(ipmi_domain_t *domain, ipmi_mc_t *mc);
108
/* Remove an MC from the list of MCs in the domain. */
109
int ipmi_remove_mc_from_domain(ipmi_domain_t *domain, ipmi_mc_t *mc);
111
/* The old interfaces (for backwards compatability). DON'T USE THESE!! */
112
struct ipmi_domain_mc_upd_s;
113
typedef struct ipmi_domain_mc_upd_s ipmi_domain_mc_upd_t
114
IPMI_TYPE_DEPRECATED;
115
int ipmi_domain_register_mc_update_handler(ipmi_domain_t *domain,
116
ipmi_domain_mc_upd_cb handler,
118
struct ipmi_domain_mc_upd_s **id)
119
IPMI_FUNC_DEPRECATED;
120
void ipmi_domain_remove_mc_update_handler(ipmi_domain_t *domain,
121
struct ipmi_domain_mc_upd_s *id)
122
IPMI_FUNC_DEPRECATED;
124
/* Call any OEM handlers for the given MC. */
125
int _ipmi_domain_check_oem_handlers(ipmi_domain_t *domain, ipmi_mc_t *mc);
127
/* Scan a system interface address for an MC. */
128
void ipmi_start_si_scan(ipmi_domain_t *domain,
130
ipmi_domain_cb done_handler,
133
/* Add an IPMB address to a list of addresses to not scan. This way,
134
if you have weak puny devices in IPMB that will break if you do
135
normal IPMB operations, you can have them be ignored. */
136
int ipmi_domain_add_ipmb_ignore(ipmi_domain_t *domain,
137
unsigned char ipmb_addr);
138
int ipmi_domain_add_ipmb_ignore_range(ipmi_domain_t *domain,
139
unsigned char first_ipmb_addr,
140
unsigned char last_ipmb_addr);
142
/* If OEM code gets and event and it doesn't deliver it to the user,
143
it should deliver it this way, that way it can be delivered to the
144
user to be deleted. */
145
void ipmi_handle_unhandled_event(ipmi_domain_t *domain, ipmi_event_t *event);
147
/* Handle a new event from something, usually from an SEL. */
148
void _ipmi_domain_system_event_handler(ipmi_domain_t *domain,
150
ipmi_event_t *event);
152
/* Returns the main SDR repository for the domain, or NULL if there is
154
ipmi_sdr_info_t *ipmi_domain_get_main_sdrs(ipmi_domain_t *domain);
156
/* Get the number of channels the domain supports. */
157
int ipmi_domain_get_num_channels(ipmi_domain_t *domain, int *val);
159
/* Get information about a channel by index. The index is not
160
necessarily the channel number, just an array index (up to the
161
number of channels). Get the channel number from the returned
163
int ipmi_domain_get_channel(ipmi_domain_t *domain,
165
ipmi_chan_info_t *chan);
167
/* These calls deal with OEM-type handlers for domains. Certain
168
domains can be detected with special means (beyond just the
169
manufacturer and product id) and this allows handlers for these
170
types of domains to be registered. At the very initial connection
171
of every domain, the handler will be called and it must detect
172
whether this is the specific type of domain or not, do any setup
173
for that domain type, and then call the done routine passed in.
174
Note that the done routine may be called later, (allowing this
175
handler to send messages and the like) but it *must* be called.
176
Note that the error value in the check_done routine should be
177
ENOSYS if the specific OEM handlers were not applicable, 0 if the
178
OEM handlers were installed, and anything else for specific
179
errors installing the OEM handlers. */
180
typedef void (*ipmi_domain_oem_check_done)(ipmi_domain_t *domain,
183
typedef int (*ipmi_domain_oem_check)(ipmi_domain_t *domain,
184
ipmi_domain_oem_check_done done,
186
int ipmi_register_domain_oem_check(ipmi_domain_oem_check check,
188
int ipmi_deregister_domain_oem_check(ipmi_domain_oem_check check,
191
/* Register OEM data for the domain. Note that you can set a function
192
that will be called after all the domain messages have been flushed
193
but before anything else is destroyed. If the OEM data or
194
destroyer is NULL, it will not be called. */
195
typedef void (*ipmi_domain_destroy_oem_data_cb)(ipmi_domain_t *domain,
197
void ipmi_domain_set_oem_data(ipmi_domain_t *domain,
199
ipmi_domain_destroy_oem_data_cb destroyer);
200
void *ipmi_domain_get_oem_data(ipmi_domain_t *domain);
202
/* Register a call that will be done at the beginning of the domain
203
shutdown process. Setting it to NULL will disable it. */
204
typedef void (*ipmi_domain_shutdown_cb)(ipmi_domain_t *domain);
205
void ipmi_domain_set_oem_shutdown_handler(ipmi_domain_t *domain,
206
ipmi_domain_shutdown_cb handler);
208
/* Set the domain type for a domain. */
209
void ipmi_domain_set_type(ipmi_domain_t *domain, enum ipmi_domain_type dtype);
211
/* OEM code can call then when it know that an MC scan is complete, to
213
void _ipmi_mc_scan_done(ipmi_domain_t *domain);
215
/* Can be used to generate unique numbers for a domain. */
216
unsigned int ipmi_domain_get_unique_num(ipmi_domain_t *domain);
218
/* Initialize the domain code, called only once at init time. */
219
int _ipmi_domain_init(void);
221
/* Clean up the global domain memory. */
222
void _ipmi_domain_shutdown(void);
225
/* Used as a refcount to know when the domain is completely
227
void _ipmi_get_domain_fully_up(ipmi_domain_t *domain);
228
void _ipmi_put_domain_fully_up(ipmi_domain_t *domain);
231
/* Option settings. */
232
int ipmi_option_SDRs(ipmi_domain_t *domain);
233
int ipmi_option_SEL(ipmi_domain_t *domain);
234
int ipmi_option_FRUs(ipmi_domain_t *domain);
235
int ipmi_option_IPMB_scan(ipmi_domain_t *domain);
236
int ipmi_option_OEM_init(ipmi_domain_t *domain);
237
int ipmi_option_set_event_rcvr(ipmi_domain_t *domain);
238
int ipmi_option_set_sel_time(ipmi_domain_t *domain);
239
int ipmi_option_activate_if_possible(ipmi_domain_t *domain);
242
* Domain attribute handling.
244
* An attribute is a string name that is registered with the domain along
245
* with a void data item. This allows things to be attached to the domain
246
* but not directly coupled to the domain. Names that begin with "ipmi_"
247
* belong to OpenIPMI, DON'T USE THEM. OEM names should start with
248
* "oem_<type>_". Other names are free for use by the application.
250
* Note that attributes are ummutable after creation and cannot be
251
* destroyed. Destruction only happens when the domain goes away, but
252
* may be delayed to after the domain is gone due to race conditions.
255
/* Attr init function. Return the data item in the data field. Returns
257
typedef int (*ipmi_domain_attr_init_cb)(ipmi_domain_t *domain, void *cb_data,
260
/* Called when the attribute is destroyed. Note that this may happen
261
after domain destruction, so the domain may not exist any more. */
262
typedef void (*ipmi_domain_attr_kill_cb)(void *cb_data, void *data);
264
typedef struct ipmi_domain_attr_s ipmi_domain_attr_t;
266
/* Find an attribute for a domain. If the attribute is not found,
267
register the attribute. If the registration occurs, the init()
268
function will be called (if non-null); it must return the data item
269
in the data field. When the domain is destroyed, the destroy
270
function will be called (if not null). */
271
int ipmi_domain_register_attribute(ipmi_domain_t *domain,
273
ipmi_domain_attr_init_cb init,
274
ipmi_domain_attr_kill_cb destroy,
276
ipmi_domain_attr_t **attr);
278
/* Find an attribute in an domain. Returns EINVAL if the name is not
279
registered. Returns 0 on success, and the data item is
281
int ipmi_domain_find_attribute(ipmi_domain_t *domain,
283
ipmi_domain_attr_t **attr);
285
/* Like the previous call, but takes a domain id. */
286
int ipmi_domain_id_find_attribute(ipmi_domain_id_t domain_id,
288
ipmi_domain_attr_t **data);
290
/* Get the data item from the attr. */
291
void *ipmi_domain_attr_get_data(ipmi_domain_attr_t *attr);
293
/* Call this when you are done with the attr. */
294
void ipmi_domain_attr_put(ipmi_domain_attr_t *attr);
296
/* Add/Remove a function, that is called when any new sensor is
297
added to the system and it allows OEM code to update information
298
about it if there are domain-specific sensor types that need
301
typedef void (*ipmi_domain_sensor_cb)(ipmi_domain_t *domain,
302
ipmi_sensor_t *sensor,
306
ipmi_domain_add_new_sensor_handler(ipmi_domain_t *domain,
307
ipmi_domain_sensor_cb handler,
311
ipmi_domain_remove_new_sensor_handler(ipmi_domain_t *domain,
312
ipmi_domain_sensor_cb handler,
316
_call_new_sensor_handlers(ipmi_domain_t *domain,
317
ipmi_sensor_t *sensor);
320
#endif /* _IPMI_DOMAIN_H */