Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: bnx2: convert to hw_features

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Michał Mirosław and committed by
David S. Miller
8d7dfc2b f593fe36

+28 -83
+28 -81
drivers/net/bnx2.c
··· 3174 3174 } 3175 3175 3176 3176 skb_checksum_none_assert(skb); 3177 - if (bp->rx_csum && 3177 + if ((bp->dev->features & NETIF_F_RXCSUM) && 3178 3178 (status & (L2_FHDR_STATUS_TCP_SEGMENT | 3179 3179 L2_FHDR_STATUS_UDP_DATAGRAM))) { 3180 3180 ··· 7189 7189 return 0; 7190 7190 } 7191 7191 7192 - static u32 7193 - bnx2_get_rx_csum(struct net_device *dev) 7194 - { 7195 - struct bnx2 *bp = netdev_priv(dev); 7196 - 7197 - return bp->rx_csum; 7198 - } 7199 - 7200 - static int 7201 - bnx2_set_rx_csum(struct net_device *dev, u32 data) 7202 - { 7203 - struct bnx2 *bp = netdev_priv(dev); 7204 - 7205 - bp->rx_csum = data; 7206 - return 0; 7207 - } 7208 - 7209 - static int 7210 - bnx2_set_tso(struct net_device *dev, u32 data) 7211 - { 7212 - struct bnx2 *bp = netdev_priv(dev); 7213 - 7214 - if (data) { 7215 - dev->features |= NETIF_F_TSO | NETIF_F_TSO_ECN; 7216 - if (CHIP_NUM(bp) == CHIP_NUM_5709) 7217 - dev->features |= NETIF_F_TSO6; 7218 - } else 7219 - dev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6 | 7220 - NETIF_F_TSO_ECN); 7221 - return 0; 7222 - } 7223 - 7224 7192 static struct { 7225 7193 char string[ETH_GSTRING_LEN]; 7226 7194 } bnx2_stats_str_arr[] = { ··· 7500 7532 return 0; 7501 7533 } 7502 7534 7503 - static int 7504 - bnx2_set_tx_csum(struct net_device *dev, u32 data) 7535 + static u32 7536 + bnx2_fix_features(struct net_device *dev, u32 features) 7505 7537 { 7506 7538 struct bnx2 *bp = netdev_priv(dev); 7507 7539 7508 - if (CHIP_NUM(bp) == CHIP_NUM_5709) 7509 - return ethtool_op_set_tx_ipv6_csum(dev, data); 7510 - else 7511 - return ethtool_op_set_tx_csum(dev, data); 7540 + if (!(bp->flags & BNX2_FLAG_CAN_KEEP_VLAN)) 7541 + features |= NETIF_F_HW_VLAN_RX; 7542 + 7543 + return features; 7512 7544 } 7513 7545 7514 7546 static int 7515 - bnx2_set_flags(struct net_device *dev, u32 data) 7547 + bnx2_set_features(struct net_device *dev, u32 features) 7516 7548 { 7517 7549 struct bnx2 *bp = netdev_priv(dev); 7518 - int rc; 7519 - 7520 - if (!(bp->flags & BNX2_FLAG_CAN_KEEP_VLAN) && 7521 - !(data & ETH_FLAG_RXVLAN)) 7522 - return -EINVAL; 7523 7550 7524 7551 /* TSO with VLAN tag won't work with current firmware */ 7525 - if (!(data & ETH_FLAG_TXVLAN)) 7526 - return -EINVAL; 7552 + if (features & NETIF_F_HW_VLAN_TX) 7553 + dev->vlan_features |= (dev->hw_features & NETIF_F_ALL_TSO); 7554 + else 7555 + dev->vlan_features &= ~NETIF_F_ALL_TSO; 7527 7556 7528 - rc = ethtool_op_set_flags(dev, data, ETH_FLAG_RXHASH | ETH_FLAG_RXVLAN | 7529 - ETH_FLAG_TXVLAN); 7530 - if (rc) 7531 - return rc; 7532 - 7533 - if ((!!(data & ETH_FLAG_RXVLAN) != 7557 + if ((!!(features & NETIF_F_HW_VLAN_RX) != 7534 7558 !!(bp->rx_mode & BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG)) && 7535 7559 netif_running(dev)) { 7536 7560 bnx2_netif_stop(bp, false); 7561 + dev->features = features; 7537 7562 bnx2_set_rx_mode(dev); 7538 7563 bnx2_fw_sync(bp, BNX2_DRV_MSG_CODE_KEEP_VLAN_UPDATE, 0, 1); 7539 7564 bnx2_netif_start(bp, false); 7565 + return 1; 7540 7566 } 7541 7567 7542 7568 return 0; ··· 7555 7593 .set_ringparam = bnx2_set_ringparam, 7556 7594 .get_pauseparam = bnx2_get_pauseparam, 7557 7595 .set_pauseparam = bnx2_set_pauseparam, 7558 - .get_rx_csum = bnx2_get_rx_csum, 7559 - .set_rx_csum = bnx2_set_rx_csum, 7560 - .set_tx_csum = bnx2_set_tx_csum, 7561 - .set_sg = ethtool_op_set_sg, 7562 - .set_tso = bnx2_set_tso, 7563 7596 .self_test = bnx2_self_test, 7564 7597 .get_strings = bnx2_get_strings, 7565 7598 .set_phys_id = bnx2_set_phys_id, 7566 7599 .get_ethtool_stats = bnx2_get_ethtool_stats, 7567 7600 .get_sset_count = bnx2_get_sset_count, 7568 - .set_flags = bnx2_set_flags, 7569 - .get_flags = ethtool_op_get_flags, 7570 7601 }; 7571 7602 7572 7603 /* Called with rtnl_lock */ ··· 8071 8116 bp->tx_ring_size = MAX_TX_DESC_CNT; 8072 8117 bnx2_set_rx_ring_size(bp, 255); 8073 8118 8074 - bp->rx_csum = 1; 8075 - 8076 8119 bp->tx_quick_cons_trip_int = 2; 8077 8120 bp->tx_quick_cons_trip = 20; 8078 8121 bp->tx_ticks_int = 18; ··· 8262 8309 .ndo_validate_addr = eth_validate_addr, 8263 8310 .ndo_set_mac_address = bnx2_change_mac_addr, 8264 8311 .ndo_change_mtu = bnx2_change_mtu, 8312 + .ndo_fix_features = bnx2_fix_features, 8313 + .ndo_set_features = bnx2_set_features, 8265 8314 .ndo_tx_timeout = bnx2_tx_timeout, 8266 8315 #ifdef CONFIG_NET_POLL_CONTROLLER 8267 8316 .ndo_poll_controller = poll_bnx2, 8268 8317 #endif 8269 8318 }; 8270 - 8271 - static inline void vlan_features_add(struct net_device *dev, u32 flags) 8272 - { 8273 - dev->vlan_features |= flags; 8274 - } 8275 8319 8276 8320 static int __devinit 8277 8321 bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ··· 8309 8359 memcpy(dev->dev_addr, bp->mac_addr, 6); 8310 8360 memcpy(dev->perm_addr, bp->mac_addr, 6); 8311 8361 8312 - dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_GRO | 8313 - NETIF_F_RXHASH; 8314 - vlan_features_add(dev, NETIF_F_IP_CSUM | NETIF_F_SG); 8315 - if (CHIP_NUM(bp) == CHIP_NUM_5709) { 8316 - dev->features |= NETIF_F_IPV6_CSUM; 8317 - vlan_features_add(dev, NETIF_F_IPV6_CSUM); 8318 - } 8319 - dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; 8320 - dev->features |= NETIF_F_TSO | NETIF_F_TSO_ECN; 8321 - vlan_features_add(dev, NETIF_F_TSO | NETIF_F_TSO_ECN); 8322 - if (CHIP_NUM(bp) == CHIP_NUM_5709) { 8323 - dev->features |= NETIF_F_TSO6; 8324 - vlan_features_add(dev, NETIF_F_TSO6); 8325 - } 8362 + dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_SG | 8363 + NETIF_F_TSO | NETIF_F_TSO_ECN | 8364 + NETIF_F_RXHASH | NETIF_F_RXCSUM; 8365 + 8366 + if (CHIP_NUM(bp) == CHIP_NUM_5709) 8367 + dev->hw_features |= NETIF_F_IPV6_CSUM | NETIF_F_TSO6; 8368 + 8369 + dev->vlan_features = dev->hw_features; 8370 + dev->hw_features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; 8371 + dev->features |= dev->hw_features; 8372 + 8326 8373 if ((rc = register_netdev(dev))) { 8327 8374 dev_err(&pdev->dev, "Cannot register net device\n"); 8328 8375 goto error;
-2
drivers/net/bnx2.h
··· 6754 6754 u32 rx_max_ring_idx; 6755 6755 u32 rx_max_pg_ring_idx; 6756 6756 6757 - u32 rx_csum; 6758 - 6759 6757 /* TX constants */ 6760 6758 int tx_ring_size; 6761 6759 u32 tx_wake_thresh;