aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2010-08-24 15:24:07 -0400
committerDavid S. Miller <davem@davemloft.net>2010-08-24 15:24:07 -0400
commitc32d83c0420950754cca01557bc5802793948d66 (patch)
treea3f16d38f5fe28f267a2dda314fb763e11937192
parent6abc2376809497b04feee554240e158ac2072587 (diff)
bcm63xx_enet: use netdev stats
Use integrated net_device stats instead of a private one Get rid of bcm_enet_get_stats() Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/bcm63xx_enet.c60
-rw-r--r--drivers/net/bcm63xx_enet.h1
2 files changed, 27 insertions, 34 deletions
diff --git a/drivers/net/bcm63xx_enet.c b/drivers/net/bcm63xx_enet.c
index 0d2c5da08937..e2f70c3d7be4 100644
--- a/drivers/net/bcm63xx_enet.c
+++ b/drivers/net/bcm63xx_enet.c
@@ -293,22 +293,22 @@ static int bcm_enet_receive_queue(struct net_device *dev, int budget)
293 /* if the packet does not have start of packet _and_ 293 /* if the packet does not have start of packet _and_
294 * end of packet flag set, then just recycle it */ 294 * end of packet flag set, then just recycle it */
295 if ((len_stat & DMADESC_ESOP_MASK) != DMADESC_ESOP_MASK) { 295 if ((len_stat & DMADESC_ESOP_MASK) != DMADESC_ESOP_MASK) {
296 priv->stats.rx_dropped++; 296 dev->stats.rx_dropped++;
297 continue; 297 continue;
298 } 298 }
299 299
300 /* recycle packet if it's marked as bad */ 300 /* recycle packet if it's marked as bad */
301 if (unlikely(len_stat & DMADESC_ERR_MASK)) { 301 if (unlikely(len_stat & DMADESC_ERR_MASK)) {
302 priv->stats.rx_errors++; 302 dev->stats.rx_errors++;
303 303
304 if (len_stat & DMADESC_OVSIZE_MASK) 304 if (len_stat & DMADESC_OVSIZE_MASK)
305 priv->stats.rx_length_errors++; 305 dev->stats.rx_length_errors++;
306 if (len_stat & DMADESC_CRC_MASK) 306 if (len_stat & DMADESC_CRC_MASK)
307 priv->stats.rx_crc_errors++; 307 dev->stats.rx_crc_errors++;
308 if (len_stat & DMADESC_UNDER_MASK) 308 if (len_stat & DMADESC_UNDER_MASK)
309 priv->stats.rx_frame_errors++; 309 dev->stats.rx_frame_errors++;
310 if (len_stat & DMADESC_OV_MASK) 310 if (len_stat & DMADESC_OV_MASK)
311 priv->stats.rx_fifo_errors++; 311 dev->stats.rx_fifo_errors++;
312 continue; 312 continue;
313 } 313 }
314 314
@@ -324,7 +324,7 @@ static int bcm_enet_receive_queue(struct net_device *dev, int budget)
324 nskb = netdev_alloc_skb_ip_align(dev, len); 324 nskb = netdev_alloc_skb_ip_align(dev, len);
325 if (!nskb) { 325 if (!nskb) {
326 /* forget packet, just rearm desc */ 326 /* forget packet, just rearm desc */
327 priv->stats.rx_dropped++; 327 dev->stats.rx_dropped++;
328 continue; 328 continue;
329 } 329 }
330 330
@@ -342,8 +342,8 @@ static int bcm_enet_receive_queue(struct net_device *dev, int budget)
342 342
343 skb_put(skb, len); 343 skb_put(skb, len);
344 skb->protocol = eth_type_trans(skb, dev); 344 skb->protocol = eth_type_trans(skb, dev);
345 priv->stats.rx_packets++; 345 dev->stats.rx_packets++;
346 priv->stats.rx_bytes += len; 346 dev->stats.rx_bytes += len;
347 netif_receive_skb(skb); 347 netif_receive_skb(skb);
348 348
349 } while (--budget > 0); 349 } while (--budget > 0);
@@ -403,7 +403,7 @@ static int bcm_enet_tx_reclaim(struct net_device *dev, int force)
403 spin_unlock(&priv->tx_lock); 403 spin_unlock(&priv->tx_lock);
404 404
405 if (desc->len_stat & DMADESC_UNDER_MASK) 405 if (desc->len_stat & DMADESC_UNDER_MASK)
406 priv->stats.tx_errors++; 406 dev->stats.tx_errors++;
407 407
408 dev_kfree_skb(skb); 408 dev_kfree_skb(skb);
409 released++; 409 released++;
@@ -563,8 +563,8 @@ static int bcm_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
563 if (!priv->tx_desc_count) 563 if (!priv->tx_desc_count)
564 netif_stop_queue(dev); 564 netif_stop_queue(dev);
565 565
566 priv->stats.tx_bytes += skb->len; 566 dev->stats.tx_bytes += skb->len;
567 priv->stats.tx_packets++; 567 dev->stats.tx_packets++;
568 ret = NETDEV_TX_OK; 568 ret = NETDEV_TX_OK;
569 569
570out_unlock: 570out_unlock:
@@ -1141,17 +1141,6 @@ static int bcm_enet_stop(struct net_device *dev)
1141} 1141}
1142 1142
1143/* 1143/*
1144 * core request to return device rx/tx stats
1145 */
1146static struct net_device_stats *bcm_enet_get_stats(struct net_device *dev)
1147{
1148 struct bcm_enet_priv *priv;
1149
1150 priv = netdev_priv(dev);
1151 return &priv->stats;
1152}
1153
1154/*
1155 * ethtool callbacks 1144 * ethtool callbacks
1156 */ 1145 */
1157struct bcm_enet_stats { 1146struct bcm_enet_stats {
@@ -1163,16 +1152,18 @@ struct bcm_enet_stats {
1163 1152
1164#define GEN_STAT(m) sizeof(((struct bcm_enet_priv *)0)->m), \ 1153#define GEN_STAT(m) sizeof(((struct bcm_enet_priv *)0)->m), \
1165 offsetof(struct bcm_enet_priv, m) 1154 offsetof(struct bcm_enet_priv, m)
1155#define DEV_STAT(m) sizeof(((struct net_device_stats *)0)->m), \
1156 offsetof(struct net_device_stats, m)
1166 1157
1167static const struct bcm_enet_stats bcm_enet_gstrings_stats[] = { 1158static const struct bcm_enet_stats bcm_enet_gstrings_stats[] = {
1168 { "rx_packets", GEN_STAT(stats.rx_packets), -1 }, 1159 { "rx_packets", DEV_STAT(rx_packets), -1 },
1169 { "tx_packets", GEN_STAT(stats.tx_packets), -1 }, 1160 { "tx_packets", DEV_STAT(tx_packets), -1 },
1170 { "rx_bytes", GEN_STAT(stats.rx_bytes), -1 }, 1161 { "rx_bytes", DEV_STAT(rx_bytes), -1 },
1171 { "tx_bytes", GEN_STAT(stats.tx_bytes), -1 }, 1162 { "tx_bytes", DEV_STAT(tx_bytes), -1 },
1172 { "rx_errors", GEN_STAT(stats.rx_errors), -1 }, 1163 { "rx_errors", DEV_STAT(rx_errors), -1 },
1173 { "tx_errors", GEN_STAT(stats.tx_errors), -1 }, 1164 { "tx_errors", DEV_STAT(tx_errors), -1 },
1174 { "rx_dropped", GEN_STAT(stats.rx_dropped), -1 }, 1165 { "rx_dropped", DEV_STAT(rx_dropped), -1 },
1175 { "tx_dropped", GEN_STAT(stats.tx_dropped), -1 }, 1166 { "tx_dropped", DEV_STAT(tx_dropped), -1 },
1176 1167
1177 { "rx_good_octets", GEN_STAT(mib.rx_gd_octets), ETH_MIB_RX_GD_OCTETS}, 1168 { "rx_good_octets", GEN_STAT(mib.rx_gd_octets), ETH_MIB_RX_GD_OCTETS},
1178 { "rx_good_pkts", GEN_STAT(mib.rx_gd_pkts), ETH_MIB_RX_GD_PKTS }, 1169 { "rx_good_pkts", GEN_STAT(mib.rx_gd_pkts), ETH_MIB_RX_GD_PKTS },
@@ -1328,7 +1319,11 @@ static void bcm_enet_get_ethtool_stats(struct net_device *netdev,
1328 char *p; 1319 char *p;
1329 1320
1330 s = &bcm_enet_gstrings_stats[i]; 1321 s = &bcm_enet_gstrings_stats[i];
1331 p = (char *)priv + s->stat_offset; 1322 if (s->mib_reg == -1)
1323 p = (char *)&netdev->stats;
1324 else
1325 p = (char *)priv;
1326 p += s->stat_offset;
1332 data[i] = (s->sizeof_stat == sizeof(u64)) ? 1327 data[i] = (s->sizeof_stat == sizeof(u64)) ?
1333 *(u64 *)p : *(u32 *)p; 1328 *(u64 *)p : *(u32 *)p;
1334 } 1329 }
@@ -1605,7 +1600,6 @@ static const struct net_device_ops bcm_enet_ops = {
1605 .ndo_open = bcm_enet_open, 1600 .ndo_open = bcm_enet_open,
1606 .ndo_stop = bcm_enet_stop, 1601 .ndo_stop = bcm_enet_stop,
1607 .ndo_start_xmit = bcm_enet_start_xmit, 1602 .ndo_start_xmit = bcm_enet_start_xmit,
1608 .ndo_get_stats = bcm_enet_get_stats,
1609 .ndo_set_mac_address = bcm_enet_set_mac_address, 1603 .ndo_set_mac_address = bcm_enet_set_mac_address,
1610 .ndo_set_multicast_list = bcm_enet_set_multicast_list, 1604 .ndo_set_multicast_list = bcm_enet_set_multicast_list,
1611 .ndo_do_ioctl = bcm_enet_ioctl, 1605 .ndo_do_ioctl = bcm_enet_ioctl,
diff --git a/drivers/net/bcm63xx_enet.h b/drivers/net/bcm63xx_enet.h
index bd3684d42d74..0e3048b788c2 100644
--- a/drivers/net/bcm63xx_enet.h
+++ b/drivers/net/bcm63xx_enet.h
@@ -274,7 +274,6 @@ struct bcm_enet_priv {
274 int pause_tx; 274 int pause_tx;
275 275
276 /* stats */ 276 /* stats */
277 struct net_device_stats stats;
278 struct bcm_enet_mib_counters mib; 277 struct bcm_enet_mib_counters mib;
279 278
280 /* after mib interrupt, mib registers update is done in this 279 /* after mib interrupt, mib registers update is done in this