diff options
author | Francois Romieu <romieu@fr.zoreil.com> | 2006-12-11 18:13:48 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-02-05 16:58:43 -0500 |
commit | 834324687d08e0f67b167934cb56406aa98ff8c6 (patch) | |
tree | bafd6715f66bf7ad17bcabb4fabfbeffbddd1538 /drivers/net/chelsio/vsc7326.c | |
parent | 3e0f75be52605a901165fa1d8acf4ffd37a4857b (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/vsc7326.c')
-rw-r--r-- | drivers/net/chelsio/vsc7326.c | 68 |
1 files changed, 37 insertions, 31 deletions
diff --git a/drivers/net/chelsio/vsc7326.c b/drivers/net/chelsio/vsc7326.c index 31a67f522597..534ffa0f616e 100644 --- a/drivers/net/chelsio/vsc7326.c +++ b/drivers/net/chelsio/vsc7326.c | |||
@@ -589,40 +589,46 @@ static void rmon_update(struct cmac *mac, unsigned int addr, u64 *stat) | |||
589 | 589 | ||
590 | static void port_stats_update(struct cmac *mac) | 590 | static void port_stats_update(struct cmac *mac) |
591 | { | 591 | { |
592 | int port = mac->instance->index; | 592 | struct { |
593 | unsigned int reg; | ||
594 | unsigned int offset; | ||
595 | } hw_stats[] = { | ||
596 | |||
597 | #define HW_STAT(reg, stat_name) \ | ||
598 | { reg, (&((struct cmac_statistics *)NULL)->stat_name) - (u64 *)NULL } | ||
599 | |||
600 | /* Rx stats */ | ||
601 | HW_STAT(RxUnicast, RxUnicastFramesOK), | ||
602 | HW_STAT(RxMulticast, RxMulticastFramesOK), | ||
603 | HW_STAT(RxBroadcast, RxBroadcastFramesOK), | ||
604 | HW_STAT(Crc, RxFCSErrors), | ||
605 | HW_STAT(RxAlignment, RxAlignErrors), | ||
606 | HW_STAT(RxOversize, RxFrameTooLongErrors), | ||
607 | HW_STAT(RxPause, RxPauseFrames), | ||
608 | HW_STAT(RxJabbers, RxJabberErrors), | ||
609 | HW_STAT(RxFragments, RxRuntErrors), | ||
610 | HW_STAT(RxUndersize, RxRuntErrors), | ||
611 | HW_STAT(RxSymbolCarrier, RxSymbolErrors), | ||
612 | HW_STAT(RxSize1519ToMax, RxJumboFramesOK), | ||
613 | |||
614 | /* Tx stats (skip collision stats as we are full-duplex only) */ | ||
615 | HW_STAT(TxUnicast, TxUnicastFramesOK), | ||
616 | HW_STAT(TxMulticast, TxMulticastFramesOK), | ||
617 | HW_STAT(TxBroadcast, TxBroadcastFramesOK), | ||
618 | HW_STAT(TxPause, TxPauseFrames), | ||
619 | HW_STAT(TxUnderrun, TxUnderrun), | ||
620 | HW_STAT(TxSize1519ToMax, TxJumboFramesOK), | ||
621 | }, *p = hw_stats; | ||
622 | unsigned int port = mac->instance->index; | ||
623 | u64 *stats = (u64 *)&mac->stats; | ||
624 | unsigned int i; | ||
625 | |||
626 | for (i = 0; i < ARRAY_SIZE(hw_stats); i++) | ||
627 | rmon_update(mac, CRA(0x4, port, p->reg), stats + p->offset); | ||
593 | 628 | ||
594 | /* Rx stats */ | 629 | rmon_update(mac, REG_TX_OK_BYTES(port), &mac->stats.TxOctetsOK); |
595 | rmon_update(mac, REG_RX_OK_BYTES(port), &mac->stats.RxOctetsOK); | 630 | rmon_update(mac, REG_RX_OK_BYTES(port), &mac->stats.RxOctetsOK); |
596 | rmon_update(mac, REG_RX_BAD_BYTES(port), &mac->stats.RxOctetsBad); | 631 | rmon_update(mac, REG_RX_BAD_BYTES(port), &mac->stats.RxOctetsBad); |
597 | rmon_update(mac, REG_RX_UNICAST(port), &mac->stats.RxUnicastFramesOK); | ||
598 | rmon_update(mac, REG_RX_MULTICAST(port), | ||
599 | &mac->stats.RxMulticastFramesOK); | ||
600 | rmon_update(mac, REG_RX_BROADCAST(port), | ||
601 | &mac->stats.RxBroadcastFramesOK); | ||
602 | rmon_update(mac, REG_CRC(port), &mac->stats.RxFCSErrors); | ||
603 | rmon_update(mac, REG_RX_ALIGNMENT(port), &mac->stats.RxAlignErrors); | ||
604 | rmon_update(mac, REG_RX_OVERSIZE(port), | ||
605 | &mac->stats.RxFrameTooLongErrors); | ||
606 | rmon_update(mac, REG_RX_PAUSE(port), &mac->stats.RxPauseFrames); | ||
607 | rmon_update(mac, REG_RX_JABBERS(port), &mac->stats.RxJabberErrors); | ||
608 | rmon_update(mac, REG_RX_FRAGMENTS(port), &mac->stats.RxRuntErrors); | ||
609 | rmon_update(mac, REG_RX_UNDERSIZE(port), &mac->stats.RxRuntErrors); | ||
610 | rmon_update(mac, REG_RX_SYMBOL_CARRIER(port), | ||
611 | &mac->stats.RxSymbolErrors); | ||
612 | rmon_update(mac, REG_RX_SIZE_1519_TO_MAX(port), | ||
613 | &mac->stats.RxJumboFramesOK); | ||
614 | |||
615 | /* Tx stats (skip collision stats as we are full-duplex only) */ | ||
616 | rmon_update(mac, REG_TX_OK_BYTES(port), &mac->stats.TxOctetsOK); | ||
617 | rmon_update(mac, REG_TX_UNICAST(port), &mac->stats.TxUnicastFramesOK); | ||
618 | rmon_update(mac, REG_TX_MULTICAST(port), | ||
619 | &mac->stats.TxMulticastFramesOK); | ||
620 | rmon_update(mac, REG_TX_BROADCAST(port), | ||
621 | &mac->stats.TxBroadcastFramesOK); | ||
622 | rmon_update(mac, REG_TX_PAUSE(port), &mac->stats.TxPauseFrames); | ||
623 | rmon_update(mac, REG_TX_UNDERRUN(port), &mac->stats.TxUnderrun); | ||
624 | rmon_update(mac, REG_TX_SIZE_1519_TO_MAX(port), | ||
625 | &mac->stats.TxJumboFramesOK); | ||
626 | } | 632 | } |
627 | 633 | ||
628 | /* | 634 | /* |