diff options
author | Michał Mirosław <mirq-linux@rere.qmqm.pl> | 2011-04-15 00:50:50 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-04-15 18:50:41 -0400 |
commit | 8b3afe95e363dbd32bd9ddc6c2d562944f5350c5 (patch) | |
tree | 6264c0376004f4dec5ed41ed54eff00806fb837a | |
parent | c8c64cff2c88b17fdd7402dd06288d7415896430 (diff) |
net: gianfar: convert to hw_features
Note: I bet that gfar_set_features() don't really need a full reset.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/gianfar.c | 16 | ||||
-rw-r--r-- | drivers/net/gianfar.h | 3 | ||||
-rw-r--r-- | drivers/net/gianfar_ethtool.c | 58 |
3 files changed, 16 insertions, 61 deletions
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index 2a0ad9a501bb..ff60b23a5b74 100644 --- a/drivers/net/gianfar.c +++ b/drivers/net/gianfar.c | |||
@@ -365,7 +365,7 @@ static void gfar_init_mac(struct net_device *ndev) | |||
365 | gfar_write(®s->rir0, DEFAULT_RIR0); | 365 | gfar_write(®s->rir0, DEFAULT_RIR0); |
366 | } | 366 | } |
367 | 367 | ||
368 | if (priv->rx_csum_enable) | 368 | if (ndev->features & NETIF_F_RXCSUM) |
369 | rctrl |= RCTRL_CHECKSUMMING; | 369 | rctrl |= RCTRL_CHECKSUMMING; |
370 | 370 | ||
371 | if (priv->extended_hash) { | 371 | if (priv->extended_hash) { |
@@ -463,6 +463,7 @@ static const struct net_device_ops gfar_netdev_ops = { | |||
463 | .ndo_start_xmit = gfar_start_xmit, | 463 | .ndo_start_xmit = gfar_start_xmit, |
464 | .ndo_stop = gfar_close, | 464 | .ndo_stop = gfar_close, |
465 | .ndo_change_mtu = gfar_change_mtu, | 465 | .ndo_change_mtu = gfar_change_mtu, |
466 | .ndo_set_features = gfar_set_features, | ||
466 | .ndo_set_multicast_list = gfar_set_multi, | 467 | .ndo_set_multicast_list = gfar_set_multi, |
467 | .ndo_tx_timeout = gfar_timeout, | 468 | .ndo_tx_timeout = gfar_timeout, |
468 | .ndo_do_ioctl = gfar_ioctl, | 469 | .ndo_do_ioctl = gfar_ioctl, |
@@ -513,7 +514,7 @@ void unlock_tx_qs(struct gfar_private *priv) | |||
513 | /* Returns 1 if incoming frames use an FCB */ | 514 | /* Returns 1 if incoming frames use an FCB */ |
514 | static inline int gfar_uses_fcb(struct gfar_private *priv) | 515 | static inline int gfar_uses_fcb(struct gfar_private *priv) |
515 | { | 516 | { |
516 | return priv->vlgrp || priv->rx_csum_enable || | 517 | return priv->vlgrp || (priv->ndev->features & NETIF_F_RXCSUM) || |
517 | (priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER); | 518 | (priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER); |
518 | } | 519 | } |
519 | 520 | ||
@@ -1030,10 +1031,11 @@ static int gfar_probe(struct platform_device *ofdev) | |||
1030 | netif_napi_add(dev, &priv->gfargrp[i].napi, gfar_poll, GFAR_DEV_WEIGHT); | 1031 | netif_napi_add(dev, &priv->gfargrp[i].napi, gfar_poll, GFAR_DEV_WEIGHT); |
1031 | 1032 | ||
1032 | if (priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM) { | 1033 | if (priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM) { |
1033 | priv->rx_csum_enable = 1; | 1034 | dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_SG | |
1034 | dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_HIGHDMA; | 1035 | NETIF_F_RXCSUM; |
1035 | } else | 1036 | dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG | |
1036 | priv->rx_csum_enable = 0; | 1037 | NETIF_F_RXCSUM | NETIF_F_HIGHDMA; |
1038 | } | ||
1037 | 1039 | ||
1038 | priv->vlgrp = NULL; | 1040 | priv->vlgrp = NULL; |
1039 | 1041 | ||
@@ -2697,7 +2699,7 @@ static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb, | |||
2697 | if (priv->padding) | 2699 | if (priv->padding) |
2698 | skb_pull(skb, priv->padding); | 2700 | skb_pull(skb, priv->padding); |
2699 | 2701 | ||
2700 | if (priv->rx_csum_enable) | 2702 | if (dev->features & NETIF_F_RXCSUM) |
2701 | gfar_rx_checksum(skb, fcb); | 2703 | gfar_rx_checksum(skb, fcb); |
2702 | 2704 | ||
2703 | /* Tell the skb what kind of packet this is */ | 2705 | /* Tell the skb what kind of packet this is */ |
diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h index 0438d3551d5c..fc86f5195445 100644 --- a/drivers/net/gianfar.h +++ b/drivers/net/gianfar.h | |||
@@ -1083,7 +1083,7 @@ struct gfar_private { | |||
1083 | struct device_node *phy_node; | 1083 | struct device_node *phy_node; |
1084 | struct device_node *tbi_node; | 1084 | struct device_node *tbi_node; |
1085 | u32 device_flags; | 1085 | u32 device_flags; |
1086 | unsigned char rx_csum_enable:1, | 1086 | unsigned char |
1087 | extended_hash:1, | 1087 | extended_hash:1, |
1088 | bd_stash_en:1, | 1088 | bd_stash_en:1, |
1089 | rx_filer_enable:1, | 1089 | rx_filer_enable:1, |
@@ -1153,6 +1153,7 @@ extern void gfar_phy_test(struct mii_bus *bus, struct phy_device *phydev, | |||
1153 | extern void gfar_configure_coalescing(struct gfar_private *priv, | 1153 | extern void gfar_configure_coalescing(struct gfar_private *priv, |
1154 | unsigned long tx_mask, unsigned long rx_mask); | 1154 | unsigned long tx_mask, unsigned long rx_mask); |
1155 | void gfar_init_sysfs(struct net_device *dev); | 1155 | void gfar_init_sysfs(struct net_device *dev); |
1156 | int gfar_set_features(struct net_device *dev, u32 features); | ||
1156 | 1157 | ||
1157 | extern const struct ethtool_ops gfar_ethtool_ops; | 1158 | extern const struct ethtool_ops gfar_ethtool_ops; |
1158 | 1159 | ||
diff --git a/drivers/net/gianfar_ethtool.c b/drivers/net/gianfar_ethtool.c index 0840590958dd..493d743839d9 100644 --- a/drivers/net/gianfar_ethtool.c +++ b/drivers/net/gianfar_ethtool.c | |||
@@ -517,15 +517,15 @@ static int gfar_sringparam(struct net_device *dev, struct ethtool_ringparam *rva | |||
517 | return err; | 517 | return err; |
518 | } | 518 | } |
519 | 519 | ||
520 | static int gfar_set_rx_csum(struct net_device *dev, uint32_t data) | 520 | int gfar_set_features(struct net_device *dev, u32 features) |
521 | { | 521 | { |
522 | struct gfar_private *priv = netdev_priv(dev); | 522 | struct gfar_private *priv = netdev_priv(dev); |
523 | unsigned long flags; | 523 | unsigned long flags; |
524 | int err = 0, i = 0; | 524 | int err = 0, i = 0; |
525 | u32 changed = dev->features ^ features; | ||
525 | 526 | ||
526 | if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM)) | 527 | if (!(changed & NETIF_F_RXCSUM)) |
527 | return -EOPNOTSUPP; | 528 | return 0; |
528 | |||
529 | 529 | ||
530 | if (dev->flags & IFF_UP) { | 530 | if (dev->flags & IFF_UP) { |
531 | /* Halt TX and RX, and process the frames which | 531 | /* Halt TX and RX, and process the frames which |
@@ -546,58 +546,15 @@ static int gfar_set_rx_csum(struct net_device *dev, uint32_t data) | |||
546 | 546 | ||
547 | /* Now we take down the rings to rebuild them */ | 547 | /* Now we take down the rings to rebuild them */ |
548 | stop_gfar(dev); | 548 | stop_gfar(dev); |
549 | } | ||
550 | 549 | ||
551 | spin_lock_irqsave(&priv->bflock, flags); | 550 | dev->features = features; |
552 | priv->rx_csum_enable = data; | ||
553 | spin_unlock_irqrestore(&priv->bflock, flags); | ||
554 | 551 | ||
555 | if (dev->flags & IFF_UP) { | ||
556 | err = startup_gfar(dev); | 552 | err = startup_gfar(dev); |
557 | netif_tx_wake_all_queues(dev); | 553 | netif_tx_wake_all_queues(dev); |
558 | } | 554 | } |
559 | return err; | 555 | return err; |
560 | } | 556 | } |
561 | 557 | ||
562 | static uint32_t gfar_get_rx_csum(struct net_device *dev) | ||
563 | { | ||
564 | struct gfar_private *priv = netdev_priv(dev); | ||
565 | |||
566 | if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM)) | ||
567 | return 0; | ||
568 | |||
569 | return priv->rx_csum_enable; | ||
570 | } | ||
571 | |||
572 | static int gfar_set_tx_csum(struct net_device *dev, uint32_t data) | ||
573 | { | ||
574 | struct gfar_private *priv = netdev_priv(dev); | ||
575 | |||
576 | if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM)) | ||
577 | return -EOPNOTSUPP; | ||
578 | |||
579 | netif_tx_lock_bh(dev); | ||
580 | |||
581 | if (data) | ||
582 | dev->features |= NETIF_F_IP_CSUM; | ||
583 | else | ||
584 | dev->features &= ~NETIF_F_IP_CSUM; | ||
585 | |||
586 | netif_tx_unlock_bh(dev); | ||
587 | |||
588 | return 0; | ||
589 | } | ||
590 | |||
591 | static uint32_t gfar_get_tx_csum(struct net_device *dev) | ||
592 | { | ||
593 | struct gfar_private *priv = netdev_priv(dev); | ||
594 | |||
595 | if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM)) | ||
596 | return 0; | ||
597 | |||
598 | return (dev->features & NETIF_F_IP_CSUM) != 0; | ||
599 | } | ||
600 | |||
601 | static uint32_t gfar_get_msglevel(struct net_device *dev) | 558 | static uint32_t gfar_get_msglevel(struct net_device *dev) |
602 | { | 559 | { |
603 | struct gfar_private *priv = netdev_priv(dev); | 560 | struct gfar_private *priv = netdev_priv(dev); |
@@ -844,11 +801,6 @@ const struct ethtool_ops gfar_ethtool_ops = { | |||
844 | .get_strings = gfar_gstrings, | 801 | .get_strings = gfar_gstrings, |
845 | .get_sset_count = gfar_sset_count, | 802 | .get_sset_count = gfar_sset_count, |
846 | .get_ethtool_stats = gfar_fill_stats, | 803 | .get_ethtool_stats = gfar_fill_stats, |
847 | .get_rx_csum = gfar_get_rx_csum, | ||
848 | .get_tx_csum = gfar_get_tx_csum, | ||
849 | .set_rx_csum = gfar_set_rx_csum, | ||
850 | .set_tx_csum = gfar_set_tx_csum, | ||
851 | .set_sg = ethtool_op_set_sg, | ||
852 | .get_msglevel = gfar_get_msglevel, | 804 | .get_msglevel = gfar_get_msglevel, |
853 | .set_msglevel = gfar_set_msglevel, | 805 | .set_msglevel = gfar_set_msglevel, |
854 | #ifdef CONFIG_PM | 806 | #ifdef CONFIG_PM |