~ubuntu-branches/ubuntu/quantal/linux-linaro-mx51/quantal

« back to all changes in this revision

Viewing changes to drivers/net/bnx2.c

  • Committer: Package Import Robot
  • Author(s): John Rigby, John Rigby
  • Date: 2011-09-26 10:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20110926104423-3o58a3c1bj7x00rs
Tags: 3.0.0-1007.9
[ John Rigby ]

Enable crypto modules and remove crypto-modules from
exclude-module files
LP: #826021

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
6696
6696
 
6697
6697
        if (bp->autoneg & AUTONEG_SPEED) {
6698
6698
                cmd->autoneg = AUTONEG_ENABLE;
6699
 
        }
6700
 
        else {
 
6699
        } else {
6701
6700
                cmd->autoneg = AUTONEG_DISABLE;
6702
6701
        }
6703
6702
 
6704
6703
        if (netif_carrier_ok(dev)) {
6705
 
                cmd->speed = bp->line_speed;
 
6704
                ethtool_cmd_speed_set(cmd, bp->line_speed);
6706
6705
                cmd->duplex = bp->duplex;
6707
6706
        }
6708
6707
        else {
6709
 
                cmd->speed = -1;
 
6708
                ethtool_cmd_speed_set(cmd, -1);
6710
6709
                cmd->duplex = -1;
6711
6710
        }
6712
6711
        spin_unlock_bh(&bp->phy_lock);
6758
6757
                advertising |= ADVERTISED_Autoneg;
6759
6758
        }
6760
6759
        else {
 
6760
                u32 speed = ethtool_cmd_speed(cmd);
6761
6761
                if (cmd->port == PORT_FIBRE) {
6762
 
                        if ((cmd->speed != SPEED_1000 &&
6763
 
                             cmd->speed != SPEED_2500) ||
 
6762
                        if ((speed != SPEED_1000 &&
 
6763
                             speed != SPEED_2500) ||
6764
6764
                            (cmd->duplex != DUPLEX_FULL))
6765
6765
                                goto err_out_unlock;
6766
6766
 
6767
 
                        if (cmd->speed == SPEED_2500 &&
 
6767
                        if (speed == SPEED_2500 &&
6768
6768
                            !(bp->phy_flags & BNX2_PHY_FLAG_2_5G_CAPABLE))
6769
6769
                                goto err_out_unlock;
6770
 
                }
6771
 
                else if (cmd->speed == SPEED_1000 || cmd->speed == SPEED_2500)
 
6770
                } else if (speed == SPEED_1000 || speed == SPEED_2500)
6772
6771
                        goto err_out_unlock;
6773
6772
 
6774
6773
                autoneg &= ~AUTONEG_SPEED;
6775
 
                req_line_speed = cmd->speed;
 
6774
                req_line_speed = speed;
6776
6775
                req_duplex = cmd->duplex;
6777
6776
                advertising = 0;
6778
6777
        }
7189
7188
        return 0;
7190
7189
}
7191
7190
 
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
7191
static struct {
7225
7192
        char string[ETH_GSTRING_LEN];
7226
7193
} bnx2_stats_str_arr[] = {
7495
7462
}
7496
7463
 
7497
7464
static int
7498
 
bnx2_phys_id(struct net_device *dev, u32 data)
 
