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);
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)
1208
1208
struct sky2_port *sky2 = netdev_priv(dev);
1209
1209
struct sky2_hw *hw = sky2->hw;
1218
1218
/* Program RSS initial values */
1219
if (dev->features & NETIF_F_RXHASH) {
1219
if (features & NETIF_F_RXHASH) {
1220
1220
u32 key[nkeys];
1222
1222
get_random_bytes(key, nkeys * sizeof(u32));
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)
1327
static void sky2_vlan_mode(struct net_device *dev)
1327
static void sky2_vlan_mode(struct net_device *dev, u32 features)
1329
1329
struct sky2_port *sky2 = netdev_priv(dev);
1330
1330
struct sky2_hw *hw = sky2->hw;
1331
1331
u16 port = sky2->port;
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);
1337
1337
sky2_write32(hw, SK_REG(port, RX_GMF_CTRL_T),
1338
1338
RX_VLAN_STRIP_OFF);
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
dev->vlan_features |= SKY2_VLAN_OFFLOADS;
1345
1346
sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T),
1346
1347
TX_VLAN_TAG_OFF);
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;
1463
1463
rx_set_checksum(sky2);
1465
1465
if (!(hw->flags & SKY2_HW_RSS_BROKEN))
1466
rx_set_rss(sky2->netdev);
1466
rx_set_rss(sky2->netdev, sky2->netdev->features);
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);
1629
sky2_vlan_mode(sky2->netdev);
1629
sky2_vlan_mode(sky2->netdev, sky2->netdev->features);
1630
netdev_update_features(sky2->netdev);
1631
1632
sky2_rx_start(sky2);
2261
2262
hw->chip_id == CHIP_ID_YUKON_FE_P))
2262
2263
return -EINVAL;
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);
2268
2265
if (!netif_running(dev)) {
2269
2266
dev->mtu = new_mtu;
2267
netdev_update_features(dev);
2535
2534
"%s: receive checksum problem (status = %#x)\n",
2536
2535
sky2->netdev->name, status);
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
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);
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;
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;
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;
3552
3555
{ "tx_fifo_underrun", GM_TXE_FIFO_UR },
3555
static u32 sky2_get_rx_csum(struct net_device *dev)
3557
struct sky2_port *sky2 = netdev_priv(dev);
3559
return !!(sky2->flags & SKY2_FLAG_RX_CHECKSUM);
3562
static int sky2_set_rx_csum(struct net_device *dev, u32 data)
3564
struct sky2_port *sky2 = netdev_priv(dev);
3567
sky2->flags |= SKY2_FLAG_RX_CHECKSUM;
3569
sky2->flags &= ~SKY2_FLAG_RX_CHECKSUM;
3571
sky2_write32(sky2->hw, Q_ADDR(rxqaddr[sky2->port], Q_CSR),
3572
data ? BMU_ENA_RX_CHKSUM : BMU_DIS_RX_CHKSUM);
3577
3558
static u32 sky2_get_msglevel(struct net_device *netdev)
3579
3560
struct sky2_port *sky2 = netdev_priv(netdev);
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)
3831
3813
struct sky2_port *sky2 = netdev_priv(dev);
3837
for (i = 0; i < data; i++) {
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);
3838
3822
sky2_led(sky2, MO_LED_ON);
3839
if (msleep_interruptible(500))
3824
case ETHTOOL_ID_OFF:
3841
3825
sky2_led(sky2, MO_LED_OFF);
3842
if (msleep_interruptible(500))
3845
sky2_led(sky2, MO_LED_NORM);
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.
4089
static int no_tx_offload(struct net_device *dev)
4091
const struct sky2_port *sky2 = netdev_priv(dev);
4092
const struct sky2_hw *hw = sky2->hw;
4094
return dev->mtu > ETH_DATA_LEN && hw->chip_id == CHIP_ID_YUKON_EC_U;
4097
static int sky2_set_tx_csum(struct net_device *dev, u32 data)
4099
if (data && no_tx_offload(dev))
4102
return ethtool_op_set_tx_csum(dev, data);
4106
static int sky2_set_tso(struct net_device *dev, u32 data)
4108
if (data && no_tx_offload(dev))
4111
return ethtool_op_set_tso(dev, data);
4114
4068
static int sky2_get_eeprom_len(struct net_device *dev)
4116
4070
struct sky2_port *sky2 = netdev_priv(dev);
4213
4167
return sky2_vpd_write(sky2->hw, cap, data, eeprom->offset, eeprom->len);
4216
static int sky2_set_flags(struct net_device *dev, u32 data)
4170
static u32 sky2_fix_features(struct net_device *dev, u32 features)
4172
const struct sky2_port *sky2 = netdev_priv(dev);
4173
const struct sky2_hw *hw = sky2->hw;
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.
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);
4184
static int sky2_set_features(struct net_device *dev, u32 features)
4218
4186
struct sky2_port *sky2 = netdev_priv(dev);
4219
unsigned long old_feat = dev->features;
4223
if (!(sky2->hw->flags & SKY2_HW_RSS_BROKEN))
4224
supported |= ETH_FLAG_RXHASH;
4226
if (!(sky2->hw->flags & SKY2_HW_VLAN_BROKEN))
4227
supported |= ETH_FLAG_RXVLAN | ETH_FLAG_TXVLAN;
4229
printk(KERN_DEBUG "sky2 set_flags: supported %x data %x\n",
4232
rc = ethtool_op_set_flags(dev, data, supported);
4236
if ((old_feat ^ dev->features) & NETIF_F_RXHASH)
4239
if ((old_feat ^ dev->features) & NETIF_F_ALL_VLAN)
4240
sky2_vlan_mode(dev);
4187
u32 changed = dev->features ^ features;
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);
4195
if (changed & NETIF_F_RXHASH)
4196
rx_set_rss(dev, features);
4198
if (changed & (NETIF_F_HW_VLAN_TX|NETIF_F_HW_VLAN_RX))
4199
sky2_vlan_mode(dev, features);
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,
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,
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;
4605
4561
sky2->flow_mode = FC_BOTH;
4620
4576
sky2->port = port;
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;
4626
4581
dev->features |= NETIF_F_HIGHDMA;
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;
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;
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;
4592
dev->features |= dev->hw_features;
4635
4594
/* read the mac address */
4636
4595
memcpy_fromio(dev->dev_addr, hw->regs + B2_MAC_1 + port * 8, ETH_ALEN);