diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-06-06 18:48:10 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-06-06 18:48:10 -0400 |
commit | 0eb0061381b2bac082cc26d573fc48fe99db3922 (patch) | |
tree | 997ea80d81025e69a3404eb142f01035e75e3412 /include/linux/ipmi.h | |
parent | 8450493076cd1dc8465db688f919708b5be17d46 (diff) | |
parent | 048f7c3e352eeef50ed2c14dd89683f8a3af2f9b (diff) |
Merge tag 'for-linus-4.18' of git://github.com/cminyard/linux-ipmi
Pull IPMI updates from Corey Minyard:
"It's been a busy release for the IPMI driver. Some notable changes:
- A user was running into timeout issues doing maintenance commands
over the IPMB network behind an IPMI controller.
Extend the maintenance mode concept to messages over IPMB and allow
the timeouts to be tuned.
- Lots of cleanup, style fixing, some bugfixes, and such.
- At least one user was having trouble with the way the IPMI driver
would lock the i2c driver module it used.
The IPMI driver was not designed for hotplug. However, hotplug is a
reality now, so the IPMI driver was modified to support hotplug.
- The proc interface code is now completely removed. Long live sysfs!"
* tag 'for-linus-4.18' of git://github.com/cminyard/linux-ipmi: (35 commits)
ipmi: Properly release srcu locks on error conditions
ipmi: NPCM7xx KCS BMC: enable interrupt to the host
ipmi:bt: Set the timeout before doing a capabilities check
ipmi: Remove the proc interface
ipmi_ssif: Fix uninitialized variable issue
ipmi: add an NPCM7xx KCS BMC driver
ipmi_si: Clean up shutdown a bit
ipmi_si: Rename intf_num to si_num
ipmi: Remove smi->intf checks
ipmi_ssif: Get rid of unused intf_num
ipmi: Get rid of ipmi_user_t and ipmi_smi_t in include files
ipmi: ipmi_unregister_smi() cannot fail, have it return void
ipmi_devintf: Add an error return on invalid ioctls
ipmi: Remove usecount function from interfaces
ipmi_ssif: Remove usecount handling
ipmi: Remove condition on interface shutdown
ipmi_ssif: Convert over to a shutdown handler
ipmi_si: Convert over to a shutdown handler
ipmi: Rework locking and shutdown for hot remove
ipmi: Fix some counter issues
...
Diffstat (limited to 'include/linux/ipmi.h')
-rw-r--r-- | include/linux/ipmi.h | 153 |
1 files changed, 96 insertions, 57 deletions
diff --git a/include/linux/ipmi.h b/include/linux/ipmi.h index 8b0626cec980..41f5c086f670 100644 --- a/include/linux/ipmi.h +++ b/include/linux/ipmi.h | |||
@@ -23,8 +23,10 @@ | |||
23 | struct module; | 23 | struct module; |
24 | struct device; | 24 | struct device; |
25 | 25 | ||
26 | /* Opaque type for a IPMI message user. One of these is needed to | 26 | /* |
27 | send and receive messages. */ | 27 | * Opaque type for a IPMI message user. One of these is needed to |
28 | * send and receive messages. | ||
29 | */ | ||
28 | typedef struct ipmi_user *ipmi_user_t; | 30 | typedef struct ipmi_user *ipmi_user_t; |
29 | 31 | ||
30 | /* | 32 | /* |
@@ -37,28 +39,36 @@ typedef struct ipmi_user *ipmi_user_t; | |||
37 | struct ipmi_recv_msg { | 39 | struct ipmi_recv_msg { |
38 | struct list_head link; | 40 | struct list_head link; |
39 | 41 | ||
40 | /* The type of message as defined in the "Receive Types" | 42 | /* |
41 | defines above. */ | 43 | * The type of message as defined in the "Receive Types" |
44 | * defines above. | ||
45 | */ | ||
42 | int recv_type; | 46 | int recv_type; |
43 | 47 | ||
44 | ipmi_user_t user; | 48 | struct ipmi_user *user; |
45 | struct ipmi_addr addr; | 49 | struct ipmi_addr addr; |
46 | long msgid; | 50 | long msgid; |
47 | struct kernel_ipmi_msg msg; | 51 | struct kernel_ipmi_msg msg; |
48 | 52 | ||
49 | /* The user_msg_data is the data supplied when a message was | 53 | /* |
50 | sent, if this is a response to a sent message. If this is | 54 | * The user_msg_data is the data supplied when a message was |
51 | not a response to a sent message, then user_msg_data will | 55 | * sent, if this is a response to a sent message. If this is |
52 | be NULL. If the user above is NULL, then this will be the | 56 | * not a response to a sent message, then user_msg_data will |
53 | intf. */ | 57 | * be NULL. If the user above is NULL, then this will be the |
58 | * intf. | ||
59 | */ | ||
54 | void *user_msg_data; | 60 | void *user_msg_data; |
55 | 61 | ||
56 | /* Call this when done with the message. It will presumably free | 62 | /* |
57 | the message and do any other necessary cleanup. */ | 63 | * Call this when done with the message. It will presumably free |
64 | * the message and do any other necessary cleanup. | ||
65 | */ | ||
58 | void (*done)(struct ipmi_recv_msg *msg); | 66 | void (*done)(struct ipmi_recv_msg *msg); |
59 | 67 | ||
60 | /* Place-holder for the data, don't make any assumptions about | 68 | /* |
61 | the size or existence of this, since it may change. */ | 69 | * Place-holder for the data, don't make any assumptions about |
70 | * the size or existence of this, since it may change. | ||
71 | */ | ||
62 | unsigned char msg_data[IPMI_MAX_MSG_LENGTH]; | 72 | unsigned char msg_data[IPMI_MAX_MSG_LENGTH]; |
63 | }; | 73 | }; |
64 | 74 | ||
@@ -66,54 +76,77 @@ struct ipmi_recv_msg { | |||
66 | void ipmi_free_recv_msg(struct ipmi_recv_msg *msg); | 76 | void ipmi_free_recv_msg(struct ipmi_recv_msg *msg); |
67 | 77 | ||
68 | struct ipmi_user_hndl { | 78 | struct ipmi_user_hndl { |
69 | /* Routine type to call when a message needs to be routed to | 79 | /* |
70 | the upper layer. This will be called with some locks held, | 80 | * Routine type to call when a message needs to be routed to |
71 | the only IPMI routines that can be called are ipmi_request | 81 | * the upper layer. This will be called with some locks held, |
72 | and the alloc/free operations. The handler_data is the | 82 | * the only IPMI routines that can be called are ipmi_request |
73 | variable supplied when the receive handler was registered. */ | 83 | * and the alloc/free operations. The handler_data is the |
84 | * variable supplied when the receive handler was registered. | ||
85 | */ | ||
74 | void (*ipmi_recv_hndl)(struct ipmi_recv_msg *msg, | 86 | void (*ipmi_recv_hndl)(struct ipmi_recv_msg *msg, |
75 | void *user_msg_data); | 87 | void *user_msg_data); |
76 | 88 | ||
77 | /* Called when the interface detects a watchdog pre-timeout. If | 89 | /* |
78 | this is NULL, it will be ignored for the user. */ | 90 | * Called when the interface detects a watchdog pre-timeout. If |
91 | * this is NULL, it will be ignored for the user. | ||
92 | */ | ||
79 | void (*ipmi_watchdog_pretimeout)(void *handler_data); | 93 | void (*ipmi_watchdog_pretimeout)(void *handler_data); |
94 | |||
95 | /* | ||
96 | * If not NULL, called at panic time after the interface has | ||
97 | * been set up to handle run to completion. | ||
98 | */ | ||
99 | void (*ipmi_panic_handler)(void *handler_data); | ||
100 | |||
101 | /* | ||
102 | * Called when the interface has been removed. After this returns | ||
103 | * the user handle will be invalid. The interface may or may | ||
104 | * not be usable when this is called, but it will return errors | ||
105 | * if it is not usable. | ||
106 | */ | ||
107 | void (*shutdown)(void *handler_data); | ||
80 | }; | 108 | }; |
81 | 109 | ||
82 | /* Create a new user of the IPMI layer on the given interface number. */ | 110 | /* Create a new user of the IPMI layer on the given interface number. */ |
83 | int ipmi_create_user(unsigned int if_num, | 111 | int ipmi_create_user(unsigned int if_num, |
84 | const struct ipmi_user_hndl *handler, | 112 | const struct ipmi_user_hndl *handler, |
85 | void *handler_data, | 113 | void *handler_data, |
86 | ipmi_user_t *user); | 114 | struct ipmi_user **user); |
87 | 115 | ||
88 | /* Destroy the given user of the IPMI layer. Note that after this | 116 | /* |
89 | function returns, the system is guaranteed to not call any | 117 | * Destroy the given user of the IPMI layer. Note that after this |
90 | callbacks for the user. Thus as long as you destroy all the users | 118 | * function returns, the system is guaranteed to not call any |
91 | before you unload a module, you will be safe. And if you destroy | 119 | * callbacks for the user. Thus as long as you destroy all the users |
92 | the users before you destroy the callback structures, it should be | 120 | * before you unload a module, you will be safe. And if you destroy |
93 | safe, too. */ | 121 | * the users before you destroy the callback structures, it should be |
94 | int ipmi_destroy_user(ipmi_user_t user); | 122 | * safe, too. |
123 | */ | ||
124 | int ipmi_destroy_user(struct ipmi_user *user); | ||
95 | 125 | ||
96 | /* Get the IPMI version of the BMC we are talking to. */ | 126 | /* Get the IPMI version of the BMC we are talking to. */ |
97 | int ipmi_get_version(ipmi_user_t user, | 127 | int ipmi_get_version(struct ipmi_user *user, |
98 | unsigned char *major, | 128 | unsigned char *major, |
99 | unsigned char *minor); | 129 | unsigned char *minor); |
100 | 130 | ||
101 | /* Set and get the slave address and LUN that we will use for our | 131 | /* |
102 | source messages. Note that this affects the interface, not just | 132 | * Set and get the slave address and LUN that we will use for our |
103 | this user, so it will affect all users of this interface. This is | 133 | * source messages. Note that this affects the interface, not just |
104 | so some initialization code can come in and do the OEM-specific | 134 | * this user, so it will affect all users of this interface. This is |
105 | things it takes to determine your address (if not the BMC) and set | 135 | * so some initialization code can come in and do the OEM-specific |
106 | it for everyone else. Note that each channel can have its own address. */ | 136 | * things it takes to determine your address (if not the BMC) and set |
107 | int ipmi_set_my_address(ipmi_user_t user, | 137 | * it for everyone else. Note that each channel can have its own |
138 | * address. | ||
139 | */ | ||
140 | int ipmi_set_my_address(struct ipmi_user *user, | ||
108 | unsigned int channel, | 141 | unsigned int channel, |
109 | unsigned char address); | 142 | unsigned char address); |
110 | int ipmi_get_my_address(ipmi_user_t user, | 143 | int ipmi_get_my_address(struct ipmi_user *user, |
111 | unsigned int channel, | 144 | unsigned int channel, |
112 | unsigned char *address); | 145 | unsigned char *address); |
113 | int ipmi_set_my_LUN(ipmi_user_t user, | 146 | int ipmi_set_my_LUN(struct ipmi_user *user, |
114 | unsigned int channel, | 147 | unsigned int channel, |
115 | unsigned char LUN); | 148 | unsigned char LUN); |
116 | int ipmi_get_my_LUN(ipmi_user_t user, | 149 | int ipmi_get_my_LUN(struct ipmi_user *user, |
117 | unsigned int channel, | 150 | unsigned int channel, |
118 | unsigned char *LUN); | 151 | unsigned char *LUN); |
119 | 152 | ||
@@ -130,7 +163,7 @@ int ipmi_get_my_LUN(ipmi_user_t user, | |||
130 | * it makes no sense to do it here. However, this can be used if you | 163 | * it makes no sense to do it here. However, this can be used if you |
131 | * have unusual requirements. | 164 | * have unusual requirements. |
132 | */ | 165 | */ |
133 | int ipmi_request_settime(ipmi_user_t user, | 166 | int ipmi_request_settime(struct ipmi_user *user, |
134 | struct ipmi_addr *addr, | 167 | struct ipmi_addr *addr, |
135 | long msgid, | 168 | long msgid, |
136 | struct kernel_ipmi_msg *msg, | 169 | struct kernel_ipmi_msg *msg, |
@@ -148,7 +181,7 @@ int ipmi_request_settime(ipmi_user_t user, | |||
148 | * change as the system changes, so don't use it unless you REALLY | 181 | * change as the system changes, so don't use it unless you REALLY |
149 | * have to. | 182 | * have to. |
150 | */ | 183 | */ |
151 | int ipmi_request_supply_msgs(ipmi_user_t user, | 184 | int ipmi_request_supply_msgs(struct ipmi_user *user, |
152 | struct ipmi_addr *addr, | 185 | struct ipmi_addr *addr, |
153 | long msgid, | 186 | long msgid, |
154 | struct kernel_ipmi_msg *msg, | 187 | struct kernel_ipmi_msg *msg, |
@@ -164,7 +197,7 @@ int ipmi_request_supply_msgs(ipmi_user_t user, | |||
164 | * way. This is useful if you need to spin waiting for something to | 197 | * way. This is useful if you need to spin waiting for something to |
165 | * happen in the IPMI driver. | 198 | * happen in the IPMI driver. |
166 | */ | 199 | */ |
167 | void ipmi_poll_interface(ipmi_user_t user); | 200 | void ipmi_poll_interface(struct ipmi_user *user); |
168 | 201 | ||
169 | /* | 202 | /* |
170 | * When commands come in to the SMS, the user can register to receive | 203 | * When commands come in to the SMS, the user can register to receive |
@@ -175,11 +208,11 @@ void ipmi_poll_interface(ipmi_user_t user); | |||
175 | * error. Channels are specified as a bitfield, use IPMI_CHAN_ALL to | 208 | * error. Channels are specified as a bitfield, use IPMI_CHAN_ALL to |
176 | * mean all channels. | 209 | * mean all channels. |
177 | */ | 210 | */ |
178 | int ipmi_register_for_cmd(ipmi_user_t user, | 211 | int ipmi_register_for_cmd(struct ipmi_user *user, |
179 | unsigned char netfn, | 212 | unsigned char netfn, |
180 | unsigned char cmd, | 213 | unsigned char cmd, |
181 | unsigned int chans); | 214 | unsigned int chans); |
182 | int ipmi_unregister_for_cmd(ipmi_user_t user, | 215 | int ipmi_unregister_for_cmd(struct ipmi_user *user, |
183 | unsigned char netfn, | 216 | unsigned char netfn, |
184 | unsigned char cmd, | 217 | unsigned char cmd, |
185 | unsigned int chans); | 218 | unsigned int chans); |
@@ -210,8 +243,8 @@ int ipmi_unregister_for_cmd(ipmi_user_t user, | |||
210 | * | 243 | * |
211 | * See the IPMI_MAINTENANCE_MODE_xxx defines for what the mode means. | 244 | * See the IPMI_MAINTENANCE_MODE_xxx defines for what the mode means. |
212 | */ | 245 | */ |
213 | int ipmi_get_maintenance_mode(ipmi_user_t user); | 246 | int ipmi_get_maintenance_mode(struct ipmi_user *user); |
214 | int ipmi_set_maintenance_mode(ipmi_user_t user, int mode); | 247 | int ipmi_set_maintenance_mode(struct ipmi_user *user, int mode); |
215 | 248 | ||
216 | /* | 249 | /* |
217 | * When the user is created, it will not receive IPMI events by | 250 | * When the user is created, it will not receive IPMI events by |
@@ -219,7 +252,7 @@ int ipmi_set_maintenance_mode(ipmi_user_t user, int mode); | |||
219 | * The first user that sets this to TRUE will receive all events that | 252 | * The first user that sets this to TRUE will receive all events that |
220 | * have been queued while no one was waiting for events. | 253 | * have been queued while no one was waiting for events. |
221 | */ | 254 | */ |
222 | int ipmi_set_gets_events(ipmi_user_t user, bool val); | 255 | int ipmi_set_gets_events(struct ipmi_user *user, bool val); |
223 | 256 | ||
224 | /* | 257 | /* |
225 | * Called when a new SMI is registered. This will also be called on | 258 | * Called when a new SMI is registered. This will also be called on |
@@ -229,14 +262,18 @@ int ipmi_set_gets_events(ipmi_user_t user, bool val); | |||
229 | struct ipmi_smi_watcher { | 262 | struct ipmi_smi_watcher { |
230 | struct list_head link; | 263 | struct list_head link; |
231 | 264 | ||
232 | /* You must set the owner to the current module, if you are in | 265 | /* |
233 | a module (generally just set it to "THIS_MODULE"). */ | 266 | * You must set the owner to the current module, if you are in |
267 | * a module (generally just set it to "THIS_MODULE"). | ||
268 | */ | ||
234 | struct module *owner; | 269 | struct module *owner; |
235 | 270 | ||
236 | /* These two are called with read locks held for the interface | 271 | /* |
237 | the watcher list. So you can add and remove users from the | 272 | * These two are called with read locks held for the interface |
238 | IPMI interface, send messages, etc., but you cannot add | 273 | * the watcher list. So you can add and remove users from the |
239 | or remove SMI watchers or SMI interfaces. */ | 274 | * IPMI interface, send messages, etc., but you cannot add |
275 | * or remove SMI watchers or SMI interfaces. | ||
276 | */ | ||
240 | void (*new_smi)(int if_num, struct device *dev); | 277 | void (*new_smi)(int if_num, struct device *dev); |
241 | void (*smi_gone)(int if_num); | 278 | void (*smi_gone)(int if_num); |
242 | }; | 279 | }; |
@@ -244,8 +281,10 @@ struct ipmi_smi_watcher { | |||
244 | int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher); | 281 | int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher); |
245 | int ipmi_smi_watcher_unregister(struct ipmi_smi_watcher *watcher); | 282 | int ipmi_smi_watcher_unregister(struct ipmi_smi_watcher *watcher); |
246 | 283 | ||
247 | /* The following are various helper functions for dealing with IPMI | 284 | /* |
248 | addresses. */ | 285 | * The following are various helper functions for dealing with IPMI |
286 | * addresses. | ||
287 | */ | ||
249 | 288 | ||
250 | /* Return the maximum length of an IPMI address given it's type. */ | 289 | /* Return the maximum length of an IPMI address given it's type. */ |
251 | unsigned int ipmi_addr_length(int addr_type); | 290 | unsigned int ipmi_addr_length(int addr_type); |
@@ -291,7 +330,7 @@ struct ipmi_smi_info { | |||
291 | union ipmi_smi_info_union addr_info; | 330 | union ipmi_smi_info_union addr_info; |
292 | }; | 331 | }; |
293 | 332 | ||
294 | /* This is to get the private info of ipmi_smi_t */ | 333 | /* This is to get the private info of struct ipmi_smi */ |
295 | extern int ipmi_get_smi_info(int if_num, struct ipmi_smi_info *data); | 334 | extern int ipmi_get_smi_info(int if_num, struct ipmi_smi_info *data); |
296 | 335 | ||
297 | #endif /* __LINUX_IPMI_H */ | 336 | #endif /* __LINUX_IPMI_H */ |