diff options
author | Michał Mirosław <mirq-linux@rere.qmqm.pl> | 2011-03-30 21:01:35 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-04-01 23:56:30 -0400 |
commit | d7b576545648e487b2958c220542e111f5ac46f0 (patch) | |
tree | 25d94afb72b2a4d220bbab0bdff63515d419c8f8 /drivers/net/jme.c | |
parent | fb507934fd6faa00b3d833facb53b90c71ddc307 (diff) |
jme: convert offload constraints to ndo_fix_features
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/jme.c')
-rw-r--r-- | drivers/net/jme.c | 77 |
1 files changed, 19 insertions, 58 deletions
diff --git a/drivers/net/jme.c b/drivers/net/jme.c index 994c80939c7a..be4773f54a24 100644 --- a/drivers/net/jme.c +++ b/drivers/net/jme.c | |||
@@ -2230,17 +2230,9 @@ jme_change_mtu(struct net_device *netdev, int new_mtu) | |||
2230 | jme_restart_rx_engine(jme); | 2230 | jme_restart_rx_engine(jme); |
2231 | } | 2231 | } |
2232 | 2232 | ||
2233 | if (new_mtu > 1900) { | ||
2234 | netdev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | | ||
2235 | NETIF_F_TSO | NETIF_F_TSO6); | ||
2236 | } else { | ||
2237 | if (test_bit(JME_FLAG_TXCSUM, &jme->flags)) | ||
2238 | netdev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; | ||
2239 | if (test_bit(JME_FLAG_TSO, &jme->flags)) | ||
2240 | netdev->features |= NETIF_F_TSO | NETIF_F_TSO6; | ||
2241 | } | ||
2242 | |||
2243 | netdev->mtu = new_mtu; | 2233 | netdev->mtu = new_mtu; |
2234 | netdev_update_features(netdev); | ||
2235 | |||
2244 | jme_reset_link(jme); | 2236 | jme_reset_link(jme); |
2245 | 2237 | ||
2246 | return 0; | 2238 | return 0; |
@@ -2640,19 +2632,20 @@ jme_set_msglevel(struct net_device *netdev, u32 value) | |||
2640 | } | 2632 | } |
2641 | 2633 | ||
2642 | static u32 | 2634 | static u32 |
2643 | jme_get_rx_csum(struct net_device *netdev) | 2635 | jme_fix_features(struct net_device *netdev, u32 features) |
2644 | { | 2636 | { |
2645 | struct jme_adapter *jme = netdev_priv(netdev); | 2637 | if (netdev->mtu > 1900) |
2646 | return jme->reg_rxmcs & RXMCS_CHECKSUM; | 2638 | features &= ~(NETIF_F_ALL_TSO | NETIF_F_ALL_CSUM); |
2639 | return features; | ||
2647 | } | 2640 | } |
2648 | 2641 | ||
2649 | static int | 2642 | static int |
2650 | jme_set_rx_csum(struct net_device *netdev, u32 on) | 2643 | jme_set_features(struct net_device *netdev, u32 features) |
2651 | { | 2644 | { |
2652 | struct jme_adapter *jme = netdev_priv(netdev); | 2645 | struct jme_adapter *jme = netdev_priv(netdev); |
2653 | 2646 | ||
2654 | spin_lock_bh(&jme->rxmcs_lock); | 2647 | spin_lock_bh(&jme->rxmcs_lock); |
2655 | if (on) | 2648 | if (features & NETIF_F_RXCSUM) |
2656 | jme->reg_rxmcs |= RXMCS_CHECKSUM; | 2649 | jme->reg_rxmcs |= RXMCS_CHECKSUM; |
2657 | else | 2650 | else |
2658 | jme->reg_rxmcs &= ~RXMCS_CHECKSUM; | 2651 | jme->reg_rxmcs &= ~RXMCS_CHECKSUM; |
@@ -2663,42 +2656,6 @@ jme_set_rx_csum(struct net_device *netdev, u32 on) | |||
2663 | } | 2656 | } |
2664 | 2657 | ||
2665 | static int | 2658 | static int |
2666 | jme_set_tx_csum(struct net_device *netdev, u32 on) | ||
2667 | { | ||
2668 | struct jme_adapter *jme = netdev_priv(netdev); | ||
2669 | |||
2670 | if (on) { | ||
2671 | set_bit(JME_FLAG_TXCSUM, &jme->flags); | ||
2672 | if (netdev->mtu <= 1900) | ||
2673 | netdev->features |= | ||
2674 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; | ||
2675 | } else { | ||
2676 | clear_bit(JME_FLAG_TXCSUM, &jme->flags); | ||
2677 | netdev->features &= | ||
2678 | ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM); | ||
2679 | } | ||
2680 | |||
2681 | return 0; | ||
2682 | } | ||
2683 | |||
2684 | static int | ||
2685 | jme_set_tso(struct net_device *netdev, u32 on) | ||
2686 | { | ||
2687 | struct jme_adapter *jme = netdev_priv(netdev); | ||
2688 | |||
2689 | if (on) { | ||
2690 | set_bit(JME_FLAG_TSO, &jme->flags); | ||
2691 | if (netdev->mtu <= 1900) | ||
2692 | netdev->features |= NETIF_F_TSO | NETIF_F_TSO6; | ||
2693 | } else { | ||
2694 | clear_bit(JME_FLAG_TSO, &jme->flags); | ||
2695 | netdev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6); | ||
2696 | } | ||
2697 | |||
2698 | return 0; | ||
2699 | } | ||
2700 | |||
2701 | static int | ||
2702 | jme_nway_reset(struct net_device *netdev) | 2659 | jme_nway_reset(struct net_device *netdev) |
2703 | { | 2660 | { |
2704 | struct jme_adapter *jme = netdev_priv(netdev); | 2661 | struct jme_adapter *jme = netdev_priv(netdev); |
@@ -2839,11 +2796,6 @@ static const struct ethtool_ops jme_ethtool_ops = { | |||
2839 | .get_link = jme_get_link, | 2796 | .get_link = jme_get_link, |
2840 | .get_msglevel = jme_get_msglevel, | 2797 | .get_msglevel = jme_get_msglevel, |
2841 | .set_msglevel = jme_set_msglevel, | 2798 | .set_msglevel = jme_set_msglevel, |
2842 | .get_rx_csum = jme_get_rx_csum, | ||
2843 | .set_rx_csum = jme_set_rx_csum, | ||
2844 | .set_tx_csum = jme_set_tx_csum, | ||
2845 | .set_tso = jme_set_tso, | ||
2846 | .set_sg = ethtool_op_set_sg, | ||
2847 | .nway_reset = jme_nway_reset, | 2799 | .nway_reset = jme_nway_reset, |
2848 | .get_eeprom_len = jme_get_eeprom_len, | 2800 | .get_eeprom_len = jme_get_eeprom_len, |
2849 | .get_eeprom = jme_get_eeprom, | 2801 | .get_eeprom = jme_get_eeprom, |
@@ -2903,6 +2855,8 @@ static const struct net_device_ops jme_netdev_ops = { | |||
2903 | .ndo_change_mtu = jme_change_mtu, | 2855 | .ndo_change_mtu = jme_change_mtu, |
2904 | .ndo_tx_timeout = jme_tx_timeout, | 2856 | .ndo_tx_timeout = jme_tx_timeout, |
2905 | .ndo_vlan_rx_register = jme_vlan_rx_register, | 2857 | .ndo_vlan_rx_register = jme_vlan_rx_register, |
2858 | .ndo_fix_features = jme_fix_features, | ||
2859 | .ndo_set_features = jme_set_features, | ||
2906 | }; | 2860 | }; |
2907 | 2861 | ||
2908 | static int __devinit | 2862 | static int __devinit |
@@ -2957,6 +2911,12 @@ jme_init_one(struct pci_dev *pdev, | |||
2957 | netdev->netdev_ops = &jme_netdev_ops; | 2911 | netdev->netdev_ops = &jme_netdev_ops; |
2958 | netdev->ethtool_ops = &jme_ethtool_ops; | 2912 | netdev->ethtool_ops = &jme_ethtool_ops; |
2959 | netdev->watchdog_timeo = TX_TIMEOUT; | 2913 | netdev->watchdog_timeo = TX_TIMEOUT; |
2914 | netdev->hw_features = NETIF_F_IP_CSUM | | ||
2915 | NETIF_F_IPV6_CSUM | | ||
2916 | NETIF_F_SG | | ||
2917 | NETIF_F_TSO | | ||
2918 | NETIF_F_TSO6 | | ||
2919 | NETIF_F_RXCSUM; | ||
2960 | netdev->features = NETIF_F_IP_CSUM | | 2920 | netdev->features = NETIF_F_IP_CSUM | |
2961 | NETIF_F_IPV6_CSUM | | 2921 | NETIF_F_IPV6_CSUM | |
2962 | NETIF_F_SG | | 2922 | NETIF_F_SG | |
@@ -3040,8 +3000,9 @@ jme_init_one(struct pci_dev *pdev, | |||
3040 | jme->reg_txpfc = 0; | 3000 | jme->reg_txpfc = 0; |
3041 | jme->reg_pmcs = PMCS_MFEN; | 3001 | jme->reg_pmcs = PMCS_MFEN; |
3042 | jme->reg_gpreg1 = GPREG1_DEFAULT; | 3002 | jme->reg_gpreg1 = GPREG1_DEFAULT; |
3043 | set_bit(JME_FLAG_TXCSUM, &jme->flags); | 3003 | |
3044 | set_bit(JME_FLAG_TSO, &jme->flags); | 3004 | if (jme->reg_rxmcs & RXMCS_CHECKSUM) |
3005 | netdev->features |= NETIF_F_RXCSUM; | ||
3045 | 3006 | ||
3046 | /* | 3007 | /* |
3047 | * Get Max Read Req Size from PCI Config Space | 3008 | * Get Max Read Req Size from PCI Config Space |