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

« back to all changes in this revision

Viewing changes to drivers/net/sky2.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:
1198
1198
 
1199
1199
        sky2_write32(sky2->hw,
1200
1200
                     Q_ADDR(rxqaddr[sky2->port], Q_CSR),
1201
 
                     (sky2->flags & SKY2_FLAG_RX_CHECKSUM)
 
1201
                     (sky2->netdev->features & NETIF_F_RXCSUM)
1202
1202
                     ? BMU_ENA_RX_CHKSUM : BMU_DIS_RX_CHKSUM);
1203
1203
}
1204
1204
 
1205
1205
/* Enable/disable receive hash calculation (RSS) */
1206
 
static void rx_set_rss(struct net_device *dev)
 
1206
static void rx_set_rss(struct net_device *dev, u32 features)
1207
1207
{
1208
1208
        struct sky2_port *sky2 = netdev_priv(dev);
1209
1209
        struct sky2_hw *hw = sky2->hw;
1216
1216
        }
1217
1217
 
1218
1218
        /* Program RSS initial values */
1219
 
        if (dev->features & NETIF_F_RXHASH) {
 
1219
        if (features & NETIF_F_RXHASH) {
1220
1220
                u32 key[nkeys];
1221
1221
 
1222
1222
                get_random_bytes(key, nkeys * sizeof(u32));
1322
1322
        return err;
1323
1323
}
1324
1324
 
1325
 
#define NETIF_F_ALL_VLAN (NETIF_F_HW_VLAN_TX|NETIF_F_HW_VLAN_RX)
 
1325
#define SKY2_VLAN_OFFLOADS (NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO)
1326
1326
 
1327
 
static void sky2_vlan_mode(struct net_device *dev)
 
1327
static void sky2_vlan_mode(struct net_device *dev, u32 features)
1328
1328
{
1329
1329
        struct sky2_port *sky2 = netdev_priv(dev);
1330
1330
        struct sky2_hw *hw = sky2->hw;
1331
1331
        u16 port = sky2->port;
1332
1332
 
1333
 
        if (dev->features & NETIF_F_HW_VLAN_RX)
 
1333
        if (features & NETIF_F_HW_VLAN_RX)
1334
1334
                sky2_write32(hw, SK_REG(port, RX_GMF_CTRL_T),
1335
1335
                             RX_VLAN_STRIP_ON);
1336
1336
        else
1337
1337
                sky2_write32(hw, SK_REG(port, RX_GMF_CTRL_T),
1338
1338
                             RX_VLAN_STRIP_OFF);
1339
1339
 
1340
 
        dev->vlan_features = dev->features &~ NETIF_F_ALL_VLAN;
1341
 
        if (dev->features & NETIF_F_HW_VLAN_TX)
 
1340
        if (features & NETIF_F_HW_VLAN_TX) {
1342
1341
                sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T),
1343
1342
                             TX_VLAN_TAG_ON);
1344
 
        else {
 
1343
 
 
1344
                dev->vlan_features |= SKY2_VLAN_OFFLOADS;
 
1345
        } else {
1345
1346
                sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T),
1346
1347
                             TX_VLAN_TAG_OFF);
1347
1348
 
1348
1349
                /* Can't do transmit offload of vlan without hw vlan */
1349
 
                dev->vlan_features &= ~(NETIF_F_TSO | NETIF_F_SG
1350
 
                                        | NETIF_F_ALL_CSUM);
 
1350
                dev->vlan_features &= ~SKY2_VLAN_OFFLOADS;
1351
1351
        }
1352
1352
}
1353
1353
 
1463
1463
                rx_set_checksum(sky2);
1464
1464
 
1465
1465
        if (!(hw->flags & SKY2_HW_RSS_BROKEN))
1466
 
                rx_set_rss(sky2->netdev);
 
1466
                rx_set_rss(sky2->netdev, sky2->netdev->features);
1467
1467
 
1468
1468
        /* submit Rx ring */
