summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2015-09-28 23:56:02 -0400
committerDavid S. Miller <davem@davemloft.net>2015-09-28 23:56:02 -0400
commiteae93fe4ff88ec0979a00c440a1aa63f92c8f367 (patch)
tree174c92ecfef8b0030684b90a98edd0222f2f4ad6
parent34c2d9fb0498c066afbe610b15e18995fd8be792 (diff)
parentcbfe360a1541a32e9e28f8f8ac925d2b7979d767 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue
Jeff Kirsher says: ==================== Intel Wired LAN Driver Updates 2015-09-28 This series contains updates to i40e, i40evf and igb to resolve issues seen and reported by Red Hat. Kiran moves i40e_get_head() in preparation for the refactor of the Tx timeout logic, so that it can be used in other areas of the driver. Refactored the driver timeout logic by issuing a writeback request via a software interrupt to the hardware the first time the driver detects a hang. This was due to the driver being too aggressive in resetting a hung queue. Shannon adds the GRE protocol to the transmit checksum encoding. Anjali fixes an issue of forcing writeback too often, which caused us to not benefit from NAPI. We now disable force writeback in the clean routine for X710 and XL710 adapters. The X722 adapters do not enable interrupt to force a writeback and benefit from WB_ON_ITR and so force WB is left enabled for those adapters. Fixed a possible deadlock issue where sync_vsi_filters() can be called directly under RTNL or through the timer subtask without RTNL. So update the flow to see if we are already under RTNL before trying to grab it. Stefan Assmann provides a fix for igb where SR-IOV was not getting enabled properly and we ran into a NULL pointer if the max_vfs module parameter is specified. This is prevented by setting the IGB_FLAG_HAS_MSIX bit before calling igb_probe_vfs(). v2: added "i40e: Fix for recursive RTNL lock during PROMISC change" patch to the series, as it resolves another issues seen and reported by Red Hat. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e.h3
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_debugfs.c4
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_main.c291
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_txrx.c214
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_txrx.h26
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c8
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40e_txrx.c94
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40e_txrx.h8
-rw-r--r--drivers/net/ethernet/intel/igb/igb_main.c3
9 files changed, 296 insertions, 355 deletions
diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h
index e7462793d48d..c64d18d4cb2d 100644
--- a/drivers/net/ethernet/intel/i40e/i40e.h
+++ b/drivers/net/ethernet/intel/i40e/i40e.h
@@ -243,7 +243,6 @@ struct i40e_pf {
243 struct pci_dev *pdev; 243 struct pci_dev *pdev;
244 struct i40e_hw hw; 244 struct i40e_hw hw;
245 unsigned long state; 245 unsigned long state;
246 unsigned long link_check_timeout;
247 struct msix_entry *msix_entries; 246 struct msix_entry *msix_entries;
248 bool fc_autoneg_status; 247 bool fc_autoneg_status;
249 248
@@ -667,7 +666,7 @@ struct i40e_mac_filter *i40e_add_filter(struct i40e_vsi *vsi,
667 bool is_vf, bool is_netdev); 666 bool is_vf, bool is_netdev);
668void i40e_del_filter(struct i40e_vsi *vsi, u8 *macaddr, s16 vlan, 667void i40e_del_filter(struct i40e_vsi *vsi, u8 *macaddr, s16 vlan,
669 bool is_vf, bool is_netdev); 668 bool is_vf, bool is_netdev);
670int i40e_sync_vsi_filters(struct i40e_vsi *vsi); 669int i40e_sync_vsi_filters(struct i40e_vsi *vsi, bool grab_rtnl);
671struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type, 670struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf, u8 type,
672 u16 uplink, u32 param1); 671 u16 uplink, u32 param1);
673int i40e_vsi_release(struct i40e_vsi *vsi); 672int i40e_vsi_release(struct i40e_vsi *vsi);
diff --git a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
index d7c15d17faa6..508efb034e87 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
@@ -1146,7 +1146,7 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
1146 } 1146 }
1147 1147
1148 f = i40e_add_filter(vsi, ma, vlan, false, false); 1148 f = i40e_add_filter(vsi, ma, vlan, false, false);
1149 ret = i40e_sync_vsi_filters(vsi); 1149 ret = i40e_sync_vsi_filters(vsi, true);
1150 if (f && !ret) 1150 if (f && !ret)
1151 dev_info(&pf->pdev->dev, 1151 dev_info(&pf->pdev->dev,
1152 "add macaddr: %pM vlan=%d added to VSI %d\n", 1152 "add macaddr: %pM vlan=%d added to VSI %d\n",
@@ -1183,7 +1183,7 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
1183 } 1183 }
1184 1184
1185 i40e_del_filter(vsi, ma, vlan, false, false); 1185 i40e_del_filter(vsi, ma, vlan, false, false);
1186 ret = i40e_sync_vsi_filters(vsi); 1186 ret = i40e_sync_vsi_filters(vsi, true);
1187 if (!ret) 1187 if (!ret)
1188 dev_info(&pf->pdev->dev, 1188 dev_info(&pf->pdev->dev,
1189 "del macaddr: %pM vlan=%d removed from VSI %d\n", 1189 "del macaddr: %pM vlan=%d removed from VSI %d\n",
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 530d8b6739f9..52e58f304b21 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -299,25 +299,69 @@ static void i40e_tx_timeout(struct net_device *netdev)
299 struct i40e_netdev_priv *np = netdev_priv(netdev); 299 struct i40e_netdev_priv *np = netdev_priv(netdev);
300 struct i40e_vsi *vsi = np->vsi; 300 struct i40e_vsi *vsi = np->vsi;
301 struct i40e_pf *pf = vsi->back; 301 struct i40e_pf *pf = vsi->back;
302 struct i40e_ring *tx_ring = NULL;
303 unsigned int i, hung_queue = 0;
304 u32 head, val;
302 305
303 pf->tx_timeout_count++; 306 pf->tx_timeout_count++;
304 307
308 /* find the stopped queue the same way the stack does */
309 for (i = 0; i < netdev->num_tx_queues; i++) {
310 struct netdev_queue *q;
311 unsigned long trans_start;
312
313 q = netdev_get_tx_queue(netdev, i);
314 trans_start = q->trans_start ? : netdev->trans_start;
315 if (netif_xmit_stopped(q) &&
316 time_after(jiffies,
317 (trans_start + netdev->watchdog_timeo))) {
318 hung_queue = i;
319 break;
320 }
321 }
322
323 if (i == netdev->num_tx_queues) {
324 netdev_info(netdev, "tx_timeout: no netdev hung queue found\n");
325 } else {
326 /* now that we have an index, find the tx_ring struct */
327 for (i = 0; i < vsi->num_queue_pairs; i++) {
328 if (vsi->tx_rings[i] && vsi->tx_rings[i]->desc) {
329 if (hung_queue ==
330 vsi->tx_rings[i]->queue_index) {
331 tx_ring = vsi->tx_rings[i];
332 break;
333 }
334 }
335 }
336 }
337
305 if (time_after(jiffies, (pf->tx_timeout_last_recovery + HZ*20))) 338 if (time_after(jiffies, (pf->tx_timeout_last_recovery + HZ*20)))
306 pf->tx_timeout_recovery_level = 1; 339 pf->tx_timeout_recovery_level = 1; /* reset after some time */
340 else if (time_before(jiffies,
341 (pf->tx_timeout_last_recovery + netdev->watchdog_timeo)))
342 return; /* don't do any new action before the next timeout */
343
344 if (tx_ring) {
345 head = i40e_get_head(tx_ring);
346 /* Read interrupt register */
347 if (pf->flags & I40E_FLAG_MSIX_ENABLED)
348 val = rd32(&pf->hw,
349 I40E_PFINT_DYN_CTLN(tx_ring->q_vector->v_idx +
350 tx_ring->vsi->base_vector - 1));
351 else
352 val = rd32(&pf->hw, I40E_PFINT_DYN_CTL0);
353
354 netdev_info(netdev, "tx_timeout: VSI_seid: %d, Q %d, NTC: 0x%x, HWB: 0x%x, NTU: 0x%x, TAIL: 0x%x, INT: 0x%x\n",
355 vsi->seid, hung_queue, tx_ring->next_to_clean,
356 head, tx_ring->next_to_use,
357 readl(tx_ring->tail), val);
358 }
359
307 pf->tx_timeout_last_recovery = jiffies; 360 pf->tx_timeout_last_recovery = jiffies;
308 netdev_info(netdev, "tx_timeout recovery level %d\n", 361 netdev_info(netdev, "tx_timeout recovery level %d, hung_queue %d\n",
309 pf->tx_timeout_recovery_level); 362 pf->tx_timeout_recovery_level, hung_queue);
310 363
311 switch (pf->tx_timeout_recovery_level) { 364 switch (pf->tx_timeout_recovery_level) {
312 case 0:
313 /* disable and re-enable queues for the VSI */
314 if (in_interrupt()) {
315 set_bit(__I40E_REINIT_REQUESTED, &pf->state);
316 set_bit(__I40E_REINIT_REQUESTED, &vsi->state);
317 } else {
318 i40e_vsi_reinit_locked(vsi);
319 }
320 break;
321 case 1: 365 case 1:
322 set_bit(__I40E_PF_RESET_REQUESTED, &pf->state); 366 set_bit(__I40E_PF_RESET_REQUESTED, &pf->state);
323 break; 367 break;
@@ -329,10 +373,9 @@ static void i40e_tx_timeout(struct net_device *netdev)
329 break; 373 break;
330 default: 374 default:
331 netdev_err(netdev, "tx_timeout recovery unsuccessful\n"); 375 netdev_err(netdev, "tx_timeout recovery unsuccessful\n");
332 set_bit(__I40E_DOWN_REQUESTED, &pf->state);
333 set_bit(__I40E_DOWN_REQUESTED, &vsi->state);
334 break; 376 break;
335 } 377 }
378
336 i40e_service_event_schedule(pf); 379 i40e_service_event_schedule(pf);
337 pf->tx_timeout_recovery_level++; 380 pf->tx_timeout_recovery_level++;
338} 381}
@@ -754,7 +797,6 @@ static void i40e_update_link_xoff_rx(struct i40e_pf *pf)
754 struct i40e_hw_port_stats *nsd = &pf->stats; 797 struct i40e_hw_port_stats *nsd = &pf->stats;
755 struct i40e_hw *hw = &pf->hw; 798 struct i40e_hw *hw = &pf->hw;
756 u64 xoff = 0; 799 u64 xoff = 0;
757 u16 i, v;
758 800
759 if ((hw->fc.current_mode != I40E_FC_FULL) && 801 if ((hw->fc.current_mode != I40E_FC_FULL) &&
760 (hw->fc.current_mode != I40E_FC_RX_PAUSE)) 802 (hw->fc.current_mode != I40E_FC_RX_PAUSE))
@@ -769,18 +811,6 @@ static void i40e_update_link_xoff_rx(struct i40e_pf *pf)
769 if (!(nsd->link_xoff_rx - xoff)) 811 if (!(nsd->link_xoff_rx - xoff))
770 return; 812 return;
771 813
772 /* Clear the __I40E_HANG_CHECK_ARMED bit for all Tx rings */
773 for (v = 0; v < pf->num_alloc_vsi; v++) {
774 struct i40e_vsi *vsi = pf->vsi[v];
775
776 if (!vsi || !vsi->tx_rings[0])
777 continue;
778
779 for (i = 0; i < vsi->num_queue_pairs; i++) {
780 struct i40e_ring *ring = vsi->tx_rings[i];
781 clear_bit(__I40E_HANG_CHECK_ARMED, &ring->state);
782 }
783 }
784} 814}
785 815
786/** 816/**
@@ -796,7 +826,7 @@ static void i40e_update_prio_xoff_rx(struct i40e_pf *pf)
796 bool xoff[I40E_MAX_TRAFFIC_CLASS] = {false}; 826 bool xoff[I40E_MAX_TRAFFIC_CLASS] = {false};
797 struct i40e_dcbx_config *dcb_cfg; 827 struct i40e_dcbx_config *dcb_cfg;
798 struct i40e_hw *hw = &pf->hw; 828 struct i40e_hw *hw = &pf->hw;
799 u16 i, v; 829 u16 i;
800 u8 tc; 830 u8 tc;
801 831
802 dcb_cfg = &hw->local_dcbx_config; 832 dcb_cfg = &hw->local_dcbx_config;
@@ -821,23 +851,6 @@ static void i40e_update_prio_xoff_rx(struct i40e_pf *pf)
821 tc = dcb_cfg->etscfg.prioritytable[i]; 851 tc = dcb_cfg->etscfg.prioritytable[i];
822 xoff[tc] = true; 852 xoff[tc] = true;
823 } 853 }
824
825 /* Clear the __I40E_HANG_CHECK_ARMED bit for Tx rings */
826 for (v = 0; v < pf->num_alloc_vsi; v++) {
827 struct i40e_vsi *vsi = pf->vsi[v];
828
829 if (!vsi || !vsi->tx_rings[0])
830 continue;
831
832 for (i = 0; i < vsi->num_queue_pairs; i++) {
833 struct i40e_ring *ring = vsi->tx_rings[i];
834
835 tc = ring->dcb_tc;
836 if (xoff[tc])
837 clear_bit(__I40E_HANG_CHECK_ARMED,
838 &ring->state);
839 }
840 }
841} 854}
842 855
843/** 856/**
@@ -1514,7 +1527,7 @@ static int i40e_set_mac(struct net_device *netdev, void *p)
1514 f->is_laa = true; 1527 f->is_laa = true;
1515 } 1528 }
1516 1529
1517 i40e_sync_vsi_filters(vsi); 1530 i40e_sync_vsi_filters(vsi, false);
1518 ether_addr_copy(netdev->dev_addr, addr->sa_data); 1531 ether_addr_copy(netdev->dev_addr, addr->sa_data);
1519 1532
1520 return 0; 1533 return 0;
@@ -1751,12 +1764,13 @@ static void i40e_set_rx_mode(struct net_device *netdev)
1751/** 1764/**
1752 * i40e_sync_vsi_filters - Update the VSI filter list to the HW 1765 * i40e_sync_vsi_filters - Update the VSI filter list to the HW
1753 * @vsi: ptr to the VSI 1766 * @vsi: ptr to the VSI
1767 * @grab_rtnl: whether RTNL needs to be grabbed
1754 * 1768 *
1755 * Push any outstanding VSI filter changes through the AdminQ. 1769 * Push any outstanding VSI filter changes through the AdminQ.
1756 * 1770 *
1757 * Returns 0 or error value 1771 * Returns 0 or error value
1758 **/ 1772 **/
1759int i40e_sync_vsi_filters(struct i40e_vsi *vsi) 1773int i40e_sync_vsi_filters(struct i40e_vsi *vsi, bool grab_rtnl)
1760{ 1774{
1761 struct i40e_mac_filter *f, *ftmp; 1775 struct i40e_mac_filter *f, *ftmp;
1762 bool promisc_forced_on = false; 1776 bool promisc_forced_on = false;
@@ -1945,7 +1959,11 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi)
1945 */ 1959 */
1946 if (pf->cur_promisc != cur_promisc) { 1960 if (pf->cur_promisc != cur_promisc) {
1947 pf->cur_promisc = cur_promisc; 1961 pf->cur_promisc = cur_promisc;
1948 i40e_do_reset_safe(pf, 1962 if (grab_rtnl)
1963 i40e_do_reset_safe(pf,
1964 BIT(__I40E_PF_RESET_REQUESTED));
1965 else
1966 i40e_do_reset(pf,
1949 BIT(__I40E_PF_RESET_REQUESTED)); 1967 BIT(__I40E_PF_RESET_REQUESTED));
1950 } 1968 }
1951 } else { 1969 } else {
@@ -1996,7 +2014,7 @@ static void i40e_sync_filters_subtask(struct i40e_pf *pf)
1996 for (v = 0; v < pf->num_alloc_vsi; v++) { 2014 for (v = 0; v < pf->num_alloc_vsi; v++) {
1997 if (pf->vsi[v] && 2015 if (pf->vsi[v] &&
1998 (pf->vsi[v]->flags & I40E_VSI_FLAG_FILTER_CHANGED)) 2016 (pf->vsi[v]->flags & I40E_VSI_FLAG_FILTER_CHANGED))
1999 i40e_sync_vsi_filters(pf->vsi[v]); 2017 i40e_sync_vsi_filters(pf->vsi[v], true);
2000 } 2018 }
2001} 2019}
2002 2020
@@ -2203,7 +2221,7 @@ int i40e_vsi_add_vlan(struct i40e_vsi *vsi, s16 vid)
2203 test_bit(__I40E_RESET_RECOVERY_PENDING, &vsi->back->state)) 2221 test_bit(__I40E_RESET_RECOVERY_PENDING, &vsi->back->state))
2204 return 0; 2222 return 0;
2205 2223
2206 return i40e_sync_vsi_filters(vsi); 2224 return i40e_sync_vsi_filters(vsi, false);
2207} 2225}
2208 2226
2209/** 2227/**
@@ -2275,7 +2293,7 @@ int i40e_vsi_kill_vlan(struct i40e_vsi *vsi, s16 vid)
2275 test_bit(__I40E_RESET_RECOVERY_PENDING, &vsi->back->state)) 2293 test_bit(__I40E_RESET_RECOVERY_PENDING, &vsi->back->state))
2276 return 0; 2294 return 0;
2277 2295
2278 return i40e_sync_vsi_filters(vsi); 2296 return i40e_sync_vsi_filters(vsi, false);
2279} 2297}
2280 2298
2281/** 2299/**
@@ -2609,8 +2627,6 @@ static int i40e_configure_tx_ring(struct i40e_ring *ring)
2609 wr32(hw, I40E_QTX_CTL(pf_q), qtx_ctl); 2627 wr32(hw, I40E_QTX_CTL(pf_q), qtx_ctl);
2610 i40e_flush(hw); 2628 i40e_flush(hw);
2611 2629
2612 clear_bit(__I40E_HANG_CHECK_ARMED, &ring->state);
2613
2614 /* cache tail off for easier writes later */ 2630 /* cache tail off for easier writes later */
2615 ring->tail = hw->hw_addr + I40E_QTX_TAIL(pf_q); 2631 ring->tail = hw->hw_addr + I40E_QTX_TAIL(pf_q);
2616 2632
@@ -4145,6 +4161,108 @@ static int i40e_pf_wait_txq_disabled(struct i40e_pf *pf)
4145} 4161}
4146 4162
4147#endif 4163#endif
4164
4165/**
4166 * i40e_detect_recover_hung_queue - Function to detect and recover hung_queue
4167 * @q_idx: TX queue number
4168 * @vsi: Pointer to VSI struct
4169 *
4170 * This function checks specified queue for given VSI. Detects hung condition.
4171 * Sets hung bit since it is two step process. Before next run of service task
4172 * if napi_poll runs, it reset 'hung' bit for respective q_vector. If not,
4173 * hung condition remain unchanged and during subsequent run, this function
4174 * issues SW interrupt to recover from hung condition.
4175 **/
4176static void i40e_detect_recover_hung_queue(int q_idx, struct i40e_vsi *vsi)
4177{
4178 struct i40e_ring *tx_ring = NULL;
4179 struct i40e_pf *pf;
4180 u32 head, val, tx_pending;
4181 int i;
4182
4183 pf = vsi->back;
4184
4185 /* now that we have an index, find the tx_ring struct */
4186 for (i = 0; i < vsi->num_queue_pairs; i++) {
4187 if (vsi->tx_rings[i] && vsi->tx_rings[i]->desc) {
4188 if (q_idx == vsi->tx_rings[i]->queue_index) {
4189 tx_ring = vsi->tx_rings[i];
4190 break;
4191 }
4192 }
4193 }
4194
4195 if (!tx_ring)
4196 return;
4197
4198 /* Read interrupt register */
4199 if (pf->flags & I40E_FLAG_MSIX_ENABLED)
4200 val = rd32(&pf->hw,
4201 I40E_PFINT_DYN_CTLN(tx_ring->q_vector->v_idx +
4202 tx_ring->vsi->base_vector - 1));
4203 else
4204 val = rd32(&pf->hw, I40E_PFINT_DYN_CTL0);
4205
4206 head = i40e_get_head(tx_ring);
4207
4208 tx_pending = i40e_get_tx_pending(tx_ring);
4209
4210 /* Interrupts are disabled and TX pending is non-zero,
4211 * trigger the SW interrupt (don't wait). Worst case
4212 * there will be one extra interrupt which may result
4213 * into not cleaning any queues because queues are cleaned.
4214 */
4215 if (tx_pending && (!(val & I40E_PFINT_DYN_CTLN_INTENA_MASK)))
4216 i40e_force_wb(vsi, tx_ring->q_vector);
4217}
4218
4219/**
4220 * i40e_detect_recover_hung - Function to detect and recover hung_queues
4221 * @pf: pointer to PF struct
4222 *
4223 * LAN VSI has netdev and netdev has TX queues. This function is to check
4224 * each of those TX queues if they are hung, trigger recovery by issuing
4225 * SW interrupt.
4226 **/
4227static void i40e_detect_recover_hung(struct i40e_pf *pf)
4228{
4229 struct net_device *netdev;
4230 struct i40e_vsi *vsi;
4231 int i;
4232
4233 /* Only for LAN VSI */
4234 vsi = pf->vsi[pf->lan_vsi];
4235
4236 if (!vsi)
4237 return;
4238
4239 /* Make sure, VSI state is not DOWN/RECOVERY_PENDING */
4240 if (test_bit(__I40E_DOWN, &vsi->back->state) ||
4241 test_bit(__I40E_RESET_RECOVERY_PENDING, &vsi->back->state))
4242 return;
4243
4244 /* Make sure type is MAIN VSI */
4245 if (vsi->type != I40E_VSI_MAIN)
4246 return;
4247
4248 netdev = vsi->netdev;
4249 if (!netdev)
4250 return;
4251
4252 /* Bail out if netif_carrier is not OK */
4253 if (!netif_carrier_ok(netdev))
4254 return;
4255
4256 /* Go thru' TX queues for netdev */
4257 for (i = 0; i < netdev->num_tx_queues; i++) {
4258 struct netdev_queue *q;
4259
4260 q = netdev_get_tx_queue(netdev, i);
4261 if (q)
4262 i40e_detect_recover_hung_queue(i, vsi);
4263 }
4264}
4265
4148/** 4266/**
4149 * i40e_get_iscsi_tc_map - Return TC map for iSCSI APP 4267 * i40e_get_iscsi_tc_map - Return TC map for iSCSI APP
4150 * @pf: pointer to PF 4268 * @pf: pointer to PF
@@ -5759,68 +5877,6 @@ static void i40e_link_event(struct i40e_pf *pf)
5759} 5877}
5760 5878
5761/** 5879/**
5762 * i40e_check_hang_subtask - Check for hung queues and dropped interrupts
5763 * @pf: board private structure
5764 *
5765 * Set the per-queue flags to request a check for stuck queues in the irq
5766 * clean functions, then force interrupts to be sure the irq clean is called.
5767 **/
5768static void i40e_check_hang_subtask(struct i40e_pf *pf)
5769{
5770 int i, v;
5771
5772 /* If we're down or resetting, just bail */
5773 if (test_bit(__I40E_DOWN, &pf->state) ||
5774 test_bit(__I40E_CONFIG_BUSY, &pf->state))
5775 return;
5776
5777 /* for each VSI/netdev
5778 * for each Tx queue
5779 * set the check flag
5780 * for each q_vector
5781 * force an interrupt
5782 */
5783 for (v = 0; v < pf->num_alloc_vsi; v++) {
5784 struct i40e_vsi *vsi = pf->vsi[v];
5785 int armed = 0;
5786
5787 if (!pf->vsi[v] ||
5788 test_bit(__I40E_DOWN, &vsi->state) ||
5789 (vsi->netdev && !netif_carrier_ok(vsi->netdev)))
5790 continue;
5791
5792 for (i = 0; i < vsi->num_queue_pairs; i++) {
5793 set_check_for_tx_hang(vsi->tx_rings[i]);
5794 if (test_bit(__I40E_HANG_CHECK_ARMED,
5795 &vsi->tx_rings[i]->state))
5796 armed++;
5797 }
5798
5799 if (armed) {
5800 if (!(pf->flags & I40E_FLAG_MSIX_ENABLED)) {
5801 wr32(&vsi->back->hw, I40E_PFINT_DYN_CTL0,
5802 (I40E_PFINT_DYN_CTL0_INTENA_MASK |
5803 I40E_PFINT_DYN_CTL0_SWINT_TRIG_MASK |
5804 I40E_PFINT_DYN_CTL0_ITR_INDX_MASK |
5805 I40E_PFINT_DYN_CTL0_SW_ITR_INDX_ENA_MASK |
5806 I40E_PFINT_DYN_CTL0_SW_ITR_INDX_MASK));
5807 } else {
5808 u16 vec = vsi->base_vector - 1;
5809 u32 val = (I40E_PFINT_DYN_CTLN_INTENA_MASK |
5810 I40E_PFINT_DYN_CTLN_SWINT_TRIG_MASK |
5811 I40E_PFINT_DYN_CTLN_ITR_INDX_MASK |
5812 I40E_PFINT_DYN_CTLN_SW_ITR_INDX_ENA_MASK |
5813 I40E_PFINT_DYN_CTLN_SW_ITR_INDX_MASK);
5814 for (i = 0; i < vsi->num_q_vectors; i++, vec++)
5815 wr32(&vsi->back->hw,
5816 I40E_PFINT_DYN_CTLN(vec), val);
5817 }
5818 i40e_flush(&vsi->back->hw);
5819 }
5820 }
5821}
5822
5823/**
5824 * i40e_watchdog_subtask - periodic checks not using event driven response 5880 * i40e_watchdog_subtask - periodic checks not using event driven response
5825 * @pf: board private structure 5881 * @pf: board private structure
5826 **/ 5882 **/
@@ -5839,7 +5895,6 @@ static void i40e_watchdog_subtask(struct i40e_pf *pf)
5839 return; 5895 return;
5840 pf->service_timer_previous = jiffies; 5896 pf->service_timer_previous = jiffies;
5841 5897
5842 i40e_check_hang_subtask(pf);
5843 i40e_link_event(pf); 5898 i40e_link_event(pf);
5844 5899
5845 /* Update the stats for active netdevs so the network stack 5900 /* Update the stats for active netdevs so the network stack
@@ -6807,6 +6862,7 @@ static void i40e_service_task(struct work_struct *work)
6807 return; 6862 return;
6808 } 6863 }
6809 6864
6865 i40e_detect_recover_hung(pf);
6810 i40e_reset_subtask(pf); 6866 i40e_reset_subtask(pf);
6811 i40e_handle_mdd_event(pf); 6867 i40e_handle_mdd_event(pf);
6812 i40e_vc_process_vflr_event(pf); 6868 i40e_vc_process_vflr_event(pf);
@@ -8770,7 +8826,7 @@ int i40e_vsi_release(struct i40e_vsi *vsi)
8770 list_for_each_entry_safe(f, ftmp, &vsi->mac_filter_list, list) 8826 list_for_each_entry_safe(f, ftmp, &vsi->mac_filter_list, list)
8771 i40e_del_filter(vsi, f->macaddr, f->vlan, 8827 i40e_del_filter(vsi, f->macaddr, f->vlan,
8772 f->is_vf, f->is_netdev); 8828 f->is_vf, f->is_netdev);
8773 i40e_sync_vsi_filters(vsi); 8829 i40e_sync_vsi_filters(vsi, false);
8774 8830
8775 i40e_vsi_delete(vsi); 8831 i40e_vsi_delete(vsi);
8776 i40e_vsi_free_q_vectors(vsi); 8832 i40e_vsi_free_q_vectors(vsi);
@@ -10101,7 +10157,6 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
10101 INIT_WORK(&pf->service_task, i40e_service_task); 10157 INIT_WORK(&pf->service_task, i40e_service_task);
10102 clear_bit(__I40E_SERVICE_SCHED, &pf->state); 10158 clear_bit(__I40E_SERVICE_SCHED, &pf->state);
10103 pf->flags |= I40E_FLAG_NEED_LINK_UPDATE; 10159 pf->flags |= I40E_FLAG_NEED_LINK_UPDATE;
10104 pf->link_check_timeout = jiffies;
10105 10160
10106 /* WoL defaults to disabled */ 10161 /* WoL defaults to disabled */
10107 pf->wol_en = false; 10162 pf->wol_en = false;
diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
index 738aca68f665..3ce4900c0c43 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
@@ -601,27 +601,13 @@ void i40e_free_tx_resources(struct i40e_ring *tx_ring)
601} 601}
602 602
603/** 603/**
604 * i40e_get_head - Retrieve head from head writeback
605 * @tx_ring: tx ring to fetch head of
606 *
607 * Returns value of Tx ring head based on value stored
608 * in head write-back location
609 **/
610static inline u32 i40e_get_head(struct i40e_ring *tx_ring)
611{
612 void *head = (struct i40e_tx_desc *)tx_ring->desc + tx_ring->count;
613
614 return le32_to_cpu(*(volatile __le32 *)head);
615}
616
617/**
618 * i40e_get_tx_pending - how many tx descriptors not processed 604 * i40e_get_tx_pending - how many tx descriptors not processed
619 * @tx_ring: the ring of descriptors 605 * @tx_ring: the ring of descriptors
620 * 606 *
621 * Since there is no access to the ring head register 607 * Since there is no access to the ring head register
622 * in XL710, we need to use our local copies 608 * in XL710, we need to use our local copies
623 **/ 609 **/
624static u32 i40e_get_tx_pending(struct i40e_ring *ring) 610u32 i40e_get_tx_pending(struct i40e_ring *ring)
625{ 611{
626 u32 head, tail; 612 u32 head, tail;
627 613
@@ -635,50 +621,6 @@ static u32 i40e_get_tx_pending(struct i40e_ring *ring)
635 return 0; 621 return 0;
636} 622}
637 623
638/**
639 * i40e_check_tx_hang - Is there a hang in the Tx queue
640 * @tx_ring: the ring of descriptors
641 **/
642static bool i40e_check_tx_hang(struct i40e_ring *tx_ring)
643{
644 u32 tx_done = tx_ring->stats.packets;
645 u32 tx_done_old = tx_ring->tx_stats.tx_done_old;
646 u32 tx_pending = i40e_get_tx_pending(tx_ring);
647 struct i40e_pf *pf = tx_ring->vsi->back;
648 bool ret = false;
649
650 clear_check_for_tx_hang(tx_ring);
651
652 /* Check for a hung queue, but be thorough. This verifies
653 * that a transmit has been completed since the previous
654 * check AND there is at least one packet pending. The
655 * ARMED bit is set to indicate a potential hang. The
656 * bit is cleared if a pause frame is received to remove
657 * false hang detection due to PFC or 802.3x frames. By
658 * requiring this to fail twice we avoid races with
659 * PFC clearing the ARMED bit and conditions where we
660 * run the check_tx_hang logic with a transmit completion
661 * pending but without time to complete it yet.
662 */
663 if ((tx_done_old == tx_done) && tx_pending) {
664 /* make sure it is true for two checks in a row */
665 ret = test_and_set_bit(__I40E_HANG_CHECK_ARMED,
666 &tx_ring->state);
667 } else if (tx_done_old == tx_done &&
668 (tx_pending < I40E_MIN_DESC_PENDING) && (tx_pending > 0)) {
669 if (I40E_DEBUG_FLOW & pf->hw.debug_mask)
670 dev_info(tx_ring->dev, "HW needs some more descs to do a cacheline flush. tx_pending %d, queue %d",
671 tx_pending, tx_ring->queue_index);
672 pf->tx_sluggish_count++;
673 } else {
674 /* update completed stats and disarm the hang check */
675 tx_ring->tx_stats.tx_done_old = tx_done;
676 clear_bit(__I40E_HANG_CHECK_ARMED, &tx_ring->state);
677 }
678
679 return ret;
680}
681
682#define WB_STRIDE 0x3 624#define WB_STRIDE 0x3
683 625
684/** 626/**
@@ -784,42 +726,21 @@ static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget)
784 tx_ring->q_vector->tx.total_bytes += total_bytes; 726 tx_ring->q_vector->tx.total_bytes += total_bytes;
785 tx_ring->q_vector->tx.total_packets += total_packets; 727 tx_ring->q_vector->tx.total_packets += total_packets;
786 728
787 /* check to see if there are any non-cache aligned descriptors 729 if (tx_ring->flags & I40E_TXR_FLAGS_WB_ON_ITR) {
788 * waiting to be written back, and kick the hardware to force 730 unsigned int j = 0;
789 * them to be written back in case of napi polling 731
790 */ 732 /* check to see if there are < 4 descriptors
791 if (budget && 733 * waiting to be written back, then kick the hardware to force
792 !((i & WB_STRIDE) == WB_STRIDE) && 734 * them to be written back in case we stay in NAPI.
793 !test_bit(__I40E_DOWN, &tx_ring->vsi->state) && 735 * In this mode on X722 we do not enable Interrupt.
794 (I40E_DESC_UNUSED(tx_ring) != tx_ring->count))
795 tx_ring->arm_wb = true;
796 else
797 tx_ring->arm_wb = false;
798
799 if (check_for_tx_hang(tx_ring) && i40e_check_tx_hang(tx_ring)) {
800 /* schedule immediate reset if we believe we hung */
801 dev_info(tx_ring->dev, "Detected Tx Unit Hang\n"
802 " VSI <%d>\n"
803 " Tx Queue <%d>\n"
804 " next_to_use <%x>\n"
805 " next_to_clean <%x>\n",
806 tx_ring->vsi->seid,
807 tx_ring->queue_index,
808 tx_ring->next_to_use, i);
809
810 netif_stop_subqueue(tx_ring->netdev, tx_ring->queue_index);
811
812 dev_info(tx_ring->dev,
813 "tx hang detected on queue %d, reset requested\n",
814 tx_ring->queue_index);
815
816 /* do not fire the reset immediately, wait for the stack to
817 * decide we are truly stuck, also prevents every queue from
818 * simultaneously requesting a reset
819 */ 736 */
737 j = i40e_get_tx_pending(tx_ring);
820 738
821 /* the adapter is about to reset, no point in enabling polling */ 739 if (budget &&
822 budget = 1; 740 ((j / (WB_STRIDE + 1)) == 0) && (j != 0) &&
741 !test_bit(__I40E_DOWN, &tx_ring->vsi->state) &&
742 (I40E_DESC_UNUSED(tx_ring) != tx_ring->count))
743 tx_ring->arm_wb = true;
823 } 744 }
824 745
825 netdev_tx_completed_queue(netdev_get_tx_queue(tx_ring->netdev, 746 netdev_tx_completed_queue(netdev_get_tx_queue(tx_ring->netdev,
@@ -851,7 +772,7 @@ static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget)
851 * @q_vector: the vector on which to force writeback 772 * @q_vector: the vector on which to force writeback
852 * 773 *
853 **/ 774 **/
854static void i40e_force_wb(struct i40e_vsi *vsi, struct i40e_q_vector *q_vector) 775void i40e_force_wb(struct i40e_vsi *vsi, struct i40e_q_vector *q_vector)
855{ 776{
856 u16 flags = q_vector->tx.ring[0].flags; 777 u16 flags = q_vector->tx.ring[0].flags;
857 778
@@ -2324,6 +2245,9 @@ static void i40e_tx_enable_csum(struct sk_buff *skb, u32 *tx_flags,
2324 l4_tunnel = I40E_TXD_CTX_UDP_TUNNELING; 2245 l4_tunnel = I40E_TXD_CTX_UDP_TUNNELING;
2325 *tx_flags |= I40E_TX_FLAGS_VXLAN_TUNNEL; 2246 *tx_flags |= I40E_TX_FLAGS_VXLAN_TUNNEL;
2326 break; 2247 break;
2248 case IPPROTO_GRE:
2249 l4_tunnel = I40E_TXD_CTX_GRE_TUNNELING;
2250 break;
2327 default: 2251 default:
2328 return; 2252 return;
2329 } 2253 }
@@ -2581,6 +2505,9 @@ static inline void i40e_tx_map(struct i40e_ring *tx_ring, struct sk_buff *skb,
2581 u32 td_tag = 0; 2505 u32 td_tag = 0;
2582 dma_addr_t dma; 2506 dma_addr_t dma;
2583 u16 gso_segs; 2507 u16 gso_segs;
2508 u16 desc_count = 0;
2509 bool tail_bump = true;
2510 bool do_rs = false;
2584 2511
2585 if (tx_flags & I40E_TX_FLAGS_HW_VLAN) { 2512 if (tx_flags & I40E_TX_FLAGS_HW_VLAN) {
2586 td_cmd |= I40E_TX_DESC_CMD_IL2TAG1; 2513 td_cmd |= I40E_TX_DESC_CMD_IL2TAG1;
@@ -2621,6 +2548,8 @@ static inline void i40e_tx_map(struct i40e_ring *tx_ring, struct sk_buff *skb,
2621 2548
2622 tx_desc++; 2549 tx_desc++;
2623 i++; 2550 i++;
2551 desc_count++;
2552
2624 if (i == tx_ring->count) { 2553 if (i == tx_ring->count) {
2625 tx_desc = I40E_TX_DESC(tx_ring, 0); 2554 tx_desc = I40E_TX_DESC(tx_ring, 0);
2626 i = 0; 2555 i = 0;
@@ -2640,6 +2569,8 @@ static inline void i40e_tx_map(struct i40e_ring *tx_ring, struct sk_buff *skb,
2640 2569
2641 tx_desc++; 2570 tx_desc++;
2642 i++; 2571 i++;
2572 desc_count++;
2573
2643 if (i == tx_ring->count) { 2574 if (i == tx_ring->count) {
2644 tx_desc = I40E_TX_DESC(tx_ring, 0); 2575 tx_desc = I40E_TX_DESC(tx_ring, 0);
2645 i = 0; 2576 i = 0;
@@ -2654,34 +2585,6 @@ static inline void i40e_tx_map(struct i40e_ring *tx_ring, struct sk_buff *skb,
2654 tx_bi = &tx_ring->tx_bi[i]; 2585 tx_bi = &tx_ring->tx_bi[i];
2655 } 2586 }
2656 2587
2657 /* Place RS bit on last descriptor of any packet that spans across the
2658 * 4th descriptor (WB_STRIDE aka 0x3) in a 64B cacheline.
2659 */
2660 if (((i & WB_STRIDE) != WB_STRIDE) &&
2661 (first <= &tx_ring->tx_bi[i]) &&
2662 (first >= &tx_ring->tx_bi[i & ~WB_STRIDE])) {
2663 tx_desc->cmd_type_offset_bsz =
2664 build_ctob(td_cmd, td_offset, size, td_tag) |
2665 cpu_to_le64((u64)I40E_TX_DESC_CMD_EOP <<
2666 I40E_TXD_QW1_CMD_SHIFT);
2667 } else {
2668 tx_desc->cmd_type_offset_bsz =
2669 build_ctob(td_cmd, td_offset, size, td_tag) |
2670 cpu_to_le64((u64)I40E_TXD_CMD <<
2671 I40E_TXD_QW1_CMD_SHIFT);
2672 }
2673
2674 netdev_tx_sent_queue(netdev_get_tx_queue(tx_ring->netdev,
2675 tx_ring->queue_index),
2676 first->bytecount);
2677
2678 /* Force memory writes to complete before letting h/w
2679 * know there are new descriptors to fetch. (Only
2680 * applicable for weak-ordered memory model archs,
2681 * such as IA-64).
2682 */
2683 wmb();
2684
2685 /* set next_to_watch value indicating a packet is present */ 2588 /* set next_to_watch value indicating a packet is present */
2686 first->next_to_watch = tx_desc; 2589 first->next_to_watch = tx_desc;
2687 2590
@@ -2691,15 +2594,72 @@ static inline void i40e_tx_map(struct i40e_ring *tx_ring, struct sk_buff *skb,
2691 2594
2692 tx_ring->next_to_use = i; 2595 tx_ring->next_to_use = i;
2693 2596
2597 netdev_tx_sent_queue(netdev_get_tx_queue(tx_ring->netdev,
2598 tx_ring->queue_index),
2599 first->bytecount);
2694 i40e_maybe_stop_tx(tx_ring, DESC_NEEDED); 2600 i40e_maybe_stop_tx(tx_ring, DESC_NEEDED);
2601
2602 /* Algorithm to optimize tail and RS bit setting:
2603 * if xmit_more is supported
2604 * if xmit_more is true
2605 * do not update tail and do not mark RS bit.
2606 * if xmit_more is false and last xmit_more was false
2607 * if every packet spanned less than 4 desc
2608 * then set RS bit on 4th packet and update tail
2609 * on every packet
2610 * else
2611 * update tail and set RS bit on every packet.
2612 * if xmit_more is false and last_xmit_more was true
2613 * update tail and set RS bit.
2614 *
2615 * Optimization: wmb to be issued only in case of tail update.
2616 * Also optimize the Descriptor WB path for RS bit with the same
2617 * algorithm.
2618 *
2619 * Note: If there are less than 4 packets
2620 * pending and interrupts were disabled the service task will
2621 * trigger a force WB.
2622 */
2623 if (skb->xmit_more &&
2624 !netif_xmit_stopped(netdev_get_tx_queue(tx_ring->netdev,
2625 tx_ring->queue_index))) {
2626 tx_ring->flags |= I40E_TXR_FLAGS_LAST_XMIT_MORE_SET;
2627 tail_bump = false;
2628 } else if (!skb->xmit_more &&
2629 !netif_xmit_stopped(netdev_get_tx_queue(tx_ring->netdev,
2630 tx_ring->queue_index)) &&
2631 (!(tx_ring->flags & I40E_TXR_FLAGS_LAST_XMIT_MORE_SET)) &&
2632 (tx_ring->packet_stride < WB_STRIDE) &&
2633 (desc_count < WB_STRIDE)) {
2634 tx_ring->packet_stride++;
2635 } else {
2636 tx_ring->packet_stride = 0;
2637 tx_ring->flags &= ~I40E_TXR_FLAGS_LAST_XMIT_MORE_SET;
2638 do_rs = true;
2639 }
2640 if (do_rs)
2641 tx_ring->packet_stride = 0;
2642
2643 tx_desc->cmd_type_offset_bsz =
2644 build_ctob(td_cmd, td_offset, size, td_tag) |
2645 cpu_to_le64((u64)(do_rs ? I40E_TXD_CMD :
2646 I40E_TX_DESC_CMD_EOP) <<
2647 I40E_TXD_QW1_CMD_SHIFT);
2648
2695 /* notify HW of packet */ 2649 /* notify HW of packet */
2696 if (!skb->xmit_more || 2650 if (!tail_bump)
2697 netif_xmit_stopped(netdev_get_tx_queue(tx_ring->netdev,
2698 tx_ring->queue_index)))
2699 writel(i, tx_ring->tail);
2700 else
2701 prefetchw(tx_desc + 1); 2651 prefetchw(tx_desc + 1);
2702 2652
2653 if (tail_bump) {
2654 /* Force memory writes to complete before letting h/w
2655 * know there are new descriptors to fetch. (Only
2656 * applicable for weak-ordered memory model archs,
2657 * such as IA-64).
2658 */
2659 wmb();
2660 writel(i, tx_ring->tail);
2661 }
2662
2703 return; 2663 return;
2704 2664
2705dma_error: 2665dma_error:
diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.h b/drivers/net/ethernet/intel/i40e/i40e_txrx.h
index f1385a1989fa..a3978c2b5fc9 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.h
@@ -199,8 +199,6 @@ struct i40e_rx_queue_stats {
199enum i40e_ring_state_t { 199enum i40e_ring_state_t {
200 __I40E_TX_FDIR_INIT_DONE, 200 __I40E_TX_FDIR_INIT_DONE,
201 __I40E_TX_XPS_INIT_DONE, 201 __I40E_TX_XPS_INIT_DONE,
202 __I40E_TX_DETECT_HANG,
203 __I40E_HANG_CHECK_ARMED,
204 __I40E_RX_PS_ENABLED, 202 __I40E_RX_PS_ENABLED,
205 __I40E_RX_16BYTE_DESC_ENABLED, 203 __I40E_RX_16BYTE_DESC_ENABLED,
206}; 204};
@@ -211,12 +209,6 @@ enum i40e_ring_state_t {
211 set_bit(__I40E_RX_PS_ENABLED, &(ring)->state) 209 set_bit(__I40E_RX_PS_ENABLED, &(ring)->state)
212#define clear_ring_ps_enabled(ring) \ 210#define clear_ring_ps_enabled(ring) \
213 clear_bit(__I40E_RX_PS_ENABLED, &(ring)->state) 211 clear_bit(__I40E_RX_PS_ENABLED, &(ring)->state)
214#define check_for_tx_hang(ring) \
215 test_bit(__I40E_TX_DETECT_HANG, &(ring)->state)
216#define set_check_for_tx_hang(ring) \
217 set_bit(__I40E_TX_DETECT_HANG, &(ring)->state)
218#define clear_check_for_tx_hang(ring) \
219 clear_bit(__I40E_TX_DETECT_HANG, &(ring)->state)
220#define ring_is_16byte_desc_enabled(ring) \ 212#define ring_is_16byte_desc_enabled(ring) \
221 test_bit(__I40E_RX_16BYTE_DESC_ENABLED, &(ring)->state) 213 test_bit(__I40E_RX_16BYTE_DESC_ENABLED, &(ring)->state)
222#define set_ring_16byte_desc_enabled(ring) \ 214#define set_ring_16byte_desc_enabled(ring) \
@@ -264,10 +256,12 @@ struct i40e_ring {
264 256
265 bool ring_active; /* is ring online or not */ 257 bool ring_active; /* is ring online or not */
266 bool arm_wb; /* do something to arm write back */ 258 bool arm_wb; /* do something to arm write back */
259 u8 packet_stride;
267 260
268 u16 flags; 261 u16 flags;
269#define I40E_TXR_FLAGS_WB_ON_ITR BIT(0) 262#define I40E_TXR_FLAGS_WB_ON_ITR BIT(0)
270#define I40E_TXR_FLAGS_OUTER_UDP_CSUM BIT(1) 263#define I40E_TXR_FLAGS_OUTER_UDP_CSUM BIT(1)
264#define I40E_TXR_FLAGS_LAST_XMIT_MORE_SET BIT(2)
271 265
272 /* stats structs */ 266 /* stats structs */
273 struct i40e_queue_stats stats; 267 struct i40e_queue_stats stats;
@@ -326,4 +320,20 @@ int i40e_xmit_descriptor_count(struct sk_buff *skb, struct i40e_ring *tx_ring);
326int i40e_tx_prepare_vlan_flags(struct sk_buff *skb, 320int i40e_tx_prepare_vlan_flags(struct sk_buff *skb,
327 struct i40e_ring *tx_ring, u32 *flags); 321 struct i40e_ring *tx_ring, u32 *flags);
328#endif 322#endif
323void i40e_force_wb(struct i40e_vsi *vsi, struct i40e_q_vector *q_vector);
324u32 i40e_get_tx_pending(struct i40e_ring *ring);
325
326/**
327 * i40e_get_head - Retrieve head from head writeback
328 * @tx_ring: tx ring to fetch head of
329 *
330 * Returns value of Tx ring head based on value stored
331 * in head write-back location
332 **/
333static inline u32 i40e_get_head(struct i40e_ring *tx_ring)
334{
335 void *head = (struct i40e_tx_desc *)tx_ring->desc + tx_ring->count;
336
337 return le32_to_cpu(*(volatile __le32 *)head);
338}
329#endif /* _I40E_TXRX_H_ */ 339#endif /* _I40E_TXRX_H_ */
diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index d99c116032f3..eacce9389962 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -561,7 +561,7 @@ static int i40e_alloc_vsi_res(struct i40e_vf *vf, enum i40e_vsi_type type)
561 } 561 }
562 562
563 /* program mac filter */ 563 /* program mac filter */
564 ret = i40e_sync_vsi_filters(vsi); 564 ret = i40e_sync_vsi_filters(vsi, false);
565 if (ret) 565 if (ret)
566 dev_err(&pf->pdev->dev, "Unable to program ucast filters\n"); 566 dev_err(&pf->pdev->dev, "Unable to program ucast filters\n");
567 567
@@ -1605,7 +1605,7 @@ static int i40e_vc_add_mac_addr_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
1605 } 1605 }
1606 1606
1607 /* program the updated filter list */ 1607 /* program the updated filter list */
1608 if (i40e_sync_vsi_filters(vsi)) 1608 if (i40e_sync_vsi_filters(vsi, false))
1609 dev_err(&pf->pdev->dev, "Unable to program VF MAC filters\n"); 1609 dev_err(&pf->pdev->dev, "Unable to program VF MAC filters\n");
1610 1610
1611error_param: 1611error_param:
@@ -1656,7 +1656,7 @@ static int i40e_vc_del_mac_addr_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
1656 I40E_VLAN_ANY, true, false); 1656 I40E_VLAN_ANY, true, false);
1657 1657
1658 /* program the updated filter list */ 1658 /* program the updated filter list */
1659 if (i40e_sync_vsi_filters(vsi)) 1659 if (i40e_sync_vsi_filters(vsi, false))
1660 dev_err(&pf->pdev->dev, "Unable to program VF MAC filters\n"); 1660 dev_err(&pf->pdev->dev, "Unable to program VF MAC filters\n");
1661 1661
1662error_param: 1662error_param:
@@ -2062,7 +2062,7 @@ int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
2062 2062
2063 dev_info(&pf->pdev->dev, "Setting MAC %pM on VF %d\n", mac, vf_id); 2063 dev_info(&pf->pdev->dev, "Setting MAC %pM on VF %d\n", mac, vf_id);
2064 /* program mac filter */ 2064 /* program mac filter */
2065 if (i40e_sync_vsi_filters(vsi)) { 2065 if (i40e_sync_vsi_filters(vsi, false)) {
2066 dev_err(&pf->pdev->dev, "Unable to program ucast filters\n"); 2066 dev_err(&pf->pdev->dev, "Unable to program ucast filters\n");
2067 ret = -EIO; 2067 ret = -EIO;
2068 goto error_param; 2068 goto error_param;
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
index 7e91d825c760..830979380466 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
@@ -140,65 +140,6 @@ static inline u32 i40e_get_head(struct i40e_ring *tx_ring)
140 return le32_to_cpu(*(volatile __le32 *)head); 140 return le32_to_cpu(*(volatile __le32 *)head);
141} 141}
142 142
143/**
144 * i40e_get_tx_pending - how many tx descriptors not processed
145 * @tx_ring: the ring of descriptors
146 *
147 * Since there is no access to the ring head register
148 * in XL710, we need to use our local copies
149 **/
150static u32 i40e_get_tx_pending(struct i40e_ring *ring)
151{
152 u32 head, tail;
153
154 head = i40e_get_head(ring);
155 tail = readl(ring->tail);
156
157 if (head != tail)
158 return (head < tail) ?
159 tail - head : (tail + ring->count - head);
160
161 return 0;
162}
163
164/**
165 * i40e_check_tx_hang - Is there a hang in the Tx queue
166 * @tx_ring: the ring of descriptors
167 **/
168static bool i40e_check_tx_hang(struct i40e_ring *tx_ring)
169{
170 u32 tx_done = tx_ring->stats.packets;
171 u32 tx_done_old = tx_ring->tx_stats.tx_done_old;
172 u32 tx_pending = i40e_get_tx_pending(tx_ring);
173 bool ret = false;
174
175 clear_check_for_tx_hang(tx_ring);
176
177 /* Check for a hung queue, but be thorough. This verifies
178 * that a transmit has been completed since the previous
179 * check AND there is at least one packet pending. The
180 * ARMED bit is set to indicate a potential hang. The
181 * bit is cleared if a pause frame is received to remove
182 * false hang detection due to PFC or 802.3x frames. By
183 * requiring this to fail twice we avoid races with
184 * PFC clearing the ARMED bit and conditions where we
185 * run the check_tx_hang logic with a transmit completion
186 * pending but without time to complete it yet.
187 */
188 if ((tx_done_old == tx_done) && tx_pending) {
189 /* make sure it is true for two checks in a row */
190 ret = test_and_set_bit(__I40E_HANG_CHECK_ARMED,
191 &tx_ring->state);
192 } else if (tx_done_old == tx_done &&
193 (tx_pending < I40E_MIN_DESC_PENDING) && (tx_pending > 0)) {
194 /* update completed stats and disarm the hang check */
195 tx_ring->tx_stats.tx_done_old = tx_done;
196 clear_bit(__I40E_HANG_CHECK_ARMED, &tx_ring->state);
197 }
198
199 return ret;
200}
201
202#define WB_STRIDE 0x3 143#define WB_STRIDE 0x3
203 144
204/** 145/**
@@ -304,6 +245,10 @@ static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget)
304 tx_ring->q_vector->tx.total_bytes += total_bytes; 245 tx_ring->q_vector->tx.total_bytes += total_bytes;
305 tx_ring->q_vector->tx.total_packets += total_packets; 246 tx_ring->q_vector->tx.total_packets += total_packets;
306 247
248 /* check to see if there are any non-cache aligned descriptors
249 * waiting to be written back, and kick the hardware to force
250 * them to be written back in case of napi polling
251 */
307 if (budget && 252 if (budget &&
308 !((i & WB_STRIDE) == WB_STRIDE) && 253 !((i & WB_STRIDE) == WB_STRIDE) &&
309 !test_bit(__I40E_DOWN, &tx_ring->vsi->state) && 254 !test_bit(__I40E_DOWN, &tx_ring->vsi->state) &&
@@ -312,29 +257,6 @@ static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget)
312 else 257 else
313 tx_ring->arm_wb = false; 258 tx_ring->arm_wb = false;
314 259
315 if (check_for_tx_hang(tx_ring) && i40e_check_tx_hang(tx_ring)) {
316 /* schedule immediate reset if we believe we hung */
317 dev_info(tx_ring->dev, "Detected Tx Unit Hang\n"
318 " VSI <%d>\n"
319 " Tx Queue <%d>\n"
320 " next_to_use <%x>\n"
321 " next_to_clean <%x>\n",
322 tx_ring->vsi->seid,
323 tx_ring->queue_index,
324 tx_ring->next_to_use, i);
325
326 netif_stop_subqueue(tx_ring->netdev, tx_ring->queue_index);
327
328 dev_info(tx_ring->dev,
329 "tx hang detected on queue %d, resetting adapter\n",
330 tx_ring->queue_index);
331
332 tx_ring->netdev->netdev_ops->ndo_tx_timeout(tx_ring->netdev);
333
334 /* the adapter is about to reset, no point in enabling stuff */
335 return true;
336 }
337
338 netdev_tx_completed_queue(netdev_get_tx_queue(tx_ring->netdev, 260 netdev_tx_completed_queue(netdev_get_tx_queue(tx_ring->netdev,
339 tx_ring->queue_index), 261 tx_ring->queue_index),
340 total_packets, total_bytes); 262 total_packets, total_bytes);
@@ -355,16 +277,16 @@ static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget)
355 } 277 }
356 } 278 }
357 279
358 return budget > 0; 280 return !!budget;
359} 281}
360 282
361/** 283/**
362 * i40e_force_wb -Arm hardware to do a wb on noncache aligned descriptors 284 * i40evf_force_wb -Arm hardware to do a wb on noncache aligned descriptors
363 * @vsi: the VSI we care about 285 * @vsi: the VSI we care about
364 * @q_vector: the vector on which to force writeback 286 * @q_vector: the vector on which to force writeback
365 * 287 *
366 **/ 288 **/
367static void i40e_force_wb(struct i40e_vsi *vsi, struct i40e_q_vector *q_vector) 289static void i40evf_force_wb(struct i40e_vsi *vsi, struct i40e_q_vector *q_vector)
368{ 290{
369 u16 flags = q_vector->tx.ring[0].flags; 291 u16 flags = q_vector->tx.ring[0].flags;
370 292
@@ -1385,7 +1307,7 @@ int i40evf_napi_poll(struct napi_struct *napi, int budget)
1385 /* If work not completed, return budget and polling will return */ 1307 /* If work not completed, return budget and polling will return */
1386 if (!clean_complete) { 1308 if (!clean_complete) {
1387 if (arm_wb) 1309 if (arm_wb)
1388 i40e_force_wb(vsi, q_vector); 1310 i40evf_force_wb(vsi, q_vector);
1389 return budget; 1311 return budget;
1390 } 1312 }
1391 1313
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_txrx.h b/drivers/net/ethernet/intel/i40evf/i40e_txrx.h
index 9a30f5d8c089..d5cb7aca87b4 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_txrx.h
+++ b/drivers/net/ethernet/intel/i40evf/i40e_txrx.h
@@ -198,8 +198,6 @@ struct i40e_rx_queue_stats {
198enum i40e_ring_state_t { 198enum i40e_ring_state_t {
199 __I40E_TX_FDIR_INIT_DONE, 199 __I40E_TX_FDIR_INIT_DONE,
200 __I40E_TX_XPS_INIT_DONE, 200 __I40E_TX_XPS_INIT_DONE,
201 __I40E_TX_DETECT_HANG,
202 __I40E_HANG_CHECK_ARMED,
203 __I40E_RX_PS_ENABLED, 201 __I40E_RX_PS_ENABLED,
204 __I40E_RX_16BYTE_DESC_ENABLED, 202 __I40E_RX_16BYTE_DESC_ENABLED,
205}; 203};
@@ -210,12 +208,6 @@ enum i40e_ring_state_t {
210 set_bit(__I40E_RX_PS_ENABLED, &(ring)->state) 208 set_bit(__I40E_RX_PS_ENABLED, &(ring)->state)
211#define clear_ring_ps_enabled(ring) \ 209#define clear_ring_ps_enabled(ring) \
212 clear_bit(__I40E_RX_PS_ENABLED, &(ring)->state) 210 clear_bit(__I40E_RX_PS_ENABLED, &(ring)->state)
213#define check_for_tx_hang(ring) \
214 test_bit(__I40E_TX_DETECT_HANG, &(ring)->state)
215#define set_check_for_tx_hang(ring) \
216 set_bit(__I40E_TX_DETECT_HANG, &(ring)->state)
217#define clear_check_for_tx_hang(ring) \
218 clear_bit(__I40E_TX_DETECT_HANG, &(ring)->state)
219#define ring_is_16byte_desc_enabled(ring) \ 211#define ring_is_16byte_desc_enabled(ring) \
220 test_bit(__I40E_RX_16BYTE_DESC_ENABLED, &(ring)->state) 212 test_bit(__I40E_RX_16BYTE_DESC_ENABLED, &(ring)->state)
221#define set_ring_16byte_desc_enabled(ring) \ 213#define set_ring_16byte_desc_enabled(ring) \
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index e174fbbdba40..ba019fc87fd1 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -2986,6 +2986,9 @@ static int igb_sw_init(struct igb_adapter *adapter)
2986 } 2986 }
2987#endif /* CONFIG_PCI_IOV */ 2987#endif /* CONFIG_PCI_IOV */
2988 2988
2989 /* Assume MSI-X interrupts, will be checked during IRQ allocation */
2990 adapter->flags |= IGB_FLAG_HAS_MSIX;
2991
2989 igb_probe_vfs(adapter); 2992 igb_probe_vfs(adapter);
2990 2993
2991 igb_init_queue_configuration(adapter); 2994 igb_init_queue_configuration(adapter);