ipmi.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. /*
  2. * ipmi.h
  3. *
  4. * MontaVista IPMI 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. #ifndef __LINUX_IPMI_H
  34. #define __LINUX_IPMI_H
  35. #include <linux/ipmi_msgdefs.h>
  36. #include <linux/compiler.h>
  37. /*
  38. * This file describes an interface to an IPMI driver. You have to
  39. * have a fairly good understanding of IPMI to use this, so go read
  40. * the specs first before actually trying to do anything.
  41. *
  42. * With that said, this driver provides a multi-user interface to the
  43. * IPMI driver, and it allows multiple IPMI physical interfaces below
  44. * the driver. The physical interfaces bind as a lower layer on the
  45. * driver. They appear as interfaces to the application using this
  46. * interface.
  47. *
  48. * Multi-user means that multiple applications may use the driver,
  49. * send commands, receive responses, etc. The driver keeps track of
  50. * commands the user sends and tracks the responses. The responses
  51. * will go back to the application that send the command. If the
  52. * response doesn't come back in time, the driver will return a
  53. * timeout error response to the application. Asynchronous events
  54. * from the BMC event queue will go to all users bound to the driver.
  55. * The incoming event queue in the BMC will automatically be flushed
  56. * if it becomes full and it is queried once a second to see if
  57. * anything is in it. Incoming commands to the driver will get
  58. * delivered as commands.
  59. *
  60. * This driver provides two main interfaces: one for in-kernel
  61. * applications and another for userland applications. The
  62. * capabilities are basically the same for both interface, although
  63. * the interfaces are somewhat different. The stuff in the
  64. * #ifdef __KERNEL__ below is the in-kernel interface. The userland
  65. * interface is defined later in the file. */
  66. /*
  67. * This is an overlay for all the address types, so it's easy to
  68. * determine the actual address type. This is kind of like addresses
  69. * work for sockets.
  70. */
  71. #define IPMI_MAX_ADDR_SIZE 32
  72. struct ipmi_addr {
  73. /* Try to take these from the "Channel Medium Type" table
  74. in section 6.5 of the IPMI 1.5 manual. */
  75. int addr_type;
  76. short channel;
  77. char data[IPMI_MAX_ADDR_SIZE];
  78. };
  79. /*
  80. * When the address is not used, the type will be set to this value.
  81. * The channel is the BMC's channel number for the channel (usually
  82. * 0), or IPMC_BMC_CHANNEL if communicating directly with the BMC.
  83. */
  84. #define IPMI_SYSTEM_INTERFACE_ADDR_TYPE 0x0c
  85. struct ipmi_system_interface_addr {
  86. int addr_type;
  87. short channel;
  88. unsigned char lun;
  89. };
  90. /* An IPMB Address. */
  91. #define IPMI_IPMB_ADDR_TYPE 0x01
  92. /* Used for broadcast get device id as described in section 17.9 of the
  93. IPMI 1.5 manual. */
  94. #define IPMI_IPMB_BROADCAST_ADDR_TYPE 0x41
  95. struct ipmi_ipmb_addr {
  96. int addr_type;
  97. short channel;
  98. unsigned char slave_addr;
  99. unsigned char lun;
  100. };
  101. /*
  102. * A LAN Address. This is an address to/from a LAN interface bridged
  103. * by the BMC, not an address actually out on the LAN.
  104. *
  105. * A conscious decision was made here to deviate slightly from the IPMI
  106. * spec. We do not use rqSWID and rsSWID like it shows in the
  107. * message. Instead, we use remote_SWID and local_SWID. This means
  108. * that any message (a request or response) from another device will
  109. * always have exactly the same address. If you didn't do this,
  110. * requests and responses from the same device would have different
  111. * addresses, and that's not too cool.
  112. *
  113. * In this address, the remote_SWID is always the SWID the remote
  114. * message came from, or the SWID we are sending the message to.
  115. * local_SWID is always our SWID. Note that having our SWID in the
  116. * message is a little weird, but this is required.
  117. */
  118. #define IPMI_LAN_ADDR_TYPE 0x04
  119. struct ipmi_lan_addr {
  120. int addr_type;
  121. short channel;
  122. unsigned char privilege;
  123. unsigned char session_handle;
  124. unsigned char remote_SWID;
  125. unsigned char local_SWID;
  126. unsigned char lun;
  127. };
  128. /*
  129. * Channel for talking directly with the BMC. When using this
  130. * channel, This is for the system interface address type only. FIXME
  131. * - is this right, or should we use -1?
  132. */
  133. #define IPMI_BMC_CHANNEL 0xf
  134. #define IPMI_NUM_CHANNELS 0x10
  135. /*
  136. * Used to signify an "all channel" bitmask. This is more than the
  137. * actual number of channels because this is used in userland and
  138. * will cover us if the number of channels is extended.
  139. */
  140. #define IPMI_CHAN_ALL (~0)
  141. /*
  142. * A raw IPMI message without any addressing. This covers both
  143. * commands and responses. The completion code is always the first
  144. * byte of data in the response (as the spec shows the messages laid
  145. * out).
  146. */
  147. struct ipmi_msg {
  148. unsigned char netfn;
  149. unsigned char cmd;
  150. unsigned short data_len;
  151. unsigned char __user *data;
  152. };
  153. struct kernel_ipmi_msg {
  154. unsigned char netfn;
  155. unsigned char cmd;
  156. unsigned short data_len;
  157. unsigned char *data;
  158. };
  159. /*
  160. * Various defines that are useful for IPMI applications.
  161. */
  162. #define IPMI_INVALID_CMD_COMPLETION_CODE 0xC1
  163. #define IPMI_TIMEOUT_COMPLETION_CODE 0xC3
  164. #define IPMI_UNKNOWN_ERR_COMPLETION_CODE 0xff
  165. /*
  166. * Receive types for messages coming from the receive interface. This
  167. * is used for the receive in-kernel interface and in the receive
  168. * IOCTL.
  169. *
  170. * The "IPMI_RESPONSE_RESPNOSE_TYPE" is a little strange sounding, but
  171. * it allows you to get the message results when you send a response
  172. * message.
  173. */
  174. #define IPMI_RESPONSE_RECV_TYPE 1 /* A response to a command */
  175. #define IPMI_ASYNC_EVENT_RECV_TYPE 2 /* Something from the event queue */
  176. #define IPMI_CMD_RECV_TYPE 3 /* A command from somewhere else */
  177. #define IPMI_RESPONSE_RESPONSE_TYPE 4 /* The response for
  178. a sent response, giving any
  179. error status for sending the
  180. response. When you send a
  181. response message, this will
  182. be returned. */
  183. #define IPMI_OEM_RECV_TYPE 5 /* The response for OEM Channels */
  184. /* Note that async events and received commands do not have a completion
  185. code as the first byte of the incoming data, unlike a response. */
  186. /*
  187. * Modes for ipmi_set_maint_mode() and the userland IOCTL. The AUTO
  188. * setting is the default and means it will be set on certain
  189. * commands. Hard setting it on and off will override automatic
  190. * operation.
  191. */
  192. #define IPMI_MAINTENANCE_MODE_AUTO 0
  193. #define IPMI_MAINTENANCE_MODE_OFF 1
  194. #define IPMI_MAINTENANCE_MODE_ON 2
  195. #ifdef __KERNEL__
  196. /*
  197. * The in-kernel interface.
  198. */
  199. #include <linux/list.h>
  200. #include <linux/proc_fs.h>
  201. struct module;
  202. struct device;
  203. /* Opaque type for a IPMI message user. One of these is needed to
  204. send and receive messages. */
  205. typedef struct ipmi_user *ipmi_user_t;
  206. /*
  207. * Stuff coming from the receive interface comes as one of these.
  208. * They are allocated, the receiver must free them with
  209. * ipmi_free_recv_msg() when done with the message. The link is not
  210. * used after the message is delivered, so the upper layer may use the
  211. * link to build a linked list, if it likes.
  212. */
  213. struct ipmi_recv_msg {
  214. struct list_head link;
  215. /* The type of message as defined in the "Receive Types"
  216. defines above. */
  217. int recv_type;
  218. ipmi_user_t user;
  219. struct ipmi_addr addr;
  220. long msgid;
  221. struct kernel_ipmi_msg msg;
  222. /* The user_msg_data is the data supplied when a message was
  223. sent, if this is a response to a sent message. If this is
  224. not a response to a sent message, then user_msg_data will
  225. be NULL. If the user above is NULL, then this will be the
  226. intf. */
  227. void *user_msg_data;
  228. /* Call this when done with the message. It will presumably free
  229. the message and do any other necessary cleanup. */
  230. void (*done)(struct ipmi_recv_msg *msg);
  231. /* Place-holder for the data, don't make any assumptions about
  232. the size or existence of this, since it may change. */
  233. unsigned char msg_data[IPMI_MAX_MSG_LENGTH];
  234. };
  235. /* Allocate and free the receive message. */
  236. void ipmi_free_recv_msg(struct ipmi_recv_msg *msg);
  237. struct ipmi_user_hndl {
  238. /* Routine type to call when a message needs to be routed to
  239. the upper layer. This will be called with some locks held,
  240. the only IPMI routines that can be called are ipmi_request
  241. and the alloc/free operations. The handler_data is the
  242. variable supplied when the receive handler was registered. */
  243. void (*ipmi_recv_hndl)(struct ipmi_recv_msg *msg,
  244. void *user_msg_data);
  245. /* Called when the interface detects a watchdog pre-timeout. If
  246. this is NULL, it will be ignored for the user. */
  247. void (*ipmi_watchdog_pretimeout)(void *handler_data);
  248. };
  249. /* Create a new user of the IPMI layer on the given interface number. */
  250. int ipmi_create_user(unsigned int if_num,
  251. struct ipmi_user_hndl *handler,
  252. void *handler_data,
  253. ipmi_user_t *user);
  254. /* Destroy the given user of the IPMI layer. Note that after this
  255. function returns, the system is guaranteed to not call any
  256. callbacks for the user. Thus as long as you destroy all the users
  257. before you unload a module, you will be safe. And if you destroy
  258. the users before you destroy the callback structures, it should be
  259. safe, too. */
  260. int ipmi_destroy_user(ipmi_user_t user);
  261. /* Get the IPMI version of the BMC we are talking to. */
  262. void ipmi_get_version(ipmi_user_t user,
  263. unsigned char *major,
  264. unsigned char *minor);
  265. /* Set and get the slave address and LUN that we will use for our
  266. source messages. Note that this affects the interface, not just
  267. this user, so it will affect all users of this interface. This is
  268. so some initialization code can come in and do the OEM-specific
  269. things it takes to determine your address (if not the BMC) and set
  270. it for everyone else. Note that each channel can have its own address. */
  271. int ipmi_set_my_address(ipmi_user_t user,
  272. unsigned int channel,
  273. unsigned char address);
  274. int ipmi_get_my_address(ipmi_user_t user,
  275. unsigned int channel,
  276. unsigned char *address);
  277. int ipmi_set_my_LUN(ipmi_user_t user,
  278. unsigned int channel,
  279. unsigned char LUN);
  280. int ipmi_get_my_LUN(ipmi_user_t user,
  281. unsigned int channel,
  282. unsigned char *LUN);
  283. /*
  284. * Like ipmi_request, but lets you specify the number of retries and
  285. * the retry time. The retries is the number of times the message
  286. * will be resent if no reply is received. If set to -1, the default
  287. * value will be used. The retry time is the time in milliseconds
  288. * between retries. If set to zero, the default value will be
  289. * used.
  290. *
  291. * Don't use this unless you *really* have to. It's primarily for the
  292. * IPMI over LAN converter; since the LAN stuff does its own retries,
  293. * it makes no sense to do it here. However, this can be used if you
  294. * have unusual requirements.
  295. */
  296. int ipmi_request_settime(ipmi_user_t user,
  297. struct ipmi_addr *addr,
  298. long msgid,
  299. struct kernel_ipmi_msg *msg,
  300. void *user_msg_data,
  301. int priority,
  302. int max_retries,
  303. unsigned int retry_time_ms);
  304. /*
  305. * Like ipmi_request, but with messages supplied. This will not
  306. * allocate any memory, and the messages may be statically allocated
  307. * (just make sure to do the "done" handling on them). Note that this
  308. * is primarily for the watchdog timer, since it should be able to
  309. * send messages even if no memory is available. This is subject to
  310. * change as the system changes, so don't use it unless you REALLY
  311. * have to.
  312. */
  313. int ipmi_request_supply_msgs(ipmi_user_t user,
  314. struct ipmi_addr *addr,
  315. long msgid,
  316. struct kernel_ipmi_msg *msg,
  317. void *user_msg_data,
  318. void *supplied_smi,
  319. struct ipmi_recv_msg *supplied_recv,
  320. int priority);
  321. /*
  322. * Poll the IPMI interface for the user. This causes the IPMI code to
  323. * do an immediate check for information from the driver and handle
  324. * anything that is immediately pending. This will not block in any
  325. * way. This is useful if you need to spin waiting for something to
  326. * happen in the IPMI driver.
  327. */
  328. void ipmi_poll_interface(ipmi_user_t user);
  329. /*
  330. * When commands come in to the SMS, the user can register to receive
  331. * them. Only one user can be listening on a specific netfn/cmd/chan tuple
  332. * at a time, you will get an EBUSY error if the command is already
  333. * registered. If a command is received that does not have a user
  334. * registered, the driver will automatically return the proper
  335. * error. Channels are specified as a bitfield, use IPMI_CHAN_ALL to
  336. * mean all channels.
  337. */
  338. int ipmi_register_for_cmd(ipmi_user_t user,
  339. unsigned char netfn,
  340. unsigned char cmd,
  341. unsigned int chans);
  342. int ipmi_unregister_for_cmd(ipmi_user_t user,
  343. unsigned char netfn,
  344. unsigned char cmd,
  345. unsigned int chans);
  346. /*
  347. * Go into a mode where the driver will not autonomously attempt to do
  348. * things with the interface. It will still respond to attentions and
  349. * interrupts, and it will expect that commands will complete. It
  350. * will not automatcially check for flags, events, or things of that
  351. * nature.
  352. *
  353. * This is primarily used for firmware upgrades. The idea is that
  354. * when you go into firmware upgrade mode, you do this operation
  355. * and the driver will not attempt to do anything but what you tell
  356. * it or what the BMC asks for.
  357. *
  358. * Note that if you send a command that resets the BMC, the driver
  359. * will still expect a response from that command. So the BMC should
  360. * reset itself *after* the response is sent. Resetting before the
  361. * response is just silly.
  362. *
  363. * If in auto maintenance mode, the driver will automatically go into
  364. * maintenance mode for 30 seconds if it sees a cold reset, a warm
  365. * reset, or a firmware NetFN. This means that code that uses only
  366. * firmware NetFN commands to do upgrades will work automatically
  367. * without change, assuming it sends a message every 30 seconds or
  368. * less.
  369. *
  370. * See the IPMI_MAINTENANCE_MODE_xxx defines for what the mode means.
  371. */
  372. int ipmi_get_maintenance_mode(ipmi_user_t user);
  373. int ipmi_set_maintenance_mode(ipmi_user_t user, int mode);
  374. /*
  375. * When the user is created, it will not receive IPMI events by
  376. * default. The user must set this to TRUE to get incoming events.
  377. * The first user that sets this to TRUE will receive all events that
  378. * have been queued while no one was waiting for events.
  379. */
  380. int ipmi_set_gets_events(ipmi_user_t user, int val);
  381. /*
  382. * Called when a new SMI is registered. This will also be called on
  383. * every existing interface when a new watcher is registered with
  384. * ipmi_smi_watcher_register().
  385. */
  386. struct ipmi_smi_watcher {
  387. struct list_head link;
  388. /* You must set the owner to the current module, if you are in
  389. a module (generally just set it to "THIS_MODULE"). */
  390. struct module *owner;
  391. /* These two are called with read locks held for the interface
  392. the watcher list. So you can add and remove users from the
  393. IPMI interface, send messages, etc., but you cannot add
  394. or remove SMI watchers or SMI interfaces. */
  395. void (*new_smi)(int if_num, struct device *dev);
  396. void (*smi_gone)(int if_num);
  397. };
  398. int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher);
  399. int ipmi_smi_watcher_unregister(struct ipmi_smi_watcher *watcher);
  400. /* The following are various helper functions for dealing with IPMI
  401. addresses. */
  402. /* Return the maximum length of an IPMI address given it's type. */
  403. unsigned int ipmi_addr_length(int addr_type);
  404. /* Validate that the given IPMI address is valid. */
  405. int ipmi_validate_addr(struct ipmi_addr *addr, int len);
  406. /*
  407. * How did the IPMI driver find out about the device?
  408. */
  409. enum ipmi_addr_src {
  410. SI_INVALID = 0, SI_HOTMOD, SI_HARDCODED, SI_SPMI, SI_ACPI, SI_SMBIOS,
  411. SI_PCI, SI_DEVICETREE, SI_DEFAULT
  412. };
  413. union ipmi_smi_info_union {
  414. /*
  415. * the acpi_info element is defined for the SI_ACPI
  416. * address type
  417. */
  418. struct {
  419. void *acpi_handle;
  420. } acpi_info;
  421. };
  422. struct ipmi_smi_info {
  423. enum ipmi_addr_src addr_src;
  424. /*
  425. * Base device for the interface. Don't forget to put this when
  426. * you are done.
  427. */
  428. struct device *dev;
  429. /*
  430. * The addr_info provides more detailed info for some IPMI
  431. * devices, depending on the addr_src. Currently only SI_ACPI
  432. * info is provided.
  433. */
  434. union ipmi_smi_info_union addr_info;
  435. };
  436. /* This is to get the private info of ipmi_smi_t */
  437. extern int ipmi_get_smi_info(int if_num, struct ipmi_smi_info *data);
  438. #endif /* __KERNEL__ */
  439. /*
  440. * The userland interface
  441. */
  442. /*
  443. * The userland interface for the IPMI driver is a standard character
  444. * device, with each instance of an interface registered as a minor
  445. * number under the major character device.
  446. *
  447. * The read and write calls do not work, to get messages in and out
  448. * requires ioctl calls because of the complexity of the data. select
  449. * and poll do work, so you can wait for input using the file
  450. * descriptor, you just can use read to get it.
  451. *
  452. * In general, you send a command down to the interface and receive
  453. * responses back. You can use the msgid value to correlate commands
  454. * and responses, the driver will take care of figuring out which
  455. * incoming messages are for which command and find the proper msgid
  456. * value to report. You will only receive reponses for commands you
  457. * send. Asynchronous events, however, go to all open users, so you
  458. * must be ready to handle these (or ignore them if you don't care).
  459. *
  460. * The address type depends upon the channel type. When talking
  461. * directly to the BMC (IPMC_BMC_CHANNEL), the address is ignored
  462. * (IPMI_UNUSED_ADDR_TYPE). When talking to an IPMB channel, you must
  463. * supply a valid IPMB address with the addr_type set properly.
  464. *
  465. * When talking to normal channels, the driver takes care of the
  466. * details of formatting and sending messages on that channel. You do
  467. * not, for instance, have to format a send command, you just send
  468. * whatever command you want to the channel, the driver will create
  469. * the send command, automatically issue receive command and get even
  470. * commands, and pass those up to the proper user.
  471. */
  472. /* The magic IOCTL value for this interface. */
  473. #define IPMI_IOC_MAGIC 'i'
  474. /* Messages sent to the interface are this format. */
  475. struct ipmi_req {
  476. unsigned char __user *addr; /* Address to send the message to. */
  477. unsigned int addr_len;
  478. long msgid; /* The sequence number for the message. This
  479. exact value will be reported back in the
  480. response to this request if it is a command.
  481. If it is a response, this will be used as
  482. the sequence value for the response. */
  483. struct ipmi_msg msg;
  484. };
  485. /*
  486. * Send a message to the interfaces. error values are:
  487. * - EFAULT - an address supplied was invalid.
  488. * - EINVAL - The address supplied was not valid, or the command
  489. * was not allowed.
  490. * - EMSGSIZE - The message to was too large.
  491. * - ENOMEM - Buffers could not be allocated for the command.
  492. */
  493. #define IPMICTL_SEND_COMMAND _IOR(IPMI_IOC_MAGIC, 13, \
  494. struct ipmi_req)
  495. /* Messages sent to the interface with timing parameters are this
  496. format. */
  497. struct ipmi_req_settime {
  498. struct ipmi_req req;
  499. /* See ipmi_request_settime() above for details on these
  500. values. */
  501. int retries;
  502. unsigned int retry_time_ms;
  503. };
  504. /*
  505. * Send a message to the interfaces with timing parameters. error values
  506. * are:
  507. * - EFAULT - an address supplied was invalid.
  508. * - EINVAL - The address supplied was not valid, or the command
  509. * was not allowed.
  510. * - EMSGSIZE - The message to was too large.
  511. * - ENOMEM - Buffers could not be allocated for the command.
  512. */
  513. #define IPMICTL_SEND_COMMAND_SETTIME _IOR(IPMI_IOC_MAGIC, 21, \
  514. struct ipmi_req_settime)
  515. /* Messages received from the interface are this format. */
  516. struct ipmi_recv {
  517. int recv_type; /* Is this a command, response or an
  518. asyncronous event. */
  519. unsigned char __user *addr; /* Address the message was from is put
  520. here. The caller must supply the
  521. memory. */
  522. unsigned int addr_len; /* The size of the address buffer.
  523. The caller supplies the full buffer
  524. length, this value is updated to
  525. the actual message length when the
  526. message is received. */
  527. long msgid; /* The sequence number specified in the request
  528. if this is a response. If this is a command,
  529. this will be the sequence number from the
  530. command. */
  531. struct ipmi_msg msg; /* The data field must point to a buffer.
  532. The data_size field must be set to the
  533. size of the message buffer. The
  534. caller supplies the full buffer
  535. length, this value is updated to the
  536. actual message length when the message
  537. is received. */
  538. };
  539. /*
  540. * Receive a message. error values:
  541. * - EAGAIN - no messages in the queue.
  542. * - EFAULT - an address supplied was invalid.
  543. * - EINVAL - The address supplied was not valid.
  544. * - EMSGSIZE - The message to was too large to fit into the message buffer,
  545. * the message will be left in the buffer. */
  546. #define IPMICTL_RECEIVE_MSG _IOWR(IPMI_IOC_MAGIC, 12, \
  547. struct ipmi_recv)
  548. /*
  549. * Like RECEIVE_MSG, but if the message won't fit in the buffer, it
  550. * will truncate the contents instead of leaving the data in the
  551. * buffer.
  552. */
  553. #define IPMICTL_RECEIVE_MSG_TRUNC _IOWR(IPMI_IOC_MAGIC, 11, \
  554. struct ipmi_recv)
  555. /* Register to get commands from other entities on this interface. */
  556. struct ipmi_cmdspec {
  557. unsigned char netfn;
  558. unsigned char cmd;
  559. };
  560. /*
  561. * Register to receive a specific command. error values:
  562. * - EFAULT - an address supplied was invalid.
  563. * - EBUSY - The netfn/cmd supplied was already in use.
  564. * - ENOMEM - could not allocate memory for the entry.
  565. */
  566. #define IPMICTL_REGISTER_FOR_CMD _IOR(IPMI_IOC_MAGIC, 14, \
  567. struct ipmi_cmdspec)
  568. /*
  569. * Unregister a regsitered command. error values:
  570. * - EFAULT - an address supplied was invalid.
  571. * - ENOENT - The netfn/cmd was not found registered for this user.
  572. */
  573. #define IPMICTL_UNREGISTER_FOR_CMD _IOR(IPMI_IOC_MAGIC, 15, \
  574. struct ipmi_cmdspec)
  575. /*
  576. * Register to get commands from other entities on specific channels.
  577. * This way, you can only listen on specific channels, or have messages
  578. * from some channels go to one place and other channels to someplace
  579. * else. The chans field is a bitmask, (1 << channel) for each channel.
  580. * It may be IPMI_CHAN_ALL for all channels.
  581. */
  582. struct ipmi_cmdspec_chans {
  583. unsigned int netfn;
  584. unsigned int cmd;
  585. unsigned int chans;
  586. };
  587. /*
  588. * Register to receive a specific command on specific channels. error values:
  589. * - EFAULT - an address supplied was invalid.
  590. * - EBUSY - One of the netfn/cmd/chans supplied was already in use.
  591. * - ENOMEM - could not allocate memory for the entry.
  592. */
  593. #define IPMICTL_REGISTER_FOR_CMD_CHANS _IOR(IPMI_IOC_MAGIC, 28, \
  594. struct ipmi_cmdspec_chans)
  595. /*
  596. * Unregister some netfn/cmd/chans. error values:
  597. * - EFAULT - an address supplied was invalid.
  598. * - ENOENT - None of the netfn/cmd/chans were found registered for this user.
  599. */
  600. #define IPMICTL_UNREGISTER_FOR_CMD_CHANS _IOR(IPMI_IOC_MAGIC, 29, \
  601. struct ipmi_cmdspec_chans)
  602. /*
  603. * Set whether this interface receives events. Note that the first
  604. * user registered for events will get all pending events for the
  605. * interface. error values:
  606. * - EFAULT - an address supplied was invalid.
  607. */
  608. #define IPMICTL_SET_GETS_EVENTS_CMD _IOR(IPMI_IOC_MAGIC, 16, int)
  609. /*
  610. * Set and get the slave address and LUN that we will use for our
  611. * source messages. Note that this affects the interface, not just
  612. * this user, so it will affect all users of this interface. This is
  613. * so some initialization code can come in and do the OEM-specific
  614. * things it takes to determine your address (if not the BMC) and set
  615. * it for everyone else. You should probably leave the LUN alone.
  616. */
  617. struct ipmi_channel_lun_address_set {
  618. unsigned short channel;
  619. unsigned char value;
  620. };
  621. #define IPMICTL_SET_MY_CHANNEL_ADDRESS_CMD \
  622. _IOR(IPMI_IOC_MAGIC, 24, struct ipmi_channel_lun_address_set)
  623. #define IPMICTL_GET_MY_CHANNEL_ADDRESS_CMD \
  624. _IOR(IPMI_IOC_MAGIC, 25, struct ipmi_channel_lun_address_set)
  625. #define IPMICTL_SET_MY_CHANNEL_LUN_CMD \
  626. _IOR(IPMI_IOC_MAGIC, 26, struct ipmi_channel_lun_address_set)
  627. #define IPMICTL_GET_MY_CHANNEL_LUN_CMD \
  628. _IOR(IPMI_IOC_MAGIC, 27, struct ipmi_channel_lun_address_set)
  629. /* Legacy interfaces, these only set IPMB 0. */
  630. #define IPMICTL_SET_MY_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 17, unsigned int)
  631. #define IPMICTL_GET_MY_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 18, unsigned int)
  632. #define IPMICTL_SET_MY_LUN_CMD _IOR(IPMI_IOC_MAGIC, 19, unsigned int)
  633. #define IPMICTL_GET_MY_LUN_CMD _IOR(IPMI_IOC_MAGIC, 20, unsigned int)
  634. /*
  635. * Get/set the default timing values for an interface. You shouldn't
  636. * generally mess with these.
  637. */
  638. struct ipmi_timing_parms {
  639. int retries;
  640. unsigned int retry_time_ms;
  641. };
  642. #define IPMICTL_SET_TIMING_PARMS_CMD _IOR(IPMI_IOC_MAGIC, 22, \
  643. struct ipmi_timing_parms)
  644. #define IPMICTL_GET_TIMING_PARMS_CMD _IOR(IPMI_IOC_MAGIC, 23, \
  645. struct ipmi_timing_parms)
  646. /*
  647. * Set the maintenance mode. See ipmi_set_maintenance_mode() above
  648. * for a description of what this does.
  649. */
  650. #define IPMICTL_GET_MAINTENANCE_MODE_CMD _IOR(IPMI_IOC_MAGIC, 30, int)
  651. #define IPMICTL_SET_MAINTENANCE_MODE_CMD _IOW(IPMI_IOC_MAGIC, 31, int)
  652. #endif /* __LINUX_IPMI_H */