1469
1469
        for (i = 0; i < sky2->rx_pending; i++) {
1626
1626
        sky2_prefetch_init(hw, txqaddr[port], sky2->tx_le_map,
1627
1627
                           sky2->tx_ring_size - 1);
1628
1628
 
1629
 
        sky2_vlan_mode(sky2->netdev);
 
1629
        sky2_vlan_mode(sky2->netdev, sky2->netdev->features);
 
1630
        netdev_update_features(sky2->netdev);
1630
1631
 
1631
1632
        sky2_rx_start(sky2);
1632
1633
}
2261
2262
             hw->chip_id == CHIP_ID_YUKON_FE_P))
2262
2263
                return -EINVAL;
2263
2264
 
2264
 
        /* TSO, etc on Yukon Ultra and MTU > 1500 not supported */
2265
 
        if (new_mtu > ETH_DATA_LEN && hw->chip_id == CHIP_ID_YUKON_EC_U)
2266
 
                dev->features &= ~(NETIF_F_TSO|NETIF_F_SG|NETIF_F_ALL_CSUM);
2267
 
 
2268
2265
        if (!netif_running(dev)) {
2269
2266
                dev->mtu = new_mtu;
 
2267
                netdev_update_features(dev);
2270
2268
                return 0;
2271
2269
        }
2272
2270
 
2288
2286
        sky2_rx_clean(sky2);
2289
2287
 
2290
2288
        dev->mtu = new_mtu;
 
2289
        netdev_update_features(dev);
2291
2290
 
2292
2291
        mode = DATA_BLIND_VAL(DATA_BLIND_DEF) |
2293
2292
                GM_SMOD_VLAN_ENA | IPG_DATA_VAL(IPG_DATA_DEF);
2535
2534
                           "%s: receive checksum problem (status = %#x)\n",
2536
2535
                           sky2->netdev->name, status);
2537
2536
 
2538
 
                /* Disable checksum offload */
2539
 
                sky2->flags &= ~SKY2_FLAG_RX_CHECKSUM;
 
2537
                /* Disable checksum offload
 
2538
                 * It will be reenabled on next ndo_set_features, but if it's
 
2539
                 * really broken, will get disabled again
 
2540
                 */
 
2541
                sky2->netdev->features &= ~NETIF_F_RXCSUM;
2540
2542
                sky2_write32(sky2->hw, Q_ADDR(rxqaddr[sky2->port], Q_CSR),
2541
2543
                             BMU_DIS_RX_CHKSUM);
2542
2544
        }
2591
2593
 
2592
2594
                        /* This chip reports checksum status differently */
