diff options
author | Michał Mirosław <mirq-linux@rere.qmqm.pl> | 2011-04-04 21:36:58 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-04-06 17:49:10 -0400 |
commit | 066413dac420c8225e3ef7f0f76c3255448782d3 (patch) | |
tree | fb171ecf667592790ccd52e24c97757b1b976d77 /drivers/net | |
parent | 1f90d6657c1ce2eaa4c7fbd1fb36738542f2b650 (diff) |
net: netxen: convert to hw_features
Rather simple conversion to hw_features.
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')
-rw-r--r-- | drivers/net/netxen/netxen_nic.h | 2 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_ethtool.c | 102 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_init.c | 3 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_main.c | 53 |
4 files changed, 46 insertions, 114 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index d7299f1a4940..15595b3a54c6 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h | |||
@@ -1177,7 +1177,7 @@ struct netxen_adapter { | |||
1177 | u8 max_sds_rings; | 1177 | u8 max_sds_rings; |
1178 | u8 driver_mismatch; | 1178 | u8 driver_mismatch; |
1179 | u8 msix_supported; | 1179 | u8 msix_supported; |
1180 | u8 rx_csum; | 1180 | u8 __pad; |
1181 | u8 pci_using_dac; | 1181 | u8 pci_using_dac; |
1182 | u8 portnum; | 1182 | u8 portnum; |
1183 | u8 physical_port; | 1183 | u8 physical_port; |
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c index 3bdcc803ec68..29f90baaa79b 100644 --- a/drivers/net/netxen/netxen_nic_ethtool.c +++ b/drivers/net/netxen/netxen_nic_ethtool.c | |||
@@ -676,62 +676,6 @@ netxen_nic_get_ethtool_stats(struct net_device *dev, | |||
676 | } | 676 | } |
677 | } | 677 | } |
678 | 678 | ||
679 | static u32 netxen_nic_get_tx_csum(struct net_device *dev) | ||
680 | { | ||
681 | return dev->features & NETIF_F_IP_CSUM; | ||
682 | } | ||
683 | |||
684 | static u32 netxen_nic_get_rx_csum(struct net_device *dev) | ||
685 | { | ||
686 | struct netxen_adapter *adapter = netdev_priv(dev); | ||
687 | return adapter->rx_csum; | ||
688 | } | ||
689 | |||
690 | static int netxen_nic_set_rx_csum(struct net_device *dev, u32 data) | ||
691 | { | ||
692 | struct netxen_adapter *adapter = netdev_priv(dev); | ||
693 | |||
694 | if (data) { | ||
695 | adapter->rx_csum = data; | ||
696 | return 0; | ||
697 | } | ||
698 | |||
699 | if (dev->features & NETIF_F_LRO) { | ||
700 | if (netxen_config_hw_lro(adapter, NETXEN_NIC_LRO_DISABLED)) | ||
701 | return -EIO; | ||
702 | |||
703 | dev->features &= ~NETIF_F_LRO; | ||
704 | netxen_send_lro_cleanup(adapter); | ||
705 | netdev_info(dev, "disabling LRO as rx_csum is off\n"); | ||
706 | } | ||
707 | adapter->rx_csum = data; | ||
708 | return 0; | ||
709 | } | ||
710 | |||
711 | static u32 netxen_nic_get_tso(struct net_device *dev) | ||
712 | { | ||
713 | struct netxen_adapter *adapter = netdev_priv(dev); | ||
714 | |||
715 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) | ||
716 | return (dev->features & (NETIF_F_TSO | NETIF_F_TSO6)) != 0; | ||
717 | |||
718 | return (dev->features & NETIF_F_TSO) != 0; | ||
719 | } | ||
720 | |||
721 | static int netxen_nic_set_tso(struct net_device *dev, u32 data) | ||
722 | { | ||
723 | if (data) { | ||
724 | struct netxen_adapter *adapter = netdev_priv(dev); | ||
725 | |||
726 | dev->features |= NETIF_F_TSO; | ||
727 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) | ||
728 | dev->features |= NETIF_F_TSO6; | ||
729 | } else | ||
730 | dev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6); | ||
731 | |||
732 | return 0; | ||
733 | } | ||
734 | |||
735 | static void | 679 | static void |
736 | netxen_nic_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) | 680 | netxen_nic_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) |
737 | { | 681 | { |
@@ -866,43 +810,6 @@ static int netxen_get_intr_coalesce(struct net_device *netdev, | |||
866 | return 0; | 810 | return 0; |
867 | } | 811 | } |
868 | 812 | ||
869 | static int netxen_nic_set_flags(struct net_device *netdev, u32 data) | ||
870 | { | ||
871 | struct netxen_adapter *adapter = netdev_priv(netdev); | ||
872 | int hw_lro; | ||
873 | |||
874 | if (ethtool_invalid_flags(netdev, data, ETH_FLAG_LRO)) | ||
875 | return -EINVAL; | ||
876 | |||
877 | if (!(adapter->capabilities & NX_FW_CAPABILITY_HW_LRO)) | ||
878 | return -EINVAL; | ||
879 | |||
880 | if (!adapter->rx_csum) { | ||
881 | netdev_info(netdev, "rx csum is off, cannot toggle LRO\n"); | ||
882 | return -EINVAL; | ||
883 | } | ||
884 | |||
885 | if (!!(data & ETH_FLAG_LRO) == !!(netdev->features & NETIF_F_LRO)) | ||
886 | return 0; | ||
887 | |||
888 | if (data & ETH_FLAG_LRO) { | ||
889 | hw_lro = NETXEN_NIC_LRO_ENABLED; | ||
890 | netdev->features |= NETIF_F_LRO; | ||
891 | } else { | ||
892 | hw_lro = NETXEN_NIC_LRO_DISABLED; | ||
893 | netdev->features &= ~NETIF_F_LRO; | ||
894 | } | ||
895 | |||
896 | if (netxen_config_hw_lro(adapter, hw_lro)) | ||
897 | return -EIO; | ||
898 | |||
899 | if ((hw_lro == 0) && netxen_send_lro_cleanup(adapter)) | ||
900 | return -EIO; | ||
901 | |||
902 | |||
903 | return 0; | ||
904 | } | ||
905 | |||
906 | const struct ethtool_ops netxen_nic_ethtool_ops = { | 813 | const struct ethtool_ops netxen_nic_ethtool_ops = { |
907 | .get_settings = netxen_nic_get_settings, | 814 | .get_settings = netxen_nic_get_settings, |
908 | .set_settings = netxen_nic_set_settings, | 815 | .set_settings = netxen_nic_set_settings, |
@@ -916,21 +823,12 @@ const struct ethtool_ops netxen_nic_ethtool_ops = { | |||
916 | .set_ringparam = netxen_nic_set_ringparam, | 823 | .set_ringparam = netxen_nic_set_ringparam, |
917 | .get_pauseparam = netxen_nic_get_pauseparam, | 824 | .get_pauseparam = netxen_nic_get_pauseparam, |
918 | .set_pauseparam = netxen_nic_set_pauseparam, | 825 | .set_pauseparam = netxen_nic_set_pauseparam, |
919 | .get_tx_csum = netxen_nic_get_tx_csum, | ||
920 | .set_tx_csum = ethtool_op_set_tx_csum, | ||
921 | .set_sg = ethtool_op_set_sg, | ||
922 | .get_tso = netxen_nic_get_tso, | ||
923 | .set_tso = netxen_nic_set_tso, | ||
924 | .get_wol = netxen_nic_get_wol, | 826 | .get_wol = netxen_nic_get_wol, |
925 | .set_wol = netxen_nic_set_wol, | 827 | .set_wol = netxen_nic_set_wol, |
926 | .self_test = netxen_nic_diag_test, | 828 | .self_test = netxen_nic_diag_test, |
927 | .get_strings = netxen_nic_get_strings, | 829 | .get_strings = netxen_nic_get_strings, |
928 | .get_ethtool_stats = netxen_nic_get_ethtool_stats, | 830 | .get_ethtool_stats = netxen_nic_get_ethtool_stats, |
929 | .get_sset_count = netxen_get_sset_count, | 831 | .get_sset_count = netxen_get_sset_count, |
930 | .get_rx_csum = netxen_nic_get_rx_csum, | ||
931 | .set_rx_csum = netxen_nic_set_rx_csum, | ||
932 | .get_coalesce = netxen_get_intr_coalesce, | 832 | .get_coalesce = netxen_get_intr_coalesce, |
933 | .set_coalesce = netxen_set_intr_coalesce, | 833 | .set_coalesce = netxen_set_intr_coalesce, |
934 | .get_flags = ethtool_op_get_flags, | ||
935 | .set_flags = netxen_nic_set_flags, | ||
936 | }; | 834 | }; |
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c index 731077d8d962..7f999671c7b2 100644 --- a/drivers/net/netxen/netxen_nic_init.c +++ b/drivers/net/netxen/netxen_nic_init.c | |||
@@ -1483,7 +1483,8 @@ static struct sk_buff *netxen_process_rxbuf(struct netxen_adapter *adapter, | |||
1483 | if (!skb) | 1483 | if (!skb) |
1484 | goto no_skb; | 1484 | goto no_skb; |
1485 | 1485 | ||
1486 | if (likely(adapter->rx_csum && cksum == STATUS_CKSUM_OK)) { | 1486 | if (likely((adapter->netdev->features & NETIF_F_RXCSUM) |
1487 | && cksum == STATUS_CKSUM_OK)) { | ||
1487 | adapter->stats.csummed++; | 1488 | adapter->stats.csummed++; |
1488 | skb->ip_summed = CHECKSUM_UNNECESSARY; | 1489 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
1489 | } else | 1490 | } else |
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index 933671556c15..201b944bd463 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
@@ -485,6 +485,37 @@ static void netxen_set_multicast_list(struct net_device *dev) | |||
485 | adapter->set_multi(dev); | 485 | adapter->set_multi(dev); |
486 | } | 486 | } |
487 | 487 | ||
488 | static u32 netxen_fix_features(struct net_device *dev, u32 features) | ||
489 | { | ||
490 | if (!(features & NETIF_F_RXCSUM)) { | ||
491 | netdev_info(dev, "disabling LRO as RXCSUM is off\n"); | ||
492 | |||
493 | features &= ~NETIF_F_LRO; | ||
494 | } | ||
495 | |||
496 | return features; | ||
497 | } | ||
498 | |||
499 | static int netxen_set_features(struct net_device *dev, u32 features) | ||
500 | { | ||
501 | struct netxen_adapter *adapter = netdev_priv(dev); | ||
502 | int hw_lro; | ||
503 | |||
504 | if (!((dev->features ^ features) & NETIF_F_LRO)) | ||
505 | return 0; | ||
506 | |||
507 | hw_lro = (features & NETIF_F_LRO) ? NETXEN_NIC_LRO_ENABLED | ||
508 | : NETXEN_NIC_LRO_DISABLED; | ||
509 | |||
510 | if (netxen_config_hw_lro(adapter, hw_lro)) | ||
511 | return -EIO; | ||
512 | |||
513 | if (!(features & NETIF_F_LRO) && netxen_send_lro_cleanup(adapter)) | ||
514 | return -EIO; | ||
515 | |||
516 | return 0; | ||
517 | } | ||
518 | |||
488 | static const struct net_device_ops netxen_netdev_ops = { | 519 | static const struct net_device_ops netxen_netdev_ops = { |
489 | .ndo_open = netxen_nic_open, | 520 | .ndo_open = netxen_nic_open, |
490 | .ndo_stop = netxen_nic_close, | 521 | .ndo_stop = netxen_nic_close, |
@@ -495,6 +526,8 @@ static const struct net_device_ops netxen_netdev_ops = { | |||
495 | .ndo_set_mac_address = netxen_nic_set_mac, | 526 | .ndo_set_mac_address = netxen_nic_set_mac, |
496 | .ndo_change_mtu = netxen_nic_change_mtu, | 527 | .ndo_change_mtu = netxen_nic_change_mtu, |
497 | .ndo_tx_timeout = netxen_tx_timeout, | 528 | .ndo_tx_timeout = netxen_tx_timeout, |
529 | .ndo_fix_features = netxen_fix_features, | ||
530 | .ndo_set_features = netxen_set_features, | ||
498 | #ifdef CONFIG_NET_POLL_CONTROLLER | 531 | #ifdef CONFIG_NET_POLL_CONTROLLER |
499 | .ndo_poll_controller = netxen_nic_poll_controller, | 532 | .ndo_poll_controller = netxen_nic_poll_controller, |
500 | #endif | 533 | #endif |
@@ -1196,7 +1229,6 @@ netxen_setup_netdev(struct netxen_adapter *adapter, | |||
1196 | int err = 0; | 1229 | int err = 0; |
1197 | struct pci_dev *pdev = adapter->pdev; | 1230 | struct pci_dev *pdev = adapter->pdev; |
1198 | 1231 | ||
1199 | adapter->rx_csum = 1; | ||
1200 | adapter->mc_enabled = 0; | 1232 | adapter->mc_enabled = 0; |
1201 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) | 1233 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) |
1202 | adapter->max_mc_count = 38; | 1234 | adapter->max_mc_count = 38; |
@@ -1210,14 +1242,13 @@ netxen_setup_netdev(struct netxen_adapter *adapter, | |||
1210 | 1242 | ||
1211 | SET_ETHTOOL_OPS(netdev, &netxen_nic_ethtool_ops); | 1243 | SET_ETHTOOL_OPS(netdev, &netxen_nic_ethtool_ops); |
1212 | 1244 | ||
1213 | netdev->features |= (NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO); | 1245 | netdev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO | |
1214 | netdev->features |= (NETIF_F_GRO); | 1246 | NETIF_F_RXCSUM; |
1215 | netdev->vlan_features |= (NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO); | ||
1216 | 1247 | ||
1217 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { | 1248 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) |
1218 | netdev->features |= (NETIF_F_IPV6_CSUM | NETIF_F_TSO6); | 1249 | netdev->hw_features |= NETIF_F_IPV6_CSUM | NETIF_F_TSO6; |
1219 | netdev->vlan_features |= (NETIF_F_IPV6_CSUM | NETIF_F_TSO6); | 1250 | |
1220 | } | 1251 | netdev->vlan_features |= netdev->hw_features; |
1221 | 1252 | ||
1222 | if (adapter->pci_using_dac) { | 1253 | if (adapter->pci_using_dac) { |
1223 | netdev->features |= NETIF_F_HIGHDMA; | 1254 | netdev->features |= NETIF_F_HIGHDMA; |
@@ -1225,10 +1256,12 @@ netxen_setup_netdev(struct netxen_adapter *adapter, | |||
1225 | } | 1256 | } |
1226 | 1257 | ||
1227 | if (adapter->capabilities & NX_FW_CAPABILITY_FVLANTX) | 1258 | if (adapter->capabilities & NX_FW_CAPABILITY_FVLANTX) |
1228 | netdev->features |= (NETIF_F_HW_VLAN_TX); | 1259 | netdev->hw_features |= NETIF_F_HW_VLAN_TX; |
1229 | 1260 | ||
1230 | if (adapter->capabilities & NX_FW_CAPABILITY_HW_LRO) | 1261 | if (adapter->capabilities & NX_FW_CAPABILITY_HW_LRO) |
1231 | netdev->features |= NETIF_F_LRO; | 1262 | netdev->hw_features |= NETIF_F_LRO; |
1263 | |||
1264 | netdev->features |= netdev->hw_features; | ||
1232 | 1265 | ||
1233 | netdev->irq = adapter->msix_entries[0].vector; | 1266 | netdev->irq = adapter->msix_entries[0].vector; |
1234 | 1267 | ||