7465
bnx2_set_phys_id(struct net_device *dev, enum ethtool_phys_id_state state)
7499
7466
{
7500
7467
        struct bnx2 *bp = netdev_priv(dev);
7501
 
        int i;
7502
 
        u32 save;
7503
 
 
7504
 
        bnx2_set_power_state(bp, PCI_D0);
7505
 
 
7506
 
        if (data == 0)
7507
 
                data = 2;
7508
 
 
7509
 
        save = REG_RD(bp, BNX2_MISC_CFG);
7510
 
        REG_WR(bp, BNX2_MISC_CFG, BNX2_MISC_CFG_LEDMODE_MAC);
7511
 
 
7512
 
        for (i = 0; i < (data * 2); i++) {
7513
 
                if ((i % 2) == 0) {
7514
 
                        REG_WR(bp, BNX2_EMAC_LED, BNX2_EMAC_LED_OVERRIDE);
7515
 
                }
7516
 
                else {
7517
 
                        REG_WR(bp, BNX2_EMAC_LED, BNX2_EMAC_LED_OVERRIDE |
7518
 
                                BNX2_EMAC_LED_1000MB_OVERRIDE |
7519
 
                                BNX2_EMAC_LED_100MB_OVERRIDE |
7520
 
                                BNX2_EMAC_LED_10MB_OVERRIDE |
7521
 
                                BNX2_EMAC_LED_TRAFFIC_OVERRIDE |
7522
 
                                BNX2_EMAC_LED_TRAFFIC);
7523
 
                }
7524
 
                msleep_interruptible(500);
7525
 
                if (signal_pending(current))
7526
 
                        break;
 
7468
 
 
7469
        switch (state) {
 
7470
        case ETHTOOL_ID_ACTIVE:
 
7471
                bnx2_set_power_state(bp, PCI_D0);
 
7472
 
 
7473
                bp->leds_save = REG_RD(bp, BNX2_MISC_CFG);
 
7474
                REG_WR(bp, BNX2_MISC_CFG, BNX2_MISC_CFG_LEDMODE_MAC);
 
7475
                return 1;       /* cycle on/off once per second */
 
7476
 
 
7477
        case ETHTOOL_ID_ON:
 
7478
                REG_WR(bp, BNX2_EMAC_LED, BNX2_EMAC_LED_OVERRIDE |
 
7479
                       BNX2_EMAC_LED_1000MB_OVERRIDE |
 
7480
                       BNX2_EMAC_LED_100MB_OVERRIDE |
 
7481
                       BNX2_EMAC_LED_10MB_OVERRIDE |
 
7482
                       BNX2_EMAC_LED_TRAFFIC_OVERRIDE |
 
7483
                       BNX2_EMAC_LED_TRAFFIC);
 
7484
                break;
 
7485
 
 
7486
        case ETHTOOL_ID_OFF:
 
7487
                REG_WR(bp, BNX2_EMAC_LED, BNX2_EMAC_LED_OVERRIDE);
 
7488
                break;
 
7489
 
 
7490
        case ETHTOOL_ID_INACTIVE:
 
7491
                REG_WR(bp, BNX2_EMAC_LED, 0);
 
7492
                REG_WR(bp, BNX2_MISC_CFG, bp->leds_save);
 
7493
 
 
7494
                if (!netif_running(dev))
 
7495
                        bnx2_set_power_state(bp, PCI_D3hot);
 
7496
                break;
7527
7497
        }
7528
 
        REG_WR(bp, BNX2_EMAC_LED, 0);
7529
 
        REG_WR(bp, BNX2_MISC_CFG, save);
7530
 
 
7531
 
        if (!netif_running(dev))
7532
 
                bnx2_set_power_state(bp, PCI_D3hot);
7533
7498
 
7534
7499
        return 0;
7535
7500
}
7536
7501
 
7537
 
static int
7538
 
bnx2_set_tx_csum(struct net_device *dev, u32 data)
 
7502
static u32
 
7503
bnx2_fix_features(struct net_device *dev, u32 features)
7539
7504
{
7540
7505
        struct bnx2 *bp = netdev_priv(dev);
7541
7506
 
7542
 
        if (CHIP_NUM(bp) == CHIP_NUM_5709)
7543
 
                return ethtool_op_set_tx_ipv6_csum(dev, data);
7544
 
        else
7545
 
                return ethtool_op_set_tx_csum(dev, data);
 
7507
        if (!(bp->flags & BNX2_FLAG_CAN_KEEP_VLAN))
 
7508
                features |= NETIF_F_HW_VLAN_RX;
 
7509
 
 
7510
        return features;
7546
7511
}
7547
7512
 
7548
7513
static int
7549
 
bnx2_set_flags(struct net_device *dev, u32 data)
 
7514
bnx2_set_features(struct net_device *dev, u32 features)
7550
7515
{
7551
7516
        struct bnx2 *bp = netdev_priv(dev);
7552
 
        int rc;
7553
 
 
7554
 
        if (!(bp->flags & BNX2_FLAG_CAN_KEEP_VLAN) &&
7555
 
            !(data & ETH_FLAG_RXVLAN))
7556
 
                return -EINVAL;
7557
7517
 
7558
7518
        /* TSO with VLAN tag won't work with current firmware */
7559
 
        if (!(data & ETH_FLAG_TXVLAN))
7560
 
                return -EINVAL;
7561
 
 
7562
 
        rc = ethtool_op_set_flags(dev, data, ETH_FLAG_RXHASH | ETH_FLAG_RXVLAN |
7563
 
                                  ETH_FLAG_TXVLAN);
7564
 
        if (rc)
7565
 
                return rc;
7566
 
 
7567
 
        if ((!!(data & ETH_FLAG_RXVLAN) !=
 
7519
        if (features & NETIF_F_HW_VLAN_TX)
 
7520
                dev->vlan_features |= (dev->hw_features & NETIF_F_ALL_TSO);
 
7521
        else
 
7522
                dev->vlan_features &= ~NETIF_F_ALL_TSO;
 
7523
 
 
7524
        if ((!!(features & NETIF_F_HW_VLAN_RX) !=
7568
7525
            !!(bp->rx_mode & BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG)) &&
7569
7526
            netif_running(dev)) {
7570
7527
                bnx2_netif_stop(bp, false);
 
7528
                dev->features = features;
7571
7529
                bnx2_set_rx_mode(dev);
7572
7530
                bnx2_fw_sync(bp, BNX2_DRV_MSG_CODE_KEEP_VLAN_UPDATE, 0, 1);
7573
7531
                bnx2_netif_start(bp, false);
 
7532
                return 1;
7574
7533
        }
7575
7534
 
7576
7535
        return 0;
7595
7554
        .set_ringparam          = bnx2_set_ringparam,
7596
7555
        .get_pauseparam         = bnx2_get_pauseparam,
7597
7556
        .set_pauseparam         = bnx2_set_pauseparam,
7598
 
        .get_rx_csum            = bnx2_get_rx_csum,
7599
 
        .set_rx_csum            = bnx2_set_rx_csum,
7600
 
        .set_tx_csum            = bnx2_set_tx_csum,
7601
 
        .set_sg                 = ethtool_op_set_sg,
7602
 
        .set_tso                = bnx2_set_tso,
7603
7557
        .self_test              = bnx2_self_test,
7604
7558
        .get_strings            = bnx2_get_strings,
7605
 
        .phys_id                = bnx2_phys_id,
 
7559
        .set_phys_id            = bnx2_set_phys_id,
7606
7560
        .get_ethtool_stats      = bnx2_get_ethtool_stats,
7607
7561
        .get_sset_count         = bnx2_get_sset_count,
7608
 
        .set_flags              = bnx2_set_flags,
7609
 
        .get_flags              = ethtool_op_get_flags,
7610
7562
};
7611
7563
 
7612
7564
/* Called with rtnl_lock */
8118
8070
        bp->tx_ring_size = MAX_TX_DESC_CNT;
8119
8071
        bnx2_set_rx_ring_size(bp, 255);
8120
8072
 
8121
 
        bp->rx_csum = 1;
8122
 
 
8123
8073
        bp->tx_quick_cons_trip_int = 2;
8124
8074
        bp->tx_quick_cons_trip = 20;
8125
8075
        bp->tx_ticks_int = 18;
8311
8261
        .ndo_validate_addr      = eth_validate_addr,
8312
8262
        .ndo_set_mac_address    = bnx2_change_mac_addr,
8313
8263
        .ndo_change_mtu         = bnx2_change_mtu,
 
8264
        .ndo_fix_features       = bnx2_fix_features,
 
8265
        .ndo_set_features       = bnx2_set_features,
8314
8266
        .ndo_tx_timeout         = bnx2_tx_timeout,
8315
8267
#ifdef CONFIG_NET_POLL_CONTROLLER
8316
8268
        .ndo_poll_controller    = poll_bnx2,
8317
8269
#endif
8318
8270
};
8319
8271
 
8320
 
static inline void vlan_features_add(struct net_device *dev, u32 flags)
8321
 
{
8322
 
        dev->vlan_features |= flags;
8323
 
}
8324
 
 
8325
8272
static int __devinit
8326
8273
bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
8327
8274
{
8361
8308
        memcpy(dev->dev_addr, bp->mac_addr, 6);
8362
8309
        memcpy(dev->perm_addr, bp->mac_addr, 6);
8363
8310
 
8364
 
        dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_GRO |
8365
 
                         NETIF_F_RXHASH;
8366
 
        vlan_features_add(dev, NETIF_F_IP_CSUM | NETIF_F_SG);
8367
 
        if (CHIP_NUM(bp) == CHIP_NUM_5709) {
8368
 
                dev->features |= NETIF_F_IPV6_CSUM;
8369
 
                vlan_features_add(dev, NETIF_F_IPV6_CSUM);
8370
 
        }
8371
 
        dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
8372
 
        dev->features |= NETIF_F_TSO | NETIF_F_TSO_ECN;
8373
 
        vlan_features_add(dev, NETIF_F_TSO | NETIF_F_TSO_ECN);
8374
 
        if (CHIP_NUM(bp) == CHIP_NUM_5709) {
8375
 
                dev->features |= NETIF_F_TSO6;
8376
 
                vlan_features_add(dev, NETIF_F_TSO6);
8377
 
        }
 
8311
        dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_SG |
 
8312
                NETIF_F_TSO | NETIF_F_TSO_ECN |
 
8313
                NETIF_F_RXHASH | NETIF_F_RXCSUM;
 
8314
 
 
8315
        if (CHIP_NUM(bp) == CHIP_NUM_5709)
 
8316
                dev->hw_features |= NETIF_F_IPV6_CSUM | NETIF_F_TSO6;
 
8317
 
 
8318
        dev->vlan_features = dev->hw_features;
 
8319
        dev->hw_features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
 
8320
        dev->features |= dev->hw_features;
 
8321
 
8378
8322
        if ((rc = register_netdev(dev))) {
8379
8323
                dev_err(&pdev->dev, "Cannot register net device\n");
8380
8324
                goto error;