~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/net/ixgbe/ixgbe_main.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno
  • Date: 2011-06-07 12:14:05 UTC
  • mfrom: (43.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110607121405-i3h1rd7nrnd2b73h
Tags: 2.6.39-2
[ Ben Hutchings ]
* [x86] Enable BACKLIGHT_APPLE, replacing BACKLIGHT_MBP_NVIDIA
  (Closes: #627492)
* cgroups: Disable memory resource controller by default. Allow it
  to be enabled using kernel parameter 'cgroup_enable=memory'.
* rt2800usb: Enable support for more USB devices including
  Linksys WUSB600N (Closes: #596626) (this change was accidentally
  omitted from 2.6.39-1)
* [x86] Remove Celeron from list of processors supporting PAE. Most
  'Celeron M' models do not.
* Update debconf template translations:
  - Swedish (Martin Bagge) (Closes: #628932)
  - French (David Prévot) (Closes: #628191)
* aufs: Update for 2.6.39 (Closes: #627837)
* Add stable 2.6.39.1, including:
  - ext4: dont set PageUptodate in ext4_end_bio()
  - pata_cmd64x: fix boot crash on parisc (Closes: #622997, #622745)
  - ext3: Fix fs corruption when make_indexed_dir() fails
  - netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages
  - sctp: fix race between sctp_bind_addr_free() and
    sctp_bind_addr_conflict()
  - sctp: fix memory leak of the ASCONF queue when free asoc
  - md/bitmap: fix saving of events_cleared and other state
  - cdc_acm: Fix oops when Droids MuIn LCD is connected
  - cx88: Fix conversion from BKL to fine-grained locks (Closes: #619827)
  - keys: Set cred->user_ns in key_replace_session_keyring (CVE-2011-2184)
  - tmpfs: fix race between truncate and writepage
  - nfs41: Correct offset for LAYOUTCOMMIT
  - xen/mmu: fix a race window causing leave_mm BUG()
  - ext4: fix possible use-after-free in ext4_remove_li_request()
  For the complete list of changes, see:
   http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.39.1
* Bump ABI to 2
* netfilter: Enable IP_SET, IP_SET_BITMAP_IP, IP_SET_BITMAP_IPMAC,
  IP_SET_BITMAP_PORT, IP_SET_HASH_IP, IP_SET_HASH_IPPORT,
  IP_SET_HASH_IPPORTIP, IP_SET_HASH_IPPORTNET, IP_SET_HASH_NET,
  IP_SET_HASH_NETPORT, IP_SET_LIST_SET, NETFILTER_XT_SET as modules
  (Closes: #629401)

[ Aurelien Jarno ]
* [mipsel/loongson-2f] Disable_SCSI_LPFC to workaround GCC ICE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*******************************************************************************
2
2
 
3
3
  Intel 10 Gigabit PCI Express Linux driver
4
 
  Copyright(c) 1999 - 2010 Intel Corporation.
 
4
  Copyright(c) 1999 - 2011 Intel Corporation.
5
5
 
6
6
  This program is free software; you can redistribute it and/or modify it
7
7
  under the terms and conditions of the GNU General Public License,
54
54
 
55
55
#define DRV_VERSION "3.2.9-k2"
56
56
const char ixgbe_driver_version[] = DRV_VERSION;
57
 
static char ixgbe_copyright[] = "Copyright (c) 1999-2010 Intel Corporation.";
 
57
static const char ixgbe_copyright[] =
 
58
                                "Copyright (c) 1999-2011 Intel Corporation.";
58
59
 
59
60
static const struct ixgbe_info *ixgbe_info_tbl[] = {
60
61
        [board_82598] = &ixgbe_82598_info,
643
644
 * @adapter: driver private struct
644
645
 * @index: reg idx of queue to query (0-127)
645
646
 *
646
 
 * Helper function to determine the traffic index for a paticular
 
647
 * Helper function to determine the traffic index for a particular
647
648
 * register index.
648
649
 *
649
650
 * Returns : a tc index for use in range 0-7, or 0-3
650
651
 */
651
 
u8 ixgbe_dcb_txq_to_tc(struct ixgbe_adapter *adapter, u8 reg_idx)
 
652
static u8 ixgbe_dcb_txq_to_tc(struct ixgbe_adapter *adapter, u8 reg_idx)
652
653
{
653
654
        int tc = -1;
654
 
        int dcb_i = adapter->ring_feature[RING_F_DCB].indices;
 
655
        int dcb_i = netdev_get_num_tc(adapter->netdev);
655
656
 
656
657
        /* if DCB is not enabled the queues have no TC */
657
658
        if (!(adapter->flags & IXGBE_FLAG_DCB_ENABLED))
2597
2598
 
2598
2599
                i--;
2599
2600
                for (; i >= 0; i--) {
 
2601
                        /* free only the irqs that were actually requested */
 
2602
                        if (!adapter->q_vector[i]->rxr_count &&
 
2603
                            !adapter->q_vector[i]->txr_count)
 
2604
                                continue;
 
2605
 
2600
2606
                        free_irq(adapter->msix_entries[i].vector,
2601
2607
                                 adapter->q_vector[i]);
2602
2608
                }
2886
2892
                                        );
2887
2893
 
2888
2894
        switch (mask) {
 
2895
#ifdef CONFIG_IXGBE_DCB
 
2896
        case (IXGBE_FLAG_DCB_ENABLED | IXGBE_FLAG_RSS_ENABLED):
 
2897
                mrqc = IXGBE_MRQC_RTRSS8TCEN;
 
2898
                break;
 
2899
        case (IXGBE_FLAG_DCB_ENABLED):
 
2900
                mrqc = IXGBE_MRQC_RT8TCEN;
 
2901
                break;
 
2902
#endif /* CONFIG_IXGBE_DCB */
2889
2903
        case (IXGBE_FLAG_RSS_ENABLED):
2890
2904
                mrqc = IXGBE_MRQC_RSSEN;
2891
2905
                break;
2892
2906
        case (IXGBE_FLAG_SRIOV_ENABLED):
2893
2907
                mrqc = IXGBE_MRQC_VMDQEN;
2894
2908
                break;
2895
 
#ifdef CONFIG_IXGBE_DCB
2896
 
        case (IXGBE_FLAG_DCB_ENABLED):
2897
 
                mrqc = IXGBE_MRQC_RT8TCEN;
2898
 
                break;
2899
 
#endif /* CONFIG_IXGBE_DCB */
2900
2909
        default:
2901
2910
                break;
2902
2911
        }
3077
3086
        ixgbe_configure_srrctl(adapter, ring);
3078
3087
        ixgbe_configure_rscctl(adapter, ring);
3079
3088
 
 
3089
        /* If operating in IOV mode set RLPML for X540 */
 
3090
        if ((adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) &&
 
3091
            hw->mac.type == ixgbe_mac_X540) {
 
3092
                rxdctl &= ~IXGBE_RXDCTL_RLPMLMASK;
 
3093
                rxdctl |= ((ring->netdev->mtu + ETH_HLEN +
 
3094
                            ETH_FCS_LEN + VLAN_HLEN) | IXGBE_RXDCTL_RLPML_EN);
 
3095
        }
 
3096
 
3080
3097
        if (hw->mac.type == ixgbe_mac_82598EB) {
3081
3098
                /*
3082
3099
                 * enable cache line friendly hardware writes:
3539
3556
                } else {
3540
3557
                        /*
3541
3558
                         * Write addresses to the MTA, if the attempt fails
3542
 
                         * then we should just turn on promiscous mode so
 
3559
                         * then we should just turn on promiscuous mode so
3543
3560
                         * that we can at least receive multicast traffic
3544
3561
                         */
3545
3562
                        hw->mac.ops.update_mc_addr_list(hw, netdev);
3550
3567
                /*
3551
3568
                 * Write addresses to available RAR registers, if there is not
3552
3569
                 * sufficient space to store all the addresses then enable
3553
 
                 * unicast promiscous mode
 
3570
                 * unicast promiscuous mode
3554
3571
                 */
3555
3572
                count = ixgbe_write_uc_addr_list(netdev);
3556
3573
                if (count < 0) {
3641
3658
        if (hw->mac.type == ixgbe_mac_82598EB)
3642
3659
                netif_set_gso_max_size(adapter->netdev, 32768);
3643
3660
 
3644
 
#ifdef CONFIG_FCOE
3645
 
        if (adapter->netdev->features & NETIF_F_FCOE_MTU)
3646
 
                max_frame = max(max_frame, IXGBE_FCOE_JUMBO_FRAME_SIZE);
3647
 
#endif
3648
 
 
3649
 
        ixgbe_dcb_calculate_tc_credits(hw, &adapter->dcb_cfg, max_frame,
3650
 
                                        DCB_TX_CONFIG);
3651
 
        ixgbe_dcb_calculate_tc_credits(hw, &adapter->dcb_cfg, max_frame,
3652
 
                                        DCB_RX_CONFIG);
3653
3661
 
3654
3662
        /* Enable VLAN tag insert/strip */
3655
3663
        adapter->netdev->features |= NETIF_F_HW_VLAN_RX;
3657
3665
        hw->mac.ops.set_vfta(&adapter->hw, 0, 0, true);
3658
3666
 
3659
3667
        /* reconfigure the hardware */
3660
 
        ixgbe_dcb_hw_config(hw, &adapter->dcb_cfg);
 
3668
        if (adapter->dcbx_cap & (DCB_CAP_DCBX_HOST | DCB_CAP_DCBX_VER_CEE)) {
 
3669
#ifdef CONFIG_FCOE
 
3670
                if (adapter->netdev->features & NETIF_F_FCOE_MTU)
 
3671
                        max_frame = max(max_frame, IXGBE_FCOE_JUMBO_FRAME_SIZE);
 
3672
#endif
 
3673
                ixgbe_dcb_calculate_tc_credits(hw, &adapter->dcb_cfg, max_frame,
 
3674
                                                DCB_TX_CONFIG);
 
3675
                ixgbe_dcb_calculate_tc_credits(hw, &adapter->dcb_cfg, max_frame,
 
3676
                                                DCB_RX_CONFIG);
 
3677
                ixgbe_dcb_hw_config(hw, &adapter->dcb_cfg);
 
3678
        } else {
 
3679
                struct net_device *dev = adapter->netdev;
 
3680
 
 
3681
                if (adapter->ixgbe_ieee_ets)
 
3682
                        dev->dcbnl_ops->ieee_setets(dev,
 
3683
                                                    adapter->ixgbe_ieee_ets);
 
3684
                if (adapter->ixgbe_ieee_pfc)
 
3685
                        dev->dcbnl_ops->ieee_setpfc(dev,
 
3686
                                                    adapter->ixgbe_ieee_pfc);
 
3687
        }
 
3688
 
 
3689
        /* Enable RSS Hash per TC */
 
3690
        if (hw->mac.type != ixgbe_mac_82598EB) {
 
3691
                int i;
 
3692
                u32 reg = 0;
 
3693
 
 
3694
                for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
 
3695
                        u8 msb = 0;
 
3696
                        u8 cnt = adapter->netdev->tc_to_txq[i].count;
 
3697
 
 
3698
                        while (cnt >>= 1)
 
3699
                                msb++;
 
3700
 
 
3701
                        reg |= msb << IXGBE_RQTC_SHIFT_TC(i);
 
3702
                }
 
3703
                IXGBE_WRITE_REG(hw, IXGBE_RQTC, reg);
 
3704
        }
3661
3705
}
3662
3706
 
3663
3707
#endif
3761
3805
        if (ret)
3762
3806
                goto link_cfg_out;
3763
3807
 
3764
 
        if (hw->mac.ops.get_link_capabilities)
 
3808
        autoneg = hw->phy.autoneg_advertised;
 
3809
        if ((!autoneg) && (hw->mac.ops.get_link_capabilities))
3765
3810
                ret = hw->mac.ops.get_link_capabilities(hw, &autoneg,
3766
3811
                                                        &negotiation);
3767
3812
        if (ret)
3876
3921
         * If we're not hot-pluggable SFP+, we just need to configure link
3877
3922
         * and bring it up.
3878
3923
         */
3879
 
        if (hw->phy.type == ixgbe_phy_unknown)
 
3924
        if (hw->phy.type == ixgbe_phy_none)
3880
3925
                schedule_work(&adapter->sfp_config_module_task);
3881
3926
 
3882
3927
        /* enable transmits */
4243
4288
        ixgbe_reinit_locked(adapter);
4244
4289
}
4245
4290
 
4246
 
#ifdef CONFIG_IXGBE_DCB
4247
 
static inline bool ixgbe_set_dcb_queues(struct ixgbe_adapter *adapter)
4248
 
{
4249
 
        bool ret = false;
4250
 
        struct ixgbe_ring_feature *f = &adapter->ring_feature[RING_F_DCB];
4251
 
 
4252
 
        if (!(adapter->flags & IXGBE_FLAG_DCB_ENABLED))
4253
 
                return ret;
4254
 
 
4255
 
        f->mask = 0x7 << 3;
4256
 
        adapter->num_rx_queues = f->indices;
4257
 
        adapter->num_tx_queues = f->indices;
4258
 
        ret = true;
4259
 
 
4260
 
        return ret;
4261
 
}
4262
 
#endif
4263
 
 
4264
4291
/**
4265
4292
 * ixgbe_set_rss_queues: Allocate queues for RSS
4266
4293
 * @adapter: board private structure to initialize
4331
4358
 **/
4332
4359
static inline bool ixgbe_set_fcoe_queues(struct ixgbe_adapter *adapter)
4333
4360
{
4334
 
        bool ret = false;
4335
4361
        struct ixgbe_ring_feature *f = &adapter->ring_feature[RING_F_FCOE];
4336
4362
 
4337
 
        f->indices = min((int)num_online_cpus(), f->indices);
4338
 
        if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) {
 
4363
        if (!(adapter->flags & IXGBE_FLAG_FCOE_ENABLED))
 
4364
                return false;
 
4365
 
 
4366
        if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
 
4367
#ifdef CONFIG_IXGBE_DCB
 
4368
                int tc;
 
4369
                struct net_device *dev = adapter->netdev;
 
4370
 
 
4371
                tc = netdev_get_prio_tc_map(dev, adapter->fcoe.up);
 
4372
                f->indices = dev->tc_to_txq[tc].count;
 
4373
                f->mask = dev->tc_to_txq[tc].offset;
 
4374
#endif
 
4375
        } else {
 
4376
                f->indices = min((int)num_online_cpus(), f->indices);
 
4377
 
4339
4378
                adapter->num_rx_queues = 1;
4340
4379
                adapter->num_tx_queues = 1;
4341
 
#ifdef CONFIG_IXGBE_DCB
4342
 
                if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
4343
 
                        e_info(probe, "FCoE enabled with DCB\n");
4344
 
                        ixgbe_set_dcb_queues(adapter);
4345
 
                }
4346
 
#endif
 
4380
 
4347
4381
                if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) {
4348
4382
                        e_info(probe, "FCoE enabled with RSS\n");
4349
4383
                        if ((adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) ||
4356
4390
                f->mask = adapter->num_rx_queues;
4357
4391
                adapter->num_rx_queues += f->indices;
4358
4392
                adapter->num_tx_queues += f->indices;
4359
 
 
4360
 
                ret = true;
4361
 
        }
 
4393
        }
 
4394
 
 
4395
        return true;
 
4396
}
 
4397
#endif /* IXGBE_FCOE */
 
4398
 
 
4399
#ifdef CONFIG_IXGBE_DCB
 
4400
static inline bool ixgbe_set_dcb_queues(struct ixgbe_adapter *adapter)
 
4401
{
 
4402
        bool ret = false;
 
4403
        struct ixgbe_ring_feature *f = &adapter->ring_feature[RING_F_DCB];
 
4404
        int i, q;
 
4405
 
 
4406
        if (!(adapter->flags & IXGBE_FLAG_DCB_ENABLED))
 
4407
                return ret;
 
4408
 
 
4409
        f->indices = 0;
 
4410
        for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
 
4411
                q = min((int)num_online_cpus(), MAX_TRAFFIC_CLASS);
 
4412
                f->indices += q;
 
4413
        }
 
4414
 
 
4415
        f->mask = 0x7 << 3;
 
4416
        adapter->num_rx_queues = f->indices;
 
4417
        adapter->num_tx_queues = f->indices;
 
4418
        ret = true;
 
4419
 
 
4420
#ifdef IXGBE_FCOE
 
4421
        /* FCoE enabled queues require special configuration done through
 
4422
         * configure_fcoe() and others. Here we map FCoE indices onto the
 
4423
         * DCB queue pairs allowing FCoE to own configuration later.
 
4424
         */
 
4425
        ixgbe_set_fcoe_queues(adapter);
 
4426
#endif
4362
4427
 
4363
4428
        return ret;
4364
4429
}
 
4430
#endif
4365
4431
 
4366
 
#endif /* IXGBE_FCOE */
4367
4432
/**
4368
4433
 * ixgbe_set_sriov_queues: Allocate queues for IOV use
4369
4434
 * @adapter: board private structure to initialize
4378
4443
}
4379
4444
 
4380
4445
/*
4381
 
 * ixgbe_set_num_queues: Allocate queues for device, feature dependant
 
4446
 * ixgbe_set_num_queues: Allocate queues for device, feature dependent
4382
4447
 * @adapter: board private structure to initialize
4383
4448
 *
4384
4449
 * This is the top level queue allocation routine.  The order here is very
4399
4464
        if (ixgbe_set_sriov_queues(adapter))
4400
4465
                goto done;
4401
4466
 
 
4467
#ifdef CONFIG_IXGBE_DCB
 
4468
        if (ixgbe_set_dcb_queues(adapter))
 
4469
                goto done;
 
4470
 
 
4471
#endif
4402
4472
#ifdef IXGBE_FCOE
4403
4473
        if (ixgbe_set_fcoe_queues(adapter))
4404
4474
                goto done;
4405
4475
 
4406
4476
#endif /* IXGBE_FCOE */
4407
 
#ifdef CONFIG_IXGBE_DCB
4408
 
        if (ixgbe_set_dcb_queues(adapter))
4409
 
                goto done;
4410
 
 
4411
 
#endif
4412
4477
        if (ixgbe_set_fdir_queues(adapter))
4413
4478
                goto done;
4414
4479
 
4500
4565
}
4501
4566
 
4502
4567
#ifdef CONFIG_IXGBE_DCB
 
4568
 
 
4569
/* ixgbe_get_first_reg_idx - Return first register index associated with ring */
 
4570
void ixgbe_get_first_reg_idx(struct ixgbe_adapter *adapter, u8 tc,
 
4571
                             unsigned int *tx, unsigned int *rx)
 
4572
{
 
4573
        struct net_device *dev = adapter->netdev;
 
4574
        struct ixgbe_hw *hw = &adapter->hw;
 
4575
        u8 num_tcs = netdev_get_num_tc(dev);
 
4576
 
 
4577
        *tx = 0;
 
4578
        *rx = 0;
 
4579
 
 
4580
        switch (hw->mac.type) {
 
4581
        case ixgbe_mac_82598EB:
 
4582
                *tx = tc << 3;
 
4583
                *rx = tc << 2;
 
4584
                break;
 
4585
        case ixgbe_mac_82599EB:
 
4586
        case ixgbe_mac_X540:
 
4587
                if (num_tcs == 8) {
 
4588
                        if (tc < 3) {
 
4589
                                *tx = tc << 5;
 
4590
                                *rx = tc << 4;
 
4591
                        } else if (tc <  5) {
 
4592
                                *tx = ((tc + 2) << 4);
 
4593
                                *rx = tc << 4;
 
4594
                        } else if (tc < num_tcs) {
 
4595
                                *tx = ((tc + 8) << 3);
 
4596
                                *rx = tc << 4;
 
4597
                        }
 
4598
                } else if (num_tcs == 4) {
 
4599
                        *rx =  tc << 5;
 
4600
                        switch (tc) {
 
4601
                        case 0:
 
4602
                                *tx =  0;
 
4603
                                break;
 
4604
                        case 1:
 
4605
                                *tx = 64;
 
4606
                                break;
 
4607
                        case 2:
 
4608
                                *tx = 96;
 
4609
                                break;
 
4610
                        case 3:
 
4611
                                *tx = 112;
 
4612
                                break;
 
4613
                        default:
 
4614
                                break;
 
4615
                        }
 
4616
                }
 
4617
                break;
 
4618
        default:
 
4619
                break;
 
4620
        }
 
4621
}
 
4622
 
 
4623
#define IXGBE_MAX_Q_PER_TC      (IXGBE_MAX_DCB_INDICES / MAX_TRAFFIC_CLASS)
 
4624
 
 
4625
/* ixgbe_setup_tc - routine to configure net_device for multiple traffic
 
4626
 * classes.
 
4627
 *
 
4628
 * @netdev: net device to configure
 
4629
 * @tc: number of traffic classes to enable
 
4630
 */
 
4631
int ixgbe_setup_tc(struct net_device *dev, u8 tc)
 
4632
{
 
4633
        int i;
 
4634
        unsigned int q, offset = 0;
 
4635
 
 
4636
        if (!tc) {
 
4637
                netdev_reset_tc(dev);
 
4638
        } else {
 
4639
                struct ixgbe_adapter *adapter = netdev_priv(dev);
 
4640
 
 
4641
                /* Hardware supports up to 8 traffic classes */
 
4642
                if (tc > MAX_TRAFFIC_CLASS || netdev_set_num_tc(dev, tc))
 
4643
                        return -EINVAL;
 
4644
 
 
4645
                /* Partition Tx queues evenly amongst traffic classes */
 
4646
                for (i = 0; i < tc; i++) {
 
4647
                        q = min((int)num_online_cpus(), IXGBE_MAX_Q_PER_TC);
 
4648
                        netdev_set_prio_tc_map(dev, i, i);
 
4649
                        netdev_set_tc_queue(dev, i, q, offset);
 
4650
                        offset += q;
 
4651
                }
 
4652
 
 
4653
                /* This enables multiple traffic class support in the hardware
 
4654
                 * which defaults to strict priority transmission by default.
 
4655
                 * If traffic classes are already enabled perhaps through DCB
 
4656
                 * code path then existing configuration will be used.
 
4657
                 */
 
4658
                if (!(adapter->flags & IXGBE_FLAG_DCB_ENABLED) &&
 
4659
                    dev->dcbnl_ops && dev->dcbnl_ops->setdcbx) {
 
4660
                        struct ieee_ets ets = {
 
4661
                                        .prio_tc = {0, 1, 2, 3, 4, 5, 6, 7},
 
4662
                                              };
 
4663
                        u8 mode = DCB_CAP_DCBX_HOST | DCB_CAP_DCBX_VER_IEEE;
 
4664
 
 
4665
                        dev->dcbnl_ops->setdcbx(dev, mode);
 
4666
                        dev->dcbnl_ops->ieee_setets(dev, &ets);
 
4667
                }
 
4668
        }
 
4669
        return 0;
 
4670
}
 
4671
 
4503
4672
/**
4504
4673
 * ixgbe_cache_ring_dcb - Descriptor ring to register mapping for DCB
4505
4674
 * @adapter: board private structure to initialize
4509
4678
 **/
4510
4679
static inline bool ixgbe_cache_ring_dcb(struct ixgbe_adapter *adapter)
4511
4680
{
4512
 
        int i;
4513
 
        bool ret = false;
4514
 
        int dcb_i = adapter->ring_feature[RING_F_DCB].indices;
 
4681
        struct net_device *dev = adapter->netdev;
 
4682
        int i, j, k;
 
4683
        u8 num_tcs = netdev_get_num_tc(dev);
4515
4684
 
4516
4685
        if (!(adapter->flags & IXGBE_FLAG_DCB_ENABLED))
4517
4686
                return false;
4518
4687
 
4519
 
        /* the number of queues is assumed to be symmetric */
4520
 
        switch (adapter->hw.mac.type) {
4521
 
        case ixgbe_mac_82598EB:
4522
 
                for (i = 0; i < dcb_i; i++) {
4523
 
                        adapter->rx_ring[i]->reg_idx = i << 3;
4524
 
                        adapter->tx_ring[i]->reg_idx = i << 2;
4525
 
                }
4526
 
                ret = true;
4527
 
                break;
4528
 
        case ixgbe_mac_82599EB:
4529
 
        case ixgbe_mac_X540:
4530
 
                if (dcb_i == 8) {
4531
 
                        /*
4532
 
                         * Tx TC0 starts at: descriptor queue 0
4533
 
                         * Tx TC1 starts at: descriptor queue 32
4534
 
                         * Tx TC2 starts at: descriptor queue 64
4535
 
                         * Tx TC3 starts at: descriptor queue 80
4536
 
                         * Tx TC4 starts at: descriptor queue 96
4537
 
                         * Tx TC5 starts at: descriptor queue 104
4538
 
                         * Tx TC6 starts at: descriptor queue 112
4539
 
                         * Tx TC7 starts at: descriptor queue 120
4540
 
                         *
4541
 
                         * Rx TC0-TC7 are offset by 16 queues each
4542
 
                         */
4543
 
                        for (i = 0; i < 3; i++) {
4544
 
                                adapter->tx_ring[i]->reg_idx = i << 5;
4545
 
                                adapter->rx_ring[i]->reg_idx = i << 4;
4546
 
                        }
4547
 
                        for ( ; i < 5; i++) {
4548
 
                                adapter->tx_ring[i]->reg_idx = ((i + 2) << 4);
4549
 
                                adapter->rx_ring[i]->reg_idx = i << 4;
4550
 
                        }
4551
 
                        for ( ; i < dcb_i; i++) {
4552
 
                                adapter->tx_ring[i]->reg_idx = ((i + 8) << 3);
4553
 
                                adapter->rx_ring[i]->reg_idx = i << 4;
4554
 
                        }
4555
 
                        ret = true;
4556
 
                } else if (dcb_i == 4) {
4557
 
                        /*
4558
 
                         * Tx TC0 starts at: descriptor queue 0
4559
 
                         * Tx TC1 starts at: descriptor queue 64
4560
 
                         * Tx TC2 starts at: descriptor queue 96
4561
 
                         * Tx TC3 starts at: descriptor queue 112
4562
 
                         *
4563
 
                         * Rx TC0-TC3 are offset by 32 queues each
4564
 
                         */
4565
 
                        adapter->tx_ring[0]->reg_idx = 0;
4566
 
                        adapter->tx_ring[1]->reg_idx = 64;
4567
 
                        adapter->tx_ring[2]->reg_idx = 96;
4568
 
                        adapter->tx_ring[3]->reg_idx = 112;
4569
 
                        for (i = 0 ; i < dcb_i; i++)
4570
 
                                adapter->rx_ring[i]->reg_idx = i << 5;
4571
 
                        ret = true;
4572
 
                }
4573
 
                break;
4574
 
        default:
4575
 
                break;
 
4688
        for (i = 0, k = 0; i < num_tcs; i++) {
 
4689
                unsigned int tx_s, rx_s;
 
4690
                u16 count = dev->tc_to_txq[i].count;
 
4691
 
 
4692
                ixgbe_get_first_reg_idx(adapter, i, &tx_s, &rx_s);
 
4693
                for (j = 0; j < count; j++, k++) {
 
4694
                        adapter->tx_ring[k]->reg_idx = tx_s + j;
 
4695
                        adapter->rx_ring[k]->reg_idx = rx_s + j;
 
4696
                        adapter->tx_ring[k]->dcb_tc = i;
 
4697
                        adapter->rx_ring[k]->dcb_tc = i;
 
4698
                }
4576
4699
        }
4577
 
        return ret;
 
4700
 
 
4701
        return true;
4578
4702
}
4579
4703
#endif
4580
4704
 
4620
4744
        if (!(adapter->flags & IXGBE_FLAG_FCOE_ENABLED))
4621
4745
                return false;
4622
4746
 
4623
 
#ifdef CONFIG_IXGBE_DCB
4624
 
        if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
4625
 
                struct ixgbe_fcoe *fcoe = &adapter->fcoe;
4626
 
 
4627
 
                ixgbe_cache_ring_dcb(adapter);
4628
 
                /* find out queues in TC for FCoE */
4629
 
                fcoe_rx_i = adapter->rx_ring[fcoe->tc]->reg_idx + 1;
4630
 
                fcoe_tx_i = adapter->tx_ring[fcoe->tc]->reg_idx + 1;
4631
 
                /*
4632
 
                 * In 82599, the number of Tx queues for each traffic
4633
 
                 * class for both 8-TC and 4-TC modes are:
4634
 
                 * TCs  : TC0 TC1 TC2 TC3 TC4 TC5 TC6 TC7
4635
 
                 * 8 TCs:  32  32  16  16   8   8   8   8
4636
 
                 * 4 TCs:  64  64  32  32
4637
 
                 * We have max 8 queues for FCoE, where 8 the is
4638
 
                 * FCoE redirection table size. If TC for FCoE is
4639
 
                 * less than or equal to TC3, we have enough queues
4640
 
                 * to add max of 8 queues for FCoE, so we start FCoE
4641
 
                 * Tx queue from the next one, i.e., reg_idx + 1.
4642
 
                 * If TC for FCoE is above TC3, implying 8 TC mode,
4643
 
                 * and we need 8 for FCoE, we have to take all queues
4644
 
                 * in that traffic class for FCoE.
4645
 
                 */
4646
 
                if ((f->indices == IXGBE_FCRETA_SIZE) && (fcoe->tc > 3))
4647
 
                        fcoe_tx_i--;
4648
 
        }
4649
 
#endif /* CONFIG_IXGBE_DCB */
4650
4747
        if (adapter->flags & IXGBE_FLAG_RSS_ENABLED) {
4651
4748
                if ((adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) ||
4652
4749
                    (adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE))
4703
4800
        if (ixgbe_cache_ring_sriov(adapter))
4704
4801
                return;
4705
4802
 
 
4803
#ifdef CONFIG_IXGBE_DCB
 
4804
        if (ixgbe_cache_ring_dcb(adapter))
 
4805
                return;
 
4806
#endif
 
4807
 
4706
4808
#ifdef IXGBE_FCOE
4707
4809
        if (ixgbe_cache_ring_fcoe(adapter))
4708
4810
                return;
4709
 
 
4710
4811
#endif /* IXGBE_FCOE */
4711
 
#ifdef CONFIG_IXGBE_DCB
4712
 
        if (ixgbe_cache_ring_dcb(adapter))
4713
 
                return;
4714
4812
 
4715
 
#endif
4716
4813
        if (ixgbe_cache_ring_fdir(adapter))
4717
4814
                return;
4718
4815
 
5174
5271
        adapter->dcb_cfg.bw_percentage[DCB_RX_CONFIG][0] = 100;
5175
5272
        adapter->dcb_cfg.rx_pba_cfg = pba_equal;
5176
5273
        adapter->dcb_cfg.pfc_mode_enable = false;
5177
 
        adapter->dcb_cfg.round_robin_enable = false;
5178
5274
        adapter->dcb_set_bitmap = 0x00;
 
5275
        adapter->dcbx_cap = DCB_CAP_DCBX_HOST | DCB_CAP_DCBX_VER_CEE;
5179
5276
        ixgbe_copy_dcb_cfg(&adapter->dcb_cfg, &adapter->temp_dcb_cfg,
5180
 
                           adapter->ring_feature[RING_F_DCB].indices);
 
5277
                           MAX_TRAFFIC_CLASS);
5181
5278
 
5182
5279
#endif
5183
5280
 
5442
5539
        int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN;
5443
5540
 
5444
5541
        /* MTU < 68 is an error and causes problems on some kernels */
5445
 
        if ((new_mtu < 68) || (max_frame > IXGBE_MAX_JUMBO_FRAME_SIZE))
5446
 
                return -EINVAL;
 
5542
        if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED &&
 
5543
            hw->mac.type != ixgbe_mac_X540) {
 
5544
                if ((new_mtu < 68) || (max_frame > MAXIMUM_ETHERNET_VLAN_SIZE))
 
5545
                        return -EINVAL;
 
5546
        } else {
 
5547
                if ((new_mtu < 68) || (max_frame > IXGBE_MAX_JUMBO_FRAME_SIZE))
 
5548
                        return -EINVAL;
 
5549
        }
5447
5550
 
5448
5551
        e_info(probe, "changing MTU from %d to %d\n", netdev->mtu, new_mtu);
5449
5552
        /* must set new MTU before calling down or up */
5611
5714
        }
5612
5715
 
5613
5716
        ixgbe_clear_interrupt_scheme(adapter);
 
5717
#ifdef CONFIG_DCB
 
5718
        kfree(adapter->ixgbe_ieee_pfc);
 
5719
        kfree(adapter->ixgbe_ieee_ets);
 
5720
#endif
5614
5721
 
5615
5722
#ifdef CONFIG_PM
5616
5723
        retval = pci_save_state(pdev);
6101
6208
                               (link_speed == IXGBE_LINK_SPEED_10GB_FULL ?
6102
6209
                               "10 Gbps" :
6103
6210
                               (link_speed == IXGBE_LINK_SPEED_1GB_FULL ?
6104
 
                               "1 Gbps" : "unknown speed")),
 
6211
                               "1 Gbps" :
 
6212
                               (link_speed == IXGBE_LINK_SPEED_100_FULL ?
 
6213
                               "100 Mbps" :
 
6214
                               "unknown speed"))),
