aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wan/pc300_drv.c
diff options
context:
space:
mode:
authorKrzysztof Halasa <khc@pm.waw.pl>2008-06-30 17:26:53 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-07-04 08:47:41 -0400
commit198191c4a7ce4daba379608fb38b9bc5a4eedc61 (patch)
tree3229362a45a15af42628553926bc040e44c39ce0 /drivers/net/wan/pc300_drv.c
parent844290e56067aed0a54142d756565abb9614136c (diff)
WAN: convert drivers to use built-in netdev_stats
There is no point in using separate net_device_stats structs when the one in struct net_device is present. Compiles. Signed-off-by: Krzysztof HaƂasa <khc@pm.waw.pl> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/wan/pc300_drv.c')
-rw-r--r--drivers/net/wan/pc300_drv.c71
1 files changed, 30 insertions, 41 deletions
diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c
index 57914fbd41d3..334170527755 100644
--- a/drivers/net/wan/pc300_drv.c
+++ b/drivers/net/wan/pc300_drv.c
@@ -285,7 +285,6 @@ static void rx_dma_buf_init(pc300_t *, int);
285static void tx_dma_buf_check(pc300_t *, int); 285static void tx_dma_buf_check(pc300_t *, int);
286static void rx_dma_buf_check(pc300_t *, int); 286static void rx_dma_buf_check(pc300_t *, int);
287static irqreturn_t cpc_intr(int, void *); 287static irqreturn_t cpc_intr(int, void *);
288static struct net_device_stats *cpc_get_stats(struct net_device *);
289static int clock_rate_calc(uclong, uclong, int *); 288static int clock_rate_calc(uclong, uclong, int *);
290static uclong detect_ram(pc300_t *); 289static uclong detect_ram(pc300_t *);
291static void plx_init(pc300_t *); 290static void plx_init(pc300_t *);
@@ -1775,13 +1774,12 @@ static void cpc_tx_timeout(struct net_device *dev)
1775 pc300dev_t *d = (pc300dev_t *) dev->priv; 1774 pc300dev_t *d = (pc300dev_t *) dev->priv;
1776 pc300ch_t *chan = (pc300ch_t *) d->chan; 1775 pc300ch_t *chan = (pc300ch_t *) d->chan;
1777 pc300_t *card = (pc300_t *) chan->card; 1776 pc300_t *card = (pc300_t *) chan->card;
1778 struct net_device_stats *stats = hdlc_stats(dev);
1779 int ch = chan->channel; 1777 int ch = chan->channel;
1780 unsigned long flags; 1778 unsigned long flags;
1781 ucchar ilar; 1779 ucchar ilar;
1782 1780
1783 stats->tx_errors++; 1781 dev->stats.tx_errors++;
1784 stats->tx_aborted_errors++; 1782 dev->stats.tx_aborted_errors++;
1785 CPC_LOCK(card, flags); 1783 CPC_LOCK(card, flags);
1786 if ((ilar = cpc_readb(card->hw.scabase + ILAR)) != 0) { 1784 if ((ilar = cpc_readb(card->hw.scabase + ILAR)) != 0) {
1787 printk("%s: ILAR=0x%x\n", dev->name, ilar); 1785 printk("%s: ILAR=0x%x\n", dev->name, ilar);
@@ -1803,7 +1801,6 @@ static int cpc_queue_xmit(struct sk_buff *skb, struct net_device *dev)
1803 pc300dev_t *d = (pc300dev_t *) dev->priv; 1801 pc300dev_t *d = (pc300dev_t *) dev->priv;
1804 pc300ch_t *chan = (pc300ch_t *) d->chan; 1802 pc300ch_t *chan = (pc300ch_t *) d->chan;
1805 pc300_t *card = (pc300_t *) chan->card; 1803 pc300_t *card = (pc300_t *) chan->card;
1806 struct net_device_stats *stats = hdlc_stats(dev);
1807 int ch = chan->channel; 1804 int ch = chan->channel;
1808 unsigned long flags; 1805 unsigned long flags;
1809#ifdef PC300_DEBUG_TX 1806#ifdef PC300_DEBUG_TX
@@ -1817,13 +1814,13 @@ static int cpc_queue_xmit(struct sk_buff *skb, struct net_device *dev)
1817 } else if (!netif_carrier_ok(dev)) { 1814 } else if (!netif_carrier_ok(dev)) {
1818 /* DCD must be OFF: drop packet */ 1815 /* DCD must be OFF: drop packet */
1819 dev_kfree_skb(skb); 1816 dev_kfree_skb(skb);
1820 stats->tx_errors++; 1817 dev->stats.tx_errors++;
1821 stats->tx_carrier_errors++; 1818 dev->stats.tx_carrier_errors++;
1822 return 0; 1819 return 0;
1823 } else if (cpc_readb(card->hw.scabase + M_REG(ST3, ch)) & ST3_DCD) { 1820 } else if (cpc_readb(card->hw.scabase + M_REG(ST3, ch)) & ST3_DCD) {
1824 printk("%s: DCD is OFF. Going administrative down.\n", dev->name); 1821 printk("%s: DCD is OFF. Going administrative down.\n", dev->name);
1825 stats->tx_errors++; 1822 dev->stats.tx_errors++;
1826 stats->tx_carrier_errors++; 1823 dev->stats.tx_carrier_errors++;
1827 dev_kfree_skb(skb); 1824 dev_kfree_skb(skb);
1828 netif_carrier_off(dev); 1825 netif_carrier_off(dev);
1829 CPC_LOCK(card, flags); 1826 CPC_LOCK(card, flags);
@@ -1843,8 +1840,8 @@ static int cpc_queue_xmit(struct sk_buff *skb, struct net_device *dev)
1843// printk("%s: write error. Dropping TX packet.\n", dev->name); 1840// printk("%s: write error. Dropping TX packet.\n", dev->name);
1844 netif_stop_queue(dev); 1841 netif_stop_queue(dev);
1845 dev_kfree_skb(skb); 1842 dev_kfree_skb(skb);
1846 stats->tx_errors++; 1843 dev->stats.tx_errors++;
1847 stats->tx_dropped++; 1844 dev->stats.tx_dropped++;
1848 return 0; 1845 return 0;
1849 } 1846 }
1850#ifdef PC300_DEBUG_TX 1847#ifdef PC300_DEBUG_TX
@@ -1886,7 +1883,6 @@ static void cpc_net_rx(struct net_device *dev)
1886 pc300dev_t *d = (pc300dev_t *) dev->priv; 1883 pc300dev_t *d = (pc300dev_t *) dev->priv;
1887 pc300ch_t *chan = (pc300ch_t *) d->chan; 1884 pc300ch_t *chan = (pc300ch_t *) d->chan;
1888 pc300_t *card = (pc300_t *) chan->card; 1885 pc300_t *card = (pc300_t *) chan->card;
1889 struct net_device_stats *stats = hdlc_stats(dev);
1890 int ch = chan->channel; 1886 int ch = chan->channel;
1891#ifdef PC300_DEBUG_RX 1887#ifdef PC300_DEBUG_RX
1892 int i; 1888 int i;
@@ -1922,24 +1918,24 @@ static void cpc_net_rx(struct net_device *dev)
1922#endif 1918#endif
1923 if ((skb == NULL) && (rxb > 0)) { 1919 if ((skb == NULL) && (rxb > 0)) {
1924 /* rxb > dev->mtu */ 1920 /* rxb > dev->mtu */
1925 stats->rx_errors++; 1921 dev->stats.rx_errors++;
1926 stats->rx_length_errors++; 1922 dev->stats.rx_length_errors++;
1927 continue; 1923 continue;
1928 } 1924 }
1929 1925
1930 if (rxb < 0) { /* Invalid frame */ 1926 if (rxb < 0) { /* Invalid frame */
1931 rxb = -rxb; 1927 rxb = -rxb;
1932 if (rxb & DST_OVR) { 1928 if (rxb & DST_OVR) {
1933 stats->rx_errors++; 1929 dev->stats.rx_errors++;
1934 stats->rx_fifo_errors++; 1930 dev->stats.rx_fifo_errors++;
1935 } 1931 }
1936 if (rxb & DST_CRC) { 1932 if (rxb & DST_CRC) {
1937 stats->rx_errors++; 1933 dev->stats.rx_errors++;
1938 stats->rx_crc_errors++; 1934 dev->stats.rx_crc_errors++;
1939 } 1935 }
1940 if (rxb & (DST_RBIT | DST_SHRT | DST_ABT)) { 1936 if (rxb & (DST_RBIT | DST_SHRT | DST_ABT)) {
1941 stats->rx_errors++; 1937 dev->stats.rx_errors++;
1942 stats->rx_frame_errors++; 1938 dev->stats.rx_frame_errors++;
1943 } 1939 }
1944 } 1940 }
1945 if (skb) { 1941 if (skb) {
@@ -1948,7 +1944,7 @@ static void cpc_net_rx(struct net_device *dev)
1948 continue; 1944 continue;
1949 } 1945 }
1950 1946
1951 stats->rx_bytes += rxb; 1947 dev->stats.rx_bytes += rxb;
1952 1948
1953#ifdef PC300_DEBUG_RX 1949#ifdef PC300_DEBUG_RX
1954 printk("%s R:", dev->name); 1950 printk("%s R:", dev->name);
@@ -1959,7 +1955,7 @@ static void cpc_net_rx(struct net_device *dev)
1959 if (d->trace_on) { 1955 if (d->trace_on) {
1960 cpc_trace(dev, skb, 'R'); 1956 cpc_trace(dev, skb, 'R');
1961 } 1957 }
1962 stats->rx_packets++; 1958 dev->stats.rx_packets++;
1963 skb->protocol = hdlc_type_trans(skb, dev); 1959 skb->protocol = hdlc_type_trans(skb, dev);
1964 netif_rx(skb); 1960 netif_rx(skb);
1965 } 1961 }
@@ -1974,16 +1970,15 @@ static void sca_tx_intr(pc300dev_t *dev)
1974 pc300_t *card = (pc300_t *)chan->card; 1970 pc300_t *card = (pc300_t *)chan->card;
1975 int ch = chan->channel; 1971 int ch = chan->channel;
1976 volatile pcsca_bd_t __iomem * ptdescr; 1972 volatile pcsca_bd_t __iomem * ptdescr;
1977 struct net_device_stats *stats = hdlc_stats(dev->dev);
1978 1973
1979 /* Clean up descriptors from previous transmission */ 1974 /* Clean up descriptors from previous transmission */
1980 ptdescr = (card->hw.rambase + 1975 ptdescr = (card->hw.rambase +
1981 TX_BD_ADDR(ch,chan->tx_first_bd)); 1976 TX_BD_ADDR(ch,chan->tx_first_bd));
1982 while ((cpc_readl(card->hw.scabase + DTX_REG(CDAL,ch)) != 1977 while ((cpc_readl(card->hw.scabase + DTX_REG(CDAL,ch)) !=
1983 TX_BD_ADDR(ch,chan->tx_first_bd)) && 1978 TX_BD_ADDR(ch,chan->tx_first_bd)) &&
1984 (cpc_readb(&ptdescr->status) & DST_OSB)) { 1979 (cpc_readb(&ptdescr->status) & DST_OSB)) {
1985 stats->tx_packets++; 1980 dev->dev->stats.tx_packets++;
1986 stats->tx_bytes += cpc_readw(&ptdescr->len); 1981 dev->dev->stats.tx_bytes += cpc_readw(&ptdescr->len);
1987 cpc_writeb(&ptdescr->status, DST_OSB); 1982 cpc_writeb(&ptdescr->status, DST_OSB);
1988 cpc_writew(&ptdescr->len, 0); 1983 cpc_writew(&ptdescr->len, 0);
1989 chan->nfree_tx_bd++; 1984 chan->nfree_tx_bd++;
@@ -2048,8 +2043,8 @@ static void sca_intr(pc300_t * card)
2048 } 2043 }
2049 cpc_net_rx(dev); 2044 cpc_net_rx(dev);
2050 /* Discard invalid frames */ 2045 /* Discard invalid frames */
2051 hdlc_stats(dev)->rx_errors++; 2046 dev->stats.rx_errors++;
2052 hdlc_stats(dev)->rx_over_errors++; 2047 dev->stats.rx_over_errors++;
2053 chan->rx_first_bd = 0; 2048 chan->rx_first_bd = 0;
2054 chan->rx_last_bd = N_DMA_RX_BUF - 1; 2049 chan->rx_last_bd = N_DMA_RX_BUF - 1;
2055 rx_dma_start(card, ch); 2050 rx_dma_start(card, ch);
@@ -2115,8 +2110,8 @@ static void sca_intr(pc300_t * card)
2115 card->hw.cpld_reg2) & 2110 card->hw.cpld_reg2) &
2116 ~ (CPLD_REG2_FALC_LED1 << (2 * ch))); 2111 ~ (CPLD_REG2_FALC_LED1 << (2 * ch)));
2117 } 2112 }
2118 hdlc_stats(dev)->tx_errors++; 2113 dev->stats.tx_errors++;
2119 hdlc_stats(dev)->tx_fifo_errors++; 2114 dev->stats.tx_fifo_errors++;
2120 sca_tx_intr(d); 2115 sca_tx_intr(d);
2121 } 2116 }
2122 } 2117 }
@@ -2604,7 +2599,7 @@ static int cpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
2604 case SIOCGPC300UTILSTATS: 2599 case SIOCGPC300UTILSTATS:
2605 { 2600 {
2606 if (!arg) { /* clear statistics */ 2601 if (!arg) { /* clear statistics */
2607 memset(hdlc_stats(dev), 0, sizeof(struct net_device_stats)); 2602 memset(&dev->stats, 0, sizeof(dev->stats));
2608 if (card->hw.type == PC300_TE) { 2603 if (card->hw.type == PC300_TE) {
2609 memset(&chan->falc, 0, sizeof(falc_t)); 2604 memset(&chan->falc, 0, sizeof(falc_t));
2610 } 2605 }
@@ -2615,8 +2610,8 @@ static int cpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
2615 pc300stats.hw_type = card->hw.type; 2610 pc300stats.hw_type = card->hw.type;
2616 pc300stats.line_on = card->chan[ch].d.line_on; 2611 pc300stats.line_on = card->chan[ch].d.line_on;
2617 pc300stats.line_off = card->chan[ch].d.line_off; 2612 pc300stats.line_off = card->chan[ch].d.line_off;
2618 memcpy(&pc300stats.gen_stats, hdlc_stats(dev), 2613 memcpy(&pc300stats.gen_stats, &dev->stats,
2619 sizeof(struct net_device_stats)); 2614 sizeof(dev->stats));
2620 if (card->hw.type == PC300_TE) 2615 if (card->hw.type == PC300_TE)
2621 memcpy(&pc300stats.te_stats,&chan->falc,sizeof(falc_t)); 2616 memcpy(&pc300stats.te_stats,&chan->falc,sizeof(falc_t));
2622 if (copy_to_user(arg, &pc300stats, sizeof(pc300stats_t))) 2617 if (copy_to_user(arg, &pc300stats, sizeof(pc300stats_t)))
@@ -2823,11 +2818,6 @@ static int cpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
2823 } 2818 }
2824} 2819}
2825 2820
2826static struct net_device_stats *cpc_get_stats(struct net_device *dev)
2827{
2828 return hdlc_stats(dev);
2829}
2830
2831static int clock_rate_calc(uclong rate, uclong clock, int *br_io) 2821static int clock_rate_calc(uclong rate, uclong clock, int *br_io)
2832{ 2822{
2833 int br, tc; 2823 int br, tc;
@@ -3394,7 +3384,6 @@ static void cpc_init_card(pc300_t * card)
3394 dev->stop = cpc_close; 3384 dev->stop = cpc_close;
3395 dev->tx_timeout = cpc_tx_timeout; 3385 dev->tx_timeout = cpc_tx_timeout;
3396 dev->watchdog_timeo = PC300_TX_TIMEOUT; 3386 dev->watchdog_timeo = PC300_TX_TIMEOUT;
3397 dev->get_stats = cpc_get_stats;
3398 dev->set_multicast_list = NULL; 3387 dev->set_multicast_list = NULL;
3399 dev->set_mac_address = NULL; 3388 dev->set_mac_address = NULL;
3400 dev->change_mtu = cpc_change_mtu; 3389 dev->change_mtu = cpc_change_mtu;