diff options
author | Konstantin Baydarov <kbaidarov@ru.mvista.com> | 2008-04-29 04:01:05 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-29 11:06:14 -0400 |
commit | b2655f2615e92e92ca3d55132b32776f1fe1a05c (patch) | |
tree | 09a92d8e56dd2742cdd33bc885cfc6d5187f55c7 /drivers | |
parent | f7caa1b51fa526586c9d9a4582b5f8af440909d7 (diff) |
ipmi: convert locked counters to atomics
Atomics are a lot more efficient and neat than using a lock.
Signed-off-by: Konstantin Baydarov <kbaidarov@ru.mvista.com>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/char/ipmi/ipmi_msghandler.c | 442 |
1 files changed, 194 insertions, 248 deletions
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 5c0abafa3e1a..4a5e159dc0f5 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c | |||
@@ -67,7 +67,6 @@ static struct proc_dir_entry *proc_ipmi_root; | |||
67 | the max message timer. This is in milliseconds. */ | 67 | the max message timer. This is in milliseconds. */ |
68 | #define MAX_MSG_TIMEOUT 60000 | 68 | #define MAX_MSG_TIMEOUT 60000 |
69 | 69 | ||
70 | |||
71 | /* | 70 | /* |
72 | * The main "user" data structure. | 71 | * The main "user" data structure. |
73 | */ | 72 | */ |
@@ -186,6 +185,96 @@ struct bmc_device | |||
186 | struct device_attribute aux_firmware_rev_attr; | 185 | struct device_attribute aux_firmware_rev_attr; |
187 | }; | 186 | }; |
188 | 187 | ||
188 | /* | ||
189 | * Various statistics for IPMI, these index stats[] in the ipmi_smi | ||
190 | * structure. | ||
191 | */ | ||
192 | /* Commands we got from the user that were invalid. */ | ||
193 | #define IPMI_STAT_sent_invalid_commands 0 | ||
194 | |||
195 | /* Commands we sent to the MC. */ | ||
196 | #define IPMI_STAT_sent_local_commands 1 | ||
197 | |||
198 | /* Responses from the MC that were delivered to a user. */ | ||
199 | #define IPMI_STAT_handled_local_responses 2 | ||
200 | |||
201 | /* Responses from the MC that were not delivered to a user. */ | ||
202 | #define IPMI_STAT_unhandled_local_responses 3 | ||
203 | |||
204 | /* Commands we sent out to the IPMB bus. */ | ||
205 | #define IPMI_STAT_sent_ipmb_commands 4 | ||
206 | |||
207 | /* Commands sent on the IPMB that had errors on the SEND CMD */ | ||
208 | #define IPMI_STAT_sent_ipmb_command_errs 5 | ||
209 | |||
210 | /* Each retransmit increments this count. */ | ||
211 | #define IPMI_STAT_retransmitted_ipmb_commands 6 | ||
212 | |||
213 | /* When a message times out (runs out of retransmits) this is incremented. */ | ||
214 | #define IPMI_STAT_timed_out_ipmb_commands 7 | ||
215 | |||
216 | /* | ||
217 | * This is like above, but for broadcasts. Broadcasts are | ||
218 | * *not* included in the above count (they are expected to | ||
219 | * time out). | ||
220 | */ | ||
221 | #define IPMI_STAT_timed_out_ipmb_broadcasts 8 | ||
222 | |||
223 | /* Responses I have sent to the IPMB bus. */ | ||
224 | #define IPMI_STAT_sent_ipmb_responses 9 | ||
225 | |||
226 | /* The response was delivered to the user. */ | ||
227 | #define IPMI_STAT_handled_ipmb_responses 10 | ||
228 | |||
229 | /* The response had invalid data in it. */ | ||
230 | #define IPMI_STAT_invalid_ipmb_responses 11 | ||
231 | |||
232 | /* The response didn't have anyone waiting for it. */ | ||
233 | #define IPMI_STAT_unhandled_ipmb_responses 12 | ||
234 | |||
235 | /* Commands we sent out to the IPMB bus. */ | ||
236 | #define IPMI_STAT_sent_lan_commands 13 | ||
237 | |||
238 | /* Commands sent on the IPMB that had errors on the SEND CMD */ | ||
239 | #define IPMI_STAT_sent_lan_command_errs 14 | ||
240 | |||
241 | /* Each retransmit increments this count. */ | ||
242 | #define IPMI_STAT_retransmitted_lan_commands 15 | ||
243 | |||
244 | /* When a message times out (runs out of retransmits) this is incremented. */ | ||
245 | #define IPMI_STAT_timed_out_lan_commands 16 | ||
246 | |||
247 | /* Responses I have sent to the IPMB bus. */ | ||
248 | #define IPMI_STAT_sent_lan_responses 17 | ||
249 | |||
250 | /* The response was delivered to the user. */ | ||
251 | #define IPMI_STAT_handled_lan_responses 18 | ||
252 | |||
253 | /* The response had invalid data in it. */ | ||
254 | #define IPMI_STAT_invalid_lan_responses 19 | ||
255 | |||
256 | /* The response didn't have anyone waiting for it. */ | ||
257 | #define IPMI_STAT_unhandled_lan_responses 20 | ||
258 | |||
259 | /* The command was delivered to the user. */ | ||
260 | #define IPMI_STAT_handled_commands 21 | ||
261 | |||
262 | /* The command had invalid data in it. */ | ||
263 | #define IPMI_STAT_invalid_commands 22 | ||
264 | |||
265 | /* The command didn't have anyone waiting for it. */ | ||
266 | #define IPMI_STAT_unhandled_commands 23 | ||
267 | |||
268 | /* Invalid data in an event. */ | ||
269 | #define IPMI_STAT_invalid_events 24 | ||
270 | |||
271 | /* Events that were received with the proper format. */ | ||
272 | #define IPMI_STAT_events 25 | ||
273 | |||
274 | /* When you add a statistic, you must update this value. */ | ||
275 | #define IPMI_NUM_STATS 26 | ||
276 | |||
277 | |||
189 | #define IPMI_IPMB_NUM_SEQ 64 | 278 | #define IPMI_IPMB_NUM_SEQ 64 |
190 | #define IPMI_MAX_CHANNELS 16 | 279 | #define IPMI_MAX_CHANNELS 16 |
191 | struct ipmi_smi | 280 | struct ipmi_smi |
@@ -286,75 +375,7 @@ struct ipmi_smi | |||
286 | struct proc_dir_entry *proc_dir; | 375 | struct proc_dir_entry *proc_dir; |
287 | char proc_dir_name[10]; | 376 | char proc_dir_name[10]; |
288 | 377 | ||
289 | spinlock_t counter_lock; /* For making counters atomic. */ | 378 | atomic_t stats[IPMI_NUM_STATS]; |
290 | |||
291 | /* Commands we got that were invalid. */ | ||
292 | unsigned int sent_invalid_commands; | ||
293 | |||
294 | /* Commands we sent to the MC. */ | ||
295 | unsigned int sent_local_commands; | ||
296 | /* Responses from the MC that were delivered to a user. */ | ||
297 | unsigned int handled_local_responses; | ||
298 | /* Responses from the MC that were not delivered to a user. */ | ||
299 | unsigned int unhandled_local_responses; | ||
300 | |||
301 | /* Commands we sent out to the IPMB bus. */ | ||
302 | unsigned int sent_ipmb_commands; | ||
303 | /* Commands sent on the IPMB that had errors on the SEND CMD */ | ||
304 | unsigned int sent_ipmb_command_errs; | ||
305 | /* Each retransmit increments this count. */ | ||
306 | unsigned int retransmitted_ipmb_commands; | ||
307 | /* When a message times out (runs out of retransmits) this is | ||
308 | incremented. */ | ||
309 | unsigned int timed_out_ipmb_commands; | ||
310 | |||
311 | /* This is like above, but for broadcasts. Broadcasts are | ||
312 | *not* included in the above count (they are expected to | ||
313 | time out). */ | ||
314 | unsigned int timed_out_ipmb_broadcasts; | ||
315 | |||
316 | /* Responses I have sent to the IPMB bus. */ | ||
317 | unsigned int sent_ipmb_responses; | ||
318 | |||
319 | /* The response was delivered to the user. */ | ||
320 | unsigned int handled_ipmb_responses; | ||
321 | /* The response had invalid data in it. */ | ||
322 | unsigned int invalid_ipmb_responses; | ||
323 | /* The response didn't have anyone waiting for it. */ | ||
324 | unsigned int unhandled_ipmb_responses; | ||
325 | |||
326 | /* Commands we sent out to the IPMB bus. */ | ||
327 | unsigned int sent_lan_commands; | ||
328 | /* Commands sent on the IPMB that had errors on the SEND CMD */ | ||
329 | unsigned int sent_lan_command_errs; | ||
330 | /* Each retransmit increments this count. */ | ||
331 | unsigned int retransmitted_lan_commands; | ||
332 | /* When a message times out (runs out of retransmits) this is | ||
333 | incremented. */ | ||
334 | unsigned int timed_out_lan_commands; | ||
335 | |||
336 | /* Responses I have sent to the IPMB bus. */ | ||
337 | unsigned int sent_lan_responses; | ||
338 | |||
339 | /* The response was delivered to the user. */ | ||
340 | unsigned int handled_lan_responses; | ||
341 | /* The response had invalid data in it. */ | ||
342 | unsigned int invalid_lan_responses; | ||
343 | /* The response didn't have anyone waiting for it. */ | ||
344 | unsigned int unhandled_lan_responses; | ||
345 | |||
346 | /* The command was delivered to the user. */ | ||
347 | unsigned int handled_commands; | ||
348 | /* The command had invalid data in it. */ | ||
349 | unsigned int invalid_commands; | ||
350 | /* The command didn't have anyone waiting for it. */ | ||
351 | unsigned int unhandled_commands; | ||
352 | |||
353 | /* Invalid data in an event. */ | ||
354 | unsigned int invalid_events; | ||
355 | |||
356 | /* Events that were received with the proper format. */ | ||
357 | unsigned int events; | ||
358 | 379 | ||
359 | /* | 380 | /* |
360 | * run_to_completion duplicate of smb_info, smi_info | 381 | * run_to_completion duplicate of smb_info, smi_info |
@@ -383,6 +404,12 @@ static LIST_HEAD(smi_watchers); | |||
383 | static DEFINE_MUTEX(smi_watchers_mutex); | 404 | static DEFINE_MUTEX(smi_watchers_mutex); |
384 | 405 | ||
385 | 406 | ||
407 | #define ipmi_inc_stat(intf, stat) \ | ||
408 | atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat]) | ||
409 | #define ipmi_get_stat(intf, stat) \ | ||
410 | ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat])) | ||
411 | |||
412 | |||
386 | static void free_recv_msg_list(struct list_head *q) | 413 | static void free_recv_msg_list(struct list_head *q) |
387 | { | 414 | { |
388 | struct ipmi_recv_msg *msg, *msg2; | 415 | struct ipmi_recv_msg *msg, *msg2; |
@@ -623,19 +650,14 @@ static void deliver_response(struct ipmi_recv_msg *msg) | |||
623 | { | 650 | { |
624 | if (!msg->user) { | 651 | if (!msg->user) { |
625 | ipmi_smi_t intf = msg->user_msg_data; | 652 | ipmi_smi_t intf = msg->user_msg_data; |
626 | unsigned long flags; | ||
627 | 653 | ||
628 | /* Special handling for NULL users. */ | 654 | /* Special handling for NULL users. */ |
629 | if (intf->null_user_handler) { | 655 | if (intf->null_user_handler) { |
630 | intf->null_user_handler(intf, msg); | 656 | intf->null_user_handler(intf, msg); |
631 | spin_lock_irqsave(&intf->counter_lock, flags); | 657 | ipmi_inc_stat(intf, handled_local_responses); |
632 | intf->handled_local_responses++; | ||
633 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
634 | } else { | 658 | } else { |
635 | /* No handler, so give up. */ | 659 | /* No handler, so give up. */ |
636 | spin_lock_irqsave(&intf->counter_lock, flags); | 660 | ipmi_inc_stat(intf, unhandled_local_responses); |
637 | intf->unhandled_local_responses++; | ||
638 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
639 | } | 661 | } |
640 | ipmi_free_recv_msg(msg); | 662 | ipmi_free_recv_msg(msg); |
641 | } else { | 663 | } else { |
@@ -1372,9 +1394,7 @@ static int i_ipmi_request(ipmi_user_t user, | |||
1372 | 1394 | ||
1373 | smi_addr = (struct ipmi_system_interface_addr *) addr; | 1395 | smi_addr = (struct ipmi_system_interface_addr *) addr; |
1374 | if (smi_addr->lun > 3) { | 1396 | if (smi_addr->lun > 3) { |
1375 | spin_lock_irqsave(&intf->counter_lock, flags); | 1397 | ipmi_inc_stat(intf, sent_invalid_commands); |
1376 | intf->sent_invalid_commands++; | ||
1377 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
1378 | rv = -EINVAL; | 1398 | rv = -EINVAL; |
1379 | goto out_err; | 1399 | goto out_err; |
1380 | } | 1400 | } |
@@ -1388,9 +1408,7 @@ static int i_ipmi_request(ipmi_user_t user, | |||
1388 | { | 1408 | { |
1389 | /* We don't let the user do these, since we manage | 1409 | /* We don't let the user do these, since we manage |
1390 | the sequence numbers. */ | 1410 | the sequence numbers. */ |
1391 | spin_lock_irqsave(&intf->counter_lock, flags); | 1411 | ipmi_inc_stat(intf, sent_invalid_commands); |
1392 | intf->sent_invalid_commands++; | ||
1393 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
1394 | rv = -EINVAL; | 1412 | rv = -EINVAL; |
1395 | goto out_err; | 1413 | goto out_err; |
1396 | } | 1414 | } |
@@ -1414,9 +1432,7 @@ static int i_ipmi_request(ipmi_user_t user, | |||
1414 | } | 1432 | } |
1415 | 1433 | ||
1416 | if ((msg->data_len + 2) > IPMI_MAX_MSG_LENGTH) { | 1434 | if ((msg->data_len + 2) > IPMI_MAX_MSG_LENGTH) { |
1417 | spin_lock_irqsave(&intf->counter_lock, flags); | 1435 | ipmi_inc_stat(intf, sent_invalid_commands); |
1418 | intf->sent_invalid_commands++; | ||
1419 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
1420 | rv = -EMSGSIZE; | 1436 | rv = -EMSGSIZE; |
1421 | goto out_err; | 1437 | goto out_err; |
1422 | } | 1438 | } |
@@ -1428,9 +1444,7 @@ static int i_ipmi_request(ipmi_user_t user, | |||
1428 | if (msg->data_len > 0) | 1444 | if (msg->data_len > 0) |
1429 | memcpy(&(smi_msg->data[2]), msg->data, msg->data_len); | 1445 | memcpy(&(smi_msg->data[2]), msg->data, msg->data_len); |
1430 | smi_msg->data_size = msg->data_len + 2; | 1446 | smi_msg->data_size = msg->data_len + 2; |
1431 | spin_lock_irqsave(&intf->counter_lock, flags); | 1447 | ipmi_inc_stat(intf, sent_local_commands); |
1432 | intf->sent_local_commands++; | ||
1433 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
1434 | } else if ((addr->addr_type == IPMI_IPMB_ADDR_TYPE) | 1448 | } else if ((addr->addr_type == IPMI_IPMB_ADDR_TYPE) |
1435 | || (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) | 1449 | || (addr->addr_type == IPMI_IPMB_BROADCAST_ADDR_TYPE)) |
1436 | { | 1450 | { |
@@ -1440,9 +1454,7 @@ static int i_ipmi_request(ipmi_user_t user, | |||
1440 | int broadcast = 0; | 1454 | int broadcast = 0; |
1441 | 1455 | ||
1442 | if (addr->channel >= IPMI_MAX_CHANNELS) { | 1456 | if (addr->channel >= IPMI_MAX_CHANNELS) { |
1443 | spin_lock_irqsave(&intf->counter_lock, flags); | 1457 | ipmi_inc_stat(intf, sent_invalid_commands); |
1444 | intf->sent_invalid_commands++; | ||
1445 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
1446 | rv = -EINVAL; | 1458 | rv = -EINVAL; |
1447 | goto out_err; | 1459 | goto out_err; |
1448 | } | 1460 | } |
@@ -1450,9 +1462,7 @@ static int i_ipmi_request(ipmi_user_t user, | |||
1450 | if (intf->channels[addr->channel].medium | 1462 | if (intf->channels[addr->channel].medium |
1451 | != IPMI_CHANNEL_MEDIUM_IPMB) | 1463 | != IPMI_CHANNEL_MEDIUM_IPMB) |
1452 | { | 1464 | { |
1453 | spin_lock_irqsave(&intf->counter_lock, flags); | 1465 | ipmi_inc_stat(intf, sent_invalid_commands); |
1454 | intf->sent_invalid_commands++; | ||
1455 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
1456 | rv = -EINVAL; | 1466 | rv = -EINVAL; |
1457 | goto out_err; | 1467 | goto out_err; |
1458 | } | 1468 | } |
@@ -1479,18 +1489,14 @@ static int i_ipmi_request(ipmi_user_t user, | |||
1479 | /* 9 for the header and 1 for the checksum, plus | 1489 | /* 9 for the header and 1 for the checksum, plus |
1480 | possibly one for the broadcast. */ | 1490 | possibly one for the broadcast. */ |
1481 | if ((msg->data_len + 10 + broadcast) > IPMI_MAX_MSG_LENGTH) { | 1491 | if ((msg->data_len + 10 + broadcast) > IPMI_MAX_MSG_LENGTH) { |
1482 | spin_lock_irqsave(&intf->counter_lock, flags); | 1492 | ipmi_inc_stat(intf, sent_invalid_commands); |
1483 | intf->sent_invalid_commands++; | ||
1484 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
1485 | rv = -EMSGSIZE; | 1493 | rv = -EMSGSIZE; |
1486 | goto out_err; | 1494 | goto out_err; |
1487 | } | 1495 | } |
1488 | 1496 | ||
1489 | ipmb_addr = (struct ipmi_ipmb_addr *) addr; | 1497 | ipmb_addr = (struct ipmi_ipmb_addr *) addr; |
1490 | if (ipmb_addr->lun > 3) { | 1498 | if (ipmb_addr->lun > 3) { |
1491 | spin_lock_irqsave(&intf->counter_lock, flags); | 1499 | ipmi_inc_stat(intf, sent_invalid_commands); |
1492 | intf->sent_invalid_commands++; | ||
1493 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
1494 | rv = -EINVAL; | 1500 | rv = -EINVAL; |
1495 | goto out_err; | 1501 | goto out_err; |
1496 | } | 1502 | } |
@@ -1500,9 +1506,7 @@ static int i_ipmi_request(ipmi_user_t user, | |||
1500 | if (recv_msg->msg.netfn & 0x1) { | 1506 | if (recv_msg->msg.netfn & 0x1) { |
1501 | /* It's a response, so use the user's sequence | 1507 | /* It's a response, so use the user's sequence |
1502 | from msgid. */ | 1508 | from msgid. */ |
1503 | spin_lock_irqsave(&intf->counter_lock, flags); | 1509 | ipmi_inc_stat(intf, sent_ipmb_responses); |
1504 | intf->sent_ipmb_responses++; | ||
1505 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
1506 | format_ipmb_msg(smi_msg, msg, ipmb_addr, msgid, | 1510 | format_ipmb_msg(smi_msg, msg, ipmb_addr, msgid, |
1507 | msgid, broadcast, | 1511 | msgid, broadcast, |
1508 | source_address, source_lun); | 1512 | source_address, source_lun); |
@@ -1515,9 +1519,7 @@ static int i_ipmi_request(ipmi_user_t user, | |||
1515 | 1519 | ||
1516 | spin_lock_irqsave(&(intf->seq_lock), flags); | 1520 | spin_lock_irqsave(&(intf->seq_lock), flags); |
1517 | 1521 | ||
1518 | spin_lock(&intf->counter_lock); | 1522 | ipmi_inc_stat(intf, sent_ipmb_commands); |
1519 | intf->sent_ipmb_commands++; | ||
1520 | spin_unlock(&intf->counter_lock); | ||
1521 | 1523 | ||
1522 | /* Create a sequence number with a 1 second | 1524 | /* Create a sequence number with a 1 second |
1523 | timeout and 4 retries. */ | 1525 | timeout and 4 retries. */ |
@@ -1565,9 +1567,7 @@ static int i_ipmi_request(ipmi_user_t user, | |||
1565 | long seqid; | 1567 | long seqid; |
1566 | 1568 | ||
1567 | if (addr->channel >= IPMI_MAX_CHANNELS) { | 1569 | if (addr->channel >= IPMI_MAX_CHANNELS) { |
1568 | spin_lock_irqsave(&intf->counter_lock, flags); | 1570 | ipmi_inc_stat(intf, sent_invalid_commands); |
1569 | intf->sent_invalid_commands++; | ||
1570 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
1571 | rv = -EINVAL; | 1571 | rv = -EINVAL; |
1572 | goto out_err; | 1572 | goto out_err; |
1573 | } | 1573 | } |
@@ -1577,9 +1577,7 @@ static int i_ipmi_request(ipmi_user_t user, | |||
1577 | && (intf->channels[addr->channel].medium | 1577 | && (intf->channels[addr->channel].medium |
1578 | != IPMI_CHANNEL_MEDIUM_ASYNC)) | 1578 | != IPMI_CHANNEL_MEDIUM_ASYNC)) |
1579 | { | 1579 | { |
1580 | spin_lock_irqsave(&intf->counter_lock, flags); | 1580 | ipmi_inc_stat(intf, sent_invalid_commands); |
1581 | intf->sent_invalid_commands++; | ||
1582 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
1583 | rv = -EINVAL; | 1581 | rv = -EINVAL; |
1584 | goto out_err; | 1582 | goto out_err; |
1585 | } | 1583 | } |
@@ -1592,18 +1590,14 @@ static int i_ipmi_request(ipmi_user_t user, | |||
1592 | 1590 | ||
1593 | /* 11 for the header and 1 for the checksum. */ | 1591 | /* 11 for the header and 1 for the checksum. */ |
1594 | if ((msg->data_len + 12) > IPMI_MAX_MSG_LENGTH) { | 1592 | if ((msg->data_len + 12) > IPMI_MAX_MSG_LENGTH) { |
1595 | spin_lock_irqsave(&intf->counter_lock, flags); | 1593 | ipmi_inc_stat(intf, sent_invalid_commands); |
1596 | intf->sent_invalid_commands++; | ||
1597 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
1598 | rv = -EMSGSIZE; | 1594 | rv = -EMSGSIZE; |
1599 | goto out_err; | 1595 | goto out_err; |
1600 | } | 1596 | } |
1601 | 1597 | ||
1602 | lan_addr = (struct ipmi_lan_addr *) addr; | 1598 | lan_addr = (struct ipmi_lan_addr *) addr; |
1603 | if (lan_addr->lun > 3) { | 1599 | if (lan_addr->lun > 3) { |
1604 | spin_lock_irqsave(&intf->counter_lock, flags); | 1600 | ipmi_inc_stat(intf, sent_invalid_commands); |
1605 | intf->sent_invalid_commands++; | ||
1606 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
1607 | rv = -EINVAL; | 1601 | rv = -EINVAL; |
1608 | goto out_err; | 1602 | goto out_err; |
1609 | } | 1603 | } |
@@ -1613,9 +1607,7 @@ static int i_ipmi_request(ipmi_user_t user, | |||
1613 | if (recv_msg->msg.netfn & 0x1) { | 1607 | if (recv_msg->msg.netfn & 0x1) { |
1614 | /* It's a response, so use the user's sequence | 1608 | /* It's a response, so use the user's sequence |
1615 | from msgid. */ | 1609 | from msgid. */ |
1616 | spin_lock_irqsave(&intf->counter_lock, flags); | 1610 | ipmi_inc_stat(intf, sent_lan_responses); |
1617 | intf->sent_lan_responses++; | ||
1618 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
1619 | format_lan_msg(smi_msg, msg, lan_addr, msgid, | 1611 | format_lan_msg(smi_msg, msg, lan_addr, msgid, |
1620 | msgid, source_lun); | 1612 | msgid, source_lun); |
1621 | 1613 | ||
@@ -1627,9 +1619,7 @@ static int i_ipmi_request(ipmi_user_t user, | |||
1627 | 1619 | ||
1628 | spin_lock_irqsave(&(intf->seq_lock), flags); | 1620 | spin_lock_irqsave(&(intf->seq_lock), flags); |
1629 | 1621 | ||
1630 | spin_lock(&intf->counter_lock); | 1622 | ipmi_inc_stat(intf, sent_lan_commands); |
1631 | intf->sent_lan_commands++; | ||
1632 | spin_unlock(&intf->counter_lock); | ||
1633 | 1623 | ||
1634 | /* Create a sequence number with a 1 second | 1624 | /* Create a sequence number with a 1 second |
1635 | timeout and 4 retries. */ | 1625 | timeout and 4 retries. */ |
@@ -1672,9 +1662,7 @@ static int i_ipmi_request(ipmi_user_t user, | |||
1672 | } | 1662 | } |
1673 | } else { | 1663 | } else { |
1674 | /* Unknown address type. */ | 1664 | /* Unknown address type. */ |
1675 | spin_lock_irqsave(&intf->counter_lock, flags); | 1665 | ipmi_inc_stat(intf, sent_invalid_commands); |
1676 | intf->sent_invalid_commands++; | ||
1677 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
1678 | rv = -EINVAL; | 1666 | rv = -EINVAL; |
1679 | goto out_err; | 1667 | goto out_err; |
1680 | } | 1668 | } |
@@ -1797,7 +1785,7 @@ static int version_file_read_proc(char *page, char **start, off_t off, | |||
1797 | char *out = (char *) page; | 1785 | char *out = (char *) page; |
1798 | ipmi_smi_t intf = data; | 1786 | ipmi_smi_t intf = data; |
1799 | 1787 | ||
1800 | return sprintf(out, "%d.%d\n", | 1788 | return sprintf(out, "%u.%u\n", |
1801 | ipmi_version_major(&intf->bmc->id), | 1789 | ipmi_version_major(&intf->bmc->id), |
1802 | ipmi_version_minor(&intf->bmc->id)); | 1790 | ipmi_version_minor(&intf->bmc->id)); |
1803 | } | 1791 | } |
@@ -1808,58 +1796,58 @@ static int stat_file_read_proc(char *page, char **start, off_t off, | |||
1808 | char *out = (char *) page; | 1796 | char *out = (char *) page; |
1809 | ipmi_smi_t intf = data; | 1797 | ipmi_smi_t intf = data; |
1810 | 1798 | ||
1811 | out += sprintf(out, "sent_invalid_commands: %d\n", | 1799 | out += sprintf(out, "sent_invalid_commands: %u\n", |
1812 | intf->sent_invalid_commands); | 1800 | ipmi_get_stat(intf, sent_invalid_commands)); |
1813 | out += sprintf(out, "sent_local_commands: %d\n", | 1801 | out += sprintf(out, "sent_local_commands: %u\n", |
1814 | intf->sent_local_commands); | 1802 | ipmi_get_stat(intf, sent_local_commands)); |
1815 | out += sprintf(out, "handled_local_responses: %d\n", | 1803 | out += sprintf(out, "handled_local_responses: %u\n", |
1816 | intf->handled_local_responses); | 1804 | ipmi_get_stat(intf, handled_local_responses)); |
1817 | out += sprintf(out, "unhandled_local_responses: %d\n", | 1805 | out += sprintf(out, "unhandled_local_responses: %u\n", |
1818 | intf->unhandled_local_responses); | 1806 | ipmi_get_stat(intf, unhandled_local_responses)); |
1819 | out += sprintf(out, "sent_ipmb_commands: %d\n", | 1807 | out += sprintf(out, "sent_ipmb_commands: %u\n", |
1820 | intf->sent_ipmb_commands); | 1808 | ipmi_get_stat(intf, sent_ipmb_commands)); |
1821 | out += sprintf(out, "sent_ipmb_command_errs: %d\n", | 1809 | out += sprintf(out, "sent_ipmb_command_errs: %u\n", |
1822 | intf->sent_ipmb_command_errs); | 1810 | ipmi_get_stat(intf, sent_ipmb_command_errs)); |
1823 | out += sprintf(out, "retransmitted_ipmb_commands: %d\n", | 1811 | out += sprintf(out, "retransmitted_ipmb_commands: %u\n", |
1824 | intf->retransmitted_ipmb_commands); | 1812 | ipmi_get_stat(intf, retransmitted_ipmb_commands)); |
1825 | out += sprintf(out, "timed_out_ipmb_commands: %d\n", | 1813 | out += sprintf(out, "timed_out_ipmb_commands: %u\n", |
1826 | intf->timed_out_ipmb_commands); | 1814 | ipmi_get_stat(intf, timed_out_ipmb_commands)); |
1827 | out += sprintf(out, "timed_out_ipmb_broadcasts: %d\n", | 1815 | out += sprintf(out, "timed_out_ipmb_broadcasts: %u\n", |
1828 | intf->timed_out_ipmb_broadcasts); | 1816 | ipmi_get_stat(intf, timed_out_ipmb_broadcasts)); |
1829 | out += sprintf(out, "sent_ipmb_responses: %d\n", | 1817 | out += sprintf(out, "sent_ipmb_responses: %u\n", |
1830 | intf->sent_ipmb_responses); | 1818 | ipmi_get_stat(intf, sent_ipmb_responses)); |
1831 | out += sprintf(out, "handled_ipmb_responses: %d\n", | 1819 | out += sprintf(out, "handled_ipmb_responses: %u\n", |
1832 | intf->handled_ipmb_responses); | 1820 | ipmi_get_stat(intf, handled_ipmb_responses)); |
1833 | out += sprintf(out, "invalid_ipmb_responses: %d\n", | 1821 | out += sprintf(out, "invalid_ipmb_responses: %u\n", |
1834 | intf->invalid_ipmb_responses); | 1822 | ipmi_get_stat(intf, invalid_ipmb_responses)); |
1835 | out += sprintf(out, "unhandled_ipmb_responses: %d\n", | 1823 | out += sprintf(out, "unhandled_ipmb_responses: %u\n", |
1836 | intf->unhandled_ipmb_responses); | 1824 | ipmi_get_stat(intf, unhandled_ipmb_responses)); |
1837 | out += sprintf(out, "sent_lan_commands: %d\n", | 1825 | out += sprintf(out, "sent_lan_commands: %u\n", |
1838 | intf->sent_lan_commands); | 1826 | ipmi_get_stat(intf, sent_lan_commands)); |
1839 | out += sprintf(out, "sent_lan_command_errs: %d\n", | 1827 | out += sprintf(out, "sent_lan_command_errs: %u\n", |
1840 | intf->sent_lan_command_errs); | 1828 | ipmi_get_stat(intf, sent_lan_command_errs)); |
1841 | out += sprintf(out, "retransmitted_lan_commands: %d\n", | 1829 | out += sprintf(out, "retransmitted_lan_commands: %u\n", |
1842 | intf->retransmitted_lan_commands); | 1830 | ipmi_get_stat(intf, retransmitted_lan_commands)); |
1843 | out += sprintf(out, "timed_out_lan_commands: %d\n", | 1831 | out += sprintf(out, "timed_out_lan_commands: %u\n", |
1844 | intf->timed_out_lan_commands); | 1832 | ipmi_get_stat(intf, timed_out_lan_commands)); |
1845 | out += sprintf(out, "sent_lan_responses: %d\n", | 1833 | out += sprintf(out, "sent_lan_responses: %u\n", |
1846 | intf->sent_lan_responses); | 1834 | ipmi_get_stat(intf, sent_lan_responses)); |
1847 | out += sprintf(out, "handled_lan_responses: %d\n", | 1835 | out += sprintf(out, "handled_lan_responses: %u\n", |
1848 | intf->handled_lan_responses); | 1836 | ipmi_get_stat(intf, handled_lan_responses)); |
1849 | out += sprintf(out, "invalid_lan_responses: %d\n", | 1837 | out += sprintf(out, "invalid_lan_responses: %u\n", |
1850 | intf->invalid_lan_responses); | 1838 | ipmi_get_stat(intf, invalid_lan_responses)); |
1851 | out += sprintf(out, "unhandled_lan_responses: %d\n", | 1839 | out += sprintf(out, "unhandled_lan_responses: %u\n", |
1852 | intf->unhandled_lan_responses); | 1840 | ipmi_get_stat(intf, unhandled_lan_responses)); |
1853 | out += sprintf(out, "handled_commands: %d\n", | 1841 | out += sprintf(out, "handled_commands: %u\n", |
1854 | intf->handled_commands); | 1842 | ipmi_get_stat(intf, handled_commands)); |
1855 | out += sprintf(out, "invalid_commands: %d\n", | 1843 | out += sprintf(out, "invalid_commands: %u\n", |
1856 | intf->invalid_commands); | 1844 | ipmi_get_stat(intf, invalid_commands)); |
1857 | out += sprintf(out, "unhandled_commands: %d\n", | 1845 | out += sprintf(out, "unhandled_commands: %u\n", |
1858 | intf->unhandled_commands); | 1846 | ipmi_get_stat(intf, unhandled_commands)); |
1859 | out += sprintf(out, "invalid_events: %d\n", | 1847 | out += sprintf(out, "invalid_events: %u\n", |
1860 | intf->invalid_events); | 1848 | ipmi_get_stat(intf, invalid_events)); |
1861 | out += sprintf(out, "events: %d\n", | 1849 | out += sprintf(out, "events: %u\n", |
1862 | intf->events); | 1850 | ipmi_get_stat(intf, events)); |
1863 | 1851 | ||
1864 | return (out - ((char *) page)); | 1852 | return (out - ((char *) page)); |
1865 | } | 1853 | } |
@@ -2695,8 +2683,9 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers, | |||
2695 | spin_lock_init(&intf->maintenance_mode_lock); | 2683 | spin_lock_init(&intf->maintenance_mode_lock); |
2696 | INIT_LIST_HEAD(&intf->cmd_rcvrs); | 2684 | INIT_LIST_HEAD(&intf->cmd_rcvrs); |
2697 | init_waitqueue_head(&intf->waitq); | 2685 | init_waitqueue_head(&intf->waitq); |
2686 | for (i = 0; i < IPMI_NUM_STATS; i++) | ||
2687 | atomic_set(&intf->stats[i], 0); | ||
2698 | 2688 | ||
2699 | spin_lock_init(&intf->counter_lock); | ||
2700 | intf->proc_dir = NULL; | 2689 | intf->proc_dir = NULL; |
2701 | 2690 | ||
2702 | mutex_lock(&smi_watchers_mutex); | 2691 | mutex_lock(&smi_watchers_mutex); |
@@ -2825,16 +2814,13 @@ static int handle_ipmb_get_msg_rsp(ipmi_smi_t intf, | |||
2825 | { | 2814 | { |
2826 | struct ipmi_ipmb_addr ipmb_addr; | 2815 | struct ipmi_ipmb_addr ipmb_addr; |
2827 | struct ipmi_recv_msg *recv_msg; | 2816 | struct ipmi_recv_msg *recv_msg; |
2828 | unsigned long flags; | ||
2829 | 2817 | ||
2830 | 2818 | ||
2831 | /* This is 11, not 10, because the response must contain a | 2819 | /* This is 11, not 10, because the response must contain a |
2832 | * completion code. */ | 2820 | * completion code. */ |
2833 | if (msg->rsp_size < 11) { | 2821 | if (msg->rsp_size < 11) { |
2834 | /* Message not big enough, just ignore it. */ | 2822 | /* Message not big enough, just ignore it. */ |
2835 | spin_lock_irqsave(&intf->counter_lock, flags); | 2823 | ipmi_inc_stat(intf, invalid_ipmb_responses); |
2836 | intf->invalid_ipmb_responses++; | ||
2837 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
2838 | return 0; | 2824 | return 0; |
2839 | } | 2825 | } |
2840 | 2826 | ||
@@ -2860,9 +2846,7 @@ static int handle_ipmb_get_msg_rsp(ipmi_smi_t intf, | |||
2860 | { | 2846 | { |
2861 | /* We were unable to find the sequence number, | 2847 | /* We were unable to find the sequence number, |
2862 | so just nuke the message. */ | 2848 | so just nuke the message. */ |
2863 | spin_lock_irqsave(&intf->counter_lock, flags); | 2849 | ipmi_inc_stat(intf, unhandled_ipmb_responses); |
2864 | intf->unhandled_ipmb_responses++; | ||
2865 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
2866 | return 0; | 2850 | return 0; |
2867 | } | 2851 | } |
2868 | 2852 | ||
@@ -2876,9 +2860,7 @@ static int handle_ipmb_get_msg_rsp(ipmi_smi_t intf, | |||
2876 | recv_msg->msg.data = recv_msg->msg_data; | 2860 | recv_msg->msg.data = recv_msg->msg_data; |
2877 | recv_msg->msg.data_len = msg->rsp_size - 10; | 2861 | recv_msg->msg.data_len = msg->rsp_size - 10; |
2878 | recv_msg->recv_type = IPMI_RESPONSE_RECV_TYPE; | 2862 | recv_msg->recv_type = IPMI_RESPONSE_RECV_TYPE; |
2879 | spin_lock_irqsave(&intf->counter_lock, flags); | 2863 | ipmi_inc_stat(intf, handled_ipmb_responses); |
2880 | intf->handled_ipmb_responses++; | ||
2881 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
2882 | deliver_response(recv_msg); | 2864 | deliver_response(recv_msg); |
2883 | 2865 | ||
2884 | return 0; | 2866 | return 0; |
@@ -2895,14 +2877,11 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf, | |||
2895 | ipmi_user_t user = NULL; | 2877 | ipmi_user_t user = NULL; |
2896 | struct ipmi_ipmb_addr *ipmb_addr; | 2878 | struct ipmi_ipmb_addr *ipmb_addr; |
2897 | struct ipmi_recv_msg *recv_msg; | 2879 | struct ipmi_recv_msg *recv_msg; |
2898 | unsigned long flags; | ||
2899 | struct ipmi_smi_handlers *handlers; | 2880 | struct ipmi_smi_handlers *handlers; |
2900 | 2881 | ||
2901 | if (msg->rsp_size < 10) { | 2882 | if (msg->rsp_size < 10) { |
2902 | /* Message not big enough, just ignore it. */ | 2883 | /* Message not big enough, just ignore it. */ |
2903 | spin_lock_irqsave(&intf->counter_lock, flags); | 2884 | ipmi_inc_stat(intf, invalid_commands); |
2904 | intf->invalid_commands++; | ||
2905 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
2906 | return 0; | 2885 | return 0; |
2907 | } | 2886 | } |
2908 | 2887 | ||
@@ -2926,9 +2905,7 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf, | |||
2926 | 2905 | ||
2927 | if (user == NULL) { | 2906 | if (user == NULL) { |
2928 | /* We didn't find a user, deliver an error response. */ | 2907 | /* We didn't find a user, deliver an error response. */ |
2929 | spin_lock_irqsave(&intf->counter_lock, flags); | 2908 | ipmi_inc_stat(intf, unhandled_commands); |
2930 | intf->unhandled_commands++; | ||
2931 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
2932 | 2909 | ||
2933 | msg->data[0] = (IPMI_NETFN_APP_REQUEST << 2); | 2910 | msg->data[0] = (IPMI_NETFN_APP_REQUEST << 2); |
2934 | msg->data[1] = IPMI_SEND_MSG_CMD; | 2911 | msg->data[1] = IPMI_SEND_MSG_CMD; |
@@ -2965,9 +2942,7 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf, | |||
2965 | rcu_read_unlock(); | 2942 | rcu_read_unlock(); |
2966 | } else { | 2943 | } else { |
2967 | /* Deliver the message to the user. */ | 2944 | /* Deliver the message to the user. */ |
2968 | spin_lock_irqsave(&intf->counter_lock, flags); | 2945 | ipmi_inc_stat(intf, handled_commands); |
2969 | intf->handled_commands++; | ||
2970 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
2971 | 2946 | ||
2972 | recv_msg = ipmi_alloc_recv_msg(); | 2947 | recv_msg = ipmi_alloc_recv_msg(); |
2973 | if (!recv_msg) { | 2948 | if (!recv_msg) { |
@@ -3011,16 +2986,13 @@ static int handle_lan_get_msg_rsp(ipmi_smi_t intf, | |||
3011 | { | 2986 | { |
3012 | struct ipmi_lan_addr lan_addr; | 2987 | struct ipmi_lan_addr lan_addr; |
3013 | struct ipmi_recv_msg *recv_msg; | 2988 | struct ipmi_recv_msg *recv_msg; |
3014 | unsigned long flags; | ||
3015 | 2989 | ||
3016 | 2990 | ||
3017 | /* This is 13, not 12, because the response must contain a | 2991 | /* This is 13, not 12, because the response must contain a |
3018 | * completion code. */ | 2992 | * completion code. */ |
3019 | if (msg->rsp_size < 13) { | 2993 | if (msg->rsp_size < 13) { |
3020 | /* Message not big enough, just ignore it. */ | 2994 | /* Message not big enough, just ignore it. */ |
3021 | spin_lock_irqsave(&intf->counter_lock, flags); | 2995 | ipmi_inc_stat(intf, invalid_lan_responses); |
3022 | intf->invalid_lan_responses++; | ||
3023 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
3024 | return 0; | 2996 | return 0; |
3025 | } | 2997 | } |
3026 | 2998 | ||
@@ -3049,9 +3021,7 @@ static int handle_lan_get_msg_rsp(ipmi_smi_t intf, | |||
3049 | { | 3021 | { |
3050 | /* We were unable to find the sequence number, | 3022 | /* We were unable to find the sequence number, |
3051 | so just nuke the message. */ | 3023 | so just nuke the message. */ |
3052 | spin_lock_irqsave(&intf->counter_lock, flags); | 3024 | ipmi_inc_stat(intf, unhandled_lan_responses); |
3053 | intf->unhandled_lan_responses++; | ||
3054 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
3055 | return 0; | 3025 | return 0; |
3056 | } | 3026 | } |
3057 | 3027 | ||
@@ -3065,9 +3035,7 @@ static int handle_lan_get_msg_rsp(ipmi_smi_t intf, | |||
3065 | recv_msg->msg.data = recv_msg->msg_data; | 3035 | recv_msg->msg.data = recv_msg->msg_data; |
3066 | recv_msg->msg.data_len = msg->rsp_size - 12; | 3036 | recv_msg->msg.data_len = msg->rsp_size - 12; |
3067 | recv_msg->recv_type = IPMI_RESPONSE_RECV_TYPE; | 3037 | recv_msg->recv_type = IPMI_RESPONSE_RECV_TYPE; |
3068 | spin_lock_irqsave(&intf->counter_lock, flags); | 3038 | ipmi_inc_stat(intf, handled_lan_responses); |
3069 | intf->handled_lan_responses++; | ||
3070 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
3071 | deliver_response(recv_msg); | 3039 | deliver_response(recv_msg); |
3072 | 3040 | ||
3073 | return 0; | 3041 | return 0; |
@@ -3084,13 +3052,10 @@ static int handle_lan_get_msg_cmd(ipmi_smi_t intf, | |||
3084 | ipmi_user_t user = NULL; | 3052 | ipmi_user_t user = NULL; |
3085 | struct ipmi_lan_addr *lan_addr; | 3053 | struct ipmi_lan_addr *lan_addr; |
3086 | struct ipmi_recv_msg *recv_msg; | 3054 | struct ipmi_recv_msg *recv_msg; |
3087 | unsigned long flags; | ||
3088 | 3055 | ||
3089 | if (msg->rsp_size < 12) { | 3056 | if (msg->rsp_size < 12) { |
3090 | /* Message not big enough, just ignore it. */ | 3057 | /* Message not big enough, just ignore it. */ |
3091 | spin_lock_irqsave(&intf->counter_lock, flags); | 3058 | ipmi_inc_stat(intf, invalid_commands); |
3092 | intf->invalid_commands++; | ||
3093 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
3094 | return 0; | 3059 | return 0; |
3095 | } | 3060 | } |
3096 | 3061 | ||
@@ -3114,17 +3079,13 @@ static int handle_lan_get_msg_cmd(ipmi_smi_t intf, | |||
3114 | 3079 | ||
3115 | if (user == NULL) { | 3080 | if (user == NULL) { |
3116 | /* We didn't find a user, just give up. */ | 3081 | /* We didn't find a user, just give up. */ |
3117 | spin_lock_irqsave(&intf->counter_lock, flags); | 3082 | ipmi_inc_stat(intf, unhandled_commands); |
3118 | intf->unhandled_commands++; | ||
3119 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
3120 | 3083 | ||
3121 | rv = 0; /* Don't do anything with these messages, just | 3084 | rv = 0; /* Don't do anything with these messages, just |
3122 | allow them to be freed. */ | 3085 | allow them to be freed. */ |
3123 | } else { | 3086 | } else { |
3124 | /* Deliver the message to the user. */ | 3087 | /* Deliver the message to the user. */ |
3125 | spin_lock_irqsave(&intf->counter_lock, flags); | 3088 | ipmi_inc_stat(intf, handled_commands); |
3126 | intf->handled_commands++; | ||
3127 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
3128 | 3089 | ||
3129 | recv_msg = ipmi_alloc_recv_msg(); | 3090 | recv_msg = ipmi_alloc_recv_msg(); |
3130 | if (!recv_msg) { | 3091 | if (!recv_msg) { |
@@ -3196,9 +3157,7 @@ static int handle_read_event_rsp(ipmi_smi_t intf, | |||
3196 | 3157 | ||
3197 | if (msg->rsp_size < 19) { | 3158 | if (msg->rsp_size < 19) { |
3198 | /* Message is too small to be an IPMB event. */ | 3159 | /* Message is too small to be an IPMB event. */ |
3199 | spin_lock_irqsave(&intf->counter_lock, flags); | 3160 | ipmi_inc_stat(intf, invalid_events); |
3200 | intf->invalid_events++; | ||
3201 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
3202 | return 0; | 3161 | return 0; |
3203 | } | 3162 | } |
3204 | 3163 | ||
@@ -3211,9 +3170,7 @@ static int handle_read_event_rsp(ipmi_smi_t intf, | |||
3211 | 3170 | ||
3212 | spin_lock_irqsave(&intf->events_lock, flags); | 3171 | spin_lock_irqsave(&intf->events_lock, flags); |
3213 | 3172 | ||
3214 | spin_lock(&intf->counter_lock); | 3173 | ipmi_inc_stat(intf, events); |
3215 | intf->events++; | ||
3216 | spin_unlock(&intf->counter_lock); | ||
3217 | 3174 | ||
3218 | /* Allocate and fill in one message for every user that is getting | 3175 | /* Allocate and fill in one message for every user that is getting |
3219 | events. */ | 3176 | events. */ |
@@ -3285,7 +3242,6 @@ static int handle_bmc_rsp(ipmi_smi_t intf, | |||
3285 | struct ipmi_smi_msg *msg) | 3242 | struct ipmi_smi_msg *msg) |
3286 | { | 3243 | { |
3287 | struct ipmi_recv_msg *recv_msg; | 3244 | struct ipmi_recv_msg *recv_msg; |
3288 | unsigned long flags; | ||
3289 | struct ipmi_user *user; | 3245 | struct ipmi_user *user; |
3290 | 3246 | ||
3291 | recv_msg = (struct ipmi_recv_msg *) msg->user_data; | 3247 | recv_msg = (struct ipmi_recv_msg *) msg->user_data; |
@@ -3302,16 +3258,12 @@ static int handle_bmc_rsp(ipmi_smi_t intf, | |||
3302 | /* Make sure the user still exists. */ | 3258 | /* Make sure the user still exists. */ |
3303 | if (user && !user->valid) { | 3259 | if (user && !user->valid) { |
3304 | /* The user for the message went away, so give up. */ | 3260 | /* The user for the message went away, so give up. */ |
3305 | spin_lock_irqsave(&intf->counter_lock, flags); | 3261 | ipmi_inc_stat(intf, unhandled_local_responses); |
3306 | intf->unhandled_local_responses++; | ||
3307 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
3308 | ipmi_free_recv_msg(recv_msg); | 3262 | ipmi_free_recv_msg(recv_msg); |
3309 | } else { | 3263 | } else { |
3310 | struct ipmi_system_interface_addr *smi_addr; | 3264 | struct ipmi_system_interface_addr *smi_addr; |
3311 | 3265 | ||
3312 | spin_lock_irqsave(&intf->counter_lock, flags); | 3266 | ipmi_inc_stat(intf, handled_local_responses); |
3313 | intf->handled_local_responses++; | ||
3314 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
3315 | recv_msg->recv_type = IPMI_RESPONSE_RECV_TYPE; | 3267 | recv_msg->recv_type = IPMI_RESPONSE_RECV_TYPE; |
3316 | recv_msg->msgid = msg->msgid; | 3268 | recv_msg->msgid = msg->msgid; |
3317 | smi_addr = ((struct ipmi_system_interface_addr *) | 3269 | smi_addr = ((struct ipmi_system_interface_addr *) |
@@ -3494,17 +3446,15 @@ void ipmi_smi_msg_received(ipmi_smi_t intf, | |||
3494 | int chan = msg->rsp[3] & 0xf; | 3446 | int chan = msg->rsp[3] & 0xf; |
3495 | 3447 | ||
3496 | /* Got an error sending the message, handle it. */ | 3448 | /* Got an error sending the message, handle it. */ |
3497 | spin_lock_irqsave(&intf->counter_lock, flags); | ||
3498 | if (chan >= IPMI_MAX_CHANNELS) | 3449 | if (chan >= IPMI_MAX_CHANNELS) |
3499 | ; /* This shouldn't happen */ | 3450 | ; /* This shouldn't happen */ |
3500 | else if ((intf->channels[chan].medium | 3451 | else if ((intf->channels[chan].medium |
3501 | == IPMI_CHANNEL_MEDIUM_8023LAN) | 3452 | == IPMI_CHANNEL_MEDIUM_8023LAN) |
3502 | || (intf->channels[chan].medium | 3453 | || (intf->channels[chan].medium |
3503 | == IPMI_CHANNEL_MEDIUM_ASYNC)) | 3454 | == IPMI_CHANNEL_MEDIUM_ASYNC)) |
3504 | intf->sent_lan_command_errs++; | 3455 | ipmi_inc_stat(intf, sent_lan_command_errs); |
3505 | else | 3456 | else |
3506 | intf->sent_ipmb_command_errs++; | 3457 | ipmi_inc_stat(intf, sent_ipmb_command_errs); |
3507 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
3508 | intf_err_seq(intf, msg->msgid, msg->rsp[2]); | 3458 | intf_err_seq(intf, msg->msgid, msg->rsp[2]); |
3509 | } else { | 3459 | } else { |
3510 | /* The message was sent, start the timer. */ | 3460 | /* The message was sent, start the timer. */ |
@@ -3610,14 +3560,12 @@ static void check_msg_timeout(ipmi_smi_t intf, struct seq_table *ent, | |||
3610 | ent->inuse = 0; | 3560 | ent->inuse = 0; |
3611 | msg = ent->recv_msg; | 3561 | msg = ent->recv_msg; |
3612 | list_add_tail(&msg->link, timeouts); | 3562 | list_add_tail(&msg->link, timeouts); |
3613 | spin_lock(&intf->counter_lock); | ||
3614 | if (ent->broadcast) | 3563 | if (ent->broadcast) |
3615 | intf->timed_out_ipmb_broadcasts++; | 3564 | ipmi_inc_stat(intf, timed_out_ipmb_broadcasts); |
3616 | else if (ent->recv_msg->addr.addr_type == IPMI_LAN_ADDR_TYPE) | 3565 | else if (ent->recv_msg->addr.addr_type == IPMI_LAN_ADDR_TYPE) |
3617 | intf->timed_out_lan_commands++; | 3566 | ipmi_inc_stat(intf, timed_out_lan_commands); |
3618 | else | 3567 | else |
3619 | intf->timed_out_ipmb_commands++; | 3568 | ipmi_inc_stat(intf, timed_out_ipmb_commands); |
3620 | spin_unlock(&intf->counter_lock); | ||
3621 | } else { | 3569 | } else { |
3622 | struct ipmi_smi_msg *smi_msg; | 3570 | struct ipmi_smi_msg *smi_msg; |
3623 | /* More retries, send again. */ | 3571 | /* More retries, send again. */ |
@@ -3626,12 +3574,10 @@ static void check_msg_timeout(ipmi_smi_t intf, struct seq_table *ent, | |||
3626 | timer after the message is sent. */ | 3574 | timer after the message is sent. */ |
3627 | ent->timeout = MAX_MSG_TIMEOUT; | 3575 | ent->timeout = MAX_MSG_TIMEOUT; |
3628 | ent->retries_left--; | 3576 | ent->retries_left--; |
3629 | spin_lock(&intf->counter_lock); | ||
3630 | if (ent->recv_msg->addr.addr_type == IPMI_LAN_ADDR_TYPE) | 3577 | if (ent->recv_msg->addr.addr_type == IPMI_LAN_ADDR_TYPE) |
3631 | intf->retransmitted_lan_commands++; | 3578 | ipmi_inc_stat(intf, retransmitted_lan_commands); |
3632 | else | 3579 | else |
3633 | intf->retransmitted_ipmb_commands++; | 3580 | ipmi_inc_stat(intf, retransmitted_ipmb_commands); |
3634 | spin_unlock(&intf->counter_lock); | ||
3635 | 3581 | ||
3636 | smi_msg = smi_from_recv_msg(intf, ent->recv_msg, slot, | 3582 | smi_msg = smi_from_recv_msg(intf, ent->recv_msg, slot, |
3637 | ent->seqid); | 3583 | ent->seqid); |