aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sfc
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/sfc')
-rw-r--r--drivers/net/sfc/efx.c8
-rw-r--r--drivers/net/sfc/efx.h2
-rw-r--r--drivers/net/sfc/ethtool.c10
-rw-r--r--drivers/net/sfc/falcon.c6
-rw-r--r--drivers/net/sfc/mcdi.c109
-rw-r--r--drivers/net/sfc/mcdi.h1
-rw-r--r--drivers/net/sfc/mcdi_pcol.h202
-rw-r--r--drivers/net/sfc/mcdi_phy.c36
-rw-r--r--drivers/net/sfc/mdio_10g.c24
-rw-r--r--drivers/net/sfc/mdio_10g.h3
-rw-r--r--drivers/net/sfc/net_driver.h17
-rw-r--r--drivers/net/sfc/nic.c13
-rw-r--r--drivers/net/sfc/qt202x_phy.c1
-rw-r--r--drivers/net/sfc/selftest.c42
-rw-r--r--drivers/net/sfc/selftest.h4
-rw-r--r--drivers/net/sfc/siena.c16
-rw-r--r--drivers/net/sfc/tenxpress.c2
17 files changed, 374 insertions, 122 deletions
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index 46997e177ee3..88f2fb193abe 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -1602,11 +1602,10 @@ static int efx_set_mac_address(struct net_device *net_dev, void *data)
1602static void efx_set_multicast_list(struct net_device *net_dev) 1602static void efx_set_multicast_list(struct net_device *net_dev)
1603{ 1603{
1604 struct efx_nic *efx = netdev_priv(net_dev); 1604 struct efx_nic *efx = netdev_priv(net_dev);
1605 struct dev_mc_list *mc_list = net_dev->mc_list; 1605 struct dev_mc_list *mc_list;
1606 union efx_multicast_hash *mc_hash = &efx->multicast_hash; 1606 union efx_multicast_hash *mc_hash = &efx->multicast_hash;
1607 u32 crc; 1607 u32 crc;
1608 int bit; 1608 int bit;
1609 int i;
1610 1609
1611 efx->promiscuous = !!(net_dev->flags & IFF_PROMISC); 1610 efx->promiscuous = !!(net_dev->flags & IFF_PROMISC);
1612 1611
@@ -1615,11 +1614,10 @@ static void efx_set_multicast_list(struct net_device *net_dev)
1615 memset(mc_hash, 0xff, sizeof(*mc_hash)); 1614 memset(mc_hash, 0xff, sizeof(*mc_hash));
1616 } else { 1615 } else {
1617 memset(mc_hash, 0x00, sizeof(*mc_hash)); 1616 memset(mc_hash, 0x00, sizeof(*mc_hash));
1618 for (i = 0; i < net_dev->mc_count; i++) { 1617 netdev_for_each_mc_addr(mc_list, net_dev) {
1619 crc = ether_crc_le(ETH_ALEN, mc_list->dmi_addr); 1618 crc = ether_crc_le(ETH_ALEN, mc_list->dmi_addr);
1620 bit = crc & (EFX_MCAST_HASH_ENTRIES - 1); 1619 bit = crc & (EFX_MCAST_HASH_ENTRIES - 1);
1621 set_bit_le(bit, mc_hash->byte); 1620 set_bit_le(bit, mc_hash->byte);
1622 mc_list = mc_list->next;
1623 } 1621 }
1624 1622
1625 /* Broadcast packets go through the multicast hash filter. 1623 /* Broadcast packets go through the multicast hash filter.
@@ -1940,7 +1938,7 @@ void efx_schedule_reset(struct efx_nic *efx, enum reset_type type)
1940 **************************************************************************/ 1938 **************************************************************************/
1941 1939
1942/* PCI device ID table */ 1940/* PCI device ID table */
1943static struct pci_device_id efx_pci_table[] __devinitdata = { 1941static DEFINE_PCI_DEVICE_TABLE(efx_pci_table) = {
1944 {PCI_DEVICE(EFX_VENDID_SFC, FALCON_A_P_DEVID), 1942 {PCI_DEVICE(EFX_VENDID_SFC, FALCON_A_P_DEVID),
1945 .driver_data = (unsigned long) &falcon_a1_nic_type}, 1943 .driver_data = (unsigned long) &falcon_a1_nic_type},
1946 {PCI_DEVICE(EFX_VENDID_SFC, FALCON_B_P_DEVID), 1944 {PCI_DEVICE(EFX_VENDID_SFC, FALCON_B_P_DEVID),
diff --git a/drivers/net/sfc/efx.h b/drivers/net/sfc/efx.h
index a615ac051530..7eff0a615cb3 100644
--- a/drivers/net/sfc/efx.h
+++ b/drivers/net/sfc/efx.h
@@ -79,8 +79,6 @@ extern int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok);
79 79
80/* Global */ 80/* Global */
81extern void efx_schedule_reset(struct efx_nic *efx, enum reset_type type); 81extern void efx_schedule_reset(struct efx_nic *efx, enum reset_type type);
82extern void efx_suspend(struct efx_nic *efx);
83extern void efx_resume(struct efx_nic *efx);
84extern void efx_init_irq_moderation(struct efx_nic *efx, int tx_usecs, 82extern void efx_init_irq_moderation(struct efx_nic *efx, int tx_usecs,
85 int rx_usecs, bool rx_adaptive); 83 int rx_usecs, bool rx_adaptive);
86extern int efx_request_power(struct efx_nic *efx, int mw, const char *name); 84extern int efx_request_power(struct efx_nic *efx, int mw, const char *name);
diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c
index 6c0bbed8c477..d9f9c02a928e 100644
--- a/drivers/net/sfc/ethtool.c
+++ b/drivers/net/sfc/ethtool.c
@@ -196,7 +196,7 @@ int efx_ethtool_get_settings(struct net_device *net_dev,
196 efx->phy_op->get_settings(efx, ecmd); 196 efx->phy_op->get_settings(efx, ecmd);
197 mutex_unlock(&efx->mac_lock); 197 mutex_unlock(&efx->mac_lock);
198 198
199 /* Falcon GMAC does not support 1000Mbps HD */ 199 /* GMAC does not support 1000Mbps HD */
200 ecmd->supported &= ~SUPPORTED_1000baseT_Half; 200 ecmd->supported &= ~SUPPORTED_1000baseT_Half;
201 /* Both MACs support pause frames (bidirectional and respond-only) */ 201 /* Both MACs support pause frames (bidirectional and respond-only) */
202 ecmd->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause; 202 ecmd->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
@@ -216,7 +216,7 @@ int efx_ethtool_set_settings(struct net_device *net_dev,
216 struct efx_nic *efx = netdev_priv(net_dev); 216 struct efx_nic *efx = netdev_priv(net_dev);
217 int rc; 217 int rc;
218 218
219 /* Falcon GMAC does not support 1000Mbps HD */ 219 /* GMAC does not support 1000Mbps HD */
220 if (ecmd->speed == SPEED_1000 && ecmd->duplex != DUPLEX_FULL) { 220 if (ecmd->speed == SPEED_1000 && ecmd->duplex != DUPLEX_FULL) {
221 EFX_LOG(efx, "rejecting unsupported 1000Mbps HD" 221 EFX_LOG(efx, "rejecting unsupported 1000Mbps HD"
222 " setting\n"); 222 " setting\n");
@@ -342,8 +342,8 @@ static int efx_ethtool_fill_self_tests(struct efx_nic *efx,
342 unsigned int n = 0, i; 342 unsigned int n = 0, i;
343 enum efx_loopback_mode mode; 343 enum efx_loopback_mode mode;
344 344
345 efx_fill_test(n++, strings, data, &tests->mdio, 345 efx_fill_test(n++, strings, data, &tests->phy_alive,
346 "core", 0, "mdio", NULL); 346 "phy", 0, "alive", NULL);
347 efx_fill_test(n++, strings, data, &tests->nvram, 347 efx_fill_test(n++, strings, data, &tests->nvram,
348 "core", 0, "nvram", NULL); 348 "core", 0, "nvram", NULL);
349 efx_fill_test(n++, strings, data, &tests->interrupt, 349 efx_fill_test(n++, strings, data, &tests->interrupt,
@@ -379,7 +379,7 @@ static int efx_ethtool_fill_self_tests(struct efx_nic *efx,
379 if (name == NULL) 379 if (name == NULL)
380 break; 380 break;
381 381
382 efx_fill_test(n++, strings, data, &tests->phy[i], 382 efx_fill_test(n++, strings, data, &tests->phy_ext[i],
383 "phy", 0, name, NULL); 383 "phy", 0, name, NULL);
384 } 384 }
385 } 385 }
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c
index 9d009c46e962..1b8d83657aaa 100644
--- a/drivers/net/sfc/falcon.c
+++ b/drivers/net/sfc/falcon.c
@@ -909,6 +909,8 @@ static int falcon_probe_port(struct efx_nic *efx)
909 efx->wanted_fc = EFX_FC_RX | EFX_FC_TX; 909 efx->wanted_fc = EFX_FC_RX | EFX_FC_TX;
910 else 910 else
911 efx->wanted_fc = EFX_FC_RX; 911 efx->wanted_fc = EFX_FC_RX;
912 if (efx->mdio.mmds & MDIO_DEVS_AN)
913 efx->wanted_fc |= EFX_FC_AUTO;
912 914
913 /* Allocate buffer for stats */ 915 /* Allocate buffer for stats */
914 rc = efx_nic_alloc_buffer(efx, &efx->stats_buffer, 916 rc = efx_nic_alloc_buffer(efx, &efx->stats_buffer,
@@ -1006,7 +1008,7 @@ static int falcon_test_nvram(struct efx_nic *efx)
1006 1008
1007static const struct efx_nic_register_test falcon_b0_register_tests[] = { 1009static const struct efx_nic_register_test falcon_b0_register_tests[] = {
1008 { FR_AZ_ADR_REGION, 1010 { FR_AZ_ADR_REGION,
1009 EFX_OWORD32(0x0001FFFF, 0x0001FFFF, 0x0001FFFF, 0x0001FFFF) }, 1011 EFX_OWORD32(0x0003FFFF, 0x0003FFFF, 0x0003FFFF, 0x0003FFFF) },
1010 { FR_AZ_RX_CFG, 1012 { FR_AZ_RX_CFG,
1011 EFX_OWORD32(0xFFFFFFFE, 0x00017FFF, 0x00000000, 0x00000000) }, 1013 EFX_OWORD32(0xFFFFFFFE, 0x00017FFF, 0x00000000, 0x00000000) },
1012 { FR_AZ_TX_CFG, 1014 { FR_AZ_TX_CFG,
@@ -1728,7 +1730,7 @@ static int falcon_set_wol(struct efx_nic *efx, u32 type)
1728 1730
1729/************************************************************************** 1731/**************************************************************************
1730 * 1732 *
1731 * Revision-dependent attributes used by efx.c 1733 * Revision-dependent attributes used by efx.c and nic.c
1732 * 1734 *
1733 ************************************************************************** 1735 **************************************************************************
1734 */ 1736 */
diff --git a/drivers/net/sfc/mcdi.c b/drivers/net/sfc/mcdi.c
index f66b3da6ddff..c48669c77414 100644
--- a/drivers/net/sfc/mcdi.c
+++ b/drivers/net/sfc/mcdi.c
@@ -896,29 +896,73 @@ fail:
896 return rc; 896 return rc;
897} 897}
898 898
899int efx_mcdi_handle_assertion(struct efx_nic *efx) 899static int efx_mcdi_nvram_test(struct efx_nic *efx, unsigned int type)
900{
901 u8 inbuf[MC_CMD_NVRAM_TEST_IN_LEN];
902 u8 outbuf[MC_CMD_NVRAM_TEST_OUT_LEN];
903 int rc;
904
905 MCDI_SET_DWORD(inbuf, NVRAM_TEST_IN_TYPE, type);
906
907 rc = efx_mcdi_rpc(efx, MC_CMD_NVRAM_TEST, inbuf, sizeof(inbuf),
908 outbuf, sizeof(outbuf), NULL);
909 if (rc)
910 return rc;
911
912 switch (MCDI_DWORD(outbuf, NVRAM_TEST_OUT_RESULT)) {
913 case MC_CMD_NVRAM_TEST_PASS:
914 case MC_CMD_NVRAM_TEST_NOTSUPP:
915 return 0;
916 default:
917 return -EIO;
918 }
919}
920
921int efx_mcdi_nvram_test_all(struct efx_nic *efx)
922{
923 u32 nvram_types;
924 unsigned int type;
925 int rc;
926
927 rc = efx_mcdi_nvram_types(efx, &nvram_types);
928 if (rc)
929 return rc;
930
931 type = 0;
932 while (nvram_types != 0) {
933 if (nvram_types & 1) {
934 rc = efx_mcdi_nvram_test(efx, type);
935 if (rc)
936 return rc;
937 }
938 type++;
939 nvram_types >>= 1;
940 }
941
942 return 0;
943}
944
945static int efx_mcdi_read_assertion(struct efx_nic *efx)
900{ 946{
901 union { 947 u8 inbuf[MC_CMD_GET_ASSERTS_IN_LEN];
902 u8 asserts[MC_CMD_GET_ASSERTS_IN_LEN]; 948 u8 outbuf[MC_CMD_GET_ASSERTS_OUT_LEN];
903 u8 reboot[MC_CMD_REBOOT_IN_LEN];
904 } inbuf;
905 u8 assertion[MC_CMD_GET_ASSERTS_OUT_LEN];
906 unsigned int flags, index, ofst; 949 unsigned int flags, index, ofst;
907 const char *reason; 950 const char *reason;
908 size_t outlen; 951 size_t outlen;
909 int retry; 952 int retry;
910 int rc; 953 int rc;
911 954
912 /* Check if the MC is in the assertion handler, retrying twice. Once 955 /* Attempt to read any stored assertion state before we reboot
956 * the mcfw out of the assertion handler. Retry twice, once
913 * because a boot-time assertion might cause this command to fail 957 * because a boot-time assertion might cause this command to fail
914 * with EINTR. And once again because GET_ASSERTS can race with 958 * with EINTR. And once again because GET_ASSERTS can race with
915 * MC_CMD_REBOOT running on the other port. */ 959 * MC_CMD_REBOOT running on the other port. */
916 retry = 2; 960 retry = 2;
917 do { 961 do {
918 MCDI_SET_DWORD(inbuf.asserts, GET_ASSERTS_IN_CLEAR, 0); 962 MCDI_SET_DWORD(inbuf, GET_ASSERTS_IN_CLEAR, 1);
919 rc = efx_mcdi_rpc(efx, MC_CMD_GET_ASSERTS, 963 rc = efx_mcdi_rpc(efx, MC_CMD_GET_ASSERTS,
920 inbuf.asserts, MC_CMD_GET_ASSERTS_IN_LEN, 964 inbuf, MC_CMD_GET_ASSERTS_IN_LEN,
921 assertion, sizeof(assertion), &outlen); 965 outbuf, sizeof(outbuf), &outlen);
922 } while ((rc == -EINTR || rc == -EIO) && retry-- > 0); 966 } while ((rc == -EINTR || rc == -EIO) && retry-- > 0);
923 967
924 if (rc) 968 if (rc)
@@ -926,21 +970,11 @@ int efx_mcdi_handle_assertion(struct efx_nic *efx)
926 if (outlen < MC_CMD_GET_ASSERTS_OUT_LEN) 970 if (outlen < MC_CMD_GET_ASSERTS_OUT_LEN)
927 return -EINVAL; 971 return -EINVAL;
928 972
929 flags = MCDI_DWORD(assertion, GET_ASSERTS_OUT_GLOBAL_FLAGS); 973 /* Print out any recorded assertion state */
974 flags = MCDI_DWORD(outbuf, GET_ASSERTS_OUT_GLOBAL_FLAGS);
930 if (flags == MC_CMD_GET_ASSERTS_FLAGS_NO_FAILS) 975 if (flags == MC_CMD_GET_ASSERTS_FLAGS_NO_FAILS)
931 return 0; 976 return 0;
932 977
933 /* Reset the hardware atomically such that only one port with succeed.
934 * This command will succeed if a reboot is no longer required (because
935 * the other port did it first), but fail with EIO if it succeeds.
936 */
937 BUILD_BUG_ON(MC_CMD_REBOOT_OUT_LEN != 0);
938 MCDI_SET_DWORD(inbuf.reboot, REBOOT_IN_FLAGS,
939 MC_CMD_REBOOT_FLAGS_AFTER_ASSERTION);
940 efx_mcdi_rpc(efx, MC_CMD_REBOOT, inbuf.reboot, MC_CMD_REBOOT_IN_LEN,
941 NULL, 0, NULL);
942
943 /* Print out the assertion */
944 reason = (flags == MC_CMD_GET_ASSERTS_FLAGS_SYS_FAIL) 978 reason = (flags == MC_CMD_GET_ASSERTS_FLAGS_SYS_FAIL)
945 ? "system-level assertion" 979 ? "system-level assertion"
946 : (flags == MC_CMD_GET_ASSERTS_FLAGS_THR_FAIL) 980 : (flags == MC_CMD_GET_ASSERTS_FLAGS_THR_FAIL)
@@ -949,20 +983,45 @@ int efx_mcdi_handle_assertion(struct efx_nic *efx)
949 ? "watchdog reset" 983 ? "watchdog reset"
950 : "unknown assertion"; 984 : "unknown assertion";
951 EFX_ERR(efx, "MCPU %s at PC = 0x%.8x in thread 0x%.8x\n", reason, 985 EFX_ERR(efx, "MCPU %s at PC = 0x%.8x in thread 0x%.8x\n", reason,
952 MCDI_DWORD(assertion, GET_ASSERTS_OUT_SAVED_PC_OFFS), 986 MCDI_DWORD(outbuf, GET_ASSERTS_OUT_SAVED_PC_OFFS),
953 MCDI_DWORD(assertion, GET_ASSERTS_OUT_THREAD_OFFS)); 987 MCDI_DWORD(outbuf, GET_ASSERTS_OUT_THREAD_OFFS));
954 988
955 /* Print out the registers */ 989 /* Print out the registers */
956 ofst = MC_CMD_GET_ASSERTS_OUT_GP_REGS_OFFS_OFST; 990 ofst = MC_CMD_GET_ASSERTS_OUT_GP_REGS_OFFS_OFST;
957 for (index = 1; index < 32; index++) { 991 for (index = 1; index < 32; index++) {
958 EFX_ERR(efx, "R%.2d (?): 0x%.8x\n", index, 992 EFX_ERR(efx, "R%.2d (?): 0x%.8x\n", index,
959 MCDI_DWORD2(assertion, ofst)); 993 MCDI_DWORD2(outbuf, ofst));
960 ofst += sizeof(efx_dword_t); 994 ofst += sizeof(efx_dword_t);
961 } 995 }
962 996
963 return 0; 997 return 0;
964} 998}
965 999
1000static void efx_mcdi_exit_assertion(struct efx_nic *efx)
1001{
1002 u8 inbuf[MC_CMD_REBOOT_IN_LEN];
1003
1004 /* Atomically reboot the mcfw out of the assertion handler */
1005 BUILD_BUG_ON(MC_CMD_REBOOT_OUT_LEN != 0);
1006 MCDI_SET_DWORD(inbuf, REBOOT_IN_FLAGS,
1007 MC_CMD_REBOOT_FLAGS_AFTER_ASSERTION);
1008 efx_mcdi_rpc(efx, MC_CMD_REBOOT, inbuf, MC_CMD_REBOOT_IN_LEN,
1009 NULL, 0, NULL);
1010}
1011
1012int efx_mcdi_handle_assertion(struct efx_nic *efx)
1013{
1014 int rc;
1015
1016 rc = efx_mcdi_read_assertion(efx);
1017 if (rc)
1018 return rc;
1019
1020 efx_mcdi_exit_assertion(efx);
1021
1022 return 0;
1023}
1024
966void efx_mcdi_set_id_led(struct efx_nic *efx, enum efx_led_mode mode) 1025void efx_mcdi_set_id_led(struct efx_nic *efx, enum efx_led_mode mode)
967{ 1026{
968 u8 inbuf[MC_CMD_SET_ID_LED_IN_LEN]; 1027 u8 inbuf[MC_CMD_SET_ID_LED_IN_LEN];
diff --git a/drivers/net/sfc/mcdi.h b/drivers/net/sfc/mcdi.h
index 10ce98f4c0fb..f1f89ad4075a 100644
--- a/drivers/net/sfc/mcdi.h
+++ b/drivers/net/sfc/mcdi.h
@@ -116,6 +116,7 @@ extern int efx_mcdi_nvram_erase(struct efx_nic *efx, unsigned int type,
116 loff_t offset, size_t length); 116 loff_t offset, size_t length);
117extern int efx_mcdi_nvram_update_finish(struct efx_nic *efx, 117extern int efx_mcdi_nvram_update_finish(struct efx_nic *efx,
118 unsigned int type); 118 unsigned int type);
119extern int efx_mcdi_nvram_test_all(struct efx_nic *efx);
119extern int efx_mcdi_handle_assertion(struct efx_nic *efx); 120extern int efx_mcdi_handle_assertion(struct efx_nic *efx);
120extern void efx_mcdi_set_id_led(struct efx_nic *efx, enum efx_led_mode mode); 121extern void efx_mcdi_set_id_led(struct efx_nic *efx, enum efx_led_mode mode);
121extern int efx_mcdi_reset_port(struct efx_nic *efx); 122extern int efx_mcdi_reset_port(struct efx_nic *efx);
diff --git a/drivers/net/sfc/mcdi_pcol.h b/drivers/net/sfc/mcdi_pcol.h
index 73e71f420624..bd59302695b3 100644
--- a/drivers/net/sfc/mcdi_pcol.h
+++ b/drivers/net/sfc/mcdi_pcol.h
@@ -786,16 +786,18 @@
786#define MC_CMD_GET_PHY_CFG_OUT_FLAGS_OFST 0 786#define MC_CMD_GET_PHY_CFG_OUT_FLAGS_OFST 0
787#define MC_CMD_GET_PHY_CFG_PRESENT_LBN 0 787#define MC_CMD_GET_PHY_CFG_PRESENT_LBN 0
788#define MC_CMD_GET_PHY_CFG_PRESENT_WIDTH 1 788#define MC_CMD_GET_PHY_CFG_PRESENT_WIDTH 1
789#define MC_CMD_GET_PHY_CFG_SHORTBIST_LBN 1 789#define MC_CMD_GET_PHY_CFG_BIST_CABLE_SHORT_LBN 1
790#define MC_CMD_GET_PHY_CFG_SHORTBIST_WIDTH 1 790#define MC_CMD_GET_PHY_CFG_BIST_CABLE_SHORT_WIDTH 1
791#define MC_CMD_GET_PHY_CFG_LONGBIST_LBN 2 791#define MC_CMD_GET_PHY_CFG_BIST_CABLE_LONG_LBN 2
792#define MC_CMD_GET_PHY_CFG_LONGBIST_WIDTH 1 792#define MC_CMD_GET_PHY_CFG_BIST_CABLE_LONG_WIDTH 1
793#define MC_CMD_GET_PHY_CFG_LOWPOWER_LBN 3 793#define MC_CMD_GET_PHY_CFG_LOWPOWER_LBN 3
794#define MC_CMD_GET_PHY_CFG_LOWPOWER_WIDTH 1 794#define MC_CMD_GET_PHY_CFG_LOWPOWER_WIDTH 1
795#define MC_CMD_GET_PHY_CFG_POWEROFF_LBN 4 795#define MC_CMD_GET_PHY_CFG_POWEROFF_LBN 4
796#define MC_CMD_GET_PHY_CFG_POWEROFF_WIDTH 1 796#define MC_CMD_GET_PHY_CFG_POWEROFF_WIDTH 1
797#define MC_CMD_GET_PHY_CFG_TXDIS_LBN 5 797#define MC_CMD_GET_PHY_CFG_TXDIS_LBN 5
798#define MC_CMD_GET_PHY_CFG_TXDIS_WIDTH 1 798#define MC_CMD_GET_PHY_CFG_TXDIS_WIDTH 1
799#define MC_CMD_GET_PHY_CFG_BIST_LBN 6
800#define MC_CMD_GET_PHY_CFG_BIST_WIDTH 1
799#define MC_CMD_GET_PHY_CFG_OUT_TYPE_OFST 4 801#define MC_CMD_GET_PHY_CFG_OUT_TYPE_OFST 4
800/* Bitmask of supported capabilities */ 802/* Bitmask of supported capabilities */
801#define MC_CMD_GET_PHY_CFG_OUT_SUPPORTED_CAP_OFST 8 803#define MC_CMD_GET_PHY_CFG_OUT_SUPPORTED_CAP_OFST 8
@@ -832,7 +834,7 @@
832#define MC_CMD_GET_PHY_CFG_OUT_REVISION_OFST 52 834#define MC_CMD_GET_PHY_CFG_OUT_REVISION_OFST 52
833#define MC_CMD_GET_PHY_CFG_OUT_REVISION_LEN 20 835#define MC_CMD_GET_PHY_CFG_OUT_REVISION_LEN 20
834 836
835/* MC_CMD_START_PHY_BIST: 837/* MC_CMD_START_BIST:
836 * Start a BIST test on the PHY. 838 * Start a BIST test on the PHY.
837 * 839 *
838 * Locks required: PHY_LOCK if doing a PHY BIST 840 * Locks required: PHY_LOCK if doing a PHY BIST
@@ -840,34 +842,71 @@
840 */ 842 */
841#define MC_CMD_START_BIST 0x25 843#define MC_CMD_START_BIST 0x25
842#define MC_CMD_START_BIST_IN_LEN 4 844#define MC_CMD_START_BIST_IN_LEN 4
843#define MC_CMD_START_BIST_TYPE_OFST 0 845#define MC_CMD_START_BIST_IN_TYPE_OFST 0
846#define MC_CMD_START_BIST_OUT_LEN 0
844 847
845/* Run the PHY's short BIST */ 848/* Run the PHY's short cable BIST */
846#define MC_CMD_PHY_BIST_SHORT 1 849#define MC_CMD_PHY_BIST_CABLE_SHORT 1
847/* Run the PHY's long BIST */ 850/* Run the PHY's long cable BIST */
848#define MC_CMD_PHY_BIST_LONG 2 851#define MC_CMD_PHY_BIST_CABLE_LONG 2
849/* Run BIST on the currently selected BPX Serdes (XAUI or XFI) */ 852/* Run BIST on the currently selected BPX Serdes (XAUI or XFI) */
850#define MC_CMD_BPX_SERDES_BIST 3 853#define MC_CMD_BPX_SERDES_BIST 3
854/* Run the MC loopback tests */
855#define MC_CMD_MC_LOOPBACK_BIST 4
856/* Run the PHY's standard BIST */
857#define MC_CMD_PHY_BIST 5
851 858
852/* MC_CMD_POLL_PHY_BIST: (variadic output) 859/* MC_CMD_POLL_PHY_BIST: (variadic output)
853 * Poll for BIST completion 860 * Poll for BIST completion
854 * 861 *
855 * Returns a single status code, and a binary blob of phy-specific 862 * Returns a single status code, and optionally some PHY specific
856 * bist output. If the driver can't succesfully parse the BIST output, 863 * bist output. The driver should only consume the BIST output
857 * it should still respect the Pass/Fail in OUT.RESULT. 864 * after validating OUTLEN and PHY_CFG.PHY_TYPE.
858 * 865 *
859 * Locks required: PHY_LOCK if doing a PHY BIST 866 * If a driver can't succesfully parse the BIST output, it should
867 * still respect the pass/Fail in OUT.RESULT
868 *
869 * Locks required: PHY_LOCK if doing a PHY BIST
860 * Return code: 0, EACCES (if PHY_LOCK is not held) 870 * Return code: 0, EACCES (if PHY_LOCK is not held)
861 */ 871 */
862#define MC_CMD_POLL_BIST 0x26 872#define MC_CMD_POLL_BIST 0x26
863#define MC_CMD_POLL_BIST_IN_LEN 0 873#define MC_CMD_POLL_BIST_IN_LEN 0
864#define MC_CMD_POLL_BIST_OUT_LEN UNKNOWN 874#define MC_CMD_POLL_BIST_OUT_LEN UNKNOWN
875#define MC_CMD_POLL_BIST_OUT_SFT9001_LEN 40
876#define MC_CMD_POLL_BIST_OUT_MRSFP_LEN 8
865#define MC_CMD_POLL_BIST_OUT_RESULT_OFST 0 877#define MC_CMD_POLL_BIST_OUT_RESULT_OFST 0
866#define MC_CMD_POLL_BIST_RUNNING 1 878#define MC_CMD_POLL_BIST_RUNNING 1
867#define MC_CMD_POLL_BIST_PASSED 2 879#define MC_CMD_POLL_BIST_PASSED 2
868#define MC_CMD_POLL_BIST_FAILED 3 880#define MC_CMD_POLL_BIST_FAILED 3
869#define MC_CMD_POLL_BIST_TIMEOUT 4 881#define MC_CMD_POLL_BIST_TIMEOUT 4
882/* Generic: */
870#define MC_CMD_POLL_BIST_OUT_PRIVATE_OFST 4 883#define MC_CMD_POLL_BIST_OUT_PRIVATE_OFST 4
884/* SFT9001-specific: */
885/* (offset 4 unused?) */
886#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_LENGTH_A_OFST 8
887#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_LENGTH_B_OFST 12
888#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_LENGTH_C_OFST 16
889#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_LENGTH_D_OFST 20
890#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_STATUS_A_OFST 24
891#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_STATUS_B_OFST 28
892#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_STATUS_C_OFST 32
893#define MC_CMD_POLL_BIST_OUT_SFT9001_CABLE_STATUS_D_OFST 36
894#define MC_CMD_POLL_BIST_SFT9001_PAIR_OK 1
895#define MC_CMD_POLL_BIST_SFT9001_PAIR_OPEN 2
896#define MC_CMD_POLL_BIST_SFT9001_INTRA_PAIR_SHORT 3
897#define MC_CMD_POLL_BIST_SFT9001_INTER_PAIR_SHORT 4
898#define MC_CMD_POLL_BIST_SFT9001_PAIR_BUSY 9
899/* mrsfp "PHY" driver: */
900#define MC_CMD_POLL_BIST_OUT_MRSFP_TEST_OFST 4
901#define MC_CMD_POLL_BIST_MRSFP_TEST_COMPLETE 0
902#define MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_OFF_I2C_WRITE 1
903#define MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_OFF_I2C_NO_ACCESS_IO_EXP 2
904#define MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_OFF_I2C_NO_ACCESS_MODULE 3
905#define MC_CMD_POLL_BIST_MRSFP_TEST_IO_EXP_I2C_CONFIGURE 4
906#define MC_CMD_POLL_BIST_MRSFP_TEST_BUS_SWITCH_I2C_NO_CROSSTALK 5
907#define MC_CMD_POLL_BIST_MRSFP_TEST_MODULE_PRESENCE 6
908#define MC_CMD_POLL_BIST_MRSFP_TEST_MODULE_ID_I2C_ACCESS 7
909#define MC_CMD_POLL_BIST_MRSFP_TEST_MODULE_ID_SANE_VALUE 8
871 910
872/* MC_CMD_PHY_SPI: (variadic in, variadic out) 911/* MC_CMD_PHY_SPI: (variadic in, variadic out)
873 * Read/Write/Erase the PHY SPI device 912 * Read/Write/Erase the PHY SPI device
@@ -1206,6 +1245,13 @@
1206#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_LAYER4_OFST \ 1245#define MC_CMD_WOL_FILTER_SET_IN_BITMAP_LAYER4_OFST \
1207 (MC_CMD_WOL_FILTER_SET_IN_DATA_OFST + 178) 1246 (MC_CMD_WOL_FILTER_SET_IN_DATA_OFST + 178)
1208 1247
1248#define MC_CMD_WOL_FILTER_SET_IN_LINK_MASK_OFST \
1249 MC_CMD_WOL_FILTER_SET_IN_DATA_OFST
1250#define MC_CMD_WOL_FILTER_SET_IN_LINK_UP_LBN 0
1251#define MC_CMD_WOL_FILTER_SET_IN_LINK_UP_WIDTH 1
1252#define MC_CMD_WOL_FILTER_SET_IN_LINK_DOWN_LBN 1
1253#define MC_CMD_WOL_FILTER_SET_IN_LINK_DOWN_WIDTH 1
1254
1209#define MC_CMD_WOL_FILTER_SET_OUT_LEN 4 1255#define MC_CMD_WOL_FILTER_SET_OUT_LEN 4
1210#define MC_CMD_WOL_FILTER_SET_OUT_FILTER_ID_OFST 0 1256#define MC_CMD_WOL_FILTER_SET_OUT_FILTER_ID_OFST 0
1211 1257
@@ -1216,7 +1262,8 @@
1216#define MC_CMD_WOL_TYPE_IPV4_SYN 0x3 1262#define MC_CMD_WOL_TYPE_IPV4_SYN 0x3
1217#define MC_CMD_WOL_TYPE_IPV6_SYN 0x4 1263#define MC_CMD_WOL_TYPE_IPV6_SYN 0x4
1218#define MC_CMD_WOL_TYPE_BITMAP 0x5 1264#define MC_CMD_WOL_TYPE_BITMAP 0x5
1219#define MC_CMD_WOL_TYPE_MAX 0x6 1265#define MC_CMD_WOL_TYPE_LINK 0x6
1266#define MC_CMD_WOL_TYPE_MAX 0x7
1220 1267
1221#define MC_CMD_FILTER_MODE_SIMPLE 0x0 1268#define MC_CMD_FILTER_MODE_SIMPLE 0x0
1222#define MC_CMD_FILTER_MODE_STRUCTURED 0xffffffff 1269#define MC_CMD_FILTER_MODE_STRUCTURED 0xffffffff
@@ -1357,14 +1404,24 @@
1357 * Returns: 0, EINVAL (bad type/offset/length), EACCES (if PHY_LOCK required and not held) 1404 * Returns: 0, EINVAL (bad type/offset/length), EACCES (if PHY_LOCK required and not held)
1358 */ 1405 */
1359#define MC_CMD_NVRAM_UPDATE_FINISH 0x3c 1406#define MC_CMD_NVRAM_UPDATE_FINISH 0x3c
1360#define MC_CMD_NVRAM_UPDATE_FINISH_IN_LEN 4 1407#define MC_CMD_NVRAM_UPDATE_FINISH_IN_LEN 8
1361#define MC_CMD_NVRAM_UPDATE_FINISH_IN_TYPE_OFST 0 1408#define MC_CMD_NVRAM_UPDATE_FINISH_IN_TYPE_OFST 0
1409#define MC_CMD_NVRAM_UPDATE_FINISH_IN_REBOOT_OFST 4
1362#define MC_CMD_NVRAM_UPDATE_FINISH_OUT_LEN 0 1410#define MC_CMD_NVRAM_UPDATE_FINISH_OUT_LEN 0
1363 1411
1364/* MC_CMD_REBOOT: 1412/* MC_CMD_REBOOT:
1365 * Reboot the MC. The AFTER_ASSERTION flag is intended to be used 1413 * Reboot the MC.
1366 * when the driver notices an assertion failure, to allow two ports to 1414 *
1367 * both recover (semi-)gracefully. 1415 * The AFTER_ASSERTION flag is intended to be used when the driver notices
1416 * an assertion failure (at which point it is expected to perform a complete
1417 * tear down and reinitialise), to allow both ports to reset the MC once
1418 * in an atomic fashion.
1419 *
1420 * Production mc firmwares are generally compiled with REBOOT_ON_ASSERT=1,
1421 * which means that they will automatically reboot out of the assertion
1422 * handler, so this is in practise an optional operation. It is still
1423 * recommended that drivers execute this to support custom firmwares
1424 * with REBOOT_ON_ASSERT=0.
1368 * 1425 *
1369 * Locks required: NONE 1426 * Locks required: NONE
1370 * Returns: Nothing. You get back a response with ERR=1, DATALEN=0 1427 * Returns: Nothing. You get back a response with ERR=1, DATALEN=0
@@ -1469,11 +1526,10 @@
1469 ((_ofst) + 6) 1526 ((_ofst) + 6)
1470 1527
1471/* MC_CMD_READ_SENSORS 1528/* MC_CMD_READ_SENSORS
1472 * Returns the current (value, state) for each sensor 1529 * Returns the current reading from each sensor
1473 * 1530 *
1474 * Returns the current (value, state) [each 16bit] of each sensor supported by 1531 * Returns a sparse array of sensor readings (indexed by the sensor
1475 * this board, by DMA'ing a sparse array (indexed by the sensor type) into host 1532 * type) into host memory. Each array element is a dword.
1476 * memory.
1477 * 1533 *
1478 * The MC will send a SENSOREVT event every time any sensor changes state. The 1534 * The MC will send a SENSOREVT event every time any sensor changes state. The
1479 * driver is responsible for ensuring that it doesn't miss any events. The board 1535 * driver is responsible for ensuring that it doesn't miss any events. The board
@@ -1486,6 +1542,12 @@
1486#define MC_CMD_READ_SENSORS_IN_DMA_ADDR_HI_OFST 4 1542#define MC_CMD_READ_SENSORS_IN_DMA_ADDR_HI_OFST 4
1487#define MC_CMD_READ_SENSORS_OUT_LEN 0 1543#define MC_CMD_READ_SENSORS_OUT_LEN 0
1488 1544
1545/* Sensor reading fields */
1546#define MC_CMD_READ_SENSOR_VALUE_LBN 0
1547#define MC_CMD_READ_SENSOR_VALUE_WIDTH 16
1548#define MC_CMD_READ_SENSOR_STATE_LBN 16
1549#define MC_CMD_READ_SENSOR_STATE_WIDTH 8
1550
1489 1551
1490/* MC_CMD_GET_PHY_STATE: 1552/* MC_CMD_GET_PHY_STATE:
1491 * Report current state of PHY. A "zombie" PHY is a PHY that has failed to 1553 * Report current state of PHY. A "zombie" PHY is a PHY that has failed to
@@ -1577,4 +1639,98 @@
1577#define MC_CMD_MAC_RESET_RESTORE_IN_LEN 0 1639#define MC_CMD_MAC_RESET_RESTORE_IN_LEN 0
1578#define MC_CMD_MAC_RESET_RESTORE_OUT_LEN 0 1640#define MC_CMD_MAC_RESET_RESTORE_OUT_LEN 0
1579 1641
1642
1643/* MC_CMD_TEST_ASSERT:
1644 * Deliberately trigger an assert-detonation in the firmware for testing
1645 * purposes (i.e. to allow tests that the driver copes gracefully).
1646 *
1647 * Locks required: None
1648 * Returns: 0
1649 */
1650
1651#define MC_CMD_TESTASSERT 0x49
1652#define MC_CMD_TESTASSERT_IN_LEN 0
1653#define MC_CMD_TESTASSERT_OUT_LEN 0
1654
1655/* MC_CMD_WORKAROUND 0x4a
1656 *
1657 * Enable/Disable a given workaround. The mcfw will return EINVAL if it
1658 * doesn't understand the given workaround number - which should not
1659 * be treated as a hard error by client code.
1660 *
1661 * This op does not imply any semantics about each workaround, that's between
1662 * the driver and the mcfw on a per-workaround basis.
1663 *
1664 * Locks required: None
1665 * Returns: 0, EINVAL
1666 */
1667#define MC_CMD_WORKAROUND 0x4a
1668#define MC_CMD_WORKAROUND_IN_LEN 8
1669#define MC_CMD_WORKAROUND_IN_TYPE_OFST 0
1670#define MC_CMD_WORKAROUND_BUG17230 1
1671#define MC_CMD_WORKAROUND_IN_ENABLED_OFST 4
1672#define MC_CMD_WORKAROUND_OUT_LEN 0
1673
1674/* MC_CMD_GET_PHY_MEDIA_INFO:
1675 * Read media-specific data from PHY (e.g. SFP/SFP+ module ID information for
1676 * SFP+ PHYs).
1677 *
1678 * The "media type" can be found via GET_PHY_CFG (GET_PHY_CFG_OUT_MEDIA_TYPE);
1679 * the valid "page number" input values, and the output data, are interpreted
1680 * on a per-type basis.
1681 *
1682 * For SFP+: PAGE=0 or 1 returns a 128-byte block read from module I2C address
1683 * 0xA0 offset 0 or 0x80.
1684 * Anything else: currently undefined.
1685 *
1686 * Locks required: None
1687 * Return code: 0
1688 */
1689#define MC_CMD_GET_PHY_MEDIA_INFO 0x4b
1690#define MC_CMD_GET_PHY_MEDIA_INFO_IN_LEN 4
1691#define MC_CMD_GET_PHY_MEDIA_INFO_IN_PAGE_OFST 0
1692#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_LEN(_num_bytes) (4 + (_num_bytes))
1693#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATALEN_OFST 0
1694#define MC_CMD_GET_PHY_MEDIA_INFO_OUT_DATA_OFST 4
1695
1696/* MC_CMD_NVRAM_TEST:
1697 * Test a particular NVRAM partition for valid contents (where "valid"
1698 * depends on the type of partition).
1699 *
1700 * Locks required: None
1701 * Return code: 0
1702 */
1703#define MC_CMD_NVRAM_TEST 0x4c
1704#define MC_CMD_NVRAM_TEST_IN_LEN 4
1705#define MC_CMD_NVRAM_TEST_IN_TYPE_OFST 0
1706#define MC_CMD_NVRAM_TEST_OUT_LEN 4
1707#define MC_CMD_NVRAM_TEST_OUT_RESULT_OFST 0
1708#define MC_CMD_NVRAM_TEST_PASS 0
1709#define MC_CMD_NVRAM_TEST_FAIL 1
1710#define MC_CMD_NVRAM_TEST_NOTSUPP 2
1711
1712/* MC_CMD_MRSFP_TWEAK: (debug)
1713 * Read status and/or set parameters for the "mrsfp" driver in mr_rusty builds.
1714 * I2C I/O expander bits are always read; if equaliser parameters are supplied,
1715 * they are configured first.
1716 *
1717 * Locks required: None
1718 * Return code: 0, EINVAL
1719 */
1720#define MC_CMD_MRSFP_TWEAK 0x4d
1721#define MC_CMD_MRSFP_TWEAK_IN_LEN_READ_ONLY 0
1722#define MC_CMD_MRSFP_TWEAK_IN_LEN_EQ_CONFIG 16
1723#define MC_CMD_MRSFP_TWEAK_IN_TXEQ_LEVEL_OFST 0 /* 0-6 low->high de-emph. */
1724#define MC_CMD_MRSFP_TWEAK_IN_TXEQ_DT_CFG_OFST 4 /* 0-8 low->high ref.V */
1725#define MC_CMD_MRSFP_TWEAK_IN_RXEQ_BOOST_OFST 8 /* 0-8 low->high boost */
1726#define MC_CMD_MRSFP_TWEAK_IN_RXEQ_DT_CFG_OFST 12 /* 0-8 low->high ref.V */
1727#define MC_CMD_MRSFP_TWEAK_OUT_LEN 12
1728#define MC_CMD_MRSFP_TWEAK_OUT_IOEXP_INPUTS_OFST 0 /* input bits */
1729#define MC_CMD_MRSFP_TWEAK_OUT_IOEXP_OUTPUTS_OFST 4 /* output bits */
1730#define MC_CMD_MRSFP_TWEAK_OUT_IOEXP_DIRECTION_OFST 8 /* dirs: 0=out, 1=in */
1731
1732/* Do NOT add new commands beyond 0x4f as part of 3.0 : 0x50 - 0x7f will be
1733 * used for post-3.0 extensions. If you run out of space, look for gaps or
1734 * commands that are unused in the existing range. */
1735
1580#endif /* MCDI_PCOL_H */ 1736#endif /* MCDI_PCOL_H */
diff --git a/drivers/net/sfc/mcdi_phy.c b/drivers/net/sfc/mcdi_phy.c
index eb694af7a473..34c22fa986e2 100644
--- a/drivers/net/sfc/mcdi_phy.c
+++ b/drivers/net/sfc/mcdi_phy.c
@@ -381,6 +381,18 @@ static int efx_mcdi_phy_probe(struct efx_nic *efx)
381 * but by convention we don't */ 381 * but by convention we don't */
382 efx->loopback_modes &= ~(1 << LOOPBACK_NONE); 382 efx->loopback_modes &= ~(1 << LOOPBACK_NONE);
383 383
384 /* Set the initial link mode */
385 efx_mcdi_phy_decode_link(
386 efx, &efx->link_state,
387 MCDI_DWORD(outbuf, GET_LINK_OUT_LINK_SPEED),
388 MCDI_DWORD(outbuf, GET_LINK_OUT_FLAGS),
389 MCDI_DWORD(outbuf, GET_LINK_OUT_FCNTL));
390
391 /* Default to Autonegotiated flow control if the PHY supports it */
392 efx->wanted_fc = EFX_FC_RX | EFX_FC_TX;
393 if (phy_data->supported_cap & (1 << MC_CMD_PHY_CAP_AN_LBN))
394 efx->wanted_fc |= EFX_FC_AUTO;
395
384 return 0; 396 return 0;
385 397
386fail: 398fail:
@@ -436,7 +448,7 @@ void efx_mcdi_phy_check_fcntl(struct efx_nic *efx, u32 lpa)
436 448
437 /* The link partner capabilities are only relevent if the 449 /* The link partner capabilities are only relevent if the
438 * link supports flow control autonegotiation */ 450 * link supports flow control autonegotiation */
439 if (~phy_cfg->supported_cap & (1 << MC_CMD_PHY_CAP_ASYM_LBN)) 451 if (~phy_cfg->supported_cap & (1 << MC_CMD_PHY_CAP_AN_LBN))
440 return; 452 return;
441 453
442 /* If flow control autoneg is supported and enabled, then fine */ 454 /* If flow control autoneg is supported and enabled, then fine */
@@ -560,6 +572,27 @@ static int efx_mcdi_phy_set_settings(struct efx_nic *efx, struct ethtool_cmd *ec
560 return 0; 572 return 0;
561} 573}
562 574
575static int efx_mcdi_phy_test_alive(struct efx_nic *efx)
576{
577 u8 outbuf[MC_CMD_GET_PHY_STATE_OUT_LEN];
578 size_t outlen;
579 int rc;
580
581 BUILD_BUG_ON(MC_CMD_GET_PHY_STATE_IN_LEN != 0);
582
583 rc = efx_mcdi_rpc(efx, MC_CMD_GET_PHY_STATE, NULL, 0,
584 outbuf, sizeof(outbuf), &outlen);
585 if (rc)
586 return rc;
587
588 if (outlen < MC_CMD_GET_PHY_STATE_OUT_LEN)
589 return -EMSGSIZE;
590 if (MCDI_DWORD(outbuf, GET_PHY_STATE_STATE) != MC_CMD_PHY_STATE_OK)
591 return -EINVAL;
592
593 return 0;
594}
595
563struct efx_phy_operations efx_mcdi_phy_ops = { 596struct efx_phy_operations efx_mcdi_phy_ops = {
564 .probe = efx_mcdi_phy_probe, 597 .probe = efx_mcdi_phy_probe,
565 .init = efx_port_dummy_op_int, 598 .init = efx_port_dummy_op_int,
@@ -569,6 +602,7 @@ struct efx_phy_operations efx_mcdi_phy_ops = {
569 .remove = efx_mcdi_phy_remove, 602 .remove = efx_mcdi_phy_remove,
570 .get_settings = efx_mcdi_phy_get_settings, 603 .get_settings = efx_mcdi_phy_get_settings,
571 .set_settings = efx_mcdi_phy_set_settings, 604 .set_settings = efx_mcdi_phy_set_settings,
605 .test_alive = efx_mcdi_phy_test_alive,
572 .run_tests = NULL, 606 .run_tests = NULL,
573 .test_name = NULL, 607 .test_name = NULL,
574}; 608};
diff --git a/drivers/net/sfc/mdio_10g.c b/drivers/net/sfc/mdio_10g.c
index 1574e52f0594..0548fcbbdcd0 100644
--- a/drivers/net/sfc/mdio_10g.c
+++ b/drivers/net/sfc/mdio_10g.c
@@ -335,3 +335,27 @@ enum efx_fc_type efx_mdio_get_pause(struct efx_nic *efx)
335 mii_advertise_flowctrl(efx->wanted_fc), 335 mii_advertise_flowctrl(efx->wanted_fc),
336 efx_mdio_read(efx, MDIO_MMD_AN, MDIO_AN_LPA)); 336 efx_mdio_read(efx, MDIO_MMD_AN, MDIO_AN_LPA));
337} 337}
338
339int efx_mdio_test_alive(struct efx_nic *efx)
340{
341 int rc;
342 int devad = __ffs(efx->mdio.mmds);
343 u16 physid1, physid2;
344
345 mutex_lock(&efx->mac_lock);
346
347 physid1 = efx_mdio_read(efx, devad, MDIO_DEVID1);
348 physid2 = efx_mdio_read(efx, devad, MDIO_DEVID2);
349
350 if ((physid1 == 0x0000) || (physid1 == 0xffff) ||
351 (physid2 == 0x0000) || (physid2 == 0xffff)) {
352 EFX_ERR(efx, "no MDIO PHY present with ID %d\n",
353 efx->mdio.prtad);
354 rc = -EINVAL;
355 } else {
356 rc = efx_mdio_check_mmds(efx, efx->mdio.mmds, 0);
357 }
358
359 mutex_unlock(&efx->mac_lock);
360 return rc;
361}
diff --git a/drivers/net/sfc/mdio_10g.h b/drivers/net/sfc/mdio_10g.h
index f6ac9503339d..f89e71929603 100644
--- a/drivers/net/sfc/mdio_10g.h
+++ b/drivers/net/sfc/mdio_10g.h
@@ -106,4 +106,7 @@ efx_mdio_set_flag(struct efx_nic *efx, int devad, int addr,
106 mdio_set_flag(&efx->mdio, efx->mdio.prtad, devad, addr, mask, state); 106 mdio_set_flag(&efx->mdio, efx->mdio.prtad, devad, addr, mask, state);
107} 107}
108 108
109/* Liveness self-test for MDIO PHYs */
110extern int efx_mdio_test_alive(struct efx_nic *efx);
111
109#endif /* EFX_MDIO_10G_H */ 112#endif /* EFX_MDIO_10G_H */
diff --git a/drivers/net/sfc/net_driver.h b/drivers/net/sfc/net_driver.h
index d5aab5b3fa06..cb018e272097 100644
--- a/drivers/net/sfc/net_driver.h
+++ b/drivers/net/sfc/net_driver.h
@@ -18,7 +18,6 @@
18#include <linux/etherdevice.h> 18#include <linux/etherdevice.h>
19#include <linux/ethtool.h> 19#include <linux/ethtool.h>
20#include <linux/if_vlan.h> 20#include <linux/if_vlan.h>
21#include <linux/timer.h>
22#include <linux/mdio.h> 21#include <linux/mdio.h>
23#include <linux/list.h> 22#include <linux/list.h>
24#include <linux/pci.h> 23#include <linux/pci.h>
@@ -101,9 +100,6 @@ do {if (net_ratelimit()) EFX_LOG(efx, fmt, ##args); } while (0)
101 * Special buffers are used for the event queues and the TX and RX 100 * Special buffers are used for the event queues and the TX and RX
102 * descriptor queues for each channel. They are *not* used for the 101 * descriptor queues for each channel. They are *not* used for the
103 * actual transmit and receive buffers. 102 * actual transmit and receive buffers.
104 *
105 * Note that for Falcon, TX and RX descriptor queues live in host memory.
106 * Allocation and freeing procedures must take this into account.
107 */ 103 */
108struct efx_special_buffer { 104struct efx_special_buffer {
109 void *addr; 105 void *addr;
@@ -300,7 +296,7 @@ struct efx_rx_queue {
300 * @dma_addr: DMA base address of the buffer 296 * @dma_addr: DMA base address of the buffer
301 * @len: Buffer length, in bytes 297 * @len: Buffer length, in bytes
302 * 298 *
303 * Falcon uses these buffers for its interrupt status registers and 299 * The NIC uses these buffers for its interrupt status registers and
304 * MAC stats dumps. 300 * MAC stats dumps.
305 */ 301 */
306struct efx_buffer { 302struct efx_buffer {
@@ -516,8 +512,9 @@ struct efx_mac_operations {
516 * @set_settings: Set ethtool settings. Serialised by the mac_lock. 512 * @set_settings: Set ethtool settings. Serialised by the mac_lock.
517 * @set_npage_adv: Set abilities advertised in (Extended) Next Page 513 * @set_npage_adv: Set abilities advertised in (Extended) Next Page
518 * (only needed where AN bit is set in mmds) 514 * (only needed where AN bit is set in mmds)
515 * @test_alive: Test that PHY is 'alive' (online)
519 * @test_name: Get the name of a PHY-specific test/result 516 * @test_name: Get the name of a PHY-specific test/result
520 * @run_tests: Run tests and record results as appropriate. 517 * @run_tests: Run tests and record results as appropriate (offline).
521 * Flags are the ethtool tests flags. 518 * Flags are the ethtool tests flags.
522 */ 519 */
523struct efx_phy_operations { 520struct efx_phy_operations {
@@ -532,6 +529,7 @@ struct efx_phy_operations {
532 int (*set_settings) (struct efx_nic *efx, 529 int (*set_settings) (struct efx_nic *efx,
533 struct ethtool_cmd *ecmd); 530 struct ethtool_cmd *ecmd);
534 void (*set_npage_adv) (struct efx_nic *efx, u32); 531 void (*set_npage_adv) (struct efx_nic *efx, u32);
532 int (*test_alive) (struct efx_nic *efx);
535 const char *(*test_name) (struct efx_nic *efx, unsigned int index); 533 const char *(*test_name) (struct efx_nic *efx, unsigned int index);
536 int (*run_tests) (struct efx_nic *efx, int *results, unsigned flags); 534 int (*run_tests) (struct efx_nic *efx, int *results, unsigned flags);
537}; 535};
@@ -672,7 +670,7 @@ union efx_multicast_hash {
672 * @irq_status: Interrupt status buffer 670 * @irq_status: Interrupt status buffer
673 * @last_irq_cpu: Last CPU to handle interrupt. 671 * @last_irq_cpu: Last CPU to handle interrupt.
674 * This register is written with the SMP processor ID whenever an 672 * This register is written with the SMP processor ID whenever an
675 * interrupt is handled. It is used by falcon_test_interrupt() 673 * interrupt is handled. It is used by efx_nic_test_interrupt()
676 * to verify that an interrupt has occurred. 674 * to verify that an interrupt has occurred.
677 * @spi_flash: SPI flash device 675 * @spi_flash: SPI flash device
678 * This field will be %NULL if no flash device is present (or for Siena). 676 * This field will be %NULL if no flash device is present (or for Siena).
@@ -721,8 +719,7 @@ union efx_multicast_hash {
721 * @loopback_modes: Supported loopback mode bitmask 719 * @loopback_modes: Supported loopback mode bitmask
722 * @loopback_selftest: Offline self-test private state 720 * @loopback_selftest: Offline self-test private state
723 * 721 *
724 * The @priv field of the corresponding &struct net_device points to 722 * This is stored in the private area of the &struct net_device.
725 * this.
726 */ 723 */
727struct efx_nic { 724struct efx_nic {
728 char name[IFNAMSIZ]; 725 char name[IFNAMSIZ];
@@ -995,7 +992,7 @@ static inline void clear_bit_le(unsigned nr, unsigned char *addr)
995 * that the net driver will program into the MAC as the maximum frame 992 * that the net driver will program into the MAC as the maximum frame
996 * length. 993 * length.
997 * 994 *
998 * The 10G MAC used in Falcon requires 8-byte alignment on the frame 995 * The 10G MAC requires 8-byte alignment on the frame
999 * length, so we round up to the nearest 8. 996 * length, so we round up to the nearest 8.
1000 * 997 *
1001 * Re-clocking by the XGXS on RX can reduce an IPG to 32 bits (half an 998 * Re-clocking by the XGXS on RX can reduce an IPG to 32 bits (half an
diff --git a/drivers/net/sfc/nic.c b/drivers/net/sfc/nic.c
index db44224ed2ca..b06f8e348307 100644
--- a/drivers/net/sfc/nic.c
+++ b/drivers/net/sfc/nic.c
@@ -623,10 +623,6 @@ void efx_nic_remove_rx(struct efx_rx_queue *rx_queue)
623 * 623 *
624 * This writes the EVQ_RPTR_REG register for the specified channel's 624 * This writes the EVQ_RPTR_REG register for the specified channel's
625 * event queue. 625 * event queue.
626 *
627 * Note that EVQ_RPTR_REG contains the index of the "last read" event,
628 * whereas channel->eventq_read_ptr contains the index of the "next to
629 * read" event.
630 */ 626 */
631void efx_nic_eventq_read_ack(struct efx_channel *channel) 627void efx_nic_eventq_read_ack(struct efx_channel *channel)
632{ 628{
@@ -1384,6 +1380,15 @@ static irqreturn_t efx_legacy_interrupt(int irq, void *dev_id)
1384 efx->last_irq_cpu = raw_smp_processor_id(); 1380 efx->last_irq_cpu = raw_smp_processor_id();
1385 EFX_TRACE(efx, "IRQ %d on CPU %d status " EFX_DWORD_FMT "\n", 1381 EFX_TRACE(efx, "IRQ %d on CPU %d status " EFX_DWORD_FMT "\n",
1386 irq, raw_smp_processor_id(), EFX_DWORD_VAL(reg)); 1382 irq, raw_smp_processor_id(), EFX_DWORD_VAL(reg));
1383 } else if (EFX_WORKAROUND_15783(efx)) {
1384 /* We can't return IRQ_HANDLED more than once on seeing ISR0=0
1385 * because this might be a shared interrupt, but we do need to
1386 * check the channel every time and preemptively rearm it if
1387 * it's idle. */
1388 efx_for_each_channel(channel, efx) {
1389 if (!channel->work_pending)
1390 efx_nic_eventq_read_ack(channel);
1391 }
1387 } 1392 }
1388 1393
1389 return result; 1394 return result;
diff --git a/drivers/net/sfc/qt202x_phy.c b/drivers/net/sfc/qt202x_phy.c
index 67eec7a6e487..1bee62c83001 100644
--- a/drivers/net/sfc/qt202x_phy.c
+++ b/drivers/net/sfc/qt202x_phy.c
@@ -445,4 +445,5 @@ struct efx_phy_operations falcon_qt202x_phy_ops = {
445 .remove = qt202x_phy_remove, 445 .remove = qt202x_phy_remove,
446 .get_settings = qt202x_phy_get_settings, 446 .get_settings = qt202x_phy_get_settings,
447 .set_settings = efx_mdio_set_settings, 447 .set_settings = efx_mdio_set_settings,
448 .test_alive = efx_mdio_test_alive,
448}; 449};
diff --git a/drivers/net/sfc/selftest.c b/drivers/net/sfc/selftest.c
index 250c8827b842..cf0139a7d9a4 100644
--- a/drivers/net/sfc/selftest.c
+++ b/drivers/net/sfc/selftest.c
@@ -24,9 +24,6 @@
24#include "nic.h" 24#include "nic.h"
25#include "selftest.h" 25#include "selftest.h"
26#include "workarounds.h" 26#include "workarounds.h"
27#include "spi.h"
28#include "io.h"
29#include "mdio_10g.h"
30 27
31/* 28/*
32 * Loopback test packet structure 29 * Loopback test packet structure
@@ -76,42 +73,15 @@ struct efx_loopback_state {
76 * 73 *
77 **************************************************************************/ 74 **************************************************************************/
78 75
79static int efx_test_mdio(struct efx_nic *efx, struct efx_self_tests *tests) 76static int efx_test_phy_alive(struct efx_nic *efx, struct efx_self_tests *tests)
80{ 77{
81 int rc = 0; 78 int rc = 0;
82 int devad;
83 u16 physid1, physid2;
84
85 if (efx->mdio.mode_support & MDIO_SUPPORTS_C45)
86 devad = __ffs(efx->mdio.mmds);
87 else if (efx->mdio.mode_support & MDIO_SUPPORTS_C22)
88 devad = MDIO_DEVAD_NONE;
89 else
90 return 0;
91
92 mutex_lock(&efx->mac_lock);
93 tests->mdio = -1;
94
95 physid1 = efx_mdio_read(efx, devad, MDIO_DEVID1);
96 physid2 = efx_mdio_read(efx, devad, MDIO_DEVID2);
97 79
98 if ((physid1 == 0x0000) || (physid1 == 0xffff) || 80 if (efx->phy_op->test_alive) {
99 (physid2 == 0x0000) || (physid2 == 0xffff)) { 81 rc = efx->phy_op->test_alive(efx);
100 EFX_ERR(efx, "no MDIO PHY present with ID %d\n", 82 tests->phy_alive = rc ? -1 : 1;
101 efx->mdio.prtad);
102 rc = -EINVAL;
103 goto out;
104 } 83 }
105 84
106 if (EFX_IS10G(efx)) {
107 rc = efx_mdio_check_mmds(efx, efx->mdio.mmds, 0);
108 if (rc)
109 goto out;
110 }
111
112out:
113 mutex_unlock(&efx->mac_lock);
114 tests->mdio = rc ? -1 : 1;
115 return rc; 85 return rc;
116} 86}
117 87
@@ -258,7 +228,7 @@ static int efx_test_phy(struct efx_nic *efx, struct efx_self_tests *tests,
258 return 0; 228 return 0;
259 229
260 mutex_lock(&efx->mac_lock); 230 mutex_lock(&efx->mac_lock);
261 rc = efx->phy_op->run_tests(efx, tests->phy, flags); 231 rc = efx->phy_op->run_tests(efx, tests->phy_ext, flags);
262 mutex_unlock(&efx->mac_lock); 232 mutex_unlock(&efx->mac_lock);
263 return rc; 233 return rc;
264} 234}
@@ -684,7 +654,7 @@ int efx_selftest(struct efx_nic *efx, struct efx_self_tests *tests,
684 /* Online (i.e. non-disruptive) testing 654 /* Online (i.e. non-disruptive) testing
685 * This checks interrupt generation, event delivery and PHY presence. */ 655 * This checks interrupt generation, event delivery and PHY presence. */
686 656
687 rc = efx_test_mdio(efx, tests); 657 rc = efx_test_phy_alive(efx, tests);
688 if (rc && !rc_test) 658 if (rc && !rc_test)
689 rc_test = rc; 659 rc_test = rc;
690 660
diff --git a/drivers/net/sfc/selftest.h b/drivers/net/sfc/selftest.h
index f6feee04c96b..643bef72b99d 100644
--- a/drivers/net/sfc/selftest.h
+++ b/drivers/net/sfc/selftest.h
@@ -32,7 +32,7 @@ struct efx_loopback_self_tests {
32 */ 32 */
33struct efx_self_tests { 33struct efx_self_tests {
34 /* online tests */ 34 /* online tests */
35 int mdio; 35 int phy_alive;
36 int nvram; 36 int nvram;
37 int interrupt; 37 int interrupt;
38 int eventq_dma[EFX_MAX_CHANNELS]; 38 int eventq_dma[EFX_MAX_CHANNELS];
@@ -40,7 +40,7 @@ struct efx_self_tests {
40 int eventq_poll[EFX_MAX_CHANNELS]; 40 int eventq_poll[EFX_MAX_CHANNELS];
41 /* offline tests */ 41 /* offline tests */
42 int registers; 42 int registers;
43 int phy[EFX_MAX_PHY_TESTS]; 43 int phy_ext[EFX_MAX_PHY_TESTS];
44 struct efx_loopback_self_tests loopback[LOOPBACK_TEST_MAX + 1]; 44 struct efx_loopback_self_tests loopback[LOOPBACK_TEST_MAX + 1];
45}; 45};
46 46
diff --git a/drivers/net/sfc/siena.c b/drivers/net/sfc/siena.c
index f8c6771e66d8..1619fb5a64f5 100644
--- a/drivers/net/sfc/siena.c
+++ b/drivers/net/sfc/siena.c
@@ -106,16 +106,11 @@ static int siena_probe_port(struct efx_nic *efx)
106 efx->mdio.mdio_read = siena_mdio_read; 106 efx->mdio.mdio_read = siena_mdio_read;
107 efx->mdio.mdio_write = siena_mdio_write; 107 efx->mdio.mdio_write = siena_mdio_write;
108 108
109 /* Fill out MDIO structure and loopback modes */ 109 /* Fill out MDIO structure, loopback modes, and initial link state */
110 rc = efx->phy_op->probe(efx); 110 rc = efx->phy_op->probe(efx);
111 if (rc != 0) 111 if (rc != 0)
112 return rc; 112 return rc;
113 113
114 /* Initial assumption */
115 efx->link_state.speed = 10000;
116 efx->link_state.fd = true;
117 efx->wanted_fc = EFX_FC_RX | EFX_FC_TX;
118
119 /* Allocate buffer for stats */ 114 /* Allocate buffer for stats */
120 rc = efx_nic_alloc_buffer(efx, &efx->stats_buffer, 115 rc = efx_nic_alloc_buffer(efx, &efx->stats_buffer,
121 MC_CMD_MAC_NSTATS * sizeof(u64)); 116 MC_CMD_MAC_NSTATS * sizeof(u64));
@@ -139,7 +134,7 @@ void siena_remove_port(struct efx_nic *efx)
139 134
140static const struct efx_nic_register_test siena_register_tests[] = { 135static const struct efx_nic_register_test siena_register_tests[] = {
141 { FR_AZ_ADR_REGION, 136 { FR_AZ_ADR_REGION,
142 EFX_OWORD32(0x0001FFFF, 0x0001FFFF, 0x0001FFFF, 0x0001FFFF) }, 137 EFX_OWORD32(0x0003FFFF, 0x0003FFFF, 0x0003FFFF, 0x0003FFFF) },
143 { FR_CZ_USR_EV_CFG, 138 { FR_CZ_USR_EV_CFG,
144 EFX_OWORD32(0x000103FF, 0x00000000, 0x00000000, 0x00000000) }, 139 EFX_OWORD32(0x000103FF, 0x00000000, 0x00000000, 0x00000000) },
145 { FR_AZ_RX_CFG, 140 { FR_AZ_RX_CFG,
@@ -181,6 +176,12 @@ static int siena_test_registers(struct efx_nic *efx)
181 176
182static int siena_reset_hw(struct efx_nic *efx, enum reset_type method) 177static int siena_reset_hw(struct efx_nic *efx, enum reset_type method)
183{ 178{
179 int rc;
180
181 /* Recover from a failed assertion pre-reset */
182 rc = efx_mcdi_handle_assertion(efx);
183 if (rc)
184 return rc;
184 185
185 if (method == RESET_TYPE_WORLD) 186 if (method == RESET_TYPE_WORLD)
186 return efx_mcdi_reset_mc(efx); 187 return efx_mcdi_reset_mc(efx);
@@ -582,6 +583,7 @@ struct efx_nic_type siena_a0_nic_type = {
582 .set_wol = siena_set_wol, 583 .set_wol = siena_set_wol,
583 .resume_wol = siena_init_wol, 584 .resume_wol = siena_init_wol,
584 .test_registers = siena_test_registers, 585 .test_registers = siena_test_registers,
586 .test_nvram = efx_mcdi_nvram_test_all,
585 .default_mac_ops = &efx_mcdi_mac_operations, 587 .default_mac_ops = &efx_mcdi_mac_operations,
586 588
587 .revision = EFX_REV_SIENA_A0, 589 .revision = EFX_REV_SIENA_A0,
diff --git a/drivers/net/sfc/tenxpress.c b/drivers/net/sfc/tenxpress.c
index 3009c297c135..10db071bd837 100644
--- a/drivers/net/sfc/tenxpress.c
+++ b/drivers/net/sfc/tenxpress.c
@@ -842,6 +842,7 @@ struct efx_phy_operations falcon_sfx7101_phy_ops = {
842 .get_settings = tenxpress_get_settings, 842 .get_settings = tenxpress_get_settings,
843 .set_settings = tenxpress_set_settings, 843 .set_settings = tenxpress_set_settings,
844 .set_npage_adv = sfx7101_set_npage_adv, 844 .set_npage_adv = sfx7101_set_npage_adv,
845 .test_alive = efx_mdio_test_alive,
845 .test_name = sfx7101_test_name, 846 .test_name = sfx7101_test_name,
846 .run_tests = sfx7101_run_tests, 847 .run_tests = sfx7101_run_tests,
847}; 848};
@@ -856,6 +857,7 @@ struct efx_phy_operations falcon_sft9001_phy_ops = {
856 .get_settings = tenxpress_get_settings, 857 .get_settings = tenxpress_get_settings,
857 .set_settings = tenxpress_set_settings, 858 .set_settings = tenxpress_set_settings,
858 .set_npage_adv = sft9001_set_npage_adv, 859 .set_npage_adv = sft9001_set_npage_adv,
860 .test_alive = efx_mdio_test_alive,
859 .test_name = sft9001_test_name, 861 .test_name = sft9001_test_name,
860 .run_tests = sft9001_run_tests, 862 .run_tests = sft9001_run_tests,
861}; 863};