aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2015-09-01 23:17:17 -0400
committerDavid S. Miller <davem@davemloft.net>2015-09-01 23:17:17 -0400
commit1bd40543534578f20889d5e999a0f184fd7ea88f (patch)
treed1131d97250860ba1e1874fe21b12b175c2b6d5b
parenta17ace95b0f08ccbcf24946db5673c4b5ee8fcae (diff)
parent990a2d6ed543bd18b864b8a11f7be3368c67ccea (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-01 This series contains updates to i40e, ixgbe and ixgbevf. Anjali fixes a bug in i40e where the port is not receiving multicast or VLAN tagged packets in promiscuous mode. Which can occur when a software bridge is created on top of the device. Don adds support in ixgbe that indicates the presence of management firmware. Added support for entering low power link up state on devices that support it when the device is closing or suspending. Updated the driver to report unknown bus speed and width since IOSF does not report a PCIe bus speed or width for X550 devices. Also added the new bus type for integrated I/O interface (IOSF). Cleaned up of redundant code in ixgbe. Mark adds support for UDP-encapsulation transmit checksum and for VXLAN receive offloads. Introduces a helper function to do the register access and processing to avoid needless PHY access on copper PHYs. Added support for reporting 2.5G link speed. Fixed warnings resulting from redundant initializations of the get_bus_info field. Maninder Singh updates the ixgbe driver to use kzalloc instead of kcalloc for allocation of one thing. Tom Barbette adds support for ethtool to change the rxfh indirection table and/or key using ethtool interface. Emil resolves an issue where users were not able to dynamically set number of queues for 82598 via ethtool -L. Alex Williamson removes bimodal SR-IOV disabling behavior since it is confusing to users and results in a state where the PF is broken for other uses unless the user sets sriov_numvfs to zero prior to unbinding the device. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e.h1
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_main.c37
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe.h7
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c89
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_common.c15
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_common.h1
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c54
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c251
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c75
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_type.h55
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c5
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c182
12 files changed, 633 insertions, 139 deletions
diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h
index 05df21c16c79..e7462793d48d 100644
--- a/drivers/net/ethernet/intel/i40e/i40e.h
+++ b/drivers/net/ethernet/intel/i40e/i40e.h
@@ -372,6 +372,7 @@ struct i40e_pf {
372#ifdef CONFIG_DEBUG_FS 372#ifdef CONFIG_DEBUG_FS
373 struct dentry *i40e_dbg_pf; 373 struct dentry *i40e_dbg_pf;
374#endif /* CONFIG_DEBUG_FS */ 374#endif /* CONFIG_DEBUG_FS */
375 bool cur_promisc;
375 376
376 u16 instance; /* A unique number per i40e_pf instance in the system */ 377 u16 instance; /* A unique number per i40e_pf instance in the system */
377 378
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index a97f193382d7..851c1a159be8 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -1937,15 +1937,35 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi)
1937 cur_promisc = (!!(vsi->current_netdev_flags & IFF_PROMISC) || 1937 cur_promisc = (!!(vsi->current_netdev_flags & IFF_PROMISC) ||
1938 test_bit(__I40E_FILTER_OVERFLOW_PROMISC, 1938 test_bit(__I40E_FILTER_OVERFLOW_PROMISC,
1939 &vsi->state)); 1939 &vsi->state));
1940 ret = i40e_aq_set_vsi_unicast_promiscuous(&vsi->back->hw, 1940 if (vsi->type == I40E_VSI_MAIN && pf->lan_veb != I40E_NO_VEB) {
1941 /* set defport ON for Main VSI instead of true promisc
1942 * this way we will get all unicast/multicast and VLAN
1943 * promisc behavior but will not get VF or VMDq traffic
1944 * replicated on the Main VSI.
1945 */
1946 if (pf->cur_promisc != cur_promisc) {
1947 pf->cur_promisc = cur_promisc;
1948 i40e_do_reset_safe(pf,
1949 BIT(__I40E_PF_RESET_REQUESTED));
1950 }
1951 } else {
1952 ret = i40e_aq_set_vsi_unicast_promiscuous(
1953 &vsi->back->hw,
1941 vsi->seid, 1954 vsi->seid,
1942 cur_promisc, NULL); 1955 cur_promisc, NULL);
1943 if (ret) 1956 if (ret)
1944 dev_info(&pf->pdev->dev, 1957 dev_info(&pf->pdev->dev,
1945 "set uni promisc failed, err %s, aq_err %s\n", 1958 "set unicast promisc failed, err %d, aq_err %d\n",
1946 i40e_stat_str(&pf->hw, ret), 1959 ret, pf->hw.aq.asq_last_status);
1947 i40e_aq_str(&pf->hw, 1960 ret = i40e_aq_set_vsi_multicast_promiscuous(
1948 pf->hw.aq.asq_last_status)); 1961 &vsi->back->hw,
1962 vsi->seid,
1963 cur_promisc, NULL);
1964 if (ret)
1965 dev_info(&pf->pdev->dev,
1966 "set multicast promisc failed, err %d, aq_err %d\n",
1967 ret, pf->hw.aq.asq_last_status);
1968 }
1949 ret = i40e_aq_set_vsi_broadcast(&vsi->back->hw, 1969 ret = i40e_aq_set_vsi_broadcast(&vsi->back->hw,
1950 vsi->seid, 1970 vsi->seid,
1951 cur_promisc, NULL); 1971 cur_promisc, NULL);
@@ -4001,6 +4021,7 @@ static void i40e_vsi_close(struct i40e_vsi *vsi)
4001 i40e_vsi_free_irq(vsi); 4021 i40e_vsi_free_irq(vsi);
4002 i40e_vsi_free_tx_resources(vsi); 4022 i40e_vsi_free_tx_resources(vsi);
4003 i40e_vsi_free_rx_resources(vsi); 4023 i40e_vsi_free_rx_resources(vsi);
4024 vsi->current_netdev_flags = 0;
4004} 4025}
4005 4026
4006/** 4027/**
@@ -9312,7 +9333,7 @@ void i40e_veb_release(struct i40e_veb *veb)
9312static int i40e_add_veb(struct i40e_veb *veb, struct i40e_vsi *vsi) 9333static int i40e_add_veb(struct i40e_veb *veb, struct i40e_vsi *vsi)
9313{ 9334{
9314 struct i40e_pf *pf = veb->pf; 9335 struct i40e_pf *pf = veb->pf;
9315 bool is_default = false; 9336 bool is_default = veb->pf->cur_promisc;
9316 bool is_cloud = false; 9337 bool is_cloud = false;
9317 int ret; 9338 int ret;
9318 9339
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
index ac3ac2a20386..edf1fb913209 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
@@ -630,6 +630,7 @@ struct ixgbe_adapter {
630#define IXGBE_FLAG_FCOE_ENABLED (u32)(1 << 21) 630#define IXGBE_FLAG_FCOE_ENABLED (u32)(1 << 21)
631#define IXGBE_FLAG_SRIOV_CAPABLE (u32)(1 << 22) 631#define IXGBE_FLAG_SRIOV_CAPABLE (u32)(1 << 22)
632#define IXGBE_FLAG_SRIOV_ENABLED (u32)(1 << 23) 632#define IXGBE_FLAG_SRIOV_ENABLED (u32)(1 << 23)
633#define IXGBE_FLAG_VXLAN_OFFLOAD_CAPABLE BIT(24)
633 634
634 u32 flags2; 635 u32 flags2;
635#define IXGBE_FLAG2_RSC_CAPABLE (u32)(1 << 0) 636#define IXGBE_FLAG2_RSC_CAPABLE (u32)(1 << 0)
@@ -644,6 +645,9 @@ struct ixgbe_adapter {
644#define IXGBE_FLAG2_RSS_FIELD_IPV6_UDP (u32)(1 << 9) 645#define IXGBE_FLAG2_RSS_FIELD_IPV6_UDP (u32)(1 << 9)
645#define IXGBE_FLAG2_PTP_PPS_ENABLED (u32)(1 << 10) 646#define IXGBE_FLAG2_PTP_PPS_ENABLED (u32)(1 << 10)
646#define IXGBE_FLAG2_PHY_INTERRUPT (u32)(1 << 11) 647#define IXGBE_FLAG2_PHY_INTERRUPT (u32)(1 << 11)
648#ifdef CONFIG_IXGBE_VXLAN
649#define IXGBE_FLAG2_VXLAN_REREG_NEEDED BIT(12)
650#endif
647 651
648 /* Tx fast path data */ 652 /* Tx fast path data */
649 int num_tx_queues; 653 int num_tx_queues;
@@ -757,7 +761,9 @@ struct ixgbe_adapter {
757 u32 timer_event_accumulator; 761 u32 timer_event_accumulator;
758 u32 vferr_refcount; 762 u32 vferr_refcount;
759 struct ixgbe_mac_addr *mac_table; 763 struct ixgbe_mac_addr *mac_table;
764#ifdef CONFIG_IXGBE_VXLAN
760 u16 vxlan_port; 765 u16 vxlan_port;
766#endif
761 struct kobject *info_kobj; 767 struct kobject *info_kobj;
762#ifdef CONFIG_IXGBE_HWMON 768#ifdef CONFIG_IXGBE_HWMON
763 struct hwmon_buff *ixgbe_hwmon_buff; 769 struct hwmon_buff *ixgbe_hwmon_buff;
@@ -967,4 +973,5 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,
967 struct ixgbe_adapter *adapter, 973 struct ixgbe_adapter *adapter,
968 struct ixgbe_ring *tx_ring); 974 struct ixgbe_ring *tx_ring);
969u32 ixgbe_rss_indir_tbl_entries(struct ixgbe_adapter *adapter); 975u32 ixgbe_rss_indir_tbl_entries(struct ixgbe_adapter *adapter);
976void ixgbe_store_reta(struct ixgbe_adapter *adapter);
970#endif /* _IXGBE_H_ */ 977#endif /* _IXGBE_H_ */
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c
index b1e364d26aa7..dd7062fed61a 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel 10 Gigabit PCI Express Linux driver 3 Intel 10 Gigabit PCI Express Linux driver
4 Copyright(c) 1999 - 2014 Intel Corporation. 4 Copyright(c) 1999 - 2015 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -504,16 +504,12 @@ static enum ixgbe_media_type ixgbe_get_media_type_82599(struct ixgbe_hw *hw)
504 **/ 504 **/
505static void ixgbe_stop_mac_link_on_d3_82599(struct ixgbe_hw *hw) 505static void ixgbe_stop_mac_link_on_d3_82599(struct ixgbe_hw *hw)
506{ 506{
507 u32 autoc2_reg, fwsm; 507 u32 autoc2_reg;
508 u16 ee_ctrl_2 = 0; 508 u16 ee_ctrl_2 = 0;
509 509
510 hw->eeprom.ops.read(hw, IXGBE_EEPROM_CTRL_2, &ee_ctrl_2); 510 hw->eeprom.ops.read(hw, IXGBE_EEPROM_CTRL_2, &ee_ctrl_2);
511 511
512 /* Check to see if MNG FW could be enabled */ 512 if (!ixgbe_mng_present(hw) && !hw->wol_enabled &&
513 fwsm = IXGBE_READ_REG(hw, IXGBE_FWSM(hw));
514
515 if (((fwsm & IXGBE_FWSM_MODE_MASK) != IXGBE_FWSM_FW_MODE_PT) &&
516 !hw->wol_enabled &&
517 ee_ctrl_2 & IXGBE_EEPROM_CCD_BIT) { 513 ee_ctrl_2 & IXGBE_EEPROM_CCD_BIT) {
518 autoc2_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC2); 514 autoc2_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
519 autoc2_reg |= IXGBE_AUTOC2_LINK_DISABLE_ON_D3_MASK; 515 autoc2_reg |= IXGBE_AUTOC2_LINK_DISABLE_ON_D3_MASK;
@@ -1246,6 +1242,25 @@ mac_reset_top:
1246} 1242}
1247 1243
1248/** 1244/**
1245 * ixgbe_fdir_check_cmd_complete - poll to check whether FDIRCMD is complete
1246 * @hw: pointer to hardware structure
1247 * @fdircmd: current value of FDIRCMD register
1248 */
1249static s32 ixgbe_fdir_check_cmd_complete(struct ixgbe_hw *hw, u32 *fdircmd)
1250{
1251 int i;
1252
1253 for (i = 0; i < IXGBE_FDIRCMD_CMD_POLL; i++) {
1254 *fdircmd = IXGBE_READ_REG(hw, IXGBE_FDIRCMD);
1255 if (!(*fdircmd & IXGBE_FDIRCMD_CMD_MASK))
1256 return 0;
1257 udelay(10);
1258 }
1259
1260 return IXGBE_ERR_FDIR_CMD_INCOMPLETE;
1261}
1262
1263/**
1249 * ixgbe_reinit_fdir_tables_82599 - Reinitialize Flow Director tables. 1264 * ixgbe_reinit_fdir_tables_82599 - Reinitialize Flow Director tables.
1250 * @hw: pointer to hardware structure 1265 * @hw: pointer to hardware structure
1251 **/ 1266 **/
@@ -1253,6 +1268,8 @@ s32 ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw)
1253{ 1268{
1254 int i; 1269 int i;
1255 u32 fdirctrl = IXGBE_READ_REG(hw, IXGBE_FDIRCTRL); 1270 u32 fdirctrl = IXGBE_READ_REG(hw, IXGBE_FDIRCTRL);
1271 u32 fdircmd;
1272 s32 err;
1256 1273
1257 fdirctrl &= ~IXGBE_FDIRCTRL_INIT_DONE; 1274 fdirctrl &= ~IXGBE_FDIRCTRL_INIT_DONE;
1258 1275
@@ -1260,15 +1277,10 @@ s32 ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw)
1260 * Before starting reinitialization process, 1277 * Before starting reinitialization process,
1261 * FDIRCMD.CMD must be zero. 1278 * FDIRCMD.CMD must be zero.
1262 */ 1279 */
1263 for (i = 0; i < IXGBE_FDIRCMD_CMD_POLL; i++) { 1280 err = ixgbe_fdir_check_cmd_complete(hw, &fdircmd);
1264 if (!(IXGBE_READ_REG(hw, IXGBE_FDIRCMD) & 1281 if (err) {
1265 IXGBE_FDIRCMD_CMD_MASK)) 1282 hw_dbg(hw, "Flow Director previous command did not complete, aborting table re-initialization.\n");
1266 break; 1283 return err;
1267 udelay(10);
1268 }
1269 if (i >= IXGBE_FDIRCMD_CMD_POLL) {
1270 hw_dbg(hw, "Flow Director previous command isn't complete, aborting table re-initialization.\n");
1271 return IXGBE_ERR_FDIR_REINIT_FAILED;
1272 } 1284 }
1273 1285
1274 IXGBE_WRITE_REG(hw, IXGBE_FDIRFREE, 0); 1286 IXGBE_WRITE_REG(hw, IXGBE_FDIRFREE, 0);
@@ -1507,20 +1519,28 @@ static u32 ixgbe_atr_compute_sig_hash_82599(union ixgbe_atr_hash_dword input,
1507 * @input: unique input dword 1519 * @input: unique input dword
1508 * @common: compressed common input dword 1520 * @common: compressed common input dword
1509 * @queue: queue index to direct traffic to 1521 * @queue: queue index to direct traffic to
1522 *
1523 * Note that the tunnel bit in input must not be set when the hardware
1524 * tunneling support does not exist.
1510 **/ 1525 **/
1511s32 ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw, 1526s32 ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw,
1512 union ixgbe_atr_hash_dword input, 1527 union ixgbe_atr_hash_dword input,
1513 union ixgbe_atr_hash_dword common, 1528 union ixgbe_atr_hash_dword common,
1514 u8 queue) 1529 u8 queue)
1515{ 1530{
1516 u64 fdirhashcmd; 1531 u64 fdirhashcmd;
1517 u32 fdircmd; 1532 u8 flow_type;
1533 bool tunnel;
1534 u32 fdircmd;
1518 1535
1519 /* 1536 /*
1520 * Get the flow_type in order to program FDIRCMD properly 1537 * Get the flow_type in order to program FDIRCMD properly
1521 * lowest 2 bits are FDIRCMD.L4TYPE, third lowest bit is FDIRCMD.IPV6 1538 * lowest 2 bits are FDIRCMD.L4TYPE, third lowest bit is FDIRCMD.IPV6
1522 */ 1539 */
1523 switch (input.formatted.flow_type) { 1540 tunnel = !!(input.formatted.flow_type & IXGBE_ATR_L4TYPE_TUNNEL_MASK);
1541 flow_type = input.formatted.flow_type &
1542 (IXGBE_ATR_L4TYPE_TUNNEL_MASK - 1);
1543 switch (flow_type) {
1524 case IXGBE_ATR_FLOW_TYPE_TCPV4: 1544 case IXGBE_ATR_FLOW_TYPE_TCPV4:
1525 case IXGBE_ATR_FLOW_TYPE_UDPV4: 1545 case IXGBE_ATR_FLOW_TYPE_UDPV4:
1526 case IXGBE_ATR_FLOW_TYPE_SCTPV4: 1546 case IXGBE_ATR_FLOW_TYPE_SCTPV4:
@@ -1536,8 +1556,10 @@ s32 ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw,
1536 /* configure FDIRCMD register */ 1556 /* configure FDIRCMD register */
1537 fdircmd = IXGBE_FDIRCMD_CMD_ADD_FLOW | IXGBE_FDIRCMD_FILTER_UPDATE | 1557 fdircmd = IXGBE_FDIRCMD_CMD_ADD_FLOW | IXGBE_FDIRCMD_FILTER_UPDATE |
1538 IXGBE_FDIRCMD_LAST | IXGBE_FDIRCMD_QUEUE_EN; 1558 IXGBE_FDIRCMD_LAST | IXGBE_FDIRCMD_QUEUE_EN;
1539 fdircmd |= input.formatted.flow_type << IXGBE_FDIRCMD_FLOW_TYPE_SHIFT; 1559 fdircmd |= (u32)flow_type << IXGBE_FDIRCMD_FLOW_TYPE_SHIFT;
1540 fdircmd |= (u32)queue << IXGBE_FDIRCMD_RX_QUEUE_SHIFT; 1560 fdircmd |= (u32)queue << IXGBE_FDIRCMD_RX_QUEUE_SHIFT;
1561 if (tunnel)
1562 fdircmd |= IXGBE_FDIRCMD_TUNNEL_FILTER;
1541 1563
1542 /* 1564 /*
1543 * The lower 32-bits of fdirhashcmd is for FDIRHASH, the upper 32-bits 1565 * The lower 32-bits of fdirhashcmd is for FDIRHASH, the upper 32-bits
@@ -1758,6 +1780,7 @@ s32 ixgbe_fdir_write_perfect_filter_82599(struct ixgbe_hw *hw,
1758 u16 soft_id, u8 queue) 1780 u16 soft_id, u8 queue)
1759{ 1781{
1760 u32 fdirport, fdirvlan, fdirhash, fdircmd; 1782 u32 fdirport, fdirvlan, fdirhash, fdircmd;
1783 s32 err;
1761 1784
1762 /* currently IPv6 is not supported, must be programmed with 0 */ 1785 /* currently IPv6 is not supported, must be programmed with 0 */
1763 IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRSIPv6(0), 1786 IXGBE_WRITE_REG_BE32(hw, IXGBE_FDIRSIPv6(0),
@@ -1806,6 +1829,11 @@ s32 ixgbe_fdir_write_perfect_filter_82599(struct ixgbe_hw *hw,
1806 fdircmd |= (u32)input->formatted.vm_pool << IXGBE_FDIRCMD_VT_POOL_SHIFT; 1829 fdircmd |= (u32)input->formatted.vm_pool << IXGBE_FDIRCMD_VT_POOL_SHIFT;
1807 1830
1808 IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD, fdircmd); 1831 IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD, fdircmd);
1832 err = ixgbe_fdir_check_cmd_complete(hw, &fdircmd);
1833 if (err) {
1834 hw_dbg(hw, "Flow Director command did not complete!\n");
1835 return err;
1836 }
1809 1837
1810 return 0; 1838 return 0;
1811} 1839}
@@ -1815,9 +1843,8 @@ s32 ixgbe_fdir_erase_perfect_filter_82599(struct ixgbe_hw *hw,
1815 u16 soft_id) 1843 u16 soft_id)
1816{ 1844{
1817 u32 fdirhash; 1845 u32 fdirhash;
1818 u32 fdircmd = 0; 1846 u32 fdircmd;
1819 u32 retry_count; 1847 s32 err;
1820 s32 err = 0;
1821 1848
1822 /* configure FDIRHASH register */ 1849 /* configure FDIRHASH register */
1823 fdirhash = input->formatted.bkt_hash; 1850 fdirhash = input->formatted.bkt_hash;
@@ -1830,18 +1857,12 @@ s32 ixgbe_fdir_erase_perfect_filter_82599(struct ixgbe_hw *hw,
1830 /* Query if filter is present */ 1857 /* Query if filter is present */
1831 IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD, IXGBE_FDIRCMD_CMD_QUERY_REM_FILT); 1858 IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD, IXGBE_FDIRCMD_CMD_QUERY_REM_FILT);
1832 1859
1833 for (retry_count = 10; retry_count; retry_count--) { 1860 err = ixgbe_fdir_check_cmd_complete(hw, &fdircmd);
1834 /* allow 10us for query to process */ 1861 if (err) {
1835 udelay(10); 1862 hw_dbg(hw, "Flow Director command did not complete!\n");
1836 /* verify query completed successfully */ 1863 return err;
1837 fdircmd = IXGBE_READ_REG(hw, IXGBE_FDIRCMD);
1838 if (!(fdircmd & IXGBE_FDIRCMD_CMD_MASK))
1839 break;
1840 } 1864 }
1841 1865
1842 if (!retry_count)
1843 err = IXGBE_ERR_FDIR_REINIT_FAILED;
1844
1845 /* if filter exists in hardware then remove it */ 1866 /* if filter exists in hardware then remove it */
1846 if (fdircmd & IXGBE_FDIRCMD_FILTER_VALID) { 1867 if (fdircmd & IXGBE_FDIRCMD_FILTER_VALID) {
1847 IXGBE_WRITE_REG(hw, IXGBE_FDIRHASH, fdirhash); 1868 IXGBE_WRITE_REG(hw, IXGBE_FDIRHASH, fdirhash);
@@ -1850,7 +1871,7 @@ s32 ixgbe_fdir_erase_perfect_filter_82599(struct ixgbe_hw *hw,
1850 IXGBE_FDIRCMD_CMD_REMOVE_FLOW); 1871 IXGBE_FDIRCMD_CMD_REMOVE_FLOW);
1851 } 1872 }
1852 1873
1853 return err; 1874 return 0;
1854} 1875}
1855 1876
1856/** 1877/**
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
index 4c1c26732b67..3f56a8080118 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
@@ -3905,3 +3905,18 @@ void ixgbe_enable_rx_generic(struct ixgbe_hw *hw)
3905 } 3905 }
3906 } 3906 }
3907} 3907}
3908
3909/** ixgbe_mng_present - returns true when management capability is present
3910 * @hw: pointer to hardware structure
3911 **/
3912bool ixgbe_mng_present(struct ixgbe_hw *hw)
3913{
3914 u32 fwsm;
3915
3916 if (hw->mac.type < ixgbe_mac_82599EB)
3917 return false;
3918
3919 fwsm = IXGBE_READ_REG(hw, IXGBE_FWSM(hw));
3920 fwsm &= IXGBE_FWSM_MODE_MASK;
3921 return fwsm == IXGBE_FWSM_FW_MODE_PT;
3922}
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
index ec015fed8fa7..2f779f35dc4f 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h
@@ -113,6 +113,7 @@ s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 maj, u8 min,
113s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer, 113s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer,
114 u32 length, u32 timeout, bool return_data); 114 u32 length, u32 timeout, bool return_data);
115void ixgbe_clear_tx_pending(struct ixgbe_hw *hw); 115void ixgbe_clear_tx_pending(struct ixgbe_hw *hw);
116bool ixgbe_mng_present(struct ixgbe_hw *hw);
116bool ixgbe_mng_enabled(struct ixgbe_hw *hw); 117bool ixgbe_mng_enabled(struct ixgbe_hw *hw);
117 118
118void ixgbe_set_rxpba_generic(struct ixgbe_hw *hw, int num_pb, 119void ixgbe_set_rxpba_generic(struct ixgbe_hw *hw, int num_pb,
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index f7aeb560a504..ab2edc8e7703 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -166,6 +166,8 @@ static int ixgbe_get_settings(struct net_device *netdev,
166 /* set the supported link speeds */ 166 /* set the supported link speeds */
167 if (supported_link & IXGBE_LINK_SPEED_10GB_FULL) 167 if (supported_link & IXGBE_LINK_SPEED_10GB_FULL)
168 ecmd->supported |= SUPPORTED_10000baseT_Full; 168 ecmd->supported |= SUPPORTED_10000baseT_Full;
169 if (supported_link & IXGBE_LINK_SPEED_2_5GB_FULL)
170 ecmd->supported |= SUPPORTED_2500baseX_Full;
169 if (supported_link & IXGBE_LINK_SPEED_1GB_FULL) 171 if (supported_link & IXGBE_LINK_SPEED_1GB_FULL)
170 ecmd->supported |= SUPPORTED_1000baseT_Full; 172 ecmd->supported |= SUPPORTED_1000baseT_Full;
171 if (supported_link & IXGBE_LINK_SPEED_100_FULL) 173 if (supported_link & IXGBE_LINK_SPEED_100_FULL)
@@ -177,6 +179,8 @@ static int ixgbe_get_settings(struct net_device *netdev,
177 ecmd->advertising |= ADVERTISED_100baseT_Full; 179 ecmd->advertising |= ADVERTISED_100baseT_Full;
178 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL) 180 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
179 ecmd->advertising |= ADVERTISED_10000baseT_Full; 181 ecmd->advertising |= ADVERTISED_10000baseT_Full;
182 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_2_5GB_FULL)
183 ecmd->advertising |= ADVERTISED_2500baseX_Full;
180 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL) 184 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
181 ecmd->advertising |= ADVERTISED_1000baseT_Full; 185 ecmd->advertising |= ADVERTISED_1000baseT_Full;
182 } else { 186 } else {
@@ -286,6 +290,9 @@ static int ixgbe_get_settings(struct net_device *netdev,
286 case IXGBE_LINK_SPEED_10GB_FULL: 290 case IXGBE_LINK_SPEED_10GB_FULL:
287 ethtool_cmd_speed_set(ecmd, SPEED_10000); 291 ethtool_cmd_speed_set(ecmd, SPEED_10000);
288 break; 292 break;
293 case IXGBE_LINK_SPEED_2_5GB_FULL:
294 ethtool_cmd_speed_set(ecmd, SPEED_2500);
295 break;
289 case IXGBE_LINK_SPEED_1GB_FULL: 296 case IXGBE_LINK_SPEED_1GB_FULL:
290 ethtool_cmd_speed_set(ecmd, SPEED_1000); 297 ethtool_cmd_speed_set(ecmd, SPEED_1000);
291 break; 298 break;
@@ -2868,6 +2875,14 @@ static int ixgbe_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)
2868 return ret; 2875 return ret;
2869} 2876}
2870 2877
2878static int ixgbe_rss_indir_tbl_max(struct ixgbe_adapter *adapter)
2879{
2880 if (adapter->hw.mac.type < ixgbe_mac_X550)
2881 return 16;
2882 else
2883 return 64;
2884}
2885
2871static u32 ixgbe_get_rxfh_key_size(struct net_device *netdev) 2886static u32 ixgbe_get_rxfh_key_size(struct net_device *netdev)
2872{ 2887{
2873 struct ixgbe_adapter *adapter = netdev_priv(netdev); 2888 struct ixgbe_adapter *adapter = netdev_priv(netdev);
@@ -2907,6 +2922,44 @@ static int ixgbe_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,
2907 return 0; 2922 return 0;
2908} 2923}
2909 2924
2925static int ixgbe_set_rxfh(struct net_device *netdev, const u32 *indir,
2926 const u8 *key, const u8 hfunc)
2927{
2928 struct ixgbe_adapter *adapter = netdev_priv(netdev);
2929 int i;
2930 u32 reta_entries = ixgbe_rss_indir_tbl_entries(adapter);
2931
2932 if (hfunc)
2933 return -EINVAL;
2934
2935 /* Fill out the redirection table */
2936 if (indir) {
2937 int max_queues = min_t(int, adapter->num_rx_queues,
2938 ixgbe_rss_indir_tbl_max(adapter));
2939
2940 /*Allow at least 2 queues w/ SR-IOV.*/
2941 if ((adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) &&
2942 (max_queues < 2))
2943 max_queues = 2;
2944
2945 /* Verify user input. */
2946 for (i = 0; i < reta_entries; i++)
2947 if (indir[i] >= max_queues)
2948 return -EINVAL;
2949
2950 for (i = 0; i < reta_entries; i++)
2951 adapter->rss_indir_tbl[i] = indir[i];
2952 }
2953
2954 /* Fill out the rss hash key */
2955 if (key)
2956 memcpy(adapter->rss_key, key, ixgbe_get_rxfh_key_size(netdev));
2957
2958 ixgbe_store_reta(adapter);
2959
2960 return 0;
2961}
2962
2910static int ixgbe_get_ts_info(struct net_device *dev, 2963static int ixgbe_get_ts_info(struct net_device *dev,
2911 struct ethtool_ts_info *info) 2964 struct ethtool_ts_info *info)
2912{ 2965{
@@ -3159,6 +3212,7 @@ static const struct ethtool_ops ixgbe_ethtool_ops = {
3159 .get_rxfh_indir_size = ixgbe_rss_indir_size, 3212 .get_rxfh_indir_size = ixgbe_rss_indir_size,
3160 .get_rxfh_key_size = ixgbe_get_rxfh_key_size, 3213 .get_rxfh_key_size = ixgbe_get_rxfh_key_size,
3161 .get_rxfh = ixgbe_get_rxfh, 3214 .get_rxfh = ixgbe_get_rxfh,
3215 .set_rxfh = ixgbe_set_rxfh,
3162 .get_channels = ixgbe_get_channels, 3216 .get_channels = ixgbe_get_channels,
3163 .set_channels = ixgbe_set_channels, 3217 .set_channels = ixgbe_set_channels,
3164 .get_ts_info = ixgbe_get_ts_info, 3218 .get_ts_info = ixgbe_get_ts_info,
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index ab28dc2c3798..63b2cfe9416b 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel 10 Gigabit PCI Express Linux driver 3 Intel 10 Gigabit PCI Express Linux driver
4 Copyright(c) 1999 - 2014 Intel Corporation. 4 Copyright(c) 1999 - 2015 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -65,6 +65,9 @@
65#include "ixgbe_common.h" 65#include "ixgbe_common.h"
66#include "ixgbe_dcb_82599.h" 66#include "ixgbe_dcb_82599.h"
67#include "ixgbe_sriov.h" 67#include "ixgbe_sriov.h"
68#ifdef CONFIG_IXGBE_VXLAN
69#include <net/vxlan.h>
70#endif
68 71
69char ixgbe_driver_name[] = "ixgbe"; 72char ixgbe_driver_name[] = "ixgbe";
70static const char ixgbe_driver_string[] = 73static const char ixgbe_driver_string[] =
@@ -79,7 +82,7 @@ static char ixgbe_default_device_descr[] =
79#define DRV_VERSION "4.0.1-k" 82#define DRV_VERSION "4.0.1-k"
80const char ixgbe_driver_version[] = DRV_VERSION; 83const char ixgbe_driver_version[] = DRV_VERSION;
81static const char ixgbe_copyright[] = 84static const char ixgbe_copyright[] =
82 "Copyright (c) 1999-2014 Intel Corporation."; 85 "Copyright (c) 1999-2015 Intel Corporation.";
83 86
84static const char ixgbe_overheat_msg[] = "Network adapter has been stopped because it has over heated. Restart the computer. If the problem persists, power off the system and replace the adapter"; 87static const char ixgbe_overheat_msg[] = "Network adapter has been stopped because it has over heated. Restart the computer. If the problem persists, power off the system and replace the adapter";
85 88
@@ -243,11 +246,19 @@ static inline bool ixgbe_pcie_from_parent(struct ixgbe_hw *hw)
243static void ixgbe_check_minimum_link(struct ixgbe_adapter *adapter, 246static void ixgbe_check_minimum_link(struct ixgbe_adapter *adapter,
244 int expected_gts) 247 int expected_gts)
245{ 248{
249 struct ixgbe_hw *hw = &adapter->hw;
246 int max_gts = 0; 250 int max_gts = 0;
247 enum pci_bus_speed speed = PCI_SPEED_UNKNOWN; 251 enum pci_bus_speed speed = PCI_SPEED_UNKNOWN;
248 enum pcie_link_width width = PCIE_LNK_WIDTH_UNKNOWN; 252 enum pcie_link_width width = PCIE_LNK_WIDTH_UNKNOWN;
249 struct pci_dev *pdev; 253 struct pci_dev *pdev;
250 254
255 /* Some devices are not connected over PCIe and thus do not negotiate
256 * speed. These devices do not have valid bus info, and thus any report
257 * we generate may not be correct.
258 */
259 if (hw->bus.type == ixgbe_bus_type_internal)
260 return;
261
251 /* determine whether to use the parent device */ 262 /* determine whether to use the parent device */
252 if (ixgbe_pcie_from_parent(&adapter->hw)) 263 if (ixgbe_pcie_from_parent(&adapter->hw))
253 pdev = adapter->pdev->bus->parent->self; 264 pdev = adapter->pdev->bus->parent->self;
@@ -1430,7 +1441,6 @@ static inline void ixgbe_rx_checksum(struct ixgbe_ring *ring,
1430 (hdr_info & cpu_to_le16(IXGBE_RXDADV_PKTTYPE_TUNNEL >> 16))) { 1441 (hdr_info & cpu_to_le16(IXGBE_RXDADV_PKTTYPE_TUNNEL >> 16))) {
1431 encap_pkt = true; 1442 encap_pkt = true;
1432 skb->encapsulation = 1; 1443 skb->encapsulation = 1;
1433 skb->ip_summed = CHECKSUM_NONE;
1434 } 1444 }
1435 1445
1436 /* if IP and error */ 1446 /* if IP and error */
@@ -3303,7 +3313,7 @@ u32 ixgbe_rss_indir_tbl_entries(struct ixgbe_adapter *adapter)
3303 * 3313 *
3304 * Write the RSS redirection table stored in adapter.rss_indir_tbl[] to HW. 3314 * Write the RSS redirection table stored in adapter.rss_indir_tbl[] to HW.
3305 */ 3315 */
3306static void ixgbe_store_reta(struct ixgbe_adapter *adapter) 3316void ixgbe_store_reta(struct ixgbe_adapter *adapter)
3307{ 3317{
3308 u32 i, reta_entries = ixgbe_rss_indir_tbl_entries(adapter); 3318 u32 i, reta_entries = ixgbe_rss_indir_tbl_entries(adapter);
3309 struct ixgbe_hw *hw = &adapter->hw; 3319 struct ixgbe_hw *hw = &adapter->hw;
@@ -4261,6 +4271,21 @@ static void ixgbe_napi_disable_all(struct ixgbe_adapter *adapter)
4261 } 4271 }
4262} 4272}
4263 4273
4274static void ixgbe_clear_vxlan_port(struct ixgbe_adapter *adapter)
4275{
4276 switch (adapter->hw.mac.type) {
4277 case ixgbe_mac_X550:
4278 case ixgbe_mac_X550EM_x:
4279 IXGBE_WRITE_REG(&adapter->hw, IXGBE_VXLANCTRL, 0);
4280#ifdef CONFIG_IXGBE_VXLAN
4281 adapter->vxlan_port = 0;
4282#endif
4283 break;
4284 default:
4285 break;
4286 }
4287}
4288
4264#ifdef CONFIG_IXGBE_DCB 4289#ifdef CONFIG_IXGBE_DCB
4265/** 4290/**
4266 * ixgbe_configure_dcb - Configure DCB hardware 4291 * ixgbe_configure_dcb - Configure DCB hardware
@@ -5302,6 +5327,9 @@ static int ixgbe_sw_init(struct ixgbe_adapter *adapter)
5302#ifdef CONFIG_IXGBE_DCA 5327#ifdef CONFIG_IXGBE_DCA
5303 adapter->flags &= ~IXGBE_FLAG_DCA_CAPABLE; 5328 adapter->flags &= ~IXGBE_FLAG_DCA_CAPABLE;
5304#endif 5329#endif
5330#ifdef CONFIG_IXGBE_VXLAN
5331 adapter->flags |= IXGBE_FLAG_VXLAN_OFFLOAD_CAPABLE;
5332#endif
5305 break; 5333 break;
5306 default: 5334 default:
5307 break; 5335 break;
@@ -5753,10 +5781,11 @@ static int ixgbe_open(struct net_device *netdev)
5753 5781
5754 ixgbe_up_complete(adapter); 5782 ixgbe_up_complete(adapter);
5755 5783
5756#if IS_ENABLED(CONFIG_IXGBE_VXLAN) 5784 ixgbe_clear_vxlan_port(adapter);
5785#ifdef CONFIG_IXGBE_VXLAN
5757 vxlan_get_rx_port(netdev); 5786 vxlan_get_rx_port(netdev);
5758
5759#endif 5787#endif
5788
5760 return 0; 5789 return 0;
5761 5790
5762err_set_queues: 5791err_set_queues:
@@ -5777,7 +5806,15 @@ static void ixgbe_close_suspend(struct ixgbe_adapter *adapter)
5777{ 5806{
5778 ixgbe_ptp_suspend(adapter); 5807 ixgbe_ptp_suspend(adapter);
5779 5808
5780 ixgbe_down(adapter); 5809 if (adapter->hw.phy.ops.enter_lplu) {
5810 adapter->hw.phy.reset_disable = true;
5811 ixgbe_down(adapter);
5812 adapter->hw.phy.ops.enter_lplu(&adapter->hw);
5813 adapter->hw.phy.reset_disable = false;
5814 } else {
5815 ixgbe_down(adapter);
5816 }
5817
5781 ixgbe_free_irq(adapter); 5818 ixgbe_free_irq(adapter);
5782 5819
5783 ixgbe_free_all_tx_resources(adapter); 5820 ixgbe_free_all_tx_resources(adapter);
@@ -6343,6 +6380,7 @@ static void ixgbe_watchdog_link_is_up(struct ixgbe_adapter *adapter)
6343 struct net_device *upper; 6380 struct net_device *upper;
6344 struct list_head *iter; 6381 struct list_head *iter;
6345 u32 link_speed = adapter->link_speed; 6382 u32 link_speed = adapter->link_speed;
6383 const char *speed_str;
6346 bool flow_rx, flow_tx; 6384 bool flow_rx, flow_tx;
6347 6385
6348 /* only continue if link was previously down */ 6386 /* only continue if link was previously down */
@@ -6380,14 +6418,24 @@ static void ixgbe_watchdog_link_is_up(struct ixgbe_adapter *adapter)
6380 if (test_bit(__IXGBE_PTP_RUNNING, &adapter->state)) 6418 if (test_bit(__IXGBE_PTP_RUNNING, &adapter->state))
6381 ixgbe_ptp_start_cyclecounter(adapter); 6419 ixgbe_ptp_start_cyclecounter(adapter);
6382 6420
6383 e_info(drv, "NIC Link is Up %s, Flow Control: %s\n", 6421 switch (link_speed) {
6384 (link_speed == IXGBE_LINK_SPEED_10GB_FULL ? 6422 case IXGBE_LINK_SPEED_10GB_FULL:
6385 "10 Gbps" : 6423 speed_str = "10 Gbps";
6386 (link_speed == IXGBE_LINK_SPEED_1GB_FULL ? 6424 break;
6387 "1 Gbps" : 6425 case IXGBE_LINK_SPEED_2_5GB_FULL:
6388 (link_speed == IXGBE_LINK_SPEED_100_FULL ? 6426 speed_str = "2.5 Gbps";
6389 "100 Mbps" : 6427 break;
6390 "unknown speed"))), 6428 case IXGBE_LINK_SPEED_1GB_FULL:
6429 speed_str = "1 Gbps";
6430 break;
6431 case IXGBE_LINK_SPEED_100_FULL:
6432 speed_str = "100 Mbps";
6433 break;
6434 default:
6435 speed_str = "unknown speed";
6436 break;
6437 }
6438 e_info(drv, "NIC Link is Up %s, Flow Control: %s\n", speed_str,
6391 ((flow_rx && flow_tx) ? "RX/TX" : 6439 ((flow_rx && flow_tx) ? "RX/TX" :
6392 (flow_rx ? "RX" : 6440 (flow_rx ? "RX" :
6393 (flow_tx ? "TX" : "None")))); 6441 (flow_tx ? "TX" : "None"))));
@@ -6816,6 +6864,12 @@ static void ixgbe_service_task(struct work_struct *work)
6816 ixgbe_service_event_complete(adapter); 6864 ixgbe_service_event_complete(adapter);
6817 return; 6865 return;
6818 } 6866 }
6867#ifdef CONFIG_IXGBE_VXLAN
6868 if (adapter->flags2 & IXGBE_FLAG2_VXLAN_REREG_NEEDED) {
6869 adapter->flags2 &= ~IXGBE_FLAG2_VXLAN_REREG_NEEDED;
6870 vxlan_get_rx_port(adapter->netdev);
6871 }
6872#endif /* CONFIG_IXGBE_VXLAN */
6819 ixgbe_reset_subtask(adapter); 6873 ixgbe_reset_subtask(adapter);
6820 ixgbe_phy_interrupt_subtask(adapter); 6874 ixgbe_phy_interrupt_subtask(adapter);
6821 ixgbe_sfp_detection_subtask(adapter); 6875 ixgbe_sfp_detection_subtask(adapter);
@@ -6912,31 +6966,55 @@ static void ixgbe_tx_csum(struct ixgbe_ring *tx_ring,
6912 if (!(first->tx_flags & IXGBE_TX_FLAGS_HW_VLAN) && 6966 if (!(first->tx_flags & IXGBE_TX_FLAGS_HW_VLAN) &&
6913 !(first->tx_flags & IXGBE_TX_FLAGS_CC)) 6967 !(first->tx_flags & IXGBE_TX_FLAGS_CC))
6914 return; 6968 return;
6969 vlan_macip_lens = skb_network_offset(skb) <<
6970 IXGBE_ADVTXD_MACLEN_SHIFT;
6915 } else { 6971 } else {
6916 u8 l4_hdr = 0; 6972 u8 l4_hdr = 0;
6917 switch (first->protocol) { 6973 union {
6918 case htons(ETH_P_IP): 6974 struct iphdr *ipv4;
6919 vlan_macip_lens |= skb_network_header_len(skb); 6975 struct ipv6hdr *ipv6;
6976 u8 *raw;
6977 } network_hdr;
6978 union {
6979 struct tcphdr *tcphdr;
6980 u8 *raw;
6981 } transport_hdr;
6982
6983 if (skb->encapsulation) {
6984 network_hdr.raw = skb_inner_network_header(skb);
6985 transport_hdr.raw = skb_inner_transport_header(skb);
6986 vlan_macip_lens = skb_inner_network_offset(skb) <<
6987 IXGBE_ADVTXD_MACLEN_SHIFT;
6988 } else {
6989 network_hdr.raw = skb_network_header(skb);
6990 transport_hdr.raw = skb_transport_header(skb);
6991 vlan_macip_lens = skb_network_offset(skb) <<
6992 IXGBE_ADVTXD_MACLEN_SHIFT;
6993 }
6994
6995 /* use first 4 bits to determine IP version */
6996 switch (network_hdr.ipv4->version) {
6997 case IPVERSION:
6998 vlan_macip_lens |= transport_hdr.raw - network_hdr.raw;
6920 type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4; 6999 type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4;
6921 l4_hdr = ip_hdr(skb)->protocol; 7000 l4_hdr = network_hdr.ipv4->protocol;
6922 break; 7001 break;
6923 case htons(ETH_P_IPV6): 7002 case 6:
6924 vlan_macip_lens |= skb_network_header_len(skb); 7003 vlan_macip_lens |= transport_hdr.raw - network_hdr.raw;
6925 l4_hdr = ipv6_hdr(skb)->nexthdr; 7004 l4_hdr = network_hdr.ipv6->nexthdr;
6926 break; 7005 break;
6927 default: 7006 default:
6928 if (unlikely(net_ratelimit())) { 7007 if (unlikely(net_ratelimit())) {
6929 dev_warn(tx_ring->dev, 7008 dev_warn(tx_ring->dev,
6930 "partial checksum but proto=%x!\n", 7009 "partial checksum but version=%d\n",
6931 first->protocol); 7010 network_hdr.ipv4->version);
6932 } 7011 }
6933 break;
6934 } 7012 }
6935 7013
6936 switch (l4_hdr) { 7014 switch (l4_hdr) {
6937 case IPPROTO_TCP: 7015 case IPPROTO_TCP:
6938 type_tucmd |= IXGBE_ADVTXD_TUCMD_L4T_TCP; 7016 type_tucmd |= IXGBE_ADVTXD_TUCMD_L4T_TCP;
6939 mss_l4len_idx = tcp_hdrlen(skb) << 7017 mss_l4len_idx = (transport_hdr.tcphdr->doff * 4) <<
6940 IXGBE_ADVTXD_L4LEN_SHIFT; 7018 IXGBE_ADVTXD_L4LEN_SHIFT;
6941 break; 7019 break;
6942 case IPPROTO_SCTP: 7020 case IPPROTO_SCTP:
@@ -6962,7 +7040,6 @@ static void ixgbe_tx_csum(struct ixgbe_ring *tx_ring,
6962 } 7040 }
6963 7041
6964 /* vlan_macip_lens: MACLEN, VLAN tag */ 7042 /* vlan_macip_lens: MACLEN, VLAN tag */
6965 vlan_macip_lens |= skb_network_offset(skb) << IXGBE_ADVTXD_MACLEN_SHIFT;
6966 vlan_macip_lens |= first->tx_flags & IXGBE_TX_FLAGS_VLAN_MASK; 7043 vlan_macip_lens |= first->tx_flags & IXGBE_TX_FLAGS_VLAN_MASK;
6967 7044
6968 ixgbe_tx_ctxtdesc(tx_ring, vlan_macip_lens, 0, 7045 ixgbe_tx_ctxtdesc(tx_ring, vlan_macip_lens, 0,
@@ -7217,6 +7294,10 @@ static void ixgbe_atr(struct ixgbe_ring *ring,
7217 struct ipv6hdr *ipv6; 7294 struct ipv6hdr *ipv6;
7218 } hdr; 7295 } hdr;
7219 struct tcphdr *th; 7296 struct tcphdr *th;
7297 struct sk_buff *skb;
7298#ifdef CONFIG_IXGBE_VXLAN
7299 u8 encap = false;
7300#endif /* CONFIG_IXGBE_VXLAN */
7220 __be16 vlan_id; 7301 __be16 vlan_id;
7221 7302
7222 /* if ring doesn't have a interrupt vector, cannot perform ATR */ 7303 /* if ring doesn't have a interrupt vector, cannot perform ATR */
@@ -7230,16 +7311,36 @@ static void ixgbe_atr(struct ixgbe_ring *ring,
7230 ring->atr_count++; 7311 ring->atr_count++;
7231 7312
7232 /* snag network header to get L4 type and address */ 7313 /* snag network header to get L4 type and address */
7233 hdr.network = skb_network_header(first->skb); 7314 skb = first->skb;
7315 hdr.network = skb_network_header(skb);
7316 if (skb->encapsulation) {
7317#ifdef CONFIG_IXGBE_VXLAN
7318 struct ixgbe_adapter *adapter = q_vector->adapter;
7234 7319
7235 /* Currently only IPv4/IPv6 with TCP is supported */ 7320 if (!adapter->vxlan_port)
7236 if ((first->protocol != htons(ETH_P_IPV6) || 7321 return;
7237 hdr.ipv6->nexthdr != IPPROTO_TCP) && 7322 if (first->protocol != htons(ETH_P_IP) ||
7238 (first->protocol != htons(ETH_P_IP) || 7323 hdr.ipv4->version != IPVERSION ||
7239 hdr.ipv4->protocol != IPPROTO_TCP)) 7324 hdr.ipv4->protocol != IPPROTO_UDP) {
7325 return;
7326 }
7327 if (ntohs(udp_hdr(skb)->dest) != adapter->vxlan_port)
7328 return;
7329 encap = true;
7330 hdr.network = skb_inner_network_header(skb);
7331 th = inner_tcp_hdr(skb);
7332#else
7240 return; 7333 return;
7241 7334#endif /* CONFIG_IXGBE_VXLAN */
7242 th = tcp_hdr(first->skb); 7335 } else {
7336 /* Currently only IPv4/IPv6 with TCP is supported */
7337 if ((first->protocol != htons(ETH_P_IPV6) ||
7338 hdr.ipv6->nexthdr != IPPROTO_TCP) &&
7339 (first->protocol != htons(ETH_P_IP) ||
7340 hdr.ipv4->protocol != IPPROTO_TCP))
7341 return;
7342 th = tcp_hdr(skb);
7343 }
7243 7344
7244 /* skip this packet since it is invalid or the socket is closing */ 7345 /* skip this packet since it is invalid or the socket is closing */
7245 if (!th || th->fin) 7346 if (!th || th->fin)
@@ -7288,6 +7389,11 @@ static void ixgbe_atr(struct ixgbe_ring *ring,
7288 hdr.ipv6->daddr.s6_addr32[3]; 7389 hdr.ipv6->daddr.s6_addr32[3];
7289 } 7390 }
7290 7391
7392#ifdef CONFIG_IXGBE_VXLAN
7393 if (encap)
7394 input.formatted.flow_type |= IXGBE_ATR_L4TYPE_TUNNEL_MASK;
7395#endif /* CONFIG_IXGBE_VXLAN */
7396
7291 /* This assumes the Rx queue and Tx queue are bound to the same CPU */ 7397 /* This assumes the Rx queue and Tx queue are bound to the same CPU */
7292 ixgbe_fdir_add_signature_filter_82599(&q_vector->adapter->hw, 7398 ixgbe_fdir_add_signature_filter_82599(&q_vector->adapter->hw,
7293 input, common, ring->queue_index); 7399 input, common, ring->queue_index);
@@ -7753,9 +7859,10 @@ int ixgbe_setup_tc(struct net_device *dev, u8 tc)
7753 bool pools; 7859 bool pools;
7754 7860
7755 /* Hardware supports up to 8 traffic classes */ 7861 /* Hardware supports up to 8 traffic classes */
7756 if (tc > adapter->dcb_cfg.num_tcs.pg_tcs || 7862 if (tc > adapter->dcb_cfg.num_tcs.pg_tcs)
7757 (hw->mac.type == ixgbe_mac_82598EB && 7863 return -EINVAL;
7758 tc < MAX_TRAFFIC_CLASS)) 7864
7865 if (hw->mac.type == ixgbe_mac_82598EB && tc && tc < MAX_TRAFFIC_CLASS)
7759 return -EINVAL; 7866 return -EINVAL;
7760 7867
7761 pools = (find_first_zero_bit(&adapter->fwd_bitmask, 32) > 1); 7868 pools = (find_first_zero_bit(&adapter->fwd_bitmask, 32) > 1);
@@ -7914,12 +8021,23 @@ static int ixgbe_set_features(struct net_device *netdev,
7914 need_reset = true; 8021 need_reset = true;
7915 8022
7916 netdev->features = features; 8023 netdev->features = features;
8024
8025#ifdef CONFIG_IXGBE_VXLAN
8026 if ((adapter->flags & IXGBE_FLAG_VXLAN_OFFLOAD_CAPABLE)) {
8027 if (features & NETIF_F_RXCSUM)
8028 adapter->flags2 |= IXGBE_FLAG2_VXLAN_REREG_NEEDED;
8029 else
8030 ixgbe_clear_vxlan_port(adapter);
8031 }
8032#endif /* CONFIG_IXGBE_VXLAN */
8033
7917 if (need_reset) 8034 if (need_reset)
7918 ixgbe_do_reset(netdev); 8035 ixgbe_do_reset(netdev);
7919 8036
7920 return 0; 8037 return 0;
7921} 8038}
7922 8039
8040#ifdef CONFIG_IXGBE_VXLAN
7923/** 8041/**
7924 * ixgbe_add_vxlan_port - Get notifications about VXLAN ports that come up 8042 * ixgbe_add_vxlan_port - Get notifications about VXLAN ports that come up
7925 * @dev: The port's netdev 8043 * @dev: The port's netdev
@@ -7933,17 +8051,18 @@ static void ixgbe_add_vxlan_port(struct net_device *dev, sa_family_t sa_family,
7933 struct ixgbe_hw *hw = &adapter->hw; 8051 struct ixgbe_hw *hw = &adapter->hw;
7934 u16 new_port = ntohs(port); 8052 u16 new_port = ntohs(port);
7935 8053
8054 if (!(adapter->flags & IXGBE_FLAG_VXLAN_OFFLOAD_CAPABLE))
8055 return;
8056
7936 if (sa_family == AF_INET6) 8057 if (sa_family == AF_INET6)
7937 return; 8058 return;
7938 8059
7939 if (adapter->vxlan_port == new_port) { 8060 if (adapter->vxlan_port == new_port)
7940 netdev_info(dev, "Port %d already offloaded\n", new_port);
7941 return; 8061 return;
7942 }
7943 8062
7944 if (adapter->vxlan_port) { 8063 if (adapter->vxlan_port) {
7945 netdev_info(dev, 8064 netdev_info(dev,
7946 "Hit Max num of UDP ports, not adding port %d\n", 8065 "Hit Max num of VXLAN ports, not adding port %d\n",
7947 new_port); 8066 new_port);
7948 return; 8067 return;
7949 } 8068 }
@@ -7962,9 +8081,11 @@ static void ixgbe_del_vxlan_port(struct net_device *dev, sa_family_t sa_family,
7962 __be16 port) 8081 __be16 port)
7963{ 8082{
7964 struct ixgbe_adapter *adapter = netdev_priv(dev); 8083 struct ixgbe_adapter *adapter = netdev_priv(dev);
7965 struct ixgbe_hw *hw = &adapter->hw;
7966 u16 new_port = ntohs(port); 8084 u16 new_port = ntohs(port);
7967 8085
8086 if (!(adapter->flags & IXGBE_FLAG_VXLAN_OFFLOAD_CAPABLE))
8087 return;
8088
7968 if (sa_family == AF_INET6) 8089 if (sa_family == AF_INET6)
7969 return; 8090 return;
7970 8091
@@ -7974,9 +8095,10 @@ static void ixgbe_del_vxlan_port(struct net_device *dev, sa_family_t sa_family,
7974 return; 8095 return;
7975 } 8096 }
7976 8097
7977 adapter->vxlan_port = 0; 8098 ixgbe_clear_vxlan_port(adapter);
7978 IXGBE_WRITE_REG(hw, IXGBE_VXLANCTRL, 0); 8099 adapter->flags2 |= IXGBE_FLAG2_VXLAN_REREG_NEEDED;
7979} 8100}
8101#endif /* CONFIG_IXGBE_VXLAN */
7980 8102
7981static int ixgbe_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], 8103static int ixgbe_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
7982 struct net_device *dev, 8104 struct net_device *dev,
@@ -8151,7 +8273,7 @@ static void *ixgbe_fwd_add(struct net_device *pdev, struct net_device *vdev)
8151 (adapter->num_rx_pools > IXGBE_MAX_MACVLANS)) 8273 (adapter->num_rx_pools > IXGBE_MAX_MACVLANS))
8152 return ERR_PTR(-EBUSY); 8274 return ERR_PTR(-EBUSY);
8153 8275
8154 fwd_adapter = kcalloc(1, sizeof(struct ixgbe_fwd_adapter), GFP_KERNEL); 8276 fwd_adapter = kzalloc(sizeof(*fwd_adapter), GFP_KERNEL);
8155 if (!fwd_adapter) 8277 if (!fwd_adapter)
8156 return ERR_PTR(-ENOMEM); 8278 return ERR_PTR(-ENOMEM);
8157 8279
@@ -8207,6 +8329,21 @@ static void ixgbe_fwd_del(struct net_device *pdev, void *priv)
8207 kfree(fwd_adapter); 8329 kfree(fwd_adapter);
8208} 8330}
8209 8331
8332#define IXGBE_MAX_TUNNEL_HDR_LEN 80
8333static netdev_features_t
8334ixgbe_features_check(struct sk_buff *skb, struct net_device *dev,
8335 netdev_features_t features)
8336{
8337 if (!skb->encapsulation)
8338 return features;
8339
8340 if (unlikely(skb_inner_mac_header(skb) - skb_transport_header(skb) >
8341 IXGBE_MAX_TUNNEL_HDR_LEN))
8342 return features & ~NETIF_F_ALL_CSUM;
8343
8344 return features;
8345}
8346
8210static const struct net_device_ops ixgbe_netdev_ops = { 8347static const struct net_device_ops ixgbe_netdev_ops = {
8211 .ndo_open = ixgbe_open, 8348 .ndo_open = ixgbe_open,
8212 .ndo_stop = ixgbe_close, 8349 .ndo_stop = ixgbe_close,
@@ -8252,8 +8389,11 @@ static const struct net_device_ops ixgbe_netdev_ops = {
8252 .ndo_bridge_getlink = ixgbe_ndo_bridge_getlink, 8389 .ndo_bridge_getlink = ixgbe_ndo_bridge_getlink,
8253 .ndo_dfwd_add_station = ixgbe_fwd_add, 8390 .ndo_dfwd_add_station = ixgbe_fwd_add,
8254 .ndo_dfwd_del_station = ixgbe_fwd_del, 8391 .ndo_dfwd_del_station = ixgbe_fwd_del,
8392#ifdef CONFIG_IXGBE_VXLAN
8255 .ndo_add_vxlan_port = ixgbe_add_vxlan_port, 8393 .ndo_add_vxlan_port = ixgbe_add_vxlan_port,
8256 .ndo_del_vxlan_port = ixgbe_del_vxlan_port, 8394 .ndo_del_vxlan_port = ixgbe_del_vxlan_port,
8395#endif /* CONFIG_IXGBE_VXLAN */
8396 .ndo_features_check = ixgbe_features_check,
8257}; 8397};
8258 8398
8259/** 8399/**
@@ -8613,17 +8753,24 @@ skip_sriov:
8613 netdev->vlan_features |= NETIF_F_IPV6_CSUM; 8753 netdev->vlan_features |= NETIF_F_IPV6_CSUM;
8614 netdev->vlan_features |= NETIF_F_SG; 8754 netdev->vlan_features |= NETIF_F_SG;
8615 8755
8756 netdev->hw_enc_features |= NETIF_F_SG | NETIF_F_IP_CSUM |
8757 NETIF_F_IPV6_CSUM;
8758
8616 netdev->priv_flags |= IFF_UNICAST_FLT; 8759 netdev->priv_flags |= IFF_UNICAST_FLT;
8617 netdev->priv_flags |= IFF_SUPP_NOFCS; 8760 netdev->priv_flags |= IFF_SUPP_NOFCS;
8618 8761
8762#ifdef CONFIG_IXGBE_VXLAN
8619 switch (adapter->hw.mac.type) { 8763 switch (adapter->hw.mac.type) {
8620 case ixgbe_mac_X550: 8764 case ixgbe_mac_X550:
8621 case ixgbe_mac_X550EM_x: 8765 case ixgbe_mac_X550EM_x:
8622 netdev->hw_enc_features |= NETIF_F_RXCSUM; 8766 netdev->hw_enc_features |= NETIF_F_RXCSUM |
8767 NETIF_F_IP_CSUM |
8768 NETIF_F_IPV6_CSUM;
8623 break; 8769 break;
8624 default: 8770 default:
8625 break; 8771 break;
8626 } 8772 }
8773#endif /* CONFIG_IXGBE_VXLAN */
8627 8774
8628#ifdef CONFIG_IXGBE_DCB 8775#ifdef CONFIG_IXGBE_DCB
8629 netdev->dcbnl_ops = &dcbnl_ops; 8776 netdev->dcbnl_ops = &dcbnl_ops;
@@ -8710,9 +8857,10 @@ skip_sriov:
8710 hw->eeprom.ops.read(hw, 0x2d, &adapter->eeprom_verl); 8857 hw->eeprom.ops.read(hw, 0x2d, &adapter->eeprom_verl);
8711 8858
8712 /* pick up the PCI bus settings for reporting later */ 8859 /* pick up the PCI bus settings for reporting later */
8713 hw->mac.ops.get_bus_info(hw);
8714 if (ixgbe_pcie_from_parent(hw)) 8860 if (ixgbe_pcie_from_parent(hw))
8715 ixgbe_get_parent_bus_info(adapter); 8861 ixgbe_get_parent_bus_info(adapter);
8862 else
8863 hw->mac.ops.get_bus_info(hw);
8716 8864
8717 /* calculate the expected PCIe bandwidth required for optimal 8865 /* calculate the expected PCIe bandwidth required for optimal
8718 * performance. Note that some older parts will never have enough 8866 * performance. Note that some older parts will never have enough
@@ -8875,12 +9023,7 @@ static void ixgbe_remove(struct pci_dev *pdev)
8875 unregister_netdev(netdev); 9023 unregister_netdev(netdev);
8876 9024
8877#ifdef CONFIG_PCI_IOV 9025#ifdef CONFIG_PCI_IOV
8878 /* 9026 ixgbe_disable_sriov(adapter);
8879 * Only disable SR-IOV on unload if the user specified the now
8880 * deprecated max_vfs module parameter.
8881 */
8882 if (max_vfs)
8883 ixgbe_disable_sriov(adapter);
8884#endif 9027#endif
8885 ixgbe_clear_interrupt_scheme(adapter); 9028 ixgbe_clear_interrupt_scheme(adapter);
8886 9029
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
index 526a20bf7488..597d0b1c2370 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c
@@ -243,9 +243,7 @@ s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw)
243 u16 ext_ability = 0; 243 u16 ext_ability = 0;
244 244
245 if (!hw->phy.phy_semaphore_mask) { 245 if (!hw->phy.phy_semaphore_mask) {
246 hw->phy.lan_id = IXGBE_READ_REG(hw, IXGBE_STATUS) & 246 if (hw->bus.lan_id)
247 IXGBE_STATUS_LAN_ID_1;
248 if (hw->phy.lan_id)
249 hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY1_SM; 247 hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY1_SM;
250 else 248 else
251 hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY0_SM; 249 hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY0_SM;
@@ -608,12 +606,7 @@ s32 ixgbe_write_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
608 u32 device_type, u16 phy_data) 606 u32 device_type, u16 phy_data)
609{ 607{
610 s32 status; 608 s32 status;
611 u32 gssr; 609 u32 gssr = hw->phy.phy_semaphore_mask;
612
613 if (IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1)
614 gssr = IXGBE_GSSR_PHY1_SM;
615 else
616 gssr = IXGBE_GSSR_PHY0_SM;
617 610
618 if (hw->mac.ops.acquire_swfw_sync(hw, gssr) == 0) { 611 if (hw->mac.ops.acquire_swfw_sync(hw, gssr) == 0) {
619 status = ixgbe_write_phy_reg_mdi(hw, reg_addr, device_type, 612 status = ixgbe_write_phy_reg_mdi(hw, reg_addr, device_type,
@@ -737,39 +730,61 @@ s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw,
737} 730}
738 731
739/** 732/**
740 * ixgbe_get_copper_link_capabilities_generic - Determines link capabilities 733 * ixgbe_get_copper_speeds_supported - Get copper link speed from phy
741 * @hw: pointer to hardware structure 734 * @hw: pointer to hardware structure
742 * @speed: pointer to link speed
743 * @autoneg: boolean auto-negotiation value
744 * 735 *
745 * Determines the link capabilities by reading the AUTOC register. 736 * Determines the supported link capabilities by reading the PHY auto
737 * negotiation register.
746 */ 738 */
747s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw, 739static s32 ixgbe_get_copper_speeds_supported(struct ixgbe_hw *hw)
748 ixgbe_link_speed *speed,
749 bool *autoneg)
750{ 740{
751 s32 status;
752 u16 speed_ability; 741 u16 speed_ability;
753 742 s32 status;
754 *speed = 0;
755 *autoneg = true;
756 743
757 status = hw->phy.ops.read_reg(hw, MDIO_SPEED, MDIO_MMD_PMAPMD, 744 status = hw->phy.ops.read_reg(hw, MDIO_SPEED, MDIO_MMD_PMAPMD,
758 &speed_ability); 745 &speed_ability);
746 if (status)
747 return status;
759 748
760 if (status == 0) { 749 if (speed_ability & MDIO_SPEED_10G)
761 if (speed_ability & MDIO_SPEED_10G) 750 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_10GB_FULL;
762 *speed |= IXGBE_LINK_SPEED_10GB_FULL; 751 if (speed_ability & MDIO_PMA_SPEED_1000)
763 if (speed_ability & MDIO_PMA_SPEED_1000) 752 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_1GB_FULL;
764 *speed |= IXGBE_LINK_SPEED_1GB_FULL; 753 if (speed_ability & MDIO_PMA_SPEED_100)
765 if (speed_ability & MDIO_PMA_SPEED_100) 754 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_100_FULL;
766 *speed |= IXGBE_LINK_SPEED_100_FULL; 755
756 switch (hw->mac.type) {
757 case ixgbe_mac_X550:
758 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_2_5GB_FULL;
759 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_5GB_FULL;
760 break;
761 case ixgbe_mac_X550EM_x:
762 hw->phy.speeds_supported &= ~IXGBE_LINK_SPEED_100_FULL;
763 break;
764 default:
765 break;
767 } 766 }
768 767
769 /* Internal PHY does not support 100 Mbps */ 768 return 0;
770 if (hw->mac.type == ixgbe_mac_X550EM_x) 769}
771 *speed &= ~IXGBE_LINK_SPEED_100_FULL; 770
771/**
772 * ixgbe_get_copper_link_capabilities_generic - Determines link capabilities
773 * @hw: pointer to hardware structure
774 * @speed: pointer to link speed
775 * @autoneg: boolean auto-negotiation value
776 */
777s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw,
778 ixgbe_link_speed *speed,
779 bool *autoneg)
780{
781 s32 status = 0;
782
783 *autoneg = true;
784 if (!hw->phy.speeds_supported)
785 status = ixgbe_get_copper_speeds_supported(hw);
772 786
787 *speed = hw->phy.speeds_supported;
773 return status; 788 return status;
774} 789}
775 790
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
index 4615a949381d..63689192b149 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
@@ -848,6 +848,7 @@ struct ixgbe_thermal_sensor_data {
848#define IXGBE_MDIO_AUTO_NEG_LINK_STATUS 0x4 /* Indicates if link is up */ 848#define IXGBE_MDIO_AUTO_NEG_LINK_STATUS 0x4 /* Indicates if link is up */
849 849
850#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_MASK 0x7 /* Speed/Duplex Mask */ 850#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_MASK 0x7 /* Speed/Duplex Mask */
851#define IXGBE_MDIO_AUTO_NEG_VEN_STAT_SPEED_MASK 0x6 /* Speed Mask */
851#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10M_HALF 0x0 /* 10Mb/s Half Duplex */ 852#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10M_HALF 0x0 /* 10Mb/s Half Duplex */
852#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10M_FULL 0x1 /* 10Mb/s Full Duplex */ 853#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10M_FULL 0x1 /* 10Mb/s Full Duplex */
853#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_100M_HALF 0x2 /* 100Mb/s H Duplex */ 854#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_100M_HALF 0x2 /* 100Mb/s H Duplex */
@@ -856,6 +857,24 @@ struct ixgbe_thermal_sensor_data {
856#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB_FULL 0x5 /* 1Gb/s Full Duplex */ 857#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB_FULL 0x5 /* 1Gb/s Full Duplex */
857#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB_HALF 0x6 /* 10Gb/s Half Duplex */ 858#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB_HALF 0x6 /* 10Gb/s Half Duplex */
858#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB_FULL 0x7 /* 10Gb/s Full Duplex */ 859#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB_FULL 0x7 /* 10Gb/s Full Duplex */
860#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB 0x4 /* 1Gb/s */
861#define IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB 0x6 /* 10Gb/s */
862
863#define IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG 0x20 /* 10G Control Reg */
864#define IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG 0xC400 /* 1G Provisioning 1 */
865#define IXGBE_MII_AUTONEG_XNP_TX_REG 0x17 /* 1G XNP Transmit */
866#define IXGBE_MII_AUTONEG_ADVERTISE_REG 0x10 /* 100M Advertisement */
867#define IXGBE_MII_10GBASE_T_ADVERTISE 0x1000 /* full duplex, bit:12*/
868#define IXGBE_MII_1GBASE_T_ADVERTISE_XNP_TX 0x4000 /* full duplex, bit:14*/
869#define IXGBE_MII_1GBASE_T_ADVERTISE 0x8000 /* full duplex, bit:15*/
870#define IXGBE_MII_2_5GBASE_T_ADVERTISE 0x0400
871#define IXGBE_MII_5GBASE_T_ADVERTISE 0x0800
872#define IXGBE_MII_100BASE_T_ADVERTISE 0x0100 /* full duplex, bit:8 */
873#define IXGBE_MII_100BASE_T_ADVERTISE_HALF 0x0080 /* half duplex, bit:7 */
874#define IXGBE_MII_RESTART 0x200
875#define IXGBE_MII_AUTONEG_COMPLETE 0x20
876#define IXGBE_MII_AUTONEG_LINK_UP 0x04
877#define IXGBE_MII_AUTONEG_REG 0x0
859 878
860/* Management */ 879/* Management */
861#define IXGBE_MAVTV(_i) (0x05010 + ((_i) * 4)) /* 8 of these (0-7) */ 880#define IXGBE_MAVTV(_i) (0x05010 + ((_i) * 4)) /* 8 of these (0-7) */
@@ -1305,6 +1324,7 @@ struct ixgbe_thermal_sensor_data {
1305#define IXGBE_MDIO_AUTO_NEG_CONTROL 0x0 /* AUTO_NEG Control Reg */ 1324#define IXGBE_MDIO_AUTO_NEG_CONTROL 0x0 /* AUTO_NEG Control Reg */
1306#define IXGBE_MDIO_AUTO_NEG_STATUS 0x1 /* AUTO_NEG Status Reg */ 1325#define IXGBE_MDIO_AUTO_NEG_STATUS 0x1 /* AUTO_NEG Status Reg */
1307#define IXGBE_MDIO_AUTO_NEG_VENDOR_STAT 0xC800 /* AUTO_NEG Vendor Status Reg */ 1326#define IXGBE_MDIO_AUTO_NEG_VENDOR_STAT 0xC800 /* AUTO_NEG Vendor Status Reg */
1327#define IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM 0xCC00 /* AUTO_NEG Vendor TX Reg */
1308#define IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM2 0xCC01 /* AUTO_NEG Vendor Tx Reg */ 1328#define IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM2 0xCC01 /* AUTO_NEG Vendor Tx Reg */
1309#define IXGBE_MDIO_AUTO_NEG_VEN_LSC 0x1 /* AUTO_NEG Vendor Tx LSC */ 1329#define IXGBE_MDIO_AUTO_NEG_VEN_LSC 0x1 /* AUTO_NEG Vendor Tx LSC */
1310#define IXGBE_MDIO_AUTO_NEG_ADVT 0x10 /* AUTO_NEG Advt Reg */ 1330#define IXGBE_MDIO_AUTO_NEG_ADVT 0x10 /* AUTO_NEG Advt Reg */
@@ -1312,7 +1332,8 @@ struct ixgbe_thermal_sensor_data {
1312#define IXGBE_MDIO_AUTO_NEG_EEE_ADVT 0x3C /* AUTO_NEG EEE Advt Reg */ 1332#define IXGBE_MDIO_AUTO_NEG_EEE_ADVT 0x3C /* AUTO_NEG EEE Advt Reg */
1313 1333
1314#define IXGBE_MDIO_PHY_SET_LOW_POWER_MODE 0x0800 /* Set low power mode */ 1334#define IXGBE_MDIO_PHY_SET_LOW_POWER_MODE 0x0800 /* Set low power mode */
1315 1335#define IXGBE_AUTO_NEG_LP_STATUS 0xE820 /* AUTO NEG Rx LP Status Reg */
1336#define IXGBE_AUTO_NEG_LP_1000BASE_CAP 0x8000 /* AUTO NEG Rx LP 1000BaseT */
1316#define IXGBE_MDIO_TX_VENDOR_ALARMS_3 0xCC02 /* Vendor Alarms 3 Reg */ 1337#define IXGBE_MDIO_TX_VENDOR_ALARMS_3 0xCC02 /* Vendor Alarms 3 Reg */
1317#define IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK 0x3 /* PHY Reset Complete Mask */ 1338#define IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK 0x3 /* PHY Reset Complete Mask */
1318#define IXGBE_MDIO_GLOBAL_RES_PR_10 0xC479 /* Global Resv Provisioning 10 Reg */ 1339#define IXGBE_MDIO_GLOBAL_RES_PR_10 0xC479 /* Global Resv Provisioning 10 Reg */
@@ -2041,6 +2062,11 @@ enum {
2041#define IXGBE_NVM_POLL_WRITE 1 /* Flag for polling for write complete */ 2062#define IXGBE_NVM_POLL_WRITE 1 /* Flag for polling for write complete */
2042#define IXGBE_NVM_POLL_READ 0 /* Flag for polling for read complete */ 2063#define IXGBE_NVM_POLL_READ 0 /* Flag for polling for read complete */
2043 2064
2065#define NVM_INIT_CTRL_3 0x38
2066#define NVM_INIT_CTRL_3_LPLU 0x8
2067#define NVM_INIT_CTRL_3_D10GMP_PORT0 0x40
2068#define NVM_INIT_CTRL_3_D10GMP_PORT1 0x100
2069
2044#define IXGBE_EEPROM_PAGE_SIZE_MAX 128 2070#define IXGBE_EEPROM_PAGE_SIZE_MAX 128
2045#define IXGBE_EEPROM_RD_BUFFER_MAX_COUNT 512 /* EEPROM words # read in burst */ 2071#define IXGBE_EEPROM_RD_BUFFER_MAX_COUNT 512 /* EEPROM words # read in burst */
2046#define IXGBE_EEPROM_WR_BUFFER_MAX_COUNT 256 /* EEPROM words # wr in burst */ 2072#define IXGBE_EEPROM_WR_BUFFER_MAX_COUNT 256 /* EEPROM words # wr in burst */
@@ -2540,9 +2566,11 @@ enum ixgbe_fdir_pballoc_type {
2540#define IXGBE_FDIRCMD_QUEUE_EN 0x00008000 2566#define IXGBE_FDIRCMD_QUEUE_EN 0x00008000
2541#define IXGBE_FDIRCMD_FLOW_TYPE_SHIFT 5 2567#define IXGBE_FDIRCMD_FLOW_TYPE_SHIFT 5
2542#define IXGBE_FDIRCMD_RX_QUEUE_SHIFT 16 2568#define IXGBE_FDIRCMD_RX_QUEUE_SHIFT 16
2569#define IXGBE_FDIRCMD_RX_TUNNEL_FILTER_SHIFT 23
2543#define IXGBE_FDIRCMD_VT_POOL_SHIFT 24 2570#define IXGBE_FDIRCMD_VT_POOL_SHIFT 24
2544#define IXGBE_FDIR_INIT_DONE_POLL 10 2571#define IXGBE_FDIR_INIT_DONE_POLL 10
2545#define IXGBE_FDIRCMD_CMD_POLL 10 2572#define IXGBE_FDIRCMD_CMD_POLL 10
2573#define IXGBE_FDIRCMD_TUNNEL_FILTER 0x00800000
2546 2574
2547#define IXGBE_FDIR_DROP_QUEUE 127 2575#define IXGBE_FDIR_DROP_QUEUE 127
2548 2576
@@ -2833,12 +2861,13 @@ typedef u32 ixgbe_link_speed;
2833#define IXGBE_ATR_SIGNATURE_HASH_KEY 0x174D3614 2861#define IXGBE_ATR_SIGNATURE_HASH_KEY 0x174D3614
2834 2862
2835/* Software ATR input stream values and masks */ 2863/* Software ATR input stream values and masks */
2836#define IXGBE_ATR_HASH_MASK 0x7fff 2864#define IXGBE_ATR_HASH_MASK 0x7fff
2837#define IXGBE_ATR_L4TYPE_MASK 0x3 2865#define IXGBE_ATR_L4TYPE_MASK 0x3
2838#define IXGBE_ATR_L4TYPE_UDP 0x1 2866#define IXGBE_ATR_L4TYPE_UDP 0x1
2839#define IXGBE_ATR_L4TYPE_TCP 0x2 2867#define IXGBE_ATR_L4TYPE_TCP 0x2
2840#define IXGBE_ATR_L4TYPE_SCTP 0x3 2868#define IXGBE_ATR_L4TYPE_SCTP 0x3
2841#define IXGBE_ATR_L4TYPE_IPV6_MASK 0x4 2869#define IXGBE_ATR_L4TYPE_IPV6_MASK 0x4
2870#define IXGBE_ATR_L4TYPE_TUNNEL_MASK 0x10
2842enum ixgbe_atr_flow_type { 2871enum ixgbe_atr_flow_type {
2843 IXGBE_ATR_FLOW_TYPE_IPV4 = 0x0, 2872 IXGBE_ATR_FLOW_TYPE_IPV4 = 0x0,
2844 IXGBE_ATR_FLOW_TYPE_UDPV4 = 0x1, 2873 IXGBE_ATR_FLOW_TYPE_UDPV4 = 0x1,
@@ -3035,9 +3064,8 @@ enum ixgbe_smart_speed {
3035/* PCI bus types */ 3064/* PCI bus types */
3036enum ixgbe_bus_type { 3065enum ixgbe_bus_type {
3037 ixgbe_bus_type_unknown = 0, 3066 ixgbe_bus_type_unknown = 0,
3038 ixgbe_bus_type_pci,
3039 ixgbe_bus_type_pcix,
3040 ixgbe_bus_type_pci_express, 3067 ixgbe_bus_type_pci_express,
3068 ixgbe_bus_type_internal,
3041 ixgbe_bus_type_reserved 3069 ixgbe_bus_type_reserved
3042}; 3070};
3043 3071
@@ -3298,6 +3326,7 @@ struct ixgbe_phy_operations {
3298 s32 (*write_i2c_combined)(struct ixgbe_hw *, u8 addr, u16 reg, u16 val); 3326 s32 (*write_i2c_combined)(struct ixgbe_hw *, u8 addr, u16 reg, u16 val);
3299 s32 (*check_overtemp)(struct ixgbe_hw *); 3327 s32 (*check_overtemp)(struct ixgbe_hw *);
3300 s32 (*set_phy_power)(struct ixgbe_hw *, bool on); 3328 s32 (*set_phy_power)(struct ixgbe_hw *, bool on);
3329 s32 (*enter_lplu)(struct ixgbe_hw *);
3301 s32 (*handle_lasi)(struct ixgbe_hw *hw); 3330 s32 (*handle_lasi)(struct ixgbe_hw *hw);
3302}; 3331};
3303 3332
@@ -3308,6 +3337,7 @@ struct ixgbe_eeprom_info {
3308 u16 word_size; 3337 u16 word_size;
3309 u16 address_bits; 3338 u16 address_bits;
3310 u16 word_page_size; 3339 u16 word_page_size;
3340 u16 ctrl_word_3;
3311}; 3341};
3312 3342
3313#define IXGBE_FLAGS_DOUBLE_RESET_REQUIRED 0x01 3343#define IXGBE_FLAGS_DOUBLE_RESET_REQUIRED 0x01
@@ -3351,10 +3381,10 @@ struct ixgbe_phy_info {
3351 bool sfp_setup_needed; 3381 bool sfp_setup_needed;
3352 u32 revision; 3382 u32 revision;
3353 enum ixgbe_media_type media_type; 3383 enum ixgbe_media_type media_type;
3354 u8 lan_id;
3355 u32 phy_semaphore_mask; 3384 u32 phy_semaphore_mask;
3356 bool reset_disable; 3385 bool reset_disable;
3357 ixgbe_autoneg_advertised autoneg_advertised; 3386 ixgbe_autoneg_advertised autoneg_advertised;
3387 ixgbe_link_speed speeds_supported;
3358 enum ixgbe_smart_speed smart_speed; 3388 enum ixgbe_smart_speed smart_speed;
3359 bool smart_speed_active; 3389 bool smart_speed_active;
3360 bool multispeed_fiber; 3390 bool multispeed_fiber;
@@ -3460,8 +3490,13 @@ struct ixgbe_info {
3460#define IXGBE_ERR_PBA_SECTION -31 3490#define IXGBE_ERR_PBA_SECTION -31
3461#define IXGBE_ERR_INVALID_ARGUMENT -32 3491#define IXGBE_ERR_INVALID_ARGUMENT -32
3462#define IXGBE_ERR_HOST_INTERFACE_COMMAND -33 3492#define IXGBE_ERR_HOST_INTERFACE_COMMAND -33
3493#define IXGBE_ERR_FDIR_CMD_INCOMPLETE -38
3463#define IXGBE_NOT_IMPLEMENTED 0x7FFFFFFF 3494#define IXGBE_NOT_IMPLEMENTED 0x7FFFFFFF
3464 3495
3496#define IXGBE_FUSES0_GROUP(_i) (0x11158 + ((_i) * 4))
3497#define IXGBE_FUSES0_300MHZ BIT(5)
3498#define IXGBE_FUSES0_REV1 BIT(6)
3499
3465#define IXGBE_KRM_PORT_CAR_GEN_CTRL(P) ((P) ? 0x8010 : 0x4010) 3500#define IXGBE_KRM_PORT_CAR_GEN_CTRL(P) ((P) ? 0x8010 : 0x4010)
3466#define IXGBE_KRM_LINK_CTRL_1(P) ((P) ? 0x820C : 0x420C) 3501#define IXGBE_KRM_LINK_CTRL_1(P) ((P) ? 0x820C : 0x420C)
3467#define IXGBE_KRM_DSP_TXFFE_STATE_4(P) ((P) ? 0x8634 : 0x4634) 3502#define IXGBE_KRM_DSP_TXFFE_STATE_4(P) ((P) ? 0x8634 : 0x4634)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c
index 032a5870abd1..4e758435ece8 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c
@@ -54,6 +54,11 @@ enum ixgbe_media_type ixgbe_get_media_type_X540(struct ixgbe_hw *hw)
54s32 ixgbe_get_invariants_X540(struct ixgbe_hw *hw) 54s32 ixgbe_get_invariants_X540(struct ixgbe_hw *hw)
55{ 55{
56 struct ixgbe_mac_info *mac = &hw->mac; 56 struct ixgbe_mac_info *mac = &hw->mac;
57 struct ixgbe_phy_info *phy = &hw->phy;
58
59 /* set_phy_power was set by default to NULL */
60 if (!ixgbe_mng_present(hw))
61 phy->ops.set_phy_power = ixgbe_set_copper_phy_power;
57 62
58 mac->mcft_size = IXGBE_X540_MC_TBL_SIZE; 63 mac->mcft_size = IXGBE_X540_MC_TBL_SIZE;
59 mac->vft_size = IXGBE_X540_VFT_TBL_SIZE; 64 mac->vft_size = IXGBE_X540_VFT_TBL_SIZE;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
index 7581da13e92a..9fe9445cd73b 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_x550.c
@@ -26,6 +26,20 @@
26#include "ixgbe_common.h" 26#include "ixgbe_common.h"
27#include "ixgbe_phy.h" 27#include "ixgbe_phy.h"
28 28
29static s32 ixgbe_get_invariants_X550_x(struct ixgbe_hw *hw)
30{
31 struct ixgbe_mac_info *mac = &hw->mac;
32 struct ixgbe_phy_info *phy = &hw->phy;
33
34 /* Start with X540 invariants, since so simular */
35 ixgbe_get_invariants_X540(hw);
36
37 if (mac->ops.get_media_type(hw) != ixgbe_media_type_copper)
38 phy->ops.set_phy_power = NULL;
39
40 return 0;
41}
42
29/** ixgbe_setup_mux_ctl - Setup ESDP register for I2C mux control 43/** ixgbe_setup_mux_ctl - Setup ESDP register for I2C mux control
30 * @hw: pointer to hardware structure 44 * @hw: pointer to hardware structure
31 **/ 45 **/
@@ -597,6 +611,24 @@ static s32 ixgbe_update_flash_X550(struct ixgbe_hw *hw)
597 return status; 611 return status;
598} 612}
599 613
614/**
615 * ixgbe_get_bus_info_X550em - Set PCI bus info
616 * @hw: pointer to hardware structure
617 *
618 * Sets bus link width and speed to unknown because X550em is
619 * not a PCI device.
620 **/
621static s32 ixgbe_get_bus_info_X550em(struct ixgbe_hw *hw)
622{
623 hw->bus.type = ixgbe_bus_type_internal;
624 hw->bus.width = ixgbe_bus_width_unknown;
625 hw->bus.speed = ixgbe_bus_speed_unknown;
626
627 hw->mac.ops.set_lan_id(hw);
628
629 return 0;
630}
631
600/** ixgbe_disable_rx_x550 - Disable RX unit 632/** ixgbe_disable_rx_x550 - Disable RX unit
601 * 633 *
602 * Enables the Rx DMA unit for x550 634 * Enables the Rx DMA unit for x550
@@ -1444,6 +1476,144 @@ static s32 ixgbe_reset_phy_t_X550em(struct ixgbe_hw *hw)
1444 return ixgbe_enable_lasi_ext_t_x550em(hw); 1476 return ixgbe_enable_lasi_ext_t_x550em(hw);
1445} 1477}
1446 1478
1479/** ixgbe_get_lcd_x550em - Determine lowest common denominator
1480 * @hw: pointer to hardware structure
1481 * @lcd_speed: pointer to lowest common link speed
1482 *
1483 * Determine lowest common link speed with link partner.
1484 **/
1485static s32 ixgbe_get_lcd_t_x550em(struct ixgbe_hw *hw,
1486 ixgbe_link_speed *lcd_speed)
1487{
1488 u16 an_lp_status;
1489 s32 status;
1490 u16 word = hw->eeprom.ctrl_word_3;
1491
1492 *lcd_speed = IXGBE_LINK_SPEED_UNKNOWN;
1493
1494 status = hw->phy.ops.read_reg(hw, IXGBE_AUTO_NEG_LP_STATUS,
1495 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1496 &an_lp_status);
1497 if (status)
1498 return status;
1499
1500 /* If link partner advertised 1G, return 1G */
1501 if (an_lp_status & IXGBE_AUTO_NEG_LP_1000BASE_CAP) {
1502 *lcd_speed = IXGBE_LINK_SPEED_1GB_FULL;
1503 return status;
1504 }
1505
1506 /* If 10G disabled for LPLU via NVM D10GMP, then return no valid LCD */
1507 if ((hw->bus.lan_id && (word & NVM_INIT_CTRL_3_D10GMP_PORT1)) ||
1508 (word & NVM_INIT_CTRL_3_D10GMP_PORT0))
1509 return status;
1510
1511 /* Link partner not capable of lower speeds, return 10G */
1512 *lcd_speed = IXGBE_LINK_SPEED_10GB_FULL;
1513 return status;
1514}
1515
1516/** ixgbe_enter_lplu_x550em - Transition to low power states
1517 * @hw: pointer to hardware structure
1518 *
1519 * Configures Low Power Link Up on transition to low power states
1520 * (from D0 to non-D0). Link is required to enter LPLU so avoid resetting
1521 * the X557 PHY immediately prior to entering LPLU.
1522 **/
1523static s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
1524{
1525 u16 an_10g_cntl_reg, autoneg_reg, speed;
1526 s32 status;
1527 ixgbe_link_speed lcd_speed;
1528 u32 save_autoneg;
1529 bool link_up;
1530
1531 /* SW LPLU not required on later HW revisions. */
1532 if (IXGBE_FUSES0_REV1 & IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0)))
1533 return 0;
1534
1535 /* If blocked by MNG FW, then don't restart AN */
1536 if (ixgbe_check_reset_blocked(hw))
1537 return 0;
1538
1539 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
1540 if (status)
1541 return status;
1542
1543 status = hw->eeprom.ops.read(hw, NVM_INIT_CTRL_3,
1544 &hw->eeprom.ctrl_word_3);
1545 if (status)
1546 return status;
1547
1548 /* If link is down, LPLU disabled in NVM, WoL disabled, or
1549 * manageability disabled, then force link down by entering
1550 * low power mode.
1551 */
1552 if (!link_up || !(hw->eeprom.ctrl_word_3 & NVM_INIT_CTRL_3_LPLU) ||
1553 !(hw->wol_enabled || ixgbe_mng_present(hw)))
1554 return ixgbe_set_copper_phy_power(hw, false);
1555
1556 /* Determine LCD */
1557 status = ixgbe_get_lcd_t_x550em(hw, &lcd_speed);
1558 if (status)
1559 return status;
1560
1561 /* If no valid LCD link speed, then force link down and exit. */
1562 if (lcd_speed == IXGBE_LINK_SPEED_UNKNOWN)
1563 return ixgbe_set_copper_phy_power(hw, false);
1564
1565 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
1566 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1567 &speed);
1568 if (status)
1569 return status;
1570
1571 /* If no link now, speed is invalid so take link down */
1572 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
1573 if (status)
1574 return ixgbe_set_copper_phy_power(hw, false);
1575
1576 /* clear everything but the speed bits */
1577 speed &= IXGBE_MDIO_AUTO_NEG_VEN_STAT_SPEED_MASK;
1578
1579 /* If current speed is already LCD, then exit. */
1580 if (((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB) &&
1581 (lcd_speed == IXGBE_LINK_SPEED_1GB_FULL)) ||
1582 ((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB) &&
1583 (lcd_speed == IXGBE_LINK_SPEED_10GB_FULL)))
1584 return status;
1585
1586 /* Clear AN completed indication */
1587 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM,
1588 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1589 &autoneg_reg);
1590 if (status)
1591 return status;
1592
1593 status = hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
1594 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1595 &an_10g_cntl_reg);
1596 if (status)
1597 return status;
1598
1599 status = hw->phy.ops.read_reg(hw,
1600 IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
1601 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1602 &autoneg_reg);
1603 if (status)
1604 return status;
1605
1606 save_autoneg = hw->phy.autoneg_advertised;
1607
1608 /* Setup link at least common link speed */
1609 status = hw->mac.ops.setup_link(hw, lcd_speed, false);
1610
1611 /* restore autoneg from before setting lplu speed */
1612 hw->phy.autoneg_advertised = save_autoneg;
1613
1614 return status;
1615}
1616
1447/** ixgbe_init_phy_ops_X550em - PHY/SFP specific init 1617/** ixgbe_init_phy_ops_X550em - PHY/SFP specific init
1448 * @hw: pointer to hardware structure 1618 * @hw: pointer to hardware structure
1449 * 1619 *
@@ -1514,6 +1684,11 @@ static s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
1514 ret_val = ixgbe_setup_kr_speed_x550em(hw, speed); 1684 ret_val = ixgbe_setup_kr_speed_x550em(hw, speed);
1515 } 1685 }
1516 1686
1687 /* setup SW LPLU only for first revision */
1688 if (!(IXGBE_FUSES0_REV1 & IXGBE_READ_REG(hw,
1689 IXGBE_FUSES0_GROUP(0))))
1690 phy->ops.enter_lplu = ixgbe_enter_lplu_t_x550em;
1691
1517 phy->ops.handle_lasi = ixgbe_handle_lasi_ext_t_x550em; 1692 phy->ops.handle_lasi = ixgbe_handle_lasi_ext_t_x550em;
1518 phy->ops.reset = ixgbe_reset_phy_t_X550em; 1693 phy->ops.reset = ixgbe_reset_phy_t_X550em;
1519 break; 1694 break;
@@ -1760,7 +1935,6 @@ static void ixgbe_set_source_address_pruning_X550(struct ixgbe_hw *hw,
1760 .get_mac_addr = &ixgbe_get_mac_addr_generic, \ 1935 .get_mac_addr = &ixgbe_get_mac_addr_generic, \
1761 .get_device_caps = &ixgbe_get_device_caps_generic, \ 1936 .get_device_caps = &ixgbe_get_device_caps_generic, \
1762 .stop_adapter = &ixgbe_stop_adapter_generic, \ 1937 .stop_adapter = &ixgbe_stop_adapter_generic, \
1763 .get_bus_info = &ixgbe_get_bus_info_generic, \
1764 .set_lan_id = &ixgbe_set_lan_id_multi_port_pcie, \ 1938 .set_lan_id = &ixgbe_set_lan_id_multi_port_pcie, \
1765 .read_analog_reg8 = NULL, \ 1939 .read_analog_reg8 = NULL, \
1766 .write_analog_reg8 = NULL, \ 1940 .write_analog_reg8 = NULL, \
@@ -1809,6 +1983,7 @@ static struct ixgbe_mac_operations mac_ops_X550 = {
1809 .get_wwn_prefix = &ixgbe_get_wwn_prefix_generic, 1983 .get_wwn_prefix = &ixgbe_get_wwn_prefix_generic,
1810 .setup_link = &ixgbe_setup_mac_link_X540, 1984 .setup_link = &ixgbe_setup_mac_link_X540,
1811 .get_link_capabilities = &ixgbe_get_copper_link_capabilities_generic, 1985 .get_link_capabilities = &ixgbe_get_copper_link_capabilities_generic,
1986 .get_bus_info = &ixgbe_get_bus_info_generic,
1812 .setup_sfp = NULL, 1987 .setup_sfp = NULL,
1813}; 1988};
1814 1989
@@ -1820,6 +1995,7 @@ static struct ixgbe_mac_operations mac_ops_X550EM_x = {
1820 .get_wwn_prefix = NULL, 1995 .get_wwn_prefix = NULL,
1821 .setup_link = NULL, /* defined later */ 1996 .setup_link = NULL, /* defined later */
1822 .get_link_capabilities = &ixgbe_get_link_capabilities_X550em, 1997 .get_link_capabilities = &ixgbe_get_link_capabilities_X550em,
1998 .get_bus_info = &ixgbe_get_bus_info_X550em,
1823 .setup_sfp = ixgbe_setup_sfp_modules_X550em, 1999 .setup_sfp = ixgbe_setup_sfp_modules_X550em,
1824 2000
1825}; 2001};
@@ -1855,7 +2031,7 @@ static struct ixgbe_eeprom_operations eeprom_ops_X550EM_x = {
1855 .read_reg = &ixgbe_read_phy_reg_generic, \ 2031 .read_reg = &ixgbe_read_phy_reg_generic, \
1856 .write_reg = &ixgbe_write_phy_reg_generic, \ 2032 .write_reg = &ixgbe_write_phy_reg_generic, \
1857 .setup_link = &ixgbe_setup_phy_link_generic, \ 2033 .setup_link = &ixgbe_setup_phy_link_generic, \
1858 .set_phy_power = &ixgbe_set_copper_phy_power, \ 2034 .set_phy_power = NULL, \
1859 .check_overtemp = &ixgbe_tn_check_overtemp, \ 2035 .check_overtemp = &ixgbe_tn_check_overtemp, \
1860 .get_firmware_version = &ixgbe_get_phy_firmware_version_generic, 2036 .get_firmware_version = &ixgbe_get_phy_firmware_version_generic,
1861 2037
@@ -1893,7 +2069,7 @@ struct ixgbe_info ixgbe_X550_info = {
1893 2069
1894struct ixgbe_info ixgbe_X550EM_x_info = { 2070struct ixgbe_info ixgbe_X550EM_x_info = {
1895 .mac = ixgbe_mac_X550EM_x, 2071 .mac = ixgbe_mac_X550EM_x,
1896 .get_invariants = &ixgbe_get_invariants_X540, 2072 .get_invariants = &ixgbe_get_invariants_X550_x,
1897 .mac_ops = &mac_ops_X550EM_x, 2073 .mac_ops = &mac_ops_X550EM_x,
1898 .eeprom_ops = &eeprom_ops_X550EM_x, 2074 .eeprom_ops = &eeprom_ops_X550EM_x,
1899 .phy_ops = &phy_ops_X550EM_x, 2075 .phy_ops = &phy_ops_X550EM_x,