Commit a0d2730c authored by Michał Mirosław's avatar Michał Mirosław Committed by David S. Miller

net: vmxnet3: convert to hw_features

This also removes private feature flags that were always set to true.

You may want to move vmxnet3_set_features() to vmxnet3_drv.c as a following
cleanup.
Signed-off-by: default avatarMichał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent feb990d4
...@@ -1082,7 +1082,7 @@ vmxnet3_rx_csum(struct vmxnet3_adapter *adapter, ...@@ -1082,7 +1082,7 @@ vmxnet3_rx_csum(struct vmxnet3_adapter *adapter,
struct sk_buff *skb, struct sk_buff *skb,
union Vmxnet3_GenericDesc *gdesc) union Vmxnet3_GenericDesc *gdesc)
{ {
if (!gdesc->rcd.cnc && adapter->rxcsum) { if (!gdesc->rcd.cnc && adapter->netdev->features & NETIF_F_RXCSUM) {
/* typical case: TCP/UDP over IP and both csums are correct */ /* typical case: TCP/UDP over IP and both csums are correct */
if ((le32_to_cpu(gdesc->dword[3]) & VMXNET3_RCD_CSUM_OK) == if ((le32_to_cpu(gdesc->dword[3]) & VMXNET3_RCD_CSUM_OK) ==
VMXNET3_RCD_CSUM_OK) { VMXNET3_RCD_CSUM_OK) {
...@@ -2081,10 +2081,10 @@ vmxnet3_setup_driver_shared(struct vmxnet3_adapter *adapter) ...@@ -2081,10 +2081,10 @@ vmxnet3_setup_driver_shared(struct vmxnet3_adapter *adapter)
devRead->misc.ddLen = cpu_to_le32(sizeof(struct vmxnet3_adapter)); devRead->misc.ddLen = cpu_to_le32(sizeof(struct vmxnet3_adapter));
/* set up feature flags */ /* set up feature flags */
if (adapter->rxcsum) if (adapter->netdev->features & NETIF_F_RXCSUM)
devRead->misc.uptFeatures |= UPT1_F_RXCSUM; devRead->misc.uptFeatures |= UPT1_F_RXCSUM;
if (adapter->lro) { if (adapter->netdev->features & NETIF_F_LRO) {
devRead->misc.uptFeatures |= UPT1_F_LRO; devRead->misc.uptFeatures |= UPT1_F_LRO;
devRead->misc.maxNumRxSG = cpu_to_le16(1 + MAX_SKB_FRAGS); devRead->misc.maxNumRxSG = cpu_to_le16(1 + MAX_SKB_FRAGS);
} }
...@@ -2593,9 +2593,6 @@ vmxnet3_change_mtu(struct net_device *netdev, int new_mtu) ...@@ -2593,9 +2593,6 @@ vmxnet3_change_mtu(struct net_device *netdev, int new_mtu)
if (new_mtu < VMXNET3_MIN_MTU || new_mtu > VMXNET3_MAX_MTU) if (new_mtu < VMXNET3_MIN_MTU || new_mtu > VMXNET3_MAX_MTU)
return -EINVAL; return -EINVAL;
if (new_mtu > 1500 && !adapter->jumbo_frame)
return -EINVAL;
netdev->mtu = new_mtu; netdev->mtu = new_mtu;
/* /*
...@@ -2641,28 +2638,18 @@ vmxnet3_declare_features(struct vmxnet3_adapter *adapter, bool dma64) ...@@ -2641,28 +2638,18 @@ vmxnet3_declare_features(struct vmxnet3_adapter *adapter, bool dma64)
{ {
struct net_device *netdev = adapter->netdev; struct net_device *netdev = adapter->netdev;
netdev->features = NETIF_F_SG | netdev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM |
NETIF_F_HW_CSUM | NETIF_F_HW_CSUM | NETIF_F_HW_VLAN_TX |
NETIF_F_HW_VLAN_TX | NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_LRO;
NETIF_F_HW_VLAN_RX | if (dma64)
NETIF_F_HW_VLAN_FILTER |
NETIF_F_TSO |
NETIF_F_TSO6 |
NETIF_F_LRO;
printk(KERN_INFO "features: sg csum vlan jf tso tsoIPv6 lro");
adapter->rxcsum = true;
adapter->jumbo_frame = true;
adapter->lro = true;
if (dma64) {
netdev->features |= NETIF_F_HIGHDMA; netdev->features |= NETIF_F_HIGHDMA;
printk(" highDMA"); netdev->vlan_features = netdev->hw_features & ~NETIF_F_HW_VLAN_TX;
} netdev->features = netdev->hw_features |
NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_FILTER;
netdev->vlan_features = netdev->features; netdev_info(adapter->netdev,
printk("\n"); "features: sg csum vlan jf tso tsoIPv6 lro%s\n",
dma64 ? " highDMA" : "");
} }
...@@ -2874,6 +2861,7 @@ vmxnet3_probe_device(struct pci_dev *pdev, ...@@ -2874,6 +2861,7 @@ vmxnet3_probe_device(struct pci_dev *pdev,
.ndo_start_xmit = vmxnet3_xmit_frame, .ndo_start_xmit = vmxnet3_xmit_frame,
.ndo_set_mac_address = vmxnet3_set_mac_addr, .ndo_set_mac_address = vmxnet3_set_mac_addr,
.ndo_change_mtu = vmxnet3_change_mtu, .ndo_change_mtu = vmxnet3_change_mtu,
.ndo_set_features = vmxnet3_set_features,
.ndo_get_stats = vmxnet3_get_stats, .ndo_get_stats = vmxnet3_get_stats,
.ndo_tx_timeout = vmxnet3_tx_timeout, .ndo_tx_timeout = vmxnet3_tx_timeout,
.ndo_set_multicast_list = vmxnet3_set_mc, .ndo_set_multicast_list = vmxnet3_set_mc,
......
...@@ -33,40 +33,6 @@ struct vmxnet3_stat_desc { ...@@ -33,40 +33,6 @@ struct vmxnet3_stat_desc {
}; };
static u32
vmxnet3_get_rx_csum(struct net_device *netdev)
{
struct vmxnet3_adapter *adapter = netdev_priv(netdev);
return adapter->rxcsum;
}
static int
vmxnet3_set_rx_csum(struct net_device *netdev, u32 val)
{
struct vmxnet3_adapter *adapter = netdev_priv(netdev);
unsigned long flags;
if (adapter->rxcsum != val) {
adapter->rxcsum = val;
if (netif_running(netdev)) {
if (val)
adapter->shared->devRead.misc.uptFeatures |=
UPT1_F_RXCSUM;
else
adapter->shared->devRead.misc.uptFeatures &=
~UPT1_F_RXCSUM;
spin_lock_irqsave(&adapter->cmd_lock, flags);
VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
VMXNET3_CMD_UPDATE_FEATURE);
spin_unlock_irqrestore(&adapter->cmd_lock, flags);
}
}
return 0;
}
/* per tq stats maintained by the device */ /* per tq stats maintained by the device */
static const struct vmxnet3_stat_desc static const struct vmxnet3_stat_desc
vmxnet3_tq_dev_stats[] = { vmxnet3_tq_dev_stats[] = {
...@@ -296,28 +262,27 @@ vmxnet3_get_strings(struct net_device *netdev, u32 stringset, u8 *buf) ...@@ -296,28 +262,27 @@ vmxnet3_get_strings(struct net_device *netdev, u32 stringset, u8 *buf)
} }
} }
static int int vmxnet3_set_features(struct net_device *netdev, u32 features)
vmxnet3_set_flags(struct net_device *netdev, u32 data)
{ {
struct vmxnet3_adapter *adapter = netdev_priv(netdev); struct vmxnet3_adapter *adapter = netdev_priv(netdev);
u8 lro_requested = (data & ETH_FLAG_LRO) == 0 ? 0 : 1;
u8 lro_present = (netdev->features & NETIF_F_LRO) == 0 ? 0 : 1;
unsigned long flags; unsigned long flags;
u32 changed = features ^ netdev->features;
if (ethtool_invalid_flags(netdev, data, ETH_FLAG_LRO)) if (changed & (NETIF_F_RXCSUM|NETIF_F_LRO)) {
return -EINVAL; if (features & NETIF_F_RXCSUM)
adapter->shared->devRead.misc.uptFeatures |=
if (lro_requested ^ lro_present) { UPT1_F_RXCSUM;
/* toggle the LRO feature*/ else
netdev->features ^= NETIF_F_LRO; adapter->shared->devRead.misc.uptFeatures &=
~UPT1_F_RXCSUM;
/* update harware LRO capability accordingly */ if (features & NETIF_F_LRO)
if (lro_requested)
adapter->shared->devRead.misc.uptFeatures |= adapter->shared->devRead.misc.uptFeatures |=
UPT1_F_LRO; UPT1_F_LRO;
else else
adapter->shared->devRead.misc.uptFeatures &= adapter->shared->devRead.misc.uptFeatures &=
~UPT1_F_LRO; ~UPT1_F_LRO;
spin_lock_irqsave(&adapter->cmd_lock, flags); spin_lock_irqsave(&adapter->cmd_lock, flags);
VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
VMXNET3_CMD_UPDATE_FEATURE); VMXNET3_CMD_UPDATE_FEATURE);
...@@ -654,17 +619,7 @@ static struct ethtool_ops vmxnet3_ethtool_ops = { ...@@ -654,17 +619,7 @@ static struct ethtool_ops vmxnet3_ethtool_ops = {
.get_wol = vmxnet3_get_wol, .get_wol = vmxnet3_get_wol,
.set_wol = vmxnet3_set_wol, .set_wol = vmxnet3_set_wol,
.get_link = ethtool_op_get_link, .get_link = ethtool_op_get_link,
.get_rx_csum = vmxnet3_get_rx_csum,
.set_rx_csum = vmxnet3_set_rx_csum,
.get_tx_csum = ethtool_op_get_tx_csum,
.set_tx_csum = ethtool_op_set_tx_hw_csum,
.get_sg = ethtool_op_get_sg,
.set_sg = ethtool_op_set_sg,
.get_tso = ethtool_op_get_tso,
.set_tso = ethtool_op_set_tso,
.get_strings = vmxnet3_get_strings, .get_strings = vmxnet3_get_strings,
.get_flags = ethtool_op_get_flags,
.set_flags = vmxnet3_set_flags,
.get_sset_count = vmxnet3_get_sset_count, .get_sset_count = vmxnet3_get_sset_count,
.get_ethtool_stats = vmxnet3_get_ethtool_stats, .get_ethtool_stats = vmxnet3_get_ethtool_stats,
.get_ringparam = vmxnet3_get_ringparam, .get_ringparam = vmxnet3_get_ringparam,
......
...@@ -329,10 +329,6 @@ struct vmxnet3_adapter { ...@@ -329,10 +329,6 @@ struct vmxnet3_adapter {
u8 __iomem *hw_addr0; /* for BAR 0 */ u8 __iomem *hw_addr0; /* for BAR 0 */
u8 __iomem *hw_addr1; /* for BAR 1 */ u8 __iomem *hw_addr1; /* for BAR 1 */
/* feature control */
bool rxcsum;
bool lro;
bool jumbo_frame;
#ifdef VMXNET3_RSS #ifdef VMXNET3_RSS
struct UPT1_RSSConf *rss_conf; struct UPT1_RSSConf *rss_conf;
bool rss; bool rss;
...@@ -403,6 +399,9 @@ vmxnet3_tq_destroy_all(struct vmxnet3_adapter *adapter); ...@@ -403,6 +399,9 @@ vmxnet3_tq_destroy_all(struct vmxnet3_adapter *adapter);
void void
vmxnet3_rq_destroy_all(struct vmxnet3_adapter *adapter); vmxnet3_rq_destroy_all(struct vmxnet3_adapter *adapter);
int
vmxnet3_set_features(struct net_device *netdev, u32 features);
int int
vmxnet3_create_queues(struct vmxnet3_adapter *adapter, vmxnet3_create_queues(struct vmxnet3_adapter *adapter,
u32 tx_ring_size, u32 rx_ring_size, u32 rx_ring2_size); u32 tx_ring_size, u32 rx_ring_size, u32 rx_ring2_size);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment