[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>
This commit is contained in:
committed by
David S. Miller
parent
ff8ac60948
commit
09f75cd7bf
@@ -248,7 +248,6 @@ struct lance_private {
|
||||
int rx_new, tx_new;
|
||||
int rx_old, tx_old;
|
||||
|
||||
struct net_device_stats stats;
|
||||
struct sbus_dma *ledma; /* If set this points to ledma */
|
||||
char tpe; /* cable-selection is TPE */
|
||||
char auto_select; /* cable-selection by carrier */
|
||||
@@ -519,17 +518,17 @@ static void lance_rx_dvma(struct net_device *dev)
|
||||
|
||||
/* We got an incomplete frame? */
|
||||
if ((bits & LE_R1_POK) != LE_R1_POK) {
|
||||
lp->stats.rx_over_errors++;
|
||||
lp->stats.rx_errors++;
|
||||
dev->stats.rx_over_errors++;
|
||||
dev->stats.rx_errors++;
|
||||
} else if (bits & LE_R1_ERR) {
|
||||
/* Count only the end frame as a rx error,
|
||||
* not the beginning
|
||||
*/
|
||||
if (bits & LE_R1_BUF) lp->stats.rx_fifo_errors++;
|
||||
if (bits & LE_R1_CRC) lp->stats.rx_crc_errors++;
|
||||
if (bits & LE_R1_OFL) lp->stats.rx_over_errors++;
|
||||
if (bits & LE_R1_FRA) lp->stats.rx_frame_errors++;
|
||||
if (bits & LE_R1_EOP) lp->stats.rx_errors++;
|
||||
if (bits & LE_R1_BUF) dev->stats.rx_fifo_errors++;
|
||||
if (bits & LE_R1_CRC) dev->stats.rx_crc_errors++;
|
||||
if (bits & LE_R1_OFL) dev->stats.rx_over_errors++;
|
||||
if (bits & LE_R1_FRA) dev->stats.rx_frame_errors++;
|
||||
if (bits & LE_R1_EOP) dev->stats.rx_errors++;
|
||||
} else {
|
||||
len = (rd->mblength & 0xfff) - 4;
|
||||
skb = dev_alloc_skb(len + 2);
|
||||
@@ -537,14 +536,14 @@ static void lance_rx_dvma(struct net_device *dev)
|
||||
if (skb == NULL) {
|
||||
printk(KERN_INFO "%s: Memory squeeze, deferring packet.\n",
|
||||
dev->name);
|
||||
lp->stats.rx_dropped++;
|
||||
dev->stats.rx_dropped++;
|
||||
rd->mblength = 0;
|
||||
rd->rmd1_bits = LE_R1_OWN;
|
||||
lp->rx_new = RX_NEXT(entry);
|
||||
return;
|
||||
}
|
||||
|
||||
lp->stats.rx_bytes += len;
|
||||
dev->stats.rx_bytes += len;
|
||||
|
||||
skb_reserve(skb, 2); /* 16 byte align */
|
||||
skb_put(skb, len); /* make room */
|
||||
@@ -554,7 +553,7 @@ static void lance_rx_dvma(struct net_device *dev)
|
||||
skb->protocol = eth_type_trans(skb, dev);
|
||||
netif_rx(skb);
|
||||
dev->last_rx = jiffies;
|
||||
lp->stats.rx_packets++;
|
||||
dev->stats.rx_packets++;
|
||||
}
|
||||
|
||||
/* Return the packet to the pool */
|
||||
@@ -586,12 +585,12 @@ static void lance_tx_dvma(struct net_device *dev)
|
||||
if (bits & LE_T1_ERR) {
|
||||
u16 status = td->misc;
|
||||
|
||||
lp->stats.tx_errors++;
|
||||
if (status & LE_T3_RTY) lp->stats.tx_aborted_errors++;
|
||||
if (status & LE_T3_LCOL) lp->stats.tx_window_errors++;
|
||||
dev->stats.tx_errors++;
|
||||
if (status & LE_T3_RTY) dev->stats.tx_aborted_errors++;
|
||||
if (status & LE_T3_LCOL) dev->stats.tx_window_errors++;
|
||||
|
||||
if (status & LE_T3_CLOS) {
|
||||
lp->stats.tx_carrier_errors++;
|
||||
dev->stats.tx_carrier_errors++;
|
||||
if (lp->auto_select) {
|
||||
lp->tpe = 1 - lp->tpe;
|
||||
printk(KERN_NOTICE "%s: Carrier Lost, trying %s\n",
|
||||
@@ -608,7 +607,7 @@ static void lance_tx_dvma(struct net_device *dev)
|
||||
* transmitter, restart the adapter.
|
||||
*/
|
||||
if (status & (LE_T3_BUF|LE_T3_UFL)) {
|
||||
lp->stats.tx_fifo_errors++;
|
||||
dev->stats.tx_fifo_errors++;
|
||||
|
||||
printk(KERN_ERR "%s: Tx: ERR_BUF|ERR_UFL, restarting\n",
|
||||
dev->name);
|
||||
@@ -626,13 +625,13 @@ static void lance_tx_dvma(struct net_device *dev)
|
||||
|
||||
/* One collision before packet was sent. */
|
||||
if (bits & LE_T1_EONE)
|
||||
lp->stats.collisions++;
|
||||
dev->stats.collisions++;
|
||||
|
||||
/* More than one collision, be optimistic. */
|
||||
if (bits & LE_T1_EMORE)
|
||||
lp->stats.collisions += 2;
|
||||
dev->stats.collisions += 2;
|
||||
|
||||
lp->stats.tx_packets++;
|
||||
dev->stats.tx_packets++;
|
||||
}
|
||||
|
||||
j = TX_NEXT(j);
|
||||
@@ -692,17 +691,17 @@ static void lance_rx_pio(struct net_device *dev)
|
||||
|
||||
/* We got an incomplete frame? */
|
||||
if ((bits & LE_R1_POK) != LE_R1_POK) {
|
||||
lp->stats.rx_over_errors++;
|
||||
lp->stats.rx_errors++;
|
||||
dev->stats.rx_over_errors++;
|
||||
dev->stats.rx_errors++;
|
||||
} else if (bits & LE_R1_ERR) {
|
||||
/* Count only the end frame as a rx error,
|
||||
* not the beginning
|
||||
*/
|
||||
if (bits & LE_R1_BUF) lp->stats.rx_fifo_errors++;
|
||||
if (bits & LE_R1_CRC) lp->stats.rx_crc_errors++;
|
||||
if (bits & LE_R1_OFL) lp->stats.rx_over_errors++;
|
||||
if (bits & LE_R1_FRA) lp->stats.rx_frame_errors++;
|
||||
if (bits & LE_R1_EOP) lp->stats.rx_errors++;
|
||||
if (bits & LE_R1_BUF) dev->stats.rx_fifo_errors++;
|
||||
if (bits & LE_R1_CRC) dev->stats.rx_crc_errors++;
|
||||
if (bits & LE_R1_OFL) dev->stats.rx_over_errors++;
|
||||
if (bits & LE_R1_FRA) dev->stats.rx_frame_errors++;
|
||||
if (bits & LE_R1_EOP) dev->stats.rx_errors++;
|
||||
} else {
|
||||
len = (sbus_readw(&rd->mblength) & 0xfff) - 4;
|
||||
skb = dev_alloc_skb(len + 2);
|
||||
@@ -710,14 +709,14 @@ static void lance_rx_pio(struct net_device *dev)
|
||||
if (skb == NULL) {
|
||||
printk(KERN_INFO "%s: Memory squeeze, deferring packet.\n",
|
||||
dev->name);
|
||||
lp->stats.rx_dropped++;
|
||||
dev->stats.rx_dropped++;
|
||||
sbus_writew(0, &rd->mblength);
|
||||
sbus_writeb(LE_R1_OWN, &rd->rmd1_bits);
|
||||
lp->rx_new = RX_NEXT(entry);
|
||||
return;
|
||||
}
|
||||
|
||||
lp->stats.rx_bytes += len;
|
||||
dev->stats.rx_bytes += len;
|
||||
|
||||
skb_reserve (skb, 2); /* 16 byte align */
|
||||
skb_put(skb, len); /* make room */
|
||||
@@ -725,7 +724,7 @@ static void lance_rx_pio(struct net_device *dev)
|
||||
skb->protocol = eth_type_trans(skb, dev);
|
||||
netif_rx(skb);
|
||||
dev->last_rx = jiffies;
|
||||
lp->stats.rx_packets++;
|
||||
dev->stats.rx_packets++;
|
||||
}
|
||||
|
||||
/* Return the packet to the pool */
|
||||
@@ -757,12 +756,12 @@ static void lance_tx_pio(struct net_device *dev)
|
||||
if (bits & LE_T1_ERR) {
|
||||
u16 status = sbus_readw(&td->misc);
|
||||
|
||||
lp->stats.tx_errors++;
|
||||
if (status & LE_T3_RTY) lp->stats.tx_aborted_errors++;
|
||||
if (status & LE_T3_LCOL) lp->stats.tx_window_errors++;
|
||||
dev->stats.tx_errors++;
|
||||
if (status & LE_T3_RTY) dev->stats.tx_aborted_errors++;
|
||||
if (status & LE_T3_LCOL) dev->stats.tx_window_errors++;
|
||||
|
||||
if (status & LE_T3_CLOS) {
|
||||
lp->stats.tx_carrier_errors++;
|
||||
dev->stats.tx_carrier_errors++;
|
||||
if (lp->auto_select) {
|
||||
lp->tpe = 1 - lp->tpe;
|
||||
printk(KERN_NOTICE "%s: Carrier Lost, trying %s\n",
|
||||
@@ -779,7 +778,7 @@ static void lance_tx_pio(struct net_device *dev)
|
||||
* transmitter, restart the adapter.
|
||||
*/
|
||||
if (status & (LE_T3_BUF|LE_T3_UFL)) {
|
||||
lp->stats.tx_fifo_errors++;
|
||||
dev->stats.tx_fifo_errors++;
|
||||
|
||||
printk(KERN_ERR "%s: Tx: ERR_BUF|ERR_UFL, restarting\n",
|
||||
dev->name);
|
||||
@@ -797,13 +796,13 @@ static void lance_tx_pio(struct net_device *dev)
|
||||
|
||||
/* One collision before packet was sent. */
|
||||
if (bits & LE_T1_EONE)
|
||||
lp->stats.collisions++;
|
||||
dev->stats.collisions++;
|
||||
|
||||
/* More than one collision, be optimistic. */
|
||||
if (bits & LE_T1_EMORE)
|
||||
lp->stats.collisions += 2;
|
||||
dev->stats.collisions += 2;
|
||||
|
||||
lp->stats.tx_packets++;
|
||||
dev->stats.tx_packets++;
|
||||
}
|
||||
|
||||
j = TX_NEXT(j);
|
||||
@@ -844,10 +843,10 @@ static irqreturn_t lance_interrupt(int irq, void *dev_id)
|
||||
lp->tx(dev);
|
||||
|
||||
if (csr0 & LE_C0_BABL)
|
||||
lp->stats.tx_errors++;
|
||||
dev->stats.tx_errors++;
|
||||
|
||||
if (csr0 & LE_C0_MISS)
|
||||
lp->stats.rx_errors++;
|
||||
dev->stats.rx_errors++;
|
||||
|
||||
if (csr0 & LE_C0_MERR) {
|
||||
if (lp->dregs) {
|
||||
@@ -1127,7 +1126,7 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
|
||||
spin_lock_irq(&lp->lock);
|
||||
|
||||
lp->stats.tx_bytes += len;
|
||||
dev->stats.tx_bytes += len;
|
||||
|
||||
entry = lp->tx_new & TX_RING_MOD_MASK;
|
||||
if (lp->pio_buffer) {
|
||||
@@ -1170,13 +1169,6 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct net_device_stats *lance_get_stats(struct net_device *dev)
|
||||
{
|
||||
struct lance_private *lp = netdev_priv(dev);
|
||||
|
||||
return &lp->stats;
|
||||
}
|
||||
|
||||
/* taken from the depca driver */
|
||||
static void lance_load_multicast(struct net_device *dev)
|
||||
{
|
||||
@@ -1463,7 +1455,6 @@ no_link_test:
|
||||
dev->hard_start_xmit = &lance_start_xmit;
|
||||
dev->tx_timeout = &lance_tx_timeout;
|
||||
dev->watchdog_timeo = 5*HZ;
|
||||
dev->get_stats = &lance_get_stats;
|
||||
dev->set_multicast_list = &lance_set_multicast;
|
||||
dev->ethtool_ops = &sparc_lance_ethtool_ops;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user