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

« back to all changes in this revision

Viewing changes to drivers/net/ixgbevf/ixgbevf_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:
44
44
#include <net/ip6_checksum.h>
45
45
#include <linux/ethtool.h>
46
46
#include <linux/if_vlan.h>
 
47
#include <linux/prefetch.h>
47
48
 
48
49
#include "ixgbevf.h"
49
50
 
50
51
char ixgbevf_driver_name[] = "ixgbevf";
51
52
static const char ixgbevf_driver_string[] =
52
 
        "Intel(R) 82599 Virtual Function";
 
53
        "Intel(R) 10 Gigabit PCI Express Virtual Function Network Driver";
53
54
 
54
 
#define DRV_VERSION "1.0.19-k0"
 
55
#define DRV_VERSION "2.0.0-k2"
55
56
const char ixgbevf_driver_version[] = DRV_VERSION;
56
57
static char ixgbevf_copyright[] =
57
58
        "Copyright (c) 2009 - 2010 Intel Corporation.";
107
108
}
108
109
 
109
110
/*
110
 
 * ixgbe_set_ivar - set the IVAR registers, mapping interrupt causes to vectors
 
111
 * ixgbevf_set_ivar - set IVAR registers - maps interrupt causes to vectors
111
112
 * @adapter: pointer to adapter struct
112
113
 * @direction: 0 for Rx, 1 for Tx, -1 for other causes
113
114
 * @queue: queue to map the corresponding interrupt to
162
163
        /* tx_buffer_info must be completely set up in the transmit path */
163
164
}
164
165
 
165
 
static inline bool ixgbevf_check_tx_hang(struct ixgbevf_adapter *adapter,
166
 
                                         struct ixgbevf_ring *tx_ring,
167
 
                                         unsigned int eop)
168
 
{
169
 
        struct ixgbe_hw *hw = &adapter->hw;
170
 
        u32 head, tail;
171
 
 
172
 
        /* Detect a transmit hang in hardware, this serializes the
173
 
         * check with the clearing of time_stamp and movement of eop */
174
 
        head = readl(hw->hw_addr + tx_ring->head);
175
 
        tail = readl(hw->hw_addr + tx_ring->tail);
176
 
        adapter->detect_tx_hung = false;
177
 
        if ((head != tail) &&
178
 
            tx_ring->tx_buffer_info[eop].time_stamp &&
179
 
            time_after(jiffies, tx_ring->tx_buffer_info[eop].time_stamp + HZ)) {
180
 
                /* detected Tx unit hang */
181
 
                union ixgbe_adv_tx_desc *tx_desc;
182
 
                tx_desc = IXGBE_TX_DESC_ADV(*tx_ring, eop);
183
 
                printk(KERN_ERR "Detected Tx Unit Hang\n"
184
 
                       "  Tx Queue             <%d>\n"
185
 
                       "  TDH, TDT             <%x>, <%x>\n"
186
 
                       "  next_to_use          <%x>\n"
187
 
                       "  next_to_clean        <%x>\n"
188
 
                       "tx_buffer_info[next_to_clean]\n"
189
 
                       "  time_stamp           <%lx>\n"
190
 
                       "  jiffies              <%lx>\n",
191
 
                       tx_ring->queue_index,
192
 
                       head, tail,
193
 
                       tx_ring->next_to_use, eop,
194
 
                       tx_ring->tx_buffer_info[eop].time_stamp, jiffies);
195
 
                return true;
196
 
        }
197
 
 
198
 
        return false;
199
 
}
200
 
 
201
166
#define IXGBE_MAX_TXD_PWR       14
202
167
#define IXGBE_MAX_DATA_PER_TXD  (1 << IXGBE_MAX_TXD_PWR)
203
168
 
293
258
#endif
294
259
        }
295
260
 
296
 
        if (adapter->detect_tx_hung) {
297
 
                if (ixgbevf_check_tx_hang(adapter, tx_ring, i)) {
298
 
                        /* schedule immediate reset if we believe we hung */
299
 
                        printk(KERN_INFO
300
 
                               "tx hang %d detected, resetting adapter\n",
301
 
                               adapter->tx_timeout_count + 1);
302
 
                        ixgbevf_tx_timeout(adapter->netdev);
303
 
                }
304
 
        }
305
 
 
306
261
        /* re-arm the interrupt */
