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/sis900.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/sis900.c')
-rw-r--r-- | drivers/net/sis900.c | 56 |
1 files changed, 19 insertions, 37 deletions
diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c index e1930c3ee75d..5da8e671324d 100644 --- a/drivers/net/sis900.c +++ b/drivers/net/sis900.c | |||
@@ -158,7 +158,6 @@ typedef struct _BufferDesc { | |||
158 | } BufferDesc; | 158 | } BufferDesc; |
159 | 159 | ||
160 | struct sis900_private { | 160 | struct sis900_private { |
161 | struct net_device_stats stats; | ||
162 | struct pci_dev * pci_dev; | 161 | struct pci_dev * pci_dev; |
163 | 162 | ||
164 | spinlock_t lock; | 163 | spinlock_t lock; |
@@ -221,7 +220,6 @@ static void sis900_finish_xmit (struct net_device *net_dev); | |||
221 | static irqreturn_t sis900_interrupt(int irq, void *dev_instance); | 220 | static irqreturn_t sis900_interrupt(int irq, void *dev_instance); |
222 | static int sis900_close(struct net_device *net_dev); | 221 | static int sis900_close(struct net_device *net_dev); |
223 | static int mii_ioctl(struct net_device *net_dev, struct ifreq *rq, int cmd); | 222 | static int mii_ioctl(struct net_device *net_dev, struct ifreq *rq, int cmd); |
224 | static struct net_device_stats *sis900_get_stats(struct net_device *net_dev); | ||
225 | static u16 sis900_mcast_bitnr(u8 *addr, u8 revision); | 223 | static u16 sis900_mcast_bitnr(u8 *addr, u8 revision); |
226 | static void set_rx_mode(struct net_device *net_dev); | 224 | static void set_rx_mode(struct net_device *net_dev); |
227 | static void sis900_reset(struct net_device *net_dev); | 225 | static void sis900_reset(struct net_device *net_dev); |
@@ -466,7 +464,6 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev, | |||
466 | net_dev->open = &sis900_open; | 464 | net_dev->open = &sis900_open; |
467 | net_dev->hard_start_xmit = &sis900_start_xmit; | 465 | net_dev->hard_start_xmit = &sis900_start_xmit; |
468 | net_dev->stop = &sis900_close; | 466 | net_dev->stop = &sis900_close; |
469 | net_dev->get_stats = &sis900_get_stats; | ||
470 | net_dev->set_config = &sis900_set_config; | 467 | net_dev->set_config = &sis900_set_config; |
471 | net_dev->set_multicast_list = &set_rx_mode; | 468 | net_dev->set_multicast_list = &set_rx_mode; |
472 | net_dev->do_ioctl = &mii_ioctl; | 469 | net_dev->do_ioctl = &mii_ioctl; |
@@ -1542,7 +1539,7 @@ static void sis900_tx_timeout(struct net_device *net_dev) | |||
1542 | sis_priv->tx_skbuff[i] = NULL; | 1539 | sis_priv->tx_skbuff[i] = NULL; |
1543 | sis_priv->tx_ring[i].cmdsts = 0; | 1540 | sis_priv->tx_ring[i].cmdsts = 0; |
1544 | sis_priv->tx_ring[i].bufptr = 0; | 1541 | sis_priv->tx_ring[i].bufptr = 0; |
1545 | sis_priv->stats.tx_dropped++; | 1542 | net_dev->stats.tx_dropped++; |
1546 | } | 1543 | } |
1547 | } | 1544 | } |
1548 | sis_priv->tx_full = 0; | 1545 | sis_priv->tx_full = 0; |
@@ -1739,15 +1736,15 @@ static int sis900_rx(struct net_device *net_dev) | |||
1739 | printk(KERN_DEBUG "%s: Corrupted packet " | 1736 | printk(KERN_DEBUG "%s: Corrupted packet " |
1740 | "received, buffer status = 0x%8.8x/%d.\n", | 1737 | "received, buffer status = 0x%8.8x/%d.\n", |
1741 | net_dev->name, rx_status, data_size); | 1738 | net_dev->name, rx_status, data_size); |
1742 | sis_priv->stats.rx_errors++; | 1739 | net_dev->stats.rx_errors++; |
1743 | if (rx_status & OVERRUN) | 1740 | if (rx_status & OVERRUN) |
1744 | sis_priv->stats.rx_over_errors++; | 1741 | net_dev->stats.rx_over_errors++; |
1745 | if (rx_status & (TOOLONG|RUNT)) | 1742 | if (rx_status & (TOOLONG|RUNT)) |
1746 | sis_priv->stats.rx_length_errors++; | 1743 | net_dev->stats.rx_length_errors++; |
1747 | if (rx_status & (RXISERR | FAERR)) | 1744 | if (rx_status & (RXISERR | FAERR)) |
1748 | sis_priv->stats.rx_frame_errors++; | 1745 | net_dev->stats.rx_frame_errors++; |
1749 | if (rx_status & CRCERR) | 1746 | if (rx_status & CRCERR) |
1750 | sis_priv->stats.rx_crc_errors++; | 1747 | net_dev->stats.rx_crc_errors++; |
1751 | /* reset buffer descriptor state */ | 1748 | /* reset buffer descriptor state */ |
1752 | sis_priv->rx_ring[entry].cmdsts = RX_BUF_SIZE; | 1749 | sis_priv->rx_ring[entry].cmdsts = RX_BUF_SIZE; |
1753 | } else { | 1750 | } else { |
@@ -1768,7 +1765,7 @@ static int sis900_rx(struct net_device *net_dev) | |||
1768 | * in the rx ring | 1765 | * in the rx ring |
1769 | */ | 1766 | */ |
1770 | skb = sis_priv->rx_skbuff[entry]; | 1767 | skb = sis_priv->rx_skbuff[entry]; |
1771 | sis_priv->stats.rx_dropped++; | 1768 | net_dev->stats.rx_dropped++; |
1772 | goto refill_rx_ring; | 1769 | goto refill_rx_ring; |
1773 | } | 1770 | } |
1774 | 1771 | ||
@@ -1793,10 +1790,10 @@ static int sis900_rx(struct net_device *net_dev) | |||
1793 | 1790 | ||
1794 | /* some network statistics */ | 1791 | /* some network statistics */ |
1795 | if ((rx_status & BCAST) == MCAST) | 1792 | if ((rx_status & BCAST) == MCAST) |
1796 | sis_priv->stats.multicast++; | 1793 | net_dev->stats.multicast++; |
1797 | net_dev->last_rx = jiffies; | 1794 | net_dev->last_rx = jiffies; |
1798 | sis_priv->stats.rx_bytes += rx_size; | 1795 | net_dev->stats.rx_bytes += rx_size; |
1799 | sis_priv->stats.rx_packets++; | 1796 | net_dev->stats.rx_packets++; |
1800 | sis_priv->dirty_rx++; | 1797 | sis_priv->dirty_rx++; |
1801 | refill_rx_ring: | 1798 | refill_rx_ring: |
1802 | sis_priv->rx_skbuff[entry] = skb; | 1799 | sis_priv->rx_skbuff[entry] = skb; |
@@ -1827,7 +1824,7 @@ refill_rx_ring: | |||
1827 | printk(KERN_INFO "%s: Memory squeeze," | 1824 | printk(KERN_INFO "%s: Memory squeeze," |
1828 | "deferring packet.\n", | 1825 | "deferring packet.\n", |
1829 | net_dev->name); | 1826 | net_dev->name); |
1830 | sis_priv->stats.rx_dropped++; | 1827 | net_dev->stats.rx_dropped++; |
1831 | break; | 1828 | break; |
1832 | } | 1829 | } |
1833 | sis_priv->rx_skbuff[entry] = skb; | 1830 | sis_priv->rx_skbuff[entry] = skb; |
@@ -1878,20 +1875,20 @@ static void sis900_finish_xmit (struct net_device *net_dev) | |||
1878 | printk(KERN_DEBUG "%s: Transmit " | 1875 | printk(KERN_DEBUG "%s: Transmit " |
1879 | "error, Tx status %8.8x.\n", | 1876 | "error, Tx status %8.8x.\n", |
1880 | net_dev->name, tx_status); | 1877 | net_dev->name, tx_status); |
1881 | sis_priv->stats.tx_errors++; | 1878 | net_dev->stats.tx_errors++; |
1882 | if (tx_status & UNDERRUN) | 1879 | if (tx_status & UNDERRUN) |
1883 | sis_priv->stats.tx_fifo_errors++; | 1880 | net_dev->stats.tx_fifo_errors++; |
1884 | if (tx_status & ABORT) | 1881 | if (tx_status & ABORT) |
1885 | sis_priv->stats.tx_aborted_errors++; | 1882 | net_dev->stats.tx_aborted_errors++; |
1886 | if (tx_status & NOCARRIER) | 1883 | if (tx_status & NOCARRIER) |
1887 | sis_priv->stats.tx_carrier_errors++; | 1884 | net_dev->stats.tx_carrier_errors++; |
1888 | if (tx_status & OWCOLL) | 1885 | if (tx_status & OWCOLL) |
1889 | sis_priv->stats.tx_window_errors++; | 1886 | net_dev->stats.tx_window_errors++; |
1890 | } else { | 1887 | } else { |
1891 | /* packet successfully transmitted */ | 1888 | /* packet successfully transmitted */ |
1892 | sis_priv->stats.collisions += (tx_status & COLCNT) >> 16; | 1889 | net_dev->stats.collisions += (tx_status & COLCNT) >> 16; |
1893 | sis_priv->stats.tx_bytes += tx_status & DSIZE; | 1890 | net_dev->stats.tx_bytes += tx_status & DSIZE; |
1894 | sis_priv->stats.tx_packets++; | 1891 | net_dev->stats.tx_packets++; |
1895 | } | 1892 | } |
1896 | /* Free the original skb. */ | 1893 | /* Free the original skb. */ |
1897 | skb = sis_priv->tx_skbuff[entry]; | 1894 | skb = sis_priv->tx_skbuff[entry]; |
@@ -2138,21 +2135,6 @@ static int mii_ioctl(struct net_device *net_dev, struct ifreq *rq, int cmd) | |||
2138 | } | 2135 | } |
2139 | 2136 | ||
2140 | /** | 2137 | /** |
2141 | * sis900_get_stats - Get sis900 read/write statistics | ||
2142 | * @net_dev: the net device to get statistics for | ||
2143 | * | ||
2144 | * get tx/rx statistics for sis900 | ||
2145 | */ | ||
2146 | |||
2147 | static struct net_device_stats * | ||
2148 | sis900_get_stats(struct net_device *net_dev) | ||
2149 | { | ||
2150 | struct sis900_private *sis_priv = net_dev->priv; | ||
2151 | |||
2152 | return &sis_priv->stats; | ||
2153 | } | ||
2154 | |||
2155 | /** | ||
2156 | * sis900_set_config - Set media type by net_device.set_config | 2138 | * sis900_set_config - Set media type by net_device.set_config |
2157 | * @dev: the net device for media type change | 2139 | * @dev: the net device for media type change |
2158 | * @map: ifmap passed by ifconfig | 2140 | * @map: ifmap passed by ifconfig |