aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Gortmaker <paul.gortmaker@windriver.com>2013-02-12 15:28:35 -0500
committerPaul Gortmaker <paul.gortmaker@windriver.com>2013-02-12 19:07:42 -0500
commit68719786cba169f93b6cb5a53f5dd6ea1bdbb9f3 (patch)
treebb80d64cf352dec80f337924b665974399b0295b
parent0790bbb68f9d483348c1d65381f3dd92602bfd05 (diff)
gianfar: remove largely unused gfar_stats struct
The gfar_stats struct is only used in copying out data via ethtool. It is declared as the extra stats, followed by the rmon stats. However, the rmon stats are never actually ever used in the driver; instead the rmon data is a u32 register read that is cast directly into the ethtool buf. It seems the only reason rmon is in the struct at all is to give the offset(s) at which it should be exported into the ethtool buffer. But note gfar_stats doesn't contain a gfar_extra_stats as a substruct -- instead it contains a u64 array of equal element count. This implicitly means we have two independent declarations of what gfar_extra_stats really is. Rather than have this duality, we already have defines which give us the offset directly, and hence do not need the struct at all. Further, since we know the extra_stats is unconditionally always present, we can write it out to the ethtool buf 1st, and then optionally write out the rmon data. There is no need for two independent loops, both of which are simply copying out the extra_stats to buf offset zero. This also helps pave the way towards allowing the extra stats fields to be converted to atomic64_t values, without having their types directly influencing the ethtool stats export code (gfar_fill_stats) that expects to deal with u64. Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
-rw-r--r--drivers/net/ethernet/freescale/gianfar.h8
-rw-r--r--drivers/net/ethernet/freescale/gianfar_ethtool.c15
2 files changed, 7 insertions, 16 deletions
diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h
index 71793f4fca32..61b1785c9ca7 100644
--- a/drivers/net/ethernet/freescale/gianfar.h
+++ b/drivers/net/ethernet/freescale/gianfar.h
@@ -646,15 +646,9 @@ struct gfar_extra_stats {
646#define GFAR_RMON_LEN ((sizeof(struct rmon_mib) - 16)/sizeof(u32)) 646#define GFAR_RMON_LEN ((sizeof(struct rmon_mib) - 16)/sizeof(u32))
647#define GFAR_EXTRA_STATS_LEN (sizeof(struct gfar_extra_stats)/sizeof(u64)) 647#define GFAR_EXTRA_STATS_LEN (sizeof(struct gfar_extra_stats)/sizeof(u64))
648 648
649/* Number of stats in the stats structure (ignore car and cam regs)*/ 649/* Number of stats exported via ethtool */
650#define GFAR_STATS_LEN (GFAR_RMON_LEN + GFAR_EXTRA_STATS_LEN) 650#define GFAR_STATS_LEN (GFAR_RMON_LEN + GFAR_EXTRA_STATS_LEN)
651 651
652struct gfar_stats {
653 u64 extra[GFAR_EXTRA_STATS_LEN];
654 u64 rmon[GFAR_RMON_LEN];
655};
656
657
658struct gfar { 652struct gfar {
659 u32 tsec_id; /* 0x.000 - Controller ID register */ 653 u32 tsec_id; /* 0x.000 - Controller ID register */
660 u32 tsec_id2; /* 0x.004 - Controller ID2 register */ 654 u32 tsec_id2; /* 0x.004 - Controller ID2 register */
diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
index 45e59d5c071f..172acb923bfb 100644
--- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
@@ -151,18 +151,15 @@ static void gfar_fill_stats(struct net_device *dev, struct ethtool_stats *dummy,
151 struct gfar __iomem *regs = priv->gfargrp[0].regs; 151 struct gfar __iomem *regs = priv->gfargrp[0].regs;
152 u64 *extra = (u64 *) & priv->extra_stats; 152 u64 *extra = (u64 *) & priv->extra_stats;
153 153
154 for (i = 0; i < GFAR_EXTRA_STATS_LEN; i++)
155 buf[i] = extra[i];
156
154 if (priv->device_flags & FSL_GIANFAR_DEV_HAS_RMON) { 157 if (priv->device_flags & FSL_GIANFAR_DEV_HAS_RMON) {
155 u32 __iomem *rmon = (u32 __iomem *) &regs->rmon; 158 u32 __iomem *rmon = (u32 __iomem *) &regs->rmon;
156 struct gfar_stats *stats = (struct gfar_stats *) buf;
157
158 for (i = 0; i < GFAR_RMON_LEN; i++)
159 stats->rmon[i] = (u64) gfar_read(&rmon[i]);
160 159
161 for (i = 0; i < GFAR_EXTRA_STATS_LEN; i++) 160 for (; i < GFAR_STATS_LEN; i++, rmon++)
162 stats->extra[i] = extra[i]; 161 buf[i] = (u64) gfar_read(rmon);
163 } else 162 }
164 for (i = 0; i < GFAR_EXTRA_STATS_LEN; i++)
165 buf[i] = extra[i];
166} 163}
167 164
168static int gfar_sset_count(struct net_device *dev, int sset) 165static int gfar_sset_count(struct net_device *dev, int sset)