diff options
author | Stephen Hemminger <shemminger@vyatta.com> | 2009-01-07 21:01:40 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-01-07 21:01:40 -0500 |
commit | dfefe02bfd865c18eeaebc07ff1cd50120c40c20 (patch) | |
tree | 0a79b3aa5845a6192b4d1a8b5e54946cc9e2b06c | |
parent | 2765df58986ac4382b70bf31be70a64a7a9eaf4c (diff) |
uli526x: convert devices to new API
Convert to net_device_ops and internal net_device_stats
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/tulip/uli526x.c | 63 |
1 files changed, 27 insertions, 36 deletions
diff --git a/drivers/net/tulip/uli526x.c b/drivers/net/tulip/uli526x.c index 00cbc5251dcc..030e02e63023 100644 --- a/drivers/net/tulip/uli526x.c +++ b/drivers/net/tulip/uli526x.c | |||
@@ -168,9 +168,6 @@ struct uli526x_board_info { | |||
168 | u8 wait_reset; /* Hardware failed, need to reset */ | 168 | u8 wait_reset; /* Hardware failed, need to reset */ |
169 | struct timer_list timer; | 169 | struct timer_list timer; |
170 | 170 | ||
171 | /* System defined statistic counter */ | ||
172 | struct net_device_stats stats; | ||
173 | |||
174 | /* Driver defined statistic counter */ | 171 | /* Driver defined statistic counter */ |
175 | unsigned long tx_fifo_underrun; | 172 | unsigned long tx_fifo_underrun; |
176 | unsigned long tx_loss_carrier; | 173 | unsigned long tx_loss_carrier; |
@@ -220,7 +217,6 @@ static int mode = 8; | |||
220 | static int uli526x_open(struct net_device *); | 217 | static int uli526x_open(struct net_device *); |
221 | static int uli526x_start_xmit(struct sk_buff *, struct net_device *); | 218 | static int uli526x_start_xmit(struct sk_buff *, struct net_device *); |
222 | static int uli526x_stop(struct net_device *); | 219 | static int uli526x_stop(struct net_device *); |
223 | static struct net_device_stats * uli526x_get_stats(struct net_device *); | ||
224 | static void uli526x_set_filter_mode(struct net_device *); | 220 | static void uli526x_set_filter_mode(struct net_device *); |
225 | static const struct ethtool_ops netdev_ethtool_ops; | 221 | static const struct ethtool_ops netdev_ethtool_ops; |
226 | static u16 read_srom_word(long, int); | 222 | static u16 read_srom_word(long, int); |
@@ -251,6 +247,19 @@ static void uli526x_set_phyxcer(struct uli526x_board_info *); | |||
251 | 247 | ||
252 | /* ULI526X network board routine ---------------------------- */ | 248 | /* ULI526X network board routine ---------------------------- */ |
253 | 249 | ||
250 | static const struct net_device_ops netdev_ops = { | ||
251 | .ndo_open = uli526x_open, | ||
252 | .ndo_stop = uli526x_stop, | ||
253 | .ndo_start_xmit = uli526x_start_xmit, | ||
254 | .ndo_set_multicast_list = uli526x_set_filter_mode, | ||
255 | .ndo_change_mtu = eth_change_mtu, | ||
256 | .ndo_set_mac_address = eth_mac_addr, | ||
257 | .ndo_validate_addr = eth_validate_addr, | ||
258 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
259 | .ndo_poll_controller = uli526x_poll, | ||
260 | #endif | ||
261 | }; | ||
262 | |||
254 | /* | 263 | /* |
255 | * Search ULI526X board, allocate space and register it | 264 | * Search ULI526X board, allocate space and register it |
256 | */ | 265 | */ |
@@ -335,15 +344,9 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev, | |||
335 | pci_set_drvdata(pdev, dev); | 344 | pci_set_drvdata(pdev, dev); |
336 | 345 | ||
337 | /* Register some necessary functions */ | 346 | /* Register some necessary functions */ |
338 | dev->open = &uli526x_open; | 347 | dev->netdev_ops = &netdev_ops; |
339 | dev->hard_start_xmit = &uli526x_start_xmit; | ||
340 | dev->stop = &uli526x_stop; | ||
341 | dev->get_stats = &uli526x_get_stats; | ||
342 | dev->set_multicast_list = &uli526x_set_filter_mode; | ||
343 | dev->ethtool_ops = &netdev_ethtool_ops; | 348 | dev->ethtool_ops = &netdev_ethtool_ops; |
344 | #ifdef CONFIG_NET_POLL_CONTROLLER | 349 | |
345 | dev->poll_controller = &uli526x_poll; | ||
346 | #endif | ||
347 | spin_lock_init(&db->lock); | 350 | spin_lock_init(&db->lock); |
348 | 351 | ||
349 | 352 | ||
@@ -733,7 +736,8 @@ static void uli526x_poll(struct net_device *dev) | |||
733 | * Free TX resource after TX complete | 736 | * Free TX resource after TX complete |
734 | */ | 737 | */ |
735 | 738 | ||
736 | static void uli526x_free_tx_pkt(struct net_device *dev, struct uli526x_board_info * db) | 739 | static void uli526x_free_tx_pkt(struct net_device *dev, |
740 | struct uli526x_board_info * db) | ||
737 | { | 741 | { |
738 | struct tx_desc *txptr; | 742 | struct tx_desc *txptr; |
739 | u32 tdes0; | 743 | u32 tdes0; |
@@ -747,15 +751,15 @@ static void uli526x_free_tx_pkt(struct net_device *dev, struct uli526x_board_inf | |||
747 | 751 | ||
748 | /* A packet sent completed */ | 752 | /* A packet sent completed */ |
749 | db->tx_packet_cnt--; | 753 | db->tx_packet_cnt--; |
750 | db->stats.tx_packets++; | 754 | dev->stats.tx_packets++; |
751 | 755 | ||
752 | /* Transmit statistic counter */ | 756 | /* Transmit statistic counter */ |
753 | if ( tdes0 != 0x7fffffff ) { | 757 | if ( tdes0 != 0x7fffffff ) { |
754 | /* printk(DRV_NAME ": tdes0=%x\n", tdes0); */ | 758 | /* printk(DRV_NAME ": tdes0=%x\n", tdes0); */ |
755 | db->stats.collisions += (tdes0 >> 3) & 0xf; | 759 | dev->stats.collisions += (tdes0 >> 3) & 0xf; |
756 | db->stats.tx_bytes += le32_to_cpu(txptr->tdes1) & 0x7ff; | 760 | dev->stats.tx_bytes += le32_to_cpu(txptr->tdes1) & 0x7ff; |
757 | if (tdes0 & TDES0_ERR_MASK) { | 761 | if (tdes0 & TDES0_ERR_MASK) { |
758 | db->stats.tx_errors++; | 762 | dev->stats.tx_errors++; |
759 | if (tdes0 & 0x0002) { /* UnderRun */ | 763 | if (tdes0 & 0x0002) { /* UnderRun */ |
760 | db->tx_fifo_underrun++; | 764 | db->tx_fifo_underrun++; |
761 | if ( !(db->cr6_data & CR6_SFT) ) { | 765 | if ( !(db->cr6_data & CR6_SFT) ) { |
@@ -825,13 +829,13 @@ static void uli526x_rx_packet(struct net_device *dev, struct uli526x_board_info | |||
825 | if (rdes0 & 0x8000) { | 829 | if (rdes0 & 0x8000) { |
826 | /* This is a error packet */ | 830 | /* This is a error packet */ |
827 | //printk(DRV_NAME ": rdes0: %lx\n", rdes0); | 831 | //printk(DRV_NAME ": rdes0: %lx\n", rdes0); |
828 | db->stats.rx_errors++; | 832 | dev->stats.rx_errors++; |
829 | if (rdes0 & 1) | 833 | if (rdes0 & 1) |
830 | db->stats.rx_fifo_errors++; | 834 | dev->stats.rx_fifo_errors++; |
831 | if (rdes0 & 2) | 835 | if (rdes0 & 2) |
832 | db->stats.rx_crc_errors++; | 836 | dev->stats.rx_crc_errors++; |
833 | if (rdes0 & 0x80) | 837 | if (rdes0 & 0x80) |
834 | db->stats.rx_length_errors++; | 838 | dev->stats.rx_length_errors++; |
835 | } | 839 | } |
836 | 840 | ||
837 | if ( !(rdes0 & 0x8000) || | 841 | if ( !(rdes0 & 0x8000) || |
@@ -854,8 +858,8 @@ static void uli526x_rx_packet(struct net_device *dev, struct uli526x_board_info | |||
854 | 858 | ||
855 | skb->protocol = eth_type_trans(skb, dev); | 859 | skb->protocol = eth_type_trans(skb, dev); |
856 | netif_rx(skb); | 860 | netif_rx(skb); |
857 | db->stats.rx_packets++; | 861 | dev->stats.rx_packets++; |
858 | db->stats.rx_bytes += rxlen; | 862 | dev->stats.rx_bytes += rxlen; |
859 | 863 | ||
860 | } else { | 864 | } else { |
861 | /* Reuse SKB buffer when the packet is error */ | 865 | /* Reuse SKB buffer when the packet is error */ |
@@ -872,19 +876,6 @@ static void uli526x_rx_packet(struct net_device *dev, struct uli526x_board_info | |||
872 | 876 | ||
873 | 877 | ||
874 | /* | 878 | /* |
875 | * Get statistics from driver. | ||
876 | */ | ||
877 | |||
878 | static struct net_device_stats * uli526x_get_stats(struct net_device *dev) | ||
879 | { | ||
880 | struct uli526x_board_info *db = netdev_priv(dev); | ||
881 | |||
882 | ULI526X_DBUG(0, "uli526x_get_stats", 0); | ||
883 | return &db->stats; | ||
884 | } | ||
885 | |||
886 | |||
887 | /* | ||
888 | * Set ULI526X multicast address | 879 | * Set ULI526X multicast address |
889 | */ | 880 | */ |
890 | 881 | ||