6105
6215
                               ((flow_rx && flow_tx) ? "RX/TX" :
6106
6216
                               (flow_rx ? "RX" :
6107
6217
                               (flow_tx ? "TX" : "None"))));
6108
6218
 
6109
6219
                        netif_carrier_on(netdev);
 
6220
                        ixgbe_check_vf_rate_limit(adapter);
6110
6221
                } else {
6111
6222
                        /* Force detection of hung controller */
6112
6223
                        for (i = 0; i < adapter->num_tx_queues; i++) {
6636
6747
 
6637
6748
        protocol = vlan_get_protocol(skb);
6638
6749
 
6639
 
        if ((protocol == htons(ETH_P_FCOE)) ||
6640
 
            (protocol == htons(ETH_P_FIP))) {
6641
 
                if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) {
6642
 
                        txq &= (adapter->ring_feature[RING_F_FCOE].indices - 1);
6643
 
                        txq += adapter->ring_feature[RING_F_FCOE].mask;
6644
 
                        return txq;
6645
 
#ifdef CONFIG_IXGBE_DCB
6646
 
                } else if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
6647
 
                        txq = adapter->fcoe.up;
6648
 
                        return txq;
6649
 
#endif
6650
 
                }
 
6750
        if (((protocol == htons(ETH_P_FCOE)) ||
 
6751
            (protocol == htons(ETH_P_FIP))) &&
 
6752
            (adapter->flags & IXGBE_FLAG_FCOE_ENABLED)) {
 
6753
                txq &= (adapter->ring_feature[RING_F_FCOE].indices - 1);
 
6754
                txq += adapter->ring_feature[RING_F_FCOE].mask;
 
6755
                return txq;
6651
6756
        }
6652
6757
#endif
6653
6758
 
6657
6762
                return txq;
6658
6763
        }