307
262
        if ((count >= tx_ring->work_limit) &&
308
263
            (!test_bit(__IXGBEVF_DOWN, &adapter->state))) {
334
289
        struct ixgbevf_adapter *adapter = q_vector->adapter;
335
290
        bool is_vlan = (status & IXGBE_RXD_STAT_VP);
336
291
        u16 tag = le16_to_cpu(rx_desc->wb.upper.vlan);
337
 
        int ret;
338
292
 
339
293
        if (!(adapter->flags & IXGBE_FLAG_IN_NETPOLL)) {
340
294
                if (adapter->vlgrp && is_vlan)
345
299
                        napi_gro_receive(&q_vector->napi, skb);
346
300
        } else {
347
301
                if (adapter->vlgrp && is_vlan)
348
 
                        ret = vlan_hwaccel_rx(skb, adapter->vlgrp, tag);
 
302
                        vlan_hwaccel_rx(skb, adapter->vlgrp, tag);
349
303
                else
350
 
                        ret = netif_rx(skb);
 
304
                        netif_rx(skb);
351
305
        }
352
306
}
353
307
 
1017
971
}
1018
972
 
1019
973
/**
1020
 
 * ixgbe_msix_clean_rx - single unshared vector rx clean (all queues)
 
974
 * ixgbevf_msix_clean_rx - single unshared vector rx clean (all queues)
1021
975
 * @irq: unused
1022
976
 * @data: pointer to our q_vector struct for this interrupt vector
1023
977
 **/
1507
1461
        }
1508
1462
}
1509
1463
 
 
1464
static int ixgbevf_write_uc_addr_list(struct net_device *netdev)
 
1465
{
 
1466
        struct ixgbevf_adapter *adapter = netdev_priv(netdev);
 
1467
        struct ixgbe_hw *hw = &adapter->hw;
 
1468
        int count = 0;
 
1469
 
 
1470
        if ((netdev_uc_count(netdev)) > 10) {
 
1471
                printk(KERN_ERR "Too many unicast filters - No Space\n");
 
1472
                return -ENOSPC;
 
1473
        }
 
1474
 
 
1475
        if (!netdev_uc_empty(netdev)) {
 
1476
                struct netdev_hw_addr *ha;
 
1477
                netdev_for_each_uc_addr(ha, netdev) {
 
1478
                        hw->mac.ops.set_uc_addr(hw, ++count, ha->addr);
 
1479
                        udelay(200);
 
1480
                }
 
1481
        } else {
 
1482
                /*
 
1483
                 * If the list is empty then send message to PF driver to
 
1484
                 * clear all macvlans on this VF.
 
1485
                 */
 
1486
                hw->mac.ops.set_uc_addr(hw, 0, NULL);
 
1487
        }
 
1488
 
 
1489
        return count;
 
1490
}
 
1491
 
1510
1492
/**
1511
1493
 * ixgbevf_set_rx_mode - Multicast set
1512
1494
 * @netdev: network interface device structure
1523
1505
        /* reprogram multicast list */
1524
1506
        if (hw->mac.ops.update_mc_addr_list)
1525
1507
                hw->mac.ops.update_mc_addr_list(hw, netdev);
 
1508
 
 
1509
        ixgbevf_write_uc_addr_list(netdev);
1526
1510
}
1527
1511
 
1528
1512
static void ixgbevf_napi_enable_all(struct ixgbevf_adapter *adapter)
1665
1649
                j = adapter->rx_ring[i].reg_idx;
1666
1650
                rxdctl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(j));
1667
1651
                rxdctl |= IXGBE_RXDCTL_ENABLE;
 
1652
                if (hw->mac.type == ixgbe_mac_X540_vf) {
 
1653
                        rxdctl &= ~IXGBE_RXDCTL_RLPMLMASK;
 
1654
                        rxdctl |= ((netdev->mtu + ETH_HLEN + ETH_FCS_LEN) |
 
1655
                                   IXGBE_RXDCTL_RLPML_EN);
 
1656
                }
1668
1657
                IXGBE_WRITE_REG(hw, IXGBE_VFRXDCTL(j), rxdctl);
1669
1658
                ixgbevf_rx_desc_queue_enable(adapter, i);
1670
1659
        }
1967
1956
}
1968
1957
 
1969
1958
/*
1970
 
 * ixgbe_set_num_queues: Allocate queues for device, feature dependant
 
1959
 * ixgbevf_set_num_queues: Allocate queues for device, feature dependent
1971
1960
 * @adapter: board private structure to initialize
1972
1961
 *
1973
1962
 * This is the top level queue allocation routine.  The order here is very
2216
2205
 
2217
2206
        hw->vendor_id = pdev->vendor;
2218
2207
        hw->device_id = pdev->device;
2219
 
        pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id);
 
2208
        hw->revision_id = pdev->revision;
2220
2209
        hw->subsystem_vendor_id = pdev->subsystem_vendor;
2221
2210
        hw->subsystem_device_id = pdev->subsystem_device;
2222
2211
 
2410
2399
                               10 : 1);
2411
2400
                        netif_carrier_on(netdev);
2412
2401
                        netif_tx_wake_all_queues(netdev);
2413
 
                } else {
2414
 
                        /* Force detection of hung controller */
