diff options
author | Michał Mirosław <mirq-linux@rere.qmqm.pl> | 2011-06-08 04:39:40 -0400 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2011-09-16 21:26:37 -0400 |
commit | d7ccb8c2f2f73a9fcdb8fb0f3bcdd09746f3a9ef (patch) | |
tree | ef6f3869eb52d196825efd454f508537c0f26366 | |
parent | f78a5fda9116525809d088917638be912b85f838 (diff) |
ixgb: 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:
- ixgb has 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>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
-rw-r--r-- | drivers/net/ethernet/intel/ixgb/ixgb.h | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/ixgb/ixgb_ethtool.c | 59 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/ixgb/ixgb_main.c | 31 |
3 files changed, 31 insertions, 61 deletions
diff --git a/drivers/net/ethernet/intel/ixgb/ixgb.h b/drivers/net/ethernet/intel/ixgb/ixgb.h index 49e8408f05fc..cb23448fe2fa 100644 --- a/drivers/net/ethernet/intel/ixgb/ixgb.h +++ b/drivers/net/ethernet/intel/ixgb/ixgb.h | |||
@@ -204,6 +204,8 @@ extern void ixgb_set_ethtool_ops(struct net_device *netdev); | |||
204 | extern char ixgb_driver_name[]; | 204 | extern char ixgb_driver_name[]; |
205 | extern const char ixgb_driver_version[]; | 205 | extern const char ixgb_driver_version[]; |
206 | 206 | ||
207 | extern void ixgb_set_speed_duplex(struct net_device *netdev); | ||
208 | |||
207 | extern int ixgb_up(struct ixgb_adapter *adapter); | 209 | extern int ixgb_up(struct ixgb_adapter *adapter); |
208 | extern void ixgb_down(struct ixgb_adapter *adapter, bool kill_watchdog); | 210 | extern void ixgb_down(struct ixgb_adapter *adapter, bool kill_watchdog); |
209 | extern void ixgb_reset(struct ixgb_adapter *adapter); | 211 | extern void ixgb_reset(struct ixgb_adapter *adapter); |
diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_ethtool.c b/drivers/net/ethernet/intel/ixgb/ixgb_ethtool.c index 6da890b9534c..fdb30cc60173 100644 --- a/drivers/net/ethernet/intel/ixgb/ixgb_ethtool.c +++ b/drivers/net/ethernet/intel/ixgb/ixgb_ethtool.c | |||
@@ -115,7 +115,7 @@ ixgb_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) | |||
115 | return 0; | 115 | return 0; |
116 | } | 116 | } |
117 | 117 | ||
118 | static void ixgb_set_speed_duplex(struct net_device *netdev) | 118 | void ixgb_set_speed_duplex(struct net_device *netdev) |
119 | { | 119 | { |
120 | struct ixgb_adapter *adapter = netdev_priv(netdev); | 120 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
121 | /* be optimistic about our link, since we were up before */ | 121 | /* be optimistic about our link, since we were up before */ |
@@ -195,57 +195,6 @@ ixgb_set_pauseparam(struct net_device *netdev, | |||
195 | } | 195 | } |
196 | 196 | ||
197 | static u32 | 197 | static u32 |
198 | ixgb_get_rx_csum(struct net_device *netdev) | ||
199 | { | ||
200 | struct ixgb_adapter *adapter = netdev_priv(netdev); | ||
201 | |||
202 | return adapter->rx_csum; | ||
203 | } | ||
204 | |||
205 | static int | ||
206 | ixgb_set_rx_csum(struct net_device *netdev, u32 data) | ||
207 | { | ||
208 | struct ixgb_adapter *adapter = netdev_priv(netdev); | ||
209 | |||
210 | adapter->rx_csum = data; | ||
211 | |||
212 | if (netif_running(netdev)) { | ||
213 | ixgb_down(adapter, true); | ||
214 | ixgb_up(adapter); | ||
215 | ixgb_set_speed_duplex(netdev); | ||
216 | } else | ||
217 | ixgb_reset(adapter); | ||
218 | return 0; | ||
219 | } | ||
220 | |||
221 | static u32 | ||
222 | ixgb_get_tx_csum(struct net_device *netdev) | ||
223 | { | ||
224 | return (netdev->features & NETIF_F_HW_CSUM) != 0; | ||
225 | } | ||
226 | |||
227 | static int | ||
228 | ixgb_set_tx_csum(struct net_device *netdev, u32 data) | ||
229 | { | ||
230 | if (data) | ||
231 | netdev->features |= NETIF_F_HW_CSUM; | ||
232 | else | ||
233 | netdev->features &= ~NETIF_F_HW_CSUM; | ||
234 | |||
235 | return 0; | ||
236 | } | ||
237 | |||
238 | static int | ||
239 | ixgb_set_tso(struct net_device *netdev, u32 data) | ||
240 | { | ||
241 | if (data) | ||
242 | netdev->features |= NETIF_F_TSO; | ||
243 | else | ||
244 | netdev->features &= ~NETIF_F_TSO; | ||
245 | return 0; | ||
246 | } | ||
247 | |||
248 | static u32 | ||
249 | ixgb_get_msglevel(struct net_device *netdev) | 198 | ixgb_get_msglevel(struct net_device *netdev) |
250 | { | 199 | { |
251 | struct ixgb_adapter *adapter = netdev_priv(netdev); | 200 | struct ixgb_adapter *adapter = netdev_priv(netdev); |
@@ -736,14 +685,8 @@ static const struct ethtool_ops ixgb_ethtool_ops = { | |||
736 | .set_ringparam = ixgb_set_ringparam, | 685 | .set_ringparam = ixgb_set_ringparam, |
737 | .get_pauseparam = ixgb_get_pauseparam, | 686 | .get_pauseparam = ixgb_get_pauseparam, |
738 | .set_pauseparam = ixgb_set_pauseparam, | 687 | .set_pauseparam = ixgb_set_pauseparam, |
739 | .get_rx_csum = ixgb_get_rx_csum, | ||
740 | .set_rx_csum = ixgb_set_rx_csum, | ||
741 | .get_tx_csum = ixgb_get_tx_csum, | ||
742 | .set_tx_csum = ixgb_set_tx_csum, | ||
743 | .set_sg = ethtool_op_set_sg, | ||
744 | .get_msglevel = ixgb_get_msglevel, | 688 | .get_msglevel = ixgb_get_msglevel, |
745 | .set_msglevel = ixgb_set_msglevel, | 689 | .set_msglevel = ixgb_set_msglevel, |
746 | .set_tso = ixgb_set_tso, | ||
747 | .get_strings = ixgb_get_strings, | 690 | .get_strings = ixgb_get_strings, |
748 | .set_phys_id = ixgb_set_phys_id, | 691 | .set_phys_id = ixgb_set_phys_id, |
749 | .get_sset_count = ixgb_get_sset_count, | 692 | .get_sset_count = ixgb_get_sset_count, |
diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_main.c b/drivers/net/ethernet/intel/ixgb/ixgb_main.c index c8b9c9028bc0..b8fb16304598 100644 --- a/drivers/net/ethernet/intel/ixgb/ixgb_main.c +++ b/drivers/net/ethernet/intel/ixgb/ixgb_main.c | |||
@@ -325,6 +325,28 @@ ixgb_reset(struct ixgb_adapter *adapter) | |||
325 | } | 325 | } |
326 | } | 326 | } |
327 | 327 | ||
328 | static int | ||
329 | ixgb_set_features(struct net_device *netdev, u32 features) | ||
330 | { | ||
331 | struct ixgb_adapter *adapter = netdev_priv(netdev); | ||
332 | u32 changed = features ^ netdev->features; | ||
333 | |||
334 | if (!(changed & NETIF_F_RXCSUM)) | ||
335 | return 0; | ||
336 | |||
337 | adapter->rx_csum = !!(features & NETIF_F_RXCSUM); | ||
338 | |||
339 | if (netif_running(netdev)) { | ||
340 | ixgb_down(adapter, true); | ||
341 | ixgb_up(adapter); | ||
342 | ixgb_set_speed_duplex(netdev); | ||
343 | } else | ||
344 | ixgb_reset(adapter); | ||
345 | |||
346 | return 0; | ||
347 | } | ||
348 | |||
349 | |||
328 | static const struct net_device_ops ixgb_netdev_ops = { | 350 | static const struct net_device_ops ixgb_netdev_ops = { |
329 | .ndo_open = ixgb_open, | 351 | .ndo_open = ixgb_open, |
330 | .ndo_stop = ixgb_close, | 352 | .ndo_stop = ixgb_close, |
@@ -340,6 +362,7 @@ static const struct net_device_ops ixgb_netdev_ops = { | |||
340 | #ifdef CONFIG_NET_POLL_CONTROLLER | 362 | #ifdef CONFIG_NET_POLL_CONTROLLER |
341 | .ndo_poll_controller = ixgb_netpoll, | 363 | .ndo_poll_controller = ixgb_netpoll, |
342 | #endif | 364 | #endif |
365 | .ndo_set_features = ixgb_set_features, | ||
343 | }; | 366 | }; |
344 | 367 | ||
345 | /** | 368 | /** |
@@ -439,12 +462,14 @@ ixgb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
439 | if (err) | 462 | if (err) |
440 | goto err_sw_init; | 463 | goto err_sw_init; |
441 | 464 | ||
442 | netdev->features = NETIF_F_SG | | 465 | netdev->hw_features = NETIF_F_SG | |
443 | NETIF_F_HW_CSUM | | 466 | NETIF_F_TSO | |
467 | NETIF_F_HW_CSUM; | ||
468 | netdev->features = netdev->hw_features | | ||
444 | NETIF_F_HW_VLAN_TX | | 469 | NETIF_F_HW_VLAN_TX | |
445 | NETIF_F_HW_VLAN_RX | | 470 | NETIF_F_HW_VLAN_RX | |
446 | NETIF_F_HW_VLAN_FILTER; | 471 | NETIF_F_HW_VLAN_FILTER; |
447 | netdev->features |= NETIF_F_TSO; | 472 | netdev->hw_features |= NETIF_F_RXCSUM; |
448 | 473 | ||
449 | if (pci_using_dac) { | 474 | if (pci_using_dac) { |
450 | netdev->features |= NETIF_F_HIGHDMA; | 475 | netdev->features |= NETIF_F_HIGHDMA; |