diff options
author | Michał Mirosław <mirq-linux@rere.qmqm.pl> | 2011-04-18 22:14:25 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-04-20 04:30:43 -0400 |
commit | b9367bf3ee6da380e0c338bd75bb8e8e4e0b981b (patch) | |
tree | c642c64be693dc21fa769afb6483bce5cf245343 /drivers/net/ibmveth.c | |
parent | 756a6b03da98903fa22ad7f10752de11782249fc (diff) |
net: ibmveth: convert to hw_features
A minimal conversion.
ibmveth_set_csum_offload() can be folded into ibmveth_set_features()
and adapter->rx_csum removed - left for later cleanup.
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/ibmveth.c')
-rw-r--r-- | drivers/net/ibmveth.c | 96 |
1 files changed, 27 insertions, 69 deletions
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c index 5522d459654c..4855f1fdff52 100644 --- a/drivers/net/ibmveth.c +++ b/drivers/net/ibmveth.c | |||
@@ -729,45 +729,24 @@ static void netdev_get_drvinfo(struct net_device *dev, | |||
729 | sizeof(info->version) - 1); | 729 | sizeof(info->version) - 1); |
730 | } | 730 | } |
731 | 731 | ||
732 | static void ibmveth_set_rx_csum_flags(struct net_device *dev, u32 data) | 732 | static u32 ibmveth_fix_features(struct net_device *dev, u32 features) |
733 | { | 733 | { |
734 | struct ibmveth_adapter *adapter = netdev_priv(dev); | 734 | /* |
735 | 735 | * Since the ibmveth firmware interface does not have the | |
736 | if (data) { | 736 | * concept of separate tx/rx checksum offload enable, if rx |
737 | adapter->rx_csum = 1; | 737 | * checksum is disabled we also have to disable tx checksum |
738 | } else { | 738 | * offload. Once we disable rx checksum offload, we are no |
739 | /* | 739 | * longer allowed to send tx buffers that are not properly |
740 | * Since the ibmveth firmware interface does not have the | 740 | * checksummed. |
741 | * concept of separate tx/rx checksum offload enable, if rx | 741 | */ |
742 | * checksum is disabled we also have to disable tx checksum | ||
743 | * offload. Once we disable rx checksum offload, we are no | ||
744 | * longer allowed to send tx buffers that are not properly | ||
745 | * checksummed. | ||
746 | */ | ||
747 | adapter->rx_csum = 0; | ||
748 | dev->features &= ~NETIF_F_IP_CSUM; | ||
749 | dev->features &= ~NETIF_F_IPV6_CSUM; | ||
750 | } | ||
751 | } | ||
752 | 742 | ||
753 | static void ibmveth_set_tx_csum_flags(struct net_device *dev, u32 data) | 743 | if (!(features & NETIF_F_RXCSUM)) |
754 | { | 744 | features &= ~NETIF_F_ALL_CSUM; |
755 | struct ibmveth_adapter *adapter = netdev_priv(dev); | ||
756 | 745 | ||
757 | if (data) { | 746 | return features; |
758 | if (adapter->fw_ipv4_csum_support) | ||
759 | dev->features |= NETIF_F_IP_CSUM; | ||
760 | if (adapter->fw_ipv6_csum_support) | ||
761 | dev->features |= NETIF_F_IPV6_CSUM; | ||
762 | adapter->rx_csum = 1; | ||
763 | } else { | ||
764 | dev->features &= ~NETIF_F_IP_CSUM; | ||
765 | dev->features &= ~NETIF_F_IPV6_CSUM; | ||
766 | } | ||
767 | } | 747 | } |
768 | 748 | ||
769 | static int ibmveth_set_csum_offload(struct net_device *dev, u32 data, | 749 | static int ibmveth_set_csum_offload(struct net_device *dev, u32 data) |
770 | void (*done) (struct net_device *, u32)) | ||
771 | { | 750 | { |
772 | struct ibmveth_adapter *adapter = netdev_priv(dev); | 751 | struct ibmveth_adapter *adapter = netdev_priv(dev); |
773 | unsigned long set_attr, clr_attr, ret_attr; | 752 | unsigned long set_attr, clr_attr, ret_attr; |
@@ -827,8 +806,8 @@ static int ibmveth_set_csum_offload(struct net_device *dev, u32 data, | |||
827 | } else | 806 | } else |
828 | adapter->fw_ipv6_csum_support = data; | 807 | adapter->fw_ipv6_csum_support = data; |
829 | 808 | ||
830 | if (ret == H_SUCCESS || ret6 == H_SUCCESS) | 809 | if (ret != H_SUCCESS || ret6 != H_SUCCESS) |
831 | done(dev, data); | 810 | adapter->rx_csum = data; |
832 | else | 811 | else |
833 | rc1 = -EIO; | 812 | rc1 = -EIO; |
834 | } else { | 813 | } else { |
@@ -844,41 +823,22 @@ static int ibmveth_set_csum_offload(struct net_device *dev, u32 data, | |||
844 | return rc1 ? rc1 : rc2; | 823 | return rc1 ? rc1 : rc2; |
845 | } | 824 | } |
846 | 825 | ||
847 | static int ibmveth_set_rx_csum(struct net_device *dev, u32 data) | 826 | static int ibmveth_set_features(struct net_device *dev, u32 features) |
848 | { | 827 | { |
849 | struct ibmveth_adapter *adapter = netdev_priv(dev); | 828 | struct ibmveth_adapter *adapter = netdev_priv(dev); |
829 | int rx_csum = !!(features & NETIF_F_RXCSUM); | ||
830 | int rc; | ||
850 | 831 | ||
851 | if ((data && adapter->rx_csum) || (!data && !adapter->rx_csum)) | 832 | if (rx_csum == adapter->rx_csum) |
852 | return 0; | ||
853 | |||
854 | return ibmveth_set_csum_offload(dev, data, ibmveth_set_rx_csum_flags); | ||
855 | } | ||
856 | |||
857 | static int ibmveth_set_tx_csum(struct net_device *dev, u32 data) | ||
858 | { | ||
859 | struct ibmveth_adapter *adapter = netdev_priv(dev); | ||
860 | int rc = 0; | ||
861 | |||
862 | if (data && (dev->features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM))) | ||
863 | return 0; | ||
864 | if (!data && !(dev->features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM))) | ||
865 | return 0; | 833 | return 0; |
866 | 834 | ||
867 | if (data && !adapter->rx_csum) | 835 | rc = ibmveth_set_csum_offload(dev, rx_csum); |
868 | rc = ibmveth_set_csum_offload(dev, data, | 836 | if (rc && !adapter->rx_csum) |
869 | ibmveth_set_tx_csum_flags); | 837 | dev->features = features & ~(NETIF_F_ALL_CSUM | NETIF_F_RXCSUM); |
870 | else | ||
871 | ibmveth_set_tx_csum_flags(dev, data); | ||
872 | 838 | ||
873 | return rc; | 839 | return rc; |
874 | } | 840 | } |
875 | 841 | ||
876 | static u32 ibmveth_get_rx_csum(struct net_device *dev) | ||
877 | { | ||
878 | struct ibmveth_adapter *adapter = netdev_priv(dev); | ||
879 | return adapter->rx_csum; | ||
880 | } | ||
881 | |||
882 | static void ibmveth_get_strings(struct net_device *dev, u32 stringset, u8 *data) | 842 | static void ibmveth_get_strings(struct net_device *dev, u32 stringset, u8 *data) |
883 | { | 843 | { |
884 | int i; | 844 | int i; |
@@ -914,13 +874,9 @@ static const struct ethtool_ops netdev_ethtool_ops = { | |||
914 | .get_drvinfo = netdev_get_drvinfo, | 874 | .get_drvinfo = netdev_get_drvinfo, |
915 | .get_settings = netdev_get_settings, | 875 | .get_settings = netdev_get_settings, |
916 | .get_link = ethtool_op_get_link, | 876 | .get_link = ethtool_op_get_link, |
917 | .set_tx_csum = ibmveth_set_tx_csum, | ||
918 | .get_rx_csum = ibmveth_get_rx_csum, | ||
919 | .set_rx_csum = ibmveth_set_rx_csum, | ||
920 | .get_strings = ibmveth_get_strings, | 877 | .get_strings = ibmveth_get_strings, |
921 | .get_sset_count = ibmveth_get_sset_count, | 878 | .get_sset_count = ibmveth_get_sset_count, |
922 | .get_ethtool_stats = ibmveth_get_ethtool_stats, | 879 | .get_ethtool_stats = ibmveth_get_ethtool_stats, |
923 | .set_sg = ethtool_op_set_sg, | ||
924 | }; | 880 | }; |
925 | 881 | ||
926 | static int ibmveth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | 882 | static int ibmveth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
@@ -1345,6 +1301,8 @@ static const struct net_device_ops ibmveth_netdev_ops = { | |||
1345 | .ndo_set_multicast_list = ibmveth_set_multicast_list, | 1301 | .ndo_set_multicast_list = ibmveth_set_multicast_list, |
1346 | .ndo_do_ioctl = ibmveth_ioctl, | 1302 | .ndo_do_ioctl = ibmveth_ioctl, |
1347 | .ndo_change_mtu = ibmveth_change_mtu, | 1303 | .ndo_change_mtu = ibmveth_change_mtu, |
1304 | .ndo_fix_features = ibmveth_fix_features, | ||
1305 | .ndo_set_features = ibmveth_set_features, | ||
1348 | .ndo_validate_addr = eth_validate_addr, | 1306 | .ndo_validate_addr = eth_validate_addr, |
1349 | .ndo_set_mac_address = eth_mac_addr, | 1307 | .ndo_set_mac_address = eth_mac_addr, |
1350 | #ifdef CONFIG_NET_POLL_CONTROLLER | 1308 | #ifdef CONFIG_NET_POLL_CONTROLLER |
@@ -1412,7 +1370,9 @@ static int __devinit ibmveth_probe(struct vio_dev *dev, | |||
1412 | netdev->netdev_ops = &ibmveth_netdev_ops; | 1370 | netdev->netdev_ops = &ibmveth_netdev_ops; |
1413 | netdev->ethtool_ops = &netdev_ethtool_ops; | 1371 | netdev->ethtool_ops = &netdev_ethtool_ops; |
1414 | SET_NETDEV_DEV(netdev, &dev->dev); | 1372 | SET_NETDEV_DEV(netdev, &dev->dev); |
1415 | netdev->features |= NETIF_F_SG; | 1373 | netdev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM | |
1374 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; | ||
1375 | netdev->features |= netdev->hw_features; | ||
1416 | 1376 | ||
1417 | memcpy(netdev->dev_addr, &adapter->mac_addr, netdev->addr_len); | 1377 | memcpy(netdev->dev_addr, &adapter->mac_addr, netdev->addr_len); |
1418 | 1378 | ||
@@ -1437,8 +1397,6 @@ static int __devinit ibmveth_probe(struct vio_dev *dev, | |||
1437 | 1397 | ||
1438 | netdev_dbg(netdev, "registering netdev...\n"); | 1398 | netdev_dbg(netdev, "registering netdev...\n"); |
1439 | 1399 | ||
1440 | ibmveth_set_csum_offload(netdev, 1, ibmveth_set_tx_csum_flags); | ||
1441 | |||
1442 | rc = register_netdev(netdev); | 1400 | rc = register_netdev(netdev); |
1443 | 1401 | ||
1444 | if (rc) { | 1402 | if (rc) { |