Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Michał Mirosław and committed by
David S. Miller
8b3afe95 c8c64cff

+16 -61
+9 -7
drivers/net/gianfar.c
··· 365 365 gfar_write(&regs->rir0, DEFAULT_RIR0); 366 366 } 367 367 368 - if (priv->rx_csum_enable) 368 + if (ndev->features & NETIF_F_RXCSUM) 369 369 rctrl |= RCTRL_CHECKSUMMING; 370 370 371 371 if (priv->extended_hash) { ··· 463 463 .ndo_start_xmit = gfar_start_xmit, 464 464 .ndo_stop = gfar_close, 465 465 .ndo_change_mtu = gfar_change_mtu, 466 + .ndo_set_features = gfar_set_features, 466 467 .ndo_set_multicast_list = gfar_set_multi, 467 468 .ndo_tx_timeout = gfar_timeout, 468 469 .ndo_do_ioctl = gfar_ioctl, ··· 514 513 /* Returns 1 if incoming frames use an FCB */ 515 514 static inline int gfar_uses_fcb(struct gfar_private *priv) 516 515 { 517 - return priv->vlgrp || priv->rx_csum_enable || 516 + return priv->vlgrp || (priv->ndev->features & NETIF_F_RXCSUM) || 518 517 (priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER); 519 518 } 520 519 ··· 1031 1030 netif_napi_add(dev, &priv->gfargrp[i].napi, gfar_poll, GFAR_DEV_WEIGHT); 1032 1031 1033 1032 if (priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM) { 1034 - priv->rx_csum_enable = 1; 1035 - dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_HIGHDMA; 1036 - } else 1037 - priv->rx_csum_enable = 0; 1033 + dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_SG | 1034 + NETIF_F_RXCSUM; 1035 + dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG | 1036 + NETIF_F_RXCSUM | NETIF_F_HIGHDMA; 1037 + } 1038 1038 1039 1039 priv->vlgrp = NULL; 1040 1040 ··· 2699 2697 if (priv->padding) 2700 2698 skb_pull(skb, priv->padding); 2701 2699 2702 - if (priv->rx_csum_enable) 2700 + if (dev->features & NETIF_F_RXCSUM) 2703 2701 gfar_rx_checksum(skb, fcb); 2704 2702 2705 2703 /* Tell the skb what kind of packet this is */
+2 -1
drivers/net/gianfar.h
··· 1083 1083 struct device_node *phy_node; 1084 1084 struct device_node *tbi_node; 1085 1085 u32 device_flags; 1086 - unsigned char rx_csum_enable:1, 1086 + unsigned char 1087 1087 extended_hash:1, 1088 1088 bd_stash_en:1, 1089 1089 rx_filer_enable:1, ··· 1153 1153 extern void gfar_configure_coalescing(struct gfar_private *priv, 1154 1154 unsigned long tx_mask, unsigned long rx_mask); 1155 1155 void gfar_init_sysfs(struct net_device *dev); 1156 + int gfar_set_features(struct net_device *dev, u32 features); 1156 1157 1157 1158 extern const struct ethtool_ops gfar_ethtool_ops; 1158 1159
+5 -53
drivers/net/gianfar_ethtool.c
··· 517 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 522 struct gfar_private *priv = netdev_priv(dev); 523 523 unsigned long flags; 524 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 - return -EOPNOTSUPP; 528 - 527 + if (!(changed & NETIF_F_RXCSUM)) 528 + return 0; 529 529 530 530 if (dev->flags & IFF_UP) { 531 531 /* Halt TX and RX, and process the frames which ··· 546 546 547 547 /* Now we take down the rings to rebuild them */ 548 548 stop_gfar(dev); 549 - } 550 549 551 - spin_lock_irqsave(&priv->bflock, flags); 552 - priv->rx_csum_enable = data; 553 - spin_unlock_irqrestore(&priv->bflock, flags); 550 + dev->features = features; 554 551 555 - if (dev->flags & IFF_UP) { 556 552 err = startup_gfar(dev); 557 553 netif_tx_wake_all_queues(dev); 558 554 } 559 555 return err; 560 - } 561 - 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 556 } 600 557 601 558 static uint32_t gfar_get_msglevel(struct net_device *dev) ··· 801 844 .get_strings = gfar_gstrings, 802 845 .get_sset_count = gfar_sset_count, 803 846 .get_ethtool_stats = gfar_fill_stats, 804 - .get_rx_csum = gfar_get_rx_csum, 805 - .get_tx_csum = gfar_get_tx_csum, 806 - .set_rx_csum = gfar_set_rx_csum, 807 - .set_tx_csum = gfar_set_tx_csum, 808 - .set_sg = ethtool_op_set_sg, 809 847 .get_msglevel = gfar_get_msglevel, 810 848 .set_msglevel = gfar_set_msglevel, 811 849 #ifdef CONFIG_PM