diff options
author | Michał Mirosław <mirq-linux@rere.qmqm.pl> | 2011-06-08 04:38:01 -0400 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2011-06-21 04:15:07 -0400 |
commit | ac52caa31e0a135a8940a66de763751760820f37 (patch) | |
tree | f4caa06886c9b9ac5b3f5686b71f64e477f1aaa0 /drivers/net/igb | |
parent | e97d3207c5e697e3d86cc67483f9cdcce16cc0bf (diff) |
igb: 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:
- 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/igb')
-rw-r--r-- | drivers/net/igb/igb_ethtool.c | 67 | ||||
-rw-r--r-- | drivers/net/igb/igb_main.c | 33 |
2 files changed, 26 insertions, 74 deletions
diff --git a/drivers/net/igb/igb_ethtool.c b/drivers/net/igb/igb_ethtool.c index fdc895e5a3f8..1862c97508ea 100644 --- a/drivers/net/igb/igb_ethtool.c +++ b/drivers/net/igb/igb_ethtool.c | |||
@@ -318,65 +318,6 @@ static int igb_set_pauseparam(struct net_device *netdev, | |||
318 | return retval; | 318 | return retval; |
319 | } | 319 | } |
320 | 320 | ||
321 | static u32 igb_get_rx_csum(struct net_device *netdev) | ||
322 | { | ||
323 | struct igb_adapter *adapter = netdev_priv(netdev); | ||
324 | return !!(adapter->rx_ring[0]->flags & IGB_RING_FLAG_RX_CSUM); | ||
325 | } | ||
326 | |||
327 | static int igb_set_rx_csum(struct net_device *netdev, u32 data) | ||
328 | { | ||
329 | struct igb_adapter *adapter = netdev_priv(netdev); | ||
330 | int i; | ||
331 | |||
332 | for (i = 0; i < adapter->num_rx_queues; i++) { | ||
333 | if (data) | ||
334 | adapter->rx_ring[i]->flags |= IGB_RING_FLAG_RX_CSUM; | ||
335 | else | ||
336 | adapter->rx_ring[i]->flags &= ~IGB_RING_FLAG_RX_CSUM; | ||
337 | } | ||
338 | |||
339 | return 0; | ||
340 | } | ||
341 | |||
342 | static u32 igb_get_tx_csum(struct net_device *netdev) | ||
343 | { | ||
344 | return (netdev->features & NETIF_F_IP_CSUM) != 0; | ||
345 | } | ||
346 | |||
347 | static int igb_set_tx_csum(struct net_device *netdev, u32 data) | ||
348 | { | ||
349 | struct igb_adapter *adapter = netdev_priv(netdev); | ||
350 | |||
351 | if (data) { | ||
352 | netdev->features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM); | ||
353 | if (adapter->hw.mac.type >= e1000_82576) | ||
354 | netdev->features |= NETIF_F_SCTP_CSUM; | ||
355 | } else { | ||
356 | netdev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | | ||
357 | NETIF_F_SCTP_CSUM); | ||
358 | } | ||
359 | |||
360 | return 0; | ||
361 | } | ||
362 | |||
363 | static int igb_set_tso(struct net_device *netdev, u32 data) | ||
364 | { | ||
365 | struct igb_adapter *adapter = netdev_priv(netdev); | ||
366 | |||
367 | if (data) { | ||
368 | netdev->features |= NETIF_F_TSO; | ||
369 | netdev->features |= NETIF_F_TSO6; | ||
370 | } else { | ||
371 | netdev->features &= ~NETIF_F_TSO; | ||
372 | netdev->features &= ~NETIF_F_TSO6; | ||
373 | } | ||
374 | |||
375 | dev_info(&adapter->pdev->dev, "TSO is %s\n", | ||
376 | data ? "Enabled" : "Disabled"); | ||
377 | return 0; | ||
378 | } | ||
379 | |||
380 | static u32 igb_get_msglevel(struct net_device *netdev) | 321 | static u32 igb_get_msglevel(struct net_device *netdev) |
381 | { | 322 | { |
382 | struct igb_adapter *adapter = netdev_priv(netdev); | 323 | struct igb_adapter *adapter = netdev_priv(netdev); |
@@ -2207,14 +2148,6 @@ static const struct ethtool_ops igb_ethtool_ops = { | |||
2207 | .set_ringparam = igb_set_ringparam, | 2148 | .set_ringparam = igb_set_ringparam, |
2208 | .get_pauseparam = igb_get_pauseparam, | 2149 | .get_pauseparam = igb_get_pauseparam, |
2209 | .set_pauseparam = igb_set_pauseparam, | 2150 | .set_pauseparam = igb_set_pauseparam, |
2210 | .get_rx_csum = igb_get_rx_csum, | ||
2211 | .set_rx_csum = igb_set_rx_csum, | ||
2212 | .get_tx_csum = igb_get_tx_csum, | ||
2213 | .set_tx_csum = igb_set_tx_csum, | ||
2214 | .get_sg = ethtool_op_get_sg, | ||
2215 | .set_sg = ethtool_op_set_sg, | ||
2216 | .get_tso = ethtool_op_get_tso, | ||
2217 | .set_tso = igb_set_tso, | ||
2218 | .self_test = igb_diag_test, | 2151 | .self_test = igb_diag_test, |
2219 | .get_strings = igb_get_strings, | 2152 | .get_strings = igb_get_strings, |
2220 | .set_phys_id = igb_set_phys_id, | 2153 | .set_phys_id = igb_set_phys_id, |
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c index fd64c56a433d..6e67258c4b4e 100644 --- a/drivers/net/igb/igb_main.c +++ b/drivers/net/igb/igb_main.c | |||
@@ -1748,6 +1748,21 @@ void igb_reset(struct igb_adapter *adapter) | |||
1748 | igb_get_phy_info(hw); | 1748 | igb_get_phy_info(hw); |
1749 | } | 1749 | } |
1750 | 1750 | ||
1751 | static int igb_set_features(struct net_device *netdev, u32 features) | ||
1752 | { | ||
1753 | struct igb_adapter *adapter = netdev_priv(netdev); | ||
1754 | int i; | ||
1755 | |||
1756 | for (i = 0; i < adapter->num_rx_queues; i++) { | ||
1757 | if (features & NETIF_F_RXCSUM) | ||
1758 | adapter->rx_ring[i]->flags |= IGB_RING_FLAG_RX_CSUM; | ||
1759 | else | ||
1760 | adapter->rx_ring[i]->flags &= ~IGB_RING_FLAG_RX_CSUM; | ||
1761 | } | ||
1762 | |||
1763 | return 0; | ||
1764 | } | ||
1765 | |||
1751 | static const struct net_device_ops igb_netdev_ops = { | 1766 | static const struct net_device_ops igb_netdev_ops = { |
1752 | .ndo_open = igb_open, | 1767 | .ndo_open = igb_open, |
1753 | .ndo_stop = igb_close, | 1768 | .ndo_stop = igb_close, |
@@ -1770,6 +1785,7 @@ static const struct net_device_ops igb_netdev_ops = { | |||
1770 | #ifdef CONFIG_NET_POLL_CONTROLLER | 1785 | #ifdef CONFIG_NET_POLL_CONTROLLER |
1771 | .ndo_poll_controller = igb_netpoll, | 1786 | .ndo_poll_controller = igb_netpoll, |
1772 | #endif | 1787 | #endif |
1788 | .ndo_set_features = igb_set_features, | ||
1773 | }; | 1789 | }; |
1774 | 1790 | ||
1775 | /** | 1791 | /** |
@@ -1909,17 +1925,18 @@ static int __devinit igb_probe(struct pci_dev *pdev, | |||
1909 | dev_info(&pdev->dev, | 1925 | dev_info(&pdev->dev, |
1910 | "PHY reset is blocked due to SOL/IDER session.\n"); | 1926 | "PHY reset is blocked due to SOL/IDER session.\n"); |
1911 | 1927 | ||
1912 | netdev->features = NETIF_F_SG | | 1928 | netdev->hw_features = NETIF_F_SG | |
1913 | NETIF_F_IP_CSUM | | 1929 | NETIF_F_IP_CSUM | |
1930 | NETIF_F_IPV6_CSUM | | ||
1931 | NETIF_F_TSO | | ||
1932 | NETIF_F_TSO6 | | ||
1933 | NETIF_F_RXCSUM; | ||
1934 | |||
1935 | netdev->features = netdev->hw_features | | ||
1914 | NETIF_F_HW_VLAN_TX | | 1936 | NETIF_F_HW_VLAN_TX | |
1915 | NETIF_F_HW_VLAN_RX | | 1937 | NETIF_F_HW_VLAN_RX | |
1916 | NETIF_F_HW_VLAN_FILTER; | 1938 | NETIF_F_HW_VLAN_FILTER; |
1917 | 1939 | ||
1918 | netdev->features |= NETIF_F_IPV6_CSUM; | ||
1919 | netdev->features |= NETIF_F_TSO; | ||
1920 | netdev->features |= NETIF_F_TSO6; | ||
1921 | netdev->features |= NETIF_F_GRO; | ||
1922 | |||
1923 | netdev->vlan_features |= NETIF_F_TSO; | 1940 | netdev->vlan_features |= NETIF_F_TSO; |
1924 | netdev->vlan_features |= NETIF_F_TSO6; | 1941 | netdev->vlan_features |= NETIF_F_TSO6; |
1925 | netdev->vlan_features |= NETIF_F_IP_CSUM; | 1942 | netdev->vlan_features |= NETIF_F_IP_CSUM; |
@@ -1931,8 +1948,10 @@ static int __devinit igb_probe(struct pci_dev *pdev, | |||
1931 | netdev->vlan_features |= NETIF_F_HIGHDMA; | 1948 | netdev->vlan_features |= NETIF_F_HIGHDMA; |
1932 | } | 1949 | } |
1933 | 1950 | ||
1934 | if (hw->mac.type >= e1000_82576) | 1951 | if (hw->mac.type >= e1000_82576) { |
1952 | netdev->hw_features |= NETIF_F_SCTP_CSUM; | ||
1935 | netdev->features |= NETIF_F_SCTP_CSUM; | 1953 | netdev->features |= NETIF_F_SCTP_CSUM; |
1954 | } | ||
1936 | 1955 | ||
1937 | adapter->en_mng_pt = igb_enable_mng_pass_thru(hw); | 1956 | adapter->en_mng_pt = igb_enable_mng_pass_thru(hw); |
1938 | 1957 | ||