aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/depca.c
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2007-10-03 20:41:50 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:51:16 -0400
commit09f75cd7bf13720738e6a196cc0107ce9a5bd5a0 (patch)
tree4c85b0b395abe7f88c87162fc22570e5de255cb1 /drivers/net/depca.c
parentff8ac60948ba819b89e9c87083e8050fc2f89999 (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/depca.c')
-rw-r--r--drivers/net/depca.c42
1 files changed, 15 insertions, 27 deletions
diff --git a/drivers/net/depca.c b/drivers/net/depca.c
index 183497020bfc..28fa2bdc8c79 100644
--- a/drivers/net/depca.c
+++ b/drivers/net/depca.c
@@ -485,7 +485,6 @@ struct depca_private {
485/* Kernel-only (not device) fields */ 485/* Kernel-only (not device) fields */
486 int rx_new, tx_new; /* The next free ring entry */ 486 int rx_new, tx_new; /* The next free ring entry */
487 int rx_old, tx_old; /* The ring entries to be free()ed. */ 487 int rx_old, tx_old; /* The ring entries to be free()ed. */
488 struct net_device_stats stats;
489 spinlock_t lock; 488 spinlock_t lock;
490 struct { /* Private stats counters */ 489 struct { /* Private stats counters */
491 u32 bins[DEPCA_PKT_STAT_SZ]; 490 u32 bins[DEPCA_PKT_STAT_SZ];
@@ -522,7 +521,6 @@ static irqreturn_t depca_interrupt(int irq, void *dev_id);
522static int depca_close(struct net_device *dev); 521static int depca_close(struct net_device *dev);
523static int depca_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 522static int depca_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
524static void depca_tx_timeout(struct net_device *dev); 523static void depca_tx_timeout(struct net_device *dev);
525static struct net_device_stats *depca_get_stats(struct net_device *dev);
526static void set_multicast_list(struct net_device *dev); 524static void set_multicast_list(struct net_device *dev);
527 525
528/* 526/*
@@ -801,7 +799,6 @@ static int __init depca_hw_init (struct net_device *dev, struct device *device)
801 dev->open = &depca_open; 799 dev->open = &depca_open;
802 dev->hard_start_xmit = &depca_start_xmit; 800 dev->hard_start_xmit = &depca_start_xmit;
803 dev->stop = &depca_close; 801 dev->stop = &depca_close;
804 dev->get_stats = &depca_get_stats;
805 dev->set_multicast_list = &set_multicast_list; 802 dev->set_multicast_list = &set_multicast_list;
806 dev->do_ioctl = &depca_ioctl; 803 dev->do_ioctl = &depca_ioctl;
807 dev->tx_timeout = depca_tx_timeout; 804 dev->tx_timeout = depca_tx_timeout;
@@ -1026,15 +1023,15 @@ static int depca_rx(struct net_device *dev)
1026 } 1023 }
1027 if (status & R_ENP) { /* Valid frame status */ 1024 if (status & R_ENP) { /* Valid frame status */
1028 if (status & R_ERR) { /* There was an error. */ 1025 if (status & R_ERR) { /* There was an error. */
1029 lp->stats.rx_errors++; /* Update the error stats. */ 1026 dev->stats.rx_errors++; /* Update the error stats. */
1030 if (status & R_FRAM) 1027 if (status & R_FRAM)
1031 lp->stats.rx_frame_errors++; 1028 dev->stats.rx_frame_errors++;
1032 if (status & R_OFLO) 1029 if (status & R_OFLO)
1033 lp->stats.rx_over_errors++; 1030 dev->stats.rx_over_errors++;
1034 if (status & R_CRC) 1031 if (status & R_CRC)
1035 lp->stats.rx_crc_errors++; 1032 dev->stats.rx_crc_errors++;
1036 if (status & R_BUFF) 1033 if (status & R_BUFF)
1037 lp->stats.rx_fifo_errors++; 1034 dev->stats.rx_fifo_errors++;
1038 } else { 1035 } else {
1039 short len, pkt_len = readw(&lp->rx_ring[entry].msg_length) - 4; 1036 short len, pkt_len = readw(&lp->rx_ring[entry].msg_length) - 4;
1040 struct sk_buff *skb; 1037 struct sk_buff *skb;
@@ -1063,8 +1060,8 @@ static int depca_rx(struct net_device *dev)
1063 ** Update stats 1060 ** Update stats
1064 */ 1061 */
1065 dev->last_rx = jiffies; 1062 dev->last_rx = jiffies;
1066 lp->stats.rx_packets++; 1063 dev->stats.rx_packets++;
1067 lp->stats.rx_bytes += pkt_len; 1064 dev->stats.rx_bytes += pkt_len;
1068 for (i = 1; i < DEPCA_PKT_STAT_SZ - 1; i++) { 1065 for (i = 1; i < DEPCA_PKT_STAT_SZ - 1; i++) {
1069 if (pkt_len < (i * DEPCA_PKT_BIN_SZ)) { 1066 if (pkt_len < (i * DEPCA_PKT_BIN_SZ)) {
1070 lp->pktStats.bins[i]++; 1067 lp->pktStats.bins[i]++;
@@ -1087,7 +1084,7 @@ static int depca_rx(struct net_device *dev)
1087 } 1084 }
1088 } else { 1085 } else {
1089 printk("%s: Memory squeeze, deferring packet.\n", dev->name); 1086 printk("%s: Memory squeeze, deferring packet.\n", dev->name);
1090 lp->stats.rx_dropped++; /* Really, deferred. */ 1087 dev->stats.rx_dropped++; /* Really, deferred. */
1091 break; 1088 break;
1092 } 1089 }
1093 } 1090 }
@@ -1125,24 +1122,24 @@ static int depca_tx(struct net_device *dev)
1125 break; 1122 break;
1126 } else if (status & T_ERR) { /* An error occurred. */ 1123 } else if (status & T_ERR) { /* An error occurred. */
1127 status = readl(&lp->tx_ring[entry].misc); 1124 status = readl(&lp->tx_ring[entry].misc);
1128 lp->stats.tx_errors++; 1125 dev->stats.tx_errors++;
1129 if (status & TMD3_RTRY) 1126 if (status & TMD3_RTRY)
1130 lp->stats.tx_aborted_errors++; 1127 dev->stats.tx_aborted_errors++;
1131 if (status & TMD3_LCAR) 1128 if (status & TMD3_LCAR)
1132 lp->stats.tx_carrier_errors++; 1129 dev->stats.tx_carrier_errors++;
1133 if (status & TMD3_LCOL) 1130 if (status & TMD3_LCOL)
1134 lp->stats.tx_window_errors++; 1131 dev->stats.tx_window_errors++;
1135 if (status & TMD3_UFLO) 1132 if (status & TMD3_UFLO)
1136 lp->stats.tx_fifo_errors++; 1133 dev->stats.tx_fifo_errors++;
1137 if (status & (TMD3_BUFF | TMD3_UFLO)) { 1134 if (status & (TMD3_BUFF | TMD3_UFLO)) {
1138 /* Trigger an immediate send demand. */ 1135 /* Trigger an immediate send demand. */
1139 outw(CSR0, DEPCA_ADDR); 1136 outw(CSR0, DEPCA_ADDR);
1140 outw(INEA | TDMD, DEPCA_DATA); 1137 outw(INEA | TDMD, DEPCA_DATA);
1141 } 1138 }
1142 } else if (status & (T_MORE | T_ONE)) { 1139 } else if (status & (T_MORE | T_ONE)) {
1143 lp->stats.collisions++; 1140 dev->stats.collisions++;
1144 } else { 1141 } else {
1145 lp->stats.tx_packets++; 1142 dev->stats.tx_packets++;
1146 } 1143 }
1147 1144
1148 /* Update all the pointers */ 1145 /* Update all the pointers */
@@ -1234,15 +1231,6 @@ static int InitRestartDepca(struct net_device *dev)
1234 return status; 1231 return status;
1235} 1232}
1236 1233
1237static struct net_device_stats *depca_get_stats(struct net_device *dev)
1238{
1239 struct depca_private *lp = (struct depca_private *) dev->priv;
1240
1241 /* Null body since there is no framing error counter */
1242
1243 return &lp->stats;
1244}
1245
1246/* 1234/*
1247** Set or clear the multicast filter for this adaptor. 1235** Set or clear the multicast filter for this adaptor.
1248*/ 1236*/