6659
6764
 
6660
 
        if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
6661
 
                if (skb->priority == TC_PRIO_CONTROL)
6662
 
                        txq = adapter->ring_feature[RING_F_DCB].indices-1;
6663
 
                else
6664
 
                        txq = (skb->vlan_tci & IXGBE_TX_FLAGS_VLAN_PRIO_MASK)
6665
 
                               >> 13;
6666
 
                return txq;
6667
 
        }
6668
 
 
6669
6765
        return skb_tx_hash(dev, skb);
6670
6766
}
6671
6767
 
6687
6783
                tx_flags |= vlan_tx_tag_get(skb);
6688
6784
                if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
6689
6785
                        tx_flags &= ~IXGBE_TX_FLAGS_VLAN_PRIO_MASK;
6690
 
                        tx_flags |= ((skb->queue_mapping & 0x7) << 13);
 
6786
                        tx_flags |= tx_ring->dcb_tc << 13;
6691
6787
                }
6692
6788
                tx_flags <<= IXGBE_TX_FLAGS_VLAN_SHIFT;
6693
6789
                tx_flags |= IXGBE_TX_FLAGS_VLAN;
6694
6790
        } else if (adapter->flags & IXGBE_FLAG_DCB_ENABLED &&
6695
6791
                   skb->priority != TC_PRIO_CONTROL) {
6696
 
                tx_flags |= ((skb->queue_mapping & 0x7) << 13);
 
6792
                tx_flags |= tx_ring->dcb_tc << 13;
6697
6793
                tx_flags <<= IXGBE_TX_FLAGS_VLAN_SHIFT;
6698
6794
                tx_flags |= IXGBE_TX_FLAGS_VLAN;
6699
6795
        }
