📄 ipmi.h
字号:
struct ipmi_addr *addr, long msgid, struct kernel_ipmi_msg *msg, void *user_msg_data, void *supplied_smi, struct ipmi_recv_msg *supplied_recv, int priority);/* * Poll the IPMI interface for the user. This causes the IPMI code to * do an immediate check for information from the driver and handle * anything that is immediately pending. This will not block in any * way. This is useful if you need to implement polling from the user * for things like modifying the watchdog timeout when a panic occurs * or disabling the watchdog timer on a reboot. */void ipmi_poll_interface(ipmi_user_t user);/* * When commands come in to the SMS, the user can register to receive * them. Only one user can be listening on a specific netfn/cmd/chan tuple * at a time, you will get an EBUSY error if the command is already * registered. If a command is received that does not have a user * registered, the driver will automatically return the proper * error. Channels are specified as a bitfield, use IPMI_CHAN_ALL to * mean all channels. */int ipmi_register_for_cmd(ipmi_user_t user, unsigned char netfn, unsigned char cmd, unsigned int chans);int ipmi_unregister_for_cmd(ipmi_user_t user, unsigned char netfn, unsigned char cmd, unsigned int chans);/* * Go into a mode where the driver will not autonomously attempt to do * things with the interface. It will still respond to attentions and * interrupts, and it will expect that commands will complete. It * will not automatcially check for flags, events, or things of that * nature. * * This is primarily used for firmware upgrades. The idea is that * when you go into firmware upgrade mode, you do this operation * and the driver will not attempt to do anything but what you tell * it or what the BMC asks for. * * Note that if you send a command that resets the BMC, the driver * will still expect a response from that command. So the BMC should * reset itself *after* the response is sent. Resetting before the * response is just silly. * * If in auto maintenance mode, the driver will automatically go into * maintenance mode for 30 seconds if it sees a cold reset, a warm * reset, or a firmware NetFN. This means that code that uses only * firmware NetFN commands to do upgrades will work automatically * without change, assuming it sends a message every 30 seconds or * less. * * See the IPMI_MAINTENANCE_MODE_xxx defines for what the mode means. */int ipmi_get_maintenance_mode(ipmi_user_t user);int ipmi_set_maintenance_mode(ipmi_user_t user, int mode);/* * Allow run-to-completion mode to be set for the interface of * a specific user. */void ipmi_user_set_run_to_completion(ipmi_user_t user, int val);/* * When the user is created, it will not receive IPMI events by * default. The user must set this to TRUE to get incoming events. * The first user that sets this to TRUE will receive all events that * have been queued while no one was waiting for events. */int ipmi_set_gets_events(ipmi_user_t user, int val);/* * Called when a new SMI is registered. This will also be called on * every existing interface when a new watcher is registered with * ipmi_smi_watcher_register(). */struct ipmi_smi_watcher{ struct list_head link; /* You must set the owner to the current module, if you are in a module (generally just set it to "THIS_MODULE"). */ struct module *owner; /* These two are called with read locks held for the interface the watcher list. So you can add and remove users from the IPMI interface, send messages, etc., but you cannot add or remove SMI watchers or SMI interfaces. */ void (*new_smi)(int if_num, struct device *dev); void (*smi_gone)(int if_num);};int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher);int ipmi_smi_watcher_unregister(struct ipmi_smi_watcher *watcher);/* The following are various helper functions for dealing with IPMI addresses. *//* Return the maximum length of an IPMI address given it's type. */unsigned int ipmi_addr_length(int addr_type);/* Validate that the given IPMI address is valid. */int ipmi_validate_addr(struct ipmi_addr *addr, int len);#endif /* __KERNEL__ *//* * The userland interface *//* * The userland interface for the IPMI driver is a standard character * device, with each instance of an interface registered as a minor * number under the major character device. * * The read and write calls do not work, to get messages in and out * requires ioctl calls because of the complexity of the data. select * and poll do work, so you can wait for input using the file * descriptor, you just can use read to get it. * * In general, you send a command down to the interface and receive * responses back. You can use the msgid value to correlate commands * and responses, the driver will take care of figuring out which * incoming messages are for which command and find the proper msgid * value to report. You will only receive reponses for commands you * send. Asynchronous events, however, go to all open users, so you * must be ready to handle these (or ignore them if you don't care). * * The address type depends upon the channel type. When talking * directly to the BMC (IPMC_BMC_CHANNEL), the address is ignored * (IPMI_UNUSED_ADDR_TYPE). When talking to an IPMB channel, you must * supply a valid IPMB address with the addr_type set properly. * * When talking to normal channels, the driver takes care of the * details of formatting and sending messages on that channel. You do * not, for instance, have to format a send command, you just send * whatever command you want to the channel, the driver will create * the send command, automatically issue receive command and get even * commands, and pass those up to the proper user. *//* The magic IOCTL value for this interface. */#define IPMI_IOC_MAGIC 'i'/* Messages sent to the interface are this format. */struct ipmi_req{ unsigned char __user *addr; /* Address to send the message to. */ unsigned int addr_len; long msgid; /* The sequence number for the message. This exact value will be reported back in the response to this request if it is a command. If it is a response, this will be used as the sequence value for the response. */ struct ipmi_msg msg;};/* * Send a message to the interfaces. error values are: * - EFAULT - an address supplied was invalid. * - EINVAL - The address supplied was not valid, or the command * was not allowed. * - EMSGSIZE - The message to was too large. * - ENOMEM - Buffers could not be allocated for the command. */#define IPMICTL_SEND_COMMAND _IOR(IPMI_IOC_MAGIC, 13, \ struct ipmi_req)/* Messages sent to the interface with timing parameters are this format. */struct ipmi_req_settime{ struct ipmi_req req; /* See ipmi_request_settime() above for details on these values. */ int retries; unsigned int retry_time_ms;};/* * Send a message to the interfaces with timing parameters. error values * are: * - EFAULT - an address supplied was invalid. * - EINVAL - The address supplied was not valid, or the command * was not allowed. * - EMSGSIZE - The message to was too large. * - ENOMEM - Buffers could not be allocated for the command. */#define IPMICTL_SEND_COMMAND_SETTIME _IOR(IPMI_IOC_MAGIC, 21, \ struct ipmi_req_settime)/* Messages received from the interface are this format. */struct ipmi_recv{ int recv_type; /* Is this a command, response or an asyncronous event. */ unsigned char __user *addr; /* Address the message was from is put here. The caller must supply the memory. */ unsigned int addr_len; /* The size of the address buffer. The caller supplies the full buffer length, this value is updated to the actual message length when the message is received. */ long msgid; /* The sequence number specified in the request if this is a response. If this is a command, this will be the sequence number from the command. */ struct ipmi_msg msg; /* The data field must point to a buffer. The data_size field must be set to the size of the message buffer. The caller supplies the full buffer length, this value is updated to the actual message length when the message is received. */};/* * Receive a message. error values: * - EAGAIN - no messages in the queue. * - EFAULT - an address supplied was invalid. * - EINVAL - The address supplied was not valid. * - EMSGSIZE - The message to was too large to fit into the message buffer, * the message will be left in the buffer. */#define IPMICTL_RECEIVE_MSG _IOWR(IPMI_IOC_MAGIC, 12, \ struct ipmi_recv)/* * Like RECEIVE_MSG, but if the message won't fit in the buffer, it * will truncate the contents instead of leaving the data in the * buffer. */#define IPMICTL_RECEIVE_MSG_TRUNC _IOWR(IPMI_IOC_MAGIC, 11, \ struct ipmi_recv)/* Register to get commands from other entities on this interface. */struct ipmi_cmdspec{ unsigned char netfn; unsigned char cmd;};/* * Register to receive a specific command. error values: * - EFAULT - an address supplied was invalid. * - EBUSY - The netfn/cmd supplied was already in use. * - ENOMEM - could not allocate memory for the entry. */#define IPMICTL_REGISTER_FOR_CMD _IOR(IPMI_IOC_MAGIC, 14, \ struct ipmi_cmdspec)/* * Unregister a regsitered command. error values: * - EFAULT - an address supplied was invalid. * - ENOENT - The netfn/cmd was not found registered for this user. */#define IPMICTL_UNREGISTER_FOR_CMD _IOR(IPMI_IOC_MAGIC, 15, \ struct ipmi_cmdspec)/* * Register to get commands from other entities on specific channels. * This way, you can only listen on specific channels, or have messages * from some channels go to one place and other channels to someplace * else. The chans field is a bitmask, (1 << channel) for each channel. * It may be IPMI_CHAN_ALL for all channels. */struct ipmi_cmdspec_chans{ unsigned int netfn; unsigned int cmd; unsigned int chans;};/* * Register to receive a specific command on specific channels. error values: * - EFAULT - an address supplied was invalid. * - EBUSY - One of the netfn/cmd/chans supplied was already in use. * - ENOMEM - could not allocate memory for the entry. */#define IPMICTL_REGISTER_FOR_CMD_CHANS _IOR(IPMI_IOC_MAGIC, 28, \ struct ipmi_cmdspec_chans)/* * Unregister some netfn/cmd/chans. error values: * - EFAULT - an address supplied was invalid. * - ENOENT - None of the netfn/cmd/chans were found registered for this user. */#define IPMICTL_UNREGISTER_FOR_CMD_CHANS _IOR(IPMI_IOC_MAGIC, 29, \ struct ipmi_cmdspec_chans)/* * Set whether this interface receives events. Note that the first * user registered for events will get all pending events for the * interface. error values: * - EFAULT - an address supplied was invalid. */#define IPMICTL_SET_GETS_EVENTS_CMD _IOR(IPMI_IOC_MAGIC, 16, int)/* * Set and get the slave address and LUN that we will use for our * source messages. Note that this affects the interface, not just * this user, so it will affect all users of this interface. This is * so some initialization code can come in and do the OEM-specific * things it takes to determine your address (if not the BMC) and set * it for everyone else. You should probably leave the LUN alone. */struct ipmi_channel_lun_address_set{ unsigned short channel; unsigned char value;};#define IPMICTL_SET_MY_CHANNEL_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 24, struct ipmi_channel_lun_address_set)#define IPMICTL_GET_MY_CHANNEL_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 25, struct ipmi_channel_lun_address_set)#define IPMICTL_SET_MY_CHANNEL_LUN_CMD _IOR(IPMI_IOC_MAGIC, 26, struct ipmi_channel_lun_address_set)#define IPMICTL_GET_MY_CHANNEL_LUN_CMD _IOR(IPMI_IOC_MAGIC, 27, struct ipmi_channel_lun_address_set)/* Legacy interfaces, these only set IPMB 0. */#define IPMICTL_SET_MY_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 17, unsigned int)#define IPMICTL_GET_MY_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 18, unsigned int)#define IPMICTL_SET_MY_LUN_CMD _IOR(IPMI_IOC_MAGIC, 19, unsigned int)#define IPMICTL_GET_MY_LUN_CMD _IOR(IPMI_IOC_MAGIC, 20, unsigned int)/* * Get/set the default timing values for an interface. You shouldn't * generally mess with these. */struct ipmi_timing_parms{ int retries; unsigned int retry_time_ms;};#define IPMICTL_SET_TIMING_PARMS_CMD _IOR(IPMI_IOC_MAGIC, 22, \ struct ipmi_timing_parms)#define IPMICTL_GET_TIMING_PARMS_CMD _IOR(IPMI_IOC_MAGIC, 23, \ struct ipmi_timing_parms)/* * Set the maintenance mode. See ipmi_set_maintenance_mode() above * for a description of what this does. */#define IPMICTL_GET_MAINTENANCE_MODE_CMD _IOR(IPMI_IOC_MAGIC, 30, int)#define IPMICTL_SET_MAINTENANCE_MODE_CMD _IOW(IPMI_IOC_MAGIC, 31, int)#endif /* __LINUX_IPMI_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -