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

net: bnx2: convert to hw_features

Signed-off-by: default avatarMichał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f593fe36
...@@ -3174,7 +3174,7 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget) ...@@ -3174,7 +3174,7 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget)
} }
skb_checksum_none_assert(skb); skb_checksum_none_assert(skb);
if (bp->rx_csum && if ((bp->dev->features & NETIF_F_RXCSUM) &&
(status & (L2_FHDR_STATUS_TCP_SEGMENT | (status & (L2_FHDR_STATUS_TCP_SEGMENT |
L2_FHDR_STATUS_UDP_DATAGRAM))) { L2_FHDR_STATUS_UDP_DATAGRAM))) {
...@@ -7189,38 +7189,6 @@ bnx2_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *epause) ...@@ -7189,38 +7189,6 @@ bnx2_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *epause)
return 0; return 0;
} }
static u32
bnx2_get_rx_csum(struct net_device *dev)
{
struct bnx2 *bp = netdev_priv(dev);
return bp->rx_csum;
}
static int
bnx2_set_rx_csum(struct net_device *dev, u32 data)
{
struct bnx2 *bp = netdev_priv(dev);
bp->rx_csum = data;
return 0;
}
static int
bnx2_set_tso(struct net_device *dev, u32 data)
{
struct bnx2 *bp = netdev_priv(dev);
if (data) {
dev->features |= NETIF_F_TSO | NETIF_F_TSO_ECN;
if (CHIP_NUM(bp) == CHIP_NUM_5709)
dev->features |= NETIF_F_TSO6;
} else
dev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6 |
NETIF_F_TSO_ECN);
return 0;
}
static struct { static struct {
char string[ETH_GSTRING_LEN]; char string[ETH_GSTRING_LEN];
} bnx2_stats_str_arr[] = { } bnx2_stats_str_arr[] = {
...@@ -7532,43 +7500,37 @@ bnx2_set_phys_id(struct net_device *dev, enum ethtool_phys_id_state state) ...@@ -7532,43 +7500,37 @@ bnx2_set_phys_id(struct net_device *dev, enum ethtool_phys_id_state state)
return 0; return 0;
} }
static int static u32
bnx2_set_tx_csum(struct net_device *dev, u32 data) bnx2_fix_features(struct net_device *dev, u32 features)
{ {
struct bnx2 *bp = netdev_priv(dev); struct bnx2 *bp = netdev_priv(dev);
if (CHIP_NUM(bp) == CHIP_NUM_5709) if (!(bp->flags & BNX2_FLAG_CAN_KEEP_VLAN))
return ethtool_op_set_tx_ipv6_csum(dev, data); features |= NETIF_F_HW_VLAN_RX;
else
return ethtool_op_set_tx_csum(dev, data); return features;
} }
static int static int
bnx2_set_flags(struct net_device *dev, u32 data) bnx2_set_features(struct net_device *dev, u32 features)
{ {
struct bnx2 *bp = netdev_priv(dev); struct bnx2 *bp = netdev_priv(dev);
int rc;
if (!(bp->flags & BNX2_FLAG_CAN_KEEP_VLAN) &&
!(data & ETH_FLAG_RXVLAN))
return -EINVAL;
/* TSO with VLAN tag won't work with current firmware */ /* TSO with VLAN tag won't work with current firmware */
if (!(data & ETH_FLAG_TXVLAN)) if (features & NETIF_F_HW_VLAN_TX)
return -EINVAL; dev->vlan_features |= (dev->hw_features & NETIF_F_ALL_TSO);
else
rc = ethtool_op_set_flags(dev, data, ETH_FLAG_RXHASH | ETH_FLAG_RXVLAN | dev->vlan_features &= ~NETIF_F_ALL_TSO;
ETH_FLAG_TXVLAN);
if (rc)
return rc;
if ((!!(data & ETH_FLAG_RXVLAN) != if ((!!(features & NETIF_F_HW_VLAN_RX) !=
!!(bp->rx_mode & BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG)) && !!(bp->rx_mode & BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG)) &&
netif_running(dev)) { netif_running(dev)) {
bnx2_netif_stop(bp, false); bnx2_netif_stop(bp, false);
dev->features = features;
bnx2_set_rx_mode(dev); bnx2_set_rx_mode(dev);
bnx2_fw_sync(bp, BNX2_DRV_MSG_CODE_KEEP_VLAN_UPDATE, 0, 1); bnx2_fw_sync(bp, BNX2_DRV_MSG_CODE_KEEP_VLAN_UPDATE, 0, 1);
bnx2_netif_start(bp, false); bnx2_netif_start(bp, false);
return 1;
} }
return 0; return 0;
...@@ -7593,18 +7555,11 @@ static const struct ethtool_ops bnx2_ethtool_ops = { ...@@ -7593,18 +7555,11 @@ static const struct ethtool_ops bnx2_ethtool_ops = {
.set_ringparam = bnx2_set_ringparam, .set_ringparam = bnx2_set_ringparam,
.get_pauseparam = bnx2_get_pauseparam, .get_pauseparam = bnx2_get_pauseparam,
.set_pauseparam = bnx2_set_pauseparam, .set_pauseparam = bnx2_set_pauseparam,
.get_rx_csum = bnx2_get_rx_csum,
.set_rx_csum = bnx2_set_rx_csum,
.set_tx_csum = bnx2_set_tx_csum,
.set_sg = ethtool_op_set_sg,
.set_tso = bnx2_set_tso,
.self_test = bnx2_self_test, .self_test = bnx2_self_test,
.get_strings = bnx2_get_strings, .get_strings = bnx2_get_strings,
.set_phys_id = bnx2_set_phys_id, .set_phys_id = bnx2_set_phys_id,
.get_ethtool_stats = bnx2_get_ethtool_stats, .get_ethtool_stats = bnx2_get_ethtool_stats,
.get_sset_count = bnx2_get_sset_count, .get_sset_count = bnx2_get_sset_count,
.set_flags = bnx2_set_flags,
.get_flags = ethtool_op_get_flags,
}; };
/* Called with rtnl_lock */ /* Called with rtnl_lock */
...@@ -8116,8 +8071,6 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev) ...@@ -8116,8 +8071,6 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
bp->tx_ring_size = MAX_TX_DESC_CNT; bp->tx_ring_size = MAX_TX_DESC_CNT;
bnx2_set_rx_ring_size(bp, 255); bnx2_set_rx_ring_size(bp, 255);
bp->rx_csum = 1;
bp->tx_quick_cons_trip_int = 2; bp->tx_quick_cons_trip_int = 2;
bp->tx_quick_cons_trip = 20; bp->tx_quick_cons_trip = 20;
bp->tx_ticks_int = 18; bp->tx_ticks_int = 18;
...@@ -8309,17 +8262,14 @@ static const struct net_device_ops bnx2_netdev_ops = { ...@@ -8309,17 +8262,14 @@ static const struct net_device_ops bnx2_netdev_ops = {
.ndo_validate_addr = eth_validate_addr, .ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = bnx2_change_mac_addr, .ndo_set_mac_address = bnx2_change_mac_addr,
.ndo_change_mtu = bnx2_change_mtu, .ndo_change_mtu = bnx2_change_mtu,
.ndo_fix_features = bnx2_fix_features,
.ndo_set_features = bnx2_set_features,
.ndo_tx_timeout = bnx2_tx_timeout, .ndo_tx_timeout = bnx2_tx_timeout,
#ifdef CONFIG_NET_POLL_CONTROLLER #ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = poll_bnx2, .ndo_poll_controller = poll_bnx2,
#endif #endif
}; };
static inline void vlan_features_add(struct net_device *dev, u32 flags)
{
dev->vlan_features |= flags;
}
static int __devinit static int __devinit
bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{ {
...@@ -8359,20 +8309,17 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -8359,20 +8309,17 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
memcpy(dev->dev_addr, bp->mac_addr, 6); memcpy(dev->dev_addr, bp->mac_addr, 6);
memcpy(dev->perm_addr, bp->mac_addr, 6); memcpy(dev->perm_addr, bp->mac_addr, 6);
dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_GRO | dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_SG |
NETIF_F_RXHASH; NETIF_F_TSO | NETIF_F_TSO_ECN |
vlan_features_add(dev, NETIF_F_IP_CSUM | NETIF_F_SG); NETIF_F_RXHASH | NETIF_F_RXCSUM;
if (CHIP_NUM(bp) == CHIP_NUM_5709) {
dev->features |= NETIF_F_IPV6_CSUM; if (CHIP_NUM(bp) == CHIP_NUM_5709)
vlan_features_add(dev, NETIF_F_IPV6_CSUM); dev->hw_features |= NETIF_F_IPV6_CSUM | NETIF_F_TSO6;
}
dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; dev->vlan_features = dev->hw_features;
dev->features |= NETIF_F_TSO | NETIF_F_TSO_ECN; dev->hw_features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
vlan_features_add(dev, NETIF_F_TSO | NETIF_F_TSO_ECN); dev->features |= dev->hw_features;
if (CHIP_NUM(bp) == CHIP_NUM_5709) {
dev->features |= NETIF_F_TSO6;
vlan_features_add(dev, NETIF_F_TSO6);
}
if ((rc = register_netdev(dev))) { if ((rc = register_netdev(dev))) {
dev_err(&pdev->dev, "Cannot register net device\n"); dev_err(&pdev->dev, "Cannot register net device\n");
goto error; goto error;
......
...@@ -6754,8 +6754,6 @@ struct bnx2 { ...@@ -6754,8 +6754,6 @@ struct bnx2 {
u32 rx_max_ring_idx; u32 rx_max_ring_idx;
u32 rx_max_pg_ring_idx; u32 rx_max_pg_ring_idx;
u32 rx_csum;
/* TX constants */ /* TX constants */
int tx_ring_size; int tx_ring_size;
u32 tx_wake_thresh; u32 tx_wake_thresh;
......
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