~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/net/atl1c/atl1c_main.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
325
325
                }
326
326
        }
327
327
 
328
 
        adapter->work_event |= ATL1C_WORK_EVENT_LINK_CHANGE;
 
328
        set_bit(ATL1C_WORK_EVENT_LINK_CHANGE, &adapter->work_event);
329
329
        schedule_work(&adapter->common_task);
330
330
}
331
331
 
337
337
        adapter = container_of(work, struct atl1c_adapter, common_task);
338
338
        netdev = adapter->netdev;
339
339
 
340
 
        if (adapter->work_event & ATL1C_WORK_EVENT_RESET) {
341
 
                adapter->work_event &= ~ATL1C_WORK_EVENT_RESET;
 
340
        if (test_and_clear_bit(ATL1C_WORK_EVENT_RESET, &adapter->work_event)) {
342
341
                netif_device_detach(netdev);
343
342
                atl1c_down(adapter);
344
343
                atl1c_up(adapter);
345
344
                netif_device_attach(netdev);
346
 
                return;
347
345
        }
348
346
 
349
 
        if (adapter->work_event & ATL1C_WORK_EVENT_LINK_CHANGE) {
350
 
                adapter->work_event &= ~ATL1C_WORK_EVENT_LINK_CHANGE;
 
347
        if (test_and_clear_bit(ATL1C_WORK_EVENT_LINK_CHANGE,
 
348
                &adapter->work_event))
351
349
                atl1c_check_link_status(adapter);
352
 
        }
353
 
        return;
354
350
}
355
351
 
356
352
 
369
365
        struct atl1c_adapter *adapter = netdev_priv(netdev);
370
366
 
371
367
        /* Do the reset outside of interrupt context */
372
 
        adapter->work_event |= ATL1C_WORK_EVENT_RESET;
 
368
        set_bit(ATL1C_WORK_EVENT_RESET, &adapter->work_event);
373
369
        schedule_work(&adapter->common_task);
374
370
}
375
371
 
484
480
        adapter->rx_buffer_len = mtu > AT_RX_BUF_SIZE ?
485
481
                roundup(mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN, 8) : AT_RX_BUF_SIZE;
486
482
}
 
483
 
 
484
static u32 atl1c_fix_features(struct net_device *netdev, u32 features)
 
485
{
 
486
        if (netdev->mtu > MAX_TSO_FRAME_SIZE)
 
487
                features &= ~(NETIF_F_TSO | NETIF_F_TSO6);
 
488
 
 
489
        return features;
 
490
}
 
491
 
487
492
/*
488
493
 * atl1c_change_mtu - Change the Maximum Transfer Unit
489
494
 * @netdev: network interface device structure
510
515
                netdev->mtu = new_mtu;
511
516
                adapter->hw.max_frame_size = new_mtu;
512
517
                atl1c_set_rxbufsize(adapter, netdev);
513
 
                if (new_mtu > MAX_TSO_FRAME_SIZE) {
514
 
                        adapter->netdev->features &= ~NETIF_F_TSO;
515
 
                        adapter->netdev->features &= ~NETIF_F_TSO6;
516
 
                } else {
517
 
                        adapter->netdev->features |= NETIF_F_TSO;
518
 
                        adapter->netdev->features |= NETIF_F_TSO6;
519
 
                }
520
518
                atl1c_down(adapter);
 
519
                netdev_update_features(netdev);
521
520
                atl1c_up(adapter);
522
521
                clear_bit(__AT_RESETTING, &adapter->flags);
523
522
                if (adapter->hw.ctrl_flags & ATL1C_FPGA_VERSION) {
1092
1091
        u32 max_pay_load;
1093
1092
        u16 tx_offload_thresh;
1094
1093
        u32 txq_ctrl_data;
1095
 
        u32 extra_size = 0;     /* Jumbo frame threshold in QWORD unit */
1096
1094
        u32 max_pay_load_data;
1097
1095
 
1098
 
        extra_size = ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN;
1099
1096
        tx_offload_thresh = MAX_TX_OFFLOAD_THRESH;
1100
1097
        AT_WRITE_REG(hw, REG_TX_TSO_OFFLOAD_THRESH,
1101
1098
                (tx_offload_thresh >> 3) & TX_TSO_OFFLOAD_THRESH_MASK);
1102
1099
        AT_READ_REG(hw, REG_DEVICE_CTRL, &dev_ctrl_data);
1103
1100
        max_pay_load  = (dev_ctrl_data >> DEVICE_CTRL_MAX_PAYLOAD_SHIFT) &
1104
1101
                        DEVICE_CTRL_MAX_PAYLOAD_MASK;
1105
 
        hw->dmaw_block = min(max_pay_load, hw->dmaw_block);
 
1102
        hw->dmaw_block = min_t(u32, max_pay_load, hw->dmaw_block);
1106
1103
        max_pay_load  = (dev_ctrl_data >> DEVICE_CTRL_MAX_RREQ_SZ_SHIFT) &
1107
1104
                        DEVICE_CTRL_MAX_RREQ_SZ_MASK;
1108
 
        hw->dmar_block = min(max_pay_load, hw->dmar_block);
 
1105
        hw->dmar_block = min_t(u32, max_pay_load, hw->dmar_block);
1109
1106
 
1110
1107
        txq_ctrl_data = (hw->tpd_burst & TXQ_NUM_TPD_BURST_MASK) <<
1111
1108
                        TXQ_NUM_TPD_BURST_SHIFT;
2540
2537
        return 0;
2541
2538
}
2542
2539
 
 
2540
#ifdef CONFIG_PM_SLEEP
2543
2541
static int atl1c_resume(struct device *dev)
2544
2542
{
2545
2543
        struct pci_dev *pdev = to_pci_dev(dev);
2566
2564
 
2567
2565
        return 0;
2568
2566
}
 
2567
#endif
2569
2568
 
2570
2569
static void atl1c_shutdown(struct pci_dev *pdev)
2571
2570
{
2585
2584
        .ndo_set_mac_address    = atl1c_set_mac_addr,
2586
2585
        .ndo_set_multicast_list = atl1c_set_multi,
2587
2586
        .ndo_change_mtu         = atl1c_change_mtu,
 
2587
        .ndo_fix_features       = atl1c_fix_features,
2588
2588
        .ndo_do_ioctl           = atl1c_ioctl,
2589
2589
        .ndo_tx_timeout         = atl1c_tx_timeout,
2590
2590
        .ndo_get_stats          = atl1c_get_stats,
2605
2605
        atl1c_set_ethtool_ops(netdev);
2606
2606
 
2607
2607
        /* TODO: add when ready */
2608
 
        netdev->features =      NETIF_F_SG         |
 
2608
        netdev->hw_features =   NETIF_F_SG         |
2609
2609
                                NETIF_F_HW_CSUM    |
2610
2610
                                NETIF_F_HW_VLAN_TX |
2611
 
                                NETIF_F_HW_VLAN_RX |
2612
2611
                                NETIF_F_TSO        |
2613
2612
                                NETIF_F_TSO6;
 
2613
        netdev->features =      netdev->hw_features |
 
2614
                                NETIF_F_HW_VLAN_RX;
2614
2615
        return 0;
2615
2616
}
2616
2617
 
2718
2719
                goto err_reset;
2719
2720
        }
2720
2721
 
2721
 
        device_init_wakeup(&pdev->dev, 1);
2722
2722
        /* reset the controller to
2723
2723
         * put the device in a known good starting state */
2724
2724
        err = atl1c_phy_init(&adapter->hw);