1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linu 1 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 15 #ifndef _UAPI__LINUX_IPMI_H 16 #define _UAPI__LINUX_IPMI_H 17 18 #include <linux/ipmi_msgdefs.h> 19 #include <linux/compiler.h> 20 21 /* 22 * This file describes an interface to an IPMI 23 * have a fairly good understanding of IPMI to 24 * the specs first before actually trying to d 25 * 26 * With that said, this driver provides a mult 27 * IPMI driver, and it allows multiple IPMI ph 28 * the driver. The physical interfaces bind a 29 * driver. They appear as interfaces to the a 30 * interface. 31 * 32 * Multi-user means that multiple applications 33 * send commands, receive responses, etc. The 34 * commands the user sends and tracks the resp 35 * will go back to the application that send t 36 * response doesn't come back in time, the dri 37 * timeout error response to the application. 38 * from the BMC event queue will go to all use 39 * The incoming event queue in the BMC will au 40 * if it becomes full and it is queried once a 41 * anything is in it. Incoming commands to th 42 * delivered as commands. 43 */ 44 45 /* 46 * This is an overlay for all the address type 47 * determine the actual address type. This is 48 * work for sockets. 49 */ 50 #define IPMI_MAX_ADDR_SIZE 32 51 struct ipmi_addr { 52 /* Try to take these from the "Channe 53 in section 6.5 of the IPMI 1.5 man 54 int addr_type; 55 short channel; 56 char data[IPMI_MAX_ADDR_SIZE]; 57 }; 58 59 /* 60 * When the address is not used, the type will 61 * The channel is the BMC's channel number for 62 * 0), or IPMC_BMC_CHANNEL if communicating di 63 */ 64 #define IPMI_SYSTEM_INTERFACE_ADDR_TYPE 0x0c 65 struct ipmi_system_interface_addr { 66 int addr_type; 67 short channel; 68 unsigned char lun; 69 }; 70 71 /* An IPMB Address. */ 72 #define IPMI_IPMB_ADDR_TYPE 0x01 73 /* Used for broadcast get device id as describ 74 IPMI 1.5 manual. */ 75 #define IPMI_IPMB_BROADCAST_ADDR_TYPE 0x41 76 struct ipmi_ipmb_addr { 77 int addr_type; 78 short channel; 79 unsigned char slave_addr; 80 unsigned char lun; 81 }; 82 83 /* 84 * Used for messages received directly from an 85 * through a MC. This is for systems that sit 86 * they can receive commands and respond to th 87 */ 88 #define IPMI_IPMB_DIRECT_ADDR_TYPE 0x81 89 struct ipmi_ipmb_direct_addr { 90 int addr_type; 91 short channel; 92 unsigned char slave_addr; 93 unsigned char rs_lun; 94 unsigned char rq_lun; 95 }; 96 97 /* 98 * A LAN Address. This is an address to/from 99 * by the BMC, not an address actually out on 100 * 101 * A conscious decision was made here to devia 102 * spec. We do not use rqSWID and rsSWID like 103 * message. Instead, we use remote_SWID and l 104 * that any message (a request or response) fr 105 * always have exactly the same address. If y 106 * requests and responses from the same device 107 * addresses, and that's not too cool. 108 * 109 * In this address, the remote_SWID is always 110 * message came from, or the SWID we are sendi 111 * local_SWID is always our SWID. Note that h 112 * message is a little weird, but this is requ 113 */ 114 #define IPMI_LAN_ADDR_TYPE 0x04 115 struct ipmi_lan_addr { 116 int addr_type; 117 short channel; 118 unsigned char privilege; 119 unsigned char session_handle; 120 unsigned char remote_SWID; 121 unsigned char local_SWID; 122 unsigned char lun; 123 }; 124 125 126 /* 127 * Channel for talking directly with the BMC. 128 * channel, This is for the system interface a 129 * - is this right, or should we use -1? 130 */ 131 #define IPMI_BMC_CHANNEL 0xf 132 #define IPMI_NUM_CHANNELS 0x10 133 134 /* 135 * Used to signify an "all channel" bitmask. 136 * actual number of channels because this is u 137 * will cover us if the number of channels is 138 */ 139 #define IPMI_CHAN_ALL (~0) 140 141 142 /* 143 * A raw IPMI message without any addressing. 144 * commands and responses. The completion cod 145 * byte of data in the response (as the spec s 146 * out). 147 */ 148 struct ipmi_msg { 149 unsigned char netfn; 150 unsigned char cmd; 151 unsigned short data_len; 152 unsigned char __user *data; 153 }; 154 155 struct kernel_ipmi_msg { 156 unsigned char netfn; 157 unsigned char cmd; 158 unsigned short data_len; 159 unsigned char *data; 160 }; 161 162 /* 163 * Various defines that are useful for IPMI ap 164 */ 165 #define IPMI_INVALID_CMD_COMPLETION_CODE 166 #define IPMI_TIMEOUT_COMPLETION_CODE 167 #define IPMI_UNKNOWN_ERR_COMPLETION_CODE 168 169 170 /* 171 * Receive types for messages coming from the 172 * is used for the receive in-kernel interface 173 * IOCTL. 174 * 175 * The "IPMI_RESPONSE_RESPONSE_TYPE" is a litt 176 * it allows you to get the message results wh 177 * message. 178 */ 179 #define IPMI_RESPONSE_RECV_TYPE 1 /* A 180 #define IPMI_ASYNC_EVENT_RECV_TYPE 2 /* S 181 #define IPMI_CMD_RECV_TYPE 3 /* A 182 #define IPMI_RESPONSE_RESPONSE_TYPE 4 /* T 183 184 185 186 187 188 #define IPMI_OEM_RECV_TYPE 5 /* T 189 190 /* Note that async events and received command 191 code as the first byte of the incoming data 192 193 194 /* 195 * Modes for ipmi_set_maint_mode() and the use 196 * setting is the default and means it will be 197 * commands. Hard setting it on and off will 198 * operation. 199 */ 200 #define IPMI_MAINTENANCE_MODE_AUTO 0 201 #define IPMI_MAINTENANCE_MODE_OFF 1 202 #define IPMI_MAINTENANCE_MODE_ON 2 203 204 205 206 /* 207 * The userland interface 208 */ 209 210 /* 211 * The userland interface for the IPMI driver 212 * device, with each instance of an interface 213 * number under the major character device. 214 * 215 * The read and write calls do not work, to ge 216 * requires ioctl calls because of the complex 217 * and poll do work, so you can wait for input 218 * descriptor, you just can use read to get it 219 * 220 * In general, you send a command down to the 221 * responses back. You can use the msgid valu 222 * and responses, the driver will take care of 223 * incoming messages are for which command and 224 * value to report. You will only receive rep 225 * send. Asynchronous events, however, go to 226 * must be ready to handle these (or ignore th 227 * 228 * The address type depends upon the channel t 229 * directly to the BMC (IPMC_BMC_CHANNEL), the 230 * (IPMI_UNUSED_ADDR_TYPE). When talking to a 231 * supply a valid IPMB address with the addr_t 232 * 233 * When talking to normal channels, the driver 234 * details of formatting and sending messages 235 * not, for instance, have to format a send co 236 * whatever command you want to the channel, t 237 * the send command, automatically issue recei 238 * commands, and pass those up to the proper u 239 */ 240 241 242 /* The magic IOCTL value for this interface. * 243 #define IPMI_IOC_MAGIC 'i' 244 245 246 /* Messages sent to the interface are this for 247 struct ipmi_req { 248 unsigned char __user *addr; /* Address 249 unsigned int addr_len; 250 251 long msgid; /* The sequence number 252 exact value will be 253 response to this req 254 If it is a response, 255 the sequence value f 256 257 struct ipmi_msg msg; 258 }; 259 /* 260 * Send a message to the interfaces. error va 261 * - EFAULT - an address supplied was invali 262 * - EINVAL - The address supplied was not v 263 * was not allowed. 264 * - EMSGSIZE - The message to was too large 265 * - ENOMEM - Buffers could not be allocated 266 */ 267 #define IPMICTL_SEND_COMMAND _IOR(I 268 s 269 270 /* Messages sent to the interface with timing 271 format. */ 272 struct ipmi_req_settime { 273 struct ipmi_req req; 274 275 /* See ipmi_request_settime() above fo 276 values. */ 277 int retries; 278 unsigned int retry_time_ms; 279 }; 280 /* 281 * Send a message to the interfaces with timin 282 * are: 283 * - EFAULT - an address supplied was invali 284 * - EINVAL - The address supplied was not v 285 * was not allowed. 286 * - EMSGSIZE - The message to was too large 287 * - ENOMEM - Buffers could not be allocated 288 */ 289 #define IPMICTL_SEND_COMMAND_SETTIME _IOR(I 290 s 291 292 /* Messages received from the interface are th 293 struct ipmi_recv { 294 int recv_type; /* Is this a comman 295 asyncronous even 296 297 unsigned char __user *addr; /* Addr 298 here. The 299 memory. */ 300 unsigned int addr_len; /* The size of 301 The caller 302 length, thi 303 the actual 304 message is 305 306 long msgid; /* The sequence number 307 if this is a respons 308 this will be the seq 309 command. */ 310 311 struct ipmi_msg msg; /* The data field 312 The data_size 313 size of the me 314 caller supplie 315 length, this v 316 actual message 317 is received. * 318 }; 319 320 /* 321 * Receive a message. error values: 322 * - EAGAIN - no messages in the queue. 323 * - EFAULT - an address supplied was invalid 324 * - EINVAL - The address supplied was not va 325 * - EMSGSIZE - The message to was too large 326 * the message will be left in t 327 #define IPMICTL_RECEIVE_MSG _IOWR( 328 329 330 /* 331 * Like RECEIVE_MSG, but if the message won't 332 * will truncate the contents instead of leavi 333 * buffer. 334 */ 335 #define IPMICTL_RECEIVE_MSG_TRUNC _IOWR( 336 337 338 /* Register to get commands from other entitie 339 struct ipmi_cmdspec { 340 unsigned char netfn; 341 unsigned char cmd; 342 }; 343 344 /* 345 * Register to receive a specific command. er 346 * - EFAULT - an address supplied was invali 347 * - EBUSY - The netfn/cmd supplied was alre 348 * - ENOMEM - could not allocate memory for 349 */ 350 #define IPMICTL_REGISTER_FOR_CMD _IOR(I 351 s 352 /* 353 * Unregister a registered command. error val 354 * - EFAULT - an address supplied was invalid 355 * - ENOENT - The netfn/cmd was not found reg 356 */ 357 #define IPMICTL_UNREGISTER_FOR_CMD _IOR(I 358 s 359 360 /* 361 * Register to get commands from other entitie 362 * This way, you can only listen on specific c 363 * from some channels go to one place and othe 364 * else. The chans field is a bitmask, (1 << 365 * It may be IPMI_CHAN_ALL for all channels. 366 */ 367 struct ipmi_cmdspec_chans { 368 unsigned int netfn; 369 unsigned int cmd; 370 unsigned int chans; 371 }; 372 373 /* 374 * Register to receive a specific command on s 375 * - EFAULT - an address supplied was invali 376 * - EBUSY - One of the netfn/cmd/chans supp 377 * - ENOMEM - could not allocate memory for 378 */ 379 #define IPMICTL_REGISTER_FOR_CMD_CHANS _IOR(I 380 s 381 /* 382 * Unregister some netfn/cmd/chans. error val 383 * - EFAULT - an address supplied was invalid 384 * - ENOENT - None of the netfn/cmd/chans wer 385 */ 386 #define IPMICTL_UNREGISTER_FOR_CMD_CHANS _IOR( 387 s 388 389 /* 390 * Set whether this interface receives events. 391 * user registered for events will get all pen 392 * interface. error values: 393 * - EFAULT - an address supplied was invalid 394 */ 395 #define IPMICTL_SET_GETS_EVENTS_CMD _IOR(I 396 397 /* 398 * Set and get the slave address and LUN that 399 * source messages. Note that this affects th 400 * this user, so it will affect all users of t 401 * so some initialization code can come in and 402 * things it takes to determine your address ( 403 * it for everyone else. You should probably 404 */ 405 struct ipmi_channel_lun_address_set { 406 unsigned short channel; 407 unsigned char value; 408 }; 409 #define IPMICTL_SET_MY_CHANNEL_ADDRESS_CMD \ 410 _IOR(IPMI_IOC_MAGIC, 24, struct ipmi_c 411 #define IPMICTL_GET_MY_CHANNEL_ADDRESS_CMD \ 412 _IOR(IPMI_IOC_MAGIC, 25, struct ipmi_c 413 #define IPMICTL_SET_MY_CHANNEL_LUN_CMD \ 414 _IOR(IPMI_IOC_MAGIC, 26, struct ipmi_c 415 #define IPMICTL_GET_MY_CHANNEL_LUN_CMD \ 416 _IOR(IPMI_IOC_MAGIC, 27, struct ipmi_c 417 /* Legacy interfaces, these only set IPMB 0. * 418 #define IPMICTL_SET_MY_ADDRESS_CMD _IOR(I 419 #define IPMICTL_GET_MY_ADDRESS_CMD _IOR(I 420 #define IPMICTL_SET_MY_LUN_CMD _IOR(I 421 #define IPMICTL_GET_MY_LUN_CMD _IOR(I 422 423 /* 424 * Get/set the default timing values for an in 425 * generally mess with these. 426 */ 427 struct ipmi_timing_parms { 428 int retries; 429 unsigned int retry_time_ms; 430 }; 431 #define IPMICTL_SET_TIMING_PARMS_CMD _IOR(I 432 s 433 #define IPMICTL_GET_TIMING_PARMS_CMD _IOR(I 434 s 435 436 /* 437 * Set the maintenance mode. See ipmi_set_mai 438 * for a description of what this does. 439 */ 440 #define IPMICTL_GET_MAINTENANCE_MODE_CMD 441 #define IPMICTL_SET_MAINTENANCE_MODE_CMD 442 443 #endif /* _UAPI__LINUX_IPMI_H */ 444
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.