diff options
author | Jeff Garzik <jeff@garzik.org> | 2007-10-03 20:41:50 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:51:16 -0400 |
commit | 09f75cd7bf13720738e6a196cc0107ce9a5bd5a0 (patch) | |
tree | 4c85b0b395abe7f88c87162fc22570e5de255cb1 /drivers/net/gianfar.c | |
parent | ff8ac60948ba819b89e9c87083e8050fc2f89999 (diff) |
[NET] drivers/net: statistics cleanup #1 -- save memory and shrink code
We now have struct net_device_stats embedded in struct net_device,
and the default ->get_stats() hook does the obvious thing for us.
Run through drivers/net/* and remove the driver-local storage of
statistics, and driver-local ->get_stats() hook where applicable.
This was just the low-hanging fruit in drivers/net; plenty more drivers
remain to be updated.
[ Resolved conflicts with napi_struct changes and fix sunqe build
regression... -DaveM ]
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/gianfar.c')
-rw-r--r-- | drivers/net/gianfar.c | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index 002f8baaab2d..5a1a1165b48c 100644 --- a/drivers/net/gianfar.c +++ b/drivers/net/gianfar.c | |||
@@ -116,7 +116,6 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev); | |||
116 | static void gfar_timeout(struct net_device *dev); | 116 | static void gfar_timeout(struct net_device *dev); |
117 | static int gfar_close(struct net_device *dev); | 117 | static int gfar_close(struct net_device *dev); |
118 | struct sk_buff *gfar_new_skb(struct net_device *dev, struct rxbd8 *bdp); | 118 | struct sk_buff *gfar_new_skb(struct net_device *dev, struct rxbd8 *bdp); |
119 | static struct net_device_stats *gfar_get_stats(struct net_device *dev); | ||
120 | static int gfar_set_mac_address(struct net_device *dev); | 119 | static int gfar_set_mac_address(struct net_device *dev); |
121 | static int gfar_change_mtu(struct net_device *dev, int new_mtu); | 120 | static int gfar_change_mtu(struct net_device *dev, int new_mtu); |
122 | static irqreturn_t gfar_error(int irq, void *dev_id); | 121 | static irqreturn_t gfar_error(int irq, void *dev_id); |
@@ -266,7 +265,6 @@ static int gfar_probe(struct platform_device *pdev) | |||
266 | dev->poll_controller = gfar_netpoll; | 265 | dev->poll_controller = gfar_netpoll; |
267 | #endif | 266 | #endif |
268 | dev->stop = gfar_close; | 267 | dev->stop = gfar_close; |
269 | dev->get_stats = gfar_get_stats; | ||
270 | dev->change_mtu = gfar_change_mtu; | 268 | dev->change_mtu = gfar_change_mtu; |
271 | dev->mtu = 1500; | 269 | dev->mtu = 1500; |
272 | dev->set_multicast_list = gfar_set_multi; | 270 | dev->set_multicast_list = gfar_set_multi; |
@@ -1013,7 +1011,7 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1013 | unsigned long flags; | 1011 | unsigned long flags; |
1014 | 1012 | ||
1015 | /* Update transmit stats */ | 1013 | /* Update transmit stats */ |
1016 | priv->stats.tx_bytes += skb->len; | 1014 | dev->stats.tx_bytes += skb->len; |
1017 | 1015 | ||
1018 | /* Lock priv now */ | 1016 | /* Lock priv now */ |
1019 | spin_lock_irqsave(&priv->txlock, flags); | 1017 | spin_lock_irqsave(&priv->txlock, flags); |
@@ -1086,7 +1084,7 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1086 | if (txbdp == priv->dirty_tx) { | 1084 | if (txbdp == priv->dirty_tx) { |
1087 | netif_stop_queue(dev); | 1085 | netif_stop_queue(dev); |
1088 | 1086 | ||
1089 | priv->stats.tx_fifo_errors++; | 1087 | dev->stats.tx_fifo_errors++; |
1090 | } | 1088 | } |
1091 | 1089 | ||
1092 | /* Update the current txbd to the next one */ | 1090 | /* Update the current txbd to the next one */ |
@@ -1119,14 +1117,6 @@ static int gfar_close(struct net_device *dev) | |||
1119 | return 0; | 1117 | return 0; |
1120 | } | 1118 | } |
1121 | 1119 | ||
1122 | /* returns a net_device_stats structure pointer */ | ||
1123 | static struct net_device_stats * gfar_get_stats(struct net_device *dev) | ||
1124 | { | ||
1125 | struct gfar_private *priv = netdev_priv(dev); | ||
1126 | |||
1127 | return &(priv->stats); | ||
1128 | } | ||
1129 | |||
1130 | /* Changes the mac address if the controller is not running. */ | 1120 | /* Changes the mac address if the controller is not running. */ |
1131 | int gfar_set_mac_address(struct net_device *dev) | 1121 | int gfar_set_mac_address(struct net_device *dev) |
1132 | { | 1122 | { |
@@ -1238,7 +1228,7 @@ static void gfar_timeout(struct net_device *dev) | |||
1238 | { | 1228 | { |
1239 | struct gfar_private *priv = netdev_priv(dev); | 1229 | struct gfar_private *priv = netdev_priv(dev); |
1240 | 1230 | ||
1241 | priv->stats.tx_errors++; | 1231 | dev->stats.tx_errors++; |
1242 | 1232 | ||
1243 | if (dev->flags & IFF_UP) { | 1233 | if (dev->flags & IFF_UP) { |
1244 | stop_gfar(dev); | 1234 | stop_gfar(dev); |
@@ -1268,12 +1258,12 @@ static irqreturn_t gfar_transmit(int irq, void *dev_id) | |||
1268 | if ((bdp == priv->cur_tx) && (netif_queue_stopped(dev) == 0)) | 1258 | if ((bdp == priv->cur_tx) && (netif_queue_stopped(dev) == 0)) |
1269 | break; | 1259 | break; |
1270 | 1260 | ||
1271 | priv->stats.tx_packets++; | 1261 | dev->stats.tx_packets++; |
1272 | 1262 | ||
1273 | /* Deferred means some collisions occurred during transmit, */ | 1263 | /* Deferred means some collisions occurred during transmit, */ |
1274 | /* but we eventually sent the packet. */ | 1264 | /* but we eventually sent the packet. */ |
1275 | if (bdp->status & TXBD_DEF) | 1265 | if (bdp->status & TXBD_DEF) |
1276 | priv->stats.collisions++; | 1266 | dev->stats.collisions++; |
1277 | 1267 | ||
1278 | /* Free the sk buffer associated with this TxBD */ | 1268 | /* Free the sk buffer associated with this TxBD */ |
1279 | dev_kfree_skb_irq(priv->tx_skbuff[priv->skb_dirtytx]); | 1269 | dev_kfree_skb_irq(priv->tx_skbuff[priv->skb_dirtytx]); |
@@ -1345,7 +1335,7 @@ struct sk_buff * gfar_new_skb(struct net_device *dev, struct rxbd8 *bdp) | |||
1345 | 1335 | ||
1346 | static inline void count_errors(unsigned short status, struct gfar_private *priv) | 1336 | static inline void count_errors(unsigned short status, struct gfar_private *priv) |
1347 | { | 1337 | { |
1348 | struct net_device_stats *stats = &priv->stats; | 1338 | struct net_device_stats *stats = &dev->stats; |
1349 | struct gfar_extra_stats *estats = &priv->extra_stats; | 1339 | struct gfar_extra_stats *estats = &priv->extra_stats; |
1350 | 1340 | ||
1351 | /* If the packet was truncated, none of the other errors | 1341 | /* If the packet was truncated, none of the other errors |
@@ -1470,7 +1460,7 @@ static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb, | |||
1470 | if (NULL == skb) { | 1460 | if (NULL == skb) { |
1471 | if (netif_msg_rx_err(priv)) | 1461 | if (netif_msg_rx_err(priv)) |
1472 | printk(KERN_WARNING "%s: Missing skb!!.\n", dev->name); | 1462 | printk(KERN_WARNING "%s: Missing skb!!.\n", dev->name); |
1473 | priv->stats.rx_dropped++; | 1463 | dev->stats.rx_dropped++; |
1474 | priv->extra_stats.rx_skbmissing++; | 1464 | priv->extra_stats.rx_skbmissing++; |
1475 | } else { | 1465 | } else { |
1476 | int ret; | 1466 | int ret; |
@@ -1528,7 +1518,7 @@ int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit) | |||
1528 | (RXBD_LARGE | RXBD_SHORT | RXBD_NONOCTET | 1518 | (RXBD_LARGE | RXBD_SHORT | RXBD_NONOCTET |
1529 | | RXBD_CRCERR | RXBD_OVERRUN | RXBD_TRUNCATED))) { | 1519 | | RXBD_CRCERR | RXBD_OVERRUN | RXBD_TRUNCATED))) { |
1530 | /* Increment the number of packets */ | 1520 | /* Increment the number of packets */ |
1531 | priv->stats.rx_packets++; | 1521 | dev->stats.rx_packets++; |
1532 | howmany++; | 1522 | howmany++; |
1533 | 1523 | ||
1534 | /* Remove the FCS from the packet length */ | 1524 | /* Remove the FCS from the packet length */ |
@@ -1536,7 +1526,7 @@ int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit) | |||
1536 | 1526 | ||
1537 | gfar_process_frame(dev, skb, pkt_len); | 1527 | gfar_process_frame(dev, skb, pkt_len); |
1538 | 1528 | ||
1539 | priv->stats.rx_bytes += pkt_len; | 1529 | dev->stats.rx_bytes += pkt_len; |
1540 | } else { | 1530 | } else { |
1541 | count_errors(bdp->status, priv); | 1531 | count_errors(bdp->status, priv); |
1542 | 1532 | ||
@@ -1916,17 +1906,17 @@ static irqreturn_t gfar_error(int irq, void *dev_id) | |||
1916 | 1906 | ||
1917 | /* Update the error counters */ | 1907 | /* Update the error counters */ |
1918 | if (events & IEVENT_TXE) { | 1908 | if (events & IEVENT_TXE) { |
1919 | priv->stats.tx_errors++; | 1909 | dev->stats.tx_errors++; |
1920 | 1910 | ||
1921 | if (events & IEVENT_LC) | 1911 | if (events & IEVENT_LC) |
1922 | priv->stats.tx_window_errors++; | 1912 | dev->stats.tx_window_errors++; |
1923 | if (events & IEVENT_CRL) | 1913 | if (events & IEVENT_CRL) |
1924 | priv->stats.tx_aborted_errors++; | 1914 | dev->stats.tx_aborted_errors++; |
1925 | if (events & IEVENT_XFUN) { | 1915 | if (events & IEVENT_XFUN) { |
1926 | if (netif_msg_tx_err(priv)) | 1916 | if (netif_msg_tx_err(priv)) |
1927 | printk(KERN_DEBUG "%s: TX FIFO underrun, " | 1917 | printk(KERN_DEBUG "%s: TX FIFO underrun, " |
1928 | "packet dropped.\n", dev->name); | 1918 | "packet dropped.\n", dev->name); |
1929 | priv->stats.tx_dropped++; | 1919 | dev->stats.tx_dropped++; |
1930 | priv->extra_stats.tx_underrun++; | 1920 | priv->extra_stats.tx_underrun++; |
1931 | 1921 | ||
1932 | /* Reactivate the Tx Queues */ | 1922 | /* Reactivate the Tx Queues */ |
@@ -1936,7 +1926,7 @@ static irqreturn_t gfar_error(int irq, void *dev_id) | |||
1936 | printk(KERN_DEBUG "%s: Transmit Error\n", dev->name); | 1926 | printk(KERN_DEBUG "%s: Transmit Error\n", dev->name); |
1937 | } | 1927 | } |
1938 | if (events & IEVENT_BSY) { | 1928 | if (events & IEVENT_BSY) { |
1939 | priv->stats.rx_errors++; | 1929 | dev->stats.rx_errors++; |
1940 | priv->extra_stats.rx_bsy++; | 1930 | priv->extra_stats.rx_bsy++; |
1941 | 1931 | ||
1942 | gfar_receive(irq, dev_id); | 1932 | gfar_receive(irq, dev_id); |
@@ -1951,7 +1941,7 @@ static irqreturn_t gfar_error(int irq, void *dev_id) | |||
1951 | dev->name, gfar_read(&priv->regs->rstat)); | 1941 | dev->name, gfar_read(&priv->regs->rstat)); |
1952 | } | 1942 | } |
1953 | if (events & IEVENT_BABR) { | 1943 | if (events & IEVENT_BABR) { |
1954 | priv->stats.rx_errors++; | 1944 | dev->stats.rx_errors++; |
1955 | priv->extra_stats.rx_babr++; | 1945 | priv->extra_stats.rx_babr++; |
1956 | 1946 | ||
1957 | if (netif_msg_rx_err(priv)) | 1947 | if (netif_msg_rx_err(priv)) |