diff options
author | Stephen Hemminger <shemminger@vyatta.com> | 2009-03-20 15:35:30 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-03-21 22:19:13 -0400 |
commit | 687c75dcf342f71329bd193af553e96a29581238 (patch) | |
tree | 44486e047227112d61c55e8597cc1e45b2e51d85 /drivers/infiniband/hw | |
parent | dde09758557120cb71fb760cfeaed1b8e27209ef (diff) |
infiniband: convert c2 to net_device_ops
Convert this driver to new net_device_ops infrastructure.
Also use default net_device get-stats infrastructure
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Reviewed-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/infiniband/hw')
-rw-r--r-- | drivers/infiniband/hw/amso1100/c2.c | 41 | ||||
-rw-r--r-- | drivers/infiniband/hw/amso1100/c2.h | 2 | ||||
-rw-r--r-- | drivers/infiniband/hw/amso1100/c2_provider.c | 22 |
3 files changed, 30 insertions, 35 deletions
diff --git a/drivers/infiniband/hw/amso1100/c2.c b/drivers/infiniband/hw/amso1100/c2.c index 113f3c03c5b5..7d79aa361e26 100644 --- a/drivers/infiniband/hw/amso1100/c2.c +++ b/drivers/infiniband/hw/amso1100/c2.c | |||
@@ -76,7 +76,6 @@ static irqreturn_t c2_interrupt(int irq, void *dev_id); | |||
76 | static void c2_tx_timeout(struct net_device *netdev); | 76 | static void c2_tx_timeout(struct net_device *netdev); |
77 | static int c2_change_mtu(struct net_device *netdev, int new_mtu); | 77 | static int c2_change_mtu(struct net_device *netdev, int new_mtu); |
78 | static void c2_reset(struct c2_port *c2_port); | 78 | static void c2_reset(struct c2_port *c2_port); |
79 | static struct net_device_stats *c2_get_stats(struct net_device *netdev); | ||
80 | 79 | ||
81 | static struct pci_device_id c2_pci_table[] = { | 80 | static struct pci_device_id c2_pci_table[] = { |
82 | { PCI_DEVICE(0x18b8, 0xb001) }, | 81 | { PCI_DEVICE(0x18b8, 0xb001) }, |
@@ -349,7 +348,7 @@ static void c2_tx_clean(struct c2_port *c2_port) | |||
349 | elem->hw_desc + C2_TXP_ADDR); | 348 | elem->hw_desc + C2_TXP_ADDR); |
350 | __raw_writew((__force u16) cpu_to_be16(TXP_HTXD_DONE), | 349 | __raw_writew((__force u16) cpu_to_be16(TXP_HTXD_DONE), |
351 | elem->hw_desc + C2_TXP_FLAGS); | 350 | elem->hw_desc + C2_TXP_FLAGS); |
352 | c2_port->netstats.tx_dropped++; | 351 | c2_port->netdev->stats.tx_dropped++; |
353 | break; | 352 | break; |
354 | } else { | 353 | } else { |
355 | __raw_writew(0, | 354 | __raw_writew(0, |
@@ -457,7 +456,7 @@ static void c2_rx_error(struct c2_port *c2_port, struct c2_element *elem) | |||
457 | elem->hw_desc + C2_RXP_FLAGS); | 456 | elem->hw_desc + C2_RXP_FLAGS); |
458 | 457 | ||
459 | pr_debug("packet dropped\n"); | 458 | pr_debug("packet dropped\n"); |
460 | c2_port->netstats.rx_dropped++; | 459 | c2_port->netdev->stats.rx_dropped++; |
461 | } | 460 | } |
462 | 461 | ||
463 | static void c2_rx_interrupt(struct net_device *netdev) | 462 | static void c2_rx_interrupt(struct net_device *netdev) |
@@ -532,8 +531,8 @@ static void c2_rx_interrupt(struct net_device *netdev) | |||
532 | netif_rx(skb); | 531 | netif_rx(skb); |
533 | 532 | ||
534 | netdev->last_rx = jiffies; | 533 | netdev->last_rx = jiffies; |
535 | c2_port->netstats.rx_packets++; | 534 | netdev->stats.rx_packets++; |
536 | c2_port->netstats.rx_bytes += buflen; | 535 | netdev->stats.rx_bytes += buflen; |
537 | } | 536 | } |
538 | 537 | ||
539 | /* Save where we left off */ | 538 | /* Save where we left off */ |
@@ -797,8 +796,8 @@ static int c2_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
797 | __raw_writew((__force u16) cpu_to_be16(TXP_HTXD_READY), | 796 | __raw_writew((__force u16) cpu_to_be16(TXP_HTXD_READY), |
798 | elem->hw_desc + C2_TXP_FLAGS); | 797 | elem->hw_desc + C2_TXP_FLAGS); |
799 | 798 | ||
800 | c2_port->netstats.tx_packets++; | 799 | netdev->stats.tx_packets++; |
801 | c2_port->netstats.tx_bytes += maplen; | 800 | netdev->stats.tx_bytes += maplen; |
802 | 801 | ||
803 | /* Loop thru additional data fragments and queue them */ | 802 | /* Loop thru additional data fragments and queue them */ |
804 | if (skb_shinfo(skb)->nr_frags) { | 803 | if (skb_shinfo(skb)->nr_frags) { |
@@ -823,8 +822,8 @@ static int c2_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
823 | __raw_writew((__force u16) cpu_to_be16(TXP_HTXD_READY), | 822 | __raw_writew((__force u16) cpu_to_be16(TXP_HTXD_READY), |
824 | elem->hw_desc + C2_TXP_FLAGS); | 823 | elem->hw_desc + C2_TXP_FLAGS); |
825 | 824 | ||
826 | c2_port->netstats.tx_packets++; | 825 | netdev->stats.tx_packets++; |
827 | c2_port->netstats.tx_bytes += maplen; | 826 | netdev->stats.tx_bytes += maplen; |
828 | } | 827 | } |
829 | } | 828 | } |
830 | 829 | ||
@@ -845,13 +844,6 @@ static int c2_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
845 | return NETDEV_TX_OK; | 844 | return NETDEV_TX_OK; |
846 | } | 845 | } |
847 | 846 | ||
848 | static struct net_device_stats *c2_get_stats(struct net_device *netdev) | ||
849 | { | ||
850 | struct c2_port *c2_port = netdev_priv(netdev); | ||
851 | |||
852 | return &c2_port->netstats; | ||
853 | } | ||
854 | |||
855 | static void c2_tx_timeout(struct net_device *netdev) | 847 | static void c2_tx_timeout(struct net_device *netdev) |
856 | { | 848 | { |
857 | struct c2_port *c2_port = netdev_priv(netdev); | 849 | struct c2_port *c2_port = netdev_priv(netdev); |
@@ -880,6 +872,16 @@ static int c2_change_mtu(struct net_device *netdev, int new_mtu) | |||
880 | return ret; | 872 | return ret; |
881 | } | 873 | } |
882 | 874 | ||
875 | static const struct net_device_ops c2_netdev = { | ||
876 | .ndo_open = c2_up, | ||
877 | .ndo_stop = c2_down, | ||
878 | .ndo_start_xmit = c2_xmit_frame, | ||
879 | .ndo_tx_timeout = c2_tx_timeout, | ||
880 | .ndo_change_mtu = c2_change_mtu, | ||
881 | .ndo_set_mac_address = eth_mac_addr, | ||
882 | .ndo_validate_addr = eth_validate_addr, | ||
883 | }; | ||
884 | |||
883 | /* Initialize network device */ | 885 | /* Initialize network device */ |
884 | static struct net_device *c2_devinit(struct c2_dev *c2dev, | 886 | static struct net_device *c2_devinit(struct c2_dev *c2dev, |
885 | void __iomem * mmio_addr) | 887 | void __iomem * mmio_addr) |
@@ -894,12 +896,7 @@ static struct net_device *c2_devinit(struct c2_dev *c2dev, | |||
894 | 896 | ||
895 | SET_NETDEV_DEV(netdev, &c2dev->pcidev->dev); | 897 | SET_NETDEV_DEV(netdev, &c2dev->pcidev->dev); |
896 | 898 | ||
897 | netdev->open = c2_up; | 899 | netdev->netdev_ops = &c2_netdev; |
898 | netdev->stop = c2_down; | ||
899 | netdev->hard_start_xmit = c2_xmit_frame; | ||
900 | netdev->get_stats = c2_get_stats; | ||
901 | netdev->tx_timeout = c2_tx_timeout; | ||
902 | netdev->change_mtu = c2_change_mtu; | ||
903 | netdev->watchdog_timeo = C2_TX_TIMEOUT; | 900 | netdev->watchdog_timeo = C2_TX_TIMEOUT; |
904 | netdev->irq = c2dev->pcidev->irq; | 901 | netdev->irq = c2dev->pcidev->irq; |
905 | 902 | ||
diff --git a/drivers/infiniband/hw/amso1100/c2.h b/drivers/infiniband/hw/amso1100/c2.h index d12a24a84fd9..f7ff66f98361 100644 --- a/drivers/infiniband/hw/amso1100/c2.h +++ b/drivers/infiniband/hw/amso1100/c2.h | |||
@@ -369,8 +369,6 @@ struct c2_port { | |||
369 | unsigned long mem_size; | 369 | unsigned long mem_size; |
370 | 370 | ||
371 | u32 rx_buf_size; | 371 | u32 rx_buf_size; |
372 | |||
373 | struct net_device_stats netstats; | ||
374 | }; | 372 | }; |
375 | 373 | ||
376 | /* | 374 | /* |
diff --git a/drivers/infiniband/hw/amso1100/c2_provider.c b/drivers/infiniband/hw/amso1100/c2_provider.c index 5119d6508181..f1948fad85d7 100644 --- a/drivers/infiniband/hw/amso1100/c2_provider.c +++ b/drivers/infiniband/hw/amso1100/c2_provider.c | |||
@@ -708,26 +708,27 @@ static int c2_pseudo_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
708 | 708 | ||
709 | static int c2_pseudo_change_mtu(struct net_device *netdev, int new_mtu) | 709 | static int c2_pseudo_change_mtu(struct net_device *netdev, int new_mtu) |
710 | { | 710 | { |
711 | int ret = 0; | ||
712 | |||
713 | if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU) | 711 | if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU) |
714 | return -EINVAL; | 712 | return -EINVAL; |
715 | 713 | ||
716 | netdev->mtu = new_mtu; | 714 | netdev->mtu = new_mtu; |
717 | 715 | ||
718 | /* TODO: Tell rnic about new rmda interface mtu */ | 716 | /* TODO: Tell rnic about new rmda interface mtu */ |
719 | return ret; | 717 | return 0; |
720 | } | 718 | } |
721 | 719 | ||
720 | static const struct net_device_ops c2_pseudo_netdev_ops = { | ||
721 | .ndo_open = c2_pseudo_up, | ||
722 | .ndo_stop = c2_pseudo_down, | ||
723 | .ndo_start_xmit = c2_pseudo_xmit_frame, | ||
724 | .ndo_change_mtu = c2_pseudo_change_mtu, | ||
725 | .ndo_validate_addr = eth_validate_addr, | ||
726 | }; | ||
727 | |||
722 | static void setup(struct net_device *netdev) | 728 | static void setup(struct net_device *netdev) |
723 | { | 729 | { |
724 | netdev->open = c2_pseudo_up; | 730 | netdev->netdev_ops = &c2_pseudo_netdev_ops; |
725 | netdev->stop = c2_pseudo_down; | 731 | |
726 | netdev->hard_start_xmit = c2_pseudo_xmit_frame; | ||
727 | netdev->get_stats = NULL; | ||
728 | netdev->tx_timeout = NULL; | ||
729 | netdev->set_mac_address = NULL; | ||
730 | netdev->change_mtu = c2_pseudo_change_mtu; | ||
731 | netdev->watchdog_timeo = 0; | 732 | netdev->watchdog_timeo = 0; |
732 | netdev->type = ARPHRD_ETHER; | 733 | netdev->type = ARPHRD_ETHER; |
733 | netdev->mtu = 1500; | 734 | netdev->mtu = 1500; |
@@ -735,7 +736,6 @@ static void setup(struct net_device *netdev) | |||
735 | netdev->addr_len = ETH_ALEN; | 736 | netdev->addr_len = ETH_ALEN; |
736 | netdev->tx_queue_len = 0; | 737 | netdev->tx_queue_len = 0; |
737 | netdev->flags |= IFF_NOARP; | 738 | netdev->flags |= IFF_NOARP; |
738 | return; | ||
739 | } | 739 | } |
740 | 740 | ||
741 | static struct net_device *c2_pseudo_netdev_init(struct c2_dev *c2dev) | 741 | static struct net_device *c2_pseudo_netdev_init(struct c2_dev *c2dev) |