summaryrefslogtreecommitdiff
path: root/drivers/net/igb/igb_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/igb/igb_main.c')
-rw-r--r--drivers/net/igb/igb_main.c892
1 files changed, 412 insertions, 480 deletions
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 325d4f2abba0..b313ee1cefdb 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -1,7 +1,7 @@
/*******************************************************************************
Intel(R) Gigabit Ethernet Linux driver
- Copyright(c) 2007-2013 Intel Corporation.
+ Copyright(c) 2007-2014 Intel Corporation.
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
@@ -12,14 +12,11 @@
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
- You should have received a copy of the GNU General Public License along with
- this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
-
The full GNU General Public License is included in this distribution in
the file called "COPYING".
Contact Information:
+ Linux NICS <linux.nics@intel.com>
e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
@@ -51,11 +48,11 @@
#endif /* CONFIG_PM_RUNTIME */
#include <linux/if_bridge.h>
-#include <linux/ctype.h>
#include "igb.h"
#include "igb_vmdq.h"
-#if defined(DEBUG) || defined (DEBUG_DUMP) || defined (DEBUG_ICR) || defined(DEBUG_ITR)
+#if defined(DEBUG) || defined(DEBUG_DUMP) || defined(DEBUG_ICR) \
+ || defined(DEBUG_ITR)
#define DRV_DEBUG "_debug"
#else
#define DRV_DEBUG
@@ -64,32 +61,28 @@
#define VERSION_SUFFIX
#define MAJ 5
-#define MIN 1
-#define BUILD 2
-#define DRV_VERSION __stringify(MAJ) "." __stringify(MIN) "." __stringify(BUILD) VERSION_SUFFIX DRV_DEBUG DRV_HW_PERF
+#define MIN 2
+#define BUILD 17
+#define DRV_VERSION __stringify(MAJ) "." __stringify(MIN) "."\
+ __stringify(BUILD) VERSION_SUFFIX DRV_DEBUG DRV_HW_PERF
char igb_driver_name[] = "igb";
char igb_driver_version[] = DRV_VERSION;
static const char igb_driver_string[] =
- "Intel(R) Gigabit Ethernet Network Driver";
+ "Intel(R) Gigabit Ethernet Network Driver";
static const char igb_copyright[] =
- "Copyright (c) 2007-2013 Intel Corporation.";
-
-static char g_mac_addr[ETH_ALEN];
-static int g_usr_mac = 0;
+ "Copyright (c) 2007-2015 Intel Corporation.";
-static DEFINE_PCI_DEVICE_TABLE(igb_pci_tbl) = {
+static const struct pci_device_id igb_pci_tbl[] = {
{ PCI_VDEVICE(INTEL, E1000_DEV_ID_I354_BACKPLANE_1GBPS) },
{ PCI_VDEVICE(INTEL, E1000_DEV_ID_I354_SGMII) },
{ PCI_VDEVICE(INTEL, E1000_DEV_ID_I354_BACKPLANE_2_5GBPS) },
- { PCI_VDEVICE(INTEL, E1000_DEV_ID_I210_TOOLS_ONLY) },
{ PCI_VDEVICE(INTEL, E1000_DEV_ID_I210_COPPER) },
{ PCI_VDEVICE(INTEL, E1000_DEV_ID_I210_FIBER) },
{ PCI_VDEVICE(INTEL, E1000_DEV_ID_I210_SERDES) },
{ PCI_VDEVICE(INTEL, E1000_DEV_ID_I210_SGMII) },
{ PCI_VDEVICE(INTEL, E1000_DEV_ID_I210_COPPER_FLASHLESS) },
{ PCI_VDEVICE(INTEL, E1000_DEV_ID_I210_SERDES_FLASHLESS) },
- { PCI_VDEVICE(INTEL, E1000_DEV_ID_I211_TOOLS_ONLY) },
{ PCI_VDEVICE(INTEL, E1000_DEV_ID_I211_COPPER) },
{ PCI_VDEVICE(INTEL, E1000_DEV_ID_I350_COPPER) },
{ PCI_VDEVICE(INTEL, E1000_DEV_ID_I350_FIBER) },
@@ -122,15 +115,13 @@ static DEFINE_PCI_DEVICE_TABLE(igb_pci_tbl) = {
MODULE_DEVICE_TABLE(pci, igb_pci_tbl);
-void igb_reset(struct igb_adapter *);
static int igb_setup_all_tx_resources(struct igb_adapter *);
static int igb_setup_all_rx_resources(struct igb_adapter *);
static void igb_free_all_tx_resources(struct igb_adapter *);
static void igb_free_all_rx_resources(struct igb_adapter *);
static void igb_setup_mrqc(struct igb_adapter *);
-void igb_update_stats(struct igb_adapter *);
static int igb_probe(struct pci_dev *, const struct pci_device_id *);
-static void __devexit igb_remove(struct pci_dev *pdev);
+static void igb_remove(struct pci_dev *pdev);
static int igb_sw_init(struct igb_adapter *);
static int igb_open(struct net_device *);
static int igb_close(struct net_device *);
@@ -149,7 +140,7 @@ static void igb_dma_err_timer(unsigned long data);
static netdev_tx_t igb_xmit_frame(struct sk_buff *skb, struct net_device *);
static struct net_device_stats *igb_get_stats(struct net_device *);
static int igb_change_mtu(struct net_device *, int);
-void igb_full_sync_mac_table(struct igb_adapter *adapter);
+/* void igb_full_sync_mac_table(struct igb_adapter *adapter); */
static int igb_set_mac(struct net_device *, void *);
static void igb_set_uta(struct igb_adapter *adapter);
static irqreturn_t igb_intr(int irq, void *);
@@ -175,7 +166,7 @@ static void igb_vlan_mode(struct net_device *, struct vlan_group *);
static int igb_vlan_rx_add_vid(struct net_device *,
__always_unused __be16 proto, u16);
static int igb_vlan_rx_kill_vid(struct net_device *,
- __always_unused __be16 proto, u16);
+ __always_unused __be16 proto, u16);
#else
static int igb_vlan_rx_add_vid(struct net_device *, u16);
static int igb_vlan_rx_kill_vid(struct net_device *, u16);
@@ -185,7 +176,6 @@ static void igb_vlan_rx_add_vid(struct net_device *, u16);
static void igb_vlan_rx_kill_vid(struct net_device *, u16);
#endif
static void igb_restore_vlan(struct igb_adapter *);
-void igb_rar_set(struct igb_adapter *adapter, u32 index);
static void igb_ping_all_vfs(struct igb_adapter *);
static void igb_msg_task(struct igb_adapter *);
static void igb_vmm_control(struct igb_adapter *);
@@ -193,14 +183,19 @@ static int igb_set_vf_mac(struct igb_adapter *, int, unsigned char *);
static void igb_restore_vf_multicasts(struct igb_adapter *adapter);
static void igb_process_mdd_event(struct igb_adapter *);
#ifdef IFLA_VF_MAX
-static int igb_ndo_set_vf_mac( struct net_device *netdev, int vf, u8 *mac);
+static int igb_ndo_set_vf_mac(struct net_device *netdev, int vf, u8 *mac);
static int igb_ndo_set_vf_vlan(struct net_device *netdev,
int vf, u16 vlan, u8 qos);
#ifdef HAVE_VF_SPOOFCHK_CONFIGURE
static int igb_ndo_set_vf_spoofchk(struct net_device *netdev, int vf,
bool setting);
#endif
-static int igb_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate);
+#ifdef HAVE_NDO_SET_VF_MIN_MAX_TX_RATE
+int igb_ndo_set_vf_bw(struct net_device *netdev, int vf, int min_tx_rate,
+ int tx_rate);
+#else
+int igb_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate);
+#endif /* HAVE_NDO_SET_VF_MIN_MAX_TX_RATE */
static int igb_ndo_get_vf_config(struct net_device *netdev, int vf,
struct ifla_vf_info *ivi);
static void igb_check_vf_rate_limit(struct igb_adapter *);
@@ -287,45 +282,13 @@ static struct pci_driver igb_driver = {
#endif
};
+/* u32 e1000_read_reg(struct e1000_hw *hw, u32 reg); */
+
MODULE_AUTHOR("Intel Corporation, <e1000-devel@lists.sourceforge.net>");
MODULE_DESCRIPTION("Intel(R) Gigabit Ethernet Network Driver");
MODULE_LICENSE("GPL");
MODULE_VERSION(DRV_VERSION);
-/* Retrieve user set MAC address */
-static int __init setup_igb_mac(char *macstr)
-{
- int i, j;
- unsigned char result, value;
-
- for (i = 0; i < ETH_ALEN; i++) {
- result = 0;
-
- if (i != 5 && *(macstr + 2) != ':')
- return -1;
-
- for (j = 0; j < 2; j++) {
- if (isxdigit(*macstr)
- && (value =
- isdigit(*macstr) ? *macstr -
- '0' : toupper(*macstr) - 'A' + 10) < 16) {
- result = result * 16 + value;
- macstr++;
- } else
- return -1;
- }
-
- macstr++;
- g_mac_addr[i] = result;
- }
-
- g_usr_mac = 1;
-
- return 0;
-}
-
-__setup("igb_mac=", setup_igb_mac);
-
static void igb_vfta_set(struct igb_adapter *adapter, u32 vid, bool add)
{
struct e1000_hw *hw = &adapter->hw;
@@ -367,16 +330,16 @@ static int __init igb_init_module(void)
{
int ret;
- printk(KERN_INFO "%s - version %s\n",
+ pr_info("%s - version %s\n",
igb_driver_string, igb_driver_version);
- printk(KERN_INFO "%s\n", igb_copyright);
+ pr_info("%s\n", igb_copyright);
#ifdef IGB_HWMON
/* only use IGB_PROCFS if IGB_HWMON is not defined */
#else
#ifdef IGB_PROCFS
if (igb_procfs_topdir_init())
- printk(KERN_INFO "Procfs failed to initialize topdir\n");
+ pr_info("Procfs failed to initialize topdir\n");
#endif /* IGB_PROCFS */
#endif /* IGB_HWMON */
@@ -385,9 +348,8 @@ static int __init igb_init_module(void)
#endif
ret = pci_register_driver(&igb_driver);
#ifdef USE_REBOOT_NOTIFIER
- if (ret >= 0) {
+ if (ret >= 0)
register_reboot_notifier(&igb_notifier_reboot);
- }
#endif
return ret;
}
@@ -434,8 +396,7 @@ static void igb_cache_ring_register(struct igb_adapter *adapter)
int i = 0, j = 0;
u32 rbase_offset = adapter->vfs_allocated_count;
- switch (adapter->hw.mac.type) {
- case e1000_82576:
+ if (adapter->hw.mac.type == e1000_82576) {
/* The queues are allocated for virtualization such that VF 0
* is allocated queues 0 and 8, VF 1 queues 1 and 9, etc.
* In order to avoid collision we start at the first free queue
@@ -444,21 +405,35 @@ static void igb_cache_ring_register(struct igb_adapter *adapter)
if ((adapter->rss_queues > 1) && adapter->vmdq_pools) {
for (; i < adapter->rss_queues; i++)
adapter->rx_ring[i]->reg_idx = rbase_offset +
- Q_IDX_82576(i);
+ Q_IDX_82576(i);
}
- case e1000_82575:
- case e1000_82580:
- case e1000_i350:
- case e1000_i354:
- case e1000_i210:
- case e1000_i211:
- default:
- for (; i < adapter->num_rx_queues; i++)
- adapter->rx_ring[i]->reg_idx = rbase_offset + i;
- for (; j < adapter->num_tx_queues; j++)
- adapter->tx_ring[j]->reg_idx = rbase_offset + j;
- break;
}
+ for (; i < adapter->num_rx_queues; i++)
+ adapter->rx_ring[i]->reg_idx = rbase_offset + i;
+ for (; j < adapter->num_tx_queues; j++)
+ adapter->tx_ring[j]->reg_idx = rbase_offset + j;
+}
+
+u32 e1000_read_reg(struct e1000_hw *hw, u32 reg)
+{
+ struct igb_adapter *igb = container_of(hw, struct igb_adapter, hw);
+ u8 __iomem *hw_addr = ACCESS_ONCE(hw->hw_addr);
+ u32 value = 0;
+
+ if (E1000_REMOVED(hw_addr))
+ return ~value;
+
+ value = readl(&hw_addr[reg]);
+
+ /* reads should not return all F's */
+ if (!(~value) && (!reg || !(~readl(hw_addr)))) {
+ struct net_device *netdev = igb->netdev;
+ hw->hw_addr = NULL;
+ netif_device_detach(netdev);
+ netdev_err(netdev, "PCIe link lost, device now detached\n");
+ }
+
+ return value;
}
static void igb_configure_lli(struct igb_adapter *adapter)
@@ -632,7 +607,7 @@ static void igb_configure_msix(struct igb_adapter *adapter)
/* enable msix_other interrupt */
E1000_WRITE_REG_ARRAY(hw, E1000_MSIXBM(0), vector++,
- E1000_EIMS_OTHER);
+ E1000_EIMS_OTHER);
adapter->eims_other = E1000_EIMS_OTHER;
break;
@@ -646,8 +621,8 @@ static void igb_configure_msix(struct igb_adapter *adapter)
/* Turn on MSI-X capability first, or our settings
* won't stick. And it will take days to debug. */
E1000_WRITE_REG(hw, E1000_GPIE, E1000_GPIE_MSIX_MODE |
- E1000_GPIE_PBA | E1000_GPIE_EIAME |
- E1000_GPIE_NSICR);
+ E1000_GPIE_PBA | E1000_GPIE_EIAME |
+ E1000_GPIE_NSICR);
/* enable msix_other interrupt */
adapter->eims_other = 1 << vector;
@@ -681,7 +656,7 @@ static int igb_request_msix(struct igb_adapter *adapter)
int i, err = 0, vector = 0, free_vector = 0;
err = request_irq(adapter->msix_entries[vector].vector,
- &igb_msix_other, 0, netdev->name, adapter);
+ &igb_msix_other, 0, netdev->name, adapter);
if (err)
goto err_out;
@@ -694,19 +669,19 @@ static int igb_request_msix(struct igb_adapter *adapter)
if (q_vector->rx.ring && q_vector->tx.ring)
sprintf(q_vector->name, "%s-TxRx-%u", netdev->name,
- q_vector->rx.ring->queue_index);
+ q_vector->rx.ring->queue_index);
else if (q_vector->tx.ring)
sprintf(q_vector->name, "%s-tx-%u", netdev->name,
- q_vector->tx.ring->queue_index);
+ q_vector->tx.ring->queue_index);
else if (q_vector->rx.ring)
sprintf(q_vector->name, "%s-rx-%u", netdev->name,
- q_vector->rx.ring->queue_index);
+ q_vector->rx.ring->queue_index);
else
sprintf(q_vector->name, "%s-unused", netdev->name);
err = request_irq(adapter->msix_entries[vector].vector,
- igb_msix_ring, 0, q_vector->name,
- q_vector);
+ igb_msix_ring, 0, q_vector->name,
+ q_vector);
if (err)
goto err_free;
}
@@ -818,8 +793,8 @@ static void igb_process_mdd_event(struct igb_adapter *adapter)
return;
netdev_info(adapter->netdev,
- "VF %d misbehaved. VF queues are disabled. "
- "VM misbehavior code is 0x%x\n", vf_queue, lvmmc);
+ "VF %d misbehaved. VF queues are disabled. VM misbehavior code is 0x%x\n",
+ vf_queue, lvmmc);
/* Disable VFTE and VFRE related bits */
vfte = E1000_READ_REG(hw, E1000_VFTE);
@@ -903,8 +878,8 @@ static void igb_reset_sriov_capability(struct igb_adapter *adapter)
dev_info(pci_dev_to_dev(pdev), "IOV Disabled\n");
} else {
- dev_info(pci_dev_to_dev(pdev), "IOV Not Disabled\n "
- "VF(s) are assigned to guests!\n");
+ dev_info(pci_dev_to_dev(pdev),
+ "IOV Not Disabled\n VF(s) are assigned to guests!\n");
}
/* Disable Malicious Driver Detection */
igb_disable_mdd(adapter);
@@ -938,9 +913,8 @@ static void igb_set_sriov_capability(struct igb_adapter *adapter)
old_vfs = pci_num_vf(pdev);
if (old_vfs) {
dev_info(pci_dev_to_dev(pdev),
- "%d pre-allocated VFs found - override "
- "max_vfs setting of %d\n", old_vfs,
- adapter->vfs_allocated_count);
+ "%d pre-allocated VFs found - override max_vfs setting of %d\n",
+ old_vfs, adapter->vfs_allocated_count);
adapter->vfs_allocated_count = old_vfs;
}
/* no VFs requested, do nothing */
@@ -949,8 +923,8 @@ static void igb_set_sriov_capability(struct igb_adapter *adapter)
/* allocate vf data storage */
adapter->vf_data = kcalloc(adapter->vfs_allocated_count,
- sizeof(struct vf_data_storage),
- GFP_KERNEL);
+ sizeof(struct vf_data_storage),
+ GFP_KERNEL);
if (adapter->vf_data) {
if (!old_vfs) {
@@ -974,9 +948,9 @@ static void igb_set_sriov_capability(struct igb_adapter *adapter)
/* DMA Coalescing is not supported in IOV mode. */
if (adapter->hw.mac.type >= e1000_i350)
- adapter->dmac = IGB_DMAC_DISABLE;
+ adapter->dmac = IGB_DMAC_DISABLE;
if (adapter->hw.mac.type < e1000_i350)
- adapter->flags |= IGB_FLAG_DETECT_BAD_DMA;
+ adapter->flags |= IGB_FLAG_DETECT_BAD_DMA;
return;
}
@@ -1036,28 +1010,27 @@ static void igb_set_interrupt_capability(struct igb_adapter *adapter, bool msix)
/* add 1 vector for link status interrupts */
numvecs++;
adapter->msix_entries = kcalloc(numvecs,
- sizeof(struct msix_entry),
- GFP_KERNEL);
+ sizeof(struct msix_entry),
+ GFP_KERNEL);
if (adapter->msix_entries) {
for (i = 0; i < numvecs; i++)
adapter->msix_entries[i].entry = i;
err = pci_enable_msix(pdev,
- adapter->msix_entries, numvecs);
+ adapter->msix_entries, numvecs);
if (err == 0)
break;
}
/* MSI-X failed, so fall through and try MSI */
- dev_warn(pci_dev_to_dev(pdev), "Failed to initialize MSI-X interrupts. "
- "Falling back to MSI interrupts.\n");
+ dev_warn(pci_dev_to_dev(pdev),
+ "Failed to initialize MSI-X interrupts. Falling back to MSI interrupts.\n");
igb_reset_interrupt_capability(adapter);
case IGB_INT_MODE_MSI:
if (!pci_enable_msi(pdev))
adapter->flags |= IGB_FLAG_HAS_MSI;
else
- dev_warn(pci_dev_to_dev(pdev), "Failed to initialize MSI "
- "interrupts. Falling back to legacy "
- "interrupts.\n");
+ dev_warn(pci_dev_to_dev(pdev),
+ "Failed to initialize MSI interrupts. Falling back to legacy interrupts.\n");
/* Fall through */
case IGB_INT_MODE_LEGACY:
/* disable advanced features and set number of queues to 1 */
@@ -1241,6 +1214,7 @@ static int igb_alloc_q_vectors(struct igb_adapter *adapter)
for (; v_idx < q_vectors; v_idx++) {
int rqpv = DIV_ROUND_UP(rxr_remaining, q_vectors - v_idx);
int tqpv = DIV_ROUND_UP(txr_remaining, q_vectors - v_idx);
+
err = igb_alloc_q_vector(adapter, q_vectors, v_idx,
tqpv, txr_idx, rqpv, rxr_idx);
@@ -1357,7 +1331,7 @@ static void igb_free_irq(struct igb_adapter *adapter)
for (i = 0; i < adapter->num_q_vectors; i++)
free_irq(adapter->msix_entries[vector++].vector,
- adapter->q_vector[i]);
+ adapter->q_vector[i]);
} else {
free_irq(adapter->pdev->irq, adapter);
}
@@ -1378,10 +1352,13 @@ static void igb_irq_disable(struct igb_adapter *adapter)
*/
if (adapter->msix_entries) {
u32 regval = E1000_READ_REG(hw, E1000_EIAM);
- E1000_WRITE_REG(hw, E1000_EIAM, regval & ~adapter->eims_enable_mask);
+
+ E1000_WRITE_REG(hw, E1000_EIAM, regval
+ & ~adapter->eims_enable_mask);
E1000_WRITE_REG(hw, E1000_EIMC, adapter->eims_enable_mask);
regval = E1000_READ_REG(hw, E1000_EIAC);
- E1000_WRITE_REG(hw, E1000_EIAC, regval & ~adapter->eims_enable_mask);
+ E1000_WRITE_REG(hw, E1000_EIAC, regval
+ & ~adapter->eims_enable_mask);
}
E1000_WRITE_REG(hw, E1000_IAM, 0);
@@ -1411,9 +1388,12 @@ static void igb_irq_enable(struct igb_adapter *adapter)
if (adapter->msix_entries) {
u32 ims = E1000_IMS_LSC | E1000_IMS_DOUTSYNC | E1000_IMS_DRSTA;
u32 regval = E1000_READ_REG(hw, E1000_EIAC);
- E1000_WRITE_REG(hw, E1000_EIAC, regval | adapter->eims_enable_mask);
+
+ E1000_WRITE_REG(hw, E1000_EIAC, regval
+ | adapter->eims_enable_mask);
regval = E1000_READ_REG(hw, E1000_EIAM);
- E1000_WRITE_REG(hw, E1000_EIAM, regval | adapter->eims_enable_mask);
+ E1000_WRITE_REG(hw, E1000_EIAM, regval
+ | adapter->eims_enable_mask);
E1000_WRITE_REG(hw, E1000_EIMS, adapter->eims_enable_mask);
if (adapter->vfs_allocated_count) {
E1000_WRITE_REG(hw, E1000_MBVFIMR, 0xFF);
@@ -1643,7 +1623,7 @@ static int igb_get_i2c_data(void *data)
struct e1000_hw *hw = &adapter->hw;
s32 i2cctl = E1000_READ_REG(hw, E1000_I2CPARAMS);
- return ((i2cctl & E1000_I2C_DATA_IN) != 0);
+ return !!(i2cctl & E1000_I2C_DATA_IN);
}
/* igb_set_i2c_data - Sets the I2C data bit
@@ -1705,7 +1685,7 @@ static int igb_get_i2c_clk(void *data)
struct e1000_hw *hw = &adapter->hw;
s32 i2cctl = E1000_READ_REG(hw, E1000_I2CPARAMS);
- return ((i2cctl & E1000_I2C_CLK_IN) != 0);
+ return !!(i2cctl & E1000_I2C_CLK_IN);
}
static const struct i2c_algo_bit_data igb_i2c_algo = {
@@ -1776,6 +1756,7 @@ int igb_up(struct igb_adapter *adapter)
/* notify VFs that reset has been completed */
if (adapter->vfs_allocated_count) {
u32 reg_data = E1000_READ_REG(hw, E1000_CTRL_EXT);
+
reg_data |= E1000_CTRL_EXT_PFRSTD;
E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg_data);
}
@@ -1988,6 +1969,7 @@ void igb_reset(struct igb_adapter *adapter)
/* disable receive for all VFs and wait one second */
if (adapter->vfs_allocated_count) {
int i;
+
/*
* Clear all flags except indication that the PF has set
* the VF MAC addresses administratively
@@ -2046,10 +2028,10 @@ void igb_reset(struct igb_adapter *adapter)
case e1000_i350:
case e1000_i210:
case e1000_i211:
- e1000_set_eee_i350(hw);
+ e1000_set_eee_i350(hw, true, true);
break;
case e1000_i354:
- e1000_set_eee_i354(hw);
+ e1000_set_eee_i354(hw, true, true);
break;
default:
break;
@@ -2064,7 +2046,6 @@ void igb_reset(struct igb_adapter *adapter)
/* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */
E1000_WRITE_REG(hw, E1000_VET, ETHERNET_IEEE_VLAN_TYPE);
-
#ifdef HAVE_PTP_1588_CLOCK
/* Re-enable PTP, where applicable. */
igb_ptp_reset(adapter);
@@ -2118,13 +2099,16 @@ static int igb_set_features(struct net_device *netdev,
static int igb_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
struct net_device *dev,
const unsigned char *addr,
+#ifdef HAVE_NDO_FDB_ADD_VID
+ u16 vid,
+#endif
u16 flags)
-#else
+#else /* USE_CONST_DEV_UC_CHAR */
static int igb_ndo_fdb_add(struct ndmsg *ndm,
struct net_device *dev,
unsigned char *addr,
u16 flags)
-#endif
+#endif /* USE_CONST_DEV_UC_CHAR */
{
struct igb_adapter *adapter = netdev_priv(dev);
struct e1000_hw *hw = &adapter->hw;
@@ -2210,8 +2194,14 @@ static int igb_ndo_fdb_dump(struct sk_buff *skb,
#endif /* USE_DEFAULT_FDB_DEL_DUMP */
#ifdef HAVE_BRIDGE_ATTRIBS
+#ifdef HAVE_NDO_BRIDGE_SET_DEL_LINK_FLAGS
+static int igb_ndo_bridge_setlink(struct net_device *dev,
+ struct nlmsghdr *nlh,
+ u16 flags)
+#else
static int igb_ndo_bridge_setlink(struct net_device *dev,
struct nlmsghdr *nlh)
+#endif /* HAVE_NDO_BRIDGE_SET_DEL_LINK_FLAGS */
{
struct igb_adapter *adapter = netdev_priv(dev);
struct e1000_hw *hw = &adapter->hw;
@@ -2274,7 +2264,11 @@ static int igb_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
else
mode = BRIDGE_MODE_VEPA;
+#ifdef HAVE_NDO_FDB_ADD_VID
+ return ndo_dflt_bridge_getlink(skb, pid, seq, dev, mode, 0, 0);
+#else
return ndo_dflt_bridge_getlink(skb, pid, seq, dev, mode);
+#endif /* HAVE_NDO_FDB_ADD_VID */
}
#endif /* HAVE_BRIDGE_ATTRIBS */
#endif /* HAVE_FDB_OPS */
@@ -2297,7 +2291,11 @@ static const struct net_device_ops igb_netdev_ops = {
#ifdef IFLA_VF_MAX
.ndo_set_vf_mac = igb_ndo_set_vf_mac,
.ndo_set_vf_vlan = igb_ndo_set_vf_vlan,
+#ifdef HAVE_NDO_SET_VF_MIN_MAX_TX_RATE
+ .ndo_set_vf_rate = igb_ndo_set_vf_bw,
+#else
.ndo_set_vf_tx_rate = igb_ndo_set_vf_bw,
+#endif /*HAVE_NDO_SET_VF_MIN_MAX_TX_RATE */
.ndo_get_vf_config = igb_ndo_get_vf_config,
#ifdef HAVE_VF_SPOOFCHK_CONFIGURE
.ndo_set_vf_spoofchk = igb_ndo_set_vf_spoofchk,
@@ -2455,10 +2453,10 @@ static void igb_set_fw_version(struct igb_adapter *adapter)
/* no option rom */
} else {
if (fw.etrack_id != 0X0000) {
- snprintf(adapter->fw_version,
- sizeof(adapter->fw_version),
- "%d.%d, 0x%08x",
- fw.eep_major, fw.eep_minor, fw.etrack_id);
+ snprintf(adapter->fw_version,
+ sizeof(adapter->fw_version),
+ "%d.%d, 0x%08x",
+ fw.eep_major, fw.eep_minor, fw.etrack_id);
} else {
snprintf(adapter->fw_version,
sizeof(adapter->fw_version),
@@ -2468,8 +2466,6 @@ static void igb_set_fw_version(struct igb_adapter *adapter)
}
break;
}
-
- return;
}
/**
@@ -2509,6 +2505,33 @@ static void igb_init_mas(struct igb_adapter *adapter)
}
}
+void igb_rar_set(struct igb_adapter *adapter, u32 index)
+{
+ u32 rar_low, rar_high;
+ struct e1000_hw *hw = &adapter->hw;
+ u8 *addr = adapter->mac_table[index].addr;
+ /* HW expects these in little endian so we reverse the byte order
+ * from network order (big endian) to little endian
+ */
+ rar_low = ((u32) addr[0] | ((u32) addr[1] << 8) |
+ ((u32) addr[2] << 16) | ((u32) addr[3] << 24));
+ rar_high = ((u32) addr[4] | ((u32) addr[5] << 8));
+
+ /* Indicate to hardware the Address is Valid. */
+ if (adapter->mac_table[index].state & IGB_MAC_STATE_IN_USE)
+ rar_high |= E1000_RAH_AV;
+
+ if (hw->mac.type == e1000_82575)
+ rar_high |= E1000_RAH_POOL_1 * adapter->mac_table[index].queue;
+ else
+ rar_high |= E1000_RAH_POOL_1 << adapter->mac_table[index].queue;
+
+ E1000_WRITE_REG(hw, E1000_RAL(index), rar_low);
+ E1000_WRITE_FLUSH(hw);
+ E1000_WRITE_REG(hw, E1000_RAH(index), rar_high);
+ E1000_WRITE_FLUSH(hw);
+}
+
/**
* igb_probe - Device Initialization Routine
* @pdev: PCI device information struct
@@ -2520,7 +2543,7 @@ static void igb_init_mas(struct igb_adapter *adapter)
* The OS initialization, configuring of the adapter private structure,
* and a hardware reset occur.
**/
-static int __devinit igb_probe(struct pci_dev *pdev,
+static int igb_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
struct net_device *netdev;
@@ -2530,7 +2553,7 @@ static int __devinit igb_probe(struct pci_dev *pdev,
u8 pba_str[E1000_PBANUM_LENGTH];
s32 ret_val;
static int global_quad_port_a; /* global quad port a indication */
- int i, err, pci_using_dac;
+ int err, pci_using_dac;
static int cards_found;
err = pci_enable_device_mem(pdev);
@@ -2540,16 +2563,18 @@ static int __devinit igb_probe(struct pci_dev *pdev,
pci_using_dac = 0;
err = dma_set_mask(pci_dev_to_dev(pdev), DMA_BIT_MASK(64));
if (!err) {
- err = dma_set_coherent_mask(pci_dev_to_dev(pdev), DMA_BIT_MASK(64));
+ err = dma_set_coherent_mask(pci_dev_to_dev(pdev),
+ DMA_BIT_MASK(64));
if (!err)
pci_using_dac = 1;
} else {
err = dma_set_mask(pci_dev_to_dev(pdev), DMA_BIT_MASK(32));
if (err) {
- err = dma_set_coherent_mask(pci_dev_to_dev(pdev), DMA_BIT_MASK(32));
+ err = dma_set_coherent_mask(pci_dev_to_dev(pdev),
+ DMA_BIT_MASK(32));
if (err) {
- IGB_ERR("No usable DMA configuration, "
- "aborting\n");
+ IGB_ERR(
+ "No usable DMA configuration, aborting\n");
goto err_dma;
}
}
@@ -2568,9 +2593,9 @@ static int __devinit igb_probe(struct pci_dev *pdev,
#endif /* HAVE_ASPM_QUIRKS */
err = pci_request_selected_regions(pdev,
- pci_select_bars(pdev,
- IORESOURCE_MEM),
- igb_driver_name);
+ pci_select_bars(pdev,
+ IORESOURCE_MEM),
+ igb_driver_name);
if (err)
goto err_pci_reg;
@@ -2581,7 +2606,7 @@ static int __devinit igb_probe(struct pci_dev *pdev,
err = -ENOMEM;
#ifdef HAVE_TX_MQ
netdev = alloc_etherdev_mq(sizeof(struct igb_adapter),
- IGB_MAX_TX_QUEUES);
+ IGB_MAX_TX_QUEUES);
#else
netdev = alloc_etherdev(sizeof(struct igb_adapter));
#endif /* HAVE_TX_MQ */
@@ -2607,7 +2632,7 @@ static int __devinit igb_probe(struct pci_dev *pdev,
#endif
err = -EIO;
hw->hw_addr = ioremap(pci_resource_start(pdev, 0),
- pci_resource_len(pdev, 0));
+ pci_resource_len(pdev, 0));
if (!hw->hw_addr)
goto err_ioremap;
@@ -2733,7 +2758,8 @@ static int __devinit igb_probe(struct pci_dev *pdev,
adapter->en_mng_pt = e1000_enable_mng_pass_thru(hw);
#ifdef DEBUG
if (adapter->dmac != IGB_DMAC_DISABLE)
- printk("%s: DMA Coalescing is enabled..\n", netdev->name);
+ netdev_info(netdev, "%s: DMA Coalescing is enabled..\n",
+ netdev->name);
#endif
/* before reading the NVM, reset the controller to put the device in a
@@ -2742,36 +2768,15 @@ static int __devinit igb_probe(struct pci_dev *pdev,
/* make sure the NVM is good */
if (e1000_validate_nvm_checksum(hw) < 0) {
-#ifdef CONFIG_MACH_APALIS_T30
- /* only warn on NVM validation failures */
- dev_warn(pci_dev_to_dev(pdev), "The NVM Checksum Is Not"
- " Valid\n");
-#else /* CONFIG_MACH_APALIS_T30 */
- dev_err(pci_dev_to_dev(pdev), "The NVM Checksum Is Not"
- " Valid\n");
+ dev_err(pci_dev_to_dev(pdev),
+ "The NVM Checksum Is Not Valid\n");
err = -EIO;
goto err_eeprom;
-#endif /* CONFIG_MACH_APALIS_T30 */
}
/* copy the MAC address out of the NVM */
if (e1000_read_mac_addr(hw))
dev_err(pci_dev_to_dev(pdev), "NVM Read Error\n");
-
-#ifdef CONFIG_MACH_APALIS_T30
- if (g_usr_mac && (g_usr_mac < 3)) {
- /* Get user set MAC address */
- if (g_usr_mac == 2) {
- /* 0x100000 offset for 2nd Ethernet MAC */
- g_mac_addr[3] += 0x10;
- if (g_mac_addr[3] < 0x10)
- dev_warn(&pdev->dev, "MAC address byte 3 (0x%02x) wrap around", g_mac_addr[3]);
- }
- memcpy(hw->mac.addr, g_mac_addr, ETH_ALEN);
- g_usr_mac++;
- }
-#endif /* CONFIG_MACH_APALIS_T30 */
-
memcpy(netdev->dev_addr, hw->mac.addr, netdev->addr_len);
#ifdef ETHTOOL_GPERMADDR
memcpy(netdev->perm_addr, hw->mac.addr, netdev->addr_len);
@@ -2780,40 +2785,36 @@ static int __devinit igb_probe(struct pci_dev *pdev,
#else
if (!is_valid_ether_addr(netdev->dev_addr)) {
#endif
-#ifdef CONFIG_MACH_APALIS_T30
- /* Use Toradex OUI as default */
- char default_mac_addr[ETH_ALEN] = {0x0, 0x14, 0x2d, 0x0, 0x0, 0x0};
- dev_warn(&pdev->dev, "using Toradex OUI as default igb MAC");
- memcpy(hw->mac.addr, default_mac_addr, ETH_ALEN);
- memcpy(netdev->dev_addr, hw->mac.addr, netdev->addr_len);
-#ifdef ETHTOOL_GPERMADDR
- memcpy(netdev->perm_addr, hw->mac.addr, netdev->addr_len);
-#endif
-#else /* CONFIG_MACH_APALIS_T30 */
dev_err(pci_dev_to_dev(pdev), "Invalid MAC Address\n");
err = -EIO;
goto err_eeprom;
-#endif /* CONFIG_MACH_APALIS_T30 */
}
memcpy(&adapter->mac_table[0].addr, hw->mac.addr, netdev->addr_len);
adapter->mac_table[0].queue = adapter->vfs_allocated_count;
- adapter->mac_table[0].state = (IGB_MAC_STATE_DEFAULT | IGB_MAC_STATE_IN_USE);
+ adapter->mac_table[0].state = (IGB_MAC_STATE_DEFAULT
+ | IGB_MAC_STATE_IN_USE);
igb_rar_set(adapter, 0);
/* get firmware version for ethtool -i */
igb_set_fw_version(adapter);
+ /* configure RXPBSIZE and TXPBSIZE */
+ if (hw->mac.type == e1000_i210) {
+ E1000_WRITE_REG(hw, E1000_RXPBS, I210_RXPBSIZE_DEFAULT);
+ E1000_WRITE_REG(hw, E1000_TXPBS, I210_TXPBSIZE_DEFAULT);
+ }
+
/* Check if Media Autosense is enabled */
if (hw->mac.type == e1000_82580)
igb_init_mas(adapter);
setup_timer(&adapter->watchdog_timer, &igb_watchdog,
- (unsigned long) adapter);
+ (unsigned long) adapter);
if (adapter->flags & IGB_FLAG_DETECT_BAD_DMA)
setup_timer(&adapter->dma_err_timer, &igb_dma_err_timer,
(unsigned long) adapter);
setup_timer(&adapter->phy_info_timer, &igb_update_phy_info,
- (unsigned long) adapter);
+ (unsigned long) adapter);
INIT_WORK(&adapter->reset_task, igb_reset_task);
INIT_WORK(&adapter->watchdog_task, igb_watchdog_task);
@@ -2837,8 +2838,8 @@ static int __devinit igb_probe(struct pci_dev *pdev,
/* Check the NVM for wake support for non-port A ports */
if (hw->mac.type >= e1000_82580)
hw->nvm.ops.read(hw, NVM_INIT_CONTROL3_PORT_A +
- NVM_82580_LAN_FUNC_OFFSET(hw->bus.func), 1,
- &eeprom_data);
+ NVM_82580_LAN_FUNC_OFFSET(hw->bus.func), 1,
+ &eeprom_data);
else if (hw->bus.func == 1)
e1000_read_nvm(hw, NVM_INIT_CONTROL3_PORT_B, 1, &eeprom_data);
@@ -2903,7 +2904,8 @@ static int __devinit igb_probe(struct pci_dev *pdev,
#endif /* HAVE_I2C_SUPPORT */
/* let the f/w know that the h/w is now under the control of the
- * driver. */
+ * driver.
+ */
igb_get_hw_control(adapter);
strncpy(netdev->name, "eth%d", IFNAMSIZ);
@@ -2935,19 +2937,15 @@ static int __devinit igb_probe(struct pci_dev *pdev,
dev_info(pci_dev_to_dev(pdev), "Intel(R) Gigabit Ethernet Network Connection\n");
/* print bus type/speed/width info */
dev_info(pci_dev_to_dev(pdev), "%s: (PCIe:%s:%s) ",
- netdev->name,
- ((hw->bus.speed == e1000_bus_speed_2500) ? "2.5GT/s" :
- (hw->bus.speed == e1000_bus_speed_5000) ? "5.0GT/s" :
- (hw->mac.type == e1000_i354) ? "integrated" :
- "unknown"),
- ((hw->bus.width == e1000_bus_width_pcie_x4) ? "Width x4" :
- (hw->bus.width == e1000_bus_width_pcie_x2) ? "Width x2" :
- (hw->bus.width == e1000_bus_width_pcie_x1) ? "Width x1" :
- (hw->mac.type == e1000_i354) ? "integrated" :
- "unknown"));
- dev_info(pci_dev_to_dev(pdev), "%s: MAC: ", netdev->name);
- for (i = 0; i < 6; i++)
- printk("%2.2x%c", netdev->dev_addr[i], i == 5 ? '\n' : ':');
+ netdev->name,
+ ((hw->bus.speed == e1000_bus_speed_2500) ? "2.5GT/s" :
+ (hw->bus.speed == e1000_bus_speed_5000) ? "5.0GT/s" :
+ (hw->mac.type == e1000_i354) ? "integrated" : "unknown"),
+ ((hw->bus.width == e1000_bus_width_pcie_x4) ? "Width x4" :
+ (hw->bus.width == e1000_bus_width_pcie_x2) ? "Width x2" :
+ (hw->bus.width == e1000_bus_width_pcie_x1) ? "Width x1" :
+ (hw->mac.type == e1000_i354) ? "integrated" : "unknown"));
+ netdev_info(netdev, "MAC: %pM\n", netdev->dev_addr);
ret_val = e1000_read_pba_string(hw, pba_str, E1000_PBANUM_LENGTH);
if (ret_val)
@@ -2955,7 +2953,6 @@ static int __devinit igb_probe(struct pci_dev *pdev,
dev_info(pci_dev_to_dev(pdev), "%s: PBA No: %s\n", netdev->name,
pba_str);
-
/* Initialize the thermal sensor on i350 devices. */
if (hw->mac.type == e1000_i350) {
if (hw->bus.func == 0) {
@@ -2990,7 +2987,7 @@ static int __devinit igb_probe(struct pci_dev *pdev,
case e1000_i210:
case e1000_i211:
/* Enable EEE for internal copper PHY devices */
- err = e1000_set_eee_i350(hw);
+ err = e1000_set_eee_i350(hw, true, true);
if ((!err) &&
(adapter->flags & IGB_FLAG_EEE))
adapter->eee_advert =
@@ -2999,7 +2996,7 @@ static int __devinit igb_probe(struct pci_dev *pdev,
case e1000_i354:
if ((E1000_READ_REG(hw, E1000_CTRL_EXT)) &
(E1000_CTRL_EXT_LINK_MODE_SGMII)) {
- err = e1000_set_eee_i354(hw);
+ err = e1000_set_eee_i354(hw, true, true);
if ((!err) &&
(adapter->flags & IGB_FLAG_EEE))
adapter->eee_advert =
@@ -3018,15 +3015,15 @@ static int __devinit igb_probe(struct pci_dev *pdev,
#ifndef IGB_NO_LRO
if (netdev->features & NETIF_F_LRO)
- dev_info(pci_dev_to_dev(pdev), "Internal LRO is enabled \n");
+ dev_info(pci_dev_to_dev(pdev), "Internal LRO is enabled\n");
else
- dev_info(pci_dev_to_dev(pdev), "LRO is disabled \n");
+ dev_info(pci_dev_to_dev(pdev), "LRO is disabled\n");
#endif
dev_info(pci_dev_to_dev(pdev),
- "Using %s interrupts. %d rx queue(s), %d tx queue(s)\n",
- adapter->msix_entries ? "MSI-X" :
- (adapter->flags & IGB_FLAG_HAS_MSI) ? "MSI" : "legacy",
- adapter->num_rx_queues, adapter->num_tx_queues);
+ "Using %s interrupts. %d rx queue(s), %d tx queue(s)\n",
+ adapter->msix_entries ? "MSI-X" :
+ (adapter->flags & IGB_FLAG_HAS_MSI) ? "MSI" : "legacy",
+ adapter->num_rx_queues, adapter->num_tx_queues);
cards_found++;
@@ -3052,7 +3049,7 @@ err_ioremap:
free_netdev(netdev);
err_alloc_etherdev:
pci_release_selected_regions(pdev,
- pci_select_bars(pdev, IORESOURCE_MEM));
+ pci_select_bars(pdev, IORESOURCE_MEM));
err_pci_reg:
err_dma:
pci_disable_device(pdev);
@@ -3081,7 +3078,7 @@ static void igb_remove_i2c(struct igb_adapter *adapter)
* Hot-Plug event, or because the driver is going to be removed from
* memory.
**/
-static void __devexit igb_remove(struct pci_dev *pdev)
+static void igb_remove(struct pci_dev *pdev)
{
struct net_device *netdev = pci_get_drvdata(pdev);
struct igb_adapter *adapter = netdev_priv(netdev);
@@ -3130,7 +3127,7 @@ static void __devexit igb_remove(struct pci_dev *pdev)
if (hw->flash_address)
iounmap(hw->flash_address);
pci_release_selected_regions(pdev,
- pci_select_bars(pdev, IORESOURCE_MEM));
+ pci_select_bars(pdev, IORESOURCE_MEM));
#ifdef IGB_HWMON
igb_sysfs_exit(adapter);
@@ -3156,7 +3153,7 @@ static void __devexit igb_remove(struct pci_dev *pdev)
* Fields are initialized based on PCI device information and
* OS network device settings (MTU size).
**/
-static int __devinit igb_sw_init(struct igb_adapter *adapter)
+static int igb_sw_init(struct igb_adapter *adapter)
{
struct e1000_hw *hw = &adapter->hw;
struct net_device *netdev = adapter->netdev;
@@ -3196,13 +3193,12 @@ static int __devinit igb_sw_init(struct igb_adapter *adapter)
GFP_ATOMIC);
/* Setup and initialize a copy of the hw vlan table array */
- adapter->shadow_vfta = (u32 *)kzalloc(sizeof(u32) * E1000_VFTA_ENTRIES,
+ adapter->shadow_vfta = kzalloc(sizeof(u32) * E1000_VFTA_ENTRIES,
GFP_ATOMIC);
/* These calls may decrease the number of queues */
- if (hw->mac.type < e1000_i210) {
+ if (hw->mac.type < e1000_i210)
igb_set_sriov_capability(adapter);
- }
if (igb_init_interrupt_scheme(adapter, true)) {
dev_err(pci_dev_to_dev(pdev), "Unable to allocate memory for queues\n");
@@ -3299,6 +3295,7 @@ static int __igb_open(struct net_device *netdev, bool resuming)
/* notify VFs that reset has been completed */
if (adapter->vfs_allocated_count) {
u32 reg_data = E1000_READ_REG(hw, E1000_CTRL_EXT);
+
reg_data |= E1000_CTRL_EXT_PFRSTD;
E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg_data);
}
@@ -3499,7 +3496,7 @@ static u32 igb_tx_wthresh(struct igb_adapter *adapter)
* Configure a transmit ring after a reset.
**/
void igb_configure_tx_ring(struct igb_adapter *adapter,
- struct igb_ring *ring)
+ struct igb_ring *ring)
{
struct e1000_hw *hw = &adapter->hw;
u32 txdctl = 0;
@@ -3512,9 +3509,9 @@ void igb_configure_tx_ring(struct igb_adapter *adapter,
mdelay(10);
E1000_WRITE_REG(hw, E1000_TDLEN(reg_idx),
- ring->count * sizeof(union e1000_adv_tx_desc));
+ ring->count * sizeof(union e1000_adv_tx_desc));
E1000_WRITE_REG(hw, E1000_TDBAL(reg_idx),
- tdba & 0x00000000ffffffffULL);
+ tdba & 0x00000000ffffffffULL);
E1000_WRITE_REG(hw, E1000_TDBAH(reg_idx), tdba >> 32);
ring->tail = hw->hw_addr + E1000_TDT(reg_idx);
@@ -3580,8 +3577,8 @@ int igb_setup_rx_resources(struct igb_ring *rx_ring)
err:
vfree(rx_ring->rx_buffer_info);
rx_ring->rx_buffer_info = NULL;
- dev_err(dev, "Unable to allocate memory for the receive descriptor"
- " ring\n");
+ dev_err(dev,
+ "Unable to allocate memory for the receive descriptor ring\n");
return -ENOMEM;
}
@@ -3642,7 +3639,8 @@ static void igb_setup_mrqc(struct igb_adapter *adapter)
}
if (adapter->rss_indir_tbl_init != num_rx_queues) {
for (j = 0; j < IGB_RETA_SIZE; j++)
- adapter->rss_indir_tbl[j] = (j * num_rx_queues) / IGB_RETA_SIZE;
+ adapter->rss_indir_tbl[j] =
+ (j * num_rx_queues) / IGB_RETA_SIZE;
adapter->rss_indir_tbl_init = num_rx_queues;
}
igb_write_rss_indir_tbl(adapter);
@@ -3673,9 +3671,9 @@ static void igb_setup_mrqc(struct igb_adapter *adapter)
* those with the results with n+1 and n+3.
*/
for (j = 0; j < 32; j++) {
- /* first pass generates n and n+2 */
- u32 base = ((j * 0x00040004) + 0x00020000) * num_rx_queues;
- u32 reta = (base & 0x07800780) >> (7 - shift);
+ /* first pass generates n and n+2 */
+ u32 base = ((j * 0x00040004) + 0x00020000) * num_rx_queues;
+ u32 reta = (base & 0x07800780) >> (7 - shift);
/* second pass generates n+1 and n+3 */
base += 0x00010001 * num_rx_queues;
@@ -3725,6 +3723,7 @@ static void igb_setup_mrqc(struct igb_adapter *adapter)
if (hw->mac.type > e1000_82575) {
/* Set the default pool for the PF's first queue */
u32 vtctl = E1000_READ_REG(hw, E1000_VT_CTL);
+
vtctl &= ~(E1000_VT_CTL_DEFAULT_POOL_MASK |
E1000_VT_CTL_DISABLE_DEF_POOL);
vtctl |= adapter->vfs_allocated_count <<
@@ -3790,7 +3789,7 @@ void igb_setup_rctl(struct igb_adapter *adapter)
}
static inline int igb_set_vf_rlpml(struct igb_adapter *adapter, int size,
- int vfn)
+ int vfn)
{
struct e1000_hw *hw = &adapter->hw;
u32 vmolr;
@@ -3913,7 +3912,7 @@ static inline void igb_set_vmolr(struct igb_adapter *adapter,
* Configure the Rx unit of the MAC after a reset.
**/
void igb_configure_rx_ring(struct igb_adapter *adapter,
- struct igb_ring *ring)
+ struct igb_ring *ring)
{
struct e1000_hw *hw = &adapter->hw;
u64 rdba = ring->dma;
@@ -3935,10 +3934,10 @@ void igb_configure_rx_ring(struct igb_adapter *adapter,
/* Set DMA base address registers */
E1000_WRITE_REG(hw, E1000_RDBAL(reg_idx),
- rdba & 0x00000000ffffffffULL);
+ rdba & 0x00000000ffffffffULL);
E1000_WRITE_REG(hw, E1000_RDBAH(reg_idx), rdba >> 32);
E1000_WRITE_REG(hw, E1000_RDLEN(reg_idx),
- ring->count * sizeof(union e1000_adv_rx_desc));
+ ring->count * sizeof(union e1000_adv_rx_desc));
/* initialize head and tail */
ring->tail = hw->hw_addr + E1000_RDT(reg_idx);
@@ -3958,7 +3957,7 @@ void igb_configure_rx_ring(struct igb_adapter *adapter,
srrctl |= IGB_RX_BUFSZ >> E1000_SRRCTL_BSIZEPKT_SHIFT;
#else /* CONFIG_IGB_DISABLE_PACKET_SPLIT */
srrctl = ALIGN(ring->rx_buffer_len, 1024) >>
- E1000_SRRCTL_BSIZEPKT_SHIFT;
+ E1000_SRRCTL_BSIZEPKT_SHIFT;
#endif /* CONFIG_IGB_DISABLE_PACKET_SPLIT */
srrctl |= E1000_SRRCTL_DESCTYPE_ADV_ONEBUF;
#ifdef HAVE_PTP_1588_CLOCK
@@ -4061,14 +4060,14 @@ void igb_unmap_and_free_tx_resource(struct igb_ring *ring,
dev_kfree_skb_any(tx_buffer->skb);
if (dma_unmap_len(tx_buffer, len))
dma_unmap_single(ring->dev,
- dma_unmap_addr(tx_buffer, dma),
- dma_unmap_len(tx_buffer, len),
- DMA_TO_DEVICE);
+ dma_unmap_addr(tx_buffer, dma),
+ dma_unmap_len(tx_buffer, len),
+ DMA_TO_DEVICE);
} else if (dma_unmap_len(tx_buffer, len)) {
dma_unmap_page(ring->dev,
- dma_unmap_addr(tx_buffer, dma),
- dma_unmap_len(tx_buffer, len),
- DMA_TO_DEVICE);
+ dma_unmap_addr(tx_buffer, dma),
+ dma_unmap_len(tx_buffer, len),
+ DMA_TO_DEVICE);
}
tx_buffer->next_to_watch = NULL;
tx_buffer->skb = NULL;
@@ -4180,7 +4179,7 @@ void igb_clean_rx_ring(struct igb_ring *rx_ring)
#ifdef CONFIG_IGB_DISABLE_PACKET_SPLIT
if (buffer_info->dma) {
dma_unmap_single(rx_ring->dev,
- buffer_info->dma,
+ buffer_info->dma,
rx_ring->rx_buffer_len,
DMA_FROM_DEVICE);
buffer_info->dma = 0;
@@ -4326,40 +4325,12 @@ int igb_write_mc_addr_list(struct net_device *netdev)
return count;
}
-void igb_rar_set(struct igb_adapter *adapter, u32 index)
-{
- u32 rar_low, rar_high;
- struct e1000_hw *hw = &adapter->hw;
- u8 *addr = adapter->mac_table[index].addr;
- /* HW expects these in little endian so we reverse the byte order
- * from network order (big endian) to little endian
- */
- rar_low = ((u32) addr[0] | ((u32) addr[1] << 8) |
- ((u32) addr[2] << 16) | ((u32) addr[3] << 24));
- rar_high = ((u32) addr[4] | ((u32) addr[5] << 8));
-
- /* Indicate to hardware the Address is Valid. */
- if (adapter->mac_table[index].state & IGB_MAC_STATE_IN_USE)
- rar_high |= E1000_RAH_AV;
-
- if (hw->mac.type == e1000_82575)
- rar_high |= E1000_RAH_POOL_1 * adapter->mac_table[index].queue;
- else
- rar_high |= E1000_RAH_POOL_1 << adapter->mac_table[index].queue;
-
- E1000_WRITE_REG(hw, E1000_RAL(index), rar_low);
- E1000_WRITE_FLUSH(hw);
- E1000_WRITE_REG(hw, E1000_RAH(index), rar_high);
- E1000_WRITE_FLUSH(hw);
-}
-
void igb_full_sync_mac_table(struct igb_adapter *adapter)
{
struct e1000_hw *hw = &adapter->hw;
int i;
- for (i = 0; i < hw->mac.rar_entry_count; i++) {
+ for (i = 0; i < hw->mac.rar_entry_count; i++)
igb_rar_set(adapter, i);
- }
}
void igb_sync_mac_table(struct igb_adapter *adapter)
@@ -4538,7 +4509,7 @@ static void igb_set_rx_mode(struct net_device *netdev)
return;
vmolr |= E1000_READ_REG(hw, E1000_VMOLR(vfn)) &
- ~(E1000_VMOLR_ROPE | E1000_VMOLR_MPME | E1000_VMOLR_ROMPE);
+ ~(E1000_VMOLR_ROPE | E1000_VMOLR_MPME | E1000_VMOLR_ROMPE);
E1000_WRITE_REG(hw, E1000_VMOLR(vfn), vmolr);
igb_restore_vf_multicasts(adapter);
}
@@ -4551,7 +4522,8 @@ static void igb_check_wvbr(struct igb_adapter *adapter)
switch (hw->mac.type) {
case e1000_82576:
case e1000_i350:
- if (!(wvbr = E1000_READ_REG(hw, E1000_WVBR)))
+ wvbr = E1000_READ_REG(hw, E1000_WVBR);
+ if (!wvbr)
return;
break;
default:
@@ -4574,12 +4546,15 @@ static void igb_spoof_check(struct igb_adapter *adapter)
case e1000_82576:
for (j = 0; j < adapter->vfs_allocated_count; j++) {
if (adapter->wvbr & (1 << j) ||
- adapter->wvbr & (1 << (j + IGB_STAGGERED_QUEUE_OFFSET))) {
+ adapter->wvbr & (1 << (j
+ + IGB_STAGGERED_QUEUE_OFFSET))) {
DPRINTK(DRV, WARNING,
- "Spoof event(s) detected on VF %d\n", j);
+ "Spoof event(s) detected on VF %d\n",
+ j);
adapter->wvbr &=
~((1 << j) |
- (1 << (j + IGB_STAGGERED_QUEUE_OFFSET)));
+ (1 << (j +
+ IGB_STAGGERED_QUEUE_OFFSET)));
}
}
break;
@@ -4587,7 +4562,8 @@ static void igb_spoof_check(struct igb_adapter *adapter)
for (j = 0; j < adapter->vfs_allocated_count; j++) {
if (adapter->wvbr & (1 << j)) {
DPRINTK(DRV, WARNING,
- "Spoof event(s) detected on VF %d\n", j);
+ "Spoof event(s) detected on VF %d\n",
+ j);
adapter->wvbr &= ~(1 << j);
}
}
@@ -4660,8 +4636,8 @@ static void igb_watchdog(unsigned long data)
static void igb_watchdog_task(struct work_struct *work)
{
struct igb_adapter *adapter = container_of(work,
- struct igb_adapter,
- watchdog_task);
+ struct igb_adapter,
+ watchdog_task);
struct e1000_hw *hw = &adapter->hw;
struct net_device *netdev = adapter->netdev;
u32 thstat, ctrl_ext, link;
@@ -4698,22 +4674,23 @@ static void igb_watchdog_task(struct work_struct *work)
if (!netif_carrier_ok(netdev)) {
u32 ctrl;
+
e1000_get_speed_and_duplex(hw,
- &adapter->link_speed,
- &adapter->link_duplex);
+ &adapter->link_speed,
+ &adapter->link_duplex);
ctrl = E1000_READ_REG(hw, E1000_CTRL);
/* Links status message must follow this format */
- printk(KERN_INFO "igb: %s NIC Link is Up %d Mbps %s, "
- "Flow Control: %s\n",
- netdev->name,
- adapter->link_speed,
- adapter->link_duplex == FULL_DUPLEX ?
+ netdev_info(netdev,
+ "igb: %s NIC Link is Up %d Mbps %s, Flow Control: %s\n",
+ netdev->name,
+ adapter->link_speed,
+ adapter->link_duplex == FULL_DUPLEX ?
"Full Duplex" : "Half Duplex",
- ((ctrl & E1000_CTRL_TFCE) &&
- (ctrl & E1000_CTRL_RFCE)) ? "RX/TX":
- ((ctrl & E1000_CTRL_RFCE) ? "RX" :
- ((ctrl & E1000_CTRL_TFCE) ? "TX" : "None")));
+ ((ctrl & E1000_CTRL_TFCE) &&
+ (ctrl & E1000_CTRL_RFCE)) ? "RX/TX" :
+ ((ctrl & E1000_CTRL_RFCE) ? "RX" :
+ ((ctrl & E1000_CTRL_TFCE) ? "TX" : "None")));
/* adjust timeout factor according to speed/duplex */
adapter->tx_timeout_factor = 1;
switch (adapter->link_speed) {
@@ -4753,26 +4730,21 @@ static void igb_watchdog_task(struct work_struct *work)
!(ctrl_ext &
E1000_CTRL_EXT_LINK_MODE_SGMII)) {
if (thstat & E1000_THSTAT_PWR_DOWN) {
- printk(KERN_ERR "igb: %s The "
- "network adapter was stopped "
- "because it overheated.\n",
- netdev->name);
+ netdev_err(netdev,
+ "igb: %s The network adapter was stopped because it overheated.\n",
+ netdev->name);
}
- if (thstat & E1000_THSTAT_LINK_THROTTLE) {
- printk(KERN_INFO
- "igb: %s The network "
- "adapter supported "
- "link speed "
- "was downshifted "
- "because it "
- "overheated.\n",
+ if (thstat &
+ E1000_THSTAT_LINK_THROTTLE) {
+ netdev_err(netdev,
+ "igb: %s The network adapter supported link speed was downshifted because it overheated.\n",
netdev->name);
}
}
}
/* Links status message must follow this format */
- printk(KERN_INFO "igb: %s NIC Link is Down\n",
+ netdev_info(netdev, "igb: %s NIC Link is Down\n",
netdev->name);
netif_carrier_off(netdev);
netif_tx_stop_all_queues(netdev);
@@ -4832,6 +4804,7 @@ static void igb_watchdog_task(struct work_struct *work)
/* Cause software interrupt to ensure rx ring is cleaned */
if (adapter->msix_entries) {
u32 eics = 0;
+
for (i = 0; i < adapter->num_q_vectors; i++)
eics |= adapter->q_vector[i]->eims_value;
E1000_WRITE_REG(hw, E1000_EICS, eics);
@@ -4855,8 +4828,8 @@ static void igb_watchdog_task(struct work_struct *work)
static void igb_dma_err_task(struct work_struct *work)
{
struct igb_adapter *adapter = container_of(work,
- struct igb_adapter,
- dma_err_task);
+ struct igb_adapter,
+ dma_err_task);
int vf;
struct e1000_hw *hw = &adapter->hw;
struct net_device *netdev = adapter->netdev;
@@ -4965,7 +4938,7 @@ static void igb_update_ring_itr(struct igb_q_vector *q_vector)
packets = q_vector->tx.total_packets;
if (packets)
avg_wire_size = max_t(u32, avg_wire_size,
- q_vector->tx.total_bytes / packets);
+ q_vector->tx.total_bytes / packets);
/* if avg_wire_size isn't set no work was done */
if (!avg_wire_size)
@@ -5119,10 +5092,9 @@ set_itr_now:
* by adding intermediate steps when interrupt rate is
* increasing */
new_itr = new_itr > q_vector->itr_val ?
- max((new_itr * q_vector->itr_val) /
- (new_itr + (q_vector->itr_val >> 2)),
- new_itr) :
- new_itr;
+ max((new_itr * q_vector->itr_val) /
+ (new_itr + (q_vector->itr_val >> 2)),
+ new_itr) : new_itr;
/* Don't write the value here; it resets the adapter's
* internal timer, and causes us to delay far longer than
* we should between interrupts. Instead, we write the ITR
@@ -5177,6 +5149,7 @@ static int igb_tso(struct igb_ring *tx_ring,
if (skb_header_cloned(skb)) {
int err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
+
if (err)
return err;
}
@@ -5184,7 +5157,7 @@ static int igb_tso(struct igb_ring *tx_ring,
/* ADV DTYP TUCMD MKRLOC/ISCSIHEDLEN */
type_tucmd = E1000_ADVTXD_TUCMD_L4T_TCP;
- if (first->protocol == __constant_htons(ETH_P_IP)) {
+ if (first->protocol == htons(ETH_P_IP)) {
struct iphdr *iph = ip_hdr(skb);
iph->tot_len = 0;
iph->check = 0;
@@ -5242,6 +5215,7 @@ static void igb_tx_csum(struct igb_ring *tx_ring, struct igb_tx_buffer *first)
return;
} else {
u8 nexthdr = 0;
+
switch (first->protocol) {
case __constant_htons(ETH_P_IP):
vlan_macip_lens |= skb_network_header_len(skb);
@@ -5550,13 +5524,21 @@ netdev_tx_t igb_xmit_frame_ring(struct sk_buff *skb,
first->bytecount = skb->len;
first->gso_segs = 1;
- skb_tx_timestamp(skb);
-
#ifdef HAVE_PTP_1588_CLOCK
+#ifdef SKB_SHARED_TX_IS_UNION
+ if (unlikely(skb_tx(skb)->hardware)) {
+#else
if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) {
+#endif
struct igb_adapter *adapter = netdev_priv(tx_ring->netdev);
- if (!adapter->ptp_tx_skb) {
+
+ if (!test_and_set_bit_lock(__IGB_PTP_TX_IN_PROGRESS,
+ &adapter->state)) {
+#ifdef SKB_SHARED_TX_IS_UNION
+ skb_tx(skb)->in_progress = 1;
+#else
skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
+#endif
tx_flags |= IGB_TX_FLAGS_TSTAMP;
adapter->ptp_tx_skb = skb_get(skb);
@@ -5566,7 +5548,7 @@ netdev_tx_t igb_xmit_frame_ring(struct sk_buff *skb,
}
}
#endif /* HAVE_PTP_1588_CLOCK */
-
+ skb_tx_timestamp(skb);
if (vlan_tx_tag_present(skb)) {
tx_flags |= IGB_TX_FLAGS_VLAN;
tx_flags |= (vlan_tx_tag_get(skb) << IGB_TX_FLAGS_VLAN_SHIFT);
@@ -5601,7 +5583,7 @@ out_drop:
#ifdef HAVE_TX_MQ
static inline struct igb_ring *igb_tx_queue_mapping(struct igb_adapter *adapter,
- struct sk_buff *skb)
+ struct sk_buff *skb)
{
unsigned int r_idx = skb->queue_mapping;
@@ -5611,11 +5593,11 @@ static inline struct igb_ring *igb_tx_queue_mapping(struct igb_adapter *adapter,
return adapter->tx_ring[r_idx];
}
#else
-#define igb_tx_queue_mapping(_adapter, _skb) (_adapter)->tx_ring[0]
+#define igb_tx_queue_mapping(_adapter, _skb) ((_adapter)->tx_ring[0])
#endif
static netdev_tx_t igb_xmit_frame(struct sk_buff *skb,
- struct net_device *netdev)
+ struct net_device *netdev)
{
struct igb_adapter *adapter = netdev_priv(netdev);
@@ -5732,7 +5714,7 @@ static int igb_change_mtu(struct net_device *netdev, int new_mtu)
igb_down(adapter);
dev_info(pci_dev_to_dev(pdev), "changing MTU from %d to %d\n",
- netdev->mtu, new_mtu);
+ netdev->mtu, new_mtu);
netdev->mtu = new_mtu;
hw->dev_spec._82575.mtu = new_mtu;
@@ -5799,8 +5781,11 @@ void igb_update_stats(struct igb_adapter *adapter)
bytes = 0;
packets = 0;
for (i = 0; i < adapter->num_rx_queues; i++) {
- u32 rqdpc_tmp = E1000_READ_REG(hw, E1000_RQDPC(i)) & 0x0FFF;
struct igb_ring *ring = adapter->rx_ring[i];
+ u32 rqdpc_tmp = E1000_READ_REG(hw, E1000_RQDPC(i)) & 0x0FFF;
+
+ if (hw->mac.type >= e1000_i210)
+ E1000_WRITE_REG(hw, E1000_RQDPC(i), 0);
ring->rx_stats.drops += rqdpc_tmp;
net_stats->rx_fifo_errors += rqdpc_tmp;
#ifdef CONFIG_IGB_VMDQ_NETDEV
@@ -6152,7 +6137,8 @@ static int __igb_notify_dca(struct device *dev, void *data)
dca_remove_requester(dev);
dev_info(pci_dev_to_dev(pdev), "DCA disabled\n");
adapter->flags &= ~IGB_FLAG_DCA_ENABLED;
- E1000_WRITE_REG(hw, E1000_DCA_CTRL, E1000_DCA_CTRL_DCA_DISABLE);
+ E1000_WRITE_REG(hw, E1000_DCA_CTRL,
+ E1000_DCA_CTRL_DCA_DISABLE);
}
break;
}
@@ -6161,12 +6147,12 @@ static int __igb_notify_dca(struct device *dev, void *data)
}
static int igb_notify_dca(struct notifier_block *nb, unsigned long event,
- void *p)
+ void *p)
{
int ret_val;
ret_val = driver_for_each_device(&igb_driver.driver, NULL, &event,
- __igb_notify_dca);
+ __igb_notify_dca);
return ret_val ? NOTIFY_BAD : NOTIFY_DONE;
}
@@ -6247,7 +6233,7 @@ static int igb_set_vf_promisc(struct igb_adapter *adapter, u32 *msgbuf, u32 vf)
struct vf_data_storage *vf_data = &adapter->vf_data[vf];
vf_data->flags &= ~(IGB_VF_FLAG_UNI_PROMISC |
- IGB_VF_FLAG_MULTI_PROMISC);
+ IGB_VF_FLAG_MULTI_PROMISC);
vmolr &= ~(E1000_VMOLR_ROPE | E1000_VMOLR_ROMPE | E1000_VMOLR_MPME);
#ifdef IGB_ENABLE_VF_PROMISC
@@ -6271,6 +6257,7 @@ static int igb_set_vf_promisc(struct igb_adapter *adapter, u32 *msgbuf, u32 vf)
vmolr |= E1000_VMOLR_MPME;
} else if (vf_data->num_vf_mc_hashes) {
int j;
+
vmolr |= E1000_VMOLR_ROMPE;
for (j = 0; j < vf_data->num_vf_mc_hashes; j++)
igb_mta_set(adapter, vf_data->vf_mc_hashes[j]);
@@ -6323,6 +6310,7 @@ static void igb_restore_vf_multicasts(struct igb_adapter *adapter)
for (i = 0; i < adapter->vfs_allocated_count; i++) {
u32 vmolr = E1000_READ_REG(hw, E1000_VMOLR(i));
+
vmolr &= ~(E1000_VMOLR_ROMPE | E1000_VMOLR_MPME);
vf_data = &adapter->vf_data[i];
@@ -6426,6 +6414,7 @@ s32 igb_vlvf_set(struct igb_adapter *adapter, u32 vid, bool add, u32 vf)
if (!adapter->vf_data[vf].vlans_enabled) {
u32 size;
+
reg = E1000_READ_REG(hw, E1000_VMOLR(vf));
size = reg & E1000_VMOLR_RLPML_MASK;
size += 4;
@@ -6454,6 +6443,7 @@ s32 igb_vlvf_set(struct igb_adapter *adapter, u32 vid, bool add, u32 vf)
adapter->vf_data[vf].vlans_enabled--;
if (!adapter->vf_data[vf].vlans_enabled) {
u32 size;
+
reg = E1000_READ_REG(hw, E1000_VMOLR(vf));
size = reg & E1000_VMOLR_RLPML_MASK;
size -= 4;
@@ -6472,7 +6462,8 @@ static void igb_set_vmvir(struct igb_adapter *adapter, u32 vid, u32 vf)
struct e1000_hw *hw = &adapter->hw;
if (vid)
- E1000_WRITE_REG(hw, E1000_VMVIR(vf), (vid | E1000_VMVIR_VLANA_DEFAULT));
+ E1000_WRITE_REG(hw, E1000_VMVIR(vf),
+ (vid | E1000_VMVIR_VLANA_DEFAULT));
else
E1000_WRITE_REG(hw, E1000_VMVIR(vf), 0);
}
@@ -6484,7 +6475,8 @@ static int igb_ndo_set_vf_vlan(struct net_device *netdev,
struct igb_adapter *adapter = netdev_priv(netdev);
/* VLAN IDs accepted range 0-4094 */
- if ((vf >= adapter->vfs_allocated_count) || (vlan > VLAN_VID_MASK-1) || (qos > 7))
+ if ((vf >= adapter->vfs_allocated_count) || (vlan > VLAN_VID_MASK-1)
+ || (qos > 7))
return -EINVAL;
if (vlan || qos) {
err = igb_vlvf_set(adapter, vlan, !!vlan, vf);
@@ -6499,11 +6491,9 @@ static int igb_ndo_set_vf_vlan(struct net_device *netdev,
"Setting VLAN %d, QOS 0x%x on VF %d\n", vlan, qos, vf);
if (test_bit(__IGB_DOWN, &adapter->state)) {
dev_warn(&adapter->pdev->dev,
- "The VF VLAN has been set,"
- " but the PF device is not up.\n");
+ "The VF VLAN has been set, but the PF device is not up.\n");
dev_warn(&adapter->pdev->dev,
- "Bring the PF device up before"
- " attempting to use the VF device.\n");
+ "Bring the PF device up before attempting to use the VF device.\n");
}
} else {
if (adapter->vf_data[vf].pf_vlan)
@@ -6516,9 +6506,9 @@ static int igb_ndo_set_vf_vlan(struct net_device *netdev,
igb_set_vf_vlan_strip(adapter, vf, false);
adapter->vf_data[vf].pf_vlan = 0;
adapter->vf_data[vf].pf_qos = 0;
- }
+ }
out:
- return err;
+ return err;
}
#ifdef HAVE_VF_SPOOFCHK_CONFIGURE
@@ -6784,9 +6774,8 @@ static void igb_rcv_msg_from_vf(struct igb_adapter *adapter, u32 vf)
retval = igb_set_vf_mac_addr(adapter, msgbuf, vf);
else
DPRINTK(DRV, INFO,
- "VF %d attempted to override administratively "
- "set MAC address\nReload the VF driver to "
- "resume operations\n", vf);
+ "VF %d attempted to override administratively set MAC address\nReload the VF driver to resume operations\n",
+ vf);
#endif
break;
case E1000_VF_SET_PROMISC:
@@ -6803,15 +6792,15 @@ static void igb_rcv_msg_from_vf(struct igb_adapter *adapter, u32 vf)
#ifdef IFLA_VF_MAX
if (vf_data->pf_vlan)
DPRINTK(DRV, INFO,
- "VF %d attempted to override administratively "
- "set VLAN tag\nReload the VF driver to "
- "resume operations\n", vf);
+ "VF %d attempted to override administratively set VLAN tag\nReload the VF driver to resume operations\n",
+ vf);
else
#endif
retval = igb_set_vf_vlan(adapter, msgbuf, vf);
break;
default:
- dev_err(pci_dev_to_dev(pdev), "Unhandled Msg %08x\n", msgbuf[0]);
+ dev_err(pci_dev_to_dev(pdev), "Unhandled Msg %08x\n",
+ msgbuf[0]);
retval = -E1000_ERR_MBX;
break;
}
@@ -7003,7 +6992,8 @@ void igb_ring_irq_enable(struct igb_q_vector *q_vector)
**/
static int igb_poll(struct napi_struct *napi, int budget)
{
- struct igb_q_vector *q_vector = container_of(napi, struct igb_q_vector, napi);
+ struct igb_q_vector *q_vector = container_of(napi,
+ struct igb_q_vector, napi);
bool clean_complete = true;
#ifdef IGB_DCA
@@ -7081,9 +7071,9 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector)
/* unmap skb header data */
dma_unmap_single(tx_ring->dev,
- dma_unmap_addr(tx_buffer, dma),
- dma_unmap_len(tx_buffer, len),
- DMA_TO_DEVICE);
+ dma_unmap_addr(tx_buffer, dma),
+ dma_unmap_len(tx_buffer, len),
+ DMA_TO_DEVICE);
/* clear tx_buffer data */
tx_buffer->skb = NULL;
@@ -7103,9 +7093,9 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector)
/* unmap any remaining paged data */
if (dma_unmap_len(tx_buffer, len)) {
dma_unmap_page(tx_ring->dev,
- dma_unmap_addr(tx_buffer, dma),
- dma_unmap_len(tx_buffer, len),
- DMA_TO_DEVICE);
+ dma_unmap_addr(tx_buffer, dma),
+ dma_unmap_len(tx_buffer, len),
+ DMA_TO_DEVICE);
dma_unmap_len_set(tx_buffer, len, 0);
}
}
@@ -7129,7 +7119,7 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector)
netdev_tx_completed_queue(txring_txq(tx_ring),
total_packets, total_bytes);
-
+
i += tx_ring->count;
tx_ring->next_to_clean = i;
tx_ring->tx_stats.bytes += total_bytes;
@@ -7150,9 +7140,9 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector)
clear_bit(IGB_RING_FLAG_TX_DETECT_HANG, &tx_ring->flags);
if (tx_buffer->next_to_watch &&
time_after(jiffies, tx_buffer->time_stamp +
- (adapter->tx_timeout_factor * HZ))
+ (adapter->tx_timeout_factor * HZ))
&& !(E1000_READ_REG(hw, E1000_STATUS) &
- E1000_STATUS_TXOFF)) {
+ E1000_STATUS_TXOFF)) {
/* detected Tx unit hang */
#ifdef DEBUG
@@ -7209,7 +7199,7 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector)
smp_mb();
if (netif_is_multiqueue(netdev_ring(tx_ring))) {
if (__netif_subqueue_stopped(netdev_ring(tx_ring),
- ring_queue_index(tx_ring)) &&
+ ring_queue_index(tx_ring)) &&
!(test_bit(__IGB_DOWN, &adapter->state))) {
netif_wake_subqueue(netdev_ring(tx_ring),
ring_queue_index(tx_ring));
@@ -7234,7 +7224,7 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector)
* @skb: packet to send up
**/
static void igb_receive_skb(struct igb_q_vector *q_vector,
- struct sk_buff *skb)
+ struct sk_buff *skb)
{
struct vlan_group **vlgrp = netdev_priv(skb->dev);
@@ -7272,7 +7262,7 @@ static void igb_reuse_rx_page(struct igb_ring *rx_ring,
rx_ring->next_to_alloc = (nta < rx_ring->count) ? nta : 0;
/* transfer page from old buffer to new buffer */
- memcpy(new_buff, old_buff, sizeof(struct igb_rx_buffer));
+ *new_buff = *old_buff;
/* sync the buffer for use by the device */
dma_sync_single_range_for_device(rx_ring->dev, old_buff->dma,
@@ -7471,7 +7461,9 @@ static inline void igb_rx_hash(struct igb_ring *ring,
struct sk_buff *skb)
{
if (netdev_ring(ring)->features & NETIF_F_RXHASH)
- skb->rxhash = le32_to_cpu(rx_desc->wb.lower.hi_dword.rss);
+ skb_set_hash(skb,
+ le32_to_cpu(rx_desc->wb.lower.hi_dword.rss),
+ PKT_HASH_TYPE_L3);
}
#endif
@@ -7510,7 +7502,8 @@ static inline struct sk_buff *igb_merge_active_tail(struct sk_buff *tail)
* will still be receiving data so we cannot yet ad it's stats to the main
* skb. That is done via igb_merge_active_tail.
**/
-static inline void igb_add_active_tail(struct sk_buff *head, struct sk_buff *tail)
+static inline void igb_add_active_tail(struct sk_buff *head,
+ struct sk_buff *tail)
{
struct sk_buff *old_tail = IGB_CB(head)->tail;
@@ -7564,7 +7557,7 @@ static inline bool igb_can_lro(struct igb_ring *rx_ring,
__le16 pkt_info = rx_desc->wb.lower.lo_dword.hs_rss.pkt_info;
/* verify hardware indicates this is IPv4/TCP */
- if((!(pkt_info & cpu_to_le16(E1000_RXDADV_PKTTYPE_TCP)) ||
+ if ((!(pkt_info & cpu_to_le16(E1000_RXDADV_PKTTYPE_TCP)) ||
!(pkt_info & cpu_to_le16(E1000_RXDADV_PKTTYPE_IPV4))))
return false;
@@ -7581,7 +7574,7 @@ static inline bool igb_can_lro(struct igb_ring *rx_ring,
return false;
/* .. and there are no VLANs on packet */
- if (skb->protocol != __constant_htons(ETH_P_IP))
+ if (skb->protocol != htons(ETH_P_IP))
return false;
/* .. and we are version 4 with no options */
@@ -7642,6 +7635,9 @@ static void igb_lro_flush(struct igb_q_vector *q_vector,
}
#ifdef NETIF_F_GSO
+#ifdef NAPI_GRO_CB
+ NAPI_GRO_CB(skb)->data_offset = 0;
+#endif
skb_shinfo(skb)->gso_size = IGB_CB(skb)->mss;
skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
#endif
@@ -7975,9 +7971,11 @@ static void igb_process_skb_fields(struct igb_ring *rx_ring,
}
#ifdef HAVE_PTP_1588_CLOCK
- igb_ptp_rx_hwtstamp(rx_ring, rx_desc, skb);
-#endif /* HAVE_PTP_1588_CLOCK */
+ if (igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TS) &&
+ !igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TSIP))
+ igb_ptp_rx_rgtstamp(rx_ring->q_vector, skb);
+#endif /* HAVE_PTP_1588_CLOCK */
#ifdef NETIF_F_HW_VLAN_CTAG_RX
if ((dev->features & NETIF_F_HW_VLAN_CTAG_RX) &&
#else
@@ -7985,6 +7983,7 @@ static void igb_process_skb_fields(struct igb_ring *rx_ring,
#endif
igb_test_staterr(rx_desc, E1000_RXD_STAT_VP)) {
u16 vid = 0;
+
if (igb_test_staterr(rx_desc, E1000_RXDEXT_STATERR_LB) &&
test_bit(IGB_RING_FLAG_RX_LB_VLAN_BSWAP, &rx_ring->flags))
vid = be16_to_cpu(rx_desc->wb.upper.vlan);
@@ -8130,116 +8129,6 @@ static bool igb_clean_rx_irq(struct igb_q_vector *q_vector, int budget)
}
#else /* CONFIG_IGB_DISABLE_PACKET_SPLIT */
/**
- * igb_get_headlen - determine size of header for LRO/GRO
- * @data: pointer to the start of the headers
- * @max_len: total length of section to find headers in
- *
- * This function is meant to determine the length of headers that will
- * be recognized by hardware for LRO, and GRO offloads. The main
- * motivation of doing this is to only perform one pull for IPv4 TCP
- * packets so that we can do basic things like calculating the gso_size
- * based on the average data per packet.
- **/
-static unsigned int igb_get_headlen(unsigned char *data,
- unsigned int max_len)
-{
- union {
- unsigned char *network;
- /* l2 headers */
- struct ethhdr *eth;
- struct vlan_hdr *vlan;
- /* l3 headers */
- struct iphdr *ipv4;
- struct ipv6hdr *ipv6;
- } hdr;
- __be16 protocol;
- u8 nexthdr = 0; /* default to not TCP */
- u8 hlen;
-
- /* this should never happen, but better safe than sorry */
- if (max_len < ETH_HLEN)
- return max_len;
-
- /* initialize network frame pointer */
- hdr.network = data;
-
- /* set first protocol and move network header forward */
- protocol = hdr.eth->h_proto;
- hdr.network += ETH_HLEN;
-
- /* handle any vlan tag if present */
- if (protocol == __constant_htons(ETH_P_8021Q)) {
- if ((hdr.network - data) > (max_len - VLAN_HLEN))
- return max_len;
-
- protocol = hdr.vlan->h_vlan_encapsulated_proto;
- hdr.network += VLAN_HLEN;
- }
-
- /* handle L3 protocols */
- if (protocol == __constant_htons(ETH_P_IP)) {
- if ((hdr.network - data) > (max_len - sizeof(struct iphdr)))
- return max_len;
-
- /* access ihl as a u8 to avoid unaligned access on ia64 */
- hlen = (hdr.network[0] & 0x0F) << 2;
-
- /* verify hlen meets minimum size requirements */
- if (hlen < sizeof(struct iphdr))
- return hdr.network - data;
-
- /* record next protocol if header is present */
- if (!(hdr.ipv4->frag_off & htons(IP_OFFSET)))
- nexthdr = hdr.ipv4->protocol;
-#ifdef NETIF_F_TSO6
- } else if (protocol == __constant_htons(ETH_P_IPV6)) {
- if ((hdr.network - data) > (max_len - sizeof(struct ipv6hdr)))
- return max_len;
-
- /* record next protocol */
- nexthdr = hdr.ipv6->nexthdr;
- hlen = sizeof(struct ipv6hdr);
-#endif /* NETIF_F_TSO6 */
- } else {
- return hdr.network - data;
- }
-
- /* relocate pointer to start of L4 header */
- hdr.network += hlen;
-
- /* finally sort out TCP */
- if (nexthdr == IPPROTO_TCP) {
- if ((hdr.network - data) > (max_len - sizeof(struct tcphdr)))
- return max_len;
-
- /* access doff as a u8 to avoid unaligned access on ia64 */
- hlen = (hdr.network[12] & 0xF0) >> 2;
-
- /* verify hlen meets minimum size requirements */
- if (hlen < sizeof(struct tcphdr))
- return hdr.network - data;
-
- hdr.network += hlen;
- } else if (nexthdr == IPPROTO_UDP) {
- if ((hdr.network - data) > (max_len - sizeof(struct udphdr)))
- return max_len;
-
- hdr.network += sizeof(struct udphdr);
- }
-
- /*
- * If everything has gone correctly hdr.network should be the
- * data section of the packet and will be the end of the header.
- * If not then it probably represents the end of the last recognized
- * header.
- */
- if ((hdr.network - data) < max_len)
- return hdr.network - data;
- else
- return max_len;
-}
-
-/**
* igb_pull_tail - igb specific version of skb_pull_tail
* @rx_ring: rx descriptor ring packet is being transacted on
* @rx_desc: pointer to the EOP Rx descriptor
@@ -8287,7 +8176,7 @@ static void igb_pull_tail(struct igb_ring *rx_ring,
* we need the header to contain the greater of either ETH_HLEN or
* 60 bytes if the skb->len is less than 60 for skb_pad.
*/
- pull_len = igb_get_headlen(va, IGB_RX_HDR_LEN);
+ pull_len = eth_get_headlen(va, IGB_RX_HDR_LEN);
/* align pull length to size of long to optimize memcpy performance */
skb_copy_to_linear_data(skb, va, ALIGN(pull_len, sizeof(long)));
@@ -8642,8 +8531,12 @@ static int igb_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
return igb_mii_ioctl(netdev, ifr, cmd);
#endif
#ifdef HAVE_PTP_1588_CLOCK
+#ifdef SIOCGHWTSTAMP
+ case SIOCGHWTSTAMP:
+ return igb_ptp_get_ts_config(netdev, ifr);
+#endif
case SIOCSHWTSTAMP:
- return igb_ptp_hwtstamp_ioctl(netdev, ifr, cmd);
+ return igb_ptp_set_ts_config(netdev, ifr);
#endif /* HAVE_PTP_1588_CLOCK */
#ifdef ETHTOOL_OPS_COMPAT
case SIOCETHTOOL:
@@ -8654,6 +8547,20 @@ static int igb_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
}
}
+void e1000_read_pci_cfg(struct e1000_hw *hw, u32 reg, u16 *value)
+{
+ struct igb_adapter *adapter = hw->back;
+
+ pci_read_config_word(adapter->pdev, reg, value);
+}
+
+void e1000_write_pci_cfg(struct e1000_hw *hw, u32 reg, u16 *value)
+{
+ struct igb_adapter *adapter = hw->back;
+
+ pci_write_config_word(adapter->pdev, reg, *value);
+}
+
s32 e1000_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value)
{
struct igb_adapter *adapter = hw->back;
@@ -9165,7 +9072,7 @@ static int igb_runtime_resume(struct device *dev)
#ifdef USE_REBOOT_NOTIFIER
/* only want to do this for 2.4 kernels? */
static int igb_notify_reboot(struct notifier_block *nb, unsigned long event,
- void *p)
+ void *p)
{
struct pci_dev *pdev = NULL;
bool wake;
@@ -9277,8 +9184,7 @@ static pci_ers_result_t igb_io_error_detected(struct pci_dev *pdev,
dev_err(pci_dev_to_dev(pdev),
"VF %d has caused a PCIe error\n", vf);
dev_err(pci_dev_to_dev(pdev),
- "TLP: dw0: %8.8x\tdw1: %8.8x\tdw2: "
- "%8.8x\tdw3: %8.8x\n",
+ "TLP: dw0: %8.8x\tdw1: %8.8x\tdw2:\n%8.8x\tdw3: %8.8x\n",
dw0, dw1, dw2, dw3);
/* Find the pci device of the offending VF */
@@ -9421,7 +9327,7 @@ int igb_add_mac_filter(struct igb_adapter *adapter, u8 *addr, u16 queue)
}
return -ENOMEM;
}
-int igb_del_mac_filter(struct igb_adapter *adapter, u8* addr, u16 queue)
+int igb_del_mac_filter(struct igb_adapter *adapter, u8 *addr, u16 queue)
{
/* search table for addr, if found, set to 0 and sync */
int i;
@@ -9442,7 +9348,7 @@ int igb_del_mac_filter(struct igb_adapter *adapter, u8* addr, u16 queue)
return -ENOMEM;
}
static int igb_set_vf_mac(struct igb_adapter *adapter,
- int vf, unsigned char *mac_addr)
+ int vf, unsigned char *mac_addr)
{
struct e1000_hw *hw = &adapter->hw;
/* VF MAC addresses start at end of receive addresses and moves
@@ -9465,13 +9371,13 @@ static int igb_ndo_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)
return -EINVAL;
adapter->vf_data[vf].flags |= IGB_VF_FLAG_PF_SET_MAC;
dev_info(&adapter->pdev->dev, "setting MAC %pM on VF %d\n", mac, vf);
- dev_info(&adapter->pdev->dev, "Reload the VF driver to make this"
- " change effective.\n");
+ dev_info(&adapter->pdev->dev,
+ "Reload the VF driver to make this change effective.\n");
if (test_bit(__IGB_DOWN, &adapter->state)) {
- dev_warn(&adapter->pdev->dev, "The VF MAC address has been set,"
- " but the PF device is not up.\n");
- dev_warn(&adapter->pdev->dev, "Bring the PF device up before"
- " attempting to use the VF device.\n");
+ dev_warn(&adapter->pdev->dev,
+ "The VF MAC address has been set, but the PF device is not up.\n");
+ dev_warn(&adapter->pdev->dev,
+ "Bring the PF device up before attempting to use the VF device.\n");
}
return igb_set_vf_mac(adapter, vf, mac);
}
@@ -9546,7 +9452,12 @@ static void igb_check_vf_rate_limit(struct igb_adapter *adapter)
}
}
-static int igb_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate)
+#ifdef HAVE_NDO_SET_VF_MIN_MAX_TX_RATE
+int igb_ndo_set_vf_bw(struct net_device *netdev, int vf, int min_tx_rate,
+ int max_tx_rate)
+#else
+int igb_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate)
+#endif /* HAVE_NDO_SET_VF_MIN_MAX_TX_RATE */
{
struct igb_adapter *adapter = netdev_priv(netdev);
struct e1000_hw *hw = &adapter->hw;
@@ -9558,12 +9469,21 @@ static int igb_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate)
actual_link_speed = igb_link_mbps(adapter->link_speed);
if ((vf >= adapter->vfs_allocated_count) ||
(!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) ||
+#ifdef HAVE_NDO_SET_VF_MIN_MAX_TX_RATE
+ (max_tx_rate < 0) || (max_tx_rate > actual_link_speed))
+#else
(tx_rate < 0) || (tx_rate > actual_link_speed))
+#endif /* HAVE_NDO_SET_VF_MIN_MAX_TX_RATE */
return -EINVAL;
adapter->vf_rate_link_speed = actual_link_speed;
+#ifdef HAVE_NDO_SET_VF_MIN_MAX_TX_RATE
+ adapter->vf_data[vf].tx_rate = (u16)max_tx_rate;
+ igb_set_vf_rate_limit(hw, vf, max_tx_rate, actual_link_speed);
+#else
adapter->vf_data[vf].tx_rate = (u16)tx_rate;
igb_set_vf_rate_limit(hw, vf, tx_rate, actual_link_speed);
+#endif /* HAVE_NDO_SET_VF_MIN_MAX_TX_RATE */
return 0;
}
@@ -9576,7 +9496,12 @@ static int igb_ndo_get_vf_config(struct net_device *netdev,
return -EINVAL;
ivi->vf = vf;
memcpy(&ivi->mac, adapter->vf_data[vf].vf_mac_addresses, ETH_ALEN);
+#ifdef HAVE_NDO_SET_VF_MIN_MAX_TX_RATE
+ ivi->max_tx_rate = adapter->vf_data[vf].tx_rate;
+ ivi->min_tx_rate = 0;
+#else
ivi->tx_rate = adapter->vf_data[vf].tx_rate;
+#endif /* HAVE_NDO_SET_VF_MIN_MAX_TX_RATE */
ivi->vlan = adapter->vf_data[vf].pf_vlan;
ivi->qos = adapter->vf_data[vf].pf_qos;
#ifdef HAVE_VF_SPOOFCHK_CONFIGURE
@@ -9602,11 +9527,13 @@ static void igb_vmm_control(struct igb_adapter *adapter)
reg |= (E1000_DTXCTL_VLAN_ADDED |
E1000_DTXCTL_SPOOF_INT);
E1000_WRITE_REG(hw, E1000_DTXCTL, reg);
+ /* Fall through */
case e1000_82580:
/* enable replication vlan tag stripping */
reg = E1000_READ_REG(hw, E1000_RPLOLR);
reg |= E1000_RPLOLR_STRVLAN;
E1000_WRITE_REG(hw, E1000_RPLOLR, reg);
+ /* Fall through */
case e1000_i350:
case e1000_i354:
/* none of the above registers are supported by i350 */
@@ -9621,7 +9548,7 @@ static void igb_vmm_control(struct igb_adapter *adapter)
}
/* enable replication and loopback support */
- count = adapter->vfs_allocated_count || adapter->vmdq_pools;
+ count = adapter->vfs_allocated_count || adapter->vmdq_pools;
if (adapter->flags & IGB_FLAG_LOOPBACK_ENABLE && count)
e1000_vmdq_set_loopback_pf(hw, 1);
e1000_vmdq_set_anti_spoofing_pf(hw,
@@ -9655,12 +9582,14 @@ static void igb_init_fw(struct igb_adapter *adapter)
fw_cmd.port_num = hw->bus.func;
fw_cmd.drv_version = FW_FAMILY_DRV_VER;
fw_cmd.hdr.checksum = 0;
- fw_cmd.hdr.checksum = e1000_calculate_checksum((u8 *)&fw_cmd,
- (FW_HDR_LEN +
- fw_cmd.hdr.buf_len));
- e1000_host_interface_command(hw, (u8*)&fw_cmd,
- sizeof(fw_cmd));
- if (fw_cmd.hdr.cmd_or_resp.ret_status == FW_STATUS_SUCCESS)
+ fw_cmd.hdr.checksum =
+ e1000_calculate_checksum((u8 *)&fw_cmd,
+ (FW_HDR_LEN +
+ fw_cmd.hdr.buf_len));
+ e1000_host_interface_command(hw, (u8 *)&fw_cmd,
+ sizeof(fw_cmd));
+ if (fw_cmd.hdr.cmd_or_resp.ret_status
+ == FW_STATUS_SUCCESS)
break;
}
} else
@@ -9740,7 +9669,9 @@ static void igb_init_dmac(struct igb_adapter *adapter, u32 pba)
reg &= ~E1000_DMACR_DC_BMC2OSW_EN;
E1000_WRITE_REG(hw, E1000_DMACR, reg);
- /* no lower threshold to disable coalescing(smart fifb)-UTRESH=0*/
+ /* no lower threshold to disable coalescing
+ * (smart fifb)-UTRESH=0
+ * */
E1000_WRITE_REG(hw, E1000_DMCRTRH, 0);
/* This sets the time to wait before requesting
@@ -9769,11 +9700,12 @@ static void igb_init_dmac(struct igb_adapter *adapter, u32 pba)
}
E1000_WRITE_REG(hw, E1000_DMCTLX, reg);
- /* free space in tx packet buffer to wake from DMA coal */
+ /* free space in tx pkt buffer to wake from DMA coal */
E1000_WRITE_REG(hw, E1000_DMCTXTH, (IGB_MIN_TXPBSIZE -
- (IGB_TX_BUF_4096 + adapter->max_frame_size)) >> 6);
+ (IGB_TX_BUF_4096 + adapter->max_frame_size))
+ >> 6);
- /* make low power state decision controlled by DMA coal */
+ /* low power state decision controlled by DMA coal */
reg = E1000_READ_REG(hw, E1000_PCIEMISC);
reg &= ~E1000_PCIEMISC_LX_DECISION;
E1000_WRITE_REG(hw, E1000_PCIEMISC, reg);
@@ -9781,7 +9713,7 @@ static void igb_init_dmac(struct igb_adapter *adapter, u32 pba)
} else if (hw->mac.type == e1000_82580) {
u32 reg = E1000_READ_REG(hw, E1000_PCIEMISC);
E1000_WRITE_REG(hw, E1000_PCIEMISC,
- reg & ~E1000_PCIEMISC_LX_DECISION);
+ reg & ~E1000_PCIEMISC_LX_DECISION);
E1000_WRITE_REG(hw, E1000_DMACR, 0);
}
}