2593
2595
                        if (hw->flags & SKY2_HW_NEW_LE) {
2594
 
                                if ((sky2->flags & SKY2_FLAG_RX_CHECKSUM) &&
 
2596
                                if ((dev->features & NETIF_F_RXCSUM) &&
2595
2597
                                    (le->css & (CSS_ISIPV4 | CSS_ISIPV6)) &&
2596
2598
                                    (le->css & CSS_TCPUDPCSOK))
2597
2599
                                        skb->ip_summed = CHECKSUM_UNNECESSARY;
2616
2618
                        sky2->rx_tag = length;
2617
2619
                        /* fall through */
2618
2620
                case OP_RXCHKS:
2619
 
                        if (likely(sky2->flags & SKY2_FLAG_RX_CHECKSUM))
 
2621
                        if (likely(dev->features & NETIF_F_RXCSUM))
2620
2622
                                sky2_rx_checksum(sky2, status);
2621
2623
                        break;
2622
2624
 
3411
3413
        ecmd->phy_address = PHY_ADDR_MARV;
3412
3414
        if (sky2_is_copper(hw)) {
3413
3415
                ecmd->port = PORT_TP;
3414
 
                ecmd->speed = sky2->speed;
 
3416
                ethtool_cmd_speed_set(ecmd, sky2->speed);
3415
3417
                ecmd->supported |=  SUPPORTED_Autoneg | SUPPORTED_TP;
3416
3418
        } else {
3417
 
                ecmd->speed = SPEED_1000;
 
3419
                ethtool_cmd_speed_set(ecmd, SPEED_1000);
3418
3420
                ecmd->port = PORT_FIBRE;
3419
3421
                ecmd->supported |=  SUPPORTED_Autoneg | SUPPORTED_FIBRE;
3420
3422
        }
3450
3452
                sky2->speed = -1;
3451
3453
        } else {
3452
3454
                u32 setting;
 
3455
                u32 speed = ethtool_cmd_speed(ecmd);
3453
3456
 
3454
 
                switch (ecmd->speed) {
 
3457
                switch (speed) {
3455
3458
                case SPEED_1000:
3456
3459
                        if (ecmd->duplex == DUPLEX_FULL)
3457
3460
                                setting = SUPPORTED_1000baseT_Full;
3484
3487
                if ((setting & supported) == 0)
3485
3488
                        return -EINVAL;
3486
3489
 
3487
 
                sky2->speed = ecmd->speed;
 
3490
                sky2->speed = speed;
3488
3491
                sky2->duplex = ecmd->duplex;
3489
3492
                sky2->flags &= ~SKY2_FLAG_AUTO_SPEED;
3490
3493
        }
3552
3555
        { "tx_fifo_underrun", GM_TXE_FIFO_UR },
3553
3556
};
3554
3557
 
3555
 
static u32 sky2_get_rx_csum(struct net_device *dev)
3556
 
{
3557
 
        struct sky2_port *sky2 = netdev_priv(dev);
3558
 
 
3559
 
        return !!(sky2->flags & SKY2_FLAG_RX_CHECKSUM);
3560
 
}
3561
 
 
3562
 
static int sky2_set_rx_csum(struct net_device *dev, u32 data)
3563
 
{
3564
 
        struct sky2_port *sky2 = netdev_priv(dev);
3565
 
 
3566
 
        if (data)
3567
 
                sky2->flags |= SKY2_FLAG_RX_CHECKSUM;
3568
 
        else
3569
 
                sky2->flags &= ~SKY2_FLAG_RX_CHECKSUM;
3570
 
 
3571
 
        sky2_write32(sky2->hw, Q_ADDR(rxqaddr[sky2->port], Q_CSR),
3572
 
                     data ? BMU_ENA_RX_CHKSUM : BMU_DIS_RX_CHKSUM);
3573
 
 
3574
 
        return 0;
3575
 
}
3576
 
 
3577
3558
static u32 sky2_get_msglevel(struct net_device *netdev)
3578
3559
{
3579
3560
        struct sky2_port *sky2 = netdev_priv(netdev);
3826
3807
}
3827
3808
 
3828
3809
/* blink LED's for finding board */
3829
 
static int sky2_phys_id(struct net_device *dev, u32 data)
 
3810
static int sky2_set_phys_id(struct net_device *dev,
 
3811
                            enum ethtool_phys_id_state state)
3830
3812
{
3831
3813
        struct sky2_port *sky2 = netdev_priv(dev);
3832
 
        unsigned int i;
3833
 
 
3834
 
        if (data == 0)
3835
 
                data = UINT_MAX;
3836
 
 
3837
 
        for (i = 0; i < data; i++) {
 
3814
 
 
3815
        switch (state) {
 
3816
        case ETHTOOL_ID_ACTIVE:
 
3817
                return 1;       /* cycle on/off once per second */
 
3818
        case ETHTOOL_ID_INACTIVE:
 
3819
                sky2_led(sky2, MO_LED_NORM);
 
3820
                break;
 
3821
        case ETHTOOL_ID_ON:
3838
3822
                sky2_led(sky2, MO_LED_ON);
3839
 
                if (msleep_interruptible(500))
3840
 
                        break;
 
3823
                break;
 
3824
        case ETHTOOL_ID_OFF:
3841
3825
                sky2_led(sky2, MO_LED_OFF);
3842
 
                if (msleep_interruptible(500))
3843
 
                        break;
 
3826
                break;
3844
3827
        }
3845
 
        sky2_led(sky2, MO_LED_NORM);
3846
3828
 
3847
3829
        return 0;
3848
3830
}
4083
4065
        }
4084
4066
}
4085
4067
 
4086
 
/* In order to do Jumbo packets on these chips, need to turn off the
4087
 
 * transmit store/forward. Therefore checksum offload won't work.
4088
 
 */
4089
 
static int no_tx_offload(struct net_device *dev)
4090
 
{
4091
 
        const struct sky2_port *sky2 = netdev_priv(dev);
4092
 
        const struct sky2_hw *hw = sky2->hw;
4093
 
 
4094
 
        return dev->mtu > ETH_DATA_LEN && hw->chip_id == CHIP_ID_YUKON_EC_U;
4095
 
}
4096
 
 
4097
 
static int sky2_set_tx_csum(struct net_device *dev, u32 data)
4098
 
{
4099
 
        if (data && no_tx_offload(dev))
4100
 
                return -EINVAL;
4101
 
 
4102
 
        return ethtool_op_set_tx_csum(dev, data);
4103
 
}
4104
 
 
4105
 
 
4106
 
static int sky2_set_tso(struct net_device *dev, u32 data)
4107
 
{
4108
 
        if (data && no_tx_offload(dev))
4109
 
                return -EINVAL;
4110
 
 
4111
 
        return ethtool_op_set_tso(dev, data);
4112
 
}
4113
 
 
4114
4068
static int sky2_get_eeprom_len(struct net_device *dev)
4115
4069
{
4116
4070
        struct sky2_port *sky2 = netdev_priv(dev);
4213
4167
        return sky2_vpd_write(sky2->hw, cap, data, eeprom->offset, eeprom->len);
4214
4168
}
4215
4169
 
4216
 
static int sky2_set_flags(struct net_device *dev, u32 data)
 
4170
static u32 sky2_fix_features(struct net_device *dev, u32 features)
 
4171
{
 
4172
        const struct sky2_port *sky2 = netdev_priv(dev);
 
4173
        const struct sky2_hw *hw = sky2->hw;
 
4174
 
 
4175
        /* In order to do Jumbo packets on these chips, need to turn off the
 
4176
         * transmit store/forward. Therefore checksum offload won't work.
 
4177
         */
 
4178
        if (dev->mtu > ETH_DATA_LEN && hw->chip_id == CHIP_ID_YUKON_EC_U)
 
4179
                features &= ~(NETIF_F_TSO|NETIF_F_SG|NETIF_F_ALL_CSUM);
 
4180
 
 
4181
        return features;
 
4182
}
 
4183
 
 
4184
static int sky2_set_features(struct net_device *dev, u32 features)
4217
4185
{
4218
4186
        struct sky2_port *sky2 = netdev_priv(dev);
4219
 
        unsigned long old_feat = dev->features;
4220
 
        u32 supported = 0;
4221
 
        int rc;
4222
 
 
4223
 
        if (!(sky2->hw->flags & SKY2_HW_RSS_BROKEN))
4224
 
                supported |= ETH_FLAG_RXHASH;
4225
 
 
4226
 
        if (!(sky2->hw->flags & SKY2_HW_VLAN_BROKEN))
4227
 
                supported |= ETH_FLAG_RXVLAN | ETH_FLAG_TXVLAN;
4228
 
 
4229
 
        printk(KERN_DEBUG "sky2 set_flags: supported %x data %x\n",
4230
 
               supported, data);
4231
 
 
4232
 
        rc = ethtool_op_set_flags(dev, data, supported);
4233
 
        if (rc)
4234
 
                return rc;
4235
 
 
4236
 
        if ((old_feat ^ dev->features) & NETIF_F_RXHASH)
4237
 
                rx_set_rss(dev);
4238
 
 
4239
 
        if ((old_feat ^ dev->features) & NETIF_F_ALL_VLAN)
4240
 
                sky2_vlan_mode(dev);
 
4187
        u32 changed = dev->features ^ features;
 
4188
 
 
4189
        if (changed & NETIF_F_RXCSUM) {
 
4190
                u32 on = features & NETIF_F_RXCSUM;
 
4191
                sky2_write32(sky2->hw, Q_ADDR(rxqaddr[sky2->port], Q_CSR),
 
4192
                             on ? BMU_ENA_RX_CHKSUM : BMU_DIS_RX_CHKSUM);
 
4193
        }
 
4194
 
 
4195
        if (changed & NETIF_F_RXHASH)
 
4196
                rx_set_rss(dev, features);
 
4197
 
 
4198
        if (changed & (NETIF_F_HW_VLAN_TX|NETIF_F_HW_VLAN_RX))
 
4199
                sky2_vlan_mode(dev, features);
4241
4200
 
4242
4201
        return 0;
4243
4202
}
4257
4216
        .get_eeprom_len = sky2_get_eeprom_len,
4258
4217
        .get_eeprom     = sky2_get_eeprom,
4259
4218
        .set_eeprom     = sky2_set_eeprom,
4260
 
        .set_sg         = ethtool_op_set_sg,
4261
 
        .set_tx_csum    = sky2_set_tx_csum,
4262
 
        .set_tso        = sky2_set_tso,
4263
 
        .get_rx_csum    = sky2_get_rx_csum,
4264
 
        .set_rx_csum    = sky2_set_rx_csum,
4265
4219
        .get_strings    = sky2_get_strings,
4266
4220
        .get_coalesce   = sky2_get_coalesce,
4267
4221
        .set_coalesce   = sky2_set_coalesce,
4269
4223
        .set_ringparam  = sky2_set_ringparam,
4270
4224
        .get_pauseparam = sky2_get_pauseparam,
4271
4225
        .set_pauseparam = sky2_set_pauseparam,
4272
 
        .phys_id        = sky2_phys_id,
 
4226
        .set_phys_id    = sky2_set_phys_id,
4273
4227
        .get_sset_count = sky2_get_sset_count,
4274
4228
        .get_ethtool_stats = sky2_get_ethtool_stats,
4275
 
        .set_flags      = sky2_set_flags,
4276
 
        .get_flags      = ethtool_op_get_flags,
4277
4229
};
4278
4230
 
