From dc221294719ae0f28cc260cc37edd439161088a9 Mon Sep 17 00:00:00 2001 From: Bruce Allan Date: Fri, 19 Aug 2011 03:23:48 +0000 Subject: e1000e: convert to netdev features/hw_features API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Private rx_csum flags are now duplicate of netdev->features & NETIF_F_RXCSUM. Remove those duplicates and use the net_device_ops ndo_set_features. This is based on the original patch submitted by Michał Mirosław Cc: Michał Mirosław Signed-off-by: Bruce Allan Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/netdev.c | 49 ++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 12 deletions(-) (limited to 'drivers/net/ethernet/intel/e1000e/netdev.c') diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 9742bc603cad..4f669995623f 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -3069,7 +3069,7 @@ static void e1000_configure_rx(struct e1000_adapter *adapter) /* Enable Receive Checksum Offload for TCP and UDP */ rxcsum = er32(RXCSUM); - if (adapter->flags & FLAG_RX_CSUM_ENABLED) { + if (adapter->netdev->features & NETIF_F_RXCSUM) { rxcsum |= E1000_RXCSUM_TUOFL; /* @@ -5860,6 +5860,26 @@ static void e1000_eeprom_checks(struct e1000_adapter *adapter) } } +static int e1000_set_features(struct net_device *netdev, u32 features) +{ + struct e1000_adapter *adapter = netdev_priv(netdev); + u32 changed = features ^ netdev->features; + + if (changed & (NETIF_F_TSO | NETIF_F_TSO6)) + adapter->flags |= FLAG_TSO_FORCE; + + if (!(changed & (NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_TX | + NETIF_F_RXCSUM))) + return 0; + + if (netif_running(netdev)) + e1000e_reinit_locked(adapter); + else + e1000e_reset(adapter); + + return 0; +} + static const struct net_device_ops e1000e_netdev_ops = { .ndo_open = e1000_open, .ndo_stop = e1000_close, @@ -5877,6 +5897,7 @@ static const struct net_device_ops e1000e_netdev_ops = { #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = e1000_netpoll, #endif + .ndo_set_features = e1000_set_features, }; /** @@ -6036,21 +6057,25 @@ static int __devinit e1000_probe(struct pci_dev *pdev, if (e1000_check_reset_block(&adapter->hw)) e_info("PHY reset is blocked due to SOL/IDER session.\n"); - netdev->features = NETIF_F_SG | - NETIF_F_HW_CSUM | - NETIF_F_HW_VLAN_TX | - NETIF_F_HW_VLAN_RX; + /* Set initial default active device features */ + netdev->features = (NETIF_F_SG | + NETIF_F_HW_VLAN_RX | + NETIF_F_HW_VLAN_TX | + NETIF_F_TSO | + NETIF_F_TSO6 | + NETIF_F_RXCSUM | + NETIF_F_HW_CSUM); + + /* Set user-changeable features (subset of all device features) */ + netdev->hw_features = netdev->features; if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) netdev->features |= NETIF_F_HW_VLAN_FILTER; - netdev->features |= NETIF_F_TSO; - netdev->features |= NETIF_F_TSO6; - - netdev->vlan_features |= NETIF_F_TSO; - netdev->vlan_features |= NETIF_F_TSO6; - netdev->vlan_features |= NETIF_F_HW_CSUM; - netdev->vlan_features |= NETIF_F_SG; + netdev->vlan_features |= (NETIF_F_SG | + NETIF_F_TSO | + NETIF_F_TSO6 | + NETIF_F_HW_CSUM); if (pci_using_dac) { netdev->features |= NETIF_F_HIGHDMA; -- cgit v1.2.3-59-g8ed1b