From: Ben Hutchings <bhutchings@solarflare.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, linux-net-drivers@solarflare.com
Subject: [PATCH 05/20] sfc: SFT9001/SFN4111T: Check PHY boot status during board initialisation
Date: Thu, 29 Jan 2009 19:17:39 +0000 [thread overview]
Message-ID: <1233256659.3656.21.camel@achroite> (raw)
In-Reply-To: <1233256358.3656.9.camel@achroite>
During SFN4111T initialisation, check whether the PHY boot status
indicates a bad firmware checksum. If so, prepare to reflash rather
than continuing with normal initialisation.
Remove redundant PHY boot status check from tenxpress_phy_init().
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
drivers/net/sfc/phy.h | 4 ++
drivers/net/sfc/sfe4001.c | 14 +++++--
drivers/net/sfc/tenxpress.c | 90 ++++++++++++++++++++++++++-----------------
3 files changed, 69 insertions(+), 39 deletions(-)
diff --git a/drivers/net/sfc/phy.h b/drivers/net/sfc/phy.h
index 07e855c..f6e4722 100644
--- a/drivers/net/sfc/phy.h
+++ b/drivers/net/sfc/phy.h
@@ -18,6 +18,10 @@ extern struct efx_phy_operations falcon_sft9001_phy_ops;
extern void tenxpress_phy_blink(struct efx_nic *efx, bool blink);
+/* Wait for the PHY to boot. Return 0 on success, -EINVAL if the PHY failed
+ * to boot due to corrupt flash, or some other negative error code. */
+extern int sft9001_wait_boot(struct efx_nic *efx);
+
/****************************************************************************
* Exported functions from the driver for XFP optical PHYs
*/
diff --git a/drivers/net/sfc/sfe4001.c b/drivers/net/sfc/sfe4001.c
index 16b80ac..2e9b4b4 100644
--- a/drivers/net/sfc/sfe4001.c
+++ b/drivers/net/sfc/sfe4001.c
@@ -379,6 +379,7 @@ static struct i2c_board_info sfn4111t_hwmon_info = {
int sfn4111t_init(struct efx_nic *efx)
{
+ int i = 0;
int rc;
efx->board_info.hwmon_client =
@@ -394,11 +395,16 @@ int sfn4111t_init(struct efx_nic *efx)
if (rc)
goto fail_hwmon;
- if (efx->phy_mode & PHY_MODE_SPECIAL)
- sfn4111t_reset(efx);
-
- return 0;
+ do {
+ if (efx->phy_mode & PHY_MODE_SPECIAL)
+ sfn4111t_reset(efx);
+ rc = sft9001_wait_boot(efx);
+ if (rc == 0)
+ return 0;
+ efx->phy_mode = PHY_MODE_SPECIAL;
+ } while (rc == -EINVAL && ++i < 2);
+ device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_flash_cfg);
fail_hwmon:
i2c_unregister_device(efx->board_info.hwmon_client);
return rc;
diff --git a/drivers/net/sfc/tenxpress.c b/drivers/net/sfc/tenxpress.c
index e6fa5c8..9e0b755 100644
--- a/drivers/net/sfc/tenxpress.c
+++ b/drivers/net/sfc/tenxpress.c
@@ -157,14 +157,16 @@
#define PCS_10GBASET_BLKLK_WIDTH 1
/* Boot status register */
-#define PCS_BOOT_STATUS_REG 53248
-#define PCS_BOOT_FATAL_ERR_LBN (0)
-#define PCS_BOOT_PROGRESS_LBN (1)
-#define PCS_BOOT_PROGRESS_WIDTH (2)
-#define PCS_BOOT_COMPLETE_LBN (3)
-
-#define PCS_BOOT_MAX_DELAY (100)
-#define PCS_BOOT_POLL_DELAY (10)
+#define PCS_BOOT_STATUS_REG 53248
+#define PCS_BOOT_FATAL_ERROR_LBN 0
+#define PCS_BOOT_PROGRESS_LBN 1
+#define PCS_BOOT_PROGRESS_WIDTH 2
+#define PCS_BOOT_PROGRESS_INIT 0
+#define PCS_BOOT_PROGRESS_WAIT_MDIO 1
+#define PCS_BOOT_PROGRESS_CHECKSUM 2
+#define PCS_BOOT_PROGRESS_JUMP 3
+#define PCS_BOOT_DOWNLOAD_WAIT_LBN 3
+#define PCS_BOOT_CODE_STARTED_LBN 4
/* 100M/1G PHY registers */
#define GPHY_XCONTROL_REG 49152
@@ -227,40 +229,62 @@ static ssize_t set_phy_short_reach(struct device *dev,
static DEVICE_ATTR(phy_short_reach, 0644, show_phy_short_reach,
set_phy_short_reach);
-/* Check that the C166 has booted successfully */
-static int tenxpress_phy_check(struct efx_nic *efx)
+int sft9001_wait_boot(struct efx_nic *efx)
{
- int phy_id = efx->mii.phy_id;
- int count = PCS_BOOT_MAX_DELAY / PCS_BOOT_POLL_DELAY;
+ unsigned long timeout = jiffies + HZ + 1;
int boot_stat;
- /* Wait for the boot to complete (or not) */
- while (count) {
- boot_stat = mdio_clause45_read(efx, phy_id,
+ for (;;) {
+ boot_stat = mdio_clause45_read(efx, efx->mii.phy_id,
MDIO_MMD_PCS,
PCS_BOOT_STATUS_REG);
- if (boot_stat & (1 << PCS_BOOT_COMPLETE_LBN))
- break;
- count--;
- udelay(PCS_BOOT_POLL_DELAY);
- }
+ if (boot_stat >= 0) {
+ EFX_LOG(efx, "PHY boot status = %#x\n", boot_stat);
+ switch (boot_stat &
+ ((1 << PCS_BOOT_FATAL_ERROR_LBN) |
+ (3 << PCS_BOOT_PROGRESS_LBN) |
+ (1 << PCS_BOOT_DOWNLOAD_WAIT_LBN) |
+ (1 << PCS_BOOT_CODE_STARTED_LBN))) {
+ case ((1 << PCS_BOOT_FATAL_ERROR_LBN) |
+ (PCS_BOOT_PROGRESS_CHECKSUM <<
+ PCS_BOOT_PROGRESS_LBN)):
+ case ((1 << PCS_BOOT_FATAL_ERROR_LBN) |
+ (PCS_BOOT_PROGRESS_INIT <<
+ PCS_BOOT_PROGRESS_LBN) |
+ (1 << PCS_BOOT_DOWNLOAD_WAIT_LBN)):
+ return -EINVAL;
+ case ((PCS_BOOT_PROGRESS_WAIT_MDIO <<
+ PCS_BOOT_PROGRESS_LBN) |
+ (1 << PCS_BOOT_DOWNLOAD_WAIT_LBN)):
+ return (efx->phy_mode & PHY_MODE_SPECIAL) ?
+ 0 : -EIO;
+ case ((PCS_BOOT_PROGRESS_JUMP <<
+ PCS_BOOT_PROGRESS_LBN) |
+ (1 << PCS_BOOT_CODE_STARTED_LBN)):
+ case ((PCS_BOOT_PROGRESS_JUMP <<
+ PCS_BOOT_PROGRESS_LBN) |
+ (1 << PCS_BOOT_DOWNLOAD_WAIT_LBN) |
+ (1 << PCS_BOOT_CODE_STARTED_LBN)):
+ return (efx->phy_mode & PHY_MODE_SPECIAL) ?
+ -EIO : 0;
+ default:
+ if (boot_stat & (1 << PCS_BOOT_FATAL_ERROR_LBN))
+ return -EIO;
+ break;
+ }
+ }
- if (!count) {
- EFX_ERR(efx, "%s: PHY boot timed out. Last status "
- "%x\n", __func__,
- (boot_stat >> PCS_BOOT_PROGRESS_LBN) &
- ((1 << PCS_BOOT_PROGRESS_WIDTH) - 1));
- return -ETIMEDOUT;
- }
+ if (time_after_eq(jiffies, timeout))
+ return -ETIMEDOUT;
- return 0;
+ msleep(50);
+ }
}
static int tenxpress_init(struct efx_nic *efx)
{
int phy_id = efx->mii.phy_id;
int reg;
- int rc;
if (efx->phy_type == PHY_TYPE_SFX7101) {
/* Enable 312.5 MHz clock */
@@ -283,10 +307,6 @@ static int tenxpress_init(struct efx_nic *efx)
false);
}
- rc = tenxpress_phy_check(efx);
- if (rc < 0)
- return rc;
-
/* Set the LEDs up as: Green = Link, Amber = Link/Act, Red = Off */
if (efx->phy_type == PHY_TYPE_SFX7101) {
mdio_clause45_set_flag(efx, phy_id, MDIO_MMD_PMAPMD,
@@ -297,7 +317,7 @@ static int tenxpress_init(struct efx_nic *efx)
PMA_PMD_LED_OVERR_REG, PMA_PMD_LED_DEFAULT);
}
- return rc;
+ return 0;
}
static int tenxpress_phy_init(struct efx_nic *efx)
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
next prev parent reply other threads:[~2009-01-29 19:17 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-29 19:12 [PATCH 00/20] sfc: Fixes and new PHY support for 2.6.29 Ben Hutchings
2009-01-29 19:15 ` [PATCH 01/20] sfc: SFT9001: Include non-breaking cable diagnostics in online self-tests Ben Hutchings
2009-01-29 19:16 ` [PATCH 02/20] sfc: Fix test for MDIO read failure Ben Hutchings
2009-01-29 19:17 ` [PATCH 03/20] sfc: SFT9001: Enable robust link training Ben Hutchings
2009-01-29 19:23 ` Ben Hutchings
2009-01-29 19:17 ` [PATCH 04/20] sfc: SFX7101: Remove workaround for bad " Ben Hutchings
2009-01-29 19:23 ` Ben Hutchings
2009-01-29 19:17 ` Ben Hutchings [this message]
2009-01-29 19:17 ` [PATCH 06/20] sfc: SFT9001: Fix speed reporting in 1G PHY loopback Ben Hutchings
2009-01-29 19:18 ` [PATCH 07/20] sfc: SFN4111T: Fix GPIO sharing between I2C and FLASH_CFG_1 Ben Hutchings
2009-01-29 19:19 ` [PATCH 08/20] sfc: Fix post-reset MAC selection Ben Hutchings
2009-01-29 19:19 ` [PATCH 09/20] sfc: Reinitialise the PHY completely in case of a PHY or NIC reset Ben Hutchings
2009-01-29 19:19 ` [PATCH 10/20] sfc: Test for PHYXS faults whenever we cannot test link state bits Ben Hutchings
2009-01-29 19:19 ` [PATCH 11/20] sfc: Update board info for hardware monitor on SFN4111T-R5 and later Ben Hutchings
2009-01-29 19:20 ` [PATCH 12/20] sfc: SFT9001: Always enable XNP exchange on SFT9001 rev B Ben Hutchings
2009-01-29 19:20 ` [PATCH 13/20] sfc: SFX7101/SFT9001: Fix AN advertisements Ben Hutchings
2009-01-29 19:20 ` [PATCH 14/20] sfc: Remove "XFP" from log messages that are not specific to XFP Ben Hutchings
2009-01-29 19:20 ` [PATCH 15/20] sfc: Fix reporting of PHY id Ben Hutchings
2009-01-29 19:21 ` [PATCH 16/20] sfc: Add support for QT2025C PHY Ben Hutchings
2009-01-29 19:21 ` [PATCH 17/20] sfc: Delete unused efx_blinker::led_num field Ben Hutchings
2009-01-29 19:21 ` [PATCH 18/20] sfc: Clean up LED control Ben Hutchings
2009-01-29 19:21 ` [PATCH 19/20] sfc: Add support for SFN4112F SFP+ reference design Ben Hutchings
2009-01-29 19:22 ` [PATCH 20/20] sfc: Replace stats_enabled flag with a disable count Ben Hutchings
2009-01-29 23:26 ` [PATCH 00/20] sfc: Fixes and new PHY support for 2.6.29 David Miller
2009-01-30 1:05 ` Ben Hutchings
2009-01-30 1:08 ` David Miller
2009-01-30 3:48 ` [PATCH 01/11] sfc: SFT9001: Enable robust link training Ben Hutchings
2009-01-30 22:09 ` David Miller
2009-01-31 0:04 ` Ben Hutchings
2009-01-31 0:02 ` David Miller
2009-01-30 3:48 ` [PATCH 02/11] sfc: SFX7101: Remove workaround for bad " Ben Hutchings
2009-01-30 3:49 ` [PATCH 03/11] sfc: SFT9001: Fix speed reporting in 1G PHY loopback Ben Hutchings
2009-01-30 3:49 ` [PATCH 04/11] sfc: SFN4111T: Fix GPIO sharing between I2C and FLASH_CFG_1 Ben Hutchings
2009-01-30 3:49 ` [PATCH 05/11] sfc: Fix post-reset MAC selection Ben Hutchings
2009-01-30 3:50 ` [PATCH 06/11] sfc: Reinitialise the PHY completely in case of a PHY or NIC reset Ben Hutchings
2009-01-30 3:51 ` [PATCH 07/11] sfc: Test for PHYXS faults whenever we cannot test link state bits Ben Hutchings
2009-01-30 3:51 ` [PATCH 08/11] sfc: Update board info for hardware monitor on SFN4111T-R5 and later Ben Hutchings
2009-01-30 3:52 ` [PATCH 09/11] sfc: SFT9001: Always enable XNP exchange on SFT9001 rev B Ben Hutchings
2009-01-30 3:59 ` [PATCH 10/11] sfc: SFX7101/SFT9001: Fix AN advertisements Ben Hutchings
2009-01-30 4:00 ` [PATCH 11/11] sfc: Replace stats_enabled flag with a disable count Ben Hutchings
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1233256659.3656.21.camel@achroite \
--to=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=linux-net-drivers@solarflare.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).