aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/chelsio/pm3393.c
diff options
context:
space:
mode:
authorFrancois Romieu <romieu@fr.zoreil.com>2006-12-11 18:13:48 -0500
committerJeff Garzik <jeff@garzik.org>2007-02-05 16:58:43 -0500
commit834324687d08e0f67b167934cb56406aa98ff8c6 (patch)
treebafd6715f66bf7ad17bcabb4fabfbeffbddd1538 /drivers/net/chelsio/pm3393.c
parent3e0f75be52605a901165fa1d8acf4ffd37a4857b (diff)
chelsio: tabulate the update of the statistic counters
Let's try to avoid some code duplication. - cxgb2 The data are contiguous. Use plain memcpy. - ixf1010/pm3393/vsc7326 The cast of &mac->stats to (u64 *) is not wonderful but it is not clear if it is worth to add an ad-hoc union under the struct cmac_statistics. vsc7326_reg.h suggests that more statistics could be available. Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Diffstat (limited to 'drivers/net/chelsio/pm3393.c')
-rw-r--r--drivers/net/chelsio/pm3393.c83
1 files changed, 48 insertions, 35 deletions
diff --git a/drivers/net/chelsio/pm3393.c b/drivers/net/chelsio/pm3393.c
index 76a7ca9e0947..69129edeefd6 100644
--- a/drivers/net/chelsio/pm3393.c
+++ b/drivers/net/chelsio/pm3393.c
@@ -446,17 +446,51 @@ static void pm3393_rmon_update(struct adapter *adapter, u32 offs, u64 *val,
446 *val += 1ull << 40; 446 *val += 1ull << 40;
447} 447}
448 448
449#define RMON_UPDATE(mac, name, stat_name) \
450 pm3393_rmon_update((mac)->adapter, OFFSET(name), \
451 &(mac)->stats.stat_name, \
452 (ro &((name - SUNI1x10GEXP_REG_MSTAT_COUNTER_0_LOW) >> 2)))
453
454
455static const struct cmac_statistics *pm3393_update_statistics(struct cmac *mac, 449static const struct cmac_statistics *pm3393_update_statistics(struct cmac *mac,
456 int flag) 450 int flag)
457{ 451{
452 static struct {
453 unsigned int reg;
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;
458 u64 ro; 490 u64 ro;
459 u32 val0, val1, val2, val3; 491 u32 val0, val1, val2, val3;
492 u64 *stats = (u64 *) &mac->stats;
493 unsigned int i;
460 494
461 /* Snap the counters */ 495 /* Snap the counters */
462 pmwrite(mac, SUNI1x10GEXP_REG_MSTAT_CONTROL, 496 pmwrite(mac, SUNI1x10GEXP_REG_MSTAT_CONTROL,
@@ -470,35 +504,14 @@ static const struct cmac_statistics *pm3393_update_statistics(struct cmac *mac,
470 ro = ((u64)val0 & 0xffff) | (((u64)val1 & 0xffff) << 16) | 504 ro = ((u64)val0 & 0xffff) | (((u64)val1 & 0xffff) << 16) |
471 (((u64)val2 & 0xffff) << 32) | (((u64)val3 & 0xffff) << 48); 505 (((u64)val2 & 0xffff) << 32) | (((u64)val3 & 0xffff) << 48);
472 506
473 /* Rx stats */ 507 for (i = 0; i < ARRAY_SIZE(hw_stats); i++) {
474 RMON_UPDATE(mac, RxOctetsReceivedOK, RxOctetsOK); 508 unsigned reg = p->reg - SUNI1x10GEXP_REG_MSTAT_COUNTER_0_LOW;
475 RMON_UPDATE(mac, RxUnicastFramesReceivedOK, RxUnicastFramesOK); 509
476 RMON_UPDATE(mac, RxMulticastFramesReceivedOK, RxMulticastFramesOK); 510 pm3393_rmon_update((mac)->adapter, OFFSET(p->reg),
477 RMON_UPDATE(mac, RxBroadcastFramesReceivedOK, RxBroadcastFramesOK); 511 stats + p->offset, ro & (reg >> 2));
478 RMON_UPDATE(mac, RxPAUSEMACCtrlFramesReceived, RxPauseFrames); 512 }
479 RMON_UPDATE(mac, RxFrameCheckSequenceErrors, RxFCSErrors); 513
480 RMON_UPDATE(mac, RxFramesLostDueToInternalMACErrors, 514
481 RxInternalMACRcvError);
482 RMON_UPDATE(mac, RxSymbolErrors, RxSymbolErrors);
483 RMON_UPDATE(mac, RxInRangeLengthErrors, RxInRangeLengthErrors);
484 RMON_UPDATE(mac, RxFramesTooLongErrors , RxFrameTooLongErrors);
485 RMON_UPDATE(mac, RxJabbers, RxJabberErrors);
486 RMON_UPDATE(mac, RxFragments, RxRuntErrors);
487 RMON_UPDATE(mac, RxUndersizedFrames, RxRuntErrors);
488 RMON_UPDATE(mac, RxJumboFramesReceivedOK, RxJumboFramesOK);
489 RMON_UPDATE(mac, RxJumboOctetsReceivedOK, RxJumboOctetsOK);
490
491 /* Tx stats */
492 RMON_UPDATE(mac, TxOctetsTransmittedOK, TxOctetsOK);
493 RMON_UPDATE(mac, TxFramesLostDueToInternalMACTransmissionError,
494 TxInternalMACXmitError);
495 RMON_UPDATE(mac, TxTransmitSystemError, TxFCSErrors);
496 RMON_UPDATE(mac, TxUnicastFramesTransmittedOK, TxUnicastFramesOK);
497 RMON_UPDATE(mac, TxMulticastFramesTransmittedOK, TxMulticastFramesOK);
498 RMON_UPDATE(mac, TxBroadcastFramesTransmittedOK, TxBroadcastFramesOK);
499 RMON_UPDATE(mac, TxPAUSEMACCtrlFramesTransmitted, TxPauseFrames);
500 RMON_UPDATE(mac, TxJumboFramesReceivedOK, TxJumboFramesOK);
501 RMON_UPDATE(mac, TxJumboOctetsReceivedOK, TxJumboOctetsOK);
502 515
503 return &mac->stats; 516 return &mac->stats;
504} 517}