aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorBruce Allan <bruce.w.allan@intel.com>2011-08-18 23:23:48 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2011-08-27 02:28:39 -0400
commitdc221294719ae0f28cc260cc37edd439161088a9 (patch)
tree6c59be3b8ebb11d2de1afae72a4f21251334d5fc /drivers/net
parent3cd0999d134235d64b175edd2eb1d46ebc97b377 (diff)
e1000e: convert to netdev features/hw_features API
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 <mirq-linux@rere.qmqm.pl> Cc: Michał Mirosław <mirq-linux@rere.qmqm.pl> Signed-off-by: Bruce Allan <bruce.w.allan@intel.com> Tested-by: Aaron Brown <aaron.f.brown@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ethernet/intel/e1000e/80003es2lan.c1
-rw-r--r--drivers/net/ethernet/intel/e1000e/82571.c5
-rw-r--r--drivers/net/ethernet/intel/e1000e/e1000.h3
-rw-r--r--drivers/net/ethernet/intel/e1000e/ethtool.c88
-rw-r--r--drivers/net/ethernet/intel/e1000e/ich8lan.c5
-rw-r--r--drivers/net/ethernet/intel/e1000e/netdev.c49
6 files changed, 38 insertions, 113 deletions
diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c b/drivers/net/ethernet/intel/e1000e/80003es2lan.c
index e4f42257c24c..b7544336cef4 100644
--- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c
+++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c
@@ -1498,7 +1498,6 @@ struct e1000_info e1000_es2_info = {
1498 | FLAG_HAS_JUMBO_FRAMES 1498 | FLAG_HAS_JUMBO_FRAMES
1499 | FLAG_HAS_WOL 1499 | FLAG_HAS_WOL
1500 | FLAG_APME_IN_CTRL3 1500 | FLAG_APME_IN_CTRL3
1501 | FLAG_RX_CSUM_ENABLED
1502 | FLAG_HAS_CTRLEXT_ON_LOAD 1501 | FLAG_HAS_CTRLEXT_ON_LOAD
1503 | FLAG_RX_NEEDS_RESTART /* errata */ 1502 | FLAG_RX_NEEDS_RESTART /* errata */
1504 | FLAG_TARC_SET_BIT_ZERO /* errata */ 1503 | FLAG_TARC_SET_BIT_ZERO /* errata */
diff --git a/drivers/net/ethernet/intel/e1000e/82571.c b/drivers/net/ethernet/intel/e1000e/82571.c
index 536b3a55c45f..2d4dc53a4fb8 100644
--- a/drivers/net/ethernet/intel/e1000e/82571.c
+++ b/drivers/net/ethernet/intel/e1000e/82571.c
@@ -2019,7 +2019,6 @@ struct e1000_info e1000_82571_info = {
2019 | FLAG_HAS_JUMBO_FRAMES 2019 | FLAG_HAS_JUMBO_FRAMES
2020 | FLAG_HAS_WOL 2020 | FLAG_HAS_WOL
2021 | FLAG_APME_IN_CTRL3 2021 | FLAG_APME_IN_CTRL3
2022 | FLAG_RX_CSUM_ENABLED
2023 | FLAG_HAS_CTRLEXT_ON_LOAD 2022 | FLAG_HAS_CTRLEXT_ON_LOAD
2024 | FLAG_HAS_SMART_POWER_DOWN 2023 | FLAG_HAS_SMART_POWER_DOWN
2025 | FLAG_RESET_OVERWRITES_LAA /* errata */ 2024 | FLAG_RESET_OVERWRITES_LAA /* errata */
@@ -2041,7 +2040,6 @@ struct e1000_info e1000_82572_info = {
2041 | FLAG_HAS_JUMBO_FRAMES 2040 | FLAG_HAS_JUMBO_FRAMES
2042 | FLAG_HAS_WOL 2041 | FLAG_HAS_WOL
2043 | FLAG_APME_IN_CTRL3 2042 | FLAG_APME_IN_CTRL3
2044 | FLAG_RX_CSUM_ENABLED
2045 | FLAG_HAS_CTRLEXT_ON_LOAD 2043 | FLAG_HAS_CTRLEXT_ON_LOAD
2046 | FLAG_TARC_SPEED_MODE_BIT, /* errata */ 2044 | FLAG_TARC_SPEED_MODE_BIT, /* errata */
2047 .flags2 = FLAG2_DISABLE_ASPM_L1 /* errata 13 */ 2045 .flags2 = FLAG2_DISABLE_ASPM_L1 /* errata 13 */
@@ -2059,7 +2057,6 @@ struct e1000_info e1000_82573_info = {
2059 .flags = FLAG_HAS_HW_VLAN_FILTER 2057 .flags = FLAG_HAS_HW_VLAN_FILTER
2060 | FLAG_HAS_WOL 2058 | FLAG_HAS_WOL
2061 | FLAG_APME_IN_CTRL3 2059 | FLAG_APME_IN_CTRL3
2062 | FLAG_RX_CSUM_ENABLED
2063 | FLAG_HAS_SMART_POWER_DOWN 2060 | FLAG_HAS_SMART_POWER_DOWN
2064 | FLAG_HAS_AMT 2061 | FLAG_HAS_AMT
2065 | FLAG_HAS_SWSM_ON_LOAD, 2062 | FLAG_HAS_SWSM_ON_LOAD,
@@ -2080,7 +2077,6 @@ struct e1000_info e1000_82574_info = {
2080 | FLAG_HAS_JUMBO_FRAMES 2077 | FLAG_HAS_JUMBO_FRAMES
2081 | FLAG_HAS_WOL 2078 | FLAG_HAS_WOL
2082 | FLAG_APME_IN_CTRL3 2079 | FLAG_APME_IN_CTRL3
2083 | FLAG_RX_CSUM_ENABLED
2084 | FLAG_HAS_SMART_POWER_DOWN 2080 | FLAG_HAS_SMART_POWER_DOWN
2085 | FLAG_HAS_AMT 2081 | FLAG_HAS_AMT
2086 | FLAG_HAS_CTRLEXT_ON_LOAD, 2082 | FLAG_HAS_CTRLEXT_ON_LOAD,
@@ -2100,7 +2096,6 @@ struct e1000_info e1000_82583_info = {
2100 .flags = FLAG_HAS_HW_VLAN_FILTER 2096 .flags = FLAG_HAS_HW_VLAN_FILTER
2101 | FLAG_HAS_WOL 2097 | FLAG_HAS_WOL
2102 | FLAG_APME_IN_CTRL3 2098 | FLAG_APME_IN_CTRL3
2103 | FLAG_RX_CSUM_ENABLED
2104 | FLAG_HAS_SMART_POWER_DOWN 2099 | FLAG_HAS_SMART_POWER_DOWN
2105 | FLAG_HAS_AMT 2100 | FLAG_HAS_AMT
2106 | FLAG_HAS_JUMBO_FRAMES 2101 | FLAG_HAS_JUMBO_FRAMES
diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h
index fa72052a0031..1b15d1ff583c 100644
--- a/drivers/net/ethernet/intel/e1000e/e1000.h
+++ b/drivers/net/ethernet/intel/e1000e/e1000.h
@@ -440,12 +440,11 @@ struct e1000_info {
440#define FLAG_LSC_GIG_SPEED_DROP (1 << 25) 440#define FLAG_LSC_GIG_SPEED_DROP (1 << 25)
441#define FLAG_SMART_POWER_DOWN (1 << 26) 441#define FLAG_SMART_POWER_DOWN (1 << 26)
442#define FLAG_MSI_ENABLED (1 << 27) 442#define FLAG_MSI_ENABLED (1 << 27)
443#define FLAG_RX_CSUM_ENABLED (1 << 28) 443/* reserved (1 << 28) */
444#define FLAG_TSO_FORCE (1 << 29) 444#define FLAG_TSO_FORCE (1 << 29)
445#define FLAG_RX_RESTART_NOW (1 << 30) 445#define FLAG_RX_RESTART_NOW (1 << 30)
446#define FLAG_MSI_TEST_FAILED (1 << 31) 446#define FLAG_MSI_TEST_FAILED (1 << 31)
447 447
448/* CRC Stripping defines */
449#define FLAG2_CRC_STRIPPING (1 << 0) 448#define FLAG2_CRC_STRIPPING (1 << 0)
450#define FLAG2_HAS_PHY_WAKEUP (1 << 1) 449#define FLAG2_HAS_PHY_WAKEUP (1 << 1)
451#define FLAG2_IS_DISCARDING (1 << 2) 450#define FLAG2_IS_DISCARDING (1 << 2)
diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c
index e0cbd6a0bde8..d96d0b0e08cf 100644
--- a/drivers/net/ethernet/intel/e1000e/ethtool.c
+++ b/drivers/net/ethernet/intel/e1000e/ethtool.c
@@ -367,59 +367,6 @@ out:
367 return retval; 367 return retval;
368} 368}
369 369
370static u32 e1000_get_rx_csum(struct net_device *netdev)
371{
372 struct e1000_adapter *adapter = netdev_priv(netdev);
373 return adapter->flags & FLAG_RX_CSUM_ENABLED;
374}
375
376static int e1000_set_rx_csum(struct net_device *netdev, u32 data)
377{
378 struct e1000_adapter *adapter = netdev_priv(netdev);
379
380 if (data)
381 adapter->flags |= FLAG_RX_CSUM_ENABLED;
382 else
383 adapter->flags &= ~FLAG_RX_CSUM_ENABLED;
384
385 if (netif_running(netdev))
386 e1000e_reinit_locked(adapter);
387 else
388 e1000e_reset(adapter);
389 return 0;
390}
391
392static u32 e1000_get_tx_csum(struct net_device *netdev)
393{
394 return (netdev->features & NETIF_F_HW_CSUM) != 0;
395}
396
397static int e1000_set_tx_csum(struct net_device *netdev, u32 data)
398{
399 if (data)
400 netdev->features |= NETIF_F_HW_CSUM;
401 else
402 netdev->features &= ~NETIF_F_HW_CSUM;
403
404 return 0;
405}
406
407static int e1000_set_tso(struct net_device *netdev, u32 data)
408{
409 struct e1000_adapter *adapter = netdev_priv(netdev);
410
411 if (data) {
412 netdev->features |= NETIF_F_TSO;
413 netdev->features |= NETIF_F_TSO6;
414 } else {
415 netdev->features &= ~NETIF_F_TSO;
416 netdev->features &= ~NETIF_F_TSO6;
417 }
418
419 adapter->flags |= FLAG_TSO_FORCE;
420 return 0;
421}
422
423static u32 e1000_get_msglevel(struct net_device *netdev) 370static u32 e1000_get_msglevel(struct net_device *netdev)
424{ 371{
425 struct e1000_adapter *adapter = netdev_priv(netdev); 372 struct e1000_adapter *adapter = netdev_priv(netdev);
@@ -2014,31 +1961,6 @@ static void e1000_get_strings(struct net_device *netdev, u32 stringset,
2014 } 1961 }
2015} 1962}
2016 1963
2017static int e1000e_set_flags(struct net_device *netdev, u32 data)
2018{
2019 struct e1000_adapter *adapter = netdev_priv(netdev);
2020 bool need_reset = false;
2021 int rc;
2022
2023 need_reset = (data & ETH_FLAG_RXVLAN) !=
2024 (netdev->features & NETIF_F_HW_VLAN_RX);
2025
2026 rc = ethtool_op_set_flags(netdev, data, ETH_FLAG_RXVLAN |
2027 ETH_FLAG_TXVLAN);
2028
2029 if (rc)
2030 return rc;
2031
2032 if (need_reset) {
2033 if (netif_running(netdev))
2034 e1000e_reinit_locked(adapter);
2035 else
2036 e1000e_reset(adapter);
2037 }
2038
2039 return 0;
2040}
2041
2042static const struct ethtool_ops e1000_ethtool_ops = { 1964static const struct ethtool_ops e1000_ethtool_ops = {
2043 .get_settings = e1000_get_settings, 1965 .get_settings = e1000_get_settings,
2044 .set_settings = e1000_set_settings, 1966 .set_settings = e1000_set_settings,
@@ -2058,14 +1980,6 @@ static const struct ethtool_ops e1000_ethtool_ops = {
2058 .set_ringparam = e1000_set_ringparam, 1980 .set_ringparam = e1000_set_ringparam,
2059 .get_pauseparam = e1000_get_pauseparam, 1981 .get_pauseparam = e1000_get_pauseparam,
2060 .set_pauseparam = e1000_set_pauseparam, 1982 .set_pauseparam = e1000_set_pauseparam,
2061 .get_rx_csum = e1000_get_rx_csum,
2062 .set_rx_csum = e1000_set_rx_csum,
2063 .get_tx_csum = e1000_get_tx_csum,
2064 .set_tx_csum = e1000_set_tx_csum,
2065 .get_sg = ethtool_op_get_sg,
2066 .set_sg = ethtool_op_set_sg,
2067 .get_tso = ethtool_op_get_tso,
2068 .set_tso = e1000_set_tso,
2069 .self_test = e1000_diag_test, 1983 .self_test = e1000_diag_test,
2070 .get_strings = e1000_get_strings, 1984 .get_strings = e1000_get_strings,
2071 .set_phys_id = e1000_set_phys_id, 1985 .set_phys_id = e1000_set_phys_id,
@@ -2073,8 +1987,6 @@ static const struct ethtool_ops e1000_ethtool_ops = {
2073 .get_sset_count = e1000e_get_sset_count, 1987 .get_sset_count = e1000e_get_sset_count,
2074 .get_coalesce = e1000_get_coalesce, 1988 .get_coalesce = e1000_get_coalesce,
2075 .set_coalesce = e1000_set_coalesce, 1989 .set_coalesce = e1000_set_coalesce,
2076 .get_flags = ethtool_op_get_flags,
2077 .set_flags = e1000e_set_flags,
2078}; 1990};
2079 1991
2080void e1000e_set_ethtool_ops(struct net_device *netdev) 1992void e1000e_set_ethtool_ops(struct net_device *netdev)
diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c
index 54add27c8f76..3fc3acce9950 100644
--- a/drivers/net/ethernet/intel/e1000e/ich8lan.c
+++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c
@@ -4058,7 +4058,6 @@ struct e1000_info e1000_ich8_info = {
4058 .mac = e1000_ich8lan, 4058 .mac = e1000_ich8lan,
4059 .flags = FLAG_HAS_WOL 4059 .flags = FLAG_HAS_WOL
4060 | FLAG_IS_ICH 4060 | FLAG_IS_ICH
4061 | FLAG_RX_CSUM_ENABLED
4062 | FLAG_HAS_CTRLEXT_ON_LOAD 4061 | FLAG_HAS_CTRLEXT_ON_LOAD
4063 | FLAG_HAS_AMT 4062 | FLAG_HAS_AMT
4064 | FLAG_HAS_FLASH 4063 | FLAG_HAS_FLASH
@@ -4076,7 +4075,6 @@ struct e1000_info e1000_ich9_info = {
4076 .flags = FLAG_HAS_JUMBO_FRAMES 4075 .flags = FLAG_HAS_JUMBO_FRAMES
4077 | FLAG_IS_ICH 4076 | FLAG_IS_ICH
4078 | FLAG_HAS_WOL 4077 | FLAG_HAS_WOL
4079 | FLAG_RX_CSUM_ENABLED
4080 | FLAG_HAS_CTRLEXT_ON_LOAD 4078 | FLAG_HAS_CTRLEXT_ON_LOAD
4081 | FLAG_HAS_AMT 4079 | FLAG_HAS_AMT
4082 | FLAG_HAS_ERT 4080 | FLAG_HAS_ERT
@@ -4095,7 +4093,6 @@ struct e1000_info e1000_ich10_info = {
4095 .flags = FLAG_HAS_JUMBO_FRAMES 4093 .flags = FLAG_HAS_JUMBO_FRAMES
4096 | FLAG_IS_ICH 4094 | FLAG_IS_ICH
4097 | FLAG_HAS_WOL 4095 | FLAG_HAS_WOL
4098 | FLAG_RX_CSUM_ENABLED
4099 | FLAG_HAS_CTRLEXT_ON_LOAD 4096 | FLAG_HAS_CTRLEXT_ON_LOAD
4100 | FLAG_HAS_AMT 4097 | FLAG_HAS_AMT
4101 | FLAG_HAS_ERT 4098 | FLAG_HAS_ERT
@@ -4113,7 +4110,6 @@ struct e1000_info e1000_pch_info = {
4113 .mac = e1000_pchlan, 4110 .mac = e1000_pchlan,
4114 .flags = FLAG_IS_ICH 4111 .flags = FLAG_IS_ICH
4115 | FLAG_HAS_WOL 4112 | FLAG_HAS_WOL
4116 | FLAG_RX_CSUM_ENABLED
4117 | FLAG_HAS_CTRLEXT_ON_LOAD 4113 | FLAG_HAS_CTRLEXT_ON_LOAD
4118 | FLAG_HAS_AMT 4114 | FLAG_HAS_AMT
4119 | FLAG_HAS_FLASH 4115 | FLAG_HAS_FLASH
@@ -4133,7 +4129,6 @@ struct e1000_info e1000_pch2_info = {
4133 .mac = e1000_pch2lan, 4129 .mac = e1000_pch2lan,
4134 .flags = FLAG_IS_ICH 4130 .flags = FLAG_IS_ICH
4135 | FLAG_HAS_WOL 4131 | FLAG_HAS_WOL
4136 | FLAG_RX_CSUM_ENABLED
4137 | FLAG_HAS_CTRLEXT_ON_LOAD 4132 | FLAG_HAS_CTRLEXT_ON_LOAD
4138 | FLAG_HAS_AMT 4133 | FLAG_HAS_AMT
4139 | FLAG_HAS_FLASH 4134 | FLAG_HAS_FLASH
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)
3069 3069
3070 /* Enable Receive Checksum Offload for TCP and UDP */ 3070 /* Enable Receive Checksum Offload for TCP and UDP */
3071 rxcsum = er32(RXCSUM); 3071 rxcsum = er32(RXCSUM);
3072 if (adapter->flags & FLAG_RX_CSUM_ENABLED) { 3072 if (adapter->netdev->features & NETIF_F_RXCSUM) {
3073 rxcsum |= E1000_RXCSUM_TUOFL; 3073 rxcsum |= E1000_RXCSUM_TUOFL;
3074 3074
3075 /* 3075 /*
@@ -5860,6 +5860,26 @@ static void e1000_eeprom_checks(struct e1000_adapter *adapter)
5860 } 5860 }
5861} 5861}
5862 5862
5863static int e1000_set_features(struct net_device *netdev, u32 features)
5864{
5865 struct e1000_adapter *adapter = netdev_priv(netdev);
5866 u32 changed = features ^ netdev->features;
5867
5868 if (changed & (NETIF_F_TSO | NETIF_F_TSO6))
5869 adapter->flags |= FLAG_TSO_FORCE;
5870
5871 if (!(changed & (NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_TX |
5872 NETIF_F_RXCSUM)))
5873 return 0;
5874
5875 if (netif_running(netdev))
5876 e1000e_reinit_locked(adapter);
5877 else
5878 e1000e_reset(adapter);
5879
5880 return 0;
5881}
5882
5863static const struct net_device_ops e1000e_netdev_ops = { 5883static const struct net_device_ops e1000e_netdev_ops = {
5864 .ndo_open = e1000_open, 5884 .ndo_open = e1000_open,
5865 .ndo_stop = e1000_close, 5885 .ndo_stop = e1000_close,
@@ -5877,6 +5897,7 @@ static const struct net_device_ops e1000e_netdev_ops = {
5877#ifdef CONFIG_NET_POLL_CONTROLLER 5897#ifdef CONFIG_NET_POLL_CONTROLLER
5878 .ndo_poll_controller = e1000_netpoll, 5898 .ndo_poll_controller = e1000_netpoll,
5879#endif 5899#endif
5900 .ndo_set_features = e1000_set_features,
5880}; 5901};
5881 5902
5882/** 5903/**
@@ -6036,21 +6057,25 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
6036 if (e1000_check_reset_block(&adapter->hw)) 6057 if (e1000_check_reset_block(&adapter->hw))
6037 e_info("PHY reset is blocked due to SOL/IDER session.\n"); 6058 e_info("PHY reset is blocked due to SOL/IDER session.\n");
6038 6059
6039 netdev->features = NETIF_F_SG | 6060 /* Set initial default active device features */
6040 NETIF_F_HW_CSUM | 6061 netdev->features = (NETIF_F_SG |
6041 NETIF_F_HW_VLAN_TX | 6062 NETIF_F_HW_VLAN_RX |
6042 NETIF_F_HW_VLAN_RX; 6063 NETIF_F_HW_VLAN_TX |
6064 NETIF_F_TSO |
6065 NETIF_F_TSO6 |
6066 NETIF_F_RXCSUM |
6067 NETIF_F_HW_CSUM);
6068
6069 /* Set user-changeable features (subset of all device features) */
6070 netdev->hw_features = netdev->features;
6043 6071
6044 if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) 6072 if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER)
6045 netdev->features |= NETIF_F_HW_VLAN_FILTER; 6073 netdev->features |= NETIF_F_HW_VLAN_FILTER;
6046 6074
6047 netdev->features |= NETIF_F_TSO; 6075 netdev->vlan_features |= (NETIF_F_SG |
6048 netdev->features |= NETIF_F_TSO6; 6076 NETIF_F_TSO |
6049 6077 NETIF_F_TSO6 |
6050 netdev->vlan_features |= NETIF_F_TSO; 6078 NETIF_F_HW_CSUM);
6051 netdev->vlan_features |= NETIF_F_TSO6;
6052 netdev->vlan_features |= NETIF_F_HW_CSUM;
6053 netdev->vlan_features |= NETIF_F_SG;
6054 6079
6055 if (pci_using_dac) { 6080 if (pci_using_dac) {
6056 netdev->features |= NETIF_F_HIGHDMA; 6081 netdev->features |= NETIF_F_HIGHDMA;