4279
4231
#ifdef CONFIG_SKY2_DEBUG
4553
4505
        .ndo_set_mac_address    = sky2_set_mac_address,
4554
4506
        .ndo_set_multicast_list = sky2_set_multicast,
4555
4507
        .ndo_change_mtu         = sky2_change_mtu,
 
4508
        .ndo_fix_features       = sky2_fix_features,
 
4509
        .ndo_set_features       = sky2_set_features,
4556
4510
        .ndo_tx_timeout         = sky2_tx_timeout,
4557
4511
        .ndo_get_stats64        = sky2_get_stats,
4558
4512
#ifdef CONFIG_NET_POLL_CONTROLLER
4568
4522
        .ndo_set_mac_address    = sky2_set_mac_address,
4569
4523
        .ndo_set_multicast_list = sky2_set_multicast,
4570
4524
        .ndo_change_mtu         = sky2_change_mtu,
 
4525
        .ndo_fix_features       = sky2_fix_features,
 
4526
        .ndo_set_features       = sky2_set_features,
4571
4527
        .ndo_tx_timeout         = sky2_tx_timeout,
4572
4528
        .ndo_get_stats64        = sky2_get_stats,
4573
4529
  },
4600
4556
        /* Auto speed and flow control */
4601
4557
        sky2->flags = SKY2_FLAG_AUTO_SPEED | SKY2_FLAG_AUTO_PAUSE;
