aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorJamie Iles <jamie@jamieiles.com>2011-03-09 11:26:35 -0500
committerJamie Iles <jamie@jamieiles.com>2011-11-22 10:21:19 -0500
commita494ed8e25759f05f5a419d675f198e4359ef6fc (patch)
tree2eea29ca18468e7e7c4d25abd6d40117ecd7a98e /drivers/net
parent70c9f3d4372ffa90775603e9c4e055a26a9b83e1 (diff)
macb: support statistics for GEM devices
GEM devices have a different number of statistics registers and they are at a different offset to MACB devices. Make the statistics collection method dependent on device type. Signed-off-by: Jamie Iles <jamie@jamieiles.com> Acked-by: David S. Miller <davem@davemloft.net> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Tested-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ethernet/cadence/macb.c57
-rw-r--r--drivers/net/ethernet/cadence/macb.h54
2 files changed, 107 insertions, 4 deletions
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index c5c3eb450c1b..6a7d3eae8cc7 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -285,8 +285,8 @@ err_out:
285static void macb_update_stats(struct macb *bp) 285static void macb_update_stats(struct macb *bp)
286{ 286{
287 u32 __iomem *reg = bp->regs + MACB_PFR; 287 u32 __iomem *reg = bp->regs + MACB_PFR;
288 u32 *p = &bp->hw_stats.rx_pause_frames; 288 u32 *p = &bp->hw_stats.macb.rx_pause_frames;
289 u32 *end = &bp->hw_stats.tx_pause_frames + 1; 289 u32 *end = &bp->hw_stats.macb.tx_pause_frames + 1;
290 290
291 WARN_ON((unsigned long)(end - p - 1) != (MACB_TPF - MACB_PFR) / 4); 291 WARN_ON((unsigned long)(end - p - 1) != (MACB_TPF - MACB_PFR) / 4);
292 292
@@ -1042,11 +1042,62 @@ static int macb_close(struct net_device *dev)
1042 return 0; 1042 return 0;
1043} 1043}
1044 1044
1045static void gem_update_stats(struct macb *bp)
1046{
1047 u32 __iomem *reg = bp->regs + GEM_OTX;
1048 u32 *p = &bp->hw_stats.gem.tx_octets_31_0;
1049 u32 *end = &bp->hw_stats.gem.rx_udp_checksum_errors + 1;
1050
1051 for (; p < end; p++, reg++)
1052 *p += __raw_readl(reg);
1053}
1054
1055static struct net_device_stats *gem_get_stats(struct macb *bp)
1056{
1057 struct gem_stats *hwstat = &bp->hw_stats.gem;
1058 struct net_device_stats *nstat = &bp->stats;
1059
1060 gem_update_stats(bp);
1061
1062 nstat->rx_errors = (hwstat->rx_frame_check_sequence_errors +
1063 hwstat->rx_alignment_errors +
1064 hwstat->rx_resource_errors +
1065 hwstat->rx_overruns +
1066 hwstat->rx_oversize_frames +
1067 hwstat->rx_jabbers +
1068 hwstat->rx_undersized_frames +
1069 hwstat->rx_length_field_frame_errors);
1070 nstat->tx_errors = (hwstat->tx_late_collisions +
1071 hwstat->tx_excessive_collisions +
1072 hwstat->tx_underrun +
1073 hwstat->tx_carrier_sense_errors);
1074 nstat->multicast = hwstat->rx_multicast_frames;
1075 nstat->collisions = (hwstat->tx_single_collision_frames +
1076 hwstat->tx_multiple_collision_frames +
1077 hwstat->tx_excessive_collisions);
1078 nstat->rx_length_errors = (hwstat->rx_oversize_frames +
1079 hwstat->rx_jabbers +
1080 hwstat->rx_undersized_frames +
1081 hwstat->rx_length_field_frame_errors);
1082 nstat->rx_over_errors = hwstat->rx_resource_errors;
1083 nstat->rx_crc_errors = hwstat->rx_frame_check_sequence_errors;
1084 nstat->rx_frame_errors = hwstat->rx_alignment_errors;
1085 nstat->rx_fifo_errors = hwstat->rx_overruns;
1086 nstat->tx_aborted_errors = hwstat->tx_excessive_collisions;
1087 nstat->tx_carrier_errors = hwstat->tx_carrier_sense_errors;
1088 nstat->tx_fifo_errors = hwstat->tx_underrun;
1089
1090 return nstat;
1091}
1092
1045static struct net_device_stats *macb_get_stats(struct net_device *dev) 1093static struct net_device_stats *macb_get_stats(struct net_device *dev)
1046{ 1094{
1047 struct macb *bp = netdev_priv(dev); 1095 struct macb *bp = netdev_priv(dev);
1048 struct net_device_stats *nstat = &bp->stats; 1096 struct net_device_stats *nstat = &bp->stats;
1049 struct macb_stats *hwstat = &bp->hw_stats; 1097 struct macb_stats *hwstat = &bp->hw_stats.macb;
1098
1099 if (macb_is_gem(bp))
1100 return gem_get_stats(bp);
1050 1101
1051 /* read stats from hardware */ 1102 /* read stats from hardware */
1052 macb_update_stats(bp); 1103 macb_update_stats(bp);
diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
index 354ed8f77884..1367b92edb3d 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -68,6 +68,7 @@
68#define GEM_HRT 0x0084 68#define GEM_HRT 0x0084
69#define GEM_SA1B 0x0088 69#define GEM_SA1B 0x0088
70#define GEM_SA1T 0x008C 70#define GEM_SA1T 0x008C
71#define GEM_OTX 0x0100
71 72
72/* Bitfields in NCR */ 73/* Bitfields in NCR */
73#define MACB_LB_OFFSET 0 74#define MACB_LB_OFFSET 0
@@ -425,6 +426,54 @@ struct macb_stats {
425 u32 tx_pause_frames; 426 u32 tx_pause_frames;
426}; 427};
427 428
429struct gem_stats {
430 u32 tx_octets_31_0;
431 u32 tx_octets_47_32;
432 u32 tx_frames;
433 u32 tx_broadcast_frames;
434 u32 tx_multicast_frames;
435 u32 tx_pause_frames;
436 u32 tx_64_byte_frames;
437 u32 tx_65_127_byte_frames;
438 u32 tx_128_255_byte_frames;
439 u32 tx_256_511_byte_frames;
440 u32 tx_512_1023_byte_frames;
441 u32 tx_1024_1518_byte_frames;
442 u32 tx_greater_than_1518_byte_frames;
443 u32 tx_underrun;
444 u32 tx_single_collision_frames;
445 u32 tx_multiple_collision_frames;
446 u32 tx_excessive_collisions;
447 u32 tx_late_collisions;
448 u32 tx_deferred_frames;
449 u32 tx_carrier_sense_errors;
450 u32 rx_octets_31_0;
451 u32 rx_octets_47_32;
452 u32 rx_frames;
453 u32 rx_broadcast_frames;
454 u32 rx_multicast_frames;
455 u32 rx_pause_frames;
456 u32 rx_64_byte_frames;
457 u32 rx_65_127_byte_frames;
458 u32 rx_128_255_byte_frames;
459 u32 rx_256_511_byte_frames;
460 u32 rx_512_1023_byte_frames;
461 u32 rx_1024_1518_byte_frames;
462 u32 rx_greater_than_1518_byte_frames;
463 u32 rx_undersized_frames;
464 u32 rx_oversize_frames;
465 u32 rx_jabbers;
466 u32 rx_frame_check_sequence_errors;
467 u32 rx_length_field_frame_errors;
468 u32 rx_symbol_errors;
469 u32 rx_alignment_errors;
470 u32 rx_resource_errors;
471 u32 rx_overruns;
472 u32 rx_ip_header_checksum_errors;
473 u32 rx_tcp_checksum_errors;
474 u32 rx_udp_checksum_errors;
475};
476
428struct macb { 477struct macb {
429 void __iomem *regs; 478 void __iomem *regs;
430 479
@@ -443,7 +492,10 @@ struct macb {
443 struct net_device *dev; 492 struct net_device *dev;
444 struct napi_struct napi; 493 struct napi_struct napi;
445 struct net_device_stats stats; 494 struct net_device_stats stats;
446 struct macb_stats hw_stats; 495 union {
496 struct macb_stats macb;
497 struct gem_stats gem;
498 } hw_stats;
447 499
448 dma_addr_t rx_ring_dma; 500 dma_addr_t rx_ring_dma;
449 dma_addr_t tx_ring_dma; 501 dma_addr_t tx_ring_dma;