提交 066413da 编写于 作者: M Michał Mirosław 提交者: David S. Miller

net: netxen: convert to hw_features

Rather simple conversion to hw_features.
Signed-off-by: NMichał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 1f90d665
...@@ -1177,7 +1177,7 @@ struct netxen_adapter { ...@@ -1177,7 +1177,7 @@ struct netxen_adapter {
u8 max_sds_rings; u8 max_sds_rings;
u8 driver_mismatch; u8 driver_mismatch;
u8 msix_supported; u8 msix_supported;
u8 rx_csum; u8 __pad;
u8 pci_using_dac; u8 pci_using_dac;
u8 portnum; u8 portnum;
u8 physical_port; u8 physical_port;
......
...@@ -676,62 +676,6 @@ netxen_nic_get_ethtool_stats(struct net_device *dev, ...@@ -676,62 +676,6 @@ netxen_nic_get_ethtool_stats(struct net_device *dev,
} }
} }
static u32 netxen_nic_get_tx_csum(struct net_device *dev)
{
return dev->features & NETIF_F_IP_CSUM;
}
static u32 netxen_nic_get_rx_csum(struct net_device *dev)
{
struct netxen_adapter *adapter = netdev_priv(dev);
return adapter->rx_csum;
}
static int netxen_nic_set_rx_csum(struct net_device *dev, u32 data)
{
struct netxen_adapter *adapter = netdev_priv(dev);
if (data) {
adapter->rx_csum = data;
return 0;
}
if (dev->features & NETIF_F_LRO) {
if (netxen_config_hw_lro(adapter, NETXEN_NIC_LRO_DISABLED))
return -EIO;
dev->features &= ~NETIF_F_LRO;
netxen_send_lro_cleanup(adapter);
netdev_info(dev, "disabling LRO as rx_csum is off\n");
}
adapter->rx_csum = data;
return 0;
}
static u32 netxen_nic_get_tso(struct net_device *dev)
{
struct netxen_adapter *adapter = netdev_priv(dev);
if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
return (dev->features & (NETIF_F_TSO | NETIF_F_TSO6)) != 0;
return (dev->features & NETIF_F_TSO) != 0;
}
static int netxen_nic_set_tso(struct net_device *dev, u32 data)
{
if (data) {
struct netxen_adapter *adapter = netdev_priv(dev);
dev->features |= NETIF_F_TSO;
if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
dev->features |= NETIF_F_TSO6;
} else
dev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6);
return 0;
}
static void static void
netxen_nic_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) netxen_nic_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{ {
...@@ -866,43 +810,6 @@ static int netxen_get_intr_coalesce(struct net_device *netdev, ...@@ -866,43 +810,6 @@ static int netxen_get_intr_coalesce(struct net_device *netdev,
return 0; return 0;
} }
static int netxen_nic_set_flags(struct net_device *netdev, u32 data)
{
struct netxen_adapter *adapter = netdev_priv(netdev);
int hw_lro;
if (ethtool_invalid_flags(netdev, data, ETH_FLAG_LRO))
return -EINVAL;
if (!(adapter->capabilities & NX_FW_CAPABILITY_HW_LRO))
return -EINVAL;
if (!adapter->rx_csum) {
netdev_info(netdev, "rx csum is off, cannot toggle LRO\n");
return -EINVAL;
}
if (!!(data & ETH_FLAG_LRO) == !!(netdev->features & NETIF_F_LRO))
return 0;
if (data & ETH_FLAG_LRO) {
hw_lro = NETXEN_NIC_LRO_ENABLED;
netdev->features |= NETIF_F_LRO;
} else {
hw_lro = NETXEN_NIC_LRO_DISABLED;
netdev->features &= ~NETIF_F_LRO;
}
if (netxen_config_hw_lro(adapter, hw_lro))
return -EIO;
if ((hw_lro == 0) && netxen_send_lro_cleanup(adapter))
return -EIO;
return 0;
}
const struct ethtool_ops netxen_nic_ethtool_ops = { const struct ethtool_ops netxen_nic_ethtool_ops = {
.get_settings = netxen_nic_get_settings, .get_settings = netxen_nic_get_settings,
.set_settings = netxen_nic_set_settings, .set_settings = netxen_nic_set_settings,
...@@ -916,21 +823,12 @@ const struct ethtool_ops netxen_nic_ethtool_ops = { ...@@ -916,21 +823,12 @@ const struct ethtool_ops netxen_nic_ethtool_ops = {
.set_ringparam = netxen_nic_set_ringparam, .set_ringparam = netxen_nic_set_ringparam,
.get_pauseparam = netxen_nic_get_pauseparam, .get_pauseparam = netxen_nic_get_pauseparam,
.set_pauseparam = netxen_nic_set_pauseparam, .set_pauseparam = netxen_nic_set_pauseparam,
.get_tx_csum = netxen_nic_get_tx_csum,
.set_tx_csum = ethtool_op_set_tx_csum,
.set_sg = ethtool_op_set_sg,
.get_tso = netxen_nic_get_tso,
.set_tso = netxen_nic_set_tso,
.get_wol = netxen_nic_get_wol, .get_wol = netxen_nic_get_wol,
.set_wol = netxen_nic_set_wol, .set_wol = netxen_nic_set_wol,
.self_test = netxen_nic_diag_test, .self_test = netxen_nic_diag_test,
.get_strings = netxen_nic_get_strings, .get_strings = netxen_nic_get_strings,
.get_ethtool_stats = netxen_nic_get_ethtool_stats, .get_ethtool_stats = netxen_nic_get_ethtool_stats,
.get_sset_count = netxen_get_sset_count, .get_sset_count = netxen_get_sset_count,
.get_rx_csum = netxen_nic_get_rx_csum,
.set_rx_csum = netxen_nic_set_rx_csum,
.get_coalesce = netxen_get_intr_coalesce, .get_coalesce = netxen_get_intr_coalesce,
.set_coalesce = netxen_set_intr_coalesce, .set_coalesce = netxen_set_intr_coalesce,
.get_flags = ethtool_op_get_flags,
.set_flags = netxen_nic_set_flags,
}; };
...@@ -1483,7 +1483,8 @@ static struct sk_buff *netxen_process_rxbuf(struct netxen_adapter *adapter, ...@@ -1483,7 +1483,8 @@ static struct sk_buff *netxen_process_rxbuf(struct netxen_adapter *adapter,
if (!skb) if (!skb)
goto no_skb; goto no_skb;
if (likely(adapter->rx_csum && cksum == STATUS_CKSUM_OK)) { if (likely((adapter->netdev->features & NETIF_F_RXCSUM)
&& cksum == STATUS_CKSUM_OK)) {
adapter->stats.csummed++; adapter->stats.csummed++;
skb->ip_summed = CHECKSUM_UNNECESSARY; skb->ip_summed = CHECKSUM_UNNECESSARY;
} else } else
......
...@@ -485,6 +485,37 @@ static void netxen_set_multicast_list(struct net_device *dev) ...@@ -485,6 +485,37 @@ static void netxen_set_multicast_list(struct net_device *dev)
adapter->set_multi(dev); adapter->set_multi(dev);
} }
static u32 netxen_fix_features(struct net_device *dev, u32 features)
{
if (!(features & NETIF_F_RXCSUM)) {
netdev_info(dev, "disabling LRO as RXCSUM is off\n");
features &= ~NETIF_F_LRO;
}
return features;
}
static int netxen_set_features(struct net_device *dev, u32 features)
{
struct netxen_adapter *adapter = netdev_priv(dev);
int hw_lro;
if (!((dev->features ^ features) & NETIF_F_LRO))
return 0;
hw_lro = (features & NETIF_F_LRO) ? NETXEN_NIC_LRO_ENABLED
: NETXEN_NIC_LRO_DISABLED;
if (netxen_config_hw_lro(adapter, hw_lro))
return -EIO;
if (!(features & NETIF_F_LRO) && netxen_send_lro_cleanup(adapter))
return -EIO;
return 0;
}
static const struct net_device_ops netxen_netdev_ops = { static const struct net_device_ops netxen_netdev_ops = {
.ndo_open = netxen_nic_open, .ndo_open = netxen_nic_open,
.ndo_stop = netxen_nic_close, .ndo_stop = netxen_nic_close,
...@@ -495,6 +526,8 @@ static const struct net_device_ops netxen_netdev_ops = { ...@@ -495,6 +526,8 @@ static const struct net_device_ops netxen_netdev_ops = {
.ndo_set_mac_address = netxen_nic_set_mac, .ndo_set_mac_address = netxen_nic_set_mac,
.ndo_change_mtu = netxen_nic_change_mtu, .ndo_change_mtu = netxen_nic_change_mtu,
.ndo_tx_timeout = netxen_tx_timeout, .ndo_tx_timeout = netxen_tx_timeout,
.ndo_fix_features = netxen_fix_features,
.ndo_set_features = netxen_set_features,
#ifdef CONFIG_NET_POLL_CONTROLLER #ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = netxen_nic_poll_controller, .ndo_poll_controller = netxen_nic_poll_controller,
#endif #endif
...@@ -1196,7 +1229,6 @@ netxen_setup_netdev(struct netxen_adapter *adapter, ...@@ -1196,7 +1229,6 @@ netxen_setup_netdev(struct netxen_adapter *adapter,
int err = 0; int err = 0;
struct pci_dev *pdev = adapter->pdev; struct pci_dev *pdev = adapter->pdev;
adapter->rx_csum = 1;
adapter->mc_enabled = 0; adapter->mc_enabled = 0;
if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
adapter->max_mc_count = 38; adapter->max_mc_count = 38;
...@@ -1210,14 +1242,13 @@ netxen_setup_netdev(struct netxen_adapter *adapter, ...@@ -1210,14 +1242,13 @@ netxen_setup_netdev(struct netxen_adapter *adapter,
SET_ETHTOOL_OPS(netdev, &netxen_nic_ethtool_ops); SET_ETHTOOL_OPS(netdev, &netxen_nic_ethtool_ops);
netdev->features |= (NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO); netdev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO |
netdev->features |= (NETIF_F_GRO); NETIF_F_RXCSUM;
netdev->vlan_features |= (NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO);
if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
netdev->features |= (NETIF_F_IPV6_CSUM | NETIF_F_TSO6); netdev->hw_features |= NETIF_F_IPV6_CSUM | NETIF_F_TSO6;
netdev->vlan_features |= (NETIF_F_IPV6_CSUM | NETIF_F_TSO6);
} netdev->vlan_features |= netdev->hw_features;
if (adapter->pci_using_dac) { if (adapter->pci_using_dac) {
netdev->features |= NETIF_F_HIGHDMA; netdev->features |= NETIF_F_HIGHDMA;
...@@ -1225,10 +1256,12 @@ netxen_setup_netdev(struct netxen_adapter *adapter, ...@@ -1225,10 +1256,12 @@ netxen_setup_netdev(struct netxen_adapter *adapter,
} }
if (adapter->capabilities & NX_FW_CAPABILITY_FVLANTX) if (adapter->capabilities & NX_FW_CAPABILITY_FVLANTX)
netdev->features |= (NETIF_F_HW_VLAN_TX); netdev->hw_features |= NETIF_F_HW_VLAN_TX;
if (adapter->capabilities & NX_FW_CAPABILITY_HW_LRO) if (adapter->capabilities & NX_FW_CAPABILITY_HW_LRO)
netdev->features |= NETIF_F_LRO; netdev->hw_features |= NETIF_F_LRO;
netdev->features |= netdev->hw_features;
netdev->irq = adapter->msix_entries[0].vector; netdev->irq = adapter->msix_entries[0].vector;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册