aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/chelsio/pm3393.c
diff options
context:
space:
mode:
authorDivy Le Ray <divy@chelsio.com>2007-11-27 16:30:20 -0500
committerJeff Garzik <jeff@garzik.org>2007-12-01 16:32:31 -0500
commite0348b9ae5374f9a24424ae680bcd80724415f60 (patch)
treef6934ec91bc1f4524991232189d40fc5bf765f81 /drivers/net/chelsio/pm3393.c
parent445cf803ca757a5c43f4e11fdfba70355d510841 (diff)
cxgb - fix stats
Fix MAC stats accounting. Fix get_stats. Signed-off-by: Divy Le Ray <divy@chelsio.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/chelsio/pm3393.c')
-rwxr-xr-x[-rw-r--r--]drivers/net/chelsio/pm3393.c112
1 files changed, 45 insertions, 67 deletions
diff --git a/drivers/net/chelsio/pm3393.c b/drivers/net/chelsio/pm3393.c
index 678778a8d133..2117c4fbb107 100644..100755
--- a/drivers/net/chelsio/pm3393.c
+++ b/drivers/net/chelsio/pm3393.c
@@ -45,7 +45,7 @@
45 45
46#include <linux/crc32.h> 46#include <linux/crc32.h>
47 47
48#define OFFSET(REG_ADDR) (REG_ADDR << 2) 48#define OFFSET(REG_ADDR) ((REG_ADDR) << 2)
49 49
50/* Max frame size PM3393 can handle. Includes Ethernet header and CRC. */ 50/* Max frame size PM3393 can handle. Includes Ethernet header and CRC. */
51#define MAX_FRAME_SIZE 9600 51#define MAX_FRAME_SIZE 9600
@@ -428,69 +428,26 @@ static int pm3393_set_speed_duplex_fc(struct cmac *cmac, int speed, int duplex,
428 return 0; 428 return 0;
429} 429}
430 430
431static void pm3393_rmon_update(struct adapter *adapter, u32 offs, u64 *val, 431#define RMON_UPDATE(mac, name, stat_name) \
432 int over) 432{ \
433{ 433 t1_tpi_read((mac)->adapter, OFFSET(name), &val0); \
434 u32 val0, val1, val2; 434 t1_tpi_read((mac)->adapter, OFFSET((name)+1), &val1); \
435 435 t1_tpi_read((mac)->adapter, OFFSET((name)+2), &val2); \
436 t1_tpi_read(adapter, offs, &val0); 436 (mac)->stats.stat_name = (u64)(val0 & 0xffff) | \
437 t1_tpi_read(adapter, offs + 4, &val1); 437 ((u64)(val1 & 0xffff) << 16) | \
438 t1_tpi_read(adapter, offs + 8, &val2); 438 ((u64)(val2 & 0xff) << 32) | \
439 439 ((mac)->stats.stat_name & \
440 *val &= ~0ull << 40; 440 0xffffff0000000000ULL); \
441 *val |= val0 & 0xffff; 441 if (ro & \
442 *val |= (val1 & 0xffff) << 16; 442 (1ULL << ((name - SUNI1x10GEXP_REG_MSTAT_COUNTER_0_LOW) >> 2))) \
443 *val |= (u64)(val2 & 0xff) << 32; 443 (mac)->stats.stat_name += 1ULL << 40; \
444
445 if (over)
446 *val += 1ull << 40;
447} 444}
448 445
449static const struct cmac_statistics *pm3393_update_statistics(struct cmac *mac, 446static const struct cmac_statistics *pm3393_update_statistics(struct cmac *mac,
450 int flag) 447 int flag)
451{ 448{
452 static struct { 449 u64 ro;
453 unsigned int reg; 450 u32 val0, val1, val2, val3;
454 unsigned int offset;
455 } hw_stats [] = {
456
457#define HW_STAT(name, stat_name) \
458 { name, (&((struct cmac_statistics *)NULL)->stat_name) - (u64 *)NULL }
459
460 /* Rx stats */
461 HW_STAT(RxOctetsReceivedOK, RxOctetsOK),
462 HW_STAT(RxUnicastFramesReceivedOK, RxUnicastFramesOK),
463 HW_STAT(RxMulticastFramesReceivedOK, RxMulticastFramesOK),
464 HW_STAT(RxBroadcastFramesReceivedOK, RxBroadcastFramesOK),
465 HW_STAT(RxPAUSEMACCtrlFramesReceived, RxPauseFrames),
466 HW_STAT(RxFrameCheckSequenceErrors, RxFCSErrors),
467 HW_STAT(RxFramesLostDueToInternalMACErrors,
468 RxInternalMACRcvError),
469 HW_STAT(RxSymbolErrors, RxSymbolErrors),
470 HW_STAT(RxInRangeLengthErrors, RxInRangeLengthErrors),
471 HW_STAT(RxFramesTooLongErrors , RxFrameTooLongErrors),
472 HW_STAT(RxJabbers, RxJabberErrors),
473 HW_STAT(RxFragments, RxRuntErrors),
474 HW_STAT(RxUndersizedFrames, RxRuntErrors),
475 HW_STAT(RxJumboFramesReceivedOK, RxJumboFramesOK),
476 HW_STAT(RxJumboOctetsReceivedOK, RxJumboOctetsOK),
477
478 /* Tx stats */
479 HW_STAT(TxOctetsTransmittedOK, TxOctetsOK),
480 HW_STAT(TxFramesLostDueToInternalMACTransmissionError,
481 TxInternalMACXmitError),
482 HW_STAT(TxTransmitSystemError, TxFCSErrors),
483 HW_STAT(TxUnicastFramesTransmittedOK, TxUnicastFramesOK),
484 HW_STAT(TxMulticastFramesTransmittedOK, TxMulticastFramesOK),
485 HW_STAT(TxBroadcastFramesTransmittedOK, TxBroadcastFramesOK),
486 HW_STAT(TxPAUSEMACCtrlFramesTransmitted, TxPauseFrames),
487 HW_STAT(TxJumboFramesReceivedOK, TxJumboFramesOK),
488 HW_STAT(TxJumboOctetsReceivedOK, TxJumboOctetsOK)
489 }, *p = hw_stats;
490 u64 ro;
491 u32 val0, val1, val2, val3;
492 u64 *stats = (u64 *) &mac->stats;
493 unsigned int i;
494 451
495 /* Snap the counters */ 452 /* Snap the counters */
496 pmwrite(mac, SUNI1x10GEXP_REG_MSTAT_CONTROL, 453 pmwrite(mac, SUNI1x10GEXP_REG_MSTAT_CONTROL,
@@ -504,14 +461,35 @@ static const struct cmac_statistics *pm3393_update_statistics(struct cmac *mac,
504 ro = ((u64)val0 & 0xffff) | (((u64)val1 & 0xffff) << 16) | 461 ro = ((u64)val0 & 0xffff) | (((u64)val1 & 0xffff) << 16) |
505 (((u64)val2 & 0xffff) << 32) | (((u64)val3 & 0xffff) << 48); 462 (((u64)val2 & 0xffff) << 32) | (((u64)val3 & 0xffff) << 48);
506 463
507 for (i = 0; i < ARRAY_SIZE(hw_stats); i++) { 464 /* Rx stats */
508 unsigned reg = p->reg - SUNI1x10GEXP_REG_MSTAT_COUNTER_0_LOW; 465 RMON_UPDATE(mac, RxOctetsReceivedOK, RxOctetsOK);
509 466 RMON_UPDATE(mac, RxUnicastFramesReceivedOK, RxUnicastFramesOK);
510 pm3393_rmon_update((mac)->adapter, OFFSET(p->reg), 467 RMON_UPDATE(mac, RxMulticastFramesReceivedOK, RxMulticastFramesOK);
511 stats + p->offset, ro & (reg >> 2)); 468 RMON_UPDATE(mac, RxBroadcastFramesReceivedOK, RxBroadcastFramesOK);
512 } 469 RMON_UPDATE(mac, RxPAUSEMACCtrlFramesReceived, RxPauseFrames);
513 470 RMON_UPDATE(mac, RxFrameCheckSequenceErrors, RxFCSErrors);
514 471 RMON_UPDATE(mac, RxFramesLostDueToInternalMACErrors,
472 RxInternalMACRcvError);
473 RMON_UPDATE(mac, RxSymbolErrors, RxSymbolErrors);
474 RMON_UPDATE(mac, RxInRangeLengthErrors, RxInRangeLengthErrors);
475 RMON_UPDATE(mac, RxFramesTooLongErrors , RxFrameTooLongErrors);
476 RMON_UPDATE(mac, RxJabbers, RxJabberErrors);
477 RMON_UPDATE(mac, RxFragments, RxRuntErrors);
478 RMON_UPDATE(mac, RxUndersizedFrames, RxRuntErrors);
479 RMON_UPDATE(mac, RxJumboFramesReceivedOK, RxJumboFramesOK);
480 RMON_UPDATE(mac, RxJumboOctetsReceivedOK, RxJumboOctetsOK);
481
482 /* Tx stats */
483 RMON_UPDATE(mac, TxOctetsTransmittedOK, TxOctetsOK);
484 RMON_UPDATE(mac, TxFramesLostDueToInternalMACTransmissionError,
485 TxInternalMACXmitError);
486 RMON_UPDATE(mac, TxTransmitSystemError, TxFCSErrors);
487 RMON_UPDATE(mac, TxUnicastFramesTransmittedOK, TxUnicastFramesOK);
488 RMON_UPDATE(mac, TxMulticastFramesTransmittedOK, TxMulticastFramesOK);
489 RMON_UPDATE(mac, TxBroadcastFramesTransmittedOK, TxBroadcastFramesOK);
490 RMON_UPDATE(mac, TxPAUSEMACCtrlFramesTransmitted, TxPauseFrames);
491 RMON_UPDATE(mac, TxJumboFramesReceivedOK, TxJumboFramesOK);
492 RMON_UPDATE(mac, TxJumboOctetsReceivedOK, TxJumboOctetsOK);
515 493
516 return &mac->stats; 494 return &mac->stats;
517} 495}