aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000
diff options
context:
space:
mode:
authorMichał Mirosław <mirq-linux@rere.qmqm.pl>2011-06-08 04:36:42 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2011-06-21 04:14:33 -0400
commite97d3207c5e697e3d86cc67483f9cdcce16cc0bf (patch)
tree70804f8bf3c1138ee100077465e2faed90458a77 /drivers/net/e1000
parent9f6ec8d697c08963d83880ccd35c13c5ace716ea (diff)
e1000: convert to ndo_fix_features
Private rx_csum flags are now duplicate of netdev->features & NETIF_F_RXCSUM. Removing this needs deeper surgery. Things noticed: - RX csum disabled by default - HW VLAN acceleration probably can be toggled, but it's left as is - the resets on RX csum offload change can probably be avoided - there is A LOT of copy-and-pasted code here Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> Tested-by: Aaron Brown <aaron.f.brown@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/e1000')
-rw-r--r--drivers/net/e1000/e1000_ethtool.c69
-rw-r--r--drivers/net/e1000/e1000_main.c30
2 files changed, 26 insertions, 73 deletions
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index ec0fa426cce2..c5f0f04219f3 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -290,69 +290,6 @@ static int e1000_set_pauseparam(struct net_device *netdev,
290 return retval; 290 return retval;
291} 291}
292 292
293static u32 e1000_get_rx_csum(struct net_device *netdev)
294{
295 struct e1000_adapter *adapter = netdev_priv(netdev);
296 return adapter->rx_csum;
297}
298
299static int e1000_set_rx_csum(struct net_device *netdev, u32 data)
300{
301 struct e1000_adapter *adapter = netdev_priv(netdev);
302 adapter->rx_csum = data;
303
304 if (netif_running(netdev))
305 e1000_reinit_locked(adapter);
306 else
307 e1000_reset(adapter);
308 return 0;
309}
310
311static u32 e1000_get_tx_csum(struct net_device *netdev)
312{
313 return (netdev->features & NETIF_F_HW_CSUM) != 0;
314}
315
316static int e1000_set_tx_csum(struct net_device *netdev, u32 data)
317{
318 struct e1000_adapter *adapter = netdev_priv(netdev);
319 struct e1000_hw *hw = &adapter->hw;
320
321 if (hw->mac_type < e1000_82543) {
322 if (!data)
323 return -EINVAL;
324 return 0;
325 }
326
327 if (data)
328 netdev->features |= NETIF_F_HW_CSUM;
329 else
330 netdev->features &= ~NETIF_F_HW_CSUM;
331
332 return 0;
333}
334
335static int e1000_set_tso(struct net_device *netdev, u32 data)
336{
337 struct e1000_adapter *adapter = netdev_priv(netdev);
338 struct e1000_hw *hw = &adapter->hw;
339
340 if ((hw->mac_type < e1000_82544) ||
341 (hw->mac_type == e1000_82547))
342 return data ? -EINVAL : 0;
343
344 if (data)
345 netdev->features |= NETIF_F_TSO;
346 else
347 netdev->features &= ~NETIF_F_TSO;
348
349 netdev->features &= ~NETIF_F_TSO6;
350
351 e_info(probe, "TSO is %s\n", data ? "Enabled" : "Disabled");
352 adapter->tso_force = true;
353 return 0;
354}
355
356static u32 e1000_get_msglevel(struct net_device *netdev) 293static u32 e1000_get_msglevel(struct net_device *netdev)
357{ 294{
358 struct e1000_adapter *adapter = netdev_priv(netdev); 295 struct e1000_adapter *adapter = netdev_priv(netdev);
@@ -1905,12 +1842,6 @@ static const struct ethtool_ops e1000_ethtool_ops = {
1905 .set_ringparam = e1000_set_ringparam, 1842 .set_ringparam = e1000_set_ringparam,
1906 .get_pauseparam = e1000_get_pauseparam, 1843 .get_pauseparam = e1000_get_pauseparam,
1907 .set_pauseparam = e1000_set_pauseparam, 1844 .set_pauseparam = e1000_set_pauseparam,
1908 .get_rx_csum = e1000_get_rx_csum,
1909 .set_rx_csum = e1000_set_rx_csum,
1910 .get_tx_csum = e1000_get_tx_csum,
1911 .set_tx_csum = e1000_set_tx_csum,
1912 .set_sg = ethtool_op_set_sg,
1913 .set_tso = e1000_set_tso,
1914 .self_test = e1000_diag_test, 1845 .self_test = e1000_diag_test,
1915 .get_strings = e1000_get_strings, 1846 .get_strings = e1000_get_strings,
1916 .set_phys_id = e1000_set_phys_id, 1847 .set_phys_id = e1000_set_phys_id,
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 76e8af00d86d..188d99ae9084 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -797,6 +797,24 @@ static int e1000_is_need_ioport(struct pci_dev *pdev)
797 } 797 }
798} 798}
799 799
800static int e1000_set_features(struct net_device *netdev, u32 features)
801{
802 struct e1000_adapter *adapter = netdev_priv(netdev);
803 u32 changed = features ^ netdev->features;
804
805 if (!(changed & NETIF_F_RXCSUM))
806 return 0;
807
808 adapter->rx_csum = !!(features & NETIF_F_RXCSUM);
809
810 if (netif_running(netdev))
811 e1000_reinit_locked(adapter);
812 else
813 e1000_reset(adapter);
814
815 return 0;
816}
817
800static const struct net_device_ops e1000_netdev_ops = { 818static const struct net_device_ops e1000_netdev_ops = {
801 .ndo_open = e1000_open, 819 .ndo_open = e1000_open,
802 .ndo_stop = e1000_close, 820 .ndo_stop = e1000_close,
@@ -815,6 +833,7 @@ static const struct net_device_ops e1000_netdev_ops = {
815#ifdef CONFIG_NET_POLL_CONTROLLER 833#ifdef CONFIG_NET_POLL_CONTROLLER
816 .ndo_poll_controller = e1000_netpoll, 834 .ndo_poll_controller = e1000_netpoll,
817#endif 835#endif
836 .ndo_set_features = e1000_set_features,
818}; 837};
819 838
820/** 839/**
@@ -1016,16 +1035,19 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
1016 } 1035 }
1017 1036
1018 if (hw->mac_type >= e1000_82543) { 1037 if (hw->mac_type >= e1000_82543) {
1019 netdev->features = NETIF_F_SG | 1038 netdev->hw_features = NETIF_F_SG |
1020 NETIF_F_HW_CSUM | 1039 NETIF_F_HW_CSUM;
1021 NETIF_F_HW_VLAN_TX | 1040 netdev->features = NETIF_F_HW_VLAN_TX |
1022 NETIF_F_HW_VLAN_RX | 1041 NETIF_F_HW_VLAN_RX |
1023 NETIF_F_HW_VLAN_FILTER; 1042 NETIF_F_HW_VLAN_FILTER;
1024 } 1043 }
1025 1044
1026 if ((hw->mac_type >= e1000_82544) && 1045 if ((hw->mac_type >= e1000_82544) &&
1027 (hw->mac_type != e1000_82547)) 1046 (hw->mac_type != e1000_82547))
1028 netdev->features |= NETIF_F_TSO; 1047 netdev->hw_features |= NETIF_F_TSO;
1048
1049 netdev->features |= netdev->hw_features;
1050 netdev->hw_features |= NETIF_F_RXCSUM;
1029 1051
1030 if (pci_using_dac) { 1052 if (pci_using_dac) {
1031 netdev->features |= NETIF_F_HIGHDMA; 1053 netdev->features |= NETIF_F_HIGHDMA;