aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@vyatta.com>2008-04-02 13:11:20 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-04-16 20:41:34 -0400
commit9c28eaea90aef8db20004d29f924ad3059d9704e (patch)
treeaf689acdc80293efba164493008698c68ebab45b /drivers
parent10c6462090cccb643f31e26a14cb933bc31d8666 (diff)
sc92031: use net_device stats
Statistics structure is available for use in net_device structure. Compile tested only. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/sc92031.c70
1 files changed, 34 insertions, 36 deletions
diff --git a/drivers/net/sc92031.c b/drivers/net/sc92031.c
index 15fcee55284e..af0422da6f99 100644
--- a/drivers/net/sc92031.c
+++ b/drivers/net/sc92031.c
@@ -311,7 +311,6 @@ struct sc92031_priv {
311 311
312 /* for dev->get_stats */ 312 /* for dev->get_stats */
313 long rx_value; 313 long rx_value;
314 struct net_device_stats stats;
315}; 314};
316 315
317/* I don't know which registers can be safely read; however, I can guess 316/* I don't know which registers can be safely read; however, I can guess
@@ -421,7 +420,7 @@ static void _sc92031_tx_clear(struct net_device *dev)
421 420
422 while (priv->tx_head - priv->tx_tail > 0) { 421 while (priv->tx_head - priv->tx_tail > 0) {
423 priv->tx_tail++; 422 priv->tx_tail++;
424 priv->stats.tx_dropped++; 423 dev->stats.tx_dropped++;
425 } 424 }
426 priv->tx_head = priv->tx_tail = 0; 425 priv->tx_head = priv->tx_tail = 0;
427} 426}
@@ -676,27 +675,27 @@ static void _sc92031_tx_tasklet(struct net_device *dev)
676 priv->tx_tail++; 675 priv->tx_tail++;
677 676
678 if (tx_status & TxStatOK) { 677 if (tx_status & TxStatOK) {
679 priv->stats.tx_bytes += tx_status & 0x1fff; 678 dev->stats.tx_bytes += tx_status & 0x1fff;
680 priv->stats.tx_packets++; 679 dev->stats.tx_packets++;
681 /* Note: TxCarrierLost is always asserted at 100mbps. */ 680 /* Note: TxCarrierLost is always asserted at 100mbps. */
682 priv->stats.collisions += (tx_status >> 22) & 0xf; 681 dev->stats.collisions += (tx_status >> 22) & 0xf;
683 } 682 }
684 683
685 if (tx_status & (TxOutOfWindow | TxAborted)) { 684 if (tx_status & (TxOutOfWindow | TxAborted)) {
686 priv->stats.tx_errors++; 685 dev->stats.tx_errors++;
687 686
688 if (tx_status & TxAborted) 687 if (tx_status & TxAborted)
689 priv->stats.tx_aborted_errors++; 688 dev->stats.tx_aborted_errors++;
690 689
691 if (tx_status & TxCarrierLost) 690 if (tx_status & TxCarrierLost)
692 priv->stats.tx_carrier_errors++; 691 dev->stats.tx_carrier_errors++;
693 692
694 if (tx_status & TxOutOfWindow) 693 if (tx_status & TxOutOfWindow)
695 priv->stats.tx_window_errors++; 694 dev->stats.tx_window_errors++;
696 } 695 }
697 696
698 if (tx_status & TxUnderrun) 697 if (tx_status & TxUnderrun)
699 priv->stats.tx_fifo_errors++; 698 dev->stats.tx_fifo_errors++;
700 } 699 }
701 700
702 if (priv->tx_tail != old_tx_tail) 701 if (priv->tx_tail != old_tx_tail)
@@ -704,27 +703,29 @@ static void _sc92031_tx_tasklet(struct net_device *dev)
704 netif_wake_queue(dev); 703 netif_wake_queue(dev);
705} 704}
706 705
707static void _sc92031_rx_tasklet_error(u32 rx_status, 706static void _sc92031_rx_tasklet_error(struct net_device *dev,
708 struct sc92031_priv *priv, unsigned rx_size) 707 u32 rx_status, unsigned rx_size)
709{ 708{
710 if(rx_size > (MAX_ETH_FRAME_SIZE + 4) || rx_size < 16) { 709 if(rx_size > (MAX_ETH_FRAME_SIZE + 4) || rx_size < 16) {
711 priv->stats.rx_errors++; 710 dev->stats.rx_errors++;
712 priv->stats.rx_length_errors++; 711 dev->stats.rx_length_errors++;
713 } 712 }
714 713
715 if (!(rx_status & RxStatesOK)) { 714 if (!(rx_status & RxStatesOK)) {
716 priv->stats.rx_errors++; 715 dev->stats.rx_errors++;
717 716
718 if (rx_status & (RxHugeFrame | RxSmallFrame)) 717 if (rx_status & (RxHugeFrame | RxSmallFrame))
719 priv->stats.rx_length_errors++; 718 dev->stats.rx_length_errors++;
720 719
721 if (rx_status & RxBadAlign) 720 if (rx_status & RxBadAlign)
722 priv->stats.rx_frame_errors++; 721 dev->stats.rx_frame_errors++;
723 722
724 if (!(rx_status & RxCRCOK)) 723 if (!(rx_status & RxCRCOK))
725 priv->stats.rx_crc_errors++; 724 dev->stats.rx_crc_errors++;
726 } else 725 } else {
726 struct sc92031_priv *priv = netdev_priv(dev);
727 priv->rx_loss++; 727 priv->rx_loss++;
728 }
728} 729}
729 730
730static void _sc92031_rx_tasklet(struct net_device *dev) 731static void _sc92031_rx_tasklet(struct net_device *dev)
@@ -783,7 +784,7 @@ static void _sc92031_rx_tasklet(struct net_device *dev)
783 || rx_size > (MAX_ETH_FRAME_SIZE + 4) 784 || rx_size > (MAX_ETH_FRAME_SIZE + 4)
784 || rx_size < 16 785 || rx_size < 16
785 || !(rx_status & RxStatesOK))) { 786 || !(rx_status & RxStatesOK))) {
786 _sc92031_rx_tasklet_error(rx_status, priv, rx_size); 787 _sc92031_rx_tasklet_error(dev, rx_status, rx_size);
787 break; 788 break;
788 } 789 }
789 790
@@ -818,11 +819,11 @@ static void _sc92031_rx_tasklet(struct net_device *dev)
818 dev->last_rx = jiffies; 819 dev->last_rx = jiffies;
819 netif_rx(skb); 820 netif_rx(skb);
820 821
821 priv->stats.rx_bytes += pkt_size; 822 dev->stats.rx_bytes += pkt_size;
822 priv->stats.rx_packets++; 823 dev->stats.rx_packets++;
823 824
824 if (rx_status & Rx_Multicast) 825 if (rx_status & Rx_Multicast)
825 priv->stats.multicast++; 826 dev->stats.multicast++;
826 827
827 next: 828 next:
828 rx_ring_offset = (rx_ring_offset + rx_size_align) % RX_BUF_LEN; 829 rx_ring_offset = (rx_ring_offset + rx_size_align) % RX_BUF_LEN;
@@ -835,13 +836,11 @@ static void _sc92031_rx_tasklet(struct net_device *dev)
835 836
836static void _sc92031_link_tasklet(struct net_device *dev) 837static void _sc92031_link_tasklet(struct net_device *dev)
837{ 838{
838 struct sc92031_priv *priv = netdev_priv(dev);
839
840 if (_sc92031_check_media(dev)) 839 if (_sc92031_check_media(dev))
841 netif_wake_queue(dev); 840 netif_wake_queue(dev);
842 else { 841 else {
843 netif_stop_queue(dev); 842 netif_stop_queue(dev);
844 priv->stats.tx_carrier_errors++; 843 dev->stats.tx_carrier_errors++;
845 } 844 }
846} 845}
847 846
@@ -866,11 +865,11 @@ static void sc92031_tasklet(unsigned long data)
866 _sc92031_rx_tasklet(dev); 865 _sc92031_rx_tasklet(dev);
867 866
868 if (intr_status & RxOverflow) 867 if (intr_status & RxOverflow)
869 priv->stats.rx_errors++; 868 dev->stats.rx_errors++;
870 869
871 if (intr_status & TimeOut) { 870 if (intr_status & TimeOut) {
872 priv->stats.rx_errors++; 871 dev->stats.rx_errors++;
873 priv->stats.rx_length_errors++; 872 dev->stats.rx_length_errors++;
874 } 873 }
875 874
876 if (intr_status & (LinkFail | LinkOK)) 875 if (intr_status & (LinkFail | LinkOK))
@@ -936,15 +935,14 @@ static struct net_device_stats *sc92031_get_stats(struct net_device *dev)
936 935
937 if (temp == 0xffff) { 936 if (temp == 0xffff) {
938 priv->rx_value += temp; 937 priv->rx_value += temp;
939 priv->stats.rx_fifo_errors = priv->rx_value; 938 dev->stats.rx_fifo_errors = priv->rx_value;
940 } else { 939 } else
941 priv->stats.rx_fifo_errors = temp + priv->rx_value; 940 dev->stats.rx_fifo_errors = temp + priv->rx_value;
942 }
943 941
944 spin_unlock_bh(&priv->lock); 942 spin_unlock_bh(&priv->lock);
945 } 943 }
946 944
947 return &priv->stats; 945 return &dev->stats;
948} 946}
949 947
950static int sc92031_start_xmit(struct sk_buff *skb, struct net_device *dev) 948static int sc92031_start_xmit(struct sk_buff *skb, struct net_device *dev)
@@ -959,7 +957,7 @@ static int sc92031_start_xmit(struct sk_buff *skb, struct net_device *dev)
959 957
960 if (unlikely(skb->len > TX_BUF_SIZE)) { 958 if (unlikely(skb->len > TX_BUF_SIZE)) {
961 err = -EMSGSIZE; 959 err = -EMSGSIZE;
962 priv->stats.tx_dropped++; 960 dev->stats.tx_dropped++;
963 goto out; 961 goto out;
964 } 962 }
965 963
@@ -967,7 +965,7 @@ static int sc92031_start_xmit(struct sk_buff *skb, struct net_device *dev)
967 965
968 if (unlikely(!netif_carrier_ok(dev))) { 966 if (unlikely(!netif_carrier_ok(dev))) {
969 err = -ENOLINK; 967 err = -ENOLINK;
970 priv->stats.tx_dropped++; 968 dev->stats.tx_dropped++;
971 goto out_unlock; 969 goto out_unlock;
972 } 970 }
973 971