diff options
| author | Michał Mirosław <mirq-linux@rere.qmqm.pl> | 2011-04-18 21:56:12 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2011-04-20 04:30:43 -0400 |
| commit | 756a6b03da98903fa22ad7f10752de11782249fc (patch) | |
| tree | a360baaa47e0669fbd75d8d7374b70d0f7250cf0 /drivers/net/pch_gbe | |
| parent | 3d96c74d8983b16bc7ecb196e61a2173fcc3f09f (diff) | |
net: pch_gbe: convert to hw_features
This also fixes bug in xmit path, where TX checksum offload state was used
instead of skb->ip_summed to decide if the offload was needed.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/pch_gbe')
| -rw-r--r-- | drivers/net/pch_gbe/pch_gbe.h | 4 | ||||
| -rw-r--r-- | drivers/net/pch_gbe/pch_gbe_ethtool.c | 54 | ||||
| -rw-r--r-- | drivers/net/pch_gbe/pch_gbe_main.c | 42 | ||||
| -rw-r--r-- | drivers/net/pch_gbe/pch_gbe_param.c | 16 |
4 files changed, 42 insertions, 74 deletions
diff --git a/drivers/net/pch_gbe/pch_gbe.h b/drivers/net/pch_gbe/pch_gbe.h index bf126e76fabf..59fac77d0dbb 100644 --- a/drivers/net/pch_gbe/pch_gbe.h +++ b/drivers/net/pch_gbe/pch_gbe.h | |||
| @@ -597,8 +597,6 @@ struct pch_gbe_hw_stats { | |||
| 597 | * @rx_ring: Pointer of Rx descriptor ring structure | 597 | * @rx_ring: Pointer of Rx descriptor ring structure |
| 598 | * @rx_buffer_len: Receive buffer length | 598 | * @rx_buffer_len: Receive buffer length |
| 599 | * @tx_queue_len: Transmit queue length | 599 | * @tx_queue_len: Transmit queue length |
| 600 | * @rx_csum: Receive TCP/IP checksum enable/disable | ||
| 601 | * @tx_csum: Transmit TCP/IP checksum enable/disable | ||
| 602 | * @have_msi: PCI MSI mode flag | 600 | * @have_msi: PCI MSI mode flag |
| 603 | */ | 601 | */ |
| 604 | 602 | ||
| @@ -623,8 +621,6 @@ struct pch_gbe_adapter { | |||
| 623 | struct pch_gbe_rx_ring *rx_ring; | 621 | struct pch_gbe_rx_ring *rx_ring; |
| 624 | unsigned long rx_buffer_len; | 622 | unsigned long rx_buffer_len; |
| 625 | unsigned long tx_queue_len; | 623 | unsigned long tx_queue_len; |
| 626 | bool rx_csum; | ||
| 627 | bool tx_csum; | ||
| 628 | bool have_msi; | 624 | bool have_msi; |
| 629 | }; | 625 | }; |
| 630 | 626 | ||
diff --git a/drivers/net/pch_gbe/pch_gbe_ethtool.c b/drivers/net/pch_gbe/pch_gbe_ethtool.c index d2174a40d708..c35d105ab285 100644 --- a/drivers/net/pch_gbe/pch_gbe_ethtool.c +++ b/drivers/net/pch_gbe/pch_gbe_ethtool.c | |||
| @@ -434,57 +434,6 @@ static int pch_gbe_set_pauseparam(struct net_device *netdev, | |||
| 434 | } | 434 | } |
| 435 | 435 | ||
| 436 | /** | 436 | /** |
| 437 | * pch_gbe_get_rx_csum - Report whether receive checksums are turned on or off | ||
| 438 | * @netdev: Network interface device structure | ||
| 439 | * Returns | ||
| 440 | * true(1): Checksum On | ||
| 441 | * false(0): Checksum Off | ||
| 442 | */ | ||
| 443 | static u32 pch_gbe_get_rx_csum(struct net_device *netdev) | ||
| 444 | { | ||
| 445 | struct pch_gbe_adapter *adapter = netdev_priv(netdev); | ||
| 446 | |||
| 447 | return adapter->rx_csum; | ||
| 448 | } | ||
| 449 | |||
| 450 | /** | ||
| 451 | * pch_gbe_set_rx_csum - Turn receive checksum on or off | ||
| 452 | * @netdev: Network interface device structure | ||
| 453 | * @data: Checksum On[true] or Off[false] | ||
| 454 | * Returns | ||
| 455 | * 0: Successful. | ||
| 456 | * Negative value: Failed. | ||
| 457 | */ | ||
| 458 | static int pch_gbe_set_rx_csum(struct net_device *netdev, u32 data) | ||
| 459 | { | ||
| 460 | struct pch_gbe_adapter *adapter = netdev_priv(netdev); | ||
| 461 | |||
| 462 | adapter->rx_csum = data; | ||
| 463 | if ((netif_running(netdev))) | ||
| 464 | pch_gbe_reinit_locked(adapter); | ||
| 465 | else | ||
| 466 | pch_gbe_reset(adapter); | ||
| 467 | |||
| 468 | return 0; | ||
| 469 | } | ||
| 470 | |||
| 471 | /** | ||
| 472 | * pch_gbe_set_tx_csum - Turn transmit checksums on or off | ||
| 473 | * @netdev: Network interface device structure | ||
| 474 | * @data: Checksum on[true] or off[false] | ||
| 475 | * Returns | ||
| 476 | * 0: Successful. | ||
| 477 | * Negative value: Failed. | ||
| 478 | */ | ||
| 479 | static int pch_gbe_set_tx_csum(struct net_device *netdev, u32 data) | ||
| 480 | { | ||
| 481 | struct pch_gbe_adapter *adapter = netdev_priv(netdev); | ||
| 482 | |||
| 483 | adapter->tx_csum = data; | ||
| 484 | return ethtool_op_set_tx_ipv6_csum(netdev, data); | ||
| 485 | } | ||
| 486 | |||
| 487 | /** | ||
| 488 | * pch_gbe_get_strings - Return a set of strings that describe the requested | 437 | * pch_gbe_get_strings - Return a set of strings that describe the requested |
| 489 | * objects | 438 | * objects |
| 490 | * @netdev: Network interface device structure | 439 | * @netdev: Network interface device structure |
| @@ -554,9 +503,6 @@ static const struct ethtool_ops pch_gbe_ethtool_ops = { | |||
| 554 | .set_ringparam = pch_gbe_set_ringparam, | 503 | .set_ringparam = pch_gbe_set_ringparam, |
| 555 | .get_pauseparam = pch_gbe_get_pauseparam, | 504 | .get_pauseparam = pch_gbe_get_pauseparam, |
| 556 | .set_pauseparam = pch_gbe_set_pauseparam, | 505 | .set_pauseparam = pch_gbe_set_pauseparam, |
| 557 | .get_rx_csum = pch_gbe_get_rx_csum, | ||
| 558 | .set_rx_csum = pch_gbe_set_rx_csum, | ||
| 559 | .set_tx_csum = pch_gbe_set_tx_csum, | ||
| 560 | .get_strings = pch_gbe_get_strings, | 506 | .get_strings = pch_gbe_get_strings, |
| 561 | .get_ethtool_stats = pch_gbe_get_ethtool_stats, | 507 | .get_ethtool_stats = pch_gbe_get_ethtool_stats, |
| 562 | .get_sset_count = pch_gbe_get_sset_count, | 508 | .get_sset_count = pch_gbe_get_sset_count, |
diff --git a/drivers/net/pch_gbe/pch_gbe_main.c b/drivers/net/pch_gbe/pch_gbe_main.c index 2ef2f9cdefa6..4cc9872f5ec4 100644 --- a/drivers/net/pch_gbe/pch_gbe_main.c +++ b/drivers/net/pch_gbe/pch_gbe_main.c | |||
| @@ -656,6 +656,7 @@ static void pch_gbe_configure_tx(struct pch_gbe_adapter *adapter) | |||
| 656 | */ | 656 | */ |
| 657 | static void pch_gbe_setup_rctl(struct pch_gbe_adapter *adapter) | 657 | static void pch_gbe_setup_rctl(struct pch_gbe_adapter *adapter) |
| 658 | { | 658 | { |
| 659 | struct net_device *netdev = adapter->netdev; | ||
| 659 | struct pch_gbe_hw *hw = &adapter->hw; | 660 | struct pch_gbe_hw *hw = &adapter->hw; |
| 660 | u32 rx_mode, tcpip; | 661 | u32 rx_mode, tcpip; |
| 661 | 662 | ||
| @@ -666,7 +667,7 @@ static void pch_gbe_setup_rctl(struct pch_gbe_adapter *adapter) | |||
| 666 | 667 | ||
| 667 | tcpip = ioread32(&hw->reg->TCPIP_ACC); | 668 | tcpip = ioread32(&hw->reg->TCPIP_ACC); |
| 668 | 669 | ||
| 669 | if (adapter->rx_csum) { | 670 | if (netdev->features & NETIF_F_RXCSUM) { |
| 670 | tcpip &= ~PCH_GBE_RX_TCPIPACC_OFF; | 671 | tcpip &= ~PCH_GBE_RX_TCPIPACC_OFF; |
| 671 | tcpip |= PCH_GBE_RX_TCPIPACC_EN; | 672 | tcpip |= PCH_GBE_RX_TCPIPACC_EN; |
| 672 | } else { | 673 | } else { |
| @@ -950,7 +951,7 @@ static void pch_gbe_tx_queue(struct pch_gbe_adapter *adapter, | |||
| 950 | frame_ctrl = 0; | 951 | frame_ctrl = 0; |
| 951 | if (unlikely(skb->len < PCH_GBE_SHORT_PKT)) | 952 | if (unlikely(skb->len < PCH_GBE_SHORT_PKT)) |
| 952 | frame_ctrl |= PCH_GBE_TXD_CTRL_APAD; | 953 | frame_ctrl |= PCH_GBE_TXD_CTRL_APAD; |
| 953 | if (unlikely(!adapter->tx_csum)) | 954 | if (skb->ip_summed == CHECKSUM_NONE) |
| 954 | frame_ctrl |= PCH_GBE_TXD_CTRL_TCPIP_ACC_OFF; | 955 | frame_ctrl |= PCH_GBE_TXD_CTRL_TCPIP_ACC_OFF; |
| 955 | 956 | ||
| 956 | /* Performs checksum processing */ | 957 | /* Performs checksum processing */ |
| @@ -958,7 +959,7 @@ static void pch_gbe_tx_queue(struct pch_gbe_adapter *adapter, | |||
| 958 | * It is because the hardware accelerator does not support a checksum, | 959 | * It is because the hardware accelerator does not support a checksum, |
| 959 | * when the received data size is less than 64 bytes. | 960 | * when the received data size is less than 64 bytes. |
| 960 | */ | 961 | */ |
| 961 | if ((skb->len < PCH_GBE_SHORT_PKT) && (adapter->tx_csum)) { | 962 | if (skb->len < PCH_GBE_SHORT_PKT && skb->ip_summed != CHECKSUM_NONE) { |
| 962 | frame_ctrl |= PCH_GBE_TXD_CTRL_APAD | | 963 | frame_ctrl |= PCH_GBE_TXD_CTRL_APAD | |
| 963 | PCH_GBE_TXD_CTRL_TCPIP_ACC_OFF; | 964 | PCH_GBE_TXD_CTRL_TCPIP_ACC_OFF; |
| 964 | if (skb->protocol == htons(ETH_P_IP)) { | 965 | if (skb->protocol == htons(ETH_P_IP)) { |
| @@ -1426,7 +1427,7 @@ pch_gbe_clean_rx(struct pch_gbe_adapter *adapter, | |||
| 1426 | length = (rx_desc->rx_words_eob) - 3; | 1427 | length = (rx_desc->rx_words_eob) - 3; |
| 1427 | 1428 | ||
| 1428 | /* Decide the data conversion method */ | 1429 | /* Decide the data conversion method */ |
| 1429 | if (!adapter->rx_csum) { | 1430 | if (!(netdev->features & NETIF_F_RXCSUM)) { |
| 1430 | /* [Header:14][payload] */ | 1431 | /* [Header:14][payload] */ |
| 1431 | if (NET_IP_ALIGN) { | 1432 | if (NET_IP_ALIGN) { |
| 1432 | /* Because alignment differs, | 1433 | /* Because alignment differs, |
| @@ -2030,6 +2031,29 @@ static int pch_gbe_change_mtu(struct net_device *netdev, int new_mtu) | |||
| 2030 | } | 2031 | } |
| 2031 | 2032 | ||
| 2032 | /** | 2033 | /** |
| 2034 | * pch_gbe_set_features - Reset device after features changed | ||
| 2035 | * @netdev: Network interface device structure | ||
| 2036 | * @features: New features | ||
| 2037 | * Returns | ||
| 2038 | * 0: HW state updated successfully | ||
| 2039 | */ | ||
| 2040 | static int pch_gbe_set_features(struct net_device *netdev, u32 features) | ||
| 2041 | { | ||
| 2042 | struct pch_gbe_adapter *adapter = netdev_priv(netdev); | ||
| 2043 | u32 changed = features ^ netdev->features; | ||
| 2044 | |||
| 2045 | if (!(changed & NETIF_F_RXCSUM)) | ||
| 2046 | return 0; | ||
| 2047 | |||
| 2048 | if (netif_running(netdev)) | ||
| 2049 | pch_gbe_reinit_locked(adapter); | ||
| 2050 | else | ||
| 2051 | pch_gbe_reset(adapter); | ||
| 2052 | |||
| 2053 | return 0; | ||
| 2054 | } | ||
| 2055 | |||
| 2056 | /** | ||
| 2033 | * pch_gbe_ioctl - Controls register through a MII interface | 2057 | * pch_gbe_ioctl - Controls register through a MII interface |
| 2034 | * @netdev: Network interface device structure | 2058 | * @netdev: Network interface device structure |
| 2035 | * @ifr: Pointer to ifr structure | 2059 | * @ifr: Pointer to ifr structure |
| @@ -2129,6 +2153,7 @@ static const struct net_device_ops pch_gbe_netdev_ops = { | |||
| 2129 | .ndo_set_mac_address = pch_gbe_set_mac, | 2153 | .ndo_set_mac_address = pch_gbe_set_mac, |
| 2130 | .ndo_tx_timeout = pch_gbe_tx_timeout, | 2154 | .ndo_tx_timeout = pch_gbe_tx_timeout, |
| 2131 | .ndo_change_mtu = pch_gbe_change_mtu, | 2155 | .ndo_change_mtu = pch_gbe_change_mtu, |
| 2156 | .ndo_set_features = pch_gbe_set_features, | ||
| 2132 | .ndo_do_ioctl = pch_gbe_ioctl, | 2157 | .ndo_do_ioctl = pch_gbe_ioctl, |
| 2133 | .ndo_set_multicast_list = &pch_gbe_set_multi, | 2158 | .ndo_set_multicast_list = &pch_gbe_set_multi, |
| 2134 | #ifdef CONFIG_NET_POLL_CONTROLLER | 2159 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| @@ -2334,7 +2359,9 @@ static int pch_gbe_probe(struct pci_dev *pdev, | |||
| 2334 | netdev->watchdog_timeo = PCH_GBE_WATCHDOG_PERIOD; | 2359 | netdev->watchdog_timeo = PCH_GBE_WATCHDOG_PERIOD; |
| 2335 | netif_napi_add(netdev, &adapter->napi, | 2360 | netif_napi_add(netdev, &adapter->napi, |
| 2336 | pch_gbe_napi_poll, PCH_GBE_RX_WEIGHT); | 2361 | pch_gbe_napi_poll, PCH_GBE_RX_WEIGHT); |
| 2337 | netdev->features = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_GRO; | 2362 | netdev->hw_features = NETIF_F_RXCSUM | |
| 2363 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; | ||
| 2364 | netdev->features = netdev->hw_features; | ||
| 2338 | pch_gbe_set_ethtool_ops(netdev); | 2365 | pch_gbe_set_ethtool_ops(netdev); |
| 2339 | 2366 | ||
| 2340 | pch_gbe_mac_load_mac_addr(&adapter->hw); | 2367 | pch_gbe_mac_load_mac_addr(&adapter->hw); |
| @@ -2373,11 +2400,6 @@ static int pch_gbe_probe(struct pci_dev *pdev, | |||
| 2373 | 2400 | ||
| 2374 | pch_gbe_check_options(adapter); | 2401 | pch_gbe_check_options(adapter); |
| 2375 | 2402 | ||
| 2376 | if (adapter->tx_csum) | ||
| 2377 | netdev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; | ||
| 2378 | else | ||
| 2379 | netdev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM); | ||
| 2380 | |||
| 2381 | /* initialize the wol settings based on the eeprom settings */ | 2403 | /* initialize the wol settings based on the eeprom settings */ |
| 2382 | adapter->wake_up_evt = PCH_GBE_WL_INIT_SETTING; | 2404 | adapter->wake_up_evt = PCH_GBE_WL_INIT_SETTING; |
| 2383 | dev_info(&pdev->dev, "MAC address : %pM\n", netdev->dev_addr); | 2405 | dev_info(&pdev->dev, "MAC address : %pM\n", netdev->dev_addr); |
diff --git a/drivers/net/pch_gbe/pch_gbe_param.c b/drivers/net/pch_gbe/pch_gbe_param.c index ef0996a0eaaa..5b5d90a47e29 100644 --- a/drivers/net/pch_gbe/pch_gbe_param.c +++ b/drivers/net/pch_gbe/pch_gbe_param.c | |||
| @@ -426,6 +426,8 @@ full_duplex_only: | |||
| 426 | void pch_gbe_check_options(struct pch_gbe_adapter *adapter) | 426 | void pch_gbe_check_options(struct pch_gbe_adapter *adapter) |
| 427 | { | 427 | { |
| 428 | struct pch_gbe_hw *hw = &adapter->hw; | 428 | struct pch_gbe_hw *hw = &adapter->hw; |
| 429 | struct net_device *dev = adapter->netdev; | ||
| 430 | int val; | ||
| 429 | 431 | ||
| 430 | { /* Transmit Descriptor Count */ | 432 | { /* Transmit Descriptor Count */ |
| 431 | static const struct pch_gbe_option opt = { | 433 | static const struct pch_gbe_option opt = { |
| @@ -466,9 +468,10 @@ void pch_gbe_check_options(struct pch_gbe_adapter *adapter) | |||
| 466 | .err = "defaulting to Enabled", | 468 | .err = "defaulting to Enabled", |
| 467 | .def = PCH_GBE_DEFAULT_RX_CSUM | 469 | .def = PCH_GBE_DEFAULT_RX_CSUM |
| 468 | }; | 470 | }; |
| 469 | adapter->rx_csum = XsumRX; | 471 | val = XsumRX; |
| 470 | pch_gbe_validate_option((int *)(&adapter->rx_csum), | 472 | pch_gbe_validate_option(&val, &opt, adapter); |
| 471 | &opt, adapter); | 473 | if (!val) |
| 474 | dev->features &= ~NETIF_F_RXCSUM; | ||
| 472 | } | 475 | } |
| 473 | { /* Checksum Offload Enable/Disable */ | 476 | { /* Checksum Offload Enable/Disable */ |
| 474 | static const struct pch_gbe_option opt = { | 477 | static const struct pch_gbe_option opt = { |
| @@ -477,9 +480,10 @@ void pch_gbe_check_options(struct pch_gbe_adapter *adapter) | |||
| 477 | .err = "defaulting to Enabled", | 480 | .err = "defaulting to Enabled", |
| 478 | .def = PCH_GBE_DEFAULT_TX_CSUM | 481 | .def = PCH_GBE_DEFAULT_TX_CSUM |
| 479 | }; | 482 | }; |
| 480 | adapter->tx_csum = XsumTX; | 483 | val = XsumTX; |
| 481 | pch_gbe_validate_option((int *)(&adapter->tx_csum), | 484 | pch_gbe_validate_option(&val, &opt, adapter); |
| 482 | &opt, adapter); | 485 | if (!val) |
| 486 | dev->features &= ~NETIF_F_ALL_CSUM; | ||
| 483 | } | 487 | } |
| 484 | { /* Flow Control */ | 488 | { /* Flow Control */ |
| 485 | static const struct pch_gbe_option opt = { | 489 | static const struct pch_gbe_option opt = { |