2415
 
                        adapter->detect_tx_hung = true;
2416
2402
                }
2417
2403
        } else {
2418
2404
                adapter->link_up = false;
2427
2413
        ixgbevf_update_stats(adapter);
2428
2414
 
2429
2415
pf_has_reset:
2430
 
        /* Force detection of hung controller every watchdog period */
2431
 
        adapter->detect_tx_hung = true;
2432
 
 
2433
2416
        /* Reset the timer */
2434
2417
        if (!test_bit(__IXGBEVF_DOWN, &adapter->state))
2435
2418
                mod_timer(&adapter->watchdog_timer,
3217
3200
static int ixgbevf_change_mtu(struct net_device *netdev, int new_mtu)
3218
3201
{
3219
3202
        struct ixgbevf_adapter *adapter = netdev_priv(netdev);
 
3203
        struct ixgbe_hw *hw = &adapter->hw;
3220
3204
        int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN;
 
3205
        int max_possible_frame = MAXIMUM_ETHERNET_VLAN_SIZE;
 
3206
        u32 msg[2];
 
3207
 
 
3208
        if (adapter->hw.mac.type == ixgbe_mac_X540_vf)
 
3209
                max_possible_frame = IXGBE_MAX_JUMBO_FRAME_SIZE;
3221
3210
 
3222
3211
        /* MTU < 68 is an error and causes problems on some kernels */
3223
 
        if ((new_mtu < 68) || (max_frame > MAXIMUM_ETHERNET_VLAN_SIZE))
 
3212
        if ((new_mtu < 68) || (max_frame > max_possible_frame))
3224
3213
                return -EINVAL;
3225
3214
 
3226
3215
        hw_dbg(&adapter->hw, "changing MTU from %d to %d\n",
3228
3217
        /* must set new MTU before calling down or up */
3229
3218
        netdev->mtu = new_mtu;
3230
3219
 
 
3220
        msg[0] = IXGBE_VF_SET_LPE;
 
3221
        msg[1] = max_frame;
 
3222
        hw->mbx.ops.write_posted(hw, msg, 2);
 
3223
 
3231
3224
        if (netif_running(netdev))
3232
3225
                ixgbevf_reinit_locked(adapter);
3233
3226
 
3272
3265
 
3273
3266
static void ixgbevf_assign_netdev_ops(struct net_device *dev)
3274
3267
{
3275
 
        struct ixgbevf_adapter *adapter;
3276
 
        adapter = netdev_priv(dev);
3277
3268
        dev->netdev_ops = &ixgbe_netdev_ops;
3278
3269
        ixgbevf_set_ethtool_ops(dev);
3279
3270
        dev->watchdog_timeo = 5 * HZ;
3519
3510
};
3520
3511
 
3521
3512
/**
3522
 
 * ixgbe_init_module - Driver Registration Routine
 
3513
 * ixgbevf_init_module - Driver Registration Routine
3523
3514
 *
3524
 
 * ixgbe_init_module is the first routine called when the driver is
 
3515
 * ixgbevf_init_module is the first routine called when the driver is
3525
3516
 * loaded. All it does is register with the PCI subsystem.
3526
3517
 **/
3527
3518
static int __init ixgbevf_init_module(void)
3539
3530
module_init(ixgbevf_init_module);
3540
3531
 
3541
3532
/**
3542
 
 * ixgbe_exit_module - Driver Exit Cleanup Routine
 
3533
 * ixgbevf_exit_module - Driver Exit Cleanup Routine
3543
3534
 *
3544
 
 * ixgbe_exit_module is called just before the driver is removed
 
3535
 * ixgbevf_exit_module is called just before the driver is removed
3545
3536
 * from memory.
3546
3537
 **/
3547
3538
static void __exit ixgbevf_exit_module(void)
3551
3542
 
3552
3543
#ifdef DEBUG
3553
3544
/**
3554
 
 * ixgbe_get_hw_dev_name - return device name string
 
3545
 * ixgbevf_get_hw_dev_name - return device name string
3555
3546
 * used by hardware layer to print debugging information
3556
3547
 **/
3557
3548
char *ixgbevf_get_hw_dev_name(struct ixgbe_hw *hw)