6702
6798
        /* for FCoE with DCB, we force the priority to what
6703
6799
         * was specified by the switch */
6704
6800
        if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED &&
6705
 
            (protocol == htons(ETH_P_FCOE) ||
6706
 
             protocol == htons(ETH_P_FIP))) {
6707
 
#ifdef CONFIG_IXGBE_DCB
6708
 
                if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
6709
 
                        tx_flags &= ~(IXGBE_TX_FLAGS_VLAN_PRIO_MASK
6710
 
                                      << IXGBE_TX_FLAGS_VLAN_SHIFT);
6711
 
                        tx_flags |= ((adapter->fcoe.up << 13)
6712
 
                                      << IXGBE_TX_FLAGS_VLAN_SHIFT);
6713
 
                }
6714
 
#endif
6715
 
                /* flag for FCoE offloads */
6716
 
                if (protocol == htons(ETH_P_FCOE))
6717
 
                        tx_flags |= IXGBE_TX_FLAGS_FCOE;
6718
 
        }
 
6801
            (protocol == htons(ETH_P_FCOE)))
 
6802
                tx_flags |= IXGBE_TX_FLAGS_FCOE;
6719
6803
#endif
6720
6804
 
6721
6805
        /* four things can cause us to need a context descriptor */
6988
7072
        .ndo_set_vf_tx_rate     = ixgbe_ndo_set_vf_bw,