4602
4558
        if (hw->chip_id != CHIP_ID_YUKON_XL)
4603
 
                sky2->flags |= SKY2_FLAG_RX_CHECKSUM;
 
4559
                dev->hw_features |= NETIF_F_RXCSUM;
4604
4560
 
4605
4561
        sky2->flow_mode = FC_BOTH;
4606
4562
 
4619
4575
 
4620
4576
        sky2->port = port;
4621
4577
 
4622
 
        dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG
4623
 
                | NETIF_F_TSO | NETIF_F_GRO;
 
4578
        dev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO;
4624
4579
 
4625
4580
        if (highmem)
4626
4581
                dev->features |= NETIF_F_HIGHDMA;
4627
4582
 
4628
4583
        /* Enable receive hashing unless hardware is known broken */
4629
4584
        if (!(hw->flags & SKY2_HW_RSS_BROKEN))
4630
 
                dev->features |= NETIF_F_RXHASH;
4631
 
 
4632
 
        if (!(hw->flags & SKY2_HW_VLAN_BROKEN))
4633
 
                dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
 
4585
                dev->hw_features |= NETIF_F_RXHASH;
 
4586
 
 
4587
        if (!(hw->flags & SKY2_HW_VLAN_BROKEN)) {
 
4588
                dev->hw_features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
 
4589
                dev->vlan_features |= SKY2_VLAN_OFFLOADS;
 
4590
        }
 
4591
 
 
4592
        dev->features |= dev->hw_features;
4634
4593
 
4635
4594
        /* read the mac address */
4636
4595
        memcpy_fromio(dev->dev_addr, hw->regs + B2_MAC_1 + port * 8, ETH_ALEN);