aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ixgbe
diff options
context:
space:
mode:
authorEmil Tantilov <emil.s.tantilov@intel.com>2011-02-26 01:40:16 -0500
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2011-03-07 21:06:43 -0500
commit0b0c2b31bdf8d6fb5c14ae70894453ac44d64672 (patch)
tree6e15145a52fc22d6701ef3db85e6cab05c39ef24 /drivers/net/ixgbe
parenta3aeea0ec8d3af854edf7dc983dc8cbe803a43e8 (diff)
ixgbe: Enable flow control pause parameter auto-negotiation support
This patch enables flow control pause parameters auto-negotiation support to 82599 based 10G Base-T, backplane devices and multi-speed fiber optics modules at 1G speed Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com> Tested-by: Stephen Ko <stephen.s.ko@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ixgbe')
-rw-r--r--drivers/net/ixgbe/ixgbe_82598.c7
-rw-r--r--drivers/net/ixgbe/ixgbe_82599.c3
-rw-r--r--drivers/net/ixgbe/ixgbe_common.c460
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c3
-rw-r--r--drivers/net/ixgbe/ixgbe_phy.h4
-rw-r--r--drivers/net/ixgbe/ixgbe_type.h3
6 files changed, 281 insertions, 199 deletions
diff --git a/drivers/net/ixgbe/ixgbe_82598.c b/drivers/net/ixgbe/ixgbe_82598.c
index dc977b1c8ea..ff23907bde0 100644
--- a/drivers/net/ixgbe/ixgbe_82598.c
+++ b/drivers/net/ixgbe/ixgbe_82598.c
@@ -366,7 +366,7 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
366 366
367 /* Negotiate the fc mode to use */ 367 /* Negotiate the fc mode to use */
368 ret_val = ixgbe_fc_autoneg(hw); 368 ret_val = ixgbe_fc_autoneg(hw);
369 if (ret_val) 369 if (ret_val == IXGBE_ERR_FLOW_CONTROL)
370 goto out; 370 goto out;
371 371
372 /* Disable any previous flow control settings */ 372 /* Disable any previous flow control settings */
@@ -384,10 +384,10 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
384 * 2: Tx flow control is enabled (we can send pause frames but 384 * 2: Tx flow control is enabled (we can send pause frames but
385 * we do not support receiving pause frames). 385 * we do not support receiving pause frames).
386 * 3: Both Rx and Tx flow control (symmetric) are enabled. 386 * 3: Both Rx and Tx flow control (symmetric) are enabled.
387 * other: Invalid.
388#ifdef CONFIG_DCB 387#ifdef CONFIG_DCB
389 * 4: Priority Flow Control is enabled. 388 * 4: Priority Flow Control is enabled.
390#endif 389#endif
390 * other: Invalid.
391 */ 391 */
392 switch (hw->fc.current_mode) { 392 switch (hw->fc.current_mode) {
393 case ixgbe_fc_none: 393 case ixgbe_fc_none:
@@ -444,9 +444,10 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
444 reg = (rx_pba_size - hw->fc.low_water) << 6; 444 reg = (rx_pba_size - hw->fc.low_water) << 6;
445 if (hw->fc.send_xon) 445 if (hw->fc.send_xon)
446 reg |= IXGBE_FCRTL_XONE; 446 reg |= IXGBE_FCRTL_XONE;
447
447 IXGBE_WRITE_REG(hw, IXGBE_FCRTL(packetbuf_num), reg); 448 IXGBE_WRITE_REG(hw, IXGBE_FCRTL(packetbuf_num), reg);
448 449
449 reg = (rx_pba_size - hw->fc.high_water) << 10; 450 reg = (rx_pba_size - hw->fc.high_water) << 6;
450 reg |= IXGBE_FCRTH_FCEN; 451 reg |= IXGBE_FCRTH_FCEN;
451 452
452 IXGBE_WRITE_REG(hw, IXGBE_FCRTH(packetbuf_num), reg); 453 IXGBE_WRITE_REG(hw, IXGBE_FCRTH(packetbuf_num), reg);
diff --git a/drivers/net/ixgbe/ixgbe_82599.c b/drivers/net/ixgbe/ixgbe_82599.c
index 2f8b9f41714..00aeba385a2 100644
--- a/drivers/net/ixgbe/ixgbe_82599.c
+++ b/drivers/net/ixgbe/ixgbe_82599.c
@@ -772,6 +772,9 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,
772 772
773 /* Check to see if speed passed in is supported. */ 773 /* Check to see if speed passed in is supported. */
774 hw->mac.ops.get_link_capabilities(hw, &link_capabilities, &autoneg); 774 hw->mac.ops.get_link_capabilities(hw, &link_capabilities, &autoneg);
775 if (status != 0)
776 goto out;
777
775 speed &= link_capabilities; 778 speed &= link_capabilities;
776 779
777 if (speed == IXGBE_LINK_SPEED_UNKNOWN) { 780 if (speed == IXGBE_LINK_SPEED_UNKNOWN) {
diff --git a/drivers/net/ixgbe/ixgbe_common.c b/drivers/net/ixgbe/ixgbe_common.c
index 561f666618e..7a6a3fbee19 100644
--- a/drivers/net/ixgbe/ixgbe_common.c
+++ b/drivers/net/ixgbe/ixgbe_common.c
@@ -47,6 +47,12 @@ static void ixgbe_lower_eeprom_clk(struct ixgbe_hw *hw, u32 *eec);
47static void ixgbe_release_eeprom(struct ixgbe_hw *hw); 47static void ixgbe_release_eeprom(struct ixgbe_hw *hw);
48 48
49static s32 ixgbe_mta_vector(struct ixgbe_hw *hw, u8 *mc_addr); 49static s32 ixgbe_mta_vector(struct ixgbe_hw *hw, u8 *mc_addr);
50static s32 ixgbe_fc_autoneg_fiber(struct ixgbe_hw *hw);
51static s32 ixgbe_fc_autoneg_backplane(struct ixgbe_hw *hw);
52static s32 ixgbe_fc_autoneg_copper(struct ixgbe_hw *hw);
53static s32 ixgbe_device_supports_autoneg_fc(struct ixgbe_hw *hw);
54static s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg,
55 u32 adv_sym, u32 adv_asm, u32 lp_sym, u32 lp_asm);
50static s32 ixgbe_setup_fc(struct ixgbe_hw *hw, s32 packetbuf_num); 56static s32 ixgbe_setup_fc(struct ixgbe_hw *hw, s32 packetbuf_num);
51 57
52/** 58/**
@@ -1566,7 +1572,7 @@ s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw, s32 packetbuf_num)
1566#endif /* CONFIG_DCB */ 1572#endif /* CONFIG_DCB */
1567 /* Negotiate the fc mode to use */ 1573 /* Negotiate the fc mode to use */
1568 ret_val = ixgbe_fc_autoneg(hw); 1574 ret_val = ixgbe_fc_autoneg(hw);
1569 if (ret_val) 1575 if (ret_val == IXGBE_ERR_FLOW_CONTROL)
1570 goto out; 1576 goto out;
1571 1577
1572 /* Disable any previous flow control settings */ 1578 /* Disable any previous flow control settings */
@@ -1674,12 +1680,13 @@ out:
1674 **/ 1680 **/
1675s32 ixgbe_fc_autoneg(struct ixgbe_hw *hw) 1681s32 ixgbe_fc_autoneg(struct ixgbe_hw *hw)
1676{ 1682{
1677 s32 ret_val = 0; 1683 s32 ret_val = IXGBE_ERR_FC_NOT_NEGOTIATED;
1678 ixgbe_link_speed speed; 1684 ixgbe_link_speed speed;
1679 u32 pcs_anadv_reg, pcs_lpab_reg, linkstat;
1680 u32 links2, anlp1_reg, autoc_reg, links;
1681 bool link_up; 1685 bool link_up;
1682 1686
1687 if (hw->fc.disable_fc_autoneg)
1688 goto out;
1689
1683 /* 1690 /*
1684 * AN should have completed when the cable was plugged in. 1691 * AN should have completed when the cable was plugged in.
1685 * Look for reasons to bail out. Bail out if: 1692 * Look for reasons to bail out. Bail out if:
@@ -1690,153 +1697,199 @@ s32 ixgbe_fc_autoneg(struct ixgbe_hw *hw)
1690 * So use link_up_wait_to_complete=false. 1697 * So use link_up_wait_to_complete=false.
1691 */ 1698 */
1692 hw->mac.ops.check_link(hw, &speed, &link_up, false); 1699 hw->mac.ops.check_link(hw, &speed, &link_up, false);
1693 1700 if (!link_up) {
1694 if (hw->fc.disable_fc_autoneg || (!link_up)) { 1701 ret_val = IXGBE_ERR_FLOW_CONTROL;
1695 hw->fc.fc_was_autonegged = false;
1696 hw->fc.current_mode = hw->fc.requested_mode;
1697 goto out; 1702 goto out;
1698 } 1703 }
1699 1704
1700 /* 1705 switch (hw->phy.media_type) {
1701 * On backplane, bail out if 1706 /* Autoneg flow control on fiber adapters */
1702 * - backplane autoneg was not completed, or if 1707 case ixgbe_media_type_fiber:
1703 * - we are 82599 and link partner is not AN enabled 1708 if (speed == IXGBE_LINK_SPEED_1GB_FULL)
1704 */ 1709 ret_val = ixgbe_fc_autoneg_fiber(hw);
1705 if (hw->phy.media_type == ixgbe_media_type_backplane) { 1710 break;
1706 links = IXGBE_READ_REG(hw, IXGBE_LINKS);
1707 if ((links & IXGBE_LINKS_KX_AN_COMP) == 0) {
1708 hw->fc.fc_was_autonegged = false;
1709 hw->fc.current_mode = hw->fc.requested_mode;
1710 goto out;
1711 }
1712 1711
1713 if (hw->mac.type == ixgbe_mac_82599EB) { 1712 /* Autoneg flow control on backplane adapters */
1714 links2 = IXGBE_READ_REG(hw, IXGBE_LINKS2); 1713 case ixgbe_media_type_backplane:
1715 if ((links2 & IXGBE_LINKS2_AN_SUPPORTED) == 0) { 1714 ret_val = ixgbe_fc_autoneg_backplane(hw);
1716 hw->fc.fc_was_autonegged = false; 1715 break;
1717 hw->fc.current_mode = hw->fc.requested_mode; 1716
1718 goto out; 1717 /* Autoneg flow control on copper adapters */
1719 } 1718 case ixgbe_media_type_copper:
1720 } 1719 if (ixgbe_device_supports_autoneg_fc(hw) == 0)
1720 ret_val = ixgbe_fc_autoneg_copper(hw);
1721 break;
1722
1723 default:
1724 break;
1725 }
1726
1727out:
1728 if (ret_val == 0) {
1729 hw->fc.fc_was_autonegged = true;
1730 } else {
1731 hw->fc.fc_was_autonegged = false;
1732 hw->fc.current_mode = hw->fc.requested_mode;
1721 } 1733 }
1734 return ret_val;
1735}
1736
1737/**
1738 * ixgbe_fc_autoneg_fiber - Enable flow control on 1 gig fiber
1739 * @hw: pointer to hardware structure
1740 *
1741 * Enable flow control according on 1 gig fiber.
1742 **/
1743static s32 ixgbe_fc_autoneg_fiber(struct ixgbe_hw *hw)
1744{
1745 u32 pcs_anadv_reg, pcs_lpab_reg, linkstat;
1746 s32 ret_val;
1722 1747
1723 /* 1748 /*
1724 * On multispeed fiber at 1g, bail out if 1749 * On multispeed fiber at 1g, bail out if
1725 * - link is up but AN did not complete, or if 1750 * - link is up but AN did not complete, or if
1726 * - link is up and AN completed but timed out 1751 * - link is up and AN completed but timed out
1727 */ 1752 */
1728 if (hw->phy.multispeed_fiber && (speed == IXGBE_LINK_SPEED_1GB_FULL)) { 1753
1729 linkstat = IXGBE_READ_REG(hw, IXGBE_PCS1GLSTA); 1754 linkstat = IXGBE_READ_REG(hw, IXGBE_PCS1GLSTA);
1730 if (((linkstat & IXGBE_PCS1GLSTA_AN_COMPLETE) == 0) || 1755 if (((linkstat & IXGBE_PCS1GLSTA_AN_COMPLETE) == 0) ||
1731 ((linkstat & IXGBE_PCS1GLSTA_AN_TIMED_OUT) == 1)) { 1756 ((linkstat & IXGBE_PCS1GLSTA_AN_TIMED_OUT) == 1)) {
1732 hw->fc.fc_was_autonegged = false; 1757 ret_val = IXGBE_ERR_FC_NOT_NEGOTIATED;
1733 hw->fc.current_mode = hw->fc.requested_mode; 1758 goto out;
1734 goto out;
1735 }
1736 } 1759 }
1737 1760
1761 pcs_anadv_reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANA);
1762 pcs_lpab_reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANLP);
1763
1764 ret_val = ixgbe_negotiate_fc(hw, pcs_anadv_reg,
1765 pcs_lpab_reg, IXGBE_PCS1GANA_SYM_PAUSE,
1766 IXGBE_PCS1GANA_ASM_PAUSE,
1767 IXGBE_PCS1GANA_SYM_PAUSE,
1768 IXGBE_PCS1GANA_ASM_PAUSE);
1769
1770out:
1771 return ret_val;
1772}
1773
1774/**
1775 * ixgbe_fc_autoneg_backplane - Enable flow control IEEE clause 37
1776 * @hw: pointer to hardware structure
1777 *
1778 * Enable flow control according to IEEE clause 37.
1779 **/
1780static s32 ixgbe_fc_autoneg_backplane(struct ixgbe_hw *hw)
1781{
1782 u32 links2, anlp1_reg, autoc_reg, links;
1783 s32 ret_val;
1784
1738 /* 1785 /*
1739 * Bail out on 1786 * On backplane, bail out if
1740 * - copper or CX4 adapters 1787 * - backplane autoneg was not completed, or if
1741 * - fiber adapters running at 10gig 1788 * - we are 82599 and link partner is not AN enabled
1742 */ 1789 */
1743 if ((hw->phy.media_type == ixgbe_media_type_copper) || 1790 links = IXGBE_READ_REG(hw, IXGBE_LINKS);
1744 (hw->phy.media_type == ixgbe_media_type_cx4) || 1791 if ((links & IXGBE_LINKS_KX_AN_COMP) == 0) {
1745 ((hw->phy.media_type == ixgbe_media_type_fiber) &&
1746 (speed == IXGBE_LINK_SPEED_10GB_FULL))) {
1747 hw->fc.fc_was_autonegged = false; 1792 hw->fc.fc_was_autonegged = false;
1748 hw->fc.current_mode = hw->fc.requested_mode; 1793 hw->fc.current_mode = hw->fc.requested_mode;
1794 ret_val = IXGBE_ERR_FC_NOT_NEGOTIATED;
1749 goto out; 1795 goto out;
1750 } 1796 }
1751 1797
1798 if (hw->mac.type == ixgbe_mac_82599EB) {
1799 links2 = IXGBE_READ_REG(hw, IXGBE_LINKS2);
1800 if ((links2 & IXGBE_LINKS2_AN_SUPPORTED) == 0) {
1801 hw->fc.fc_was_autonegged = false;
1802 hw->fc.current_mode = hw->fc.requested_mode;
1803 ret_val = IXGBE_ERR_FC_NOT_NEGOTIATED;
1804 goto out;
1805 }
1806 }
1752 /* 1807 /*
1753 * Read the AN advertisement and LP ability registers and resolve 1808 * Read the 10g AN autoc and LP ability registers and resolve
1754 * local flow control settings accordingly 1809 * local flow control settings accordingly
1755 */ 1810 */
1756 if ((speed == IXGBE_LINK_SPEED_1GB_FULL) && 1811 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
1757 (hw->phy.media_type != ixgbe_media_type_backplane)) { 1812 anlp1_reg = IXGBE_READ_REG(hw, IXGBE_ANLP1);
1758 pcs_anadv_reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANA);
1759 pcs_lpab_reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANLP);
1760 if ((pcs_anadv_reg & IXGBE_PCS1GANA_SYM_PAUSE) &&
1761 (pcs_lpab_reg & IXGBE_PCS1GANA_SYM_PAUSE)) {
1762 /*
1763 * Now we need to check if the user selected Rx ONLY
1764 * of pause frames. In this case, we had to advertise
1765 * FULL flow control because we could not advertise RX
1766 * ONLY. Hence, we must now check to see if we need to
1767 * turn OFF the TRANSMISSION of PAUSE frames.
1768 */
1769 if (hw->fc.requested_mode == ixgbe_fc_full) {
1770 hw->fc.current_mode = ixgbe_fc_full;
1771 hw_dbg(hw, "Flow Control = FULL.\n");
1772 } else {
1773 hw->fc.current_mode = ixgbe_fc_rx_pause;
1774 hw_dbg(hw, "Flow Control=RX PAUSE only\n");
1775 }
1776 } else if (!(pcs_anadv_reg & IXGBE_PCS1GANA_SYM_PAUSE) &&
1777 (pcs_anadv_reg & IXGBE_PCS1GANA_ASM_PAUSE) &&
1778 (pcs_lpab_reg & IXGBE_PCS1GANA_SYM_PAUSE) &&
1779 (pcs_lpab_reg & IXGBE_PCS1GANA_ASM_PAUSE)) {
1780 hw->fc.current_mode = ixgbe_fc_tx_pause;
1781 hw_dbg(hw, "Flow Control = TX PAUSE frames only.\n");
1782 } else if ((pcs_anadv_reg & IXGBE_PCS1GANA_SYM_PAUSE) &&
1783 (pcs_anadv_reg & IXGBE_PCS1GANA_ASM_PAUSE) &&
1784 !(pcs_lpab_reg & IXGBE_PCS1GANA_SYM_PAUSE) &&
1785 (pcs_lpab_reg & IXGBE_PCS1GANA_ASM_PAUSE)) {
1786 hw->fc.current_mode = ixgbe_fc_rx_pause;
1787 hw_dbg(hw, "Flow Control = RX PAUSE frames only.\n");
1788 } else {
1789 hw->fc.current_mode = ixgbe_fc_none;
1790 hw_dbg(hw, "Flow Control = NONE.\n");
1791 }
1792 }
1793 1813
1794 if (hw->phy.media_type == ixgbe_media_type_backplane) { 1814 ret_val = ixgbe_negotiate_fc(hw, autoc_reg,
1815 anlp1_reg, IXGBE_AUTOC_SYM_PAUSE, IXGBE_AUTOC_ASM_PAUSE,
1816 IXGBE_ANLP1_SYM_PAUSE, IXGBE_ANLP1_ASM_PAUSE);
1817
1818out:
1819 return ret_val;
1820}
1821
1822/**
1823 * ixgbe_fc_autoneg_copper - Enable flow control IEEE clause 37
1824 * @hw: pointer to hardware structure
1825 *
1826 * Enable flow control according to IEEE clause 37.
1827 **/
1828static s32 ixgbe_fc_autoneg_copper(struct ixgbe_hw *hw)
1829{
1830 u16 technology_ability_reg = 0;
1831 u16 lp_technology_ability_reg = 0;
1832
1833 hw->phy.ops.read_reg(hw, MDIO_AN_ADVERTISE,
1834 MDIO_MMD_AN,
1835 &technology_ability_reg);
1836 hw->phy.ops.read_reg(hw, MDIO_AN_LPA,
1837 MDIO_MMD_AN,
1838 &lp_technology_ability_reg);
1839
1840 return ixgbe_negotiate_fc(hw, (u32)technology_ability_reg,
1841 (u32)lp_technology_ability_reg,
1842 IXGBE_TAF_SYM_PAUSE, IXGBE_TAF_ASM_PAUSE,
1843 IXGBE_TAF_SYM_PAUSE, IXGBE_TAF_ASM_PAUSE);
1844}
1845
1846/**
1847 * ixgbe_negotiate_fc - Negotiate flow control
1848 * @hw: pointer to hardware structure
1849 * @adv_reg: flow control advertised settings
1850 * @lp_reg: link partner's flow control settings
1851 * @adv_sym: symmetric pause bit in advertisement
1852 * @adv_asm: asymmetric pause bit in advertisement
1853 * @lp_sym: symmetric pause bit in link partner advertisement
1854 * @lp_asm: asymmetric pause bit in link partner advertisement
1855 *
1856 * Find the intersection between advertised settings and link partner's
1857 * advertised settings
1858 **/
1859static s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg,
1860 u32 adv_sym, u32 adv_asm, u32 lp_sym, u32 lp_asm)
1861{
1862 if ((!(adv_reg)) || (!(lp_reg)))
1863 return IXGBE_ERR_FC_NOT_NEGOTIATED;
1864
1865 if ((adv_reg & adv_sym) && (lp_reg & lp_sym)) {
1795 /* 1866 /*
1796 * Read the 10g AN autoc and LP ability registers and resolve 1867 * Now we need to check if the user selected Rx ONLY
1797 * local flow control settings accordingly 1868 * of pause frames. In this case, we had to advertise
1869 * FULL flow control because we could not advertise RX
1870 * ONLY. Hence, we must now check to see if we need to
1871 * turn OFF the TRANSMISSION of PAUSE frames.
1798 */ 1872 */
1799 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC); 1873 if (hw->fc.requested_mode == ixgbe_fc_full) {
1800 anlp1_reg = IXGBE_READ_REG(hw, IXGBE_ANLP1); 1874 hw->fc.current_mode = ixgbe_fc_full;
1801 1875 hw_dbg(hw, "Flow Control = FULL.\n");
1802 if ((autoc_reg & IXGBE_AUTOC_SYM_PAUSE) &&
1803 (anlp1_reg & IXGBE_ANLP1_SYM_PAUSE)) {
1804 /*
1805 * Now we need to check if the user selected Rx ONLY
1806 * of pause frames. In this case, we had to advertise
1807 * FULL flow control because we could not advertise RX
1808 * ONLY. Hence, we must now check to see if we need to
1809 * turn OFF the TRANSMISSION of PAUSE frames.
1810 */
1811 if (hw->fc.requested_mode == ixgbe_fc_full) {
1812 hw->fc.current_mode = ixgbe_fc_full;
1813 hw_dbg(hw, "Flow Control = FULL.\n");
1814 } else {
1815 hw->fc.current_mode = ixgbe_fc_rx_pause;
1816 hw_dbg(hw, "Flow Control=RX PAUSE only\n");
1817 }
1818 } else if (!(autoc_reg & IXGBE_AUTOC_SYM_PAUSE) &&
1819 (autoc_reg & IXGBE_AUTOC_ASM_PAUSE) &&
1820 (anlp1_reg & IXGBE_ANLP1_SYM_PAUSE) &&
1821 (anlp1_reg & IXGBE_ANLP1_ASM_PAUSE)) {
1822 hw->fc.current_mode = ixgbe_fc_tx_pause;
1823 hw_dbg(hw, "Flow Control = TX PAUSE frames only.\n");
1824 } else if ((autoc_reg & IXGBE_AUTOC_SYM_PAUSE) &&
1825 (autoc_reg & IXGBE_AUTOC_ASM_PAUSE) &&
1826 !(anlp1_reg & IXGBE_ANLP1_SYM_PAUSE) &&
1827 (anlp1_reg & IXGBE_ANLP1_ASM_PAUSE)) {
1828 hw->fc.current_mode = ixgbe_fc_rx_pause;
1829 hw_dbg(hw, "Flow Control = RX PAUSE frames only.\n");
1830 } else { 1876 } else {
1831 hw->fc.current_mode = ixgbe_fc_none; 1877 hw->fc.current_mode = ixgbe_fc_rx_pause;
1832 hw_dbg(hw, "Flow Control = NONE.\n"); 1878 hw_dbg(hw, "Flow Control=RX PAUSE frames only\n");
1833 } 1879 }
1880 } else if (!(adv_reg & adv_sym) && (adv_reg & adv_asm) &&
1881 (lp_reg & lp_sym) && (lp_reg & lp_asm)) {
1882 hw->fc.current_mode = ixgbe_fc_tx_pause;
1883 hw_dbg(hw, "Flow Control = TX PAUSE frames only.\n");
1884 } else if ((adv_reg & adv_sym) && (adv_reg & adv_asm) &&
1885 !(lp_reg & lp_sym) && (lp_reg & lp_asm)) {
1886 hw->fc.current_mode = ixgbe_fc_rx_pause;
1887 hw_dbg(hw, "Flow Control = RX PAUSE frames only.\n");
1888 } else {
1889 hw->fc.current_mode = ixgbe_fc_none;
1890 hw_dbg(hw, "Flow Control = NONE.\n");
1834 } 1891 }
1835 /* Record that current_mode is the result of a successful autoneg */ 1892 return 0;
1836 hw->fc.fc_was_autonegged = true;
1837
1838out:
1839 return ret_val;
1840} 1893}
1841 1894
1842/** 1895/**
@@ -1848,7 +1901,8 @@ out:
1848static s32 ixgbe_setup_fc(struct ixgbe_hw *hw, s32 packetbuf_num) 1901static s32 ixgbe_setup_fc(struct ixgbe_hw *hw, s32 packetbuf_num)
1849{ 1902{
1850 s32 ret_val = 0; 1903 s32 ret_val = 0;
1851 u32 reg; 1904 u32 reg = 0, reg_bp = 0;
1905 u16 reg_cu = 0;
1852 1906
1853#ifdef CONFIG_DCB 1907#ifdef CONFIG_DCB
1854 if (hw->fc.requested_mode == ixgbe_fc_pfc) { 1908 if (hw->fc.requested_mode == ixgbe_fc_pfc) {
@@ -1856,7 +1910,7 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw, s32 packetbuf_num)
1856 goto out; 1910 goto out;
1857 } 1911 }
1858 1912
1859#endif 1913#endif /* CONFIG_DCB */
1860 /* Validate the packetbuf configuration */ 1914 /* Validate the packetbuf configuration */
1861 if (packetbuf_num < 0 || packetbuf_num > 7) { 1915 if (packetbuf_num < 0 || packetbuf_num > 7) {
1862 hw_dbg(hw, "Invalid packet buffer number [%d], expected range " 1916 hw_dbg(hw, "Invalid packet buffer number [%d], expected range "
@@ -1894,11 +1948,26 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw, s32 packetbuf_num)
1894 hw->fc.requested_mode = ixgbe_fc_full; 1948 hw->fc.requested_mode = ixgbe_fc_full;
1895 1949
1896 /* 1950 /*
1897 * Set up the 1G flow control advertisement registers so the HW will be 1951 * Set up the 1G and 10G flow control advertisement registers so the
1898 * able to do fc autoneg once the cable is plugged in. If we end up 1952 * HW will be able to do fc autoneg once the cable is plugged in. If
1899 * using 10g instead, this is harmless. 1953 * we link at 10G, the 1G advertisement is harmless and vice versa.
1900 */ 1954 */
1901 reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANA); 1955
1956 switch (hw->phy.media_type) {
1957 case ixgbe_media_type_fiber:
1958 case ixgbe_media_type_backplane:
1959 reg = IXGBE_READ_REG(hw, IXGBE_PCS1GANA);
1960 reg_bp = IXGBE_READ_REG(hw, IXGBE_AUTOC);
1961 break;
1962
1963 case ixgbe_media_type_copper:
1964 hw->phy.ops.read_reg(hw, MDIO_AN_ADVERTISE,
1965 MDIO_MMD_AN, &reg_cu);
1966 break;
1967
1968 default:
1969 ;
1970 }
1902 1971
1903 /* 1972 /*
1904 * The possible values of fc.requested_mode are: 1973 * The possible values of fc.requested_mode are:
@@ -1917,6 +1986,11 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw, s32 packetbuf_num)
1917 case ixgbe_fc_none: 1986 case ixgbe_fc_none:
1918 /* Flow control completely disabled by software override. */ 1987 /* Flow control completely disabled by software override. */
1919 reg &= ~(IXGBE_PCS1GANA_SYM_PAUSE | IXGBE_PCS1GANA_ASM_PAUSE); 1988 reg &= ~(IXGBE_PCS1GANA_SYM_PAUSE | IXGBE_PCS1GANA_ASM_PAUSE);
1989 if (hw->phy.media_type == ixgbe_media_type_backplane)
1990 reg_bp &= ~(IXGBE_AUTOC_SYM_PAUSE |
1991 IXGBE_AUTOC_ASM_PAUSE);
1992 else if (hw->phy.media_type == ixgbe_media_type_copper)
1993 reg_cu &= ~(IXGBE_TAF_SYM_PAUSE | IXGBE_TAF_ASM_PAUSE);
1920 break; 1994 break;
1921 case ixgbe_fc_rx_pause: 1995 case ixgbe_fc_rx_pause:
1922 /* 1996 /*
@@ -1928,6 +2002,11 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw, s32 packetbuf_num)
1928 * disable the adapter's ability to send PAUSE frames. 2002 * disable the adapter's ability to send PAUSE frames.
1929 */ 2003 */
1930 reg |= (IXGBE_PCS1GANA_SYM_PAUSE | IXGBE_PCS1GANA_ASM_PAUSE); 2004 reg |= (IXGBE_PCS1GANA_SYM_PAUSE | IXGBE_PCS1GANA_ASM_PAUSE);
2005 if (hw->phy.media_type == ixgbe_media_type_backplane)
2006 reg_bp |= (IXGBE_AUTOC_SYM_PAUSE |
2007 IXGBE_AUTOC_ASM_PAUSE);
2008 else if (hw->phy.media_type == ixgbe_media_type_copper)
2009 reg_cu |= (IXGBE_TAF_SYM_PAUSE | IXGBE_TAF_ASM_PAUSE);
1931 break; 2010 break;
1932 case ixgbe_fc_tx_pause: 2011 case ixgbe_fc_tx_pause:
1933 /* 2012 /*
@@ -1936,10 +2015,22 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw, s32 packetbuf_num)
1936 */ 2015 */
1937 reg |= (IXGBE_PCS1GANA_ASM_PAUSE); 2016 reg |= (IXGBE_PCS1GANA_ASM_PAUSE);
1938 reg &= ~(IXGBE_PCS1GANA_SYM_PAUSE); 2017 reg &= ~(IXGBE_PCS1GANA_SYM_PAUSE);
2018 if (hw->phy.media_type == ixgbe_media_type_backplane) {
2019 reg_bp |= (IXGBE_AUTOC_ASM_PAUSE);
2020 reg_bp &= ~(IXGBE_AUTOC_SYM_PAUSE);
2021 } else if (hw->phy.media_type == ixgbe_media_type_copper) {
2022 reg_cu |= (IXGBE_TAF_ASM_PAUSE);
2023 reg_cu &= ~(IXGBE_TAF_SYM_PAUSE);
2024 }
1939 break; 2025 break;
1940 case ixgbe_fc_full: 2026 case ixgbe_fc_full:
1941 /* Flow control (both Rx and Tx) is enabled by SW override. */ 2027 /* Flow control (both Rx and Tx) is enabled by SW override. */
1942 reg |= (IXGBE_PCS1GANA_SYM_PAUSE | IXGBE_PCS1GANA_ASM_PAUSE); 2028 reg |= (IXGBE_PCS1GANA_SYM_PAUSE | IXGBE_PCS1GANA_ASM_PAUSE);
2029 if (hw->phy.media_type == ixgbe_media_type_backplane)
2030 reg_bp |= (IXGBE_AUTOC_SYM_PAUSE |
2031 IXGBE_AUTOC_ASM_PAUSE);
2032 else if (hw->phy.media_type == ixgbe_media_type_copper)
2033 reg_cu |= (IXGBE_TAF_SYM_PAUSE | IXGBE_TAF_ASM_PAUSE);
1943 break; 2034 break;
1944#ifdef CONFIG_DCB 2035#ifdef CONFIG_DCB
1945 case ixgbe_fc_pfc: 2036 case ixgbe_fc_pfc:
@@ -1953,80 +2044,37 @@ static s32 ixgbe_setup_fc(struct ixgbe_hw *hw, s32 packetbuf_num)
1953 break; 2044 break;
1954 } 2045 }
1955 2046
1956 IXGBE_WRITE_REG(hw, IXGBE_PCS1GANA, reg); 2047 if (hw->mac.type != ixgbe_mac_X540) {
1957 reg = IXGBE_READ_REG(hw, IXGBE_PCS1GLCTL); 2048 /*
1958 2049 * Enable auto-negotiation between the MAC & PHY;
1959 /* Disable AN timeout */ 2050 * the MAC will advertise clause 37 flow control.
1960 if (hw->fc.strict_ieee) 2051 */
1961 reg &= ~IXGBE_PCS1GLCTL_AN_1G_TIMEOUT_EN; 2052 IXGBE_WRITE_REG(hw, IXGBE_PCS1GANA, reg);
2053 reg = IXGBE_READ_REG(hw, IXGBE_PCS1GLCTL);
1962 2054
1963 IXGBE_WRITE_REG(hw, IXGBE_PCS1GLCTL, reg); 2055 /* Disable AN timeout */
1964 hw_dbg(hw, "Set up FC; PCS1GLCTL = 0x%08X\n", reg); 2056 if (hw->fc.strict_ieee)
2057 reg &= ~IXGBE_PCS1GLCTL_AN_1G_TIMEOUT_EN;
1965 2058
1966 /* 2059 IXGBE_WRITE_REG(hw, IXGBE_PCS1GLCTL, reg);
1967 * Set up the 10G flow control advertisement registers so the HW 2060 hw_dbg(hw, "Set up FC; PCS1GLCTL = 0x%08X\n", reg);
1968 * can do fc autoneg once the cable is plugged in. If we end up 2061 }
1969 * using 1g instead, this is harmless.
1970 */
1971 reg = IXGBE_READ_REG(hw, IXGBE_AUTOC);
1972 2062
1973 /* 2063 /*
1974 * The possible values of fc.requested_mode are: 2064 * AUTOC restart handles negotiation of 1G and 10G on backplane
1975 * 0: Flow control is completely disabled 2065 * and copper. There is no need to set the PCS1GCTL register.
1976 * 1: Rx flow control is enabled (we can receive pause frames, 2066 *
1977 * but not send pause frames).
1978 * 2: Tx flow control is enabled (we can send pause frames but
1979 * we do not support receiving pause frames).
1980 * 3: Both Rx and Tx flow control (symmetric) are enabled.
1981 * other: Invalid.
1982 */ 2067 */
1983 switch (hw->fc.requested_mode) { 2068 if (hw->phy.media_type == ixgbe_media_type_backplane) {
1984 case ixgbe_fc_none: 2069 reg_bp |= IXGBE_AUTOC_AN_RESTART;
1985 /* Flow control completely disabled by software override. */ 2070 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, reg_bp);
1986 reg &= ~(IXGBE_AUTOC_SYM_PAUSE | IXGBE_AUTOC_ASM_PAUSE); 2071 } else if ((hw->phy.media_type == ixgbe_media_type_copper) &&
1987 break; 2072 (ixgbe_device_supports_autoneg_fc(hw) == 0)) {
1988 case ixgbe_fc_rx_pause: 2073 hw->phy.ops.write_reg(hw, MDIO_AN_ADVERTISE,
1989 /* 2074 MDIO_MMD_AN, reg_cu);
1990 * Rx Flow control is enabled and Tx Flow control is
1991 * disabled by software override. Since there really
1992 * isn't a way to advertise that we are capable of RX
1993 * Pause ONLY, we will advertise that we support both
1994 * symmetric and asymmetric Rx PAUSE. Later, we will
1995 * disable the adapter's ability to send PAUSE frames.
1996 */
1997 reg |= (IXGBE_AUTOC_SYM_PAUSE | IXGBE_AUTOC_ASM_PAUSE);
1998 break;
1999 case ixgbe_fc_tx_pause:
2000 /*
2001 * Tx Flow control is enabled, and Rx Flow control is
2002 * disabled by software override.
2003 */
2004 reg |= (IXGBE_AUTOC_ASM_PAUSE);
2005 reg &= ~(IXGBE_AUTOC_SYM_PAUSE);
2006 break;
2007 case ixgbe_fc_full:
2008 /* Flow control (both Rx and Tx) is enabled by SW override. */
2009 reg |= (IXGBE_AUTOC_SYM_PAUSE | IXGBE_AUTOC_ASM_PAUSE);
2010 break;
2011#ifdef CONFIG_DCB
2012 case ixgbe_fc_pfc:
2013 goto out;
2014 break;
2015#endif /* CONFIG_DCB */
2016 default:
2017 hw_dbg(hw, "Flow control param set incorrectly\n");
2018 ret_val = IXGBE_ERR_CONFIG;
2019 goto out;
2020 break;
2021 } 2075 }
2022 /*
2023 * AUTOC restart handles negotiation of 1G and 10G. There is
2024 * no need to set the PCS1GCTL register.
2025 */
2026 reg |= IXGBE_AUTOC_AN_RESTART;
2027 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, reg);
2028 hw_dbg(hw, "Set up FC; IXGBE_AUTOC = 0x%08X\n", reg);
2029 2076
2077 hw_dbg(hw, "Set up FC; IXGBE_AUTOC = 0x%08X\n", reg);
2030out: 2078out:
2031 return ret_val; 2079 return ret_val;
2032} 2080}
@@ -2751,6 +2799,28 @@ wwn_prefix_out:
2751} 2799}
2752 2800
2753/** 2801/**
2802 * ixgbe_device_supports_autoneg_fc - Check if phy supports autoneg flow
2803 * control
2804 * @hw: pointer to hardware structure
2805 *
2806 * There are several phys that do not support autoneg flow control. This
2807 * function check the device id to see if the associated phy supports
2808 * autoneg flow control.
2809 **/
2810static s32 ixgbe_device_supports_autoneg_fc(struct ixgbe_hw *hw)
2811{
2812
2813 switch (hw->device_id) {
2814 case IXGBE_DEV_ID_X540T:
2815 return 0;
2816 case IXGBE_DEV_ID_82599_T3_LOM:
2817 return 0;
2818 default:
2819 return IXGBE_ERR_FC_NOT_SUPPORTED;
2820 }
2821}
2822
2823/**
2754 * ixgbe_set_mac_anti_spoofing - Enable/Disable MAC anti-spoofing 2824 * ixgbe_set_mac_anti_spoofing - Enable/Disable MAC anti-spoofing
2755 * @hw: pointer to hardware structure 2825 * @hw: pointer to hardware structure
2756 * @enable: enable or disable switch for anti-spoofing 2826 * @enable: enable or disable switch for anti-spoofing
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 5e8c39decca..5998dc94dd5 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -3775,7 +3775,8 @@ static int ixgbe_non_sfp_link_config(struct ixgbe_hw *hw)
3775 if (ret) 3775 if (ret)
3776 goto link_cfg_out; 3776 goto link_cfg_out;
3777 3777
3778 if (hw->mac.ops.get_link_capabilities) 3778 autoneg = hw->phy.autoneg_advertised;
3779 if ((!autoneg) && (hw->mac.ops.get_link_capabilities))
3779 ret = hw->mac.ops.get_link_capabilities(hw, &autoneg, 3780 ret = hw->mac.ops.get_link_capabilities(hw, &autoneg,
3780 &negotiation); 3781 &negotiation);
3781 if (ret) 3782 if (ret)
diff --git a/drivers/net/ixgbe/ixgbe_phy.h b/drivers/net/ixgbe/ixgbe_phy.h
index 2327baf0442..9bf2783d7a7 100644
--- a/drivers/net/ixgbe/ixgbe_phy.h
+++ b/drivers/net/ixgbe/ixgbe_phy.h
@@ -58,6 +58,10 @@
58#define IXGBE_I2C_EEPROM_STATUS_FAIL 0x2 58#define IXGBE_I2C_EEPROM_STATUS_FAIL 0x2
59#define IXGBE_I2C_EEPROM_STATUS_IN_PROGRESS 0x3 59#define IXGBE_I2C_EEPROM_STATUS_IN_PROGRESS 0x3
60 60
61/* Flow control defines */
62#define IXGBE_TAF_SYM_PAUSE 0x400
63#define IXGBE_TAF_ASM_PAUSE 0x800
64
61/* Bit-shift macros */ 65/* Bit-shift macros */
62#define IXGBE_SFF_VENDOR_OUI_BYTE0_SHIFT 24 66#define IXGBE_SFF_VENDOR_OUI_BYTE0_SHIFT 24
63#define IXGBE_SFF_VENDOR_OUI_BYTE1_SHIFT 16 67#define IXGBE_SFF_VENDOR_OUI_BYTE1_SHIFT 16
diff --git a/drivers/net/ixgbe/ixgbe_type.h b/drivers/net/ixgbe/ixgbe_type.h
index 76bf21b8a10..f190a4a8faf 100644
--- a/drivers/net/ixgbe/ixgbe_type.h
+++ b/drivers/net/ixgbe/ixgbe_type.h
@@ -2698,6 +2698,9 @@ struct ixgbe_info {
2698#define IXGBE_ERR_EEPROM_VERSION -24 2698#define IXGBE_ERR_EEPROM_VERSION -24
2699#define IXGBE_ERR_NO_SPACE -25 2699#define IXGBE_ERR_NO_SPACE -25
2700#define IXGBE_ERR_OVERTEMP -26 2700#define IXGBE_ERR_OVERTEMP -26
2701#define IXGBE_ERR_FC_NOT_NEGOTIATED -27
2702#define IXGBE_ERR_FC_NOT_SUPPORTED -28
2703#define IXGBE_ERR_FLOW_CONTROL -29
2701#define IXGBE_ERR_SFP_SETUP_NOT_COMPLETE -30 2704#define IXGBE_ERR_SFP_SETUP_NOT_COMPLETE -30
2702#define IXGBE_ERR_PBA_SECTION -31 2705#define IXGBE_ERR_PBA_SECTION -31
2703#define IXGBE_ERR_INVALID_ARGUMENT -32 2706#define IXGBE_ERR_INVALID_ARGUMENT -32