6989
7073
        .ndo_get_vf_config      = ixgbe_ndo_get_vf_config,
6990
7074
        .ndo_get_stats64        = ixgbe_get_stats64,
 
7075
#ifdef CONFIG_IXGBE_DCB
 
7076
        .ndo_setup_tc           = ixgbe_setup_tc,
 
7077
#endif
6991
7078
#ifdef CONFIG_NET_POLL_CONTROLLER
6992
7079
        .ndo_poll_controller    = ixgbe_netpoll,
6993
7080
#endif
6994
7081
#ifdef IXGBE_FCOE
6995
7082
        .ndo_fcoe_ddp_setup = ixgbe_fcoe_ddp_get,
 
7083
        .ndo_fcoe_ddp_target = ixgbe_fcoe_ddp_target,
6996
7084
        .ndo_fcoe_ddp_done = ixgbe_fcoe_ddp_put,
6997
7085
        .ndo_fcoe_enable = ixgbe_fcoe_enable,
6998
7086
        .ndo_fcoe_disable = ixgbe_fcoe_disable,
7128
7216
        else
7129
7217
                indices = min_t(unsigned int, indices, IXGBE_MAX_FDIR_INDICES);
7130
7218
 
 
7219
#if defined(CONFIG_DCB)
7131
7220
        indices = max_t(unsigned int, indices, IXGBE_MAX_DCB_INDICES);
