aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMallikarjuna R Chilakala <mallikarjuna.chilakala@intel.com>2009-06-04 07:11:13 -0400
committerDavid S. Miller <davem@davemloft.net>2009-06-07 08:20:19 -0400
commit620fa036b2459ca9acf7484c8074147f0dda68da (patch)
tree22ed490ea8f6c711c6c6e6779583dee475cc9729 /drivers
parent50ac58ba1d707df33f0c398ae700214e49bf918f (diff)
ixgbe: Fix 82599 adapter link flickering issues
Fix autoneg restart issues in flow control path which might create endless link flickering due to known timing issues with 82599 adapters. Signed-off-by: Mallikarjuna R Chilakala <mallikarjuna.chilakakla@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ixgbe/ixgbe_82598.c115
-rw-r--r--drivers/net/ixgbe/ixgbe_82599.c13
-rw-r--r--drivers/net/ixgbe/ixgbe_common.c245
-rw-r--r--drivers/net/ixgbe/ixgbe_common.h4
-rw-r--r--drivers/net/ixgbe/ixgbe_dcb_82599.c2
-rw-r--r--drivers/net/ixgbe/ixgbe_ethtool.c28
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c6
-rw-r--r--drivers/net/ixgbe/ixgbe_type.h7
8 files changed, 193 insertions, 227 deletions
diff --git a/drivers/net/ixgbe/ixgbe_82598.c b/drivers/net/ixgbe/ixgbe_82598.c
index 88e8350aa78..b9923047ce1 100644
--- a/drivers/net/ixgbe/ixgbe_82598.c
+++ b/drivers/net/ixgbe/ixgbe_82598.c
@@ -293,6 +293,17 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
293 u32 rmcs_reg; 293 u32 rmcs_reg;
294 u32 reg; 294 u32 reg;
295 295
296#ifdef CONFIG_DCB
297 if (hw->fc.requested_mode == ixgbe_fc_pfc)
298 goto out;
299
300#endif /* CONFIG_DCB */
301 /* Negotiate the fc mode to use */
302 ret_val = ixgbe_fc_autoneg(hw);
303 if (ret_val)
304 goto out;
305
306 /* Disable any previous flow control settings */
296 fctrl_reg = IXGBE_READ_REG(hw, IXGBE_FCTRL); 307 fctrl_reg = IXGBE_READ_REG(hw, IXGBE_FCTRL);
297 fctrl_reg &= ~(IXGBE_FCTRL_RFCE | IXGBE_FCTRL_RPFCE); 308 fctrl_reg &= ~(IXGBE_FCTRL_RFCE | IXGBE_FCTRL_RPFCE);
298 309
@@ -304,14 +315,20 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
304 * 0: Flow control is completely disabled 315 * 0: Flow control is completely disabled
305 * 1: Rx flow control is enabled (we can receive pause frames, 316 * 1: Rx flow control is enabled (we can receive pause frames,
306 * but not send pause frames). 317 * but not send pause frames).
307 * 2: Tx flow control is enabled (we can send pause frames but 318 * 2: Tx flow control is enabled (we can send pause frames but
308 * we do not support receiving pause frames). 319 * we do not support receiving pause frames).
309 * 3: Both Rx and Tx flow control (symmetric) are enabled. 320 * 3: Both Rx and Tx flow control (symmetric) are enabled.
310 * other: Invalid. 321 * other: Invalid.
322#ifdef CONFIG_DCB
323 * 4: Priority Flow Control is enabled.
324#endif
311 */ 325 */
312 switch (hw->fc.current_mode) { 326 switch (hw->fc.current_mode) {
313 case ixgbe_fc_none: 327 case ixgbe_fc_none:
314 /* Flow control completely disabled by software override. */ 328 /*
329 * Flow control is disabled by software override or autoneg.
330 * The code below will actually disable it in the HW.
331 */
315 break; 332 break;
316 case ixgbe_fc_rx_pause: 333 case ixgbe_fc_rx_pause:
317 /* 334 /*
@@ -336,6 +353,11 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
336 fctrl_reg |= IXGBE_FCTRL_RFCE; 353 fctrl_reg |= IXGBE_FCTRL_RFCE;
337 rmcs_reg |= IXGBE_RMCS_TFCE_802_3X; 354 rmcs_reg |= IXGBE_RMCS_TFCE_802_3X;
338 break; 355 break;
356#ifdef CONFIG_DCB
357 case ixgbe_fc_pfc:
358 goto out;
359 break;
360#endif /* CONFIG_DCB */
339 default: 361 default:
340 hw_dbg(hw, "Flow control param set incorrectly\n"); 362 hw_dbg(hw, "Flow control param set incorrectly\n");
341 ret_val = -IXGBE_ERR_CONFIG; 363 ret_val = -IXGBE_ERR_CONFIG;
@@ -343,7 +365,7 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
343 break; 365 break;
344 } 366 }
345 367
346 /* Enable 802.3x based flow control settings. */ 368 /* Set 802.3x based flow control settings. */
347 fctrl_reg |= IXGBE_FCTRL_DPF; 369 fctrl_reg |= IXGBE_FCTRL_DPF;
348 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl_reg); 370 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl_reg);
349 IXGBE_WRITE_REG(hw, IXGBE_RMCS, rmcs_reg); 371 IXGBE_WRITE_REG(hw, IXGBE_RMCS, rmcs_reg);
@@ -377,79 +399,6 @@ out:
377} 399}
378 400
379/** 401/**
380 * ixgbe_setup_fc_82598 - Configure flow control settings
381 * @hw: pointer to hardware structure
382 * @packetbuf_num: packet buffer number (0-7)
383 *
384 * Configures the flow control settings based on SW configuration. This
385 * function is used for 802.3x flow control configuration only.
386 **/
387static s32 ixgbe_setup_fc_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
388{
389 s32 ret_val = 0;
390 ixgbe_link_speed speed;
391 bool link_up;
392
393 /* Validate the packetbuf configuration */
394 if (packetbuf_num < 0 || packetbuf_num > 7) {
395 hw_dbg(hw, "Invalid packet buffer number [%d], expected range is"
396 " 0-7\n", packetbuf_num);
397 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
398 goto out;
399 }
400
401 /*
402 * Validate the water mark configuration. Zero water marks are invalid
403 * because it causes the controller to just blast out fc packets.
404 */
405 if (!hw->fc.low_water || !hw->fc.high_water || !hw->fc.pause_time) {
406 if (hw->fc.requested_mode != ixgbe_fc_none) {
407 hw_dbg(hw, "Invalid water mark configuration\n");
408 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
409 goto out;
410 }
411 }
412
413 /*
414 * Validate the requested mode. Strict IEEE mode does not allow
415 * ixgbe_fc_rx_pause because it will cause testing anomalies.
416 */
417 if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
418 hw_dbg(hw, "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
419 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
420 goto out;
421 }
422
423 /*
424 * 10gig parts do not have a word in the EEPROM to determine the
425 * default flow control setting, so we explicitly set it to full.
426 */
427 if (hw->fc.requested_mode == ixgbe_fc_default)
428 hw->fc.requested_mode = ixgbe_fc_full;
429
430 /*
431 * Save off the requested flow control mode for use later. Depending
432 * on the link partner's capabilities, we may or may not use this mode.
433 */
434
435 hw->fc.current_mode = hw->fc.requested_mode;
436
437 /* Decide whether to use autoneg or not. */
438 hw->mac.ops.check_link(hw, &speed, &link_up, false);
439 if (!hw->fc.disable_fc_autoneg && hw->phy.multispeed_fiber &&
440 (speed == IXGBE_LINK_SPEED_1GB_FULL))
441 ret_val = ixgbe_fc_autoneg(hw);
442
443 if (ret_val)
444 goto out;
445
446 ret_val = ixgbe_fc_enable_82598(hw, packetbuf_num);
447
448out:
449 return ret_val;
450}
451
452/**
453 * ixgbe_setup_mac_link_82598 - Configures MAC link settings 402 * ixgbe_setup_mac_link_82598 - Configures MAC link settings
454 * @hw: pointer to hardware structure 403 * @hw: pointer to hardware structure
455 * 404 *
@@ -488,13 +437,6 @@ static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw)
488 } 437 }
489 } 438 }
490 439
491 /*
492 * We want to save off the original Flow Control configuration just in
493 * case we get disconnected and then reconnected into a different hub
494 * or switch with different Flow Control capabilities.
495 */
496 ixgbe_setup_fc_82598(hw, 0);
497
498 /* Add delay to filter out noises during initial link setup */ 440 /* Add delay to filter out noises during initial link setup */
499 msleep(50); 441 msleep(50);
500 442
@@ -581,6 +523,11 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,
581 else 523 else
582 *speed = IXGBE_LINK_SPEED_1GB_FULL; 524 *speed = IXGBE_LINK_SPEED_1GB_FULL;
583 525
526 /* if link is down, zero out the current_mode */
527 if (*link_up == false) {
528 hw->fc.current_mode = ixgbe_fc_none;
529 hw->fc.fc_was_autonegged = false;
530 }
584out: 531out:
585 return 0; 532 return 0;
586} 533}
@@ -1168,7 +1115,7 @@ static struct ixgbe_mac_operations mac_ops_82598 = {
1168 .disable_mc = &ixgbe_disable_mc_generic, 1115 .disable_mc = &ixgbe_disable_mc_generic,
1169 .clear_vfta = &ixgbe_clear_vfta_82598, 1116 .clear_vfta = &ixgbe_clear_vfta_82598,
1170 .set_vfta = &ixgbe_set_vfta_82598, 1117 .set_vfta = &ixgbe_set_vfta_82598,
1171 .setup_fc = &ixgbe_setup_fc_82598, 1118 .fc_enable = &ixgbe_fc_enable_82598,
1172}; 1119};
1173 1120
1174static struct ixgbe_eeprom_operations eeprom_ops_82598 = { 1121static struct ixgbe_eeprom_operations eeprom_ops_82598 = {
diff --git a/drivers/net/ixgbe/ixgbe_82599.c b/drivers/net/ixgbe/ixgbe_82599.c
index 84b83f7b473..4d83e591659 100644
--- a/drivers/net/ixgbe/ixgbe_82599.c
+++ b/drivers/net/ixgbe/ixgbe_82599.c
@@ -413,9 +413,6 @@ s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw)
413 } 413 }
414 } 414 }
415 415
416 /* Set up flow control */
417 status = ixgbe_setup_fc_generic(hw, 0);
418
419 /* Add delay to filter out noises during initial link setup */ 416 /* Add delay to filter out noises during initial link setup */
420 msleep(50); 417 msleep(50);
421 418
@@ -641,6 +638,11 @@ s32 ixgbe_check_mac_link_82599(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
641 else 638 else
642 *speed = IXGBE_LINK_SPEED_100_FULL; 639 *speed = IXGBE_LINK_SPEED_100_FULL;
643 640
641 /* if link is down, zero out the current_mode */
642 if (*link_up == false) {
643 hw->fc.current_mode = ixgbe_fc_none;
644 hw->fc.fc_was_autonegged = false;
645 }
644 646
645 return 0; 647 return 0;
646} 648}
@@ -747,9 +749,6 @@ s32 ixgbe_setup_mac_link_speed_82599(struct ixgbe_hw *hw,
747 } 749 }
748 } 750 }
749 751
750 /* Set up flow control */
751 status = ixgbe_setup_fc_generic(hw, 0);
752
753 /* Add delay to filter out noises during initial link setup */ 752 /* Add delay to filter out noises during initial link setup */
754 msleep(50); 753 msleep(50);
755 } 754 }
@@ -1509,7 +1508,7 @@ static struct ixgbe_mac_operations mac_ops_82599 = {
1509 .disable_mc = &ixgbe_disable_mc_generic, 1508 .disable_mc = &ixgbe_disable_mc_generic,
1510 .clear_vfta = &ixgbe_clear_vfta_82599, 1509 .clear_vfta = &ixgbe_clear_vfta_82599,
1511 .set_vfta = &ixgbe_set_vfta_82599, 1510 .set_vfta = &ixgbe_set_vfta_82599,
1512 .setup_fc = &ixgbe_setup_fc_generic, 1511 .fc_enable = &ixgbe_fc_enable_generic,
1513 .init_uta_tables = &ixgbe_init_uta_tables_82599, 1512 .init_uta_tables = &ixgbe_init_uta_tables_82599,
1514 .setup_sfp = &ixgbe_setup_sfp_modules_82599, 1513 .setup_sfp = &ixgbe_setup_sfp_modules_82599,
1515}; 1514};
diff --git a/drivers/net/ixgbe/ixgbe_common.c b/drivers/net/ixgbe/ixgbe_common.c
index 4d36cd32cd3..db339d6fe63 100644
--- a/drivers/net/ixgbe/ixgbe_common.c
+++ b/drivers/net/ixgbe/ixgbe_common.c
@@ -85,6 +85,9 @@ s32 ixgbe_start_hw_generic(struct ixgbe_hw *hw)
85 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext); 85 IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
86 IXGBE_WRITE_FLUSH(hw); 86 IXGBE_WRITE_FLUSH(hw);
87 87
88 /* Setup flow control */
89 ixgbe_setup_fc(hw, 0);
90
88 /* Clear adapter stopped flag */ 91 /* Clear adapter stopped flag */
89 hw->adapter_stopped = false; 92 hw->adapter_stopped = false;
90 93
@@ -1577,17 +1580,16 @@ s32 ixgbe_disable_mc_generic(struct ixgbe_hw *hw)
1577} 1580}
1578 1581
1579/** 1582/**
1580 * ixgbe_fc_enable - Enable flow control 1583 * ixgbe_fc_enable_generic - Enable flow control
1581 * @hw: pointer to hardware structure 1584 * @hw: pointer to hardware structure
1582 * @packetbuf_num: packet buffer number (0-7) 1585 * @packetbuf_num: packet buffer number (0-7)
1583 * 1586 *
1584 * Enable flow control according to the current settings. 1587 * Enable flow control according to the current settings.
1585 **/ 1588 **/
1586s32 ixgbe_fc_enable(struct ixgbe_hw *hw, s32 packetbuf_num) 1589s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw, s32 packetbuf_num)
1587{ 1590{
1588 s32 ret_val = 0; 1591 s32 ret_val = 0;
1589 u32 mflcn_reg; 1592 u32 mflcn_reg, fccfg_reg;
1590 u32 fccfg_reg;
1591 u32 reg; 1593 u32 reg;
1592 u32 rx_pba_size; 1594 u32 rx_pba_size;
1593 1595
@@ -1596,7 +1598,12 @@ s32 ixgbe_fc_enable(struct ixgbe_hw *hw, s32 packetbuf_num)
1596 goto out; 1598 goto out;
1597 1599
1598#endif /* CONFIG_DCB */ 1600#endif /* CONFIG_DCB */
1601 /* Negotiate the fc mode to use */
1602 ret_val = ixgbe_fc_autoneg(hw);
1603 if (ret_val)
1604 goto out;
1599 1605
1606 /* Disable any previous flow control settings */
1600 mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN); 1607 mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
1601 mflcn_reg &= ~(IXGBE_MFLCN_RFCE | IXGBE_MFLCN_RPFCE); 1608 mflcn_reg &= ~(IXGBE_MFLCN_RFCE | IXGBE_MFLCN_RPFCE);
1602 1609
@@ -1616,7 +1623,10 @@ s32 ixgbe_fc_enable(struct ixgbe_hw *hw, s32 packetbuf_num)
1616 */ 1623 */
1617 switch (hw->fc.current_mode) { 1624 switch (hw->fc.current_mode) {
1618 case ixgbe_fc_none: 1625 case ixgbe_fc_none:
1619 /* Flow control completely disabled by software override. */ 1626 /*
1627 * Flow control is disabled by software override or autoneg.
1628 * The code below will actually disable it in the HW.
1629 */
1620 break; 1630 break;
1621 case ixgbe_fc_rx_pause: 1631 case ixgbe_fc_rx_pause:
1622 /* 1632 /*
@@ -1645,7 +1655,7 @@ s32 ixgbe_fc_enable(struct ixgbe_hw *hw, s32 packetbuf_num)
1645 case ixgbe_fc_pfc: 1655 case ixgbe_fc_pfc:
1646 goto out; 1656 goto out;
1647 break; 1657 break;
1648#endif 1658#endif /* CONFIG_DCB */
1649 default: 1659 default:
1650 hw_dbg(hw, "Flow control param set incorrectly\n"); 1660 hw_dbg(hw, "Flow control param set incorrectly\n");
1651 ret_val = -IXGBE_ERR_CONFIG; 1661 ret_val = -IXGBE_ERR_CONFIG;
@@ -1653,7 +1663,7 @@ s32 ixgbe_fc_enable(struct ixgbe_hw *hw, s32 packetbuf_num)
1653 break; 1663 break;
1654 } 1664 }
1655 1665
1656 /* Enable 802.3x based flow control settings. */ 1666 /* Set 802.3x based flow control settings. */
1657 mflcn_reg |= IXGBE_MFLCN_DPF; 1667 mflcn_reg |= IXGBE_MFLCN_DPF;
1658 IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn_reg); 1668 IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn_reg);
1659 IXGBE_WRITE_REG(hw, IXGBE_FCCFG, fccfg_reg); 1669 IXGBE_WRITE_REG(hw, IXGBE_FCCFG, fccfg_reg);
@@ -1661,10 +1671,12 @@ s32 ixgbe_fc_enable(struct ixgbe_hw *hw, s32 packetbuf_num)
1661 reg = IXGBE_READ_REG(hw, IXGBE_MTQC); 1671 reg = IXGBE_READ_REG(hw, IXGBE_MTQC);
1662 /* Thresholds are different for link flow control when in DCB mode */ 1672 /* Thresholds are different for link flow control when in DCB mode */
1663 if (reg & IXGBE_MTQC_RT_ENA) { 1673 if (reg & IXGBE_MTQC_RT_ENA) {
1674 rx_pba_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(packetbuf_num));
1675
1664 /* Always disable XON for LFC when in DCB mode */ 1676 /* Always disable XON for LFC when in DCB mode */
1665 IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(packetbuf_num), 0); 1677 reg = (rx_pba_size >> 5) & 0xFFE0;
1678 IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(packetbuf_num), reg);
1666 1679
1667 rx_pba_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(packetbuf_num));
1668 reg = (rx_pba_size >> 2) & 0xFFE0; 1680 reg = (rx_pba_size >> 2) & 0xFFE0;
1669 if (hw->fc.current_mode & ixgbe_fc_tx_pause) 1681 if (hw->fc.current_mode & ixgbe_fc_tx_pause)
1670 reg |= IXGBE_FCRTH_FCEN; 1682 reg |= IXGBE_FCRTH_FCEN;
@@ -1709,100 +1721,41 @@ out:
1709 * ixgbe_fc_autoneg - Configure flow control 1721 * ixgbe_fc_autoneg - Configure flow control
1710 * @hw: pointer to hardware structure 1722 * @hw: pointer to hardware structure
1711 * 1723 *
1712 * Negotiates flow control capabilities with link partner using autoneg and 1724 * Compares our advertised flow control capabilities to those advertised by
1713 * applies the results. 1725 * our link partner, and determines the proper flow control mode to use.
1714 **/ 1726 **/
1715s32 ixgbe_fc_autoneg(struct ixgbe_hw *hw) 1727s32 ixgbe_fc_autoneg(struct ixgbe_hw *hw)
1716{ 1728{
1717 s32 ret_val = 0; 1729 s32 ret_val = 0;
1718 u32 i, reg, pcs_anadv_reg, pcs_lpab_reg; 1730 ixgbe_link_speed speed;
1719 1731 u32 pcs_anadv_reg, pcs_lpab_reg, linkstat;
1720 reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANA); 1732 bool link_up;
1721 1733
1722 /* 1734 /*
1723 * The possible values of fc.current_mode are: 1735 * AN should have completed when the cable was plugged in.
1724 * 0: Flow control is completely disabled 1736 * Look for reasons to bail out. Bail out if:
1725 * 1: Rx flow control is enabled (we can receive pause frames, 1737 * - FC autoneg is disabled, or if
1726 * but not send pause frames). 1738 * - we don't have multispeed fiber, or if
1727 * 2: Tx flow control is enabled (we can send pause frames but 1739 * - we're not running at 1G, or if
1728 * we do not support receiving pause frames). 1740 * - link is not up, or if
1729 * 3: Both Rx and Tx flow control (symmetric) are enabled. 1741 * - link is up but AN did not complete, or if
1730 * 4: Priority Flow Control is enabled. 1742 * - link is up and AN completed but timed out
1731 * other: Invalid. 1743 *
1744 * Since we're being called from an LSC, link is already know to be up.
1745 * So use link_up_wait_to_complete=false.
1732 */ 1746 */
1733 switch (hw->fc.current_mode) { 1747 hw->mac.ops.check_link(hw, &speed, &link_up, false);
1734 case ixgbe_fc_none: 1748 linkstat = IXGBE_READ_REG(hw, IXGBE_PCS1GLSTA);
1735 /* Flow control completely disabled by software override. */ 1749
1736 reg &= ~(IXGBE_PCS1GANA_SYM_PAUSE | IXGBE_PCS1GANA_ASM_PAUSE); 1750 if (hw->fc.disable_fc_autoneg ||
1737 break; 1751 !hw->phy.multispeed_fiber ||
1738 case ixgbe_fc_rx_pause: 1752 (speed != IXGBE_LINK_SPEED_1GB_FULL) ||
1739 /* 1753 !link_up ||
1740 * Rx Flow control is enabled and Tx Flow control is 1754 ((linkstat & IXGBE_PCS1GLSTA_AN_COMPLETE) == 0) ||
1741 * disabled by software override. Since there really 1755 ((linkstat & IXGBE_PCS1GLSTA_AN_TIMED_OUT) == 1)) {
1742 * isn't a way to advertise that we are capable of RX 1756 hw->fc.fc_was_autonegged = false;
1743 * Pause ONLY, we will advertise that we support both 1757 hw->fc.current_mode = hw->fc.requested_mode;
1744 * symmetric and asymmetric Rx PAUSE. Later, we will 1758 hw_dbg(hw, "Autoneg FC was skipped.\n");
1745 * disable the adapter's ability to send PAUSE frames.
1746 */
1747 reg |= (IXGBE_PCS1GANA_SYM_PAUSE | IXGBE_PCS1GANA_ASM_PAUSE);
1748 break;
1749 case ixgbe_fc_tx_pause:
1750 /*
1751 * Tx Flow control is enabled, and Rx Flow control is
1752 * disabled by software override.
1753 */
1754 reg |= (IXGBE_PCS1GANA_ASM_PAUSE);
1755 reg &= ~(IXGBE_PCS1GANA_SYM_PAUSE);
1756 break;
1757 case ixgbe_fc_full:
1758 /* Flow control (both Rx and Tx) is enabled by SW override. */
1759 reg |= (IXGBE_PCS1GANA_SYM_PAUSE | IXGBE_PCS1GANA_ASM_PAUSE);
1760 break;
1761#ifdef CONFIG_DCB
1762 case ixgbe_fc_pfc:
1763 goto out;
1764 break;
1765#endif
1766 default:
1767 hw_dbg(hw, "Flow control param set incorrectly\n");
1768 ret_val = -IXGBE_ERR_CONFIG;
1769 goto out;
1770 break;
1771 }
1772
1773 IXGBE_WRITE_REG(hw, IXGBE_PCS1GANA, reg);
1774 reg = IXGBE_READ_REG(hw, IXGBE_PCS1GLCTL);
1775
1776 /* Set PCS register for autoneg */
1777 /* Enable and restart autoneg */
1778 reg |= IXGBE_PCS1GLCTL_AN_ENABLE | IXGBE_PCS1GLCTL_AN_RESTART;
1779
1780 /* Disable AN timeout */
1781 if (hw->fc.strict_ieee)
1782 reg &= ~IXGBE_PCS1GLCTL_AN_1G_TIMEOUT_EN;
1783
1784 hw_dbg(hw, "Configuring Autoneg; PCS_LCTL = 0x%08X\n", reg);
1785 IXGBE_WRITE_REG(hw, IXGBE_PCS1GLCTL, reg);
1786
1787 /* See if autonegotiation has succeeded */
1788 hw->mac.autoneg_succeeded = 0;
1789 for (i = 0; i < FIBER_LINK_UP_LIMIT; i++) {
1790 msleep(10);
1791 reg = IXGBE_READ_REG(hw, IXGBE_PCS1GLSTA);
1792 if ((reg & (IXGBE_PCS1GLSTA_LINK_OK |
1793 IXGBE_PCS1GLSTA_AN_COMPLETE)) ==
1794 (IXGBE_PCS1GLSTA_LINK_OK |
1795 IXGBE_PCS1GLSTA_AN_COMPLETE)) {
1796 if (!(reg & IXGBE_PCS1GLSTA_AN_TIMED_OUT))
1797 hw->mac.autoneg_succeeded = 1;
1798 break;
1799 }
1800 }
1801
1802 if (!hw->mac.autoneg_succeeded) {
1803 /* Autoneg failed to achieve a link, so we turn fc off */
1804 hw->fc.current_mode = ixgbe_fc_none;
1805 hw_dbg(hw, "Flow Control = NONE.\n");
1806 goto out; 1759 goto out;
1807 } 1760 }
1808 1761
@@ -1845,21 +1798,23 @@ s32 ixgbe_fc_autoneg(struct ixgbe_hw *hw)
1845 hw_dbg(hw, "Flow Control = NONE.\n"); 1798 hw_dbg(hw, "Flow Control = NONE.\n");
1846 } 1799 }
1847 1800
1801 /* Record that current_mode is the result of a successful autoneg */
1802 hw->fc.fc_was_autonegged = true;
1803
1848out: 1804out:
1849 return ret_val; 1805 return ret_val;
1850} 1806}
1851 1807
1852/** 1808/**
1853 * ixgbe_setup_fc_generic - Set up flow control 1809 * ixgbe_setup_fc - Set up flow control
1854 * @hw: pointer to hardware structure 1810 * @hw: pointer to hardware structure
1855 * 1811 *
1856 * Sets up flow control. 1812 * Called at init time to set up flow control.
1857 **/ 1813 **/
1858s32 ixgbe_setup_fc_generic(struct ixgbe_hw *hw, s32 packetbuf_num) 1814s32 ixgbe_setup_fc(struct ixgbe_hw *hw, s32 packetbuf_num)
1859{ 1815{
1860 s32 ret_val = 0; 1816 s32 ret_val = 0;
1861 ixgbe_link_speed speed; 1817 u32 reg;
1862 bool link_up;
1863 1818
1864#ifdef CONFIG_DCB 1819#ifdef CONFIG_DCB
1865 if (hw->fc.requested_mode == ixgbe_fc_pfc) { 1820 if (hw->fc.requested_mode == ixgbe_fc_pfc) {
@@ -1881,16 +1836,14 @@ s32 ixgbe_setup_fc_generic(struct ixgbe_hw *hw, s32 packetbuf_num)
1881 * because it causes the controller to just blast out fc packets. 1836 * because it causes the controller to just blast out fc packets.
1882 */ 1837 */
1883 if (!hw->fc.low_water || !hw->fc.high_water || !hw->fc.pause_time) { 1838 if (!hw->fc.low_water || !hw->fc.high_water || !hw->fc.pause_time) {
1884 if (hw->fc.requested_mode != ixgbe_fc_none) { 1839 hw_dbg(hw, "Invalid water mark configuration\n");
1885 hw_dbg(hw, "Invalid water mark configuration\n"); 1840 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
1886 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS; 1841 goto out;
1887 goto out;
1888 }
1889 } 1842 }
1890 1843
1891 /* 1844 /*
1892 * Validate the requested mode. Strict IEEE mode does not allow 1845 * Validate the requested mode. Strict IEEE mode does not allow
1893 * ixgbe_fc_rx_pause because it will cause testing anomalies. 1846 * ixgbe_fc_rx_pause because it will cause us to fail at UNH.
1894 */ 1847 */
1895 if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) { 1848 if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
1896 hw_dbg(hw, "ixgbe_fc_rx_pause not valid in strict " 1849 hw_dbg(hw, "ixgbe_fc_rx_pause not valid in strict "
@@ -1907,21 +1860,77 @@ s32 ixgbe_setup_fc_generic(struct ixgbe_hw *hw, s32 packetbuf_num)
1907 hw->fc.requested_mode = ixgbe_fc_full; 1860 hw->fc.requested_mode = ixgbe_fc_full;
1908 1861
1909 /* 1862 /*
1910 * Save off the requested flow control mode for use later. Depending 1863 * Set up the 1G flow control advertisement registers so the HW will be
1911 * on the link partner's capabilities, we may or may not use this mode. 1864 * able to do fc autoneg once the cable is plugged in. If we end up
1865 * using 10g instead, this is harmless.
1912 */ 1866 */
1913 hw->fc.current_mode = hw->fc.requested_mode; 1867 reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANA);
1914
1915 /* Decide whether to use autoneg or not. */
1916 hw->mac.ops.check_link(hw, &speed, &link_up, false);
1917 if (!hw->fc.disable_fc_autoneg && hw->phy.multispeed_fiber &&
1918 (speed == IXGBE_LINK_SPEED_1GB_FULL))
1919 ret_val = ixgbe_fc_autoneg(hw);
1920 1868
1921 if (ret_val) 1869 /*
1870 * The possible values of fc.requested_mode are:
1871 * 0: Flow control is completely disabled
1872 * 1: Rx flow control is enabled (we can receive pause frames,
1873 * but not send pause frames).
1874 * 2: Tx flow control is enabled (we can send pause frames but
1875 * we do not support receiving pause frames).
1876 * 3: Both Rx and Tx flow control (symmetric) are enabled.
1877#ifdef CONFIG_DCB
1878 * 4: Priority Flow Control is enabled.
1879#endif
1880 * other: Invalid.
1881 */
1882 switch (hw->fc.requested_mode) {
1883 case ixgbe_fc_none:
1884 /* Flow control completely disabled by software override. */
1885 reg &= ~(IXGBE_PCS1GANA_SYM_PAUSE | IXGBE_PCS1GANA_ASM_PAUSE);
1886 break;
1887 case ixgbe_fc_rx_pause:
1888 /*
1889 * Rx Flow control is enabled and Tx Flow control is
1890 * disabled by software override. Since there really
1891 * isn't a way to advertise that we are capable of RX
1892 * Pause ONLY, we will advertise that we support both
1893 * symmetric and asymmetric Rx PAUSE. Later, we will
1894 * disable the adapter's ability to send PAUSE frames.
1895 */
1896 reg |= (IXGBE_PCS1GANA_SYM_PAUSE | IXGBE_PCS1GANA_ASM_PAUSE);
1897 break;
1898 case ixgbe_fc_tx_pause:
1899 /*
1900 * Tx Flow control is enabled, and Rx Flow control is
1901 * disabled by software override.
1902 */
1903 reg |= (IXGBE_PCS1GANA_ASM_PAUSE);
1904 reg &= ~(IXGBE_PCS1GANA_SYM_PAUSE);
1905 break;
1906 case ixgbe_fc_full:
1907 /* Flow control (both Rx and Tx) is enabled by SW override. */
1908 reg |= (IXGBE_PCS1GANA_SYM_PAUSE | IXGBE_PCS1GANA_ASM_PAUSE);
1909 break;
1910#ifdef CONFIG_DCB
1911 case ixgbe_fc_pfc:
1922 goto out; 1912 goto out;
1913 break;
1914#endif /* CONFIG_DCB */
1915 default:
1916 hw_dbg(hw, "Flow control param set incorrectly\n");
1917 ret_val = -IXGBE_ERR_CONFIG;
1918 goto out;
1919 break;
1920 }
1921
1922 IXGBE_WRITE_REG(hw, IXGBE_PCS1GANA, reg);
1923 reg = IXGBE_READ_REG(hw, IXGBE_PCS1GLCTL);
1923 1924
1924 ret_val = ixgbe_fc_enable(hw, packetbuf_num); 1925 /* Enable and restart autoneg to inform the link partner */
1926 reg |= IXGBE_PCS1GLCTL_AN_ENABLE | IXGBE_PCS1GLCTL_AN_RESTART;
1927
1928 /* Disable AN timeout */
1929 if (hw->fc.strict_ieee)
1930 reg &= ~IXGBE_PCS1GLCTL_AN_1G_TIMEOUT_EN;
1931
1932 IXGBE_WRITE_REG(hw, IXGBE_PCS1GLCTL, reg);
1933 hw_dbg(hw, "Set up FC; PCS1GLCTL = 0x%08X\n", reg);
1925 1934
1926out: 1935out:
1927 return ret_val; 1936 return ret_val;
diff --git a/drivers/net/ixgbe/ixgbe_common.h b/drivers/net/ixgbe/ixgbe_common.h
index b2a4b2c99c4..0d34d4d8244 100644
--- a/drivers/net/ixgbe/ixgbe_common.h
+++ b/drivers/net/ixgbe/ixgbe_common.h
@@ -64,8 +64,8 @@ s32 ixgbe_update_uc_addr_list_generic(struct ixgbe_hw *hw,
64s32 ixgbe_enable_mc_generic(struct ixgbe_hw *hw); 64s32 ixgbe_enable_mc_generic(struct ixgbe_hw *hw);
65s32 ixgbe_disable_mc_generic(struct ixgbe_hw *hw); 65s32 ixgbe_disable_mc_generic(struct ixgbe_hw *hw);
66s32 ixgbe_enable_rx_dma_generic(struct ixgbe_hw *hw, u32 regval); 66s32 ixgbe_enable_rx_dma_generic(struct ixgbe_hw *hw, u32 regval);
67s32 ixgbe_setup_fc_generic(struct ixgbe_hw *hw, s32 packetbuf_num); 67s32 ixgbe_setup_fc(struct ixgbe_hw *hw, s32 packetbuf_num);
68s32 ixgbe_fc_enable(struct ixgbe_hw *hw, s32 packtetbuf_num); 68s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw, s32 packtetbuf_num);
69s32 ixgbe_fc_autoneg(struct ixgbe_hw *hw); 69s32 ixgbe_fc_autoneg(struct ixgbe_hw *hw);
70 70
71s32 ixgbe_validate_mac_addr(u8 *mac_addr); 71s32 ixgbe_validate_mac_addr(u8 *mac_addr);
diff --git a/drivers/net/ixgbe/ixgbe_dcb_82599.c b/drivers/net/ixgbe/ixgbe_dcb_82599.c
index f4417fc3b0f..589f62c7062 100644
--- a/drivers/net/ixgbe/ixgbe_dcb_82599.c
+++ b/drivers/net/ixgbe/ixgbe_dcb_82599.c
@@ -295,7 +295,7 @@ s32 ixgbe_dcb_config_pfc_82599(struct ixgbe_hw *hw,
295 /* If PFC is disabled globally then fall back to LFC. */ 295 /* If PFC is disabled globally then fall back to LFC. */
296 if (!dcb_config->pfc_mode_enable) { 296 if (!dcb_config->pfc_mode_enable) {
297 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) 297 for (i = 0; i < MAX_TRAFFIC_CLASS; i++)
298 hw->mac.ops.setup_fc(hw, i); 298 hw->mac.ops.fc_enable(hw, i);
299 goto out; 299 goto out;
300 } 300 }
301 301
diff --git a/drivers/net/ixgbe/ixgbe_ethtool.c b/drivers/net/ixgbe/ixgbe_ethtool.c
index 583cc5a3c4f..1c110459d33 100644
--- a/drivers/net/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ixgbe/ixgbe_ethtool.c
@@ -283,6 +283,7 @@ static int ixgbe_set_pauseparam(struct net_device *netdev,
283{ 283{
284 struct ixgbe_adapter *adapter = netdev_priv(netdev); 284 struct ixgbe_adapter *adapter = netdev_priv(netdev);
285 struct ixgbe_hw *hw = &adapter->hw; 285 struct ixgbe_hw *hw = &adapter->hw;
286 struct ixgbe_fc_info fc;
286 287
287#ifdef CONFIG_DCB 288#ifdef CONFIG_DCB
288 if (adapter->dcb_cfg.pfc_mode_enable || 289 if (adapter->dcb_cfg.pfc_mode_enable ||
@@ -291,26 +292,37 @@ static int ixgbe_set_pauseparam(struct net_device *netdev,
291 return -EINVAL; 292 return -EINVAL;
292 293
293#endif 294#endif
295
296 fc = hw->fc;
297
294 if (pause->autoneg != AUTONEG_ENABLE) 298 if (pause->autoneg != AUTONEG_ENABLE)
295 hw->fc.disable_fc_autoneg = true; 299 fc.disable_fc_autoneg = true;
296 else 300 else
297 hw->fc.disable_fc_autoneg = false; 301 fc.disable_fc_autoneg = false;
298 302
299 if (pause->rx_pause && pause->tx_pause) 303 if (pause->rx_pause && pause->tx_pause)
300 hw->fc.requested_mode = ixgbe_fc_full; 304 fc.requested_mode = ixgbe_fc_full;
301 else if (pause->rx_pause && !pause->tx_pause) 305 else if (pause->rx_pause && !pause->tx_pause)
302 hw->fc.requested_mode = ixgbe_fc_rx_pause; 306 fc.requested_mode = ixgbe_fc_rx_pause;
303 else if (!pause->rx_pause && pause->tx_pause) 307 else if (!pause->rx_pause && pause->tx_pause)
304 hw->fc.requested_mode = ixgbe_fc_tx_pause; 308 fc.requested_mode = ixgbe_fc_tx_pause;
305 else if (!pause->rx_pause && !pause->tx_pause) 309 else if (!pause->rx_pause && !pause->tx_pause)
306 hw->fc.requested_mode = ixgbe_fc_none; 310 fc.requested_mode = ixgbe_fc_none;
307 else 311 else
308 return -EINVAL; 312 return -EINVAL;
309 313
310#ifdef CONFIG_DCB 314#ifdef CONFIG_DCB
311 adapter->last_lfc_mode = hw->fc.requested_mode; 315 adapter->last_lfc_mode = fc.requested_mode;
312#endif 316#endif
313 hw->mac.ops.setup_fc(hw, 0); 317
318 /* if the thing changed then we'll update and use new autoneg */
319 if (memcmp(&fc, &hw->fc, sizeof(struct ixgbe_fc_info))) {
320 hw->fc = fc;
321 if (netif_running(netdev))
322 ixgbe_reinit_locked(adapter);
323 else
324 ixgbe_reset(adapter);
325 }
314 326
315 return 0; 327 return 0;
316} 328}
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 0a3e8a35a0b..9684632f15b 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -4344,12 +4344,12 @@ static void ixgbe_watchdog_task(struct work_struct *work)
4344#ifdef CONFIG_DCB 4344#ifdef CONFIG_DCB
4345 if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) { 4345 if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {
4346 for (i = 0; i < MAX_TRAFFIC_CLASS; i++) 4346 for (i = 0; i < MAX_TRAFFIC_CLASS; i++)
4347 hw->mac.ops.setup_fc(hw, i); 4347 hw->mac.ops.fc_enable(hw, i);
4348 } else { 4348 } else {
4349 hw->mac.ops.setup_fc(hw, 0); 4349 hw->mac.ops.fc_enable(hw, 0);
4350 } 4350 }
4351#else 4351#else
4352 hw->mac.ops.setup_fc(hw, 0); 4352 hw->mac.ops.fc_enable(hw, 0);
4353#endif 4353#endif
4354 } 4354 }
4355 4355
diff --git a/drivers/net/ixgbe/ixgbe_type.h b/drivers/net/ixgbe/ixgbe_type.h
index 199b288c345..4402552eb3e 100644
--- a/drivers/net/ixgbe/ixgbe_type.h
+++ b/drivers/net/ixgbe/ixgbe_type.h
@@ -1368,8 +1368,6 @@
1368#define IXGBE_LINK_UP_TIME 90 /* 9.0 Seconds */ 1368#define IXGBE_LINK_UP_TIME 90 /* 9.0 Seconds */
1369#define IXGBE_AUTO_NEG_TIME 45 /* 4.5 Seconds */ 1369#define IXGBE_AUTO_NEG_TIME 45 /* 4.5 Seconds */
1370 1370
1371#define FIBER_LINK_UP_LIMIT 50
1372
1373/* PCS1GLSTA Bit Masks */ 1371/* PCS1GLSTA Bit Masks */
1374#define IXGBE_PCS1GLSTA_LINK_OK 1 1372#define IXGBE_PCS1GLSTA_LINK_OK 1
1375#define IXGBE_PCS1GLSTA_SYNK_OK 0x10 1373#define IXGBE_PCS1GLSTA_SYNK_OK 0x10
@@ -2094,7 +2092,8 @@ struct ixgbe_fc_info {
2094 u16 pause_time; /* Flow Control Pause timer */ 2092 u16 pause_time; /* Flow Control Pause timer */
2095 bool send_xon; /* Flow control send XON */ 2093 bool send_xon; /* Flow control send XON */
2096 bool strict_ieee; /* Strict IEEE mode */ 2094 bool strict_ieee; /* Strict IEEE mode */
2097 bool disable_fc_autoneg; /* Turn off autoneg FC mode */ 2095 bool disable_fc_autoneg; /* Do not autonegotiate FC */
2096 bool fc_was_autonegged; /* Is current_mode the result of autonegging? */
2098 enum ixgbe_fc_mode current_mode; /* FC mode in effect */ 2097 enum ixgbe_fc_mode current_mode; /* FC mode in effect */
2099 enum ixgbe_fc_mode requested_mode; /* FC mode requested by caller */ 2098 enum ixgbe_fc_mode requested_mode; /* FC mode requested by caller */
2100}; 2099};
@@ -2236,7 +2235,7 @@ struct ixgbe_mac_operations {
2236 s32 (*init_uta_tables)(struct ixgbe_hw *); 2235 s32 (*init_uta_tables)(struct ixgbe_hw *);
2237 2236
2238 /* Flow Control */ 2237 /* Flow Control */
2239 s32 (*setup_fc)(struct ixgbe_hw *, s32); 2238 s32 (*fc_enable)(struct ixgbe_hw *, s32);
2240}; 2239};
2241 2240
2242struct ixgbe_phy_operations { 2241struct ixgbe_phy_operations {