Skip to content

Commit dc22129

Browse files
bwallanJeff Kirsher
authored andcommitted
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>
1 parent 3cd0999 commit dc22129

File tree

6 files changed

+38
-113
lines changed

6 files changed

+38
-113
lines changed

drivers/net/ethernet/intel/e1000e/80003es2lan.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1498,7 +1498,6 @@ struct e1000_info e1000_es2_info = {
14981498
| FLAG_HAS_JUMBO_FRAMES
14991499
| FLAG_HAS_WOL
15001500
| FLAG_APME_IN_CTRL3
1501-
| FLAG_RX_CSUM_ENABLED
15021501
| FLAG_HAS_CTRLEXT_ON_LOAD
15031502
| FLAG_RX_NEEDS_RESTART /* errata */
15041503
| FLAG_TARC_SET_BIT_ZERO /* errata */

drivers/net/ethernet/intel/e1000e/82571.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,7 +2019,6 @@ struct e1000_info e1000_82571_info = {
20192019
| FLAG_HAS_JUMBO_FRAMES
20202020
| FLAG_HAS_WOL
20212021
| FLAG_APME_IN_CTRL3
2022-
| FLAG_RX_CSUM_ENABLED
20232022
| FLAG_HAS_CTRLEXT_ON_LOAD
20242023
| FLAG_HAS_SMART_POWER_DOWN
20252024
| FLAG_RESET_OVERWRITES_LAA /* errata */
@@ -2041,7 +2040,6 @@ struct e1000_info e1000_82572_info = {
20412040
| FLAG_HAS_JUMBO_FRAMES
20422041
| FLAG_HAS_WOL
20432042
| FLAG_APME_IN_CTRL3
2044-
| FLAG_RX_CSUM_ENABLED
20452043
| FLAG_HAS_CTRLEXT_ON_LOAD
20462044
| FLAG_TARC_SPEED_MODE_BIT, /* errata */
20472045
.flags2 = FLAG2_DISABLE_ASPM_L1 /* errata 13 */
@@ -2059,7 +2057,6 @@ struct e1000_info e1000_82573_info = {
20592057
.flags = FLAG_HAS_HW_VLAN_FILTER
20602058
| FLAG_HAS_WOL
20612059
| FLAG_APME_IN_CTRL3
2062-
| FLAG_RX_CSUM_ENABLED
20632060
| FLAG_HAS_SMART_POWER_DOWN
20642061
| FLAG_HAS_AMT
20652062
| FLAG_HAS_SWSM_ON_LOAD,
@@ -2080,7 +2077,6 @@ struct e1000_info e1000_82574_info = {
20802077
| FLAG_HAS_JUMBO_FRAMES
20812078
| FLAG_HAS_WOL
20822079
| FLAG_APME_IN_CTRL3
2083-
| FLAG_RX_CSUM_ENABLED
20842080
| FLAG_HAS_SMART_POWER_DOWN
20852081
| FLAG_HAS_AMT
20862082
| FLAG_HAS_CTRLEXT_ON_LOAD,
@@ -2100,7 +2096,6 @@ struct e1000_info e1000_82583_info = {
21002096
.flags = FLAG_HAS_HW_VLAN_FILTER
21012097
| FLAG_HAS_WOL
21022098
| FLAG_APME_IN_CTRL3
2103-
| FLAG_RX_CSUM_ENABLED
21042099
| FLAG_HAS_SMART_POWER_DOWN
21052100
| FLAG_HAS_AMT
21062101
| FLAG_HAS_JUMBO_FRAMES

drivers/net/ethernet/intel/e1000e/e1000.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,11 @@ struct e1000_info {
440440
#define FLAG_LSC_GIG_SPEED_DROP (1 << 25)
441441
#define FLAG_SMART_POWER_DOWN (1 << 26)
442442
#define FLAG_MSI_ENABLED (1 << 27)
443-
#define FLAG_RX_CSUM_ENABLED (1 << 28)
443+
/* reserved (1 << 28) */
444444
#define FLAG_TSO_FORCE (1 << 29)
445445
#define FLAG_RX_RESTART_NOW (1 << 30)
446446
#define FLAG_MSI_TEST_FAILED (1 << 31)
447447

448-
/* CRC Stripping defines */
449448
#define FLAG2_CRC_STRIPPING (1 << 0)
450449
#define FLAG2_HAS_PHY_WAKEUP (1 << 1)
451450
#define FLAG2_IS_DISCARDING (1 << 2)

drivers/net/ethernet/intel/e1000e/ethtool.c

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -367,59 +367,6 @@ static int e1000_set_pauseparam(struct net_device *netdev,
367367
return retval;
368368
}
369369

370-
static 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-
376-
static 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-
392-
static u32 e1000_get_tx_csum(struct net_device *netdev)
393-
{
394-
return (netdev->features & NETIF_F_HW_CSUM) != 0;
395-
}
396-
397-
static 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-
407-
static 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-
423370
static u32 e1000_get_msglevel(struct net_device *netdev)
424371
{
425372
struct e1000_adapter *adapter = netdev_priv(netdev);
@@ -2014,31 +1961,6 @@ static void e1000_get_strings(struct net_device *netdev, u32 stringset,
20141961
}
20151962
}
20161963

2017-
static 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-
20421964
static const struct ethtool_ops e1000_ethtool_ops = {
20431965
.get_settings = e1000_get_settings,
20441966
.set_settings = e1000_set_settings,
@@ -2058,23 +1980,13 @@ static const struct ethtool_ops e1000_ethtool_ops = {
20581980
.set_ringparam = e1000_set_ringparam,
20591981
.get_pauseparam = e1000_get_pauseparam,
20601982
.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,
20691983
.self_test = e1000_diag_test,
20701984
.get_strings = e1000_get_strings,
20711985
.set_phys_id = e1000_set_phys_id,
20721986
.get_ethtool_stats = e1000_get_ethtool_stats,
20731987
.get_sset_count = e1000e_get_sset_count,
20741988
.get_coalesce = e1000_get_coalesce,
20751989
.set_coalesce = e1000_set_coalesce,
2076-
.get_flags = ethtool_op_get_flags,
2077-
.set_flags = e1000e_set_flags,
20781990
};
20791991

20801992
void e1000e_set_ethtool_ops(struct net_device *netdev)

drivers/net/ethernet/intel/e1000e/ich8lan.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4058,7 +4058,6 @@ struct e1000_info e1000_ich8_info = {
40584058
.mac = e1000_ich8lan,
40594059
.flags = FLAG_HAS_WOL
40604060
| FLAG_IS_ICH
4061-
| FLAG_RX_CSUM_ENABLED
40624061
| FLAG_HAS_CTRLEXT_ON_LOAD
40634062
| FLAG_HAS_AMT
40644063
| FLAG_HAS_FLASH
@@ -4076,7 +4075,6 @@ struct e1000_info e1000_ich9_info = {
40764075
.flags = FLAG_HAS_JUMBO_FRAMES
40774076
| FLAG_IS_ICH
40784077
| FLAG_HAS_WOL
4079-
| FLAG_RX_CSUM_ENABLED
40804078
| FLAG_HAS_CTRLEXT_ON_LOAD
40814079
| FLAG_HAS_AMT
40824080
| FLAG_HAS_ERT
@@ -4095,7 +4093,6 @@ struct e1000_info e1000_ich10_info = {
40954093
.flags = FLAG_HAS_JUMBO_FRAMES
40964094
| FLAG_IS_ICH
40974095
| FLAG_HAS_WOL
4098-
| FLAG_RX_CSUM_ENABLED
40994096
| FLAG_HAS_CTRLEXT_ON_LOAD
41004097
| FLAG_HAS_AMT
41014098
| FLAG_HAS_ERT
@@ -4113,7 +4110,6 @@ struct e1000_info e1000_pch_info = {
41134110
.mac = e1000_pchlan,
41144111
.flags = FLAG_IS_ICH
41154112
| FLAG_HAS_WOL
4116-
| FLAG_RX_CSUM_ENABLED
41174113
| FLAG_HAS_CTRLEXT_ON_LOAD
41184114
| FLAG_HAS_AMT
41194115
| FLAG_HAS_FLASH
@@ -4133,7 +4129,6 @@ struct e1000_info e1000_pch2_info = {
41334129
.mac = e1000_pch2lan,
41344130
.flags = FLAG_IS_ICH
41354131
| FLAG_HAS_WOL
4136-
| FLAG_RX_CSUM_ENABLED
41374132
| FLAG_HAS_CTRLEXT_ON_LOAD
41384133
| FLAG_HAS_AMT
41394134
| FLAG_HAS_FLASH

drivers/net/ethernet/intel/e1000e/netdev.c

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3069,7 +3069,7 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
30693069

30703070
/* Enable Receive Checksum Offload for TCP and UDP */
30713071
rxcsum = er32(RXCSUM);
3072-
if (adapter->flags & FLAG_RX_CSUM_ENABLED) {
3072+
if (adapter->netdev->features & NETIF_F_RXCSUM) {
30733073
rxcsum |= E1000_RXCSUM_TUOFL;
30743074

30753075
/*
@@ -5860,6 +5860,26 @@ static void e1000_eeprom_checks(struct e1000_adapter *adapter)
58605860
}
58615861
}
58625862

5863+
static 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+
58635883
static const struct net_device_ops e1000e_netdev_ops = {
58645884
.ndo_open = e1000_open,
58655885
.ndo_stop = e1000_close,
@@ -5877,6 +5897,7 @@ static const struct net_device_ops e1000e_netdev_ops = {
58775897
#ifdef CONFIG_NET_POLL_CONTROLLER
58785898
.ndo_poll_controller = e1000_netpoll,
58795899
#endif
5900+
.ndo_set_features = e1000_set_features,
58805901
};
58815902

58825903
/**
@@ -6036,21 +6057,25 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
60366057
if (e1000_check_reset_block(&adapter->hw))
60376058
e_info("PHY reset is blocked due to SOL/IDER session.\n");
60386059

6039-
netdev->features = NETIF_F_SG |
6040-
NETIF_F_HW_CSUM |
6041-
NETIF_F_HW_VLAN_TX |
6042-
NETIF_F_HW_VLAN_RX;
6060+
/* Set initial default active device features */
6061+
netdev->features = (NETIF_F_SG |
6062+
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;
60436071

60446072
if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER)
60456073
netdev->features |= NETIF_F_HW_VLAN_FILTER;
60466074

6047-
netdev->features |= NETIF_F_TSO;
6048-
netdev->features |= NETIF_F_TSO6;
6049-
6050-
netdev->vlan_features |= NETIF_F_TSO;
6051-
netdev->vlan_features |= NETIF_F_TSO6;
6052-
netdev->vlan_features |= NETIF_F_HW_CSUM;
6053-
netdev->vlan_features |= NETIF_F_SG;
6075+
netdev->vlan_features |= (NETIF_F_SG |
6076+
NETIF_F_TSO |
6077+
NETIF_F_TSO6 |
6078+
NETIF_F_HW_CSUM);
60546079

60556080
if (pci_using_dac) {
60566081
netdev->features |= NETIF_F_HIGHDMA;

0 commit comments

Comments
 (0)