7132
 
#ifdef IXGBE_FCOE
 
7221
#elif defined(IXGBE_FCOE)
7133
7222
        indices += min_t(unsigned int, num_possible_cpus(),
7134
7223
                         IXGBE_MAX_FCOE_INDICES);
7135
7224
#endif
7285
7374
        if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)
7286
7375
                adapter->flags &= ~(IXGBE_FLAG_RSS_ENABLED |
7287
7376
                                    IXGBE_FLAG_DCB_ENABLED);
7288
 
        if (adapter->flags & IXGBE_FLAG_DCB_ENABLED)
7289
 
                adapter->flags &= ~IXGBE_FLAG_RSS_ENABLED;
7290
7377
 
7291
7378
#ifdef CONFIG_IXGBE_DCB
7292
7379
        netdev->dcbnl_ops = &dcbnl_ops;
7706
7793
 
7707
7794
#endif /* CONFIG_IXGBE_DCA */
7708
7795
 
7709
 
/**
7710
 
 * ixgbe_get_hw_dev return device
7711
 
 * used by hardware layer to print debugging information
7712
 
 **/
7713
 
struct net_device *ixgbe_get_hw_dev(struct ixgbe_hw *hw)
7714
 
{
7715
 
        struct ixgbe_adapter *adapter = hw->back;
7716
 
        return adapter->netdev;
7717
 
}
7718
 
 
7719
7796
module_exit(ixgbe_exit_module);
7720
7797
 
7721
7798
/* ixgbe_main.c */