Skip to content

Commit

Permalink
igbvf: convert to ndo_fix_features
Browse files Browse the repository at this point in the history
Private rx_csum flags are now duplicate of netdev->features & NETIF_F_RXCSUM.
Removing this needs deeper surgery.

Things noticed:
 - 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 <[email protected]>
Signed-off-by: Jeff Kirsher <[email protected]>
  • Loading branch information
osctobe authored and Jeff Kirsher committed Oct 16, 2011
1 parent 11ba69e commit fd38f73
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 62 deletions.
57 changes: 0 additions & 57 deletions drivers/net/ethernet/intel/igbvf/ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,55 +128,6 @@ static int igbvf_set_pauseparam(struct net_device *netdev,
return -EOPNOTSUPP;
}

static u32 igbvf_get_rx_csum(struct net_device *netdev)
{
struct igbvf_adapter *adapter = netdev_priv(netdev);
return !(adapter->flags & IGBVF_FLAG_RX_CSUM_DISABLED);
}

static int igbvf_set_rx_csum(struct net_device *netdev, u32 data)
{
struct igbvf_adapter *adapter = netdev_priv(netdev);

if (data)
adapter->flags &= ~IGBVF_FLAG_RX_CSUM_DISABLED;
else
adapter->flags |= IGBVF_FLAG_RX_CSUM_DISABLED;

return 0;
}

static u32 igbvf_get_tx_csum(struct net_device *netdev)
{
return (netdev->features & NETIF_F_IP_CSUM) != 0;
}

static int igbvf_set_tx_csum(struct net_device *netdev, u32 data)
{
if (data)
netdev->features |= (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
else
netdev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM);
return 0;
}

static int igbvf_set_tso(struct net_device *netdev, u32 data)
{
struct igbvf_adapter *adapter = netdev_priv(netdev);

if (data) {
netdev->features |= NETIF_F_TSO;
netdev->features |= NETIF_F_TSO6;
} else {
netdev->features &= ~NETIF_F_TSO;
netdev->features &= ~NETIF_F_TSO6;
}

dev_info(&adapter->pdev->dev, "TSO is %s\n",
data ? "Enabled" : "Disabled");
return 0;
}

static u32 igbvf_get_msglevel(struct net_device *netdev)
{
struct igbvf_adapter *adapter = netdev_priv(netdev);
Expand Down Expand Up @@ -507,14 +458,6 @@ static const struct ethtool_ops igbvf_ethtool_ops = {
.set_ringparam = igbvf_set_ringparam,
.get_pauseparam = igbvf_get_pauseparam,
.set_pauseparam = igbvf_set_pauseparam,
.get_rx_csum = igbvf_get_rx_csum,
.set_rx_csum = igbvf_set_rx_csum,
.get_tx_csum = igbvf_get_tx_csum,
.set_tx_csum = igbvf_set_tx_csum,
.get_sg = ethtool_op_get_sg,
.set_sg = ethtool_op_set_sg,
.get_tso = ethtool_op_get_tso,
.set_tso = igbvf_set_tso,
.self_test = igbvf_diag_test,
.get_sset_count = igbvf_get_sset_count,
.get_strings = igbvf_get_strings,
Expand Down
25 changes: 20 additions & 5 deletions drivers/net/ethernet/intel/igbvf/netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2530,6 +2530,18 @@ static void igbvf_print_device_info(struct igbvf_adapter *adapter)
dev_info(&pdev->dev, "MAC: %d\n", hw->mac.type);
}

static int igbvf_set_features(struct net_device *netdev, u32 features)
{
struct igbvf_adapter *adapter = netdev_priv(netdev);

if (features & NETIF_F_RXCSUM)
adapter->flags &= ~IGBVF_FLAG_RX_CSUM_DISABLED;
else
adapter->flags |= IGBVF_FLAG_RX_CSUM_DISABLED;

return 0;
}

static const struct net_device_ops igbvf_netdev_ops = {
.ndo_open = igbvf_open,
.ndo_stop = igbvf_close,
Expand All @@ -2545,6 +2557,7 @@ static const struct net_device_ops igbvf_netdev_ops = {
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = igbvf_netpoll,
#endif
.ndo_set_features = igbvf_set_features,
};

/**
Expand Down Expand Up @@ -2652,16 +2665,18 @@ static int __devinit igbvf_probe(struct pci_dev *pdev,

adapter->bd_number = cards_found++;

netdev->features = NETIF_F_SG |
netdev->hw_features = NETIF_F_SG |
NETIF_F_IP_CSUM |
NETIF_F_IPV6_CSUM |
NETIF_F_TSO |
NETIF_F_TSO6 |
NETIF_F_RXCSUM;

netdev->features = netdev->hw_features |
NETIF_F_HW_VLAN_TX |
NETIF_F_HW_VLAN_RX |
NETIF_F_HW_VLAN_FILTER;

netdev->features |= NETIF_F_IPV6_CSUM;
netdev->features |= NETIF_F_TSO;
netdev->features |= NETIF_F_TSO6;

if (pci_using_dac)
netdev->features |= NETIF_F_HIGHDMA;

Expand Down

0 comments on commit fd38f73

Please sign in to comment.