Skip to content

Commit

Permalink
natsemi: Use the instance of net_device_stats from net_device.
Browse files Browse the repository at this point in the history
Since net_device has an instance of net_device_stats,
we can remove the instance of this from the adapter structure.

Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Kulikov Vasiliy authored and David S. Miller committed Jul 6, 2010
1 parent 897dd41 commit 2321e80
Showing 1 changed file with 27 additions and 29 deletions.
56 changes: 27 additions & 29 deletions drivers/net/natsemi.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,6 @@ struct netdev_private {
dma_addr_t tx_dma[TX_RING_SIZE];
struct net_device *dev;
struct napi_struct napi;
struct net_device_stats stats;
/* Media monitoring timer */
struct timer_list timer;
/* Frequently used values: keep some adjacent for cache effect */
Expand Down Expand Up @@ -1906,7 +1905,7 @@ static void ns_tx_timeout(struct net_device *dev)
enable_irq(dev->irq);

dev->trans_start = jiffies; /* prevent tx timeout */
np->stats.tx_errors++;
dev->stats.tx_errors++;
netif_wake_queue(dev);
}

Expand Down Expand Up @@ -2009,7 +2008,7 @@ static void drain_tx(struct net_device *dev)
np->tx_dma[i], np->tx_skbuff[i]->len,
PCI_DMA_TODEVICE);
dev_kfree_skb(np->tx_skbuff[i]);
np->stats.tx_dropped++;
dev->stats.tx_dropped++;
}
np->tx_skbuff[i] = NULL;
}
Expand Down Expand Up @@ -2115,7 +2114,7 @@ static netdev_tx_t start_tx(struct sk_buff *skb, struct net_device *dev)
writel(TxOn, ioaddr + ChipCmd);
} else {
dev_kfree_skb_irq(skb);
np->stats.tx_dropped++;
dev->stats.tx_dropped++;
}
spin_unlock_irqrestore(&np->lock, flags);

Expand All @@ -2140,20 +2139,20 @@ static void netdev_tx_done(struct net_device *dev)
dev->name, np->dirty_tx,
le32_to_cpu(np->tx_ring[entry].cmd_status));
if (np->tx_ring[entry].cmd_status & cpu_to_le32(DescPktOK)) {
np->stats.tx_packets++;
np->stats.tx_bytes += np->tx_skbuff[entry]->len;
dev->stats.tx_packets++;
dev->stats.tx_bytes += np->tx_skbuff[entry]->len;
} else { /* Various Tx errors */
int tx_status =
le32_to_cpu(np->tx_ring[entry].cmd_status);
if (tx_status & (DescTxAbort|DescTxExcColl))
np->stats.tx_aborted_errors++;
dev->stats.tx_aborted_errors++;
if (tx_status & DescTxFIFO)
np->stats.tx_fifo_errors++;
dev->stats.tx_fifo_errors++;
if (tx_status & DescTxCarrier)
np->stats.tx_carrier_errors++;
dev->stats.tx_carrier_errors++;
if (tx_status & DescTxOOWCol)
np->stats.tx_window_errors++;
np->stats.tx_errors++;
dev->stats.tx_window_errors++;
dev->stats.tx_errors++;
}
pci_unmap_single(np->pci_dev,np->tx_dma[entry],
np->tx_skbuff[entry]->len,
Expand Down Expand Up @@ -2301,7 +2300,7 @@ static void netdev_rx(struct net_device *dev, int *work_done, int work_to_do)
"buffers, entry %#08x "
"status %#08x.\n", dev->name,
np->cur_rx, desc_status);
np->stats.rx_length_errors++;
dev->stats.rx_length_errors++;

/* The RX state machine has probably
* locked up beneath us. Follow the
Expand All @@ -2321,15 +2320,15 @@ static void netdev_rx(struct net_device *dev, int *work_done, int work_to_do)

} else {
/* There was an error. */
np->stats.rx_errors++;
dev->stats.rx_errors++;
if (desc_status & (DescRxAbort|DescRxOver))
np->stats.rx_over_errors++;
dev->stats.rx_over_errors++;
if (desc_status & (DescRxLong|DescRxRunt))
np->stats.rx_length_errors++;
dev->stats.rx_length_errors++;
if (desc_status & (DescRxInvalid|DescRxAlign))
np->stats.rx_frame_errors++;
dev->stats.rx_frame_errors++;
if (desc_status & DescRxCRC)
np->stats.rx_crc_errors++;
dev->stats.rx_crc_errors++;
}
} else if (pkt_len > np->rx_buf_sz) {
/* if this is the tail of a double buffer
Expand Down Expand Up @@ -2364,8 +2363,8 @@ static void netdev_rx(struct net_device *dev, int *work_done, int work_to_do)
}
skb->protocol = eth_type_trans(skb, dev);
netif_receive_skb(skb);
np->stats.rx_packets++;
np->stats.rx_bytes += pkt_len;
dev->stats.rx_packets++;
dev->stats.rx_bytes += pkt_len;
}
entry = (++np->cur_rx) % RX_RING_SIZE;
np->rx_head_desc = &np->rx_ring[entry];
Expand Down Expand Up @@ -2428,29 +2427,28 @@ static void netdev_error(struct net_device *dev, int intr_status)
printk(KERN_NOTICE "%s: Rx status FIFO overrun\n",
dev->name);
}
np->stats.rx_fifo_errors++;
np->stats.rx_errors++;
dev->stats.rx_fifo_errors++;
dev->stats.rx_errors++;
}
/* Hmmmmm, it's not clear how to recover from PCI faults. */
if (intr_status & IntrPCIErr) {
printk(KERN_NOTICE "%s: PCI error %#08x\n", dev->name,
intr_status & IntrPCIErr);
np->stats.tx_fifo_errors++;
np->stats.tx_errors++;
np->stats.rx_fifo_errors++;
np->stats.rx_errors++;
dev->stats.tx_fifo_errors++;
dev->stats.tx_errors++;
dev->stats.rx_fifo_errors++;
dev->stats.rx_errors++;
}
spin_unlock(&np->lock);
}

static void __get_stats(struct net_device *dev)
{
void __iomem * ioaddr = ns_ioaddr(dev);
struct netdev_private *np = netdev_priv(dev);

/* The chip only need report frame silently dropped. */
np->stats.rx_crc_errors += readl(ioaddr + RxCRCErrs);
np->stats.rx_missed_errors += readl(ioaddr + RxMissed);
dev->stats.rx_crc_errors += readl(ioaddr + RxCRCErrs);
dev->stats.rx_missed_errors += readl(ioaddr + RxMissed);
}

static struct net_device_stats *get_stats(struct net_device *dev)
Expand All @@ -2463,7 +2461,7 @@ static struct net_device_stats *get_stats(struct net_device *dev)
__get_stats(dev);
spin_unlock_irq(&np->lock);

return &np->stats;
return &dev->stats;
}

#ifdef CONFIG_NET_POLL_CONTROLLER
Expand Down

0 comments on commit 2321e80

Please sign in to comment.