aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2014-03-24 12:45:16 -0400
committerDavid S. Miller <davem@davemloft.net>2014-03-24 12:45:16 -0400
commit35d499ee3a63b645f355d98dc407b22751896a43 (patch)
tree7650549beb70a46cbe5f6e7e5f0315a71bb1920b
parent0b8c7f6f2a26ed2dee24881299fc69f554596dbb (diff)
parentb709323d2477614823a38c2f2a9a206e087e28fc (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net-next
Jeff Kirsher says: ==================== Intel Wired LAN Driver Updates This series contains updates to igb, ixgbe, ixgbevf, i40e and i40evf. Anjali provides a i40e/i40evf patch to add Energy Efficient Ethernet Low Power Idle stats and a fix for i40e to change the string "Side Band" to "Sideband" for consistency. Mitch provides 2 patches for i40evf to fix if the driver encounters an error while communicating with the PF driver, do not shut down the admin queue unconditionally. Add an error message when the admin queue message never completes and fix formatting on another message that was unnecessarily wrapped. Mark provides a ixgbe patch and five ixgbevf patches. Fix a possible infinite recursion when an adapter is removed and registers all read as all one's in ixgbe_clear_vmdq_generic() and ixgbe_clear_rar_generic(). Converts macros to static inline functions to align kernel coding standard and prepare for adding Live Error Recovery (LER) to ixgbevf. Change the ethtool register test to use the normal register accessor functions and eliminate macors used for calling register test functions to make error exits more clear. Checks all register reads for adapter removal by checking the status register after any register read that returns all F's since the status register will never return 0xFFFFFFFF unless the adapter is removed. Jacob implements SIOCGHWTSTAMP ioctl for igb which enables user processes to read the current hardware stamp config settings non-destructively. Todd adds the initial register read and write for surprise removal (LER) for igb. Christian Engelmayer fixes an igb memory leak in the igb_get_module_eeprom() error handling path. Ken Ichikawa provides a fix for igb, specifically for 82575 hardware to specify -1 to the phc_index for ethtool's get_ts_info, otherwise a wrong value will be set to the phc_index. Christopher Paasch fixes a null pointer dereference in igb and makes sure to unset the HAS_MSIX flag when the driver falls back to MSI only. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_ethtool.c5
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_main.c17
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_type.h5
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40e_type.h5
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40evf_main.c9
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_regs.h21
-rw-r--r--drivers/net/ethernet/intel/igb/igb.h5
-rw-r--r--drivers/net/ethernet/intel/igb/igb_ethtool.c14
-rw-r--r--drivers/net/ethernet/intel/igb/igb_main.c33
-rw-r--r--drivers/net/ethernet/intel/igb/igb_ptp.c46
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_common.c3
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ethtool.c141
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ixgbevf.h6
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c68
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/regs.h12
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/vf.h33
16 files changed, 321 insertions, 102 deletions
diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
index 6049e63a826d..28da4125c8c9 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
@@ -114,6 +114,11 @@ static struct i40e_stats i40e_gstrings_stats[] = {
114 I40E_PF_STAT("VF_admin_queue_requests", vf_aq_requests), 114 I40E_PF_STAT("VF_admin_queue_requests", vf_aq_requests),
115 I40E_PF_STAT("tx_hwtstamp_timeouts", tx_hwtstamp_timeouts), 115 I40E_PF_STAT("tx_hwtstamp_timeouts", tx_hwtstamp_timeouts),
116 I40E_PF_STAT("rx_hwtstamp_cleared", rx_hwtstamp_cleared), 116 I40E_PF_STAT("rx_hwtstamp_cleared", rx_hwtstamp_cleared),
117 /* LPI stats */
118 I40E_PF_STAT("tx_lpi_status", stats.tx_lpi_status),
119 I40E_PF_STAT("rx_lpi_status", stats.rx_lpi_status),
120 I40E_PF_STAT("tx_lpi_count", stats.tx_lpi_count),
121 I40E_PF_STAT("rx_lpi_count", stats.rx_lpi_count),
117}; 122};
118 123
119#define I40E_QUEUE_STATS_LEN(n) \ 124#define I40E_QUEUE_STATS_LEN(n) \
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 113354214517..28df88ef3c8b 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -740,6 +740,7 @@ void i40e_update_stats(struct i40e_vsi *vsi)
740 u32 rx_page, rx_buf; 740 u32 rx_page, rx_buf;
741 u64 rx_p, rx_b; 741 u64 rx_p, rx_b;
742 u64 tx_p, tx_b; 742 u64 tx_p, tx_b;
743 u32 val;
743 int i; 744 int i;
744 u16 q; 745 u16 q;
745 746
@@ -972,6 +973,20 @@ void i40e_update_stats(struct i40e_vsi *vsi)
972 i40e_stat_update32(hw, I40E_GLPRT_RJC(hw->port), 973 i40e_stat_update32(hw, I40E_GLPRT_RJC(hw->port),
973 pf->stat_offsets_loaded, 974 pf->stat_offsets_loaded,
974 &osd->rx_jabber, &nsd->rx_jabber); 975 &osd->rx_jabber, &nsd->rx_jabber);
976
977 val = rd32(hw, I40E_PRTPM_EEE_STAT);
978 nsd->tx_lpi_status =
979 (val & I40E_PRTPM_EEE_STAT_TX_LPI_STATUS_MASK) >>
980 I40E_PRTPM_EEE_STAT_TX_LPI_STATUS_SHIFT;
981 nsd->rx_lpi_status =
982 (val & I40E_PRTPM_EEE_STAT_RX_LPI_STATUS_MASK) >>
983 I40E_PRTPM_EEE_STAT_RX_LPI_STATUS_SHIFT;
984 i40e_stat_update32(hw, I40E_PRTPM_TLPIC,
985 pf->stat_offsets_loaded,
986 &osd->tx_lpi_count, &nsd->tx_lpi_count);
987 i40e_stat_update32(hw, I40E_PRTPM_RLPIC,
988 pf->stat_offsets_loaded,
989 &osd->rx_lpi_count, &nsd->rx_lpi_count);
975 } 990 }
976 991
977 pf->stat_offsets_loaded = true; 992 pf->stat_offsets_loaded = true;
@@ -6381,7 +6396,7 @@ static int i40e_sw_init(struct i40e_pf *pf)
6381 pf->flags |= I40E_FLAG_FD_SB_ENABLED; 6396 pf->flags |= I40E_FLAG_FD_SB_ENABLED;
6382 } else { 6397 } else {
6383 dev_info(&pf->pdev->dev, 6398 dev_info(&pf->pdev->dev,
6384 "Flow Director Side Band mode Disabled in MFP mode\n"); 6399 "Flow Director Sideband mode Disabled in MFP mode\n");
6385 } 6400 }
6386 pf->fdir_pf_filter_count = 6401 pf->fdir_pf_filter_count =
6387 pf->hw.func_caps.fd_filters_guaranteed; 6402 pf->hw.func_caps.fd_filters_guaranteed;
diff --git a/drivers/net/ethernet/intel/i40e/i40e_type.h b/drivers/net/ethernet/intel/i40e/i40e_type.h
index 5c902f448b1d..d2f0b95fd0d7 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_type.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_type.h
@@ -1014,6 +1014,11 @@ struct i40e_hw_port_stats {
1014 u64 tx_size_big; /* ptc9522 */ 1014 u64 tx_size_big; /* ptc9522 */
1015 u64 mac_short_packet_dropped; /* mspdc */ 1015 u64 mac_short_packet_dropped; /* mspdc */
1016 u64 checksum_error; /* xec */ 1016 u64 checksum_error; /* xec */
1017 /* EEE LPI */
1018 bool tx_lpi_status;
1019 bool rx_lpi_status;
1020 u64 tx_lpi_count; /* etlpic */
1021 u64 rx_lpi_count; /* erlpic */
1017}; 1022};
1018 1023
1019/* Checksum and Shadow RAM pointers */ 1024/* Checksum and Shadow RAM pointers */
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_type.h b/drivers/net/ethernet/intel/i40evf/i40e_type.h
index 7189d6f08ddd..efe73ad6fdb9 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_type.h
+++ b/drivers/net/ethernet/intel/i40evf/i40e_type.h
@@ -1020,6 +1020,11 @@ struct i40e_hw_port_stats {
1020 u64 tx_size_big; /* ptc9522 */ 1020 u64 tx_size_big; /* ptc9522 */
1021 u64 mac_short_packet_dropped; /* mspdc */ 1021 u64 mac_short_packet_dropped; /* mspdc */
1022 u64 checksum_error; /* xec */ 1022 u64 checksum_error; /* xec */
1023 /* EEE LPI */
1024 bool tx_lpi_status;
1025 bool rx_lpi_status;
1026 u64 tx_lpi_count; /* etlpic */
1027 u64 rx_lpi_count; /* erlpic */
1023}; 1028};
1024 1029
1025/* Checksum and Shadow RAM pointers */ 1030/* Checksum and Shadow RAM pointers */
diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_main.c b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
index d381bcc4ea9f..d3eafa320ba9 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_main.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
@@ -1968,8 +1968,7 @@ static void i40evf_init_task(struct work_struct *work)
1968 } 1968 }
1969 err = i40evf_send_api_ver(adapter); 1969 err = i40evf_send_api_ver(adapter);
1970 if (err) { 1970 if (err) {
1971 dev_err(&pdev->dev, "Unable to send to PF (%d)\n", 1971 dev_err(&pdev->dev, "Unable to send to PF (%d)\n", err);
1972 err);
1973 i40evf_shutdown_adminq(hw); 1972 i40evf_shutdown_adminq(hw);
1974 goto err; 1973 goto err;
1975 } 1974 }
@@ -1977,8 +1976,10 @@ static void i40evf_init_task(struct work_struct *work)
1977 goto restart; 1976 goto restart;
1978 break; 1977 break;
1979 case __I40EVF_INIT_VERSION_CHECK: 1978 case __I40EVF_INIT_VERSION_CHECK:
1980 if (!i40evf_asq_done(hw)) 1979 if (!i40evf_asq_done(hw)) {
1980 dev_err(&pdev->dev, "Admin queue command never completed.\n");
1981 goto err; 1981 goto err;
1982 }
1982 1983
1983 /* aq msg sent, awaiting reply */ 1984 /* aq msg sent, awaiting reply */
1984 err = i40evf_verify_api_ver(adapter); 1985 err = i40evf_verify_api_ver(adapter);
@@ -2133,8 +2134,6 @@ err_alloc:
2133 kfree(adapter->vf_res); 2134 kfree(adapter->vf_res);
2134 adapter->vf_res = NULL; 2135 adapter->vf_res = NULL;
2135err: 2136err:
2136 if (hw->aq.asq.count)
2137 i40evf_shutdown_adminq(hw); /* ignore error */
2138 /* Things went into the weeds, so try again later */ 2137 /* Things went into the weeds, so try again later */
2139 if (++adapter->aq_wait_count > I40EVF_AQ_MAX_ERR) { 2138 if (++adapter->aq_wait_count > I40EVF_AQ_MAX_ERR) {
2140 dev_err(&pdev->dev, "Failed to communicate with PF; giving up.\n"); 2139 dev_err(&pdev->dev, "Failed to communicate with PF; giving up.\n");
diff --git a/drivers/net/ethernet/intel/igb/e1000_regs.h b/drivers/net/ethernet/intel/igb/e1000_regs.h
index d0f14be3d94f..bdb246e848e1 100644
--- a/drivers/net/ethernet/intel/igb/e1000_regs.h
+++ b/drivers/net/ethernet/intel/igb/e1000_regs.h
@@ -362,12 +362,25 @@
362 * Filter - RW */ 362 * Filter - RW */
363#define E1000_VMVIR(_n) (0x03700 + (4 * (_n))) 363#define E1000_VMVIR(_n) (0x03700 + (4 * (_n)))
364 364
365#define wr32(reg, value) (writel(value, hw->hw_addr + reg)) 365struct e1000_hw;
366#define rd32(reg) (readl(hw->hw_addr + reg)) 366
367u32 igb_rd32(struct e1000_hw *hw, u32 reg);
368
369/* write operations, indexed using DWORDS */
370#define wr32(reg, val) \
371do { \
372 u8 __iomem *hw_addr = ACCESS_ONCE((hw)->hw_addr); \
373 if (!E1000_REMOVED(hw_addr)) \
374 writel((val), &hw_addr[(reg)]); \
375} while (0)
376
377#define rd32(reg) (igb_rd32(hw, reg))
378
367#define wrfl() ((void)rd32(E1000_STATUS)) 379#define wrfl() ((void)rd32(E1000_STATUS))
368 380
369#define array_wr32(reg, offset, value) \ 381#define array_wr32(reg, offset, value) \
370 (writel(value, hw->hw_addr + reg + ((offset) << 2))) 382 wr32((reg) + ((offset) << 2), (value))
383
371#define array_rd32(reg, offset) \ 384#define array_rd32(reg, offset) \
372 (readl(hw->hw_addr + reg + ((offset) << 2))) 385 (readl(hw->hw_addr + reg + ((offset) << 2)))
373 386
@@ -406,4 +419,6 @@
406#define E1000_INVM_DATA_REG(_n) (0x12120 + 4*(_n)) 419#define E1000_INVM_DATA_REG(_n) (0x12120 + 4*(_n))
407#define E1000_INVM_SIZE 64 /* Number of INVM Data Registers */ 420#define E1000_INVM_SIZE 64 /* Number of INVM Data Registers */
408 421
422#define E1000_REMOVED(h) unlikely(!(h))
423
409#endif 424#endif
diff --git a/drivers/net/ethernet/intel/igb/igb.h b/drivers/net/ethernet/intel/igb/igb.h
index a202c9640e93..411b213c63be 100644
--- a/drivers/net/ethernet/intel/igb/igb.h
+++ b/drivers/net/ethernet/intel/igb/igb.h
@@ -434,6 +434,7 @@ struct igb_adapter {
434 struct delayed_work ptp_overflow_work; 434 struct delayed_work ptp_overflow_work;
435 struct work_struct ptp_tx_work; 435 struct work_struct ptp_tx_work;
436 struct sk_buff *ptp_tx_skb; 436 struct sk_buff *ptp_tx_skb;
437 struct hwtstamp_config tstamp_config;
437 unsigned long ptp_tx_start; 438 unsigned long ptp_tx_start;
438 unsigned long last_rx_ptp_check; 439 unsigned long last_rx_ptp_check;
439 spinlock_t tmreg_lock; 440 spinlock_t tmreg_lock;
@@ -545,8 +546,8 @@ static inline void igb_ptp_rx_hwtstamp(struct igb_ring *rx_ring,
545 rx_ring->last_rx_timestamp = jiffies; 546 rx_ring->last_rx_timestamp = jiffies;
546} 547}
547 548
548int igb_ptp_hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr, 549int igb_ptp_set_ts_config(struct net_device *netdev, struct ifreq *ifr);
549 int cmd); 550int igb_ptp_get_ts_config(struct net_device *netdev, struct ifreq *ifr);
550#ifdef CONFIG_IGB_HWMON 551#ifdef CONFIG_IGB_HWMON
551void igb_sysfs_exit(struct igb_adapter *adapter); 552void igb_sysfs_exit(struct igb_adapter *adapter);
552int igb_sysfs_init(struct igb_adapter *adapter); 553int igb_sysfs_init(struct igb_adapter *adapter);
diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c
index e35bc1faa452..e5570acbeea8 100644
--- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
+++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
@@ -2353,6 +2353,11 @@ static int igb_get_ts_info(struct net_device *dev,
2353{ 2353{
2354 struct igb_adapter *adapter = netdev_priv(dev); 2354 struct igb_adapter *adapter = netdev_priv(dev);
2355 2355
2356 if (adapter->ptp_clock)
2357 info->phc_index = ptp_clock_index(adapter->ptp_clock);
2358 else
2359 info->phc_index = -1;
2360
2356 switch (adapter->hw.mac.type) { 2361 switch (adapter->hw.mac.type) {
2357 case e1000_82575: 2362 case e1000_82575:
2358 info->so_timestamping = 2363 info->so_timestamping =
@@ -2374,11 +2379,6 @@ static int igb_get_ts_info(struct net_device *dev,
2374 SOF_TIMESTAMPING_RX_HARDWARE | 2379 SOF_TIMESTAMPING_RX_HARDWARE |
2375 SOF_TIMESTAMPING_RAW_HARDWARE; 2380 SOF_TIMESTAMPING_RAW_HARDWARE;
2376 2381
2377 if (adapter->ptp_clock)
2378 info->phc_index = ptp_clock_index(adapter->ptp_clock);
2379 else
2380 info->phc_index = -1;
2381
2382 info->tx_types = 2382 info->tx_types =
2383 (1 << HWTSTAMP_TX_OFF) | 2383 (1 << HWTSTAMP_TX_OFF) |
2384 (1 << HWTSTAMP_TX_ON); 2384 (1 << HWTSTAMP_TX_ON);
@@ -2791,9 +2791,11 @@ static int igb_get_module_eeprom(struct net_device *netdev,
2791 /* Read EEPROM block, SFF-8079/SFF-8472, word at a time */ 2791 /* Read EEPROM block, SFF-8079/SFF-8472, word at a time */
2792 for (i = 0; i < last_word - first_word + 1; i++) { 2792 for (i = 0; i < last_word - first_word + 1; i++) {
2793 status = igb_read_phy_reg_i2c(hw, first_word + i, &dataword[i]); 2793 status = igb_read_phy_reg_i2c(hw, first_word + i, &dataword[i]);
2794 if (status != E1000_SUCCESS) 2794 if (status != E1000_SUCCESS) {
2795 /* Error occurred while reading module */ 2795 /* Error occurred while reading module */
2796 kfree(dataword);
2796 return -EIO; 2797 return -EIO;
2798 }
2797 2799
2798 be16_to_cpus(&dataword[i]); 2800 be16_to_cpus(&dataword[i]);
2799 } 2801 }
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index 17feea0ea2b0..cd20409858d1 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -751,6 +751,28 @@ static void igb_cache_ring_register(struct igb_adapter *adapter)
751 } 751 }
752} 752}
753 753
754u32 igb_rd32(struct e1000_hw *hw, u32 reg)
755{
756 struct igb_adapter *igb = container_of(hw, struct igb_adapter, hw);
757 u8 __iomem *hw_addr = ACCESS_ONCE(hw->hw_addr);
758 u32 value = 0;
759
760 if (E1000_REMOVED(hw_addr))
761 return ~value;
762
763 value = readl(&hw_addr[reg]);
764
765 /* reads should not return all F's */
766 if (!(~value) && (!reg || !(~readl(hw_addr)))) {
767 struct net_device *netdev = igb->netdev;
768 hw->hw_addr = NULL;
769 netif_device_detach(netdev);
770 netdev_err(netdev, "PCIe link lost, device now detached\n");
771 }
772
773 return value;
774}
775
754/** 776/**
755 * igb_write_ivar - configure ivar for given MSI-X vector 777 * igb_write_ivar - configure ivar for given MSI-X vector
756 * @hw: pointer to the HW structure 778 * @hw: pointer to the HW structure
@@ -1013,6 +1035,12 @@ static void igb_reset_q_vector(struct igb_adapter *adapter, int v_idx)
1013{ 1035{
1014 struct igb_q_vector *q_vector = adapter->q_vector[v_idx]; 1036 struct igb_q_vector *q_vector = adapter->q_vector[v_idx];
1015 1037
1038 /* Coming from igb_set_interrupt_capability, the vectors are not yet
1039 * allocated. So, q_vector is NULL so we should stop here.
1040 */
1041 if (!q_vector)
1042 return;
1043
1016 if (q_vector->tx.ring) 1044 if (q_vector->tx.ring)
1017 adapter->tx_ring[q_vector->tx.ring->queue_index] = NULL; 1045 adapter->tx_ring[q_vector->tx.ring->queue_index] = NULL;
1018 1046
@@ -1121,6 +1149,7 @@ static void igb_set_interrupt_capability(struct igb_adapter *adapter, bool msix)
1121 1149
1122 /* If we can't do MSI-X, try MSI */ 1150 /* If we can't do MSI-X, try MSI */
1123msi_only: 1151msi_only:
1152 adapter->flags &= ~IGB_FLAG_HAS_MSIX;
1124#ifdef CONFIG_PCI_IOV 1153#ifdef CONFIG_PCI_IOV
1125 /* disable SR-IOV for non MSI-X configurations */ 1154 /* disable SR-IOV for non MSI-X configurations */
1126 if (adapter->vf_data) { 1155 if (adapter->vf_data) {
@@ -7162,8 +7191,10 @@ static int igb_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
7162 case SIOCGMIIREG: 7191 case SIOCGMIIREG:
7163 case SIOCSMIIREG: 7192 case SIOCSMIIREG:
7164 return igb_mii_ioctl(netdev, ifr, cmd); 7193 return igb_mii_ioctl(netdev, ifr, cmd);
7194 case SIOCGHWTSTAMP:
7195 return igb_ptp_get_ts_config(netdev, ifr);
7165 case SIOCSHWTSTAMP: 7196 case SIOCSHWTSTAMP:
7166 return igb_ptp_hwtstamp_ioctl(netdev, ifr, cmd); 7197 return igb_ptp_set_ts_config(netdev, ifr);
7167 default: 7198 default:
7168 return -EOPNOTSUPP; 7199 return -EOPNOTSUPP;
7169 } 7200 }
diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
index a894551ae3c0..da55fbb090b2 100644
--- a/drivers/net/ethernet/intel/igb/igb_ptp.c
+++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
@@ -541,10 +541,26 @@ void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector,
541} 541}
542 542
543/** 543/**
544 * igb_ptp_hwtstamp_ioctl - control hardware time stamping 544 * igb_ptp_get_ts_config - get hardware time stamping config
545 * @netdev:
546 * @ifreq:
547 *
548 * Get the hwtstamp_config settings to return to the user. Rather than attempt
549 * to deconstruct the settings from the registers, just return a shadow copy
550 * of the last known settings.
551 **/
552int igb_ptp_get_ts_config(struct net_device *netdev, struct ifreq *ifr)
553{
554 struct igb_adapter *adapter = netdev_priv(netdev);
555 struct hwtstamp_config *config = &adapter->tstamp_config;
556
557 return copy_to_user(ifr->ifr_data, config, sizeof(*config)) ?
558 -EFAULT : 0;
559}
560/**
561 * igb_ptp_set_ts_config - control hardware time stamping
545 * @netdev: 562 * @netdev:
546 * @ifreq: 563 * @ifreq:
547 * @cmd:
548 * 564 *
549 * Outgoing time stamping can be enabled and disabled. Play nice and 565 * Outgoing time stamping can be enabled and disabled. Play nice and
550 * disable it when requested, although it shouldn't case any overhead 566 * disable it when requested, although it shouldn't case any overhead
@@ -558,12 +574,11 @@ void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector,
558 * not supported, with the exception of "all V2 events regardless of 574 * not supported, with the exception of "all V2 events regardless of
559 * level 2 or 4". 575 * level 2 or 4".
560 **/ 576 **/
561int igb_ptp_hwtstamp_ioctl(struct net_device *netdev, 577int igb_ptp_set_ts_config(struct net_device *netdev, struct ifreq *ifr)
562 struct ifreq *ifr, int cmd)
563{ 578{
564 struct igb_adapter *adapter = netdev_priv(netdev); 579 struct igb_adapter *adapter = netdev_priv(netdev);
565 struct e1000_hw *hw = &adapter->hw; 580 struct e1000_hw *hw = &adapter->hw;
566 struct hwtstamp_config config; 581 struct hwtstamp_config *config = &adapter->tstamp_config;
567 u32 tsync_tx_ctl = E1000_TSYNCTXCTL_ENABLED; 582 u32 tsync_tx_ctl = E1000_TSYNCTXCTL_ENABLED;
568 u32 tsync_rx_ctl = E1000_TSYNCRXCTL_ENABLED; 583 u32 tsync_rx_ctl = E1000_TSYNCRXCTL_ENABLED;
569 u32 tsync_rx_cfg = 0; 584 u32 tsync_rx_cfg = 0;
@@ -571,14 +586,14 @@ int igb_ptp_hwtstamp_ioctl(struct net_device *netdev,
571 bool is_l2 = false; 586 bool is_l2 = false;
572 u32 regval; 587 u32 regval;
573 588
574 if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) 589 if (copy_from_user(config, ifr->ifr_data, sizeof(*config)))
575 return -EFAULT; 590 return -EFAULT;
576 591
577 /* reserved for future extensions */ 592 /* reserved for future extensions */
578 if (config.flags) 593 if (config->flags)
579 return -EINVAL; 594 return -EINVAL;
580 595
581 switch (config.tx_type) { 596 switch (config->tx_type) {
582 case HWTSTAMP_TX_OFF: 597 case HWTSTAMP_TX_OFF:
583 tsync_tx_ctl = 0; 598 tsync_tx_ctl = 0;
584 case HWTSTAMP_TX_ON: 599 case HWTSTAMP_TX_ON:
@@ -587,7 +602,7 @@ int igb_ptp_hwtstamp_ioctl(struct net_device *netdev,
587 return -ERANGE; 602 return -ERANGE;
588 } 603 }
589 604
590 switch (config.rx_filter) { 605 switch (config->rx_filter) {
591 case HWTSTAMP_FILTER_NONE: 606 case HWTSTAMP_FILTER_NONE:
592 tsync_rx_ctl = 0; 607 tsync_rx_ctl = 0;
593 break; 608 break;
@@ -611,7 +626,7 @@ int igb_ptp_hwtstamp_ioctl(struct net_device *netdev,
611 case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ: 626 case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ:
612 case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ: 627 case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
613 tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_EVENT_V2; 628 tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_EVENT_V2;
614 config.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; 629 config->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
615 is_l2 = true; 630 is_l2 = true;
616 is_l4 = true; 631 is_l4 = true;
617 break; 632 break;
@@ -622,12 +637,12 @@ int igb_ptp_hwtstamp_ioctl(struct net_device *netdev,
622 */ 637 */
623 if (hw->mac.type != e1000_82576) { 638 if (hw->mac.type != e1000_82576) {
624 tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_ALL; 639 tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_ALL;
625 config.rx_filter = HWTSTAMP_FILTER_ALL; 640 config->rx_filter = HWTSTAMP_FILTER_ALL;
626 break; 641 break;
627 } 642 }
628 /* fall through */ 643 /* fall through */
629 default: 644 default:
630 config.rx_filter = HWTSTAMP_FILTER_NONE; 645 config->rx_filter = HWTSTAMP_FILTER_NONE;
631 return -ERANGE; 646 return -ERANGE;
632 } 647 }
633 648
@@ -644,7 +659,7 @@ int igb_ptp_hwtstamp_ioctl(struct net_device *netdev,
644 if ((hw->mac.type >= e1000_82580) && tsync_rx_ctl) { 659 if ((hw->mac.type >= e1000_82580) && tsync_rx_ctl) {
645 tsync_rx_ctl = E1000_TSYNCRXCTL_ENABLED; 660 tsync_rx_ctl = E1000_TSYNCRXCTL_ENABLED;
646 tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_ALL; 661 tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_ALL;
647 config.rx_filter = HWTSTAMP_FILTER_ALL; 662 config->rx_filter = HWTSTAMP_FILTER_ALL;
648 is_l2 = true; 663 is_l2 = true;
649 is_l4 = true; 664 is_l4 = true;
650 665
@@ -708,7 +723,7 @@ int igb_ptp_hwtstamp_ioctl(struct net_device *netdev,
708 regval = rd32(E1000_RXSTMPL); 723 regval = rd32(E1000_RXSTMPL);
709 regval = rd32(E1000_RXSTMPH); 724 regval = rd32(E1000_RXSTMPH);
710 725
711 return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? 726 return copy_to_user(ifr->ifr_data, config, sizeof(*config)) ?
712 -EFAULT : 0; 727 -EFAULT : 0;
713} 728}
714 729
@@ -865,6 +880,9 @@ void igb_ptp_reset(struct igb_adapter *adapter)
865 if (!(adapter->flags & IGB_FLAG_PTP)) 880 if (!(adapter->flags & IGB_FLAG_PTP))
866 return; 881 return;
867 882
883 /* reset the tstamp_config */
884 memset(&adapter->tstamp_config, 0, sizeof(adapter->tstamp_config));
885
868 switch (adapter->hw.mac.type) { 886 switch (adapter->hw.mac.type) {
869 case e1000_82576: 887 case e1000_82576:
870 /* Dial the nominal frequency. */ 888 /* Dial the nominal frequency. */
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
index 911b711b6ba1..24fba39e194e 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
@@ -2913,6 +2913,9 @@ s32 ixgbe_clear_vmdq_generic(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
2913 mpsar_lo = IXGBE_READ_REG(hw, IXGBE_MPSAR_LO(rar)); 2913 mpsar_lo = IXGBE_READ_REG(hw, IXGBE_MPSAR_LO(rar));
2914 mpsar_hi = IXGBE_READ_REG(hw, IXGBE_MPSAR_HI(rar)); 2914 mpsar_hi = IXGBE_READ_REG(hw, IXGBE_MPSAR_HI(rar));
2915 2915
2916 if (ixgbe_removed(hw->hw_addr))
2917 goto done;
2918
2916 if (!mpsar_lo && !mpsar_hi) 2919 if (!mpsar_lo && !mpsar_hi)
2917 goto done; 2920 goto done;
2918 2921
diff --git a/drivers/net/ethernet/intel/ixgbevf/ethtool.c b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
index f68b78c732a8..b2d002394e5d 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel 82599 Virtual Function driver 3 Intel 82599 Virtual Function driver
4 Copyright(c) 1999 - 2012 Intel Corporation. 4 Copyright(c) 1999 - 2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -530,41 +530,55 @@ static const u32 register_test_patterns[] = {
530 0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF 530 0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF
531}; 531};
532 532
533#define REG_PATTERN_TEST(R, M, W) \ 533static bool reg_pattern_test(struct ixgbevf_adapter *adapter, u64 *data,
534{ \ 534 int reg, u32 mask, u32 write)
535 u32 pat, val, before; \ 535{
536 for (pat = 0; pat < ARRAY_SIZE(register_test_patterns); pat++) { \ 536 u32 pat, val, before;
537 before = readl(adapter->hw.hw_addr + R); \ 537
538 writel((register_test_patterns[pat] & W), \ 538 if (IXGBE_REMOVED(adapter->hw.hw_addr)) {
539 (adapter->hw.hw_addr + R)); \ 539 *data = 1;
540 val = readl(adapter->hw.hw_addr + R); \ 540 return true;
541 if (val != (register_test_patterns[pat] & W & M)) { \ 541 }
542 hw_dbg(&adapter->hw, \ 542 for (pat = 0; pat < ARRAY_SIZE(register_test_patterns); pat++) {
543 "pattern test reg %04X failed: got " \ 543 before = ixgbe_read_reg(&adapter->hw, reg);
544 "0x%08X expected 0x%08X\n", \ 544 ixgbe_write_reg(&adapter->hw, reg,
545 R, val, (register_test_patterns[pat] & W & M)); \ 545 register_test_patterns[pat] & write);
546 *data = R; \ 546 val = ixgbe_read_reg(&adapter->hw, reg);
547 writel(before, adapter->hw.hw_addr + R); \ 547 if (val != (register_test_patterns[pat] & write & mask)) {
548 return 1; \ 548 hw_dbg(&adapter->hw,
549 } \ 549 "pattern test reg %04X failed: got 0x%08X expected 0x%08X\n",
550 writel(before, adapter->hw.hw_addr + R); \ 550 reg, val,
551 } \ 551 register_test_patterns[pat] & write & mask);
552 *data = reg;
553 ixgbe_write_reg(&adapter->hw, reg, before);
554 return true;
555 }
556 ixgbe_write_reg(&adapter->hw, reg, before);
557 }
558 return false;
552} 559}
553 560
554#define REG_SET_AND_CHECK(R, M, W) \ 561static bool reg_set_and_check(struct ixgbevf_adapter *adapter, u64 *data,
555{ \ 562 int reg, u32 mask, u32 write)
556 u32 val, before; \ 563{
557 before = readl(adapter->hw.hw_addr + R); \ 564 u32 val, before;
558 writel((W & M), (adapter->hw.hw_addr + R)); \ 565
559 val = readl(adapter->hw.hw_addr + R); \ 566 if (IXGBE_REMOVED(adapter->hw.hw_addr)) {
560 if ((W & M) != (val & M)) { \ 567 *data = 1;
561 pr_err("set/check reg %04X test failed: got 0x%08X expected " \ 568 return true;
562 "0x%08X\n", R, (val & M), (W & M)); \ 569 }
563 *data = R; \ 570 before = ixgbe_read_reg(&adapter->hw, reg);
564 writel(before, (adapter->hw.hw_addr + R)); \ 571 ixgbe_write_reg(&adapter->hw, reg, write & mask);
565 return 1; \ 572 val = ixgbe_read_reg(&adapter->hw, reg);
566 } \ 573 if ((write & mask) != (val & mask)) {
567 writel(before, (adapter->hw.hw_addr + R)); \ 574 pr_err("set/check reg %04X test failed: got 0x%08X expected 0x%08X\n",
575 reg, (val & mask), write & mask);
576 *data = reg;
577 ixgbe_write_reg(&adapter->hw, reg, before);
578 return true;
579 }
580 ixgbe_write_reg(&adapter->hw, reg, before);
581 return false;
568} 582}
569 583
570static int ixgbevf_reg_test(struct ixgbevf_adapter *adapter, u64 *data) 584static int ixgbevf_reg_test(struct ixgbevf_adapter *adapter, u64 *data)
@@ -572,6 +586,12 @@ static int ixgbevf_reg_test(struct ixgbevf_adapter *adapter, u64 *data)
572 const struct ixgbevf_reg_test *test; 586 const struct ixgbevf_reg_test *test;
573 u32 i; 587 u32 i;
574 588
589 if (IXGBE_REMOVED(adapter->hw.hw_addr)) {
590 dev_err(&adapter->pdev->dev,
591 "Adapter removed - register test blocked\n");
592 *data = 1;
593 return 1;
594 }
575 test = reg_test_vf; 595 test = reg_test_vf;
576 596
577 /* 597 /*
@@ -580,38 +600,47 @@ static int ixgbevf_reg_test(struct ixgbevf_adapter *adapter, u64 *data)
580 */ 600 */
581 while (test->reg) { 601 while (test->reg) {
582 for (i = 0; i < test->array_len; i++) { 602 for (i = 0; i < test->array_len; i++) {
603 bool b = false;
604
583 switch (test->test_type) { 605 switch (test->test_type) {
584 case PATTERN_TEST: 606 case PATTERN_TEST:
585 REG_PATTERN_TEST(test->reg + (i * 0x40), 607 b = reg_pattern_test(adapter, data,
586 test->mask, 608 test->reg + (i * 0x40),
587 test->write); 609 test->mask,
610 test->write);
588 break; 611 break;
589 case SET_READ_TEST: 612 case SET_READ_TEST:
590 REG_SET_AND_CHECK(test->reg + (i * 0x40), 613 b = reg_set_and_check(adapter, data,
591 test->mask, 614 test->reg + (i * 0x40),
592 test->write); 615 test->mask,
616 test->write);
593 break; 617 break;
594 case WRITE_NO_TEST: 618 case WRITE_NO_TEST:
595 writel(test->write, 619 ixgbe_write_reg(&adapter->hw,
596 (adapter->hw.hw_addr + test->reg) 620 test->reg + (i * 0x40),
597 + (i * 0x40)); 621 test->write);
598 break; 622 break;
599 case TABLE32_TEST: 623 case TABLE32_TEST:
600 REG_PATTERN_TEST(test->reg + (i * 4), 624 b = reg_pattern_test(adapter, data,
601 test->mask, 625 test->reg + (i * 4),
602 test->write); 626 test->mask,
627 test->write);
603 break; 628 break;
604 case TABLE64_TEST_LO: 629 case TABLE64_TEST_LO:
605 REG_PATTERN_TEST(test->reg + (i * 8), 630 b = reg_pattern_test(adapter, data,
606 test->mask, 631 test->reg + (i * 8),
607 test->write); 632 test->mask,
633 test->write);
608 break; 634 break;
609 case TABLE64_TEST_HI: 635 case TABLE64_TEST_HI:
610 REG_PATTERN_TEST((test->reg + 4) + (i * 8), 636 b = reg_pattern_test(adapter, data,
611 test->mask, 637 test->reg + 4 + (i * 8),
612 test->write); 638 test->mask,
639 test->write);
613 break; 640 break;
614 } 641 }
642 if (b)
643 return 1;
615 } 644 }
616 test++; 645 test++;
617 } 646 }
@@ -626,6 +655,14 @@ static void ixgbevf_diag_test(struct net_device *netdev,
626 struct ixgbevf_adapter *adapter = netdev_priv(netdev); 655 struct ixgbevf_adapter *adapter = netdev_priv(netdev);
627 bool if_running = netif_running(netdev); 656 bool if_running = netif_running(netdev);
628 657
658 if (IXGBE_REMOVED(adapter->hw.hw_addr)) {
659 dev_err(&adapter->pdev->dev,
660 "Adapter removed - test blocked\n");
661 data[0] = 1;
662 data[1] = 1;
663 eth_test->flags |= ETH_TEST_FL_FAILED;
664 return;
665 }
629 set_bit(__IXGBEVF_TESTING, &adapter->state); 666 set_bit(__IXGBEVF_TESTING, &adapter->state);
630 if (eth_test->flags == ETH_TEST_FL_OFFLINE) { 667 if (eth_test->flags == ETH_TEST_FL_OFFLINE) {
631 /* Offline tests */ 668 /* Offline tests */
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h b/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
index 08fb88aba67b..a08bd7c46766 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
@@ -315,6 +315,11 @@ static inline u16 ixgbevf_desc_unused(struct ixgbevf_ring *ring)
315 return ((ntc > ntu) ? 0 : ring->count) + ntc - ntu - 1; 315 return ((ntc > ntu) ? 0 : ring->count) + ntc - ntu - 1;
316} 316}
317 317
318static inline void ixgbevf_write_tail(struct ixgbevf_ring *ring, u32 value)
319{
320 writel(value, ring->tail);
321}
322
318#define IXGBEVF_RX_DESC(R, i) \ 323#define IXGBEVF_RX_DESC(R, i) \
319 (&(((union ixgbe_adv_rx_desc *)((R)->desc))[i])) 324 (&(((union ixgbe_adv_rx_desc *)((R)->desc))[i]))
320#define IXGBEVF_TX_DESC(R, i) \ 325#define IXGBEVF_TX_DESC(R, i) \
@@ -401,6 +406,7 @@ struct ixgbevf_adapter {
401 u64 bp_tx_missed; 406 u64 bp_tx_missed;
402#endif 407#endif
403 408
409 u8 __iomem *io_addr; /* Mainly for iounmap use */
404 u32 link_speed; 410 u32 link_speed;
405 bool link_up; 411 bool link_up;
406 412
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
index 592d8a6baabc..a50e892a5d21 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
@@ -99,6 +99,49 @@ static void ixgbevf_queue_reset_subtask(struct ixgbevf_adapter *adapter);
99static void ixgbevf_set_itr(struct ixgbevf_q_vector *q_vector); 99static void ixgbevf_set_itr(struct ixgbevf_q_vector *q_vector);
100static void ixgbevf_free_all_rx_resources(struct ixgbevf_adapter *adapter); 100static void ixgbevf_free_all_rx_resources(struct ixgbevf_adapter *adapter);
101 101
102static void ixgbevf_remove_adapter(struct ixgbe_hw *hw)
103{
104 struct ixgbevf_adapter *adapter = hw->back;
105
106 if (!hw->hw_addr)
107 return;
108 hw->hw_addr = NULL;
109 dev_err(&adapter->pdev->dev, "Adapter removed\n");
110 schedule_work(&adapter->watchdog_task);
111}
112
113static void ixgbevf_check_remove(struct ixgbe_hw *hw, u32 reg)
114{
115 u32 value;
116
117 /* The following check not only optimizes a bit by not
118 * performing a read on the status register when the
119 * register just read was a status register read that
120 * returned IXGBE_FAILED_READ_REG. It also blocks any
121 * potential recursion.
122 */
123 if (reg == IXGBE_VFSTATUS) {
124 ixgbevf_remove_adapter(hw);
125 return;
126 }
127 value = ixgbe_read_reg(hw, IXGBE_VFSTATUS);
128 if (value == IXGBE_FAILED_READ_REG)
129 ixgbevf_remove_adapter(hw);
130}
131
132u32 ixgbe_read_reg(struct ixgbe_hw *hw, u32 reg)
133{
134 u8 __iomem *reg_addr = ACCESS_ONCE(hw->hw_addr);
135 u32 value;
136
137 if (IXGBE_REMOVED(reg_addr))
138 return IXGBE_FAILED_READ_REG;
139 value = readl(reg_addr + reg);
140 if (unlikely(value == IXGBE_FAILED_READ_REG))
141 ixgbevf_check_remove(hw, reg);
142 return value;
143}
144
102static inline void ixgbevf_release_rx_desc(struct ixgbevf_ring *rx_ring, 145static inline void ixgbevf_release_rx_desc(struct ixgbevf_ring *rx_ring,
103 u32 val) 146 u32 val)
104{ 147{
@@ -111,7 +154,7 @@ static inline void ixgbevf_release_rx_desc(struct ixgbevf_ring *rx_ring,
111 * such as IA-64). 154 * such as IA-64).
112 */ 155 */
113 wmb(); 156 wmb();
114 writel(val, rx_ring->tail); 157 ixgbevf_write_tail(rx_ring, val);
115} 158}
116 159
117/** 160/**
@@ -1139,7 +1182,7 @@ static void ixgbevf_configure_tx_ring(struct ixgbevf_adapter *adapter,
1139 /* reset head and tail pointers */ 1182 /* reset head and tail pointers */
1140 IXGBE_WRITE_REG(hw, IXGBE_VFTDH(reg_idx), 0); 1183 IXGBE_WRITE_REG(hw, IXGBE_VFTDH(reg_idx), 0);
1141 IXGBE_WRITE_REG(hw, IXGBE_VFTDT(reg_idx), 0); 1184 IXGBE_WRITE_REG(hw, IXGBE_VFTDT(reg_idx), 0);
1142 ring->tail = hw->hw_addr + IXGBE_VFTDT(reg_idx); 1185 ring->tail = adapter->io_addr + IXGBE_VFTDT(reg_idx);
1143 1186
1144 /* reset ntu and ntc to place SW in sync with hardwdare */ 1187 /* reset ntu and ntc to place SW in sync with hardwdare */
1145 ring->next_to_clean = 0; 1188 ring->next_to_clean = 0;
@@ -1259,6 +1302,8 @@ static void ixgbevf_disable_rx_queue(struct ixgbevf_adapter *adapter,
1259 u32 rxdctl; 1302 u32 rxdctl;
1260 u8 reg_idx = ring->reg_idx; 1303 u8 reg_idx = ring->reg_idx;
1261 1304
1305 if (IXGBE_REMOVED(hw->hw_addr))
1306 return;
1262 rxdctl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(reg_idx)); 1307 rxdctl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(reg_idx));
1263 rxdctl &= ~IXGBE_RXDCTL_ENABLE; 1308 rxdctl &= ~IXGBE_RXDCTL_ENABLE;
1264 1309
@@ -1284,6 +1329,8 @@ static void ixgbevf_rx_desc_queue_enable(struct ixgbevf_adapter *adapter,
1284 u32 rxdctl; 1329 u32 rxdctl;
1285 u8 reg_idx = ring->reg_idx; 1330 u8 reg_idx = ring->reg_idx;
1286 1331
1332 if (IXGBE_REMOVED(hw->hw_addr))
1333 return;
1287 do { 1334 do {
1288 usleep_range(1000, 2000); 1335 usleep_range(1000, 2000);
1289 rxdctl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(reg_idx)); 1336 rxdctl = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(reg_idx));
@@ -1318,7 +1365,7 @@ static void ixgbevf_configure_rx_ring(struct ixgbevf_adapter *adapter,
1318 /* reset head and tail pointers */ 1365 /* reset head and tail pointers */
1319 IXGBE_WRITE_REG(hw, IXGBE_VFRDH(reg_idx), 0); 1366 IXGBE_WRITE_REG(hw, IXGBE_VFRDH(reg_idx), 0);
1320 IXGBE_WRITE_REG(hw, IXGBE_VFRDT(reg_idx), 0); 1367 IXGBE_WRITE_REG(hw, IXGBE_VFRDT(reg_idx), 0);
1321 ring->tail = hw->hw_addr + IXGBE_VFRDT(reg_idx); 1368 ring->tail = adapter->io_addr + IXGBE_VFRDT(reg_idx);
1322 1369
1323 /* reset ntu and ntc to place SW in sync with hardwdare */ 1370 /* reset ntu and ntc to place SW in sync with hardwdare */
1324 ring->next_to_clean = 0; 1371 ring->next_to_clean = 0;
@@ -2357,6 +2404,14 @@ static void ixgbevf_watchdog_task(struct work_struct *work)
2357 bool link_up = adapter->link_up; 2404 bool link_up = adapter->link_up;
2358 s32 need_reset; 2405 s32 need_reset;
2359 2406
2407 if (IXGBE_REMOVED(hw->hw_addr)) {
2408 if (!test_bit(__IXGBEVF_DOWN, &adapter->state)) {
2409 rtnl_lock();
2410 ixgbevf_down(adapter);
2411 rtnl_unlock();
2412 }
2413 return;
2414 }
2360 ixgbevf_queue_reset_subtask(adapter); 2415 ixgbevf_queue_reset_subtask(adapter);
2361 2416
2362 adapter->flags |= IXGBE_FLAG_IN_WATCHDOG_TASK; 2417 adapter->flags |= IXGBE_FLAG_IN_WATCHDOG_TASK;
@@ -3060,7 +3115,7 @@ static void ixgbevf_tx_map(struct ixgbevf_ring *tx_ring,
3060 tx_ring->next_to_use = i; 3115 tx_ring->next_to_use = i;
3061 3116
3062 /* notify HW of packet */ 3117 /* notify HW of packet */
3063 writel(i, tx_ring->tail); 3118 ixgbevf_write_tail(tx_ring, i);
3064 3119
3065 return; 3120 return;
3066dma_error: 3121dma_error:
@@ -3459,6 +3514,7 @@ static int ixgbevf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3459 3514
3460 hw->hw_addr = ioremap(pci_resource_start(pdev, 0), 3515 hw->hw_addr = ioremap(pci_resource_start(pdev, 0),
3461 pci_resource_len(pdev, 0)); 3516 pci_resource_len(pdev, 0));
3517 adapter->io_addr = hw->hw_addr;
3462 if (!hw->hw_addr) { 3518 if (!hw->hw_addr) {
3463 err = -EIO; 3519 err = -EIO;
3464 goto err_ioremap; 3520 goto err_ioremap;
@@ -3544,7 +3600,7 @@ err_register:
3544 ixgbevf_clear_interrupt_scheme(adapter); 3600 ixgbevf_clear_interrupt_scheme(adapter);
3545err_sw_init: 3601err_sw_init:
3546 ixgbevf_reset_interrupt_capability(adapter); 3602 ixgbevf_reset_interrupt_capability(adapter);
3547 iounmap(hw->hw_addr); 3603 iounmap(adapter->io_addr);
3548err_ioremap: 3604err_ioremap:
3549 free_netdev(netdev); 3605 free_netdev(netdev);
3550err_alloc_etherdev: 3606err_alloc_etherdev:
@@ -3582,7 +3638,7 @@ static void ixgbevf_remove(struct pci_dev *pdev)
3582 ixgbevf_clear_interrupt_scheme(adapter); 3638 ixgbevf_clear_interrupt_scheme(adapter);
3583 ixgbevf_reset_interrupt_capability(adapter); 3639 ixgbevf_reset_interrupt_capability(adapter);
3584 3640
3585 iounmap(adapter->hw.hw_addr); 3641 iounmap(adapter->io_addr);
3586 pci_release_regions(pdev); 3642 pci_release_regions(pdev);
3587 3643
3588 hw_dbg(&adapter->hw, "Remove complete\n"); 3644 hw_dbg(&adapter->hw, "Remove complete\n");
diff --git a/drivers/net/ethernet/intel/ixgbevf/regs.h b/drivers/net/ethernet/intel/ixgbevf/regs.h
index debd8c0e1f28..09dd8f698bea 100644
--- a/drivers/net/ethernet/intel/ixgbevf/regs.h
+++ b/drivers/net/ethernet/intel/ixgbevf/regs.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel 82599 Virtual Function driver 3 Intel 82599 Virtual Function driver
4 Copyright(c) 1999 - 2012 Intel Corporation. 4 Copyright(c) 1999 - 2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -70,16 +70,6 @@
70#define IXGBE_VFGOTC_MSB 0x02024 70#define IXGBE_VFGOTC_MSB 0x02024
71#define IXGBE_VFMPRC 0x01034 71#define IXGBE_VFMPRC 0x01034
72 72
73#define IXGBE_WRITE_REG(a, reg, value) writel((value), ((a)->hw_addr + (reg)))
74
75#define IXGBE_READ_REG(a, reg) readl((a)->hw_addr + (reg))
76
77#define IXGBE_WRITE_REG_ARRAY(a, reg, offset, value) ( \
78 writel((value), ((a)->hw_addr + (reg) + ((offset) << 2))))
79
80#define IXGBE_READ_REG_ARRAY(a, reg, offset) ( \
81 readl((a)->hw_addr + (reg) + ((offset) << 2)))
82
83#define IXGBE_WRITE_FLUSH(a) (IXGBE_READ_REG(a, IXGBE_VFSTATUS)) 73#define IXGBE_WRITE_FLUSH(a) (IXGBE_READ_REG(a, IXGBE_VFSTATUS))
84 74
85#endif /* _IXGBEVF_REGS_H_ */ 75#endif /* _IXGBEVF_REGS_H_ */
diff --git a/drivers/net/ethernet/intel/ixgbevf/vf.h b/drivers/net/ethernet/intel/ixgbevf/vf.h
index 7b1f502d1716..096d33a59def 100644
--- a/drivers/net/ethernet/intel/ixgbevf/vf.h
+++ b/drivers/net/ethernet/intel/ixgbevf/vf.h
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel 82599 Virtual Function driver 3 Intel 82599 Virtual Function driver
4 Copyright(c) 1999 - 2012 Intel Corporation. 4 Copyright(c) 1999 - 2014 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -172,6 +172,37 @@ struct ixgbevf_info {
172 const struct ixgbe_mac_operations *mac_ops; 172 const struct ixgbe_mac_operations *mac_ops;
173}; 173};
174 174
175#define IXGBE_FAILED_READ_REG 0xffffffffU
176
177#define IXGBE_REMOVED(a) unlikely(!(a))
178
179static inline void ixgbe_write_reg(struct ixgbe_hw *hw, u32 reg, u32 value)
180{
181 u8 __iomem *reg_addr = ACCESS_ONCE(hw->hw_addr);
182
183 if (IXGBE_REMOVED(reg_addr))
184 return;
185 writel(value, reg_addr + reg);
186}
187#define IXGBE_WRITE_REG(h, r, v) ixgbe_write_reg(h, r, v)
188
189u32 ixgbe_read_reg(struct ixgbe_hw *hw, u32 reg);
190#define IXGBE_READ_REG(h, r) ixgbe_read_reg(h, r)
191
192static inline void ixgbe_write_reg_array(struct ixgbe_hw *hw, u32 reg,
193 u32 offset, u32 value)
194{
195 ixgbe_write_reg(hw, reg + (offset << 2), value);
196}
197#define IXGBE_WRITE_REG_ARRAY(h, r, o, v) ixgbe_write_reg_array(h, r, o, v)
198
199static inline u32 ixgbe_read_reg_array(struct ixgbe_hw *hw, u32 reg,
200 u32 offset)
201{
202 return ixgbe_read_reg(hw, reg + (offset << 2));
203}
204#define IXGBE_READ_REG_ARRAY(h, r, o) ixgbe_read_reg_array(h, r, o)
205
175void ixgbevf_rlpml_set_vf(struct ixgbe_hw *hw, u16 max_size); 206void ixgbevf_rlpml_set_vf(struct ixgbe_hw *hw, u16 max_size);
176int ixgbevf_negotiate_api_version(struct ixgbe_hw *hw, int api); 207int ixgbevf_negotiate_api_version(struct ixgbe_hw *hw, int api);
177int ixgbevf_get_queues(struct ixgbe_hw *hw, unsigned int *num_tcs, 208int ixgbevf_get_queues(struct ixgbe_hw *hw, unsigned int *num_tcs,