logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

ipmi.h (15442B)


  1. /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
  2. /*
  3. * ipmi.h
  4. *
  5. * MontaVista IPMI interface
  6. *
  7. * Author: MontaVista Software, Inc.
  8. * Corey Minyard <minyard@mvista.com>
  9. * source@mvista.com
  10. *
  11. * Copyright 2002 MontaVista Software Inc.
  12. *
  13. */
  14. #ifndef __LINUX_IPMI_H
  15. #define __LINUX_IPMI_H
  16. #include <linux/ipmi_msgdefs.h>
  17. /*
  18. * This file describes an interface to an IPMI driver. You have to
  19. * have a fairly good understanding of IPMI to use this, so go read
  20. * the specs first before actually trying to do anything.
  21. *
  22. * With that said, this driver provides a multi-user interface to the
  23. * IPMI driver, and it allows multiple IPMI physical interfaces below
  24. * the driver. The physical interfaces bind as a lower layer on the
  25. * driver. They appear as interfaces to the application using this
  26. * interface.
  27. *
  28. * Multi-user means that multiple applications may use the driver,
  29. * send commands, receive responses, etc. The driver keeps track of
  30. * commands the user sends and tracks the responses. The responses
  31. * will go back to the application that send the command. If the
  32. * response doesn't come back in time, the driver will return a
  33. * timeout error response to the application. Asynchronous events
  34. * from the BMC event queue will go to all users bound to the driver.
  35. * The incoming event queue in the BMC will automatically be flushed
  36. * if it becomes full and it is queried once a second to see if
  37. * anything is in it. Incoming commands to the driver will get
  38. * delivered as commands.
  39. */
  40. /*
  41. * This is an overlay for all the address types, so it's easy to
  42. * determine the actual address type. This is kind of like addresses
  43. * work for sockets.
  44. */
  45. #define IPMI_MAX_ADDR_SIZE 32
  46. struct ipmi_addr {
  47. /* Try to take these from the "Channel Medium Type" table
  48. in section 6.5 of the IPMI 1.5 manual. */
  49. int addr_type;
  50. short channel;
  51. char data[IPMI_MAX_ADDR_SIZE];
  52. };
  53. /*
  54. * When the address is not used, the type will be set to this value.
  55. * The channel is the BMC's channel number for the channel (usually
  56. * 0), or IPMC_BMC_CHANNEL if communicating directly with the BMC.
  57. */
  58. #define IPMI_SYSTEM_INTERFACE_ADDR_TYPE 0x0c
  59. struct ipmi_system_interface_addr {
  60. int addr_type;
  61. short channel;
  62. unsigned char lun;
  63. };
  64. /* An IPMB Address. */
  65. #define IPMI_IPMB_ADDR_TYPE 0x01
  66. /* Used for broadcast get device id as described in section 17.9 of the
  67. IPMI 1.5 manual. */
  68. #define IPMI_IPMB_BROADCAST_ADDR_TYPE 0x41
  69. struct ipmi_ipmb_addr {
  70. int addr_type;
  71. short channel;
  72. unsigned char slave_addr;
  73. unsigned char lun;
  74. };
  75. /*
  76. * Used for messages received directly from an IPMB that have not gone
  77. * through a MC. This is for systems that sit right on an IPMB so
  78. * they can receive commands and respond to them.
  79. */
  80. #define IPMI_IPMB_DIRECT_ADDR_TYPE 0x81
  81. struct ipmi_ipmb_direct_addr {
  82. int addr_type;
  83. short channel;
  84. unsigned char slave_addr;
  85. unsigned char rs_lun;
  86. unsigned char rq_lun;
  87. };
  88. /*
  89. * A LAN Address. This is an address to/from a LAN interface bridged
  90. * by the BMC, not an address actually out on the LAN.
  91. *
  92. * A conscious decision was made here to deviate slightly from the IPMI
  93. * spec. We do not use rqSWID and rsSWID like it shows in the
  94. * message. Instead, we use remote_SWID and local_SWID. This means
  95. * that any message (a request or response) from another device will
  96. * always have exactly the same address. If you didn't do this,
  97. * requests and responses from the same device would have different
  98. * addresses, and that's not too cool.
  99. *
  100. * In this address, the remote_SWID is always the SWID the remote
  101. * message came from, or the SWID we are sending the message to.
  102. * local_SWID is always our SWID. Note that having our SWID in the
  103. * message is a little weird, but this is required.
  104. */
  105. #define IPMI_LAN_ADDR_TYPE 0x04
  106. struct ipmi_lan_addr {
  107. int addr_type;
  108. short channel;
  109. unsigned char privilege;
  110. unsigned char session_handle;
  111. unsigned char remote_SWID;
  112. unsigned char local_SWID;
  113. unsigned char lun;
  114. };
  115. /*
  116. * Channel for talking directly with the BMC. When using this
  117. * channel, This is for the system interface address type only. FIXME
  118. * - is this right, or should we use -1?
  119. */
  120. #define IPMI_BMC_CHANNEL 0xf
  121. #define IPMI_NUM_CHANNELS 0x10
  122. /*
  123. * Used to signify an "all channel" bitmask. This is more than the
  124. * actual number of channels because this is used in userland and
  125. * will cover us if the number of channels is extended.
  126. */
  127. #define IPMI_CHAN_ALL (~0)
  128. /*
  129. * A raw IPMI message without any addressing. This covers both
  130. * commands and responses. The completion code is always the first
  131. * byte of data in the response (as the spec shows the messages laid
  132. * out).
  133. */
  134. struct ipmi_msg {
  135. unsigned char netfn;
  136. unsigned char cmd;
  137. unsigned short data_len;
  138. unsigned char *data;
  139. };
  140. struct kernel_ipmi_msg {
  141. unsigned char netfn;
  142. unsigned char cmd;
  143. unsigned short data_len;
  144. unsigned char *data;
  145. };
  146. /*
  147. * Various defines that are useful for IPMI applications.
  148. */
  149. #define IPMI_INVALID_CMD_COMPLETION_CODE 0xC1
  150. #define IPMI_TIMEOUT_COMPLETION_CODE 0xC3
  151. #define IPMI_UNKNOWN_ERR_COMPLETION_CODE 0xff
  152. /*
  153. * Receive types for messages coming from the receive interface. This
  154. * is used for the receive in-kernel interface and in the receive
  155. * IOCTL.
  156. *
  157. * The "IPMI_RESPONSE_RESPONSE_TYPE" is a little strange sounding, but
  158. * it allows you to get the message results when you send a response
  159. * message.
  160. */
  161. #define IPMI_RESPONSE_RECV_TYPE 1 /* A response to a command */
  162. #define IPMI_ASYNC_EVENT_RECV_TYPE 2 /* Something from the event queue */
  163. #define IPMI_CMD_RECV_TYPE 3 /* A command from somewhere else */
  164. #define IPMI_RESPONSE_RESPONSE_TYPE 4 /* The response for
  165. a sent response, giving any
  166. error status for sending the
  167. response. When you send a
  168. response message, this will
  169. be returned. */
  170. #define IPMI_OEM_RECV_TYPE 5 /* The response for OEM Channels */
  171. /* Note that async events and received commands do not have a completion
  172. code as the first byte of the incoming data, unlike a response. */
  173. /*
  174. * Modes for ipmi_set_maint_mode() and the userland IOCTL. The AUTO
  175. * setting is the default and means it will be set on certain
  176. * commands. Hard setting it on and off will override automatic
  177. * operation.
  178. */
  179. #define IPMI_MAINTENANCE_MODE_AUTO 0
  180. #define IPMI_MAINTENANCE_MODE_OFF 1
  181. #define IPMI_MAINTENANCE_MODE_ON 2
  182. /*
  183. * The userland interface
  184. */
  185. /*
  186. * The userland interface for the IPMI driver is a standard character
  187. * device, with each instance of an interface registered as a minor
  188. * number under the major character device.
  189. *
  190. * The read and write calls do not work, to get messages in and out
  191. * requires ioctl calls because of the complexity of the data. select
  192. * and poll do work, so you can wait for input using the file
  193. * descriptor, you just can use read to get it.
  194. *
  195. * In general, you send a command down to the interface and receive
  196. * responses back. You can use the msgid value to correlate commands
  197. * and responses, the driver will take care of figuring out which
  198. * incoming messages are for which command and find the proper msgid
  199. * value to report. You will only receive reponses for commands you
  200. * send. Asynchronous events, however, go to all open users, so you
  201. * must be ready to handle these (or ignore them if you don't care).
  202. *
  203. * The address type depends upon the channel type. When talking
  204. * directly to the BMC (IPMC_BMC_CHANNEL), the address is ignored
  205. * (IPMI_UNUSED_ADDR_TYPE). When talking to an IPMB channel, you must
  206. * supply a valid IPMB address with the addr_type set properly.
  207. *
  208. * When talking to normal channels, the driver takes care of the
  209. * details of formatting and sending messages on that channel. You do
  210. * not, for instance, have to format a send command, you just send
  211. * whatever command you want to the channel, the driver will create
  212. * the send command, automatically issue receive command and get even
  213. * commands, and pass those up to the proper user.
  214. */
  215. /* The magic IOCTL value for this interface. */
  216. #define IPMI_IOC_MAGIC 'i'
  217. /* Messages sent to the interface are this format. */
  218. struct ipmi_req {
  219. unsigned char *addr; /* Address to send the message to. */
  220. unsigned int addr_len;
  221. long msgid; /* The sequence number for the message. This
  222. exact value will be reported back in the
  223. response to this request if it is a command.
  224. If it is a response, this will be used as
  225. the sequence value for the response. */
  226. struct ipmi_msg msg;
  227. };
  228. /*
  229. * Send a message to the interfaces. error values are:
  230. * - EFAULT - an address supplied was invalid.
  231. * - EINVAL - The address supplied was not valid, or the command
  232. * was not allowed.
  233. * - EMSGSIZE - The message to was too large.
  234. * - ENOMEM - Buffers could not be allocated for the command.
  235. */
  236. #define IPMICTL_SEND_COMMAND _IOR(IPMI_IOC_MAGIC, 13, \
  237. struct ipmi_req)
  238. /* Messages sent to the interface with timing parameters are this
  239. format. */
  240. struct ipmi_req_settime {
  241. struct ipmi_req req;
  242. /* See ipmi_request_settime() above for details on these
  243. values. */
  244. int retries;
  245. unsigned int retry_time_ms;
  246. };
  247. /*
  248. * Send a message to the interfaces with timing parameters. error values
  249. * are:
  250. * - EFAULT - an address supplied was invalid.
  251. * - EINVAL - The address supplied was not valid, or the command
  252. * was not allowed.
  253. * - EMSGSIZE - The message to was too large.
  254. * - ENOMEM - Buffers could not be allocated for the command.
  255. */
  256. #define IPMICTL_SEND_COMMAND_SETTIME _IOR(IPMI_IOC_MAGIC, 21, \
  257. struct ipmi_req_settime)
  258. /* Messages received from the interface are this format. */
  259. struct ipmi_recv {
  260. int recv_type; /* Is this a command, response or an
  261. asyncronous event. */
  262. unsigned char *addr; /* Address the message was from is put
  263. here. The caller must supply the
  264. memory. */
  265. unsigned int addr_len; /* The size of the address buffer.
  266. The caller supplies the full buffer
  267. length, this value is updated to
  268. the actual message length when the
  269. message is received. */
  270. long msgid; /* The sequence number specified in the request
  271. if this is a response. If this is a command,
  272. this will be the sequence number from the
  273. command. */
  274. struct ipmi_msg msg; /* The data field must point to a buffer.
  275. The data_size field must be set to the
  276. size of the message buffer. The
  277. caller supplies the full buffer
  278. length, this value is updated to the
  279. actual message length when the message
  280. is received. */
  281. };
  282. /*
  283. * Receive a message. error values:
  284. * - EAGAIN - no messages in the queue.
  285. * - EFAULT - an address supplied was invalid.
  286. * - EINVAL - The address supplied was not valid.
  287. * - EMSGSIZE - The message to was too large to fit into the message buffer,
  288. * the message will be left in the buffer. */
  289. #define IPMICTL_RECEIVE_MSG _IOWR(IPMI_IOC_MAGIC, 12, \
  290. struct ipmi_recv)
  291. /*
  292. * Like RECEIVE_MSG, but if the message won't fit in the buffer, it
  293. * will truncate the contents instead of leaving the data in the
  294. * buffer.
  295. */
  296. #define IPMICTL_RECEIVE_MSG_TRUNC _IOWR(IPMI_IOC_MAGIC, 11, \
  297. struct ipmi_recv)
  298. /* Register to get commands from other entities on this interface. */
  299. struct ipmi_cmdspec {
  300. unsigned char netfn;
  301. unsigned char cmd;
  302. };
  303. /*
  304. * Register to receive a specific command. error values:
  305. * - EFAULT - an address supplied was invalid.
  306. * - EBUSY - The netfn/cmd supplied was already in use.
  307. * - ENOMEM - could not allocate memory for the entry.
  308. */
  309. #define IPMICTL_REGISTER_FOR_CMD _IOR(IPMI_IOC_MAGIC, 14, \
  310. struct ipmi_cmdspec)
  311. /*
  312. * Unregister a registered command. error values:
  313. * - EFAULT - an address supplied was invalid.
  314. * - ENOENT - The netfn/cmd was not found registered for this user.
  315. */
  316. #define IPMICTL_UNREGISTER_FOR_CMD _IOR(IPMI_IOC_MAGIC, 15, \
  317. struct ipmi_cmdspec)
  318. /*
  319. * Register to get commands from other entities on specific channels.
  320. * This way, you can only listen on specific channels, or have messages
  321. * from some channels go to one place and other channels to someplace
  322. * else. The chans field is a bitmask, (1 << channel) for each channel.
  323. * It may be IPMI_CHAN_ALL for all channels.
  324. */
  325. struct ipmi_cmdspec_chans {
  326. unsigned int netfn;
  327. unsigned int cmd;
  328. unsigned int chans;
  329. };
  330. /*
  331. * Register to receive a specific command on specific channels. error values:
  332. * - EFAULT - an address supplied was invalid.
  333. * - EBUSY - One of the netfn/cmd/chans supplied was already in use.
  334. * - ENOMEM - could not allocate memory for the entry.
  335. */
  336. #define IPMICTL_REGISTER_FOR_CMD_CHANS _IOR(IPMI_IOC_MAGIC, 28, \
  337. struct ipmi_cmdspec_chans)
  338. /*
  339. * Unregister some netfn/cmd/chans. error values:
  340. * - EFAULT - an address supplied was invalid.
  341. * - ENOENT - None of the netfn/cmd/chans were found registered for this user.
  342. */
  343. #define IPMICTL_UNREGISTER_FOR_CMD_CHANS _IOR(IPMI_IOC_MAGIC, 29, \
  344. struct ipmi_cmdspec_chans)
  345. /*
  346. * Set whether this interface receives events. Note that the first
  347. * user registered for events will get all pending events for the
  348. * interface. error values:
  349. * - EFAULT - an address supplied was invalid.
  350. */
  351. #define IPMICTL_SET_GETS_EVENTS_CMD _IOR(IPMI_IOC_MAGIC, 16, int)
  352. /*
  353. * Set and get the slave address and LUN that we will use for our
  354. * source messages. Note that this affects the interface, not just
  355. * this user, so it will affect all users of this interface. This is
  356. * so some initialization code can come in and do the OEM-specific
  357. * things it takes to determine your address (if not the BMC) and set
  358. * it for everyone else. You should probably leave the LUN alone.
  359. */
  360. struct ipmi_channel_lun_address_set {
  361. unsigned short channel;
  362. unsigned char value;
  363. };
  364. #define IPMICTL_SET_MY_CHANNEL_ADDRESS_CMD \
  365. _IOR(IPMI_IOC_MAGIC, 24, struct ipmi_channel_lun_address_set)
  366. #define IPMICTL_GET_MY_CHANNEL_ADDRESS_CMD \
  367. _IOR(IPMI_IOC_MAGIC, 25, struct ipmi_channel_lun_address_set)
  368. #define IPMICTL_SET_MY_CHANNEL_LUN_CMD \
  369. _IOR(IPMI_IOC_MAGIC, 26, struct ipmi_channel_lun_address_set)
  370. #define IPMICTL_GET_MY_CHANNEL_LUN_CMD \
  371. _IOR(IPMI_IOC_MAGIC, 27, struct ipmi_channel_lun_address_set)
  372. /* Legacy interfaces, these only set IPMB 0. */
  373. #define IPMICTL_SET_MY_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 17, unsigned int)
  374. #define IPMICTL_GET_MY_ADDRESS_CMD _IOR(IPMI_IOC_MAGIC, 18, unsigned int)
  375. #define IPMICTL_SET_MY_LUN_CMD _IOR(IPMI_IOC_MAGIC, 19, unsigned int)
  376. #define IPMICTL_GET_MY_LUN_CMD _IOR(IPMI_IOC_MAGIC, 20, unsigned int)
  377. /*
  378. * Get/set the default timing values for an interface. You shouldn't
  379. * generally mess with these.
  380. */
  381. struct ipmi_timing_parms {
  382. int retries;
  383. unsigned int retry_time_ms;
  384. };
  385. #define IPMICTL_SET_TIMING_PARMS_CMD _IOR(IPMI_IOC_MAGIC, 22, \
  386. struct ipmi_timing_parms)
  387. #define IPMICTL_GET_TIMING_PARMS_CMD _IOR(IPMI_IOC_MAGIC, 23, \
  388. struct ipmi_timing_parms)
  389. /*
  390. * Set the maintenance mode. See ipmi_set_maintenance_mode() above
  391. * for a description of what this does.
  392. */
  393. #define IPMICTL_GET_MAINTENANCE_MODE_CMD _IOR(IPMI_IOC_MAGIC, 30, int)
  394. #define IPMICTL_SET_MAINTENANCE_MODE_CMD _IOW(IPMI_IOC_MAGIC, 31, int)
  395. #endif /* __LINUX_IPMI_H */